Throw clean exception when no volatile script is found when adding one.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-04-11 00:22:08 +02:00
parent 79c4d28c75
commit 2e5d463e45
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 10 additions and 0 deletions

View File

@ -129,6 +129,11 @@ void Battle::AddVolatileScript(const ConstString& key) {
return; return;
} }
script = _library->LoadScript(ScriptCategory::Battle, key); script = _library->LoadScript(ScriptCategory::Battle, key);
if (script == nullptr) {
std::stringstream ss;
ss << "Invalid volatile script requested for battle: '" << key.c_str() << "'.";
throw CreatureException(ss.str());
}
return _volatile.Add(script); return _volatile.Add(script);
} }
void Battle::AddVolatileScript(Script* script) { return _volatile.Add(script); } void Battle::AddVolatileScript(Script* script) { return _volatile.Add(script); }

View File

@ -217,6 +217,11 @@ void Battling::Creature::AddVolatileScript(const ConstString& name) {
return; return;
} }
script = this->_library->LoadScript(ScriptCategory::Creature, name); script = this->_library->LoadScript(ScriptCategory::Creature, name);
if (script == nullptr) {
std::stringstream ss;
ss << "Invalid volatile script requested for creature: '" << name.c_str() << "'.";
throw CreatureException(ss.str());
}
_volatile.Add(script); _volatile.Add(script);
} }