From 23ea565846bbd65f731b66af243d1e3910df4e08 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 27 Aug 2005 08:26:34 +0000 Subject: [PATCH] better form: max one param per Input node --- stepmania/src/Actor.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index 199e36a910..5a34506067 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -181,29 +181,30 @@ void Actor::LoadFromNode( const CString& sDir, const XNode* pNode ) // Load Name, if any. pNode->GetAttrValue( "Name", m_sName ); - const XNode* pParameters = pNode->GetChild( "Input" ); - if( pParameters ) + FOREACH_CONST_Child( pNode, pChild ) { - FOREACH_CONST_Attr( pParameters, p ) + if( pChild->m_sName == "Input" ) { /* Parameters are set as globals by ActorUtil::LoadFromActorFile. * If parameters are specified here, save them to the actor. Accessing * parameters as globals directly is deprecated. */ - if( p->m_sName == "Name" ) + CString sName; + if( !pChild->GetAttrValue( "Name", sName ) ) { - const CString &sValue = p->m_sValue; - Lua *L = LUA->Get(); - this->PushSelf( L ); - LuaHelpers::Push( sValue, L ); - lua_getglobal( L, sValue ); - - if( lua_isnil(L, -1) ) - RageException::Throw( "Actor in \"%s\" requires parameter \"%s\" that is not set", sDir.c_str(), sValue.c_str() ); - - lua_settable( L, -3 ); - lua_pop( L, 1 ); - LUA->Release( L ); + RageException::Throw( ssprintf("Input node in '%s' is missing the attribute 'Name'", sDir.c_str()) ); } + + Lua *L = LUA->Get(); + this->PushSelf( L ); + LuaHelpers::Push( sName, L ); + lua_getglobal( L, sName ); + + if( lua_isnil(L, -1) ) + RageException::Throw( "Actor in \"%s\" requires parameter \"%s\" that is not set", sDir.c_str(), sName.c_str() ); + + lua_settable( L, -3 ); + lua_pop( L, 1 ); + LUA->Release( L ); } }