Procházet zdrojové kódy

Added trimming of parsed object names to ensure whitespace before and after isn't accidentally processed as invalid characters
Also made the classname validity check happen on the other creation keyword types
Added logic so when processing an importing material definition that already has an asset, can handle it if the scriptPath doesn't have the extension in it already.

JeffR před 3 roky
rodič
revize
7659b51ac9

+ 6 - 0
Templates/BaseGame/game/tools/projectImporter/importers/pre40/T3Dpre4ProjectImporter.tscript

@@ -1038,6 +1038,12 @@ function T3Dpre4ProjectImporter::processMaterialObject(%this, %fileObject, %obje
       
       %assetScriptPath = %assetDef.getScriptPath();
       
+      if(fileExt(%assetScriptPath) $= "")
+      {
+         //try the default extension
+         %assetScriptPath = %assetScriptPath @ "." @ $TorqueScriptFileExtension;  
+      }
+      
       if(isFile(%assetScriptPath) && isObject(%objectName))
       {
          //Regular material in a companion file, so we'll want to write it to the

+ 23 - 1
Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript

@@ -488,7 +488,7 @@ function preprocessImportingFiles()
                
                if(%className $= "")
                {
-                  //we clearly have some unusual formatting, potentially a progromattic 
+                  //we clearly have some unusual formatting, potentially a programmatic 
                   //object block creation going on here. so we'll just skip it and move on  
                   %currentFileSectionObject.add(%line);
                   continue;
@@ -506,6 +506,8 @@ function preprocessImportingFiles()
                   %objectName = getSubStr(%objectName, 0, %inheritanceSplit);
                }
                
+               %objectName = trim(%objectName);
+               
                %parentFileSectionObject = %currentFileSectionObject;
                
                %currentFileSectionObject = new ArrayObject();
@@ -548,6 +550,14 @@ function preprocessImportingFiles()
                   %className = getSubStr(%line, %start + 10, %end-%start-10);
                }
                
+               if(%className $= "")
+               {
+                  //we clearly have some unusual formatting, potentially a programmatic 
+                  //object block creation going on here. so we'll just skip it and move on  
+                  %currentFileSectionObject.add(%line);
+                  continue;
+               }
+               
                %nameEnd = strpos(%line, ")", %end);
                
                %objectName = getSubStr(%line, %end+1, %nameEnd-%end-1);
@@ -560,6 +570,8 @@ function preprocessImportingFiles()
                   %objectName = getSubStr(%objectName, 0, %inheritanceSplit);
                }
                
+               %objectName = trim(%objectName);
+               
                %parentFileSectionObject = %currentFileSectionObject;
                
                %currentFileSectionObject = new ArrayObject();
@@ -602,6 +614,14 @@ function preprocessImportingFiles()
                   %className = getSubStr(%line, %start + 10, %end-%start-10);
                }
                
+               if(%className $= "")
+               {
+                  //we clearly have some unusual formatting, potentially a programmatic 
+                  //object block creation going on here. so we'll just skip it and move on  
+                  %currentFileSectionObject.add(%line);
+                  continue;
+               }
+               
                %nameEnd = strpos(%line, ")", %end);
                
                %objectName = getSubStr(%line, %end+1, %nameEnd-%end-1);
@@ -614,6 +634,8 @@ function preprocessImportingFiles()
                   %objectName = getSubStr(%objectName, 0, %inheritanceSplit);
                }
 
+               %objectName = trim(%objectName);
+
                %parentFileSectionObject = %currentFileSectionObject;
                
                %currentFileSectionObject = new ArrayObject();