Jump to content
  • 0
Sinval

Doubt CheckClientVersion Source mainline

Question

config.cpp

bool        g_bCheckClientVersion = true; // activated function
string    g_stClientVersion = "1215955205"; // key
void CheckClientVersion()
{
    if (LC_IsEurope())
    {
        g_bCheckClientVersion = true;
    }
    else
    {
        g_bCheckClientVersion = false;
    }

    const DESC_MANAGER::DESC_SET & set = DESC_MANAGER::instance().GetClientSet();
    DESC_MANAGER::DESC_SET::const_iterator it = set.begin();

    while (it != set.end())
    {
        LPDESC d = *(it++);

        if (!d->GetCharacter())
            continue;


        int version = atoi(g_stClientVersion.c_str());
        int date    = atoi(d->GetClientVersion() );

        //if (0 != g_stClientVersion.compare(d->GetClientVersion()) )
        if (version > date)
        {
            d->GetCharacter()->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("Ŭ¶óÀ̾ðÆ® ¹öÀüÀÌ Æ²·Á ·Î±×¾Æ¿ô µË´Ï´Ù. Á¤»óÀûÀ¸·Î ÆÐÄ¡ ÈÄ Á¢¼ÓÇϼ¼¿ä."));
            d->DelayedDisconnect(10);
        }
    }
}

what it takes to CheckClientVersion fix ?

Share this post


Link to post

8 answers to this question

Recommended Posts

  • 0

If you read the code, you'll see two integers, version and date, which are equal to the client version and the g_stClientVersion string, so if the string is bigger than the client version, it'll print that text and disconnect the character in 10 seconds.
What I've done to "fix" it, is change the > to !=, so if both versions are different, it'll always disconnect the character.

  • Love 1

Share this post


Link to post
  • 0

in normal case it wouldn't disconnect players because version of client was bigger than server version (you can have client version in example 20140229 and server version 20140228, in this case client is potentially 'newer' that server so there is no disconnect)

Share this post


Link to post
  • 0

Still that won't work.

It'll not disconnect you. You have to change some more.

 

    if (LC_IsEurope())
    {
        g_bCheckClientVersion = true;
    }
    else
    {
        g_bCheckClientVersion = false;
    }
 
This should be removed. Makes sure you always check the version even when you don't use Europe locale.
 
Next, I've changed the check variables to char* so the server won't have to convert the versions into integers (which may overflow and result into false values). It'll just use char's instead. You can compare them with strcmp. This version works fine (tested on my vanilla core).
  • Love 1

Share this post


Link to post
  • 0

thanks Vanilla

Variable which have to char, you can leave example?

char        g_bCheckClientVersion = true; // função ativada false desativa
string    g_stClientVersion = "1215955205"; // "1215955205" chave -key

well?

Share this post


Link to post
  • 0

No, don't do this.

If you're using true or false for a variable, then always use bool.

 

bool        g_bCheckClientVersion = true; // função ativada false desativa
const char*    g_stClientVersion = "1215955205"; // "1215955205" chave -key
 
const char* will do the trick. Make it constant since you won't have to change the version in your code. It keeps as it is.
And if you're using char* you won't need atoi anymore.

 

  • Love 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.