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.
This commit is contained in:
JeffR 2022-02-24 01:33:14 -06:00
parent 8d8432115b
commit 7659b51ac9
2 changed files with 29 additions and 1 deletions

View file

@ -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

View file

@ -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();