Skip to content

Commit

Permalink
Revert "Properly explain RPC/RSET mode failure."
Browse files Browse the repository at this point in the history
This reverts commit 95ad747.
It introduced regressions, see #27655.
  • Loading branch information
akien-mga committed Apr 5, 2019
1 parent afe45f9 commit cc34933
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions core/io/multiplayer_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ _FORCE_INLINE_ bool _should_call_local(MultiplayerAPI::RPCMode mode, bool is_mas
return false;
}

_FORCE_INLINE_ bool _can_call_mode(MultiplayerAPI::RPCMode mode, int p_node_master, int p_remote_id) {
_FORCE_INLINE_ bool _can_call_mode(Node *p_node, MultiplayerAPI::RPCMode mode, int p_remote_id) {
switch (mode) {

case MultiplayerAPI::RPC_MODE_DISABLED: {
Expand All @@ -77,11 +77,11 @@ _FORCE_INLINE_ bool _can_call_mode(MultiplayerAPI::RPCMode mode, int p_node_mast
} break;
case MultiplayerAPI::RPC_MODE_MASTERSYNC:
case MultiplayerAPI::RPC_MODE_MASTER: {
return p_node_master == NetworkedMultiplayerPeer::TARGET_PEER_SERVER;
return p_node->is_network_master();
} break;
case MultiplayerAPI::RPC_MODE_PUPPETSYNC:
case MultiplayerAPI::RPC_MODE_PUPPET: {
return p_node_master != NetworkedMultiplayerPeer::TARGET_PEER_SERVER && p_remote_id == p_node_master;
return !p_node->is_network_master() && p_remote_id == p_node->get_network_master();
} break;
}

Expand Down Expand Up @@ -283,9 +283,8 @@ void MultiplayerAPI::_process_rpc(Node *p_node, const StringName &p_name, int p_
rpc_mode = p_node->get_script_instance()->get_rpc_mode(p_name);
}

int node_master_id = p_node->get_network_master();
ERR_EXPLAIN("RPC '" + String(p_name) + "' is not allowed on node " + p_node->get_path() + " from: " + itos(p_from) + ". Mode is " + itos((int)rpc_mode) + ", master is " + itos(node_master_id) + ".");
ERR_FAIL_COND(!_can_call_mode(rpc_mode, p_from, node_master_id));
ERR_EXPLAIN("RPC '" + String(p_name) + "' is not allowed from: " + itos(p_from) + ". Mode is " + itos((int)rpc_mode) + ", master is " + itos(p_node->get_network_master()) + ".");
ERR_FAIL_COND(!_can_call_mode(p_node, rpc_mode, p_from));

int argc = p_packet[p_offset];
Vector<Variant> args;
Expand Down Expand Up @@ -333,9 +332,8 @@ void MultiplayerAPI::_process_rset(Node *p_node, const StringName &p_name, int p
rset_mode = p_node->get_script_instance()->get_rset_mode(p_name);
}

int node_master_id = p_node->get_network_master();
ERR_EXPLAIN("RSET '" + String(p_name) + "' is not allowed on node " + p_node->get_path() + " from: " + itos(p_from) + ". Mode is " + itos((int)rset_mode) + ", master is " + itos(node_master_id) + ".");
ERR_FAIL_COND(!_can_call_mode(rset_mode, p_from, node_master_id));
ERR_EXPLAIN("RSET '" + String(p_name) + "' is not allowed from: " + itos(p_from) + ". Mode is " + itos((int)rset_mode) + ", master is " + itos(p_node->get_network_master()) + ".");
ERR_FAIL_COND(!_can_call_mode(p_node, rset_mode, p_from));

Variant value;
Error err = decode_variant(value, &p_packet[p_offset], p_packet_len - p_offset, NULL, allow_object_decoding || network_peer->is_object_decoding_allowed());
Expand Down

0 comments on commit cc34933

Please sign in to comment.