Tüm Gereksiz Kod Bloklarını Kaldırın - [Sırlar Adasından Dosyalar]

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

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
Selamlar filesinizdeki optimizasyonu daha iyi hale getirmek için aşağıdaki adımları uygulayabilirsiniz.

Gereksiz kod bloklarını kaldırmak için anlatımda geçenleri yapmanız yeterlidir.


Anlatım bana ait değildir yakın zamanda elime ulaştı. Yapımcı arkadaş ulaşırsa konuya dahil ederim.

İndirme dosyasında olan kodlar :

Auction
Passpod
openid
vcard





Bunları da yapın:

Kod:
open db/clientmanagerlogin.cpp search this and remove:   #ifdef ENABLE_LIMIT_TIME     static int s_updateCount = 0;     static int s_curTime = time(0);     if (s_updateCount > 100)     {         s_curTime = time(0);         s_updateCount = 0;     }     ++s_updateCount;     if (s_curTime >= GLOBAL_LIMIT_TIME)     {         sys_err("Server life time expired.");         exit(0);         return;     } [HASH=3]#endif[/HASH] open game/desc.cpp and remove this:   #ifdef ENABLE_LIMIT_TIME     if ((unsigned)get_global_time() >= GLOBAL_LIMIT_TIME)     {         extern void ClearAdminPages();         ClearAdminPages();         extern g_bShutdown;         g_bShutdown = true;     } #endif open game/input.cpp search this + remove:   #ifndef __WIN32__ [HASH=2388]#include[/HASH] "limit_time.h" #endif and this:   #ifdef ENABLE_LIMIT_TIME     if (Metin2Server_IsInvalid())     {         extern bool g_bShutdown;         g_bShutdown = true;         ClearAdminPages();     } #endif open input_auth.cpp search this and remove:   #ifndef __WIN32__ [HASH=2388]#include[/HASH] "limit_time.h" #endif +   #ifdef ENABLE_LIMIT_TIME     extern bool Metin2Server_IsInvalid();     if (Metin2Server_IsInvalid())     {         extern void ClearAdminPages();         ClearAdminPages();         exit(1);         return;     } #endif and + this:   #ifdef ENABLE_LIMIT_TIME     extern bool Metin2Server_IsInvalid();     if (Metin2Server_IsInvalid())     {         extern void ClearAdminPages();         ClearAdminPages();         exit(1);         return;     } #endif delete two file from game folder (limit_time.h + update_limit_time.py) Open game/main.cpp search this and remove:   #ifndef __WIN32__ [HASH=2388]#include[/HASH] "limit_time.h" #endif + this:   #ifdef ENABLE_LIMIT_TIME         if ((unsigned)get_global_time() >= GLOBAL_LIMIT_TIME)         {             g_bShutdown = true;         } #endif and YEAH this too:   #ifdef ENABLE_LIMIT_TIME     if ((unsigned)get_global_time() >= GLOBAL_LIMIT_TIME)     {         return 0;     } #endif open game/makefile and remove this:   limit_time:     @echo update limit time     @python update_limit_time.py


Kod:
Common/tables.h search this and remove:       HEADER_GD_BLOCK_COUNTRY_IP        = 127,        // ±¤´ëżŞ IP-Block     HEADER_GD_BLOCK_EXCEPTION        = 128,        // ±¤´ëżŞ IP-Block żążÜ     HEADER_DG_BLOCK_COUNTRY_IP        = 171,        // ±¤´ëżŞ IP-Block     HEADER_DG_BLOCK_EXCEPTION        = 172,        // ±¤´ëżŞ IP-Block żążÜ account search this too and remove   // Block Country Ip typedef struct tBlockCountryIp {     DWORD    ip_from;     DWORD    ip_to; } TPacketBlockCountryIp; enum EBlockExceptionCommand {     BLOCK_EXCEPTION_CMD_ADD = 1,     BLOCK_EXCEPTION_CMD_DEL = 2, }; // Block Exception Account typedef struct tBlockException {     BYTE    cmd;    // 1 == add, 2 == delete     char    login[LOGIN_MAX_LEN + 1]; }TPacketBlockException; db/src: remove this files: BlockCountry.cpp +  BlockCountry.h   open db/clientmanager.cpp remove this:   [HASH=2388]#include[/HASH] "BlockCountry.h" search this and remove:           case HEADER_GD_BLOCK_COUNTRY_IP:             sys_log(0, "HEADER_GD_BLOCK_COUNTRY_IP received");             CBlockCountry::instance().SendBlockedCountryIp(peer);             CBlockCountry::instance().SendBlockException(peer);             break;         case HEADER_GD_BLOCK_EXCEPTION:             sys_log(0, "HEADER_GD_BLOCK_EXCEPTION received");             BlockException((TPacketBlockException*)data);             break; search this and remove too:   void CClientManager::BlockException(TPacketBlockException* data) {     sys_log(0, "[BLOCK_EXCEPTION] CMD(%d) login(%s)", data->cmd, data->login);     // save sql     {         char buf[1024];         switch (data->cmd)         {         case BLOCK_EXCEPTION_CMD_ADD:             snprintf(buf, sizeof(buf), "INSERT INTO block_exception VALUES('%s')", data->login);             CDBManager::instance().AsyncQuery(buf, SQL_ACCOUNT);             CBlockCountry::instance().AddBlockException(data->login);             break;         case BLOCK_EXCEPTION_CMD_DEL:             snprintf(buf, sizeof(buf), "DELETE FROM block_exception VALUES('%s')", data->login);             CDBManager::instance().AsyncQuery(buf, SQL_ACCOUNT);             CBlockCountry::instance().DelBlockException(data->login);             break;         default:             return;         }     }     for (itertype(m_peerList) it = m_peerList.begin(); it != m_peerList.end(); ++it)     {         CPeer* peer = *it;         if (!peer->GetChannel())             continue;         CBlockCountry::instance().SendBlockExceptionOne(peer, data->login, data->cmd);     } } Open db/clientmanager.h search this and remove:       void BlockException(TPacketBlockException* data); Open Main.cpp search this and remove:   [HASH=2388]#include[/HASH] "BlockCountry.h" search too and remove:       CBlockCountry    BlockCountry; and this:       BlockCountry.Load(); makefile Search this and remove too:   BlockCountry.cpp   open game src and remove this files: Block_Country.cpp + Block_Country.h -> cpp remove too makefile Open game/db.cpp search this and remove:   void DBManager::RequestBlockException(const char* login, int cmd) {     TPacketBlockException packet;     packet.cmd = cmd;     strlcpy(packet.login, login, sizeof(packet.login));     db_clientdesc->DBPacket(HEADER_GD_BLOCK_EXCEPTION, 0, &packet, sizeof(packet)); } open db.h and remove this:       // BLOCK EXCEPTION     void            RequestBlockException(const char* login, int cmd);     // BLOCK EXCEPTION open input.cpp and remove this:                   else if (!stBuf.compare(0, 15, "BLOCK_EXCEPTION"))                 {                     // BLOCK_EXCEPTION cmd(add=1, del=2) login                     std::istringstream is(stBuf);                     std::string    dummy_string;                     std::string    login_string;                     int            cmd;                     is >> dummy_string >> cmd >> login_string;                     sys_log(0, "block_exception %s:%d", login_string.c_str(), cmd);                     DBManager::instance().RequestBlockException(login_string.c_str(), cmd);                     stResult = "BLOCK_EXCEPTION_YES";                 } open input.h and remove this:       void        AddBlockCountryIp(TPacketBlockCountryIp* data);     void        BlockException(TPacketBlockException* data); open input_db and remove this:   [HASH=2388]#include[/HASH] "block_country.h" + this:       // request blocked_country_ip     {         db_clientdesc->DBPacket(HEADER_GD_BLOCK_COUNTRY_IP, 0, NULL, 0);         dev_log(LOG_DEB0, "<sent HEADER_GD_BLOCK_COUNTRY_IP>");     } and this:       case HEADER_DG_BLOCK_COUNTRY_IP:         this->AddBlockCountryIp((TPacketBlockCountryIp*)c_pData);         break;     case HEADER_DG_BLOCK_EXCEPTION:         this->BlockException((TPacketBlockException*)c_pData);         break; and more this:   void CInputDB::AddBlockCountryIp(TPacketBlockCountryIp* data) {     add_blocked_country_ip(data); } void CInputDB::BlockException(TPacketBlockException* data) {     block_exception(data); } open input_login.cpp and remove this:   [HASH=2388]#include[/HASH] "block_country.h" + this:       // is blocked ip?     {         dev_log(LOG_DEB0, "check_blocked_country_start");         if (!is_block_exception(login) && is_blocked_country_ip(d->GetHostName()))         {             sys_log(0, "BLOCK_COUNTRY_IP (%s)", d->GetHostName());             d->SetPhase(PHASE_CLOSE);             return;         }         dev_log(LOG_DEB0, "check_blocked_country_end");     } open packet.h and remove this:       HEADER_GG_BLOCK_EXCEPTION        = 24,


Tüm Gereksiz Kod Bloklarını Kaldırın - [Sırlar Adasından Dosyalar]

Metin2 Lobby olarak, Metin2 özel sunucu geliştirme süreçlerinde temiz ve optimize edilmiş kod yapısının ne kadar önemli olduğunu biliyoruz. Özellikle Martysama veya diğer C++ sistemler üzerinde çalışan geliştiriciler için kod kalitesi, performans ve stabilite açısından kritik öneme sahiptir. Bu yazıda, Sırlar Adası gibi projelerden alınan dosyalar üzerinde yapılan optimize işlemlerinden biri olan gereksiz kod bloklarının kaldırılması konusunu ele alacağız.

Neden Gereksiz Kod Bloklarını Kaldırmalıyız?

Metin2 özel sunucularında game server programming yaparken, özellikle eski sistemlerden gelen veya örnek projelerden alınan dosyalarda birçok gereksiz kod bloğu bulunabilir. Bu bloklar:

- Performans kaybına neden olabilir.
- Kod okunabilirliğini düşürebilir.
- Hata ayıklamayı zorlaştırabilir.
- Derleme süresini artırabilir.

Özellikle C++ source edit işlemleri sırasında bu tür kodları temizlemek, hem geliştirme sürecini kolaylaştırır hem de sunucu performansını artırır.

Sırlar Adası Dosyalarında Yapılan Temizlikler

Sırlar Adası gibi açık kaynak projelerden alınan dosyalar genellikle fazladan yorum satırları, kullanılmayan fonksiyonlar, test amaçlı eklenmiş ancak aktif olmayan kod parçaları içerir. Örneğin:

auth server[/COORD]
- Eski giriş denemeleriyle ilgili loglamalar
- Geçici debug mesajları
- Artık kullanılmayan veritabanı sorguları

game server
- Yeni eklenen PvP sistemleri ile çakışan eski mantık blokları
- Artık kullanılmayan event handlerlar

Bu gibi kodlar, Metin2 server src üzerinde çalışırken dikkat edilmesi gereken detaylardır. Core yapılar üzerinden bu temizlikler yapıldığında, hem db core hem de game core daha hızlı ve verimli çalışır.

Python GUI ve Uiscript Üzerinde Temizlik

Py GUI ve uiscript dosyalarında da benzer durumlarla karşılaşılır. Özellikle py root klasöründe bulunan scriptlerde:

- Kullanılmayan importlar
- Artık işlevi olmayan fonksiyonlar
- Test amacıyla eklenmiş fakat aktif olmayan butonlar veya ekranlar

Geliştiricilerin bu tür yapıları düzenli olarak kontrol etmeleri, Metin2 development sürecini hızlandırır. Ayrıca, client src üzerinde değişiklik yaparken bu yapıların temiz olması, hata çıkma riskini azaltır.

Derleme ve Performans Artışı

Tüm bu temizlikler sonrası yapılan compile işlemi daha hızlı tamamlanır. Source edit süreçlerinde bu gibi optimizasyonlar yapmak, Metin2 lobby gibi platformlarda sunulan sistemlerin kalitesini doğrudan etkiler. Performans artışı, daha az hata ve daha kolay bakım imkanı sağlar.

Sonuç

Metin2 özel sunucularında kod temizliği, uzun vadede büyük fark yaratır. Sırlar Adası gibi projelerden alınan dosyalar üzerinde yapılan bu tür temizlikler, Metin2Dev süreçlerini daha verimli hale getirir. Game core, DB core, PvP sistemleri ve diğer bileşenler üzerinde yapılan bu temizlikler, profesyonel düzeyde Metin2 server programlama için temel oluşturur.


Remove All Unnecessary Code Blocks - [Files from Secrets Island]

Metin2 Lobby, in Metin2 private server development[/CR] processes, we know how important clean and optimized code structure is. Especially for developers working on Martysama or other C++ systems, code quality is critical for performance and stability. In this article, we will discuss one of the optimization operations done on files taken from projects like Secrets Island: removing unnecessary code blocks.

Why Should We Remove Unnecessary Code Blocks?

When doing game server programming in Metin2 private servers, especially files taken from older systems or sample projects often contain many unnecessary code blocks. These blocks can:

- Cause performance loss.
- Reduce code readability.
- Make debugging harder.
- Increase compilation time.

Especially during C++ source edit operations, cleaning up such code simplifies the development process and improves server performance.

Cleanups Done on Secrets Island Files

Files taken from open-source projects like Secrets Island typically include excessive comment lines, unused functions, and code snippets added for testing but not active. For example:

auth server
- Old login attempt logs
- Temporary debug messages
- Database queries no longer used

game server
- Old logic blocks conflicting with newly added PvP systems
- Event handlers no longer in use

These types of code are details developers should pay attention to while working on Metin2 server src. When these cleanups are performed over core structures, both db core and game core run faster and more efficiently.

Cleaning Up Python GUI and Uiscript

Similar situations occur in Py GUI and uiscript files as well. In scripts located in the py root folder:

- Unused imports
- Functions that no longer serve any purpose
- Buttons or screens added for testing but not active

Regular checks by developers on such structures accelerate the Metin2 development process. Moreover, having clean structures while making changes to client src reduces the chance of errors.

Compilation and Performance Improvement

After all these cleanups, the subsequent compile operation completes faster. Performing such optimizations during source edit processes directly affects the quality of systems provided on platforms like Metin2 lobby. Performance increase, fewer errors, and easier maintenance opportunities are provided.

Conclusion

Code cleanup in Metin2 private servers makes a big difference in the long term. Cleanups performed on files taken from projects like Secrets Island make Metin2Dev processes more efficient. Cleanups performed on game core, DB core, PvP systems, and other components form the foundation for professional-level Metin2 server programming.
 

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

Geri
Üst Alt