Browse Source

Added BuildingInfo tags.

* Adjusted RenX_ProcessTags in RenX::Plugin accordingly.
** Updated Plugins accordingly.
Changed BuildingInfo health/max_health type to double
Added Rx_Building_ translations.
Fixed binfo RCON command spam, and improved Server::updateClientList().
Updated Jupiter.
pull/3/head
JustinAJ 10 years ago
parent
commit
262c79d778
  1. 2
      Jupiter
  2. BIN
      Release/Plugins/RenX.Core.lib
  3. 4
      RenX.Core/RenX_BuildingInfo.h
  4. 26
      RenX.Core/RenX_Functions.cpp
  5. 2
      RenX.Core/RenX_Plugin.cpp
  6. 3
      RenX.Core/RenX_Plugin.h
  7. 4
      RenX.Core/RenX_Server.cpp
  8. 84
      RenX.Core/RenX_Tags.cpp
  9. 24
      RenX.Core/RenX_Tags.h
  10. 2
      RenX.Medals/RenX_Medals.cpp
  11. 2
      RenX.Medals/RenX_Medals.h

2
Jupiter

@ -1 +1 @@
Subproject commit 5bb6f9e45f2a41f6427ae43441ecb1aab3137c4c Subproject commit 6400a1542e1d005e47cd5c9989a58a1731e00e27

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

4
RenX.Core/RenX_BuildingInfo.h

@ -43,8 +43,8 @@ namespace RenX
{ {
Jupiter::StringS name; Jupiter::StringS name;
TeamType team = TeamType::Other; TeamType team = TeamType::Other;
int health = 0; double health = 0;
int max_health = 0; double max_health = 0;
bool capturable = false; bool capturable = false;
mutable Jupiter::INIFile varData; mutable Jupiter::INIFile varData;
}; };

26
RenX.Core/RenX_Functions.cpp

@ -262,22 +262,35 @@ Jupiter::ReferenceString translated_DmgType_Orca = STRING_LITERAL_AS_REFERENCE("
Jupiter::ReferenceString translated_DmgType_A10_Missile = STRING_LITERAL_AS_REFERENCE("A10 Missile"); Jupiter::ReferenceString translated_DmgType_A10_Missile = STRING_LITERAL_AS_REFERENCE("A10 Missile");
/** Nod structures */ /** Nod structures */
Jupiter::ReferenceString translated_Building_HandOfNod = STRING_LITERAL_AS_REFERENCE("Hand of Nod");
Jupiter::ReferenceString translated_Building_AirTower = STRING_LITERAL_AS_REFERENCE("Airstrip");
Jupiter::ReferenceString translated_Building_Airstrip = STRING_LITERAL_AS_REFERENCE("Airstrip");
Jupiter::ReferenceString translated_Building_Refinery_Nod = STRING_LITERAL_AS_REFERENCE("Nod Refinery");
Jupiter::ReferenceString translated_Building_PowerPlant_Nod = STRING_LITERAL_AS_REFERENCE("Nod Power Plant");
Jupiter::ReferenceString translated_Building_HandOfNod_Internals = STRING_LITERAL_AS_REFERENCE("Hand of Nod"); Jupiter::ReferenceString translated_Building_HandOfNod_Internals = STRING_LITERAL_AS_REFERENCE("Hand of Nod");
Jupiter::ReferenceString translated_Building_AirTower_Internals = STRING_LITERAL_AS_REFERENCE("Airstrip"); Jupiter::ReferenceString translated_Building_AirTower_Internals = STRING_LITERAL_AS_REFERENCE("Airstrip");
Jupiter::ReferenceString translated_Building_Airstrip_Internals = STRING_LITERAL_AS_REFERENCE("Airstrip");
Jupiter::ReferenceString translated_Building_Refinery_Nod_Internals = STRING_LITERAL_AS_REFERENCE("Nod Refinery"); Jupiter::ReferenceString translated_Building_Refinery_Nod_Internals = STRING_LITERAL_AS_REFERENCE("Nod Refinery");
Jupiter::ReferenceString translated_Building_PowerPlant_Nod_Internals = STRING_LITERAL_AS_REFERENCE("Nod Power Plant"); Jupiter::ReferenceString translated_Building_PowerPlant_Nod_Internals = STRING_LITERAL_AS_REFERENCE("Nod Power Plant");
/** GDI structures */ /** GDI structures */
Jupiter::ReferenceString translated_Building_Barracks = STRING_LITERAL_AS_REFERENCE("Barracks");
Jupiter::ReferenceString translated_Building_WeaponsFactory = STRING_LITERAL_AS_REFERENCE("Weapons Factory");
Jupiter::ReferenceString translated_Building_Refinery_GDI = STRING_LITERAL_AS_REFERENCE("GDI Refinery");
Jupiter::ReferenceString translated_Building_PowerPlant_GDI = STRING_LITERAL_AS_REFERENCE("GDI Power Plant");
Jupiter::ReferenceString translated_Building_Barracks_Internals = STRING_LITERAL_AS_REFERENCE("Barracks"); Jupiter::ReferenceString translated_Building_Barracks_Internals = STRING_LITERAL_AS_REFERENCE("Barracks");
Jupiter::ReferenceString translated_Building_WeaponsFactory_Internals = STRING_LITERAL_AS_REFERENCE("Weapons Factory"); Jupiter::ReferenceString translated_Building_WeaponsFactory_Internals = STRING_LITERAL_AS_REFERENCE("Weapons Factory");
Jupiter::ReferenceString translated_Building_Refinery_GDI_Internals = STRING_LITERAL_AS_REFERENCE("GDI Refinery"); Jupiter::ReferenceString translated_Building_Refinery_GDI_Internals = STRING_LITERAL_AS_REFERENCE("GDI Refinery");
Jupiter::ReferenceString translated_Building_PowerPlant_GDI_Internals = STRING_LITERAL_AS_REFERENCE("GDI Power Plant"); Jupiter::ReferenceString translated_Building_PowerPlant_GDI_Internals = STRING_LITERAL_AS_REFERENCE("GDI Power Plant");
/** Defense structures */ /** Defense structures */
Jupiter::ReferenceString translated_Building_AdvancedGuardTower = STRING_LITERAL_AS_REFERENCE("Advanced Guard Tower");
Jupiter::ReferenceString translated_Building_Obelisk = STRING_LITERAL_AS_REFERENCE("Obelisk of Light");
Jupiter::ReferenceString translated_Building_AdvancedGuardTower_Internals = STRING_LITERAL_AS_REFERENCE("Advanced Guard Tower"); Jupiter::ReferenceString translated_Building_AdvancedGuardTower_Internals = STRING_LITERAL_AS_REFERENCE("Advanced Guard Tower");
Jupiter::ReferenceString translated_Building_Obelisk_Internals = STRING_LITERAL_AS_REFERENCE("Obelisk of Light"); Jupiter::ReferenceString translated_Building_Obelisk_Internals = STRING_LITERAL_AS_REFERENCE("Obelisk of Light");
/** Other structures */ /** Other structures */
Jupiter::ReferenceString translated_Building_Silo = STRING_LITERAL_AS_REFERENCE("Tiberium Silo");
Jupiter::ReferenceString translated_Building_Silo_Internals = STRING_LITERAL_AS_REFERENCE("Tiberium Silo"); Jupiter::ReferenceString translated_Building_Silo_Internals = STRING_LITERAL_AS_REFERENCE("Tiberium Silo");
/** Defences */ /** Defences */
@ -640,22 +653,35 @@ const Jupiter::ReferenceString RenX::translateName(const Jupiter::ReadableString
{ {
object.shiftRight(9); object.shiftRight(9);
/** Nod structures */ /** Nod structures */
if (object.equals(STRING_LITERAL_AS_REFERENCE("HandOfNod"))) return translated_Building_HandOfNod;
if (object.equals(STRING_LITERAL_AS_REFERENCE("AirTower"))) return translated_Building_AirTower;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Airstrip"))) return translated_Building_Airstrip;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Refinery_Nod"))) return translated_Building_Refinery_Nod;
if (object.equals(STRING_LITERAL_AS_REFERENCE("PowerPlant_Nod"))) return translated_Building_PowerPlant_Nod;
if (object.equals(STRING_LITERAL_AS_REFERENCE("HandOfNod_Internals"))) return translated_Building_HandOfNod_Internals; if (object.equals(STRING_LITERAL_AS_REFERENCE("HandOfNod_Internals"))) return translated_Building_HandOfNod_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("AirTower_Internals"))) return translated_Building_AirTower_Internals; if (object.equals(STRING_LITERAL_AS_REFERENCE("AirTower_Internals"))) return translated_Building_AirTower_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Airstrip_Internals"))) return translated_Building_Airstrip_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Refinery_Nod_Internals"))) return translated_Building_Refinery_Nod_Internals; if (object.equals(STRING_LITERAL_AS_REFERENCE("Refinery_Nod_Internals"))) return translated_Building_Refinery_Nod_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("PowerPlant_Nod_Internals"))) return translated_Building_PowerPlant_Nod_Internals; if (object.equals(STRING_LITERAL_AS_REFERENCE("PowerPlant_Nod_Internals"))) return translated_Building_PowerPlant_Nod_Internals;
/** GDI structures */ /** GDI structures */
if (object.equals(STRING_LITERAL_AS_REFERENCE("Barracks"))) return translated_Building_Barracks;
if (object.equals(STRING_LITERAL_AS_REFERENCE("WeaponsFactory"))) return translated_Building_WeaponsFactory;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Refinery_GDI"))) return translated_Building_Refinery_GDI;
if (object.equals(STRING_LITERAL_AS_REFERENCE("PowerPlant_GDI"))) return translated_Building_PowerPlant_GDI;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Barracks_Internals"))) return translated_Building_Barracks_Internals; if (object.equals(STRING_LITERAL_AS_REFERENCE("Barracks_Internals"))) return translated_Building_Barracks_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("WeaponsFactory_Internals"))) return translated_Building_WeaponsFactory_Internals; if (object.equals(STRING_LITERAL_AS_REFERENCE("WeaponsFactory_Internals"))) return translated_Building_WeaponsFactory_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Refinery_GDI_Internals"))) return translated_Building_Refinery_GDI_Internals; if (object.equals(STRING_LITERAL_AS_REFERENCE("Refinery_GDI_Internals"))) return translated_Building_Refinery_GDI_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("PowerPlant_GDI_Internals"))) return translated_Building_PowerPlant_GDI_Internals; if (object.equals(STRING_LITERAL_AS_REFERENCE("PowerPlant_GDI_Internals"))) return translated_Building_PowerPlant_GDI_Internals;
/** Defense structures */ /** Defense structures */
if (object.equals(STRING_LITERAL_AS_REFERENCE("AdvancedGuardTower"))) return translated_Building_AdvancedGuardTower;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Obelisk"))) return translated_Building_Obelisk;
if (object.equals(STRING_LITERAL_AS_REFERENCE("AdvancedGuardTower_Internals"))) return translated_Building_AdvancedGuardTower_Internals; if (object.equals(STRING_LITERAL_AS_REFERENCE("AdvancedGuardTower_Internals"))) return translated_Building_AdvancedGuardTower_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Obelisk_Internals"))) return translated_Building_Obelisk_Internals; if (object.equals(STRING_LITERAL_AS_REFERENCE("Obelisk_Internals"))) return translated_Building_Obelisk_Internals;
/** Other structures */ /** Other structures */
if (object.equals(STRING_LITERAL_AS_REFERENCE("Silo"))) return translated_Building_Silo;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Silo_Internals"))) return translated_Building_Silo_Internals; if (object.equals(STRING_LITERAL_AS_REFERENCE("Silo_Internals"))) return translated_Building_Silo_Internals;
} }
else if (object.find(STRING_LITERAL_AS_REFERENCE("Defence_")) == 0) else if (object.find(STRING_LITERAL_AS_REFERENCE("Defence_")) == 0)

2
RenX.Core/RenX_Plugin.cpp

@ -40,7 +40,7 @@ void RenX::Plugin::RenX_SanitizeTags(Jupiter::StringType &)
return; return;
} }
void RenX::Plugin::RenX_ProcessTags(Jupiter::StringType &, const RenX::Server *, const RenX::PlayerInfo *, const RenX::PlayerInfo *) void RenX::Plugin::RenX_ProcessTags(Jupiter::StringType &, const RenX::Server *, const RenX::PlayerInfo *, const RenX::PlayerInfo *, const RenX::BuildingInfo *)
{ {
return; return;
} }

3
RenX.Core/RenX_Plugin.h

@ -32,6 +32,7 @@ namespace RenX
/** Forward declarations */ /** Forward declarations */
struct PlayerInfo; struct PlayerInfo;
struct BuildingInfo;
class Plugin; class Plugin;
class Server; class Server;
@ -40,7 +41,7 @@ namespace RenX
public: public:
/** Tag-related events */ /** Tag-related events */
virtual void RenX_SanitizeTags(Jupiter::StringType &fmt); virtual void RenX_SanitizeTags(Jupiter::StringType &fmt);
virtual void RenX_ProcessTags(Jupiter::StringType &msg, const Server *server, const PlayerInfo *player, const PlayerInfo *victim); virtual void RenX_ProcessTags(Jupiter::StringType &msg, const Server *server, const PlayerInfo *player, const PlayerInfo *victim, const BuildingInfo *building);
/** Non-RCON RenX logs */ /** Non-RCON RenX logs */
virtual void RenX_OnPlayerCreate(Server *server, const PlayerInfo *player); virtual void RenX_OnPlayerCreate(Server *server, const PlayerInfo *player);

4
RenX.Core/RenX_Server.cpp

@ -83,7 +83,7 @@ int RenX::Server::think()
} }
return 0; return 0;
} }
if (RenX::Server::rconVersion >= 3) if (RenX::Server::rconVersion >= 3 && RenX::Server::players.size() != 0)
{ {
if (RenX::Server::clientUpdateRate != std::chrono::milliseconds::zero() && std::chrono::steady_clock::now() > RenX::Server::lastClientListUpdate + RenX::Server::clientUpdateRate) if (RenX::Server::clientUpdateRate != std::chrono::milliseconds::zero() && std::chrono::steady_clock::now() > RenX::Server::lastClientListUpdate + RenX::Server::clientUpdateRate)
RenX::Server::updateClientList(); RenX::Server::updateClientList();
@ -380,8 +380,6 @@ bool RenX::Server::fetchClientList()
bool RenX::Server::updateClientList() bool RenX::Server::updateClientList()
{ {
RenX::Server::lastClientListUpdate = std::chrono::steady_clock::now(); RenX::Server::lastClientListUpdate = std::chrono::steady_clock::now();
if (RenX::Server::players.size() == 0)
return true;
size_t botCount = 0; size_t botCount = 0;
for (size_t i = 0; i != RenX::Server::players.size(); i++) for (size_t i = 0; i != RenX::Server::players.size(); i++)

84
RenX.Core/RenX_Tags.cpp

@ -22,15 +22,17 @@
#include "RenX_Functions.h" #include "RenX_Functions.h"
#include "RenX_Server.h" #include "RenX_Server.h"
#include "RenX_PlayerInfo.h" #include "RenX_PlayerInfo.h"
#include "RenX_BuildingInfo.h"
#include "RenX_Plugin.h" #include "RenX_Plugin.h"
#include "RenX_Tags.h" #include "RenX_Tags.h"
struct TagsImp : RenX::Tags struct TagsImp : RenX::Tags
{ {
TagsImp(); TagsImp();
void processTags(Jupiter::StringType &msg, const RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim); void processTags(Jupiter::StringType &msg, const RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim, const RenX::BuildingInfo *building);
void sanitizeTags(Jupiter::StringType &fmt); void sanitizeTags(Jupiter::StringType &fmt);
const Jupiter::ReadableString &getUniqueInternalTag(); const Jupiter::ReadableString &getUniqueInternalTag();
Jupiter::StringS get_building_health_bar(const RenX::BuildingInfo *building);
private: private:
Jupiter::StringS uniqueTag; Jupiter::StringS uniqueTag;
union union
@ -44,6 +46,7 @@ private:
uint8_t tagItrP4; uint8_t tagItrP4;
}; };
}; };
size_t bar_width;
} _tags; } _tags;
RenX::Tags *RenX::tags = &_tags; RenX::Tags *RenX::tags = &_tags;
@ -53,6 +56,7 @@ TagsImp::TagsImp()
this->uniqueTag = STRING_LITERAL_AS_REFERENCE("\0\0\0\0\0\0"); this->uniqueTag = STRING_LITERAL_AS_REFERENCE("\0\0\0\0\0\0");
const Jupiter::ReadableString &configSection = Jupiter::IRC::Client::Config->get(STRING_LITERAL_AS_REFERENCE("RenX"), STRING_LITERAL_AS_REFERENCE("TagDefinitions"), STRING_LITERAL_AS_REFERENCE("RenX.Tags")); const Jupiter::ReadableString &configSection = Jupiter::IRC::Client::Config->get(STRING_LITERAL_AS_REFERENCE("RenX"), STRING_LITERAL_AS_REFERENCE("TagDefinitions"), STRING_LITERAL_AS_REFERENCE("RenX.Tags"));
TagsImp::bar_width = Jupiter::IRC::Client::Config->getInt(configSection, STRING_LITERAL_AS_REFERENCE("BarWidth"), 20);
/** Global formats */ /** Global formats */
this->dateFmt = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("DateFormat"), STRING_LITERAL_AS_REFERENCE("%A, %B %d, %Y")); this->dateFmt = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("DateFormat"), STRING_LITERAL_AS_REFERENCE("%A, %B %d, %Y"));
@ -147,6 +151,17 @@ TagsImp::TagsImp()
this->INTERNAL_VICTIM_STOLEN_TAG = this->getUniqueInternalTag(); this->INTERNAL_VICTIM_STOLEN_TAG = this->getUniqueInternalTag();
this->INTERNAL_VICTIM_ACCESS_TAG = this->getUniqueInternalTag(); this->INTERNAL_VICTIM_ACCESS_TAG = this->getUniqueInternalTag();
/** Building tags */
this->INTERNAL_BUILDING_NAME_TAG = this->getUniqueInternalTag();
this->INTERNAL_BUILDING_RAW_NAME_TAG = this->getUniqueInternalTag();
this->INTERNAL_BUILDING_HEALTH_TAG = this->getUniqueInternalTag();
this->INTERNAL_BUILDING_MAX_HEALTH_TAG = this->getUniqueInternalTag();
this->INTERNAL_BUILDING_HEALTH_PERCENTAGE_TAG = this->getUniqueInternalTag();
this->INTERNAL_BUILDING_HEALTH_BAR_TAG = this->getUniqueInternalTag();
this->INTERNAL_BUILDING_TEAM_COLOR_TAG = this->getUniqueInternalTag();
this->INTERNAL_BUILDING_TEAM_SHORT_TAG = this->getUniqueInternalTag();
this->INTERNAL_BUILDING_TEAM_LONG_TAG = this->getUniqueInternalTag();
/** Other tags */ /** Other tags */
this->INTERNAL_WEAPON_TAG = this->getUniqueInternalTag(); this->INTERNAL_WEAPON_TAG = this->getUniqueInternalTag();
this->INTERNAL_OBJECT_TAG = this->getUniqueInternalTag(); this->INTERNAL_OBJECT_TAG = this->getUniqueInternalTag();
@ -244,6 +259,17 @@ TagsImp::TagsImp()
this->victimStolenTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimStolenTag"), STRING_LITERAL_AS_REFERENCE("{VSTOLEN}")); 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}")); this->victimAccessTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("VictimAccessTag"), STRING_LITERAL_AS_REFERENCE("{VACCESS}"));
/** Building tags */
this->buildingNameTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("BuildingNameTag"), STRING_LITERAL_AS_REFERENCE("{BNAME}"));
this->buildingRawNameTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("BuildingRawNameTag"), STRING_LITERAL_AS_REFERENCE("{BRNAME}"));
this->buildingHealthTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("BuildingHealthTag"), STRING_LITERAL_AS_REFERENCE("{BHEALTH}"));
this->buildingMaxHealthTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("BuildingMaxHealthTag"), STRING_LITERAL_AS_REFERENCE("{BMHEALTH}"));
this->buildingHealthPercentageTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("BuildingHealthPercentageTag"), STRING_LITERAL_AS_REFERENCE("{BHP}"));
this->buildingHealthBarTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("BuildingHealthBarTag"), STRING_LITERAL_AS_REFERENCE("{BHBAR}"));
this->buildingTeamColorTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("BuildingTeamColorTag"), STRING_LITERAL_AS_REFERENCE("{BCOLOR}"));
this->buildingTeamShortTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("BuildingShortTeamTag"), STRING_LITERAL_AS_REFERENCE("{BTEAMS}"));
this->buildingTeamLongTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("BuildingLongTeamTag"), STRING_LITERAL_AS_REFERENCE("{BTEAML}"));
/** Other tags */ /** Other tags */
this->weaponTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("WeaponTag"), STRING_LITERAL_AS_REFERENCE("{WEAPON}")); 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->objectTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("ObjectTag"), STRING_LITERAL_AS_REFERENCE("{OBJECT}"));
@ -253,14 +279,37 @@ TagsImp::TagsImp()
this->loseScoreTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("LoseScoreTag"), STRING_LITERAL_AS_REFERENCE("{LOSESCORE}")); this->loseScoreTag = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("LoseScoreTag"), STRING_LITERAL_AS_REFERENCE("{LOSESCORE}"));
} }
Jupiter::StringS TagsImp::get_building_health_bar(const RenX::BuildingInfo *building)
{
if (TagsImp::bar_width == 0)
return Jupiter::StringS::empty;
size_t index = 0;
size_t greenBars = (building->health / building->max_health) * TagsImp::bar_width;
Jupiter::String r(TagsImp::bar_width);
if (greenBars != 0)
{
r = IRCCOLOR "09,09";
do
r += " ";
while (++index != greenBars);
if (greenBars == TagsImp::bar_width)
return r += IRCNORMAL;
}
r += IRCCOLOR "04,04";
do
r += " ";
while (++greenBars != TagsImp::bar_width);
return r += IRCNORMAL;
}
#define PROCESS_TAG(tag, value) \ #define PROCESS_TAG(tag, value) \
while(true) { \ while(true) { \
index = msg.find(tag); \ index = msg.find(tag); \
if (index == Jupiter::INVALID_INDEX) break; \ if (index == Jupiter::INVALID_INDEX) break; \
msg.replace(index, tag.size(), value); } msg.replace(index, tag.size(), value); }
void TagsImp::processTags(Jupiter::StringType &msg, const RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim, const RenX::BuildingInfo *building)
void TagsImp::processTags(Jupiter::StringType &msg, const RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim)
{ {
size_t index; size_t index;
PROCESS_TAG(this->INTERNAL_DATE_TAG, Jupiter::ReferenceString(getTimeFormat(this->dateFmt.c_str()))); PROCESS_TAG(this->INTERNAL_DATE_TAG, Jupiter::ReferenceString(getTimeFormat(this->dateFmt.c_str())));
@ -357,10 +406,22 @@ void TagsImp::processTags(Jupiter::StringType &msg, const RenX::Server *server,
PROCESS_TAG(this->INTERNAL_VICTIM_STOLEN_TAG, Jupiter::StringS::Format("%u", victim->stolen)); PROCESS_TAG(this->INTERNAL_VICTIM_STOLEN_TAG, Jupiter::StringS::Format("%u", victim->stolen));
PROCESS_TAG(this->INTERNAL_VICTIM_ACCESS_TAG, Jupiter::StringS::Format("%d", victim->access)); PROCESS_TAG(this->INTERNAL_VICTIM_ACCESS_TAG, Jupiter::StringS::Format("%d", victim->access));
} }
if (building != nullptr)
{
PROCESS_TAG(this->INTERNAL_BUILDING_NAME_TAG, RenX::translateName(building->name));
PROCESS_TAG(this->INTERNAL_BUILDING_RAW_NAME_TAG, building->name);
PROCESS_TAG(this->INTERNAL_BUILDING_HEALTH_TAG, Jupiter::StringS::Format("%.0f", building->health));
PROCESS_TAG(this->INTERNAL_BUILDING_MAX_HEALTH_TAG, Jupiter::StringS::Format("%.0f", building->health));
PROCESS_TAG(this->INTERNAL_BUILDING_HEALTH_PERCENTAGE_TAG, Jupiter::StringS::Format("%.0f", (building->health / building->max_health) * 100.0));
PROCESS_TAG(this->INTERNAL_BUILDING_HEALTH_BAR_TAG, get_building_health_bar(building));
PROCESS_TAG(this->INTERNAL_BUILDING_TEAM_COLOR_TAG, RenX::getTeamColor(building->team));
PROCESS_TAG(this->INTERNAL_BUILDING_TEAM_SHORT_TAG, RenX::getTeamName(building->team));
PROCESS_TAG(this->INTERNAL_BUILDING_TEAM_LONG_TAG, RenX::getFullTeamName(building->team));
}
Jupiter::ArrayList<RenX::Plugin> &xPlugins = *RenX::getCore()->getPlugins(); Jupiter::ArrayList<RenX::Plugin> &xPlugins = *RenX::getCore()->getPlugins();
for (size_t i = 0; i < xPlugins.size(); i++) for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_ProcessTags(msg, server, player, victim); xPlugins.get(i)->RenX_ProcessTags(msg, server, player, victim, building);
} }
void TagsImp::sanitizeTags(Jupiter::StringType &fmt) void TagsImp::sanitizeTags(Jupiter::StringType &fmt)
@ -452,6 +513,17 @@ void TagsImp::sanitizeTags(Jupiter::StringType &fmt)
fmt.replace(this->victimStolenTag, this->INTERNAL_VICTIM_STOLEN_TAG); fmt.replace(this->victimStolenTag, this->INTERNAL_VICTIM_STOLEN_TAG);
fmt.replace(this->victimAccessTag, this->INTERNAL_VICTIM_ACCESS_TAG); fmt.replace(this->victimAccessTag, this->INTERNAL_VICTIM_ACCESS_TAG);
/** Building tags */
fmt.replace(this->buildingNameTag, this->INTERNAL_BUILDING_NAME_TAG);
fmt.replace(this->buildingRawNameTag, this->INTERNAL_BUILDING_RAW_NAME_TAG);
fmt.replace(this->buildingHealthTag, this->INTERNAL_BUILDING_HEALTH_TAG);
fmt.replace(this->buildingMaxHealthTag, this->INTERNAL_BUILDING_MAX_HEALTH_TAG);
fmt.replace(this->buildingHealthPercentageTag, this->INTERNAL_BUILDING_HEALTH_PERCENTAGE_TAG);
fmt.replace(this->buildingHealthBarTag, this->INTERNAL_BUILDING_HEALTH_BAR_TAG);
fmt.replace(this->buildingTeamColorTag, this->INTERNAL_BUILDING_TEAM_COLOR_TAG);
fmt.replace(this->buildingTeamShortTag, this->INTERNAL_BUILDING_TEAM_SHORT_TAG);
fmt.replace(this->buildingTeamLongTag, this->INTERNAL_BUILDING_TEAM_LONG_TAG);
/** Other tags */ /** Other tags */
fmt.replace(this->weaponTag, this->INTERNAL_WEAPON_TAG); fmt.replace(this->weaponTag, this->INTERNAL_WEAPON_TAG);
fmt.replace(this->objectTag, this->INTERNAL_OBJECT_TAG); fmt.replace(this->objectTag, this->INTERNAL_OBJECT_TAG);
@ -482,9 +554,9 @@ const Jupiter::ReadableString &RenX::getUniqueInternalTag()
return _tags.getUniqueInternalTag(); return _tags.getUniqueInternalTag();
} }
void RenX::processTags(Jupiter::StringType &msg, const RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim) void RenX::processTags(Jupiter::StringType &msg, const RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim, const RenX::BuildingInfo *building)
{ {
_tags.processTags(msg, server, player, victim); _tags.processTags(msg, server, player, victim, building);
} }
void RenX::sanitizeTags(Jupiter::StringType &fmt) void RenX::sanitizeTags(Jupiter::StringType &fmt)

24
RenX.Core/RenX_Tags.h

@ -39,7 +39,7 @@ namespace RenX
struct PlayerInfo; struct PlayerInfo;
class Server; 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 processTags(Jupiter::StringType &msg, const RenX::Server *server = nullptr, const RenX::PlayerInfo *player = nullptr, const RenX::PlayerInfo *victim = nullptr, const RenX::BuildingInfo *building = nullptr);
RENX_API void sanitizeTags(Jupiter::StringType &fmt); RENX_API void sanitizeTags(Jupiter::StringType &fmt);
RENX_API const Jupiter::ReadableString &getUniqueInternalTag(); RENX_API const Jupiter::ReadableString &getUniqueInternalTag();
@ -136,6 +136,17 @@ namespace RenX
Jupiter::StringS INTERNAL_VICTIM_STOLEN_TAG; Jupiter::StringS INTERNAL_VICTIM_STOLEN_TAG;
Jupiter::StringS INTERNAL_VICTIM_ACCESS_TAG; Jupiter::StringS INTERNAL_VICTIM_ACCESS_TAG;
/** Building tags */
Jupiter::StringS INTERNAL_BUILDING_NAME_TAG;
Jupiter::StringS INTERNAL_BUILDING_RAW_NAME_TAG;
Jupiter::StringS INTERNAL_BUILDING_HEALTH_TAG;
Jupiter::StringS INTERNAL_BUILDING_MAX_HEALTH_TAG;
Jupiter::StringS INTERNAL_BUILDING_HEALTH_PERCENTAGE_TAG;
Jupiter::StringS INTERNAL_BUILDING_HEALTH_BAR_TAG;
Jupiter::StringS INTERNAL_BUILDING_TEAM_COLOR_TAG;
Jupiter::StringS INTERNAL_BUILDING_TEAM_SHORT_TAG;
Jupiter::StringS INTERNAL_BUILDING_TEAM_LONG_TAG;
/** Other tags */ /** Other tags */
Jupiter::StringS INTERNAL_WEAPON_TAG; Jupiter::StringS INTERNAL_WEAPON_TAG;
Jupiter::StringS INTERNAL_OBJECT_TAG; Jupiter::StringS INTERNAL_OBJECT_TAG;
@ -233,6 +244,17 @@ namespace RenX
Jupiter::StringS victimStolenTag; Jupiter::StringS victimStolenTag;
Jupiter::StringS victimAccessTag; Jupiter::StringS victimAccessTag;
/** Building tags */
Jupiter::StringS buildingNameTag;
Jupiter::StringS buildingRawNameTag;
Jupiter::StringS buildingHealthTag;
Jupiter::StringS buildingMaxHealthTag;
Jupiter::StringS buildingHealthPercentageTag;
Jupiter::StringS buildingHealthBarTag;
Jupiter::StringS buildingTeamColorTag;
Jupiter::StringS buildingTeamShortTag;
Jupiter::StringS buildingTeamLongTag;
/** Other tags */ /** Other tags */
Jupiter::StringS weaponTag; Jupiter::StringS weaponTag;
Jupiter::StringS objectTag; Jupiter::StringS objectTag;

2
RenX.Medals/RenX_Medals.cpp

@ -94,7 +94,7 @@ void RenX_MedalsPlugin::RenX_SanitizeTags(Jupiter::StringType &fmt)
fmt.replace(RenX_MedalsPlugin::worthTag, this->INTERNAL_WORTH_TAG); fmt.replace(RenX_MedalsPlugin::worthTag, this->INTERNAL_WORTH_TAG);
} }
void RenX_MedalsPlugin::RenX_ProcessTags(Jupiter::StringType &msg, const RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim) void RenX_MedalsPlugin::RenX_ProcessTags(Jupiter::StringType &msg, const RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *, const RenX::BuildingInfo *)
{ {
if (player != nullptr) if (player != nullptr)
{ {

2
RenX.Medals/RenX_Medals.h

@ -43,7 +43,7 @@ class RenX_MedalsPlugin : public RenX::Plugin
{ {
public: // RenX::Plugin public: // RenX::Plugin
void RenX_SanitizeTags(Jupiter::StringType &fmt) override; 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_ProcessTags(Jupiter::StringType &msg, const RenX::Server *server, const RenX::PlayerInfo *player, const RenX::PlayerInfo *victim, const RenX::BuildingInfo *building) override;
void RenX_OnPlayerCreate(RenX::Server *server, const RenX::PlayerInfo *player) 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_OnPlayerDelete(RenX::Server *server, const RenX::PlayerInfo *player) override;
void RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player) override; void RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player) override;

Loading…
Cancel
Save