Browse Source

Finished player data tracking for RCONv3.

Player beacon disarms, building captures, vehicle steals, and vehicles stolen now tracked; appropriate tags added.
pull/3/head
JustinAJ 10 years ago
parent
commit
ba002c8b5e
  1. BIN
      Release/Plugins/RenX.Core.lib
  2. 4
      RenX.Core/RenX_PlayerInfo.h
  3. 49
      RenX.Core/RenX_Server.cpp
  4. 32
      RenX.Core/RenX_Tags.cpp
  5. 16
      RenX.Core/RenX_Tags.h

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

4
RenX.Core/RenX_PlayerInfo.h

@ -68,6 +68,10 @@ namespace RenX
unsigned int wins = 0;
unsigned int loses = 0;
unsigned int beaconPlacements = 0;
unsigned int beaconDisarms = 0;
unsigned int captures = 0;
unsigned int steals = 0;
unsigned int stolen = 0;
mutable Jupiter::StringS gamePrefix;
mutable Jupiter::StringS formatNamePrefix;

49
RenX.Core/RenX_Server.cpp

@ -154,7 +154,8 @@ int RenX::Server::send(const Jupiter::ReadableString &command)
{
char *t = new char[command.size() + 2];
*t = 'c';
for (size_t i = 0; i != command.size(); i++) t[i + 1] = command.get(i);
for (size_t i = 0; i != command.size(); i++)
t[i + 1] = command.get(i);
t[command.size() + 1] = '\n';
int r;
if (RenX::Server::profile->mustSanitize)
@ -211,7 +212,9 @@ int RenX::Server::sendData(const Jupiter::ReadableString &data)
RenX::PlayerInfo *RenX::Server::getPlayer(int id) const
{
if (RenX::Server::players.size() == 0) return nullptr;
for (Jupiter::DLList<RenX::PlayerInfo>::Node *node = RenX::Server::players.getNode(0); node != nullptr; node = node->next) if (node->data->id == id) return node->data;
for (Jupiter::DLList<RenX::PlayerInfo>::Node *node = RenX::Server::players.getNode(0); node != nullptr; node = node->next)
if (node->data->id == id)
return node->data;
return nullptr;
}
@ -485,9 +488,10 @@ RenX::GameCommand *RenX::Server::getCommand(unsigned int index) const
RenX::GameCommand *RenX::Server::getCommand(const Jupiter::ReadableString &trigger) const
{
RenX::GameCommand *cmd;
for (size_t i = 0; i != RenX::Server::commands.size(); i++)
{
RenX::GameCommand *cmd = RenX::Server::commands.get(i);
cmd = RenX::Server::commands.get(i);
if (cmd->matches(trigger))
return cmd;
}
@ -539,26 +543,22 @@ void RenX::Server::addCommand(RenX::GameCommand *command)
bool RenX::Server::removeCommand(RenX::GameCommand *command)
{
for (size_t i = 0; i != RenX::Server::commands.size(); i++)
{
if (RenX::Server::commands.get(i) == command)
{
delete RenX::Server::commands.remove(i);
return true;
}
}
return false;
}
bool RenX::Server::removeCommand(const Jupiter::ReadableString &trigger)
{
for (size_t i = 0; i != RenX::Server::commands.size(); i++)
{
if (RenX::Server::commands.get(i)->matches(trigger))
{
delete RenX::Server::commands.remove(i);
return true;
}
}
return false;
}
@ -682,6 +682,8 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
player = n->data;
if (player != nullptr)
{
player->score = 0.0f;
player->credits = 0.0f;
player->kills = 0;
player->deaths = 0;
player->suicides = 0;
@ -689,6 +691,11 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
player->vehicleKills = 0;
player->buildingKills = 0;
player->defenceKills = 0;
player->beaconPlacements = 0;
player->beaconDisarms = 0;
player->captures = 0;
player->steals = 0;
player->stolen = 0;
}
}
}
@ -878,7 +885,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
RenX::PlayerInfo *player = parseGetPlayerOrAdd(buff.getToken(4, RenX::DelimC));
Jupiter::ReferenceString objectType = buff.getToken(2, RenX::DelimC);
if (objectType.match("*Beacon"))
player->beaconPlacements++;
player->beaconDisarms++;
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnDisarm(this, player, objectType);
onAction();
@ -903,6 +910,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
}
TeamType oldTeam = teamToken.isEmpty() ? TeamType::None : RenX::getTeam(teamToken.get(0));
RenX::PlayerInfo *player = parseGetPlayerOrAdd(buff.getToken(4, RenX::DelimC));
player->captures++;
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnCapture(this, player, building, oldTeam);
onAction();
@ -936,6 +944,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
if (playerToken.isEmpty() == false)
{
RenX::PlayerInfo *player = parseGetPlayerOrAdd(playerToken);
player->deaths++;
Jupiter::ReferenceString type = buff.getToken(4, RenX::DelimC);
Jupiter::ReferenceString damageType;
if (type.equals("by"))
@ -965,6 +974,9 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
else
kID = kIDToken.asInt();
RenX::PlayerInfo *killer = getPlayerOrAdd(kName, kID, vTeam, kIsBot, 0, Jupiter::ReferenceString::empty);
killer->kills++;
if (damageType.equals("Rx_DmgType_Headshot"))
killer->headshots++;
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnKill(this, killer, player, damageType);
}
@ -977,6 +989,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
}
else if (type.equals("suicide by"))
{
player->suicides++;
damageType = buff.getToken(5, RenX::DelimC);
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnSuicide(this, player, damageType);
@ -993,6 +1006,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
if (byLine.equals("by"))
{
RenX::PlayerInfo *player = parseGetPlayerOrAdd(buff.getToken(4, RenX::DelimC));
player->steals++;
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnSteal(this, player, vehicle);
}
@ -1000,6 +1014,8 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
{
RenX::PlayerInfo *victim = parseGetPlayerOrAdd(buff.getToken(4, RenX::DelimC));
RenX::PlayerInfo *player = parseGetPlayerOrAdd(buff.getToken(6, RenX::DelimC));
player->steals++;
victim->stolen++;
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnSteal(this, player, vehicle, victim);
}
@ -1036,10 +1052,8 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
team = RenX::getTeam(teamToken.get(0));
if (idToken.equals("ai") || idToken.isEmpty())
{
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnDestroy(this, name, team, objectName, RenX::getEnemy(team), damageType, type);
}
else
{
int id;
@ -1051,6 +1065,20 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
}
id = idToken.asInt();
RenX::PlayerInfo *player = getPlayerOrAdd(name, id, team, isBot, 0, Jupiter::ReferenceString::empty);
switch (type)
{
case RenX::ObjectType::Vehicle:
player->vehicleKills++;
break;
case RenX::ObjectType::Building:
player->buildingKills++;
break;
case RenX::ObjectType::Defence:
player->defenceKills++;
break;
default:
break;
}
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnDestroy(this, player, objectName, damageType, type);
}
@ -1149,6 +1177,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
if (buff.getToken(5, RenX::DelimC).equals("steamid"))
steamid = buff.getToken(6, RenX::DelimC).asUnsignedLongLong();
RenX::PlayerInfo *player = getPlayerOrAdd(name, id, team, isBot, steamid, buff.getToken(4, RenX::DelimC));
player->joinTime = time(0);
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnJoin(this, player);
}

32
RenX.Core/RenX_Tags.cpp

@ -102,6 +102,10 @@ TagsImp::TagsImp()
this->INTERNAL_WINS_TAG = this->getUniqueInternalTag();
this->INTERNAL_LOSES_TAG = this->getUniqueInternalTag();
this->INTERNAL_BEACON_PLACEMENTS_TAG = this->getUniqueInternalTag();
this->INTERNAL_BEACON_DISARMS_TAG = this->getUniqueInternalTag();
this->INTERNAL_CAPTURES_TAG = this->getUniqueInternalTag();
this->INTERNAL_STEALS_TAG = this->getUniqueInternalTag();
this->INTERNAL_STOLEN_TAG = this->getUniqueInternalTag();
this->INTERNAL_ACCESS_TAG = this->getUniqueInternalTag();
/** Victim tags */
@ -133,6 +137,10 @@ TagsImp::TagsImp()
this->INTERNAL_VICTIM_WINS_TAG = this->getUniqueInternalTag();
this->INTERNAL_VICTIM_LOSES_TAG = this->getUniqueInternalTag();
this->INTERNAL_VICTIM_BEACON_PLACEMENTS_TAG = this->getUniqueInternalTag();
this->INTERNAL_VICTIM_BEACON_DISARMS_TAG = this->getUniqueInternalTag();
this->INTERNAL_VICTIM_CAPTURES_TAG = this->getUniqueInternalTag();
this->INTERNAL_VICTIM_STEALS_TAG = this->getUniqueInternalTag();
this->INTERNAL_VICTIM_STOLEN_TAG = this->getUniqueInternalTag();
this->INTERNAL_VICTIM_ACCESS_TAG = this->getUniqueInternalTag();
/** Other tags */
@ -187,6 +195,10 @@ TagsImp::TagsImp()
this->winsTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("WinsTag"), STRING_LITERAL_AS_REFERENCE("{WINS}"));
this->losesTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("LosesTag"), STRING_LITERAL_AS_REFERENCE("{LOSES}"));
this->beaconPlacementsTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("BeaconPlacementsTag"), STRING_LITERAL_AS_REFERENCE("{BEACONPLACEMENTS}"));
this->beaconDisarmsTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("BeaconDisarmsTag"), STRING_LITERAL_AS_REFERENCE("{BEACONDISARMS}"));
this->capturesTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("CapturesTag"), STRING_LITERAL_AS_REFERENCE("{CAPTURES}"));
this->stealsTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("StealsTag"), STRING_LITERAL_AS_REFERENCE("{STEALS}"));
this->stolenTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("StolenTag"), STRING_LITERAL_AS_REFERENCE("{STOLEN}"));
this->accessTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("AccessTag"), STRING_LITERAL_AS_REFERENCE("{ACCESS}"));
/** Victim player tags */
@ -218,6 +230,10 @@ TagsImp::TagsImp()
this->victimWinsTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimWinsTag"), STRING_LITERAL_AS_REFERENCE("{VWINS}"));
this->victimLosesTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimLosesTag"), STRING_LITERAL_AS_REFERENCE("{VLOSES}"));
this->victimBeaconPlacementsTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimBeaconPlacementsTag"), STRING_LITERAL_AS_REFERENCE("{VBEACONPLACEMENTS}"));
this->victimBeaconDisarmsTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimBeaconDisarmsTag"), STRING_LITERAL_AS_REFERENCE("{VBEACONDISARMS}"));
this->victimCapturesTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimCapturesTag"), STRING_LITERAL_AS_REFERENCE("{VCAPTURES}"));
this->victimStealsTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimStealsTag"), STRING_LITERAL_AS_REFERENCE("{VSTEALS}"));
this->victimStolenTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimStolenTag"), STRING_LITERAL_AS_REFERENCE("{VSTOLEN}"));
this->victimAccessTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimAccessTag"), STRING_LITERAL_AS_REFERENCE("{VACCESS}"));
/** Other tags */
@ -280,6 +296,10 @@ void TagsImp::processTags(Jupiter::StringType &msg, const RenX::Server *server,
msg.replace(this->INTERNAL_WINS_TAG, Jupiter::StringS::Format("%u", player->wins));
msg.replace(this->INTERNAL_LOSES_TAG, Jupiter::StringS::Format("%u", player->loses));
msg.replace(this->INTERNAL_BEACON_PLACEMENTS_TAG, Jupiter::StringS::Format("%u", player->beaconPlacements));
msg.replace(this->INTERNAL_BEACON_DISARMS_TAG, Jupiter::StringS::Format("%u", player->beaconDisarms));
msg.replace(this->INTERNAL_CAPTURES_TAG, Jupiter::StringS::Format("%u", player->captures));
msg.replace(this->INTERNAL_STEALS_TAG, Jupiter::StringS::Format("%u", player->steals));
msg.replace(this->INTERNAL_STOLEN_TAG, Jupiter::StringS::Format("%u", player->stolen));
msg.replace(this->INTERNAL_ACCESS_TAG, Jupiter::StringS::Format("%d", player->access));
}
if (victim != nullptr)
@ -311,6 +331,10 @@ void TagsImp::processTags(Jupiter::StringType &msg, const RenX::Server *server,
msg.replace(this->INTERNAL_VICTIM_WINS_TAG, Jupiter::StringS::Format("%u", victim->wins));
msg.replace(this->INTERNAL_VICTIM_LOSES_TAG, Jupiter::StringS::Format("%u", victim->loses));
msg.replace(this->INTERNAL_VICTIM_BEACON_PLACEMENTS_TAG, Jupiter::StringS::Format("%u", victim->beaconPlacements));
msg.replace(this->INTERNAL_VICTIM_BEACON_DISARMS_TAG, Jupiter::StringS::Format("%u", victim->beaconDisarms));
msg.replace(this->INTERNAL_VICTIM_CAPTURES_TAG, Jupiter::StringS::Format("%u", victim->captures));
msg.replace(this->INTERNAL_VICTIM_STEALS_TAG, Jupiter::StringS::Format("%u", victim->steals));
msg.replace(this->INTERNAL_VICTIM_STOLEN_TAG, Jupiter::StringS::Format("%u", victim->stolen));
msg.replace(this->INTERNAL_VICTIM_ACCESS_TAG, Jupiter::StringS::Format("%d", victim->access));
}
@ -363,6 +387,10 @@ void TagsImp::sanitizeTags(Jupiter::StringType &fmt)
fmt.replace(this->winsTag, this->INTERNAL_WINS_TAG);
fmt.replace(this->losesTag, this->INTERNAL_LOSES_TAG);
fmt.replace(this->beaconPlacementsTag, this->INTERNAL_BEACON_PLACEMENTS_TAG);
fmt.replace(this->beaconDisarmsTag, this->INTERNAL_BEACON_DISARMS_TAG);
fmt.replace(this->capturesTag, this->INTERNAL_CAPTURES_TAG);
fmt.replace(this->stealsTag, this->INTERNAL_STEALS_TAG);
fmt.replace(this->stolenTag, this->INTERNAL_STOLEN_TAG);
fmt.replace(this->accessTag, this->INTERNAL_ACCESS_TAG);
/** Victim tags */
@ -394,6 +422,10 @@ void TagsImp::sanitizeTags(Jupiter::StringType &fmt)
fmt.replace(this->victimWinsTag, this->INTERNAL_VICTIM_WINS_TAG);
fmt.replace(this->victimLosesTag, this->INTERNAL_VICTIM_LOSES_TAG);
fmt.replace(this->victimBeaconPlacementsTag, this->INTERNAL_VICTIM_BEACON_PLACEMENTS_TAG);
fmt.replace(this->victimBeaconDisarmsTag, this->INTERNAL_VICTIM_BEACON_DISARMS_TAG);
fmt.replace(this->victimCapturesTag, this->INTERNAL_VICTIM_CAPTURES_TAG);
fmt.replace(this->victimStealsTag, this->INTERNAL_VICTIM_STEALS_TAG);
fmt.replace(this->victimStolenTag, this->INTERNAL_VICTIM_STOLEN_TAG);
fmt.replace(this->victimAccessTag, this->INTERNAL_VICTIM_ACCESS_TAG);
/** Other tags */

16
RenX.Core/RenX_Tags.h

@ -92,6 +92,10 @@ namespace RenX
Jupiter::StringS INTERNAL_WINS_TAG;
Jupiter::StringS INTERNAL_LOSES_TAG;
Jupiter::StringS INTERNAL_BEACON_PLACEMENTS_TAG;
Jupiter::StringS INTERNAL_BEACON_DISARMS_TAG;
Jupiter::StringS INTERNAL_CAPTURES_TAG;
Jupiter::StringS INTERNAL_STEALS_TAG;
Jupiter::StringS INTERNAL_STOLEN_TAG;
Jupiter::StringS INTERNAL_ACCESS_TAG;
/** Victim tags */
@ -123,6 +127,10 @@ namespace RenX
Jupiter::StringS INTERNAL_VICTIM_WINS_TAG;
Jupiter::StringS INTERNAL_VICTIM_LOSES_TAG;
Jupiter::StringS INTERNAL_VICTIM_BEACON_PLACEMENTS_TAG;
Jupiter::StringS INTERNAL_VICTIM_BEACON_DISARMS_TAG;
Jupiter::StringS INTERNAL_VICTIM_CAPTURES_TAG;
Jupiter::StringS INTERNAL_VICTIM_STEALS_TAG;
Jupiter::StringS INTERNAL_VICTIM_STOLEN_TAG;
Jupiter::StringS INTERNAL_VICTIM_ACCESS_TAG;
/** Other tags */
@ -177,6 +185,10 @@ namespace RenX
Jupiter::StringS winsTag;
Jupiter::StringS losesTag;
Jupiter::StringS beaconPlacementsTag;
Jupiter::StringS beaconDisarmsTag;
Jupiter::StringS capturesTag;
Jupiter::StringS stealsTag;
Jupiter::StringS stolenTag;
Jupiter::StringS accessTag;
/** Victim tags */
@ -208,6 +220,10 @@ namespace RenX
Jupiter::StringS victimWinsTag;
Jupiter::StringS victimLosesTag;
Jupiter::StringS victimBeaconPlacementsTag;
Jupiter::StringS victimBeaconDisarmsTag;
Jupiter::StringS victimCapturesTag;
Jupiter::StringS victimStealsTag;
Jupiter::StringS victimStolenTag;
Jupiter::StringS victimAccessTag;
/** Other tags */

Loading…
Cancel
Save