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

Method addCmd_renameNode

Engine/source/ts/tsShapeConstruct.cpp:2527–2566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2525}
2526
2527bool TSShapeConstructor::ChangeSet::addCmd_renameNode(const TSShapeConstructor::ChangeSet::Command& newCmd)
2528{
2529 // Replace name argument for previous addNode or renameNode, but stop
2530 // if the new name is already in use (can occur if 2 nodes switch names). eg.
2531 // A->C
2532 // B->A
2533 // C->B (cannot replace the previous A->C with A->B as 'B' is in use)
2534
2535 for (S32 index = mCommands.size() - 1; index >= 0; index--)
2536 {
2537 Command& cmd = mCommands[index];
2538 switch (cmd.type)
2539 {
2540 case CmdAddNode:
2541 if (namesEqual(cmd.argv[0], newCmd.argv[0]))
2542 {
2543 cmd.argv[0] = newCmd.argv[1]; // Replace initial name argument
2544 return false;
2545 }
2546 break;
2547
2548 case CmdRenameNode:
2549 if (namesEqual(cmd.argv[1], newCmd.argv[0]))
2550 {
2551 cmd.argv[1] = newCmd.argv[1]; // Collapse successive renames
2552 if (namesEqual(cmd.argv[0], cmd.argv[1]))
2553 mCommands.erase(index); // Ignore empty renames
2554 return false;
2555 }
2556 else if (namesEqual(cmd.argv[0], newCmd.argv[1]))
2557 return true; // Name is in use, cannot go back further
2558 break;
2559
2560 default:
2561 break;
2562 }
2563 }
2564
2565 return true;
2566}
2567
2568bool TSShapeConstructor::ChangeSet::addCmd_removeNode(const TSShapeConstructor::ChangeSet::Command& newCmd)
2569{

Callers

nothing calls this directly

Calls 3

namesEqualFunction · 0.85
sizeMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected