| 359 | //----------------------------------------------------------------------------- |
| 360 | |
| 361 | template<class T> bool doRename(TSShape* shape, Vector<T>& group, const String& oldName, const String& newName) |
| 362 | { |
| 363 | // Find the element in the group with the oldName |
| 364 | S32 index = findByName(group, shape->findName(oldName)); |
| 365 | if (index < 0) |
| 366 | { |
| 367 | Con::errorf("TSShape::rename: Could not find '%s'", oldName.c_str()); |
| 368 | return false; |
| 369 | } |
| 370 | |
| 371 | // Ignore trivial renames |
| 372 | if (oldName.equal(newName, String::NoCase)) |
| 373 | return true; |
| 374 | |
| 375 | // Check that this name is not already in use |
| 376 | if (findByName(group, shape->findName(newName)) >= 0) |
| 377 | { |
| 378 | Con::errorf("TSShape::rename: '%s' is already in use", newName.c_str()); |
| 379 | return false; |
| 380 | } |
| 381 | |
| 382 | // Do the rename (the old name will be removed if it is no longer in use) |
| 383 | group[index].nameIndex = shape->addName(newName); |
| 384 | shape->removeName(oldName); |
| 385 | return true; |
| 386 | } |
| 387 | |
| 388 | bool TSShape::renameNode(const String& oldName, const String& newName) |
| 389 | { |
no test coverage detected