Fixes for ScriptSet throwing when adding a not yet found volatile script.
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2021-03-27 20:20:49 +01:00
parent bfe83ef271
commit 1ddbfd2357
5 changed files with 17 additions and 17 deletions

View File

@@ -155,15 +155,15 @@ void Battle::ValidateBattleState() {
}
BattleScript* Battle::AddVolatileScript(const ArbUt::StringView& key) {
auto script = _volatile.Get(key);
if (script.has_value()) {
script.value()->Stack();
return script.value();
if (script.HasValue()) {
script.GetValue()->Stack();
return script.GetValue();
}
script = _library->LoadScript(ScriptCategory::Battle, key);
if (!script.has_value()) {
if (!script.HasValue()) {
THROW("Invalid volatile script requested for battle: '" << key.c_str() << "'.");
}
return _volatile.Add(script.value().GetRaw());
return _volatile.Add(script.GetValue());
}
BattleScript* Battle::AddVolatileScript(BattleScript* script) { return _volatile.Add(script); }
void Battle::RemoveVolatileScript(BattleScript* script) { _volatile.Remove(script->GetName()); }