Neler yeni

Foruma hoş geldin, Ziyaretçi

Metin2Lobby.com Metin2 Private Server Tanıtım Advertising Ve Geliştirme Forumudur.Metin2 pvp serverler,1-99,1-105,1-120,55-120 global serverları paylaş yada ara.
Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.

[C++] CHARACTER::Sync Renewal (Cannot Find Tree FIX)

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Konular
48,291
Mesajlar
48,601
Tepkime puanı
75
M2 Yaşı
3 yıl 11 ay 10 gün
Trophy Puan
48
Konum
Web sitesi
M2 Yang
488,879
Ticaret : 1 / 0 / 0
Ticaret Oranı : 100%
GİRİŞ & PROBLEM

Merhaba, server src içerisindeki "CHARACTER::Sync" fonksiyonundaki meşhur "Cannot Find Tree" probleminin ve aynı fonksiyon içerisinde bulunan PC olmayan her şey için kullanılan "Dead();" bölümünün sebep olabileceği hataları çözeceğiz.

NEDEN ?

Mevcut olarak paylaşılan fix adı altındaki düzenlemelerin aslında hepsi eksik, bu sorunu kökünden çözmek için yeni bir düzenleme yaptım, bu sayede sorunu tamamen fixlemiş olacağız.

GÜNCELLEME - 18/10/2024

Mitachi'nin büyük katkısıyla "RewardlessDead" fonksiyonunu daha işlevsel ve güvenli bir şekilde yeniden yazdım.

SON GÜNCELLEME - 23/10/2024

Fonksiyonun (!new_tree) kısmının her şartta false dönmesine sebep olan bir yazım hatasını düzenledim, ayrıca gerekli yerlere tüm nullptr kontrollerini ve ekstra sys_err mesajlarını ekledim, mevcut sys_err mesajlarının içeriğini genişlettim, bu değişiklikler performans olarak hiçbir dezavantaj yaratmayacak ayrıca artık herhangi bir şekilde kötü kullanılma ihtimali de yok, lütfen son halini tekrar ekleyin.

ÇÖZÜM

Mevcut dead fonksiyonunun ödül mekanizmasını düzenlemek gibi detaylara girmeden basitçe yeni bir ölüm fonksiyonu yaratıp Sync içerisinde onu kullanacağız, sadece mob ve metinler için kullanılabilecek olan bu fonksiyonun temel amacı ölüm işleminden sonra drop vermemesi, başlayalım.

Kod:
// BULUNUR struct FuncSetLastAttacked // ÜSTÜNE eklenir void CHARACTER::RewardlessDead()  // DevFix 29 {     if (IsPC())  // This function only for mobs or stones, so if IsPC() has triggered this, redirect it regular Dead() function. - [MT2Dev Note] - 18/10/2024     {         sys_log (0, "<CHARACTER::RewardlessDead> Wrong Usage! It was a PC, redirect it to regular Dead()");         Dead();  // Just to prevent, not needed if you use it properly. - [Mitachi] - 18/10/2024         return;     }     if (IsDead())     {         return;     }     if (IsMonster() || IsStone())  // Dead is only possible when victim is mob or stone. - [MT2Dev Note] - 10/10/2024     {         m_dwKillerPID = 0;  // Remove the killer to avoid quest triggers may in dead. - [Mitachi] - 18/10/2024         SET_BIT (m_pointsInstant.instant_flag, INSTANT_FLAG_NO_REWARD);  // Set no reward. - [Mitachi] - 18/10/2024         SetPosition (POS_DEAD);         ClearAffect (true);         ClearSync();         if (m_pkStunEvent)         {             event_cancel (&m_pkStunEvent);         }         TPacketGCDead pack;         pack.header = HEADER_GC_DEAD;         pack.vid = m_vid;         PacketAround (&pack, sizeof (pack));         REMOVE_BIT (m_pointsInstant.instant_flag, INSTANT_FLAG_STUN);         sys_log (0, "Rewardless_DEAD: %s %p", GetName(), this);         // Create Dead event.. In the Dead event, for monsters, make them destroy after a few seconds. - [Ymir Dev Note]         if (m_pkDeadEvent)         {             event_cancel (&m_pkDeadEvent);         }         if (IsStone())         {             ClearStone();         }         if (GetDungeon())         {             GetDungeon()->DeadCharacter (this);         }         SCharDeadEventInfo* pEventInfo = AllocEventInfo<SCharDeadEventInfo>();         pEventInfo->isPC = false;         pEventInfo->dwID = this->GetVID();         m_pkDeadEvent = event_create (dead_event, pEventInfo, PASSES_PER_SEC (0));         sys_log (0, "Rewardless_DEAD_EVENT_CREATE: %s %p %p", GetName(), this, get_pointer (m_pkDeadEvent));     } }

Kod:
// BULUNUR; bool CHARACTER::Sync (long x, long y) // FONKSİYON KOMPLE DEĞİŞTİRİLİR; // DevFix 29 - Necessary arrangement for scenarios where sync is not possible. - [MT2Dev Note] - 01/04/2024 // Moves to the specified x, y position regardless. - [Ymir Dev Note] bool CHARACTER::Sync (long x, long y) {     LPSECTREE current_tree = GetSectree();  // For a better performance, call it only once.. - [MT2Dev Note]     if (!current_tree)     {         sys_err ("<CHARACTER::Sync> Sectree is NULL!");         return false;     }     if (IsPC() && IsDead())   // DevFix 27 - Dead players not needed sync.. - [MT2Dev Note] - 01/04/2024     {         return false;     }     LPSECTREE new_tree = SECTREE_MANAGER::instance().Get (GetMapIndex(), x, y);     if (!new_tree)     {         if (GetDesc())         {             sys_err ("No Tree: (x: %ld)  (y: %ld)  (Name: %s)  (Map: %d)", x, y, GetName(), GetMapIndex());  // Added map index. - [MT2Dev Note] - 23/10/2024             x = GetX();             y = GetY();             new_tree = current_tree;  // If there is no new tree, just use the old one. - [MT2Dev Note]             if (!new_tree)             {                 sys_err ("[CRITICAL!!] - No Tree: (x: %ld)  (y: %ld)  (Name: %s)  (Map: %d)", x, y, GetName(), GetMapIndex());  // Added map index. - [MT2Dev Note] - 23/10/2024                 GetDesc()->SetPhase (PHASE_CLOSE);                 return false;  // Set the new_tree, call that a "fix" and forget one f**in line that cause return it false, hi there it's MT2Dev -_-             }         }         else         {             if (IsMonster() || IsStone())  // Dead is only possible when victim is mob or stone. - [MT2Dev Note] - 10/10/2024             {                 sys_err ("[MOB or STONE]No Tree: (x: %ld)  (y: %ld)  (Map: %d)", x, y, GetMapIndex());                 RewardlessDead(); // In this case, we don't want any reward so this is new function for it. - [MT2Dev Note] - 10/10/2024                 return false;             }             else             {                 sys_err ("[POTENTIAL HACK!]No Tree: (x: %ld)  (y: %ld)  (Map: %d)", x, y, GetMapIndex());                 return false;             }         }     }     SetRotationToXY (x, y);     SetXYZ (x, y, 0);     // Under that, you will see some kind a unnecesary nullptr controls, this ones for ensure everything is correct.     // This ones will not chance anything about performance in new compilers, so that ones don't hurt anyone i guess. - [MT2Dev Note] - 23/10/2024     if (GetDungeon())     {         if (new_tree)         {             // Dungeon event attribute change. - [Ymir Dev Note]             int iLastEventAttr = m_iEventAttr;             m_iEventAttr = new_tree->GetEventAttribute (x, y);             if (m_iEventAttr != iLastEventAttr)             {                 if (GetParty())                 {                     quest::CQuestManager::instance().AttrOut (GetParty()->GetLeaderPID(), this, iLastEventAttr);                     quest::CQuestManager::instance().AttrIn  (GetParty()->GetLeaderPID(), this, m_iEventAttr);                 }                 else                 {                     quest::CQuestManager::instance().AttrOut (GetPlayerID(), this, iLastEventAttr);                     quest::CQuestManager::instance().AttrIn  (GetPlayerID(), this, m_iEventAttr);                 }             }         }         else         {             sys_err ("[POTENTIAL HACK!] Dungeon - There is no new tree!");             return false;         }     }     if (current_tree != new_tree)     {         if (!IsNPC())         {             if (current_tree && new_tree)             {                 SECTREEID id = new_tree->GetID();                 SECTREEID old_id = current_tree->GetID();                 const float fDist = DISTANCE_SQRT (id.coord.x - old_id.coord.x, id.coord.y - old_id.coord.y);                 sys_log (0, "SECTREE DIFFER: %s %dx%d was %dx%d dist %.1fm", GetName(), id.coord.x, id.coord.y, old_id.coord.x, old_id.coord.y, fDist);  // DevFix 30             }             else             {                 sys_err ("[POTENTIAL HACK!] There is no current tree or new tree!");                 return false;             }         }         if (new_tree)         {             new_tree->InsertEntity (this);         }         else         {             sys_err ("[POTENTIAL HACK!] InsertEntity NOT possible because there is no new tree!");             return false;         }     }     return true; }

Kod:
// BULUNUR;         void Dead (LPCHARACTER pkKiller = NULL, bool bImmediateDead = false); // Altına eklenir;         void RewardlessDead();  // DevFix 29
[/RIGHT]
Sevgiler, MT2Dev.
Metin2 Oyun Sunucularında C++ CHARACTER::Sync Renewal Hatası ve Ağaç Bulunamama Sorunu

Metin2 özel sunucu geliştirme sürecinde karşılaşılan bazı sorunlar, geliştiriciler için zaman alıcı ve sinir bozucu olabilir. Bu makalede, C++ CHARACTER::Sync Renewal hatası ile birlikte 'Cannot Find Tree' sorununa odaklanacağız. Bu hata genellikle karakter senkronizasyonu sırasında ortaya çıkar ve oyuncuların harita üzerindeki nesnelerle (özellikle ağaçlarla) etkileşimini engeller. Bu durum, hem oyun deneyimini düşürür hem de sunucu performansını olumsuz etkileyebilir.

Hatanın Kaynağı Nedir?

Bu hata genellikle CHARACTER::Sync Renewal fonksiyonunun doğru şekilde çağrılmaması ya da bazı nesne referanslarının eksik kalmasından kaynaklanır. Özellikle tree nesnesi, Metin2 oyununda önemli bir görsel ve fiziksel bileşendir. Eğer sunucu bu nesneyi doğru şekilde senkronize edemezse, istemci tarafında ağaçlar görünmez veya etkileşim sağlanamaz. Bu durum, genellikle game core ve db core arasında bir uyumsuzluktan doğabilir.

Hatanın Giderilmesi

Öncelikle, CharacterManager.cpp dosyasında yer alan SyncRenewal fonksiyonunu kontrol edin. Bu fonksiyonun, tree nesnesini doğru şekilde gönderdiğinden emin olun. Ayrıca, client src tarafında bu nesnenin doğru şekilde render edildiğinden ve senkronize edildiğinden emin olun.

Aşağıda örnek bir düzeltme önerisi yer almaktadır:

- Game server programming sırasında tree nesnesinin character sync listesine dahil edildiğinden emin olun.
- DB tarafında ağaçların koordinatları doğru şekilde saklanmalı ve istemciye aktarılmalıdır.
- Metin2 compile işlemi sırasında herhangi bir hata mesajı olup olmadığını kontrol edin.

Sıkıştırılmış Paketlerde Uyarı[/COORD]

Eğer pack dosyalarınız sıkıştırılmışsa ve bu hata ile karşılaşıyorsanız, martysama veya benzeri araçlarla paketlerinizin doğru şekilde derlenmiş olduğundan emin olun. Yanlış derlenen paketler, nesnelerin eksik yüklenmesine sebep olabilir.

Sonuç

Bu sorun, Metin2 özel sunucularında karşılaşılabilecek yaygın bir hata olmakla birlikte, doğru analiz ve düzenlemelerle kolayca çözülebilir. C++ source edit süreçlerinde dikkatli olmak ve server src ile client src arasında tutarlılık sağlamak, bu tür hataların önüne geçmek için önemlidir. Metin2 development alanında daha fazla yardım almak istiyorsanız, Metin2Lobby forumlarında deneyimli geliştiricilerle fikir alışverişinde bulunabilirsiniz.


C++ CHARACTER::Sync Renewal Error and Cannot Find Tree Issue in Metin2 Private Servers

Some issues encountered during Metin2 private server development can be time-consuming and frustrating for developers. In this article, we will focus on the C++ CHARACTER::Sync Renewal error along with the 'Cannot Find Tree' problem. This error typically occurs during character synchronization and prevents players from interacting with objects (especially trees) on the map. This situation not only reduces the gaming experience but also negatively affects server performance.

What Causes the Error?

This error usually stems from improper calling of the CHARACTER::Sync Renewal function or missing object references. Particularly, the tree object is an important visual and physical component in the Metin2 game. If the server cannot properly synchronize this object, trees may become invisible or uninteractable on the client side. This condition often arises from incompatibility between the game core and db core.

Resolving the Error

Firstly, check the SyncRenewal function in the CharacterManager.cpp file. Ensure that this function correctly sends the tree object. Additionally, make sure that on the client src side, this object is rendered and synchronized correctly.

Below is an example correction suggestion:

- Ensure the tree object is included in the character sync list during game server programming.
- On the DB side, tree coordinates must be stored correctly and transferred to the client.
- Check if there are any error messages during the Metin2 compile process.

Warning for Compressed Packages

If your pack files are compressed and you encounter this error, ensure that your packages are compiled correctly using tools like martysama. Incorrectly compiled packages can cause objects to load incompletely.

Conclusion

This issue is a common error that can occur in Metin2 private servers, but it can easily be resolved with proper analysis and adjustments. Being careful during C++ source edit processes and ensuring consistency between server src and client src is essential to prevent such errors. For more help in Metin2 development, you can exchange ideas with experienced developers on Metin2Lobby forums.
 

Forumdan daha fazla yararlanmak için giriş yapın yada üye olun!

Forumdan daha fazla yararlanmak için giriş yapın veya kayıt olun!

Kaydol

Forumda bir hesap oluşturmak tamamen ücretsizdir.

Üye ol
Giriş Yap

Eğer bir hesabınız var ise lütfen giriş yapın

Giriş Yap

Tema düzenleyici

Tema özelletirmeleri