Browse Source

added parsePlayerData() lambda function; Added PARSE_PLAYER_DATA_P macro.

pull/3/head
JustinAJ 10 years ago
parent
commit
23f9b1744f
  1. BIN
      Release/Plugins/RenX.Core.lib
  2. 27
      RenX.Core/RenX_Server.cpp

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

27
RenX.Core/RenX_Server.cpp

@ -572,18 +572,14 @@ void RenX::Server::sendLogChan(const Jupiter::ReadableString &msg) const
}
}
#define PARSE_PLAYER_DATA() \
#define PARSE_PLAYER_DATA_P(playerData) \
Jupiter::ReferenceString name; \
TeamType team; \
int id; \
bool isBot = false; { \
Jupiter::ReferenceString idToken; \
name = playerData.gotoToken(2, ','); \
idToken = playerData.getToken(1, ','); \
if (playerData[0] == ',') team = Other; \
else team = RenX::getTeam(playerData[0]); \
if (idToken[0] == 'b') { idToken.shiftRight(1); isBot = true; } \
id = idToken.asInt(10); }
bool isBot; \
parsePlayerData(playerData, name, team, id, isBot);
#define PARSE_PLAYER_DATA() PARSE_PLAYER_DATA_P(playerData)
void RenX::Server::processLine(const Jupiter::ReadableString &line)
{
@ -667,6 +663,19 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
this->silenceJoins = false;
}
};
auto parsePlayerData = [&](const Jupiter::ReadableString &data, Jupiter::ReferenceString &name, TeamType &team, int &id, bool &isBot)
{
Jupiter::ReferenceString idToken = playerData.getToken(1, ',');
name = Jupiter::ReferenceString::gotoToken(data, 2, ',');
if (idToken.get(0) == 'b')
{
idToken.shiftRight(1);
isBot = true;
}
else
isBot = false;
id = idToken.asInt(10);
};
auto getPlayerOrAdd = [&](RenX::Server *server, const Jupiter::ReadableString &name, int id, RenX::TeamType team, bool isBot, uint64_t steamid, const Jupiter::ReadableString &ip)
{
RenX::PlayerInfo *r = server->getPlayer(id);

Loading…
Cancel
Save