Core/Packets: converted SMSG_RAID_INSTANCE_MESSAGE, SMSG_PENDING_RAID_LOCK, SMSG_INSTANCE_SAVE_CREATED and SMSG_TRANSFER_ABORTED to packet class

This commit is contained in:
Ovahlord
2021-01-10 11:55:10 +01:00
parent 0e09bdc6c5
commit f9f69bb0fe
9 changed files with 136 additions and 27 deletions

View File

@@ -18923,6 +18923,20 @@ InstancePlayerBind* Player::GetBoundInstance(uint32 mapid, Difficulty difficulty
return nullptr;
}
InstancePlayerBind const* Player::GetBoundInstance(uint32 mapid, Difficulty difficulty, bool withExpired) const
{
// some instances only have one difficulty
MapDifficulty const* mapDiff = sDBCManager.GetDownscaledMapDifficultyData(mapid, difficulty);
if (!mapDiff)
return nullptr;
BoundInstancesMap::const_iterator itr = m_boundInstances[difficulty].find(mapid);
if (itr != m_boundInstances[difficulty].end())
if (itr->second.extendState || withExpired)
return &itr->second;
return nullptr;
}
InstanceSave* Player::GetInstanceSave(uint32 mapid, bool raid)
{
InstancePlayerBind* pBind = GetBoundInstance(mapid, GetDifficulty(raid));
@@ -23520,11 +23534,11 @@ void Player::SendUpdateToOutOfRangeGroupMembers()
void Player::SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 arg) const
{
WorldPacket data(SMSG_TRANSFER_ABORTED, 4+2);
data << uint32(mapid);
data << uint8(reason); // transfer abort reason
data << uint8(arg);
SendDirectMessage(&data);
WorldPackets::Movement::TransferAborted packet;
packet.MapID = mapid;
packet.TransfertAbort = reason; // transfer abort reason
packet.Arg = arg;
SendDirectMessage(packet.Write());
}
void Player::SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool welcome) const
@@ -23542,17 +23556,17 @@ void Player::SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint3
else
type = RAID_INSTANCE_WARNING_MIN_SOON;
WorldPacket data(SMSG_RAID_INSTANCE_MESSAGE, 4+4+4+4);
data << uint32(type);
data << uint32(mapid);
data << uint32(difficulty); // difficulty
data << uint32(time);
if (type == RAID_INSTANCE_WELCOME)
{
data << uint8(0); // is locked
data << uint8(0); // is extended, ignored if prev field is 0
}
SendDirectMessage(&data);
WorldPackets::Instance::RaidInstanceMessage raidInstanceMessage;
raidInstanceMessage.Type = type;
raidInstanceMessage.MapID = mapid;
raidInstanceMessage.Difficulty = difficulty;
raidInstanceMessage.TimeLeft = time;
if (InstancePlayerBind const* bind = GetBoundInstance(mapid, difficulty))
raidInstanceMessage.Locked = bind->perm;
else
raidInstanceMessage.Locked = false;
raidInstanceMessage.Extended = false;
SendDirectMessage(raidInstanceMessage.Write());
}
void Player::ApplyEquipCooldown(Item* pItem)

View File

@@ -2249,6 +2249,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
// permanent binds and solo binds by difficulty
BoundInstancesMap m_boundInstances[MAX_DIFFICULTY];
InstancePlayerBind* GetBoundInstance(uint32 mapid, Difficulty difficulty, bool withExpired = false);
InstancePlayerBind const* GetBoundInstance(uint32 mapid, Difficulty difficulty, bool withExpired = false) const;
BoundInstancesMap& GetBoundInstances(Difficulty difficulty) { return m_boundInstances[difficulty]; }
InstanceSave* GetInstanceSave(uint32 mapid, bool raid);
void UnbindInstance(uint32 mapid, Difficulty difficulty, bool unload = false);

View File

@@ -28,6 +28,7 @@
#include "GridStates.h"
#include "Group.h"
#include "InstanceScript.h"
#include "InstancePackets.h"
#include "Log.h"
#include "MapInstanced.h"
#include "MapManager.h"
@@ -3965,12 +3966,12 @@ bool InstanceMap::AddPlayerToMap(Player* player)
// players also become permanently bound when they enter
if (groupBind->perm)
{
WorldPacket data(SMSG_INSTANCE_LOCK_WARNING_QUERY, 10);
data << uint32(60000);
data << uint32(i_data ? i_data->GetCompletedEncounterMask() : 0);
data << uint8(0);
data << uint8(0); // events it throws: 1 : INSTANCE_LOCK_WARNING 0 : INSTANCE_LOCK_STOP / INSTANCE_LOCK_START
player->SendDirectMessage(&data);
WorldPackets::Instance::PendingRaidLock pendingRaidLock;
pendingRaidLock.TimeUntilLock = 60000;
pendingRaidLock.CompletedMask = i_data ? i_data->GetCompletedEncounterMask() : 0;
pendingRaidLock.Extending = false;
pendingRaidLock.WarningOnly = false; // events it throws: 1 : INSTANCE_LOCK_WARNING 0 : INSTANCE_LOCK_STOP / INSTANCE_LOCK_START
player->SendDirectMessage(pendingRaidLock.Write());
player->SetPendingBind(mapSave->GetInstanceId(), 60000);
}
}
@@ -4162,9 +4163,9 @@ void InstanceMap::PermBindAllPlayers()
else
{
player->BindToInstance(save, true);
WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4);
data << uint32(0);
player->SendDirectMessage(&data);
WorldPackets::Instance::InstanceSaveCreated data;
data.Gm = player->IsGameMaster();
player->SendDirectMessage(data.Write());
player->GetSession()->SendCalendarRaidLockout(save, true);
// if group leader is in instance, group also gets bound

View File

@@ -16,6 +16,7 @@
*/
#include "InstancePackets.h"
#include "Player.h"
WorldPacket const* WorldPackets::Instance::UpdateLastInstance::Write()
{
@@ -54,3 +55,36 @@ WorldPacket const* WorldPackets::Instance::InstanceInfo::Write()
return &_worldPacket;
}
WorldPacket const* WorldPackets::Instance::RaidInstanceMessage::Write()
{
_worldPacket << int32(Type);
_worldPacket << int32(MapID);
_worldPacket << int32(Difficulty);
_worldPacket << int32(TimeLeft);
if (Type == RAID_INSTANCE_WELCOME)
{
_worldPacket << bool(Extended);
_worldPacket << bool(Locked);
}
return &_worldPacket;
}
WorldPacket const* WorldPackets::Instance::PendingRaidLock::Write()
{
_worldPacket << int32(TimeUntilLock);
_worldPacket << uint32(CompletedMask);
_worldPacket << bool(Extending);
_worldPacket << bool(WarningOnly);
return &_worldPacket;
}
WorldPacket const* WorldPackets::Instance::InstanceSaveCreated::Write()
{
_worldPacket << uint32(Gm);
return &_worldPacket;
}

View File

@@ -67,6 +67,44 @@ namespace WorldPackets
std::vector<InstanceLock> LockList;
};
class RaidInstanceMessage final : public ServerPacket
{
public:
RaidInstanceMessage() : ServerPacket(SMSG_RAID_INSTANCE_MESSAGE, 1 + 4 + 4 + 4 + 1) { }
WorldPacket const* Write() override;
bool Locked = false;
bool Extended = false;
uint8 Type = 0;
uint32 MapID = 0;
uint32 Difficulty = 0;
int32 TimeLeft = 0;
};
class PendingRaidLock final : public ServerPacket
{
public:
PendingRaidLock() : ServerPacket(SMSG_PENDING_RAID_LOCK, 4 + 4 + 1 + 1) { }
WorldPacket const* Write() override;
int32 TimeUntilLock = 0;
uint32 CompletedMask = 0;
bool Extending = false;
bool WarningOnly = false;
};
class InstanceSaveCreated final : public ServerPacket
{
public:
InstanceSaveCreated() : ServerPacket(SMSG_INSTANCE_SAVE_CREATED, 4) { }
WorldPacket const* Write() override;
bool Gm = false;
};
}
}

View File

@@ -483,6 +483,15 @@ WorldPacket const* WorldPackets::Movement::FlightSplineSync::Write()
return &_worldPacket;
}
WorldPacket const* WorldPackets::Movement::TransferAborted::Write()
{
_worldPacket << uint32(MapID);
_worldPacket << uint8(TransfertAbort);
_worldPacket << uint8(Arg);
return &_worldPacket;
}
ByteBuffer& WorldPackets::operator<<(ByteBuffer& data, Movement::MovementSpline const& movementSpline)
{
data << int8(movementSpline.Face);

View File

@@ -236,6 +236,18 @@ namespace WorldPackets
ObjectGuid Guid;
float SplineDist = 0.0f;
};
class TransferAborted final : public ServerPacket
{
public:
TransferAborted() : ServerPacket(SMSG_TRANSFER_ABORTED, 4 + 1 + 1) { }
WorldPacket const* Write() override;
uint32 MapID = 0;
uint8 TransfertAbort;
uint8 Arg = 0;
};
}
ByteBuffer& operator<<(ByteBuffer& data, Movement::MovementSpline const& movementSpline);

View File

@@ -942,7 +942,6 @@ void OpcodeTable::Initialize()
DEFINE_SERVER_OPCODE_HANDLER(SMSG_INSPECT_RESULTS_UPDATE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_INSPECT_TALENT, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_INSTANCE_INFO, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_INSTANCE_LOCK_WARNING_QUERY, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_INSTANCE_RESET, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_INSTANCE_RESET_FAILED, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_INSTANCE_SAVE_CREATED, STATUS_NEVER, CONNECTION_TYPE_REALM);
@@ -1088,6 +1087,7 @@ void OpcodeTable::Initialize()
DEFINE_SERVER_OPCODE_HANDLER(SMSG_PARTY_MEMBER_STATE, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_PARTY_MEMBER_FULL_STATE, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_PAUSE_MIRROR_TIMER, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_PENDING_RAID_LOCK, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_PERIODICAURALOG, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_PETGODMODE, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_PETITION_ALREADY_SIGNED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);

View File

@@ -887,7 +887,6 @@ enum OpcodeServer
SMSG_INSPECT_RESULTS_UPDATE = 0x0C14,
SMSG_INSPECT_TALENT = 0x4014,
SMSG_INSTANCE_INFO = 0x6626,
SMSG_INSTANCE_LOCK_WARNING_QUERY = 0x4F17,
SMSG_INSTANCE_RESET = 0x6F05,
SMSG_INSTANCE_RESET_FAILED = 0x4725,
SMSG_INSTANCE_SAVE_CREATED = 0x0124,
@@ -1044,6 +1043,7 @@ enum OpcodeServer
SMSG_PARTY_MEMBER_STATE = 0x2104,
SMSG_PARTY_MEMBER_FULL_STATE = 0x0215,
SMSG_PAUSE_MIRROR_TIMER = 0x4015,
SMSG_PENDING_RAID_LOCK = 0x4F17,
SMSG_PERIODICAURALOG = 0x0416,
SMSG_PETGODMODE = 0x2E36,
SMSG_PETITION_ALREADY_SIGNED = 0x5DA3,