Skip to content

Commit

Permalink
Merge pull request #24951 from Mr-Slurpy/local-rpc-sender-id-fix
Browse files Browse the repository at this point in the history
Sender network id is now set to local network id for local rpc calls.
  • Loading branch information
Faless authored Apr 20, 2019
2 parents 725e8b7 + 0606062 commit 175942d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/io/multiplayer_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,11 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const
}

if (call_local_native) {
int temp_id = rpc_sender_id;
rpc_sender_id = get_network_unique_id();
Variant::CallError ce;
p_node->call(p_method, p_arg, p_argcount, ce);
rpc_sender_id = temp_id;
if (ce.error != Variant::CallError::CALL_OK) {
String error = Variant::get_call_error_text(p_node, p_method, p_arg, p_argcount, ce);
error = "rpc() aborted in local call: - " + error;
Expand All @@ -670,9 +673,12 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const
}

if (call_local_script) {
int temp_id = rpc_sender_id;
rpc_sender_id = get_network_unique_id();
Variant::CallError ce;
ce.error = Variant::CallError::CALL_OK;
p_node->get_script_instance()->call(p_method, p_arg, p_argcount, ce);
rpc_sender_id = temp_id;
if (ce.error != Variant::CallError::CALL_OK) {
String error = Variant::get_call_error_text(p_node, p_method, p_arg, p_argcount, ce);
error = "rpc() aborted in script local call: - " + error;
Expand Down Expand Up @@ -708,7 +714,11 @@ void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const

if (set_local) {
bool valid;
int temp_id = rpc_sender_id;

rpc_sender_id = get_network_unique_id();
p_node->set(p_property, p_value, &valid);
rpc_sender_id = temp_id;

if (!valid) {
String error = "rset() aborted in local set, property not found: - " + String(p_property);
Expand All @@ -722,8 +732,11 @@ void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const
set_local = _should_call_local(rpc_mode, is_master, skip_rset);

if (set_local) {
int temp_id = rpc_sender_id;

rpc_sender_id = get_network_unique_id();
bool valid = p_node->get_script_instance()->set(p_property, p_value);
rpc_sender_id = temp_id;

if (!valid) {
String error = "rset() aborted in local script set, property not found: - " + String(p_property);
Expand Down

0 comments on commit 175942d

Please sign in to comment.