diff --git a/src/Battling/ScriptHandling/ScriptSet.hpp b/src/Battling/ScriptHandling/ScriptSet.hpp index f7602de..557b187 100644 --- a/src/Battling/ScriptHandling/ScriptSet.hpp +++ b/src/Battling/ScriptHandling/ScriptSet.hpp @@ -16,9 +16,9 @@ namespace CreatureLib::Battling { ScriptSet() : _scripts(defaultCapacity), _lookup(defaultCapacity){}; void Add(Script* script) { - size_t v; - if (_lookup.TryGet(script->GetName(), v)) { - _scripts[v]->Stack(); + auto v = _lookup.TryGet(script->GetName()); + if (v.has_value()) { + _scripts[v.value()]->Stack(); delete script; return; } @@ -32,9 +32,9 @@ namespace CreatureLib::Battling { } std::optional> Get(uint32_t keyHash) const noexcept { - size_t v; - if (_lookup.TryGet(keyHash, v)) { - return _scripts[v]; + auto v = _lookup.TryGet(keyHash); + if (v.has_value()) { + return _scripts[v.value()]; } return {}; } @@ -42,11 +42,11 @@ namespace CreatureLib::Battling { void Remove(const ArbUt::BasicStringView& key) { Remove(key.GetHash()); } void Remove(uint32_t keyHash) { - size_t v; - if (_lookup.TryGet(keyHash, v)) { - auto script = _scripts[v]; + auto v = _lookup.TryGet(keyHash); + if (v.has_value()) { + auto script = _scripts[v.value()]; script->OnRemove(); - _scripts.Remove(v); + _scripts.Remove(v.value()); _lookup.Remove(keyHash); } }