mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-29 16:43:47 +00:00
refactor(Core/Packet): Character packets (#9546)
* Character * Update CharacterHandler.cpp
This commit is contained in:
committed by
GitHub
parent
43ea4aa2df
commit
93322bcb4d
@@ -21,6 +21,7 @@
|
||||
#include "Battleground.h"
|
||||
#include "CalendarMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "CharacterPackets.h"
|
||||
#include "Chat.h"
|
||||
#include "Common.h"
|
||||
#include "DatabaseEnv.h"
|
||||
@@ -1199,9 +1200,9 @@ void WorldSession::HandlePlayerLoginToCharInWorld(Player* pCurrChar)
|
||||
|
||||
_mask[i] = uint32(1) << (eff - (32 * i));
|
||||
int32 val = 0;
|
||||
for (SpellModList::const_iterator itr = spellMods.begin(); itr != spellMods.end(); ++itr)
|
||||
if ((*itr)->type == modType && (*itr)->mask & _mask)
|
||||
val += (*itr)->value;
|
||||
for (auto const& spellMod : spellMods)
|
||||
if (spellMod->type == modType && spellMod->mask & _mask)
|
||||
val += spellMod->value;
|
||||
|
||||
if (val == 0)
|
||||
continue;
|
||||
@@ -1315,18 +1316,20 @@ void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket& recvData)
|
||||
_player->GetReputationMgr().SetInactive(replistid, inactive);
|
||||
}
|
||||
|
||||
void WorldSession::HandleShowingHelmOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleShowingHelmOpcode(WorldPackets::Character::ShowingHelm& packet)
|
||||
{
|
||||
LOG_DEBUG("network.opcode", "CMSG_SHOWING_HELM for %s", _player->GetName().c_str());
|
||||
recvData.read_skip<uint8>(); // unknown, bool?
|
||||
_player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM);
|
||||
if (packet.ShowHelm)
|
||||
_player->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM);
|
||||
else
|
||||
_player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM);
|
||||
}
|
||||
|
||||
void WorldSession::HandleShowingCloakOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleShowingCloakOpcode(WorldPackets::Character::ShowingCloak& packet)
|
||||
{
|
||||
LOG_DEBUG("network.opcode", "CMSG_SHOWING_CLOAK for %s", _player->GetName().c_str());
|
||||
recvData.read_skip<uint8>(); // unknown, bool?
|
||||
_player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK);
|
||||
if (packet.ShowCloak)
|
||||
_player->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK);
|
||||
else
|
||||
_player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK);
|
||||
}
|
||||
|
||||
void WorldSession::HandleCharRenameOpcode(WorldPacket& recvData)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user