diff --git a/.gitmodules b/.gitmodules index af79585d..2f46cb5f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -40,7 +40,7 @@ [submodule "deps/protobuf"] path = deps/protobuf url = https://github.com/protocolbuffers/protobuf.git - branch = 3.17.x + branch = 3.20.x [submodule "deps/zlib"] path = deps/zlib url = https://github.com/madler/zlib.git diff --git a/deps/protobuf b/deps/protobuf index 5500c72c..6e9e6036 160000 --- a/deps/protobuf +++ b/deps/protobuf @@ -1 +1 @@ -Subproject commit 5500c72c5b616da9f0125bcfab513987a1226e2b +Subproject commit 6e9e60367d8744e86856590d8ea0e793c61deeec diff --git a/src/client/component/bots.cpp b/src/client/component/bots.cpp index 896f00a7..019242fd 100644 --- a/src/client/component/bots.cpp +++ b/src/client/component/bots.cpp @@ -60,7 +60,7 @@ namespace bots if (bot_ent) { - spawn_bot(bot_ent->s.entityNum); + spawn_bot(bot_ent->s.number); } else { diff --git a/src/client/component/command.cpp b/src/client/component/command.cpp index 6b4febb2..c26eea7e 100644 --- a/src/client/component/command.cpp +++ b/src/client/component/command.cpp @@ -1,6 +1,10 @@ #include #include "loader/component_loader.hpp" +#include "game/game.hpp" +#include "game/dvars.hpp" +#include "game/scripting/execution.hpp" + #include "command.hpp" #include "console.hpp" #include "game_console.hpp" @@ -8,11 +12,6 @@ #include "scheduler.hpp" #include "logfile.hpp" -#include "game/game.hpp" -#include "game/dvars.hpp" - -#include "game/scripting/execution.hpp" - #include #include #include @@ -39,8 +38,14 @@ namespace command } } - void client_command(const int client_num) + void client_command(const char client_num) { + if (game::mp::g_entities[client_num].client == nullptr) + { + // Client is not fully connected + return; + } + if (!logfile::client_command_stub(client_num)) { return; @@ -539,9 +544,9 @@ namespace command static void add_commands_generic() { add("quit", game::Quit); - add("crash", []() + add("crash", [] { - *reinterpret_cast(1) = 0; + *reinterpret_cast(1) = 0x12345678; }); add("commandDump", [](const params& argument) diff --git a/src/client/component/logfile.cpp b/src/client/component/logfile.cpp index 2e2b3e4f..64600ffe 100644 --- a/src/client/component/logfile.cpp +++ b/src/client/component/logfile.cpp @@ -32,7 +32,7 @@ namespace logfile return {}; } - const scripting::entity player{game::Scr_GetEntityId(ent->s.entityNum, 0)}; + const scripting::entity player{game::Scr_GetEntityId(ent->s.number, 0)}; return scripting::lua::convert(state, player); } @@ -262,7 +262,7 @@ namespace logfile scheduler::once([cmd, message, self, hidden]() { const scripting::entity level{*game::levelEntityId}; - const scripting::entity player{game::Scr_GetEntityId(self->s.entityNum, 0)}; + const scripting::entity player{game::Scr_GetEntityId(self->s.number, 0)}; scripting::notify(level, cmd, {player, message, hidden}); scripting::notify(player, cmd, {message, hidden}); diff --git a/src/client/component/patches.cpp b/src/client/component/patches.cpp index 9ea0deb6..c84d6c01 100644 --- a/src/client/component/patches.cpp +++ b/src/client/component/patches.cpp @@ -122,7 +122,7 @@ namespace patches command::params_sv params{}; const auto menu_id = atoi(params.get(1)); - const auto client = &svs_clients[ent->s.entityNum]; + const auto client = &svs_clients[ent->s.number]; // 13 => change class if (menu_id == 13 && ent->client->team == game::mp::TEAM_SPECTATOR) diff --git a/src/client/game/structs.hpp b/src/client/game/structs.hpp index 02ee96aa..a75ed125 100644 --- a/src/client/game/structs.hpp +++ b/src/client/game/structs.hpp @@ -1565,7 +1565,7 @@ namespace game struct EntityState { - uint16_t entityNum; + uint16_t number; }; // size = ? #pragma pack(push, 1) diff --git a/src/common/utils/flags.cpp b/src/common/utils/flags.cpp index 09f13114..a90247ac 100644 --- a/src/common/utils/flags.cpp +++ b/src/common/utils/flags.cpp @@ -21,7 +21,8 @@ namespace utils::flags if (wide_flag[0] == L'-') { wide_flag.erase(wide_flag.begin()); - flags.emplace_back(string::convert(wide_flag)); + const auto flag = string::convert(wide_flag); + flags.emplace_back(string::to_lower(flag)); } } @@ -40,14 +41,7 @@ namespace utils::flags parsed = true; } - for (const auto& entry : enabled_flags) - { - if (string::to_lower(entry) == string::to_lower(flag)) - { - return true; - } - } - - return false; + return std::ranges::any_of(enabled_flags.cbegin(), enabled_flags.cend(), + [flag](const auto& elem) { return elem == string::to_lower(flag); }); } } diff --git a/src/common/utils/info_string.cpp b/src/common/utils/info_string.cpp index 3b0287e3..56ed56ab 100644 --- a/src/common/utils/info_string.cpp +++ b/src/common/utils/info_string.cpp @@ -26,7 +26,7 @@ namespace utils return value->second; } - return ""; + return {}; } void info_string::parse(std::string buffer) @@ -49,15 +49,15 @@ namespace utils { //auto first = true; std::string info_string; - for (auto i = this->key_value_pairs_.begin(); i != this->key_value_pairs_.end(); ++i) + for (const auto& [key, val] : this->key_value_pairs_) { //if (first) first = false; /*else*/ info_string.append("\\"); - info_string.append(i->first); // Key + info_string.append(key); info_string.append("\\"); - info_string.append(i->second); // Value + info_string.append(val); } return info_string; diff --git a/src/common/utils/io.cpp b/src/common/utils/io.cpp index 9b161d39..52083ac9 100644 --- a/src/common/utils/io.cpp +++ b/src/common/utils/io.cpp @@ -32,7 +32,7 @@ namespace utils::io if (stream.is_open()) { - stream.write(data.data(), data.size()); + stream.write(data.data(), static_cast(data.size())); stream.close(); return true; } diff --git a/src/common/utils/memory.cpp b/src/common/utils/memory.cpp index 99a03916..12b36e70 100644 --- a/src/common/utils/memory.cpp +++ b/src/common/utils/memory.cpp @@ -72,7 +72,7 @@ namespace utils void* memory::allocate(const size_t length) { - return calloc(length, 1); + return std::calloc(length, 1); } char* memory::duplicate_string(const std::string& string) @@ -86,7 +86,7 @@ namespace utils { if (data) { - ::free(data); + std::free(data); } } diff --git a/tools/protoc.exe b/tools/protoc.exe index 87bf60b6..cc258a52 100644 Binary files a/tools/protoc.exe and b/tools/protoc.exe differ