diff --git a/stepmania/src/LuaManager.cpp b/stepmania/src/LuaManager.cpp index e8bc2639e8..e35addf1ee 100644 --- a/stepmania/src/LuaManager.cpp +++ b/stepmania/src/LuaManager.cpp @@ -199,6 +199,18 @@ LuaManager::~LuaManager() lua_close( L ); } +void LuaManager::RegisterTypes() +{ + if( g_vRegisterActorTypes ) + { + for( unsigned i=0; isize(); i++ ) + { + RegisterActorFn fn = (*g_vRegisterActorTypes)[i]; + fn( L ); + } + } +} + void LuaManager::ResetState() { if( L != NULL ) @@ -221,15 +233,8 @@ void LuaManager::ResetState() for( const LuaFunctionList *p = g_LuaFunctions; p; p=p->next ) lua_register( L, p->name, p->func ); - - if( g_vRegisterActorTypes ) - { - for( unsigned i=0; isize(); i++ ) - { - RegisterActorFn fn = (*g_vRegisterActorTypes)[i]; - fn( L ); - } - } + + RegisterTypes(); LuaReference::AfterResetAll(); } diff --git a/stepmania/src/LuaManager.h b/stepmania/src/LuaManager.h index 918ad7abb9..55117d3929 100644 --- a/stepmania/src/LuaManager.h +++ b/stepmania/src/LuaManager.h @@ -18,6 +18,9 @@ public: bool RunScriptFile( const CString &sFile ); + /* Register all subscribing types. There's no harm in registering when already registered. */ + void RegisterTypes(); + /* Reset the environment, freeing any globals left over by previously executed scripts. */ void ResetState(); diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index af09ea7205..e77c609955 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -1092,9 +1092,9 @@ int main(int argc, char* argv[]) MESSAGEMAN = new MessageManager; STATSMAN = new StatsManager; - // UGLY: Reload the current theme now that all global singletons are - // constructed so that they can be registered with Lua. - THEME->UpdateLuaGlobals(); + // UGLY: Now that all global singletons are constructed so that they, let them + // all register with Lua. + LUA->RegisterTypes(); SAFE_DELETE( loading_window ); // destroy this before init'ing Display