Browse Source

Changed internal steamid representation to uint64_t. Added UUID parameter to PlayerInfo.

pull/3/head
JustinAJ 10 years ago
parent
commit
87b6310642
  1. BIN
      Release/Plugins/RenX.Core.lib
  2. 19
      RenX.Commands/RenX_Commands.cpp
  3. 3
      RenX.Core/RenX_PlayerInfo.h
  4. 34
      RenX.Core/RenX_Server.cpp
  5. 1
      RenX.Core/RenX_Server.h
  6. 2
      RenX.ExcessiveHeadshots/ExcessiveHeadshots.cpp
  7. 4
      RenX.Logging/RenX_Logging.cpp
  8. 65
      RenX.Medals/RenX_Medals.cpp
  9. 16
      RenX.SetJoin/RenX_SetJoin.cpp

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

19
RenX.Commands/RenX_Commands.cpp

@ -354,12 +354,8 @@ void PlayerInfoIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableStrin
}
else msg += "IP Not Found" IRCBOLD;
}
if (player->steamid.size() != 0)
{
msg += " - Steam ID: " IRCBOLD;
msg += player->steamid;
msg += IRCBOLD;
}
if (player->steamid != 0)
msg.aformat(" - Steam ID: " IRCBOLD "%llx" IRCBOLD, player->steamid);
if (player->adminType.size() != 0)
{
msg += " - Admin Type: " IRCBOLD;
@ -415,12 +411,8 @@ void SteamIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &ch
{
Jupiter::String &playerName = RenX::getFormattedPlayerName(player);
msg.format(IRCCOLOR "03[Steam] " IRCCOLOR "%.*s (ID: %d) ", playerName.size(), playerName.ptr(), player->id);
if (player->steamid.size() != 0)
{
msg += "is using steam ID " IRCBOLD;
msg += player->steamid;
msg += IRCBOLD;
}
if (player->steamid != 0)
msg.aformat("is using steam ID " IRCBOLD "%llx" IRCBOLD, player->steamid);
else msg += "is not using steam.";
source->sendMessage(channel, msg);
}
@ -445,7 +437,8 @@ void SteamIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &ch
if (player->isBot == false)
{
realPlayers++;
if (player->steamid.size() != 0) total++;
if (player->steamid != 0)
total++;
}
}
}

3
RenX.Core/RenX_PlayerInfo.h

@ -44,7 +44,8 @@ namespace RenX
Jupiter::StringS name;
Jupiter::StringS ip;
Jupiter::StringS adminType;
Jupiter::StringS steamid;
Jupiter::StringS uuid;
uint64_t steamid = 0;
TeamType team = Other;
int id = 0;
bool isBot = false;

34
RenX.Core/RenX_Server.cpp

@ -681,7 +681,21 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
else if (action.equals("entered from"))
{
player->ip = buff.getWord(3, RenX::DelimS);
if (buff.getWord(4, RenX::DelimS).equals("steamid")) player->steamid = buff.getWord(5, RenX::DelimS);
if (buff.getWord(4, RenX::DelimS).equals("steamid"))
player->steamid = buff.getWord(5, RenX::DelimS).asUnsignedInt();
switch (RenX::Server::uuidMode)
{
default:
case 0:
if (player->steamid != 0)
player->uuid.format("%llx", player->steamid);
break;
case 1:
player->uuid = player->name;
break;
}
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnJoin(this, player);
}
@ -691,6 +705,8 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnNameChange(this, player, newName);
player->name = newName;
if (RenX::Server::uuidMode == 1)
player->uuid = player->name;
}
}
else if (header.equals("lRCON:"))
@ -769,7 +785,19 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
if (player->ip.size() == 0)
{
player->ip = ip;
player->steamid = steamid;
player->steamid = steamid.asUnsignedInt();
switch (RenX::Server::uuidMode)
{
default:
case 0:
if (player->steamid != 0)
player->uuid.format("%llx", player->steamid);
break;
case 1:
player->uuid = player->name;
break;
}
}
}
else
@ -886,8 +914,8 @@ RenX::Server::Server(const Jupiter::ReadableString &configurationSection)
RenX::Server::setPrefix(Jupiter::IRC::Client::Config->get(RenX::Server::configSection, STRING_LITERAL_AS_REFERENCE("IRCPrefix")));
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::uuidMode = Jupiter::IRC::Client::Config->getInt(RenX::Server::configSection, STRING_LITERAL_AS_REFERENCE("UUIDMode"), 0);
for (size_t i = 0; i < RenX::GameMasterCommandList->size(); i++)
RenX::Server::addCommand(RenX::GameMasterCommandList->get(i)->copy());

1
RenX.Core/RenX_Server.h

@ -425,6 +425,7 @@ namespace RenX
int adminLogChanType;
time_t lastAttempt = 0;
time_t delay;
unsigned int uuidMode; /** 0 = steam, 1 = nickname */
Jupiter::TCPSocket sock;
Jupiter::CStringS clientHostname;
Jupiter::CStringS hostname;

2
RenX.ExcessiveHeadshots/ExcessiveHeadshots.cpp

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

4
RenX.Logging/RenX_Logging.cpp

@ -60,10 +60,10 @@ void RenX_LoggingPlugin::RenX_OnJoin(RenX::Server *server, const RenX::PlayerInf
if (RenX_LoggingPlugin::joinPublic)
server->sendPubChan(IRCCOLOR "12[Join]" IRCCOLOR "%.*s " IRCBOLD "%.*s" IRCBOLD " joined the game fighting for the %.*s!", teamColor.size(), teamColor.ptr(), player->name.size(), player->name.ptr(), teamName.size(), teamName.ptr());
if (player->steamid.isEmpty())
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());
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 "%.*s" IRCBOLD ".", teamColor.size(), teamColor.ptr(), player->name.size(), player->name.ptr(), teamName.size(), teamName.ptr(), player->ip.size(), player->ip.ptr(), player->steamid.size(), player->steamid.ptr());
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 "%llx" IRCBOLD ".", teamColor.size(), teamColor.ptr(), player->name.size(), player->name.ptr(), teamName.size(), teamName.ptr(), player->ip.size(), player->ip.ptr(), player->steamid);
}
void RenX_LoggingPlugin::RenX_OnPart(RenX::Server *server, const RenX::PlayerInfo *player)

65
RenX.Medals/RenX_Medals.cpp

@ -27,21 +27,21 @@ const char *medalsFileName = "medals.ini";
struct MedalPlayerData
{
Jupiter::StringS steamID;
Jupiter::StringS uuid;
unsigned long recs = 0;
unsigned long noobs = 0;
Jupiter::StringS lastName;
time_t lastSeen = 0;
MedalPlayerData(Jupiter::INIFile &medalsFile, const Jupiter::ReadableString &steamid)
MedalPlayerData(Jupiter::INIFile &medalsFile, const Jupiter::ReadableString &id)
{
MedalPlayerData::steamID = steamid;
if (medalsFile.getSectionIndex(MedalPlayerData::steamID) != Jupiter::INVALID_INDEX)
MedalPlayerData::uuid = id;
if (medalsFile.getSectionIndex(MedalPlayerData::uuid) != Jupiter::INVALID_INDEX)
{
MedalPlayerData::recs = medalsFile.get(MedalPlayerData::steamID, STRING_LITERAL_AS_REFERENCE("Recs")).asUnsignedInt(10);
MedalPlayerData::noobs = medalsFile.get(MedalPlayerData::steamID, STRING_LITERAL_AS_REFERENCE("Noobs")).asUnsignedInt(10);
MedalPlayerData::lastName = medalsFile.get(MedalPlayerData::steamID, STRING_LITERAL_AS_REFERENCE("Name"));
MedalPlayerData::lastSeen = medalsFile.getInt(MedalPlayerData::steamID, STRING_LITERAL_AS_REFERENCE("Seen"));
MedalPlayerData::recs = medalsFile.get(MedalPlayerData::uuid, STRING_LITERAL_AS_REFERENCE("Recs")).asUnsignedInt(10);
MedalPlayerData::noobs = medalsFile.get(MedalPlayerData::uuid, STRING_LITERAL_AS_REFERENCE("Noobs")).asUnsignedInt(10);
MedalPlayerData::lastName = medalsFile.get(MedalPlayerData::uuid, STRING_LITERAL_AS_REFERENCE("Name"));
MedalPlayerData::lastSeen = medalsFile.getInt(MedalPlayerData::uuid, STRING_LITERAL_AS_REFERENCE("Seen"));
}
}
};
@ -57,10 +57,10 @@ void updateMedalPlayerData(MedalPlayerData &player, RenX::PlayerInfo *pInfo)
player.lastSeen = time(0);
}
void syncPlayerMedalDataToINI(Jupiter::INIFile &file, MedalPlayerData &player, const Jupiter::ReadableString &steamid)
void syncPlayerMedalDataToINI(Jupiter::INIFile &file, MedalPlayerData &player, const Jupiter::ReadableString &uuid)
{
file.set(steamid, STRING_LITERAL_AS_REFERENCE("Name"), player.lastName);
file.set(steamid, STRING_LITERAL_AS_REFERENCE("Seen"), Jupiter::StringS::Format("%d", player.lastSeen));
file.set(uuid, STRING_LITERAL_AS_REFERENCE("Name"), player.lastName);
file.set(uuid, STRING_LITERAL_AS_REFERENCE("Seen"), Jupiter::StringS::Format("%d", player.lastSeen));
}
struct CongratPlayerData
@ -112,11 +112,11 @@ void RenX_MedalsPlugin::RenX_OnGameOver(RenX::Server *server, RenX::WinType winT
if (pInfo->vehicleKills > mostVehicleKills->vehicleKills) mostVehicleKills = pInfo;
if (RenX::getKillDeathRatio(pInfo) > RenX::getKillDeathRatio(bestKD)) bestKD = pInfo;
if (pInfo->steamid.size() != 0)
if (pInfo->uuid.isEmpty() == false)
{
MedalPlayerData player(RenX_MedalsPlugin::medalsFile, pInfo->steamid);
MedalPlayerData player(RenX_MedalsPlugin::medalsFile, pInfo->uuid);
updateMedalPlayerData(player, pInfo);
syncPlayerMedalDataToINI(RenX_MedalsPlugin::medalsFile, player, pInfo->steamid);
syncPlayerMedalDataToINI(RenX_MedalsPlugin::medalsFile, player, pInfo->uuid);
}
n = n->next;
}
@ -124,11 +124,11 @@ void RenX_MedalsPlugin::RenX_OnGameOver(RenX::Server *server, RenX::WinType winT
CongratPlayerData *congratPlayerData;
/** +1 for most kills */
if (mostKills->steamid.size() != 0 && mostKills->kills > 0)
if (mostKills->uuid.isEmpty() == false && mostKills->kills > 0)
{
addRec(mostKills);
MedalPlayerData player(RenX_MedalsPlugin::medalsFile, mostKills->steamid);
syncPlayerMedalDataToINI(RenX_MedalsPlugin::medalsFile, player, mostKills->steamid);
MedalPlayerData player(RenX_MedalsPlugin::medalsFile, mostKills->uuid);
syncPlayerMedalDataToINI(RenX_MedalsPlugin::medalsFile, player, mostKills->uuid);
congratPlayerData = new CongratPlayerData();
congratPlayerData->server = server;
@ -138,11 +138,11 @@ void RenX_MedalsPlugin::RenX_OnGameOver(RenX::Server *server, RenX::WinType winT
}
/** +1 for most Vehicle kills */
if (mostVehicleKills->steamid.size() != 0 && mostVehicleKills->vehicleKills > 0)
if (mostVehicleKills->uuid.isEmpty() == false && mostVehicleKills->vehicleKills > 0)
{
addRec(mostVehicleKills);
MedalPlayerData player(RenX_MedalsPlugin::medalsFile, mostVehicleKills->steamid);
syncPlayerMedalDataToINI(RenX_MedalsPlugin::medalsFile, player, mostVehicleKills->steamid);
MedalPlayerData player(RenX_MedalsPlugin::medalsFile, mostVehicleKills->uuid);
syncPlayerMedalDataToINI(RenX_MedalsPlugin::medalsFile, player, mostVehicleKills->uuid);
congratPlayerData = new CongratPlayerData();
congratPlayerData->server = server;
@ -152,11 +152,11 @@ void RenX_MedalsPlugin::RenX_OnGameOver(RenX::Server *server, RenX::WinType winT
}
/** +1 for best K/D ratio */
if (bestKD->steamid.size() != 0)
if (bestKD->uuid.isEmpty() == false)
{
addRec(bestKD);
MedalPlayerData player(RenX_MedalsPlugin::medalsFile, bestKD->steamid);
syncPlayerMedalDataToINI(RenX_MedalsPlugin::medalsFile, player, bestKD->steamid);
MedalPlayerData player(RenX_MedalsPlugin::medalsFile, bestKD->uuid);
syncPlayerMedalDataToINI(RenX_MedalsPlugin::medalsFile, player, bestKD->uuid);
congratPlayerData = new CongratPlayerData();
congratPlayerData->server = server;
@ -173,9 +173,9 @@ void RenX_MedalsPlugin::RenX_OnDestroy(RenX::Server *server, const RenX::PlayerI
if (type == RenX::ObjectType::Building)
{
addRec((RenX::PlayerInfo *) player); // -whistles-
MedalPlayerData playerMedalData(RenX_MedalsPlugin::medalsFile, player->steamid);
MedalPlayerData playerMedalData(RenX_MedalsPlugin::medalsFile, player->uuid);
updateMedalPlayerData(playerMedalData, (RenX::PlayerInfo *) player); // -whistles-
syncPlayerMedalDataToINI(RenX_MedalsPlugin::medalsFile, playerMedalData, player->steamid);
syncPlayerMedalDataToINI(RenX_MedalsPlugin::medalsFile, playerMedalData, player->uuid);
const Jupiter::ReadableString &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()));
@ -203,13 +203,13 @@ void RecsGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, co
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: Player not found! Syntax: recs [player]"));
// Check INI?
}
else if (target->steamid.size() == 0)
else if (target->uuid.isEmpty())
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: Player is not using steam."));
else if (target == player)
RecsGameCommand::trigger(source, player, Jupiter::ReferenceString::empty);
else source->sendMessage(Jupiter::StringS::Format("%.*s has %lu and %lu n00bs. Their worth: %d", target->name.size(), target->name.ptr(), getRecs(target), getNoobs(target), getWorth(target)));
}
else if (player->steamid.size() == 0)
else if (player->uuid.isEmpty())
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: You are not using steam."));
else source->sendMessage(Jupiter::StringS::Format("%.*s, you have %lu and %lu n00bs. Your worth: %d", player->name.size(), player->name.ptr(), getRecs(player), getNoobs(player), getWorth(player)));
}
@ -236,7 +236,7 @@ void RecGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, con
{
RenX::PlayerInfo *target = source->getPlayerByPartName(parameters);
if (target == nullptr) source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: Player not found! Syntax: rec <player>"));
else if (target->steamid.size() == 0)
else if (target->uuid.isEmpty())
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: Player is not using steam."));
else if (target == player)
{
@ -277,7 +277,8 @@ void NoobGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, co
{
RenX::PlayerInfo *target = source->getPlayerByPartName(parameters);
if (target == nullptr) source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: Player not found! Syntax: noob [player]"));
else if (target->steamid.size() == 0) source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: Player is not using steam."));
else if (target->uuid.isEmpty())
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: Player is not using steam."));
else if (player->varData.get(STRING_LITERAL_AS_REFERENCE("RenX.Medals"), STRING_LITERAL_AS_REFERENCE("gn")) != nullptr)
source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("You can only give one noob per game."));
else
@ -305,13 +306,13 @@ RenX_MedalsPlugin pluginInstance;
void addRec(MedalPlayerData &player, int amount)
{
player.recs += amount;
pluginInstance.medalsFile.set(player.steamID, STRING_LITERAL_AS_REFERENCE("Recs"), Jupiter::StringS::Format("%u", player.recs));
pluginInstance.medalsFile.set(player.uuid, STRING_LITERAL_AS_REFERENCE("Recs"), Jupiter::StringS::Format("%u", player.recs));
}
void addNoob(MedalPlayerData &player, int amount)
{
player.noobs += amount;
pluginInstance.medalsFile.set(player.steamID, STRING_LITERAL_AS_REFERENCE("Noobs"), Jupiter::StringS::Format("%u", player.noobs));
pluginInstance.medalsFile.set(player.uuid, STRING_LITERAL_AS_REFERENCE("Noobs"), Jupiter::StringS::Format("%u", player.noobs));
}
int getWorth(MedalPlayerData &player)
@ -321,7 +322,7 @@ int getWorth(MedalPlayerData &player)
inline MedalPlayerData getMedalPlayerData(RenX::PlayerInfo *player)
{
return MedalPlayerData(pluginInstance.medalsFile, player->steamid);
return MedalPlayerData(pluginInstance.medalsFile, player->uuid);
}
void addRec(RenX::PlayerInfo *player, int amount)

16
RenX.SetJoin/RenX_SetJoin.cpp

@ -25,9 +25,9 @@ const Jupiter::ReferenceString configSection(STRING_LITERAL_AS_REFERENCE("RenX.S
void RenX_SetJoinPlugin::RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player)
{
if (player->steamid.size() != 0)
if (player->steamid != 0)
{
const Jupiter::ReadableString &setjoin = Jupiter::IRC::Client::Config->get(configSection, player->steamid);
const Jupiter::ReadableString &setjoin = Jupiter::IRC::Client::Config->get(configSection, Jupiter::StringS::Format("%llx", player->steamid));
if (setjoin.isEmpty() == false)
server->sendMessage(Jupiter::StringS::Format("[%.*s] %.*s", player->name.size(), player->name.ptr(), setjoin.size(), setjoin.ptr()));
}
@ -43,9 +43,9 @@ void ViewJoinGameCommand::create()
void ViewJoinGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, const Jupiter::ReadableString &parameters)
{
if (player->steamid.size() != 0)
if (player->steamid != 0)
{
const Jupiter::ReadableString &setjoin = Jupiter::IRC::Client::Config->get(configSection, player->steamid);
const Jupiter::ReadableString &setjoin = Jupiter::IRC::Client::Config->get(configSection, Jupiter::StringS::Format("%llx", player->steamid));
if (setjoin.isEmpty() == false)
source->sendMessage(Jupiter::StringS::Format("[%.*s] %.*s", player->name.size(), player->name.ptr(), setjoin.size(), setjoin.ptr()));
else source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: No setjoin found."));
@ -73,9 +73,9 @@ void DelJoinGameCommand::create()
void DelJoinGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, const Jupiter::ReadableString &)
{
if (player->steamid.size() != 0)
if (player->steamid != 0)
{
if (Jupiter::IRC::Client::Config->remove(configSection, player->steamid))
if (Jupiter::IRC::Client::Config->remove(configSection, Jupiter::StringS::Format("%llx", player->steamid)))
source->sendMessage(player, Jupiter::StringS::Format("%.*s, your join message has been removed.", player->name.size(), player->name.ptr()));
else source->sendMessage(player, STRING_LITERAL_AS_REFERENCE("Error: Setjoin not found."));
}
@ -100,11 +100,11 @@ void SetJoinGameCommand::create()
void SetJoinGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player, const Jupiter::ReadableString &parameters)
{
if (player->steamid.isEmpty() == false)
if (player->steamid != 0)
{
if (parameters.isEmpty() == false)
{
Jupiter::IRC::Client::Config->set(configSection, player->steamid, parameters);
Jupiter::IRC::Client::Config->set(configSection, Jupiter::StringS::Format("%llx", player->steamid), parameters);
Jupiter::IRC::Client::Config->sync();
source->sendMessage(player, Jupiter::StringS::Format("%.*s, your join message is now: %.*s", player->name.size(), player->name.ptr(), parameters.size(), parameters.ptr()));
}

Loading…
Cancel
Save