refactor(Core/Packet): Character packets (#9546)

* Character

* Update CharacterHandler.cpp
This commit is contained in:
IntelligentQuantum
2022-01-06 15:25:00 +03:30
committed by GitHub
parent 43ea4aa2df
commit 93322bcb4d
8 changed files with 228 additions and 51 deletions

View File

@@ -19,6 +19,7 @@
#include "BattlefieldMgr.h"
#include "Battleground.h"
#include "BattlegroundMgr.h"
#include "CharacterPackets.h"
#include "Chat.h"
#include "Common.h"
#include "CreatureAI.h"
@@ -406,7 +407,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recvData)
FMT_LOG_DEBUG("network", "WORLD: Send SMSG_WHO Message");
}
void WorldSession::HandleLogoutRequestOpcode(WorldPacket& /*recv_data*/)
void WorldSession::HandleLogoutRequestOpcode(WorldPackets::Character::LogoutRequest& /*logoutRequest*/)
{
LOG_DEBUG("network", "WORLD: Recvd CMSG_LOGOUT_REQUEST Message, security - %u", GetSecurity());
@@ -433,14 +434,14 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket& /*recv_data*/)
else if (preventAfkSanctuaryLogout || preventAfkLogout || GetPlayer()->duel || GetPlayer()->HasAura(9454)) // is dueling or frozen by GM via freeze command
reason = 2; // FIXME - Need the correct value
WorldPacket data(SMSG_LOGOUT_RESPONSE, 1 + 4);
data << uint32(reason);
data << uint8(instantLogout);
SendPacket(&data);
WorldPackets::Character::LogoutResponse logoutResponse;
logoutResponse.LogoutResult = reason;
logoutResponse.Instant = instantLogout;
SendPacket(logoutResponse.Write());
if (reason)
{
LogoutRequest(0);
SetLogoutStartTime(0);
return;
}
@@ -459,35 +460,27 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket& /*recv_data*/)
GetPlayer()->SetStandState(UNIT_STAND_STATE_SIT);
}
WorldPacket data2(SMSG_FORCE_MOVE_ROOT, (8 + 4)); // guess size
data2 << GetPlayer()->GetPackGUID();
data2 << (uint32)2;
SendPacket(&data2);
GetPlayer()->SetRooted(true);
GetPlayer()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
}
LogoutRequest(time(nullptr));
SetLogoutStartTime(time(nullptr));
}
void WorldSession::HandlePlayerLogoutOpcode(WorldPacket& /*recv_data*/)
void WorldSession::HandlePlayerLogoutOpcode(WorldPackets::Character::PlayerLogout& /*playerLogout*/)
{
LOG_DEBUG("network", "WORLD: Recvd CMSG_PLAYER_LOGOUT Message");
}
void WorldSession::HandleLogoutCancelOpcode(WorldPacket& /*recv_data*/)
void WorldSession::HandleLogoutCancelOpcode(WorldPackets::Character::LogoutCancel& /*logoutCancel*/)
{
LogoutRequest(0);
SetLogoutStartTime(0);
WorldPacket data(SMSG_LOGOUT_CANCEL_ACK, 0);
SendPacket(&data);
SendPacket(WorldPackets::Character::LogoutCancelAck().Write());
// not remove flags if can't free move - its not set in Logout request code.
if (GetPlayer()->CanFreeMove())
{
data.Initialize(SMSG_FORCE_MOVE_UNROOT, 9 + 4);
data << GetPlayer()->GetPackGUID();
data << uint32(0);
SendPacket(&data);
GetPlayer()->SetRooted(false);
GetPlayer()->SetStandState(UNIT_STAND_STATE_STAND);
GetPlayer()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
@@ -1000,16 +993,13 @@ void WorldSession::HandleSetActionBarToggles(WorldPacket& recv_data)
GetPlayer()->SetByteValue(PLAYER_FIELD_BYTES, 2, ActionBar);
}
void WorldSession::HandlePlayedTime(WorldPacket& recv_data)
void WorldSession::HandlePlayedTime(WorldPackets::Character::PlayedTimeClient& packet)
{
uint8 unk1;
recv_data >> unk1; // 0 or 1 expected
WorldPacket data(SMSG_PLAYED_TIME, 4 + 4 + 1);
data << uint32(_player->GetTotalPlayedTime());
data << uint32(_player->GetLevelPlayedTime());
data << uint8(unk1); // 0 - will not show in chat frame
SendPacket(&data);
WorldPackets::Character::PlayedTime playedTime;
playedTime.TotalTime = _player->GetTotalPlayedTime();
playedTime.LevelTime = _player->GetLevelPlayedTime();
playedTime.TriggerScriptEvent = packet.TriggerScriptEvent; // 0-1 - will not show in chat frame
SendPacket(playedTime.Write());
}
void WorldSession::HandleInspectOpcode(WorldPacket& recv_data)