From 0e22488434f6af6c41a12c1e64588761048d4ebe Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 19 Jan 2025 13:31:23 -0600 Subject: [PATCH] cleanups and safeties. had a bunch of dupliated code injectors that are bypassed by the nature of AbstractClassRep::FIELD_SpecialtyArrayField since those getSpecialFieldOut entries return a const char * from the stringtable, we *don't* want to try and kill those off, since that can lead to trying to delete deleted things from what was designed as a permanent record --- Engine/source/console/persistenceManager.cpp | 58 ++------------------ 1 file changed, 5 insertions(+), 53 deletions(-) diff --git a/Engine/source/console/persistenceManager.cpp b/Engine/source/console/persistenceManager.cpp index 9e0acbaf4..7badd000f 100644 --- a/Engine/source/console/persistenceManager.cpp +++ b/Engine/source/console/persistenceManager.cpp @@ -1433,29 +1433,7 @@ void PersistenceManager::updateObject(SimObject* object, ParsedObject* parentObj } else { - // TODO: This should be wrapped in a helper method... probably. - // Detect and collapse relative path information - if (f->type == TypeFilename || - f->type == TypeStringFilename || - f->type == TypeImageFilename || - f->type == TypePrefabFilename || - f->type == TypeShapeFilename || - f->type == TypeSoundFilename) - { - char fnBuf[1024]; - Con::collapseScriptFilename(fnBuf, 1024, value); - - updateToken(prop.valueLine, prop.valuePosition, prop.endPosition - prop.valuePosition, fnBuf, true); - } - else if (f->type == TypeCommand || f->type == TypeString || f->type == TypeRealString) - { - char cmdBuf[1024]; - expandEscape(cmdBuf, value); - - updateToken(prop.valueLine, prop.valuePosition, prop.endPosition - prop.valuePosition, cmdBuf, true); - } - else - updateToken(prop.valueLine, prop.valuePosition, prop.endPosition - prop.valuePosition, value, true); + updateToken(prop.valueLine, prop.valuePosition, prop.endPosition - prop.valuePosition, value, true); } } } @@ -1520,33 +1498,7 @@ void PersistenceManager::updateObject(SimObject* object, ParsedObject* parentObj // value then add it to the ParsedObject's newLines if (mustUpdate) { - // TODO: This should be wrapped in a helper method... probably. - // Detect and collapse relative path information - if (f->type == TypeFilename || - f->type == TypeStringFilename || - f->type == TypeImageFilename || - f->type == TypePrefabFilename || - f->type == TypeShapeFilename || - f->type == TypeSoundFilename) - { - char fnBuf[1024]; - Con::collapseScriptFilename(fnBuf, 1024, value); - - newLines.push_back(createNewProperty(f->pFieldname, fnBuf, f->elementCount > 1, j)); - } - else if (f->type == TypeCommand) - { - char cmdBuf[1024]; - expandEscape(cmdBuf, value); - - newLines.push_back(createNewProperty(f->pFieldname, cmdBuf, f->elementCount > 1, j)); - } - else if (f->flag.test(AbstractClassRep::FIELD_SpecialtyArrayField)) - { - newLines.push_back(value); - } - else - newLines.push_back(createNewProperty(f->pFieldname, value, f->elementCount > 1, j)); + newLines.push_back(String::String(value).c_str()); } if (defaultValue) @@ -1862,11 +1814,11 @@ void PersistenceManager::updateObject(SimObject* object, ParsedObject* parentObj // Clean up the newLines memory for (U32 i = 0; i < newLines.size(); i++) { - if (newLines[i]) - { + if (!isEmptyLine(newLines[i]) && !StringTable->lookup(newLines[i])) + {//don't try killing empty lines or lines that are in the string table dFree(newLines[i]); - newLines[ i ] = NULL; } + newLines[ i ] = NULL; } newLines.clear();