Misc cleanup

This commit is contained in:
brainiac 2025-12-28 02:26:16 -08:00
parent 72fa8cf845
commit 70558cb2ff
5 changed files with 38 additions and 36 deletions

View File

@ -23,12 +23,9 @@
namespace EQEmuCommand {
std::map<std::string, void (*)(
int argc,
char **argv,
argh::parser &cmd,
std::string &description
)> function_map;
using CommandFunction = void(*)(int argc, char** argv, argh::parser& cmd, std::string& description);
std::map<std::string, CommandFunction> function_map;
/**
* @param cmd

View File

@ -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;

View File

@ -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;
};

View File

@ -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<size_t>(std::rand()) % max_index];
};
std::string str(length, 0);
std::generate_n(str.begin(), length, randchar);
return str;

View File

@ -44,6 +44,6 @@ public:
private:
inline std::string GetIP() const { return (connection && connection->Handle()) ? connection->Handle()->RemoteIP() : 0; }
std::shared_ptr<EQ::Net::ServertalkServerConnection> connection;
std::shared_ptr<EQ::Net::ServertalkServerConnection> connection;
};