summaryrefslogtreecommitdiff
path: root/modules/enet
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-09-03 19:40:47 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-09-07 11:14:30 +0200
commitbf9aae09ba5eccde7ec355dac96b6a2088fb1a3f (patch)
tree4012cb4aa0f6d9bb548cf15c165dd11d77e09a16 /modules/enet
parentb0b30aaf41191ccbfdc8786cb79a76efb16d1459 (diff)
[Net] Move multiplayer to core subdir, split RPCManager.
Move multiplayer classes to "core/multiplayer" subdir. Move the RPCConfig and enums (TransferMode, RPCMode) to a separate file (multiplayer.h), and bind them to the global namespace. Move the RPC handling code to its own class (RPCManager). Renames "get_rpc_sender_id" to "get_remote_sender_id".
Diffstat (limited to 'modules/enet')
-rw-r--r--modules/enet/doc_classes/ENetMultiplayerPeer.xml2
-rw-r--r--modules/enet/enet_multiplayer_peer.cpp10
-rw-r--r--modules/enet/enet_multiplayer_peer.h8
3 files changed, 10 insertions, 10 deletions
diff --git a/modules/enet/doc_classes/ENetMultiplayerPeer.xml b/modules/enet/doc_classes/ENetMultiplayerPeer.xml
index 3a37b396a4..79dc77d41d 100644
--- a/modules/enet/doc_classes/ENetMultiplayerPeer.xml
+++ b/modules/enet/doc_classes/ENetMultiplayerPeer.xml
@@ -81,7 +81,7 @@
<member name="server_relay" type="bool" setter="set_server_relay_enabled" getter="is_server_relay_enabled" default="true">
Enable or disable the server feature that notifies clients of other peers' connection/disconnection, and relays messages between them. When this option is [code]false[/code], clients won't be automatically notified of other peers and won't be able to send them packets through the server.
</member>
- <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="MultiplayerPeer.TransferMode" default="2" />
+ <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="TransferMode" default="2" />
</members>
<constants>
</constants>
diff --git a/modules/enet/enet_multiplayer_peer.cpp b/modules/enet/enet_multiplayer_peer.cpp
index 7a9a780238..afd31207f6 100644
--- a/modules/enet/enet_multiplayer_peer.cpp
+++ b/modules/enet/enet_multiplayer_peer.cpp
@@ -41,11 +41,11 @@ int ENetMultiplayerPeer::get_transfer_channel() const {
return transfer_channel;
}
-void ENetMultiplayerPeer::set_transfer_mode(TransferMode p_mode) {
+void ENetMultiplayerPeer::set_transfer_mode(Multiplayer::TransferMode p_mode) {
transfer_mode = p_mode;
}
-MultiplayerPeer::TransferMode ENetMultiplayerPeer::get_transfer_mode() const {
+Multiplayer::TransferMode ENetMultiplayerPeer::get_transfer_mode() const {
return transfer_mode;
}
@@ -455,15 +455,15 @@ Error ENetMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size
channel = SYSCH_MAX + transfer_channel - 1;
} else {
switch (transfer_mode) {
- case TRANSFER_MODE_UNRELIABLE: {
+ case Multiplayer::TRANSFER_MODE_UNRELIABLE: {
packet_flags = ENET_PACKET_FLAG_UNSEQUENCED;
channel = SYSCH_UNRELIABLE;
} break;
- case TRANSFER_MODE_UNRELIABLE_ORDERED: {
+ case Multiplayer::TRANSFER_MODE_ORDERED: {
packet_flags = 0;
channel = SYSCH_UNRELIABLE;
} break;
- case TRANSFER_MODE_RELIABLE: {
+ case Multiplayer::TRANSFER_MODE_RELIABLE: {
packet_flags = ENET_PACKET_FLAG_RELIABLE;
channel = SYSCH_RELIABLE;
} break;
diff --git a/modules/enet/enet_multiplayer_peer.h b/modules/enet/enet_multiplayer_peer.h
index 78e280db7c..b5316b8292 100644
--- a/modules/enet/enet_multiplayer_peer.h
+++ b/modules/enet/enet_multiplayer_peer.h
@@ -32,7 +32,7 @@
#define NETWORKED_MULTIPLAYER_ENET_H
#include "core/crypto/crypto.h"
-#include "core/io/multiplayer_peer.h"
+#include "core/multiplayer/multiplayer_peer.h"
#include "enet_connection.h"
#include <enet/enet.h>
@@ -66,7 +66,7 @@ private:
int target_peer = 0;
int transfer_channel = 0;
- TransferMode transfer_mode = TRANSFER_MODE_RELIABLE;
+ Multiplayer::TransferMode transfer_mode = Multiplayer::TRANSFER_MODE_RELIABLE;
bool refuse_connections = false;
bool server_relay = true;
@@ -104,8 +104,8 @@ public:
virtual void set_transfer_channel(int p_channel) override;
virtual int get_transfer_channel() const override;
- virtual void set_transfer_mode(TransferMode p_mode) override;
- virtual TransferMode get_transfer_mode() const override;
+ virtual void set_transfer_mode(Multiplayer::TransferMode p_mode) override;
+ virtual Multiplayer::TransferMode get_transfer_mode() const override;
virtual void set_target_peer(int p_peer) override;
virtual int get_packet_peer() const override;