Fixed issue where attempting setting to a non existing field on userdata would crash.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2019-09-19 15:27:31 +02:00
parent 8c13c2c84c
commit 99c91164be
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 1 additions and 1 deletions

View File

@ -90,7 +90,7 @@ namespace Porygon::UserData {
[[nodiscard]] bool CanSetIndexValue(Utilities::HashedString indexer, shared_ptr<const ScriptType> val) const override { [[nodiscard]] bool CanSetIndexValue(Utilities::HashedString indexer, shared_ptr<const ScriptType> val) const override {
auto ud = _userData->Get(); auto ud = _userData->Get();
if (ud->ContainsField(indexer.GetHash())) if (!ud->ContainsField(indexer.GetHash()))
return false; return false;
auto field = _userData->Get()->GetField(indexer.GetHash()); auto field = _userData->Get()->GetField(indexer.GetHash());
return (val->CastableTo(field->GetType(), false) != CastResult::InvalidCast); return (val->CastableTo(field->GetType(), false) != CastResult::InvalidCast);