Fix a crash in BattleGroundMgr::BuildPvpLogDataPacket caused by objmgr not finding player object by guid when showing scoreboard. In this case get bg team ID for player via character database. Closes #938

--HG--
branch : trunk
This commit is contained in:
Machiavelli
2009-12-25 19:44:15 +01:00
parent f75c0f8081
commit cb2cb590e3

View File

@@ -1336,8 +1336,22 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg)
*data << uint32(itr->second->KillingBlows);
if (type) // if (bg->isArena())
{
// BG Team ID (Green/Gold team, not faction teams in arena)
Player *plr = objmgr.GetPlayer(itr->first);
*data << uint8(plr->GetBGTeam()); // BG Team ID (Green/Gold team, not faction teams in arena)
uint8 team = 0;
if (plr)
team = plr->GetBGTeam();
else
{
QueryResult *result = CharacterDatabase.PQuery("SELECT team FROM character_battleground_data WHERE guid = '%u'", GUID_LOPART(itr->first));
if (result)
{
team = (*result)[0].GetUInt8();
delete result;
}
else
sLog.outError("Player GUID %u - unable to find correct BG Team ID for MSG_PVP_LOG_DATA (scoreboard). Defaulting to 0.", GUID_LOPART(itr->first));
}
}
else // if (!bg->isArena())
{