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

Function doRename

Engine/source/ts/tsShapeEdit.cpp:361–386  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359//-----------------------------------------------------------------------------
360
361template<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
388bool TSShape::renameNode(const String& oldName, const String& newName)
389{

Callers 4

renameNodeMethod · 0.85
renameObjectMethod · 0.85
renameDetailMethod · 0.85
renameSequenceMethod · 0.85

Calls 7

findByNameFunction · 0.85
findNameMethod · 0.80
addNameMethod · 0.80
removeNameMethod · 0.80
errorfFunction · 0.50
c_strMethod · 0.45
equalMethod · 0.45

Tested by

no test coverage detected