summaryrefslogtreecommitdiff
path: root/modules/enet
diff options
context:
space:
mode:
Diffstat (limited to 'modules/enet')
-rw-r--r--modules/enet/doc_classes/ENetMultiplayerPeer.xml9
-rw-r--r--modules/enet/enet_multiplayer_peer.cpp16
-rw-r--r--modules/enet/enet_multiplayer_peer.h2
3 files changed, 14 insertions, 13 deletions
diff --git a/modules/enet/doc_classes/ENetMultiplayerPeer.xml b/modules/enet/doc_classes/ENetMultiplayerPeer.xml
index 5b2c72dce4..30dec5987b 100644
--- a/modules/enet/doc_classes/ENetMultiplayerPeer.xml
+++ b/modules/enet/doc_classes/ENetMultiplayerPeer.xml
@@ -155,8 +155,9 @@
<member name="channel_count" type="int" setter="set_channel_count" getter="get_channel_count" default="3">
The number of channels to be used by ENet. Channels are used to separate different kinds of data. In reliable or ordered mode, for example, the packet delivery order is ensured on a per-channel basis. This is done to combat latency and reduces ordering restrictions on packets. The delivery status of a packet in one channel won't stall the delivery of other packets in another channel.
</member>
- <member name="compression_mode" type="int" setter="set_compression_mode" getter="get_compression_mode" enum="ENetMultiplayerPeer.CompressionMode" default="0">
+ <member name="compression_mode" type="int" setter="set_compression_mode" getter="get_compression_mode" enum="ENetMultiplayerPeer.CompressionMode" default="1">
The compression method used for network packets. These have different tradeoffs of compression speed versus bandwidth, you may need to test which one works best for your use case if you use compression at all.
+ [b]Note:[/b] Most games' network design involve sending many small packets frequently (smaller than 4 KB each). If in doubt, it is recommended to keep the default compression algorithm as it works best on these small packets.
</member>
<member name="dtls_verify" type="bool" setter="set_dtls_verify_enabled" getter="is_dtls_verify_enabled" default="true">
Enable or disable certificate verification when [member use_dtls] [code]true[/code].
@@ -176,10 +177,10 @@
</members>
<constants>
<constant name="COMPRESS_NONE" value="0" enum="CompressionMode">
- No compression. This uses the most bandwidth, but has the upside of requiring the fewest CPU resources.
+ No compression. This uses the most bandwidth, but has the upside of requiring the fewest CPU resources. This option may also be used to make network debugging using tools like Wireshark easier.
</constant>
<constant name="COMPRESS_RANGE_CODER" value="1" enum="CompressionMode">
- ENet's built-in range encoding.
+ ENet's built-in range encoding. Works well on small packets, but is not the most efficient algorithm on packets larger than 4 KB.
</constant>
<constant name="COMPRESS_FASTLZ" value="2" enum="CompressionMode">
[url=http://fastlz.org/]FastLZ[/url] compression. This option uses less CPU resources compared to [constant COMPRESS_ZLIB], at the expense of using more bandwidth.
@@ -188,7 +189,7 @@
[url=https://www.zlib.net/]Zlib[/url] compression. This option uses less bandwidth compared to [constant COMPRESS_FASTLZ], at the expense of using more CPU resources.
</constant>
<constant name="COMPRESS_ZSTD" value="4" enum="CompressionMode">
- [url=https://facebook.github.io/zstd/]Zstandard[/url] compression.
+ [url=https://facebook.github.io/zstd/]Zstandard[/url] compression. Note that this algorithm is not very efficient on packets smaller than 4 KB. Therefore, it's recommended to use other compression algorithms in most cases.
</constant>
</constants>
</class>
diff --git a/modules/enet/enet_multiplayer_peer.cpp b/modules/enet/enet_multiplayer_peer.cpp
index a9726426ad..b4ca93f4d9 100644
--- a/modules/enet/enet_multiplayer_peer.cpp
+++ b/modules/enet/enet_multiplayer_peer.cpp
@@ -249,7 +249,7 @@ void ENetMultiplayerPeer::poll() {
connection_status = CONNECTION_CONNECTED; // If connecting, this means it connected to something!
- emit_signal("peer_connected", *new_id);
+ emit_signal(SNAME("peer_connected"), *new_id);
if (server) {
// Do not notify other peers when server_relay is disabled.
@@ -274,7 +274,7 @@ void ENetMultiplayerPeer::poll() {
enet_peer_send(E->get(), SYSCH_CONFIG, packet);
}
} else {
- emit_signal("connection_succeeded");
+ emit_signal(SNAME("connection_succeeded"));
}
} break;
@@ -285,7 +285,7 @@ void ENetMultiplayerPeer::poll() {
if (!id) {
if (!server) {
- emit_signal("connection_failed");
+ emit_signal(SNAME("connection_failed"));
}
// Never fully connected.
break;
@@ -293,7 +293,7 @@ void ENetMultiplayerPeer::poll() {
if (!server) {
// Client just disconnected from server.
- emit_signal("server_disconnected");
+ emit_signal(SNAME("server_disconnected"));
close_connection();
return;
} else if (server_relay) {
@@ -310,7 +310,7 @@ void ENetMultiplayerPeer::poll() {
}
}
- emit_signal("peer_disconnected", *id);
+ emit_signal(SNAME("peer_disconnected"), *id);
peer_map.erase(*id);
memdelete(id);
} break;
@@ -328,12 +328,12 @@ void ENetMultiplayerPeer::poll() {
switch (msg) {
case SYSMSG_ADD_PEER: {
peer_map[id] = nullptr;
- emit_signal("peer_connected", id);
+ emit_signal(SNAME("peer_connected"), id);
} break;
case SYSMSG_REMOVE_PEER: {
peer_map.erase(id);
- emit_signal("peer_disconnected", id);
+ emit_signal(SNAME("peer_disconnected"), id);
} break;
}
@@ -491,7 +491,7 @@ void ENetMultiplayerPeer::disconnect_peer(int p_peer, bool now) {
memdelete(id);
}
- emit_signal("peer_disconnected", p_peer);
+ emit_signal(SNAME("peer_disconnected"), p_peer);
peer_map.erase(p_peer);
} else {
enet_peer_disconnect_later(peer_map[p_peer], 0);
diff --git a/modules/enet/enet_multiplayer_peer.h b/modules/enet/enet_multiplayer_peer.h
index e6d45eb16a..63f2ec5870 100644
--- a/modules/enet/enet_multiplayer_peer.h
+++ b/modules/enet/enet_multiplayer_peer.h
@@ -90,7 +90,7 @@ private:
int channel = 0;
};
- CompressionMode compression_mode = COMPRESS_NONE;
+ CompressionMode compression_mode = COMPRESS_RANGE_CODER;
List<Packet> incoming_packets;