From 1cd1c6b06295b9331f54afb42c4e4ff08a1f9a74 Mon Sep 17 00:00:00 2001 From: JustinAJ Date: Sun, 7 Jun 2015 10:51:21 -0400 Subject: [PATCH] Added BuildingInfoIRCCommand. Removed detaul access requirements for PlayerInfoIRCCommand. --- RenX.Commands/RenX_Commands.cpp | 104 +++++++++++++++++++++++++++++++- RenX.Commands/RenX_Commands.h | 5 +- 2 files changed, 105 insertions(+), 4 deletions(-) diff --git a/RenX.Commands/RenX_Commands.cpp b/RenX.Commands/RenX_Commands.cpp index 0d70f27..8f8092c 100644 --- a/RenX.Commands/RenX_Commands.cpp +++ b/RenX.Commands/RenX_Commands.cpp @@ -17,15 +17,19 @@ #include #include "Jupiter/Functions.h" +#include "Jupiter/SLList.h" #include "IRC_Bot.h" #include "RenX_Commands.h" #include "RenX_Core.h" #include "RenX_Server.h" #include "RenX_PlayerInfo.h" +#include "RenX_BuildingInfo.h" #include "RenX_Functions.h" #include "RenX_BanDatabase.h" #include "RenX_Tags.h" +using namespace Jupiter::literals; + inline bool togglePhasing(RenX::Server *server, bool newState) { server->varData.set(STRING_LITERAL_AS_REFERENCE("RenX.Commands"), STRING_LITERAL_AS_REFERENCE("phasing"), newState ? STRING_LITERAL_AS_REFERENCE("true") : STRING_LITERAL_AS_REFERENCE("false")); @@ -69,13 +73,15 @@ int RenX_CommandsPlugin::OnRehash() RenX_CommandsPlugin::_defaultTempBanTime = Jupiter::IRC::Client::Config->getLongLong(RenX_CommandsPlugin::getName(), STRING_LITERAL_AS_REFERENCE("TBanTime"), 86400); RenX_CommandsPlugin::playerInfoFormat = Jupiter::IRC::Client::Config->get(RenX_CommandsPlugin::getName(), STRING_LITERAL_AS_REFERENCE("PlayerInfoFormat"), STRING_LITERAL_AS_REFERENCE(IRCCOLOR "03[Player Info]" IRCCOLOR "{TCOLOR} Name: " IRCBOLD "{RNAME}" IRCBOLD " - ID: {ID} - Team: " IRCBOLD "{TEAML}" IRCBOLD " - Vehicle Kills: {VEHICLEKILLS} - Building Kills {BUILDINGKILLS} - Kills {KILLS} - Deaths: {DEATHS} - KDR: {KDR} - Access: {ACCESS}")); RenX_CommandsPlugin::adminPlayerInfoFormat = Jupiter::IRC::Client::Config->get(RenX_CommandsPlugin::getName(), STRING_LITERAL_AS_REFERENCE("AdminPlayerInfoFormat"), Jupiter::StringS::Format("%.*s - IP: " IRCBOLD "{IP}" IRCBOLD " - Steam ID: " IRCBOLD "{STEAM}", RenX_CommandsPlugin::playerInfoFormat.size(), RenX_CommandsPlugin::playerInfoFormat.ptr())); + RenX_CommandsPlugin::buildingInfoFormat = Jupiter::IRC::Client::Config->get(RenX_CommandsPlugin::getName(), STRING_LITERAL_AS_REFERENCE("BuildingInfoFormat"), STRING_LITERAL_AS_REFERENCE(IRCCOLOR) + RenX::tags->buildingTeamColorTag + RenX::tags->buildingNameTag + STRING_LITERAL_AS_REFERENCE(IRCCOLOR " - " IRCCOLOR "07") + RenX::tags->buildingHealthPercentageTag + STRING_LITERAL_AS_REFERENCE("%")); RenX::sanitizeTags(RenX_CommandsPlugin::playerInfoFormat); RenX::sanitizeTags(RenX_CommandsPlugin::adminPlayerInfoFormat); + RenX::sanitizeTags(RenX_CommandsPlugin::buildingInfoFormat); return 0; } -time_t RenX_CommandsPlugin::getTBanTime() +time_t RenX_CommandsPlugin::getTBanTime() const { return RenX_CommandsPlugin::_defaultTempBanTime; } @@ -90,6 +96,11 @@ const Jupiter::ReadableString &RenX_CommandsPlugin::getAdminPlayerInfoFormat() c return RenX_CommandsPlugin::adminPlayerInfoFormat; } +const Jupiter::ReadableString &RenX_CommandsPlugin::getBuildingInfoFormat() const +{ + return RenX_CommandsPlugin::buildingInfoFormat; +} + RenX_CommandsPlugin::RenX_CommandsPlugin() { this->OnRehash(); @@ -454,7 +465,6 @@ const Jupiter::ReadableString &PlayersIRCCommand::getHelp(const Jupiter::Readabl IRC_COMMAND_INIT(PlayersIRCCommand) // PlayerTable IRC Command -#include "Jupiter/SLList.h" void PlayerTableIRCCommand::create() { this->addTrigger(STRING_LITERAL_AS_REFERENCE("pt")); @@ -577,7 +587,6 @@ void PlayerInfoIRCCommand::create() this->addTrigger(STRING_LITERAL_AS_REFERENCE("pi")); this->addTrigger(STRING_LITERAL_AS_REFERENCE("player")); this->addTrigger(STRING_LITERAL_AS_REFERENCE("pinfo")); - this->setAccessLevel(2); } void PlayerInfoIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString ¶meters) @@ -624,6 +633,95 @@ const Jupiter::ReadableString &PlayerInfoIRCCommand::getHelp(const Jupiter::Read IRC_COMMAND_INIT(PlayerInfoIRCCommand) +// BuildingInfo IRC Command + +void BuildingInfoIRCCommand::create() +{ + this->addTrigger(STRING_LITERAL_AS_REFERENCE("binfo")); + this->addTrigger(STRING_LITERAL_AS_REFERENCE("bi")); + this->addTrigger(STRING_LITERAL_AS_REFERENCE("buildinginfo")); + this->addTrigger(STRING_LITERAL_AS_REFERENCE("building")); +} + +void BuildingInfoIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString ¶meters) +{ + Jupiter::IRC::Client::Channel *chan = source->getChannel(channel); + if (chan != nullptr) + { + int type = chan->getType(); + bool seenStrip; + Jupiter::SLList gStrings; + Jupiter::SLList nStrings; + Jupiter::SLList oStrings; + Jupiter::SLList cStrings; + Jupiter::String *str = nullptr; + RenX::BuildingInfo *building; + for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++) + { + RenX::Server *server = RenX::getCore()->getServer(i); + if (server->isLogChanType(type)) + { + seenStrip = false; + for (size_t index = 0; index != server->buildings.size(); ++index) + { + building = server->buildings.get(index); + if (building->name.find("Rx_Building_Air"_jrs) == 0) + { + if (seenStrip) + continue; + + seenStrip = true; + } + str = new Jupiter::String(pluginInstance.getBuildingInfoFormat()); + RenX::processTags(*str, server, nullptr, nullptr, building); + if (building->capturable) + cStrings.add(str); + else if (building->team == RenX::TeamType::GDI) + gStrings.add(str); + else if (building->team == RenX::TeamType::Nod) + nStrings.add(str); + else + oStrings.add(str); + } + while (gStrings.size() != 0) + { + str = gStrings.remove(0); + source->sendMessage(channel, *str); + delete str; + } + while (nStrings.size() != 0) + { + str = nStrings.remove(0); + source->sendMessage(channel, *str); + delete str; + } + while (oStrings.size() != 0) + { + str = oStrings.remove(0); + source->sendMessage(channel, *str); + delete str; + } + while (cStrings.size() != 0) + { + str = cStrings.remove(0); + source->sendMessage(channel, *str); + delete str; + } + } + } + if (str == nullptr) + source->sendMessage(channel, "Error: Channel not attached to any connected Renegade X servers."_jrs); + } +} + +const Jupiter::ReadableString &BuildingInfoIRCCommand::getHelp(const Jupiter::ReadableString &) +{ + static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Gets information about a player. Syntax: PlayerInfo "); + return defaultHelp; +} + +IRC_COMMAND_INIT(BuildingInfoIRCCommand) + // Steam IRC Command void SteamIRCCommand::create() diff --git a/RenX.Commands/RenX_Commands.h b/RenX.Commands/RenX_Commands.h index 604a06b..5979730 100644 --- a/RenX.Commands/RenX_Commands.h +++ b/RenX.Commands/RenX_Commands.h @@ -37,9 +37,10 @@ public: // Jupiter::Plugin int OnRehash() override; public: - time_t getTBanTime(); + time_t getTBanTime() const; const Jupiter::ReadableString &getPlayerInfoFormat() const; const Jupiter::ReadableString &getAdminPlayerInfoFormat() const; + const Jupiter::ReadableString &getBuildingInfoFormat() const; RenX_CommandsPlugin(); private: @@ -47,6 +48,7 @@ private: time_t _defaultTempBanTime; Jupiter::StringS playerInfoFormat; Jupiter::StringS adminPlayerInfoFormat; + Jupiter::StringS buildingInfoFormat; }; GENERIC_CONSOLE_COMMAND(RawRCONConsoleCommand) @@ -59,6 +61,7 @@ GENERIC_IRC_COMMAND(HostMsgIRCCommand) GENERIC_IRC_COMMAND(PlayersIRCCommand) GENERIC_IRC_COMMAND(PlayerTableIRCCommand) GENERIC_IRC_COMMAND(PlayerInfoIRCCommand) +GENERIC_IRC_COMMAND(BuildingInfoIRCCommand) GENERIC_IRC_COMMAND(SteamIRCCommand) GENERIC_IRC_COMMAND(KillDeathRatioIRCCommand) GENERIC_IRC_COMMAND(ShowModsIRCCommand)