From 475e2142c6fcde1cfbd87c6ea2158489bf910864 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 30 Oct 2021 00:14:15 +0200 Subject: [PATCH] Slight optimization and defensive programming. --- src/ScriptResolving/AngelScript/AngelScriptScript.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp index c39b2b5..a4c5373 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp @@ -19,7 +19,10 @@ AngelScriptScript::AngelScriptScript(const ArbUt::OptionalBorrowedPtr& own AngelScriptResolver* resolver, AngelScriptTypeInfo* type, asIScriptObject* obj, ContextPool* ctxPool) : PkmnLib::Battling::PkmnScript(owner), _resolver(resolver), _type(type), _ctxPool(ctxPool), _obj(obj) { - if (_type->GetGetOwner().Exists) { + if (_type->GetGetOwner().Exists && owner.HasValue()) { + if (ownerType == nullptr){ + THROW("Script was created with owner value, but with unknown owner type.") + } CScriptHandle* handle = nullptr; AngelScriptUtils::AngelscriptFunctionCall( _type->GetGetOwner().Function, _ctxPool, _obj, _resolver, GetName(), [&](asIScriptContext*) {},