better form: max one param per Input node

This commit is contained in:
Glenn Maynard
2005-08-27 08:26:34 +00:00
parent 60317928f2
commit 23ea565846
+17 -16
View File
@@ -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 );
}
}