iterate over each Attrib only one, not 8 times while searching for name matches

This commit is contained in:
Chris Danford
2005-09-02 00:01:58 +00:00
parent e0b39f225b
commit 30515ffaa4
+18 -26
View File
@@ -190,17 +190,19 @@ Actor::Actor( const Actor &cpy )
void Actor::LoadFromNode( const CString& sDir, const XNode* pNode ) void Actor::LoadFromNode( const CString& sDir, const XNode* pNode )
{ {
// Load Name, if any. FOREACH_CONST_Attr( pNode, pAttr )
pNode->GetAttrValue( "Name", m_sName );
FOREACH_CONST_Attr( pNode, pChild )
{ {
if( pChild->m_sName == "Input" ) // Load Name, if any.
if( pAttr->m_sName == "Name" )
{
m_sName = pAttr->m_sValue;
}
else if( pAttr->m_sName == "Input" )
{ {
/* Parameters are set as globals by ActorUtil::LoadFromActorFile. /* Parameters are set as globals by ActorUtil::LoadFromActorFile.
* If parameters are specified here, save them to the actor. Accessing * If parameters are specified here, save them to the actor. Accessing
* parameters as globals directly is deprecated. */ * parameters as globals directly is deprecated. */
const CString &sName = pChild->m_sValue; const CString &sName = pAttr->m_sValue;
Lua *L = LUA->Get(); Lua *L = LUA->Get();
this->PushSelf( L ); this->PushSelf( L );
@@ -214,28 +216,17 @@ void Actor::LoadFromNode( const CString& sDir, const XNode* pNode )
lua_pop( L, 1 ); lua_pop( L, 1 );
LUA->Release( L ); LUA->Release( L );
} }
} else if( pAttr->m_sName == "BaseRotationXDegrees" ) SetBaseRotationX( atof( pAttr->m_sValue ) );
else if( pAttr->m_sName == "BaseRotationYDegrees" ) SetBaseRotationY( atof( pAttr->m_sValue ) );
float f; else if( pAttr->m_sName == "BaseRotationZDegrees" ) SetBaseRotationZ( atof( pAttr->m_sValue ) );
if( pNode->GetAttrValue( "BaseRotationXDegrees", f ) ) SetBaseRotationX( f ); else if( pAttr->m_sName == "BaseZoomX" ) SetBaseZoomX( atof( pAttr->m_sValue ) );
if( pNode->GetAttrValue( "BaseRotationYDegrees", f ) ) SetBaseRotationY( f ); else if( pAttr->m_sName == "BaseZoomY" ) SetBaseZoomY( atof( pAttr->m_sValue ) );
if( pNode->GetAttrValue( "BaseRotationZDegrees", f ) ) SetBaseRotationZ( f ); else if( pAttr->m_sName == "BaseZoomZ" ) SetBaseZoomZ( atof( pAttr->m_sValue ) );
if( pNode->GetAttrValue( "BaseZoomX", f ) ) SetBaseZoomX( f ); else if( EndsWith(pAttr->m_sName,"Command") )
if( pNode->GetAttrValue( "BaseZoomY", f ) ) SetBaseZoomY( f );
if( pNode->GetAttrValue( "BaseZoomZ", f ) ) SetBaseZoomZ( f );
//
// Load command attributes
//
FOREACH_CONST_Attr( pNode, a )
{ {
CString sKeyName = a->m_sName; /* "OnCommand" */ CString sKeyName = pAttr->m_sName; /* "OnCommand" */
if( sKeyName.Right(7).CompareNoCase("Command") != 0 ) CString sValue = pAttr->m_sValue;
continue; /* not a command */
CString sValue = a->m_sValue;
THEME->EvaluateString( sValue ); THEME->EvaluateString( sValue );
apActorCommands apac( new ActorCommands( sValue ) ); apActorCommands apac( new ActorCommands( sValue ) );
@@ -247,6 +238,7 @@ void Actor::LoadFromNode( const CString& sDir, const XNode* pNode )
sCmdName = sKeyName.Left( sKeyName.size()-7 ); sCmdName = sKeyName.Left( sKeyName.size()-7 );
AddCommand( sCmdName, apac ); AddCommand( sCmdName, apac );
} }
}
// //
// Load command elements // Load command elements