| 480 | } |
| 481 | |
| 482 | String 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 | |
| 519 | bool isValidObjectName( const char* name ) |
| 520 | { |