• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Fix/Patch Level and vocation instead of world name on character login

Jetro

jangeldev
Joined
Aug 1, 2011
Messages
452
Reaction score
68
Location
Venezuela
Hi all, i just took the code of GSMaster who posted here : http://otland.net/f35/level-instead-world-name-character-login-help-156580/index3.html#post1521747 and i added the vocation...

It shows the character login like this:
LK3SG.jpg


of course, if you have another vocation names you have to fix it by yourself xD (don't worry, it's too easy)

ok, here is the code:

iologindata.h
go to:

Code:
uint32_t getAccountIdByName(const std::string& name) const;

paste under
Code:
std::string getCheckPlayerLevel(const std::string& name) const;


iologindata.cpp (paste end file..)
for 0.3.6pl1

Code:
std::string IOLoginData::getCheckPlayerLevel(const std::string& name) const
{
    Database* db = Database::getInstance();
    DBQuery query;
    query << "SELECT `level`, `vocation`, `promotion`  FROM `players` WHERE `name` " << db->getStringComparison() << db->escapeString(name) << ";";
    DBResult* result;
    if (!(result = db->storeQuery(query.str())))
        return false;

    const uint32_t pLevel = result->getDataInt("level");
    const uint32_t pVoc = result->getDataInt("vocation");
    const uint32_t prom = result->getDataInt("promotion");
    std::string voc;

    if (prom == 0) {
        switch (pVoc) {
            case 0:
                voc = "Rookie";
                break;
            case 1:
                voc = "S";
                break;
            case 2:
                voc = "D";
                break;
            case 3:
                voc = "P";
                break;
            case 4:
                voc = "K";
                break;
            default:
                voc = "Uknown";
        }
    } else if (prom == 1) {
         switch (pVoc) {
             case 0:
                 voc = "Rookie";
                  break;
             case 1:
                 voc = "MS";
                  break;
             case 2:
                 voc = "ED";
                  break;
             case 3:
                 voc = "RP";
                  break;
             case 4:
                 voc = "EK";
                  break;
             default:
                 voc = "Uknown";
         }
    }   

    std::stringstream ret;
    ret << "Level: "<< pLevel << " Voc: " << voc;
    result->free();
    return ret.str();
}
for 0.4
Code:
std::string IOLoginData::getCheckPlayerLevel(const std::string& name) const
{
    Database* db = Database::getInstance();
    DBQuery query;
    query << "SELECT `level`, `vocation`, `promotion`  FROM `players` WHERE `name` " << db->getStringComparer() << db->escapeString(name) << ";";
    DBResult* result;
    if (!(result = db->storeQuery(query.str())))
        return false;

    const uint32_t pLevel = result->getDataInt("level");
    const uint32_t pVoc = result->getDataInt("vocation");
    const uint32_t prom = result->getDataInt("promotion");
    std::string voc;

    if (prom == 0) {
        switch (pVoc) {
            case 0:
                voc = "Rookie";
                break;
            case 1:
                voc = "S";
                break;
            case 2:
                voc = "D";
                break;
            case 3:
                voc = "P";
                break;
            case 4:
                voc = "K";
                break;
            default:
                voc = "Uknown";
        }
    } else if (prom == 1) {
         switch (pVoc) {
             case 0:
                 voc = "Rookie";
                  break;
             case 1:
                 voc = "MS";
                  break;
             case 2:
                 voc = "ED";
                  break;
             case 3:
                 voc = "RP";
                  break;
             case 4:
                 voc = "EK";
                  break;
             default:
                 voc = "Uknown";
         }
    }   

    std::stringstream ret;
    ret << "Level: "<< pLevel << " Voc: " << voc;
    result->free();
    return ret.str();
}

protocollogin.cpp
find

Code:
output->putString(g_config.getString(ConfigManager::SERVE R_NAME));
replace with:
[code//output->putString(g_config.getString(ConfigManager::SERVE R_NAME));[/code]

paste under:
Code:
output->putString(IOLoginData::getInstance()->getCheckPlayerLevel((*it)));

works on tfs 0.3.6pl1 and 0.4
I hope you like it :cool:
Regards
 
Last edited by a moderator:
Got this problem:
Lua:
\0.3.6pl1.r98\iologindata.cpp prototype for `std::string IOLoginData::getCheckPlayerLevel(const std::string&) const' does not match any in class `IOLoginData' 
\0.3.6pl1.r98\iologindata.h uint32_t IOLoginData::getCheckPlayerLevel(const std::string&) const 
\0.3.6pl1.r98\iologindata.cpp `std::string IOLoginData::getCheckPlayerLevel(const std::string&) const' and `uint32_t IOLoginData::getCheckPlayerLevel(const std::string&) const' cannot be overloaded 
\0.3.6pl1.r98\iologindata.cpp In member function `std::string IOLoginData::getCheckPlayerLevel(const std::string&) const': 
\0.3.6pl1.r98\iologindata.cpp 'class _Database' has no member named 'getStringComparer' 
\0.3.6pl1.r98\dev-cpp\Makefile.win [Build Error]  [obj//iologindata.o] Error 1
 
i'll check the sources, i've tested this code on tfs 0.4 and worked perfectly xd
 
change the function of iologindata.cpp for this:
[cpp]std::string IOLoginData::getCheckPlayerLevel(const std::string& name) const
{
Database* db = Database::getInstance();
DBQuery query;
query << "SELECT `level`, `vocation`, `promotion` FROM `players` WHERE `name` " << db->getStringComparison() << db->escapeString(name) << ";";
DBResult* result;
if(!(result = db->storeQuery(query.str())))
return false;

const uint32_t pLevel = result->getDataInt("level");
const uint32_t pVoc = result->getDataInt("vocation");
const uint32_t prom = result->getDataInt("promotion");
std::string voc;

if (prom == 0)
{
switch (pVoc)
{
case 0: voc = "Rookie";
break;
case 1: voc = "S";
break;
case 2: voc = "D";
break;
case 3: voc = "P";
break;
case 4: voc = "K";
break;
default: voc = "Uknown";
}


}
else if (prom == 1)
{
switch (pVoc)
{
case 0: voc = "Rookie";
break;
case 1: voc = "MS";
break;
case 2: voc = "ED";
break;
case 3: voc = "RP";
break;
case 4: voc = "EK";
break;
default: voc = "Uknown";
}
}

std::stringstream ret;
ret << "Level: "<< pLevel << " Voc: " << voc;
result->free();
return ret.str();

}[/cpp]
 
I really like this and I was witing for this in silent :) I waited for kito's thread haha but one thing:

Code:
output->putString(g_config.getString(ConfigManager::SERVE R_NAME));

was like this:

Code:
//output->AddString(g_config.getString(ConfigManager::SERVER_NAME));

and this is how i did it working:

Code:
				//output->AddString(g_config.getString(ConfigManager::SERVER_NAME));
                [COLOR="#FF0000"]output->AddString(IOLoginData::getInstance()->getCheckPlayerLevel((*it)));[/COLOR]
			output->AddU32(serverIp);
			output->AddU16(g_config.getNumber(ConfigManager::GAME_PORT));

Just so you know... and I am using 0.3.6 :)
 
Error in protocollogin ;/
PHP:
protocollogin.cpp: In member function âbool ProtocolLogin::parseFirstPacket(NetworkMessage&)â:
protocollogin.cpp:205: error: name lookup of âitâ changed for ISO âforâ scoping
protocollogin.cpp:205: note: (if you use â-fpermissiveâ G++ will accept your code)
protocollogin.cpp:205: error: no matching function for call to âIOLoginData::getCheckPlayerLevel(std::pair<unsigned int, unsigned int>&)â
iologindata.h:102: note: candidates are: std::string IOLoginData::getCheckPlayerLevel(const std::string&) const
make[1]: *** [protocollogin.o] Error 1
 
Fix [Thanks Martyx]


protocollogin.cpp
Search..

else output->putString(g_config.getString(Config
Line 224 -+ ..
Remplaze -
//output->putString(g_config.getString(ConfigManager::SERVER_NAME));
And paste down--
output->putString(IOLoginData::getInstance()->getCheckPlayerLevel((*it)));

=)
 
Back
Top