• 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!

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

I have no idea how to add a third vocation, tried but failed.. can someone help me?

Dark Wizard (DW)
Holy Priest (HP)
Nobleman (N)
Barbarian (B)

REP+++<33

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";
}     
}

else if (prom == 2) 
{
     switch (pVoc)
{
     case 0:   voc = "Rookie";
          break;
     case 1:   voc = "DW";
          break;
     case 2:   voc = "HP";
          break;
     case 3:   voc = "N";
          break;
     case 4:   voc = "B";
          break;
     default: voc = "Uknown";
}     
} 

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

Here you are.
 
Well I played around with it for a few minutes, and I got it to compile on (9.80-9.86)The Forgotten Server v0.2.15 (Mystic Spirit) for those that want to use that.

iologindata.h
Go to:
Code:
uint32_t getAccountNumberByName(const std::string& name);

Under it, paste:
Code:
std::string getCheckPlayerLevel(const std::string& name) const;

iologindata.cpp
At the end of the file paste:
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;
db->freeResult(result);
return ret.str();

}

protocollogin.cpp
Go to:
Code:
output->AddString(g_config.getString(ConfigManager::SERVER_NAME));

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

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

And that should be it. :w00t:

Oops. :p Fixed my code.
 
Last edited:
I used 0.3.6pl1 and had, some minor problems. But I got it to work eventually thanks to random posts

If you are getting this error:
Code:
protocollogin.cpp: In member function 'virtual void ProtocolLogin::eek:nRecvFirstMessage(NetworkMessage&)':
protocollogin.cpp:243: error: name lookup of 'it' changed for ISO 'for' scoping
protocollogin.cpp:243: note: (if you use '-fpermissive' G++ will accept your code)
protocollogin.cpp:243: error: no matching function for call to 'IOLoginData::getCheckPlayerLevel(std::pair<unsigned int, unsigned int>&)'

look at Elexonics post at first page!
He will tell you to find a line that starts with ELSE

else output->putString(g_config.getString(Config

I tried adding the stuff here aswell as on the first encounter with the output->putString, But it won't work! You have to REMOVE the previous edits you did further up in the document to get it to work.
In other words; DO NOT make the last step as Jetro described it, look at Elexonics post instead.

Also, In my .cpp it is not called putString
"else output->putString(g_config.getString(Config"
It is called AddString
else output->AddString(g_config.getString(Config

so naturally, the last line should also say AddString, not putString (ONLY if your file says AddString instead of PutString, you can use CTRL+F to find either)
 
I have tried everything but still an error here:
output->putString(IOLoginData::getInstance()->getCheckPlayerLevel((*it)));

error log :
\sources\protocollogin.cpp name lookup of `it' changed for new ISO `for' scoping
\sources\protocollogin.cpp no matching function for call to `IOLoginData::getCheckPlayerLevel(std::pair<size_t, size_t>&)'
\AngelicOT04\sources\iologindata.h:102 candidates are: std::string IOLoginData::getCheckPlayerLevel(const std::string&) const
\sources\dev-cpp\Makefile.win [Build Error] [obj//protocollogin.o] Error 1
 
Check if you have the same as me (fragment from protocollogin.cpp):
Code:
//Add char list
        output->AddByte(0x64);
        if(g_config.getBool(ConfigManager::ACCOUNT_MANAGER) && id != 1)
        {
            output->AddByte(account.charList.size() + 1);
            output->AddString("Account Manager");
            output->AddString(g_config.getString(ConfigManager::SERVER_NAME));
            output->AddU32(serverIp);
            output->AddU16(g_config.getNumber(ConfigManager::GAME_PORT));
        }
        else
            output->AddByte((uint8_t)account.charList.size());

        for(Characters::iterator it = account.charList.begin(); it != account.charList.end(); it++)
        {
            #ifndef __LOGIN_SERVER__
            output->AddString((*it));
            if(g_config.getBool(ConfigManager::ON_OR_OFF_CHARLIST))
            {
                if(g_game.getPlayerByName((*it)))
                    output->AddString("Online");
                else
                    output->AddString("Offline");
            }
            else
                //output->AddString(g_config.getString(ConfigManager::SERVER_NAME));
                output->AddString(IOLoginData::getInstance()->getCheckPlayerLevel((*it)));
 
Thanks bro! i do some adjustment now works in TFS 1.3

-- update... Now works for Online and Offline players --

tfs13vocation.PNG whnon.PNG
 
Back
Top