MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / getUniqueInternalName

Function getUniqueInternalName

Engine/source/console/simManager.cpp:482–517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480}
481
482String getUniqueInternalName( const char *inName, SimSet *inSet, bool searchChildren )
483{
484 // Since SimSet::findObjectByInternalName operates with StringTableEntry(s)
485 // we have to muck up the StringTable with our attempts.
486 // But then again, so does everywhere else.
487
488 StringTableEntry outName = StringTable->insert( inName );
489
490 if ( !outName || !outName[0] )
491 return String::EmptyString;
492
493 if ( !inSet->findObjectByInternalName( outName, searchChildren ) )
494 return String(outName);
495
496 S32 suffixNumb = -1;
497 String nameStr( String::GetTrailingNumber( outName, suffixNumb ) );
498 suffixNumb++;
499
500 static char tempStr[512];
501
502#define MAX_TRIES 100
503
504 for ( U32 i = 0; i < MAX_TRIES; i++ )
505 {
506 dSprintf( tempStr, 512, "%s%d", nameStr.c_str(), suffixNumb );
507 outName = StringTable->insert( tempStr );
508
509 if ( !inSet->findObjectByInternalName( outName, searchChildren ) )
510 return String(outName);
511
512 suffixNumb++;
513 }
514
515 Con::errorf( "Sim::getUniqueInternalName( %s ) - failed after %d attempts", inName, MAX_TRIES );
516 return String::EmptyString;
517}
518
519bool isValidObjectName( const char* name )
520{

Callers 1

sim.cppFile · 0.85

Calls 6

dSprintfFunction · 0.85
StringClass · 0.70
errorfFunction · 0.70
insertMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected