simplify singleton registration
This commit is contained in:
+12
-10
@@ -118,10 +118,22 @@ GameState::GameState() :
|
||||
/* Don't reset yet; let the first screen do it, so we can
|
||||
* use PREFSMAN and THEME. */
|
||||
// Reset();
|
||||
|
||||
// Register with Lua.
|
||||
{
|
||||
Lua *L = LUA->Get();
|
||||
lua_pushstring( L, "GAMESTATE" );
|
||||
this->PushSelf( L );
|
||||
lua_settable( L, LUA_GLOBALSINDEX );
|
||||
LUA->Release( L );
|
||||
}
|
||||
}
|
||||
|
||||
GameState::~GameState()
|
||||
{
|
||||
// Unregister with Lua.
|
||||
LUA->UnsetGlobal( "GAMESTATE" );
|
||||
|
||||
FOREACH_PlayerNumber( p )
|
||||
SAFE_DELETE( m_pPlayerState[p] );
|
||||
FOREACH_MultiPlayer( p )
|
||||
@@ -2116,16 +2128,6 @@ public:
|
||||
ADD_METHOD( GetCurrentStyle );
|
||||
|
||||
Luna<T>::Register( L );
|
||||
|
||||
// Add global singleton if constructed already. If it's not constructed yet,
|
||||
// then we'll register it later when we reinit Lua just before
|
||||
// initializing the display.
|
||||
if( GAMESTATE )
|
||||
{
|
||||
lua_pushstring(L, "GAMESTATE");
|
||||
GAMESTATE->PushSelf( L );
|
||||
lua_settable(L, LUA_GLOBALSINDEX);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user