diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-12-12 13:51:48 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-12-12 13:51:48 +0100 |
commit | ec8f52df8f2b5fb55ca5c9d37ab77927ea53477f (patch) | |
tree | e342a562b7a20852a4ea55dbf5e3b88979b3cc42 /modules/navigation | |
parent | 92dfa7901b61e43e275e50e4c5f2f91f6d250356 (diff) | |
parent | 194c1c44e0a20faa4463e3a41bb12cf93a71fc03 (diff) |
Merge pull request #69629 from smix8/agent_wild_callback_pointer_4.x
Fix Navigation agent callback wild pointer crash
Diffstat (limited to 'modules/navigation')
-rw-r--r-- | modules/navigation/godot_navigation_server.cpp | 6 | ||||
-rw-r--r-- | modules/navigation/godot_navigation_server.h | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/modules/navigation/godot_navigation_server.cpp b/modules/navigation/godot_navigation_server.cpp index 0e40e5a4af..e5949c935b 100644 --- a/modules/navigation/godot_navigation_server.cpp +++ b/modules/navigation/godot_navigation_server.cpp @@ -704,14 +704,14 @@ bool GodotNavigationServer::agent_is_map_changed(RID p_agent) const { return agent->is_map_changed(); } -COMMAND_4(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_method, Variant, p_udata) { +COMMAND_4(agent_set_callback, RID, p_agent, ObjectID, p_object_id, StringName, p_method, Variant, p_udata) { RvoAgent *agent = agent_owner.get_or_null(p_agent); ERR_FAIL_COND(agent == nullptr); - agent->set_callback(p_receiver == nullptr ? ObjectID() : p_receiver->get_instance_id(), p_method, p_udata); + agent->set_callback(p_object_id, p_method, p_udata); if (agent->get_map()) { - if (p_receiver == nullptr) { + if (p_object_id == ObjectID()) { agent->get_map()->remove_agent_as_controlled(agent); } else { agent->get_map()->set_agent_as_controlled(agent); diff --git a/modules/navigation/godot_navigation_server.h b/modules/navigation/godot_navigation_server.h index 08ad545b37..18431e39b8 100644 --- a/modules/navigation/godot_navigation_server.h +++ b/modules/navigation/godot_navigation_server.h @@ -172,7 +172,7 @@ public: COMMAND_2(agent_set_position, RID, p_agent, Vector3, p_position); COMMAND_2(agent_set_ignore_y, RID, p_agent, bool, p_ignore); virtual bool agent_is_map_changed(RID p_agent) const override; - COMMAND_4_DEF(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_method, Variant, p_udata, Variant()); + COMMAND_4_DEF(agent_set_callback, RID, p_agent, ObjectID, p_object_id, StringName, p_method, Variant, p_udata, Variant()); COMMAND_1(free, RID, p_object); |