From 6b7b6f5cd7d330f2253439b8f3126229de41a2a4 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 18 Jan 2006 06:14:58 +0000 Subject: [PATCH] fix restoring params --- stepmania/src/ActorUtil.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/stepmania/src/ActorUtil.cpp b/stepmania/src/ActorUtil.cpp index c33842d61e..1ea84352fe 100644 --- a/stepmania/src/ActorUtil.cpp +++ b/stepmania/src/ActorUtil.cpp @@ -185,6 +185,7 @@ Actor* ActorUtil::LoadFromNode( const CString& sDir, const XNode* pNode ) } // Load Params + map setOldParams; { FOREACH_CONST_Child( pNode, pChild ) { @@ -204,7 +205,8 @@ Actor* ActorUtil::LoadFromNode( const CString& sDir, const XNode* pNode ) Lua *L = LUA->Get(); LuaHelpers::RunScript( L, "return " + s, "", 1 ); - SetParamFromStack( L, sName, NULL ); + + SetParamFromStack( L, sName, &setOldParams[sName] ); LUA->Release(L); } else @@ -272,19 +274,13 @@ all_done: // Unload Params { - FOREACH_CONST_Child( pNode, pChild ) + Lua *L = LUA->Get(); + FOREACHM( CString, LuaReference, setOldParams, old ) { - if( pChild->m_sName == "Param" ) - { - CString sName; - if( !pChild->GetAttrValue( "Name", sName ) ) - { - RageException::Throw( ssprintf("Param node in '%s' is missing the attribute 'Name'", sDir.c_str()) ); - } - - LUA->UnsetGlobal( sName ); - } + old->second.PushSelf( L ); + SetParamFromStack( L, old->first, NULL ); } + LUA->Release(L); } return pReturn;