Browse Source

Added tags system; updated Jupiter

pull/3/head
JustinAJ 10 years ago
parent
commit
3beb213299
  1. 2
      Jupiter
  2. BIN
      Release/Bot.lib
  3. BIN
      Release/Plugins/RenX.Core.lib
  4. 13
      RenX.Announcements/RenX_Announcements.cpp
  5. 7
      RenX.Announcements/RenX_Announcements.h
  6. 2
      RenX.Core/RenX.Core.vcxproj
  7. 6
      RenX.Core/RenX.Core.vcxproj.filters
  8. 9
      RenX.Core/RenX_PlayerInfo.h
  9. 62
      RenX.Core/RenX_Plugin.cpp
  10. 18
      RenX.Core/RenX_Plugin.h
  11. 299
      RenX.Core/RenX_Server.cpp
  12. 10
      RenX.Core/RenX_Server.h
  13. 273
      RenX.Core/RenX_Tags.cpp
  14. 164
      RenX.Core/RenX_Tags.h
  15. 19
      RenX.Greetings/RenX_Greetings.cpp
  16. 6
      RenX.Greetings/RenX_Greetings.h
  17. 687
      RenX.Logging/RenX_Logging.cpp
  18. 70
      RenX.Logging/RenX_Logging.h
  19. 37
      RenX.Medals/RenX_Medals.cpp
  20. 5
      RenX.Medals/RenX_Medals.h

2
Jupiter

@ -1 +1 @@
Subproject commit 6f022059334b893a77cefcafa7713033e1580f7a
Subproject commit 2cd14a3b5bd0b0cf1efe6bec6cbff60af512af02

BIN
Release/Bot.lib

Binary file not shown.

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

13
RenX.Announcements/RenX_Announcements.cpp

@ -1,5 +1,5 @@
/**
* Copyright (C) 2014 Justin James.
* Copyright (C) 2014-2015 Justin James.
*
* This license must be preserved.
* Any applications, libraries, or code which make any use of any
@ -20,6 +20,7 @@
#include "RenX_Announcements.h"
#include "RenX_Core.h"
#include "RenX_Server.h"
#include "RenX_Tags.h"
RenX_AnnouncementsPlugin pluginInstance;
@ -43,8 +44,7 @@ void RenX_AnnouncementsPlugin::announce(unsigned int)
RenX_AnnouncementsPlugin::lastLine = trand;
}
Jupiter::StringS announcement = RenX_AnnouncementsPlugin::announcementsFile.getLine(RenX_AnnouncementsPlugin::lastLine);
announcement.replace(RenX_AnnouncementsPlugin::dateTag, Jupiter::ReferenceString(getTimeFormat(RenX_AnnouncementsPlugin::dateFmt.c_str())));
announcement.replace(RenX_AnnouncementsPlugin::timeTag, Jupiter::ReferenceString(getTimeFormat(RenX_AnnouncementsPlugin::timeFmt.c_str())));
RenX::sanitizeTags(announcement);
Jupiter::String msg;
RenX::Core *core = RenX::getCore();
@ -55,7 +55,7 @@ void RenX_AnnouncementsPlugin::announce(unsigned int)
if (server->players.size() != 0)
{
msg = announcement;
msg.replace(RenX_AnnouncementsPlugin::rulesTag, server->getRules());
RenX::processTags(msg, server);
server->sendMessage(msg);
}
}
@ -69,11 +69,6 @@ int RenX_AnnouncementsPlugin::OnRehash()
int RenX_AnnouncementsPlugin::init()
{
RenX_AnnouncementsPlugin::dateTag = Jupiter::IRC::Client::Config->get(this->getName(), STRING_LITERAL_AS_REFERENCE("DateTag"), STRING_LITERAL_AS_REFERENCE("{DATE}"));
RenX_AnnouncementsPlugin::timeTag = Jupiter::IRC::Client::Config->get(this->getName(), STRING_LITERAL_AS_REFERENCE("TimeTag"), STRING_LITERAL_AS_REFERENCE("{TIME}"));
RenX_AnnouncementsPlugin::rulesTag = Jupiter::IRC::Client::Config->get(this->getName(), STRING_LITERAL_AS_REFERENCE("RulesTag"), STRING_LITERAL_AS_REFERENCE("{RULES}"));;
RenX_AnnouncementsPlugin::dateFmt = Jupiter::IRC::Client::Config->get(this->getName(), STRING_LITERAL_AS_REFERENCE("DateFormat"), STRING_LITERAL_AS_REFERENCE("%A, %B %d, %Y"));
RenX_AnnouncementsPlugin::timeFmt = Jupiter::IRC::Client::Config->get(this->getName(), STRING_LITERAL_AS_REFERENCE("TimeFormat"), STRING_LITERAL_AS_REFERENCE("%H:%M:%S"));
RenX_AnnouncementsPlugin::random = Jupiter::IRC::Client::Config->getBool(STRING_LITERAL_AS_REFERENCE("RenX.Announcements"), STRING_LITERAL_AS_REFERENCE("Random"));
RenX_AnnouncementsPlugin::announcementsFile.load(Jupiter::IRC::Client::Config->get(STRING_LITERAL_AS_REFERENCE("RenX.Announcements"), STRING_LITERAL_AS_REFERENCE("File"), STRING_LITERAL_AS_REFERENCE("Announcements.txt")));

7
RenX.Announcements/RenX_Announcements.h

@ -1,5 +1,5 @@
/**
* Copyright (C) 2014 Justin James.
* Copyright (C) 2014-2015 Justin James.
*
* This license must be preserved.
* Any applications, libraries, or code which make any use of any
@ -43,12 +43,7 @@ private:
bool random;
unsigned int lastLine;
Jupiter::Timer *timer;
Jupiter::StringS dateTag;
Jupiter::StringS timeTag;
Jupiter::StringS rulesTag;
//Jupiter::StringS modsTag;
Jupiter::CStringS dateFmt;
Jupiter::CStringS timeFmt;
Jupiter::File announcementsFile;
};

2
RenX.Core/RenX.Core.vcxproj

@ -79,6 +79,7 @@
<ClInclude Include="RenX_Plugin.h" />
<ClInclude Include="RenX_Server.h" />
<ClInclude Include="RenX_ServerProfile.h" />
<ClInclude Include="RenX_Tags.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="RenX_BanDatabase.cpp" />
@ -88,6 +89,7 @@
<ClCompile Include="RenX_Plugin.cpp" />
<ClCompile Include="RenX_Server.cpp" />
<ClCompile Include="RenX_ServerProfile.cpp" />
<ClCompile Include="RenX_Tags.cpp" />
</ItemGroup>
<ItemGroup>
<Library Include="..\Jupiter\Release\Jupiter.lib" />

6
RenX.Core/RenX.Core.vcxproj.filters

@ -50,6 +50,9 @@
<ClInclude Include="RenX_BanDatabase.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RenX_Tags.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="RenX_Plugin.cpp">
@ -73,5 +76,8 @@
<ClCompile Include="RenX_BanDatabase.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RenX_Tags.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

9
RenX.Core/RenX_PlayerInfo.h

@ -1,5 +1,5 @@
/**
* Copyright (C) 2014 Justin James.
* Copyright (C) 2014-2015 Justin James.
*
* This license must be preserved.
* Any applications, libraries, or code which make any use of any
@ -41,16 +41,23 @@ namespace RenX
*/
struct RENX_API PlayerInfo
{
// TODO: Add backpack
Jupiter::StringS name;
Jupiter::StringS ip;
Jupiter::StringS adminType;
Jupiter::StringS uuid;
Jupiter::StringS character;
Jupiter::StringS vehicle;
uint64_t steamid = 0;
uint32_t ip32 = 0;
TeamType team = Other;
int id = 0;
bool isBot = false;
time_t joinTime = 0;
float ping = -1.0f;
float score = 0.0f;
float credits = 0.0f;
unsigned int kills = 0;
unsigned int deaths = 0;
unsigned int suicides = 0;

62
RenX.Core/RenX_Plugin.cpp

@ -1,5 +1,5 @@
/**
* Copyright (C) 2014 Justin James.
* Copyright (C) 2014-2015 Justin James.
*
* This license must be preserved.
* Any applications, libraries, or code which make any use of any
@ -35,6 +35,16 @@ RenX::Plugin::~Plugin()
}
}
void RenX::Plugin::RenX_SanitizeTags(Jupiter::StringType &)
{
return;
}
void RenX::Plugin::RenX_ProcessTags(Jupiter::StringType &, const RenX::Server *, const RenX::PlayerInfo *, const RenX::PlayerInfo *)
{
return;
}
void RenX::Plugin::RenX_OnPlayerCreate(Server *, const RenX::PlayerInfo *)
{
return;
@ -95,16 +105,31 @@ void RenX::Plugin::RenX_OnKill(Server *, const RenX::PlayerInfo *, const RenX::P
return;
}
void RenX::Plugin::RenX_OnKill(Server *, const Jupiter::ReadableString &, TeamType, const RenX::PlayerInfo *, const Jupiter::ReadableString &)
{
return;
}
void RenX::Plugin::RenX_OnDie(Server *, const RenX::PlayerInfo *, const Jupiter::ReadableString &)
{
return;
}
void RenX::Plugin::RenX_OnDie(Server *, const Jupiter::ReadableString &, TeamType, const Jupiter::ReadableString &)
{
return;
}
void RenX::Plugin::RenX_OnDestroy(Server *, const RenX::PlayerInfo *, const Jupiter::ReadableString &, const Jupiter::ReadableString &, ObjectType)
{
return;
}
void RenX::Plugin::RenX_OnDestroy(Server *, const Jupiter::ReadableString &, TeamType, const Jupiter::ReadableString &, TeamType, const Jupiter::ReadableString &, ObjectType)
{
return;
}
void RenX::Plugin::RenX_OnGameOver(Server *, RenX::WinType, TeamType, int, int)
{
return;
@ -155,6 +180,41 @@ void RenX::Plugin::RenX_OnLog(Server *, const Jupiter::ReadableString &)
return;
}
void RenX::Plugin::RenX_XOnVersion(Server *, unsigned int)
{
return;
}
void RenX::Plugin::RenX_OnGrantCharacter(Server *, const PlayerInfo *, const Jupiter::ReadableString &)
{
return;
}
void RenX::Plugin::RenX_OnGrantWeapon(Server *, const PlayerInfo *, const Jupiter::ReadableString &)
{
return;
}
void RenX::Plugin::RenX_OnSpawnVehicle(Server *, const PlayerInfo *, const Jupiter::ReadableString &)
{
return;
}
void RenX::Plugin::RenX_OnSpawnVehicleNoOwner(Server *, const TeamType, const Jupiter::ReadableString &)
{
return;
}
void RenX::Plugin::RenX_OnMinePlace(Server *, const PlayerInfo *, const Jupiter::ReadableString &)
{
return;
}
void RenX::Plugin::RenX_XOnOther(Server *, const Jupiter::ReadableString &)
{
return;
}
void RenX::Plugin::RenX_OnCommand(Server *, const Jupiter::ReadableString &)
{
return;

18
RenX.Core/RenX_Plugin.h

@ -1,5 +1,5 @@
/**
* Copyright (C) 2014 Justin James.
* Copyright (C) 2014-2015 Justin James.
*
* This license must be preserved.
* Any applications, libraries, or code which make any use of any
@ -38,6 +38,10 @@ namespace RenX
class RENX_API Plugin : public Jupiter::Plugin
{
public:
/** Tag-related events */
virtual void RenX_SanitizeTags(Jupiter::StringType &fmt);
virtual void RenX_ProcessTags(Jupiter::StringType &msg, const Server *server, const PlayerInfo *player, const PlayerInfo *victim);
/** Non-RCON RenX logs */
virtual void RenX_OnPlayerCreate(Server *server, const PlayerInfo *player);
virtual void RenX_OnPlayerDelete(Server *server, const PlayerInfo *player);
@ -57,8 +61,11 @@ namespace RenX
virtual void RenX_OnDeploy(Server *server, const PlayerInfo *player, const Jupiter::ReadableString &object);
virtual void RenX_OnSuicide(Server *server, const PlayerInfo *player, const Jupiter::ReadableString &damageType);
virtual void RenX_OnKill(Server *server, const PlayerInfo *player, const PlayerInfo *victim, const Jupiter::ReadableString &damageType);
virtual void RenX_OnKill(Server *server, const Jupiter::ReadableString &killer, TeamType killerTeam, const PlayerInfo *victim, const Jupiter::ReadableString &damageType);
virtual void RenX_OnDie(Server *server, const PlayerInfo *player, const Jupiter::ReadableString &damageType);
virtual void RenX_OnDie(Server *server, const Jupiter::ReadableString &object, TeamType objectTeam, const Jupiter::ReadableString &damageType);
virtual void RenX_OnDestroy(Server *server, const PlayerInfo *player, const Jupiter::ReadableString &objectName, const Jupiter::ReadableString &damageType, ObjectType type);
virtual void RenX_OnDestroy(Server *server, const Jupiter::ReadableString &killer, TeamType killerTeam, const Jupiter::ReadableString &objectName, TeamType objectTeam, const Jupiter::ReadableString &damageType, ObjectType type);
virtual void RenX_OnGameOver(Server *server, WinType winType, TeamType team, int gScore, int nScore);
virtual void RenX_OnGame(Server *server, const Jupiter::ReadableString &raw);
@ -76,6 +83,15 @@ namespace RenX
/** Other Logs */
virtual void RenX_OnLog(Server *server, const Jupiter::ReadableString &raw);
/** eXtended RCON */
virtual void RenX_XOnVersion(Server *server, unsigned int version);
virtual void RenX_OnGrantCharacter(Server *server, const PlayerInfo *player, const Jupiter::ReadableString &character);
virtual void RenX_OnGrantWeapon(Server *server, const PlayerInfo *player, const Jupiter::ReadableString &weapon);
virtual void RenX_OnSpawnVehicle(Server *server, const PlayerInfo *owner, const Jupiter::ReadableString &vehicle);
virtual void RenX_OnSpawnVehicleNoOwner(Server *server, const TeamType team, const Jupiter::ReadableString &vehicle);
virtual void RenX_OnMinePlace(Server *server, const PlayerInfo *player, const Jupiter::ReadableString &mine);
virtual void RenX_XOnOther(Server *server, const Jupiter::ReadableString &raw);
/** Command type */
virtual void RenX_OnCommand(Server *server, const Jupiter::ReadableString &raw);

299
RenX.Core/RenX_Server.cpp

@ -1,5 +1,5 @@
/**
* Copyright (C) 2014 Justin James.
* Copyright (C) 2014-2015 Justin James.
*
* This license must be preserved.
* Any applications, libraries, or code which make any use of any
@ -572,12 +572,12 @@ void RenX::Server::sendLogChan(const Jupiter::ReadableString &msg) const
}
}
#define PARSE_PLAYER_DATA_P(playerData) \
#define PARSE_PLAYER_DATA_P(DATA) \
Jupiter::ReferenceString name; \
TeamType team; \
int id; \
bool isBot; \
parsePlayerData(playerData, name, team, id, isBot);
parsePlayerData(DATA, name, team, id, isBot);
#define PARSE_PLAYER_DATA() PARSE_PLAYER_DATA_P(playerData)
@ -665,12 +665,12 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
};
auto parsePlayerData = [&](const Jupiter::ReadableString &data, Jupiter::ReferenceString &name, TeamType &team, int &id, bool &isBot)
{
Jupiter::ReferenceString idToken = playerData.getToken(1, ',');
Jupiter::ReferenceString idToken = Jupiter::ReferenceString::getToken(data, 1, ',');
name = Jupiter::ReferenceString::gotoToken(data, 2, ',');
if (playerData[0] == ',')
if (data[0] == ',')
team = Other;
else
team = RenX::getTeam(playerData[0]);
team = RenX::getTeam(data[0]);
if (idToken.get(0) == 'b')
{
idToken.shiftRight(1);
@ -682,34 +682,51 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
};
auto getPlayerOrAdd = [&](RenX::Server *server, const Jupiter::ReadableString &name, int id, RenX::TeamType team, bool isBot, uint64_t steamid, const Jupiter::ReadableString &ip)
{
bool checkBans = false;
RenX::PlayerInfo *r = server->getPlayer(id);
auto checkMissing = [&]()
{
if (r->ip32 == 0 && ip.isEmpty() == false)
{
r->ip = ip;
r->ip32 = Jupiter::Socket::pton4(Jupiter::CStringS(r->ip).c_str());
checkBans = true;
}
if (r->steamid == 0U && steamid != 0U)
{
r->steamid = steamid;
if (this->uuidMode == 0)
r->uuid = this->formatSteamID(r);
checkBans = true;
}
};
if (r == nullptr)
{
checkBans = true;
r = new RenX::PlayerInfo();
r->id = id;
r->name = name;
checkMissing();
if (r->isBot = isBot)
r->formatNamePrefix = IRCCOLOR "05[B]";
r->joinTime = time(nullptr);
r->steamid = steamid;
r->ip = ip;
r->ip32 = Jupiter::Socket::pton4(Jupiter::CStringS(r->ip).c_str());
if (id != 0)
server->players.add(r);
switch (this->uuidMode)
{
default:
case 0:
if (r->steamid != 0)
r->uuid = this->formatSteamID(r);
break;
case 1:
if (this->uuidMode == 1)
r->uuid = r->name;
break;
}
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnPlayerCreate(server, r);
}
else
{
checkMissing();
if (r->name.size() == 0)
r->name = name;
}
r->team = team;
if (checkBans)
{
const Jupiter::ArrayList<RenX::BanDatabase::Entry> &entries = RenX::banDatabase->getEntries();
RenX::BanDatabase::Entry *entry;
for (size_t i = 0; i != entries.size(); i++)
@ -728,8 +745,6 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
}
}
}
else if (r->name.size() == 0) r->name = name;
r->team = team;
return r;
};
@ -767,22 +782,29 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
PARSE_PLAYER_DATA();
RenX::PlayerInfo *player = getPlayerOrAdd(this, name, id, team, isBot, 0, Jupiter::ReferenceString::empty);
Jupiter::ReferenceString victimData = buff.getToken(3, RenX::DelimC);
Jupiter::ReferenceString vname = victimData.getToken(2, ',');
Jupiter::ReferenceString vTeamToken = victimData.getToken(0, ',');
Jupiter::ReferenceString vidToken = victimData.getToken(1, ',');
int vid;
bool visBot = false;
if (vidToken[0] == 'b')
if (vTeamToken.size() != 0 && vidToken.size() != 0)
{
vidToken.shiftRight(1);
visBot = true;
Jupiter::ReferenceString vname = victimData.getToken(2, ',');
int vid;
bool visBot = false;
if (vidToken[0] == 'b')
{
vidToken.shiftRight(1);
visBot = true;
}
vid = vidToken.asInt(10);
TeamType vteam = RenX::getTeam(vTeamToken.get(0));
Jupiter::ReferenceString damageType = buff.getToken(5, RenX::DelimC);
RenX::PlayerInfo *victim = getPlayerOrAdd(this, vname, vid, vteam, visBot, 0, Jupiter::ReferenceString::empty);
player->kills++;
if (damageType.equals("Rx_DmgType_Headshot")) player->headshots++;
victim->deaths++;
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnKill(this, player, victim, damageType);
}
vid = vidToken.asInt(10);
TeamType vteam = RenX::getTeam(victimData.getToken(0, ',')[0]);
Jupiter::ReferenceString damageType = buff.getToken(5, RenX::DelimC);
RenX::PlayerInfo *victim = getPlayerOrAdd(this, vname, vid, vteam, visBot, 0, Jupiter::ReferenceString::empty);
player->kills++;
if (damageType.equals("Rx_DmgType_Headshot")) player->headshots++;
victim->deaths++;
if (this->needsCList)
{
@ -790,9 +812,6 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
this->needsCList = false;
}
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnKill(this, player, victim, damageType);
this->firstKill = true;
this->firstDeath = true;
onAction();
@ -962,11 +981,12 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnExecute(this, playerData, command);
}
else if (action.equals("subscribed")) for (size_t i = 0; i < xPlugins.size(); i++)
else if (action.equals("subscribed"))
{
if (this->rconUser.isEmpty())
this->rconUser = playerData;
xPlugins.get(i)->RenX_OnSubscribe(this, playerData);
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnSubscribe(this, playerData);
}
else for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnRCON(this, buff.gotoToken(1, RenX::DelimC));
@ -1058,6 +1078,200 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
}
break;
case 'x':
header.shiftRight(1);
if (header.size() == 0)
{
header.shiftLeft(1);
break;
}
if (header[0] == 'r') // Command response
{
if (header.size() == 1)
{
header.shiftLeft(1);
break;
}
header.shiftRight(1);
switch (header[0])
{
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));
}
header.shiftLeft(1);
break;
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());
}
header.shiftLeft(1);
break;
case 3: // Echo: Data
break;
case 4: // Add Credits: Normal Player Data | Credits
header.shiftRight(1);
{
PARSE_PLAYER_DATA_P(header);
PlayerInfo *player = getPlayerOrAdd(this, name, id, team, isBot, 0U, Jupiter::ReferenceString::empty);
player->credits = static_cast<float>(playerData.asDouble());
}
header.shiftLeft(1);
break;
case 5: // Ping: {Average Ping}/{Normal Player Data | Ping}
break;
case 6: // Command 2 on Timer: Time interval
break;
default:
break;
}
header.shiftLeft(1);
}
else if (header.equals("version"))
{
RenX::Server::xRconVersion = playerData.asUnsignedInt(10);
if (this->rconUser.equals(action) == false)
this->rconUser = action;
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_XOnVersion(this, RenX::Server::xRconVersion);
RenX::Server::sock.send(STRING_LITERAL_AS_REFERENCE("_x\x01\n"));
}
else if (header.equals("grant_character"))
{
PARSE_PLAYER_DATA();
RenX::PlayerInfo *player = getPlayerOrAdd(this, name, id, team, isBot, 0, Jupiter::ReferenceString::empty);
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnGrantCharacter(this, player, action);
player->character = RenX::getCharacter(action);
}
else if (header.equals("grant_weapon"))
{
PARSE_PLAYER_DATA();
RenX::PlayerInfo *player = getPlayerOrAdd(this, name, id, team, isBot, 0, Jupiter::ReferenceString::empty);
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnGrantWeapon(this, player, action);
}
else if (header.equals("spawn_vehicle"))
{
if (playerData.equalsi("buy"))
{
PARSE_PLAYER_DATA_P(buff.getToken(3, RenX::DelimC));
RenX::PlayerInfo *player = getPlayerOrAdd(this, name, id, team, isBot, 0, Jupiter::ReferenceString::empty);
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnSpawnVehicle(this, player, action);
}
else
{
RenX::TeamType team;
if (playerData.isEmpty())
team = Other;
else
team = RenX::getTeam(playerData.get(0));
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnSpawnVehicleNoOwner(this, team, action);
}
}
else if (header.equals("mine_place"))
{
PARSE_PLAYER_DATA();
RenX::PlayerInfo *player = getPlayerOrAdd(this, name, id, team, isBot, 0, Jupiter::ReferenceString::empty);
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnMinePlace(this, player, action);
}
/*else if (header.equals("mlimit_inc"))
{
}*/
else if (header.equals("kill"))
{
Jupiter::ReferenceString vData = buff.getToken(3, RenX::DelimC);
if (action.isEmpty() == false && vData.isEmpty() == false) // Safety check
{
struct
{
uint8_t type; // 1 = Player, 2 = Non-Player, 3 = None
Jupiter::ReferenceString data;
} killerData, victimData;
Jupiter::ReadableString &damageType = playerData;
killerData.type = action[0];
killerData.data = action.substring(1);
victimData.type = vData[0];
victimData.data = vData.substring(1);
if (killerData.type == 1) // These are already handled in standard RCON logs; update models and move on.
{
{
PARSE_PLAYER_DATA_P(killerData.data.gotoToken(1, ','));
RenX::PlayerInfo *player = getPlayerOrAdd(this, name, id, team, isBot, 0, Jupiter::ReferenceString::empty);
player->character = RenX::getCharacter(killerData.data.getToken(0, ','));
}
if (victimData.type == 1)
{
PARSE_PLAYER_DATA_P(victimData.data.gotoToken(1, ','));
RenX::PlayerInfo *player = getPlayerOrAdd(this, name, id, team, isBot, 0, Jupiter::ReferenceString::empty);
player->character = RenX::getCharacter(victimData.data.getToken(0, ','));
}
}
else if (killerData.type == 3) // No killer!
{
if (victimData.type == 2 && victimData.data.size() != 0)
{
TeamType victimTeam = RenX::getTeam(victimData.data.getToken(0, ',').get(0));
victimData.data = victimData.data.gotoToken(1, ',');
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnDie(this, victimData.data, victimTeam, damageType);
}
}
else if (killerData.data.size() != 0) // Non-player killer (log!)
{
TeamType killerTeam = RenX::getTeam(killerData.data.getToken(0, ',').get(0));
killerData.data = killerData.data.gotoToken(1, ',');
if (victimData.type == 1) // Non-player killed player
{
PARSE_PLAYER_DATA_P(victimData.data.gotoToken(1, ','));
RenX::PlayerInfo *player = getPlayerOrAdd(this, name, id, team, isBot, 0, Jupiter::ReferenceString::empty);
player->character = RenX::getCharacter(victimData.data.getToken(0, ','));
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnKill(this, killerData.data, killerTeam, player, damageType);
}
else if (victimData.data.size() != 0) // Non-player destroyed non-player
{
TeamType victimTeam = RenX::getTeam(victimData.data.getToken(0, ',').get(0));
victimData.data = victimData.data.gotoToken(1, ',');
ObjectType type;
if (victimData.data.match("Rx_Building_*"))
type = Building;
else if (victimData.data.match("Rx_Defence_*"))
type = Defence;
else
type = Vehicle;
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnDestroy(this, killerData.data, killerTeam, victimData.data, victimTeam, damageType, type);
}
}
}
}
else
{
buff.shiftRight(1);
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_XOnOther(this, buff);
buff.shiftLeft(1);
}
header.shiftLeft(1);
break;
case 'c':
buff.shiftRight(1);
for (size_t i = 0; i < xPlugins.size(); i++)
@ -1158,6 +1372,11 @@ unsigned int RenX::Server::getVersion() const
return RenX::Server::rconVersion;
}
unsigned int RenX::Server::getXVersion() const
{
return RenX::Server::xRconVersion;
}
const Jupiter::ReadableString &RenX::Server::getGameVersion() const
{
return RenX::Server::gameVersion;

10
RenX.Core/RenX_Server.h

@ -1,5 +1,5 @@
/**
* Copyright (C) 2014 Justin James.
* Copyright (C) 2014-2015 Justin James.
*
* This license must be preserved.
* Any applications, libraries, or code which make any use of any
@ -473,6 +473,13 @@ namespace RenX
*/
unsigned int getVersion() const;
/**
* @brief Fetches the eXtended-RCON version number, or 0 or none has been set.
*
* @return XRCON version number
*/
unsigned int getXVersion() const;
/**
* @brief Fetches the game version string, or an empty string if none has been set.
*
@ -513,6 +520,7 @@ namespace RenX
bool firstDeath = false;
bool firstAction = false;
unsigned int rconVersion = 0;
unsigned int xRconVersion = 0;
time_t lastAttempt = 0;
Jupiter::String lastLine;
Jupiter::StringS gameVersion;

273
RenX.Core/RenX_Tags.cpp

@ -0,0 +1,273 @@
/**
* Copyright (C) 2015 Justin James.
*
* This license must be preserved.
* Any applications, libraries, or code which make any use of any
* component of this program must not be commercial, unless explicit
* permission is granted from the original author. The use of this
* program for non-profit purposes is permitted.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* In the event that this license restricts you from making desired use of this program, contact the original author.
* Written by Justin James <justin.aj@hotmail.com>
*/
#include "Jupiter/Reference_String.h"
#include "Jupiter/INIFile.h"
#include "Jupiter/IRC_Client.h"
#include "RenX_Core.h"
#include "RenX_Functions.h"
#include "RenX_Server.h"
#include "RenX_PlayerInfo.h"
#include "RenX_Plugin.h"
#include "RenX_Tags.h"
struct TagsImp : RenX::Tags
{
TagsImp();
void processTags(Jupiter::StringType &msg, const RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim);
void sanitizeTags(Jupiter::StringType &fmt);
} _tags;
RenX::Tags *RenX::tags = &_tags;
TagsImp::TagsImp()
{
const Jupiter::ReadableString &configSection = Jupiter::IRC::Client::Config->get(RenX::getCore()->getName(), STRING_LITERAL_AS_REFERENCE("TagDefinitions"), RenX::getCore()->getName());
/** Global formats */
this->dateFmt = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("DateFormat"), STRING_LITERAL_AS_REFERENCE("%A, %B %d, %Y"));
this->timeFmt = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("TimeFormat"), STRING_LITERAL_AS_REFERENCE("%H:%M:%S"));;
/** Internal message tags */
/** Global tags */
this->INTERNAL_DATE_TAG = STRING_LITERAL_AS_REFERENCE("\0DAT\0");
this->INTERNAL_TIME_TAG = STRING_LITERAL_AS_REFERENCE("\0TIM\0");
/** Server tags */
this->INTERNAL_RCON_VERSION_TAG = STRING_LITERAL_AS_REFERENCE("\0RVER\0");
this->INTERNAL_GAME_VERSION_TAG = STRING_LITERAL_AS_REFERENCE("\0GVER\0");
this->INTERNAL_XRCON_VERSION_TAG = STRING_LITERAL_AS_REFERENCE("\0XVER\0");
this->INTERNAL_RULES_TAG = STRING_LITERAL_AS_REFERENCE("\0RUL\0");
/** Player tags*/
this->INTERNAL_NAME_TAG = STRING_LITERAL_AS_REFERENCE("\0NAME\0");
this->INTERNAL_RAW_NAME_TAG = STRING_LITERAL_AS_REFERENCE("\0RNAME\0");
this->INTERNAL_IP_TAG = STRING_LITERAL_AS_REFERENCE("\0IP\0");
this->INTERNAL_STEAM_TAG = STRING_LITERAL_AS_REFERENCE("\0STEAM\0");
this->INTERNAL_UUID_TAG = STRING_LITERAL_AS_REFERENCE("\0UUID\0");
this->INTERNAL_ID_TAG = STRING_LITERAL_AS_REFERENCE("\0ID\0");
this->INTERNAL_CHARACTER_TAG = STRING_LITERAL_AS_REFERENCE("\0CHR\0");
this->INTERNAL_VEHICLE_TAG = STRING_LITERAL_AS_REFERENCE("\0VEH\0");
this->INTERNAL_ADMIN_TAG = STRING_LITERAL_AS_REFERENCE("\0ADM\0");
this->INTERNAL_PREFIX_TAG = STRING_LITERAL_AS_REFERENCE("\0PFX\0");
this->INTERNAL_GAME_PREFIX_TAG = STRING_LITERAL_AS_REFERENCE("\0GPF\0");
this->INTERNAL_TEAM_COLOR_TAG = STRING_LITERAL_AS_REFERENCE("\0TC\0");
this->INTERNAL_TEAM_SHORT_TAG = STRING_LITERAL_AS_REFERENCE("\0TS\0");
this->INTERNAL_TEAM_LONG_TAG = STRING_LITERAL_AS_REFERENCE("\0TL\0");
/** Victim tags */
this->INTERNAL_VICTIM_NAME_TAG = STRING_LITERAL_AS_REFERENCE("\0VNAME\0");
this->INTERNAL_VICTIM_RAW_NAME_TAG = STRING_LITERAL_AS_REFERENCE("\0VRNAME\0");
this->INTERNAL_VICTIM_IP_TAG = STRING_LITERAL_AS_REFERENCE("\0VIP\0");
this->INTERNAL_VICTIM_STEAM_TAG = STRING_LITERAL_AS_REFERENCE("\0VSTEAM\0");
this->INTERNAL_VICTIM_UUID_TAG = STRING_LITERAL_AS_REFERENCE("\0VUUID\0");
this->INTERNAL_VICTIM_ID_TAG = STRING_LITERAL_AS_REFERENCE("\0VID\0");
this->INTERNAL_VICTIM_CHARACTER_TAG = STRING_LITERAL_AS_REFERENCE("\0VCHR\0");
this->INTERNAL_VICTIM_VEHICLE_TAG = STRING_LITERAL_AS_REFERENCE("\0VVEH\0");
this->INTERNAL_VICTIM_ADMIN_TAG = STRING_LITERAL_AS_REFERENCE("\0VADM\0");
this->INTERNAL_VICTIM_PREFIX_TAG = STRING_LITERAL_AS_REFERENCE("\0VPFX\0");
this->INTERNAL_VICTIM_GAME_PREFIX_TAG = STRING_LITERAL_AS_REFERENCE("\0VGPF\0");
this->INTERNAL_VICTIM_TEAM_COLOR_TAG = STRING_LITERAL_AS_REFERENCE("\0VTC\0");
this->INTERNAL_VICTIM_TEAM_SHORT_TAG = STRING_LITERAL_AS_REFERENCE("\0VTS\0");
this->INTERNAL_VICTIM_TEAM_LONG_TAG = STRING_LITERAL_AS_REFERENCE("\0VTL\0");
/** Other tags */
this->INTERNAL_WEAPON_TAG = STRING_LITERAL_AS_REFERENCE("\0WEP\0");
this->INTERNAL_OBJECT_TAG = STRING_LITERAL_AS_REFERENCE("\0OBJ\0");
this->INTERNAL_MESSAGE_TAG = STRING_LITERAL_AS_REFERENCE("\0MSG\0");
this->INTERNAL_NEW_NAME_TAG = STRING_LITERAL_AS_REFERENCE("\0NNAME\0");
this->INTERNAL_WIN_SCORE_TAG = STRING_LITERAL_AS_REFERENCE("\0WSC\0");
this->INTERNAL_LOSE_SCORE_TAG = STRING_LITERAL_AS_REFERENCE("\0LSC\0");
/** External (config) tags */
/** Global tags */
this->dateTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("DateTag"), STRING_LITERAL_AS_REFERENCE("{DATE}"));
this->timeTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("TimeTag"), STRING_LITERAL_AS_REFERENCE("{TIME}"));
/** Server tags */
this->rconVersionTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("RCONVersionTag"), STRING_LITERAL_AS_REFERENCE("{RVER}"));
this->gameVersionTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("GameVersionTag"), STRING_LITERAL_AS_REFERENCE("{GVER}"));
this->xRconVersionTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("XRCONVersionTag"), STRING_LITERAL_AS_REFERENCE("{XVER}"));
this->rulesTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("RulesTag"), STRING_LITERAL_AS_REFERENCE("{RULES}"));
/** Player tags */
this->nameTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("NameTag"), STRING_LITERAL_AS_REFERENCE("{NAME}"));
this->rawNameTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("RawNameTag"), STRING_LITERAL_AS_REFERENCE("{RNAME}"));
this->ipTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("IPTag"), STRING_LITERAL_AS_REFERENCE("{IP}"));
this->steamTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("SteamTag"), STRING_LITERAL_AS_REFERENCE("{STEAM}"));
this->uuidTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("UUIDTag"), STRING_LITERAL_AS_REFERENCE("{UUID}"));
this->idTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("IDTag"), STRING_LITERAL_AS_REFERENCE("{ID}"));
this->characterTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("CharacterTag"), STRING_LITERAL_AS_REFERENCE("{CHAR}"));
this->vehicleTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VehicleTag"), STRING_LITERAL_AS_REFERENCE("{VEH}"));
this->adminTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("AdminTag"), STRING_LITERAL_AS_REFERENCE("{ADMIN}"));
this->prefixTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("PrefixTag"), STRING_LITERAL_AS_REFERENCE("{PREFIX}"));
this->gamePrefixTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("GamePrefixTag"), STRING_LITERAL_AS_REFERENCE("{GPREFIX}"));
this->teamColorTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("TeamColorTag"), STRING_LITERAL_AS_REFERENCE("{TCOLOR}"));
this->teamShortTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("ShortTeamTag"), STRING_LITERAL_AS_REFERENCE("{TEAMS}"));
this->teamLongTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("LongTeamTag"), STRING_LITERAL_AS_REFERENCE("{TEAML}"));
/** Victim player tags */
this->victimNameTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimNameTag"), STRING_LITERAL_AS_REFERENCE("{VNAME}"));
this->victimRawNameTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimRawNameTag"), STRING_LITERAL_AS_REFERENCE("{VRNAME}"));
this->victimIPTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimIPTag"), STRING_LITERAL_AS_REFERENCE("{VIP}"));
this->victimSteamTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimSteamTag"), STRING_LITERAL_AS_REFERENCE("{VSTEAM}"));
this->victimUUIDTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimUUIDTag"), STRING_LITERAL_AS_REFERENCE("{VUUID}"));
this->victimIDTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimIDTag"), STRING_LITERAL_AS_REFERENCE("{VID}"));
this->victimCharacterTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimCharacterTag"), STRING_LITERAL_AS_REFERENCE("{VCHAR}"));
this->victimVehicleTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimVehicleTag"), STRING_LITERAL_AS_REFERENCE("{VVEH}"));
this->victimAdminTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimAdminTag"), STRING_LITERAL_AS_REFERENCE("{VADMIN}"));
this->victimPrefixTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimPrefixTag"), STRING_LITERAL_AS_REFERENCE("{VPREFIX}"));
this->victimGamePrefixTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimGamePrefixTag"), STRING_LITERAL_AS_REFERENCE("{VGPREFIX}"));
this->victimTeamColorTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimTeamColorTag"), STRING_LITERAL_AS_REFERENCE("{VTCOLOR}"));
this->victimTeamShortTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimShortTeamTag"), STRING_LITERAL_AS_REFERENCE("{VTEAMS}"));
this->victimTeamLongTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimLongTeamTag"), STRING_LITERAL_AS_REFERENCE("{VTEAML}"));
/** Other tags */
this->weaponTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("WeaponTag"), STRING_LITERAL_AS_REFERENCE("{WEAPON}"));
this->objectTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("ObjectTag"), STRING_LITERAL_AS_REFERENCE("{OBJECT}"));
this->messageTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("MessageTag"), STRING_LITERAL_AS_REFERENCE("{MESSAGE}"));
this->newNameTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("NewNameTag"), STRING_LITERAL_AS_REFERENCE("{NNAME}"));
this->winScoreTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("WinScoreTag"), STRING_LITERAL_AS_REFERENCE("{WINSCORE}"));
this->loseScoreTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("LoseScoreTag"), STRING_LITERAL_AS_REFERENCE("{LOSESCORE}"));
}
void TagsImp::processTags(Jupiter::StringType &msg, const RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim)
{
msg.replace(this->INTERNAL_DATE_TAG, Jupiter::ReferenceString(getTimeFormat(this->dateFmt.c_str())));
msg.replace(this->INTERNAL_TIME_TAG, Jupiter::ReferenceString(getTimeFormat(this->timeFmt.c_str())));
if (server != nullptr)
{
msg.replace(this->INTERNAL_RCON_VERSION_TAG, Jupiter::StringS::Format("%u", server->getVersion()));
msg.replace(this->INTERNAL_GAME_VERSION_TAG, server->getGameVersion());
msg.replace(this->INTERNAL_XRCON_VERSION_TAG, Jupiter::StringS::Format("%u", server->getXVersion()));
msg.replace(this->INTERNAL_RULES_TAG, server->getRules());
if (player != nullptr)
{
msg.replace(this->INTERNAL_STEAM_TAG, server->formatSteamID(player));
}
if (victim != nullptr)
{
msg.replace(this->INTERNAL_VICTIM_STEAM_TAG, server->formatSteamID(victim));
}
}
if (player != nullptr)
{
msg.replace(this->INTERNAL_NAME_TAG, RenX::getFormattedPlayerName(player));
msg.replace(this->INTERNAL_RAW_NAME_TAG, player->name);
msg.replace(this->INTERNAL_IP_TAG, player->ip);
msg.replace(this->INTERNAL_UUID_TAG, player->uuid);
msg.replace(this->INTERNAL_ID_TAG, Jupiter::StringS::Format("%d", player->id));
msg.replace(this->INTERNAL_CHARACTER_TAG, RenX::translateName(player->character));
msg.replace(this->INTERNAL_VEHICLE_TAG, RenX::translateName(player->vehicle));
msg.replace(this->INTERNAL_ADMIN_TAG, player->adminType);
msg.replace(this->INTERNAL_PREFIX_TAG, player->formatNamePrefix);
msg.replace(this->INTERNAL_GAME_PREFIX_TAG, player->gamePrefix);
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));
}
if (victim != nullptr)
{
msg.replace(this->INTERNAL_VICTIM_NAME_TAG, RenX::getFormattedPlayerName(victim));
msg.replace(this->INTERNAL_VICTIM_RAW_NAME_TAG, victim->name);
msg.replace(this->INTERNAL_VICTIM_IP_TAG, victim->ip);
msg.replace(this->INTERNAL_VICTIM_UUID_TAG, victim->uuid);
msg.replace(this->INTERNAL_VICTIM_ID_TAG, Jupiter::StringS::Format("%d", victim->id));
msg.replace(this->INTERNAL_VICTIM_CHARACTER_TAG, RenX::translateName(victim->character));
msg.replace(this->INTERNAL_VICTIM_VEHICLE_TAG, RenX::translateName(victim->vehicle));
msg.replace(this->INTERNAL_VICTIM_ADMIN_TAG, victim->adminType);
msg.replace(this->INTERNAL_VICTIM_PREFIX_TAG, victim->formatNamePrefix);
msg.replace(this->INTERNAL_VICTIM_GAME_PREFIX_TAG, victim->gamePrefix);
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));
}
Jupiter::ArrayList<RenX::Plugin> &xPlugins = *RenX::getCore()->getPlugins();
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_ProcessTags(msg, server, player, victim);
}
void TagsImp::sanitizeTags(Jupiter::StringType &fmt)
{
/** Global tags */
fmt.replace(this->dateTag, this->INTERNAL_DATE_TAG);
fmt.replace(this->timeTag, this->INTERNAL_TIME_TAG);
/** Server tags */
fmt.replace(this->rconVersionTag, this->INTERNAL_RCON_VERSION_TAG);
fmt.replace(this->gameVersionTag, this->INTERNAL_GAME_VERSION_TAG);
fmt.replace(this->xRconVersionTag, this->INTERNAL_XRCON_VERSION_TAG);
fmt.replace(this->rulesTag, this->INTERNAL_RULES_TAG);
/** Player tags */
fmt.replace(this->nameTag, this->INTERNAL_NAME_TAG);
fmt.replace(this->rawNameTag, this->INTERNAL_RAW_NAME_TAG);
fmt.replace(this->ipTag, this->INTERNAL_IP_TAG);
fmt.replace(this->steamTag, this->INTERNAL_STEAM_TAG);
fmt.replace(this->uuidTag, this->INTERNAL_UUID_TAG);
fmt.replace(this->idTag, this->INTERNAL_ID_TAG);
fmt.replace(this->characterTag, this->INTERNAL_CHARACTER_TAG);
fmt.replace(this->vehicleTag, this->INTERNAL_VEHICLE_TAG);
fmt.replace(this->adminTag, this->INTERNAL_ADMIN_TAG);
fmt.replace(this->prefixTag, this->INTERNAL_PREFIX_TAG);
fmt.replace(this->gamePrefixTag, this->INTERNAL_GAME_PREFIX_TAG);
fmt.replace(this->teamColorTag, this->INTERNAL_TEAM_COLOR_TAG);
fmt.replace(this->teamShortTag, this->INTERNAL_TEAM_SHORT_TAG);
fmt.replace(this->teamLongTag, this->INTERNAL_TEAM_LONG_TAG);
/** Victim tags */
fmt.replace(this->victimNameTag, this->INTERNAL_VICTIM_NAME_TAG);
fmt.replace(this->victimRawNameTag, this->INTERNAL_VICTIM_RAW_NAME_TAG);
fmt.replace(this->victimIPTag, this->INTERNAL_VICTIM_IP_TAG);
fmt.replace(this->victimSteamTag, this->INTERNAL_VICTIM_STEAM_TAG);
fmt.replace(this->victimUUIDTag, this->INTERNAL_VICTIM_UUID_TAG);
fmt.replace(this->victimIDTag, this->INTERNAL_VICTIM_ID_TAG);
fmt.replace(this->victimCharacterTag, this->INTERNAL_VICTIM_CHARACTER_TAG);
fmt.replace(this->victimVehicleTag, this->INTERNAL_VICTIM_VEHICLE_TAG);
fmt.replace(this->victimAdminTag, this->INTERNAL_VICTIM_ADMIN_TAG);
fmt.replace(this->victimPrefixTag, this->INTERNAL_VICTIM_PREFIX_TAG);
fmt.replace(this->victimGamePrefixTag, this->INTERNAL_VICTIM_GAME_PREFIX_TAG);
fmt.replace(this->victimTeamColorTag, this->INTERNAL_VICTIM_TEAM_COLOR_TAG);
fmt.replace(this->victimTeamShortTag, this->INTERNAL_VICTIM_TEAM_SHORT_TAG);
fmt.replace(this->victimTeamLongTag, this->INTERNAL_VICTIM_TEAM_LONG_TAG);
/** Other tags */
fmt.replace(this->weaponTag, this->INTERNAL_WEAPON_TAG);
fmt.replace(this->objectTag, this->INTERNAL_OBJECT_TAG);
fmt.replace(this->messageTag, this->INTERNAL_MESSAGE_TAG);
fmt.replace(this->newNameTag, this->INTERNAL_NEW_NAME_TAG);
fmt.replace(this->winScoreTag, this->INTERNAL_WIN_SCORE_TAG);
fmt.replace(this->loseScoreTag, this->INTERNAL_LOSE_SCORE_TAG);
Jupiter::ArrayList<RenX::Plugin> &xPlugins = *RenX::getCore()->getPlugins();
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_SanitizeTags(fmt);
}
/** Foward functions */
void RenX::processTags(Jupiter::StringType &msg, const RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim)
{
_tags.processTags(msg, server, player, victim);
}
void RenX::sanitizeTags(Jupiter::StringType &fmt)
{
_tags.sanitizeTags(fmt);
}

164
RenX.Core/RenX_Tags.h

@ -0,0 +1,164 @@
/**
* Copyright (C) 2015 Justin James.
*
* This license must be preserved.
* Any applications, libraries, or code which make any use of any
* component of this program must not be commercial, unless explicit
* permission is granted from the original author. The use of this
* program for non-profit purposes is permitted.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* In the event that this license restricts you from making desired use of this program, contact the original author.
* Written by Justin James <justin.aj@hotmail.com>
*/
#if !defined _RENX_TAGS_H_HEADER
#define _RENX_TAGS_H_HEADER
/**
* @file RenX_Tags.h
* @brief Provides tag processing functions
*/
#include "Jupiter/String.h"
#include "Jupiter/CString.h"
#include "RenX.h"
/** DLL Linkage Nagging */
#if defined _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
namespace RenX
{
/** Forward declarations */
struct PlayerInfo;
class Server;
RENX_API void processTags(Jupiter::StringType &msg, const RenX::Server *server = nullptr, const RenX::PlayerInfo *player = nullptr, const RenX::PlayerInfo *victim = nullptr);
RENX_API void sanitizeTags(Jupiter::StringType &fmt);
struct RENX_API Tags
{
/** Global formats */
Jupiter::CStringS dateFmt;
Jupiter::CStringS timeFmt;
/** Internal message tags */
/** Global tags */
Jupiter::ReferenceString INTERNAL_DATE_TAG;
Jupiter::ReferenceString INTERNAL_TIME_TAG;
/** Server tags */
Jupiter::ReferenceString INTERNAL_RCON_VERSION_TAG;
Jupiter::ReferenceString INTERNAL_GAME_VERSION_TAG;
Jupiter::ReferenceString INTERNAL_XRCON_VERSION_TAG;
Jupiter::ReferenceString INTERNAL_RULES_TAG;
/** Player tags */
Jupiter::ReferenceString INTERNAL_NAME_TAG;
Jupiter::ReferenceString INTERNAL_RAW_NAME_TAG;
Jupiter::ReferenceString INTERNAL_IP_TAG;
Jupiter::ReferenceString INTERNAL_STEAM_TAG;
Jupiter::ReferenceString INTERNAL_UUID_TAG;
Jupiter::ReferenceString INTERNAL_ID_TAG;
Jupiter::ReferenceString INTERNAL_CHARACTER_TAG;
Jupiter::ReferenceString INTERNAL_VEHICLE_TAG;
Jupiter::ReferenceString INTERNAL_ADMIN_TAG;
Jupiter::ReferenceString INTERNAL_PREFIX_TAG;
Jupiter::ReferenceString INTERNAL_GAME_PREFIX_TAG;
Jupiter::ReferenceString INTERNAL_TEAM_COLOR_TAG;
Jupiter::ReferenceString INTERNAL_TEAM_SHORT_TAG;
Jupiter::ReferenceString INTERNAL_TEAM_LONG_TAG;
/** Victim tags */
Jupiter::ReferenceString INTERNAL_VICTIM_NAME_TAG;
Jupiter::ReferenceString INTERNAL_VICTIM_RAW_NAME_TAG;
Jupiter::ReferenceString INTERNAL_VICTIM_IP_TAG;
Jupiter::ReferenceString INTERNAL_VICTIM_STEAM_TAG;
Jupiter::ReferenceString INTERNAL_VICTIM_UUID_TAG;
Jupiter::ReferenceString INTERNAL_VICTIM_ID_TAG;
Jupiter::ReferenceString INTERNAL_VICTIM_CHARACTER_TAG;
Jupiter::ReferenceString INTERNAL_VICTIM_VEHICLE_TAG;
Jupiter::ReferenceString INTERNAL_VICTIM_ADMIN_TAG;
Jupiter::ReferenceString INTERNAL_VICTIM_PREFIX_TAG;
Jupiter::ReferenceString INTERNAL_VICTIM_GAME_PREFIX_TAG;
Jupiter::ReferenceString INTERNAL_VICTIM_TEAM_COLOR_TAG;
Jupiter::ReferenceString INTERNAL_VICTIM_TEAM_SHORT_TAG;
Jupiter::ReferenceString INTERNAL_VICTIM_TEAM_LONG_TAG;
/** Other tags */
Jupiter::ReferenceString INTERNAL_WEAPON_TAG;
Jupiter::ReferenceString INTERNAL_OBJECT_TAG;
Jupiter::ReferenceString INTERNAL_MESSAGE_TAG;
Jupiter::ReferenceString INTERNAL_NEW_NAME_TAG;
Jupiter::ReferenceString INTERNAL_WIN_SCORE_TAG;
Jupiter::ReferenceString INTERNAL_LOSE_SCORE_TAG;
/** External message tags */
/** Global tags */
Jupiter::StringS dateTag;
Jupiter::StringS timeTag;
/** Server tags */
Jupiter::StringS rconVersionTag;
Jupiter::StringS gameVersionTag;
Jupiter::StringS xRconVersionTag;
Jupiter::StringS rulesTag;
/** Player tags */
Jupiter::StringS nameTag;
Jupiter::StringS rawNameTag;
Jupiter::StringS ipTag;
Jupiter::StringS steamTag;
Jupiter::StringS uuidTag;
Jupiter::StringS idTag;
Jupiter::StringS characterTag;
Jupiter::StringS vehicleTag;
Jupiter::StringS adminTag;
Jupiter::StringS prefixTag;
Jupiter::StringS gamePrefixTag;
Jupiter::StringS teamColorTag;
Jupiter::StringS teamShortTag;
Jupiter::StringS teamLongTag;
/** Victim tags */
Jupiter::StringS victimNameTag;
Jupiter::StringS victimRawNameTag;
Jupiter::StringS victimIPTag;
Jupiter::StringS victimSteamTag;
Jupiter::StringS victimUUIDTag;
Jupiter::StringS victimIDTag;
Jupiter::StringS victimCharacterTag;
Jupiter::StringS victimVehicleTag;
Jupiter::StringS victimAdminTag;
Jupiter::StringS victimPrefixTag;
Jupiter::StringS victimGamePrefixTag;
Jupiter::StringS victimTeamColorTag;
Jupiter::StringS victimTeamShortTag;
Jupiter::StringS victimTeamLongTag;
/** Other tags */
Jupiter::StringS weaponTag;
Jupiter::StringS objectTag;
Jupiter::StringS messageTag;
Jupiter::StringS newNameTag;
Jupiter::StringS winScoreTag;
Jupiter::StringS loseScoreTag;
};
RENX_API extern Tags *tags;
}
/** Re-enable warnings */
#if defined _MSC_VER
#pragma warning(pop)
#endif
#endif // _RENX_TAGS_H_HEADER

19
RenX.Greetings/RenX_Greetings.cpp

@ -1,5 +1,5 @@
/**
* Copyright (C) 2014 Justin James.
* Copyright (C) 2014-2015 Justin James.
*
* This license must be preserved.
* Any applications, libraries, or code which make any use of any
@ -15,21 +15,21 @@
* Written by Justin James <justin.aj@hotmail.com>
*/
#include "Jupiter/IRC_Client.h"
#include "Jupiter/INIFile.h"
#include "RenX_Greetings.h"
#include "RenX_PlayerInfo.h"
#include "RenX_Server.h"
#include "Jupiter/IRC_Client.h"
#include "Jupiter/INIFile.h"
#include "RenX_Tags.h"
void RenX_GreetingsPlugin::RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player)
{
auto sendMessage = [&](const Jupiter::ReadableString &m)
{
Jupiter::String msg = m;
msg.replace(this->steamTag, server->formatSteamID(player));
msg.replace(this->ipTag, player->ip);
msg.replace(this->uuidTag, player->uuid);
msg.replace(this->nameTag, player->name);
RenX::sanitizeTags(msg);
RenX::processTags(msg, server, player);
if (this->sendPrivate)
server->sendMessage(player, msg);
@ -79,11 +79,6 @@ void RenX_GreetingsPlugin::init()
if (RenX_GreetingsPlugin::greetingsFile.getLineCount() == 0)
RenX_GreetingsPlugin::greetingsFile.addData(STRING_LITERAL_AS_REFERENCE("Please notify the server administrator to properly configure or disable server greetings.\r\n"));
RenX_GreetingsPlugin::lastLine = RenX_GreetingsPlugin::greetingsFile.getLineCount() - 1;
RenX_GreetingsPlugin::nameTag = Jupiter::IRC::Client::Config->get(RenX_GreetingsPlugin::name, STRING_LITERAL_AS_REFERENCE("NameTag"), STRING_LITERAL_AS_REFERENCE("{NAME}"));
RenX_GreetingsPlugin::ipTag = Jupiter::IRC::Client::Config->get(RenX_GreetingsPlugin::name, STRING_LITERAL_AS_REFERENCE("IPTag"), STRING_LITERAL_AS_REFERENCE("{IP}"));
RenX_GreetingsPlugin::steamTag = Jupiter::IRC::Client::Config->get(RenX_GreetingsPlugin::name, STRING_LITERAL_AS_REFERENCE("SteamTag"), STRING_LITERAL_AS_REFERENCE("{STEAM}"));
RenX_GreetingsPlugin::uuidTag = Jupiter::IRC::Client::Config->get(RenX_GreetingsPlugin::name, STRING_LITERAL_AS_REFERENCE("UUIDTag"), STRING_LITERAL_AS_REFERENCE("{UUID}"));
}
// Plugin instantiation and entry point.

6
RenX.Greetings/RenX_Greetings.h

@ -1,5 +1,5 @@
/**
* Copyright (C) 2014 Justin James.
* Copyright (C) 2014-2015 Justin James.
*
* This license must be preserved.
* Any applications, libraries, or code which make any use of any
@ -40,10 +40,6 @@ private:
unsigned int lastLine;
unsigned int sendMode = 0; /** 0 = Send greetings randomly, 1 = Send greetings sequentially, 2 = Send all greetings */
Jupiter::File greetingsFile;
Jupiter::StringS nameTag;
Jupiter::StringS ipTag;
Jupiter::StringS steamTag;
Jupiter::StringS uuidTag;
STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.Greetings");
};

687
RenX.Logging/RenX_Logging.cpp

File diff suppressed because it is too large

70
RenX.Logging/RenX_Logging.h

@ -35,8 +35,11 @@ public: // RenX::Plugin
void RenX_OnDeploy(RenX::Server *server, const RenX::PlayerInfo *player, const Jupiter::ReadableString &object) override;
void RenX_OnSuicide(RenX::Server *server, const RenX::PlayerInfo *player, const Jupiter::ReadableString &damageType) override;
void RenX_OnKill(RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim, const Jupiter::ReadableString &damageType) override;
void RenX_OnKill(RenX::Server *server, const Jupiter::ReadableString &killer, RenX::TeamType killerTeam, const RenX::PlayerInfo *victim, const Jupiter::ReadableString &damageType) override;
void RenX_OnDie(RenX::Server *server, const RenX::PlayerInfo *player, const Jupiter::ReadableString &damageType) override;
void RenX_OnDie(RenX::Server *server, const Jupiter::ReadableString &object, RenX::TeamType objectTeam, const Jupiter::ReadableString &damageType) override;
void RenX_OnDestroy(RenX::Server *server, const RenX::PlayerInfo *player, const Jupiter::ReadableString &objectName, const Jupiter::ReadableString &damageType, RenX::ObjectType type) override;
void RenX_OnDestroy(RenX::Server *server, const Jupiter::ReadableString &killer, RenX::TeamType killerTeam, const Jupiter::ReadableString &objectName, RenX::TeamType objectTeam, const Jupiter::ReadableString &damageType, RenX::ObjectType type) override;
void RenX_OnGameOver(RenX::Server *server, RenX::WinType winType, RenX::TeamType team, int gScore, int nScore) override;
void RenX_OnGame(RenX::Server *server, const Jupiter::ReadableString &raw) override;
@ -50,6 +53,14 @@ public: // RenX::Plugin
void RenX_OnAdmin(RenX::Server *server, const Jupiter::ReadableString &raw) override;
void RenX_OnLog(RenX::Server *server, const Jupiter::ReadableString &raw) override;
void RenX_XOnVersion(RenX::Server *server, unsigned int version) override;
void RenX_OnGrantCharacter(RenX::Server *server, const RenX::PlayerInfo *player, const Jupiter::ReadableString &character) override;
void RenX_OnSpawnVehicle(RenX::Server *server, const RenX::PlayerInfo *owner, const Jupiter::ReadableString &vehicle) override;
void RenX_OnSpawnVehicleNoOwner(RenX::Server *server, const RenX::TeamType team, const Jupiter::ReadableString &vehicle) override;
void RenX_OnMinePlace(RenX::Server *server, const RenX::PlayerInfo *player, const Jupiter::ReadableString &mine) override;
void RenX_XOnOther(RenX::Server *server, const Jupiter::ReadableString &raw) override;
void RenX_OnCommand(RenX::Server *server, const Jupiter::ReadableString &raw) override;
void RenX_OnError(RenX::Server *server, const Jupiter::ReadableString &raw) override;
void RenX_OnVersion(RenX::Server *server, const Jupiter::ReadableString &raw) override;
@ -64,8 +75,6 @@ public: // Jupiter::Plugin
private:
void init();
void sanitizeTags(Jupiter::StringType &fmt) const;
void processTags(Jupiter::StringType &msg, const RenX::Server *server, const RenX::PlayerInfo *player = nullptr, const RenX::PlayerInfo *victim = nullptr) const;
STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.Logging");
unsigned int joinPublic : 1;
@ -89,52 +98,18 @@ private:
unsigned int adminLogoutPublic : 1;
unsigned int adminPublic : 1;
unsigned int logPublic : 1;
unsigned int xVersionPublic : 1;
unsigned int grantCharacterPublic : 1;
unsigned int spawnVehiclePublic : 1;
unsigned int spawnVehicleNoOwnerPublic : 1;
unsigned int minePlacePublic : 1;
unsigned int xOtherPublic : 1;
unsigned int commandPublic : 1;
unsigned int errorPublic : 1;
unsigned int versionPublic : 1;
unsigned int authorizedPublic : 1;
unsigned int otherPublic : 1;
/** Server tags */
Jupiter::StringS rconVersionTag;
Jupiter::StringS gameVersionTag;
/** Player tags */
Jupiter::StringS nameTag;
Jupiter::StringS rawNameTag;
Jupiter::StringS ipTag;
Jupiter::StringS steamTag;
Jupiter::StringS uuidTag;
Jupiter::StringS idTag;
Jupiter::StringS adminTag;
Jupiter::StringS prefixTag;
Jupiter::StringS gamePrefixTag;
Jupiter::StringS teamColorTag;
Jupiter::StringS teamShortTag;
Jupiter::StringS teamLongTag;
/** Victim tags */
Jupiter::StringS victimNameTag;
Jupiter::StringS victimRawNameTag;
Jupiter::StringS victimIPTag;
Jupiter::StringS victimSteamTag;
Jupiter::StringS victimUUIDTag;
Jupiter::StringS victimIDTag;
Jupiter::StringS victimAdminTag;
Jupiter::StringS victimPrefixTag;
Jupiter::StringS victimGamePrefixTag;
Jupiter::StringS victimTeamColorTag;
Jupiter::StringS victimTeamShortTag;
Jupiter::StringS victimTeamLongTag;
/** Other tags */
Jupiter::StringS weaponTag;
Jupiter::StringS objectTag;
Jupiter::StringS messageTag;
Jupiter::StringS newNameTag;
Jupiter::StringS winScoreTag;
Jupiter::StringS loseScoreTag;
/** Event formats */
Jupiter::StringS joinPublicFmt, joinAdminFmt, joinNoSteamAdminFmt;
Jupiter::StringS partFmt;
@ -145,10 +120,15 @@ private:
Jupiter::StringS deployFmt;
Jupiter::StringS suicideFmt;
Jupiter::StringS dieFmt;
Jupiter::StringS dieFmt2;
Jupiter::StringS killFmt;
Jupiter::StringS killFmt2;
Jupiter::StringS destroyBuildingFmt;
Jupiter::StringS destroyBuildingFmt2;
Jupiter::StringS destroyDefenceFmt;
Jupiter::StringS destroyDefenceFmt2;
Jupiter::StringS destroyVehicleFmt;
Jupiter::StringS destroyVehicleFmt2;
Jupiter::StringS gameOverFmt;
Jupiter::StringS gameOverTieFmt;
Jupiter::StringS gameOverTieNoWinFmt;
@ -162,6 +142,12 @@ private:
Jupiter::StringS adminLogoutFmt;
Jupiter::StringS adminFmt;
Jupiter::StringS logFmt;
Jupiter::StringS xVersionFmt;
Jupiter::StringS grantCharacterFmt;
Jupiter::StringS spawnVehicleFmt;
Jupiter::StringS spawnVehicleNoOwnerFmt;
Jupiter::StringS minePlaceFmt;
Jupiter::StringS xOtherFmt;
Jupiter::StringS commandFmt;
Jupiter::StringS errorFmt;
Jupiter::StringS versionFmt;

37
RenX.Medals/RenX_Medals.cpp

@ -1,5 +1,5 @@
/**
* Copyright (C) 2014 Justin James.
* Copyright (C) 2014-2015 Justin James.
*
* This license must be preserved.
* Any applications, libraries, or code which make any use of any
@ -24,6 +24,11 @@
#include "RenX_PlayerInfo.h"
#include "RenX_Functions.h"
#include "RenX_Core.h"
#include "RenX_Tags.h"
Jupiter::ReferenceString INTERNAL_RECS_TAG = STRING_LITERAL_AS_REFERENCE("\0RX.MEDALS.RECS\0");
Jupiter::ReferenceString INTERNAL_NOOB_TAG = STRING_LITERAL_AS_REFERENCE("\0RX.MEDALS.NOOB\0");
Jupiter::ReferenceString INTERNAL_WORTH_TAG = STRING_LITERAL_AS_REFERENCE("\0RX.MEDALS.WORTH\0");
RenX_MedalsPlugin::RenX_MedalsPlugin()
{
@ -83,6 +88,26 @@ void congratPlayer(unsigned int, void *params)
delete congratPlayerData;
}
void RenX_MedalsPlugin::RenX_SanitizeTags(Jupiter::StringType &fmt)
{
fmt.replace(RenX_MedalsPlugin::recsTag, INTERNAL_RECS_TAG);
fmt.replace(RenX_MedalsPlugin::noobTag, INTERNAL_NOOB_TAG);
fmt.replace(RenX_MedalsPlugin::worthTag, INTERNAL_WORTH_TAG);
}
void RenX_MedalsPlugin::RenX_ProcessTags(Jupiter::StringType &msg, const RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim)
{
if (player != nullptr)
{
const Jupiter::ReadableString &recs = RenX_MedalsPlugin::medalsFile.get(player->uuid, STRING_LITERAL_AS_REFERENCE("Recs"));
const Jupiter::ReadableString &noobs = RenX_MedalsPlugin::medalsFile.get(player->uuid, STRING_LITERAL_AS_REFERENCE("Noobs"));
msg.replace(INTERNAL_RECS_TAG, recs);
msg.replace(INTERNAL_NOOB_TAG, noobs);
msg.replace(INTERNAL_WORTH_TAG, Jupiter::StringS::Format("%d", recs.asInt() - noobs.asInt()));
}
}
void RenX_MedalsPlugin::RenX_OnPlayerCreate(RenX::Server *server, const RenX::PlayerInfo *player)
{
if (player->uuid.isEmpty() == false && player->isBot == false)
@ -123,14 +148,9 @@ void RenX_MedalsPlugin::RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo
pair = section->getPair(r);
} while (pair->getKey().asInt() == 0);
const Jupiter::ReadableString &recs = RenX_MedalsPlugin::medalsFile.get(player->uuid, STRING_LITERAL_AS_REFERENCE("Recs"));
const Jupiter::ReadableString &noobs = RenX_MedalsPlugin::medalsFile.get(player->uuid, STRING_LITERAL_AS_REFERENCE("Noobs"));
Jupiter::StringS msg = pair->getValue();
msg.replace(RenX_MedalsPlugin::nameTag, player->name);
msg.replace(RenX_MedalsPlugin::recsTag, recs);
msg.replace(RenX_MedalsPlugin::noobTag, noobs);
msg.replace(RenX_MedalsPlugin::worthTag, Jupiter::StringS::Format("%d", recs.asInt() - noobs.asInt()));
RenX::sanitizeTags(msg);
RenX::processTags(msg, server, player);
server->sendMessage(msg);
}
@ -237,7 +257,6 @@ void RenX_MedalsPlugin::init()
RenX_MedalsPlugin::medalsFile.readFile(RenX_MedalsPlugin::medalsFileName);
RenX_MedalsPlugin::joinMessageFile.readFile(RenX_MedalsPlugin::joinMessageFileName);
RenX_MedalsPlugin::firstSection = RenX_MedalsPlugin::joinMessageFile.get(Jupiter::StringS::empty, STRING_LITERAL_AS_REFERENCE("FirstSection"));
RenX_MedalsPlugin::nameTag = RenX_MedalsPlugin::joinMessageFile.get(Jupiter::String::empty, STRING_LITERAL_AS_REFERENCE("NameTag"), STRING_LITERAL_AS_REFERENCE("{NAME}"));
RenX_MedalsPlugin::recsTag = RenX_MedalsPlugin::joinMessageFile.get(Jupiter::String::empty, STRING_LITERAL_AS_REFERENCE("RecsTag"), STRING_LITERAL_AS_REFERENCE("{RECS}"));
RenX_MedalsPlugin::noobTag = RenX_MedalsPlugin::joinMessageFile.get(Jupiter::String::empty, STRING_LITERAL_AS_REFERENCE("NoobsTag"), STRING_LITERAL_AS_REFERENCE("{NOOBS}"));
RenX_MedalsPlugin::worthTag = RenX_MedalsPlugin::joinMessageFile.get(Jupiter::String::empty, STRING_LITERAL_AS_REFERENCE("WorthTag"), STRING_LITERAL_AS_REFERENCE("{WORTH}"));

5
RenX.Medals/RenX_Medals.h

@ -1,5 +1,5 @@
/**
* Copyright (C) 2014 Justin James.
* Copyright (C) 2014-2015 Justin James.
*
* This license must be preserved.
* Any applications, libraries, or code which make any use of any
@ -42,6 +42,8 @@ int getWorth(const RenX::PlayerInfo *player);
class RenX_MedalsPlugin : public RenX::Plugin
{
public: // RenX::Plugin
void RenX_SanitizeTags(Jupiter::StringType &fmt) override;
void RenX_ProcessTags(Jupiter::StringType &msg, const RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim) override;
void RenX_OnPlayerCreate(RenX::Server *server, const RenX::PlayerInfo *player) override;
void RenX_OnPlayerDelete(RenX::Server *server, const RenX::PlayerInfo *player) override;
void RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player) override;
@ -58,7 +60,6 @@ public:
time_t killCongratDelay;
time_t vehicleKillCongratDelay;
time_t kdrCongratDelay;
Jupiter::StringS nameTag;
Jupiter::StringS recsTag;
Jupiter::StringS noobTag;
Jupiter::StringS worthTag;

Loading…
Cancel
Save