diff --git a/src/Components/Modules/AssetInterfaces/IFont_s.cpp b/src/Components/Modules/AssetInterfaces/IFont_s.cpp index ed23d835..c68d2a19 100644 --- a/src/Components/Modules/AssetInterfaces/IFont_s.cpp +++ b/src/Components/Modules/AssetInterfaces/IFont_s.cpp @@ -4,8 +4,6 @@ #define STB_TRUETYPE_IMPLEMENTATION #include -#include - namespace Assets { namespace diff --git a/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp b/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp index 2bbbb004..1656d480 100644 --- a/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp +++ b/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp @@ -1,8 +1,6 @@ #include #include "IGameWorldMp.hpp" -#include - #define IW4X_GAMEWORLD_VERSION 1 namespace Assets diff --git a/src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp b/src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp index 063a0ee6..243c0958 100644 --- a/src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp +++ b/src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp @@ -1,8 +1,6 @@ #include #include "ILocalizeEntry.hpp" -#include - namespace Assets { void ILocalizeEntry::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) diff --git a/src/Components/Modules/Bans.cpp b/src/Components/Modules/Bans.cpp index b84ed62f..507223bd 100644 --- a/src/Components/Modules/Bans.cpp +++ b/src/Components/Modules/Bans.cpp @@ -1,8 +1,6 @@ #include #include "Bans.hpp" -#include - namespace Components { const char* Bans::BanListFile = "userraw/bans.json"; diff --git a/src/Components/Modules/Chat.cpp b/src/Components/Modules/Chat.cpp index cd9c2c40..31218971 100644 --- a/src/Components/Modules/Chat.cpp +++ b/src/Components/Modules/Chat.cpp @@ -5,8 +5,6 @@ #include "GSC/Script.hpp" -#include - namespace Components { Dvar::Var Chat::cg_chatWidth; diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 976aad6d..d9ea8b16 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -3,6 +3,7 @@ #include #include "Download.hpp" +#include "MapRotation.hpp" #include "Party.hpp" #include "ServerInfo.hpp" @@ -348,10 +349,6 @@ namespace Components } } -#pragma endregion - -#pragma region Server - void Download::DownloadProgress(FileDownload* fDownload, std::size_t bytes) { fDownload->receivedBytes += bytes; @@ -415,6 +412,10 @@ namespace Components } } +#pragma endregion + +#pragma region Server + static std::string InfoHandler() { const auto status = ServerInfo::GetInfo(); @@ -423,6 +424,7 @@ namespace Components std::unordered_map info; info["status"] = status.to_json(); info["host"] = host.to_json(); + info["map_rotation"] = MapRotation::to_json(); std::vector players; diff --git a/src/Components/Modules/GSC/ScriptStorage.cpp b/src/Components/Modules/GSC/ScriptStorage.cpp index eeb85719..be45b796 100644 --- a/src/Components/Modules/GSC/ScriptStorage.cpp +++ b/src/Components/Modules/GSC/ScriptStorage.cpp @@ -1,7 +1,5 @@ #include -#include - #include "ScriptStorage.hpp" #include "Script.hpp" diff --git a/src/Components/Modules/MapRotation.cpp b/src/Components/Modules/MapRotation.cpp index 9db8f327..8ed6ad4a 100644 --- a/src/Components/Modules/MapRotation.cpp +++ b/src/Components/Modules/MapRotation.cpp @@ -78,6 +78,32 @@ namespace Components }); } + nlohmann::json MapRotation::RotationData::to_json() const + { + std::vector mapVector; + std::vector gametypeVector; + + for (const auto& [key, val] : this->rotationEntries_) + { + if (key == "map"s) + { + mapVector.emplace_back(val); + } + else if (key == "gametype"s) + { + gametypeVector.emplace_back(val); + } + } + + auto mapRotationJson = nlohmann::json + { + {"maps", mapVector}, + {"gametypes", gametypeVector}, + }; + + return mapRotationJson; + } + void MapRotation::LoadRotation(const std::string& data) { try @@ -142,6 +168,12 @@ namespace Components return DedicatedRotation.contains(key, value); } + nlohmann::json MapRotation::to_json() + { + assert(!DedicatedRotation.empty()); + return DedicatedRotation.to_json(); + } + bool MapRotation::ShouldRotate() { if (!Dedicated::IsEnabled() && SVDontRotate.get()) diff --git a/src/Components/Modules/MapRotation.hpp b/src/Components/Modules/MapRotation.hpp index 7c80bfb0..68e51b23 100644 --- a/src/Components/Modules/MapRotation.hpp +++ b/src/Components/Modules/MapRotation.hpp @@ -9,6 +9,8 @@ namespace Components static bool Contains(const std::string& key, const std::string& value); + static nlohmann::json to_json(); + bool unitTest() override; private: @@ -39,6 +41,8 @@ namespace Components [[nodiscard]] bool empty() const noexcept; [[nodiscard]] bool contains(const std::string& key, const std::string& value) const; + [[nodiscard]] nlohmann::json to_json() const; + private: std::vector rotationEntries_; diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index 38769218..7a6f26a3 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -1,7 +1,5 @@ #include -#include - #include "FastFiles.hpp" #include "RawFiles.hpp" #include "StartupMessages.hpp" diff --git a/src/Components/Modules/StructuredData.cpp b/src/Components/Modules/StructuredData.cpp index ce7546a7..e8dd0ca1 100644 --- a/src/Components/Modules/StructuredData.cpp +++ b/src/Components/Modules/StructuredData.cpp @@ -1,8 +1,6 @@ #include #include "StructuredData.hpp" -#include - namespace Components { Utils::Memory::Allocator StructuredData::MemAllocator; diff --git a/src/Components/Modules/Theatre.cpp b/src/Components/Modules/Theatre.cpp index 0a27c9f9..4d89eb19 100644 --- a/src/Components/Modules/Theatre.cpp +++ b/src/Components/Modules/Theatre.cpp @@ -1,7 +1,5 @@ #include -#include - #include "Theatre.hpp" #include "UIFeeder.hpp" diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index a2961c30..675e0b30 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -4,8 +4,6 @@ #include "Console.hpp" #include "FastFiles.hpp" -#include - #include #include "AssetInterfaces/ILocalizeEntry.hpp" diff --git a/src/STDInclude.hpp b/src/STDInclude.hpp index 14233156..a6df1636 100644 --- a/src/STDInclude.hpp +++ b/src/STDInclude.hpp @@ -109,6 +109,7 @@ using namespace std::literals; #define AssertUnreachable assert(0 && "unreachable") #include +#include #include #pragma warning(pop) diff --git a/src/Utils/InfoString.hpp b/src/Utils/InfoString.hpp index ce2e1220..3229eebb 100644 --- a/src/Utils/InfoString.hpp +++ b/src/Utils/InfoString.hpp @@ -1,5 +1,4 @@ #pragma once -#include namespace Utils { diff --git a/src/Utils/Json.hpp b/src/Utils/Json.hpp index c73de553..463e24b0 100644 --- a/src/Utils/Json.hpp +++ b/src/Utils/Json.hpp @@ -1,5 +1,4 @@ #pragma once -#include namespace Utils::Json {