From 741df993ff33832d773536ed571c1a67ed93b5cb Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Thu, 2 Oct 2014 15:58:13 -0400 Subject: Fix object reference pushing functions when called from coroutines --- src/script/cpp_api/s_base.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/script/cpp_api/s_base.cpp') diff --git a/src/script/cpp_api/s_base.cpp b/src/script/cpp_api/s_base.cpp index d27506fbe..779819007 100644 --- a/src/script/cpp_api/s_base.cpp +++ b/src/script/cpp_api/s_base.cpp @@ -238,22 +238,18 @@ void ScriptApiBase::removeObjectReference(ServerActiveObject *cobj) } // Creates a new anonymous reference if cobj=NULL or id=0 -void ScriptApiBase::objectrefGetOrCreate( +void ScriptApiBase::objectrefGetOrCreate(lua_State *L, ServerActiveObject *cobj) { - lua_State *L = getStack(); - if(cobj == NULL || cobj->getId() == 0){ ObjectRef::create(L, cobj); } else { - objectrefGet(cobj->getId()); + objectrefGet(L, cobj->getId()); } } -void ScriptApiBase::objectrefGet(u16 id) +void ScriptApiBase::objectrefGet(lua_State *L, u16 id) { - lua_State *L = getStack(); - // Get core.object_refs[i] lua_getglobal(L, "core"); lua_getfield(L, -1, "object_refs"); @@ -263,3 +259,4 @@ void ScriptApiBase::objectrefGet(u16 id) lua_remove(L, -2); // object_refs lua_remove(L, -2); // core } + -- cgit v1.2.3