|
@ -1448,16 +1448,41 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line) |
|
|
idToken.shiftRight(1); |
|
|
idToken.shiftRight(1); |
|
|
isBot = true; |
|
|
isBot = true; |
|
|
} |
|
|
} |
|
|
|
|
|
else if (idToken == "ai") { |
|
|
|
|
|
isBot = true; |
|
|
|
|
|
} |
|
|
else |
|
|
else |
|
|
isBot = false; |
|
|
isBot = false; |
|
|
id = idToken.asInt(10); |
|
|
id = idToken.asInt(10); |
|
|
}; |
|
|
}; |
|
|
|
|
|
auto get_next_temp_playerinfo = [](const Jupiter::ReadableString &name, RenX::TeamType team, bool isBot) { |
|
|
|
|
|
static RenX::PlayerInfo s_temp_players[4]; |
|
|
|
|
|
static size_t s_temp_player_index{ 0 }; |
|
|
|
|
|
|
|
|
|
|
|
// Go to next temp player
|
|
|
|
|
|
++s_temp_player_index; |
|
|
|
|
|
if (s_temp_player_index >= sizeof(s_temp_players) / sizeof(RenX::PlayerInfo)) { |
|
|
|
|
|
s_temp_player_index = 0; |
|
|
|
|
|
} |
|
|
|
|
|
RenX::PlayerInfo *temp_player = &s_temp_players[s_temp_player_index]; |
|
|
|
|
|
|
|
|
|
|
|
// Populate temp player with input data
|
|
|
|
|
|
temp_player->name = name; |
|
|
|
|
|
temp_player->team = team; |
|
|
|
|
|
temp_player->isBot = isBot; |
|
|
|
|
|
|
|
|
|
|
|
return temp_player; |
|
|
|
|
|
}; |
|
|
auto getPlayerOrAdd = [&](const Jupiter::ReadableString &name, int id, RenX::TeamType team, bool isBot, uint64_t steamid, const Jupiter::ReadableString &ip, const Jupiter::ReadableString &hwid) |
|
|
auto getPlayerOrAdd = [&](const Jupiter::ReadableString &name, int id, RenX::TeamType team, bool isBot, uint64_t steamid, const Jupiter::ReadableString &ip, const Jupiter::ReadableString &hwid) |
|
|
{ |
|
|
{ |
|
|
if (id == 0) { |
|
|
if (id == 0) { |
|
|
// Bad parse; return null player
|
|
|
if (name.isEmpty()) { |
|
|
static RenX::PlayerInfo s_null_player; |
|
|
// Bad parse; return null player
|
|
|
return &s_null_player; |
|
|
static RenX::PlayerInfo s_null_player; |
|
|
|
|
|
return &s_null_player; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return get_next_temp_playerinfo(name, team, isBot); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
RenX::PlayerInfo *player = this->getPlayer(id); |
|
|
RenX::PlayerInfo *player = this->getPlayer(id); |
|
@ -1547,7 +1572,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line) |
|
|
auto parseGetPlayerOrAdd = [&parsePlayerData, &getPlayerOrAdd, this](const Jupiter::ReadableString &token) |
|
|
auto parseGetPlayerOrAdd = [&parsePlayerData, &getPlayerOrAdd, this](const Jupiter::ReadableString &token) |
|
|
{ |
|
|
{ |
|
|
PARSE_PLAYER_DATA_P(token); |
|
|
PARSE_PLAYER_DATA_P(token); |
|
|
if (id == 0) { |
|
|
if (id == 0 && name.isEmpty()) { |
|
|
sendAdmChan(IRCCOLOR "04[Error]" IRCCOLOR" Failed to parse player token: %.*s", token.size(), token.ptr()); |
|
|
sendAdmChan(IRCCOLOR "04[Error]" IRCCOLOR" Failed to parse player token: %.*s", token.size(), token.ptr()); |
|
|
} |
|
|
} |
|
|
return getPlayerOrAdd(name, id, team, isBot, 0U, Jupiter::ReferenceString::empty, Jupiter::ReferenceString::empty); |
|
|
return getPlayerOrAdd(name, id, team, isBot, 0U, Jupiter::ReferenceString::empty, Jupiter::ReferenceString::empty); |
|
|