diff --git a/Release/Bot.lib b/Release/Bot.lib index 187a490..d652ed9 100644 Binary files a/Release/Bot.lib and b/Release/Bot.lib differ diff --git a/Release/Plugins/RenX.Core.lib b/Release/Plugins/RenX.Core.lib index 5080868..36cfc26 100644 Binary files a/Release/Plugins/RenX.Core.lib and b/Release/Plugins/RenX.Core.lib differ diff --git a/RenX.Core/RenX_Server.cpp b/RenX.Core/RenX_Server.cpp index 72c0ef8..28ec8f8 100644 --- a/RenX.Core/RenX_Server.cpp +++ b/RenX.Core/RenX_Server.cpp @@ -351,7 +351,14 @@ std::chrono::milliseconds RenX::Server::getGameTime(const RenX::PlayerInfo *play size_t RenX::Server::getBotCount() const { - return RenX::Server::bot_count; + size_t count = 0; + + for (size_t index = 0; index != this->players.size(); ++index) + if (this->players.get(index)->isBot) + ++count; + + return count; + //return RenX::Server::bot_count; } RenX::PlayerInfo *RenX::Server::getPlayer(int id) const @@ -732,7 +739,7 @@ bool RenX::Server::updateClientList() RenX::Server::lastClientListUpdate = std::chrono::steady_clock::now(); int r = 0; - if (RenX::Server::players.size() != RenX::Server::bot_count) + if (RenX::Server::players.size() != this->getBotCount()) { if (this->rconVersion >= 4) r = RenX::Server::sock.send(STRING_LITERAL_AS_REFERENCE("cclientvarlist ID SCORE CREDITS PING\n")) > 0; @@ -740,7 +747,7 @@ bool RenX::Server::updateClientList() r = RenX::Server::sock.send(STRING_LITERAL_AS_REFERENCE("cclientvarlist ID\xA0""SCORE\xA0""CREDITS\xA0""PING\n")) > 0; } - if (RenX::Server::bot_count != 0) + if (this->getBotCount() != 0) { if (this->rconVersion >= 4) r |= RenX::Server::sock.send(STRING_LITERAL_AS_REFERENCE("cbotvarlist ID SCORE CREDITS\n")) > 0; @@ -785,7 +792,7 @@ bool RenX::Server::gameoverStop() void RenX::Server::gameoverWhenEmpty() { - if (this->players.size() == this->bot_count) + if (this->players.size() == this->getBotCount()) this->gameover(); else this->gameover_when_empty = true; @@ -2673,7 +2680,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line) this->removePlayer(player); } - if (this->gameover_when_empty && this->players.size() == this->bot_count) + if (this->gameover_when_empty && this->players.size() == this->getBotCount()) this->gameover(); } else if (subHeader.equals("Kick;")) diff --git a/RenX.ServerList/RenX_ServerList.cpp b/RenX.ServerList/RenX_ServerList.cpp index dc8b201..1772473 100644 --- a/RenX.ServerList/RenX_ServerList.cpp +++ b/RenX.ServerList/RenX_ServerList.cpp @@ -36,11 +36,11 @@ const Jupiter::ReferenceString server_list_game_footer = "\n"_jrs; Jupiter::String jsonify(const Jupiter::ReadableString &in_str) { - const char *ptr = in_str.ptr(); - size_t str_length = in_str.size(); - Jupiter::String result(str_length); + const unsigned char *ptr = reinterpret_cast(in_str.ptr()); + const unsigned char *end_ptr = ptr + in_str.size(); + Jupiter::String result(in_str.size()); - while (str_length != 0) + while (ptr < end_ptr) { if (*ptr == '\\') // backslash { @@ -82,7 +82,6 @@ Jupiter::String jsonify(const Jupiter::ReadableString &in_str) result += *ptr; ++ptr; - --str_length; } return result; @@ -90,11 +89,11 @@ Jupiter::String jsonify(const Jupiter::ReadableString &in_str) Jupiter::String sanitize_game(const Jupiter::ReadableString &in_str) { - const char *ptr = in_str.ptr(); - size_t str_length = in_str.size(); - Jupiter::String result(str_length); + const unsigned char *ptr = reinterpret_cast(in_str.ptr()); + const unsigned char *end_ptr = ptr + in_str.size(); + Jupiter::String result(in_str.size()); - while (str_length != 0) + while (ptr < end_ptr != 0) { if (*ptr == '\\') // backslash { @@ -140,7 +139,6 @@ Jupiter::String sanitize_game(const Jupiter::ReadableString &in_str) result += *ptr; ++ptr; - --str_length; } return result;