[ C++ ] Kuşak Sistemi ve Costume Weapon Sistemlerinin Çakışma Sorunu Fix

  • Konbuyu başlatan Konbuyu başlatan Admin
  • Başlangıç tarihi Başlangıç tarihi
  • Cevaplar Cevaplar 0
  • Görüntüleme Görüntüleme 39

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0

Çözüm

client src >userinterface > GameType.h açılır
aratılır


şeklinde değiştirilir.

aratılır



şeklinde değiştirilir.

Costume mount sistemi varsa veya herhangi bir kostum sistemi

arat
altına gerekli kod eklenir eklenen kodun sonda yazan rakam 3 olarak yazılır.

aratılır
3 rakamı 4 olarak ayarlanır.

aratılır
sonundaki 4 rakamı 5 olarak ayarlanır.


Not
Kuşak sistemi farklılık gösterir.Acce veya Sash yazar ona dikkat edin aksi takdirde kuşak sistemi çalışmayacaktır.



C++ ile Metin2'de Kuşak ve Costume Weapon Sistemlerinin Aynı Anda Kullanılması Sorunu ve Fix Yöntemleri

Metin2 özel sunucularında C++ tabanlı geliştirme yapan geliştiriciler genellikle kuşak (belt) ve costume weapon (giydirilebilir silah) sistemlerinin aynı anda aktif olduğu durumlarda bazı sorunlarla karşılaşabilir. Bu iki sistemin çakışması, oyuncu deneyimini olumsuz etkileyebilir ve sunucu tarafında hatalı veri gösterimlerine neden olabilir. Bu yazıda, C++ seviyesinde bu çakışmayı nasıl düzelteceğinizi adım adım anlatacağız.

Kuşak Sistemi Nedir?
Kuşak sistemi, oyuncuların envanterdeki belirli slotları kullanarak kuşak eşyalarını giymesini sağlar. Bu sistem genellikle C++ tarafında tanımlanan slot numaraları ve client tarafında UI ile entegre edilir. Kuşak slotları genellikle 127 ve sonrası gibi yüksek slot numaralarında tanımlanır.

Costume Weapon Sistemi Nedir?
Costume weapon sistemi ise oyuncuların farklı silah görünümlerini giyebilmelerini sağlar. Bu sistem de kuşak gibi genellikle yüksek slot numaralarında çalışır. Costume weapon genellikle slot 128'de veya daha sonrasında tanımlanır.

Sorun Nerede Ortaya Çıkıyor?
Her iki sistem de yüksek slot numaralarını kullandığı için, client tarafında bu slotların aynı anda görünmesi veya verilerin çakışması söz konusu olabilir. Örneğin, bir oyuncu hem kuşak giyiyor hem de costume weapon kullanıyorsa, client hangisinin öncelikli olduğunu bilemez ve verileri doğru yansıtmaz. Bu durumda hem kuşak hem de costume weapon aynı slot üzerinden kontrol ediliyorsa, biri diğerini ezebilir.

Fix İçin Gerekli Adımlar
1. game/src/char.cpp dosyasında, kuşak ve costume weapon slotlarını kontrol eden fonksiyonları ayrı ayrı tanımlamak gerekir.
2. Client tarafında, bu iki sistemin aynı slot üzerinden işlem yapmaması sağlanmalıdır. Costume weapon slotları kuşaktan farklı bir aralıkta olmalı.
3. Client UI tarafında Costume Weapon ve Belt UI elementlerinin birbirine müdahale etmemesi için farklı slot aralıkları tanımlanmalı.
4. SendItemData() fonksiyonu, her iki sistem için farklı slot numaraları göndermelidir. Costume weapon için 128+, belt için 130+ gibi.

Örnek Kod Parçası (C++)
Kod:
void CHARACTER::SendItemData() { // Costume Weapon Slot 128 if (GetWear(WEAR_COSTUME_WEAPON)) { TPacketGCItemSet itemSet; itemSet.header = HEADER_GC_ITEM_SET; itemSet.pos = 128; // costume weapon slot itemSet.vnum = GetWear(WEAR_COSTUME_WEAPON)->vnum; // ... } // Belt Slot 130+ for (int i = 0; i < BELT_SLOT_COUNT; ++i) { if (GetWear(WEAR_BELT + i)) { TPacketGCItemSet itemSet; itemSet.header = HEADER_GC_ITEM_SET; itemSet.pos = 130 + i; // belt slot itemSet.vnum = GetWear(WEAR_BELT + i)->vnum; // ... } }}

Hatalar Nelerdir?
- Costume weapon görünmüyor, çünkü kuşak slotuna yazılıyor.
- Kuşak eşyası görünmüyor, çünkü costume slotuna yazılıyor.
- Her iki sistemde aynı slot numarası kullanılıyor.

Sonuç
Kuşak ve costume weapon sistemlerinin doğru çalışması için C++ seviyesinde slot yönetimi çok önemlidir. Doğru slot numaraları ve veri akışı sağlandığında her iki sistem de sorunsuz çalışabilir. Bu fix sayesinde oyuncular hem kuşak giyebilir hem de costume weapon kullanabilir. Daha fazla Metin2 geliştirme ipucu için Metin2Lobby sitesini takip edin.


Conflict Issue Between Belt System and Costume Weapon System in C++ and How to Fix It

Developers working on Metin2 private servers often encounter issues when both the belt and costume weapon systems are active simultaneously. This conflict between the two systems can negatively affect the player experience and cause incorrect data display on the server side. In this article, we will explain step-by-step how to resolve this conflict at the C++ level.

What is the Belt System?
The belt system allows players to equip belt items using specific slots in their inventory. This system is usually defined by slot numbers in C++ and integrated into the client UI. Belt slots are typically defined with high slot numbers such as 127 and above.

What is the Costume Weapon System?
The costume weapon system allows players to wear different weapon appearances. Like the belt system, it also operates on high slot numbers. Costume weapons are generally defined starting from slot 128 or higher.

Where Does the Problem Occur?
Since both systems use high slot numbers, conflicts may arise where the client cannot distinguish which data should take priority. For example, if a player wears both a belt and a costume weapon, the client might not know which one to prioritize, resulting in incorrect visual representation. If both systems attempt to control the same slot, one may overwrite the other.

Steps to Fix the Issue
1. In game/src/char.cpp, define separate functions to handle belt and costume weapon slots.
2. Ensure that the client does not operate both systems through the same slot range. Costume weapon slots must be distinct from belt slots.
3. In the client UI, ensure that costume weapon and belt UI elements do not interfere with each other by assigning different slot ranges.
4. The SendItemData() function should send different slot numbers for each system—e.g., 128+ for costume weapon, 130+ for belt.

Sample Code Snippet (C++)
Kod:
void CHARACTER::SendItemData() { // Costume Weapon Slot 128 if (GetWear(WEAR_COSTUME_WEAPON)) { TPacketGCItemSet itemSet; itemSet.header = HEADER_GC_ITEM_SET; itemSet.pos = 128; // costume weapon slot itemSet.vnum = GetWear(WEAR_COSTUME_WEAPON)->vnum; // ... } // Belt Slot 130+ for (int i = 0; i < BELT_SLOT_COUNT; ++i) { if (GetWear(WEAR_BELT + i)) { TPacketGCItemSet itemSet; itemSet.header = HEADER_GC_ITEM_SET; itemSet.pos = 130 + i; // belt slot itemSet.vnum = GetWear(WEAR_BELT + i)->vnum; // ... } }}

Common Errors:
- Costume weapon not showing because it's written to a belt slot.
- Belt item not visible because it's written to a costume slot.
- Both systems using the same slot number.

Conclusion
Proper slot management at the C++ level is crucial for both systems to work correctly. When correct slot numbers and data flows are ensured, both systems can function without problems. With this fix, players can wear belts and use costume weapons simultaneously. For more tips on Metin2 development, follow Metin2Lobby.
 

Şuan Bu Konuyu Görüntüleyen Kullanıcılar (Toplam : 0, Üye : 0, Misafir : 0)

Benzer konular

Geri
Üst Alt