2022-05-25 12:03:26 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
class MapRotation : public Component
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MapRotation();
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct ParseRotationError : public std::exception
|
|
|
|
{
|
|
|
|
const char* what() const noexcept override { return "Parse Rotation Error"; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class RotationData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using rotationEntry = std::pair<std::string, std::string>;
|
|
|
|
|
|
|
|
RotationData();
|
|
|
|
|
|
|
|
void randomize();
|
|
|
|
|
|
|
|
// In case a new way to enrich the map rotation is added (other than sv_mapRotation)
|
|
|
|
// this method should be called to add a new entry (gamemode/map & value)
|
|
|
|
void addEntry(const std::string& key, const std::string& value);
|
|
|
|
|
|
|
|
[[nodiscard]] std::size_t getEntriesSize() const;
|
|
|
|
rotationEntry& getNextEntry();
|
|
|
|
|
|
|
|
void parse(const std::string& data);
|
|
|
|
|
|
|
|
private:
|
2022-06-11 05:55:12 -04:00
|
|
|
std::vector<rotationEntry> rotationEntries_;
|
2022-05-25 12:03:26 -04:00
|
|
|
|
|
|
|
std::size_t index_;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Rotation Dvars
|
|
|
|
static Dvar::Var SVRandomMapRotation;
|
|
|
|
static Dvar::Var SVDontRotate;
|
|
|
|
// Game Dvars
|
|
|
|
static Game::dvar_t** SVMapRotation;
|
|
|
|
static Game::dvar_t** SVMapname;
|
|
|
|
|
|
|
|
// Holds the parsed data from sv_mapRotation
|
|
|
|
static RotationData DedicatedRotation;
|
|
|
|
|
|
|
|
static void LoadRotation(const std::string& data);
|
|
|
|
|
|
|
|
static bool ShouldRotate();
|
|
|
|
static void RestartCurrentMap();
|
|
|
|
static void ApplyMapRotation();
|
|
|
|
|
|
|
|
static void SV_MapRotate_f();
|
|
|
|
};
|
|
|
|
}
|