Core/Packets: converted SMSG_START_TIMER to packet class

This commit is contained in:
Ovahlord committed 2020-04-28 18:05:06 +02:00
1 parent 2edba50bcd
commit 54d0170235
3 files changed
+32 -10

No files matched your search

+11 -10
View File
@@ -468,14 +468,14 @@ inline void Battleground::_ProcessJoin(uint32 diff)
{
uint32 countdownMaxForBGType = isArena() ? ARENA_COUNTDOWN_MAX : BATTLEGROUND_COUNTDOWN_MAX;
WorldPacket data(SMSG_START_TIMER, 4+4+4);
data << uint32(0); // unk
data << uint32(countdownMaxForBGType - (GetElapsedTime() / 1000));
data << uint32(countdownMaxForBGType);
WorldPackets::Misc::StartTimer packet;
packet.Type = 0;
packet.TimeLeft = countdownMaxForBGType - (GetElapsedTime() / IN_MILLISECONDS);
packet.TotalTime = countdownMaxForBGType;
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(itr->first))
player->SendDirectMessage(&data);
player->SendDirectMessage(packet.Write());
m_CountdownTimer = 0;
}
@@ -1139,11 +1139,12 @@ void Battleground::AddPlayer(Player* player)
player->CastSpell(player, SPELL_PREPARATION, true); // reduces all mana cost of spells.
int32 countdownMaxForBGType = isArena() ? ARENA_COUNTDOWN_MAX : BATTLEGROUND_COUNTDOWN_MAX;
WorldPacket data(SMSG_START_TIMER, 4+4+4);
data << uint32(0); // unk
data << uint32(countdownMaxForBGType - (GetElapsedTime() / 1000));
data << uint32(countdownMaxForBGType);
player->SendDirectMessage(&data);
WorldPackets::Misc::StartTimer packet;
packet.Type = 0;
packet.TimeLeft = countdownMaxForBGType - (GetElapsedTime() / IN_MILLISECONDS);
packet.TotalTime = countdownMaxForBGType;
player->SendDirectMessage(packet.Write());
}
}
@@ -232,3 +232,12 @@ WorldPacket const* WorldPackets::Misc::UnitHealthFrequent::Write()
return &_worldPacket;
}
WorldPacket const* WorldPackets::Misc::StartTimer::Write()
{
_worldPacket << uint32(Type);
_worldPacket << uint32(TimeLeft);
_worldPacket << uint32(TotalTime);
return &_worldPacket;
}
@@ -281,6 +281,18 @@ namespace WorldPackets
ObjectGuid UnitGUID;
int32 Health = 0;
};
class StartTimer final : public ServerPacket
{
public:
StartTimer() : ServerPacket(SMSG_START_TIMER, 12) { }
WorldPacket const* Write() override;
uint32 Type = 0;
int32 TimeLeft = 0;
int32 TotalTime = 0;
};
}
}