mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-15 10:00:28 +00:00
refactor(Core/Packets): Rewrite MSG_RANDOM_ROLL to new packet class (#10590)
* refactor(Core/Packets): Rewrite MSG_RANDOM_ROLL
* cherry-pick commit (c0f516caee)
Co-Authored-By: ForesterDev <11771800+ForesterDev@users.noreply.github.com>
Co-Authored-By: DJScias <439655+DJScias@users.noreply.github.com>
* handle crash check in DoRandomRoll()
* Update MiscPackets.h
* Update Player.h
Co-authored-by: ForesterDev <11771800+ForesterDev@users.noreply.github.com>
Co-authored-by: DJScias <439655+DJScias@users.noreply.github.com>
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "Log.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "MiscPackets.h"
|
||||
#include "Pet.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
@@ -560,31 +561,13 @@ void WorldSession::HandleMinimapPingOpcode(WorldPacket& recvData)
|
||||
GetPlayer()->GetGroup()->BroadcastPacket(&data, true, -1, GetPlayer()->GetGUID());
|
||||
}
|
||||
|
||||
void WorldSession::HandleRandomRollOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleRandomRollOpcode(WorldPackets::Misc::RandomRollClient& packet)
|
||||
{
|
||||
LOG_DEBUG("network", "WORLD: Received MSG_RANDOM_ROLL");
|
||||
uint32 minimum, maximum;
|
||||
minimum = packet.Min;
|
||||
maximum = packet.Max;
|
||||
|
||||
uint32 minimum, maximum, roll;
|
||||
recvData >> minimum;
|
||||
recvData >> maximum;
|
||||
|
||||
/** error handling **/
|
||||
if (minimum > maximum || maximum > 10000) // < 32768 for urand call
|
||||
return;
|
||||
/********************/
|
||||
|
||||
// everything's fine, do it
|
||||
roll = urand(minimum, maximum);
|
||||
|
||||
WorldPacket data(MSG_RANDOM_ROLL, 4 + 4 + 4 + 8);
|
||||
data << uint32(minimum);
|
||||
data << uint32(maximum);
|
||||
data << uint32(roll);
|
||||
data << GetPlayer()->GetGUID();
|
||||
if (GetPlayer()->GetGroup())
|
||||
GetPlayer()->GetGroup()->BroadcastPacket(&data, false);
|
||||
else
|
||||
SendPacket(&data);
|
||||
GetPlayer()->DoRandomRoll(minimum, maximum);
|
||||
}
|
||||
|
||||
void WorldSession::HandleRaidTargetUpdateOpcode(WorldPacket& recvData)
|
||||
|
||||
Reference in New Issue
Block a user