Browse Source

* Added full support for multiple ladder databases.

* Removed ladder database from RenX.Ladder
* Added ladder databases: All-Time, Yearly, Monthly, Weekly, Daily
* Search/database input objects are now generated in RenX.Ladder.Web
* "gameover" IRC Command now accepts "stop" as a parameter for cancelling delayed gameovers
pull/3/head
Jessica James 9 years ago
parent
commit
1e08f6035e
  1. 2
      Jupiter
  2. 53
      Jupiter Bot.sln
  3. BIN
      Release/Bot.lib
  4. BIN
      Release/Plugins/RenX.Core.lib
  5. 25
      RenX.Commands/RenX_Commands.cpp
  6. 70
      RenX.Core/RenX_LadderDatabase.cpp
  7. 71
      RenX.Core/RenX_LadderDatabase.h
  8. 7
      RenX.Core/RenX_Server.h
  9. 2
      RenX.Core/RenX_Tags.h
  10. 85
      RenX.Ladder.All-Time/RenX.Ladder.All-Time.vcxproj
  11. 38
      RenX.Ladder.All-Time/RenX.Ladder.All-Time.vcxproj.filters
  12. 42
      RenX.Ladder.All-Time/RenX_Ladder_All_Time.cpp
  13. 38
      RenX.Ladder.All-Time/RenX_Ladder_All_Time.h
  14. 85
      RenX.Ladder.Daily/RenX.Ladder.Daily.vcxproj
  15. 38
      RenX.Ladder.Daily/RenX.Ladder.Daily.vcxproj.filters
  16. 54
      RenX.Ladder.Daily/RenX_Ladder_Daily.cpp
  17. 42
      RenX.Ladder.Daily/RenX_Ladder_Daily.h
  18. 85
      RenX.Ladder.Monthly/RenX.Ladder.Monthly.vcxproj
  19. 38
      RenX.Ladder.Monthly/RenX.Ladder.Monthly.vcxproj.filters
  20. 54
      RenX.Ladder.Monthly/RenX_Ladder_Monthly.cpp
  21. 42
      RenX.Ladder.Monthly/RenX_Ladder_Monthly.h
  22. 161
      RenX.Ladder.Web/RenX_Ladder_Web.cpp
  23. 8
      RenX.Ladder.Web/RenX_Ladder_Web.h
  24. 85
      RenX.Ladder.Weekly/RenX.Ladder.Weekly.vcxproj
  25. 38
      RenX.Ladder.Weekly/RenX.Ladder.Weekly.vcxproj.filters
  26. 55
      RenX.Ladder.Weekly/RenX_Ladder_Weekly.cpp
  27. 43
      RenX.Ladder.Weekly/RenX_Ladder_Weekly.h
  28. 85
      RenX.Ladder.Yearly/RenX.Ladder.Yearly.vcxproj
  29. 38
      RenX.Ladder.Yearly/RenX.Ladder.Yearly.vcxproj.filters
  30. 54
      RenX.Ladder.Yearly/RenX_Ladder_Yearly.cpp
  31. 42
      RenX.Ladder.Yearly/RenX_Ladder_Yearly.h
  32. 13
      RenX.Ladder/RenX_Ladder.cpp
  33. 4
      RenX.Ladder/RenX_Ladder.h

2
Jupiter

@ -1 +1 @@
Subproject commit 0fba343102afa3d397e613c85ca451d0085522f8
Subproject commit 1df5bee1d49817471d9151b019dd244a610069eb

53
Jupiter Bot.sln

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Bot", "Bot\Bot.vcxproj", "{C188871B-5F32-4946-B301-24CA2EBB275D}"
EndProject
@ -178,7 +178,36 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenX.Ladder.Web", "RenX.Lad
{C188871B-5F32-4946-B301-24CA2EBB275D} = {C188871B-5F32-4946-B301-24CA2EBB275D}
{9103DF3D-8B4A-48E5-A6B3-CBE2554630E2} = {9103DF3D-8B4A-48E5-A6B3-CBE2554630E2}
{BB048D6F-F001-4E9B-95F4-886081E0807A} = {BB048D6F-F001-4E9B-95F4-886081E0807A}
{B2846BD6-2332-4DA6-A13B-113318F76D5E} = {B2846BD6-2332-4DA6-A13B-113318F76D5E}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenX.Ladder.All-Time", "RenX.Ladder.All-Time\RenX.Ladder.All-Time.vcxproj", "{24B039D0-5A71-4F76-8908-BAD772FDBE1A}"
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
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenX.Ladder.Monthly", "RenX.Ladder.Monthly\RenX.Ladder.Monthly.vcxproj", "{34FDE301-A29D-44ED-8ECC-15693F137DE2}"
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
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenX.Ladder.Yearly", "RenX.Ladder.Yearly\RenX.Ladder.Yearly.vcxproj", "{075AF69B-71D6-43B9-B102-4649CB2CA40C}"
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
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenX.Ladder.Weekly", "RenX.Ladder.Weekly\RenX.Ladder.Weekly.vcxproj", "{6F0141F3-CF64-47D9-8EC2-80A38FAFDAC7}"
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
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenX.Ladder.Daily", "RenX.Ladder.Daily\RenX.Ladder.Daily.vcxproj", "{73F0EEF6-CE5E-46EB-80B4-2B319AE2B258}"
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
@ -311,6 +340,26 @@ Global
{57661A2A-EE94-4E9C-B792-AB756533DEFA}.Debug|Win32.Build.0 = Debug|Win32
{57661A2A-EE94-4E9C-B792-AB756533DEFA}.Release|Win32.ActiveCfg = Release|Win32
{57661A2A-EE94-4E9C-B792-AB756533DEFA}.Release|Win32.Build.0 = Release|Win32
{24B039D0-5A71-4F76-8908-BAD772FDBE1A}.Debug|Win32.ActiveCfg = Debug|Win32
{24B039D0-5A71-4F76-8908-BAD772FDBE1A}.Debug|Win32.Build.0 = Debug|Win32
{24B039D0-5A71-4F76-8908-BAD772FDBE1A}.Release|Win32.ActiveCfg = Release|Win32
{24B039D0-5A71-4F76-8908-BAD772FDBE1A}.Release|Win32.Build.0 = Release|Win32
{34FDE301-A29D-44ED-8ECC-15693F137DE2}.Debug|Win32.ActiveCfg = Debug|Win32
{34FDE301-A29D-44ED-8ECC-15693F137DE2}.Debug|Win32.Build.0 = Debug|Win32
{34FDE301-A29D-44ED-8ECC-15693F137DE2}.Release|Win32.ActiveCfg = Release|Win32
{34FDE301-A29D-44ED-8ECC-15693F137DE2}.Release|Win32.Build.0 = Release|Win32
{075AF69B-71D6-43B9-B102-4649CB2CA40C}.Debug|Win32.ActiveCfg = Debug|Win32
{075AF69B-71D6-43B9-B102-4649CB2CA40C}.Debug|Win32.Build.0 = Debug|Win32
{075AF69B-71D6-43B9-B102-4649CB2CA40C}.Release|Win32.ActiveCfg = Release|Win32
{075AF69B-71D6-43B9-B102-4649CB2CA40C}.Release|Win32.Build.0 = Release|Win32
{6F0141F3-CF64-47D9-8EC2-80A38FAFDAC7}.Debug|Win32.ActiveCfg = Debug|Win32
{6F0141F3-CF64-47D9-8EC2-80A38FAFDAC7}.Debug|Win32.Build.0 = Debug|Win32
{6F0141F3-CF64-47D9-8EC2-80A38FAFDAC7}.Release|Win32.ActiveCfg = Release|Win32
{6F0141F3-CF64-47D9-8EC2-80A38FAFDAC7}.Release|Win32.Build.0 = Release|Win32
{73F0EEF6-CE5E-46EB-80B4-2B319AE2B258}.Debug|Win32.ActiveCfg = Debug|Win32
{73F0EEF6-CE5E-46EB-80B4-2B319AE2B258}.Debug|Win32.Build.0 = Debug|Win32
{73F0EEF6-CE5E-46EB-80B4-2B319AE2B258}.Release|Win32.ActiveCfg = Release|Win32
{73F0EEF6-CE5E-46EB-80B4-2B319AE2B258}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

BIN
Release/Bot.lib

Binary file not shown.

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

25
RenX.Commands/RenX_Commands.cpp

@ -1307,6 +1307,8 @@ void GameOverIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString
{
int type = chan->getType();
bool match = false;
std::chrono::seconds delay;
for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++)
{
RenX::Server *server = RenX::getCore()->getServer(i);
@ -1317,15 +1319,28 @@ void GameOverIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString
server->gameoverWhenEmpty();
if (parameters.equalsi("if empty"_jrs))
{
if (server->players.size() == 0)
if (server->players.size() == server->getBotCount())
server->gameover();
}
else if (parameters.equalsi("now"_jrs))
server->gameover();
else if (parameters.isEmpty())
server->gameover(std::chrono::seconds(10));
else if (parameters.equalsi("stop"_jrs) || parameters.equalsi("cancel"_jrs))
{
if (server->gameoverStop())
server->sendMessage("Notice: The scheduled gameover has been cancelled."_jrs);
else
source->sendNotice(nick, "Error: There is no gameover scheduled."_jrs);
}
else
server->gameover(std::chrono::seconds(parameters.asInt()));
{
if (parameters.isEmpty())
delay = std::chrono::seconds(10);
else
delay = std::chrono::seconds(parameters.asLongLong());
server->sendMessage(Jupiter::StringS::Format("Notice: This server will gameover in %lld seconds.", static_cast<long long>(delay.count())));
server->gameover(delay);
}
}
}
if (match == false)
@ -1335,7 +1350,7 @@ void GameOverIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString
const Jupiter::ReadableString &GameOverIRCCommand::getHelp(const Jupiter::ReadableString &)
{
static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Ends the game immediately. Syntax: Gameover [NOW | Empty | Seconds = 10]");
static STRING_LITERAL_AS_NAMED_REFERENCE(defaultHelp, "Forcefully ends the game in progress. Syntax: Gameover [NOW | STOP | Empty | Seconds = 10]");
return defaultHelp;
}

70
RenX.Core/RenX_LadderDatabase.cpp

@ -1,32 +1,41 @@
/**
* Copyright (C) 2015-2016 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
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
* Copyright (C) 2015-2016 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
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
#include "RenX_LadderDatabase.h"
#include "RenX_Server.h"
#include "RenX_PlayerInfo.h"
#include "RenX_BanDatabase.h"
RenX::LadderDatabase *RenX::default_ladder_database = nullptr;
Jupiter::ArrayList<RenX::LadderDatabase> _ladder_databases;
Jupiter::ArrayList<RenX::LadderDatabase> &RenX::ladder_databases = _ladder_databases;
RenX::LadderDatabase::LadderDatabase()
{
_ladder_databases.add(this);
if (RenX::default_ladder_database == nullptr)
RenX::default_ladder_database = this;
}
RenX::LadderDatabase::LadderDatabase(const Jupiter::ReadableString &in_name) : LadderDatabase()
{
RenX::LadderDatabase::setName(in_name);
}
RenX::LadderDatabase::~LadderDatabase()
@ -37,6 +46,21 @@ RenX::LadderDatabase::~LadderDatabase()
RenX::LadderDatabase::head = RenX::LadderDatabase::head->next;
delete RenX::LadderDatabase::end;
}
for (size_t index = 0; index != _ladder_databases.size(); ++index)
if (_ladder_databases.get(index) == this)
{
_ladder_databases.remove(index);
break;
}
if (RenX::default_ladder_database == this)
{
if (_ladder_databases.size() == 0)
RenX::default_ladder_database = nullptr;
else
RenX::default_ladder_database = _ladder_databases.get(0);
}
}
void RenX::LadderDatabase::process_data(Jupiter::DataBuffer &buffer, FILE *file, fpos_t pos)
@ -371,6 +395,10 @@ void RenX::LadderDatabase::updateLadder(RenX::Server *server, const RenX::TeamTy
{
if (server->players.size() != server->getBotCount())
{
// call the PreUpdateLadder event
if (this->OnPreUpdateLadder != nullptr)
this->OnPreUpdateLadder(*this, server, team, output_times);
// update player stats in memory
RenX::PlayerInfo *player;
RenX::LadderDatabase::Entry *entry;
@ -482,3 +510,13 @@ void RenX::LadderDatabase::erase()
RenX::LadderDatabase::end = nullptr;
}
}
const Jupiter::ReadableString &RenX::LadderDatabase::getName() const
{
return RenX::LadderDatabase::name;
}
void RenX::LadderDatabase::setName(const Jupiter::ReadableString &in_name)
{
RenX::LadderDatabase::name = in_name;
}

71
RenX.Core/RenX_LadderDatabase.h

@ -1,20 +1,20 @@
/**
* Copyright (C) 2015-2016 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
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
* Copyright (C) 2015-2016 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
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
#if !defined _RENX_LADDERDATABASE_H_HEADER
#define _RENX_LADDERDATABASE_H_HEADER
@ -39,13 +39,14 @@ namespace RenX
class RENX_API LadderDatabase : public Jupiter::Database
{
public: // Jupiter::Database
/**
* @brief Processes a chunk of data in a database.
*
* @param buffer Buffer to process
* @param file File being processed
* @param pos position that the buffer starts at in the file
*/
/**
* @brief Processes a chunk of data in a database.
*
* @param buffer Buffer to process
* @param file File being processed
* @param pos position that the buffer starts at in the file
*/
void process_data(Jupiter::DataBuffer &buffer, FILE *file, fpos_t pos) override;
/**
@ -174,27 +175,47 @@ namespace RenX
*/
void erase();
/**
* @brief Gets the name of this database.
*/
const Jupiter::ReadableString &getName() const;
/**
* @brief Sets the name of this database.
*/
void setName(const Jupiter::ReadableString &in_name);
/**
* @brief Constructor for the LadderDatabase class
*/
LadderDatabase();
/**
* @brief Named constructor for the LadderDatabase class
*/
LadderDatabase(const Jupiter::ReadableString &in_name);
/**
* @brief Deconstructor for the LadderDatabase class
*/
~LadderDatabase();
private:
typedef void PreUpdateLadderFunction(RenX::LadderDatabase &database, RenX::Server *server, const RenX::TeamType &team, bool output_times);
PreUpdateLadderFunction *OnPreUpdateLadder = nullptr;
private:
/** Database version */
const uint8_t write_version = 0;
uint8_t read_version = write_version;
Jupiter::StringS name;
std::chrono::steady_clock::time_point last_sort = std::chrono::steady_clock::now();
size_t entries = 0;
Entry *head = nullptr;
Entry *end;
Entry *end = nullptr;
};
RENX_API extern RenX::LadderDatabase *default_ladder_database;
RENX_API extern Jupiter::ArrayList<RenX::LadderDatabase> &ladder_databases;
}

7
RenX.Core/RenX_Server.h

@ -430,6 +430,13 @@ namespace RenX
*/
void gameover(std::chrono::seconds delay);
/**
* @brief Prevents a delayed gameover from starting.
*
* @return True if a delayed gameover was stopped, false otherwise.
*/
bool gameoverStop();
/**
* @brief Forces the game to end when the server is empty
*/

2
RenX.Core/RenX_Tags.h

@ -1,5 +1,5 @@
/**
* Copyright (C) 2015 Jessica James.
* Copyright (C) 2015-2016 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

85
RenX.Ladder.All-Time/RenX.Ladder.All-Time.vcxproj

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{24B039D0-5A71-4F76-8908-BAD772FDBE1A}</ProjectGuid>
<RootNamespace>RenX.Ladder.All-Time</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\Plugins\</OutDir>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../Bot;../Jupiter;../RenX.Core</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="RenX_Ladder_All_Time.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="RenX_Ladder_All_Time.cpp" />
</ItemGroup>
<ItemGroup>
<Library Include="..\Jupiter\Release\Jupiter.lib" />
<Library Include="..\Release\Bot.lib" />
<Library Include="..\Release\Plugins\RenX.Core.lib" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

38
RenX.Ladder.All-Time/RenX.Ladder.All-Time.vcxproj.filters

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Library Include="..\Release\Plugins\RenX.Core.lib">
<Filter>Resource Files</Filter>
</Library>
<Library Include="..\Release\Bot.lib">
<Filter>Resource Files</Filter>
</Library>
<Library Include="..\Jupiter\Release\Jupiter.lib">
<Filter>Resource Files</Filter>
</Library>
</ItemGroup>
<ItemGroup>
<ClInclude Include="RenX_Ladder_All_Time.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="RenX_Ladder_All_Time.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

42
RenX.Ladder.All-Time/RenX_Ladder_All_Time.cpp

@ -0,0 +1,42 @@
/**
* Copyright (C) 2016 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
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
#include "Jupiter/INIFile.h"
#include "Jupiter/IRC_Client.h"
#include "RenX_Ladder_All_Time.h"
using namespace Jupiter::literals;
RenX_Ladder_All_TimePlugin::RenX_Ladder_All_TimePlugin()
{
// Load database
this->database.process_file(Jupiter::IRC::Client::Config->get(this->getName(), "LadderDatabase"_jrs, "Ladder.db"_jrs));
this->database.setName(Jupiter::IRC::Client::Config->get(this->getName(), "DatabaseName"_jrs, "All-Time"_jrs));
// Force database to default, if desired
if (Jupiter::IRC::Client::Config->getBool(this->getName(), "ForceDefault"_jrs, false))
RenX::default_ladder_database = &this->database;
}
// Plugin instantiation and entry point.
RenX_Ladder_All_TimePlugin pluginInstance;
extern "C" __declspec(dllexport) Jupiter::Plugin *getPlugin()
{
return &pluginInstance;
}

38
RenX.Ladder.All-Time/RenX_Ladder_All_Time.h

@ -0,0 +1,38 @@
/**
* Copyright (C) 2016 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
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
#if !defined _RENX_LADDER_ALL_TIME
#define _RENX_LADDER_ALL_TIME
#include "Jupiter/Plugin.h"
#include "Jupiter/Reference_String.h"
#include "RenX_Plugin.h"
#include "RenX_LadderDatabase.h"
class RenX_Ladder_All_TimePlugin : public RenX::Plugin
{
public:
const Jupiter::ReadableString &getName() override { return name; }
RenX_Ladder_All_TimePlugin();
private:
RenX::LadderDatabase database;
STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.Ladder.All-Time");
};
#endif // _RENX_LADDER_ALL_TIME

85
RenX.Ladder.Daily/RenX.Ladder.Daily.vcxproj

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{73F0EEF6-CE5E-46EB-80B4-2B319AE2B258}</ProjectGuid>
<RootNamespace>RenX.Ladder.Daily</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\Plugins\</OutDir>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../Bot;../Jupiter;../RenX.Core</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="RenX_Ladder_Daily.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="RenX_Ladder_Daily.cpp" />
</ItemGroup>
<ItemGroup>
<Library Include="..\Jupiter\Release\Jupiter.lib" />
<Library Include="..\Release\Bot.lib" />
<Library Include="..\Release\Plugins\RenX.Core.lib" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

38
RenX.Ladder.Daily/RenX.Ladder.Daily.vcxproj.filters

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="RenX_Ladder_Daily.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Library Include="..\Release\Plugins\RenX.Core.lib">
<Filter>Resource Files</Filter>
</Library>
<Library Include="..\Release\Bot.lib">
<Filter>Resource Files</Filter>
</Library>
<Library Include="..\Jupiter\Release\Jupiter.lib">
<Filter>Resource Files</Filter>
</Library>
</ItemGroup>
<ItemGroup>
<ClInclude Include="RenX_Ladder_Daily.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

54
RenX.Ladder.Daily/RenX_Ladder_Daily.cpp

@ -0,0 +1,54 @@
/**
* Copyright (C) 2016 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
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
#include <ctime>
#include "Jupiter/INIFile.h"
#include "Jupiter/IRC_Client.h"
#include "RenX_Ladder_Daily.h"
using namespace Jupiter::literals;
RenX_Ladder_Daily_TimePlugin::RenX_Ladder_Daily_TimePlugin()
{
// Load database
this->database.process_file(Jupiter::IRC::Client::Config->get(this->getName(), "LadderDatabase"_jrs, "Ladder.Daily.db"_jrs));
this->database.setName(Jupiter::IRC::Client::Config->get(this->getName(), "DatabaseName"_jrs, "Daily"_jrs));
this->last_sorted_day = gmtime(std::addressof<const time_t>(time(0)))->tm_wday;
this->database.OnPreUpdateLadder = OnPreUpdateLadder;
// Force database to default, if desired
if (Jupiter::IRC::Client::Config->getBool(this->getName(), "ForceDefault"_jrs, false))
RenX::default_ladder_database = &this->database;
}
// Plugin instantiation and entry point.
RenX_Ladder_Daily_TimePlugin pluginInstance;
void OnPreUpdateLadder(RenX::LadderDatabase &database, RenX::Server *server, const RenX::TeamType &team, bool output_times)
{
tm *tm_ptr = gmtime(std::addressof<const time_t>(time(0)));
if (pluginInstance.last_sorted_day != tm_ptr->tm_wday)
database.erase();
pluginInstance.last_sorted_day = tm_ptr->tm_wday;
}
extern "C" __declspec(dllexport) Jupiter::Plugin *getPlugin()
{
return &pluginInstance;
}

42
RenX.Ladder.Daily/RenX_Ladder_Daily.h

@ -0,0 +1,42 @@
/**
* Copyright (C) 2016 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
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
#if !defined _RENX_LADDER_ALL_TIME
#define _RENX_LADDER_ALL_TIME
#include "Jupiter/Plugin.h"
#include "Jupiter/Reference_String.h"
#include "RenX_Plugin.h"
#include "RenX_LadderDatabase.h"
class RenX_Ladder_Daily_TimePlugin : public RenX::Plugin
{
public:
const Jupiter::ReadableString &getName() override { return name; }
RenX_Ladder_Daily_TimePlugin();
int last_sorted_day = 0;
private:
RenX::LadderDatabase database;
STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.Ladder.Daily");
};
void OnPreUpdateLadder(RenX::LadderDatabase &database, RenX::Server *server, const RenX::TeamType &team, bool output_times);
#endif // _RENX_LADDER_ALL_TIME

85
RenX.Ladder.Monthly/RenX.Ladder.Monthly.vcxproj

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{34FDE301-A29D-44ED-8ECC-15693F137DE2}</ProjectGuid>
<RootNamespace>RenX.Ladder.Monthly</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\Plugins\</OutDir>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../Bot;../Jupiter;../RenX.Core</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="RenX_Ladder_Monthly.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="RenX_Ladder_Monthly.cpp" />
</ItemGroup>
<ItemGroup>
<Library Include="..\Jupiter\Release\Jupiter.lib" />
<Library Include="..\Release\Bot.lib" />
<Library Include="..\Release\Plugins\RenX.Core.lib" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

38
RenX.Ladder.Monthly/RenX.Ladder.Monthly.vcxproj.filters

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="RenX_Ladder_Monthly.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Library Include="..\Release\Plugins\RenX.Core.lib">
<Filter>Resource Files</Filter>
</Library>
<Library Include="..\Release\Bot.lib">
<Filter>Resource Files</Filter>
</Library>
<Library Include="..\Jupiter\Release\Jupiter.lib">
<Filter>Resource Files</Filter>
</Library>
</ItemGroup>
<ItemGroup>
<ClInclude Include="RenX_Ladder_Monthly.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

54
RenX.Ladder.Monthly/RenX_Ladder_Monthly.cpp

@ -0,0 +1,54 @@
/**
* Copyright (C) 2016 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
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
#include <ctime>
#include "Jupiter/INIFile.h"
#include "Jupiter/IRC_Client.h"
#include "RenX_Ladder_Monthly.h"
using namespace Jupiter::literals;
RenX_Ladder_Monthly_TimePlugin::RenX_Ladder_Monthly_TimePlugin()
{
// Load database
this->database.process_file(Jupiter::IRC::Client::Config->get(this->getName(), "LadderDatabase"_jrs, "Ladder.Monthly.db"_jrs));
this->database.setName(Jupiter::IRC::Client::Config->get(this->getName(), "DatabaseName"_jrs, "Monthly"_jrs));
this->last_sorted_month = gmtime(std::addressof<const time_t>(time(0)))->tm_mon;
this->database.OnPreUpdateLadder = OnPreUpdateLadder;
// Force database to default, if desired
if (Jupiter::IRC::Client::Config->getBool(this->getName(), "ForceDefault"_jrs, false))
RenX::default_ladder_database = &this->database;
}
// Plugin instantiation and entry point.
RenX_Ladder_Monthly_TimePlugin pluginInstance;
void OnPreUpdateLadder(RenX::LadderDatabase &database, RenX::Server *server, const RenX::TeamType &team, bool output_times)
{
tm *tm_ptr = gmtime(std::addressof<const time_t>(time(0)));
if (pluginInstance.last_sorted_month != tm_ptr->tm_mon)
database.erase();
pluginInstance.last_sorted_month = tm_ptr->tm_mon;
}
extern "C" __declspec(dllexport) Jupiter::Plugin *getPlugin()
{
return &pluginInstance;
}

42
RenX.Ladder.Monthly/RenX_Ladder_Monthly.h

@ -0,0 +1,42 @@
/**
* Copyright (C) 2016 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
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
#if !defined _RENX_LADDER_ALL_TIME
#define _RENX_LADDER_ALL_TIME
#include "Jupiter/Plugin.h"
#include "Jupiter/Reference_String.h"
#include "RenX_Plugin.h"
#include "RenX_LadderDatabase.h"
class RenX_Ladder_Monthly_TimePlugin : public RenX::Plugin
{
public:
const Jupiter::ReadableString &getName() override { return name; }
RenX_Ladder_Monthly_TimePlugin();
int last_sorted_month = 0;
private:
RenX::LadderDatabase database;
STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.Ladder.Monthly");
};
void OnPreUpdateLadder(RenX::LadderDatabase &database, RenX::Server *server, const RenX::TeamType &team, bool output_times);
#endif // _RENX_LADDER_ALL_TIME

161
RenX.Ladder.Web/RenX_Ladder_Web.cpp

@ -150,15 +150,62 @@ int RenX_Ladder_WebPlugin::OnRehash()
return 0;
}
/** Ladder page */
/** Search bar */
Jupiter::String generate_search(RenX::LadderDatabase *db)
{
Jupiter::String result(256);
result = R"database-search(<form action="search" method="get" class="leaderboard-search"><input type="text" class="leaderboard-input" name="name" size="30" placeholder="Player name" value=""/>)database-search"_jrs;
if (db != nullptr && db != RenX::default_ladder_database)
{
result += R"database-search(<input type="hidden" name="database" value=")database-search"_jrs;
result += db->getName();
result += R"database-search("/>)database-search"_jrs;
}
result += R"database-search(<input type="submit" class="leaderboard-input" value="Search"/></form>)database-search"_jrs;
return result;
}
Jupiter::String RenX_Ladder_WebPlugin::generate_entry_table(size_t index, size_t count)
/** Database selector */
Jupiter::String generate_database_selector(RenX::LadderDatabase *db)
{
if (RenX::ladder_databases.size() == 0)
return Jupiter::String("Error: No ladder databases loaded"_jrs);
RenX::LadderDatabase *db_ptr;
Jupiter::String result(256);
result = R"database-select(<form method="get" class="database-select-form"><select name="database" class="database-select">)database-select"_jrs;
if (db != nullptr)
{
result += "<option value=\""_jrs;
result += db->getName();
result += "\">"_jrs;
result += db->getName();
result += "</option>"_jrs;
}
else if (RenX::ladder_databases.size() == 0)
return Jupiter::String::empty;
for (size_t index = 0; index != RenX::ladder_databases.size(); ++index)
{
db_ptr = RenX::ladder_databases.get(index);
if (db_ptr != db)
{
db_ptr = RenX::ladder_databases.get(index);
result += "<option value=\""_jrs;
result += db_ptr->getName();
result += "\">"_jrs;
result += db_ptr->getName();
result += "</option>"_jrs;
}
}
result += R"database-select(</select><input type="submit" class="leaderboard-input" value="Go"/></form>)database-select"_jrs;
return result;
}
RenX::LadderDatabase *db = RenX::ladder_databases.get(0);
/** Ladder page */
Jupiter::String RenX_Ladder_WebPlugin::generate_entry_table(RenX::LadderDatabase *db, size_t index, size_t count)
{
if (db->getEntries() == 0) // No ladder data
return Jupiter::String("Error: No ladder data"_jrs);
@ -197,27 +244,22 @@ Jupiter::String RenX_Ladder_WebPlugin::generate_entry_table(size_t index, size_t
return result;
}
Jupiter::String *RenX_Ladder_WebPlugin::generate_ladder_page(size_t index, size_t count)
Jupiter::String *RenX_Ladder_WebPlugin::generate_ladder_page(RenX::LadderDatabase *db, size_t index, size_t count)
{
Jupiter::String *result = new Jupiter::String(RenX_Ladder_WebPlugin::header);
result->concat(this->generate_entry_table(index, count));
result->concat(generate_search(db));
result->concat(generate_database_selector(db));
result->concat(this->generate_entry_table(db, index, count));
result->concat(RenX_Ladder_WebPlugin::footer);
return result;
}
/** Search page */
Jupiter::String *RenX_Ladder_WebPlugin::generate_search_page(const Jupiter::ReadableString &name)
Jupiter::String *RenX_Ladder_WebPlugin::generate_search_page(RenX::LadderDatabase *db, const Jupiter::ReadableString &name)
{
Jupiter::String *result = new Jupiter::String(RenX_Ladder_WebPlugin::header);
if (RenX::ladder_databases.size() == 0)
{
result->concat("Error: No ladder databases loaded"_jrs);
result->concat(RenX_Ladder_WebPlugin::footer);
return result;
}
RenX::LadderDatabase *db = RenX::ladder_databases.get(0);
result->concat(generate_search(db));
result->concat(generate_database_selector(db));
if (db->getEntries() == 0) // No ladder data
{
@ -248,18 +290,11 @@ Jupiter::String *RenX_Ladder_WebPlugin::generate_search_page(const Jupiter::Read
}
/** Profile page */
Jupiter::String *RenX_Ladder_WebPlugin::generate_profile_page(uint64_t steam_id)
Jupiter::String *RenX_Ladder_WebPlugin::generate_profile_page(RenX::LadderDatabase *db, uint64_t steam_id)
{
Jupiter::String *result = new Jupiter::String(RenX_Ladder_WebPlugin::header);
if (RenX::ladder_databases.size() == 0)
{
result->concat("Error: No ladder databases loaded"_jrs);
result->concat(RenX_Ladder_WebPlugin::footer);
return result;
}
RenX::LadderDatabase *db = RenX::ladder_databases.get(0);
result->concat(generate_search(db));
result->concat(generate_database_selector(db));
if (db->getEntries() == 0) // No ladder data
{
@ -294,8 +329,24 @@ RenX_Ladder_WebPlugin pluginInstance;
/** Content functions */
Jupiter::ReadableString *generate_no_db_page()
{
Jupiter::String *result = new Jupiter::String(pluginInstance.header);
if (RenX::ladder_databases.size() != 0)
{
result->concat(generate_search(nullptr));
result->concat(generate_database_selector(nullptr));
result->concat("Error: No such database exists"_jrs);
}
else
result->concat("Error: No ladder databases loaded"_jrs);
result->concat(pluginInstance.footer);
return result;
}
Jupiter::ReadableString *handle_ladder_page(const Jupiter::ReadableString &query_string)
{
RenX::LadderDatabase *db = RenX::default_ladder_database;
size_t start_index = 0, count = 50;
if (query_string.isNotEmpty())
@ -303,35 +354,85 @@ Jupiter::ReadableString *handle_ladder_page(const Jupiter::ReadableString &query
Jupiter::HTTP::HTMLFormResponse html_form_response(query_string);
start_index = static_cast<size_t>(html_form_response.table.getInt("start"_jrs, 0));
count = static_cast<size_t>(html_form_response.table.getInt("count"_jrs, 50));
const Jupiter::ReadableString &db_name = html_form_response.table.get("database"_jrs);
if (db_name.isNotEmpty())
{
db = nullptr;
for (size_t index = 0; index != RenX::ladder_databases.size(); ++index)
if (RenX::ladder_databases.get(index)->getName().equalsi(db_name))
{
db = RenX::ladder_databases.get(index);
break;
}
}
}
return pluginInstance.generate_ladder_page(start_index, count);
if (db == nullptr)
return generate_no_db_page();
return pluginInstance.generate_ladder_page(db, start_index, count);
}
Jupiter::ReadableString *handle_search_page(const Jupiter::ReadableString &query_string)
{
RenX::LadderDatabase *db = RenX::default_ladder_database;
Jupiter::ReferenceString name;
if (query_string.isNotEmpty())
{
Jupiter::HTTP::HTMLFormResponse html_form_response(query_string);
name = html_form_response.table.get("name"_jrs);
const Jupiter::ReadableString &db_name = html_form_response.table.get("database"_jrs);
if (db_name.isNotEmpty())
{
db = nullptr;
for (size_t index = 0; index != RenX::ladder_databases.size(); ++index)
if (RenX::ladder_databases.get(index)->getName().equalsi(db_name))
{
db = RenX::ladder_databases.get(index);
break;
}
}
}
if (db == nullptr)
return generate_no_db_page();
if (name.isEmpty()) // Generate ladder page when no name specified
return handle_ladder_page(query_string);
return pluginInstance.generate_search_page(name);
return pluginInstance.generate_search_page(db, name);
}
Jupiter::ReadableString *handle_profile_page(const Jupiter::ReadableString &query_string)
{
RenX::LadderDatabase *db = RenX::default_ladder_database;
uint64_t steam_id = 0;
if (query_string.isNotEmpty())
{
Jupiter::HTTP::HTMLFormResponse html_form_response(query_string);
steam_id = html_form_response.table.getLongLong("id"_jrs);
const Jupiter::ReadableString &db_name = html_form_response.table.get("database"_jrs);
if (db_name.isNotEmpty())
{
db = nullptr;
for (size_t index = 0; index != RenX::ladder_databases.size(); ++index)
if (RenX::ladder_databases.get(index)->getName().equalsi(db_name))
{
db = RenX::ladder_databases.get(index);
break;
}
}
}
return pluginInstance.generate_profile_page(steam_id);
if (db == nullptr)
return generate_no_db_page();
return pluginInstance.generate_profile_page(db, steam_id);
}
extern "C" __declspec(dllexport) Jupiter::Plugin *getPlugin()

8
RenX.Ladder.Web/RenX_Ladder_Web.h

@ -27,14 +27,14 @@
class RenX_Ladder_WebPlugin : public RenX::Plugin
{
protected:
Jupiter::String generate_entry_table(size_t index, size_t count);
Jupiter::String generate_entry_table(RenX::LadderDatabase *db, size_t index, size_t count);
public:
Jupiter::StringS header;
Jupiter::StringS footer;
Jupiter::String *generate_ladder_page(size_t start_index, size_t count);
Jupiter::String *generate_search_page(const Jupiter::ReadableString &name);
Jupiter::String *generate_profile_page(uint64_t steam_id);
Jupiter::String *generate_ladder_page(RenX::LadderDatabase *db, size_t start_index, size_t count);
Jupiter::String *generate_search_page(RenX::LadderDatabase *db, const Jupiter::ReadableString &name);
Jupiter::String *generate_profile_page(RenX::LadderDatabase *db, uint64_t steam_id);
RenX_Ladder_WebPlugin();
~RenX_Ladder_WebPlugin();

85
RenX.Ladder.Weekly/RenX.Ladder.Weekly.vcxproj

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{6F0141F3-CF64-47D9-8EC2-80A38FAFDAC7}</ProjectGuid>
<RootNamespace>RenX.Ladder.Weekly</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\Plugins\</OutDir>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../Bot;../Jupiter;../RenX.Core</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="RenX_Ladder_Weekly.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="RenX_Ladder_Weekly.cpp" />
</ItemGroup>
<ItemGroup>
<Library Include="..\Jupiter\Release\Jupiter.lib" />
<Library Include="..\Release\Bot.lib" />
<Library Include="..\Release\Plugins\RenX.Core.lib" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

38
RenX.Ladder.Weekly/RenX.Ladder.Weekly.vcxproj.filters

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="RenX_Ladder_Weekly.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Library Include="..\Release\Plugins\RenX.Core.lib">
<Filter>Resource Files</Filter>
</Library>
<Library Include="..\Release\Bot.lib">
<Filter>Resource Files</Filter>
</Library>
<Library Include="..\Jupiter\Release\Jupiter.lib">
<Filter>Resource Files</Filter>
</Library>
</ItemGroup>
<ItemGroup>
<ClInclude Include="RenX_Ladder_Weekly.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

55
RenX.Ladder.Weekly/RenX_Ladder_Weekly.cpp

@ -0,0 +1,55 @@
/**
* Copyright (C) 2016 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
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
#include <ctime>
#include "Jupiter/INIFile.h"
#include "Jupiter/IRC_Client.h"
#include "RenX_Ladder_Weekly.h"
using namespace Jupiter::literals;
RenX_Ladder_Weekly_TimePlugin::RenX_Ladder_Weekly_TimePlugin()
{
// Load database
this->database.process_file(Jupiter::IRC::Client::Config->get(this->getName(), "LadderDatabase"_jrs, "Ladder.Weekly.db"_jrs));
this->database.setName(Jupiter::IRC::Client::Config->get(this->getName(), "DatabaseName"_jrs, "Weekly"_jrs));
this->last_sorted_day = gmtime(std::addressof<const time_t>(time(0)))->tm_wday;
this->reset_day = Jupiter::IRC::Client::Config->getInt(this->getName(), "ResetDay"_jrs);
this->database.OnPreUpdateLadder = OnPreUpdateLadder;
// Force database to default, if desired
if (Jupiter::IRC::Client::Config->getBool(this->getName(), "ForceDefault"_jrs, false))
RenX::default_ladder_database = &this->database;
}
// Plugin instantiation and entry point.
RenX_Ladder_Weekly_TimePlugin pluginInstance;
void OnPreUpdateLadder(RenX::LadderDatabase &database, RenX::Server *server, const RenX::TeamType &team, bool output_times)
{
tm *tm_ptr = gmtime(std::addressof<const time_t>(time(0)));
if (pluginInstance.last_sorted_day != tm_ptr->tm_wday && tm_ptr->tm_wday == pluginInstance.reset_day)
database.erase();
pluginInstance.last_sorted_day = tm_ptr->tm_wday;
}
extern "C" __declspec(dllexport) Jupiter::Plugin *getPlugin()
{
return &pluginInstance;
}

43
RenX.Ladder.Weekly/RenX_Ladder_Weekly.h

@ -0,0 +1,43 @@
/**
* Copyright (C) 2016 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
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
#if !defined _RENX_LADDER_ALL_TIME
#define _RENX_LADDER_ALL_TIME
#include "Jupiter/Plugin.h"
#include "Jupiter/Reference_String.h"
#include "RenX_Plugin.h"
#include "RenX_LadderDatabase.h"
class RenX_Ladder_Weekly_TimePlugin : public RenX::Plugin
{
public:
const Jupiter::ReadableString &getName() override { return name; }
RenX_Ladder_Weekly_TimePlugin();
int last_sorted_day;
int reset_day;
private:
RenX::LadderDatabase database;
STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.Ladder.Weekly");
};
void OnPreUpdateLadder(RenX::LadderDatabase &database, RenX::Server *server, const RenX::TeamType &team, bool output_times);
#endif // _RENX_LADDER_ALL_TIME

85
RenX.Ladder.Yearly/RenX.Ladder.Yearly.vcxproj

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{075AF69B-71D6-43B9-B102-4649CB2CA40C}</ProjectGuid>
<RootNamespace>RenX.Ladder.Yearly</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\Plugins\</OutDir>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../Bot;../Jupiter;../RenX.Core</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="RenX_Ladder_Yearly.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="RenX_Ladder_Yearly.cpp" />
</ItemGroup>
<ItemGroup>
<Library Include="..\Jupiter\Release\Jupiter.lib" />
<Library Include="..\Release\Bot.lib" />
<Library Include="..\Release\Plugins\RenX.Core.lib" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

38
RenX.Ladder.Yearly/RenX.Ladder.Yearly.vcxproj.filters

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="RenX_Ladder_Yearly.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Library Include="..\Release\Plugins\RenX.Core.lib">
<Filter>Resource Files</Filter>
</Library>
<Library Include="..\Release\Bot.lib">
<Filter>Resource Files</Filter>
</Library>
<Library Include="..\Jupiter\Release\Jupiter.lib">
<Filter>Resource Files</Filter>
</Library>
</ItemGroup>
<ItemGroup>
<ClInclude Include="RenX_Ladder_Yearly.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

54
RenX.Ladder.Yearly/RenX_Ladder_Yearly.cpp

@ -0,0 +1,54 @@
/**
* Copyright (C) 2016 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
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
#include <ctime>
#include "Jupiter/INIFile.h"
#include "Jupiter/IRC_Client.h"
#include "RenX_Ladder_Yearly.h"
using namespace Jupiter::literals;
RenX_Ladder_Yearly_TimePlugin::RenX_Ladder_Yearly_TimePlugin()
{
// Load database
this->database.process_file(Jupiter::IRC::Client::Config->get(this->getName(), "LadderDatabase"_jrs, "Ladder.Yearly.db"_jrs));
this->database.setName(Jupiter::IRC::Client::Config->get(this->getName(), "DatabaseName"_jrs, "Yearly"_jrs));
this->last_sorted_year = gmtime(std::addressof<const time_t>(time(0)))->tm_year;
this->database.OnPreUpdateLadder = OnPreUpdateLadder;
// Force database to default, if desired
if (Jupiter::IRC::Client::Config->getBool(this->getName(), "ForceDefault"_jrs, false))
RenX::default_ladder_database = &this->database;
}
// Plugin instantiation and entry point.
RenX_Ladder_Yearly_TimePlugin pluginInstance;
void OnPreUpdateLadder(RenX::LadderDatabase &database, RenX::Server *server, const RenX::TeamType &team, bool output_times)
{
tm *tm_ptr = gmtime(std::addressof<const time_t>(time(0)));
if (pluginInstance.last_sorted_year != tm_ptr->tm_year)
database.erase();
pluginInstance.last_sorted_year = tm_ptr->tm_year;
}
extern "C" __declspec(dllexport) Jupiter::Plugin *getPlugin()
{
return &pluginInstance;
}

42
RenX.Ladder.Yearly/RenX_Ladder_Yearly.h

@ -0,0 +1,42 @@
/**
* Copyright (C) 2016 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
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
#if !defined _RENX_LADDER_ALL_TIME
#define _RENX_LADDER_ALL_TIME
#include "Jupiter/Plugin.h"
#include "Jupiter/Reference_String.h"
#include "RenX_Plugin.h"
#include "RenX_LadderDatabase.h"
class RenX_Ladder_Yearly_TimePlugin : public RenX::Plugin
{
public:
const Jupiter::ReadableString &getName() override { return name; }
RenX_Ladder_Yearly_TimePlugin();
int last_sorted_year = 0;
private:
RenX::LadderDatabase database;
STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.Ladder.Yearly");
};
void OnPreUpdateLadder(RenX::LadderDatabase &database, RenX::Server *server, const RenX::TeamType &team, bool output_times);
#endif // _RENX_LADDER_ALL_TIME

13
RenX.Ladder/RenX_Ladder.cpp

@ -35,10 +35,6 @@ RenX_LadderPlugin::RenX_LadderPlugin()
RenX_LadderPlugin::max_ladder_command_part_name_output = 0;
else
RenX_LadderPlugin::max_ladder_command_part_name_output = mlcpno;
RenX_LadderPlugin::db_filename = Jupiter::IRC::Client::Config->get(this->getName(), "LadderDatabase"_jrs, "Ladder.db"_jrs);
// load database
RenX_LadderPlugin::database.process_file(RenX_LadderPlugin::db_filename);
}
/** Wait until the client list has been updated to update the ladder */
@ -62,7 +58,8 @@ void RenX_LadderPlugin::RenX_OnCommand(RenX::Server *server, const Jupiter::Read
{
server->varData.set(this->name, "w"_jrs, "0"_jrs);
RenX::TeamType team = static_cast<RenX::TeamType>(server->varData.get(this->name, "t"_jrs, "\0"_jrs).get(0));
RenX_LadderPlugin::database.updateLadder(server, team, RenX_LadderPlugin::output_times);
for (size_t index = 0; index != RenX::ladder_databases.size(); ++index)
RenX::ladder_databases.get(index)->updateLadder(server, team, RenX_LadderPlugin::output_times);
}
}
}
@ -103,14 +100,14 @@ GenericCommand::ResponseLine *LadderGenericCommand::trigger(const Jupiter::Reada
if (rank == 0)
return new GenericCommand::ResponseLine("Error: Invalid parameters"_jrs, GenericCommand::DisplayType::PrivateError);
entry = pluginInstance.database.getPlayerEntryByIndex(rank - 1);
entry = RenX::default_ladder_database->getPlayerEntryByIndex(rank - 1);
if (entry == nullptr)
return new GenericCommand::ResponseLine("Error: Player not found"_jrs, GenericCommand::DisplayType::PrivateError);
return new GenericCommand::ResponseLine(FormatLadderResponse(entry, rank), GenericCommand::DisplayType::PublicSuccess);
}
Jupiter::SLList<std::pair<RenX::LadderDatabase::Entry, size_t>> list = pluginInstance.database.getPlayerEntriesAndIndexByPartName(parameters, pluginInstance.getMaxLadderCommandPartNameOutput());
Jupiter::SLList<std::pair<RenX::LadderDatabase::Entry, size_t>> list = RenX::default_ladder_database->getPlayerEntriesAndIndexByPartName(parameters, pluginInstance.getMaxLadderCommandPartNameOutput());
if (list.size() == 0)
return new GenericCommand::ResponseLine("Error: Player not found"_jrs, GenericCommand::DisplayType::PrivateError);
@ -152,7 +149,7 @@ void LadderGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player,
{
if (player->steamid != 0)
{
std::pair<RenX::LadderDatabase::Entry *, size_t> pair = pluginInstance.database.getPlayerEntryAndIndex(player->steamid);
std::pair<RenX::LadderDatabase::Entry *, size_t> pair = RenX::default_ladder_database->getPlayerEntryAndIndex(player->steamid);
if (pair.first != nullptr)
source->sendMessage(FormatLadderResponse(pair.first, pair.second + 1));
else

4
RenX.Ladder/RenX_Ladder.h

@ -1,5 +1,5 @@
/**
* Copyright (C) 2015 Jessica James.
* Copyright (C) 2015-2016 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
@ -42,12 +42,10 @@ public:
size_t getMaxLadderCommandPartNameOutput() const;
RenX_LadderPlugin();
RenX::LadderDatabase database;
private:
/** Configuration variables */
bool only_pure, output_times;
size_t max_ladder_command_part_name_output;
Jupiter::CStringS db_filename;
STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.Ladder");
};

Loading…
Cancel
Save