From 99c91164be93810b3f28c46447bc72459ff478b6 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Thu, 19 Sep 2019 15:27:31 +0200 Subject: [PATCH] Fixed issue where attempting setting to a non existing field on userdata would crash. --- src/UserData/UserDataScriptType.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UserData/UserDataScriptType.hpp b/src/UserData/UserDataScriptType.hpp index 55651af..45cd35b 100644 --- a/src/UserData/UserDataScriptType.hpp +++ b/src/UserData/UserDataScriptType.hpp @@ -90,7 +90,7 @@ namespace Porygon::UserData { [[nodiscard]] bool CanSetIndexValue(Utilities::HashedString indexer, shared_ptr val) const override { auto ud = _userData->Get(); - if (ud->ContainsField(indexer.GetHash())) + if (!ud->ContainsField(indexer.GetHash())) return false; auto field = _userData->Get()->GetField(indexer.GetHash()); return (val->CastableTo(field->GetType(), false) != CastResult::InvalidCast);