diff --git a/common/database.cpp b/common/database.cpp index 92627f3bf..bf156d5a9 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -1210,19 +1210,25 @@ bool Database::AddToNameFilter(const char* name) { return true; } +/** + * @param in_loginserver_id + * @param in_loginserver_account_id + * @param in_account_name + * @param in_status + * @return + */ uint32 Database::GetAccountIDFromLSID( - const std::string &iLoginServer, - uint32 iLSID, char *oAccountName, - int16 *oStatus + const std::string &in_loginserver_id, + uint32 in_loginserver_account_id, + char *in_account_name, + int16 *in_status ) { uint32 account_id = 0; - //iLoginServer is set by config so don't need to worry about escaping it. - auto query = fmt::format( "SELECT id, name, status FROM account WHERE lsaccount_id = {0} AND ls_id = '{1}'", - iLSID, - iLoginServer + in_loginserver_account_id, + in_loginserver_id ); auto results = QueryDatabase(query); @@ -1236,13 +1242,13 @@ uint32 Database::GetAccountIDFromLSID( } for (auto row = results.begin(); row != results.end(); ++row) { - account_id = atoi(row[0]); + account_id = std::stoi(row[0]); - if (oAccountName) { - strcpy(oAccountName, row[1]); + if (in_account_name) { + strcpy(in_account_name, row[1]); } - if (oStatus) { - *oStatus = atoi(row[2]); + if (in_status) { + *in_status = std::stoi(row[2]); } } diff --git a/common/database.h b/common/database.h index 510812177..2c1c1205a 100644 --- a/common/database.h +++ b/common/database.h @@ -184,7 +184,7 @@ public: uint32 CheckLogin(const char* name, const char* password, const char *loginserver, int16* oStatus = 0); uint32 CreateAccount(const char* name, const char* password, int16 status, const char* loginserver, uint32 lsaccount_id); - uint32 GetAccountIDFromLSID(const std::string& iLoginServer, uint32 iLSID, char* oAccountName = 0, int16* oStatus = 0); + uint32 GetAccountIDFromLSID(const std::string& in_loginserver_id, uint32 in_loginserver_account_id, char* in_account_name = 0, int16* in_status = 0); uint8 GetAgreementFlag(uint32 acctid); void GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus); diff --git a/world/client.cpp b/world/client.cpp index ce97c98d9..18e6d3810 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -394,35 +394,36 @@ void Client::SendPostEnterWorld() { safe_delete(outapp); } -bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) { +bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) +{ if (app->size != sizeof(LoginInfo_Struct)) { return false; } - - LoginInfo_Struct *li=(LoginInfo_Struct *)app->pBuffer; + + auto *login_info = (LoginInfo_Struct *) app->pBuffer; // Quagmire - max len for name is 18, pass 15 - char name[19] = {0}; + char name[19] = {0}; char password[16] = {0}; - strn0cpy(name, (char*)li->login_info,18); - strn0cpy(password, (char*)&(li->login_info[strlen(name)+1]), 15); + strn0cpy(name, (char *) login_info->login_info, 18); + strn0cpy(password, (char *) &(login_info->login_info[strlen(name) + 1]), 15); + + LogDebug("Receiving Login Info Packet from Client | name [{0}] password [{1}]", name, password); if (strlen(password) <= 1) { Log(Logs::Detail, Logs::World_Server, "Login without a password"); return false; } - is_player_zoning = (li->zoning == 1); - - LogDebug("Receiving Login Info Packet from Client | name [{0}] password [{1}]", name, password); - - uint32 id = atoi(name); + is_player_zoning = (login_info->zoning == 1); + + uint32 id = std::stoi(name); if (id == 0) { LogWarning("Receiving Login Info Packet from Client | account_id is 0 - disconnecting"); return false; } - if (cle = client_list.CheckAuth(id, password)) { + if ((cle = client_list.CheckAuth(id, password))) { if (!is_player_zoning) { // Track who is in and who is out of the game char *inout= (char *) ""; diff --git a/world/cliententry.cpp b/world/cliententry.cpp index 45e281409..2ce17c53e 100644 --- a/world/cliententry.cpp +++ b/world/cliententry.cpp @@ -80,10 +80,6 @@ ClientListEntry::ClientListEntry( pworldadmin = in_is_world_admin; plocal = (local == 1); - pinstance = 0; - pLFGFromLevel = 0; - pLFGToLevel = 0; - pLFGMatchFilter = false; memset(pLFGComments, 0, 64); } diff --git a/world/cliententry.h b/world/cliententry.h index 5c3619e07..30ba002d5 100644 --- a/world/cliententry.h +++ b/world/cliententry.h @@ -138,7 +138,7 @@ private: // Character info ZoneServer* pzoneserver{}; uint32 pzone{}; - uint16 pinstance; + uint16 pinstance{}; uint32 pcharid{}; char pname[64]{}; uint8 plevel{}; @@ -150,9 +150,9 @@ private: bool pLFG{}; uint8 gm{}; uint8 pClientVersion{}; - uint8 pLFGFromLevel; - uint8 pLFGToLevel; - bool pLFGMatchFilter; + uint8 pLFGFromLevel{}; + uint8 pLFGToLevel{}; + bool pLFGMatchFilter{}; char pLFGComments[64]{}; // Tell Queue -- really a vector :D