📌2 Senelik Yolculuğumuzda 1.000.000m+ Ham Görüntüleme İçin Teşekkürler. İyi ki varsınız! 🙏🏻
Discord sunucumuza tüm üyelerimiz davetlidir! ✨(Link)
  • Discord ile Kayıt Aktif | Onaylı Üyelik
    Forumdan daha fazla yararlanmak için, Discord ile kaydolun ve daha ayrıcalıklı olun 👑
  • Telegram ile Kayıt Aktif | Onaylı Üyelik
    Forumdan daha fazla yararlanmak için, Telegram ile kaydolun ve daha ayrıcalıklı olun 👑

C++ / C# / Python Metin2 - Tüm Gereksiz Kod Bloklarını Kaldırın - [Sırlar Adasından Dosyalar]

ProxyXF

Yönetim Üyesi
Administrator
Onaylı Üye
S1 Üye
LV
7
 
Son görülme
Katılım
13 Haz 2021
Mesajlar
6,124
Ödüller
13
Web sitesi
sadece1.com
Hobi/Meslek
Webmaster | Web Uzmanı


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


INDIR
VT

Bunları da yapın:
limit_time kaldırma:
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

blocked_country_ip kaldırma:
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,
 
Son düzenleme:

Discord Sunucumuz

Üst