diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp index 40f7a61..e26b019 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp @@ -53,8 +53,18 @@ public: std::stringstream err; \ err << "Script exception in script '" << GetName().c_str() << "', line " << ctx->GetExceptionLineNumber() \ << ". Message: '" << ctx->GetExceptionString() << "'."; \ + if (newContext) { \ + _ctxPool->ReturnContextToPool(ctx); \ + } else { \ + ctx->PopState(); \ + } \ throw CreatureException(err.str()); \ } \ + if (newContext) { \ + _ctxPool->ReturnContextToPool(ctx); \ + } else { \ + ctx->PopState(); \ + } \ throw CreatureException("Script didn't finish properly; message " + std::to_string(scriptResult)); \ } \ if (newContext) { \