Skip to content

Commit 69f3acf

Browse files
joschiwaldShauren
authored andcommitted
Core/PacketIO: Reduce differences between branches
(cherry picked from commit 2fee7d1)
1 parent 87d5571 commit 69f3acf

7 files changed

Lines changed: 29 additions & 27 deletions

File tree

src/server/game/Battlefield/Battlefield.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -452,19 +452,19 @@ void Battlefield::SendInitWorldStatesTo(Player* player)
452452
{
453453
WorldPackets::WorldState::InitWorldStates packet;
454454
packet.MapID = m_MapId;
455-
packet.ZoneID = m_ZoneId;
456-
packet.AreaID = player->GetAreaId();
455+
packet.AreaID = m_ZoneId;
456+
packet.SubareaID = player->GetAreaId();
457457
FillInitialWorldStates(packet);
458458

459459
player->SendDirectMessage(packet.Write());
460460
}
461461

462-
void Battlefield::SendUpdateWorldState(uint32 field, uint32 value)
462+
void Battlefield::SendUpdateWorldState(uint32 variable, uint32 value)
463463
{
464-
for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
465-
for (auto itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
466-
if (Player* player = ObjectAccessor::FindPlayer(*itr))
467-
player->SendUpdateWorldState(field, value);
464+
WorldPackets::WorldState::UpdateWorldState worldstate;
465+
worldstate.VariableID = variable;
466+
worldstate.Value = value;
467+
BroadcastPacketToZone(worldstate.Write());
468468
}
469469

470470
void Battlefield::RegisterZone(uint32 zoneId)

src/server/game/Battlefield/Battlefield.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ class TC_GAME_API Battlefield : public ZoneScript
231231
void SendInitWorldStatesTo(Player* player);
232232

233233
/// Update data of a worldstate to all players present in zone
234-
void SendUpdateWorldState(uint32 field, uint32 value);
234+
void SendUpdateWorldState(uint32 variable, uint32 value);
235235

236236
/**
237237
* \brief Called every time for update bf data and time

src/server/game/Battlegrounds/Battleground.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,14 +574,14 @@ Position const* Battleground::GetTeamStartPosition(TeamId teamId) const
574574
return &StartPosition[teamId];
575575
}
576576

577-
void Battleground::SendPacketToAll(WorldPacket const* packet)
577+
void Battleground::SendPacketToAll(WorldPacket const* packet) const
578578
{
579579
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
580580
if (Player* player = _GetPlayer(itr, "SendPacketToAll"))
581581
player->SendDirectMessage(packet);
582582
}
583583

584-
void Battleground::SendPacketToTeam(uint32 TeamID, WorldPacket const* packet, Player* sender, bool self)
584+
void Battleground::SendPacketToTeam(uint32 TeamID, WorldPacket const* packet, Player* sender, bool self) const
585585
{
586586
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
587587
{

src/server/game/Battlegrounds/Battleground.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ class TC_GAME_API Battleground
377377
// Packet Transfer
378378
// method that should fill worldpacket with actual world states (not yet implemented for all battlegrounds!)
379379
virtual void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& /*packet*/) { }
380-
void SendPacketToTeam(uint32 TeamID, WorldPacket const* packet, Player* sender = nullptr, bool self = true);
381-
void SendPacketToAll(WorldPacket const* packet);
380+
void SendPacketToTeam(uint32 TeamID, WorldPacket const* packet, Player* sender = nullptr, bool self = true) const;
381+
void SendPacketToAll(WorldPacket const* packet) const;
382382

383383
void SendChatMessage(Creature* source, uint8 textId, WorldObject* target = nullptr);
384384
void SendBroadcastText(uint32 id, ChatMsg msgType, WorldObject const* target = nullptr);

src/server/game/Entities/Player/Player.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8527,8 +8527,8 @@ void Player::SendInitWorldStates(uint32 zoneId, uint32 areaId)
85278527

85288528
WorldPackets::WorldState::InitWorldStates packet;
85298529
packet.MapID = mapId;
8530-
packet.ZoneID = zoneId;
8531-
packet.AreaID = areaId;
8530+
packet.AreaID = zoneId;
8531+
packet.SubareaID = areaId;
85328532

85338533
packet.Worldstates.emplace_back(2264, 0); // SCOURGE_EVENT_WORLDSTATE_EASTERN_PLAGUELANDS
85348534
packet.Worldstates.emplace_back(2263, 0); // SCOURGE_EVENT_WORLDSTATE_TANARIS

src/server/game/Server/Packets/WorldStatePackets.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717

1818
#include "WorldStatePackets.h"
1919

20-
WorldPackets::WorldState::InitWorldStates::InitWorldStates() : ServerPacket(SMSG_INIT_WORLD_STATES, 4 + 4 + 4 + 2) { }
21-
22-
WorldPacket const* WorldPackets::WorldState::InitWorldStates::Write()
20+
namespace WorldPackets::WorldState
21+
{
22+
WorldPacket const* InitWorldStates::Write()
2323
{
2424
_worldPacket.reserve(4 + 4 + 4 + 2 + Worldstates.size() * 8);
2525

2626
_worldPacket << int32(MapID);
27-
_worldPacket << int32(ZoneID);
2827
_worldPacket << int32(AreaID);
28+
_worldPacket << int32(SubareaID);
2929

3030
_worldPacket << uint16(Worldstates.size());
3131
for (WorldStateInfo const& wsi : Worldstates)
@@ -37,10 +37,11 @@ WorldPacket const* WorldPackets::WorldState::InitWorldStates::Write()
3737
return &_worldPacket;
3838
}
3939

40-
WorldPacket const* WorldPackets::WorldState::UpdateWorldState::Write()
40+
WorldPacket const* UpdateWorldState::Write()
4141
{
4242
_worldPacket << int32(VariableID);
4343
_worldPacket << int32(Value);
4444

4545
return &_worldPacket;
4646
}
47+
}

src/server/game/Server/Packets/WorldStatePackets.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
* with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
#ifndef WorldStatePackets_h__
19-
#define WorldStatePackets_h__
18+
#ifndef TRINITYCORE_WORLD_STATE_PACKETS_H
19+
#define TRINITYCORE_WORLD_STATE_PACKETS_H
2020

2121
#include "Packet.h"
2222

@@ -29,19 +29,20 @@ namespace WorldPackets
2929
public:
3030
struct WorldStateInfo
3131
{
32-
WorldStateInfo(int32 variableID, int32 value) : VariableID(variableID), Value(value) { }
32+
WorldStateInfo(int32 variableID, int32 value)
33+
: VariableID(variableID), Value(value) { }
3334

3435
int32 VariableID;
3536
int32 Value;
3637
};
3738

38-
InitWorldStates();
39+
explicit InitWorldStates() : ServerPacket(SMSG_INIT_WORLD_STATES, 4 + 4 + 4 + 2) { }
3940

4041
WorldPacket const* Write() override;
4142

42-
int32 MapID = 0;
43-
int32 ZoneID = 0;
44-
int32 AreaID = 0;
43+
int32 AreaID = 0; ///< ZoneId
44+
int32 SubareaID = 0; ///< AreaId
45+
int32 MapID = 0; ///< MapId
4546

4647
std::vector<WorldStateInfo> Worldstates;
4748
};
@@ -59,4 +60,4 @@ namespace WorldPackets
5960
}
6061
}
6162

62-
#endif // WorldStatePackets_h__
63+
#endif // TRINITYCORE_WORLD_STATE_PACKETS_H

0 commit comments

Comments
 (0)