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>
*/
#include <forward_list>
#include "Jupiter/Functions.h"
#include "Jupiter/SLList.h"
#include "IRC_Bot.h"
#include "RenX_Commands.h"
#include "RenX_Core.h"
@ -505,9 +505,9 @@ void PlayerTableIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableStri
noServers = false;
if (server->players.size() != server->getBotCount())
{
Jupiter::SLList<RenX::PlayerInfo> gPlayers;
Jupiter::SLList<RenX::PlayerInfo> nPlayers;
Jupiter::SLList<RenX::PlayerInfo> oPlayers;
std::forward_list<RenX::PlayerInfo *> gPlayers;
std::forward_list<RenX::PlayerInfo *> nPlayers;
std::forward_list<RenX::PlayerInfo *> oPlayers;
STRING_LITERAL_AS_NAMED_REFERENCE(NICK_COL_HEADER, "Nickname");
size_t maxNickLen = 8;
@ -536,13 +536,13 @@ void PlayerTableIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableStri
switch (player->team)
{
case RenX::TeamType::GDI:
gPlayers.add(player);
gPlayers.push_front(player);
break;
case RenX::TeamType::Nod:
nPlayers.add(player);
nPlayers.push_front(player);
break;
default:
oPlayers.add(player);
oPlayers.push_front(player);
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));
};
for (Jupiter::SLList<RenX::PlayerInfo>::Node *node = gPlayers.getNode(0); node != nullptr; node = node->next)
output_player(node->data, gTeamColor);
for (auto node = gPlayers.begin(); node != gPlayers.end(); ++node)
output_player(*node, gTeamColor);
for (Jupiter::SLList<RenX::PlayerInfo>::Node *node = nPlayers.getNode(0); node != nullptr; node = node->next)
output_player(node->data, nTeamColor);
for (auto node = nPlayers.begin(); node != nPlayers.end(); ++node)
output_player(*node, nTeamColor);
for (Jupiter::SLList<RenX::PlayerInfo>::Node *node = oPlayers.getNode(0); node != nullptr; node = node->next)
output_player(node->data, oTeamColor);
for (auto node = oPlayers.begin(); node != oPlayers.end(); ++node)
output_player(*node, oTeamColor);
}
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();
bool seenStrip;
Jupiter::SLList<Jupiter::String> gStrings;
Jupiter::SLList<Jupiter::String> nStrings;
Jupiter::SLList<Jupiter::String> oStrings;
Jupiter::SLList<Jupiter::String> cStrings;
std::forward_list<Jupiter::String *> gStrings;
std::forward_list<Jupiter::String *> nStrings;
std::forward_list<Jupiter::String *> oStrings;
std::forward_list<Jupiter::String *> cStrings;
Jupiter::String *str = nullptr;
RenX::BuildingInfo *building;
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());
RenX::processTags(*str, server, nullptr, nullptr, building);
if (building->capturable)
cStrings.add(str);
cStrings.push_front(str);
else if (building->team == RenX::TeamType::GDI)
gStrings.add(str);
gStrings.push_front(str);
else if (building->team == RenX::TeamType::Nod)
nStrings.add(str);
nStrings.push_front(str);
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);
delete str;
}
while (nStrings.size() != 0)
while (nStrings.empty() == false)
{
str = nStrings.remove(0);
str = nStrings.front();
nStrings.pop_front();
source->sendMessage(channel, *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);
delete str;
}
while (cStrings.size() != 0)
while (cStrings.empty() == false)
{
str = cStrings.remove(0);
str = cStrings.front();
cStrings.pop_front();
source->sendMessage(channel, *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
* 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);
}
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)
{
for (RenX::LadderDatabase::Entry *itr = RenX::LadderDatabase::head; itr != nullptr; itr = itr->next)
if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX)
list.add(new RenX::LadderDatabase::Entry(*itr));
list.emplace_front(*itr);
}
else
for (RenX::LadderDatabase::Entry *itr = RenX::LadderDatabase::head; itr != nullptr; itr = itr->next)
if (itr->most_recent_name.findi(name) != Jupiter::INVALID_INDEX)
{
list.add(new RenX::LadderDatabase::Entry(*itr));
list.emplace_front(*itr);
if (--max == 0)
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;
if (max == 0)
{
for (RenX::LadderDatabase::Entry *itr = RenX::LadderDatabase::head; itr != nullptr; itr = itr->next, ++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
for (RenX::LadderDatabase::Entry *itr = RenX::LadderDatabase::head; itr != nullptr; itr = itr->next, ++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)
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
* purpose with or without fee is hereby granted, provided that the above
@ -20,9 +20,9 @@
#define _RENX_LADDERDATABASE_H_HEADER
#include <chrono>
#include <forward_list>
#include "Jupiter/Database.h"
#include "Jupiter/String.h"
#include "Jupiter/SLList.h"
#include "Jupiter/ArrayList.h"
#include "RenX.h"
@ -128,8 +128,8 @@ namespace RenX
* @param max Maximum number of entries to return
* @return List containing entries with matching names.
*/
Jupiter::SLList<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<Entry> getPlayerEntriesByPartName(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

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
* 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);
}
Jupiter::SLList<std::pair<RenX::LadderDatabase::Entry, size_t>> list = RenX::default_ladder_database->getPlayerEntriesAndIndexByPartName(parameters, pluginInstance.getMaxLadderCommandPartNameOutput());
if (list.size() == 0)
std::forward_list<std::pair<RenX::LadderDatabase::Entry, size_t>> list = RenX::default_ladder_database->getPlayerEntriesAndIndexByPartName(parameters, pluginInstance.getMaxLadderCommandPartNameOutput());
if (list.empty())
return new Jupiter::GenericCommand::ResponseLine("Error: Player not found"_jrs, GenericCommand::DisplayType::PrivateError);
std::pair<RenX::LadderDatabase::Entry, size_t> *pair = list.remove(0);
Jupiter::GenericCommand::ResponseLine *response_head = new Jupiter::GenericCommand::ResponseLine(FormatLadderResponse(std::addressof(pair->first), pair->second + 1), GenericCommand::DisplayType::PrivateSuccess);
std::pair<RenX::LadderDatabase::Entry, size_t> &head_pair = list.front();
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;
delete pair;
while (list.size() != 0)
list.pop_front();
while (list.empty() == false)
{
pair = list.remove(0);
response_end->next = new Jupiter::GenericCommand::ResponseLine(FormatLadderResponse(std::addressof(pair->first), pair->second + 1), GenericCommand::DisplayType::PrivateSuccess);
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 = response_end->next;
delete pair;
list.pop_front();
}
return response_head;
}

Loading…
Cancel
Save