diff --git a/common/cli/eqemu_command_handler.cpp b/common/cli/eqemu_command_handler.cpp index 2f150b621..59dec2b2d 100644 --- a/common/cli/eqemu_command_handler.cpp +++ b/common/cli/eqemu_command_handler.cpp @@ -23,12 +23,9 @@ namespace EQEmuCommand { - std::map function_map; + using CommandFunction = void(*)(int argc, char** argv, argh::parser& cmd, std::string& description); + + std::map function_map; /** * @param cmd diff --git a/common/op_codes.h b/common/op_codes.h index fbf0735a6..a488e8c4d 100644 --- a/common/op_codes.h +++ b/common/op_codes.h @@ -17,17 +17,16 @@ */ #pragma once - -static const char OP_SessionRequest = 0x01; -static const char OP_SessionResponse = 0x02; -static const char OP_Combined = 0x03; -static const char OP_SessionDisconnect = 0x05; -static const char OP_KeepAlive = 0x06; -static const char OP_SessionStatRequest = 0x07; -static const char OP_SessionStatResponse= 0x08; -static const char OP_Packet = 0x09; -static const char OP_Fragment = 0x0d; -static const char OP_OutOfOrderAck = 0x11; -static const char OP_Ack = 0x15; -static const char OP_AppCombined = 0x19; -static const char OP_OutOfSession = 0x1d; +static constexpr char OP_SessionRequest = 0x01; +static constexpr char OP_SessionResponse = 0x02; +static constexpr char OP_Combined = 0x03; +static constexpr char OP_SessionDisconnect = 0x05; +static constexpr char OP_KeepAlive = 0x06; +static constexpr char OP_SessionStatRequest = 0x07; +static constexpr char OP_SessionStatResponse = 0x08; +static constexpr char OP_Packet = 0x09; +static constexpr char OP_Fragment = 0x0d; +static constexpr char OP_OutOfOrderAck = 0x11; +static constexpr char OP_Ack = 0x15; +static constexpr char OP_AppCombined = 0x19; +static constexpr char OP_OutOfSession = 0x1d; diff --git a/common/opcodemgr.h b/common/opcodemgr.h index d28a02467..ba274bf12 100644 --- a/common/opcodemgr.h +++ b/common/opcodemgr.h @@ -31,7 +31,8 @@ #define SHARED_OPCODES #endif -class OpcodeManager { +class OpcodeManager +{ public: OpcodeManager(); virtual ~OpcodeManager() {} @@ -48,9 +49,10 @@ public: EmuOpcode NameSearch(const char *name); //This has to be public for stupid visual studio - class OpcodeSetStrategy { + class OpcodeSetStrategy + { public: - virtual ~OpcodeSetStrategy() {} //shut up compiler! + virtual ~OpcodeSetStrategy() = default; virtual void Set(EmuOpcode emu_op, uint16 eq_op) = 0; }; @@ -62,10 +64,12 @@ protected: static bool LoadOpcodesFile(const char *filename, OpcodeSetStrategy *s, bool report_errors); }; -class MutableOpcodeManager : public OpcodeManager { +class MutableOpcodeManager : public OpcodeManager +{ public: - MutableOpcodeManager() : OpcodeManager() {} - virtual bool Mutable() { return(true); } + MutableOpcodeManager() = default; + + virtual bool Mutable() override { return true; } virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op) = 0; }; @@ -108,16 +112,16 @@ public: virtual void SetOpcode(EmuOpcode emu_op, uint16 eq_op); protected: - class NormalMemStrategy : public OpcodeManager::OpcodeSetStrategy { + class NormalMemStrategy : public OpcodeManager::OpcodeSetStrategy + { public: - virtual ~NormalMemStrategy() {} //shut up compiler! - RegularOpcodeManager *it; - void Set(EmuOpcode emu_op, uint16 eq_op); - }; - friend class NormalMemStrategy; + RegularOpcodeManager* it; - uint16 *emu_to_eq; - EmuOpcode *eq_to_emu; + virtual void Set(EmuOpcode emu_op, uint16 eq_op) override; + }; + + uint16* emu_to_eq; + EmuOpcode* eq_to_emu; uint32 EQOpcodeCount; uint32 EmuOpcodeCount; }; diff --git a/common/process.cpp b/common/process.cpp index 44554f367..54521715b 100644 --- a/common/process.cpp +++ b/common/process.cpp @@ -23,11 +23,13 @@ inline std::string random_string(size_t length) { - auto randchar = []() -> char { + auto randchar = []() -> char + { const char charset[] = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"; const size_t max_index = (sizeof(charset) - 1); return charset[static_cast(std::rand()) % max_index]; }; + std::string str(length, 0); std::generate_n(str.begin(), length, randchar); return str; diff --git a/world/ucs.h b/world/ucs.h index df3ec9e6d..884628784 100644 --- a/world/ucs.h +++ b/world/ucs.h @@ -44,6 +44,6 @@ public: private: inline std::string GetIP() const { return (connection && connection->Handle()) ? connection->Handle()->RemoteIP() : 0; } - std::shared_ptr connection; + std::shared_ptr connection; };