Skip to content

Commit cd78220

Browse files
committed
Merge pull request #95216 from Chaosed0/enet-get-packet-flags
Add method for getting packet flags from ENetPacketPeer
2 parents 9ce149c + 21c5a73 commit cd78220

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

modules/enet/doc_classes/ENetPacketPeer.xml

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
Returns the number of channels allocated for communication with peer.
1919
</description>
2020
</method>
21+
<method name="get_packet_flags" qualifiers="const">
22+
<return type="int" />
23+
<description>
24+
Returns the ENet flags of the next packet in the received queue. See [code]FLAG_*[/code] constants for available packet flags. Note that not all flags are replicated from the sending peer to the receiving peer.
25+
</description>
26+
</method>
2127
<method name="get_remote_address" qualifiers="const">
2228
<return type="String" />
2329
<description>

modules/enet/enet_packet_peer.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ int ENetPacketPeer::get_channels() const {
175175
return peer->channelCount;
176176
}
177177

178+
int ENetPacketPeer::get_packet_flags() const {
179+
ERR_FAIL_COND_V(packet_queue.is_empty(), 0);
180+
return packet_queue.front()->get()->flags;
181+
}
182+
178183
void ENetPacketPeer::_on_disconnect() {
179184
if (peer) {
180185
peer->data = nullptr;
@@ -206,6 +211,7 @@ void ENetPacketPeer::_bind_methods() {
206211
ClassDB::bind_method(D_METHOD("send", "channel", "packet", "flags"), &ENetPacketPeer::_send);
207212
ClassDB::bind_method(D_METHOD("throttle_configure", "interval", "acceleration", "deceleration"), &ENetPacketPeer::throttle_configure);
208213
ClassDB::bind_method(D_METHOD("set_timeout", "timeout", "timeout_min", "timeout_max"), &ENetPacketPeer::set_timeout);
214+
ClassDB::bind_method(D_METHOD("get_packet_flags"), &ENetPacketPeer::get_packet_flags);
209215
ClassDB::bind_method(D_METHOD("get_remote_address"), &ENetPacketPeer::get_remote_address);
210216
ClassDB::bind_method(D_METHOD("get_remote_port"), &ENetPacketPeer::get_remote_port);
211217
ClassDB::bind_method(D_METHOD("get_statistic", "statistic"), &ENetPacketPeer::get_statistic);

modules/enet/enet_packet_peer.h

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class ENetPacketPeer : public PacketPeer {
113113
double get_statistic(PeerStatistic p_stat);
114114
PeerState get_state() const;
115115
int get_channels() const;
116+
int get_packet_flags() const;
116117

117118
// Extras
118119
IPAddress get_remote_address() const;

0 commit comments

Comments
 (0)