Browse Source

RenX.Server: Made a temp fix to getBotCount() until I can figure out why bot_count is incorrect

RenX.ServerList: Fixed a Unicode related bug
pull/3/head
Jessica James 9 years ago
parent
commit
b0da2930f7
  1. BIN
      Release/Bot.lib
  2. BIN
      Release/Plugins/RenX.Core.lib
  3. 17
      RenX.Core/RenX_Server.cpp
  4. 18
      RenX.ServerList/RenX_ServerList.cpp

BIN
Release/Bot.lib

Binary file not shown.

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

17
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;"))

18
RenX.ServerList/RenX_ServerList.cpp

@ -36,11 +36,11 @@ const Jupiter::ReferenceString server_list_game_footer = "\n</body></html>"_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<const unsigned char *>(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<const unsigned char *>(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;

Loading…
Cancel
Save