Account manager has moved to the bottom of the list I want it at the top, not at the bottomMove
afterC++:if (account.id != 1){ account.characters.push_back("Account Manager"); }
C++:std::sort(account.characters.begin(), account.characters.end());
bool IOLoginData::loginserverAuthentication(uint32_t accountName...
result = db.storeQuery(fmt::format(
"SELECT `name` FROM `players` WHERE `account_id` = {:d} AND `deletion` = 0 ORDER BY `name` ASC", account.id));
if (result) {
do {
if(result->getString("name") == "Account Manager"){
account.characters.insert(account.characters.begin(), result->getString("name"));
} else {
account.characters.push_back(result->getString("name"));
}
} while (result->next());
}
i replace my code to you'r code and compile without error but in login im get debug clientProbably something like this in iologindata.cpp in the function loginserverAuthentication
C++:result = db.storeQuery(fmt::format( "SELECT `name` FROM `players` WHERE `account_id` = {:d} AND `deletion` = 0 ORDER BY `name` ASC", account.id)); if (result) { do { if(result->getString("name") == "Account Manager"){ account.characters.insert(account.characters.begin(), result->getString("name")); } else { account.characters.push_back(result->getString("name")); } } while (result->next()); }
bool IOLoginData::loginserverAuthentication(uint32_t accountName, const std::string& password, Account& account)
{
Database* db = Database::getInstance();
std::ostringstream query;
query << "SELECT id, name, password, type, premdays, lastday FROM accounts WHERE name = " << accountName;
DBResult_ptr result = db->storeQuery(query.str());
if (!result) {
return false;
}
if (transformToSHA1(password) != result->getString("password")) {
return false;
}
account.id = result->getNumber<uint32_t>("id");
account.name = result->getNumber<uint32_t>("name");
account.accountType = static_cast<AccountType_t>(result->getNumber<int32_t>("type"));
account.premiumDays = result->getNumber<uint16_t>("premdays");
account.lastDay = result->getNumber<time_t>("lastday");
query.str(std::string());
query << "SELECT name, deletion FROM players WHERE account_id = " << account.id;
result = db->storeQuery(query.str());
if(!result){
account.characters.push_back("Account Manager");
return true;
}
if (result) {
if (account.id != 1){
account.characters.push_back("Account Manager");
}
do {
if (result->getNumber<uint64_t>("deletion") == 0) {
account.characters.push_back(result->getString("name"));
}
}
while (result->next());
std::sort(account.characters.begin(), account.characters.end());
}
return true;
}
This line:This is my file please help me show the account manager in the first value iologindata.cpp/** * The Forgotten Server - a free and open-source MMORPG server emulator * - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.pastebin.com
std::sort(account.characters.begin(), account.characters.end());
Account Manager
to list.Does that mean I can't do that?This line:
sorts characters by name alphabetically.Code:std::sort(account.characters.begin(), account.characters.end());
You can't sort them after addingAccount Manager
to list.
Account manager has moved to the bottom of the list I want it at the top, not at the bottomMove
afterC++:if (account.id != 1){ account.characters.push_back("Account Manager"); }
C++:std::sort(account.characters.begin(), account.characters.end());
bool IOLoginData::loginserverAuthentication(uint32_t accountName, const std::string& password, Account& account)
{
Database* db = Database::getInstance();
std::ostringstream query;
query << "SELECT `id`, `name`, `password`, `type`, `premdays`, `lastday` FROM `accounts` WHERE `name` = " << accountName;
DBResult_ptr result = db->storeQuery(query.str());
if (!result) {
return false;
}
if (transformToSHA1(password) != result->getString("password")) {
return false;
}
account.id = result->getNumber<uint32_t>("id");
account.name = result->getNumber<uint32_t>("name");
account.accountType = static_cast<AccountType_t>(result->getNumber<int32_t>("type"));
account.premiumDays = result->getNumber<uint16_t>("premdays");
account.lastDay = result->getNumber<time_t>("lastday");
query.str(std::string());
query << "SELECT `name`, `deletion` FROM `players` WHERE `account_id` = " << account.id;
result = db->storeQuery(query.str());
if(!result){
// give the account the account manager to use if they have no account
account.characters.push_back("Account Manager");
return true;
}
// --
if (result) {
// allow them to access the account manager if there are players on the account
if (account.id != 1){
account.characters.push_back("Account Manager");
}
std::sort(account.characters.begin(), account.characters.end());
do {
if (result->getNumber<uint64_t>("deletion") == 0) {
account.characters.push_back(result->getString("name"));
}
} while (result->next());
}
return true;
}
// --
if (result) {
do {
if (result->getNumber<uint64_t>("deletion") == 0) {
account.characters.push_back(result->getString("name"));
}
} while (result->next());
std::sort(account.characters.begin(), account.characters.end());
// allow them to access the account manager if there are players on the account
if (account.id != 1){
account.characters.emplace(account.characters.begin(),"Account Manager");
}
}
return true;