diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 8 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 8 | ||||
-rw-r--r-- | src/server/game/Movement/MovementStructures.cpp | 6 | ||||
-rw-r--r-- | src/server/game/Movement/MovementStructures.h | 8 | ||||
-rw-r--r-- | src/server/game/Server/Protocol/Opcodes.cpp | 44 | ||||
-rw-r--r-- | src/server/game/Server/Protocol/Opcodes.h | 62 | ||||
-rw-r--r-- | src/server/game/Server/WorldPacket.cpp | 8 | ||||
-rw-r--r-- | src/server/game/Server/WorldPacket.h | 12 | ||||
-rw-r--r-- | src/server/game/Server/WorldSession.cpp | 30 | ||||
-rw-r--r-- | src/server/game/Server/WorldSocket.cpp | 6 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.h | 2 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_debug.cpp | 2 |
13 files changed, 125 insertions, 73 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 1de9be2350a..2b03d8f59fa 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -21196,7 +21196,7 @@ bool Player::IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier* mod void Player::AddSpellMod(SpellModifier* mod, bool apply) { TC_LOG_DEBUG("spells", "Player::AddSpellMod %d", mod->spellId); - Opcodes opcode = Opcodes((mod->type == SPELLMOD_FLAT) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER); + OpcodeServer opcode = (mod->type == SPELLMOD_FLAT) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER; int i = 0; flag96 _mask = 0; @@ -27462,7 +27462,7 @@ VoidStorageItem* Player::GetVoidStorageItem(uint64 id, uint8& slot) const void Player::SendMovementSetCanTransitionBetweenSwimAndFly(bool apply) { - Movement::PacketSender(this, NULL_OPCODE, apply ? + Movement::PacketSender(this, static_cast<OpcodeServer>(NULL_OPCODE), apply ? SMSG_MOVE_SET_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY : SMSG_MOVE_UNSET_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY).Send(); } @@ -27472,7 +27472,7 @@ void Player::SendMovementSetCollisionHeight(float height) static MovementStatusElements const heightElement = MSEExtraFloat; Movement::ExtraMovementStatusElement extra(&heightElement); extra.Data.floatData = height; - Movement::PacketSender(this, NULL_OPCODE, SMSG_MOVE_SET_COLLISION_HEIGHT, SMSG_MOVE_UPDATE_COLLISION_HEIGHT, &extra).Send(); + Movement::PacketSender(this, static_cast<OpcodeServer>(NULL_OPCODE), SMSG_MOVE_SET_COLLISION_HEIGHT, SMSG_MOVE_UPDATE_COLLISION_HEIGHT, &extra).Send(); } float Player::GetCollisionHeight(bool mounted) const @@ -27665,7 +27665,7 @@ void Player::ReadMovementInfo(WorldPacket& data, MovementInfo* mi, Movement::Ext MovementStatusElements const* sequence = GetMovementStatusElementsSequence(data.GetOpcode()); if (!sequence) { - TC_LOG_ERROR("network", "Player::ReadMovementInfo: No movement sequence found for opcode %s", GetOpcodeNameForLogging(data.GetOpcode()).c_str()); + TC_LOG_ERROR("network", "Player::ReadMovementInfo: No movement sequence found for opcode %s", GetOpcodeNameForLogging(static_cast<OpcodeClient>(data.GetOpcode())).c_str()); return; } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 601194dc2d1..6ff17c9b7cc 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -10768,7 +10768,7 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced) propagateSpeedChange(); - static Opcodes const moveTypeToOpcode[MAX_MOVE_TYPE][3] = + static OpcodeServer const moveTypeToOpcode[MAX_MOVE_TYPE][3] = { {SMSG_SPLINE_MOVE_SET_WALK_SPEED, SMSG_MOVE_SET_WALK_SPEED, SMSG_MOVE_UPDATE_WALK_SPEED }, {SMSG_SPLINE_MOVE_SET_RUN_SPEED, SMSG_MOVE_SET_RUN_SPEED, SMSG_MOVE_UPDATE_RUN_SPEED }, @@ -15613,7 +15613,7 @@ void Unit::WriteMovementInfo(WorldPacket& data, Movement::ExtraMovementStatusEle MovementStatusElements const* sequence = GetMovementStatusElementsSequence(data.GetOpcode()); if (!sequence) { - TC_LOG_ERROR("network", "Unit::WriteMovementInfo: No movement sequence found for opcode %s", GetOpcodeNameForLogging(data.GetOpcode()).c_str()); + TC_LOG_ERROR("network", "Unit::WriteMovementInfo: No movement sequence found for opcode %s", GetOpcodeNameForLogging(static_cast<OpcodeServer>(data.GetOpcode())).c_str()); return; } @@ -16317,9 +16317,9 @@ bool Unit::SetSwim(bool enable) RemoveUnitMovementFlag(MOVEMENTFLAG_SWIMMING); if (enable) - Movement::PacketSender(this, SMSG_SPLINE_MOVE_START_SWIM, NULL_OPCODE).Send(); + Movement::PacketSender(this, SMSG_SPLINE_MOVE_START_SWIM, static_cast<OpcodeServer>(NULL_OPCODE)).Send(); else - Movement::PacketSender(this, SMSG_SPLINE_MOVE_STOP_SWIM, NULL_OPCODE).Send(); + Movement::PacketSender(this, SMSG_SPLINE_MOVE_STOP_SWIM, static_cast<OpcodeServer>(NULL_OPCODE)).Send(); return true; } diff --git a/src/server/game/Movement/MovementStructures.cpp b/src/server/game/Movement/MovementStructures.cpp index 1c67bf1a6cc..93e940f0e64 100644 --- a/src/server/game/Movement/MovementStructures.cpp +++ b/src/server/game/Movement/MovementStructures.cpp @@ -5192,7 +5192,7 @@ bool Movement::PrintInvalidSequenceElement(MovementStatusElements const element, return false; } -Movement::PacketSender::PacketSender(Unit* unit, Opcodes serverControl, Opcodes playerControl, Opcodes broadcast /*= SMSG_PLAYER_MOVE*/, ExtraMovementStatusElement* extras /*= NULL*/) +Movement::PacketSender::PacketSender(Unit* unit, OpcodeServer serverControl, OpcodeServer playerControl, OpcodeServer broadcast /*= SMSG_PLAYER_MOVE*/, ExtraMovementStatusElement* extras /*= NULL*/) : _extraElements(extras), _unit(unit) { if (unit->GetTypeId() == TYPEID_PLAYER && unit->ToPlayer()->m_mover->GetTypeId() == TYPEID_PLAYER) @@ -5202,7 +5202,7 @@ Movement::PacketSender::PacketSender(Unit* unit, Opcodes serverControl, Opcodes } else { - _selfOpcode = NULL_OPCODE; + _selfOpcode = static_cast<OpcodeServer>(NULL_OPCODE); _broadcast = serverControl; } } @@ -5233,7 +5233,7 @@ void Movement::PacketSender::Send() const } } -MovementStatusElements const* GetMovementStatusElementsSequence(Opcodes opcode) +MovementStatusElements const* GetMovementStatusElementsSequence(uint32 opcode) { switch (opcode) { diff --git a/src/server/game/Movement/MovementStructures.h b/src/server/game/Movement/MovementStructures.h index 278eaa877fa..d348d08b415 100644 --- a/src/server/game/Movement/MovementStructures.h +++ b/src/server/game/Movement/MovementStructures.h @@ -139,20 +139,20 @@ namespace Movement class PacketSender { public: - PacketSender(Unit* unit, Opcodes serverControl, Opcodes playerControl, Opcodes broadcast = SMSG_PLAYER_MOVE, ExtraMovementStatusElement* extras = NULL); + PacketSender(Unit* unit, OpcodeServer serverControl, OpcodeServer playerControl, OpcodeServer broadcast = SMSG_PLAYER_MOVE, ExtraMovementStatusElement* extras = NULL); void Send() const; private: ExtraMovementStatusElement* _extraElements; Unit* _unit; - Opcodes _selfOpcode; - Opcodes _broadcast; + OpcodeServer _selfOpcode; + OpcodeServer _broadcast; }; bool PrintInvalidSequenceElement(MovementStatusElements element, char const* function); } -MovementStatusElements const* GetMovementStatusElementsSequence(Opcodes opcode); +MovementStatusElements const* GetMovementStatusElementsSequence(uint32 opcode); #endif diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index 86267d4c035..e0901bf9708 100644 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -22,31 +22,61 @@ OpcodeTable opcodeTable; template<bool isInValidRange, bool isNonZero> -void OpcodeTable::ValidateAndSetOpcode(uint16 /*opcode*/, char const* /*name*/, SessionStatus /*status*/, PacketProcessing /*processing*/, pOpcodeHandler /*handler*/) +void OpcodeTable::ValidateAndSetOpcode(OpcodeClient /*opcode*/, char const* /*name*/, SessionStatus /*status*/, PacketProcessing /*processing*/, pOpcodeHandler /*handler*/) +{ + // if for some reason we are here, that means NUM_OPCODE_HANDLERS == 0 (or your compiler is broken) +} + +template<bool isInValidRange, bool isNonZero> +void OpcodeTable::ValidateAndSetOpcode(OpcodeServer /*opcode*/, char const* /*name*/, SessionStatus /*status*/, PacketProcessing /*processing*/, pOpcodeHandler /*handler*/) { // if for some reason we are here, that means NUM_OPCODE_HANDLERS == 0 (or your compiler is broken) } template<> -void OpcodeTable::ValidateAndSetOpcode<true, true>(uint16 opcode, char const* name, SessionStatus status, PacketProcessing processing, pOpcodeHandler handler) +void OpcodeTable::ValidateAndSetOpcode<true, true>(OpcodeClient opcode, char const* name, SessionStatus status, PacketProcessing processing, pOpcodeHandler handler) { - if (_internalTable[opcode] != NULL) + if (_internalTableClient[opcode] != NULL) { - TC_LOG_ERROR("network", "Tried to override handler of %s with %s (opcode %u)", opcodeTable[opcode]->Name, name, opcode); + TC_LOG_ERROR("network", "Tried to override client handler of %s with %s (opcode %u)", opcodeTable[opcode]->Name, name, opcode); return; } - _internalTable[opcode] = new OpcodeHandler(name, status, processing, handler); + _internalTableClient[opcode] = new OpcodeHandler(name, status, processing, handler); } template<> -void OpcodeTable::ValidateAndSetOpcode<false, true>(uint16 opcode, char const* /*name*/, SessionStatus /*status*/, PacketProcessing /*processing*/, pOpcodeHandler /*handler*/) +void OpcodeTable::ValidateAndSetOpcode<true, true>(OpcodeServer opcode, char const* name, SessionStatus status, PacketProcessing processing, pOpcodeHandler handler) +{ + if (_internalTableServer[opcode] != NULL) + { + TC_LOG_ERROR("network", "Tried to override server handler of %s with %s (opcode %u)", opcodeTable[opcode]->Name, name, opcode); + return; + } + + _internalTableServer[opcode] = new OpcodeHandler(name, status, processing, handler); +} + +template<> +void OpcodeTable::ValidateAndSetOpcode<false, true>(OpcodeClient opcode, char const* /*name*/, SessionStatus /*status*/, PacketProcessing /*processing*/, pOpcodeHandler /*handler*/) +{ + TC_LOG_ERROR("network", "Tried to set handler for an invalid opcode %d", opcode); +} + +template<> +void OpcodeTable::ValidateAndSetOpcode<false, true>(OpcodeServer opcode, char const* /*name*/, SessionStatus /*status*/, PacketProcessing /*processing*/, pOpcodeHandler /*handler*/) { TC_LOG_ERROR("network", "Tried to set handler for an invalid opcode %d", opcode); } template<> -void OpcodeTable::ValidateAndSetOpcode<true, false>(uint16 /*opcode*/, char const* name, SessionStatus /*status*/, PacketProcessing /*processing*/, pOpcodeHandler /*handler*/) +void OpcodeTable::ValidateAndSetOpcode<true, false>(OpcodeClient /*opcode*/, char const* name, SessionStatus /*status*/, PacketProcessing /*processing*/, pOpcodeHandler /*handler*/) +{ + TC_LOG_ERROR("network", "Opcode %s got value 0", name); +} + +template<> +void OpcodeTable::ValidateAndSetOpcode<true, false>(OpcodeServer /*opcode*/, char const* name, SessionStatus /*status*/, PacketProcessing /*processing*/, pOpcodeHandler /*handler*/) { TC_LOG_ERROR("network", "Opcode %s got value 0", name); } diff --git a/src/server/game/Server/Protocol/Opcodes.h b/src/server/game/Server/Protocol/Opcodes.h index 3ba5864d913..acd40f41aa7 100644 --- a/src/server/game/Server/Protocol/Opcodes.h +++ b/src/server/game/Server/Protocol/Opcodes.h @@ -25,15 +25,18 @@ #include "Common.h" -/// List of Opcodes -enum Opcodes +enum OpcodeMisc : uint32 { - MAX_OPCODE = 0x1FFF, - NUM_OPCODE_HANDLERS = (MAX_OPCODE+1), - UNKNOWN_OPCODE = (0xFFFF+1), - NULL_OPCODE = 0, - COMPRESSED_OPCODE_MASK = 0x8000, + MAX_OPCODE = 0x1FFF, + NUM_OPCODE_HANDLERS = (MAX_OPCODE + 1), + UNKNOWN_OPCODE = (0xFFFF + 1), + NULL_OPCODE = 0, + COMPRESSED_OPCODE_MASK = 0x8000 +}; +// CMSGs +enum OpcodeClient : uint32 +{ CMSG_ACCEPT_LEVEL_GRANT = 0x0000, CMSG_ACCEPT_TRADE = 0x0000, CMSG_ACTIVATETAXI = 0x0000, @@ -657,7 +660,12 @@ enum Opcodes MSG_SET_DUNGEON_DIFFICULTY = 0x0000, MSG_SET_RAID_DIFFICULTY = 0x0000, MSG_TABARDVENDOR_ACTIVATE = 0x0000, - MSG_TALENT_WIPE_CONFIRM = 0x0000, + MSG_TALENT_WIPE_CONFIRM = 0x0000 +}; + +// SMSGs +enum OpcodeServer : uint32 +{ SMSG_ACCOUNT_DATA_TIMES = 0x11AC, SMSG_ACCOUNT_INFO_RESPONSE = 0x0000, SMSG_ACCOUNT_RESTRICTED_WARNING = 0x0000, @@ -1444,31 +1452,43 @@ class OpcodeTable public: OpcodeTable() { - memset(_internalTable, 0, sizeof(_internalTable)); + memset(_internalTableClient, 0, sizeof(_internalTableClient)); + memset(_internalTableServer, 0, sizeof(_internalTableServer)); } + OpcodeTable(OpcodeTable const&) = delete; + OpcodeTable& operator=(OpcodeTable const&) = delete; + ~OpcodeTable() { for (uint16 i = 0; i < NUM_OPCODE_HANDLERS; ++i) - delete _internalTable[i]; + { + delete _internalTableClient[i]; + delete _internalTableServer[i]; + } } void Initialize(); - OpcodeHandler const* operator[](uint32 index) const + OpcodeHandler const* operator[](OpcodeClient index) const { - return _internalTable[index]; + return _internalTableClient[index]; + } + + OpcodeHandler const* operator[](OpcodeServer index) const + { + return _internalTableServer[index]; } private: template<bool isInValidRange, bool isNonZero> - void ValidateAndSetOpcode(uint16 opcode, char const* name, SessionStatus status, PacketProcessing processing, pOpcodeHandler handler); + void ValidateAndSetOpcode(OpcodeClient opcode, char const* name, SessionStatus status, PacketProcessing processing, pOpcodeHandler handler); - // Prevent copying this structure - OpcodeTable(OpcodeTable const&); - OpcodeTable& operator=(OpcodeTable const&); + template<bool isInValidRange, bool isNonZero> + void ValidateAndSetOpcode(OpcodeServer opcode, char const* name, SessionStatus status, PacketProcessing processing, pOpcodeHandler handler); - OpcodeHandler* _internalTable[NUM_OPCODE_HANDLERS]; + OpcodeHandler* _internalTableClient[NUM_OPCODE_HANDLERS]; + OpcodeHandler* _internalTableServer[NUM_OPCODE_HANDLERS]; }; extern OpcodeTable opcodeTable; @@ -1481,8 +1501,9 @@ extern OpcodeTable opcodeTable; void InitOpcodes(); -/// Lookup opcode name for human understandable logging -inline std::string GetOpcodeNameForLogging(Opcodes id) +/// Lookup opcode name for human understandable logging (T = OpcodeClient|OpcodeServer) +template<typename T> +inline std::string GetOpcodeNameForLogging(T id) { uint32 opcode = uint32(id); std::ostringstream ss; @@ -1490,7 +1511,7 @@ inline std::string GetOpcodeNameForLogging(Opcodes id) if (id < UNKNOWN_OPCODE) { - if (OpcodeHandler const* handler = opcodeTable[uint32(id) & 0x7FFF]) + if (OpcodeHandler const* handler = opcodeTable[T(opcode & 0x7FFF)]) { ss << handler->Name; if (opcode & COMPRESSED_OPCODE_MASK) @@ -1506,5 +1527,6 @@ inline std::string GetOpcodeNameForLogging(Opcodes id) return ss.str(); } + #endif /// @} diff --git a/src/server/game/Server/WorldPacket.cpp b/src/server/game/Server/WorldPacket.cpp index 0658973f320..a1a9b15f20b 100644 --- a/src/server/game/Server/WorldPacket.cpp +++ b/src/server/game/Server/WorldPacket.cpp @@ -22,14 +22,14 @@ //! Compresses packet in place void WorldPacket::Compress(z_stream* compressionStream) { - Opcodes uncompressedOpcode = GetOpcode(); + OpcodeServer uncompressedOpcode = static_cast<OpcodeServer>(GetOpcode()); if (uncompressedOpcode & COMPRESSED_OPCODE_MASK) { TC_LOG_ERROR("network", "Packet with opcode 0x%04X is already compressed!", uncompressedOpcode); return; } - Opcodes opcode = Opcodes(uncompressedOpcode | COMPRESSED_OPCODE_MASK); + OpcodeServer opcode = OpcodeServer(uncompressedOpcode | COMPRESSED_OPCODE_MASK); uint32 size = wpos(); uint32 destsize = compressBound(size); @@ -53,14 +53,14 @@ void WorldPacket::Compress(z_stream* compressionStream, WorldPacket const* sourc { ASSERT(source != this); - Opcodes uncompressedOpcode = source->GetOpcode(); + OpcodeServer uncompressedOpcode = static_cast<OpcodeServer>(source->GetOpcode()); if (uncompressedOpcode & COMPRESSED_OPCODE_MASK) { TC_LOG_ERROR("network", "Packet with opcode 0x%04X is already compressed!", uncompressedOpcode); return; } - Opcodes opcode = Opcodes(uncompressedOpcode | COMPRESSED_OPCODE_MASK); + OpcodeServer opcode = OpcodeServer(uncompressedOpcode | COMPRESSED_OPCODE_MASK); uint32 size = source->size(); uint32 destsize = compressBound(size); diff --git a/src/server/game/Server/WorldPacket.h b/src/server/game/Server/WorldPacket.h index b047b20bce2..7c36f8f2321 100644 --- a/src/server/game/Server/WorldPacket.h +++ b/src/server/game/Server/WorldPacket.h @@ -33,7 +33,7 @@ class WorldPacket : public ByteBuffer { } - explicit WorldPacket(Opcodes opcode, size_t res=200) : ByteBuffer(res), m_opcode(opcode) { } + explicit WorldPacket(uint32 opcode, size_t res = 200) : ByteBuffer(res), m_opcode(opcode) { } WorldPacket(WorldPacket&& packet) : ByteBuffer(std::move(packet)), m_opcode(packet.m_opcode) { @@ -54,23 +54,23 @@ class WorldPacket : public ByteBuffer return *this; } - WorldPacket(Opcodes opcode, MessageBuffer&& buffer) : ByteBuffer(std::move(buffer)), m_opcode(opcode) { } + WorldPacket(uint32 opcode, MessageBuffer&& buffer) : ByteBuffer(std::move(buffer)), m_opcode(opcode) { } - void Initialize(Opcodes opcode, size_t newres=200) + void Initialize(uint32 opcode, size_t newres = 200) { clear(); _storage.reserve(newres); m_opcode = opcode; } - Opcodes GetOpcode() const { return m_opcode; } - void SetOpcode(Opcodes opcode) { m_opcode = opcode; } + uint32 GetOpcode() const { return m_opcode; } + void SetOpcode(uint32 opcode) { m_opcode = opcode; } bool IsCompressed() const { return (m_opcode & COMPRESSED_OPCODE_MASK) != 0; } void Compress(z_stream_s* compressionStream); void Compress(z_stream_s* compressionStream, WorldPacket const* source); protected: - Opcodes m_opcode; + uint32 m_opcode; void Compress(void* dst, uint32 *dst_size, const void* src, int src_size); z_stream_s* _compressionStream; }; diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index 42e9a385672..437f36cc3e3 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -57,7 +57,7 @@ std::string const DefaultPlayerName = "<none>"; bool MapSessionFilter::Process(WorldPacket* packet) { - OpcodeHandler const* opHandle = opcodeTable[packet->GetOpcode()]; + OpcodeHandler const* opHandle = opcodeTable[static_cast<OpcodeClient>(packet->GetOpcode())]; //let's check if our opcode can be really processed in Map::Update() if (opHandle->ProcessingPlace == PROCESS_INPLACE) @@ -79,7 +79,7 @@ bool MapSessionFilter::Process(WorldPacket* packet) //OR packet handler is not thread-safe! bool WorldSessionFilter::Process(WorldPacket* packet) { - OpcodeHandler const* opHandle = opcodeTable[packet->GetOpcode()]; + OpcodeHandler const* opHandle = opcodeTable[static_cast<OpcodeClient>(packet->GetOpcode())]; //check if packet handler is supposed to be safe if (opHandle->ProcessingPlace == PROCESS_INPLACE) return true; @@ -219,10 +219,10 @@ void WorldSession::SendPacket(WorldPacket* packet, bool forced /*= false*/) if (!forced) { - OpcodeHandler const* handler = opcodeTable[packet->GetOpcode()]; + OpcodeHandler const* handler = opcodeTable[static_cast<OpcodeServer>(packet->GetOpcode())]; if (!handler || handler->Status == STATUS_UNHANDLED) { - TC_LOG_ERROR("network.opcode", "Prevented sending disabled opcode %s to %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), GetPlayerInfo().c_str()); + TC_LOG_ERROR("network.opcode", "Prevented sending disabled opcode %s to %s", GetOpcodeNameForLogging(static_cast<OpcodeServer>(packet->GetOpcode())).c_str(), GetPlayerInfo().c_str()); return; } } @@ -276,7 +276,7 @@ void WorldSession::QueuePacket(WorldPacket* new_packet) void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, const char* status, const char *reason) { TC_LOG_ERROR("network.opcode", "Received unexpected opcode %s Status: %s Reason: %s from %s", - GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), status, reason, GetPlayerInfo().c_str()); + GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str(), status, reason, GetPlayerInfo().c_str()); } /// Logging helper for unexpected opcodes @@ -286,7 +286,7 @@ void WorldSession::LogUnprocessedTail(WorldPacket* packet) return; TC_LOG_TRACE("network.opcode", "Unprocessed tail data (read stop at %u from %u) Opcode %s from %s", - uint32(packet->rpos()), uint32(packet->wpos()), GetOpcodeNameForLogging(packet->GetOpcode()).c_str(), GetPlayerInfo().c_str()); + uint32(packet->rpos()), uint32(packet->wpos()), GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str(), GetPlayerInfo().c_str()); packet->print_storage(); } @@ -321,7 +321,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) if (!AntiDOS.EvaluateOpcode(*packet, currentTime)) KickPlayer(); - OpcodeHandler const* opHandle = opcodeTable[packet->GetOpcode()]; + OpcodeHandler const* opHandle = opcodeTable[static_cast<OpcodeClient>(packet->GetOpcode())]; try { switch (opHandle->Status) @@ -342,7 +342,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) QueuePacket(packet); //! Log TC_LOG_DEBUG("network", "Re-enqueueing packet with opcode %s with with status STATUS_LOGGEDIN. " - "Player is currently not in world yet.", GetOpcodeNameForLogging(packet->GetOpcode()).c_str()); + "Player is currently not in world yet.", GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str()); } } else if (_player->IsInWorld()) @@ -395,11 +395,11 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) LogUnprocessedTail(packet); break; case STATUS_NEVER: - TC_LOG_ERROR("network.opcode", "Received not allowed opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str() + TC_LOG_ERROR("network.opcode", "Received not allowed opcode %s from %s", GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str() , GetPlayerInfo().c_str()); break; case STATUS_UNHANDLED: - TC_LOG_ERROR("network.opcode", "Received not handled opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str() + TC_LOG_ERROR("network.opcode", "Received not handled opcode %s from %s", GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str() , GetPlayerInfo().c_str()); break; } @@ -663,25 +663,25 @@ char const* WorldSession::GetTrinityString(uint32 entry) const void WorldSession::Handle_NULL(WorldPacket& recvPacket) { TC_LOG_ERROR("network.opcode", "Received unhandled opcode %s from %s" - , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerInfo().c_str()); + , GetOpcodeNameForLogging(static_cast<OpcodeClient>(recvPacket.GetOpcode())).c_str(), GetPlayerInfo().c_str()); } void WorldSession::Handle_EarlyProccess(WorldPacket& recvPacket) { TC_LOG_ERROR("network.opcode", "Received opcode %s that must be processed in WorldSocket::OnRead from %s" - , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerInfo().c_str()); + , GetOpcodeNameForLogging(static_cast<OpcodeClient>(recvPacket.GetOpcode())).c_str(), GetPlayerInfo().c_str()); } void WorldSession::Handle_ServerSide(WorldPacket& recvPacket) { TC_LOG_ERROR("network.opcode", "Received server-side opcode %s from %s" - , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerInfo().c_str()); + , GetOpcodeNameForLogging(static_cast<OpcodeClient>(recvPacket.GetOpcode())).c_str(), GetPlayerInfo().c_str()); } void WorldSession::Handle_Deprecated(WorldPacket& recvPacket) { TC_LOG_ERROR("network.opcode", "Received deprecated opcode %s from %s" - , GetOpcodeNameForLogging(recvPacket.GetOpcode()).c_str(), GetPlayerInfo().c_str()); + , GetOpcodeNameForLogging(static_cast<OpcodeClient>(recvPacket.GetOpcode())).c_str(), GetPlayerInfo().c_str()); } void WorldSession::SendAuthWaitQue(uint32 position) @@ -1198,7 +1198,7 @@ bool WorldSession::DosProtection::EvaluateOpcode(WorldPacket& p, time_t time) co TC_LOG_WARN("network", "AntiDOS: Account %u, IP: %s, Ping: %u, Character: %s, flooding packet (opc: %s (0x%X), count: %u)", Session->GetAccountId(), Session->GetRemoteAddress().c_str(), Session->GetLatency(), Session->GetPlayerName().c_str(), - opcodeTable[p.GetOpcode()]->Name, p.GetOpcode(), packetCounter.amountCounter); + opcodeTable[static_cast<OpcodeClient>(p.GetOpcode())]->Name, p.GetOpcode(), packetCounter.amountCounter); switch (_policy) { diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index 4739c613e7f..c9184b1be4c 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -188,7 +188,7 @@ bool WorldSocket::ReadDataHandler() ExtractOpcodeAndSize(header, cmd, size); - Opcodes opcode = Opcodes(cmd); + OpcodeClient opcode = static_cast<OpcodeClient>(cmd); std::string opcodeName = GetOpcodeNameForLogging(opcode); @@ -251,7 +251,7 @@ bool WorldSocket::ReadDataHandler() OpcodeHandler const* handler = opcodeTable[opcode]; if (!handler) { - TC_LOG_ERROR("network.opcode", "No defined handler for opcode %s sent by %s", GetOpcodeNameForLogging(packet.GetOpcode()).c_str(), _worldSession->GetPlayerInfo().c_str()); + TC_LOG_ERROR("network.opcode", "No defined handler for opcode %s sent by %s", GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet.GetOpcode())).c_str(), _worldSession->GetPlayerInfo().c_str()); return true; } @@ -294,7 +294,7 @@ void WorldSocket::SendPacket(WorldPacket& packet) if (_worldSession && packet.size() > 0x400 && !packet.IsCompressed()) packet.Compress(_worldSession->GetCompressionStream()); - TC_LOG_TRACE("network.opcode", "S->C: %s %s", (_worldSession ? _worldSession->GetPlayerInfo() : GetRemoteIpAddress().to_string()).c_str(), GetOpcodeNameForLogging(packet.GetOpcode()).c_str()); + TC_LOG_TRACE("network.opcode", "S->C: %s %s", (_worldSession ? _worldSession->GetPlayerInfo() : GetRemoteIpAddress().to_string()).c_str(), GetOpcodeNameForLogging(static_cast<OpcodeServer>(packet.GetOpcode())).c_str()); std::unique_lock<std::mutex> guard(_writeLock); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 71798448292..ee447509c2b 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -3662,7 +3662,7 @@ void Spell::SendPetCastResult(SpellCastResult result) SendCastResult(owner->ToPlayer(), m_spellInfo, m_cast_count, result, SPELL_CUSTOM_ERROR_NONE, SMSG_PET_CAST_FAILED); } -void Spell::SendCastResult(Player* caster, SpellInfo const* spellInfo, uint8 cast_count, SpellCastResult result, SpellCustomErrors customError /*= SPELL_CUSTOM_ERROR_NONE*/, Opcodes opcode /*= SMSG_CAST_FAILED*/) +void Spell::SendCastResult(Player* caster, SpellInfo const* spellInfo, uint8 cast_count, SpellCastResult result, SpellCustomErrors customError /*= SPELL_CUSTOM_ERROR_NONE*/, OpcodeServer opcode /*= SMSG_CAST_FAILED*/) { if (result == SPELL_CAST_OK) return; diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 65fe51b37e3..dc07449c41f 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -433,7 +433,7 @@ class Spell void CheckSrc() { if (!m_targets.HasSrc()) m_targets.SetSrc(*m_caster); } void CheckDst() { if (!m_targets.HasDst()) m_targets.SetDst(*m_caster); } - static void SendCastResult(Player* caster, SpellInfo const* spellInfo, uint8 cast_count, SpellCastResult result, SpellCustomErrors customError = SPELL_CUSTOM_ERROR_NONE, Opcodes opcode = SMSG_CAST_FAILED); + static void SendCastResult(Player* caster, SpellInfo const* spellInfo, uint8 cast_count, SpellCastResult result, SpellCustomErrors customError = SPELL_CUSTOM_ERROR_NONE, OpcodeServer opcode = SMSG_CAST_FAILED); void SendCastResult(SpellCastResult result); void SendPetCastResult(SpellCastResult result); void SendSpellStart(); diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 4a559e759ca..f93208a4186 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -314,7 +314,7 @@ public: uint32 opcode; parsedStream >> opcode; - WorldPacket data(Opcodes(opcode), 0); + WorldPacket data(OpcodeServer(opcode), 0); while (!parsedStream.eof()) { |