diff --git a/src/XmlFileUtil.cpp b/src/XmlFileUtil.cpp index 449fd08764..4bcfe0e40f 100644 --- a/src/XmlFileUtil.cpp +++ b/src/XmlFileUtil.cpp @@ -600,6 +600,27 @@ namespace } } +void XmlFileUtil::AnnotateXNodeTree( XNode *pNode, const RString &sFile ) +{ + RString sDir = Dirname( sFile ); + + vector queue; + queue.push_back( pNode ); + while( !queue.empty() ) + { + pNode = queue.back(); + queue.pop_back(); + FOREACH_Child( pNode, pChild ) + queue.push_back( pChild ); + + /* Source file, for error messages: */ + pNode->AppendAttr( "_Source", sFile ); + + /* Directory of caller, for relative paths: */ + pNode->AppendAttr( "_Dir", sDir ); + } +} + void XmlFileUtil::CompileXNodeTree( XNode *pNode, const RString &sFile ) { vector aToCompile; diff --git a/src/XmlFileUtil.h b/src/XmlFileUtil.h index 9691e47237..c4e0c10e10 100644 --- a/src/XmlFileUtil.h +++ b/src/XmlFileUtil.h @@ -21,6 +21,7 @@ namespace XmlFileUtil bool SaveToFile( const XNode *pNode, const RString &sFile, const RString &sStylesheet = "", bool bWriteTabs = true ); bool SaveToFile( const XNode *pNode, RageFileBasic &f, const RString &sStylesheet = "", bool bWriteTabs = true ); + void AnnotateXNodeTree( XNode *pNode, const RString &sFile ); void CompileXNodeTree( XNode *pNode, const RString &sFile ); XNode *XNodeFromTable( lua_State *L );