summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-10-31 11:55:56 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-10-31 11:55:56 +0100
commitbe126d42d44bfc3ca4133ff6c3c12fcfe849f0c2 (patch)
treed7bcb97c48e7cef1a234ab13ad9eeb9e65afa50b /scene/main
parent33c7c8020a7c1b4103642ff5124b2b76ecdeea14 (diff)
parentd06a8320e5d5117f8a057da16d33443f410a5d9f (diff)
Merge pull request #67588 from KoBeWi/if(!GDVIRTUAL_CALL)don't
Simplify GDVIRTUAL_CALL calls
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/multiplayer_api.cpp52
1 files changed, 18 insertions, 34 deletions
diff --git a/scene/main/multiplayer_api.cpp b/scene/main/multiplayer_api.cpp
index 7e2c82c88d..946929aa89 100644
--- a/scene/main/multiplayer_api.cpp
+++ b/scene/main/multiplayer_api.cpp
@@ -329,11 +329,9 @@ void MultiplayerAPI::_bind_methods() {
/// MultiplayerAPIExtension
Error MultiplayerAPIExtension::poll() {
- int err;
- if (GDVIRTUAL_CALL(_poll, err)) {
- return (Error)err;
- }
- return OK;
+ int err = OK;
+ GDVIRTUAL_CALL(_poll, err);
+ return (Error)err;
}
void MultiplayerAPIExtension::set_multiplayer_peer(const Ref<MultiplayerPeer> &p_peer) {
@@ -342,26 +340,20 @@ void MultiplayerAPIExtension::set_multiplayer_peer(const Ref<MultiplayerPeer> &p
Ref<MultiplayerPeer> MultiplayerAPIExtension::get_multiplayer_peer() {
Ref<MultiplayerPeer> peer;
- if (GDVIRTUAL_CALL(_get_multiplayer_peer, peer)) {
- return peer;
- }
- return nullptr;
+ GDVIRTUAL_CALL(_get_multiplayer_peer, peer);
+ return peer;
}
int MultiplayerAPIExtension::get_unique_id() {
- int id;
- if (GDVIRTUAL_CALL(_get_unique_id, id)) {
- return id;
- }
- return 1;
+ int id = 1;
+ GDVIRTUAL_CALL(_get_unique_id, id);
+ return id;
}
Vector<int> MultiplayerAPIExtension::get_peer_ids() {
Vector<int> ids;
- if (GDVIRTUAL_CALL(_get_peer_ids, ids)) {
- return ids;
- }
- return Vector<int>();
+ GDVIRTUAL_CALL(_get_peer_ids, ids);
+ return ids;
}
Error MultiplayerAPIExtension::rpcp(Object *p_obj, int p_peer_id, const StringName &p_method, const Variant **p_arg, int p_argcount) {
@@ -373,34 +365,26 @@ Error MultiplayerAPIExtension::rpcp(Object *p_obj, int p_peer_id, const StringNa
args.push_back(*p_arg[i]);
}
int ret = FAILED;
- if (GDVIRTUAL_CALL(_rpc, p_peer_id, p_obj, p_method, args, ret)) {
- return (Error)ret;
- }
- return FAILED;
+ GDVIRTUAL_CALL(_rpc, p_peer_id, p_obj, p_method, args, ret);
+ return (Error)ret;
}
int MultiplayerAPIExtension::get_remote_sender_id() {
int id = 0;
- if (GDVIRTUAL_CALL(_get_remote_sender_id, id)) {
- return id;
- }
- return 0;
+ GDVIRTUAL_CALL(_get_remote_sender_id, id);
+ return id;
}
Error MultiplayerAPIExtension::object_configuration_add(Object *p_object, Variant p_config) {
int err = ERR_UNAVAILABLE;
- if (GDVIRTUAL_CALL(_object_configuration_add, p_object, p_config, err)) {
- return (Error)err;
- }
- return ERR_UNAVAILABLE;
+ GDVIRTUAL_CALL(_object_configuration_add, p_object, p_config, err);
+ return (Error)err;
}
Error MultiplayerAPIExtension::object_configuration_remove(Object *p_object, Variant p_config) {
int err = ERR_UNAVAILABLE;
- if (GDVIRTUAL_CALL(_object_configuration_remove, p_object, p_config, err)) {
- return (Error)err;
- }
- return ERR_UNAVAILABLE;
+ GDVIRTUAL_CALL(_object_configuration_remove, p_object, p_config, err);
+ return (Error)err;
}
void MultiplayerAPIExtension::_bind_methods() {