Browse Source

Changed ping from float to unsigned short.

pull/3/head
JustinAJ 10 years ago
parent
commit
b2695908bb
  1. BIN
      Release/Plugins/RenX.Core.lib
  2. 2
      RenX.Core/RenX_PlayerInfo.h
  3. 32
      RenX.Core/RenX_Server.cpp
  4. 8
      RenX.Core/RenX_Tags.cpp

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

2
RenX.Core/RenX_PlayerInfo.h

@ -55,7 +55,7 @@ namespace RenX
bool isBot = false;
time_t joinTime = 0;
float ping = -1.0f;
unsigned short ping = 0;
float score = 0.0f;
float credits = 0.0f;
unsigned int kills = 0;

32
RenX.Core/RenX_Server.cpp

@ -1095,28 +1095,38 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
header.shiftRight(1);
switch (header[0])
{
case 1: // Client list: Normal Player Data | IP | Steam ID | Start Time | Ping | Kills | Deaths | Score | Credits | Class
case 1: // Client list: Normal Player Data | IP | Steam ID | Start Time | Ping Kills | Deaths | Score | Credits | Class
header.shiftRight(1);
{
PARSE_PLAYER_DATA_P(header);
PlayerInfo *player = getPlayerOrAdd(this, name, id, team, isBot, playerData.asUnsignedLongLong(0), action);
player->ping = static_cast<float>(buff.getToken(4, RenX::DelimC).asDouble());
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));
Jupiter::ReferenceString pingKillsToken = buff.getToken(4, RenX::DelimC);
if (pingKillsToken.isEmpty() == false)
{
player->ping = static_cast<unsigned char>(pingKillsToken.get(0)) * 4;
pingKillsToken.shiftRight(1);
player->kills = pingKillsToken.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;
case 2: // Ping, Score, Credits list: Normal Player Data | Ping | Score | Credits
case 2: // Ping, Score, Credits list: Normal Player Data | Ping Score | Credits
header.shiftRight(1);
{
PARSE_PLAYER_DATA_P(header);
PlayerInfo *player = getPlayerOrAdd(this, name, id, team, isBot, 0U, Jupiter::ReferenceString::empty);
player->ping = static_cast<float>(playerData.asDouble());
player->score = static_cast<float>(action.asDouble());
player->credits = static_cast<float>(buff.getToken(3, RenX::DelimC).asDouble());
if (playerData.isEmpty() == false)
{
player->ping = static_cast<unsigned char>(playerData.get(0)) * 4;
playerData.shiftRight(1);
player->score = playerData.asDouble();
playerData.shiftLeft(1);
}
player->credits = static_cast<float>(action.asDouble());
}
header.shiftLeft(1);
break;

8
RenX.Core/RenX_Tags.cpp

@ -240,7 +240,7 @@ void TagsImp::processTags(Jupiter::StringType &msg, const RenX::Server *server,
msg.replace(this->INTERNAL_TEAM_COLOR_TAG, RenX::getTeamColor(player->team));
msg.replace(this->INTERNAL_TEAM_SHORT_TAG, RenX::getTeamName(player->team));
msg.replace(this->INTERNAL_TEAM_LONG_TAG, RenX::getFullTeamName(player->team));
msg.replace(this->INTERNAL_PING_TAG, Jupiter::StringS::Format("%.2f", player->ping));
msg.replace(this->INTERNAL_PING_TAG, Jupiter::StringS::Format("%hu", player->ping));
msg.replace(this->INTERNAL_SCORE_TAG, Jupiter::StringS::Format("%.0f", player->score));
msg.replace(this->INTERNAL_CREDITS_TAG, Jupiter::StringS::Format("%.0f", player->credits));
msg.replace(this->INTERNAL_KILLS_TAG, Jupiter::StringS::Format("%u", player->kills));
@ -271,9 +271,9 @@ void TagsImp::processTags(Jupiter::StringType &msg, const RenX::Server *server,
msg.replace(this->INTERNAL_VICTIM_TEAM_COLOR_TAG, RenX::getTeamColor(victim->team));
msg.replace(this->INTERNAL_VICTIM_TEAM_SHORT_TAG, RenX::getTeamName(victim->team));
msg.replace(this->INTERNAL_VICTIM_TEAM_LONG_TAG, RenX::getFullTeamName(victim->team));
msg.replace(this->INTERNAL_VICTIM_PING_TAG, Jupiter::StringS::Format("%f", victim->ping));
msg.replace(this->INTERNAL_VICTIM_SCORE_TAG, Jupiter::StringS::Format("%f", victim->score));
msg.replace(this->INTERNAL_VICTIM_CREDITS_TAG, Jupiter::StringS::Format("%f", victim->credits));
msg.replace(this->INTERNAL_VICTIM_PING_TAG, Jupiter::StringS::Format("%hu", victim->ping));
msg.replace(this->INTERNAL_VICTIM_SCORE_TAG, Jupiter::StringS::Format("%.0f", victim->score));
msg.replace(this->INTERNAL_VICTIM_CREDITS_TAG, Jupiter::StringS::Format("%.0f", victim->credits));
msg.replace(this->INTERNAL_VICTIM_KILLS_TAG, Jupiter::StringS::Format("%u", victim->kills));
msg.replace(this->INTERNAL_VICTIM_DEATHS_TAG, Jupiter::StringS::Format("%u", victim->deaths));
msg.replace(this->INTERNAL_VICTIM_KDR_TAG, Jupiter::StringS::Format("%.2f", static_cast<float>(victim->kills) / (victim->deaths == 0 ? 1.0f : static_cast<float>(victim->deaths))));

Loading…
Cancel
Save