underewar
Well-Known Member
MultiWorld protocol system.
ioaccountsql.cpp
Look for
Now go to protocollogin.cpp look for parsefirstpacket and change.
Look for.
Change for.
Now go account.h.
Look for.
class Account
Add below.
//ROGIER_MULTIWORLD
Again on account.h we change
Look for
Add this compiler parameter in your compiling stages
Login in PhpMyAdmin and create a new table called worlds with 4 registry,
ioaccountsql.cpp
Look for
Change for this (Obs: You need configure multiple words in your database).IOAccountSQL::loadAccount(uint32_t accno)
C++:
Account IOAccountSQL::loadAccount(uint32_t accno)
{
Account acc;
Database* mysql = Database::instance();
DBQuery query;
DBResult result;
query << "SELECT id,password FROM accounts WHERE id=" << accno;
if(mysql->connect() && mysql->storeQuery(query, result)){
acc.accnumber = result.getDataInt("id");
acc.password = result.getDataString("password");
#ifndef __ROGIER_MULTIWORLD__
query << "SELECT name FROM players WHERE account_id=" << accno;
#else //__ROGIER_MULTIWORLD__
query << "SELECT name,worldid FROM players WHERE account_id=" << accno;
#endif //__ROGIER_MULTIWORLD__
if(mysql->storeQuery(query, result)){
for(uint32_t i = 0; i < result.getNumRows(); ++i){
std::string ss = result.getDataString("name", i);
#ifndef __ROGIER_MULTIWORLD__
acc.charList.push_back(ss.c_str());
#else //__ROGIER_MULTIWORLD__
int worldid = result.getDataInt("worldid", i);
query.reset();
result.clear();
query << "SELECT * FROM worlds WHERE worldid=" << worldid;
mysql->storeQuery(query, result);
struct CharInfo info;
info.worldName = result.getDataString("worldname", i);
info.worldIp = result.getDataString("worldip", i);
info.worldPort = result.getDataInt("worldport", i);
acc.charList[ss] = info;
#endif //__ROGIER_MULTIWORLD__
}
#ifndef __ROGIER_MULTIWORLD__
acc.charList.sort();
#endif //__ROGIER_MULTIWORLD__
}
}
return acc;
}
Look for.
C++:
std::list<std::string>::iterator it;
for(it = account.charList.begin(); it != account.charList.end(); it++){
output->AddString((*it));
output->AddString(g_config.getString(ConfigManager::WORLD _NAME));
output->AddU32(serverip);
output->AddU16(g_config.getNumber(ConfigManager::PORT)) ;
}
C++:
#ifndef __ROGIER_MULTIWORLD__
std::list<std::string>::iterator it;
for(it = account.charList.begin(); it != account.charList.end(); it++){
output->AddString((*it));
output->AddString(g_config.getString(ConfigManager::WORLD _NAME));
output->AddU32(serverip);
output->AddU16(g_config.getNumber(ConfigManager::PORT)) ;
}
#else //__ROGIER_MULTIWORLD__
std::map<std::string, CharInfo>::iterator it;
for(it = account.charList.begin(); it != account.charList.end(); it++){
output->AddString(it->first);
output->AddString(it->second.worldName);
output->AddU32(inet_addr(it->second.worldIp.c_str()));
output->AddU16(it->second.worldPort);
}
#endif
Look for.
class Account
Add below.
C++:
#ifdef __ROGIER_MULTIWORLD__
#include <map>
struct CharInfo
{
std::string worldIp;
std::string worldName;
short worldPort;
};
#endif
Again on account.h we change
Look for
Change forstd::list<std::string> charList;
C++:
#ifdef __ROGIER_MULTIWORLD__
std::list<std::string> charList;
#else //__ROGIER_MULTIWORLD__
std::map<std::string, CharInfo> charList;
#endif //__ROGIER_MULTIWORLD__
How Configure Worlds-D__ROGIER_MULTIWORLD__
Login in PhpMyAdmin and create a new table called worlds with 4 registry,
1.worldid
int type.
2.worldname
string type.
3.worldip
string type.
4.worldport
int type.
Now, in player table, add a new registry called
worldid
int type