mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-03-01 19:04:21 +01:00
Rescue orphan nodes in inherited scenes
(cherry picked from commit 2b53826ee6872d48acafb9ece1b9027467d2611d)
This commit is contained in:
parent
c1010f7d1b
commit
b6fc4de92f
@ -115,6 +115,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
|
||||
const NodeData &n = nd[i];
|
||||
|
||||
Node *parent = nullptr;
|
||||
String old_parent_path;
|
||||
|
||||
if (i > 0) {
|
||||
ERR_FAIL_COND_V_MSG(n.parent == -1, nullptr, vformat("Invalid scene: node %s does not specify its parent node.", snames[n.name]));
|
||||
@ -122,6 +123,8 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (!nparent && (n.parent & FLAG_ID_IS_PATH)) {
|
||||
WARN_PRINT(String("Parent path '" + String(node_paths[n.parent & FLAG_MASK]) + "' for node '" + String(snames[n.name]) + "' has vanished when instancing: '" + get_path() + "'.").ascii().get_data());
|
||||
old_parent_path = String(node_paths[n.parent & FLAG_MASK]).trim_prefix("./").replace("/", "@");
|
||||
nparent = ret_nodes[0];
|
||||
}
|
||||
#endif
|
||||
parent = nparent;
|
||||
@ -306,6 +309,10 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
|
||||
}
|
||||
}
|
||||
|
||||
if (!old_parent_path.empty()) {
|
||||
node->_set_name_nocheck(old_parent_path + "@" + node->get_name());
|
||||
}
|
||||
|
||||
if (n.owner >= 0) {
|
||||
NODE_FROM_ID(owner, n.owner);
|
||||
if (owner) {
|
||||
|
Loading…
Reference in New Issue
Block a user