aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/server/game/Battlegrounds/BattlegroundMgr.cpp306
-rwxr-xr-xsrc/server/game/Handlers/BattleGroundHandler.cpp43
-rw-r--r--src/server/game/Server/Protocol/Opcodes.cpp9
-rwxr-xr-xsrc/server/game/Server/Protocol/Opcodes.h1
-rwxr-xr-xsrc/server/game/Server/WorldSession.h2
-rwxr-xr-xsrc/server/shared/Packets/ByteBuffer.h9
6 files changed, 221 insertions, 149 deletions
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
index 9ff21ca2d30..afc63ed6704 100755
--- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
@@ -199,7 +199,7 @@ void BattlegroundMgr::BuildBattlegroundStatusPacket(WorldPacket *data, Battlegro
case STATUS_WAIT_QUEUE:
{
data->Initialize(SMSG_BATTLEFIELD_STATUS_QUEUED);
-
+
data->WriteBit(guidBytes1[3]);
data->WriteBit(guidBytes1[0]);
data->WriteBit(guidBytes2[3]);
@@ -222,7 +222,7 @@ void BattlegroundMgr::BuildBattlegroundStatusPacket(WorldPacket *data, Battlegro
data->WriteBit(guidBytes2[1]);
data->FlushBits();
-
+
data->WriteByteSeq(guidBytes1[0]);
*data << uint32(0); // unk
data->WriteByteSeq(guidBytes2[5]);
@@ -306,7 +306,7 @@ void BattlegroundMgr::BuildBattlegroundStatusPacket(WorldPacket *data, Battlegro
case STATUS_IN_PROGRESS:
{
data->Initialize(SMSG_BATTLEFIELD_STATUS_ACTIVE, 49);
-
+
data->WriteBit(guidBytes1[2]);
data->WriteBit(guidBytes1[7]);
data->WriteBit(guidBytes2[7]);
@@ -325,7 +325,9 @@ void BattlegroundMgr::BuildBattlegroundStatusPacket(WorldPacket *data, Battlegro
data->WriteBit(guidBytes2[2]);
data->WriteBit(guidBytes1[3]);
data->WriteBit(guidBytes1[0]);
-
+
+ data->FlushBits();
+
data->WriteByteSeq(guidBytes2[4]);
data->WriteByteSeq(guidBytes2[5]);
data->WriteByteSeq(guidBytes1[5]);
@@ -337,7 +339,7 @@ void BattlegroundMgr::BuildBattlegroundStatusPacket(WorldPacket *data, Battlegro
*data << uint32(Time2); // Time
*data << uint8(bg->GetPlayersCountByTeam(bg->GetPlayerTeam(pPlayer->GetGUID()))); // Teamsize
-
+
data->WriteByteSeq(guidBytes1[4]);
data->WriteByteSeq(guidBytes1[1]);
@@ -351,13 +353,13 @@ void BattlegroundMgr::BuildBattlegroundStatusPacket(WorldPacket *data, Battlegro
data->WriteByteSeq(guidBytes1[2]);
*data << uint32(bg->GetStartTime()); // Time since started
-
+
data->WriteByteSeq(guidBytes1[0]);
data->WriteByteSeq(guidBytes1[3]);
data->WriteByteSeq(guidBytes1[2]);
-
+
*data << uint32(bg->GetClientInstanceID()); // Client Instance ID
-
+
data->WriteByteSeq(guidBytes2[0]);
data->WriteByteSeq(guidBytes1[7]);
break;
@@ -379,7 +381,7 @@ void BattlegroundMgr::BuildBattlegroundStatusPacket(WorldPacket *data, Battlegro
*data << uint32(bg->GetMapId()); // Map Id
*data << uint32(Time2); // Time
*data << uint8(0); // unk
-
+
data->WriteBit(guidBytes2[0]);
data->WriteBit(guidBytes2[1]);
data->WriteBit(guidBytes2[7]);
@@ -397,7 +399,7 @@ void BattlegroundMgr::BuildBattlegroundStatusPacket(WorldPacket *data, Battlegro
data->WriteBit(bg->isRated()); // Is Rated
data->WriteBit(guidBytes1[1]);
data->WriteBit(guidBytes2[6]);
-
+
data->FlushBits();
data->WriteByteSeq(guidBytes1[0]);
@@ -423,47 +425,30 @@ void BattlegroundMgr::BuildBattlegroundStatusPacket(WorldPacket *data, Battlegro
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 << uint8(type); // type (battleground=0/arena=1)
-
- if (type) // arena
- {
- // it seems this must be according to BG_WINNER_A/H and _NOT_ BG_TEAM_A/H
- for (int8 i = 1; i >= 0; --i)
- {
- int32 rating_change = bg->GetArenaTeamRatingChangeByIndex(i);
+ uint8 isRated = (bg->isRated() ? 1 : 0); // type (normal=0/rated=1) -- ATM arena or bg, RBG NYI
+ uint8 isArena = (bg->isArena() ? 1 : 0); // Arena names
- uint32 pointsLost = rating_change < 0 ? -rating_change : 0;
- uint32 pointsGained = rating_change > 0 ? rating_change : 0;
- uint32 MatchmakerRating = bg->GetArenaMatchmakerRatingByIndex(i);
+ data->Initialize(SMSG_PVP_LOG_DATA, (1+1+4+40*bg->GetPlayerScoresSize()));
+ data->WriteBit(isArena);
+ data->WriteBit(isRated);
- *data << uint32(pointsLost); // Rating Lost
- *data << uint32(pointsGained); // Rating gained
- *data << uint32(MatchmakerRating); // Matchmaking Value
- sLog->outDebug(LOG_FILTER_BATTLEGROUND, "rating change: %d", rating_change);
- }
+ if (isArena)
+ {
for (int8 i = 1; i >= 0; --i)
{
if (ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(bg->GetArenaTeamIdByIndex(i)))
- *data << at->GetName();
+ data->WriteBits(at->GetName().length(), 8);
else
- *data << uint8(0);
+ data->WriteBits(0, 8);
}
}
- if (bg->GetStatus() != STATUS_WAIT_LEAVE)
- *data << uint8(0); // bg not ended
- else
- {
- *data << uint8(1); // bg ended
- *data << uint8(bg->GetWinner()); // who win
- }
+ size_t count_pos = data->bitwpos();
- size_t wpos = data->wpos();
- uint32 scoreCount = 0;
- *data << uint32(scoreCount); // placeholder
+ data->WriteBits(0, 21); // Placeholder
+
+ int32 count = 0;
+ ByteBuffer buff;
Battleground::BattlegroundScoreMap::const_iterator itr2 = bg->GetPlayerScoresBegin();
for (Battleground::BattlegroundScoreMap::const_iterator itr = itr2; itr != bg->GetPlayerScoresEnd();)
@@ -474,137 +459,202 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg)
sLog->outError(LOG_FILTER_BATTLEGROUND, "Player " UI64FMTD " has scoreboard entry for battleground %u but is not in battleground!", itr->first, bg->GetTypeID(true));
continue;
}
-
- *data << uint64(itr2->first);
- *data << uint32(itr2->second->KillingBlows);
- if (type == 0)
- {
- *data << uint32(itr2->second->HonorableKills);
- *data << uint32(itr2->second->Deaths);
- *data << uint32(itr2->second->BonusHonor);
- }
- else
+ ObjectGuid guid = itr2->first;
+ Player* player = ObjectAccessor::FindPlayer(itr2->first);
+ data->WriteBit(0); // Unk 1
+ data->WriteBit(0); // Unk 2
+ data->WriteBit(guid[2]);
+ data->WriteBit(!isArena); // Unk 3 -- Prolly if (bg)
+ data->WriteBit(0); // Unk 4
+ data->WriteBit(0); // Unk 5
+ data->WriteBit(0); // Unk 6
+ data->WriteBit(guid[3]);
+ data->WriteBit(guid[0]);
+ data->WriteBit(guid[5]);
+ data->WriteBit(guid[1]);
+ data->WriteBit(guid[6]);
+ data->WriteBit(player->GetTeam() == ALLIANCE);
+ data->WriteBit(guid[7]);
+
+ buff << uint32(itr2->second->HealingDone); // healing done
+ buff << uint32(itr2->second->DamageDone); // damage done
+
+ if (!isArena) // Unk 3 prolly is (bg)
{
- Player* player = ObjectAccessor::FindPlayer(itr2->first);
- uint32 team = bg->GetPlayerTeam(itr2->first);
- if (!team && player)
- team = player->GetBGTeam();
- *data << uint8(team == ALLIANCE ? 1 : 0); // green or yellow
+ buff << uint32(itr2->second->BonusHonor);
+ buff << uint32(itr2->second->Deaths);
+ buff << uint32(itr2->second->HonorableKills);
}
- *data << uint32(itr2->second->DamageDone); // damage done
- *data << uint32(itr2->second->HealingDone); // healing done
- switch (bg->GetTypeID(true)) // battleground specific things
+
+ buff.WriteByteSeq(guid[4]);
+ buff << uint32(itr2->second->KillingBlows);
+
+ // if (unk 5) << uint32() unk
+
+ buff.WriteByteSeq(guid[5]);
+
+ // if (unk 6) << uint32() unk
+ // if (unk 2) << uint32() unk
+
+ buff.WriteByteSeq(guid[1]);
+ buff.WriteByteSeq(guid[6]);
+
+ buff << int32(player->GetPrimaryTalentTree(player->GetActiveSpec()));
+
+ switch (bg->GetTypeID(true)) // Custom values
{
case BATTLEGROUND_RB:
switch (bg->GetMapId())
{
case 489:
- *data << uint32(0x00000002); // count of next fields
- *data << uint32(((BattlegroundWGScore*)itr2->second)->FlagCaptures); // flag captures
- *data << uint32(((BattlegroundWGScore*)itr2->second)->FlagReturns); // flag returns
+ data->WriteBits(0x00000002, 24);
+ buff << uint32(((BattlegroundWGScore*)itr2->second)->FlagCaptures); // flag captures
+ buff << uint32(((BattlegroundWGScore*)itr2->second)->FlagReturns); // flag returns
break;
case 566:
- *data << uint32(0x00000001); // count of next fields
- *data << uint32(((BattlegroundEYScore*)itr2->second)->FlagCaptures); // flag captures
+ data->WriteBits(0x00000001, 24);
+ buff << uint32(((BattlegroundEYScore*)itr2->second)->FlagCaptures); // flag captures
break;
case 529:
- *data << uint32(0x00000002); // count of next fields
- *data << uint32(((BattlegroundABScore*)itr2->second)->BasesAssaulted); // bases asssulted
- *data << uint32(((BattlegroundABScore*)itr2->second)->BasesDefended); // bases defended
+ data->WriteBits(0x00000002, 24);
+ buff << uint32(((BattlegroundABScore*)itr2->second)->BasesAssaulted); // bases asssulted
+ buff << uint32(((BattlegroundABScore*)itr2->second)->BasesDefended); // bases defended
break;
case 30:
- *data << uint32(0x00000005); // count of next fields
- *data << uint32(((BattlegroundAVScore*)itr2->second)->GraveyardsAssaulted); // GraveyardsAssaulted
- *data << uint32(((BattlegroundAVScore*)itr2->second)->GraveyardsDefended); // GraveyardsDefended
- *data << uint32(((BattlegroundAVScore*)itr2->second)->TowersAssaulted); // TowersAssaulted
- *data << uint32(((BattlegroundAVScore*)itr2->second)->TowersDefended); // TowersDefended
- *data << uint32(((BattlegroundAVScore*)itr2->second)->MinesCaptured); // MinesCaptured
+ data->WriteBits(0x00000005, 24);
+ buff << uint32(((BattlegroundAVScore*)itr2->second)->GraveyardsAssaulted); // GraveyardsAssaulted
+ buff << uint32(((BattlegroundAVScore*)itr2->second)->GraveyardsDefended); // GraveyardsDefended
+ buff << uint32(((BattlegroundAVScore*)itr2->second)->TowersAssaulted); // TowersAssaulted
+ buff << uint32(((BattlegroundAVScore*)itr2->second)->TowersDefended); // TowersDefended
+ buff << uint32(((BattlegroundAVScore*)itr2->second)->MinesCaptured); // MinesCaptured
break;
case 607:
- *data << uint32(0x00000002); // count of next fields
- *data << uint32(((BattlegroundSAScore*)itr2->second)->demolishers_destroyed);
- *data << uint32(((BattlegroundSAScore*)itr2->second)->gates_destroyed);
+ data->WriteBits(0x00000002, 24);
+ buff << uint32(((BattlegroundSAScore*)itr2->second)->demolishers_destroyed);
+ buff << uint32(((BattlegroundSAScore*)itr2->second)->gates_destroyed);
break;
case 628: // IC
- *data << uint32(0x00000002); // count of next fields
- *data << uint32(((BattlegroundICScore*)itr2->second)->BasesAssaulted); // bases asssulted
- *data << uint32(((BattlegroundICScore*)itr2->second)->BasesDefended); // bases defended
+ data->WriteBits(0x00000002, 24);
+ buff << uint32(((BattlegroundICScore*)itr2->second)->BasesAssaulted); // bases asssulted
+ buff << uint32(((BattlegroundICScore*)itr2->second)->BasesDefended); // bases defended
+ break;
case 726:
- *data << uint32(0x00000002); // count of next fields
- *data << uint32(((BattlegroundTPScore*)itr2->second)->FlagCaptures); // flag captures
- *data << uint32(((BattlegroundTPScore*)itr2->second)->FlagReturns); // flag returns
+ data->WriteBits(0x00000002, 24);
+ buff << uint32(((BattlegroundTPScore*)itr2->second)->FlagCaptures); // flag captures
+ buff << uint32(((BattlegroundTPScore*)itr2->second)->FlagReturns); // flag returns
break;
case 761:
- *data << uint32(0x00000002); // count of next fields
- *data << uint32(((BattlegroundBFGScore*)itr2->second)->BasesAssaulted); // bases asssulted
- *data << uint32(((BattlegroundBFGScore*)itr2->second)->BasesDefended); // bases defended
+ data->WriteBits(0x00000002, 24);
+ buff << uint32(((BattlegroundBFGScore*)itr2->second)->BasesAssaulted); // bases asssulted
+ buff << uint32(((BattlegroundBFGScore*)itr2->second)->BasesDefended); // bases defended
break;
default:
- *data << uint32(0);
+ data->WriteBits(0, 24);
break;
}
+ break;
case BATTLEGROUND_AV:
- *data << uint32(0x00000005); // count of next fields
- *data << uint32(((BattlegroundAVScore*)itr2->second)->GraveyardsAssaulted); // GraveyardsAssaulted
- *data << uint32(((BattlegroundAVScore*)itr2->second)->GraveyardsDefended); // GraveyardsDefended
- *data << uint32(((BattlegroundAVScore*)itr2->second)->TowersAssaulted); // TowersAssaulted
- *data << uint32(((BattlegroundAVScore*)itr2->second)->TowersDefended); // TowersDefended
- *data << uint32(((BattlegroundAVScore*)itr2->second)->MinesCaptured); // MinesCaptured
+ data->WriteBits(0x00000005, 24);
+ buff << uint32(((BattlegroundAVScore*)itr2->second)->GraveyardsAssaulted); // GraveyardsAssaulted
+ buff << uint32(((BattlegroundAVScore*)itr2->second)->GraveyardsDefended); // GraveyardsDefended
+ buff << uint32(((BattlegroundAVScore*)itr2->second)->TowersAssaulted); // TowersAssaulted
+ buff << uint32(((BattlegroundAVScore*)itr2->second)->TowersDefended); // TowersDefended
+ buff << uint32(((BattlegroundAVScore*)itr2->second)->MinesCaptured); // MinesCaptured
break;
case BATTLEGROUND_WS:
- *data << uint32(0x00000002); // count of next fields
- *data << uint32(((BattlegroundWGScore*)itr2->second)->FlagCaptures); // flag captures
- *data << uint32(((BattlegroundWGScore*)itr2->second)->FlagReturns); // flag returns
+ data->WriteBits(0x00000002, 24);
+ buff << uint32(((BattlegroundWGScore*)itr2->second)->FlagCaptures); // flag captures
+ buff << uint32(((BattlegroundWGScore*)itr2->second)->FlagReturns); // flag returns
break;
case BATTLEGROUND_AB:
- *data << uint32(0x00000002); // count of next fields
- *data << uint32(((BattlegroundABScore*)itr2->second)->BasesAssaulted); // bases asssulted
- *data << uint32(((BattlegroundABScore*)itr2->second)->BasesDefended); // bases defended
+ data->WriteBits(0x00000002, 24);
+ buff << uint32(((BattlegroundABScore*)itr2->second)->BasesAssaulted); // bases asssulted
+ buff << uint32(((BattlegroundABScore*)itr2->second)->BasesDefended); // bases defended
break;
case BATTLEGROUND_EY:
- *data << uint32(0x00000001); // count of next fields
- *data << uint32(((BattlegroundEYScore*)itr2->second)->FlagCaptures); // flag captures
+ data->WriteBits(0x00000001, 24);
+ buff << uint32(((BattlegroundEYScore*)itr2->second)->FlagCaptures); // flag captures
break;
case BATTLEGROUND_SA:
- *data << uint32(0x00000002); // count of next fields
- *data << uint32(((BattlegroundSAScore*)itr2->second)->demolishers_destroyed);
- *data << uint32(((BattlegroundSAScore*)itr2->second)->gates_destroyed);
+ data->WriteBits(0x00000002, 24);
+ buff << uint32(((BattlegroundSAScore*)itr2->second)->demolishers_destroyed);
+ buff << uint32(((BattlegroundSAScore*)itr2->second)->gates_destroyed);
break;
- case BATTLEGROUND_IC: // wotlk
- *data << uint32(0x00000002); // count of next fields
- *data << uint32(((BattlegroundICScore*)itr2->second)->BasesAssaulted); // bases asssulted
- *data << uint32(((BattlegroundICScore*)itr2->second)->BasesDefended); // bases defended
+ case BATTLEGROUND_IC:
+ data->WriteBits(0x00000002, 24);
+ buff << uint32(((BattlegroundICScore*)itr2->second)->BasesAssaulted); // bases asssulted
+ buff << uint32(((BattlegroundICScore*)itr2->second)->BasesDefended); // bases defended
break;
case BATTLEGROUND_TP:
- *data << uint32(0x00000002); // count of next fields
- *data << uint32(((BattlegroundTPScore*)itr2->second)->FlagCaptures); // flag captures
- *data << uint32(((BattlegroundTPScore*)itr2->second)->FlagReturns); // flag returns
+ data->WriteBits(0x00000002, 24);
+ buff << uint32(((BattlegroundTPScore*)itr2->second)->FlagCaptures); // flag captures
+ buff << uint32(((BattlegroundTPScore*)itr2->second)->FlagReturns); // flag returns
+ break;
case BATTLEGROUND_BFG:
- *data << uint32(0x00000002); // count of next fields
- *data << uint32(((BattlegroundBFGScore*)itr2->second)->BasesAssaulted); // bases asssulted
- *data << uint32(((BattlegroundBFGScore*)itr2->second)->BasesDefended); // bases defended
+ data->WriteBits(0x00000002, 24);
+ buff << uint32(((BattlegroundBFGScore*)itr2->second)->BasesAssaulted); // bases asssulted
+ buff << uint32(((BattlegroundBFGScore*)itr2->second)->BasesDefended); // bases defended
+ break;
case BATTLEGROUND_NA:
case BATTLEGROUND_BE:
case BATTLEGROUND_AA:
case BATTLEGROUND_RL:
case BATTLEGROUND_DS: // wotlk
case BATTLEGROUND_RV: // wotlk
- *data << uint32(0);
+ data->WriteBits(0, 24);
break;
default:
- sLog->outDebug(LOG_FILTER_NETWORKIO, "Unhandled MSG_PVP_LOG_DATA for BG id %u", bg->GetTypeID());
- *data << uint32(0);
+ data->WriteBits(0, 24);
break;
}
- // should never happen
- if (++scoreCount >= bg->GetMaxPlayers() && itr != bg->GetPlayerScoresEnd())
+ data->WriteBit(guid[4]);
+
+ buff.WriteByteSeq(guid[0]);
+ buff.WriteByteSeq(guid[3]);
+
+ // if (unk 4) << uint32() unk
+
+ buff.WriteByteSeq(guid[7]);
+ buff.WriteByteSeq(guid[2]);
+
+ ++count;
+ }
+
+ data->WriteBit(bg->GetStatus() == STATUS_WAIT_LEAVE); // If Ended
+ data->FlushBits();
+ data->PutBits<int32>(count_pos, count, 21); // Number of Players
+
+ if (isRated) // arena TODO : Fix Order on Rated Implementation
+ {
+ // it seems this must be according to BG_WINNER_A/H and _NOT_ BG_TEAM_A/H
+ for (int8 i = 1; i >= 0; --i)
{
- sLog->outError(LOG_FILTER_BATTLEGROUND, "Battleground %u scoreboard has more entries (%u) than allowed players in this bg (%u)", bg->GetTypeID(true), bg->GetPlayerScoresSize(), bg->GetMaxPlayers());
- break;
+ int32 rating_change = bg->GetArenaTeamRatingChangeByIndex(i);
+
+ uint32 pointsLost = rating_change < 0 ? -rating_change : 0;
+ uint32 pointsGained = rating_change > 0 ? rating_change : 0;
+ uint32 MatchmakerRating = bg->GetArenaMatchmakerRatingByIndex(i);
+
+ *data << uint32(pointsLost); // Rating Lost
+ *data << uint32(pointsGained); // Rating gained
+ *data << uint32(MatchmakerRating); // Matchmaking Value
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "rating change: %d", rating_change);
}
}
- data->put(wpos, scoreCount);
+ data->append(buff);
+
+ if (isArena)
+ for (int8 i = 1; i >= 0; --i)
+ if (ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(bg->GetArenaTeamIdByIndex(i)))
+ data->WriteString(at->GetName());
+
+ *data << uint8(0); // unk
+
+ if (bg->GetStatus() == STATUS_WAIT_LEAVE)
+ *data << uint8(bg->GetWinner()); // who win
+
+ *data << uint8(0); // unk
}
void BattlegroundMgr::BuildGroupJoinedBattlegroundPacket(WorldPacket* data, Battleground* bg, Player* pPlayer, GroupJoinBattlegroundResult result)
@@ -613,7 +663,7 @@ void BattlegroundMgr::BuildGroupJoinedBattlegroundPacket(WorldPacket* data, Batt
ObjectGuid guidBytes2 = bg->GetGUID();
data->Initialize(SMSG_BATTLEFIELD_STATUS_FAILED);
-
+
}
void BattlegroundMgr::BuildUpdateWorldStatePacket(WorldPacket* data, uint32 field, uint32 value)
@@ -659,7 +709,7 @@ void BattlegroundMgr::BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, uin
ObjectGuid guidBytes = guid;
data->Initialize(SMSG_BATTLEGROUND_PLAYER_JOINED, 8);
-
+
data->WriteBit(guidBytes[0]);
data->WriteBit(guidBytes[4]);
data->WriteBit(guidBytes[3]);
@@ -668,7 +718,7 @@ void BattlegroundMgr::BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, uin
data->WriteBit(guidBytes[6]);
data->WriteBit(guidBytes[2]);
data->WriteBit(guidBytes[1]);
-
+
data->WriteByteSeq(guidBytes[1]);
data->WriteByteSeq(guidBytes[5]);
data->WriteByteSeq(guidBytes[3]);
@@ -1095,8 +1145,10 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid
data->WriteBit(guidBytes[7]);
data->WriteBit(0); // unk
data->WriteBit(0); // unk
- size_t count_pos = data->wpos();
- data->WriteBit(0); // bg instance count
+
+ data->FlushBits();
+ size_t count_pos = data->bitwpos();
+ data->WriteBits(0, 24); // placeholder
data->WriteBit(guidBytes[6]);
data->WriteBit(guidBytes[4]);
@@ -1125,7 +1177,7 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid
*data << uint32(*itr); // instance id
++count;
}
- data->put<uint32>(count_pos, count);
+ data->PutBits(count_pos, count, 24); // bg instance count
}
}
diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp
index d3e28bd84d1..085b5181913 100755
--- a/src/server/game/Handlers/BattleGroundHandler.cpp
+++ b/src/server/game/Handlers/BattleGroundHandler.cpp
@@ -354,7 +354,7 @@ void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket & /*recvD
void WorldSession::HandlePVPLogDataOpcode(WorldPacket & /*recvData*/)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd MSG_PVP_LOG_DATA Message");
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_PVP_LOG_DATA Message");
Battleground* bg = _player->GetBattleground();
if (!bg)
@@ -368,7 +368,7 @@ void WorldSession::HandlePVPLogDataOpcode(WorldPacket & /*recvData*/)
sBattlegroundMgr->BuildPvpLogDataPacket(&data, bg);
SendPacket(&data);
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent MSG_PVP_LOG_DATA Message");
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_PVP_LOG_DATA Message");
}
void WorldSession::HandleBattlefieldListOpcode(WorldPacket& recvData)
@@ -394,13 +394,35 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_BATTLEFIELD_PORT Message");
- uint8 type; // arenatype if arena
- uint8 unk2; // unk, can be 0x0 (may be if was invited?) and 0x1
+ uint32 time;
+ uint32 type; // guessed
uint32 bgTypeId_; // type id from dbc
- uint16 unk; // 0x1F90 constant?
uint8 action; // enter battle 0x1, leave queue 0x0
+ ObjectGuid guid;
+
+ recvData >> time;
+ recvData >> type;
+ recvData >> bgTypeId_;
+
+ guid[0] = recvData.ReadBit();
+ guid[1] = recvData.ReadBit();
+ guid[5] = recvData.ReadBit();
+ guid[6] = recvData.ReadBit();
+ guid[7] = recvData.ReadBit();
+ guid[4] = recvData.ReadBit();
+ guid[3] = recvData.ReadBit();
+ guid[2] = recvData.ReadBit();
- recvData >> type >> unk2 >> bgTypeId_ >> unk >> action;
+ action = recvData.ReadBit();
+
+ recvData.ReadByteSeq(guid[1]);
+ recvData.ReadByteSeq(guid[3]);
+ recvData.ReadByteSeq(guid[5]);
+ recvData.ReadByteSeq(guid[7]);
+ recvData.ReadByteSeq(guid[0]);
+ recvData.ReadByteSeq(guid[2]);
+ recvData.ReadByteSeq(guid[6]);
+ recvData.ReadByteSeq(guid[4]);
if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
{
@@ -539,14 +561,9 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
}
}
-void WorldSession::HandleLeaveBattlefieldOpcode(WorldPacket& recvData)
+void WorldSession::HandleBattlefieldLeaveOpcode(WorldPacket& recvData)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_LEAVE_BATTLEFIELD Message");
-
- recvData.read_skip<uint8>(); // unk1
- recvData.read_skip<uint8>(); // unk2
- recvData.read_skip<uint32>(); // BattlegroundTypeId
- recvData.read_skip<uint16>(); // unk3
+ sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_BATTLEFIELD_LEAVE Message");
// not allow leave battleground in combat
if (_player->isInCombat())
diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp
index 81620808485..6eeb3661028 100644
--- a/src/server/game/Server/Protocol/Opcodes.cpp
+++ b/src/server/game/Server/Protocol/Opcodes.cpp
@@ -99,7 +99,7 @@ void InitOpcodes()
DEFINE_OPCODE_HANDLER(CMSG_AUTOSTORE_LOOT_ITEM, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleAutostoreLootItemOpcode );
DEFINE_OPCODE_HANDLER(CMSG_AUTO_DECLINE_GUILD_INVITES, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
DEFINE_OPCODE_HANDLER(CMSG_BANKER_ACTIVATE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBankerActivateOpcode );
- DEFINE_OPCODE_HANDLER(CMSG_BATTLEFIELD_LEAVE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
+ DEFINE_OPCODE_HANDLER(CMSG_BATTLEFIELD_LEAVE, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleBattlefieldLeaveOpcode );
DEFINE_OPCODE_HANDLER(CMSG_BATTLEFIELD_LIST, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBattlefieldListOpcode );
DEFINE_OPCODE_HANDLER(CMSG_BATTLEFIELD_MGR_ENTRY_INVITE_RESPONSE, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleBfEntryInviteResponse );
DEFINE_OPCODE_HANDLER(CMSG_BATTLEFIELD_MGR_EXIT_REQUEST, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleBfExitRequest );
@@ -289,6 +289,7 @@ void InitOpcodes()
DEFINE_OPCODE_HANDLER(CMSG_IGNORE_TRADE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleIgnoreTradeOpcode );
DEFINE_OPCODE_HANDLER(CMSG_INITIATE_TRADE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleInitiateTradeOpcode );
DEFINE_OPCODE_HANDLER(CMSG_INSPECT, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleInspectOpcode );
+ DEFINE_OPCODE_HANDLER(CMSG_INSPECT_HONOR_STATS, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleInspectHonorStatsOpcode );
DEFINE_OPCODE_HANDLER(CMSG_INSTANCE_LOCK_WARNING_RESPONSE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
DEFINE_OPCODE_HANDLER(CMSG_ITEM_REFUND, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleItemRefund );
DEFINE_OPCODE_HANDLER(CMSG_ITEM_REFUND_INFO, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleItemRefundInfoRequest );
@@ -413,7 +414,7 @@ void InitOpcodes()
DEFINE_OPCODE_HANDLER(CMSG_PLAYER_VEHICLE_ENTER, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleEnterPlayerVehicle );
DEFINE_OPCODE_HANDLER(CMSG_PLAY_DANCE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
DEFINE_OPCODE_HANDLER(CMSG_PUSHQUESTTOPARTY, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandlePushQuestToParty );
- DEFINE_OPCODE_HANDLER(CMSG_PVP_LOG_DATA, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
+ DEFINE_OPCODE_HANDLER(CMSG_PVP_LOG_DATA, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandlePVPLogDataOpcode );
DEFINE_OPCODE_HANDLER(CMSG_QUERY_BATTLEFIELD_STATE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
DEFINE_OPCODE_HANDLER(CMSG_QUERY_GUILD_MEMBERS_FOR_RECIPE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
DEFINE_OPCODE_HANDLER(CMSG_QUERY_GUILD_MEMBER_RECIPES, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
@@ -1087,7 +1088,7 @@ void InitOpcodes()
DEFINE_OPCODE_HANDLER(SMSG_PROCRESIST, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide );
DEFINE_OPCODE_HANDLER(SMSG_PROPOSE_LEVEL_GRANT, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide );
DEFINE_OPCODE_HANDLER(SMSG_PVP_CREDIT, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide );
- DEFINE_OPCODE_HANDLER(SMSG_PVP_LOG_DATA, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_ServerSide );
+ DEFINE_OPCODE_HANDLER(SMSG_PVP_LOG_DATA, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide );
DEFINE_OPCODE_HANDLER(SMSG_PVP_OPTIONS_ENABLED, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_ServerSide );
DEFINE_OPCODE_HANDLER(SMSG_QUERY_QUESTS_COMPLETED_RESPONSE, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide );
DEFINE_OPCODE_HANDLER(SMSG_QUERY_TIME_RESPONSE, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide );
@@ -1421,7 +1422,6 @@ void InitOpcodes()
//DEFINE_OPCODE_HANDLER(CMSG_INSTANCE_LOCK_RESPONSE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleInstanceLockResponse );
//DEFINE_OPCODE_HANDLER(CMSG_LEARN_DANCE_MOVE, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL );
//DEFINE_OPCODE_HANDLER(CMSG_LEARN_SPELL, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL );
- //DEFINE_OPCODE_HANDLER(CMSG_LEAVE_BATTLEFIELD, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleLeaveBattlefieldOpcode );
//DEFINE_OPCODE_HANDLER(CMSG_LEVEL_CHEAT, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL );
//DEFINE_OPCODE_HANDLER(CMSG_LFD_PARTY_LOCK_INFO_REQUEST, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleLfgPartyLockInfoRequestOpcode);
//DEFINE_OPCODE_HANDLER(CMSG_LFD_PLAYER_LOCK_INFO_REQUEST, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleLfgPlayerLockInfoRequestOpcode);
@@ -1559,7 +1559,6 @@ void InitOpcodes()
//DEFINE_OPCODE_HANDLER(MSG_GM_RESETINSTANCELIMIT, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL );
//DEFINE_OPCODE_HANDLER(MSG_GM_SHOWLABEL, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL );
//DEFINE_OPCODE_HANDLER(MSG_GM_SUMMON, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL );
- DEFINE_OPCODE_HANDLER(CMSG_INSPECT_HONOR_STATS, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleInspectHonorStatsOpcode );
//DEFINE_OPCODE_HANDLER(MSG_MOVE_FEATHER_FALL, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL );
//DEFINE_OPCODE_HANDLER(MSG_MOVE_GRAVITY_CHNG, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL );
//DEFINE_OPCODE_HANDLER(MSG_MOVE_HOVER, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL );
diff --git a/src/server/game/Server/Protocol/Opcodes.h b/src/server/game/Server/Protocol/Opcodes.h
index 3155c4eb922..b948ce76ca6 100755
--- a/src/server/game/Server/Protocol/Opcodes.h
+++ b/src/server/game/Server/Protocol/Opcodes.h
@@ -294,7 +294,6 @@ enum Opcodes
CMSG_LEARN_PREVIEW_TALENTS = 0x2415,
CMSG_LEARN_PREVIEW_TALENTS_PET = 0x6E24,
CMSG_LEARN_TALENT = 0x0306,
- CMSG_LEAVE_BATTLEFIELD = 0x0000,
CMSG_LEAVE_CHANNEL = 0x2D56,
CMSG_LFG_GET_PLAYER_INFO = 0x0000,
CMSG_LFG_GET_STATUS = 0x2581,
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index dda9d0c146d..0ac7884efe2 100755
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -789,7 +789,7 @@ class WorldSession
void HandlePVPLogDataOpcode(WorldPacket& recvData);
void HandleBattleFieldPortOpcode(WorldPacket& recvData);
void HandleBattlefieldListOpcode(WorldPacket& recvData);
- void HandleLeaveBattlefieldOpcode(WorldPacket& recvData);
+ void HandleBattlefieldLeaveOpcode(WorldPacket& recvData);
void HandleBattlemasterJoinArena(WorldPacket& recvData);
void HandleReportPvPAFK(WorldPacket& recvData);
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h
index bed09e8e372..39d3724835c 100755
--- a/src/server/shared/Packets/ByteBuffer.h
+++ b/src/server/shared/Packets/ByteBuffer.h
@@ -191,7 +191,9 @@ class ByteBuffer
/**
* @name PutBits
- * @brief Places specified amount of bits of value at specified position in packet
+ * @brief Places specified amount of bits of value at specified position in packet.
+ * To ensure all bits are correctly written, only call this method after
+ * bit flush has been performed
* @param pos Position to place the value at, in bits. The entire value must fit in the packet
* It is advised to obtain the position using bitwpos() function.
@@ -201,8 +203,11 @@ class ByteBuffer
*/
template <typename T> void PutBits(size_t pos, T value, uint32 bitCount)
{
+ if (!bitCount)
+ throw ByteBufferSourceException((pos + bitCount) / 8, , size(), 0);
+
if (pos + bitCount > size() * 8)
- throw ByteBufferPositionException(false, (pos + bitCount) / 8, size());
+ throw ByteBufferPositionException(false, (pos + bitCount) / 8, size(), (bitCount - 1) / 8 + 1);
for (int32 i = 0; i < bitCount; ++i)
{