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.
This commit is contained in:
Andrii Doroshenko (Xrayez) 2019-10-04 00:01:12 +03:00 committed by Hugo Locurcio
parent 0f10eafb38
commit accdd575f6
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
2 changed files with 5 additions and 4 deletions

View file

@ -1153,8 +1153,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);
if (r_error.error != Variant::CallError::CALL_OK) {
r_ret = Variant();