You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Add templated version of ObjectDB::get_instance()
This commit is contained in:
@@ -198,7 +198,7 @@ void MultiplayerDebugger::RPCProfiler::init_node(const ObjectID p_node) {
|
||||
}
|
||||
rpc_node_data.insert(p_node, RPCNodeInfo());
|
||||
rpc_node_data[p_node].node = p_node;
|
||||
rpc_node_data[p_node].node_path = Object::cast_to<Node>(ObjectDB::get_instance(p_node))->get_path();
|
||||
rpc_node_data[p_node].node_path = ObjectDB::get_instance<Node>(p_node)->get_path();
|
||||
}
|
||||
|
||||
void MultiplayerDebugger::RPCProfiler::toggle(bool p_enable, const Array &p_opts) {
|
||||
@@ -304,7 +304,7 @@ void MultiplayerDebugger::ReplicationProfiler::add(const Array &p_data) {
|
||||
const String what = p_data[0];
|
||||
const ObjectID id = p_data[1];
|
||||
const uint64_t size = p_data[2];
|
||||
MultiplayerSynchronizer *sync = Object::cast_to<MultiplayerSynchronizer>(ObjectDB::get_instance(id));
|
||||
MultiplayerSynchronizer *sync = ObjectDB::get_instance<MultiplayerSynchronizer>(id);
|
||||
ERR_FAIL_NULL(sync);
|
||||
if (!sync_data.has(id)) {
|
||||
sync_data[id] = SyncInfo(sync);
|
||||
|
||||
@@ -185,7 +185,7 @@ void MultiplayerSpawner::_update_spawn_node() {
|
||||
}
|
||||
#endif
|
||||
if (spawn_node.is_valid()) {
|
||||
Node *node = Object::cast_to<Node>(ObjectDB::get_instance(spawn_node));
|
||||
Node *node = ObjectDB::get_instance<Node>(spawn_node);
|
||||
if (node && node->is_connected("child_entered_tree", callable_mp(this, &MultiplayerSpawner::_node_added))) {
|
||||
node->disconnect("child_entered_tree", callable_mp(this, &MultiplayerSpawner::_node_added));
|
||||
}
|
||||
@@ -211,7 +211,7 @@ void MultiplayerSpawner::_notification(int p_what) {
|
||||
_update_spawn_node();
|
||||
|
||||
for (const KeyValue<ObjectID, SpawnInfo> &E : tracked_nodes) {
|
||||
Node *node = Object::cast_to<Node>(ObjectDB::get_instance(E.key));
|
||||
Node *node = ObjectDB::get_instance<Node>(E.key);
|
||||
ERR_CONTINUE(!node);
|
||||
node->disconnect(SceneStringName(tree_exiting), callable_mp(this, &MultiplayerSpawner::_node_exit));
|
||||
get_multiplayer()->object_configuration_remove(node, this);
|
||||
@@ -265,7 +265,7 @@ void MultiplayerSpawner::_spawn_notify(ObjectID p_id) {
|
||||
}
|
||||
|
||||
void MultiplayerSpawner::_node_exit(ObjectID p_id) {
|
||||
Node *node = Object::cast_to<Node>(ObjectDB::get_instance(p_id));
|
||||
Node *node = ObjectDB::get_instance<Node>(p_id);
|
||||
ERR_FAIL_NULL(node);
|
||||
if (tracked_nodes.has(p_id)) {
|
||||
tracked_nodes.erase(p_id);
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
PackedStringArray get_configuration_warnings() const override;
|
||||
|
||||
Node *get_spawn_node() const {
|
||||
return spawn_node.is_valid() ? Object::cast_to<Node>(ObjectDB::get_instance(spawn_node)) : nullptr;
|
||||
return spawn_node.is_valid() ? ObjectDB::get_instance<Node>(spawn_node) : nullptr;
|
||||
}
|
||||
|
||||
void add_spawnable_scene(const String &p_path);
|
||||
|
||||
@@ -100,7 +100,7 @@ void MultiplayerSynchronizer::_update_process() {
|
||||
}
|
||||
|
||||
Node *MultiplayerSynchronizer::get_root_node() {
|
||||
return root_node_cache.is_valid() ? Object::cast_to<Node>(ObjectDB::get_instance(root_node_cache)) : nullptr;
|
||||
return root_node_cache.is_valid() ? ObjectDB::get_instance<Node>(root_node_cache) : nullptr;
|
||||
}
|
||||
|
||||
void MultiplayerSynchronizer::reset() {
|
||||
|
||||
@@ -154,7 +154,7 @@ void SceneCacheInterface::process_confirm_path(int p_from, const uint8_t *p_pack
|
||||
}
|
||||
|
||||
if (valid_rpc_checksum == false) {
|
||||
const Node *node = Object::cast_to<Node>(ObjectDB::get_instance(*oid));
|
||||
const Node *node = ObjectDB::get_instance<Node>(*oid);
|
||||
ERR_FAIL_NULL(node); // Bug.
|
||||
ERR_PRINT("The rpc node checksum failed. Make sure to have the same methods on both nodes. Node path: " + node->get_path());
|
||||
}
|
||||
@@ -280,7 +280,7 @@ Object *SceneCacheInterface::get_cached_object(int p_from, uint32_t p_cache_id)
|
||||
|
||||
RecvNode *recv_node = pinfo->recv_nodes.getptr(p_cache_id);
|
||||
ERR_FAIL_NULL_V_MSG(recv_node, nullptr, vformat("ID %d not found in cache of peer %d.", p_cache_id, p_from));
|
||||
Node *node = Object::cast_to<Node>(ObjectDB::get_instance(recv_node->oid));
|
||||
Node *node = ObjectDB::get_instance<Node>(recv_node->oid);
|
||||
if (!node) {
|
||||
// Fallback to path lookup.
|
||||
Node *root_node = SceneTree::get_singleton()->get_root()->get_node(multiplayer->get_root_path());
|
||||
|
||||
@@ -113,7 +113,7 @@ private:
|
||||
|
||||
template <typename T>
|
||||
static T *get_id_as(const ObjectID &p_id) {
|
||||
return p_id.is_valid() ? Object::cast_to<T>(ObjectDB::get_instance(p_id)) : nullptr;
|
||||
return p_id.is_valid() ? ObjectDB::get_instance<T>(p_id) : nullptr;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
||||
Reference in New Issue
Block a user