refactor(Core/Packets): Rewrite various instance packets to modern class. (#22762)
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include "GossipDef.h"
|
||||
#include "Group.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "InstancePackets.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "Language.h"
|
||||
#include "Log.h"
|
||||
@@ -1240,7 +1241,7 @@ void WorldSession::HandleSetTitleOpcode(WorldPacket& recv_data)
|
||||
GetPlayer()->SetUInt32Value(PLAYER_CHOSEN_TITLE, title);
|
||||
}
|
||||
|
||||
void WorldSession::HandleResetInstancesOpcode(WorldPacket& /*recv_data*/)
|
||||
void WorldSession::HandleResetInstancesOpcode(WorldPackets::Instance::ResetInstances& /*packet*/)
|
||||
{
|
||||
LOG_DEBUG("network", "WORLD: CMSG_RESET_INSTANCES");
|
||||
|
||||
@@ -1253,17 +1254,14 @@ void WorldSession::HandleResetInstancesOpcode(WorldPacket& /*recv_data*/)
|
||||
Player::ResetInstances(_player->GetGUID(), INSTANCE_RESET_ALL, false);
|
||||
}
|
||||
|
||||
void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recv_data)
|
||||
void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPackets::Instance::SetDungeonDifficultyClient& packet)
|
||||
{
|
||||
LOG_DEBUG("network", "MSG_SET_DUNGEON_DIFFICULTY");
|
||||
|
||||
uint32 mode;
|
||||
recv_data >> mode;
|
||||
|
||||
if (mode >= MAX_DUNGEON_DIFFICULTY)
|
||||
if (packet.Mode >= MAX_DUNGEON_DIFFICULTY)
|
||||
return;
|
||||
|
||||
if (Difficulty(mode) == _player->GetDungeonDifficulty())
|
||||
if (Difficulty(packet.Mode) == _player->GetDungeonDifficulty())
|
||||
return;
|
||||
|
||||
Group* group = _player->GetGroup();
|
||||
@@ -1291,7 +1289,7 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recv_data)
|
||||
}
|
||||
|
||||
group->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY, false, _player);
|
||||
group->SetDungeonDifficulty(Difficulty(mode));
|
||||
group->SetDungeonDifficulty(Difficulty(packet.Mode));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1302,21 +1300,18 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recv_data)
|
||||
return;
|
||||
}
|
||||
Player::ResetInstances(_player->GetGUID(), INSTANCE_RESET_CHANGE_DIFFICULTY, false);
|
||||
_player->SetDungeonDifficulty(Difficulty(mode));
|
||||
_player->SetDungeonDifficulty(Difficulty(packet.Mode));
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recv_data)
|
||||
void WorldSession::HandleSetRaidDifficultyOpcode(WorldPackets::Instance::SetRaidDifficultyClient& packet)
|
||||
{
|
||||
LOG_DEBUG("network", "MSG_SET_RAID_DIFFICULTY");
|
||||
|
||||
uint32 mode;
|
||||
recv_data >> mode;
|
||||
|
||||
if (mode >= MAX_RAID_DIFFICULTY)
|
||||
if (packet.Mode >= MAX_RAID_DIFFICULTY)
|
||||
return;
|
||||
|
||||
if (Difficulty(mode) == _player->GetRaidDifficulty())
|
||||
if (Difficulty(packet.Mode) == _player->GetRaidDifficulty())
|
||||
return;
|
||||
|
||||
Group* group = _player->GetGroup();
|
||||
@@ -1357,7 +1352,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recv_data)
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsSharedDifficultyMap(groupGuy->GetMap()->GetId()) && (uint32(mode % 2) == uint32(_player->GetRaidDifficulty() % 2)) && group->isRaidGroup())
|
||||
if (IsSharedDifficultyMap(groupGuy->GetMap()->GetId()) && (uint32(packet.Mode % 2) == uint32(_player->GetRaidDifficulty() % 2)) && group->isRaidGroup())
|
||||
{
|
||||
if (!currMap)
|
||||
currMap = groupGuy->GetMap();
|
||||
@@ -1371,7 +1366,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recv_data)
|
||||
|
||||
if (!groupGuy->IsAlive() || groupGuy->IsInCombat() || groupGuy->GetVictim() || groupGuy->m_mover != groupGuy || groupGuy->IsNonMeleeSpellCast(true) || (!groupGuy->GetMotionMaster()->empty() && groupGuy->GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE)
|
||||
|| !groupGuy->movespline->Finalized() || !groupGuy->GetMap()->ToInstanceMap() || !groupGuy->GetMap()->ToInstanceMap()->GetInstanceScript() || groupGuy->GetMap()->ToInstanceMap()->GetInstanceScript()->IsEncounterInProgress()
|
||||
|| !groupGuy->Satisfy(sObjectMgr->GetAccessRequirement(groupGuy->GetMap()->GetId(), Difficulty(mode)), groupGuy->GetMap()->GetId(), false))
|
||||
|| !groupGuy->Satisfy(sObjectMgr->GetAccessRequirement(groupGuy->GetMap()->GetId(), Difficulty(packet.Mode)), groupGuy->GetMap()->GetId(), false))
|
||||
{
|
||||
_player->SendRaidDifficulty(group != nullptr);
|
||||
return;
|
||||
@@ -1443,12 +1438,12 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recv_data)
|
||||
|
||||
if (!anyoneInside) // pussywizard: don't reset if changing ICC/RS difficulty while inside
|
||||
group->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY, true, _player);
|
||||
group->SetRaidDifficulty(Difficulty(mode));
|
||||
group->SetRaidDifficulty(Difficulty(packet.Mode));
|
||||
group->SetDifficultyChangePrevention(DIFFICULTY_PREVENTION_CHANGE_RECENTLY_CHANGED);
|
||||
|
||||
for (std::map<Player*, Position>::iterator itr = playerTeleport.begin(); itr != playerTeleport.end(); ++itr)
|
||||
{
|
||||
itr->first->SetRaidDifficulty(Difficulty(mode)); // needed for teleport not to fail
|
||||
itr->first->SetRaidDifficulty(Difficulty(packet.Mode)); // needed for teleport not to fail
|
||||
if (!itr->first->TeleportTo(*(foundMaps.begin()), itr->second.GetPositionX(), itr->second.GetPositionY(), itr->second.GetPositionZ(), itr->second.GetOrientation()))
|
||||
itr->first->GetSession()->KickPlayer("HandleSetRaidDifficultyOpcode 2");
|
||||
}
|
||||
@@ -1462,7 +1457,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recv_data)
|
||||
return;
|
||||
}
|
||||
Player::ResetInstances(_player->GetGUID(), INSTANCE_RESET_CHANGE_DIFFICULTY, true);
|
||||
_player->SetRaidDifficulty(Difficulty(mode));
|
||||
_player->SetRaidDifficulty(Difficulty(packet.Mode));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1698,11 +1693,8 @@ void WorldSession::HandleHearthAndResurrect(WorldPacket& /*recv_data*/)
|
||||
_player->TeleportTo(_player->m_homebindMapId, _player->m_homebindX, _player->m_homebindY, _player->m_homebindZ, _player->GetOrientation());
|
||||
}
|
||||
|
||||
void WorldSession::HandleInstanceLockResponse(WorldPacket& recvPacket)
|
||||
void WorldSession::HandleInstanceLockResponse(WorldPackets::Instance::InstanceLockResponse& packet)
|
||||
{
|
||||
uint8 accept;
|
||||
recvPacket >> accept;
|
||||
|
||||
if (!_player->HasPendingBind() || _player->GetPendingBind() != _player->GetInstanceId() || (_player->GetGroup() && _player->GetGroup()->isLFGGroup() && _player->GetGroup()->IsLfgRandomInstance()))
|
||||
{
|
||||
LOG_DEBUG("network.opcode", "InstanceLockResponse: Player {} ({}) tried to bind himself/teleport to graveyard without a pending bind!",
|
||||
@@ -1710,7 +1702,7 @@ void WorldSession::HandleInstanceLockResponse(WorldPacket& recvPacket)
|
||||
return;
|
||||
}
|
||||
|
||||
if (accept)
|
||||
if (packet.Accept)
|
||||
_player->BindToInstance();
|
||||
else
|
||||
_player->RepopAtGraveyard();
|
||||
|
||||
Reference in New Issue
Block a user