tighten up MergeActorXML: only merge commands, fix and clean up

warning
This commit is contained in:
Glenn Maynard
2006-10-11 04:54:08 +00:00
parent 33a4b55076
commit 0b87622780
+9 -12
View File
@@ -272,7 +272,7 @@ all_done:
} }
/* /*
* Merge a parent and child XML. For example, * Merge commands from a parent into a child. For example,
* *
* parent.xml: <Layer File="child" OnCommand="x,10" /> * parent.xml: <Layer File="child" OnCommand="x,10" />
* child.xml: <Layer1 File="image" OffCommand="y,10" /> * child.xml: <Layer1 File="image" OffCommand="y,10" />
@@ -281,9 +281,7 @@ all_done:
* *
* <Layer1 File="image" OnCommand="x,10" OffCommand="y,10" /> * <Layer1 File="image" OnCommand="x,10" OffCommand="y,10" />
* *
* The result is a copy of the child, with attributes and children * Warn about duplicate commands.
* from the parent merged, excluding the attribute "File". Warn
* about duplicate attributes.
*/ */
static void MergeActorXML( XNode *pChild, const XNode *pParent ) static void MergeActorXML( XNode *pChild, const XNode *pParent )
{ {
@@ -292,19 +290,18 @@ static void MergeActorXML( XNode *pChild, const XNode *pParent )
FOREACH_CONST_Attr( pParent, p ) FOREACH_CONST_Attr( pParent, p )
{ {
if( p->first == "File" ) const RString &sName = p->first;
if( !EndsWith(sName, "Command") )
continue; continue;
RString sOld; if( pChild->GetAttr(p->first) != NULL )
if( pChild->GetChildValue(p->first, sOld) )
{ {
RString sWarning = RString sWarning =
ssprintf( "Overriding \"%s\" (\"%s\") in XML node \"%s\" with \"%s\" in XML node \"%s\"", ssprintf( "%s: \"%s\" overrides \"%s\" in %s",
p->first.c_str(), ActorUtil::GetWhere(pParent).c_str(),
sName.c_str(),
p->second->GetValue<RString>().c_str(), p->second->GetValue<RString>().c_str(),
pChild->GetName().c_str(), ActorUtil::GetWhere(pChild).c_str() );
sOld.c_str(),
pParent->GetName().c_str() );
Dialog::OK( sWarning, "XML_ATTRIB_OVERRIDE" ); Dialog::OK( sWarning, "XML_ATTRIB_OVERRIDE" );
} }
pChild->AppendAttrFrom( p->first, p->second->Copy() ); pChild->AppendAttrFrom( p->first, p->second->Copy() );