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:
hunuza 2008-11-02 15:58:24 +01:00
parent 8563b88859
commit f2852a95b7
3 changed files with 73 additions and 51 deletions

View file

@ -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);