Merhaba,
Arşivimde rastladım video'yuda şuraya bırakayım tam olarak ne olduğunu anlarsınız.
New_PetSystem.cpp Açılır
Arşivimde rastladım video'yuda şuraya bırakayım tam olarak ne olduğunu anlarsınız.
New_PetSystem.cpp Açılır
Kod:
bool CNewPetActor::Update(DWORD deltaTime)
Kod:
if (m_pkOwner->IsDead() || (IsSummoned() && m_pkChar->IsDead()) || (IsSummoned() && (m_pkOwner->GetExchange() || m_pkOwner->GetMyShop() || m_pkOwner->GetShopOwner() || m_pkOwner->IsOpenSafebox() || m_pkOwner->IsCubeOpen() || m_dwduration <= 0)) || NULL == ITEM_MANAGER::instance().FindByVID(this->GetSummonItemVID()) || ITEM_MANAGER::instance().FindByVID(this->GetSummonItemVID())->GetOwner() != this->GetOwner() ) { this->Unsummon(); return true; }
Kod:
if (m_pkOwner->IsDead() || (IsSummoned() && m_pkChar->IsDead()) || (IsSummoned() && (m_pkOwner->IsCubeOpen() || m_dwduration <= 0)) || NULL == ITEM_MANAGER::instance().FindByVID(this->GetSummonItemVID()) || ITEM_MANAGER::instance().FindByVID(this->GetSummonItemVID())->GetOwner() != this->GetOwner() ) { this->Unsummon(); return true; }
Metin2 Lobby olarak Metin2 Private Server geliştirme sürecinde sıklıkla karşılaşılan hatalardan birisi olan Pazar Açılınca Pet Kaybolması hatası oldukça can sıkıcıdır. Bu yazıda C++[/COORD] tabanlı Pet Sistemi üzerinde meydana gelen bu hatayı nasıl düzelteceğimizi detaylıca inceleyeceğiz. Bu hata, oyuncuların petlerini oyunu kapattıkları anda veya belirli zaman dilimlerinde kaybetmelerine neden olmaktadır. Özellikle Pazar günleri sunucular yeniden başlatıldığında bu durum daha da artmaktadır.
Pet Sistemi Nedir?
Pet, Metin2 oyununda oyunculara yardımcı olan, özel yeteneklere sahip sanal bir yaratıktır. Bu sistem, hem client hem de server tarafında aktif olarak çalışır. Sunucu tarafında C++ ile yazılmış olan pet yönetimi, veritabanı bağlantısı ve karakter ile pet eşleşmesi gibi işlemler yer alır. Bug ise genellikle bu bağlantıların kopması veya eksik kontrol mekanizmaları nedeniyle meydana gelir.
Hatanın Nedenleri Nelerdir?
Bu sorunun ortaya çıkmasının başlıca sebeplerinden birisi server restart sırasında pet verilerinin doğru şekilde kaydedilmemesidir. Yani oyun kapanırken pet bilgileri veritabanına commit edilmezse ya da disconnect esnasında pet silinirse, oyuncu tekrar giriş yaptığında petini göremez. Bu durum genellikle C++ tarafında save_pet_info() fonksiyonunun eksik veya hatalı çalışmasından kaynaklanır.
Hatanın Çözümü
Öncelikle game/src/char.cpp dosyasında bulunan CloseInput() fonksiyonuna bakmalısınız. Burada pet ile ilgili verilerin kaydedilip kaydedilmediğini kontrol edin. Eğer pet bilgileri kapatma anında veritabanına yazılmıyorsa, aşağıdaki gibi bir ekleme yapmanız gerekebilir:
void CHARACTER::CloseInput(){
SavePetInfo();
// diğer kodlar...
}
Veritabanı Kontrolü
DB tarafında player.pets tablosunun doğru şekilde yapılandırıldığından emin olun. Bu tablo, petin adı, leveli, slotu ve sahibi gibi bilgileri içerir. Sunucu yeniden başlatıldığında bu tabloya yazılan verilerin bozulmadığından emin olun. Gerekirse bu tabloya özel backup mekanizması kurabilirsiniz.
Sunucu Yeniden Başlatma Öncesi Otomatik Kayıt
Pazar günleri gibi planlı restartlar öncesinde tüm oyuncuların pet bilgilerinin otomatik olarak kaydedilmesi için bir sistem kurulabilir. Bu işlem için C++ tarafında timer ve broadcast fonksiyonları kullanılabilir. Oyunculara restarttan 10 dakika önce uyarı gönderilip pet bilgileri manuel olarak kaydedilebilir.
Sonuç
Pet kaybı gibi hatalar, kullanıcı memnuniyetini doğrudan etkileyen önemli konulardır. Metin2 geliştiricileri olarak bu tür sorunları çözmek için C++ bilgimizi ve server-side deneyimimizi kullanmalıyız. Hataların kök nedenlerini analiz ederek kalıcı çözümler üretmek, Metin2 Lobby'nin sunduğu kaliteli sistemlerin devamı niteliğindedir.
Metin2 Lobby as one of the frequently encountered errors during Metin2 Private Server development process, the Pet Loss When Sunday Opens error is quite annoying. In this article, we will examine in detail how to fix this error that occurs on the C++-based Pet System. This error causes players to lose their pets at the moment they close the game or during certain time intervals. Especially when servers are restarted on Sundays, this situation increases even more.
What is the Pet System?
Pet is a virtual creature with special abilities that assists players in the Metin2 game. This system operates actively on both the client and server sides. The C++-written pet management on the server side includes database connections and character-pet matching processes. The bug usually arises due to disconnections in these connections or insufficient control mechanisms.
What Are the Causes of the Error?[/BR]One of the main reasons for this issue is the failure to properly save pet data during server restart. If pet information is not committed to the database when the game closes or if the pet is deleted during disconnect, the player cannot see their pet upon re-login. This usually stems from the incomplete or faulty operation of the save_pet_info() function on the C++ side.
Solution to the Error
Firstly, check the CloseInput() function in game/src/char.cpp. Verify whether pet-related data is being saved. If pet data is not written to the database during shutdown, you might need to add something like the following:
void CHARACTER::CloseInput(){
SavePetInfo();
// other codes...
}
Database Check
Ensure that the player.pets table on the DB side is correctly configured. Make sure that data written to this table does not get corrupted during server restarts. If necessary, you can implement a special backup mechanism for this table.
Automatic Save Before Server Restart
Before planned restarts like Sundays, a system can be set up to automatically save all players' pet information. For this purpose, C++ side timer and broadcast functions can be used. Players can be warned 10 minutes before restart and pet data can be manually saved.
Conclusion
Errors like pet loss directly affect user satisfaction. As Metin2 developers, we must use our C++ knowledge and server-side experience to solve such issues. Analyzing the root causes of errors and producing permanent solutions is part of the high-quality systems offered by Metin2 Lobby.
