diff --git a/src/Components/Modules/Auth.cpp b/src/Components/Modules/Auth.cpp index 1ea665f7..02a35b59 100644 --- a/src/Components/Modules/Auth.cpp +++ b/src/Components/Modules/Auth.cpp @@ -83,7 +83,7 @@ namespace Components Command::ServerParams params; - if (params.length() < 3) + if (params.size() < 3) { Game::SV_Cmd_EndTokenizedString(); Logger::SoftError("Connecting failed: Command parsing error!"); @@ -170,7 +170,7 @@ namespace Components Command::ServerParams params; // Ensure there are enough params - if (params.length() < 3) + if (params.size() < 3) { Network::Send(address, "error\nInvalid connect string!"); return; @@ -455,7 +455,7 @@ namespace Components { Command::Add("securityLevel", [](Command::Params* params) { - if (params->length() < 2) + if (params->size() < 2) { uint32_t level = Auth::GetZeroBits(Auth::GuidToken, Auth::GuidKey.getPublicKey()); Logger::Print("Your current security level is %d\n", level); diff --git a/src/Components/Modules/Bans.cpp b/src/Components/Modules/Bans.cpp index 38cd20e9..14eb15b5 100644 --- a/src/Components/Modules/Bans.cpp +++ b/src/Components/Modules/Bans.cpp @@ -234,17 +234,17 @@ namespace Components { Command::Add("banclient", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string reason = "EXE_ERR_BANNED_PERM"; - if (params->length() >= 3) reason = params->join(2); + if (params->size() >= 3) reason = params->join(2); Bans::BanClientNum(atoi(params->get(1)), reason); }); Command::Add("unbanclient", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string type = params->get(1); diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index 78d42d0a..d177c573 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -447,7 +447,7 @@ namespace Components { unsigned int count = 1; - if (params->length() > 1) + if (params->size() > 1) { if (params->get(1) == "all"s) count = static_cast(-1); else count = atoi(params->get(1)); diff --git a/src/Components/Modules/CardTitles.cpp b/src/Components/Modules/CardTitles.cpp index 471dd8ec..0a47ce91 100644 --- a/src/Components/Modules/CardTitles.cpp +++ b/src/Components/Modules/CardTitles.cpp @@ -199,7 +199,7 @@ namespace Components { if (params->get(1) == "customTitles"s && !Dedicated::IsEnabled()) { - if (params->length() == 3) + if (params->size() == 3) { CardTitles::ParseCustomTitles(params->get(2)); return true; diff --git a/src/Components/Modules/Chat.cpp b/src/Components/Modules/Chat.cpp index abe117d8..80740e7c 100644 --- a/src/Components/Modules/Chat.cpp +++ b/src/Components/Modules/Chat.cpp @@ -263,7 +263,7 @@ namespace Components } const auto* cmd = params->get(0); - if (params->length() < 2) + if (params->size() < 2) { Logger::Print("Usage: %s : prevent the player from using the chat\n", cmd); return; @@ -285,7 +285,7 @@ namespace Components } const auto* cmd = params->get(0); - if (params->length() < 2) + if (params->size() < 2) { Logger::Print("Usage: %s \n%s all = unmute everyone\n", cmd, cmd); return; @@ -299,7 +299,7 @@ namespace Components return; } - if (params->get(1) == "all"s) + if (std::strcmp(params->get(1), "all") == 0) { Logger::Print("All players were unmuted\n"); Chat::UnmuteInternal(0, true); diff --git a/src/Components/Modules/Clantags.cpp b/src/Components/Modules/Clantags.cpp index ff6e2022..f78fdbdf 100644 --- a/src/Components/Modules/Clantags.cpp +++ b/src/Components/Modules/Clantags.cpp @@ -83,7 +83,7 @@ namespace Components { if (params->get(1) == "clantags"s && !Dedicated::IsEnabled()) { - if (params->length() == 3) + if (params->size() == 3) { ClanTags::ParseClantags(params->get(2)); return true; diff --git a/src/Components/Modules/ClientCommand.cpp b/src/Components/Modules/ClientCommand.cpp index 1c0c7fa4..4bdb8b03 100644 --- a/src/Components/Modules/ClientCommand.cpp +++ b/src/Components/Modules/ClientCommand.cpp @@ -147,7 +147,7 @@ namespace Components Command::ServerParams params = {}; Game::vec3_t origin, angles{0.f, 0.f, 0.f}; - if (params.length() < 4u || params.length() > 6u) + if (params.size() < 4 || params.size() > 6) { Game::SV_GameSendServerCommand(ent->s.number, 0, Utils::String::VA("%c \"GAME_USAGE\x15: setviewpos x y z [yaw] [pitch]\n\"", 0x65)); @@ -159,12 +159,12 @@ namespace Components origin[i] = std::strtof(params.get(i + 1), nullptr); } - if (params.length() >= 5u) + if (params.size() >= 5) { angles[1] = std::strtof(params.get(4), nullptr); // Yaw } - if (params.length() == 6u) + if (params.size() == 6) { angles[0] = std::strtof(params.get(5), nullptr); // Pitch } diff --git a/src/Components/Modules/Command.cpp b/src/Components/Modules/Command.cpp index d3846df5..071be212 100644 --- a/src/Components/Modules/Command.cpp +++ b/src/Components/Modules/Command.cpp @@ -5,56 +5,72 @@ namespace Components std::unordered_map> Command::FunctionMap; std::unordered_map> Command::FunctionMapSV; - std::string Command::Params::join(size_t startIndex) + std::string Command::Params::join(const int index) { std::string result; - for (size_t i = startIndex; i < this->length(); ++i) + for (auto i = index; i < this->size(); i++) { - if (i > startIndex) result.append(" "); - result.append(this->operator[](i)); + if (i > index) result.append(" "); + result.append(this->get(i)); } return result; } - const char* Command::Params::operator[](size_t index) + Command::ClientParams::ClientParams() + : nesting_(Game::cmd_args->nesting) { - return this->get(index); + assert(Game::cmd_args->nesting < Game::CMD_MAX_NESTING); } - const char* Command::ClientParams::get(size_t index) + int Command::ClientParams::size() { - if (index >= this->length()) return ""; - return Game::cmd_argv[this->commandId][index]; + return Game::cmd_args->argc[this->nesting_]; } - size_t Command::ClientParams::length() + const char* Command::ClientParams::get(const int index) { - return Game::cmd_argc[this->commandId]; + if (index >= this->size()) + { + return ""; + } + + return Game::cmd_args->argv[this->nesting_][index]; } - const char* Command::ServerParams::get(size_t index) + Command::ServerParams::ServerParams() + : nesting_(Game::sv_cmd_args->nesting) { - if (index >= this->length()) return ""; - return Game::cmd_argv_sv[this->commandId][index]; + assert(Game::sv_cmd_args->nesting < Game::CMD_MAX_NESTING); } - size_t Command::ServerParams::length() + int Command::ServerParams::size() { - return Game::cmd_argc_sv[this->commandId]; + return Game::sv_cmd_args->argc[this->nesting_]; + } + + const char* Command::ServerParams::get(const int index) + { + if (index >= this->size()) + { + return ""; + } + + return Game::sv_cmd_args->argv[this->nesting_][index]; } void Command::Add(const char* name, Utils::Slot callback) { - std::string command = Utils::String::ToLower(name); + const auto command = Utils::String::ToLower(name); + const auto got = Command::FunctionMap.find(command); - if (Command::FunctionMap.find(command) == Command::FunctionMap.end()) + if (got == Command::FunctionMap.end()) { Command::AddRaw(name, Command::MainCallback); } - Command::FunctionMap[command] = callback; + got->second = std::move(callback); } void Command::AddSV(const char* name, Utils::Slot callback) @@ -70,9 +86,10 @@ namespace Components return; } - std::string command = Utils::String::ToLower(name); + const auto command = Utils::String::ToLower(name); + const auto got = Command::FunctionMapSV.find(command); - if (Command::FunctionMapSV.find(command) == Command::FunctionMapSV.end()) + if (got == Command::FunctionMapSV.end()) { Command::AddRawSV(name, Command::MainCallbackSV); @@ -80,7 +97,7 @@ namespace Components Command::AddRaw(name, Game::Cbuf_AddServerText); } - Command::FunctionMapSV[command] = callback; + got->second = std::move(callback); } void Command::AddRaw(const char* name, void(*callback)(), bool key) @@ -134,25 +151,27 @@ namespace Components void Command::MainCallback() { - Command::ClientParams params(*Game::cmd_id); + Command::ClientParams params; - std::string command = Utils::String::ToLower(params[0]); + const auto command = Utils::String::ToLower(params[0]); + const auto got = Command::FunctionMap.find(command); - if (Command::FunctionMap.find(command) != Command::FunctionMap.end()) + if (got != Command::FunctionMap.end()) { - Command::FunctionMap[command](¶ms); + got->second(¶ms); } } void Command::MainCallbackSV() { - Command::ServerParams params(*Game::cmd_id_sv); + Command::ServerParams params; - std::string command = Utils::String::ToLower(params[0]); + const auto command = Utils::String::ToLower(params[0]); + const auto got = Command::FunctionMapSV.find(command); - if (Command::FunctionMapSV.find(command) != Command::FunctionMapSV.end()) + if (got != Command::FunctionMapSV.end()) { - Command::FunctionMapSV[command](¶ms); + got->second(¶ms); } } @@ -162,7 +181,7 @@ namespace Components Command::Add("openLink", [](Command::Params* params) { - if (params->length() > 1) + if (params->size() > 1) { Utils::OpenUrl(params->get(1)); } diff --git a/src/Components/Modules/Command.hpp b/src/Components/Modules/Command.hpp index 4e07ba87..365555e6 100644 --- a/src/Components/Modules/Command.hpp +++ b/src/Components/Modules/Command.hpp @@ -9,40 +9,39 @@ namespace Components { public: Params() {}; - virtual ~Params() {}; - virtual const char* get(size_t index) = 0; - virtual size_t length() = 0; - virtual std::string join(size_t startIndex); - virtual const char* operator[](size_t index); + virtual int size() = 0; + virtual const char* get(int index) = 0; + virtual std::string join(int index); + + virtual const char* operator[](const int index) + { + return this->get(index); + } }; class ClientParams : public Params { public: - ClientParams(unsigned int id) : commandId(id) {}; - ClientParams(const ClientParams &obj) : commandId(obj.commandId) {}; - ClientParams() : ClientParams(*Game::cmd_id) {}; + ClientParams(); - const char* get(size_t index) override; - size_t length() override; + int size() override; + const char* get(int index) override; private: - unsigned int commandId; + int nesting_; }; class ServerParams : public Params { public: - ServerParams(unsigned int id) : commandId(id) {}; - ServerParams(const ServerParams &obj) : commandId(obj.commandId) {}; - ServerParams() : ServerParams(*Game::cmd_id_sv) {}; + ServerParams(); - const char* get(size_t index) override; - size_t length() override; + int size() override; + const char* get(int index) override; private: - unsigned int commandId; + int nesting_; }; typedef void(Callback)(Command::Params* params); diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index 3e615dab..0c20904c 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -398,7 +398,7 @@ namespace Components // Say command Command::AddSV("say", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string message = params->join(1); std::string name = Dvar::Var("sv_sayName").get(); @@ -418,7 +418,7 @@ namespace Components // Tell command Command::AddSV("tell", [](Command::Params* params) { - if (params->length() < 3) return; + if (params->size() < 3) return; int client = atoi(params->get(1)); std::string message = params->join(2); @@ -439,7 +439,7 @@ namespace Components // Sayraw command Command::AddSV("sayraw", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string message = params->join(1); Game::SV_GameSendServerCommand(-1, 0, Utils::String::VA("%c \"%s\"", 104, message.data())); @@ -449,33 +449,13 @@ namespace Components // Tellraw command Command::AddSV("tellraw", [](Command::Params* params) { - if (params->length() < 3) return; + if (params->size() < 3) return; int client = atoi(params->get(1)); std::string message = params->join(2); Game::SV_GameSendServerCommand(client, 0, Utils::String::VA("%c \"%s\"", 104, message.data())); Game::Com_Printf(15, "Raw -> %i: %s\n", client, message.data()); }); - - // ! command - Command::AddSV("!", [](Command::Params* params) - { - if (params->length() != 2) return; - - int client = -1; - if (params->get(1) != "all"s) - { - client = atoi(params->get(1)); - - if (client >= *reinterpret_cast(0x31D938C)) - { - Game::Com_Printf(0, "Invalid player.\n"); - return; - } - } - - Game::SV_GameSendServerCommand(client, 0, Utils::String::VA("%c \"\"", 106)); - }); }); } } diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index 5e6f8a60..c9e385ba 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -181,22 +181,22 @@ namespace Components } } - template<> static Dvar::Var Dvar::Register(const char* name, bool value, Dvar::Flag flag, const char* description) + template<> Dvar::Var Dvar::Register(const char* name, bool value, Dvar::Flag flag, const char* description) { return Game::Dvar_RegisterBool(name, value, flag.val, description); } - template<> static Dvar::Var Dvar::Register(const char* name, const char* value, Dvar::Flag flag, const char* description) + template<> Dvar::Var Dvar::Register(const char* name, const char* value, Dvar::Flag flag, const char* description) { return Game::Dvar_RegisterString(name, value, flag.val, description); } - template<> static Dvar::Var Dvar::Register(const char* name, int value, int min, int max, Dvar::Flag flag, const char* description) + template<> Dvar::Var Dvar::Register(const char* name, int value, int min, int max, Dvar::Flag flag, const char* description) { return Game::Dvar_RegisterInt(name, value, min, max, flag.val, description); } - template<> static Dvar::Var Dvar::Register(const char* name, float value, float min, float max, Dvar::Flag flag, const char* description) + template<> Dvar::Var Dvar::Register(const char* name, float value, float min, float max, Dvar::Flag flag, const char* description) { return Game::Dvar_RegisterFloat(name, value, min, max, flag.val, description); } @@ -336,10 +336,10 @@ namespace Components // remove write protection from fs_game Utils::Hook::Xor(0x6431EA, Game::dvar_flag::DVAR_FLAG_WRITEPROTECTED); - // set cg_fov max to 90.0 - // ...120 because of V2 - static float cgFov90 = 120.0f; - Utils::Hook::Set(0x4F8E28, &cgFov90); + // set cg_fov max to 160.0 + // because that's the max on SP + static float cg_Fov = 160.0f; + Utils::Hook::Set(0x4F8E28, &cg_Fov); // set max volume to 1 static float volume = 1.0f; @@ -385,7 +385,6 @@ namespace Components Utils::Hook(0x59386A, Dvar::DvarSetFromStringByNameStub, HOOK_CALL).install()->quick(); // If the game closed abruptly, the dvars would not have been restored - Dvar::OnInit([] { Dvar::ResetDvarsValue(); diff --git a/src/Components/Modules/Exception.cpp b/src/Components/Modules/Exception.cpp index c5b09faf..3700587b 100644 --- a/src/Components/Modules/Exception.cpp +++ b/src/Components/Modules/Exception.cpp @@ -234,7 +234,7 @@ namespace Components Game::UI_UpdateArenas(); std::string command; - for (auto i = 0; i < (params->length() >= 2 ? atoi(params->get(1)) : *Game::arenaCount); ++i) + for (auto i = 0; i < (params->size() >= 2 ? atoi(params->get(1)) : *Game::arenaCount); ++i) { const auto* mapname = ArenaLength::NewArenas[i % *Game::arenaCount].mapName; diff --git a/src/Components/Modules/FastFiles.cpp b/src/Components/Modules/FastFiles.cpp index 2170e3c6..6a900ed1 100644 --- a/src/Components/Modules/FastFiles.cpp +++ b/src/Components/Modules/FastFiles.cpp @@ -594,7 +594,7 @@ namespace Components Command::Add("loadzone", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; Game::XZoneInfo info; info.name = params->get(1); diff --git a/src/Components/Modules/Friends.cpp b/src/Components/Modules/Friends.cpp index d8d483ac..77a8eaa2 100644 --- a/src/Components/Modules/Friends.cpp +++ b/src/Components/Modules/Friends.cpp @@ -583,7 +583,7 @@ namespace Components Command::Add("addFriend", [](Command::Params* params) { - if (params->length() < 2u) + if (params->size() < 2u) { Logger::Print("Usage: %s \n", params->get(0)); return; diff --git a/src/Components/Modules/Gamepad.cpp b/src/Components/Modules/Gamepad.cpp index 445868aa..5b6de852 100644 --- a/src/Components/Modules/Gamepad.cpp +++ b/src/Components/Modules/Gamepad.cpp @@ -1641,7 +1641,7 @@ namespace Components void Gamepad::Axis_Bind_f(Command::Params* params) { - if (params->length() < 4) + if (params->size() < 4) { Logger::Print("bindaxis \n"); return; diff --git a/src/Components/Modules/Logger.cpp b/src/Components/Modules/Logger.cpp index 75f2ec3b..69a8e9e6 100644 --- a/src/Components/Modules/Logger.cpp +++ b/src/Components/Modules/Logger.cpp @@ -261,7 +261,7 @@ namespace Components { Command::AddSV("log_add", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; Network::Address addr(params->get(1)); @@ -273,7 +273,7 @@ namespace Components Command::AddSV("log_del", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; int num = atoi(params->get(1)); if (Utils::String::VA("%i", num) == std::string(params->get(1)) && static_cast(num) < Logger::LoggingAddresses[0].size()) @@ -312,7 +312,7 @@ namespace Components Command::AddSV("g_log_add", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; Network::Address addr(params->get(1)); @@ -324,7 +324,7 @@ namespace Components Command::AddSV("g_log_del", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; int num = atoi(params->get(1)); if (Utils::String::VA("%i", num) == std::string(params->get(1)) && static_cast(num) < Logger::LoggingAddresses[1].size()) diff --git a/src/Components/Modules/Menus.cpp b/src/Components/Modules/Menus.cpp index 9f7faa12..f3cf9b05 100644 --- a/src/Components/Modules/Menus.cpp +++ b/src/Components/Modules/Menus.cpp @@ -845,7 +845,7 @@ namespace Components Command::Add("openmenu", [](Command::Params* params) { - if (params->length() != 2) + if (params->size() != 2) { Logger::Print("USAGE: openmenu \n"); return; diff --git a/src/Components/Modules/Node.cpp b/src/Components/Modules/Node.cpp index 7aa1584b..50797f93 100644 --- a/src/Components/Modules/Node.cpp +++ b/src/Components/Modules/Node.cpp @@ -377,7 +377,7 @@ namespace Components Command::Add("addnode", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; Node::Add({ params->get(1) }); }); } diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index afa418ad..abfe36df 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -261,7 +261,7 @@ namespace Components Command::Add("connect", [](Command::Params* params) { - if (params->length() < 2) + if (params->size() < 2) { return; } diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 64ab5efe..30543a79 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -86,17 +86,15 @@ namespace Components void QuickPatch::SelectStringTableEntryInDvarStub() { - Command::ClientParams args; + Command::ClientParams params; - if (args.length() >= 4) + if (params.size() >= 4) { - std::string cmd = args[0]; - std::string table = args[1]; - std::string col = args[2]; - std::string dvarName = args[3]; - Game::dvar_t* dvar = Game::Dvar_FindVar(dvarName.data()); + const auto* dvarName = params[3]; + const auto* dvar = Game::Dvar_FindVar(dvarName); - if (Command::Find(dvarName) || (dvar && (dvar->flags & (Game::DVAR_FLAG_WRITEPROTECTED | Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_READONLY)))) + if (Command::Find(dvarName) || + (dvar != nullptr && dvar->flags & (Game::DVAR_FLAG_WRITEPROTECTED | Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_READONLY))) { return; } @@ -671,7 +669,7 @@ namespace Components Command::Add("dumptechsets", [](Command::Params* param) { - if (param->length() != 2) + if (param->size() != 2) { Logger::Print("usage: dumptechsets | all\n"); return; diff --git a/src/Components/Modules/RCon.cpp b/src/Components/Modules/RCon.cpp index 1ab6fc59..e14f0a4f 100644 --- a/src/Components/Modules/RCon.cpp +++ b/src/Components/Modules/RCon.cpp @@ -11,15 +11,15 @@ namespace Components { Command::Add("rcon", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; - std::string operation = params->get(1); - if (operation == "login") + const auto* operation = params->get(1); + if (std::strcmp(operation, "login") == 0) { - if (params->length() < 3) return; + if (params->size() < 3) return; RCon::Password = params->get(2); } - else if (operation == "logout") + else if (std::strcmp(operation, "logout") == 0) { RCon::Password.clear(); } diff --git a/src/Components/Modules/RawFiles.cpp b/src/Components/Modules/RawFiles.cpp index 30489edf..108da3e0 100644 --- a/src/Components/Modules/RawFiles.cpp +++ b/src/Components/Modules/RawFiles.cpp @@ -24,7 +24,7 @@ namespace Components Command::Add("dumpraw", [](Command::Params* params) { - if (params->length() < 2) + if (params->size() < 2) { Logger::Print("Specify a filename!\n"); return; diff --git a/src/Components/Modules/ServerCommands.cpp b/src/Components/Modules/ServerCommands.cpp index 471b32a6..3cbbde8b 100644 --- a/src/Components/Modules/ServerCommands.cpp +++ b/src/Components/Modules/ServerCommands.cpp @@ -11,11 +11,11 @@ namespace Components bool ServerCommands::OnServerCommand() { - Command::ClientParams params(*Game::cmd_id); + Command::ClientParams params; - for (auto &serverCommandCB : ServerCommands::Commands) + for (const auto& serverCommandCB : ServerCommands::Commands) { - if (params.length() >= 1) + if (params.size() >= 1) { if (params.get(0)[0] == serverCommandCB.first) { diff --git a/src/Components/Modules/Weapon.cpp b/src/Components/Modules/Weapon.cpp index d526c747..e1becfe7 100644 --- a/src/Components/Modules/Weapon.cpp +++ b/src/Components/Modules/Weapon.cpp @@ -37,7 +37,10 @@ namespace Components int Weapon::ParseWeaponConfigStrings() { Command::ClientParams params; - if (params.length() <= 1) return 0; + + if (params.size() <= 1) + return 0; + int index = atoi(params[1]); if (index >= 4139) diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index d3be354b..de49b525 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -1110,7 +1110,7 @@ namespace Components Command::Add("verifyzone", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; /* Utils::Hook(0x4AE9C2, [] { Game::WeaponCompleteDef** varPtr = (Game::WeaponCompleteDef**)0x112A9F4; @@ -1165,7 +1165,7 @@ namespace Components Command::Add("buildzone", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string zoneName = params->get(1); Logger::Print("Building zone '%s'...\n", zoneName.data()); @@ -1455,7 +1455,7 @@ namespace Components Command::Add("listassets", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; Game::XAssetType type = Game::DB_GetXAssetNameType(params->get(1)); if (type != Game::XAssetType::ASSET_TYPE_INVALID) @@ -1470,7 +1470,7 @@ namespace Components Command::Add("loadtempzone", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; if (FastFiles::Exists(params->get(1))) { @@ -1502,7 +1502,7 @@ namespace Components Command::Add("iwiDump", [](Command::Params* params) { - if (params->length() < 2) return; + if (params->size() < 2) return; std::string path = Utils::String::VA("%s\\mods\\%s\\images", Dvar::Var("fs_basepath").get(), params->get(1)); std::vector images = FileSystem::GetSysFileList(path, "iwi", false); diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index ad853b8d..0a7e4b89 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -390,13 +390,8 @@ namespace Game XAssetHeader* DB_XAssetPool = reinterpret_cast(0x7998A8); unsigned int* g_poolSize = reinterpret_cast(0x7995E8); - DWORD* cmd_id = reinterpret_cast(0x1AAC5D0); - DWORD* cmd_argc = reinterpret_cast(0x1AAC614); - char*** cmd_argv = reinterpret_cast(0x1AAC634); - - DWORD* cmd_id_sv = reinterpret_cast(0x1ACF8A0); - DWORD* cmd_argc_sv = reinterpret_cast(0x1ACF8E4); - char*** cmd_argv_sv = reinterpret_cast(0x1ACF904); + CmdArgs* cmd_args = reinterpret_cast(0x1AAC5D0); + CmdArgs* sv_cmd_args = reinterpret_cast(0x1ACF8A0); cmd_function_t** cmd_functions = reinterpret_cast(0x1AAC658); diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 3940ba99..47635d49 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -921,13 +921,9 @@ namespace Game extern XAssetHeader* DB_XAssetPool; extern unsigned int* g_poolSize; - extern DWORD* cmd_id; - extern DWORD* cmd_argc; - extern char*** cmd_argv; - - extern DWORD* cmd_id_sv; - extern DWORD* cmd_argc_sv; - extern char*** cmd_argv_sv; + constexpr auto CMD_MAX_NESTING = 8; + extern CmdArgs* cmd_args; + extern CmdArgs* sv_cmd_args; extern cmd_function_t** cmd_functions; diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 1f8d712d..2ce48006 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -170,8 +170,8 @@ namespace Game typedef enum { CS_FREE = 0x0, - CS_UNKNOWN1 = 0x1, - CS_UNKNOWN2 = 0x2, + CS_ZOMBIE = 0x1, + CS_RECONNECTING = 0x2, CS_CONNECTED = 0x3, CS_CLIENTLOADING = 0x4, CS_ACTIVE = 0x5, @@ -244,6 +244,17 @@ namespace Game struct MenuEventHandlerSet; struct menuDef_t; + struct CmdArgs + { + int nesting; + int localClientNum[8]; + int controllerIndex[8]; + int argc[8]; + const char** argv[8]; + }; + + static_assert(sizeof(CmdArgs) == 132); + typedef struct cmd_function_s { cmd_function_s *next;