Core/Packets Fix SMSG_START_TIMER struct & update to new packet system (#22614)

This commit is contained in:
Traesh
2020-04-27 21:31:27 +02:00
committed by GitHub
parent ec87d048b4
commit 98b1c02a1c
4 changed files with 34 additions and 12 deletions

View File

@@ -411,16 +411,16 @@ inline void Battleground::_ProcessJoin(uint32 diff)
// Send packet every 10 seconds until the 2nd field reach 0
if (m_CountdownTimer >= 10000)
{
uint32 countdownMaxForBGType = isArena() ? ARENA_COUNTDOWN_MAX : BATTLEGROUND_COUNTDOWN_MAX;
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);
WorldPackets::Misc::StartTimer startTimer;
startTimer.Type = 0;
startTimer.TimeLeft = countdownMaxForBGType - (GetElapsedTime() / 1000);
startTimer.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(startTimer.Write());
m_CountdownTimer = 0;
}
@@ -1088,11 +1088,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 startTimer;
startTimer.Type = 0;
startTimer.TimeLeft = countdownMaxForBGType - (GetElapsedTime() / 1000);
startTimer.TotalTime = countdownMaxForBGType;
player->SendDirectMessage(startTimer.Write());
}
}

View File

@@ -699,3 +699,12 @@ void WorldPackets::Misc::CloseInteraction::Read()
{
_worldPacket >> SourceGuid;
}
WorldPacket const* WorldPackets::Misc::StartTimer::Write()
{
_worldPacket << int32(TimeLeft);
_worldPacket << int32(TotalTime);
_worldPacket << int32(Type);
return &_worldPacket;
}

View File

@@ -902,6 +902,18 @@ namespace WorldPackets
ObjectGuid SourceGuid;
};
class StartTimer final : public ServerPacket
{
public:
StartTimer() : ServerPacket(SMSG_START_TIMER, 12) { }
WorldPacket const* Write() override;
int32 Type = 0;
int32 TimeLeft = 0;
int32 TotalTime = 0;
};
}
}

View File

@@ -1821,7 +1821,7 @@ void OpcodeTable::Initialize()
DEFINE_SERVER_OPCODE_HANDLER(SMSG_START_ELAPSED_TIMERS, STATUS_UNHANDLED, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_START_LOOT_ROLL, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_START_MIRROR_TIMER, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_START_TIMER, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_START_TIMER, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_STOP_ELAPSED_TIMER, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_STOP_MIRROR_TIMER, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_STOP_SPEAKERBOT_SOUND, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);