mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
Removed some unnecessary database queries.
Removed unnecessary database queries in some command handlers. Replaced them with access to cached data or queries for only the needed data. Move database access in gossip select code to less often called place.
This commit is contained in:
parent
8563b88859
commit
f2852a95b7
3 changed files with 73 additions and 51 deletions
|
|
@ -1799,13 +1799,30 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
|||
// get additional information from DB
|
||||
else
|
||||
{
|
||||
// 0
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT totaltime FROM characters WHERE guid = '%u'", targetGUID);
|
||||
if (!result)
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
Field *fields = result->Fetch();
|
||||
total_player_time = fields[0].GetUInt32();
|
||||
delete result;
|
||||
|
||||
Tokens data;
|
||||
if (!Player::LoadValuesArrayFromDB(data,targetGUID))
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
money = Player::GetUInt32ValueFromArray(data, PLAYER_FIELD_COINAGE);
|
||||
level = Player::GetUInt32ValueFromArray(data, UNIT_FIELD_LEVEL);
|
||||
|
||||
accId = objmgr.GetPlayerAccountIdByGUID(targetGUID);
|
||||
WorldSession session(0,NULL,SEC_PLAYER,0,0,LOCALE_enUS);
|
||||
Player plr(&session); // use fake session for temporary load
|
||||
plr.MinimalLoadFromDB(NULL, targetGUID);
|
||||
money = plr.GetMoney();
|
||||
total_player_time = plr.GetTotalPlayedTime();
|
||||
level = plr.getLevel();
|
||||
}
|
||||
|
||||
std::string username = GetMangosString(LANG_ERROR);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue