[General]: Re-write error message

This commit is contained in:
Diavolo 2023-01-09 23:14:07 +01:00
parent b7f5f17c1a
commit 453575da93
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
2 changed files with 11 additions and 13 deletions

View File

@ -54,7 +54,7 @@ namespace Components
} }
else else
{ {
throw ParseRotationError(); throw MapRotationParseError();
} }
} }
} }
@ -148,7 +148,7 @@ namespace Components
if (Dvar::Var("party_enable").get<bool>() && Dvar::Var("party_host").get<bool>()) if (Dvar::Var("party_enable").get<bool>() && Dvar::Var("party_host").get<bool>())
{ {
Logger::Print(Game::CON_CHANNEL_SERVER, "Not performing map rotation as we are hosting a party!\n"); Logger::Warning(Game::CON_CHANNEL_SERVER, "Not performing map rotation as we are hosting a party!\n");
return false; return false;
} }
@ -172,7 +172,7 @@ namespace Components
void MapRotation::ApplyGametype(const std::string& gametype) void MapRotation::ApplyGametype(const std::string& gametype)
{ {
assert(!gametype.empty()); assert(!gametype.empty());
Dvar::Var("g_gametype").set(gametype); Game::Dvar_SetStringByName("g_gametype", gametype.data());
} }
void MapRotation::RestartCurrentMap() void MapRotation::RestartCurrentMap()
@ -193,24 +193,22 @@ namespace Components
assert(!rotation.empty()); assert(!rotation.empty());
// Continue to apply gametype until a map is found // Continue to apply gametype until a map is found
auto foundMap = false;
std::size_t i = 0; std::size_t i = 0;
while (!foundMap && i < rotation.getEntriesSize()) while (i < rotation.getEntriesSize())
{ {
const auto& entry = rotation.getNextEntry(); const auto& entry = rotation.getNextEntry();
if (entry.first == "map"s) if (entry.first == "map"s)
{ {
Logger::Debug("Loading new map: '{}'", entry.second); Logger::Print("Loading new map: '{}'", entry.second);
ApplyMap(entry.second); ApplyMap(entry.second);
// Map was found so we exit the loop // Map was found so we exit the loop
foundMap = true; break;
} }
else if (entry.first == "gametype"s)
if (entry.first == "gametype"s)
{ {
Logger::Debug("Applying new gametype: '{}'", entry.second); Logger::Print("Applying new gametype: '{}'", entry.second);
ApplyGametype(entry.second); ApplyGametype(entry.second);
} }

View File

@ -12,9 +12,9 @@ namespace Components
bool unitTest() override; bool unitTest() override;
private: private:
struct ParseRotationError : public std::exception struct MapRotationParseError : public std::exception
{ {
const char* what() const noexcept override { return "Parse Rotation Error"; } [[nodiscard]] const char* what() const noexcept override { return "Map Rotation Parse Error"; }
}; };
class RotationData class RotationData