summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_functions.cpp
diff options
context:
space:
mode:
authorAndrii Doroshenko (Xrayez) <xrayez@gmail.com>2019-10-04 00:01:12 +0300
committerAndrii Doroshenko (Xrayez) <xrayez@gmail.com>2020-04-30 18:30:04 +0300
commit7001d06f9d7e11e042147899acbdd01c13ad8983 (patch)
tree21854fa8d131dd66064afc35d6eef0038963ecd0 /modules/gdscript/gdscript_functions.cpp
parentf870118323f9f1e4cd7d3ea63e951a2214f63c48 (diff)
downloadredot-engine-7001d06f9d7e11e042147899acbdd01c13ad8983.tar.gz
Make `dict2inst` to work with arbitrary `_init` parameters
This is achieved by skipping initializer call while creating an instance of a GDScript. This is implemented by passing -1 as an argument count to `_new` and interpreting any value below 0 to mean that the initializer should not be called during instantiation, because internal members of an instance are going to be overridden afterwards.
Diffstat (limited to 'modules/gdscript/gdscript_functions.cpp')
-rw-r--r--modules/gdscript/gdscript_functions.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index 58161d6f53..0199af642f 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -1197,8 +1197,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
return;
}
}
-
- r_ret = gdscr->_new(nullptr, 0, r_error);
+ r_ret = gdscr->_new(nullptr, -1 /*skip initializer*/, r_error);
GDScriptInstance *ins = static_cast<GDScriptInstance *>(static_cast<Object *>(r_ret)->get_script_instance());
Ref<GDScript> gd_ref = ins->get_script();