From fc9d79d7b268430bc5be34a3bcecbd2ca3052848 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 3 Feb 2007 11:02:45 +0000 Subject: [PATCH] remove old actor parameters; obsoleted by LuaThreadVariable --- stepmania/src/Actor.cpp | 18 --------- stepmania/src/ActorUtil.cpp | 80 ------------------------------------- stepmania/src/ActorUtil.h | 3 -- 3 files changed, 101 deletions(-) diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index 774acb6b3d..d6736aa517 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -211,24 +211,6 @@ void Actor::LoadFromNode( const XNode* pNode ) Lua *L = LUA->Get(); FOREACH_CONST_Child( pNode, pChild ) { - if( pChild->GetName() == "Input" ) - { - /* If parameters are specified here, save their values to the actor. */ - RString sName; - if( !pChild->GetAttrValue( "Name", sName ) ) - RageException::Throw( "%s: Input: missing the attribute \"Name\"", ActorUtil::GetWhere(pNode).c_str() ); - - this->PushSelf( L ); - LuaHelpers::Push( L, sName ); - ActorUtil::GetParam( L, sName ); - - if( lua_isnil(L, -1) ) - RageException::Throw( "%s: Actor requires parameter \"%s\" that is not set", ActorUtil::GetWhere(pNode).c_str(), sName.c_str() ); - - lua_settable( L, -3 ); - lua_pop( L, 1 ); - } - if( pChild->GetName() == "Context" ) { RString sName; diff --git a/stepmania/src/ActorUtil.cpp b/stepmania/src/ActorUtil.cpp index 8e256ceb2b..d9ca9d6bfa 100644 --- a/stepmania/src/ActorUtil.cpp +++ b/stepmania/src/ActorUtil.cpp @@ -124,53 +124,6 @@ retry: return true; } -static void PushParamsTable( Lua *L ) -{ - lua_pushstring( L, "P" ); - lua_rawget( L, LUA_GLOBALSINDEX ); - if( lua_isnil(L, -1) ) - { - lua_pop( L, 1 ); - lua_newtable( L ); - lua_pushstring( L, "P" ); - lua_pushvalue( L, -2 ); - lua_rawset( L, LUA_GLOBALSINDEX ); - } -} - -/* Set an input parameter to the first value on the stack. If pOld is non-NULL, - * set it to the old value. The value used on the stack will be removed. */ -void ActorUtil::SetParamFromStack( Lua *L, RString sName, LuaReference *pOld ) -{ - int iValue = lua_gettop(L); - - PushParamsTable( L ); - int iParams = lua_gettop(L); - - /* Save the old value. */ - if( pOld != NULL ) - { - lua_getfield( L, iParams, sName ); - pOld->SetFromStack( L ); - } - - /* Set the value in the table. */ - lua_pushvalue( L, iValue ); - lua_setfield( L, iParams, sName ); - - lua_settop( L, iValue-1 ); -} - -/* Look up a param set with SetParamFromStack, and push it on the stack. */ -void ActorUtil::GetParam( Lua *L, const RString &sName ) -{ - /* Search the params table. */ - PushParamsTable( L ); - LuaHelpers::Push( L, sName ); - lua_rawget( L, -2 ); - lua_remove( L, -2 ); -} - Actor* ActorUtil::LoadFromNode( const XNode* pNode, Actor *pParentActor ) { ASSERT( pNode ); @@ -181,28 +134,6 @@ Actor* ActorUtil::LoadFromNode( const XNode* pNode, Actor *pParentActor ) return NULL; } - // Load Params - map setOldParams; - { - FOREACH_CONST_Child( pNode, pChild ) - { - if( pChild->GetName() == "Param" ) - { - RString sName; - if( !pChild->GetAttrValue( "Name", sName ) ) - Dialog::OK( ssprintf("%s: Param: missing the attribute \"Name\"", ActorUtil::GetWhere(pNode).c_str()), "MISSING_ATTRIBUTE" ); - - Lua *L = LUA->Get(); - if( !pChild->PushAttrValue( L, "Value" ) ) - Dialog::OK( ssprintf("%s: Param: missing the attribute \"Value\"", ActorUtil::GetWhere(pNode).c_str()), "MISSING_ATTRIBUTE" ); - - SetParamFromStack( L, sName, &setOldParams[sName] ); - LUA->Release(L); - } - } - } - - // Element name is the type in XML. // Type= is the name in INI. // TODO: Remove the backward compat fallback @@ -249,17 +180,6 @@ Actor* ActorUtil::LoadFromNode( const XNode* pNode, Actor *pParentActor ) all_done: - // Unload Params - { - Lua *L = LUA->Get(); - FOREACHM( RString, LuaReference, setOldParams, old ) - { - old->second.PushSelf( L ); - SetParamFromStack( L, old->first, NULL ); - } - LUA->Release(L); - } - return pReturn; } diff --git a/stepmania/src/ActorUtil.h b/stepmania/src/ActorUtil.h index a8adfcc8e2..73ea3bfb41 100644 --- a/stepmania/src/ActorUtil.h +++ b/stepmania/src/ActorUtil.h @@ -77,9 +77,6 @@ namespace ActorUtil void SortByZPosition( vector &vActors ); FileType GetFileType( const RString &sPath ); - - void SetParamFromStack( Lua *L, RString sName, LuaReference *pOld=NULL ); - void GetParam( Lua *L, const RString &sName ); }; #define SET_XY( actor ) ActorUtil::SetXY( actor, m_sName )