Commits

mattan_f committed 67eafb0

Fixed serializing material attribute values with spaces

Comments (0)

Files changed (1)

OgreMain/src/OgreMaterialSerializer.cpp

 			return;		
 
         // Material name
-		writeAttribute(0, "material " + outMaterialName);
+		writeAttribute(0, "material");
+		writeValue(quoteWord(outMaterialName));
+		
         beginSection(0);
         {
 			// Fire write begin event.
         writeAttribute(1, "technique");
         // only output technique name if it exists.
         if (!pTech->getName().empty())
-            writeValue(pTech->getName());
+            writeValue(quoteWord(pTech->getName()));
 
         beginSection(1);
         {
 				pTech->getSchemeName() != MaterialManager::DEFAULT_SCHEME_NAME)
 			{
 				writeAttribute(2, "scheme");
-				writeValue(pTech->getSchemeName());
+				writeValue(quoteWord(pTech->getSchemeName()));
 			}
 
 			// ShadowCasterMaterial name
 			if (!pTech->getShadowCasterMaterial().isNull())
 			{
 				writeAttribute(2, "shadow_caster_material");
-				writeValue(pTech->getShadowCasterMaterial()->getName());
+				writeValue(quoteWord(pTech->getShadowCasterMaterial()->getName()));
 			}
 			// ShadowReceiverMaterial name
 			if (!pTech->getShadowReceiverMaterial().isNull())
 			{
 				writeAttribute(2, "shadow_receiver_material");
-				writeValue(pTech->getShadowReceiverMaterial()->getName());
+				writeValue(quoteWord(pTech->getShadowReceiverMaterial()->getName()));
 			}
 			// GPU vendor rules
 			Technique::GPUVendorRuleIterator vrit = pTech->getGPUVendorRuleIterator();
 					writeValue("include");
 				else
 					writeValue("exclude");
-				writeValue(RenderSystemCapabilities::vendorToString(rule.vendor));
+				writeValue(quoteWord(RenderSystemCapabilities::vendorToString(rule.vendor)));
 			}
 			// GPU device rules
 			Technique::GPUDeviceNameRuleIterator dnit = pTech->getGPUDeviceNameRuleIterator();
 					writeValue("include");
 				else
 					writeValue("exclude");
-				writeValue(rule.devicePattern);
+				writeValue(quoteWord(rule.devicePattern));
 				writeValue(StringConverter::toString(rule.caseSensitive));
 			}
             // Iterate over passes
         writeAttribute(2, "pass");
         // only output pass name if its not the default name
         if (pPass->getName() != StringConverter::toString(pPass->getIndex()))
-            writeValue(pPass->getName());
+            writeValue(quoteWord(pPass->getName()));
 
         beginSection(2);
         {
         writeAttribute(3, "texture_unit");
         // only write out name if its not equal to the default name
         if (pTex->getName() != StringConverter::toString(pTex->getParent()->getTextureUnitStateIndex(pTex)))
-            writeValue(pTex->getName());
+            writeValue(quoteWord(pTex->getName()));
 
         beginSection(3);
         {
             if (!pTex->getTextureNameAlias().empty())
             {
                 writeAttribute(4, "texture_alias");
-                writeValue(pTex->getTextureNameAlias());
+                writeValue(quoteWord(pTex->getTextureNameAlias()));
             }
 
             //texture name
             if (pTex->getNumFrames() == 1 && !pTex->getTextureName().empty() && !pTex->isCubic())
             {
                 writeAttribute(4, "texture");
-                writeValue(pTex->getTextureName());
+                writeValue(quoteWord(pTex->getTextureName()));
 
                 switch (pTex->getTextureType())
                 {
             {
                 writeAttribute(4, "anim_texture");
                 for (unsigned int n = 0; n < pTex->getNumFrames(); n++)
-                    writeValue(pTex->getFrameTextureName(n));
+                    writeValue(quoteWord(pTex->getFrameTextureName(n)));
                 writeValue(StringConverter::toString(pTex->getAnimationDuration()));
             }
 
             {
                 writeAttribute(4, "cubic_texture");
                 for (unsigned int n = 0; n < pTex->getNumFrames(); n++)
-                    writeValue(pTex->getFrameTextureName(n));
+                    writeValue(quoteWord(pTex->getFrameTextureName(n)));
 
                 //combinedUVW/separateUW
                 if (pTex->getTextureType() == TEX_TYPE_CUBE_MAP)
 					break;
 				case TextureUnitState::CONTENT_COMPOSITOR:
 					writeValue("compositor");
-					writeValue(pTex->getReferencedCompositorName());
-					writeValue(pTex->getReferencedTextureName());
+					writeValue(quoteWord(pTex->getReferencedCompositorName()));
+					writeValue(quoteWord(pTex->getReferencedTextureName()));
 					writeValue(StringConverter::toString(pTex->getReferencedMRTIndex()));
 					break;
 				};
 
         mBuffer += "\n";
         writeAttribute(3, attrib);
-        writeValue(program->getName());
+        writeValue(quoteWord(program->getName()));
         beginSection(3);
         {
             // write out paramters
 
 			writeAttribute(level, label, useMainBuffer);
 			// output param index / name
-			writeValue(identifier, useMainBuffer);
+			writeValue(quoteWord(identifier), useMainBuffer);
 
 			// if auto output auto type name and data if needed
 			if (autoEntry)
 
 				assert(autoConstDef && "Bad auto constant Definition Table");
 				// output auto constant name
-				writeValue(autoConstDef->name, useMainBuffer);
+				writeValue(quoteWord(autoConstDef->name), useMainBuffer);
 				// output data if it uses it
 				switch(autoConstDef->dataType)
 				{
             writeAttribute(0, program->getParameter("type"), false);
 
             // write program name
-            writeValue( program->getName(), false);
+            writeValue( quoteWord(program->getName()), false);
             // write program language
             const String language = program->getLanguage();
             writeValue( language, false );
             {
                 // write program source + filename
                 writeAttribute(1, "source", false);
-                writeValue(program->getSourceFile(), false);
+                writeValue(quoteWord(program->getSourceFile()), false);
                 // write special parameters based on language
                 const ParameterList& params = program->getParameters();
                 ParameterList::const_iterator currentParam = params.begin();