diff options
author | Lee Salzman <[email protected]> | 2024-07-24 01:45:54 -0400 |
---|---|---|
committer | Lee Salzman <[email protected]> | 2024-07-24 01:45:54 -0400 |
commit | a52811ef275e25d4df29dbee68fee410249d571e (patch) | |
tree | 5ab5440535120cfd730f536001c68dc8d768314e /peer.c | |
parent | 0b924c79ceb7b3c46d82dd00f6f1ed3f664d02d0 (diff) | |
download | enet-a52811ef275e25d4df29dbee68fee410249d571e.tar.gz enet-a52811ef275e25d4df29dbee68fee410249d571e.zip |
update totalWaitingData when removing an incoming command
Diffstat (limited to 'peer.c')
-rw-r--r-- | peer.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -255,7 +255,7 @@ enet_peer_receive (ENetPeer * peer, enet_uint8 * channelID) } static void -enet_peer_reset_outgoing_commands (ENetList * queue) +enet_peer_reset_outgoing_commands (ENetPeer * peer, ENetList * queue) { ENetOutgoingCommand * outgoingCommand; @@ -276,7 +276,7 @@ enet_peer_reset_outgoing_commands (ENetList * queue) } static void -enet_peer_remove_incoming_commands (ENetList * queue, ENetListIterator startCommand, ENetListIterator endCommand, ENetIncomingCommand * excludeCommand) +enet_peer_remove_incoming_commands (ENetPeer * peer, ENetList * queue, ENetListIterator startCommand, ENetListIterator endCommand, ENetIncomingCommand * excludeCommand) { ENetListIterator currentCommand; @@ -295,6 +295,8 @@ enet_peer_remove_incoming_commands (ENetList * queue, ENetListIterator startComm { -- incomingCommand -> packet -> referenceCount; + peer -> totalWaitingData -= incomingCommand -> packet -> dataLength; + if (incomingCommand -> packet -> referenceCount == 0) enet_packet_destroy (incomingCommand -> packet); } @@ -307,9 +309,9 @@ enet_peer_remove_incoming_commands (ENetList * queue, ENetListIterator startComm } static void -enet_peer_reset_incoming_commands (ENetList * queue) +enet_peer_reset_incoming_commands (ENetPeer * peer, ENetList * queue) { - enet_peer_remove_incoming_commands(queue, enet_list_begin (queue), enet_list_end (queue), NULL); + enet_peer_remove_incoming_commands(peer, queue, enet_list_begin (queue), enet_list_end (queue), NULL); } void @@ -327,10 +329,10 @@ enet_peer_reset_queues (ENetPeer * peer) while (! enet_list_empty (& peer -> acknowledgements)) enet_free (enet_list_remove (enet_list_begin (& peer -> acknowledgements))); - enet_peer_reset_outgoing_commands (& peer -> sentReliableCommands); - enet_peer_reset_outgoing_commands (& peer -> outgoingCommands); - enet_peer_reset_outgoing_commands (& peer -> outgoingSendReliableCommands); - enet_peer_reset_incoming_commands (& peer -> dispatchedCommands); + enet_peer_reset_outgoing_commands (peer, & peer -> sentReliableCommands); + enet_peer_reset_outgoing_commands (peer, & peer -> outgoingCommands); + enet_peer_reset_outgoing_commands (peer, & peer -> outgoingSendReliableCommands); + enet_peer_reset_incoming_commands (peer, & peer -> dispatchedCommands); if (peer -> channels != NULL && peer -> channelCount > 0) { @@ -338,8 +340,8 @@ enet_peer_reset_queues (ENetPeer * peer) channel < & peer -> channels [peer -> channelCount]; ++ channel) { - enet_peer_reset_incoming_commands (& channel -> incomingReliableCommands); - enet_peer_reset_incoming_commands (& channel -> incomingUnreliableCommands); + enet_peer_reset_incoming_commands (peer, & channel -> incomingReliableCommands); + enet_peer_reset_incoming_commands (peer, & channel -> incomingUnreliableCommands); } enet_free (peer -> channels); @@ -801,7 +803,7 @@ enet_peer_dispatch_incoming_unreliable_commands (ENetPeer * peer, ENetChannel * droppedCommand = currentCommand; } - enet_peer_remove_incoming_commands (& channel -> incomingUnreliableCommands, enet_list_begin (& channel -> incomingUnreliableCommands), droppedCommand, queuedCommand); + enet_peer_remove_incoming_commands (peer, & channel -> incomingUnreliableCommands, enet_list_begin (& channel -> incomingUnreliableCommands), droppedCommand, queuedCommand); } void |