From 016f71d2c53e72b50ee7b99c83e990d255a4e57a Mon Sep 17 00:00:00 2001 From: Jessica James Date: Fri, 18 Nov 2016 17:41:16 -0500 Subject: [PATCH] RenX.Core: RenX_OnPlayerIdentify event RenX.Logging: Added log for RenX_OnPlayerIdentify; disabled some logs by default. MakeRelease.bat: Now copies LICENSE and all files in "Configs/" --- Configs/RenX.Logging.ini | 7 ++++--- LICENSE | 2 +- MakeRelease.bat | 6 +++--- RenX.Core/RenX_GameCommand.cpp | 3 +++ RenX.Core/RenX_GameCommand.h | 5 +++++ RenX.Core/RenX_Plugin.cpp | 5 +++++ RenX.Core/RenX_Plugin.h | 1 + RenX.Core/RenX_Server.cpp | 16 ++++++++++++++++ RenX.Logging/RenX_Logging.cpp | 27 ++++++++++++++++++++++++--- RenX.Logging/RenX_Logging.h | 5 ++++- 10 files changed, 66 insertions(+), 11 deletions(-) diff --git a/Configs/RenX.Logging.ini b/Configs/RenX.Logging.ini index ff5174f..cb89ff6 100644 --- a/Configs/RenX.Logging.ini +++ b/Configs/RenX.Logging.ini @@ -100,9 +100,10 @@ MuteOwnExecute=true ; ;PlayerRDNSFormat=05[RDNS] {NAME}'s hostname is {RDNS} +;PlayerIdentifyFormat=12[Join] {NAME} ({STEAM}) joined the game fighting for the {TEAML} from {IP} ({RDNS}) with HWID {HWID} ;JoinPublicFormat=12[Join] {NAME} joined the game fighting for the {TEAML}! -;JoinAdminFormat=12[Join] {NAME} joined the game fighting for the {TEAML} from {IP} using Steam ID {STEAM}. HWID: "{HWID}" -;JoinNoSteamAdminFormat=12[Join] {NAME} joined the game fighting for the {TEAML} from {IP}, but is not using Steam. HWID: "{HWID}" +;JoinAdminFormat=12[Join] {NAME} joined the game fighting for the {TEAML} from {IP} using Steam ID {STEAM}." +;JoinNoSteamAdminFormat=12[Join] {NAME} joined the game fighting for the {TEAML} from {IP}, but is not using Steam." ;PartFormat=12[Part] {NAME} left the {TEAML}. ;KickFormat=04[Kick] {NAME} was 04kicked (04{MESSAGE}) ;PlayerExecuteFormat={NAME}07 executed: {MESSAGE} @@ -170,7 +171,7 @@ MuteOwnExecute=true ;GameOverTieFormat=03[Game]10 The battle ended in a {MESSAGE} ;GameOverScoreFormat=03[Game]{TCOLOR} {TEAML}: {WINSCORE} | {VTCOLOR}{VTEAML}: {LOSESCORE} ;GameFormat=03[Game] {MESSAGE} -; ExecuteFormat=07{NAME} executed: {MESSAGE} +;ExecuteFormat=07{NAME} executed: {MESSAGE} ExecuteFormat= ;DevBotExecuteFormat= ;SubscribeFormat=03{NAME} subscribed to the RCON data stream. diff --git a/LICENSE b/LICENSE index 731794c..cb7c05a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (C) 2013-2015 Jessica James. +Copyright (C) 2013-2016 Jessica James. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/MakeRelease.bat b/MakeRelease.bat index 7a59fa6..a9a92b2 100644 --- a/MakeRelease.bat +++ b/MakeRelease.bat @@ -1,5 +1,5 @@ @ECHO OFF -if NOT "%2" == "-scr" ECHO Copyright (C) 2014 Jessica James. All rights reserved. +if NOT "%2" == "-scr" ECHO Copyright (C) 2014-2016 Jessica James. All rights reserved. ECHO. if "%1" == "/?" GOTO Help @@ -45,8 +45,8 @@ GOTO EOF :BinaryCopy: ROBOCOPY "Release\\" "..\Jupiter Bot Binaries\\" *.dll *.exe /S /xf Tester.exe -ROBOCOPY "Configs\\" "..\Jupiter Bot Binaries\Configs\\" *.ini -ROBOCOPY ".\\" "..\Jupiter Bot Binaries\\" *.ini *.txt +ROBOCOPY "Configs\\" "..\Jupiter Bot Binaries\Configs\\" * +ROBOCOPY ".\\" "..\Jupiter Bot Binaries\\" *.ini *.txt LICENSE "C:\Program Files\WinRAR\WinRAR.exe" a -r "..\Jupiter Bot Binaries.zip" "..\Jupiter Bot Binaries" GOTO EOF diff --git a/RenX.Core/RenX_GameCommand.cpp b/RenX.Core/RenX_GameCommand.cpp index e682868..5c0e23d 100644 --- a/RenX.Core/RenX_GameCommand.cpp +++ b/RenX.Core/RenX_GameCommand.cpp @@ -22,6 +22,9 @@ Jupiter::ArrayList _GameMasterCommandList; Jupiter::ArrayList *RenX::GameMasterCommandList = &_GameMasterCommandList; +RenX::Server *RenX::GameCommand::active_server = nullptr; +RenX::Server *RenX::GameCommand::selected_server = nullptr; + RenX::GameCommand::GameCommand(nullptr_t) { } diff --git a/RenX.Core/RenX_GameCommand.h b/RenX.Core/RenX_GameCommand.h index 75de127..8850fce 100644 --- a/RenX.Core/RenX_GameCommand.h +++ b/RenX.Core/RenX_GameCommand.h @@ -109,6 +109,11 @@ namespace RenX */ virtual ~GameCommand(); + /** Public members */ + + static RenX::Server *active_server; /** Currently active IRC server */ + static RenX::Server *selected_server; /** Currently selected IRC server */ + private: int access = 0; /** Minimum access level */ }; diff --git a/RenX.Core/RenX_Plugin.cpp b/RenX.Core/RenX_Plugin.cpp index 07f2b0b..f32333a 100644 --- a/RenX.Core/RenX_Plugin.cpp +++ b/RenX.Core/RenX_Plugin.cpp @@ -66,6 +66,11 @@ void RenX::Plugin::RenX_OnPlayerRDNS(Server *, const RenX::PlayerInfo *) return; } +void RenX::Plugin::RenX_OnPlayerIdentify(Server *, const RenX::PlayerInfo *) +{ + return; +} + void RenX::Plugin::RenX_OnServerCreate(Server *) { return; diff --git a/RenX.Core/RenX_Plugin.h b/RenX.Core/RenX_Plugin.h index 86380df..a5a0ede 100644 --- a/RenX.Core/RenX_Plugin.h +++ b/RenX.Core/RenX_Plugin.h @@ -50,6 +50,7 @@ namespace RenX virtual void RenX_OnPlayerDelete(Server *server, const PlayerInfo *player); virtual void RenX_OnPlayerUUIDChange(Server *server, const PlayerInfo *player, const Jupiter::ReadableString &newUUID); virtual void RenX_OnPlayerRDNS(Server *server, const PlayerInfo *player); + virtual void RenX_OnPlayerIdentify(Server *server, const PlayerInfo *player); virtual void RenX_OnServerCreate(Server *server); virtual void RenX_OnServerFullyConnected(Server *server); virtual void RenX_OnServerDisconnect(Server *server, RenX::DisconnectReason reason); diff --git a/RenX.Core/RenX_Server.cpp b/RenX.Core/RenX_Server.cpp index 426ae05..8d523fd 100644 --- a/RenX.Core/RenX_Server.cpp +++ b/RenX.Core/RenX_Server.cpp @@ -80,6 +80,11 @@ int RenX::Server::think() for (size_t index = 0; index < xPlugins.size(); ++index) xPlugins.get(index)->RenX_OnPlayerRDNS(this, player); + // Fire player indentified event if ready + if (player->hwid.isNotEmpty()) + for (size_t index = 0; index < xPlugins.size(); ++index) + xPlugins.get(index)->RenX_OnPlayerIdentify(this, player); + if (this->player_rdns_resolutions_pending == 0) // No more resolutions pending return; } @@ -1099,6 +1104,7 @@ RenX::GameCommand *RenX::Server::triggerCommand(const Jupiter::ReadableString &t { RenX::GameCommand *cmd; + RenX::GameCommand::active_server = this; for (size_t i = 0; i < RenX::Server::commands.size(); i++) { cmd = RenX::Server::commands.get(i); @@ -1112,6 +1118,7 @@ RenX::GameCommand *RenX::Server::triggerCommand(const Jupiter::ReadableString &t return cmd; } } + RenX::GameCommand::active_server = RenX::GameCommand::selected_server; return nullptr; } @@ -2679,6 +2686,10 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line) for (size_t index = 0; index < xPlugins.size(); ++index) xPlugins.get(index)->RenX_OnHWID(this, player); + + if (player->rdns.isNotEmpty()) + for (size_t index = 0; index < xPlugins.size(); ++index) + xPlugins.get(index)->RenX_OnPlayerIdentify(this, player); } else if (subHeader.equals("Exit;")) { @@ -3542,6 +3553,11 @@ void RenX::Server::init(const Jupiter::INIFile::Section &config) RenX::Server::~Server() { + if (RenX::GameCommand::selected_server == nullptr) + RenX::GameCommand::selected_server = nullptr; + if (RenX::GameCommand::active_server == nullptr) + RenX::GameCommand::active_server = RenX::GameCommand::selected_server; + sock.close(); RenX::Server::wipeData(); RenX::Server::commands.emptyAndDelete(); diff --git a/RenX.Logging/RenX_Logging.cpp b/RenX.Logging/RenX_Logging.cpp index 5b57b15..f4a26ff 100644 --- a/RenX.Logging/RenX_Logging.cpp +++ b/RenX.Logging/RenX_Logging.cpp @@ -31,6 +31,7 @@ bool RenX_LoggingPlugin::initialize() { RenX_LoggingPlugin::muteOwnExecute = this->config.getBool(Jupiter::ReferenceString::empty, "MuteOwnExecute"_jrs, true); RenX_LoggingPlugin::playerRDNSPublic = this->config.getBool(Jupiter::ReferenceString::empty, "PlayerRDNSPublic"_jrs, false); + RenX_LoggingPlugin::playerIdentifyPublic = this->config.getBool(Jupiter::ReferenceString::empty, "PlayerIdentifyPublic"_jrs, false); RenX_LoggingPlugin::joinPublic = this->config.getBool(Jupiter::ReferenceString::empty, "JoinPublic"_jrs, true); RenX_LoggingPlugin::partPublic = this->config.getBool(Jupiter::ReferenceString::empty, "PartPublic"_jrs, true); RenX_LoggingPlugin::kickPublic = this->config.getBool(Jupiter::ReferenceString::empty, "KickPublic"_jrs, true); @@ -110,16 +111,19 @@ bool RenX_LoggingPlugin::initialize() /** Event formats */ RenX_LoggingPlugin::playerRDNSFmt = this->config.get(Jupiter::ReferenceString::empty, "PlayerRDNSFormat"_jrs, - Jupiter::StringS::Format(IRCCOLOR "05[RDNS] " IRCBOLD "%.*s" IRCNORMAL "'s hostname is " IRCBOLD "%.*s", RenX::tags->nameTag.size(), RenX::tags->nameTag.ptr(), RenX::tags->rdnsTag.size(), RenX::tags->rdnsTag.ptr())); + Jupiter::ReferenceString::empty); + + RenX_LoggingPlugin::playerIdentifyFmt = this->config.get(Jupiter::ReferenceString::empty, "PlayerIdentifyFormat"_jrs, + Jupiter::StringS::Format(IRCCOLOR "12[Join] " IRCBOLD "%.*s" IRCBOLD " (" IRCBOLD "%.*s" IRCBOLD ") joined the game fighting for the %.*s from " IRCBOLD "%.*s" IRCBOLD " (" IRCBOLD "%.*s" IRCBOLD ") with HWID " IRCBOLD "%.*s" IRCBOLD ".", RenX::tags->nameTag.size(), RenX::tags->nameTag.ptr(), RenX::tags->steamTag.size(), RenX::tags->steamTag.ptr(), RenX::tags->teamLongTag.size(), RenX::tags->teamLongTag.ptr(), RenX::tags->ipTag.size(), RenX::tags->ipTag.ptr(), RenX::tags->rdnsTag.size(), RenX::tags->rdnsTag.ptr(), RenX::tags->hwidTag.size(), RenX::tags->hwidTag.ptr())); RenX_LoggingPlugin::joinPublicFmt = this->config.get(Jupiter::ReferenceString::empty, "JoinPublicFormat"_jrs, Jupiter::StringS::Format(IRCCOLOR "12[Join] " IRCBOLD "%.*s" IRCBOLD " joined the game fighting for the %.*s!", RenX::tags->nameTag.size(), RenX::tags->nameTag.ptr(), RenX::tags->teamLongTag.size(), RenX::tags->teamLongTag.ptr())); RenX_LoggingPlugin::joinAdminFmt = this->config.get(Jupiter::ReferenceString::empty, "JoinAdminFormat"_jrs, - Jupiter::StringS::Format(IRCCOLOR "12[Join] " IRCBOLD "%.*s" IRCBOLD " joined the game fighting for the %.*s from " IRCBOLD "%.*s" IRCBOLD " using Steam ID " IRCBOLD "%.*s" IRCBOLD ". HWID: \"" IRCBOLD "%.*s" IRCBOLD "\"", RenX::tags->nameTag.size(), RenX::tags->nameTag.ptr(), RenX::tags->teamLongTag.size(), RenX::tags->teamLongTag.ptr(), RenX::tags->ipTag.size(), RenX::tags->ipTag.ptr(), RenX::tags->steamTag.size(), RenX::tags->steamTag.ptr(), RenX::tags->hwidTag.size(), RenX::tags->hwidTag.ptr())); + Jupiter::ReferenceString::empty); RenX_LoggingPlugin::joinNoSteamAdminFmt = this->config.get(Jupiter::ReferenceString::empty, "JoinNoSteamAdminFormat"_jrs, - Jupiter::StringS::Format(IRCCOLOR "12[Join] " IRCBOLD "%.*s" IRCBOLD " joined the game fighting for the %.*s from " IRCBOLD "%.*s" IRCBOLD ", but is " IRCBOLD "not" IRCBOLD " using Steam. HWID: \"" IRCBOLD "%.*s" IRCBOLD "\"", RenX::tags->nameTag.size(), RenX::tags->nameTag.ptr(), RenX::tags->teamLongTag.size(), RenX::tags->teamLongTag.ptr(), RenX::tags->ipTag.size(), RenX::tags->ipTag.ptr(), RenX::tags->hwidTag.size(), RenX::tags->hwidTag.ptr())); + Jupiter::ReferenceString::empty); RenX_LoggingPlugin::partFmt = this->config.get(Jupiter::ReferenceString::empty, "PartFormat"_jrs, Jupiter::StringS::Format(IRCCOLOR "12[Part] " IRCBOLD "%.*s" IRCBOLD " left the %.*s.", RenX::tags->nameTag.size(), RenX::tags->nameTag.ptr(), RenX::tags->teamLongTag.size(), RenX::tags->teamLongTag.ptr())); @@ -427,6 +431,7 @@ bool RenX_LoggingPlugin::initialize() /** Sanitize tags */ RenX::sanitizeTags(playerRDNSFmt); + RenX::sanitizeTags(playerIdentifyFmt); RenX::sanitizeTags(joinPublicFmt); RenX::sanitizeTags(joinAdminFmt); RenX::sanitizeTags(joinNoSteamAdminFmt); @@ -554,6 +559,22 @@ void RenX_LoggingPlugin::RenX_OnPlayerRDNS(RenX::Server *server, const RenX::Pla } } +void RenX_LoggingPlugin::RenX_OnPlayerIdentify(RenX::Server *server, const RenX::PlayerInfo *player) +{ + logFuncType func; + if (RenX_LoggingPlugin::playerIdentifyPublic) + func = &RenX::Server::sendLogChan; + else + func = &RenX::Server::sendAdmChan; + + Jupiter::String msg = this->playerIdentifyFmt; + if (msg.isNotEmpty() && server->isMatchPending() == false) + { + RenX::processTags(msg, server, player); + (server->*func)(msg); + } +} + void RenX_LoggingPlugin::RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player) { Jupiter::String msg; diff --git a/RenX.Logging/RenX_Logging.h b/RenX.Logging/RenX_Logging.h index 04e6a0b..8255204 100644 --- a/RenX.Logging/RenX_Logging.h +++ b/RenX.Logging/RenX_Logging.h @@ -26,6 +26,7 @@ class RenX_LoggingPlugin : public RenX::Plugin { public: // RenX::Plugin void RenX_OnPlayerRDNS(RenX::Server *server, const RenX::PlayerInfo *player) override; + void RenX_OnPlayerIdentify(RenX::Server *server, const RenX::PlayerInfo *player) override; void RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player) override; void RenX_OnPart(RenX::Server *server, const RenX::PlayerInfo *player) override; @@ -134,6 +135,7 @@ public: // Jupiter::Plugin private: unsigned int muteOwnExecute : 1; unsigned int playerRDNSPublic : 1; + unsigned int playerIdentifyPublic : 1; unsigned int joinPublic : 1; unsigned int partPublic : 1; unsigned int kickPublic : 1; @@ -212,7 +214,8 @@ private: unsigned int otherPublic : 1; /** Event formats */ - Jupiter::String playerRDNSFmt; + Jupiter::StringS playerRDNSFmt; + Jupiter::StringS playerIdentifyFmt; Jupiter::StringS joinPublicFmt, joinAdminFmt, joinNoSteamAdminFmt; Jupiter::StringS partFmt; Jupiter::StringS kickFmt;