From 07eb28ffe8e414890e4bba35f413f7c100e5ac7c Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Tue, 9 Jun 2020 19:51:14 +1000 Subject: [PATCH] Fixing issue with restored vscript classes that are not registered being unable to be instantiated --- sp/src/vscript/vscript_squirrel.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sp/src/vscript/vscript_squirrel.cpp b/sp/src/vscript/vscript_squirrel.cpp index 7026e991..81c2f308 100644 --- a/sp/src/vscript/vscript_squirrel.cpp +++ b/sp/src/vscript/vscript_squirrel.cpp @@ -1675,8 +1675,16 @@ bool SquirrelVM::RegisterClass(ScriptClassDesc_t* pClassDesc) // Check if class name is already taken if (sq_get(vm_, -2) == SQ_OK) { - sq_pop(vm_, 2); - return false; + HSQOBJECT obj; + sq_resetobject(&obj); + sq_getstackobj(vm_, -1, &obj); + if (!sq_isnull(obj)) + { + sq_pop(vm_, 2); + return false; + } + + sq_pop(vm_, 1); } // Register base in case it doesn't exist