Browse Source

Update Jupiter submodule; adjust code accordingly

master
Jessica James 3 years ago
parent
commit
d836aa13f7
  1. 8
      src/Bot/include/IRC_Bot.h
  2. 2
      src/Bot/include/ServerManager.h
  3. 22
      src/Bot/src/IRC_Bot.cpp
  4. 2
      src/Bot/src/Main.cpp
  5. 2
      src/Bot/src/ServerManager.cpp
  6. 2
      src/Jupiter
  7. 12
      src/Plugins/CoreCommands/CoreCommands.cpp
  8. 3
      src/Plugins/FunCommands/FunCommands.cpp
  9. 11
      src/Plugins/IRC.Core/IRC_Core.cpp
  10. 55
      src/Plugins/RenX/RenX.Commands/RenX_Commands.cpp
  11. 4
      src/Plugins/RenX/RenX.Core/RenX_BanDatabase.cpp
  12. 8
      src/Plugins/RenX/RenX.Core/RenX_BanDatabase.h
  13. 2
      src/Plugins/RenX/RenX.Core/RenX_BuildingInfo.h
  14. 11
      src/Plugins/RenX/RenX.Core/RenX_Core.cpp
  15. 462
      src/Plugins/RenX/RenX.Core/RenX_Functions.cpp
  16. 6
      src/Plugins/RenX/RenX.Core/RenX_Functions.h
  17. 8
      src/Plugins/RenX/RenX.Core/RenX_GameCommand.cpp
  18. 8
      src/Plugins/RenX/RenX.Core/RenX_GameCommand.h
  19. 35
      src/Plugins/RenX/RenX.Core/RenX_LadderDatabase.cpp
  20. 22
      src/Plugins/RenX/RenX.Core/RenX_LadderDatabase.h
  21. 2
      src/Plugins/RenX/RenX.Core/RenX_Map.h
  22. 4
      src/Plugins/RenX/RenX.Core/RenX_PlayerInfo.h
  23. 535
      src/Plugins/RenX/RenX.Core/RenX_Server.cpp
  24. 42
      src/Plugins/RenX/RenX.Core/RenX_Server.h
  25. 8
      src/Plugins/RenX/RenX.Core/RenX_Tags.cpp
  26. 17
      src/Plugins/RenX/RenX.ExcessiveHeadshots/RenX_ExcessiveHeadshots.cpp
  27. 4
      src/Plugins/RenX/RenX.KickDupes/RenX_KickDupes.cpp
  28. 8
      src/Plugins/RenX/RenX.Ladder.Web/RenX_Ladder_Web.cpp
  29. 14
      src/Plugins/RenX/RenX.Ladder/RenX_Ladder.cpp
  30. 2
      src/Plugins/RenX/RenX.Listen/RenX_Listen.cpp
  31. 2
      src/Plugins/RenX/RenX.Listen/RenX_Listen.h
  32. 12
      src/Plugins/RenX/RenX.Logging/RenX_Logging.cpp
  33. 48
      src/Plugins/RenX/RenX.Medals/RenX_Medals.cpp
  34. 2
      src/Plugins/RenX/RenX.Medals/RenX_Medals.h
  35. 109
      src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.cpp
  36. 18
      src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.h
  37. 4
      src/Plugins/RenX/RenX.Relay/RenX_Relay.cpp
  38. 18
      src/Plugins/RenX/RenX.ServerList/RenX_ServerList.cpp
  39. 4
      src/Plugins/RenX/RenX.ServerList/RenX_ServerList.h
  40. 24
      src/Plugins/RenX/RenX.SetJoin/RenX_SetJoin.cpp
  41. 29
      src/Plugins/RenX/RenX.Warn/RenX_Warn.cpp
  42. 21
      src/Plugins/SetJoin/SetJoin.cpp

8
src/Bot/include/IRC_Bot.h

@ -61,7 +61,7 @@ public:
* @param trigger Trigger of the command to remove * @param trigger Trigger of the command to remove
* @return True if a command is removed, false otherwise. * @return True if a command is removed, false otherwise.
*/ */
bool freeCommand(const Jupiter::ReadableString &trigger); bool freeCommand(std::string_view trigger);
/** /**
* @return Gets a command. * @return Gets a command.
@ -69,7 +69,7 @@ public:
* @param trigger Trigger of the command to find. * @param trigger Trigger of the command to find.
* @return First command using the specified trigger, nullptr otherwise. * @return First command using the specified trigger, nullptr otherwise.
*/ */
IRCCommand *getCommand(const Jupiter::ReadableString &trigger) const; IRCCommand *getCommand(std::string_view trigger) const;
/** /**
* @brief Creates and returns a vector of IRC Commands with a specified access level. * @brief Creates and returns a vector of IRC Commands with a specified access level.
@ -86,7 +86,7 @@ public:
* @param cmds Commands to construct the string with. * @param cmds Commands to construct the string with.
* @return A string containing the triggers of the commands in a space-deliminated list. * @return A string containing the triggers of the commands in a space-deliminated list.
*/ */
static Jupiter::StringL getTriggers(std::vector<IRCCommand*> &cmds); static std::string getTriggers(std::vector<IRCCommand*> &cmds);
/** /**
* @brief Reloads some settings. * @brief Reloads some settings.
@ -117,7 +117,7 @@ protected:
/** Private members for internal usage */ /** Private members for internal usage */
private: private:
std::vector<std::unique_ptr<IRCCommand>> m_commands; std::vector<std::unique_ptr<IRCCommand>> m_commands;
Jupiter::StringS m_commandPrefix; std::string m_commandPrefix;
}; };
/** Re-enable warnings */ /** Re-enable warnings */

2
src/Bot/include/ServerManager.h

@ -109,7 +109,7 @@ public:
* *
* @return True if a socket connection was successfully established, false otherwise. * @return True if a socket connection was successfully established, false otherwise.
*/ */
bool addServer(const Jupiter::ReadableString &serverConfig); bool addServer(std::string_view serverConfig);
/** /**
* @brief Removes a server from the manager, based on its index. * @brief Removes a server from the manager, based on its index.

22
src/Bot/src/IRC_Bot.cpp

@ -19,6 +19,7 @@
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <cctype> #include <cctype>
#include "jessilib/unicode.hpp"
#include "Jupiter/Config.h" #include "Jupiter/Config.h"
#include "Jupiter/Plugin.h" #include "Jupiter/Plugin.h"
#include "Jupiter/Functions.h" #include "Jupiter/Functions.h"
@ -26,6 +27,7 @@
#include "IRC_Command.h" #include "IRC_Command.h"
using namespace Jupiter::literals; using namespace Jupiter::literals;
using namespace std::literals;
IRC_Bot::IRC_Bot(Jupiter::Config *in_primary_section, Jupiter::Config *in_secondary_section) IRC_Bot::IRC_Bot(Jupiter::Config *in_primary_section, Jupiter::Config *in_secondary_section)
: Client(in_primary_section, in_secondary_section) { : Client(in_primary_section, in_secondary_section) {
@ -53,7 +55,7 @@ void IRC_Bot::addCommand(IRCCommand *in_command) {
setCommandAccessLevels(in_command); setCommandAccessLevels(in_command);
} }
bool IRC_Bot::freeCommand(const Jupiter::ReadableString &trigger) { bool IRC_Bot::freeCommand(std::string_view trigger) {
for (auto itr = m_commands.begin(); itr != m_commands.end(); ++itr) { for (auto itr = m_commands.begin(); itr != m_commands.end(); ++itr) {
if ((*itr)->matches(trigger)) { if ((*itr)->matches(trigger)) {
m_commands.erase(itr); m_commands.erase(itr);
@ -64,7 +66,7 @@ bool IRC_Bot::freeCommand(const Jupiter::ReadableString &trigger) {
return false; return false;
} }
IRCCommand* IRC_Bot::getCommand(const Jupiter::ReadableString &trigger) const { IRCCommand* IRC_Bot::getCommand(std::string_view trigger) const {
for (const auto& command : m_commands) { for (const auto& command : m_commands) {
if (command->matches(trigger)) { if (command->matches(trigger)) {
return command.get(); return command.get();
@ -86,8 +88,8 @@ std::vector<IRCCommand*> IRC_Bot::getAccessCommands(Jupiter::IRC::Client::Channe
} }
// TODO: This isn't really needed on here // TODO: This isn't really needed on here
Jupiter::StringL IRC_Bot::getTriggers(std::vector<IRCCommand*> &commands) { std::string IRC_Bot::getTriggers(std::vector<IRCCommand*> &commands) {
Jupiter::StringL result; std::string result;
for (const auto& command : commands) { for (const auto& command : commands) {
result += command->getTrigger(); result += command->getTrigger();
result += ' '; result += ' ';
@ -116,33 +118,33 @@ void IRC_Bot::setCommandAccessLevels(IRCCommand *in_command) {
if (tmp_index != Jupiter::INVALID_INDEX) { if (tmp_index != Jupiter::INVALID_INDEX) {
// non-default access assignment // non-default access assignment
tmp_key.set(entry.first.ptr(), tmp_index); tmp_key.set(entry.first.data(), tmp_index);
tmp_sub_key = entry.first; tmp_sub_key = entry.first;
tmp_sub_key.shiftRight(tmp_index + 1); tmp_sub_key.shiftRight(tmp_index + 1);
if (tmp_sub_key.findi("Type."_jrs) == 0) { if (jessilib::starts_withi(tmp_sub_key, "Type."sv)) {
tmp_sub_key.shiftRight(5); // shift beyond "Type." tmp_sub_key.shiftRight(5); // shift beyond "Type."
command = this->getCommand(tmp_key); command = this->getCommand(tmp_key);
if (command != nullptr && (in_command == nullptr || in_command == command)) { if (command != nullptr && (in_command == nullptr || in_command == command)) {
command->setAccessLevel(tmp_sub_key.asInt(), entry.second.asInt()); command->setAccessLevel(tmp_sub_key.asInt(), Jupiter::ReferenceString{entry.second}.asInt());
} }
} }
else if (tmp_sub_key.findi("Channel."_jrs) == 0) { else if (jessilib::starts_withi(tmp_sub_key, "Channel."sv)) {
tmp_sub_key.shiftRight(8); // shift beyond "Channel." tmp_sub_key.shiftRight(8); // shift beyond "Channel."
// Assign access level to command (if command exists) // Assign access level to command (if command exists)
command = this->getCommand(tmp_key); command = this->getCommand(tmp_key);
if (command != nullptr && (in_command == nullptr || in_command == command)) if (command != nullptr && (in_command == nullptr || in_command == command))
command->setAccessLevel(tmp_sub_key, entry.second.asInt()); command->setAccessLevel(tmp_sub_key, Jupiter::ReferenceString{entry.second}.asInt());
} }
} }
else { else {
// Assign access level to command (if command exists) // Assign access level to command (if command exists)
command = this->getCommand(entry.first); command = this->getCommand(entry.first);
if (command != nullptr && (in_command == nullptr || in_command == command)) if (command != nullptr && (in_command == nullptr || in_command == command))
command->setAccessLevel(entry.second.asInt()); command->setAccessLevel(Jupiter::ReferenceString{entry.second}.asInt());
} }
}; };
}; };

2
src/Bot/src/Main.cpp

@ -189,7 +189,7 @@ int main(int argc, const char **args) {
configFileName = args[i]; configFileName = args[i];
else if ("-pluginsdir"_jrs.equalsi(args[i]) && ++i < argc) else if ("-pluginsdir"_jrs.equalsi(args[i]) && ++i < argc)
plugins_directory = args[i]; plugins_directory = args[i];
else if ("-configsdir"_jrs.equals(args[i]) && ++i < argc) else if ("-configsdir"_jrs.equalsi(args[i]) && ++i < argc)
configs_directory = args[i]; configs_directory = args[i];
else if ("-configFormat"_jrs.equalsi(args[i]) && ++i < argc) else if ("-configFormat"_jrs.equalsi(args[i]) && ++i < argc)
puts("Feature not yet supported!"); puts("Feature not yet supported!");

2
src/Bot/src/ServerManager.cpp

@ -102,7 +102,7 @@ IRC_Bot *ServerManager::getServer(size_t serverIndex) {
return nullptr; return nullptr;
} }
bool ServerManager::addServer(const Jupiter::ReadableString &serverConfig) { bool ServerManager::addServer(std::string_view serverConfig) {
auto server = std::make_unique<IRC_Bot>(m_config->getSection(serverConfig), m_config->getSection("Default"_jrs)); auto server = std::make_unique<IRC_Bot>(m_config->getSection(serverConfig), m_config->getSection("Default"_jrs));
if (server->connect()) { if (server->connect()) {
m_servers.push_back(std::move(server)); m_servers.push_back(std::move(server));

2
src/Jupiter

@ -1 +1 @@
Subproject commit 5715a041d2791d36128cc840c81626030091157b Subproject commit 90165eead3d3bdbaf7403eb947a41b4a7513b161

12
src/Plugins/CoreCommands/CoreCommands.cpp

@ -31,13 +31,13 @@ HelpConsoleCommand::HelpConsoleCommand() {
void HelpConsoleCommand::trigger(const Jupiter::ReadableString &parameters) { void HelpConsoleCommand::trigger(const Jupiter::ReadableString &parameters) {
if (parameters.isEmpty()) { if (parameters.isEmpty()) {
fputs("Supported commands:", stdout); std::cout << "Supported commands:";
for (const auto& command : consoleCommands) { for (const auto& command : consoleCommands) {
fputc(' ', stdout); std::cout << ' ' << command->getTrigger();
command->getTrigger().print(stdout);
} }
printf(ENDL "%s - %s" ENDL, Jupiter::version, Jupiter::copyright); std::cout << std::endl
puts("For command-specific help, use: help <command>"); << Jupiter::version << " - " << Jupiter::copyright << std::endl
<< "For command-specific help, use: help <command>" << std::endl;
return; return;
} }
@ -69,7 +69,7 @@ void HelpIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &in_
if (channel != nullptr) if (channel != nullptr)
{ {
int access = source->getAccessLevel(*channel, nick); int access = source->getAccessLevel(*channel, nick);
if (parameters == nullptr) if (parameters.isEmpty())
{ {
for (int i = 0; i <= access; i++) for (int i = 0; i <= access; i++)
{ {

3
src/Plugins/FunCommands/FunCommands.cpp

@ -23,6 +23,7 @@
#include "IRC_Bot.h" #include "IRC_Bot.h"
using namespace Jupiter::literals; using namespace Jupiter::literals;
using namespace std::literals;
// 8ball // 8ball
@ -78,7 +79,7 @@ void EightBallIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString
msg.set("Fuck your lineage."_jrs); msg.set("Fuck your lineage."_jrs);
break; break;
case 13: case 13:
if (channel.equals("#Jail"_jrs)) if (channel == "#Jail"sv)
msg.set("Ask me those kind of questions in #Politics"_jrs); msg.set("Ask me those kind of questions in #Politics"_jrs);
else else
msg.set("Ask me those kind of questions in #Jail"_jrs); msg.set("Ask me those kind of questions in #Jail"_jrs);

11
src/Plugins/IRC.Core/IRC_Core.cpp

@ -16,6 +16,7 @@
* Written by Jessica James <jessica.aj@outlook.com> * Written by Jessica James <jessica.aj@outlook.com>
*/ */
#include "jessilib/word_split.hpp"
#include "Jupiter/GenericCommand.h" #include "Jupiter/GenericCommand.h"
#include "ServerManager.h" #include "ServerManager.h"
#include "IRC_Command.h" #include "IRC_Command.h"
@ -32,13 +33,13 @@ IRCCorePlugin::~IRCCorePlugin() {
bool IRCCorePlugin::initialize() { bool IRCCorePlugin::initialize() {
// TODO: initialize() isn't bringing in generic commands from already-loaded plugins // TODO: initialize() isn't bringing in generic commands from already-loaded plugins
const Jupiter::ReadableString &serverList = this->config.get("Servers"_jrs); std::string_view serverList = this->config.get("Servers"_jrs);
if (serverList != nullptr) { if (!serverList.empty()) {
serverManager->setConfig(this->config); serverManager->setConfig(this->config);
unsigned int server_count = serverList.wordCount(WHITESPACE); auto server_entries = jessilib::word_split(serverList, WHITESPACE_SV);
for (unsigned int index = 0; index != server_count; ++index) { for (const auto& entry : server_entries) {
serverManager->addServer(Jupiter::ReferenceString::getWord(serverList, index, WHITESPACE)); serverManager->addServer(entry);
} }
} }

55
src/Plugins/RenX/RenX.Commands/RenX_Commands.cpp

@ -20,6 +20,7 @@
#include <functional> #include <functional>
#include "Jupiter/Functions.h" #include "Jupiter/Functions.h"
#include "jessilib/duration.hpp" #include "jessilib/duration.hpp"
#include "jessilib/unicode.hpp"
#include "IRC_Bot.h" #include "IRC_Bot.h"
#include "RenX_Commands.h" #include "RenX_Commands.h"
#include "RenX_Core.h" #include "RenX_Core.h"
@ -33,11 +34,12 @@
using namespace Jupiter::literals; using namespace Jupiter::literals;
using namespace jessilib::literals; using namespace jessilib::literals;
using namespace std::literals;
const Jupiter::ReferenceString RxCommandsSection = "RenX.Commands"_jrs; const Jupiter::ReferenceString RxCommandsSection = "RenX.Commands"_jrs;
bool togglePhasing(RenX::Server *server, bool newState) { bool togglePhasing(RenX::Server *server, bool newState) {
server->varData[RxCommandsSection].set("phasing"_jrs, newState ? "true"_jrs : "false"_jrs); server->varData[RxCommandsSection].set("phasing"sv, newState ? "true"s : "false"s);
return newState; return newState;
} }
@ -660,9 +662,9 @@ void PlayerTableIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableStri
auto output_player = [server, type, source, &channel, maxNickLen, idColLen, scoreColLen, creditColLen](RenX::PlayerInfo *player, const Jupiter::ReadableString &color) auto output_player = [server, type, source, &channel, maxNickLen, idColLen, scoreColLen, creditColLen](RenX::PlayerInfo *player, const Jupiter::ReadableString &color)
{ {
if (server->isAdminLogChanType(type)) if (server->isAdminLogChanType(type))
source->sendMessage(channel, Jupiter::StringS::Format(IRCCOLOR "%.*s%*.*s" IRCCOLOR " " IRCCOLOR "03|" IRCCOLOR " %*d " IRCCOLOR "03|" IRCCOLOR " %*.0f " IRCCOLOR "03|" IRCCOLOR " %*.0f " IRCCOLOR "03|" IRCNORMAL " %.*s", color.size(), color.ptr(), maxNickLen, player->name.size(), player->name.ptr(), idColLen, player->id, scoreColLen, player->score, creditColLen, player->credits, player->ip.size(), player->ip.ptr())); source->sendMessage(channel, Jupiter::StringS::Format(IRCCOLOR "%.*s%*.*s" IRCCOLOR " " IRCCOLOR "03|" IRCCOLOR " %*d " IRCCOLOR "03|" IRCCOLOR " %*.0f " IRCCOLOR "03|" IRCCOLOR " %*.0f " IRCCOLOR "03|" IRCNORMAL " %.*s", color.size(), color.ptr(), maxNickLen, player->name.size(), player->name.data(), idColLen, player->id, scoreColLen, player->score, creditColLen, player->credits, player->ip.size(), player->ip.ptr()));
else else
source->sendMessage(channel, Jupiter::StringS::Format(IRCCOLOR "%.*s%*.*s" IRCCOLOR " " IRCCOLOR "03|" IRCCOLOR " %*d " IRCCOLOR "03|" IRCCOLOR " %*.0f " IRCCOLOR "03|" IRCCOLOR " %*.0f", color.size(), color.ptr(), maxNickLen, player->name.size(), player->name.ptr(), idColLen, player->id, scoreColLen, player->score, creditColLen, player->credits)); source->sendMessage(channel, Jupiter::StringS::Format(IRCCOLOR "%.*s%*.*s" IRCCOLOR " " IRCCOLOR "03|" IRCCOLOR " %*d " IRCCOLOR "03|" IRCCOLOR " %*.0f " IRCCOLOR "03|" IRCCOLOR " %*.0f", color.size(), color.ptr(), maxNickLen, player->name.size(), player->name.data(), idColLen, player->id, scoreColLen, player->score, creditColLen, player->credits));
}; };
for (auto node = gPlayers.begin(); node != gPlayers.end(); ++node) for (auto node = gPlayers.begin(); node != gPlayers.end(); ++node)
@ -723,7 +725,7 @@ void PlayerInfoIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableStrin
server = RenX::getCore()->getServer(index++); server = RenX::getCore()->getServer(index++);
if (server->isLogChanType(type) && server->players.size() != 0) { if (server->isLogChanType(type) && server->players.size() != 0) {
for (auto node = server->players.begin(); node != server->players.end(); ++node) { for (auto node = server->players.begin(); node != server->players.end(); ++node) {
if (node->name.findi(parameters) != Jupiter::INVALID_INDEX) { if (jessilib::findi(node->name, std::string_view{parameters}) != std::string::npos) {
msg = player_info_format; msg = player_info_format;
RenX::processTags(msg, server, &*node); RenX::processTags(msg, server, &*node);
source->sendMessage(channel, msg); source->sendMessage(channel, msg);
@ -895,7 +897,7 @@ void RotationIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString
if (server->isLogChanType(type)) { if (server->isLogChanType(type)) {
list = STRING_LITERAL_AS_REFERENCE(IRCCOLOR "03[Rotation]" IRCNORMAL); list = STRING_LITERAL_AS_REFERENCE(IRCCOLOR "03[Rotation]" IRCNORMAL);
for (const auto& map : server->maps) { for (const auto& map : server->maps) {
if (server->getMap().name.equalsi(map.name)) { if (jessilib::equalsi(server->getMap().name, map.name)) {
list += STRING_LITERAL_AS_REFERENCE(" " IRCBOLD "[") + map.name + STRING_LITERAL_AS_REFERENCE("]" IRCBOLD); list += STRING_LITERAL_AS_REFERENCE(" " IRCBOLD "[") + map.name + STRING_LITERAL_AS_REFERENCE("]" IRCBOLD);
} }
else { else {
@ -981,7 +983,7 @@ void GameInfoIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString
match = true; match = true;
const RenX::Map &map = server->getMap(); const RenX::Map &map = server->getMap();
std::chrono::seconds time = std::chrono::duration_cast<std::chrono::seconds>(server->getGameTime()); std::chrono::seconds time = std::chrono::duration_cast<std::chrono::seconds>(server->getGameTime());
source->sendMessage(channel, IRCCOLOR "03[GameInfo] "_jrs IRCCOLOR + server->getGameVersion()); source->sendMessage(channel, Jupiter::StringS::Format(IRCCOLOR "03[GameInfo] " IRCCOLOR "%.*s", server->getGameVersion().size(), server->getGameVersion().data()));
source->sendMessage(channel, IRCCOLOR "03[GameInfo] " IRCCOLOR "10Map" IRCCOLOR ": "_jrs + map.name + "; " IRCCOLOR "10GUID" IRCCOLOR ": "_jrs + RenX::formatGUID(map)); source->sendMessage(channel, IRCCOLOR "03[GameInfo] " IRCCOLOR "10Map" IRCCOLOR ": "_jrs + map.name + "; " IRCCOLOR "10GUID" IRCCOLOR ": "_jrs + RenX::formatGUID(map));
source->sendMessage(channel, Jupiter::StringS::Format(IRCCOLOR "03[GameInfo] " IRCCOLOR "10Elapsed time" IRCCOLOR ": %.2lld:%.2lld:%.2lld", time.count() / 3600, (time.count() % 3600) / 60, time.count() % 60)); source->sendMessage(channel, Jupiter::StringS::Format(IRCCOLOR "03[GameInfo] " IRCCOLOR "10Elapsed time" IRCCOLOR ": %.2lld:%.2lld:%.2lld", time.count() / 3600, (time.count() % 3600) / 60, time.count() % 60));
source->sendMessage(channel, Jupiter::StringS::Format(IRCCOLOR "03[GameInfo] " IRCCOLOR "There are " IRCCOLOR "10%d" IRCCOLOR " players online.", server->players.size())); source->sendMessage(channel, Jupiter::StringS::Format(IRCCOLOR "03[GameInfo] " IRCCOLOR "There are " IRCCOLOR "10%d" IRCCOLOR " players online.", server->players.size()));
@ -1024,7 +1026,7 @@ void SteamIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &ch
{ {
for (auto node = server->players.begin(); node != server->players.end(); ++node) for (auto node = server->players.begin(); node != server->players.end(); ++node)
{ {
if (node->name.findi(parameters) != Jupiter::INVALID_INDEX) if (jessilib::findi(node->name, Jupiter::ReferenceString{parameters}) != std::string::npos)
{ {
Jupiter::String playerName = RenX::getFormattedPlayerName(*node); Jupiter::String playerName = RenX::getFormattedPlayerName(*node);
msg.format(IRCCOLOR "03[Steam] " IRCCOLOR "%.*s (ID: %d) ", playerName.size(), playerName.ptr(), node->id); msg.format(IRCCOLOR "03[Steam] " IRCCOLOR "%.*s (ID: %d) ", playerName.size(), playerName.ptr(), node->id);
@ -1110,7 +1112,7 @@ void KillDeathRatioIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableS
{ {
for (auto node = server->players.begin(); node != server->players.end(); ++node) for (auto node = server->players.begin(); node != server->players.end(); ++node)
{ {
if (node->name.findi(parameters) != Jupiter::INVALID_INDEX) if (jessilib::findi(node->name, Jupiter::ReferenceString{parameters}) != std::string::npos)
{ {
Jupiter::String playerName = RenX::getFormattedPlayerName(*node); Jupiter::String playerName = RenX::getFormattedPlayerName(*node);
msg.format(IRCBOLD "%.*s" IRCBOLD IRCCOLOR ": Kills: %u - Deaths: %u - KDR: %.2f", playerName.size(), playerName.ptr(), node->kills, node->deaths, static_cast<double>(node->kills) / (node->deaths == 0 ? 1.0f : static_cast<double>(node->deaths))); msg.format(IRCBOLD "%.*s" IRCBOLD IRCCOLOR ": Kills: %u - Deaths: %u - KDR: %.2f", playerName.size(), playerName.ptr(), node->kills, node->deaths, static_cast<double>(node->kills) / (node->deaths == 0 ? 1.0f : static_cast<double>(node->deaths)));
@ -1431,7 +1433,7 @@ void SetMapIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &c
Jupiter::IRC::Client::Channel *chan = source->getChannel(channel); Jupiter::IRC::Client::Channel *chan = source->getChannel(channel);
if (chan != nullptr) if (chan != nullptr)
{ {
const Jupiter::ReadableString *map_name = nullptr; std::string_view map_name;
int type = chan->getType(); int type = chan->getType();
for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++) for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++)
{ {
@ -1439,9 +1441,9 @@ void SetMapIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &c
if (server->isLogChanType(type)) if (server->isLogChanType(type))
{ {
map_name = server->getMapName(parameters); map_name = server->getMapName(parameters);
if (map_name == nullptr) if (map_name.empty())
source->sendMessage(channel, STRING_LITERAL_AS_REFERENCE("Error: Map not in rotation.")); source->sendMessage(channel, STRING_LITERAL_AS_REFERENCE("Error: Map not in rotation."));
else if (server->setMap(*map_name) == false) else if (server->setMap(map_name) == false)
source->sendMessage(channel, STRING_LITERAL_AS_REFERENCE("Error: Transmission error.")); source->sendMessage(channel, STRING_LITERAL_AS_REFERENCE("Error: Transmission error."));
} }
} }
@ -1903,15 +1905,15 @@ void BanSearchIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString
case 2: // IP case 2: // IP
return entry->ip == params.asUnsignedInt(); return entry->ip == params.asUnsignedInt();
case 3: // HWID case 3: // HWID
return entry->hwid.equals(params); return entry->hwid == std::string_view{params};
case 4: // RDNS case 4: // RDNS
return entry->rdns.equals(params); return entry->rdns == std::string_view{params};
case 5: // STEAM case 5: // STEAM
return entry->steamid == params.asUnsignedLongLong(); return entry->steamid == params.asUnsignedLongLong();
case 6: // NAME case 6: // NAME
return entry->name.equalsi(params); return entry->name.equalsi(params);
case 7: // BANNER case 7: // BANNER
return entry->banner.equalsi(params); return jessilib::equalsi(entry->banner, params);
case 8: // ACTIVE case 8: // ACTIVE
return params.asBool() == entry->is_active(); return params.asBool() == entry->is_active();
} }
@ -1919,7 +1921,7 @@ void BanSearchIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString
unsigned int type; unsigned int type;
Jupiter::ReferenceString type_str = Jupiter::ReferenceString::getWord(parameters, 0, WHITESPACE); Jupiter::ReferenceString type_str = Jupiter::ReferenceString::getWord(parameters, 0, WHITESPACE);
if (type_str.equalsi(STRING_LITERAL_AS_REFERENCE("all")) || type_str.equals('*')) if (type_str.equalsi(STRING_LITERAL_AS_REFERENCE("all")) || type_str == '*')
type = 1; type = 1;
else if (type_str.equalsi(STRING_LITERAL_AS_REFERENCE("ip"))) else if (type_str.equalsi(STRING_LITERAL_AS_REFERENCE("ip")))
type = 2; type = 2;
@ -1986,14 +1988,14 @@ void BanSearchIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString
out.format("ID: %lu (" IRCCOLOR "%sactive" IRCCOLOR "); Added: %s; Expires: %s; IP: %.*s/%u; HWID: %.*s; Steam: %llu; Types:%.*s Name: %.*s; Banner: %.*s", out.format("ID: %lu (" IRCCOLOR "%sactive" IRCCOLOR "); Added: %s; Expires: %s; IP: %.*s/%u; HWID: %.*s; Steam: %llu; Types:%.*s Name: %.*s; Banner: %.*s",
i, entry->is_active() ? "12" : "04in", dateStr, expireStr, ip_str.size(), ip_str.ptr(), entry->prefix_length, entry->hwid.size(), entry->hwid.ptr(), entry->steamid, i, entry->is_active() ? "12" : "04in", dateStr, expireStr, ip_str.size(), ip_str.ptr(), entry->prefix_length, entry->hwid.size(), entry->hwid.ptr(), entry->steamid,
types.size(), types.ptr(), entry->name.size(), entry->name.ptr(), entry->banner.size(), entry->banner.ptr()); types.size(), types.ptr(), entry->name.size(), entry->name.ptr(), entry->banner.size(), entry->banner.data());
if (entry->rdns.isNotEmpty()) if (entry->rdns.isNotEmpty())
{ {
out.concat("; RDNS: "_jrs); out.concat("; RDNS: "_jrs);
out.concat(entry->rdns); out.concat(entry->rdns);
} }
if (entry->reason.isNotEmpty()) if (!entry->reason.empty())
{ {
out.concat("; Reason: "_jrs); out.concat("; Reason: "_jrs);
out.concat(entry->reason); out.concat(entry->reason);
@ -2492,7 +2494,7 @@ void ExemptionSearchIRCCommand::trigger(IRC_Bot *source, const Jupiter::Readable
unsigned int type; unsigned int type;
Jupiter::ReferenceString type_str = Jupiter::ReferenceString::getWord(parameters, 0, WHITESPACE); Jupiter::ReferenceString type_str = Jupiter::ReferenceString::getWord(parameters, 0, WHITESPACE);
if (type_str.equalsi(STRING_LITERAL_AS_REFERENCE("all")) || type_str.equals('*')) if (type_str.equalsi(STRING_LITERAL_AS_REFERENCE("all")) || type_str == '*')
type = 1; type = 1;
else if (type_str.equalsi(STRING_LITERAL_AS_REFERENCE("ip"))) else if (type_str.equalsi(STRING_LITERAL_AS_REFERENCE("ip")))
type = 2; type = 2;
@ -3043,7 +3045,7 @@ void RefundIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &c
if (server->giveCredits(*player, credits)) { if (server->giveCredits(*player, credits)) {
msg.format("You have been refunded %.0f credits by %.*s.", credits, nick.size(), nick.ptr()); msg.format("You have been refunded %.0f credits by %.*s.", credits, nick.size(), nick.ptr());
server->sendMessage(*player, msg); server->sendMessage(*player, msg);
msg.format("%.*s has been refunded %.0f credits.", player->name.size(), player->name.ptr(), credits); msg.format("%.*s has been refunded %.0f credits.", player->name.size(), player->name.data(), credits);
} }
else { else {
msg.set("Error: Server does not support refunds."); msg.set("Error: Server does not support refunds.");
@ -3097,7 +3099,7 @@ void TeamChangeIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableStrin
{ {
for (auto node = server->players.begin(); node != server->players.end(); ++node) for (auto node = server->players.begin(); node != server->players.end(); ++node)
{ {
if (node->name.findi(playerName) != Jupiter::INVALID_INDEX) if (jessilib::findi(node->name, playerName) != std::string::npos)
{ {
playerFound = true; playerFound = true;
if (server->changeTeam(*node) == false) if (server->changeTeam(*node) == false)
@ -3150,7 +3152,7 @@ void TeamChange2IRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableStri
{ {
for (auto node = server->players.begin(); node != server->players.end(); ++node) for (auto node = server->players.begin(); node != server->players.end(); ++node)
{ {
if (node->name.findi(playerName) != Jupiter::INVALID_INDEX) if (jessilib::findi(node->name, playerName) != std::string::npos)
{ {
playerFound = true; playerFound = true;
if (server->changeTeam(*node, false) == false) if (server->changeTeam(*node, false) == false)
@ -3351,7 +3353,7 @@ void HelpGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, co
unsigned int cmdCount = 0; unsigned int cmdCount = 0;
auto getAccessCommands = [&](int accessLevel) auto getAccessCommands = [&](int accessLevel)
{ {
Jupiter::String list; std::string list;
unsigned int i = 0; unsigned int i = 0;
while (i != source->getCommandCount()) while (i != source->getCommandCount())
{ {
@ -3359,7 +3361,8 @@ void HelpGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, co
if (cmd->getAccessLevel() == accessLevel) if (cmd->getAccessLevel() == accessLevel)
{ {
cmdCount++; cmdCount++;
list.format("Access level %d commands: %.*s", accessLevel, cmd->getTrigger().size(), cmd->getTrigger().ptr()); list = "Access level "s + std::to_string(accessLevel) + " commands: "s;
list += cmd->getTrigger();
break; break;
} }
} }
@ -3381,7 +3384,7 @@ void HelpGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, co
for (int i = 0; i <= player->access; i++) for (int i = 0; i <= player->access; i++)
{ {
auto msg = getAccessCommands(i); auto msg = getAccessCommands(i);
if (msg.isNotEmpty()) if (!msg.empty())
source->sendMessage(*player, getAccessCommands(i)); source->sendMessage(*player, getAccessCommands(i));
} }
if (cmdCount == 0) if (cmdCount == 0)
@ -3435,7 +3438,7 @@ void ModsGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *, const Ju
msg += "No "_jrs + staff_word + "s are in-game"_jrs; msg += "No "_jrs + staff_word + "s are in-game"_jrs;
RenX::GameCommand *cmd = source->getCommand(STRING_LITERAL_AS_REFERENCE("modrequest")); RenX::GameCommand *cmd = source->getCommand(STRING_LITERAL_AS_REFERENCE("modrequest"));
if (cmd != nullptr) if (cmd != nullptr)
msg.aformat("; please use \"%.*s%.*s\" if you require assistance.", source->getCommandPrefix().size(), source->getCommandPrefix().ptr(), cmd->getTrigger().size(), cmd->getTrigger().ptr()); msg.aformat("; please use \"%.*s%.*s\" if you require assistance.", source->getCommandPrefix().size(), source->getCommandPrefix().data(), cmd->getTrigger().size(), cmd->getTrigger().data());
else msg += '.'; else msg += '.';
} }
source->sendMessage(msg); source->sendMessage(msg);
@ -3498,7 +3501,7 @@ void ModRequestGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *play
for (auto& user : channel.getUsers()) { for (auto& user : channel.getUsers()) {
if (channel.getUserPrefix(*user.second) != 0 // If the user has a prefix... if (channel.getUserPrefix(*user.second) != 0 // If the user has a prefix...
&& !user.second->getNickname().equals(server.getNickname())) { // And the user isn't this bot... && user.second->getNickname() != server.getNickname()) { // And the user isn't this bot...
// Alert the user // Alert the user
server.sendMessage(user.second->getNickname(), user_message); server.sendMessage(user.second->getNickname(), user_message);
++total_user_alerts; ++total_user_alerts;

4
src/Plugins/RenX/RenX.Core/RenX_BanDatabase.cpp

@ -157,7 +157,7 @@ void RenX::BanDatabase::write(Entry* entry, FILE *file) {
fgetpos(file, std::addressof(m_eof)); fgetpos(file, std::addressof(m_eof));
} }
void RenX::BanDatabase::add(RenX::Server *server, const RenX::PlayerInfo &player, const Jupiter::ReadableString &banner, const Jupiter::ReadableString &reason, std::chrono::seconds length, uint16_t flags) { void RenX::BanDatabase::add(RenX::Server *server, const RenX::PlayerInfo &player, std::string_view banner, std::string_view reason, std::chrono::seconds length, uint16_t flags) {
std::unique_ptr<Entry> entry = std::make_unique<Entry>(); std::unique_ptr<Entry> entry = std::make_unique<Entry>();
if (flags != 0) { if (flags != 0) {
entry->set_active(); entry->set_active();
@ -190,7 +190,7 @@ void RenX::BanDatabase::add(RenX::Server *server, const RenX::PlayerInfo &player
write(m_entries.back().get()); write(m_entries.back().get());
} }
void RenX::BanDatabase::add(const Jupiter::ReadableString &name, uint32_t ip, uint8_t prefix_length, uint64_t steamid, const Jupiter::ReadableString &hwid, const Jupiter::ReadableString &rdns, const Jupiter::ReadableString &banner, Jupiter::ReadableString &reason, std::chrono::seconds length, uint16_t flags) { void RenX::BanDatabase::add(const Jupiter::ReadableString &name, uint32_t ip, uint8_t prefix_length, uint64_t steamid, const Jupiter::ReadableString &hwid, const Jupiter::ReadableString &rdns, std::string_view banner, std::string_view reason, std::chrono::seconds length, uint16_t flags) {
std::unique_ptr<Entry> entry = std::make_unique<Entry>(); std::unique_ptr<Entry> entry = std::make_unique<Entry>();
entry->set_active(); entry->set_active();
entry->flags |= flags; entry->flags |= flags;

8
src/Plugins/RenX/RenX.Core/RenX_BanDatabase.h

@ -90,8 +90,8 @@ namespace RenX
Jupiter::StringS hwid; /** Hardware ID of the banned player */ Jupiter::StringS hwid; /** Hardware ID of the banned player */
Jupiter::StringS rdns /** RDNS of the banned player */; Jupiter::StringS rdns /** RDNS of the banned player */;
Jupiter::StringS name /** Name of the banned player */; Jupiter::StringS name /** Name of the banned player */;
Jupiter::StringS banner /** Name of the user who initiated the ban */; std::string banner /** Name of the user who initiated the ban */;
Jupiter::StringS reason /** Reason the player was banned */; std::string reason /** Reason the player was banned */;
VarDataTableType varData; /** Variable entry data */ VarDataTableType varData; /** Variable entry data */
static const uint16_t FLAG_ACTIVE = 0x8000U; static const uint16_t FLAG_ACTIVE = 0x8000U;
@ -144,7 +144,7 @@ namespace RenX
* @param player Data of the player to be banned * @param player Data of the player to be banned
* @param length Duration of the ban * @param length Duration of the ban
*/ */
void add(RenX::Server *server, const RenX::PlayerInfo &player, const Jupiter::ReadableString &banner, const Jupiter::ReadableString &reason, std::chrono::seconds length, uint16_t flags = RenX::BanDatabase::Entry::FLAG_TYPE_GAME); void add(RenX::Server *server, const RenX::PlayerInfo &player, std::string_view banner, std::string_view reason, std::chrono::seconds length, uint16_t flags = RenX::BanDatabase::Entry::FLAG_TYPE_GAME);
/** /**
* @brief Adds a ban entry for a set of player information and immediately writes it to the database. * @brief Adds a ban entry for a set of player information and immediately writes it to the database.
@ -158,7 +158,7 @@ namespace RenX
* @param reason Reason the player is getting banned * @param reason Reason the player is getting banned
* @param length Duration of the ban * @param length Duration of the ban
*/ */
void add(const Jupiter::ReadableString &name, uint32_t ip, uint8_t prefix_length, uint64_t steamid, const Jupiter::ReadableString &hwid, const Jupiter::ReadableString &rdns, const Jupiter::ReadableString &banner, Jupiter::ReadableString &reason, std::chrono::seconds length, uint16_t flags = RenX::BanDatabase::Entry::FLAG_TYPE_GAME); void add(const Jupiter::ReadableString &name, uint32_t ip, uint8_t prefix_length, uint64_t steamid, const Jupiter::ReadableString &hwid, const Jupiter::ReadableString &rdns, std::string_view banner, std::string_view reason, std::chrono::seconds length, uint16_t flags = RenX::BanDatabase::Entry::FLAG_TYPE_GAME);
/** /**
* @brief Upgrades the ban database to the current write_version. * @brief Upgrades the ban database to the current write_version.

2
src/Plugins/RenX/RenX.Core/RenX_BuildingInfo.h

@ -42,7 +42,7 @@ namespace RenX
*/ */
struct RENX_API BuildingInfo struct RENX_API BuildingInfo
{ {
Jupiter::StringS name; std::string name;
TeamType team = TeamType::Other; TeamType team = TeamType::Other;
int health = 0; int health = 0;
int max_health = 0; int max_health = 0;

11
src/Plugins/RenX/RenX.Core/RenX_Core.cpp

@ -17,6 +17,7 @@
*/ */
#include <ctime> #include <ctime>
#include "jessilib/word_split.hpp"
#include "Jupiter/Functions.h" #include "Jupiter/Functions.h"
#include "IRC_Bot.h" #include "IRC_Bot.h"
#include "RenX_Core.h" #include "RenX_Core.h"
@ -44,14 +45,12 @@ bool RenX::Core::initialize() {
RenX::tags->initialize(); RenX::tags->initialize();
RenX::initTranslations(this->config); RenX::initTranslations(this->config);
const Jupiter::ReadableString &serverList = this->config.get("Servers"_jrs); std::string_view serverList = this->config.get("Servers"_jrs);
m_commandsFile.read(this->config.get("CommandsFile"_jrs, "RenXGameCommands.ini"_jrs)); m_commandsFile.read(this->config.get("CommandsFile"_jrs, "RenXGameCommands.ini"_jrs));
unsigned int wc = serverList.wordCount(WHITESPACE); auto server_entries = jessilib::word_split_view(serverList, WHITESPACE_SV);
for (const auto& entry : server_entries) {
std::unique_ptr<RenX::Server> server; auto server = std::make_unique<RenX::Server>(entry);
for (unsigned int i = 0; i != wc; i++) {
server = std::make_unique<RenX::Server>(Jupiter::ReferenceString::getWord(serverList, i, WHITESPACE));
if (server->connect() == false) { if (server->connect() == false) {
fprintf(stderr, "[RenX] ERROR: Failed to connect to %s on port %u. Error code: %d" ENDL, server->getHostname().c_str(), server->getPort(), Jupiter::Socket::getLastError()); fprintf(stderr, "[RenX] ERROR: Failed to connect to %s on port %u. Error code: %d" ENDL, server->getHostname().c_str(), server->getPort(), Jupiter::Socket::getLastError());

462
src/Plugins/RenX/RenX.Core/RenX_Functions.cpp

@ -47,7 +47,7 @@ Jupiter::ReferenceString OtherLongName = "Unknown";
/** RenegadeX RCON protocol message deliminator */ /** RenegadeX RCON protocol message deliminator */
const char RenX::DelimC = '\x02'; const char RenX::DelimC = '\x02';
const char RenX::DelimC3 = '\xA0'; const char RenX::DelimC3 = '\xA0';
const Jupiter::ReferenceString RenX::DevBotName = "DevBot"_jrs; const std::string_view RenX::DevBotName = "DevBot"sv;
/** WinType translations */ /** WinType translations */
@ -453,51 +453,51 @@ const Jupiter::ReferenceString &translateCharacter(Jupiter::ReferenceString &obj
if (object.find(STRING_LITERAL_AS_REFERENCE("GDI_")) == 0) if (object.find(STRING_LITERAL_AS_REFERENCE("GDI_")) == 0)
{ {
object.shiftRight(4); object.shiftRight(4);
if (object.equals(STRING_LITERAL_AS_REFERENCE("Deadeye"))) return translated_GDI_Deadeye; if (object == "Deadeye"sv) return translated_GDI_Deadeye;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Engineer"))) return translated_GDI_Engineer; if (object == "Engineer"sv) return translated_GDI_Engineer;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Grenadier"))) return translated_GDI_Grenadier; if (object == "Grenadier"sv) return translated_GDI_Grenadier;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Gunner"))) return translated_GDI_Gunner; if (object == "Gunner"sv) return translated_GDI_Gunner;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Havoc"))) return translated_GDI_Havoc; if (object == "Havoc"sv) return translated_GDI_Havoc;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Hotwire"))) return translated_GDI_Hotwire; if (object == "Hotwire"sv) return translated_GDI_Hotwire;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Marksman"))) return translated_GDI_Marksman; if (object == "Marksman"sv) return translated_GDI_Marksman;
if (object.equals(STRING_LITERAL_AS_REFERENCE("McFarland"))) return translated_GDI_McFarland; if (object == "McFarland"sv) return translated_GDI_McFarland;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Mobius"))) return translated_GDI_Mobius; if (object == "Mobius"sv) return translated_GDI_Mobius;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Officer"))) return translated_GDI_Officer; if (object == "Officer"sv) return translated_GDI_Officer;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Patch"))) return translated_GDI_Patch; if (object == "Patch"sv) return translated_GDI_Patch;
if (object.equals(STRING_LITERAL_AS_REFERENCE("RocketSoldier"))) return translated_GDI_RocketSoldier; if (object == "RocketSoldier"sv) return translated_GDI_RocketSoldier;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Shotgunner"))) return translated_GDI_Shotgunner; if (object == "Shotgunner"sv) return translated_GDI_Shotgunner;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Soldier"))) return translated_GDI_Soldier; if (object == "Soldier"sv) return translated_GDI_Soldier;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Sydney"))) return translated_GDI_Sydney; if (object == "Sydney"sv) return translated_GDI_Sydney;
} }
else if (object.find(STRING_LITERAL_AS_REFERENCE("Nod_")) == 0) else if (object.find(STRING_LITERAL_AS_REFERENCE("Nod_")) == 0)
{ {
object.shiftRight(4); object.shiftRight(4);
if (object.equals(STRING_LITERAL_AS_REFERENCE("BlackHandSniper"))) return translated_Nod_BlackHandSniper; if (object == "BlackHandSniper"sv) return translated_Nod_BlackHandSniper;
if (object.equals(STRING_LITERAL_AS_REFERENCE("ChemicalTrooper"))) return translated_Nod_ChemicalTrooper; if (object == "ChemicalTrooper"sv) return translated_Nod_ChemicalTrooper;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Engineer"))) return translated_Nod_Engineer; if (object == "Engineer"sv) return translated_Nod_Engineer;
if (object.equals(STRING_LITERAL_AS_REFERENCE("FlameTrooper"))) return translated_Nod_FlameTrooper; if (object == "FlameTrooper"sv) return translated_Nod_FlameTrooper;
if (object.equals(STRING_LITERAL_AS_REFERENCE("LaserChainGunner"))) return translated_Nod_LaserChainGunner; if (object == "LaserChainGunner"sv) return translated_Nod_LaserChainGunner;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Marksman"))) return translated_Nod_Marksman; if (object == "Marksman"sv) return translated_Nod_Marksman;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Mendoza"))) return translated_Nod_Mendoza; if (object == "Mendoza"sv) return translated_Nod_Mendoza;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Officer"))) return translated_Nod_Officer; if (object == "Officer"sv) return translated_Nod_Officer;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Raveshaw"))) return translated_Nod_Raveshaw; if (object == "Raveshaw"sv) return translated_Nod_Raveshaw;
if (object.equals(STRING_LITERAL_AS_REFERENCE("RocketSoldier"))) return translated_Nod_RocketSoldier; if (object == "RocketSoldier"sv) return translated_Nod_RocketSoldier;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Sakura"))) return translated_Nod_Sakura; if (object == "Sakura"sv) return translated_Nod_Sakura;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Shotgunner"))) return translated_Nod_Shotgunner; if (object == "Shotgunner"sv) return translated_Nod_Shotgunner;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Soldier"))) return translated_Nod_Soldier; if (object == "Soldier"sv) return translated_Nod_Soldier;
if (object.equals(STRING_LITERAL_AS_REFERENCE("StealthBlackHand"))) return translated_Nod_StealthBlackHand; if (object == "StealthBlackHand"sv) return translated_Nod_StealthBlackHand;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Technician"))) return translated_Nod_Technician; if (object == "Technician"sv) return translated_Nod_Technician;
} }
return object; return object;
} }
const Jupiter::ReferenceString RenX::translateName(const Jupiter::ReadableString &obj) std::string_view RenX::translateName(std::string_view obj)
{ {
if (obj.isEmpty()) if (obj.empty())
return Jupiter::ReferenceString::empty; return Jupiter::ReferenceString::empty;
Jupiter::ReferenceString iniTranslation = RenX::getCore()->getConfig()["Name"_jrs].get(obj); Jupiter::ReferenceString iniTranslation = RenX::getCore()->getConfig()["Name"_jrs].get(Jupiter::ReferenceString{obj});
if (iniTranslation.isNotEmpty()) if (iniTranslation.isNotEmpty())
return iniTranslation; return iniTranslation;
@ -516,71 +516,71 @@ const Jupiter::ReferenceString RenX::translateName(const Jupiter::ReadableString
object.shiftRight(8); object.shiftRight(8);
/** Nod Vehicles */ /** Nod Vehicles */
if (object.equals(STRING_LITERAL_AS_REFERENCE("Harvester_Nod"))) return translated_Vehicle_Harvester_Nod; if (object == "Harvester_Nod"sv) return translated_Vehicle_Harvester_Nod;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Buggy"))) return translated_Vehicle_Buggy; if (object == "Buggy"sv) return translated_Vehicle_Buggy;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Artillery"))) return translated_Vehicle_Artillery; if (object == "Artillery"sv) return translated_Vehicle_Artillery;
if (object.equals(STRING_LITERAL_AS_REFERENCE("APC_Nod"))) return translated_Vehicle_APC_Nod; if (object == "APC_Nod"sv) return translated_Vehicle_APC_Nod;
if (object.equals(STRING_LITERAL_AS_REFERENCE("LightTank"))) return translated_Vehicle_LightTank; if (object == "LightTank"sv) return translated_Vehicle_LightTank;
if (object.equals(STRING_LITERAL_AS_REFERENCE("FlameTank"))) return translated_Vehicle_FlameTank; if (object == "FlameTank"sv) return translated_Vehicle_FlameTank;
if (object.equals(STRING_LITERAL_AS_REFERENCE("StealthTank"))) return translated_Vehicle_StealthTank; if (object == "StealthTank"sv) return translated_Vehicle_StealthTank;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Chinook_Nod"))) return translated_Vehicle_Chinook_Nod; if (object == "Chinook_Nod"sv) return translated_Vehicle_Chinook_Nod;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Apache"))) return translated_Vehicle_Apache; if (object == "Apache"sv) return translated_Vehicle_Apache;
if (object.equals(STRING_LITERAL_AS_REFERENCE("ReconBike"))) return translated_Vehicle_ReconBike; if (object == "ReconBike"sv) return translated_Vehicle_ReconBike;
if (object.equals(STRING_LITERAL_AS_REFERENCE("TickTank"))) return translated_Vehicle_TickTank; if (object == "TickTank"sv) return translated_Vehicle_TickTank;
/** GDI Vehicles */ /** GDI Vehicles */
if (object.equals(STRING_LITERAL_AS_REFERENCE("Harvester_GDI"))) return translated_Vehicle_Harvester_GDI; if (object == "Harvester_GDI"sv) return translated_Vehicle_Harvester_GDI;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Humvee"))) return translated_Vehicle_Humvee; if (object == "Humvee"sv) return translated_Vehicle_Humvee;
if (object.equals(STRING_LITERAL_AS_REFERENCE("MRLS"))) return translated_Vehicle_MRLS; if (object == "MRLS"sv) return translated_Vehicle_MRLS;
if (object.equals(STRING_LITERAL_AS_REFERENCE("APC_GDI"))) return translated_Vehicle_APC_GDI; if (object == "APC_GDI"sv) return translated_Vehicle_APC_GDI;
if (object.equals(STRING_LITERAL_AS_REFERENCE("MediumTank"))) return translated_Vehicle_MediumTank; if (object == "MediumTank"sv) return translated_Vehicle_MediumTank;
if (object.equals(STRING_LITERAL_AS_REFERENCE("MammothTank"))) return translated_Vehicle_MammothTank; if (object == "MammothTank"sv) return translated_Vehicle_MammothTank;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Chinook_GDI"))) return translated_Vehicle_Chinook_GDI; if (object == "Chinook_GDI"sv) return translated_Vehicle_Chinook_GDI;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Orca"))) return translated_Vehicle_Orca; if (object == "Orca"sv) return translated_Vehicle_Orca;
if (object.equals(STRING_LITERAL_AS_REFERENCE("HoverMRLS"))) return translated_Vehicle_HoverMRLS; if (object == "HoverMRLS"sv) return translated_Vehicle_HoverMRLS;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Titan"))) return translated_Vehicle_Titan; if (object == "Titan"sv) return translated_Vehicle_Titan;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Wolverine"))) return translated_Vehicle_Wolverine; if (object == "Wolverine"sv) return translated_Vehicle_Wolverine;
/** Other Vehicles */ /** Other Vehicles */
if (object.equals(STRING_LITERAL_AS_REFERENCE("A10_DmgType_GattlingGun"))) return translated_Vehicle_A10_DmgType_GattlingGun; if (object == "A10_DmgType_GattlingGun"sv) return translated_Vehicle_A10_DmgType_GattlingGun;
if (object.equals(STRING_LITERAL_AS_REFERENCE("A10_DmgType_Bomb"))) return translated_Vehicle_A10_DmgType_Bomb; if (object == "A10_DmgType_Bomb"sv) return translated_Vehicle_A10_DmgType_Bomb;
if (object.equals(STRING_LITERAL_AS_REFERENCE("AC130_DmgType_HeavyCannon"))) return translated_Vehicle_AC130_DmgType_HeavyCannon; if (object == "AC130_DmgType_HeavyCannon"sv) return translated_Vehicle_AC130_DmgType_HeavyCannon;
if (object.equals(STRING_LITERAL_AS_REFERENCE("AC130_DmgType_AutoCannon"))) return translated_Vehicle_AC130_DmgType_AutoCannon; if (object == "AC130_DmgType_AutoCannon"sv) return translated_Vehicle_AC130_DmgType_AutoCannon;
} }
else if (object.find(STRING_LITERAL_AS_REFERENCE("Weapon_")) == 0) else if (object.find(STRING_LITERAL_AS_REFERENCE("Weapon_")) == 0)
{ {
object.shiftRight(7); object.shiftRight(7);
if (object.equals(STRING_LITERAL_AS_REFERENCE("HeavyPistol"))) return translated_Weapon_HeavyPistol; if (object == "HeavyPistol"sv) return translated_Weapon_HeavyPistol;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Carbine"))) return translated_Weapon_Carbine; if (object == "Carbine"sv) return translated_Weapon_Carbine;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Airstrike_GDI"))) return translated_Weapon_Airstrike_GDI; if (object == "Airstrike_GDI"sv) return translated_Weapon_Airstrike_GDI;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Airstrike_Nod"))) return translated_Weapon_Airstrike_Nod; if (object == "Airstrike_Nod"sv) return translated_Weapon_Airstrike_Nod;
if (object.equals(STRING_LITERAL_AS_REFERENCE("TiberiumFlechetteRifle"))) return translated_Weapon_TiberiumFlechetteRifle; if (object == "TiberiumFlechetteRifle"sv) return translated_Weapon_TiberiumFlechetteRifle;
if (object.equals(STRING_LITERAL_AS_REFERENCE("TiberiumAutoRifle"))) return translated_Weapon_TiberiumAutoRifle; if (object == "TiberiumAutoRifle"sv) return translated_Weapon_TiberiumAutoRifle;
if (object.equals(STRING_LITERAL_AS_REFERENCE("TiberiumAutoRifle_Blue"))) return translated_Weapon_TiberiumAutoRifle_Blue; if (object == "TiberiumAutoRifle_Blue"sv) return translated_Weapon_TiberiumAutoRifle_Blue;
if (object.equals(STRING_LITERAL_AS_REFERENCE("EMPGrenade"))) return translated_Weapon_EMPGrenade; if (object == "EMPGrenade"sv) return translated_Weapon_EMPGrenade;
if (object.equals(STRING_LITERAL_AS_REFERENCE("SmokeGrenade"))) return translated_Weapon_SmokeGrenade; if (object == "SmokeGrenade"sv) return translated_Weapon_SmokeGrenade;
if (object.equals(STRING_LITERAL_AS_REFERENCE("TimedC4"))) return translated_Weapon_TimedC4; if (object == "TimedC4"sv) return translated_Weapon_TimedC4;
if (object.equals(STRING_LITERAL_AS_REFERENCE("RemoteC4"))) return translated_Weapon_RemoteC4; if (object == "RemoteC4"sv) return translated_Weapon_RemoteC4;
if (object.equals(STRING_LITERAL_AS_REFERENCE("ProxyC4"))) return translated_Weapon_ProxyC4; if (object == "ProxyC4"sv) return translated_Weapon_ProxyC4;
if (object.equals(STRING_LITERAL_AS_REFERENCE("ATMine"))) return translated_Weapon_ATMine; if (object == "ATMine"sv) return translated_Weapon_ATMine;
if (object.equals(STRING_LITERAL_AS_REFERENCE("IonCannonBeacon"))) return translated_Weapon_IonCannonBeacon; if (object == "IonCannonBeacon"sv) return translated_Weapon_IonCannonBeacon;
if (object.equals(STRING_LITERAL_AS_REFERENCE("NukeBeacon"))) return translated_Weapon_NukeBeacon; if (object == "NukeBeacon"sv) return translated_Weapon_NukeBeacon;
if (object.equals(STRING_LITERAL_AS_REFERENCE("DeployedC4"))) return translated_Weapon_DeployedC4; if (object == "DeployedC4"sv) return translated_Weapon_DeployedC4;
if (object.equals(STRING_LITERAL_AS_REFERENCE("DeployedTimedC4"))) return translated_Weapon_DeployedTimedC4; if (object == "DeployedTimedC4"sv) return translated_Weapon_DeployedTimedC4;
if (object.equals(STRING_LITERAL_AS_REFERENCE("DeployedRemoteC4"))) return translated_Weapon_DeployedRemoteC4; if (object == "DeployedRemoteC4"sv) return translated_Weapon_DeployedRemoteC4;
if (object.equals(STRING_LITERAL_AS_REFERENCE("DeployedProxyC4"))) return translated_Weapon_DeployedProxyC4; if (object == "DeployedProxyC4"sv) return translated_Weapon_DeployedProxyC4;
if (object.equals(STRING_LITERAL_AS_REFERENCE("DeployedATMine"))) return translated_Weapon_DeployedATMine; if (object == "DeployedATMine"sv) return translated_Weapon_DeployedATMine;
if (object.equals(STRING_LITERAL_AS_REFERENCE("DeployedIonCannonBeacon"))) return translated_Weapon_DeployedIonCannonBeacon; if (object == "DeployedIonCannonBeacon"sv) return translated_Weapon_DeployedIonCannonBeacon;
if (object.equals(STRING_LITERAL_AS_REFERENCE("DeployedNukeBeacon"))) return translated_Weapon_DeployedNukeBeacon; if (object == "DeployedNukeBeacon"sv) return translated_Weapon_DeployedNukeBeacon;
if (object.equals(STRING_LITERAL_AS_REFERENCE("CrateNuke"))) return translated_Weapon_CrateNuke; if (object == "CrateNuke"sv) return translated_Weapon_CrateNuke;
} }
else if (object.find(STRING_LITERAL_AS_REFERENCE("Projectile_")) == 0) else if (object.find(STRING_LITERAL_AS_REFERENCE("Projectile_")) == 0)
{ {
object.shiftRight(11); object.shiftRight(11);
if (object.equals(STRING_LITERAL_AS_REFERENCE("EMPGrenade"))) return translated_Projectile_EMPGrenade; if (object == "EMPGrenade"sv) return translated_Projectile_EMPGrenade;
if (object.equals(STRING_LITERAL_AS_REFERENCE("SmokeGrenade"))) return translated_Projectile_SmokeGrenade; if (object == "SmokeGrenade"sv) return translated_Projectile_SmokeGrenade;
} }
else if (object.find(STRING_LITERAL_AS_REFERENCE("InventoryManager_")) == 0) else if (object.find(STRING_LITERAL_AS_REFERENCE("InventoryManager_")) == 0)
{ {
@ -597,196 +597,196 @@ const Jupiter::ReferenceString RenX::translateName(const Jupiter::ReadableString
object.shiftRight(8); object.shiftRight(8);
/** Non-weapon damage types */ /** Non-weapon damage types */
if (object.equals(STRING_LITERAL_AS_REFERENCE("Suicided"))) return translated_DmgType_Suicided; if (object == "Suicided"sv) return translated_DmgType_Suicided;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Fell"))) return translated_DmgType_Fell; if (object == "Fell"sv) return translated_DmgType_Fell;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Tiberium"))) return translated_DmgType_Tiberium; if (object == "Tiberium"sv) return translated_DmgType_Tiberium;
if (object.equals(STRING_LITERAL_AS_REFERENCE("TiberiumBleed"))) return translated_DmgType_TiberiumBleed; if (object == "TiberiumBleed"sv) return translated_DmgType_TiberiumBleed;
if (object.equals(STRING_LITERAL_AS_REFERENCE("TiberiumBleed_Blue"))) return translated_DmgType_TiberiumBleed_Blue; if (object == "TiberiumBleed_Blue"sv) return translated_DmgType_TiberiumBleed_Blue;
if (object.equals(STRING_LITERAL_AS_REFERENCE("RanOver"))) return translated_DmgType_RanOver; if (object == "RanOver"sv) return translated_DmgType_RanOver;
/** Infantry weapons */ /** Infantry weapons */
if (object.equals(STRING_LITERAL_AS_REFERENCE("Pistol"))) return translated_DmgType_Pistol; if (object == "Pistol"sv) return translated_DmgType_Pistol;
if (object.equals(STRING_LITERAL_AS_REFERENCE("SMG"))) return translated_DmgType_SMG; if (object == "SMG"sv) return translated_DmgType_SMG;
if (object.equals(STRING_LITERAL_AS_REFERENCE("HeavyPistol"))) return translated_DmgType_HeavyPistol; if (object == "HeavyPistol"sv) return translated_DmgType_HeavyPistol;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Carbine"))) return translated_DmgType_Carbine; if (object == "Carbine"sv) return translated_DmgType_Carbine;
if (object.equals(STRING_LITERAL_AS_REFERENCE("TiberiumFlechetteRifle"))) return translated_DmgType_TiberiumFlechetteRifle; // Not a rifle. if (object == "TiberiumFlechetteRifle"sv) return translated_DmgType_TiberiumFlechetteRifle; // Not a rifle.
if (object.equals(STRING_LITERAL_AS_REFERENCE("TiberiumAutoRifle"))) return translated_DmgType_TiberiumAutoRifle; if (object == "TiberiumAutoRifle"sv) return translated_DmgType_TiberiumAutoRifle;
if (object.equals(STRING_LITERAL_AS_REFERENCE("TiberiumAutoRifle_Blue"))) return translated_DmgType_TiberiumAutoRifle_Blue; if (object == "TiberiumAutoRifle_Blue"sv) return translated_DmgType_TiberiumAutoRifle_Blue;
if (object.equals(STRING_LITERAL_AS_REFERENCE("TiberiumAutoRifle_Flechette_Blue"))) return translated_DmgType_TiberiumAutoRifle_Flechette_Blue; if (object == "TiberiumAutoRifle_Flechette_Blue"sv) return translated_DmgType_TiberiumAutoRifle_Flechette_Blue;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Grenade"))) return translated_DmgType_Grenade; if (object == "Grenade"sv) return translated_DmgType_Grenade;
if (object.equals(STRING_LITERAL_AS_REFERENCE("TimedC4"))) return translated_DmgType_TimedC4; if (object == "TimedC4"sv) return translated_DmgType_TimedC4;
if (object.equals(STRING_LITERAL_AS_REFERENCE("RemoteC4"))) return translated_DmgType_RemoteC4; if (object == "RemoteC4"sv) return translated_DmgType_RemoteC4;
if (object.equals(STRING_LITERAL_AS_REFERENCE("ProxyC4"))) return translated_DmgType_ProxyC4; if (object == "ProxyC4"sv) return translated_DmgType_ProxyC4;
if (object.equals(STRING_LITERAL_AS_REFERENCE("ATMine"))) return translated_DmgType_ATMine; if (object == "ATMine"sv) return translated_DmgType_ATMine;
if (object.equals(STRING_LITERAL_AS_REFERENCE("EMPGrenade"))) return translated_DmgType_EMPGrenade; if (object == "EMPGrenade"sv) return translated_DmgType_EMPGrenade;
if (object.equals(STRING_LITERAL_AS_REFERENCE("BurnC4"))) return translated_DmgType_BurnC4; if (object == "BurnC4"sv) return translated_DmgType_BurnC4;
if (object.equals(STRING_LITERAL_AS_REFERENCE("FireBleed"))) return translated_DmgType_FireBleed; // Caused by C4 or flame weapons if (object == "FireBleed"sv) return translated_DmgType_FireBleed; // Caused by C4 or flame weapons
if (object.equals(STRING_LITERAL_AS_REFERENCE("AutoRifle"))) return translated_DmgType_AutoRifle; if (object == "AutoRifle"sv) return translated_DmgType_AutoRifle;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Shotgun"))) return translated_DmgType_Shotgun; if (object == "Shotgun"sv) return translated_DmgType_Shotgun;
if (object.equals(STRING_LITERAL_AS_REFERENCE("FlameThrower"))) return translated_DmgType_FlameThrower; if (object == "FlameThrower"sv) return translated_DmgType_FlameThrower;
if (object.equals(STRING_LITERAL_AS_REFERENCE("GrenadeLauncher"))) return translated_DmgType_GrenadeLauncher; if (object == "GrenadeLauncher"sv) return translated_DmgType_GrenadeLauncher;
if (object.equals(STRING_LITERAL_AS_REFERENCE("MarksmanRifle"))) return translated_DmgType_MarksmanRifle; if (object == "MarksmanRifle"sv) return translated_DmgType_MarksmanRifle;
if (object.equals(STRING_LITERAL_AS_REFERENCE("ChainGun"))) return translated_DmgType_ChainGun; if (object == "ChainGun"sv) return translated_DmgType_ChainGun;
if (object.equals(STRING_LITERAL_AS_REFERENCE("MissileLauncher"))) return translated_DmgType_MissileLauncher; if (object == "MissileLauncher"sv) return translated_DmgType_MissileLauncher;
if (object.equals(STRING_LITERAL_AS_REFERENCE("MissileLauncher_Alt"))) return translated_DmgType_MissileLauncher_Alt; if (object == "MissileLauncher_Alt"sv) return translated_DmgType_MissileLauncher_Alt;
if (object.equals(STRING_LITERAL_AS_REFERENCE("ChemicalThrower"))) return translated_DmgType_ChemicalThrower; if (object == "ChemicalThrower"sv) return translated_DmgType_ChemicalThrower;
if (object.equals(STRING_LITERAL_AS_REFERENCE("LaserRifle"))) return translated_DmgType_LaserRifle; if (object == "LaserRifle"sv) return translated_DmgType_LaserRifle;
if (object.equals(STRING_LITERAL_AS_REFERENCE("TacticalRifle"))) return translated_DmgType_TacticalRifle; if (object == "TacticalRifle"sv) return translated_DmgType_TacticalRifle;
if (object.equals(STRING_LITERAL_AS_REFERENCE("RocketLauncher"))) return translated_DmgType_RocketLauncher; if (object == "RocketLauncher"sv) return translated_DmgType_RocketLauncher;
if (object.equals(STRING_LITERAL_AS_REFERENCE("LaserChainGun"))) return translated_DmgType_LaserChainGun; if (object == "LaserChainGun"sv) return translated_DmgType_LaserChainGun;
if (object.equals(STRING_LITERAL_AS_REFERENCE("FlakCannon"))) return translated_DmgType_FlakCannon; if (object == "FlakCannon"sv) return translated_DmgType_FlakCannon;
if (object.equals(STRING_LITERAL_AS_REFERENCE("FlakCannon_Alt"))) return translated_DmgType_FlakCannon_Alt; if (object == "FlakCannon_Alt"sv) return translated_DmgType_FlakCannon_Alt;
if (object.equals(STRING_LITERAL_AS_REFERENCE("SniperRifle"))) return translated_DmgType_SniperRifle; if (object == "SniperRifle"sv) return translated_DmgType_SniperRifle;
if (object.equals(STRING_LITERAL_AS_REFERENCE("RamjetRifle"))) return translated_DmgType_RamjetRifle; if (object == "RamjetRifle"sv) return translated_DmgType_RamjetRifle;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Railgun"))) return translated_DmgType_Railgun; if (object == "Railgun"sv) return translated_DmgType_Railgun;
if (object.equals(STRING_LITERAL_AS_REFERENCE("PersonalIonCannon"))) return translated_DmgType_PersonalIonCannon; if (object == "PersonalIonCannon"sv) return translated_DmgType_PersonalIonCannon;
if (object.equals(STRING_LITERAL_AS_REFERENCE("VoltRifle"))) return translated_DmgType_VoltRifle; if (object == "VoltRifle"sv) return translated_DmgType_VoltRifle;
if (object.equals(STRING_LITERAL_AS_REFERENCE("VoltRifle_Alt"))) return translated_DmgType_VoltRifle_Alt; if (object == "VoltRifle_Alt"sv) return translated_DmgType_VoltRifle_Alt;
if (object.equals(STRING_LITERAL_AS_REFERENCE("VoltAutoRifle"))) return translated_DmgType_VoltAutoRifle; if (object == "VoltAutoRifle"sv) return translated_DmgType_VoltAutoRifle;
if (object.equals(STRING_LITERAL_AS_REFERENCE("VoltAutoRifle_Alt"))) return translated_DmgType_VoltAutoRifle_Alt; if (object == "VoltAutoRifle_Alt"sv) return translated_DmgType_VoltAutoRifle_Alt;
/** Vehicle weapons */ /** Vehicle weapons */
if (object.equals(STRING_LITERAL_AS_REFERENCE("MammothTank_Missile"))) return translated_DmgType_MammothTank_Missile; if (object == "MammothTank_Missile"sv) return translated_DmgType_MammothTank_Missile;
if (object.equals(STRING_LITERAL_AS_REFERENCE("MammothTank_Cannon"))) return translated_DmgType_MammothTank_Cannon; if (object == "MammothTank_Cannon"sv) return translated_DmgType_MammothTank_Cannon;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Orca_Missile"))) return translated_DmgType_Orca_Missile; if (object == "Orca_Missile"sv) return translated_DmgType_Orca_Missile;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Orca_Gun"))) return translated_DmgType_Orca_Gun; if (object == "Orca_Gun"sv) return translated_DmgType_Orca_Gun;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Orca_Passenger"))) return translated_DmgType_Orca_Passenger; if (object == "Orca_Passenger"sv) return translated_DmgType_Orca_Passenger;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Apache_Rocket"))) return translated_DmgType_Apache_Rocket; if (object == "Apache_Rocket"sv) return translated_DmgType_Apache_Rocket;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Apache_Gun"))) return translated_DmgType_Apache_Gun; if (object == "Apache_Gun"sv) return translated_DmgType_Apache_Gun;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Apache_Passenger"))) return translated_DmgType_Apache_Passenger; if (object == "Apache_Passenger"sv) return translated_DmgType_Apache_Passenger;
/** Base Defence Weapons */ /** Base Defence Weapons */
if (object.equals(STRING_LITERAL_AS_REFERENCE("AGT_MG"))) return translated_DmgType_AGT_MG; if (object == "AGT_MG"sv) return translated_DmgType_AGT_MG;
if (object.equals(STRING_LITERAL_AS_REFERENCE("AGT_Rocket"))) return translated_DmgType_AGT_Rocket; if (object == "AGT_Rocket"sv) return translated_DmgType_AGT_Rocket;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Obelisk"))) return translated_DmgType_Obelisk; if (object == "Obelisk"sv) return translated_DmgType_Obelisk;
/** Defence Structure Weapons */ /** Defence Structure Weapons */
if (object.equals(STRING_LITERAL_AS_REFERENCE("AGT_MG"))) return translated_DmgType_AGT_MG; if (object == "AGT_MG"sv) return translated_DmgType_AGT_MG;
if (object.equals(STRING_LITERAL_AS_REFERENCE("AGT_Rocket"))) return translated_DmgType_AGT_Rocket; if (object == "AGT_Rocket"sv) return translated_DmgType_AGT_Rocket;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Obelisk"))) return translated_DmgType_Obelisk; if (object == "Obelisk"sv) return translated_DmgType_Obelisk;
if (object.equals(STRING_LITERAL_AS_REFERENCE("GuardTower"))) return translated_DmgType_GuardTower; if (object == "GuardTower"sv) return translated_DmgType_GuardTower;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Turret"))) return translated_DmgType_Turret; if (object == "Turret"sv) return translated_DmgType_Turret;
if (object.equals(STRING_LITERAL_AS_REFERENCE("SAMSite"))) return translated_DmgType_SAMSite; if (object == "SAMSite"sv) return translated_DmgType_SAMSite;
if (object.equals(STRING_LITERAL_AS_REFERENCE("AATower"))) return translated_DmgType_AATower; if (object == "AATower"sv) return translated_DmgType_AATower;
if (object.equals(STRING_LITERAL_AS_REFERENCE("GunEmpl"))) return translated_DmgType_GunEmpl; if (object == "GunEmpl"sv) return translated_DmgType_GunEmpl;
if (object.equals(STRING_LITERAL_AS_REFERENCE("GunEmpl_Alt"))) return translated_DmgType_GunEmpl_Alt; if (object == "GunEmpl_Alt"sv) return translated_DmgType_GunEmpl_Alt;
if (object.equals(STRING_LITERAL_AS_REFERENCE("RocketEmpl_Swarm"))) return translated_DmgType_RocketEmpl_Swarm; if (object == "RocketEmpl_Swarm"sv) return translated_DmgType_RocketEmpl_Swarm;
if (object.equals(STRING_LITERAL_AS_REFERENCE("RocketEmpl_Missile"))) return translated_DmgType_RocketEmpl_Missile; if (object == "RocketEmpl_Missile"sv) return translated_DmgType_RocketEmpl_Missile;
/** Other Weapons */ /** Other Weapons */
if (object.equals(STRING_LITERAL_AS_REFERENCE("Nuke"))) return translated_DmgType_Nuke; if (object == "Nuke"sv) return translated_DmgType_Nuke;
if (object.equals(STRING_LITERAL_AS_REFERENCE("IonCannon"))) return translated_DmgType_IonCannon; if (object == "IonCannon"sv) return translated_DmgType_IonCannon;
/** Nod Vehicles */ /** Nod Vehicles */
if (object.equals(STRING_LITERAL_AS_REFERENCE("Harvester_Nod"))) return translated_DmgType_Harvester_Nod; if (object == "Harvester_Nod"sv) return translated_DmgType_Harvester_Nod;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Buggy"))) return translated_DmgType_Buggy; if (object == "Buggy"sv) return translated_DmgType_Buggy;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Artillery"))) return translated_DmgType_Artillery; if (object == "Artillery"sv) return translated_DmgType_Artillery;
if (object.equals(STRING_LITERAL_AS_REFERENCE("APC_Nod"))) return translated_DmgType_APC_Nod; if (object == "APC_Nod"sv) return translated_DmgType_APC_Nod;
if (object.equals(STRING_LITERAL_AS_REFERENCE("LightTank"))) return translated_DmgType_LightTank; if (object == "LightTank"sv) return translated_DmgType_LightTank;
if (object.equals(STRING_LITERAL_AS_REFERENCE("FlameTank"))) return translated_DmgType_FlameTank; if (object == "FlameTank"sv) return translated_DmgType_FlameTank;
if (object.equals(STRING_LITERAL_AS_REFERENCE("StealthTank"))) return translated_DmgType_StealthTank; if (object == "StealthTank"sv) return translated_DmgType_StealthTank;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Chinook_Nod"))) return translated_DmgType_Chinook_Nod; if (object == "Chinook_Nod"sv) return translated_DmgType_Chinook_Nod;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Apache"))) return translated_DmgType_Apache; if (object == "Apache"sv) return translated_DmgType_Apache;
/** GDI Vehicles */ /** GDI Vehicles */
if (object.equals(STRING_LITERAL_AS_REFERENCE("Harvester_GDI"))) return translated_DmgType_Harvester_GDI; if (object == "Harvester_GDI"sv) return translated_DmgType_Harvester_GDI;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Humvee"))) return translated_DmgType_Humvee; if (object == "Humvee"sv) return translated_DmgType_Humvee;
if (object.equals(STRING_LITERAL_AS_REFERENCE("MRLS"))) return translated_DmgType_MRLS; if (object == "MRLS"sv) return translated_DmgType_MRLS;
if (object.equals(STRING_LITERAL_AS_REFERENCE("APC_GDI"))) return translated_DmgType_APC_GDI; if (object == "APC_GDI"sv) return translated_DmgType_APC_GDI;
if (object.equals(STRING_LITERAL_AS_REFERENCE("MediumTank"))) return translated_DmgType_MediumTank; if (object == "MediumTank"sv) return translated_DmgType_MediumTank;
if (object.equals(STRING_LITERAL_AS_REFERENCE("MammothTank"))) return translated_DmgType_MammothTank; if (object == "MammothTank"sv) return translated_DmgType_MammothTank;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Chinook_GDI"))) return translated_DmgType_Chinook_GDI; if (object == "Chinook_GDI"sv) return translated_DmgType_Chinook_GDI;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Orca"))) return translated_DmgType_Orca; if (object == "Orca"sv) return translated_DmgType_Orca;
/** Other Vehicles */ /** Other Vehicles */
if (object.equals(STRING_LITERAL_AS_REFERENCE("A10_Missile"))) return translated_DmgType_A10_Missile; if (object == "A10_Missile"sv) return translated_DmgType_A10_Missile;
} }
else if (object.find(STRING_LITERAL_AS_REFERENCE("Building_")) == 0) else if (object.find(STRING_LITERAL_AS_REFERENCE("Building_")) == 0)
{ {
object.shiftRight(9); object.shiftRight(9);
/** Nod structures */ /** Nod structures */
if (object.equals(STRING_LITERAL_AS_REFERENCE("HandOfNod"))) return translated_Building_HandOfNod; if (object == "HandOfNod"sv) return translated_Building_HandOfNod;
if (object.equals(STRING_LITERAL_AS_REFERENCE("AirTower"))) return translated_Building_AirTower; if (object == "AirTower"sv) return translated_Building_AirTower;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Airstrip"))) return translated_Building_Airstrip; if (object == "Airstrip"sv) return translated_Building_Airstrip;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Refinery_Nod"))) return translated_Building_Refinery_Nod; if (object == "Refinery_Nod"sv) return translated_Building_Refinery_Nod;
if (object.equals(STRING_LITERAL_AS_REFERENCE("PowerPlant_Nod"))) return translated_Building_PowerPlant_Nod; if (object == "PowerPlant_Nod"sv) return translated_Building_PowerPlant_Nod;
if (object.equals(STRING_LITERAL_AS_REFERENCE("HandOfNod_Internals"))) return translated_Building_HandOfNod_Internals; if (object == "HandOfNod_Internals"sv) return translated_Building_HandOfNod_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("AirTower_Internals"))) return translated_Building_AirTower_Internals; if (object == "AirTower_Internals"sv) return translated_Building_AirTower_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Airstrip_Internals"))) return translated_Building_Airstrip_Internals; if (object == "Airstrip_Internals"sv) return translated_Building_Airstrip_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Refinery_Nod_Internals"))) return translated_Building_Refinery_Nod_Internals; if (object == "Refinery_Nod_Internals"sv) return translated_Building_Refinery_Nod_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("PowerPlant_Nod_Internals"))) return translated_Building_PowerPlant_Nod_Internals; if (object == "PowerPlant_Nod_Internals"sv) return translated_Building_PowerPlant_Nod_Internals;
/** GDI structures */ /** GDI structures */
if (object.equals(STRING_LITERAL_AS_REFERENCE("Barracks"))) return translated_Building_Barracks; if (object == "Barracks"sv) return translated_Building_Barracks;
if (object.equals(STRING_LITERAL_AS_REFERENCE("WeaponsFactory"))) return translated_Building_WeaponsFactory; if (object == "WeaponsFactory"sv) return translated_Building_WeaponsFactory;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Refinery_GDI"))) return translated_Building_Refinery_GDI; if (object == "Refinery_GDI"sv) return translated_Building_Refinery_GDI;
if (object.equals(STRING_LITERAL_AS_REFERENCE("PowerPlant_GDI"))) return translated_Building_PowerPlant_GDI; if (object == "PowerPlant_GDI"sv) return translated_Building_PowerPlant_GDI;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Barracks_Internals"))) return translated_Building_Barracks_Internals; if (object == "Barracks_Internals"sv) return translated_Building_Barracks_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("WeaponsFactory_Internals"))) return translated_Building_WeaponsFactory_Internals; if (object == "WeaponsFactory_Internals"sv) return translated_Building_WeaponsFactory_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Refinery_GDI_Internals"))) return translated_Building_Refinery_GDI_Internals; if (object == "Refinery_GDI_Internals"sv) return translated_Building_Refinery_GDI_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("PowerPlant_GDI_Internals"))) return translated_Building_PowerPlant_GDI_Internals; if (object == "PowerPlant_GDI_Internals"sv) return translated_Building_PowerPlant_GDI_Internals;
/** Defense structures */ /** Defense structures */
if (object.equals(STRING_LITERAL_AS_REFERENCE("AdvancedGuardTower"))) return translated_Building_AdvancedGuardTower; if (object == "AdvancedGuardTower"sv) return translated_Building_AdvancedGuardTower;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Obelisk"))) return translated_Building_Obelisk; if (object == "Obelisk"sv) return translated_Building_Obelisk;
if (object.equals(STRING_LITERAL_AS_REFERENCE("AdvancedGuardTower_Internals"))) return translated_Building_AdvancedGuardTower_Internals; if (object == "AdvancedGuardTower_Internals"sv) return translated_Building_AdvancedGuardTower_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Obelisk_Internals"))) return translated_Building_Obelisk_Internals; if (object == "Obelisk_Internals"sv) return translated_Building_Obelisk_Internals;
/** Other structures */ /** Other structures */
if (object.equals(STRING_LITERAL_AS_REFERENCE("Silo"))) return translated_Building_Silo; if (object == "Silo"sv) return translated_Building_Silo;
if (object.equals(STRING_LITERAL_AS_REFERENCE("CommCentre"))) return translated_Building_CommCentre; if (object == "CommCentre"sv) return translated_Building_CommCentre;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Silo_Internals"))) return translated_Building_Silo_Internals; if (object == "Silo_Internals"sv) return translated_Building_Silo_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("CommCentre_Internals"))) return translated_Building_CommCentre_Internals; if (object == "CommCentre_Internals"sv) return translated_Building_CommCentre_Internals;
} }
else if (object.find(STRING_LITERAL_AS_REFERENCE("CapturableMCT_")) == 0) else if (object.find(STRING_LITERAL_AS_REFERENCE("CapturableMCT_")) == 0)
{ {
object.shiftRight(14); object.shiftRight(14);
if (object.equals(STRING_LITERAL_AS_REFERENCE("Fort"))) return translated_CapturableMCT_Fort; if (object == "Fort"sv) return translated_CapturableMCT_Fort;
if (object.equals(STRING_LITERAL_AS_REFERENCE("MC"))) return translated_CapturableMCT_MC; if (object == "MC"sv) return translated_CapturableMCT_MC;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Fort_Internals"))) return translated_CapturableMCT_Fort_Internals; if (object == "Fort_Internals"sv) return translated_CapturableMCT_Fort_Internals;
if (object.equals(STRING_LITERAL_AS_REFERENCE("MC_Internals"))) return translated_CapturableMCT_MC_Internals; if (object == "MC_Internals"sv) return translated_CapturableMCT_MC_Internals;
} }
else if (object.find(STRING_LITERAL_AS_REFERENCE("Defence_")) == 0) else if (object.find(STRING_LITERAL_AS_REFERENCE("Defence_")) == 0)
{ {
object.shiftRight(8); object.shiftRight(8);
if (object.equals(STRING_LITERAL_AS_REFERENCE("GuardTower"))) return translated_Defence_GuardTower; if (object == "GuardTower"sv) return translated_Defence_GuardTower;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Turret"))) return translated_Defence_Turret; if (object == "Turret"sv) return translated_Defence_Turret;
if (object.equals(STRING_LITERAL_AS_REFERENCE("SAMSite"))) return translated_Defence_SAMSite; if (object == "SAMSite"sv) return translated_Defence_SAMSite;
if (object.equals(STRING_LITERAL_AS_REFERENCE("AATower"))) return translated_Defence_AATower; if (object == "AATower"sv) return translated_Defence_AATower;
if (object.equals(STRING_LITERAL_AS_REFERENCE("GunEmplacement"))) return translated_Defence_GunEmplacement; if (object == "GunEmplacement"sv) return translated_Defence_GunEmplacement;
if (object.equals(STRING_LITERAL_AS_REFERENCE("RocketEmplacement"))) return translated_Defence_RocketEmplacement; if (object == "RocketEmplacement"sv) return translated_Defence_RocketEmplacement;
} }
else if (object.find(STRING_LITERAL_AS_REFERENCE("Sentinel_")) == 0) else if (object.find(STRING_LITERAL_AS_REFERENCE("Sentinel_")) == 0)
{ {
object.shiftRight(9); object.shiftRight(9);
if (object.equals(STRING_LITERAL_AS_REFERENCE("AGT_MG_Base"))) return translated_Sentinel_AGT_MG_Base; if (object == "AGT_MG_Base"sv) return translated_Sentinel_AGT_MG_Base;
if (object.equals(STRING_LITERAL_AS_REFERENCE("AGT_Rockets_Base"))) return translated_Sentinel_AGT_Rockets_Base; if (object == "AGT_Rockets_Base"sv) return translated_Sentinel_AGT_Rockets_Base;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Obelisk_Laser_Base"))) return translated_Sentinel_Obelisk_Laser_Base; if (object == "Obelisk_Laser_Base"sv) return translated_Sentinel_Obelisk_Laser_Base;
} }
else if (object.find(STRING_LITERAL_AS_REFERENCE("UTDmgType_")) == 0) else if (object.find(STRING_LITERAL_AS_REFERENCE("UTDmgType_")) == 0)
{ {
object.shiftRight(10); object.shiftRight(10);
if (object.equals(STRING_LITERAL_AS_REFERENCE("VehicleExplosion"))) return translated_UTDmgType_VehicleExplosion; if (object == "VehicleExplosion"sv) return translated_UTDmgType_VehicleExplosion;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Drowned"))) return translated_UTDmgType_Drowned; if (object == "Drowned"sv) return translated_UTDmgType_Drowned;
} }
else if (object.find(STRING_LITERAL_AS_REFERENCE("VoteMenuChoice_")) == 0) else if (object.find(STRING_LITERAL_AS_REFERENCE("VoteMenuChoice_")) == 0)
{ {
object.shiftRight(15); object.shiftRight(15);
if (object.equals(STRING_LITERAL_AS_REFERENCE("AddBots"))) return translated_VoteMenuChoice_AddBots; if (object == "AddBots"sv) return translated_VoteMenuChoice_AddBots;
if (object.equals(STRING_LITERAL_AS_REFERENCE("ChangeMap"))) return translated_VoteMenuChoice_ChangeMap; if (object == "ChangeMap"sv) return translated_VoteMenuChoice_ChangeMap;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Donate"))) return translated_VoteMenuChoice_Donate; if (object == "Donate"sv) return translated_VoteMenuChoice_Donate;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Kick"))) return translated_VoteMenuChoice_Kick; if (object == "Kick"sv) return translated_VoteMenuChoice_Kick;
if (object.equals(STRING_LITERAL_AS_REFERENCE("RemoveBots"))) return translated_VoteMenuChoice_RemoveBots; if (object == "RemoveBots"sv) return translated_VoteMenuChoice_RemoveBots;
if (object.equals(STRING_LITERAL_AS_REFERENCE("RestartMatch"))) return translated_VoteMenuChoice_RestartMatch; if (object == "RestartMatch"sv) return translated_VoteMenuChoice_RestartMatch;
if (object.equals(STRING_LITERAL_AS_REFERENCE("StartMatch"))) return translated_VoteMenuChoice_StartMatch; if (object == "StartMatch"sv) return translated_VoteMenuChoice_StartMatch;
if (object.equals(STRING_LITERAL_AS_REFERENCE("Survey"))) return translated_VoteMenuChoice_Survey; if (object == "Survey"sv) return translated_VoteMenuChoice_Survey;
} }
else if (object.equals(STRING_LITERAL_AS_REFERENCE("IonCannonBeacon"))) return translated_IonCannonBeacon; else if (object == "IonCannonBeacon"sv) return translated_IonCannonBeacon;
else if (object.equals(STRING_LITERAL_AS_REFERENCE("NukeBeacon"))) return translated_NukeBeacon; else if (object == "NukeBeacon"sv) return translated_NukeBeacon;
else if (object.equals(STRING_LITERAL_AS_REFERENCE("KillZDamageType"))) return translated_KillZDamageType; else if (object == "KillZDamageType"sv) return translated_KillZDamageType;
return translateCharacter(object); return translateCharacter(object);
} }
@ -912,9 +912,9 @@ double RenX::getHeadshotKillRatio(const RenX::PlayerInfo &player)
return static_cast<double>(player.headshots) / static_cast<double>(player.kills); return static_cast<double>(player.headshots) / static_cast<double>(player.kills);
} }
Jupiter::String RenX::escapifyRCON(const Jupiter::ReadableString &str) Jupiter::String RenX::escapifyRCON(std::string_view str)
{ {
const char *ptr = str.ptr(); const char *ptr = str.data();
size_t length = str.size(); size_t length = str.size();
Jupiter::String result(str.size() + 32); Jupiter::String result(str.size() + 32);
uint16_t value; uint16_t value;

6
src/Plugins/RenX/RenX.Core/RenX_Functions.h

@ -101,7 +101,7 @@ namespace RenX
* @param object Preset to translate. * @param object Preset to translate.
* @return Translated name of the preset. * @return Translated name of the preset.
*/ */
RENX_API const Jupiter::ReferenceString translateName(const Jupiter::ReadableString &object); RENX_API std::string_view translateName(std::string_view object);
/** /**
* @brief Translates a WinType into a human-readable string. * @brief Translates a WinType into a human-readable string.
@ -187,12 +187,12 @@ namespace RenX
* @param str String to escapify * @param str String to escapify
* @return Escapified version of str. * @return Escapified version of str.
*/ */
RENX_API Jupiter::String escapifyRCON(const Jupiter::ReadableString &str); RENX_API Jupiter::String escapifyRCON(std::string_view str);
/** Constant variables */ /** Constant variables */
RENX_API extern const char DelimC; /** RCON message deliminator */ RENX_API extern const char DelimC; /** RCON message deliminator */
RENX_API extern const char DelimC3; /** RCON message deliminator for RCON version number 003 */ RENX_API extern const char DelimC3; /** RCON message deliminator for RCON version number 003 */
RENX_API extern const Jupiter::ReferenceString DevBotName; RENX_API extern const std::string_view DevBotName;
} }
#ifdef NDEBUG #ifdef NDEBUG

8
src/Plugins/RenX/RenX.Core/RenX_GameCommand.cpp

@ -70,7 +70,7 @@ RenX::BasicGameCommand::BasicGameCommand() : RenX::GameCommand(nullptr) {
RenX::BasicGameCommand::BasicGameCommand(BasicGameCommand &c) : RenX::GameCommand(c) { RenX::BasicGameCommand::BasicGameCommand(BasicGameCommand &c) : RenX::GameCommand(c) {
} }
RenX::BasicGameCommand::BasicGameCommand(const Jupiter::ReadableString &in_trigger, const Jupiter::ReadableString &in_message, const Jupiter::ReadableString &in_help_message) RenX::BasicGameCommand::BasicGameCommand(std::string_view in_trigger, std::string_view in_message, std::string_view in_help_message)
: RenX::GameCommand(nullptr) { : RenX::GameCommand(nullptr) {
this->addTrigger(in_trigger); this->addTrigger(in_trigger);
m_message = in_message; m_message = in_message;
@ -83,11 +83,13 @@ void RenX::BasicGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *pla
const Jupiter::ReadableString &RenX::BasicGameCommand::getHelp(const Jupiter::ReadableString &) { const Jupiter::ReadableString &RenX::BasicGameCommand::getHelp(const Jupiter::ReadableString &) {
static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Returns a basic text string."); static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Returns a basic text string.");
if (m_help_message.isEmpty()) { if (m_help_message.empty()) {
return defaultHelp; return defaultHelp;
} }
return m_help_message; static Jupiter::ReferenceString please_delete_this_later_jessica;
please_delete_this_later_jessica = m_help_message;
return please_delete_this_later_jessica;
} }
RenX::BasicGameCommand *RenX::BasicGameCommand::copy() { RenX::BasicGameCommand *RenX::BasicGameCommand::copy() {

8
src/Plugins/RenX/RenX.Core/RenX_GameCommand.h

@ -125,15 +125,15 @@ namespace RenX
{ {
public: public:
void trigger(RenX::Server *source, RenX::PlayerInfo *player, const Jupiter::ReadableString &parameters); void trigger(RenX::Server *source, RenX::PlayerInfo *player, const Jupiter::ReadableString &parameters);
const Jupiter::ReadableString &getHelp(const Jupiter::ReadableString &parameters); const Jupiter::ReadableString &getHelp(const Jupiter::ReadableString &parameters) override;
BasicGameCommand *copy(); BasicGameCommand *copy();
void create(); void create();
BasicGameCommand(); BasicGameCommand();
BasicGameCommand(BasicGameCommand &c); BasicGameCommand(BasicGameCommand &c);
BasicGameCommand(const Jupiter::ReadableString &trigger, const Jupiter::ReadableString &in_message, const Jupiter::ReadableString &in_help_message); BasicGameCommand(std::string_view trigger, std::string_view in_message, std::string_view in_help_message);
private: private:
Jupiter::StringS m_message, m_help_message; std::string m_message, m_help_message;
}; };
} }
@ -143,7 +143,7 @@ namespace RenX
#define BASE_GAME_COMMAND(CLASS) \ #define BASE_GAME_COMMAND(CLASS) \
public: \ public: \
void trigger(RenX::Server *source, RenX::PlayerInfo *player, const Jupiter::ReadableString &parameters); \ void trigger(RenX::Server *source, RenX::PlayerInfo *player, const Jupiter::ReadableString &parameters); \
const Jupiter::ReadableString &getHelp(const Jupiter::ReadableString &parameters); \ const Jupiter::ReadableString &getHelp(const Jupiter::ReadableString &parameters) override; \
CLASS *copy(); \ CLASS *copy(); \
void create(); \ void create(); \
CLASS() { this->create(); RenX::getCore()->addCommand(this); } CLASS() { this->create(); RenX::getCore()->addCommand(this); }

35
src/Plugins/RenX/RenX.Core/RenX_LadderDatabase.cpp

@ -16,6 +16,7 @@
* Written by Jessica James <jessica.aj@outlook.com> * Written by Jessica James <jessica.aj@outlook.com>
*/ */
#include "jessilib/unicode.hpp"
#include "RenX_LadderDatabase.h" #include "RenX_LadderDatabase.h"
#include "RenX_Server.h" #include "RenX_Server.h"
#include "RenX_PlayerInfo.h" #include "RenX_PlayerInfo.h"
@ -33,7 +34,7 @@ RenX::LadderDatabase::LadderDatabase() {
} }
} }
RenX::LadderDatabase::LadderDatabase(const Jupiter::ReadableString &in_name) : LadderDatabase() { RenX::LadderDatabase::LadderDatabase(std::string_view in_name) : LadderDatabase() {
RenX::LadderDatabase::setName(in_name); RenX::LadderDatabase::setName(in_name);
} }
@ -208,9 +209,9 @@ std::pair<RenX::LadderDatabase::Entry *, size_t> RenX::LadderDatabase::getPlayer
return std::pair<Entry*, size_t>(nullptr, Jupiter::INVALID_INDEX); return std::pair<Entry*, size_t>(nullptr, Jupiter::INVALID_INDEX);
} }
RenX::LadderDatabase::Entry *RenX::LadderDatabase::getPlayerEntryByName(const Jupiter::ReadableString &name) const { RenX::LadderDatabase::Entry *RenX::LadderDatabase::getPlayerEntryByName(std::string_view name) const {
for (Entry *itr = m_head; itr != nullptr; itr = itr->next) { for (Entry *itr = m_head; itr != nullptr; itr = itr->next) {
if (itr->most_recent_name.equalsi(name)) { if (jessilib::equalsi(itr->most_recent_name, name)) {
return itr; return itr;
} }
} }
@ -218,10 +219,10 @@ RenX::LadderDatabase::Entry *RenX::LadderDatabase::getPlayerEntryByName(const Ju
return nullptr; return nullptr;
} }
std::pair<RenX::LadderDatabase::Entry *, size_t> RenX::LadderDatabase::getPlayerEntryAndIndexByName(const Jupiter::ReadableString &name) const { std::pair<RenX::LadderDatabase::Entry *, size_t> RenX::LadderDatabase::getPlayerEntryAndIndexByName(std::string_view name) const {
size_t index = 0; size_t index = 0;
for (Entry *itr = m_head; itr != nullptr; itr = itr->next, ++index) { for (Entry *itr = m_head; itr != nullptr; itr = itr->next, ++index) {
if (itr->most_recent_name.equalsi(name)) { if (jessilib::equalsi(itr->most_recent_name, name)) {
return std::pair<Entry*, size_t>(itr, index); return std::pair<Entry*, size_t>(itr, index);
} }
} }
@ -229,9 +230,9 @@ std::pair<RenX::LadderDatabase::Entry *, size_t> RenX::LadderDatabase::getPlayer
return std::pair<Entry*, size_t>(nullptr, Jupiter::INVALID_INDEX); return std::pair<Entry*, size_t>(nullptr, Jupiter::INVALID_INDEX);
} }
RenX::LadderDatabase::Entry *RenX::LadderDatabase::getPlayerEntryByPartName(const Jupiter::ReadableString &name) const { RenX::LadderDatabase::Entry *RenX::LadderDatabase::getPlayerEntryByPartName(std::string_view name) const {
for (Entry *itr = m_head; itr != nullptr; itr = itr->next) { for (Entry *itr = m_head; itr != nullptr; itr = itr->next) {
if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX) { if (jessilib::findi(itr->most_recent_name, name) != std::string::npos) {
return itr; return itr;
} }
} }
@ -239,10 +240,10 @@ RenX::LadderDatabase::Entry *RenX::LadderDatabase::getPlayerEntryByPartName(cons
return nullptr; return nullptr;
} }
std::pair<RenX::LadderDatabase::Entry *, size_t> RenX::LadderDatabase::getPlayerEntryAndIndexByPartName(const Jupiter::ReadableString &name) const { std::pair<RenX::LadderDatabase::Entry *, size_t> RenX::LadderDatabase::getPlayerEntryAndIndexByPartName(std::string_view name) const {
size_t index = 0; size_t index = 0;
for (Entry *itr = m_head; itr != nullptr; itr = itr->next, ++index) { for (Entry *itr = m_head; itr != nullptr; itr = itr->next, ++index) {
if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX) { if (jessilib::findi(itr->most_recent_name, name) != std::string::npos) {
return std::pair<RenX::LadderDatabase::Entry*, size_t>(itr, index); return std::pair<RenX::LadderDatabase::Entry*, size_t>(itr, index);
} }
} }
@ -250,18 +251,18 @@ std::pair<RenX::LadderDatabase::Entry *, size_t> RenX::LadderDatabase::getPlayer
return std::pair<Entry *, size_t>(nullptr, Jupiter::INVALID_INDEX); return std::pair<Entry *, size_t>(nullptr, Jupiter::INVALID_INDEX);
} }
std::forward_list<RenX::LadderDatabase::Entry> RenX::LadderDatabase::getPlayerEntriesByPartName(const Jupiter::ReadableString &name, size_t max) const { std::forward_list<RenX::LadderDatabase::Entry> RenX::LadderDatabase::getPlayerEntriesByPartName(std::string_view name, size_t max) const {
std::forward_list<Entry> list; std::forward_list<Entry> list;
if (max == 0) { if (max == 0) {
for (Entry *itr = m_head; itr != nullptr; itr = itr->next) { for (Entry *itr = m_head; itr != nullptr; itr = itr->next) {
if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX) { if (jessilib::findi(itr->most_recent_name, name) != std::string::npos) {
list.emplace_front(*itr); list.emplace_front(*itr);
} }
} }
} }
else { else {
for (Entry* itr = m_head; itr != nullptr; itr = itr->next) { for (Entry* itr = m_head; itr != nullptr; itr = itr->next) {
if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX) { if (jessilib::findi(itr->most_recent_name, name) != std::string::npos) {
list.emplace_front(*itr); list.emplace_front(*itr);
if (--max == 0) { if (--max == 0) {
return list; return list;
@ -272,20 +273,20 @@ std::forward_list<RenX::LadderDatabase::Entry> RenX::LadderDatabase::getPlayerEn
return list; return list;
} }
std::forward_list<std::pair<RenX::LadderDatabase::Entry, size_t>> RenX::LadderDatabase::getPlayerEntriesAndIndexByPartName(const Jupiter::ReadableString &name, size_t max) const { std::forward_list<std::pair<RenX::LadderDatabase::Entry, size_t>> RenX::LadderDatabase::getPlayerEntriesAndIndexByPartName(std::string_view name, size_t max) const {
std::forward_list<std::pair<Entry, size_t>> list; std::forward_list<std::pair<Entry, size_t>> list;
size_t index = 0; size_t index = 0;
if (max == 0) if (max == 0)
{ {
for (Entry *itr = m_head; itr != nullptr; itr = itr->next, ++index) { for (Entry *itr = m_head; itr != nullptr; itr = itr->next, ++index) {
if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX) { if (jessilib::findi(itr->most_recent_name, name) != std::string::npos) {
list.emplace_front(*itr, index); list.emplace_front(*itr, index);
} }
} }
} }
else { else {
for (Entry* itr = m_head; itr != nullptr; itr = itr->next, ++index) { for (Entry* itr = m_head; itr != nullptr; itr = itr->next, ++index) {
if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX) { if (jessilib::findi(itr->most_recent_name, name) != std::string::npos) {
list.emplace_front(*itr, index); list.emplace_front(*itr, index);
if (--max) { if (--max) {
return list; return list;
@ -616,11 +617,11 @@ void RenX::LadderDatabase::erase() {
} }
} }
const Jupiter::ReadableString &RenX::LadderDatabase::getName() const { std::string_view RenX::LadderDatabase::getName() const {
return m_name; return m_name;
} }
void RenX::LadderDatabase::setName(const Jupiter::ReadableString &in_name) { void RenX::LadderDatabase::setName(std::string_view in_name) {
m_name = in_name; m_name = in_name;
} }

22
src/Plugins/RenX/RenX.Core/RenX_LadderDatabase.h

@ -79,7 +79,7 @@ namespace RenX {
top_score, top_kills, most_deaths, top_headshot_kills, top_vehicle_kills, top_building_kills, top_defence_kills, top_captures, top_game_time, top_beacon_placements, top_beacon_disarms, top_proxy_placements, top_proxy_disarms, // tops (13) top_score, top_kills, most_deaths, top_headshot_kills, top_vehicle_kills, top_building_kills, top_defence_kills, top_captures, top_game_time, top_beacon_placements, top_beacon_disarms, top_proxy_placements, top_proxy_disarms, // tops (13)
most_recent_ip; // other (1) most_recent_ip; // other (1)
time_t last_game; time_t last_game;
Jupiter::StringS most_recent_name; std::string most_recent_name;
Entry *next = nullptr; Entry *next = nullptr;
Entry *prev = nullptr; Entry *prev = nullptr;
}; };
@ -106,8 +106,8 @@ namespace RenX {
* @param name Name to search ladder for * @param name Name to search ladder for
* @return Ladder entry with a matching name if one exists, nullptr otherwise. * @return Ladder entry with a matching name if one exists, nullptr otherwise.
*/ */
Entry *getPlayerEntryByName(const Jupiter::ReadableString &name) const; Entry *getPlayerEntryByName(std::string_view name) const;
std::pair<Entry *, size_t> getPlayerEntryAndIndexByName(const Jupiter::ReadableString &name) const; std::pair<Entry *, size_t> getPlayerEntryAndIndexByName(std::string_view name) const;
/** /**
* @brief Searches for a ladder entry by part name * @brief Searches for a ladder entry by part name
@ -115,8 +115,8 @@ namespace RenX {
* @param name Part of name to search ladder for * @param name Part of name to search ladder for
* @return Ladder entry with a matching name if one exists, nullptr otherwise. * @return Ladder entry with a matching name if one exists, nullptr otherwise.
*/ */
Entry *getPlayerEntryByPartName(const Jupiter::ReadableString &name) const; Entry *getPlayerEntryByPartName(std::string_view name) const;
std::pair<Entry *, size_t> getPlayerEntryAndIndexByPartName(const Jupiter::ReadableString &name) const; std::pair<Entry *, size_t> getPlayerEntryAndIndexByPartName(std::string_view name) const;
/** /**
* @brief Fetches all entries matching a part name. * @brief Fetches all entries matching a part name.
@ -125,8 +125,8 @@ namespace RenX {
* @param max Maximum number of entries to return * @param max Maximum number of entries to return
* @return List containing entries with matching names. * @return List containing entries with matching names.
*/ */
std::forward_list<Entry> getPlayerEntriesByPartName(const Jupiter::ReadableString &name, size_t max) const; std::forward_list<Entry> getPlayerEntriesByPartName(std::string_view name, size_t max) const;
std::forward_list<std::pair<Entry, size_t>> getPlayerEntriesAndIndexByPartName(const Jupiter::ReadableString &name, size_t max) const; std::forward_list<std::pair<Entry, size_t>> getPlayerEntriesAndIndexByPartName(std::string_view name, size_t max) const;
/** /**
* @brief Fetches a ladder entry at a specified index * @brief Fetches a ladder entry at a specified index
@ -184,12 +184,12 @@ namespace RenX {
/** /**
* @brief Gets the name of this database. * @brief Gets the name of this database.
*/ */
const Jupiter::ReadableString &getName() const; std::string_view getName() const;
/** /**
* @brief Sets the name of this database. * @brief Sets the name of this database.
*/ */
void setName(const Jupiter::ReadableString &in_name); void setName(std::string_view in_name);
/** /**
* @brief Checks if this database outputs sort/write times when 'updateLadder' is called. * @brief Checks if this database outputs sort/write times when 'updateLadder' is called.
@ -213,7 +213,7 @@ namespace RenX {
/** /**
* @brief Named constructor for the LadderDatabase class * @brief Named constructor for the LadderDatabase class
*/ */
LadderDatabase(const Jupiter::ReadableString &in_name); LadderDatabase(std::string_view in_name);
/** /**
* @brief Deconstructor for the LadderDatabase class * @brief Deconstructor for the LadderDatabase class
@ -229,7 +229,7 @@ namespace RenX {
uint8_t m_read_version = m_write_version; uint8_t m_read_version = m_write_version;
bool m_output_times = false; bool m_output_times = false;
Jupiter::StringS m_name; std::string m_name;
std::chrono::steady_clock::time_point m_last_sort = std::chrono::steady_clock::now(); std::chrono::steady_clock::time_point m_last_sort = std::chrono::steady_clock::now();
size_t m_entries = 0; size_t m_entries = 0;
Entry* m_head = nullptr; Entry* m_head = nullptr;

2
src/Plugins/RenX/RenX.Core/RenX_Map.h

@ -38,7 +38,7 @@ namespace RenX
struct RENX_API Map struct RENX_API Map
{ {
uint64_t guid[2]; uint64_t guid[2];
Jupiter::StringS name; std::string name;
bool equals(const RenX::Map &map) const; bool equals(const RenX::Map &map) const;

4
src/Plugins/RenX/RenX.Core/RenX_PlayerInfo.h

@ -49,7 +49,7 @@ namespace RenX
std::chrono::steady_clock::time_point joinTime = std::chrono::steady_clock::now(); std::chrono::steady_clock::time_point joinTime = std::chrono::steady_clock::now();
// TODO: Add backpack // TODO: Add backpack
Jupiter::StringS name; std::string name;
Jupiter::StringS ip; Jupiter::StringS ip;
Jupiter::StringS adminType; Jupiter::StringS adminType;
Jupiter::StringS uuid; Jupiter::StringS uuid;
@ -96,7 +96,7 @@ namespace RenX
mutable Jupiter::Config varData; mutable Jupiter::Config varData;
}; };
static Jupiter::ReferenceString rdns_pending = STRING_LITERAL_AS_REFERENCE("RDNS_PENDING"); static std::string_view rdns_pending{ "RDNS_PENDING" };
} }
/** Re-enable warnings */ /** Re-enable warnings */

535
src/Plugins/RenX/RenX.Core/RenX_Server.cpp

File diff suppressed because it is too large

42
src/Plugins/RenX/RenX.Core/RenX_Server.h

@ -240,7 +240,7 @@ namespace RenX
* @param message Message to send in-game. * @param message Message to send in-game.
* @return The number of bytes sent on success, less than or equal to zero otherwise. * @return The number of bytes sent on success, less than or equal to zero otherwise.
*/ */
int sendMessage(const Jupiter::ReadableString &message); int sendMessage(std::string_view message);
/** /**
* @brief Sends an in-game message to a player in the server. * @brief Sends an in-game message to a player in the server.
@ -249,7 +249,7 @@ namespace RenX
* @param message Message to send in-game. * @param message Message to send in-game.
* @return The number of bytes sent on success, less than or equal to zero otherwise. * @return The number of bytes sent on success, less than or equal to zero otherwise.
*/ */
int sendMessage(const RenX::PlayerInfo &player, const Jupiter::ReadableString &message); int sendMessage(const RenX::PlayerInfo &player, std::string_view message);
/** /**
* @brief Sends an in-game admin message to the server. * @brief Sends an in-game admin message to the server.
@ -291,7 +291,7 @@ namespace RenX
* @param name Name of the player. * @param name Name of the player.
* @return A player's data on success, nullptr otherwise. * @return A player's data on success, nullptr otherwise.
*/ */
RenX::BuildingInfo *getBuildingByName(const Jupiter::ReadableString &name) const; RenX::BuildingInfo *getBuildingByName(std::string_view name) const;
/** /**
* @brief Checks if a map name is in the rotation. * @brief Checks if a map name is in the rotation.
@ -299,15 +299,15 @@ namespace RenX
* @param name Name of map to search for * @param name Name of map to search for
* @return True if the map exists, false otherwise. * @return True if the map exists, false otherwise.
*/ */
bool hasMapInRotation(const Jupiter::ReadableString &name) const; bool hasMapInRotation(std::string_view name) const;
/** /**
* @brief Searches for a map based on a part of its name. * @brief Searches for a map based on a part of its name.
* *
* @param name Part of the map's name to search for * @param name Part of the map's name to search for
* @return A map's full name if it exists, nullptr otherwise. * @return A map's full name if it exists, an empty view otherwise.
*/ */
const Jupiter::ReadableString *getMapName(const Jupiter::ReadableString &name) const; std::string_view getMapName(std::string_view name) const;
/** /**
* @brief Fetches the RCON command currently being processed. * @brief Fetches the RCON command currently being processed.
@ -386,7 +386,7 @@ namespace RenX
* @param name Name of the player. * @param name Name of the player.
* @return A player's data on success, nullptr otherwise. * @return A player's data on success, nullptr otherwise.
*/ */
RenX::PlayerInfo *getPlayerByPartNameFast(const Jupiter::ReadableString &partName) const; RenX::PlayerInfo *getPlayerByPartNameFast(std::string_view partName) const;
/** /**
* @brief Formats a player's Steam ID into a readable string. * @brief Formats a player's Steam ID into a readable string.
@ -450,7 +450,7 @@ namespace RenX
* *
* @param id Player ID of the player to ban. * @param id Player ID of the player to ban.
*/ */
void banPlayer(int id, const Jupiter::ReadableString &banner, const Jupiter::ReadableString &reason); void banPlayer(int id, std::string_view banner, std::string_view reason);
/** /**
* @brief Bans a player from the server. * @brief Bans a player from the server.
@ -458,7 +458,7 @@ namespace RenX
* @param player Data of the player to ban. * @param player Data of the player to ban.
* @param length Duration of the ban (0 for permanent). * @param length Duration of the ban (0 for permanent).
*/ */
void banPlayer(const RenX::PlayerInfo &player, const Jupiter::ReadableString &banner, const Jupiter::ReadableString &reason, std::chrono::seconds length = std::chrono::seconds::zero()); void banPlayer(const RenX::PlayerInfo &player, std::string_view banner, std::string_view reason, std::chrono::seconds length = std::chrono::seconds::zero());
/** /**
* @brief Removes a player's data based on their ID number. * @brief Removes a player's data based on their ID number.
@ -530,7 +530,7 @@ namespace RenX
* *
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
bool setMap(const Jupiter::ReadableString &map); bool setMap(std::string_view map);
/** /**
* @brief Forces the current game to end. * @brief Forces the current game to end.
@ -725,21 +725,21 @@ namespace RenX
* *
* @param prefix Prefix to use. * @param prefix Prefix to use.
*/ */
void setPrefix(const Jupiter::ReadableString &prefix); void setPrefix(std::string_view prefix);
/** /**
* @brief Fetches a server's game command prefix. * @brief Fetches a server's game command prefix.
* *
* @return The server's game command prefix. * @return The server's game command prefix.
*/ */
const Jupiter::ReadableString &getCommandPrefix() const; std::string_view getCommandPrefix() const;
/** /**
* @brief Sets a server's game command prefix. * @brief Sets a server's game command prefix.
* *
* @param prefix Prefix to use. * @param prefix Prefix to use.
*/ */
void setCommandPrefix(const Jupiter::ReadableString &prefix); void setCommandPrefix(std::string_view prefix);
void setRanked(bool in_value); void setRanked(bool in_value);
@ -864,7 +864,7 @@ namespace RenX
* @param trigger Trigger of the command to get * @param trigger Trigger of the command to get
* @return Command with the specified trigger. * @return Command with the specified trigger.
*/ */
GameCommand *getCommand(const Jupiter::ReadableString &trigger) const; GameCommand *getCommand(std::string_view trigger) const;
/** /**
* @brief Returns the number of commands in the command list. * @brief Returns the number of commands in the command list.
@ -903,7 +903,7 @@ namespace RenX
* @param trigger Trigger of the command to remove. * @param trigger Trigger of the command to remove.
* @return True if a command was removed, false otherwise. * @return True if a command was removed, false otherwise.
*/ */
bool removeCommand(const Jupiter::ReadableString &trigger); bool removeCommand(std::string_view trigger);
/** /**
* @brief Prototype of UUID calculation function. * @brief Prototype of UUID calculation function.
@ -1031,7 +1031,7 @@ namespace RenX
* *
* @return String containing the Game version * @return String containing the Game version
*/ */
const Jupiter::ReadableString &getGameVersion() const; std::string_view getGameVersion() const;
/** /**
* @brief Fetches the RCON user name. * @brief Fetches the RCON user name.
@ -1046,14 +1046,14 @@ namespace RenX
* @param socket Initialized Socket to use for the connection * @param socket Initialized Socket to use for the connection
* @param configurationSection Configuration section to load from. * @param configurationSection Configuration section to load from.
*/ */
Server(Jupiter::Socket &&socket, const Jupiter::ReadableString &configurationSection); Server(Jupiter::Socket &&socket, std::string_view configurationSection);
/** /**
* @brief Creates the Server object, and loads settings from the specified configuration section. * @brief Creates the Server object, and loads settings from the specified configuration section.
* *
* @param configurationSection Configuration section to load from. * @param configurationSection Configuration section to load from.
*/ */
Server(const Jupiter::ReadableString &configurationSection); Server(std::string_view configurationSection);
/** /**
* @brief Destructor for Server class. * @brief Destructor for Server class.
@ -1144,11 +1144,11 @@ namespace RenX
std::string m_clientHostname; std::string m_clientHostname;
std::string m_hostname; std::string m_hostname;
Jupiter::StringS m_pass; Jupiter::StringS m_pass;
Jupiter::StringS m_configSection; std::string m_configSection;
Jupiter::StringS m_rules; Jupiter::StringS m_rules;
Jupiter::StringS m_ban_from_str; Jupiter::StringS m_ban_from_str;
Jupiter::StringS m_IRCPrefix; std::string m_IRCPrefix;
Jupiter::StringS m_CommandPrefix; std::string m_CommandPrefix;
Jupiter::Config* m_commandAccessLevels; Jupiter::Config* m_commandAccessLevels;
Jupiter::Config* m_commandAliases; Jupiter::Config* m_commandAliases;
}; };

8
src/Plugins/RenX/RenX.Core/RenX_Tags.cpp

@ -446,8 +446,8 @@ double get_ratio(double num, double denom)
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, const RenX::BuildingInfo *building)
{ {
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, std::string_view(getTimeFormat(this->dateFmt.c_str())));
PROCESS_TAG(this->INTERNAL_TIME_TAG, Jupiter::ReferenceString(getTimeFormat(this->timeFmt.c_str()))); PROCESS_TAG(this->INTERNAL_TIME_TAG, std::string_view(getTimeFormat(this->timeFmt.c_str())));
if (server != nullptr) if (server != nullptr)
{ {
PROCESS_TAG(this->INTERNAL_RCON_VERSION_TAG, Jupiter::StringS::Format("%u", server->getVersion())); PROCESS_TAG(this->INTERNAL_RCON_VERSION_TAG, Jupiter::StringS::Format("%u", server->getVersion()));
@ -457,9 +457,9 @@ void TagsImp::processTags(Jupiter::StringType &msg, const RenX::Server *server,
PROCESS_TAG(this->INTERNAL_SERVER_NAME_TAG, server->getName()); PROCESS_TAG(this->INTERNAL_SERVER_NAME_TAG, server->getName());
PROCESS_TAG(this->INTERNAL_MAP_TAG, server->getMap().name); PROCESS_TAG(this->INTERNAL_MAP_TAG, server->getMap().name);
PROCESS_TAG(this->INTERNAL_MAP_GUID_TAG, RenX::formatGUID(server->getMap())); PROCESS_TAG(this->INTERNAL_MAP_GUID_TAG, RenX::formatGUID(server->getMap()));
PROCESS_TAG(this->INTERNAL_SERVER_HOSTNAME_TAG, Jupiter::ReferenceString(server->getHostname().c_str())); PROCESS_TAG(this->INTERNAL_SERVER_HOSTNAME_TAG, server->getHostname());
PROCESS_TAG(this->INTERNAL_SERVER_PORT_TAG, Jupiter::StringS::Format("%u", server->getPort())); PROCESS_TAG(this->INTERNAL_SERVER_PORT_TAG, Jupiter::StringS::Format("%u", server->getPort()));
PROCESS_TAG(this->INTERNAL_SOCKET_HOSTNAME_TAG, Jupiter::ReferenceString(server->getSocketHostname().c_str())); PROCESS_TAG(this->INTERNAL_SOCKET_HOSTNAME_TAG, server->getSocketHostname());
PROCESS_TAG(this->INTERNAL_SOCKET_PORT_TAG, Jupiter::StringS::Format("%u", server->getSocketPort())); PROCESS_TAG(this->INTERNAL_SOCKET_PORT_TAG, Jupiter::StringS::Format("%u", server->getSocketPort()));
PROCESS_TAG(this->INTERNAL_SERVER_PREFIX_TAG, server->getPrefix()); PROCESS_TAG(this->INTERNAL_SERVER_PREFIX_TAG, server->getPrefix());
if (player != nullptr) if (player != nullptr)

17
src/Plugins/RenX/RenX.ExcessiveHeadshots/RenX_ExcessiveHeadshots.cpp

@ -24,9 +24,9 @@
#include "RenX_Functions.h" #include "RenX_Functions.h"
using namespace Jupiter::literals; using namespace Jupiter::literals;
using namespace std::literals;
bool RenX_ExcessiveHeadshotsPlugin::initialize() bool RenX_ExcessiveHeadshotsPlugin::initialize() {
{
RenX_ExcessiveHeadshotsPlugin::ratio = this->config.get<double>("HeadshotKillRatio"_jrs, 0.5); RenX_ExcessiveHeadshotsPlugin::ratio = this->config.get<double>("HeadshotKillRatio"_jrs, 0.5);
RenX_ExcessiveHeadshotsPlugin::minKills = this->config.get<unsigned int>("Kills"_jrs, 10); RenX_ExcessiveHeadshotsPlugin::minKills = this->config.get<unsigned int>("Kills"_jrs, 10);
RenX_ExcessiveHeadshotsPlugin::minKD = this->config.get<double>("KillDeathRatio"_jrs, 5.0); RenX_ExcessiveHeadshotsPlugin::minKD = this->config.get<double>("KillDeathRatio"_jrs, 5.0);
@ -35,19 +35,16 @@ bool RenX_ExcessiveHeadshotsPlugin::initialize()
return true; return true;
} }
int RenX_ExcessiveHeadshotsPlugin::OnRehash() int RenX_ExcessiveHeadshotsPlugin::OnRehash() {
{
RenX::Plugin::OnRehash(); RenX::Plugin::OnRehash();
return this->initialize() ? 0 : -1; return this->initialize() ? 0 : -1;
} }
void RenX_ExcessiveHeadshotsPlugin::RenX_OnKill(RenX::Server &server, const RenX::PlayerInfo &player, const RenX::PlayerInfo &victim, const Jupiter::ReadableString &damageType) void RenX_ExcessiveHeadshotsPlugin::RenX_OnKill(RenX::Server &server, const RenX::PlayerInfo &player, const RenX::PlayerInfo &victim, const Jupiter::ReadableString &damageType) {
{
if (player.kills < 3) if (player.kills < 3)
return; return;
if (damageType.equals("Rx_DmgType_Headshot"_jrs)) if (damageType == "Rx_DmgType_Headshot"sv) {
{
unsigned int flags = 0; unsigned int flags = 0;
std::chrono::milliseconds game_time = server.getGameTime(player); std::chrono::milliseconds game_time = server.getGameTime(player);
double kps = game_time == std::chrono::milliseconds::zero() ? static_cast<double>(player.kills) : static_cast<double>(player.kills) / static_cast<double>(game_time.count()); double kps = game_time == std::chrono::milliseconds::zero() ? static_cast<double>(player.kills) : static_cast<double>(player.kills) / static_cast<double>(game_time.count());
@ -61,9 +58,9 @@ void RenX_ExcessiveHeadshotsPlugin::RenX_OnKill(RenX::Server &server, const RenX
if (flags >= RenX_ExcessiveHeadshotsPlugin::minFlags) if (flags >= RenX_ExcessiveHeadshotsPlugin::minFlags)
{ {
server.banPlayer(player, "Jupiter Bot"_jrs, "Aimbot detected"_jrs); server.banPlayer(player, "Jupiter Bot"_jrs, "Aimbot detected"_jrs);
server.sendPubChan(IRCCOLOR "13[Aimbot]" IRCCOLOR " %.*s was banned from the server! Kills: %u - Deaths: %u - Headshots: %u", player.name.size(), player.name.ptr(), player.kills, player.deaths, player.headshots); server.sendPubChan(IRCCOLOR "13[Aimbot]" IRCCOLOR " %.*s was banned from the server! Kills: %u - Deaths: %u - Headshots: %u", player.name.size(), player.name.data(), player.kills, player.deaths, player.headshots);
const Jupiter::ReadableString &steamid = server.formatSteamID(player); const Jupiter::ReadableString &steamid = server.formatSteamID(player);
server.sendAdmChan(IRCCOLOR "13[Aimbot]" IRCCOLOR " %.*s was banned from the server! Kills: %u - Deaths: %u - Headshots: %u - IP: " IRCBOLD "%.*s" IRCBOLD " - Steam ID: " IRCBOLD "%.*s" IRCBOLD, player.name.size(), player.name.ptr(), player.kills, player.deaths, player.headshots, player.ip.size(), player.ip.ptr(), steamid.size(), steamid.ptr()); server.sendAdmChan(IRCCOLOR "13[Aimbot]" IRCCOLOR " %.*s was banned from the server! Kills: %u - Deaths: %u - Headshots: %u - IP: " IRCBOLD "%.*s" IRCBOLD " - Steam ID: " IRCBOLD "%.*s" IRCBOLD, player.name.size(), player.name.data(), player.kills, player.deaths, player.headshots, player.ip.size(), player.ip.ptr(), steamid.size(), steamid.ptr());
} }
} }
} }

4
src/Plugins/RenX/RenX.KickDupes/RenX_KickDupes.cpp

@ -16,6 +16,7 @@
* Written by Jessica James <jessica.aj@outlook.com> * Written by Jessica James <jessica.aj@outlook.com>
*/ */
#include "jessilib/unicode.hpp"
#include "RenX_Core.h" #include "RenX_Core.h"
#include "RenX_Server.h" #include "RenX_Server.h"
#include "RenX_Functions.h" #include "RenX_Functions.h"
@ -23,6 +24,7 @@
#include "RenX_KickDupes.h" #include "RenX_KickDupes.h"
using namespace Jupiter::literals; using namespace Jupiter::literals;
using namespace std::literals;
bool RenX_KickDupesPlugin::initialize() { bool RenX_KickDupesPlugin::initialize() {
return true; return true;
@ -36,7 +38,7 @@ void RenX_KickDupesPlugin::RenX_OnPlayerIdentify(RenX::Server &in_server, const
} }
// Exempt development servers from this check // Exempt development servers from this check
if (in_server.getGameVersion().findi("-DEV"_jrs) != Jupiter::INVALID_INDEX) { if (jessilib::findi(in_server.getGameVersion(), "-DEV"sv) != std::string::npos) {
return; return;
} }

8
src/Plugins/RenX/RenX.Ladder.Web/RenX_Ladder_Web.cpp

@ -156,7 +156,7 @@ RenX_Ladder_WebPlugin pluginInstance;
/** Search bar */ /** Search bar */
Jupiter::String generate_search(RenX::LadderDatabase *db) { Jupiter::String generate_search(RenX::LadderDatabase *db) {
Jupiter::String result(256); std::string result;
result = R"database-search(<form action="search" method="get" class="leaderboard-search"><input type="text" class="leaderboard-search-input" name="name" size="30" placeholder="Player name" value=""/>)database-search"_jrs; result = R"database-search(<form action="search" method="get" class="leaderboard-search"><input type="text" class="leaderboard-search-input" name="name" size="30" placeholder="Player name" value=""/>)database-search"_jrs;
if (db != nullptr && db != RenX::default_ladder_database) { if (db != nullptr && db != RenX::default_ladder_database) {
@ -170,7 +170,7 @@ Jupiter::String generate_search(RenX::LadderDatabase *db) {
/** Database selector */ /** Database selector */
Jupiter::String generate_database_selector(RenX::LadderDatabase *db, const Jupiter::HTTP::HTMLFormResponse& query_params) { Jupiter::String generate_database_selector(RenX::LadderDatabase *db, const Jupiter::HTTP::HTMLFormResponse& query_params) {
Jupiter::String result(256); std::string result;
result = R"database-select(<form method="get" class="database-select-form"><select name="database" class="database-select">)database-select"_jrs; result = R"database-select(<form method="get" class="database-select-form"><select name="database" class="database-select">)database-select"_jrs;
if (db != nullptr) { if (db != nullptr) {
@ -206,7 +206,7 @@ Jupiter::String generate_database_selector(RenX::LadderDatabase *db, const Jupit
/** Page buttons */ /** Page buttons */
Jupiter::String generate_page_buttons(RenX::LadderDatabase *db) { Jupiter::String generate_page_buttons(RenX::LadderDatabase *db) {
Jupiter::String result(256); std::string result;
size_t entry_count = db->getEntries(); size_t entry_count = db->getEntries();
size_t entries_per_page = pluginInstance.getEntriesPerPage(); size_t entries_per_page = pluginInstance.getEntriesPerPage();
@ -337,7 +337,7 @@ Jupiter::String *RenX_Ladder_WebPlugin::generate_search_page(RenX::LadderDatabas
Jupiter::String row(256); Jupiter::String row(256);
RenX::LadderDatabase::Entry *node = db->getHead(); RenX::LadderDatabase::Entry *node = db->getHead();
while (node != nullptr) { while (node != nullptr) {
if (node->most_recent_name.findi(Jupiter::ReferenceString{name}) != Jupiter::INVALID_INDEX) { // match found if (jessilib::findi(node->most_recent_name, name) != std::string::npos) { // match found
row = RenX_Ladder_WebPlugin::entry_table_row; row = RenX_Ladder_WebPlugin::entry_table_row;
row.replace(RenX::tags->INTERNAL_OBJECT_TAG, db->getName()); row.replace(RenX::tags->INTERNAL_OBJECT_TAG, db->getName());
RenX::processTags(row, *node); RenX::processTags(row, *node);

14
src/Plugins/RenX/RenX.Ladder/RenX_Ladder.cpp

@ -24,6 +24,7 @@
#include "RenX_BanDatabase.h" #include "RenX_BanDatabase.h"
using namespace Jupiter::literals; using namespace Jupiter::literals;
using namespace std::literals;
bool RenX_LadderPlugin::initialize() { bool RenX_LadderPlugin::initialize() {
RenX_LadderPlugin::only_pure = this->config.get<bool>("OnlyPure"_jrs, false); RenX_LadderPlugin::only_pure = this->config.get<bool>("OnlyPure"_jrs, false);
@ -55,16 +56,16 @@ void RenX_LadderPlugin::RenX_OnServerFullyConnected(RenX::Server &server) {
void RenX_LadderPlugin::RenX_OnGameOver(RenX::Server &server, RenX::WinType winType, const RenX::TeamType &team, int gScore, int nScore) { void RenX_LadderPlugin::RenX_OnGameOver(RenX::Server &server, RenX::WinType winType, const RenX::TeamType &team, int gScore, int nScore) {
if (server.isRanked() && server.isReliable() && server.players.size() != server.getBotCount()) { if (server.isRanked() && server.isReliable() && server.players.size() != server.getBotCount()) {
char chr = static_cast<char>(team); char chr = static_cast<char>(team);
server.varData[this->name].set("t"_jrs, Jupiter::ReferenceString(&chr, 1)); server.varData[this->name].set("t"sv, std::string(&chr, 1));
server.varData[this->name].set("w"_jrs, "1"_jrs); server.varData[this->name].set("w"sv, "1"s);
server.updateClientList(); server.updateClientList();
} }
} }
void RenX_LadderPlugin::RenX_OnCommand(RenX::Server &server, const Jupiter::ReadableString &) { void RenX_LadderPlugin::RenX_OnCommand(RenX::Server &server, const Jupiter::ReadableString &) {
if (server.getCurrentRCONCommand().equalsi("clientvarlist"_jrs)) { if (server.getCurrentRCONCommand().equalsi("clientvarlist"_jrs)) {
if (server.varData[this->name].get("w"_jrs, "0"_jrs).equals("1")) { if (server.varData[this->name].get("w"_jrs, "0"_jrs) == "1"sv) {
server.varData[this->name].set("w"_jrs, "0"_jrs); server.varData[this->name].set("w"sv, "0"s);
RenX::TeamType team = static_cast<RenX::TeamType>(server.varData[this->name].get("t"_jrs, "\0"_jrs).get(0)); RenX::TeamType team = static_cast<RenX::TeamType>(server.varData[this->name].get("t"_jrs, "\0"_jrs).get(0));
for (const auto& database : RenX::ladder_databases) { for (const auto& database : RenX::ladder_databases) {
database->updateLadder(server, team); database->updateLadder(server, team);
@ -83,7 +84,10 @@ RenX_LadderPlugin pluginInstance;
/** Ladder Commands */ /** Ladder Commands */
Jupiter::StringS FormatLadderResponse(RenX::LadderDatabase::Entry *entry, size_t rank) { Jupiter::StringS FormatLadderResponse(RenX::LadderDatabase::Entry *entry, size_t rank) {
return Jupiter::StringS::Format("#%" PRIuPTR ": \"%.*s\" - Score: %" PRIu64 " - Kills: %" PRIu32 " - Deaths: %" PRIu32 " - KDR: %.2f - SPM: %.2f", rank, entry->most_recent_name.size(), entry->most_recent_name.ptr(), entry->total_score, entry->total_kills, entry->total_deaths, static_cast<double>(entry->total_kills) / (entry->total_deaths == 0 ? 1 : static_cast<double>(entry->total_deaths)), static_cast<double>(entry->total_score) / (entry->total_game_time == 0 ? 1.0 : static_cast<double>(entry->total_game_time)) * 60.0); return Jupiter::StringS::Format("#%" PRIuPTR ": \"%.*s\" - Score: %" PRIu64 " - Kills: %" PRIu32 " - Deaths: %" PRIu32 " - KDR: %.2f - SPM: %.2f",
rank, entry->most_recent_name.size(), entry->most_recent_name.data(), entry->total_score, entry->total_kills, entry->total_deaths,
static_cast<double>(entry->total_kills) / (entry->total_deaths == 0 ? 1 : static_cast<double>(entry->total_deaths)),
static_cast<double>(entry->total_score) / (entry->total_game_time == 0 ? 1.0 : static_cast<double>(entry->total_game_time)) * 60.0);
} }
// Ladder Command // Ladder Command

2
src/Plugins/RenX/RenX.Listen/RenX_Listen.cpp

@ -55,7 +55,7 @@ int RenX_ListenPlugin::OnRehash() {
const Jupiter::ReadableString &address = this->config.get("Address"_jrs, "0.0.0.0"_jrs); const Jupiter::ReadableString &address = this->config.get("Address"_jrs, "0.0.0.0"_jrs);
RenX_ListenPlugin::serverSection = this->config.get("ServerSection"_jrs, this->getName()); RenX_ListenPlugin::serverSection = this->config.get("ServerSection"_jrs, this->getName());
if (port != RenX_ListenPlugin::socket.getBoundPort() || address.equals(RenX_ListenPlugin::socket.getBoundHostname()) == false) { if (port != RenX_ListenPlugin::socket.getBoundPort() || address != RenX_ListenPlugin::socket.getBoundHostname()) {
puts("Notice: The Renegade-X listening socket has been changed!"); puts("Notice: The Renegade-X listening socket has been changed!");
RenX_ListenPlugin::socket.close(); RenX_ListenPlugin::socket.close();
return RenX_ListenPlugin::socket.bind(static_cast<std::string>(address).c_str(), port, true) == false || RenX_ListenPlugin::socket.setBlocking(false) == false; return RenX_ListenPlugin::socket.bind(static_cast<std::string>(address).c_str(), port, true) == false || RenX_ListenPlugin::socket.setBlocking(false) == false;

2
src/Plugins/RenX/RenX.Listen/RenX_Listen.h

@ -38,7 +38,7 @@ public: // RenX_ListenPlugin
private: private:
Jupiter::TCPSocket socket; Jupiter::TCPSocket socket;
Jupiter::StringS serverSection; std::string serverSection;
}; };
#endif // _EXAMPLE_H_HEADER #endif // _EXAMPLE_H_HEADER

12
src/Plugins/RenX/RenX.Logging/RenX_Logging.cpp

@ -138,7 +138,7 @@ bool RenX_LoggingPlugin::initialize()
RenX_LoggingPlugin::playerCommandSuccessFmt = this->config.get("PlayerCommandSuccessFormat"_jrs, RenX_LoggingPlugin::playerCommandSuccessFmt = this->config.get("PlayerCommandSuccessFormat"_jrs,
Jupiter::StringS::Format("%.*s" IRCCOLOR ": " IRCCOLOR "10%.*s", RenX::tags->nameTag.size(), RenX::tags->nameTag.ptr(), RenX::tags->messageTag.size(), RenX::tags->messageTag.ptr())); Jupiter::StringS::Format("%.*s" IRCCOLOR ": " IRCCOLOR "10%.*s", RenX::tags->nameTag.size(), RenX::tags->nameTag.ptr(), RenX::tags->messageTag.size(), RenX::tags->messageTag.ptr()));
RenX_LoggingPlugin::playerCommandFailFmt = this->config.get("PlayerCommandFailFormat"_jrs); RenX_LoggingPlugin::playerCommandFailFmt = this->config.get("PlayerCommandFailFormat"_jrs, ""_jss);
RenX_LoggingPlugin::playerFmt = this->config.get("PlayerFormat"_jrs, RenX_LoggingPlugin::playerFmt = this->config.get("PlayerFormat"_jrs,
Jupiter::StringS::Format(IRCCOLOR "12[Player]" IRCCOLOR " %.*s", RenX::tags->messageTag.size(), RenX::tags->messageTag.ptr())); Jupiter::StringS::Format(IRCCOLOR "12[Player]" IRCCOLOR " %.*s", RenX::tags->messageTag.size(), RenX::tags->messageTag.ptr()));
@ -341,7 +341,7 @@ bool RenX_LoggingPlugin::initialize()
RenX_LoggingPlugin::executeFmt = this->config.get("ExecuteFormat"_jrs, RenX_LoggingPlugin::executeFmt = this->config.get("ExecuteFormat"_jrs,
Jupiter::StringS::Format(IRCCOLOR "07%.*s executed: %.*s", RenX::tags->nameTag.size(), RenX::tags->nameTag.ptr(), RenX::tags->messageTag.size(), RenX::tags->messageTag.ptr())); Jupiter::StringS::Format(IRCCOLOR "07%.*s executed: %.*s", RenX::tags->nameTag.size(), RenX::tags->nameTag.ptr(), RenX::tags->messageTag.size(), RenX::tags->messageTag.ptr()));
RenX_LoggingPlugin::devBotExecuteFmt = this->config.get("DevBotExecuteFormat"_jrs); RenX_LoggingPlugin::devBotExecuteFmt = this->config.get("DevBotExecuteFormat"_jrs, ""_jss);
RenX_LoggingPlugin::subscribeFmt = this->config.get("SubscribeFormat"_jrs, RenX_LoggingPlugin::subscribeFmt = this->config.get("SubscribeFormat"_jrs,
Jupiter::StringS::Format(IRCCOLOR "03%.*s subscribed to the RCON data stream.", RenX::tags->nameTag.size(), RenX::tags->nameTag.ptr())); Jupiter::StringS::Format(IRCCOLOR "03%.*s subscribed to the RCON data stream.", RenX::tags->nameTag.size(), RenX::tags->nameTag.ptr()));
@ -1868,10 +1868,8 @@ void RenX_LoggingPlugin::RenX_OnGame(RenX::Server &server, const Jupiter::Readab
} }
} }
void RenX_LoggingPlugin::RenX_OnExecute(RenX::Server &server, const Jupiter::ReadableString &user, const Jupiter::ReadableString &command) void RenX_LoggingPlugin::RenX_OnExecute(RenX::Server &server, const Jupiter::ReadableString &user, const Jupiter::ReadableString &command) {
{ if (RenX_LoggingPlugin::muteOwnExecute == false || server.getUser() != user) {
if (RenX_LoggingPlugin::muteOwnExecute == false || server.getUser().equals(user) == false)
{
logFuncType func; logFuncType func;
if (RenX_LoggingPlugin::executePublic) if (RenX_LoggingPlugin::executePublic)
func = &RenX::Server::sendLogChan; func = &RenX::Server::sendLogChan;
@ -1879,7 +1877,7 @@ void RenX_LoggingPlugin::RenX_OnExecute(RenX::Server &server, const Jupiter::Rea
func = &RenX::Server::sendAdmChan; func = &RenX::Server::sendAdmChan;
Jupiter::String msg; Jupiter::String msg;
if (user.equals(RenX::DevBotName)) if (user == RenX::DevBotName)
msg = this->devBotExecuteFmt; msg = this->devBotExecuteFmt;
else else
msg = this->executeFmt; msg = this->executeFmt;

48
src/Plugins/RenX/RenX.Medals/RenX_Medals.cpp

@ -27,6 +27,7 @@
#include "RenX_Tags.h" #include "RenX_Tags.h"
using namespace Jupiter::literals; using namespace Jupiter::literals;
using namespace std::literals;
bool RenX_MedalsPlugin::initialize() bool RenX_MedalsPlugin::initialize()
{ {
@ -53,8 +54,8 @@ RenX_MedalsPlugin::~RenX_MedalsPlugin()
{ {
if (node->uuid.isNotEmpty() && node->isBot == false) if (node->uuid.isNotEmpty() && node->isBot == false)
{ {
RenX_MedalsPlugin::medalsFile[node->uuid].set("Recs"_jrs, node->varData[this->getName()].get("Recs"_jrs)); RenX_MedalsPlugin::medalsFile[node->uuid].set("Recs"_jrs, node->varData[this->getName()].get("Recs"sv, ""s));
RenX_MedalsPlugin::medalsFile[node->uuid].set("Noobs"_jrs, node->varData[this->getName()].get("Noobs"_jrs)); RenX_MedalsPlugin::medalsFile[node->uuid].set("Noobs"_jrs, node->varData[this->getName()].get("Noobs"sv, ""s));
} }
} }
} }
@ -121,8 +122,8 @@ void RenX_MedalsPlugin::RenX_OnPlayerCreate(RenX::Server &, const RenX::PlayerIn
{ {
if (player.uuid.isNotEmpty() && player.isBot == false) if (player.uuid.isNotEmpty() && player.isBot == false)
{ {
player.varData[this->getName()].set("Recs"_jrs, RenX_MedalsPlugin::medalsFile.get(player.uuid, "Recs"_jrs)); player.varData[this->getName()].set("Recs"sv, RenX_MedalsPlugin::medalsFile.get(player.uuid, "Recs"s));
player.varData[this->getName()].set("Noobs"_jrs, RenX_MedalsPlugin::medalsFile.get(player.uuid, "Noobs"_jrs)); player.varData[this->getName()].set("Noobs"sv, RenX_MedalsPlugin::medalsFile.get(player.uuid, "Noobs"s));
} }
} }
@ -130,8 +131,8 @@ void RenX_MedalsPlugin::RenX_OnPlayerDelete(RenX::Server &, const RenX::PlayerIn
{ {
if (player.uuid.isNotEmpty() && player.isBot == false) if (player.uuid.isNotEmpty() && player.isBot == false)
{ {
RenX_MedalsPlugin::medalsFile[player.uuid].set("Recs"_jrs, player.varData[this->getName()].get("Recs"_jrs)); RenX_MedalsPlugin::medalsFile[player.uuid].set("Recs"_jrs, player.varData[this->getName()].get("Recs"sv, ""s));
RenX_MedalsPlugin::medalsFile[player.uuid].set("Noobs"_jrs, player.varData[this->getName()].get("Noobs"_jrs)); RenX_MedalsPlugin::medalsFile[player.uuid].set("Noobs"_jrs, player.varData[this->getName()].get("Noobs"sv, ""s));
} }
} }
@ -151,13 +152,14 @@ void RenX_MedalsPlugin::RenX_OnJoin(RenX::Server &server, const RenX::PlayerInfo
if (table_size != 0) if (table_size != 0)
{ {
Jupiter::StringS msg = section->get(Jupiter::StringS::Format("%u", (rand() % table_size) + 1)); std::string_view msg = section->get(Jupiter::StringS::Format("%u", (rand() % table_size) + 1));
if (msg.isNotEmpty()) if (!msg.empty())
{ {
RenX::sanitizeTags(msg); Jupiter::StringS tagged_msg = static_cast<Jupiter::ReferenceString>(msg);
RenX::processTags(msg, &server, &player); RenX::sanitizeTags(tagged_msg);
server.sendMessage(msg); RenX::processTags(tagged_msg, &server, &player);
server.sendMessage(tagged_msg);
} }
} }
} }
@ -248,8 +250,8 @@ void RenX_MedalsPlugin::RenX_OnDestroy(RenX::Server &server, const RenX::PlayerI
{ {
addRec(player); addRec(player);
const Jupiter::ReadableString &translated = RenX::translateName(objectName); std::string_view translated = RenX::translateName(objectName);
server.sendMessage(Jupiter::StringS::Format("%.*s has been recommended for destroying the %.*s!", player.name.size(), player.name.ptr(), translated.size(), translated.ptr())); server.sendMessage(Jupiter::StringS::Format("%.*s has been recommended for destroying the %.*s!", player.name.size(), player.name.data(), translated.size(), translated.data()));
} }
} }
@ -282,8 +284,8 @@ void RenX_MedalsPlugin::init()
server = core->getServer(index); server = core->getServer(index);
if (server->players.size() != server->getBotCount()) { if (server->players.size() != server->getBotCount()) {
for (auto node = server->players.begin(); node != server->players.end(); ++node) { for (auto node = server->players.begin(); node != server->players.end(); ++node) {
node->varData[this->getName()].set("Recs"_jrs, RenX_MedalsPlugin::medalsFile[node->name].get("Recs"_jrs)); node->varData[this->getName()].set("Recs"sv, RenX_MedalsPlugin::medalsFile[node->name].get("Recs"sv, ""s));
node->varData[this->getName()].set("Noobs"_jrs, RenX_MedalsPlugin::medalsFile[node->name].get("Noobs"_jrs)); node->varData[this->getName()].set("Noobs"sv, RenX_MedalsPlugin::medalsFile[node->name].get("Noobs"sv, ""s));
} }
} }
} }
@ -329,12 +331,12 @@ void RecsGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, co
else if (target == player) else if (target == player)
RecsGameCommand::trigger(source, player, Jupiter::ReferenceString::empty); RecsGameCommand::trigger(source, player, Jupiter::ReferenceString::empty);
else else
source->sendMessage(*player, Jupiter::StringS::Format("%.*s has %lu and %lu n00bs. Their worth: %d", target->name.size(), target->name.ptr(), getRecs(*target), getNoobs(*target), getWorth(*target))); source->sendMessage(*player, Jupiter::StringS::Format("%.*s has %lu and %lu n00bs. Their worth: %d", target->name.size(), target->name.data(), getRecs(*target), getNoobs(*target), getWorth(*target)));
} }
else if (player->uuid.isEmpty()) else if (player->uuid.isEmpty())
source->sendMessage(*player, "Error: You are not using steam."_jrs); source->sendMessage(*player, "Error: You are not using steam."_jrs);
else else
source->sendMessage(*player, Jupiter::StringS::Format("%.*s, you have %lu recs and %lu n00bs. Your worth: %d", player->name.size(), player->name.ptr(), getRecs(*player), getNoobs(*player), getWorth(*player))); source->sendMessage(*player, Jupiter::StringS::Format("%.*s, you have %lu recs and %lu n00bs. Your worth: %d", player->name.size(), player->name.data(), getRecs(*player), getNoobs(*player), getWorth(*player)));
} }
const Jupiter::ReadableString &RecsGameCommand::getHelp(const Jupiter::ReadableString &) const Jupiter::ReadableString &RecsGameCommand::getHelp(const Jupiter::ReadableString &)
@ -376,8 +378,8 @@ void RecGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, con
else else
{ {
addRec(*target); addRec(*target);
source->sendMessage(Jupiter::StringS::Format("%.*s has recommended %.*s!", player->name.size(), player->name.ptr(), target->name.size(), target->name.ptr())); source->sendMessage(Jupiter::StringS::Format("%.*s has recommended %.*s!", player->name.size(), player->name.data(), target->name.size(), target->name.data()));
player->varData["RenX.Medals"_jrs].set("gr"_jrs, "1"_jrs); player->varData["RenX.Medals"_jrs].set("gr"_jrs, "1"s);
} }
} }
else RecsGameCommand_instance.trigger(source, player, parameters); else RecsGameCommand_instance.trigger(source, player, parameters);
@ -417,8 +419,8 @@ void NoobGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, co
else else
{ {
addNoob(*target); addNoob(*target);
source->sendMessage(Jupiter::StringS::Format("%.*s has noob'd %.*s!", player->name.size(), player->name.ptr(), target->name.size(), target->name.ptr())); source->sendMessage(Jupiter::StringS::Format("%.*s has noob'd %.*s!", player->name.size(), player->name.data(), target->name.size(), target->name.data()));
player->varData["RenX.Medals"_jrs].set("gn"_jrs, "1"_jrs); player->varData["RenX.Medals"_jrs].set("gn"_jrs, "1"s);
} }
} }
else RecsGameCommand_instance.trigger(source, player, parameters); else RecsGameCommand_instance.trigger(source, player, parameters);
@ -435,13 +437,13 @@ GAME_COMMAND_INIT(NoobGameCommand)
void addRec(const RenX::PlayerInfo &player, int amount) void addRec(const RenX::PlayerInfo &player, int amount)
{ {
if (player.uuid.matchi("Player*") == false && player.isBot == false) if (player.uuid.matchi("Player*") == false && player.isBot == false)
player.varData[pluginInstance.getName()].set("Recs"_jrs, Jupiter::StringS::Format("%u", getRecs(player) + amount)); player.varData[pluginInstance.getName()].set("Recs"_jrs, static_cast<std::string>(Jupiter::StringS::Format("%u", getRecs(player) + amount)));
} }
void addNoob(const RenX::PlayerInfo &player, int amount) void addNoob(const RenX::PlayerInfo &player, int amount)
{ {
if (player.uuid.matchi("Player*") == false && player.isBot == false) if (player.uuid.matchi("Player*") == false && player.isBot == false)
player.varData[pluginInstance.getName()].set("Noobs"_jrs, Jupiter::StringS::Format("%u", getNoobs(player) + amount)); player.varData[pluginInstance.getName()].set("Noobs"_jrs, static_cast<std::string>(Jupiter::StringS::Format("%u", getNoobs(player) + amount)));
} }
unsigned long getRecs(const RenX::PlayerInfo &player) unsigned long getRecs(const RenX::PlayerInfo &player)

2
src/Plugins/RenX/RenX.Medals/RenX_Medals.h

@ -63,7 +63,7 @@ public:
Jupiter::StringS recsTag; Jupiter::StringS recsTag;
Jupiter::StringS noobTag; Jupiter::StringS noobTag;
Jupiter::StringS worthTag; Jupiter::StringS worthTag;
Jupiter::StringS firstSection; std::string firstSection;
Jupiter::StringS medalsFileName; Jupiter::StringS medalsFileName;
Jupiter::INIConfig medalsFile; Jupiter::INIConfig medalsFile;

109
src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.cpp

@ -16,6 +16,7 @@
* Written by Jessica James <jessica.aj@outlook.com> * Written by Jessica James <jessica.aj@outlook.com>
*/ */
#include "jessilib/unicode.hpp"
#include "Jupiter/IRC_Client.h" #include "Jupiter/IRC_Client.h"
#include "IRC_Bot.h" #include "IRC_Bot.h"
#include "RenX_ModSystem.h" #include "RenX_ModSystem.h"
@ -25,6 +26,10 @@
#include "RenX_Functions.h" #include "RenX_Functions.h"
using namespace Jupiter::literals; using namespace Jupiter::literals;
using namespace std::literals;
constexpr std::string_view game_administrator_name = "administrator"sv;
constexpr std::string_view game_moderator_name = "moderator"sv;
bool RenX_ModSystemPlugin::initialize() { bool RenX_ModSystemPlugin::initialize() {
m_lockSteam = this->config.get<bool>("LockSteam"_jrs, true); m_lockSteam = this->config.get<bool>("LockSteam"_jrs, true);
@ -49,9 +54,9 @@ bool RenX_ModSystemPlugin::initialize() {
Jupiter::ReferenceString dotPrefix = ".Prefix"; Jupiter::ReferenceString dotPrefix = ".Prefix";
Jupiter::ReferenceString dotGamePrefix = ".GamePrefix"; Jupiter::ReferenceString dotGamePrefix = ".GamePrefix";
Jupiter::String groupName = this->config.get("Default"_jrs); std::string groupName = this->config.get("Default"_jrs, ""s);
while (groupName.isNotEmpty()) while (!groupName.empty())
{ {
// Add group // Add group
groups.emplace_back(); groups.emplace_back();
@ -60,39 +65,39 @@ bool RenX_ModSystemPlugin::initialize() {
groupName += dotLockSteam; groupName += dotLockSteam;
group->lockSteam = this->config.get<bool>(groupName, m_lockSteam); group->lockSteam = this->config.get<bool>(groupName, m_lockSteam);
groupName.truncate(dotLockSteam.size()); groupName.erase(dotLockSteam.size());
groupName += dotLockIP; groupName += dotLockIP;
group->lockIP = this->config.get<bool>(groupName, m_lockIP); group->lockIP = this->config.get<bool>(groupName, m_lockIP);
groupName.truncate(dotLockIP.size()); groupName.erase(dotLockIP.size());
groupName += dotLockName; groupName += dotLockName;
group->lockName = this->config.get<bool>(groupName, m_lockName); group->lockName = this->config.get<bool>(groupName, m_lockName);
groupName.truncate(dotLockName.size()); groupName.erase(dotLockName.size());
groupName += dotKickLockMismatch; groupName += dotKickLockMismatch;
group->kickLockMismatch = this->config.get<bool>(groupName, m_kickLockMismatch); group->kickLockMismatch = this->config.get<bool>(groupName, m_kickLockMismatch);
groupName.truncate(dotKickLockMismatch.size()); groupName.erase(dotKickLockMismatch.size());
groupName += dotAutoAuthSteam; groupName += dotAutoAuthSteam;
group->autoAuthSteam = this->config.get<bool>(groupName, m_autoAuthSteam); group->autoAuthSteam = this->config.get<bool>(groupName, m_autoAuthSteam);
groupName.truncate(dotAutoAuthSteam.size()); groupName.erase(dotAutoAuthSteam.size());
groupName += dotAutoAuthIP; groupName += dotAutoAuthIP;
group->autoAuthIP = this->config.get<bool>(groupName, m_autoAuthIP); group->autoAuthIP = this->config.get<bool>(groupName, m_autoAuthIP);
groupName.truncate(dotAutoAuthIP.size()); groupName.erase(dotAutoAuthIP.size());
groupName += dotAccess; groupName += dotAccess;
group->access = this->config.get<int>(groupName); group->access = this->config.get<int>(groupName);
groupName.truncate(dotAccess.size()); groupName.erase(dotAccess.size());
groupName += dotPrefix; groupName += dotPrefix;
group->prefix = this->config.get(groupName); group->prefix = this->config.get(groupName);
groupName.truncate(dotPrefix.size()); groupName.erase(dotPrefix.size());
groupName += dotGamePrefix; groupName += dotGamePrefix;
group->gamePrefix = this->config.get(groupName); group->gamePrefix = this->config.get(groupName);
groupName.truncate(dotGamePrefix.size()); groupName.erase(dotGamePrefix.size());
// Next // Next
groupName += dotNext; groupName += dotNext;
@ -128,7 +133,7 @@ unsigned int RenX_ModSystemPlugin::logoutAllMods(RenX::Server &server) {
bool RenX_ModSystemPlugin::resetAccess(RenX::PlayerInfo &player) { bool RenX_ModSystemPlugin::resetAccess(RenX::PlayerInfo &player) {
int oAccess = player.access; int oAccess = player.access;
if (player.adminType.equals("administrator")) if (player.adminType == game_administrator_name)
{ {
ModGroup *group = getGroupByName(m_administratorGroup); ModGroup *group = getGroupByName(m_administratorGroup);
if (group == nullptr) if (group == nullptr)
@ -136,7 +141,7 @@ bool RenX_ModSystemPlugin::resetAccess(RenX::PlayerInfo &player) {
else else
player.access = group->access; player.access = group->access;
} }
else if (player.adminType.equals("moderator")) else if (player.adminType == game_moderator_name)
{ {
ModGroup *group = getGroupByName(m_moderatorGroup); ModGroup *group = getGroupByName(m_moderatorGroup);
if (group == nullptr) if (group == nullptr)
@ -162,9 +167,9 @@ int RenX_ModSystemPlugin::auth(RenX::Server &server, const RenX::PlayerInfo &pla
Jupiter::Config *section = this->config.getSection(player.uuid); Jupiter::Config *section = this->config.getSection(player.uuid);
if (section != nullptr) if (section != nullptr)
{ {
const Jupiter::ReadableString &groupName = section->get("Group"_jrs); std::string_view groupName = section->get("Group"_jrs);
if (groupName.isEmpty()) if (groupName.empty())
group = &RenX_ModSystemPlugin::groups.front(); group = &RenX_ModSystemPlugin::groups.front();
else else
{ {
@ -181,7 +186,7 @@ int RenX_ModSystemPlugin::auth(RenX::Server &server, const RenX::PlayerInfo &pla
player.access = section->get<int>("Access"_jrs, group->access); player.access = section->get<int>("Access"_jrs, group->access);
if (player.access != 0) if (player.access != 0)
{ {
server.sendMessage(player, Jupiter::StringS::Format("You are now authenticated with access level %d; group: %.*s.", player.access, group->name.size(), group->name.ptr())); server.sendMessage(player, Jupiter::StringS::Format("You are now authenticated with access level %d; group: %.*s.", player.access, group->name.size(), group->name.data()));
if (server.isDevBot() && player.access > 1) if (server.isDevBot() && player.access > 1)
{ {
if (server.getVersion() >= 4) if (server.getVersion() >= 4)
@ -191,7 +196,7 @@ int RenX_ModSystemPlugin::auth(RenX::Server &server, const RenX::PlayerInfo &pla
} }
} }
Jupiter::String playerName = RenX::getFormattedPlayerName(player); Jupiter::String playerName = RenX::getFormattedPlayerName(player);
server.sendLogChan(IRCCOLOR "03[Authentication] " IRCBOLD "%.*s" IRCBOLD IRCCOLOR " is now authenticated with access level %d; group: %.*s.", playerName.size(), playerName.ptr(), player.access, group->name.size(), group->name.ptr()); server.sendLogChan(IRCCOLOR "03[Authentication] " IRCBOLD "%.*s" IRCBOLD IRCCOLOR " is now authenticated with access level %d; group: %.*s.", playerName.size(), playerName.ptr(), player.access, group->name.size(), group->name.data());
return player.access; return player.access;
}; };
@ -205,13 +210,13 @@ int RenX_ModSystemPlugin::auth(RenX::Server &server, const RenX::PlayerInfo &pla
bool autoAuthSteam_l = section->get<bool>("AutoAuthSteam"_jrs, group->autoAuthSteam); bool autoAuthSteam_l = section->get<bool>("AutoAuthSteam"_jrs, group->autoAuthSteam);
bool autoAuthIP_l = section->get<bool>("AutoAuthIP"_jrs, group->autoAuthIP); bool autoAuthIP_l = section->get<bool>("AutoAuthIP"_jrs, group->autoAuthIP);
uint64_t steamid = section->get("SteamID"_jrs).asUnsignedLongLong(); uint64_t steamid = Jupiter::ReferenceString{section->get("SteamID"_jrs)}.asUnsignedLongLong();
const Jupiter::ReadableString &ip = section->get("LastIP"_jrs); std::string_view ip = section->get("LastIP"_jrs);
const Jupiter::ReadableString &name = section->get("Name"_jrs); std::string_view name = section->get("Name"_jrs);
if ((lockSteam_l == false || player.steamid == steamid) && (lockIP_l == false || player.ip.equalsi(ip)) && (lockName_l == false || player.name.equalsi(name))) if ((lockSteam_l == false || player.steamid == steamid) && (lockIP_l == false || player.ip == ip) && (lockName_l == false || jessilib::equalsi(player.name, name)))
{ {
if (checkAuto == false || (autoAuthSteam_l && player.steamid == steamid) || (autoAuthIP_l && player.ip.equalsi(ip))) if (checkAuto == false || (autoAuthSteam_l && player.steamid == steamid) || (autoAuthIP_l && player.ip == ip))
return sectionAuth(); return sectionAuth();
} }
else if (kickLockMismatch_l) else if (kickLockMismatch_l)
@ -239,28 +244,29 @@ void RenX_ModSystemPlugin::tempAuth(RenX::Server &server, const RenX::PlayerInfo
player.access = group->access; player.access = group->access;
if (notify) if (notify)
server.sendMessage(player, Jupiter::StringS::Format("You have been authorized into group \"%.*s\", with access level %u.", group->name.size(), group->name.ptr(), player.access)); server.sendMessage(player, Jupiter::StringS::Format("You have been authorized into group \"%.*s\", with access level %u.", group->name.size(), group->name.data(), player.access));
} }
bool RenX_ModSystemPlugin::set(RenX::PlayerInfo &player, ModGroup &group) { bool RenX_ModSystemPlugin::set(RenX::PlayerInfo &player, ModGroup &group) {
bool r = this->config[player.uuid].set("Group"_jrs, group.name); bool r = this->config[player.uuid].set("Group"_jrs, group.name);
this->config[player.uuid].set("SteamID"_jrs, Jupiter::StringS::Format("%llu", player.steamid)); this->config[player.uuid].set("SteamID"_jrs, static_cast<std::string>(Jupiter::StringS::Format("%llu", player.steamid)));
this->config[player.uuid].set("LastIP"_jrs, player.ip); this->config[player.uuid].set("LastIP"_jrs, static_cast<std::string>(player.ip));
this->config[player.uuid].set("Name"_jrs, player.name); this->config[player.uuid].set("Name"_jrs, player.name);
this->config.write(); this->config.write();
return r; return r;
} }
bool RenX_ModSystemPlugin::removeModSection(const Jupiter::ReadableString& section) { bool RenX_ModSystemPlugin::removeModSection(std::string_view section) {
return config.removeSection(section) && config.write(); return config.removeSection(section) && config.write();
} }
RenX_ModSystemPlugin::ModGroup *RenX_ModSystemPlugin::getGroupByName(const Jupiter::ReadableString &name, ModGroup *defaultGroup) const { RenX_ModSystemPlugin::ModGroup *RenX_ModSystemPlugin::getGroupByName(std::string_view name, ModGroup *defaultGroup) const {
if (RenX_ModSystemPlugin::groups.size() != 0) for (const auto& group : groups) {
for (auto node = this->groups.begin(); node != this->groups.end(); ++node) if (jessilib::equalsi(group.name, name)) {
if (node->name.equalsi(name)) return const_cast<ModGroup*>(&group);
return const_cast<ModGroup *>(&*node); }
}
return defaultGroup; return defaultGroup;
} }
@ -283,12 +289,13 @@ RenX_ModSystemPlugin::ModGroup *RenX_ModSystemPlugin::getGroupByIndex(size_t ind
return nullptr; return nullptr;
} }
int RenX_ModSystemPlugin::getConfigAccess(const Jupiter::ReadableString &uuid) const { int RenX_ModSystemPlugin::getConfigAccess(std::string_view uuid) const {
Jupiter::Config *section = this->config.getSection(uuid); Jupiter::Config *section = this->config.getSection(uuid);
if (section == nullptr) if (section == nullptr) {
return RenX_ModSystemPlugin::groups.front().access; return RenX_ModSystemPlugin::groups.front().access;
//for (auto node = this->groups.begin(); node != this->groups.end(); ++node) }
return section->get<int>("Access"_jrs, getGroupByName(section->get("Group"_jrs),const_cast<ModGroup *>(&groups.front()))->access); return section->get<int>("Access"_jrs, getGroupByName(section->get("Group"_jrs),const_cast<ModGroup *>(&groups.front()))->access);
} }
@ -324,9 +331,9 @@ RenX_ModSystemPlugin::~RenX_ModSystemPlugin() {
node->varData[RenX_ModSystemPlugin::name].remove("Group"_jrs); node->varData[RenX_ModSystemPlugin::name].remove("Group"_jrs);
node->gamePrefix.truncate(node->gamePrefix.size()); node->gamePrefix.truncate(node->gamePrefix.size());
node->formatNamePrefix.truncate(node->formatNamePrefix.size()); node->formatNamePrefix.truncate(node->formatNamePrefix.size());
if (node->adminType.equals("administrator")) if (node->adminType == game_administrator_name)
node->access = 2; node->access = 2;
else if (node->adminType.equals("moderator")) else if (node->adminType == game_moderator_name)
node->access = 1; node->access = 1;
else else
node->access = 0; node->access = 0;
@ -347,8 +354,8 @@ void RenX_ModSystemPlugin::RenX_OnPlayerDelete(RenX::Server &server, const RenX:
if (RenX_ModSystemPlugin::groups.size() != 0 && player.isBot == false && player.uuid.isNotEmpty()) { if (RenX_ModSystemPlugin::groups.size() != 0 && player.isBot == false && player.uuid.isNotEmpty()) {
Jupiter::Config *section = this->config.getSection(player.uuid); Jupiter::Config *section = this->config.getSection(player.uuid);
if (section != nullptr) { if (section != nullptr) {
section->set("SteamID"_jrs, Jupiter::StringS::Format("%llu", player.steamid)); section->set("SteamID"_jrs, static_cast<std::string>(Jupiter::StringS::Format("%llu", player.steamid)));
section->set("LastIP"_jrs, player.ip); section->set("LastIP"_jrs, static_cast<std::string>(player.ip));
section->set("Name"_jrs, player.name); section->set("Name"_jrs, player.name);
} }
} }
@ -362,9 +369,9 @@ void RenX_ModSystemPlugin::RenX_OnIDChange(RenX::Server &server, const RenX::Pla
void RenX_ModSystemPlugin::RenX_OnAdminLogin(RenX::Server &server, const RenX::PlayerInfo &player) { void RenX_ModSystemPlugin::RenX_OnAdminLogin(RenX::Server &server, const RenX::PlayerInfo &player) {
ModGroup *group = nullptr; ModGroup *group = nullptr;
if (player.adminType.equals("administrator")) if (player.adminType == game_administrator_name)
group = getGroupByName(m_administratorGroup); group = getGroupByName(m_administratorGroup);
else if (player.adminType.equals("moderator")) else if (player.adminType == game_moderator_name)
group = getGroupByName(m_moderatorGroup); group = getGroupByName(m_moderatorGroup);
if (group != nullptr && player.access < group->access) if (group != nullptr && player.access < group->access)
@ -378,12 +385,12 @@ void RenX_ModSystemPlugin::RenX_OnAdminGrant(RenX::Server &server, const RenX::P
void RenX_ModSystemPlugin::RenX_OnAdminLogout(RenX::Server &server, const RenX::PlayerInfo &player) { void RenX_ModSystemPlugin::RenX_OnAdminLogout(RenX::Server &server, const RenX::PlayerInfo &player) {
ModGroup *group = nullptr; ModGroup *group = nullptr;
int access = RenX_ModSystemPlugin::groups.size() == 0 ? 0 : RenX_ModSystemPlugin::groups.front().access; int access = RenX_ModSystemPlugin::groups.size() == 0 ? 0 : RenX_ModSystemPlugin::groups.front().access;
if (player.adminType.equals("administrator")) if (player.adminType == game_administrator_name)
{ {
access = 2; access = 2;
group = getGroupByName(m_administratorGroup); group = getGroupByName(m_administratorGroup);
} }
else if (player.adminType.equals("moderator")) else if (player.adminType == game_moderator_name)
{ {
access = 1; access = 1;
group = getGroupByName(m_moderatorGroup); group = getGroupByName(m_moderatorGroup);
@ -455,7 +462,7 @@ void AuthIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &cha
RenX_ModSystemPlugin::ModGroup *defaultGroup = pluginInstance.getDefaultGroup(); RenX_ModSystemPlugin::ModGroup *defaultGroup = pluginInstance.getDefaultGroup();
if (pluginInstance.auth(*server, *player) == -1) if (pluginInstance.auth(*server, *player) == -1)
source->sendNotice(nick, "Error: Player failed to pass strict lock checks. Player kicked."_jrs); source->sendNotice(nick, "Error: Player failed to pass strict lock checks. Player kicked."_jrs);
else if (defaultGroup->name.equals(player->varData[pluginInstance.getName()].get("Group"_jrs))) else if (defaultGroup->name == player->varData[pluginInstance.getName()].get("Group"_jrs))
source->sendNotice(nick, "Error: Failed to authenticate player."_jrs); source->sendNotice(nick, "Error: Failed to authenticate player."_jrs);
else else
source->sendNotice(nick, "Player authenticated successfully."_jrs); source->sendNotice(nick, "Player authenticated successfully."_jrs);
@ -681,9 +688,9 @@ void AddIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &chan
{ {
pluginInstance.resetAccess(*player); pluginInstance.resetAccess(*player);
if (pluginInstance.set(*player, *group)) if (pluginInstance.set(*player, *group))
source->sendNotice(nick, Jupiter::StringS::Format("%.*s has been added to group \"%.*s\"", player->name.size(), player->name.ptr(), group->name.size(), group->name.ptr())); source->sendNotice(nick, Jupiter::StringS::Format("%.*s has been added to group \"%.*s\"", player->name.size(), player->name.data(), group->name.size(), group->name.data()));
else else
source->sendNotice(nick, Jupiter::StringS::Format("%.*s has been moved to group \"%.*s\"", player->name.size(), player->name.ptr(), group->name.size(), group->name.ptr())); source->sendNotice(nick, Jupiter::StringS::Format("%.*s has been moved to group \"%.*s\"", player->name.size(), player->name.data(), group->name.size(), group->name.data()));
pluginInstance.auth(*server, *player, false, true); pluginInstance.auth(*server, *player, false, true);
} }
} }
@ -716,6 +723,7 @@ void DelIRCCommand::create()
void DelIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString &parameters) void DelIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString &parameters)
{ {
std::string_view parameters_view = parameters;
if (parameters.isEmpty()) if (parameters.isEmpty())
source->sendNotice(nick, "Error: Too few parameters. Syntax: del <player>"_jrs); source->sendNotice(nick, "Error: Too few parameters. Syntax: del <player>"_jrs);
else else
@ -742,7 +750,7 @@ void DelIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &chan
{ {
for (auto& section : pluginInstance.getConfig().getSections()) for (auto& section : pluginInstance.getConfig().getSections())
{ {
if (section.second.get("Name"_jrs).equalsi(parameters)) { if (jessilib::equalsi(section.second.get("Name"_jrs), parameters_view)) {
if (pluginInstance.removeModSection(section.first)) if (pluginInstance.removeModSection(section.first))
source->sendNotice(nick, "Player has been removed from the moderator list."_jrs); source->sendNotice(nick, "Player has been removed from the moderator list."_jrs);
else else
@ -822,7 +830,7 @@ void ForceAuthIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString
{ {
RenX_ModSystemPlugin::ModGroup *defaultGroup = pluginInstance.getDefaultGroup(); RenX_ModSystemPlugin::ModGroup *defaultGroup = pluginInstance.getDefaultGroup();
pluginInstance.auth(*server, *player, false, true); pluginInstance.auth(*server, *player, false, true);
if (defaultGroup->name.equals(player->varData[pluginInstance.getName()].get("Group"_jrs))) if (defaultGroup->name == player->varData[pluginInstance.getName()].get("Group"_jrs))
source->sendNotice(nick, "Error: Failed to authenticate player."_jrs); source->sendNotice(nick, "Error: Failed to authenticate player."_jrs);
else else
source->sendNotice(nick, "Player authenticated successfully."_jrs); source->sendNotice(nick, "Player authenticated successfully."_jrs);
@ -867,8 +875,7 @@ void ModListIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &
msgBaseSize = msg.size(); msgBaseSize = msg.size();
for (auto& section : pluginInstance.getConfig().getSections()) { for (auto& section : pluginInstance.getConfig().getSections()) {
if (section.second.get("Group"_jrs).equalsi(node->name)) if (jessilib::equalsi(section.second.get("Group"_jrs), node->name)) {
{
msg += section.second.get("Name"_jrs, section.second.getName()); msg += section.second.get("Name"_jrs, section.second.getName());
msg += ", "_jrs; msg += ", "_jrs;
} }
@ -926,7 +933,7 @@ void AuthGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, co
RenX_ModSystemPlugin::ModGroup *defaultGroup = pluginInstance.getDefaultGroup(); RenX_ModSystemPlugin::ModGroup *defaultGroup = pluginInstance.getDefaultGroup();
if (pluginInstance.auth(*source, *player) == -1) if (pluginInstance.auth(*source, *player) == -1)
source->sendMessage(*player, "Error: Player failed to pass strict lock checks. Player kicked."_jrs); source->sendMessage(*player, "Error: Player failed to pass strict lock checks. Player kicked."_jrs);
else if (defaultGroup->name.equals(player->varData[pluginInstance.getName()].get("Group"_jrs))) else if (defaultGroup->name == player->varData[pluginInstance.getName()].get("Group"_jrs))
source->sendMessage(*player, "Error: Failed to authenticate player."_jrs); source->sendMessage(*player, "Error: Failed to authenticate player."_jrs);
else else
source->sendMessage(*player, "Player authenticated successfully."_jrs); source->sendMessage(*player, "Player authenticated successfully."_jrs);
@ -1041,7 +1048,7 @@ void ForceAuthGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *playe
{ {
RenX_ModSystemPlugin::ModGroup *defaultGroup = pluginInstance.getDefaultGroup(); RenX_ModSystemPlugin::ModGroup *defaultGroup = pluginInstance.getDefaultGroup();
pluginInstance.auth(*source, *player, false, true); pluginInstance.auth(*source, *player, false, true);
if (defaultGroup->name.equals(player->varData[pluginInstance.getName()].get("Group"_jrs))) if (defaultGroup->name == player->varData[pluginInstance.getName()].get("Group"_jrs))
source->sendMessage(*player, "Error: Failed to authenticate player."_jrs); source->sendMessage(*player, "Error: Failed to authenticate player."_jrs);
else else
source->sendMessage(*player, "Player authenticated successfully."_jrs); source->sendMessage(*player, "Player authenticated successfully."_jrs);

18
src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.h

@ -39,9 +39,9 @@ public:
bool autoAuthSteam; bool autoAuthSteam;
bool autoAuthIP; bool autoAuthIP;
int access; int access;
Jupiter::StringS prefix; std::string prefix;
Jupiter::StringS gamePrefix; std::string gamePrefix;
Jupiter::StringS name; std::string name;
}; };
std::list<ModGroup> groups; std::list<ModGroup> groups;
@ -76,11 +76,11 @@ public:
void tempAuth(RenX::Server &server, const RenX::PlayerInfo &player, const ModGroup *group, bool notify = true) const; void tempAuth(RenX::Server &server, const RenX::PlayerInfo &player, const ModGroup *group, bool notify = true) const;
bool set(RenX::PlayerInfo &player, ModGroup &group); bool set(RenX::PlayerInfo &player, ModGroup &group);
bool removeModSection(const Jupiter::ReadableString& section); bool removeModSection(std::string_view section);
int getConfigAccess(const Jupiter::ReadableString &uuid) const; int getConfigAccess(std::string_view uuid) const;
size_t getGroupCount() const; size_t getGroupCount() const;
ModGroup *getGroupByName(const Jupiter::ReadableString &name, ModGroup *defaultGroup = nullptr) const; ModGroup *getGroupByName(std::string_view name, ModGroup *defaultGroup = nullptr) const;
ModGroup *getGroupByAccess(int access, ModGroup *defaultGroup = nullptr) const; ModGroup *getGroupByAccess(int access, ModGroup *defaultGroup = nullptr) const;
ModGroup *getGroupByIndex(size_t index) const; ModGroup *getGroupByIndex(size_t index) const;
ModGroup *getDefaultGroup() const; ModGroup *getDefaultGroup() const;
@ -111,9 +111,9 @@ private:
bool m_kickLockMismatch; bool m_kickLockMismatch;
bool m_autoAuthSteam; bool m_autoAuthSteam;
bool m_autoAuthIP; bool m_autoAuthIP;
Jupiter::StringS m_atmDefault; std::string m_atmDefault;
Jupiter::StringS m_moderatorGroup; std::string m_moderatorGroup;
Jupiter::StringS m_administratorGroup; std::string m_administratorGroup;
}; };
GENERIC_IRC_COMMAND(AuthIRCCommand) GENERIC_IRC_COMMAND(AuthIRCCommand)

4
src/Plugins/RenX/RenX.Relay/RenX_Relay.cpp

@ -638,12 +638,12 @@ void RenX_RelayPlugin::upstream_connected(RenX::Server& in_server, upstream_serv
in_server_info.m_last_activity = in_server_info.m_last_connect_attempt; in_server_info.m_last_activity = in_server_info.m_last_connect_attempt;
// New format: 004 | Game Version Number | Game Version // New format: 004 | Game Version Number | Game Version
auto& version_str = in_server.getGameVersion(); const auto& version_str = in_server.getGameVersion();
std::string version_message = "v004"; std::string version_message = "v004";
version_message += RenX::DelimC; version_message += RenX::DelimC;
version_message += std::to_string(in_server.getGameVersionNumber()); version_message += std::to_string(in_server.getGameVersionNumber());
version_message += RenX::DelimC; version_message += RenX::DelimC;
version_message.append(version_str.ptr(), version_str.size()); version_message.append(version_str.data(), version_str.size());
version_message += '\n'; version_message += '\n';
// Tack on username auth // Tack on username auth

18
src/Plugins/RenX/RenX.ServerList/RenX_ServerList.cpp

@ -36,8 +36,8 @@ const Jupiter::ReferenceString server_list_game_header = "<html><body>"_jrs;
const Jupiter::ReferenceString server_list_game_footer = "\n</body></html>"_jrs; const Jupiter::ReferenceString server_list_game_footer = "\n</body></html>"_jrs;
// TODO: can probably replace with some of the jessilib stuff // TODO: can probably replace with some of the jessilib stuff
Jupiter::String jsonify(const Jupiter::ReadableString &in_str) { Jupiter::String jsonify(std::string_view in_str) {
const unsigned char *ptr = reinterpret_cast<const unsigned char *>(in_str.ptr()); const unsigned char *ptr = reinterpret_cast<const unsigned char *>(in_str.data());
const unsigned char *end_ptr = ptr + in_str.size(); const unsigned char *end_ptr = ptr + in_str.size();
Jupiter::String result(in_str.size()); Jupiter::String result(in_str.size());
@ -233,8 +233,8 @@ Jupiter::StringS RenX_ServerListPlugin::server_as_json(const RenX::Server &serve
return server_json_block; return server_json_block;
} }
Jupiter::StringS RenX_ServerListPlugin::server_as_server_details_json(const RenX::Server& server) { std::string RenX_ServerListPlugin::server_as_server_details_json(const RenX::Server& server) {
Jupiter::StringS server_json_block; std::string server_json_block;
server_json_block = '{'; server_json_block = '{';
@ -290,7 +290,7 @@ Jupiter::StringS RenX_ServerListPlugin::server_as_server_details_json(const RenX
server_json_block += "\", \"isBot\":"_jrs; server_json_block += "\", \"isBot\":"_jrs;
server_json_block += json_bool_as_cstring(node->isBot); server_json_block += json_bool_as_cstring(node->isBot);
server_json_block += ", \"Team\":"_jrs; server_json_block += ", \"Team\":"_jrs;
server_json_block.aformat("%d", static_cast<int>(node->team)); server_json_block += std::to_string(static_cast<int>(node->team));
server_json_block += "}"_jrs; server_json_block += "}"_jrs;
++node; ++node;
@ -302,7 +302,7 @@ Jupiter::StringS RenX_ServerListPlugin::server_as_server_details_json(const RenX
server_json_block += "\", \"isBot\":"_jrs; server_json_block += "\", \"isBot\":"_jrs;
server_json_block += json_bool_as_cstring(node->isBot); server_json_block += json_bool_as_cstring(node->isBot);
server_json_block += ", \"Team\":"_jrs; server_json_block += ", \"Team\":"_jrs;
server_json_block.aformat("%d", static_cast<int>(node->team)); server_json_block += std::to_string(static_cast<int>(node->team));
server_json_block += "}"_jrs; server_json_block += "}"_jrs;
++node; ++node;
@ -539,13 +539,13 @@ void RenX_ServerListPlugin::markDetailsStale(RenX::Server& in_server) {
void RenX_ServerListPlugin::touchDetails(RenX::Server& in_server) { void RenX_ServerListPlugin::touchDetails(RenX::Server& in_server) {
auto& server_varData = in_server.varData[this->name]; auto& server_varData = in_server.varData[this->name];
if (server_varData.get("j"_jrs).isEmpty()) { if (server_varData.get("j"_jrs).empty()) {
auto server_json_block = server_as_server_details_json(in_server); auto server_json_block = server_as_server_details_json(in_server);
server_varData.set("j"_jrs, server_json_block); server_varData.set("j"_jrs, server_json_block);
} }
} }
Jupiter::ReferenceString RenX_ServerListPlugin::getListServerAddress(const RenX::Server& server) { std::string_view RenX_ServerListPlugin::getListServerAddress(const RenX::Server& server) {
Jupiter::ReferenceString serverHostname; Jupiter::ReferenceString serverHostname;
serverHostname = server.getSocketHostname(); serverHostname = server.getSocketHostname();
@ -682,7 +682,7 @@ Jupiter::ReadableString *handle_server_page(std::string_view query_string) {
return new Jupiter::ReferenceString(); return new Jupiter::ReferenceString();
server = servers[index]; server = servers[index];
if (address.equals(pluginInstance.getListServerAddress(*server)) && server->getPort() == port) if (address == pluginInstance.getListServerAddress(*server) && server->getPort() == port)
break; break;
++index; ++index;

4
src/Plugins/RenX/RenX.ServerList/RenX_ServerList.h

@ -44,10 +44,10 @@ public: // RenX_ServerListPlugin
void updateMetadata(); void updateMetadata();
void markDetailsStale(RenX::Server& in_server); void markDetailsStale(RenX::Server& in_server);
void touchDetails(RenX::Server& in_server); void touchDetails(RenX::Server& in_server);
Jupiter::ReferenceString getListServerAddress(const RenX::Server& server); std::string_view getListServerAddress(const RenX::Server& server);
ListServerInfo getListServerInfo(const RenX::Server& server); ListServerInfo getListServerInfo(const RenX::Server& server);
Jupiter::StringS server_as_json(const RenX::Server &server); Jupiter::StringS server_as_json(const RenX::Server &server);
Jupiter::StringS server_as_server_details_json(const RenX::Server& server); std::string server_as_server_details_json(const RenX::Server& server);
Jupiter::StringS server_as_long_json(const RenX::Server &server); Jupiter::StringS server_as_long_json(const RenX::Server &server);
virtual bool initialize() override; virtual bool initialize() override;

24
src/Plugins/RenX/RenX.SetJoin/RenX_SetJoin.cpp

@ -27,9 +27,9 @@ void RenX_SetJoinPlugin::RenX_OnJoin(RenX::Server &server, const RenX::PlayerInf
{ {
if (player.uuid.isNotEmpty() && server.isMatchInProgress()) if (player.uuid.isNotEmpty() && server.isMatchInProgress())
{ {
const Jupiter::ReadableString &setjoin = RenX_SetJoinPlugin::setjoin_file.get(player.uuid); std::string_view setjoin = RenX_SetJoinPlugin::setjoin_file.get(player.uuid);
if (setjoin.isNotEmpty()) if (!setjoin.empty())
server.sendMessage(Jupiter::StringS::Format("[%.*s] %.*s", player.name.size(), player.name.ptr(), setjoin.size(), setjoin.ptr())); server.sendMessage(Jupiter::StringS::Format("[%.*s] %.*s", player.name.size(), player.name.data(), setjoin.size(), setjoin.data()));
} }
} }
@ -48,10 +48,10 @@ void ViewJoinGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player
{ {
if (player->uuid.isNotEmpty()) if (player->uuid.isNotEmpty())
{ {
const Jupiter::ReadableString &setjoin = pluginInstance.setjoin_file.get(player->uuid); std::string_view setjoin = pluginInstance.setjoin_file.get(player->uuid);
if (setjoin.isNotEmpty()) if (!setjoin.empty())
source->sendMessage(*player, Jupiter::StringS::Format("[%.*s] %.*s", player->name.size(), player->name.ptr(), setjoin.size(), setjoin.ptr())); source->sendMessage(*player, Jupiter::StringS::Format("[%.*s] %.*s", player->name.size(), player->name.data(), setjoin.size(), setjoin.data()));
else else
source->sendMessage(*player, "Error: No setjoin found."_jrs); source->sendMessage(*player, "Error: No setjoin found."_jrs);
} }
@ -79,10 +79,10 @@ void ShowJoinGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player
{ {
if (player->uuid.isNotEmpty()) if (player->uuid.isNotEmpty())
{ {
const Jupiter::ReadableString &setjoin = pluginInstance.setjoin_file.get(player->uuid); std::string_view setjoin = pluginInstance.setjoin_file.get(player->uuid);
if (setjoin.isNotEmpty()) if (!setjoin.empty())
source->sendMessage(Jupiter::StringS::Format("[%.*s] %.*s", player->name.size(), player->name.ptr(), setjoin.size(), setjoin.ptr())); source->sendMessage(Jupiter::StringS::Format("[%.*s] %.*s", player->name.size(), player->name.data(), setjoin.size(), setjoin.data()));
else else
source->sendMessage(*player, "Error: No setjoin found."_jrs); source->sendMessage(*player, "Error: No setjoin found."_jrs);
} }
@ -113,7 +113,7 @@ void DelJoinGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player,
if (player->uuid.isNotEmpty()) if (player->uuid.isNotEmpty())
{ {
if (pluginInstance.setjoin_file.remove(player->uuid)) if (pluginInstance.setjoin_file.remove(player->uuid))
source->sendMessage(*player, Jupiter::StringS::Format("%.*s, your join message has been removed.", player->name.size(), player->name.ptr())); source->sendMessage(*player, Jupiter::StringS::Format("%.*s, your join message has been removed.", player->name.size(), player->name.data()));
else else
source->sendMessage(*player, "Error: Setjoin not found."_jrs); source->sendMessage(*player, "Error: Setjoin not found."_jrs);
} }
@ -143,9 +143,9 @@ void SetJoinGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player,
{ {
if (parameters.isNotEmpty()) if (parameters.isNotEmpty())
{ {
pluginInstance.setjoin_file.set(player->uuid, parameters); pluginInstance.setjoin_file.set(player->uuid, static_cast<std::string>(parameters));
pluginInstance.setjoin_file.write(); pluginInstance.setjoin_file.write();
source->sendMessage(*player, Jupiter::StringS::Format("%.*s, your join message is now: %.*s", player->name.size(), player->name.ptr(), parameters.size(), parameters.ptr())); source->sendMessage(*player, Jupiter::StringS::Format("%.*s, your join message is now: %.*s", player->name.size(), player->name.data(), parameters.size(), parameters.ptr()));
} }
else DelJoinGameCommand_instance.trigger(source, player, parameters); else DelJoinGameCommand_instance.trigger(source, player, parameters);
} }

29
src/Plugins/RenX/RenX.Warn/RenX_Warn.cpp

@ -77,18 +77,18 @@ void WarnIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &cha
switch (pluginInstance.m_warnAction) { switch (pluginInstance.m_warnAction) {
case -1: case -1:
server->kickPlayer(*player, Jupiter::StringS::Format("Warning limit reached (%d warnings)", warns)); server->kickPlayer(*player, Jupiter::StringS::Format("Warning limit reached (%d warnings)", warns));
source->sendNotice(nick, Jupiter::StringS::Format("%.*s has been kicked from the server for exceeding the warning limit (%d warnings).", player->name.size(), player->name.ptr(), warns)); source->sendNotice(nick, Jupiter::StringS::Format("%.*s has been kicked from the server for exceeding the warning limit (%d warnings).", player->name.size(), player->name.data(), warns));
break; break;
default: default:
server->banPlayer(*player, "Jupiter Bot/RenX.Warn"_jrs, Jupiter::StringS::Format("Warning limit reached (%d warnings)", warns), std::chrono::seconds(pluginInstance.m_warnAction)); server->banPlayer(*player, "Jupiter Bot/RenX.Warn"_jrs, Jupiter::StringS::Format("Warning limit reached (%d warnings)", warns), std::chrono::seconds(pluginInstance.m_warnAction));
source->sendNotice(nick, Jupiter::StringS::Format("%.*s has been banned from the server for exceeding the warning limit (%d warnings).", player->name.size(), player->name.ptr(), reason.size(), reason.ptr(), warns)); source->sendNotice(nick, Jupiter::StringS::Format("%.*s has been banned from the server for exceeding the warning limit (%d warnings).", player->name.size(), player->name.data(), reason.size(), reason.ptr(), warns));
break; break;
} }
} }
else { else {
player->varData[pluginInstance.getName()].set(WARNS_KEY, Jupiter::StringS::Format("%d", warns)); player->varData[pluginInstance.getName()].set(WARNS_KEY, std::to_string(warns));
server->sendWarnMessage(*player, Jupiter::StringS::Format("You have been warned by %.*s@IRC for: %.*s. You have %d warnings.", nick.size(), nick.ptr(), reason.size(), reason.ptr(), warns)); server->sendWarnMessage(*player, Jupiter::StringS::Format("You have been warned by %.*s@IRC for: %.*s. You have %d warnings.", nick.size(), nick.ptr(), reason.size(), reason.ptr(), warns));
source->sendNotice(nick, Jupiter::StringS::Format("%.*s has been warned; they now have %d warnings.", player->name.size(), player->name.ptr(), warns)); source->sendNotice(nick, Jupiter::StringS::Format("%.*s has been warned; they now have %d warnings.", player->name.size(), player->name.data(), warns));
} }
} }
} }
@ -136,7 +136,7 @@ void PardonIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &c
if (player != nullptr) { if (player != nullptr) {
player->varData[pluginInstance.getName()].remove(WARNS_KEY); player->varData[pluginInstance.getName()].remove(WARNS_KEY);
server->sendMessage(*player, Jupiter::StringS::Format("You have been pardoned by %.*s@IRC; your warnings have been reset.", nick.size(), nick.ptr())); server->sendMessage(*player, Jupiter::StringS::Format("You have been pardoned by %.*s@IRC; your warnings have been reset.", nick.size(), nick.ptr()));
source->sendNotice(nick, Jupiter::StringS::Format("%.*s has been pardoned; their warnings have been reset.", player->name.size(), player->name.ptr())); source->sendNotice(nick, Jupiter::StringS::Format("%.*s has been pardoned; their warnings have been reset.", player->name.size(), player->name.data()));
} }
} }
} }
@ -169,18 +169,18 @@ void WarnGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, co
{ {
case -1: case -1:
source->kickPlayer(*target, Jupiter::StringS::Format("Warning limit reached (%d warnings)", warns)); source->kickPlayer(*target, Jupiter::StringS::Format("Warning limit reached (%d warnings)", warns));
source->sendMessage(*player, Jupiter::StringS::Format("%.*s has been kicked from the server for exceeding the warning limit (%d warnings).", target->name.size(), target->name.ptr(), warns)); source->sendMessage(*player, Jupiter::StringS::Format("%.*s has been kicked from the server for exceeding the warning limit (%d warnings).", target->name.size(), target->name.data(), warns));
break; break;
default: default:
source->banPlayer(*target, "Jupiter Bot/RenX.Warn"_jrs, Jupiter::StringS::Format("Warning limit reached (%d warnings)", warns), std::chrono::seconds(pluginInstance.m_warnAction)); source->banPlayer(*target, "Jupiter Bot/RenX.Warn"_jrs, Jupiter::StringS::Format("Warning limit reached (%d warnings)", warns), std::chrono::seconds(pluginInstance.m_warnAction));
source->sendMessage(*player, Jupiter::StringS::Format("%.*s has been banned from the server for exceeding the warning limit (%d warnings).", target->name.size(), target->name.ptr(), warns)); source->sendMessage(*player, Jupiter::StringS::Format("%.*s has been banned from the server for exceeding the warning limit (%d warnings).", target->name.size(), target->name.data(), warns));
break; break;
} }
} }
else { else {
target->varData[pluginInstance.getName()].set(WARNS_KEY, Jupiter::StringS::Format("%d", warns)); target->varData[pluginInstance.getName()].set(WARNS_KEY, std::to_string(warns));
source->sendWarnMessage(*target, Jupiter::StringS::Format("You have been warned by %.*s for: %.*s. You have %d warnings.", player->name.size(), player->name.ptr(), reason.size(), reason.ptr(), warns)); source->sendWarnMessage(*target, Jupiter::StringS::Format("You have been warned by %.*s for: %.*s. You have %d warnings.", player->name.size(), player->name.data(), reason.size(), reason.ptr(), warns));
source->sendMessage(*player, Jupiter::StringS::Format("%.*s has been warned; they now have %d warnings.", target->name.size(), target->name.ptr(), warns)); source->sendMessage(*player, Jupiter::StringS::Format("%.*s has been warned; they now have %d warnings.", target->name.size(), target->name.data(), warns));
} }
} }
} }
@ -209,12 +209,13 @@ void PardonGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player,
RenX::PlayerInfo *target = source->getPlayerByPartName(parameters); RenX::PlayerInfo *target = source->getPlayerByPartName(parameters);
if (target != nullptr) { if (target != nullptr) {
target->varData[pluginInstance.getName()].remove(WARNS_KEY); target->varData[pluginInstance.getName()].remove(WARNS_KEY);
source->sendMessage(*target, Jupiter::StringS::Format("You have been pardoned by %.*s@IRC; your warnings have been reset.", player->name.size(), player->name.ptr())); source->sendMessage(*target, Jupiter::StringS::Format("You have been pardoned by %.*s@IRC; your warnings have been reset.", player->name.size(), player->name.data()));
source->sendMessage(*player, Jupiter::StringS::Format("%.*s has been pardoned; their warnings have been reset.", target->name.size(), target->name.ptr())); source->sendMessage(*player, Jupiter::StringS::Format("%.*s has been pardoned; their warnings have been reset.", target->name.size(), target->name.data()));
} }
} }
else else {
this->trigger(source, player, player->name); this->trigger(source, player, Jupiter::ReferenceString{player->name});
}
} }
const Jupiter::ReadableString &PardonGameCommand::getHelp(const Jupiter::ReadableString &) { const Jupiter::ReadableString &PardonGameCommand::getHelp(const Jupiter::ReadableString &) {

21
src/Plugins/SetJoin/SetJoin.cpp

@ -25,14 +25,11 @@ using namespace Jupiter::literals;
void SetJoinPlugin::OnJoin(Jupiter::IRC::Client *server, const Jupiter::ReadableString &chan, const Jupiter::ReadableString &nick) void SetJoinPlugin::OnJoin(Jupiter::IRC::Client *server, const Jupiter::ReadableString &chan, const Jupiter::ReadableString &nick)
{ {
const Jupiter::ReadableString &setjoin = this->config[server->getConfigSection()].get(nick); std::string_view setjoin = this->config[server->getConfigSection()].get(nick);
if (setjoin.isNotEmpty()) if (setjoin.empty())
{ server->sendNotice(nick, "No setjoin has been set for you. To set one, use the !setjoin command"_jrs);
if (setjoin == nullptr) else
server->sendNotice(nick, "No setjoin has been set for you. To set one, use the !setjoin command"_jrs); server->sendMessage(chan, Jupiter::StringS::Format(IRCBOLD IRCCOLOR "07[%.*s]" IRCCOLOR IRCBOLD ": %.*s", nick.size(), nick.ptr(), setjoin.size(), setjoin.data()));
else
server->sendMessage(chan, Jupiter::StringS::Format(IRCBOLD IRCCOLOR "07[%.*s]" IRCCOLOR IRCBOLD ": %.*s", nick.size(), nick.ptr(), setjoin.size(), setjoin.ptr()));
}
} }
SetJoinPlugin pluginInstance; SetJoinPlugin pluginInstance;
@ -48,7 +45,7 @@ void SetJoinIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &
{ {
if (parameters.isNotEmpty()) if (parameters.isNotEmpty())
{ {
pluginInstance.setjoin_file[source->getConfigSection()].set(nick, parameters); pluginInstance.setjoin_file[source->getConfigSection()].set(nick, static_cast<std::string>(parameters));
pluginInstance.setjoin_file.write(); pluginInstance.setjoin_file.write();
source->sendMessage(channel, "Your join message has been set."_jrs); source->sendMessage(channel, "Your join message has been set."_jrs);
} }
@ -74,12 +71,12 @@ void ViewJoinIRCCommand::create()
void ViewJoinIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString &parameters) void ViewJoinIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString &parameters)
{ {
const Jupiter::ReadableString &target = parameters.isEmpty() ? nick : parameters; const Jupiter::ReadableString &target = parameters.isEmpty() ? nick : parameters;
const Jupiter::ReadableString &r = pluginInstance.setjoin_file[source->getConfigSection()].get(target); std::string_view setjoin = pluginInstance.setjoin_file[source->getConfigSection()].get(target);
if (r.isEmpty()) if (setjoin.empty())
source->sendMessage(channel, Jupiter::StringS::Format("No setjoin has been set for \"%.*s\".", target.size(), target.ptr())); source->sendMessage(channel, Jupiter::StringS::Format("No setjoin has been set for \"%.*s\".", target.size(), target.ptr()));
else else
source->sendMessage(channel, Jupiter::StringS::Format(IRCBOLD IRCCOLOR "07[%.*s]" IRCCOLOR IRCBOLD ": %.*s", target.size(), target.ptr(), r.size(), r.ptr())); source->sendMessage(channel, Jupiter::StringS::Format(IRCBOLD IRCCOLOR "07[%.*s]" IRCCOLOR IRCBOLD ": %.*s", target.size(), target.ptr(), setjoin.size(), setjoin.data()));
} }
const Jupiter::ReadableString &ViewJoinIRCCommand::getHelp(const Jupiter::ReadableString &) const Jupiter::ReadableString &ViewJoinIRCCommand::getHelp(const Jupiter::ReadableString &)

Loading…
Cancel
Save