-bool XmlTagBuilder::AddShaderNode(const char* shader, TextureType textureType, NodeShaderType nodeShaderType)
-{
- /* Adds a shader node
-
- char* shader - the name of the shader or texture (without trailing .tga or something)
-
- returns TRUE if the node was added successfully or FALSE when failed
- */
-
- xmlNodeSetPtr nodePtr = NULL;
- xmlXPathObjectPtr xpathPtr = NULL;
-
- switch(textureType)
- {
- case STOCK:
- xpathPtr = XpathEval("/root/stock");
- break;
- case CUSTOM:
- xpathPtr = XpathEval("/root/custom");
- };
-
- if(xpathPtr)
- nodePtr = xpathPtr->nodesetval;
- else
- return false;
-
- if(!xmlXPathNodeSetIsEmpty(nodePtr))
- {
- xmlNodePtr newnode, newtext;
- xmlNodePtr nodeParent = nodePtr->nodeTab[0];
-
- // create a new node and set the node attribute (shader path)
- switch(nodeShaderType)
- {
- case SHADER:
- newnode = xmlNewNode(NULL, (xmlChar*)"shader");
- break;
- case TEXTURE:
- newnode = xmlNewNode(NULL, (xmlChar*)"texture");
- };
-
- newnode = xmlDocCopyNode(newnode, doc, 1);
- xmlSetProp(newnode, (xmlChar*)"path", (xmlChar*)shader);
- xmlNodeSetContent(newnode, (xmlChar*)"\n ");
-
- if(nodePtr->nodeTab[0]->children->next == NULL) // there are no shaders yet
- {
- // add spaces
- newtext = xmlNewText((xmlChar*)" ");
- xmlAddChild(nodeParent->children, newtext);
-
- // add the new node
- xmlAddNextSibling(nodeParent->children, newnode);
-
- // append a new line
- newtext = xmlNewText((xmlChar*)"\n ");
- xmlAddNextSibling(nodeParent->children->next, newtext);
- } else {
- // add the node
- xmlAddNextSibling(nodeParent->children, newnode);
-
- // append a new line and spaces
- newtext = xmlNewText((xmlChar*)"\n ");
- xmlAddNextSibling(nodeParent->children->next, newtext);
- }
-
- xmlXPathFreeObject(xpathPtr);
- return true;
- } else {
- xmlXPathFreeObject(xpathPtr);
- return false;
- }
+bool XmlTagBuilder::AddShaderNode( const char* shader, TextureType textureType, NodeShaderType nodeShaderType ){
+ /* Adds a shader node
+
+ char* shader - the name of the shader or texture (without trailing .tga or something)
+
+ returns TRUE if the node was added successfully or FALSE when failed
+ */
+
+ xmlNodeSetPtr nodePtr = NULL;
+ xmlXPathObjectPtr xpathPtr = NULL;
+
+ switch ( textureType )
+ {
+ case STOCK:
+ xpathPtr = XpathEval( "/root/stock" );
+ break;
+ case CUSTOM:
+ xpathPtr = XpathEval( "/root/custom" );
+ };
+
+ if ( xpathPtr ) {
+ nodePtr = xpathPtr->nodesetval;
+ }
+ else{
+ return false;
+ }
+
+ if ( !xmlXPathNodeSetIsEmpty( nodePtr ) ) {
+ xmlNodePtr newnode, newtext;
+ xmlNodePtr nodeParent = nodePtr->nodeTab[0];
+
+ // create a new node and set the node attribute (shader path)
+ switch ( nodeShaderType )
+ {
+ case SHADER:
+ newnode = xmlNewNode( NULL, (xmlChar*)"shader" );
+ break;
+ case TEXTURE:
+ newnode = xmlNewNode( NULL, (xmlChar*)"texture" );
+ };
+
+ newnode = xmlDocCopyNode( newnode, doc, 1 );
+ xmlSetProp( newnode, (xmlChar*)"path", (xmlChar*)shader );
+ xmlNodeSetContent( newnode, (xmlChar*)"\n " );
+
+ if ( nodePtr->nodeTab[0]->children->next == NULL ) { // there are no shaders yet
+ // add spaces
+ newtext = xmlNewText( (xmlChar*)" " );
+ xmlAddChild( nodeParent->children, newtext );
+
+ // add the new node
+ xmlAddNextSibling( nodeParent->children, newnode );
+
+ // append a new line
+ newtext = xmlNewText( (xmlChar*)"\n " );
+ xmlAddNextSibling( nodeParent->children->next, newtext );
+ }
+ else {
+ // add the node
+ xmlAddNextSibling( nodeParent->children, newnode );
+
+ // append a new line and spaces
+ newtext = xmlNewText( (xmlChar*)"\n " );
+ xmlAddNextSibling( nodeParent->children->next, newtext );
+ }
+
+ xmlXPathFreeObject( xpathPtr );
+ return true;
+ }
+ else {
+ xmlXPathFreeObject( xpathPtr );
+ return false;
+ }