Browse Source

Added "SteamFormat" config option; added formatSteamID() to RenX::Server; adjusted usage of steamids in strings appropriately.

pull/3/head
JustinAJ 10 years ago
parent
commit
92bb5f185e
  1. BIN
      Release/Plugins/RenX.Core.lib
  2. 12
      RenX.Commands/RenX_Commands.cpp
  3. 27
      RenX.Core/RenX_Server.cpp
  4. 17
      RenX.Core/RenX_Server.h
  5. 3
      RenX.ExcessiveHeadshots/ExcessiveHeadshots.cpp
  6. 5
      RenX.Logging/RenX_Logging.cpp

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

12
RenX.Commands/RenX_Commands.cpp

@ -403,7 +403,11 @@ void PlayerInfoIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableStrin
else msg += "IP Not Found" IRCBOLD; else msg += "IP Not Found" IRCBOLD;
} }
if (player->steamid != 0) if (player->steamid != 0)
msg.aformat(" - Steam ID: " IRCBOLD "0x%.16llX" IRCBOLD, player->steamid); {
msg += " - Steam ID: " IRCBOLD;
msg += server->formatSteamID(player);
msg += IRCBOLD;
}
if (player->adminType.size() != 0) if (player->adminType.size() != 0)
{ {
msg += " - Admin Type: " IRCBOLD; msg += " - Admin Type: " IRCBOLD;
@ -460,7 +464,11 @@ void SteamIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &ch
Jupiter::String &playerName = RenX::getFormattedPlayerName(player); Jupiter::String &playerName = RenX::getFormattedPlayerName(player);
msg.format(IRCCOLOR "03[Steam] " IRCCOLOR "%.*s (ID: %d) ", playerName.size(), playerName.ptr(), player->id); msg.format(IRCCOLOR "03[Steam] " IRCCOLOR "%.*s (ID: %d) ", playerName.size(), playerName.ptr(), player->id);
if (player->steamid != 0) if (player->steamid != 0)
msg.aformat("is using steam ID " IRCBOLD "0x%.16llX" IRCBOLD, player->steamid); {
msg += "is using steam ID " IRCBOLD;
msg += server->formatSteamID(player);
msg += IRCBOLD;
}
else msg += "is not using steam."; else msg += "is not using steam.";
source->sendMessage(channel, msg); source->sendMessage(channel, msg);
} }

27
RenX.Core/RenX_Server.cpp

@ -173,6 +173,28 @@ RenX::PlayerInfo *RenX::Server::getPlayerByPartNameFast(const Jupiter::ReadableS
return nullptr; return nullptr;
} }
Jupiter::StringS RenX::Server::formatSteamID(const RenX::PlayerInfo *player)
{
return RenX::Server::formatSteamID(player->steamid);
}
Jupiter::StringS RenX::Server::formatSteamID(uint64_t id)
{
switch (RenX::Server::steamFormat)
{
default:
case 16:
return Jupiter::StringS::Format("0x%.16llX", id);
break;
case 10:
return Jupiter::StringS::Format("%llu", id);
break;
case 8:
return Jupiter::StringS::Format("0%llo", id);
break;
}
}
void RenX::Server::kickPlayer(int id) void RenX::Server::kickPlayer(int id)
{ {
RenX::Server::sock.send(Jupiter::StringS::Format("cadminkick pid%d\n", id)); RenX::Server::sock.send(Jupiter::StringS::Format("cadminkick pid%d\n", id));
@ -698,7 +720,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
default: default:
case 0: case 0:
if (player->steamid != 0) if (player->steamid != 0)
player->uuid.format("0x%.16llX", player->steamid); player->uuid = this->formatSteamID(player);
break; break;
case 1: case 1:
player->uuid = player->name; player->uuid = player->name;
@ -801,7 +823,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
default: default:
case 0: case 0:
if (player->steamid != 0) if (player->steamid != 0)
player->uuid.format("0x%.16llX", player->steamid); player->uuid = this->formatSteamID(player);
break; break;
case 1: case 1:
player->uuid = player->name; player->uuid = player->name;
@ -934,6 +956,7 @@ RenX::Server::Server(const Jupiter::ReadableString &configurationSection)
RenX::Server::rules = Jupiter::IRC::Client::Config->get(RenX::Server::configSection, STRING_LITERAL_AS_REFERENCE("Rules"), STRING_LITERAL_AS_REFERENCE("Anarchy!")); RenX::Server::rules = Jupiter::IRC::Client::Config->get(RenX::Server::configSection, STRING_LITERAL_AS_REFERENCE("Rules"), STRING_LITERAL_AS_REFERENCE("Anarchy!"));
RenX::Server::delay = Jupiter::IRC::Client::Config->getInt(RenX::Server::configSection, STRING_LITERAL_AS_REFERENCE("ReconnectDelay"), 60); RenX::Server::delay = Jupiter::IRC::Client::Config->getInt(RenX::Server::configSection, STRING_LITERAL_AS_REFERENCE("ReconnectDelay"), 60);
RenX::Server::uuidMode = Jupiter::IRC::Client::Config->getInt(RenX::Server::configSection, STRING_LITERAL_AS_REFERENCE("UUIDMode"), 0); RenX::Server::uuidMode = Jupiter::IRC::Client::Config->getInt(RenX::Server::configSection, STRING_LITERAL_AS_REFERENCE("UUIDMode"), 0);
RenX::Server::steamFormat = Jupiter::IRC::Client::Config->getInt(RenX::Server::configSection, STRING_LITERAL_AS_REFERENCE("SteamFormat"), 16);
for (size_t i = 0; i < RenX::GameMasterCommandList->size(); i++) for (size_t i = 0; i < RenX::GameMasterCommandList->size(); i++)
RenX::Server::addCommand(RenX::GameMasterCommandList->get(i)->copy()); RenX::Server::addCommand(RenX::GameMasterCommandList->get(i)->copy());

17
RenX.Core/RenX_Server.h

@ -163,6 +163,22 @@ namespace RenX
*/ */
RenX::PlayerInfo *getPlayerByPartNameFast(const Jupiter::ReadableString &partName) const; RenX::PlayerInfo *getPlayerByPartNameFast(const Jupiter::ReadableString &partName) const;
/**
* @brief Formats a player's Steam ID into a readable string.
*
* @param player Player to fetch Steam ID from
* @return A player's formatted Steam ID on success, an empty string otherwise.
*/
Jupiter::StringS formatSteamID(const RenX::PlayerInfo *player);
/**
* @brief Formats a Steam ID into a readable string.
*
* @param id Steam ID to format
* @return A player's formatted Steam ID on success, an empty string otherwise.
*/
Jupiter::StringS formatSteamID(uint64_t id);
/** /**
* @brief Kicks a player from the server. * @brief Kicks a player from the server.
* *
@ -428,6 +444,7 @@ namespace RenX
int adminLogChanType; int adminLogChanType;
time_t lastAttempt = 0; time_t lastAttempt = 0;
time_t delay; time_t delay;
unsigned int steamFormat; /** 16 = hex, 10 = base 10, 8 = octal */
unsigned int uuidMode; /** 0 = steam, 1 = nickname */ unsigned int uuidMode; /** 0 = steam, 1 = nickname */
Jupiter::TCPSocket sock; Jupiter::TCPSocket sock;
Jupiter::CStringS clientHostname; Jupiter::CStringS clientHostname;

3
RenX.ExcessiveHeadshots/ExcessiveHeadshots.cpp

@ -55,7 +55,8 @@ void RenX_ExcessiveHeadshotsPlugin::RenX_OnKill(RenX::Server *server, const RenX
{ {
server->kickPlayer(player); server->kickPlayer(player);
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.ptr(), player->kills, player->deaths, player->headshots);
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 "0x%.16llX" IRCBOLD, player->name.size(), player->name.ptr(), player->kills, player->deaths, player->headshots, player->ip.size(), player->ip.ptr(), player->steamid); 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());
} }
} }
} }

5
RenX.Logging/RenX_Logging.cpp

@ -63,7 +63,10 @@ void RenX_LoggingPlugin::RenX_OnJoin(RenX::Server *server, const RenX::PlayerInf
if (player->steamid == 0) if (player->steamid == 0)
server->sendAdmChan(IRCCOLOR "12[Join]" IRCCOLOR "%.*s " IRCBOLD "%.*s" IRCBOLD " joined the game fighting for the %.*s from " IRCBOLD "%.*s" IRCBOLD ", but is not using Steam.", teamColor.size(), teamColor.ptr(), player->name.size(), player->name.ptr(), teamName.size(), teamName.ptr(), player->ip.size(), player->ip.ptr()); server->sendAdmChan(IRCCOLOR "12[Join]" IRCCOLOR "%.*s " IRCBOLD "%.*s" IRCBOLD " joined the game fighting for the %.*s from " IRCBOLD "%.*s" IRCBOLD ", but is not using Steam.", teamColor.size(), teamColor.ptr(), player->name.size(), player->name.ptr(), teamName.size(), teamName.ptr(), player->ip.size(), player->ip.ptr());
else else
server->sendAdmChan(IRCCOLOR "12[Join]" IRCCOLOR "%.*s " IRCBOLD "%.*s" IRCBOLD " joined the game fighting for the %.*s from " IRCBOLD "%.*s" IRCBOLD " using Steam ID " IRCBOLD "0x%.16llX" IRCBOLD ".", teamColor.size(), teamColor.ptr(), player->name.size(), player->name.ptr(), teamName.size(), teamName.ptr(), player->ip.size(), player->ip.ptr(), player->steamid); {
const Jupiter::ReadableString &steamid = server->formatSteamID(player);
server->sendAdmChan(IRCCOLOR "12[Join]" IRCCOLOR "%.*s " IRCBOLD "%.*s" IRCBOLD " joined the game fighting for the %.*s from " IRCBOLD "%.*s" IRCBOLD " using Steam ID " IRCBOLD "%.*s" IRCBOLD ".", teamColor.size(), teamColor.ptr(), player->name.size(), player->name.ptr(), teamName.size(), teamName.ptr(), player->ip.size(), player->ip.ptr(), steamid.size(), steamid.ptr());
}
} }
void RenX_LoggingPlugin::RenX_OnPart(RenX::Server *server, const RenX::PlayerInfo *player) void RenX_LoggingPlugin::RenX_OnPart(RenX::Server *server, const RenX::PlayerInfo *player)

Loading…
Cancel
Save