Explorar o código

Merge pull request #731 from Areloch/importerObjectProcessingFix

Fixes some mishandled cases when preprocessing objects and functions for project import
Brian Roberts %!s(int64=3) %!d(string=hai) anos
pai
achega
da5cb56c83

+ 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

+ 34 - 4
Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript

@@ -476,7 +476,7 @@ function preprocessImportingFiles()
          {
             %line = $ProjectImporter::fileObject.readLine();
             
-            if(strIsMatchExpr("* new*(*)*", %line))
+            if(strIsMatchExpr("*new *(*)*", %line))
             {
                %start = strpos(%line, "new ");
                %end = strpos(%line, "(", %start);
@@ -486,6 +486,14 @@ function preprocessImportingFiles()
                   %className = getSubStr(%line, %start + 4, %end-%start-4);
                }
                
+               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);
@@ -498,6 +506,8 @@ function preprocessImportingFiles()
                   %objectName = getSubStr(%objectName, 0, %inheritanceSplit);
                }
                
+               %objectName = trim(%objectName);
+               
                %parentFileSectionObject = %currentFileSectionObject;
                
                %currentFileSectionObject = new ArrayObject();
@@ -530,7 +540,7 @@ function preprocessImportingFiles()
                      %insideObjectBlock = true;
                }
             }
-            else if(strIsMatchExpr("* datablock*(*)*", %line))
+            else if(strIsMatchExpr("*datablock *(*)*", %line))
             {
                %start = strpos(%line, "datablock ");
                %end = strpos(%line, "(", %start);
@@ -540,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);
@@ -552,6 +570,8 @@ function preprocessImportingFiles()
                   %objectName = getSubStr(%objectName, 0, %inheritanceSplit);
                }
                
+               %objectName = trim(%objectName);
+               
                %parentFileSectionObject = %currentFileSectionObject;
                
                %currentFileSectionObject = new ArrayObject();
@@ -584,7 +604,7 @@ function preprocessImportingFiles()
                      %insideObjectBlock = true;
                }
             }
-            else if(strIsMatchExpr("* singleton*(*)*", %line))
+            else if(strIsMatchExpr("*singleton *(*)*", %line))
             {
                %start = strpos(%line, "singleton ");
                %end = strpos(%line, "(", %start);
@@ -594,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);
@@ -606,6 +634,8 @@ function preprocessImportingFiles()
                   %objectName = getSubStr(%objectName, 0, %inheritanceSplit);
                }
 
+               %objectName = trim(%objectName);
+
                %parentFileSectionObject = %currentFileSectionObject;
                
                %currentFileSectionObject = new ArrayObject();
@@ -638,7 +668,7 @@ function preprocessImportingFiles()
                      %insideObjectBlock = true;
                }
             }
-            else if(strIsMatchExpr("*function*(*)*", %line))
+            else if(strIsMatchExpr("*function *(*)*", %line))
             {
                %start = strpos(%line, "function ");
                %end = strpos(%line, "(", %start);