Browse Source

Fixed eXtended RCON client list and ping/score/credit list parsing; Added changeTeam() and setTeam() functions.

pull/3/head
JustinAJ 10 years ago
parent
commit
2c373c2ebb
  1. BIN
      Release/Plugins/RenX.Core.lib
  2. 34
      RenX.Core/RenX_Server.cpp
  3. 38
      RenX.Core/RenX_Server.h

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

34
RenX.Core/RenX_Server.cpp

@ -368,6 +368,26 @@ bool RenX::Server::giveCredits(RenX::PlayerInfo *player, double credits)
return RenX::Server::giveCredits(player->id, credits);
}
bool RenX::Server::changeTeam(int id, unsigned char options)
{
return RenX::Server::xRconVersion != 0 && RenX::Server::sock.send(Jupiter::StringS::Format("_x\x07%d%c%c\n", id, RenX::DelimC, options)) > 0;
}
bool RenX::Server::changeTeam(RenX::PlayerInfo *player, unsigned char options)
{
return RenX::Server::changeTeam(player->id, options);
}
bool RenX::Server::setTeam(int id, int team, unsigned char options)
{
return RenX::Server::xRconVersion != 0 && RenX::Server::sock.send(Jupiter::StringS::Format("_x\x07%d%c%c%c%d\n", id, RenX::DelimC, options, RenX::DelimC, team)) > 0;
}
bool RenX::Server::setTeam(RenX::PlayerInfo *player, int team, unsigned char options)
{
return RenX::Server::setTeam(player->id, team, options);
}
const Jupiter::ReadableString &RenX::Server::getPrefix() const
{
return RenX::Server::IRCPrefix;
@ -1110,12 +1130,12 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
{
PARSE_PLAYER_DATA_P(header);
PlayerInfo *player = getPlayerOrAdd(this, name, id, team, isBot, playerData.asUnsignedLongLong(0), action);
player->ping = buff.getToken(4, RenX::DelimC).asUnsignedInt() * 4;
player->kills = buff.getToken(5, RenX::DelimC).asUnsignedInt();
player->deaths = buff.getToken(6, RenX::DelimC).asUnsignedInt();
player->score = static_cast<float>(buff.getToken(7, RenX::DelimC).asDouble());
player->credits = static_cast<float>(buff.getToken(8, RenX::DelimC).asDouble());
player->character = RenX::getCharacter(buff.getToken(9, RenX::DelimC));
player->ping = buff.getToken(3, RenX::DelimC).asUnsignedInt() * 4;
player->kills = buff.getToken(4, RenX::DelimC).asUnsignedInt();
player->deaths = buff.getToken(5, RenX::DelimC).asUnsignedInt();
player->score = static_cast<float>(buff.getToken(6, RenX::DelimC).asDouble());
player->credits = static_cast<float>(buff.getToken(7, RenX::DelimC).asDouble());
player->character = RenX::getCharacter(buff.getToken(8, RenX::DelimC));
}
header.shiftLeft(1);
break;
@ -1126,7 +1146,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
PlayerInfo *player = getPlayerOrAdd(this, name, id, team, isBot, 0U, Jupiter::ReferenceString::empty);
player->ping = playerData.asUnsignedInt();
player->score = static_cast<float>(action.asDouble());
player->credits = static_cast<float>(buff.getToken(4, RenX::DelimC).asDouble());
player->credits = static_cast<float>(buff.getToken(3, RenX::DelimC).asDouble());
}
header.shiftLeft(1);
break;

38
RenX.Core/RenX_Server.h

@ -296,6 +296,44 @@ namespace RenX
*/
bool giveCredits(RenX::PlayerInfo *player, double credits);
/**
* @brief Forces a player to change teams, if the server supports it.
*
* @param id ID of the player to give credits to
* @param options Options to pass to the command
* @return True on success, false otherwise.
*/
bool changeTeam(int id, unsigned char options = 0x03);
/**
* @brief Forces a player to change teams, if the server supports it.
*
* @param player Player to change teams
* @param options Options to pass to the command
* @return True on success, false otherwise.
*/
bool changeTeam(RenX::PlayerInfo *player, unsigned char options = 0x03);
/**
* @brief Forces a player to change teams, if the server supports it.
*
* @param id ID of the player to give credits to
* @param team Team number to switch to
* @param options Options to pass to the command
* @return True on success, false otherwise.
*/
bool setTeam(int id, int team, unsigned char options = 0x03);
/**
* @brief Forces a player to change teams, if the server supports it.
*
* @param player Player to change teams
* @param team Team number to switch to
* @param options Options to pass to the command
* @return True on success, false otherwise.
*/
bool setTeam(RenX::PlayerInfo *player, int team, unsigned char options = 0x03);
/**
* @brief Fetches a server's IRC logging prefix.
*

Loading…
Cancel
Save