Açıklamaya gerek yok herşey ortada 
Öncesi:
Öncesi:
Sonrası:
Not:Alıntıdır
Kod:
//UserInterFace/InstanceBase.h Aç: //Arat: typedef std::list<SEffectDamage> CommandDamageQueue; //Değiştir: typedef std::queue<SEffectDamage> CommandDamageQueue; /************************************************************************************************************/ //UserInterFace/InstanceBaseEffect.cpp Aç: //Arat: void CInstanceBase::AddDamageEffect(DWORD damage, BYTE flag, BOOL bSelf, BOOL bTarget) { [...] } //Komple Değiştir: void CInstanceBase::AddDamageEffect(DWORD damage, BYTE flag, BOOL bSelf, BOOL bTarget) { if (CPythonSystem::Instance().IsShowDamage()) { SEffectDamage sDamage; sDamage.bSelf = bSelf; sDamage.bTarget = bTarget; sDamage.damage = damage; sDamage.flag = flag; m_DamageQueue.push(sDamage); if (m_DamageQueue.size() > 20) m_DamageQueue.pop(); } } //Arat: void CInstanceBase::ProcessDamage() //İçerisinde Bul: m_DamageQueue.pop_front(); //Bununla Değiştir: m_DamageQueue.pop();
C++ Damage Efekt Birikme Sorunu Fix
Metin2 özel sunucularında geliştirme yapan geliştiricilerin karşılaştığı yaygın sorunlardan birisi de 'damage efekt birikme' problemidir. Bu sorun, oyuncuların PvP sistemlerinde veya canavarlarla yapılan dövüşler sırasında hasar efektlerinin birikmesiyle ortaya çıkar. Bu durum, hem grafiksel olarak kötü bir deneyim yaratır hem de sunucu performansını ciddi anlamda düşürebilir. Bu yazıda, C++ tabanlı Metin2 sunucularında meydana gelen bu hasar efekti birikimi sorununa yönelik bir çözüm sunacağız.
Hasar Efekti Birikimi Nedir?
Metin2 oyununda bir karakter bir hedefe saldırırken, her saldırı sonucunda ekranda beliren rakamsal değerler (örneğin 1250 hasar) bir efekt olarak gösterilir. Bu efektler genellikle client tarafında işlenir ve hedefte kısa süreliğine görünür. Ancak bazı durumlarda, özellikle yüksek saldırı hızında veya PvP savaşlarında, bu efektler doğru zamanda silinmezse ekranda birikmeye başlar. Bu da hem görsel kirlilik hem de CPU tüketimi açısından olumsuzluklara neden olur.
C++ Kaynak Kodu Seviyesinde Sorunun Yeri
Bu sorun genellikle client/src/game/EffectsManager.cpp ya da benzeri efekt yönetim dosyalarında yer alır. Hasar efektlerinin oluşturulduğu ve silindiği fonksiyonlar, doğru zamanlamada çalışmadığında efektler birikmeye başlar. Özellikle EffectsManager sınıfında bulunan Update() veya DeleteOldEffects() gibi metodlarda eksiklikler olabilir.
Fix Uygulama Adımları
Adım 1: EffectsManager.cpp dosyasını açın.
Adım 2: Hasar efektlerinin zamanlanmış silinmesini sağlayan bir sayaç veya zamanlayıcı fonksiyonu bulun veya oluşturun.
Adım 3: Her efekt oluşturulduğunda bir zaman değeri (timestamp) atayın.
Adım 4: Update() fonksiyonu içinde, şu anki zaman ile efektin oluşturulma zamanı arasındaki farkı kontrol ederek süresi dolmuş efektleri silin.
Örnek Kod Parçası:
int currentTime = time(NULL);
for (auto it = m_damageEffects.begin(); it != m_damageEffects.end()
{
if (currentTime - it->second.createdTime > 1.5f) // 1.5 saniye sonra sil
it = m_damageEffects.erase(it);
else
++it;
}
Sunucu Tarafında Ekstra Kontroller
Ayrıca, game server tarafında gönderilen DAMAGE_PACKET mesajlarının frekansını sınırlamak da faydalı olabilir. Çok fazla paket gönderilmesi, client tarafında efekt birikimine sebep olabilir. Paket filtreleme veya rate limiting teknikleri kullanılabilir.
Sonuç
C++ tabanlı Metin2 özel sunucularda.damage efekt birikimi, kullanıcı deneyimini ciddi şekilde etkileyen bir sorundur. Ancak doğru zamanda efektleri silmek ve gerekli zamanlayıcı kontrollerini eklemek suretiyle bu sorun kolayca çözülebilir. Bu fix sayesinde hem daha temiz bir oyun deneyimi sağlanır hem de sunucu ve client tarafında performans artışı gözlemlenebilir. Daha fazla Metin2 geliştirici kaynağı için Metin2Lobby'yi takip edin.
C++ Damage Effect Stacking Issue Fix
One of the common problems encountered by developers working on Metin2 private servers is the 'damage effect stacking' issue. This problem occurs when damage effects accumulate on screen during PvP combat or monster fights, resulting in visual clutter and decreased server performance. In this article, we will provide a solution for this issue within C++ based Metin2 server environments.
What Is Damage Effect Stacking?
In Metin2, numerical damage values (e.g., 1250 damage) appear as effects when a character attacks a target. These effects are typically rendered on the client side and appear briefly on the target. However, in certain situations—especially during high attack speeds or PvP battles—if these effects do not disappear at the right time, they begin to stack on the screen, causing visual pollution and increased CPU usage.
Location of the Issue in C++ Source Code
This issue often originates from files such as client/src/game/EffectsManager.cpp or similar effect management files. Functions responsible for creating and deleting damage effects may fail to execute at the correct timing, leading to accumulation. Particularly, methods like Update() or DeleteOldEffects() inside the EffectsManager class might have deficiencies.
Steps to Apply the Fix
Step 1: Open the EffectsManager.cpp file.
Step 2: Locate or create a timer function that manages the timed deletion of damage effects.
Step 3: Assign a timestamp to each created effect.
Step 4: Within the Update() function, compare the current time with the creation time of each effect and delete those whose lifetime has expired.
Sample Code Snippet:
int currentTime = time(NULL);
for (auto it = m_damageEffects.begin(); it != m_damageEffects.end()
{
if (currentTime - it->second.createdTime > 1.5f) // Delete after 1.5 seconds
it = m_damageEffects.erase(it);
else
++it;
}
Additional Server-Side Checks
Moreover, limiting the frequency of DAMAGE_PACKET messages sent from the game server can also be beneficial. Excessive packet transmission can cause effect stacking on the client side. Techniques like packet filtering or rate limiting can be applied.
Conclusion
Damage effect stacking in C++ based Metin2 private servers is a significant issue affecting user experience. However, by properly deleting outdated effects and implementing necessary timer checks, this issue can be easily resolved. With this fix, both a cleaner gameplay experience and improved performance on the server and client sides can be achieved. For more Metin2 developer resources, follow Metin2Lobby.
