From f2dd8d5c3802734f5cd7ff1e409ff1adf8d845ab Mon Sep 17 00:00:00 2001 From: Diamante Date: Sat, 4 May 2024 10:15:40 +0200 Subject: [PATCH] fix(elimination_handler): re-write patch (#86) --- .gitmodules | 2 +- deps/curl | 2 +- src/server.cpp | 12 +++++------- src/server_list.hpp | 2 +- src/services/elimination_handler.cpp | 12 +++++------- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.gitmodules b/.gitmodules index 588e7b6..2ca343b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,4 +19,4 @@ [submodule "deps/curl"] path = deps/curl url = https://github.com/curl/curl.git - branch = curl-8_5_0 + branch = curl-8_7_1 diff --git a/deps/curl b/deps/curl index 7161cb1..de7b3e8 160000 --- a/deps/curl +++ b/deps/curl @@ -1 +1 @@ -Subproject commit 7161cb17c01dcff1dc5bf89a18437d9d729f1ecd +Subproject commit de7b3e89218467159a7af72d58cea8425946e97d diff --git a/src/server.cpp b/src/server.cpp index 77f293a..9ba1d9e 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -57,11 +57,11 @@ void server::run_frame() } catch (const service::execution_exception& e) { - console::warn("Execption in service: %s", e.what()); + console::warn("Exception in service: %s", e.what()); } catch (const std::exception& e) { - console::error("Fatal execption in service: %s", e.what()); + console::error("Fatal exception in service: %s", e.what()); } } } @@ -84,8 +84,7 @@ void server::handle_command(const network::address& target, const std::string_vi } #ifdef DEBUG - console::log("Handling command (%s): %.*s - %.*s", target.to_string().data(), command.size(), command.data(), - data.size(), data.data()); + console::log("Handling command (%s): %.*s - %.*s", target.to_string().data(), command.size(), command.data(), data.size(), data.data()); #endif try @@ -94,12 +93,11 @@ void server::handle_command(const network::address& target, const std::string_vi } catch (const service::execution_exception& e) { - console::warn("Execption in command %.*s (%s): %s", command.size(), command.data(), target.to_string().data(), + console::warn("Exception in command %.*s (%s): %s", command.size(), command.data(), target.to_string().data(), e.what()); } catch (const std::exception& e) { - console::error("Fatal execption in command %.*s (%s): %s", command.size(), command.data(), - target.to_string().data(), e.what()); + console::error("Fatal exception in command %.*s (%s): %s", command.size(), command.data(), target.to_string().data(), e.what()); } } diff --git a/src/server_list.hpp b/src/server_list.hpp index 37de262..fdeed1a 100644 --- a/src/server_list.hpp +++ b/src/server_list.hpp @@ -3,7 +3,7 @@ #include "game_server.hpp" #include "network_list.hpp" -class server_list : public network_list +class server_list : public network_list { public: void find_registered_servers(game_type game, int protocol, const access_func& accessor); diff --git a/src/services/elimination_handler.cpp b/src/services/elimination_handler.cpp index fc41ebd..b0f8bb4 100644 --- a/src/services/elimination_handler.cpp +++ b/src/services/elimination_handler.cpp @@ -7,7 +7,7 @@ constexpr size_t MAX_SERVERS_PER_GAME = 10; void elimination_handler::run_frame() { - std::unordered_map> server_count; + std::unordered_map> server_count; auto now = std::chrono::high_resolution_clock::now(); this->get_server().get_server_list().iterate([&](server_list::iteration_context& context) @@ -29,17 +29,15 @@ void elimination_handler::run_frame() if (server.game == game_type::t7 && server.protocol < T7_PROTOCOL) { #ifdef _DEBUG - console::log("Removing T7 server '%s' because they are using an outdated protocol (%i)\n", - context.get_address().to_string().data(), server.protocol); + console::log("Removing T7 server '%s' because they are using an outdated protocol (%i)", context.get_address().to_string().data(), server.protocol); #endif context.remove(); } - ++server_count[server.game][context.get_address()]; - if (server_count[server.game][context.get_address()] >= MAX_SERVERS_PER_GAME) + ++server_count[server.game][context.get_address().to_string(false)]; + if (server_count[server.game][context.get_address().to_string(false)] >= MAX_SERVERS_PER_GAME) { - console::log("Removing server '%s' because it exceeds MAX_SERVERS_PER_GAME\n", - context.get_address().to_string().data()); + console::log("Removing server '%s' because it exceeds MAX_SERVERS_PER_GAME", context.get_address().to_string().data()); context.remove(); } });