Browse Source

Updated Jupiter and adjusted as necessary

pull/4/head
Jessica James 8 years ago
parent
commit
16b6ae2772
  1. 2
      Jupiter
  2. 64
      RenX.Commands/RenX_Commands.cpp
  3. 18
      RenX.Core/RenX_LadderDatabase.cpp
  4. 8
      RenX.Core/RenX_LadderDatabase.h
  5. 21
      RenX.Ladder/RenX_Ladder.cpp

2
Jupiter

@ -1 +1 @@
Subproject commit a1446315ad928005825d4746ef66e57b759ebe4d Subproject commit b8983d476abb9c34b77794394e51fa0001f25f8e

64
RenX.Commands/RenX_Commands.cpp

@ -16,8 +16,8 @@
* Written by Jessica James <jessica.aj@outlook.com> * Written by Jessica James <jessica.aj@outlook.com>
*/ */
#include <forward_list>
#include "Jupiter/Functions.h" #include "Jupiter/Functions.h"
#include "Jupiter/SLList.h"
#include "IRC_Bot.h" #include "IRC_Bot.h"
#include "RenX_Commands.h" #include "RenX_Commands.h"
#include "RenX_Core.h" #include "RenX_Core.h"
@ -505,9 +505,9 @@ void PlayerTableIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableStri
noServers = false; noServers = false;
if (server->players.size() != server->getBotCount()) if (server->players.size() != server->getBotCount())
{ {
Jupiter::SLList<RenX::PlayerInfo> gPlayers; std::forward_list<RenX::PlayerInfo *> gPlayers;
Jupiter::SLList<RenX::PlayerInfo> nPlayers; std::forward_list<RenX::PlayerInfo *> nPlayers;
Jupiter::SLList<RenX::PlayerInfo> oPlayers; std::forward_list<RenX::PlayerInfo *> oPlayers;
STRING_LITERAL_AS_NAMED_REFERENCE(NICK_COL_HEADER, "Nickname"); STRING_LITERAL_AS_NAMED_REFERENCE(NICK_COL_HEADER, "Nickname");
size_t maxNickLen = 8; size_t maxNickLen = 8;
@ -536,13 +536,13 @@ void PlayerTableIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableStri
switch (player->team) switch (player->team)
{ {
case RenX::TeamType::GDI: case RenX::TeamType::GDI:
gPlayers.add(player); gPlayers.push_front(player);
break; break;
case RenX::TeamType::Nod: case RenX::TeamType::Nod:
nPlayers.add(player); nPlayers.push_front(player);
break; break;
default: default:
oPlayers.add(player); oPlayers.push_front(player);
break; break;
} }
} }
@ -572,14 +572,14 @@ void PlayerTableIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableStri
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.ptr(), idColLen, player->id, scoreColLen, player->score, creditColLen, player->credits));
}; };
for (Jupiter::SLList<RenX::PlayerInfo>::Node *node = gPlayers.getNode(0); node != nullptr; node = node->next) for (auto node = gPlayers.begin(); node != gPlayers.end(); ++node)
output_player(node->data, gTeamColor); output_player(*node, gTeamColor);
for (Jupiter::SLList<RenX::PlayerInfo>::Node *node = nPlayers.getNode(0); node != nullptr; node = node->next) for (auto node = nPlayers.begin(); node != nPlayers.end(); ++node)
output_player(node->data, nTeamColor); output_player(*node, nTeamColor);
for (Jupiter::SLList<RenX::PlayerInfo>::Node *node = oPlayers.getNode(0); node != nullptr; node = node->next) for (auto node = oPlayers.begin(); node != oPlayers.end(); ++node)
output_player(node->data, oTeamColor); output_player(*node, oTeamColor);
} }
else source->sendMessage(channel, STRING_LITERAL_AS_REFERENCE("No players are in-game.")); else source->sendMessage(channel, STRING_LITERAL_AS_REFERENCE("No players are in-game."));
} }
@ -683,10 +683,10 @@ void BuildingInfoIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableStr
{ {
int type = chan->getType(); int type = chan->getType();
bool seenStrip; bool seenStrip;
Jupiter::SLList<Jupiter::String> gStrings; std::forward_list<Jupiter::String *> gStrings;
Jupiter::SLList<Jupiter::String> nStrings; std::forward_list<Jupiter::String *> nStrings;
Jupiter::SLList<Jupiter::String> oStrings; std::forward_list<Jupiter::String *> oStrings;
Jupiter::SLList<Jupiter::String> cStrings; std::forward_list<Jupiter::String *> cStrings;
Jupiter::String *str = nullptr; Jupiter::String *str = nullptr;
RenX::BuildingInfo *building; RenX::BuildingInfo *building;
for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++) for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++)
@ -707,36 +707,42 @@ void BuildingInfoIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableStr
} }
str = new Jupiter::String(pluginInstance.getBuildingInfoFormat()); str = new Jupiter::String(pluginInstance.getBuildingInfoFormat());
RenX::processTags(*str, server, nullptr, nullptr, building); RenX::processTags(*str, server, nullptr, nullptr, building);
if (building->capturable) if (building->capturable)
cStrings.add(str); cStrings.push_front(str);
else if (building->team == RenX::TeamType::GDI) else if (building->team == RenX::TeamType::GDI)
gStrings.add(str); gStrings.push_front(str);
else if (building->team == RenX::TeamType::Nod) else if (building->team == RenX::TeamType::Nod)
nStrings.add(str); nStrings.push_front(str);
else else
oStrings.add(str); oStrings.push_front(str);
} }
while (gStrings.size() != 0)
while (gStrings.empty() == false)
{ {
str = gStrings.remove(0); str = gStrings.front();
gStrings.pop_front();
source->sendMessage(channel, *str); source->sendMessage(channel, *str);
delete str; delete str;
} }
while (nStrings.size() != 0) while (nStrings.empty() == false)
{ {
str = nStrings.remove(0); str = nStrings.front();
nStrings.pop_front();
source->sendMessage(channel, *str); source->sendMessage(channel, *str);
delete str; delete str;
} }
while (oStrings.size() != 0) while (oStrings.empty() == false)
{ {
str = oStrings.remove(0); str = oStrings.front();
oStrings.pop_front();
source->sendMessage(channel, *str); source->sendMessage(channel, *str);
delete str; delete str;
} }
while (cStrings.size() != 0) while (cStrings.empty() == false)
{ {
str = cStrings.remove(0); str = cStrings.front();
cStrings.pop_front();
source->sendMessage(channel, *str); source->sendMessage(channel, *str);
delete str; delete str;
} }

18
RenX.Core/RenX_LadderDatabase.cpp

@ -1,5 +1,5 @@
/** /**
* Copyright (C) 2015-2016 Jessica James. * Copyright (C) 2015-2017 Jessica James.
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@ -248,41 +248,41 @@ std::pair<RenX::LadderDatabase::Entry *, size_t> RenX::LadderDatabase::getPlayer
return std::pair<RenX::LadderDatabase::Entry *, size_t>(nullptr, Jupiter::INVALID_INDEX); return std::pair<RenX::LadderDatabase::Entry *, size_t>(nullptr, Jupiter::INVALID_INDEX);
} }
Jupiter::SLList<RenX::LadderDatabase::Entry> RenX::LadderDatabase::getPlayerEntriesByPartName(const Jupiter::ReadableString &name, size_t max) const std::forward_list<RenX::LadderDatabase::Entry> RenX::LadderDatabase::getPlayerEntriesByPartName(const Jupiter::ReadableString &name, size_t max) const
{ {
Jupiter::SLList<RenX::LadderDatabase::Entry> list; std::forward_list<RenX::LadderDatabase::Entry> list;
if (max == 0) if (max == 0)
{ {
for (RenX::LadderDatabase::Entry *itr = RenX::LadderDatabase::head; itr != nullptr; itr = itr->next) for (RenX::LadderDatabase::Entry *itr = RenX::LadderDatabase::head; itr != nullptr; itr = itr->next)
if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX) if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX)
list.add(new RenX::LadderDatabase::Entry(*itr)); list.emplace_front(*itr);
} }
else else
for (RenX::LadderDatabase::Entry *itr = RenX::LadderDatabase::head; itr != nullptr; itr = itr->next) for (RenX::LadderDatabase::Entry *itr = RenX::LadderDatabase::head; itr != nullptr; itr = itr->next)
if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX) if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX)
{ {
list.add(new RenX::LadderDatabase::Entry(*itr)); list.emplace_front(*itr);
if (--max == 0) if (--max == 0)
return list; return list;
} }
return list; return list;
} }
Jupiter::SLList<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(const Jupiter::ReadableString &name, size_t max) const
{ {
Jupiter::SLList<std::pair<RenX::LadderDatabase::Entry, size_t>> list; std::forward_list<std::pair<RenX::LadderDatabase::Entry, size_t>> list;
size_t index = 0; size_t index = 0;
if (max == 0) if (max == 0)
{ {
for (RenX::LadderDatabase::Entry *itr = RenX::LadderDatabase::head; itr != nullptr; itr = itr->next, ++index) for (RenX::LadderDatabase::Entry *itr = RenX::LadderDatabase::head; itr != nullptr; itr = itr->next, ++index)
if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX) if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX)
list.add(new std::pair<RenX::LadderDatabase::Entry, size_t>(*itr, index)); list.emplace_front(*itr, index);
} }
else else
for (RenX::LadderDatabase::Entry *itr = RenX::LadderDatabase::head; itr != nullptr; itr = itr->next, ++index) for (RenX::LadderDatabase::Entry *itr = RenX::LadderDatabase::head; itr != nullptr; itr = itr->next, ++index)
if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX) if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX)
{ {
list.add(new std::pair<RenX::LadderDatabase::Entry, size_t>(*itr, index)); list.emplace_front(*itr, index);
if (--max) if (--max)
return list; return list;
} }

8
RenX.Core/RenX_LadderDatabase.h

@ -1,5 +1,5 @@
/** /**
* Copyright (C) 2015-2016 Jessica James. * Copyright (C) 2015-2017 Jessica James.
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@ -20,9 +20,9 @@
#define _RENX_LADDERDATABASE_H_HEADER #define _RENX_LADDERDATABASE_H_HEADER
#include <chrono> #include <chrono>
#include <forward_list>
#include "Jupiter/Database.h" #include "Jupiter/Database.h"
#include "Jupiter/String.h" #include "Jupiter/String.h"
#include "Jupiter/SLList.h"
#include "Jupiter/ArrayList.h" #include "Jupiter/ArrayList.h"
#include "RenX.h" #include "RenX.h"
@ -128,8 +128,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.
*/ */
Jupiter::SLList<Entry> getPlayerEntriesByPartName(const Jupiter::ReadableString &name, size_t max) const; std::forward_list<Entry> getPlayerEntriesByPartName(const Jupiter::ReadableString &name, size_t max) const;
Jupiter::SLList<std::pair<Entry, size_t>> getPlayerEntriesAndIndexByPartName(const Jupiter::ReadableString &name, size_t max) const; std::forward_list<std::pair<Entry, size_t>> getPlayerEntriesAndIndexByPartName(const Jupiter::ReadableString &name, size_t max) const;
/** /**
* @brief Fetches a ladder entry at a specified index * @brief Fetches a ladder entry at a specified index

21
RenX.Ladder/RenX_Ladder.cpp

@ -1,5 +1,5 @@
/** /**
* Copyright (C) 2015-2016 Jessica James. * Copyright (C) 2015-2017 Jessica James.
* *
* Permission to use, copy, modify, and/or distribute this software for any * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@ -124,20 +124,21 @@ Jupiter::GenericCommand::ResponseLine *LadderGenericCommand::trigger(const Jupit
return new Jupiter::GenericCommand::ResponseLine(FormatLadderResponse(entry, rank), GenericCommand::DisplayType::PublicSuccess); return new Jupiter::GenericCommand::ResponseLine(FormatLadderResponse(entry, rank), GenericCommand::DisplayType::PublicSuccess);
} }
Jupiter::SLList<std::pair<RenX::LadderDatabase::Entry, size_t>> list = RenX::default_ladder_database->getPlayerEntriesAndIndexByPartName(parameters, pluginInstance.getMaxLadderCommandPartNameOutput()); std::forward_list<std::pair<RenX::LadderDatabase::Entry, size_t>> list = RenX::default_ladder_database->getPlayerEntriesAndIndexByPartName(parameters, pluginInstance.getMaxLadderCommandPartNameOutput());
if (list.size() == 0) if (list.empty())
return new Jupiter::GenericCommand::ResponseLine("Error: Player not found"_jrs, GenericCommand::DisplayType::PrivateError); return new Jupiter::GenericCommand::ResponseLine("Error: Player not found"_jrs, GenericCommand::DisplayType::PrivateError);
std::pair<RenX::LadderDatabase::Entry, size_t> *pair = list.remove(0); std::pair<RenX::LadderDatabase::Entry, size_t> &head_pair = list.front();
Jupiter::GenericCommand::ResponseLine *response_head = new Jupiter::GenericCommand::ResponseLine(FormatLadderResponse(std::addressof(pair->first), pair->second + 1), GenericCommand::DisplayType::PrivateSuccess); Jupiter::GenericCommand::ResponseLine *response_head = new Jupiter::GenericCommand::ResponseLine(FormatLadderResponse(std::addressof(head_pair.first), head_pair.second + 1), GenericCommand::DisplayType::PrivateSuccess);
Jupiter::GenericCommand::ResponseLine *response_end = response_head; Jupiter::GenericCommand::ResponseLine *response_end = response_head;
delete pair; list.pop_front();
while (list.size() != 0)
while (list.empty() == false)
{ {
pair = list.remove(0); std::pair<RenX::LadderDatabase::Entry, size_t> &pair = list.front();
response_end->next = new Jupiter::GenericCommand::ResponseLine(FormatLadderResponse(std::addressof(pair->first), pair->second + 1), GenericCommand::DisplayType::PrivateSuccess); response_end->next = new Jupiter::GenericCommand::ResponseLine(FormatLadderResponse(std::addressof(pair.first), pair.second + 1), GenericCommand::DisplayType::PrivateSuccess);
response_end = response_end->next; response_end = response_end->next;
delete pair; list.pop_front();
} }
return response_head; return response_head;
} }

Loading…
Cancel
Save