Fix the update node method
This commit is contained in:
parent
f46991f313
commit
cd0d3bc89e
@ -375,21 +375,25 @@ func update_node_and_send(node_id: String):
|
|||||||
if not pending_updates.has(node_id):
|
if not pending_updates.has(node_id):
|
||||||
return # No updates for this node
|
return # No updates for this node
|
||||||
|
|
||||||
var target_node = node_map.get(node_id)
|
var updates_for_node = pending_updates[node_id]
|
||||||
if not target_node:
|
|
||||||
return # Node not found
|
if not node_map.has(node_id):
|
||||||
|
# Handle cases where the node might not exist yet (e.g., during node creation)
|
||||||
|
return # Node not found (might be created later)
|
||||||
|
|
||||||
|
var target_node = node_map[node_id]
|
||||||
|
|
||||||
# Apply updates to the target node's properties
|
# Apply updates to the target node's properties
|
||||||
for key in pending_updates[node_id].keys():
|
for key in updates_for_node.keys():
|
||||||
target_node[key] = pending_updates[node_id][key]
|
target_node.set(key, updates_for_node[key])
|
||||||
|
|
||||||
|
# Clear updates for this node after applying them
|
||||||
|
pending_updates.erase(node_id)
|
||||||
|
|
||||||
# Send an update packet immediately for reliability
|
# Send an update packet immediately for reliability
|
||||||
var packet_data = {"message": "property_update", "updates": {node_id: pending_updates[node_id]}}
|
var packet_data = {"message": "property_update", "updates": {node_id: updates_for_node}}
|
||||||
send_p2p_packet(0, packet_data)
|
send_p2p_packet(0, packet_data)
|
||||||
|
|
||||||
# Clear updates for this node after sending them
|
|
||||||
pending_updates.erase(node_id)
|
|
||||||
|
|
||||||
|
|
||||||
func send_pending_updates():
|
func send_pending_updates():
|
||||||
if pending_updates.size() == 0:
|
if pending_updates.size() == 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user