merge ResetState into ctor
This commit is contained in:
@@ -192,7 +192,31 @@ LuaManager::LuaManager()
|
|||||||
L = NULL;
|
L = NULL;
|
||||||
m_pLock = new RageMutex( "Lua" );
|
m_pLock = new RageMutex( "Lua" );
|
||||||
|
|
||||||
ResetState();
|
m_pLock->Lock();
|
||||||
|
|
||||||
|
if( L != NULL )
|
||||||
|
{
|
||||||
|
LuaReference::BeforeResetAll();
|
||||||
|
|
||||||
|
lua_close( L );
|
||||||
|
}
|
||||||
|
|
||||||
|
L = lua_open();
|
||||||
|
ASSERT( L );
|
||||||
|
|
||||||
|
lua_atpanic( L, LuaPanic );
|
||||||
|
|
||||||
|
luaopen_base( L );
|
||||||
|
luaopen_math( L );
|
||||||
|
luaopen_string( L );
|
||||||
|
luaopen_table( L );
|
||||||
|
lua_settop(L, 0); // luaopen_* pushes stuff onto the stack that we don't need
|
||||||
|
|
||||||
|
RegisterTypes();
|
||||||
|
|
||||||
|
LuaReference::AfterResetAll();
|
||||||
|
|
||||||
|
m_pLock->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaManager::~LuaManager()
|
LuaManager::~LuaManager()
|
||||||
@@ -245,34 +269,6 @@ void LuaManager::RegisterTypes()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaManager::ResetState()
|
|
||||||
{
|
|
||||||
m_pLock->Lock();
|
|
||||||
|
|
||||||
if( L != NULL )
|
|
||||||
{
|
|
||||||
LuaReference::BeforeResetAll();
|
|
||||||
|
|
||||||
lua_close( L );
|
|
||||||
}
|
|
||||||
|
|
||||||
L = lua_open();
|
|
||||||
ASSERT( L );
|
|
||||||
|
|
||||||
lua_atpanic( L, LuaPanic );
|
|
||||||
|
|
||||||
luaopen_base( L );
|
|
||||||
luaopen_math( L );
|
|
||||||
luaopen_string( L );
|
|
||||||
luaopen_table( L );
|
|
||||||
lua_settop(L, 0); // luaopen_* pushes stuff onto the stack that we don't need
|
|
||||||
|
|
||||||
RegisterTypes();
|
|
||||||
|
|
||||||
LuaReference::AfterResetAll();
|
|
||||||
|
|
||||||
m_pLock->Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,9 +29,6 @@ public:
|
|||||||
Lua *Get();
|
Lua *Get();
|
||||||
void Release( Lua *&p );
|
void Release( Lua *&p );
|
||||||
|
|
||||||
/* Reset the environment, freeing any globals left over by previously executed scripts. */
|
|
||||||
void ResetState();
|
|
||||||
|
|
||||||
/* Register all subscribing types. There's no harm in registering when already registered. */
|
/* Register all subscribing types. There's no harm in registering when already registered. */
|
||||||
void RegisterTypes();
|
void RegisterTypes();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user