diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-05-02 17:31:32 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-05-02 17:31:32 +0200 |
commit | a7029e4c8a0714400deb40ec6d57b31c2025d22e (patch) | |
tree | ad6ea405eb88d80fcba45e43c02f06d7eab065d2 /modules/gdscript/gdscript.cpp | |
parent | 7a968c619d478f06d1ab94de8b0f1afffb985d28 (diff) | |
parent | 99b702ea3d12952b842055a4d5d4b1928ed69186 (diff) | |
download | redot-engine-a7029e4c8a0714400deb40ec6d57b31c2025d22e.tar.gz |
Merge pull request #91364 from vnen/gdscript-implicit-ready-base-first
GDScript: Call implicit ready on base script first
Diffstat (limited to 'modules/gdscript/gdscript.cpp')
-rw-r--r-- | modules/gdscript/gdscript.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index f238958f25..73abf71bde 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -1958,19 +1958,22 @@ int GDScriptInstance::get_method_argument_count(const StringName &p_method, bool return 0; } +void GDScriptInstance::_call_implicit_ready_recursively(GDScript *p_script) { + // Call base class first. + if (p_script->_base) { + _call_implicit_ready_recursively(p_script->_base); + } + if (p_script->implicit_ready) { + Callable::CallError err; + p_script->implicit_ready->call(this, nullptr, 0, err); + } +} + Variant GDScriptInstance::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { GDScript *sptr = script.ptr(); if (unlikely(p_method == SNAME("_ready"))) { - // Call implicit ready first, including for the super classes. - while (sptr) { - if (sptr->implicit_ready) { - sptr->implicit_ready->call(this, nullptr, 0, r_error); - } - sptr = sptr->_base; - } - - // Reset this back for the regular call. - sptr = script.ptr(); + // Call implicit ready first, including for the super classes recursively. + _call_implicit_ready_recursively(sptr); } while (sptr) { HashMap<StringName, GDScriptFunction *>::Iterator E = sptr->member_functions.find(p_method); |