Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rpc call from name based Callables #87858

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions core/variant/callable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,31 @@ Error Callable::rpcp(int p_id, const Variant **p_arguments, int p_argcount, Call
r_call_error.expected = 0;
return ERR_UNCONFIGURED;
} else if (!is_custom()) {
r_call_error.error = CallError::CALL_ERROR_INVALID_METHOD;
r_call_error.argument = 0;
r_call_error.expected = 0;
return ERR_UNCONFIGURED;
Object *obj = ObjectDB::get_instance(ObjectID(object));
#ifdef DEBUG_ENABLED
AThousandShips marked this conversation as resolved.
Show resolved Hide resolved
if (!obj || !obj->is_class("Node")) {
r_call_error.error = CallError::CALL_ERROR_INSTANCE_IS_NULL;
r_call_error.argument = 0;
r_call_error.expected = 0;
return ERR_UNCONFIGURED;
}
#endif

int argcount = p_argcount + 2;
const Variant **argptrs = (const Variant **)alloca(sizeof(Variant *) * argcount);
const Variant args[2] = { p_id, method };

argptrs[0] = &args[0];
argptrs[1] = &args[1];
for (int i = 0; i < p_argcount; ++i) {
argptrs[i + 2] = p_arguments[i];
}

CallError tmp;
Error err = (Error)obj->callp(SNAME("rpc_id"), argptrs, argcount, tmp).operator int64_t();

r_call_error.error = Callable::CallError::CALL_OK;
return err;
} else {
return custom->rpc(p_id, p_arguments, p_argcount, r_call_error);
}
Expand Down
Loading