From 2a753972f5c3afb880ac91014471d4fe09e2469e Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 29 Oct 2019 00:24:37 +0100 Subject: [PATCH] Fix compile for android. --- entities/entity.cpp | 14 +++++++------- entities/entity.h | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/entities/entity.cpp b/entities/entity.cpp index 302300f..4f54bbf 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -1007,7 +1007,7 @@ void Entity::sdie() { son_death(); //send an event to client - VRPC(cdie); + VRPCN(cdie); //signal emit_signal("sdied", this); @@ -2842,13 +2842,13 @@ void Entity::sfail_cast() { _s_spell_cast_info.unref(); - VRPC(cfail_cast); + VRPCN(cfail_cast); } void Entity::sdelay_cast() { emit_signal("scast_delayed", _s_spell_cast_info); - VRPC(cdelay_cast); + VRPCN(cdelay_cast); } void Entity::sfinish_cast() { @@ -2860,7 +2860,7 @@ void Entity::sfinish_cast() { _s_spell_cast_info.unref(); - VRPC(cfinish_cast); + VRPCN(cfinish_cast); } void Entity::sinterrupt_cast() { @@ -2874,7 +2874,7 @@ void Entity::sinterrupt_cast() { _s_spell_cast_info.unref(); - VRPC(cinterrupt_cast); + VRPCN(cinterrupt_cast); } void Entity::cstart_casting_rpc(String data) { @@ -3762,7 +3762,7 @@ void Entity::sreset_talents() { emit_signal("stalent_reset", this); - ORPC(creset_talents); + ORPCN(creset_talents); } void Entity::creset_talents() { _c_talents.clear(); @@ -3827,7 +3827,7 @@ int Entity::gets_talent_count() { void Entity::sclear_talents() { _s_talents.clear(); - ORPC(cclear_talents); + ORPCN(cclear_talents); } void Entity::addc_talent(int talent) { diff --git a/entities/entity.h b/entities/entity.h index b6c54ea..8a23a60 100644 --- a/entities/entity.h +++ b/entities/entity.h @@ -80,6 +80,38 @@ enum PlayerSendFlags { #define SET_RPC_MASTERSYNC(p_method_name) rpc_config(p_method_name, MultiplayerAPI::RPC_MODE_MASTERSYNC); #define SET_RPC_PUPPETSYNC(p_method_name) rpc_config(p_method_name, MultiplayerAPI::RPC_MODE_PUPPETSYNC); +//Normal +#define RPCN(func) \ + if (is_inside_tree() && get_tree()->has_network_peer()) { \ + rpc(#func); \ + } \ + func(); + +#define VRPCN(func) \ + if (is_inside_tree() && get_tree()->has_network_peer()) { \ + vrpc(#func); \ + } \ + func(); + +#define ORPCN(func) \ + if (is_inside_tree() && get_tree()->has_network_peer()) { \ + if (get_tree()->is_network_server() && get_network_master() != 1) \ + rpc_id(get_network_master(), #func); \ + } \ + func(); + +#define RPCSN(func) \ + if (is_inside_tree() && get_tree()->has_network_peer()) { \ + if (get_tree()->is_network_server()) { \ + func(); \ + } else { \ + rpc_id(1, #func); \ + } \ + } else { \ + func(); \ + } + +//Variadic // f.e. RPC(method, arg0, arg1, etc) #define RPC(func, ...) \ if (is_inside_tree() && get_tree()->has_network_peer()) { \ @@ -477,7 +509,7 @@ public: void sremove_aura_expired(Ref aura); void sremove_aura_dispelled(Ref aura); void saura_refreshed(Ref aura); - + void cadd_aura_rpc(String data); void cremove_aura_rpc(String data); void cremove_aura_exact_rpc(String data);