Merge pull request #768 from diamante0018/develop

[Download]: Add maprotation to info endpoint
This commit is contained in:
Edo 2023-02-10 00:19:51 +00:00 committed by GitHub
commit e924c2907f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 43 additions and 26 deletions

View File

@ -4,8 +4,6 @@
#define STB_TRUETYPE_IMPLEMENTATION
#include <stb_truetype.hpp>
#include <json.hpp>
namespace Assets
{
namespace

View File

@ -1,8 +1,6 @@
#include <STDInclude.hpp>
#include "IGameWorldMp.hpp"
#include <json.hpp>
#define IW4X_GAMEWORLD_VERSION 1
namespace Assets

View File

@ -1,8 +1,6 @@
#include <STDInclude.hpp>
#include "ILocalizeEntry.hpp"
#include <json.hpp>
namespace Assets
{
void ILocalizeEntry::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)

View File

@ -1,8 +1,6 @@
#include <STDInclude.hpp>
#include "Bans.hpp"
#include <json.hpp>
namespace Components
{
const char* Bans::BanListFile = "userraw/bans.json";

View File

@ -5,8 +5,6 @@
#include "GSC/Script.hpp"
#include <json.hpp>
namespace Components
{
Dvar::Var Chat::cg_chatWidth;

View File

@ -3,6 +3,7 @@
#include <Utils/WebIO.hpp>
#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<std::string, nlohmann::json> info;
info["status"] = status.to_json();
info["host"] = host.to_json();
info["map_rotation"] = MapRotation::to_json();
std::vector<nlohmann::json> players;

View File

@ -1,7 +1,5 @@
#include <STDInclude.hpp>
#include <json.hpp>
#include "ScriptStorage.hpp"
#include "Script.hpp"

View File

@ -78,6 +78,32 @@ namespace Components
});
}
nlohmann::json MapRotation::RotationData::to_json() const
{
std::vector<std::string> mapVector;
std::vector<std::string> 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<bool>())

View File

@ -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<rotationEntry> rotationEntries_;

View File

@ -1,7 +1,5 @@
#include <STDInclude.hpp>
#include <json.hpp>
#include "FastFiles.hpp"
#include "RawFiles.hpp"
#include "StartupMessages.hpp"

View File

@ -1,8 +1,6 @@
#include <STDInclude.hpp>
#include "StructuredData.hpp"
#include <json.hpp>
namespace Components
{
Utils::Memory::Allocator StructuredData::MemAllocator;

View File

@ -1,7 +1,5 @@
#include <STDInclude.hpp>
#include <json.hpp>
#include "Theatre.hpp"
#include "UIFeeder.hpp"

View File

@ -4,8 +4,6 @@
#include "Console.hpp"
#include "FastFiles.hpp"
#include <json.hpp>
#include <version.hpp>
#include "AssetInterfaces/ILocalizeEntry.hpp"

View File

@ -109,6 +109,7 @@ using namespace std::literals;
#define AssertUnreachable assert(0 && "unreachable")
#include <gsl/gsl>
#include <json.hpp>
#include <tomcrypt.h>
#pragma warning(pop)

View File

@ -1,5 +1,4 @@
#pragma once
#include <json.hpp>
namespace Utils
{

View File

@ -1,5 +1,4 @@
#pragma once
#include <json.hpp>
namespace Utils::Json
{