AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Opcodes.cpp File Reference
#include "Opcodes.h"
#include "Log.h"
#include "Packets/AllPackets.h"
#include "WorldSession.h"
#include <iomanip>
#include <sstream>

Go to the source code of this file.

Classes

class  PacketHandler< PacketClass, HandlerFunction >
 
class  PacketHandler< WorldPacket, HandlerFunction >
 
struct  get_packet_class< T >
 
struct  get_packet_class< void(WorldSession::*)(PacketClass &)>
 

Macros

#define DEFINE_HANDLER(opcode, status, processing, handler)    ValidateAndSetClientOpcode<decltype(handler), handler>(opcode, #opcode, status, processing)
 
#define DEFINE_SERVER_OPCODE_HANDLER(opcode, status)
 

Functions

template<typename T >
std::string GetOpcodeNameForLoggingImpl (T id)
 
std::string GetOpcodeNameForLogging (Opcodes opcode)
 Lookup opcode name for human understandable logging.
 

Variables

OpcodeTable opcodeTable
 

Macro Definition Documentation

◆ DEFINE_HANDLER

#define DEFINE_HANDLER (   opcode,
  status,
  processing,
  handler 
)     ValidateAndSetClientOpcode<decltype(handler), handler>(opcode, #opcode, status, processing)

◆ DEFINE_SERVER_OPCODE_HANDLER

#define DEFINE_SERVER_OPCODE_HANDLER (   opcode,
  status 
)
Value:
static_assert(status == STATUS_NEVER || status == STATUS_UNHANDLED, "Invalid status for server opcode"); \
ValidateAndSetServerOpcode(opcode, #opcode, status)
@ STATUS_NEVER
Definition Opcodes.h:1362
@ STATUS_UNHANDLED
Definition Opcodes.h:1363

Function Documentation

◆ GetOpcodeNameForLoggingImpl()

template<typename T >
std::string GetOpcodeNameForLoggingImpl ( id)
inline
1451{
1452 uint16 opcode = uint16(id);
1453 std::ostringstream ss;
1454 ss << '[';
1455
1456 if (static_cast<uint16>(id) < NUM_OPCODE_HANDLERS)
1457 {
1458 if (OpcodeHandler const* handler = opcodeTable[id])
1459 ss << handler->Name;
1460 else
1461 ss << "UNKNOWN OPCODE";
1462 }
1463 else
1464 ss << "INVALID OPCODE";
1465
1466 ss << " 0x" << std::hex << std::setw(4) << std::setfill('0') << std::uppercase << opcode << std::nouppercase << std::dec << " (" << opcode << ")]";
1467 return ss.str();
1468}
std::uint16_t uint16
Definition Define.h:108
Definition Opcodes.h:1377
OpcodeTable opcodeTable
Definition Opcodes.cpp:51
@ NUM_OPCODE_HANDLERS
Definition Opcodes.h:1348

References NUM_OPCODE_HANDLERS, and opcodeTable.

Referenced by GetOpcodeNameForLogging().