maint(stats_handler): refactor code (#94)

This commit is contained in:
2024-08-29 18:17:50 +02:00
committed by GitHub
parent 3b11b9bab9
commit 268e3961e7
24 changed files with 98 additions and 52 deletions
+5 -5
View File
@@ -35,22 +35,22 @@ void info_response_command::handle_command(const network::address& target, const
throw execution_exception{"Invalid challenge"};
}
const auto player_count = atoi(info.get("clients").data());
const auto bot_count = atoi(info.get("bots").data());
const auto player_count = atoi(info.get("clients").c_str());
const auto bot_count = atoi(info.get("bots").c_str());
auto real_player_count = player_count - bot_count;
real_player_count = std::clamp(real_player_count, 0, 18);
server.registered = true;
server.game = game_type;
server.state = game_server::state::can_ping;
server.protocol = atoi(info.get("protocol").data());
server.protocol = atoi(info.get("protocol").c_str());
server.clients = static_cast<unsigned int>(real_player_count);
server.name = info.get("hostname");
server.heartbeat = std::chrono::high_resolution_clock::now();
server.info_string = std::move(info);
console::log("Server registered for game %s (%i):\t%s\t- %s", game.data(), server.protocol,
address.to_string().data(), server.name.data());
console::log("Server registered for game %s (%i):\t%s\t- %s", game.c_str(), server.protocol,
address.to_string().c_str(), server.name.c_str());
});
if (!found)