Merge pull request #308 from diamante0018/develop

[MapRotation] Allow people to have empty sv_mapRotation
This commit is contained in:
Edo 2022-06-16 18:29:28 +02:00 committed by GitHub
commit e8aadc2382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 14 deletions

View File

@ -109,13 +109,6 @@ namespace Components
Logger::DebugInfo("DedicatedRotation size after parsing is '{}'\n", DedicatedRotation.getEntriesSize());
// Shuffles values
if (SVRandomMapRotation.get<bool>())
{
Logger::Print(Game::CON_CHANNEL_SERVER, "Randomizing the map rotation\n");
DedicatedRotation.randomize();
}
loaded = true;
}
@ -210,6 +203,19 @@ namespace Components
}
}
void MapRotation::RandomizeMapRotation()
{
if (SVRandomMapRotation.get<bool>())
{
Logger::Print(Game::CON_CHANNEL_SERVER, "Randomizing the map rotation\n");
DedicatedRotation.randomize();
}
else
{
Logger::DebugInfo("Map rotation was not randomized");
}
}
void MapRotation::SV_MapRotate_f()
{
if (!ShouldRotate())
@ -220,22 +226,22 @@ namespace Components
Logger::Print(Game::CON_CHANNEL_SERVER, "Rotating map...\n");
const std::string mapRotation = (*SVMapRotation)->current.string;
if (mapRotation.empty())
// People may have sv_mapRotation empty because they only use 'addMap' or 'addMap'
if (!mapRotation.empty())
{
Logger::Print(Game::CON_CHANNEL_SERVER, "No rotation defined (sv_mapRotation is empty), restarting map.\n");
RestartCurrentMap();
return;
Logger::DebugInfo("sv_mapRotation is not empty. Parsing...");
LoadRotation(mapRotation);
}
LoadRotation(mapRotation);
if (DedicatedRotation.getEntriesSize() == 0)
{
Logger::Print(Game::CON_CHANNEL_SERVER, "sv_mapRotation is empty or contains invalid data, restarting map.\n");
Logger::Print(Game::CON_CHANNEL_SERVER, "sv_mapRotation is empty or contains invalid data. Restarting map\n");
RestartCurrentMap();
return;
}
RandomizeMapRotation();
ApplyMapRotation();
}

View File

@ -60,6 +60,7 @@ namespace Components
static bool ShouldRotate();
static void RestartCurrentMap();
static void ApplyMapRotation();
static void RandomizeMapRotation();
static void SV_MapRotate_f();
};