Converts all game, gui editor, and system classes to utilize assets

Processed core, tools and default modules to utilize assets
Converted all console types that were string based, such as TypeImageFilename to utilize const char*/the string table, which avoids a lot of type swapping shenanigans and avoids string corruption
Removed unneeded MainEditor mockup module
Removed some unused/duplicate image assets from the tools
This commit is contained in:
Areloch 2021-07-19 01:07:08 -05:00
parent 83b0432283
commit 5525f8ecdd
1708 changed files with 19619 additions and 4596 deletions

View file

@ -2801,3 +2801,11 @@ DefineEngineFunction( getMaxDynamicVerts, S32, (),,
{
return GFX_MAX_DYNAMIC_VERTS / 2;
}
DefineEngineFunction( getStringHash, S32, (const char* _inString, bool _sensitive), ("", true), "generate a hash from a string. foramt is (string, casesensitive). defaults to true")
{
if (_sensitive)
return S32(String::String(_inString).getHashCaseSensitive());
else
return S32(String::String(_inString).getHashCaseInsensitive());
}

View file

@ -159,7 +159,7 @@ ConsoleProcessData( TypeFilename )
//-----------------------------------------------------------------------------
// TypeStringFilename
//-----------------------------------------------------------------------------
ConsolePrepType( filename, TypeStringFilename, String )
ConsolePrepType( filename, TypeStringFilename, const char* )
ConsoleSetType( TypeStringFilename )
{
@ -177,7 +177,7 @@ ConsoleSetType( TypeStringFilename )
return;
}
*((String*)dptr) = String(buffer);
*((const char**)dptr) = StringTable->insert(buffer);
}
else
Con::printf("(TypeStringFilename) Cannot set multiple args to a single filename.");
@ -185,7 +185,7 @@ ConsoleSetType( TypeStringFilename )
ConsoleGetType( TypeStringFilename )
{
return *((String*)dptr);
return *((const char**)(dptr));
}
ConsoleProcessData( TypeStringFilename )
@ -204,7 +204,7 @@ ConsoleProcessData( TypeStringFilename )
//-----------------------------------------------------------------------------
// TypePrefabFilename
//-----------------------------------------------------------------------------
ConsolePrepType( filename, TypePrefabFilename, String )
ConsolePrepType( filename, TypePrefabFilename, const char* )
ConsoleSetType( TypePrefabFilename )
{
@ -213,7 +213,7 @@ ConsoleSetType( TypePrefabFilename )
ConsoleGetType( TypePrefabFilename )
{
return *((String*)dptr);
return *((const char**)(dptr));
}
ConsoleProcessData( TypePrefabFilename )
@ -232,16 +232,16 @@ ConsoleProcessData( TypePrefabFilename )
//-----------------------------------------------------------------------------
// TypeImageFilename
//-----------------------------------------------------------------------------
ConsolePrepType( filename, TypeImageFilename, String )
ConsolePrepType( filename, TypeImageFilename, const char* )
ConsoleSetType( TypeImageFilename )
{
Con::setData(TypeStringFilename, dptr, 0, argc, argv, tbl, flag);
Con::setData(TypeFilename, dptr, 0, argc, argv, tbl, flag);
}
ConsoleGetType( TypeImageFilename )
{
return *((String*)dptr);
return *((const char**)(dptr));
}
ConsoleProcessData( TypeImageFilename )
@ -281,6 +281,33 @@ ConsoleProcessData( TypeShapeFilename )
}
}
//-----------------------------------------------------------------------------
// TypeSoundFilename
//-----------------------------------------------------------------------------
ConsolePrepType(filename, TypeSoundFilename, const char*)
ConsoleSetType(TypeSoundFilename)
{
Con::setData(TypeFilename, dptr, 0, argc, argv, tbl, flag);
}
ConsoleGetType(TypeSoundFilename)
{
return *((const char **)(dptr));
}
ConsoleProcessData(TypeSoundFilename)
{
if (Con::expandScriptFilename(buffer, bufferSz, data))
return buffer;
else
{
Con::warnf("(TypeSoundFilename) illegal filename detected: %s", data);
return data;
}
}
//-----------------------------------------------------------------------------
// TypeS8
//-----------------------------------------------------------------------------
@ -797,20 +824,17 @@ ConsoleSetType( TypeParticleParameterString )
// TypeMaterialName
//-----------------------------------------------------------------------------
ConsoleType(string, TypeMaterialName, String, "")
ConsoleType(string, TypeMaterialName, const char*, "")
ConsoleGetType( TypeMaterialName )
{
const String *theString = static_cast<const String*>(dptr);
return theString->c_str();
return* ((const char**)(dptr));
}
ConsoleSetType( TypeMaterialName )
{
String *theString = static_cast<String*>(dptr);
if(argc == 1)
*theString = argv[0];
*((const char**)dptr) = StringTable->insert(argv[0]);
else
Con::printf("(TypeMaterialName) Cannot set multiple args to a single string.");
}
@ -860,20 +884,17 @@ ConsoleSetType( TypeTerrainMaterialName )
// TypeCubemapName
//-----------------------------------------------------------------------------
ConsoleType(string, TypeCubemapName, String, "")
ConsoleType(string, TypeCubemapName, const char*, "")
ConsoleGetType( TypeCubemapName )
{
const String *theString = static_cast<const String*>(dptr);
return theString->c_str();
return*((const char**)(dptr));
}
ConsoleSetType( TypeCubemapName )
{
String *theString = static_cast<String*>(dptr);
if(argc == 1)
*theString = argv[0];
*((const char**)dptr) = StringTable->insert(argv[0]);
else
Con::printf("(TypeCubemapName) Cannot set multiple args to a single string.");
}

View file

@ -73,7 +73,7 @@ DefineConsoleType( TypeCaseString, const char * )
DefineConsoleType( TypeRealString, String )
DefineConsoleType( TypeCommand, String )
DefineConsoleType( TypeFilename, const char * )
DefineConsoleType( TypeStringFilename, String )
DefineConsoleType( TypeStringFilename, const char*)
DefineConsoleType(TypeRotationF, RotationF)
@ -87,22 +87,27 @@ DefineUnmappedConsoleType( TypePID, SimPersistID* );
/// TypeImageFilename is equivalent to TypeStringFilename in its usage,
/// it exists for the benefit of GuiInspector, which will provide a custom
/// InspectorField for this type that can display a texture preview.
DefineConsoleType( TypeImageFilename, String )
DefineConsoleType( TypeImageFilename, const char* )
/// TypePrefabFilename is equivalent to TypeStringFilename in its usage,
/// it exists for the benefit of GuiInspector, which will provide a
/// custom InspectorField for this type.
DefineConsoleType( TypePrefabFilename, String )
DefineConsoleType( TypePrefabFilename, const char*)
/// TypeShapeFilename is equivalent to TypeStringFilename in its usage,
/// it exists for the benefit of GuiInspector, which will provide a
/// custom InspectorField for this type.
DefineConsoleType( TypeShapeFilename, String )
DefineConsoleType( TypeShapeFilename, const char* )
/// TypeSoundFilename is exactly the same as TypeShapeFilename
/// it exists for the benefit of GuiInspector, which will provide a
/// custom InspectorField for this type.
DefineConsoleType(TypeSoundFilename, const char*)
/// TypeMaterialName is equivalent to TypeRealString in its usage,
/// it exists for the benefit of GuiInspector, which will provide a
/// custom InspectorField for this type.
DefineConsoleType( TypeMaterialName, String )
DefineConsoleType( TypeMaterialName, const char*)
/// TypeTerrainMaterialIndex is equivalent to TypeS32 in its usage,
/// it exists for the benefit of GuiInspector, which will provide a
@ -116,7 +121,7 @@ DefineConsoleType( TypeTerrainMaterialName, const char * )
/// TypeCubemapName is equivalent to TypeRealString in its usage,
/// but the Inspector will provide a drop-down list of CubemapData objects.
DefineConsoleType( TypeCubemapName, String )
DefineConsoleType( TypeCubemapName, const char*)
DefineConsoleType( TypeParticleParameterString, const char * )

View file

@ -1254,17 +1254,7 @@ PersistenceManager::ParsedObject* PersistenceManager::writeNewObject(SimObject*
dynamic_cast<TSShapeConstructor*>(object))
dclToken = "singleton";
else if( dynamic_cast< SimDataBlock* >( object ) )
{
SimDataBlock* db = static_cast<SimDataBlock*>(object);
if( db->isClientOnly() )
{
if( db->getName() && db->getName()[ 0 ] )
dclToken = "singleton";
}
else
dclToken = "datablock";
}
dclToken = "datablock";
char newLine[ 4096 ];
dMemset(newLine, 0, sizeof( newLine));
@ -1416,17 +1406,25 @@ void PersistenceManager::updateObject(SimObject* object, ParsedObject* parentObj
{
// 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)
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);
}
@ -1495,17 +1493,25 @@ void PersistenceManager::updateObject(SimObject* object, ParsedObject* parentObj
{
// TODO: This should be wrapped in a helper method... probably.
// Detect and collapse relative path information
if (f->type == TypeFilename ||
if (f->type == TypeFilename ||
f->type == TypeStringFilename ||
f->type == TypeImageFilename ||
f->type == TypeImageFilename ||
f->type == TypePrefabFilename ||
f->type == TypeShapeFilename)
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
newLines.push_back(createNewProperty(f->pFieldname, value, f->elementCount > 1, j));
}

View file

@ -339,11 +339,12 @@ void SimObject::writeFields(Stream &stream, U32 tabStop)
// detect and collapse relative path information
char fnBuf[1024];
if (f->type == TypeFilename ||
if (f->type == TypeFilename ||
f->type == TypeStringFilename ||
f->type == TypeImageFilename ||
f->type == TypeImageFilename ||
f->type == TypePrefabFilename ||
f->type == TypeShapeFilename)
f->type == TypeShapeFilename ||
f->type == TypeSoundFilename )
{
Con::collapseScriptFilename(fnBuf, 1024, val);
val = fnBuf;
@ -919,7 +920,15 @@ void SimObject::assignFieldsFrom(SimObject *parent)
dMemset( bufferSecure, 0, 2048 );
dMemcpy( bufferSecure, szBuffer, dStrlen( szBuffer ) );
if((*f->setDataFn)( this, NULL, bufferSecure ) )
//If we have an index worth mentioning, process it for pass-along as well to ensure we set stuff correctly
char* elementIdxBuffer = nullptr;
if (f->elementCount > 1)
{
elementIdxBuffer = Con::getArgBuffer(256);
dSprintf(elementIdxBuffer, 256, "%i", j);
}
if((*f->setDataFn)( this, elementIdxBuffer, bufferSecure ) )
Con::setData(f->type, (void *) (((const char *)this) + f->offset), j, 1, &fieldVal, f->table);
if (f->networkMask != 0)