mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 17:54:48 +01:00
Core/PacketIO: Updated logout opcodes (#24519)
(cherry picked from commit f59a701e29)
# Conflicts:
# src/server/database/Database/Implementation/LoginDatabase.cpp
# src/server/database/Database/Implementation/LoginDatabase.h
# src/server/game/Handlers/MiscHandler.cpp
# src/server/game/Server/Packets/AuthenticationPackets.cpp
# src/server/game/Server/Packets/AuthenticationPackets.h
# src/server/game/Server/Packets/CharacterPackets.h
# src/server/game/Server/Protocol/Opcodes.cpp
# src/server/game/Server/Protocol/Opcodes.h
# src/server/game/Server/WorldSession.cpp
# src/server/game/Server/WorldSession.h
# src/server/game/Server/WorldSocket.cpp
Co-authored-by: Shauren <shauren.trinity@gmail.com>
This commit is contained in:
@@ -1788,6 +1788,8 @@ class TC_GAME_API Unit : public WorldObject
|
||||
|
||||
void ProcSkillsAndReactives(bool isVictim, Unit* procTarget, uint32 typeMask, uint32 hitMask, WeaponAttackType attType);
|
||||
|
||||
protected:
|
||||
|
||||
void SetFeared(bool apply);
|
||||
void SetConfused(bool apply);
|
||||
void SetStunned(bool apply);
|
||||
@@ -1795,6 +1797,8 @@ class TC_GAME_API Unit : public WorldObject
|
||||
|
||||
uint32 m_rootTimes;
|
||||
|
||||
private:
|
||||
|
||||
uint32 m_state; // Even derived shouldn't modify
|
||||
uint32 m_lastManaUse; // msecs
|
||||
TimeTrackerSmall m_splineSyncTimer;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "BattlefieldMgr.h"
|
||||
#include "Battleground.h"
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "CharacterPackets.h"
|
||||
#include "Chat.h"
|
||||
#include "CinematicMgr.h"
|
||||
#include "Common.h"
|
||||
@@ -352,10 +353,8 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recvData)
|
||||
TC_LOG_DEBUG("network", "WORLD: Send SMSG_WHO Message");
|
||||
}
|
||||
|
||||
void WorldSession::HandleLogoutRequestOpcode(WorldPacket& /*recvData*/)
|
||||
void WorldSession::HandleLogoutRequestOpcode(WorldPackets::Character::LogoutRequest& /*logoutRequest*/)
|
||||
{
|
||||
TC_LOG_DEBUG("network", "WORLD: Recvd CMSG_LOGOUT_REQUEST Message, security - %u", GetSecurity());
|
||||
|
||||
if (ObjectGuid lguid = GetPlayer()->GetLootGUID())
|
||||
DoLootRelease(lguid);
|
||||
|
||||
@@ -373,18 +372,18 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket& /*recvData*/)
|
||||
else if (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;
|
||||
}
|
||||
|
||||
//instant logout in taverns/cities or on taxi or for admins, gm's, mod's if its enabled in worldserver.conf
|
||||
// instant logout in taverns/cities or on taxi or for admins, gm's, mod's if its enabled in worldserver.conf
|
||||
if (instantLogout)
|
||||
{
|
||||
LogoutPlayer(true);
|
||||
@@ -396,43 +395,32 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket& /*recvData*/)
|
||||
{
|
||||
if (GetPlayer()->GetStandState() == UNIT_STAND_STATE_STAND)
|
||||
GetPlayer()->SetStandState(UNIT_STAND_STATE_SIT);
|
||||
|
||||
data.Initialize(SMSG_FORCE_MOVE_ROOT, (8+4)); // guess size
|
||||
data << GetPlayer()->GetPackGUID();
|
||||
data << (uint32)2;
|
||||
SendPacket(&data);
|
||||
GetPlayer()->SetRooted(true);
|
||||
GetPlayer()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
|
||||
}
|
||||
|
||||
LogoutRequest(GameTime::GetGameTime());
|
||||
SetLogoutStartTime(GameTime::GetGameTime());
|
||||
}
|
||||
|
||||
void WorldSession::HandlePlayerLogoutOpcode(WorldPacket& /*recvData*/)
|
||||
void WorldSession::HandlePlayerLogoutOpcode(WorldPackets::Character::PlayerLogout& /*playerLogout*/)
|
||||
{
|
||||
TC_LOG_DEBUG("network", "WORLD: Recvd CMSG_PLAYER_LOGOUT Message");
|
||||
}
|
||||
|
||||
void WorldSession::HandleLogoutCancelOpcode(WorldPacket& /*recvData*/)
|
||||
void WorldSession::HandleLogoutCancelOpcode(WorldPackets::Character::LogoutCancel& /*logoutCancel*/)
|
||||
{
|
||||
TC_LOG_DEBUG("network", "WORLD: Recvd CMSG_LOGOUT_CANCEL Message");
|
||||
|
||||
// Player have already logged out serverside, too late to cancel
|
||||
if (!GetPlayer())
|
||||
return;
|
||||
|
||||
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())
|
||||
{
|
||||
//!we can move again
|
||||
data.Initialize(SMSG_FORCE_MOVE_UNROOT, 8); // guess size
|
||||
data << GetPlayer()->GetPackGUID();
|
||||
data << uint32(0);
|
||||
SendPacket(&data);
|
||||
GetPlayer()->SetRooted(false);
|
||||
|
||||
//! Stand Up
|
||||
GetPlayer()->SetStandState(UNIT_STAND_STATE_STAND);
|
||||
|
||||
@@ -33,3 +33,10 @@ WorldPacket const* WorldPackets::Character::LoginVerifyWorld::Write()
|
||||
_worldPacket << Pos;
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Character::LogoutResponse::Write()
|
||||
{
|
||||
_worldPacket << uint32(LogoutResult);
|
||||
_worldPacket << uint8(Instant);
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,57 @@ namespace WorldPackets
|
||||
int32 MapID = -1;
|
||||
TaggedPosition<Position::XYZO> Pos;
|
||||
};
|
||||
|
||||
class LogoutRequest final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
LogoutRequest(WorldPacket&& packet) : ClientPacket(std::move(packet)) { }
|
||||
|
||||
void Read() override { }
|
||||
};
|
||||
|
||||
class LogoutResponse final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
LogoutResponse() : ServerPacket(SMSG_LOGOUT_RESPONSE, 4 + 1) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
uint32 LogoutResult = 0;
|
||||
bool Instant = false;
|
||||
};
|
||||
|
||||
class LogoutComplete final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
LogoutComplete() : ServerPacket(SMSG_LOGOUT_COMPLETE, 0) { }
|
||||
|
||||
WorldPacket const* Write() override { return &_worldPacket; }
|
||||
};
|
||||
|
||||
class LogoutCancel final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
LogoutCancel(WorldPacket&& packet) : ClientPacket(std::move(packet)) { }
|
||||
|
||||
void Read() override { }
|
||||
};
|
||||
|
||||
class LogoutCancelAck final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
LogoutCancelAck() : ServerPacket(SMSG_LOGOUT_CANCEL_ACK, 0) { }
|
||||
|
||||
WorldPacket const* Write() override { return &_worldPacket; }
|
||||
};
|
||||
|
||||
class PlayerLogout final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
PlayerLogout(WorldPacket&& packet) : ClientPacket(std::move(packet)) { }
|
||||
|
||||
void Read() override { }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "AccountMgr.h"
|
||||
#include "AddonMgr.h"
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "CharacterPackets.h"
|
||||
#include "Config.h"
|
||||
#include "Common.h"
|
||||
#include "DatabaseEnv.h"
|
||||
@@ -595,8 +596,7 @@ void WorldSession::LogoutPlayer(bool save)
|
||||
|
||||
//! Send the 'logout complete' packet to the client
|
||||
//! Client will respond by sending 3x CMSG_CANCEL_TRADE, which we currently dont handle
|
||||
WorldPacket data(SMSG_LOGOUT_COMPLETE, 0);
|
||||
SendPacket(&data);
|
||||
SendPacket(WorldPackets::Character::LogoutComplete().Write());
|
||||
TC_LOG_DEBUG("network", "SESSION: Sent SMSG_LOGOUT_COMPLETE Message");
|
||||
|
||||
//! Since each account can only have one online character at any given time, ensure all characters for active account are marked as offline
|
||||
@@ -608,7 +608,7 @@ void WorldSession::LogoutPlayer(bool save)
|
||||
m_playerLogout = false;
|
||||
m_playerSave = false;
|
||||
m_playerRecentlyLogout = true;
|
||||
LogoutRequest(0);
|
||||
SetLogoutStartTime(0);
|
||||
}
|
||||
|
||||
/// Kick a player out of the World
|
||||
|
||||
@@ -80,9 +80,13 @@ namespace WorldPackets
|
||||
{
|
||||
namespace Character
|
||||
{
|
||||
class LogoutCancel;
|
||||
class LogoutRequest;
|
||||
class ShowingCloak;
|
||||
class ShowingHelm;
|
||||
class PlayerLogout;
|
||||
}
|
||||
|
||||
namespace Chat
|
||||
{
|
||||
class EmoteClient;
|
||||
@@ -414,7 +418,7 @@ class TC_GAME_API WorldSession
|
||||
bool isLogingOut() const { return _logoutTime || m_playerLogout; }
|
||||
|
||||
/// Engage the logout process for the user
|
||||
void LogoutRequest(time_t requestTime)
|
||||
void SetLogoutStartTime(time_t requestTime)
|
||||
{
|
||||
_logoutTime = requestTime;
|
||||
}
|
||||
@@ -618,9 +622,9 @@ class TC_GAME_API WorldSession
|
||||
void HandleLootReleaseOpcode(WorldPacket& recvPacket);
|
||||
void HandleLootMasterGiveOpcode(WorldPacket& recvPacket);
|
||||
void HandleWhoOpcode(WorldPacket& recvPacket);
|
||||
void HandleLogoutRequestOpcode(WorldPacket& recvPacket);
|
||||
void HandlePlayerLogoutOpcode(WorldPacket& recvPacket);
|
||||
void HandleLogoutCancelOpcode(WorldPacket& recvPacket);
|
||||
void HandleLogoutRequestOpcode(WorldPackets::Character::LogoutRequest& logoutRequest);
|
||||
void HandlePlayerLogoutOpcode(WorldPackets::Character::PlayerLogout& playerLogout);
|
||||
void HandleLogoutCancelOpcode(WorldPackets::Character::LogoutCancel& logoutCancel);
|
||||
|
||||
// GM Ticket opcodes
|
||||
void HandleGMTicketCreateOpcode(WorldPacket& recvPacket);
|
||||
|
||||
Reference in New Issue
Block a user