Browse Source

Updated Jupiter

Added PlayerTable IRC Command
pull/3/head
JustinAJ 10 years ago
parent
commit
7137b4c65f
  1. 2
      Jupiter
  2. 4
      Jupiter Bot.sln
  3. BIN
      Release/Bot.lib
  4. BIN
      Release/Plugins/RenX.Core.lib
  5. 122
      RenX.Commands/RenX_Commands.cpp
  6. 1
      RenX.Commands/RenX_Commands.h

2
Jupiter

@ -1 +1 @@
Subproject commit 0530dbee7b4b3e5b0b93eef57884c4af839af384
Subproject commit 884357b443381ac8034c7ec6ce30bc46a20c08e7

4
Jupiter Bot.sln

@ -146,6 +146,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenX.NicknameUUID", "RenX.N
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenX.HybridUUID", "RenX.HybridUUID\RenX.HybridUUID.vcxproj", "{FF61361F-CB09-4C72-80E2-9CA2DA63910E}"
ProjectSection(ProjectDependencies) = postProject
{C188871B-5F32-4946-B301-24CA2EBB275D} = {C188871B-5F32-4946-B301-24CA2EBB275D}
{9103DF3D-8B4A-48E5-A6B3-CBE2554630E2} = {9103DF3D-8B4A-48E5-A6B3-CBE2554630E2}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

BIN
Release/Bot.lib

Binary file not shown.

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

122
RenX.Commands/RenX_Commands.cpp

@ -298,6 +298,7 @@ void PlayersIRCCommand::create()
{
this->addTrigger(STRING_LITERAL_AS_REFERENCE("players"));
this->addTrigger(STRING_LITERAL_AS_REFERENCE("pl"));
this->addTrigger(STRING_LITERAL_AS_REFERENCE("playerlist"));
}
const size_t STRING_LENGTH = 240;
@ -451,6 +452,127 @@ const Jupiter::ReadableString &PlayersIRCCommand::getHelp(const Jupiter::Readabl
IRC_COMMAND_INIT(PlayersIRCCommand)
// PlayerTable IRC Command
#include "Jupiter/SLList.h"
void PlayerTableIRCCommand::create()
{
this->addTrigger(STRING_LITERAL_AS_REFERENCE("pt"));
this->addTrigger(STRING_LITERAL_AS_REFERENCE("playertable"));
}
void PlayerTableIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString &)
{
int type = source->getChannel(channel)->getType();
// Team colors
const Jupiter::ReadableString &gTeamColor = RenX::getTeamColor(RenX::TeamType::GDI);
const Jupiter::ReadableString &nTeamColor = RenX::getTeamColor(RenX::TeamType::Nod);
const Jupiter::ReadableString &oTeamColor = RenX::getTeamColor(RenX::TeamType::Other);
// Team names
const Jupiter::ReadableString &gTeam = RenX::getTeamName(RenX::TeamType::GDI);
const Jupiter::ReadableString &nTeam = RenX::getTeamName(RenX::TeamType::Nod);
const Jupiter::ReadableString &oTeam = RenX::getTeamName(RenX::TeamType::Other);
bool noServers = true;
for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++)
{
RenX::Server *server = RenX::getCore()->getServer(i);
if (server->isLogChanType(type))
{
noServers = false;
if (server->players.size() != 0)
{
Jupiter::SLList<RenX::PlayerInfo> gPlayers;
Jupiter::SLList<RenX::PlayerInfo> nPlayers;
Jupiter::SLList<RenX::PlayerInfo> oPlayers;
STRING_LITERAL_AS_NAMED_REFERENCE(NICK_COL_HEADER, "Nickname");
size_t maxNickLen = 8;
int highID = 999;
float highScore = 99999.0;
float highCredits = 9999999.0;
RenX::PlayerInfo *player;
for (Jupiter::DLList<RenX::PlayerInfo>::Node *node = server->players.getNode(0); node != nullptr; node = node->next)
{
player = node->data;
if (player != nullptr && player->isBot == false)
{
if (player->name.size() > maxNickLen)
maxNickLen = player->name.size();
if (player->id > highID)
highID = player->id;
if (player->score > highScore)
highScore = player->score;
if (player->credits > highCredits)
highCredits = player->credits;
switch (player->team)
{
case RenX::TeamType::GDI:
gPlayers.add(player);
break;
case RenX::TeamType::Nod:
nPlayers.add(player);
break;
default:
oPlayers.add(player);
break;
}
}
}
size_t idColLen = 1, scoreColLen = 1, creditColLen = 1;
while ((highID /= 10) > 0)
++idColLen;
while ((highScore /= 10) >= 1.0)
++scoreColLen;
while ((highCredits /= 10) >= 1.0)
++creditColLen;
source->sendMessage(channel, Jupiter::StringS::Format(IRCUNDERLINE IRCCOLOR "03%*.*s | %*s | %*s | %*s", maxNickLen, NICK_COL_HEADER.size(), NICK_COL_HEADER.ptr(), idColLen, "ID", scoreColLen, "Score", creditColLen, "Credits"));
auto output_player = [source, &channel, maxNickLen, idColLen, scoreColLen, creditColLen](RenX::PlayerInfo *player, const Jupiter::ReadableString &color)
{
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));
};
// Team colors
const Jupiter::ReadableString &gTeamColor = RenX::getTeamColor(RenX::TeamType::GDI);
const Jupiter::ReadableString &nTeamColor = RenX::getTeamColor(RenX::TeamType::Nod);
const Jupiter::ReadableString &oTeamColor = RenX::getTeamColor(RenX::TeamType::Other);
for (Jupiter::SLList<RenX::PlayerInfo>::Node *node = gPlayers.getNode(0); node != nullptr; node = node->next)
output_player(node->data, gTeamColor);
for (Jupiter::SLList<RenX::PlayerInfo>::Node *node = nPlayers.getNode(0); node != nullptr; node = node->next)
output_player(node->data, nTeamColor);
for (Jupiter::SLList<RenX::PlayerInfo>::Node *node = oPlayers.getNode(0); node != nullptr; node = node->next)
output_player(node->data, oTeamColor);
}
else source->sendMessage(channel, STRING_LITERAL_AS_REFERENCE("No players are in-game."));
}
}
if (noServers)
source->sendMessage(channel, STRING_LITERAL_AS_REFERENCE("Error: Channel not attached to any connected Renegade X servers."));
}
const Jupiter::ReadableString &PlayerTableIRCCommand::getHelp(const Jupiter::ReadableString &)
{
static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Generates a table of all the players in-game. Syntax: PT");
return defaultHelp;
}
IRC_COMMAND_INIT(PlayerTableIRCCommand)
// PlayerInfo IRC Command
void PlayerInfoIRCCommand::create()

1
RenX.Commands/RenX_Commands.h

@ -57,6 +57,7 @@ GENERIC_IRC_COMMAND(MsgIRCCommand)
GENERIC_IRC_COMMAND(PMsgIRCCommand)
GENERIC_IRC_COMMAND(HostMsgIRCCommand)
GENERIC_IRC_COMMAND(PlayersIRCCommand)
GENERIC_IRC_COMMAND(PlayerTableIRCCommand)
GENERIC_IRC_COMMAND(PlayerInfoIRCCommand)
GENERIC_IRC_COMMAND(SteamIRCCommand)
GENERIC_IRC_COMMAND(KillDeathRatioIRCCommand)

Loading…
Cancel
Save