Skip to content

Commit

Permalink
Temp fix client crash when too many players in bg
Browse files Browse the repository at this point in the history
  • Loading branch information
Wowka321 committed Mar 18, 2010
1 parent 20cdcdf commit ded253f
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/game/BattleGroundMgr.cpp
Expand Up @@ -1262,7 +1262,7 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg)
{
uint8 type = (bg->isArena() ? 1 : 0);
// last check on 3.0.3
data->Initialize(MSG_PVP_LOG_DATA, (1+1+4+40*bg->GetPlayerScoresSize()));
data->Initialize(MSG_PVP_LOG_DATA, (1 + 1 + 4 + (BG_TEAMS_COUNT * bg->GetMaxPlayersPerTeam() * bg->GetPlayerScoresSize())));
*data << uint8(type); // type (battleground=0/arena=1)

if(type) // arena
Expand Down Expand Up @@ -1296,14 +1296,35 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg)
*data << uint8(bg->GetWinner()); // who win
}

*data << (int32)(bg->GetPlayerScoresSize());
int32 scoresize = 0;
// hack to avoid clientcrash
if (bg->GetPlayerScoresSize() > BG_TEAMS_COUNT * bg->GetMaxPlayersPerTeam())
scoresize = BG_TEAMS_COUNT * bg->GetMaxPlayersPerTeam();
else
scoresize = bg->GetPlayerScoresSize();
*data << (int32)(scoresize);

uint32 counter = 0;

for(BattleGround::BattleGroundScoreMap::const_iterator itr = bg->GetPlayerScoresBegin(); itr != bg->GetPlayerScoresEnd(); ++itr)
{
*data << (uint64)itr->first;
*data << (int32)itr->second->KillingBlows;
if (type == 0)
{
if (!bg->IsPlayerInBattleGround(itr->first))
sLog.outError("battleground: scoreboard: player not in bg %u", GUID_LOPART(itr->first));

counter++;
// hack to avoid clientcrash
if (counter > BG_TEAMS_COUNT * bg->GetMaxPlayersPerTeam())
{
sLog.outError("battleground: scoreboard: too much players in the scoreboard "
"bgtype: %u free slots, alliance: %u, horde: %u .."
"scoreboardsize: %u", bg->GetTypeID(), bg->GetFreeSlotsForTeam(BG_TEAM_ALLIANCE),
bg->GetFreeSlotsForTeam(BG_TEAM_HORDE), bg->GetPlayerScoresSize());
break;
}
*data << (int32)itr->second->HonorableKills;
*data << (int32)itr->second->Deaths;
*data << (int32)(itr->second->BonusHonor);
Expand Down

0 comments on commit ded253f

Please sign in to comment.