2
0
Эх сурвалжийг харах

Update taml_ScriptBinding.h

fix spam on saving, we only care about compression when baml is being written out. set it to false for all apart from where specified as binary, if the format is specified then turn off auto format. This warning was also wrong its binary format
marauder2k7 1 долоо хоног өмнө
parent
commit
efe8c184d4

+ 19 - 15
Engine/source/persistence/taml/taml_ScriptBinding.h

@@ -226,7 +226,7 @@ DefineEngineMethod(Taml, read, SimObject*, (const char* filename), ,    "(filena
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 
 
 DefineEngineFunction(TamlWrite, bool, (SimObject* simObject, const char* filename, const char* format, bool compressed), 
 DefineEngineFunction(TamlWrite, bool, (SimObject* simObject, const char* filename, const char* format, bool compressed), 
-                                       ("xml", true),  
+                                       ("xml", false),  
                                         "(object, filename, [format], [compressed]) - Writes an object to a file using Taml.\n"
                                         "(object, filename, [format], [compressed]) - Writes an object to a file using Taml.\n"
                                         "@param object The object to write.\n"
                                         "@param object The object to write.\n"
                                         "@param filename The filename to write to.\n"
                                         "@param filename The filename to write to.\n"
@@ -245,25 +245,29 @@ DefineEngineFunction(TamlWrite, bool, (SimObject* simObject, const char* filenam
 
 
    Taml taml;
    Taml taml;
 
 
-   taml.setFormatMode( Taml::getFormatModeEnum(format) );  
-
-   // Yes, so is the format mode binary?
-   if ( taml.getFormatMode() == Taml::BinaryFormat )
+   if (filename != NULL && filename[0] != '\0')
    {
    {
-      // Yes, so set binary compression.
-      taml.setBinaryCompression( compressed );
+      taml.setFormatMode(Taml::getFormatModeEnum(format));
+      // Turn-off auto-formatting.
+      taml.setAutoFormat(false);
    }
    }
-   else
+
+   // should only be checking if compression if compressed is true.
+   if (compressed)
    {
    {
-      #ifdef TORQUE_DEBUG
-      // No, so warn.
-      Con::warnf( "TamlWrite() - Setting binary compression is only valid for XML formatting." );
-      #endif
+      // Yes, so is the format mode binary?
+      if (taml.getFormatMode() == Taml::BinaryFormat)
+      {
+         // Yes, so set binary compression.
+         taml.setBinaryCompression(compressed);
+      }
+      else
+      {
+         // No, so warn.
+         Con::warnf("TamlWrite() - Setting binary compression is only valid for BINARY format.");
+      }
    }
    }
 
 
-   // Turn-off auto-formatting.
-   taml.setAutoFormat( false );
-
    // Write.
    // Write.
    return taml.write( simObject, filename );
    return taml.write( simObject, filename );
 }
 }