MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _watch_changes

Method _watch_changes

modules/multiplayer/multiplayer_synchronizer.cpp:381–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379}
380
381Error MultiplayerSynchronizer::_watch_changes(uint64_t p_usec) {
382 ERR_FAIL_COND_V(replication_config.is_null(), FAILED);
383 const List<NodePath> props = replication_config->get_watch_properties();
384 if (props.size() != watchers.size()) {
385 watchers.resize(props.size());
386 }
387 if (props.is_empty()) {
388 return OK;
389 }
390 Node *node = get_root_node();
391 ERR_FAIL_NULL_V(node, FAILED);
392 int idx = -1;
393 Watcher *ptr = watchers.ptrw();
394 for (const NodePath &prop : props) {
395 idx++;
396 bool valid = false;
397 const Object *obj = _get_prop_target(node, prop);
398 ERR_CONTINUE_MSG(!obj, vformat("Node not found for property '%s'.", prop));
399 Variant v = obj->get_indexed(prop.get_subnames(), &valid);
400 ERR_CONTINUE_MSG(!valid, vformat("Property '%s' not found.", prop));
401 Watcher &w = ptr[idx];
402 if (w.prop != prop) {
403 w.prop = prop;
404 w.value = v.duplicate(true);
405 w.last_change_usec = p_usec;
406 } else if (!w.value.hash_compare(v)) {
407 w.value = v.duplicate(true);
408 w.last_change_usec = p_usec;
409 }
410 }
411 return OK;
412}
413
414List<Variant> MultiplayerSynchronizer::get_delta_state(uint64_t p_cur_usec, uint64_t p_last_usec, uint64_t &r_indexes) {
415 r_indexes = 0;

Callers

nothing calls this directly

Calls 10

vformatFunction · 0.85
get_indexedMethod · 0.80
get_subnamesMethod · 0.80
hash_compareMethod · 0.80
sizeMethod · 0.65
is_nullMethod · 0.45
resizeMethod · 0.45
is_emptyMethod · 0.45
ptrwMethod · 0.45
duplicateMethod · 0.45

Tested by

no test coverage detected