[MapRotation]: Recover from edge case (#711)
This commit is contained in:
parent
b5d348527b
commit
889d43de6f
@ -24,12 +24,12 @@ namespace Components
|
||||
assert(Game::cmd_args->nesting < Game::CMD_MAX_NESTING);
|
||||
}
|
||||
|
||||
int Command::ClientParams::size() const
|
||||
int Command::ClientParams::size() const noexcept
|
||||
{
|
||||
return Game::cmd_args->argc[this->nesting_];
|
||||
}
|
||||
|
||||
const char* Command::ClientParams::get(const int index) const
|
||||
const char* Command::ClientParams::get(const int index) const noexcept
|
||||
{
|
||||
if (index >= this->size())
|
||||
{
|
||||
@ -45,12 +45,12 @@ namespace Components
|
||||
assert(Game::sv_cmd_args->nesting < Game::CMD_MAX_NESTING);
|
||||
}
|
||||
|
||||
int Command::ServerParams::size() const
|
||||
int Command::ServerParams::size() const noexcept
|
||||
{
|
||||
return Game::sv_cmd_args->argc[this->nesting_];
|
||||
}
|
||||
|
||||
const char* Command::ServerParams::get(const int index) const
|
||||
const char* Command::ServerParams::get(const int index) const noexcept
|
||||
{
|
||||
if (index >= this->size())
|
||||
{
|
||||
@ -62,31 +62,31 @@ namespace Components
|
||||
|
||||
void Command::Add(const char* name, const std::function<void()>& callback)
|
||||
{
|
||||
Add(name, [callback]([[maybe_unused]] const Command::Params* params)
|
||||
Add(name, [callback]([[maybe_unused]] const Params* params)
|
||||
{
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
void Command::Add(const char* name, const std::function<void(Command::Params*)>& callback)
|
||||
void Command::Add(const char* name, const std::function<void(Params*)>& callback)
|
||||
{
|
||||
const auto command = Utils::String::ToLower(name);
|
||||
|
||||
if (!Command::FunctionMap.contains(command))
|
||||
if (!FunctionMap.contains(command))
|
||||
{
|
||||
Command::AddRaw(name, Command::MainCallback);
|
||||
AddRaw(name, MainCallback);
|
||||
}
|
||||
|
||||
Command::FunctionMap.insert_or_assign(command, std::move(callback));
|
||||
FunctionMap.insert_or_assign(command, callback);
|
||||
}
|
||||
|
||||
void Command::AddSV(const char* name, const std::function<void(Command::Params*)>& callback)
|
||||
void Command::AddSV(const char* name, const std::function<void(Params*)>& callback)
|
||||
{
|
||||
if (Loader::IsPregame())
|
||||
{
|
||||
MessageBoxA(nullptr, "Registering server commands in pregame state is illegal!", nullptr, MB_ICONERROR);
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef _DEBUG
|
||||
__debugbreak();
|
||||
#endif
|
||||
|
||||
@ -95,9 +95,9 @@ namespace Components
|
||||
|
||||
const auto command = Utils::String::ToLower(name);
|
||||
|
||||
if (!Command::FunctionMapSV.contains(command))
|
||||
if (!FunctionMapSV.contains(command))
|
||||
{
|
||||
Command::AddRawSV(name, Command::MainCallbackSV);
|
||||
AddRawSV(name, MainCallbackSV);
|
||||
}
|
||||
|
||||
FunctionMapSV.insert_or_assign(command, callback);
|
||||
@ -105,15 +105,15 @@ namespace Components
|
||||
|
||||
void Command::AddRaw(const char* name, void(*callback)(), bool key)
|
||||
{
|
||||
Game::Cmd_AddCommand(name, callback, Command::Allocate(), key);
|
||||
Game::Cmd_AddCommand(name, callback, Allocate(), key);
|
||||
}
|
||||
|
||||
void Command::AddRawSV(const char* name, void(*callback)())
|
||||
{
|
||||
Game::Cmd_AddServerCommand(name, callback, Command::Allocate());
|
||||
Game::Cmd_AddServerCommand(name, callback, Allocate());
|
||||
|
||||
// If the main command is registered as Cbuf_AddServerText, the command will be redirected to the SV handler
|
||||
Command::AddRaw(name, Game::Cbuf_AddServerText_f, false);
|
||||
AddRaw(name, Game::Cbuf_AddServerText_f, false);
|
||||
}
|
||||
|
||||
void Command::Execute(std::string command, bool sync)
|
||||
|
@ -13,8 +13,13 @@ namespace Components
|
||||
Params() = default;
|
||||
virtual ~Params() = default;
|
||||
|
||||
[[nodiscard]] virtual int size() const = 0;
|
||||
[[nodiscard]] virtual const char* get(int index) const = 0;
|
||||
Params(Params&&) = delete;
|
||||
Params(const Params&) = delete;
|
||||
Params& operator=(Params&&) = delete;
|
||||
Params& operator=(const Params&) = delete;
|
||||
|
||||
[[nodiscard]] virtual int size() const noexcept = 0;
|
||||
[[nodiscard]] virtual const char* get(int index) const noexcept = 0;
|
||||
[[nodiscard]] virtual std::string join(int index) const;
|
||||
|
||||
virtual const char* operator[](const int index)
|
||||
@ -28,8 +33,8 @@ namespace Components
|
||||
public:
|
||||
ClientParams();
|
||||
|
||||
[[nodiscard]] int size() const override;
|
||||
[[nodiscard]] const char* get(int index) const override;
|
||||
[[nodiscard]] int size() const noexcept override;
|
||||
[[nodiscard]] const char* get(int index) const noexcept override;
|
||||
|
||||
private:
|
||||
int nesting_;
|
||||
@ -40,8 +45,8 @@ namespace Components
|
||||
public:
|
||||
ServerParams();
|
||||
|
||||
[[nodiscard]] int size() const override;
|
||||
[[nodiscard]] const char* get(int index) const override;
|
||||
[[nodiscard]] int size() const noexcept override;
|
||||
[[nodiscard]] const char* get(int index) const noexcept override;
|
||||
|
||||
private:
|
||||
int nesting_;
|
||||
|
@ -214,6 +214,12 @@ namespace Components
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
if (i == rotation.getEntriesSize())
|
||||
{
|
||||
Logger::PrintError(Game::CON_CHANNEL_ERROR, "Map rotation does not contain any map. Restarting\n");
|
||||
RestartCurrentMap();
|
||||
}
|
||||
}
|
||||
|
||||
void MapRotation::ApplyMapRotationCurrent(const std::string& data)
|
||||
|
Loading…
Reference in New Issue
Block a user