remove unnecessary sent unreliable list from peers
This commit is contained in:
@@ -124,7 +124,6 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
|
||||
|
||||
enet_list_clear (& currentPeer -> acknowledgements);
|
||||
enet_list_clear (& currentPeer -> sentReliableCommands);
|
||||
enet_list_clear (& currentPeer -> sentUnreliableCommands);
|
||||
enet_list_clear (& currentPeer -> outgoingCommands);
|
||||
enet_list_clear (& currentPeer -> outgoingSendReliableCommands);
|
||||
enet_list_clear (& currentPeer -> dispatchedCommands);
|
||||
|
||||
+1
-2
@@ -315,9 +315,8 @@ typedef struct _ENetPeer
|
||||
enet_uint16 outgoingReliableSequenceNumber;
|
||||
ENetList acknowledgements;
|
||||
ENetList sentReliableCommands;
|
||||
ENetList sentUnreliableCommands;
|
||||
ENetList outgoingCommands;
|
||||
ENetList outgoingSendReliableCommands;
|
||||
ENetList outgoingCommands;
|
||||
ENetList dispatchedCommands;
|
||||
enet_uint16 flags;
|
||||
enet_uint16 reserved;
|
||||
|
||||
@@ -328,7 +328,6 @@ enet_peer_reset_queues (ENetPeer * peer)
|
||||
enet_free (enet_list_remove (enet_list_begin (& peer -> acknowledgements)));
|
||||
|
||||
enet_peer_reset_outgoing_commands (& peer -> sentReliableCommands);
|
||||
enet_peer_reset_outgoing_commands (& peer -> sentUnreliableCommands);
|
||||
enet_peer_reset_outgoing_commands (& peer -> outgoingCommands);
|
||||
enet_peer_reset_outgoing_commands (& peer -> outgoingSendReliableCommands);
|
||||
enet_peer_reset_incoming_commands (& peer -> dispatchedCommands);
|
||||
|
||||
+15
-12
@@ -159,16 +159,16 @@ enet_protocol_notify_disconnect (ENetHost * host, ENetPeer * peer, ENetEvent * e
|
||||
}
|
||||
|
||||
static void
|
||||
enet_protocol_remove_sent_unreliable_commands (ENetPeer * peer)
|
||||
enet_protocol_remove_sent_unreliable_commands (ENetPeer * peer, ENetList * sentUnreliableCommands)
|
||||
{
|
||||
ENetOutgoingCommand * outgoingCommand;
|
||||
|
||||
if (enet_list_empty (& peer -> sentUnreliableCommands))
|
||||
if (enet_list_empty (sentUnreliableCommands))
|
||||
return;
|
||||
|
||||
do
|
||||
{
|
||||
outgoingCommand = (ENetOutgoingCommand *) enet_list_front (& peer -> sentUnreliableCommands);
|
||||
outgoingCommand = (ENetOutgoingCommand *) enet_list_front (sentUnreliableCommands);
|
||||
|
||||
enet_list_remove (& outgoingCommand -> outgoingCommandList);
|
||||
|
||||
@@ -185,7 +185,7 @@ enet_protocol_remove_sent_unreliable_commands (ENetPeer * peer)
|
||||
}
|
||||
|
||||
enet_free (outgoingCommand);
|
||||
} while (! enet_list_empty (& peer -> sentUnreliableCommands));
|
||||
} while (! enet_list_empty (sentUnreliableCommands));
|
||||
|
||||
if (peer -> state == ENET_PEER_STATE_DISCONNECT_LATER &&
|
||||
! enet_peer_has_outgoing_commands (peer))
|
||||
@@ -1399,7 +1399,7 @@ enet_protocol_check_timeouts (ENetHost * host, ENetPeer * peer, ENetEvent * even
|
||||
}
|
||||
|
||||
static int
|
||||
enet_protocol_check_outgoing_commands (ENetHost * host, ENetPeer * peer)
|
||||
enet_protocol_check_outgoing_commands (ENetHost * host, ENetPeer * peer, ENetList * sentUnreliableCommands)
|
||||
{
|
||||
ENetProtocol * command = & host -> commands [host -> commandCount];
|
||||
ENetBuffer * buffer = & host -> buffers [host -> bufferCount];
|
||||
@@ -1551,7 +1551,7 @@ enet_protocol_check_outgoing_commands (ENetHost * host, ENetPeer * peer)
|
||||
enet_list_remove (& outgoingCommand -> outgoingCommandList);
|
||||
|
||||
if (outgoingCommand -> packet != NULL)
|
||||
enet_list_insert (enet_list_end (& peer -> sentUnreliableCommands), outgoingCommand);
|
||||
enet_list_insert (enet_list_end (sentUnreliableCommands), outgoingCommand);
|
||||
}
|
||||
|
||||
buffer -> data = command;
|
||||
@@ -1585,7 +1585,7 @@ enet_protocol_check_outgoing_commands (ENetHost * host, ENetPeer * peer)
|
||||
|
||||
if (peer -> state == ENET_PEER_STATE_DISCONNECT_LATER &&
|
||||
! enet_peer_has_outgoing_commands (peer) &&
|
||||
enet_list_empty (& peer -> sentUnreliableCommands))
|
||||
enet_list_empty (sentUnreliableCommands))
|
||||
enet_peer_disconnect (peer, peer -> eventData);
|
||||
|
||||
return canPing;
|
||||
@@ -1596,10 +1596,13 @@ enet_protocol_send_outgoing_commands (ENetHost * host, ENetEvent * event, int ch
|
||||
{
|
||||
enet_uint8 headerData [sizeof (ENetProtocolHeader) + sizeof (enet_uint32)];
|
||||
ENetProtocolHeader * header = (ENetProtocolHeader *) headerData;
|
||||
int continueSending = 0, sentLength = 0;
|
||||
int sentLength = 0;
|
||||
size_t shouldCompress = 0;
|
||||
ENetList sentUnreliableCommands;
|
||||
|
||||
for (int sendPass = 0; sendPass <= continueSending; ++ sendPass)
|
||||
enet_list_clear (& sentUnreliableCommands);
|
||||
|
||||
for (int sendPass = 0, continueSending = 0; sendPass <= continueSending; ++ sendPass)
|
||||
for (ENetPeer * currentPeer = host -> peers;
|
||||
currentPeer < & host -> peers [host -> peerCount];
|
||||
++ currentPeer)
|
||||
@@ -1632,13 +1635,13 @@ enet_protocol_send_outgoing_commands (ENetHost * host, ENetEvent * event, int ch
|
||||
|
||||
if (((enet_list_empty (& currentPeer -> outgoingCommands) &&
|
||||
enet_list_empty (& currentPeer -> outgoingSendReliableCommands)) ||
|
||||
enet_protocol_check_outgoing_commands (host, currentPeer)) &&
|
||||
enet_protocol_check_outgoing_commands (host, currentPeer, & sentUnreliableCommands)) &&
|
||||
enet_list_empty (& currentPeer -> sentReliableCommands) &&
|
||||
ENET_TIME_DIFFERENCE (host -> serviceTime, currentPeer -> lastReceiveTime) >= currentPeer -> pingInterval &&
|
||||
currentPeer -> mtu - host -> packetSize >= sizeof (ENetProtocolPing))
|
||||
{
|
||||
enet_peer_ping (currentPeer);
|
||||
enet_protocol_check_outgoing_commands (host, currentPeer);
|
||||
enet_protocol_check_outgoing_commands (host, currentPeer, & sentUnreliableCommands);
|
||||
}
|
||||
|
||||
if (host -> commandCount == 0)
|
||||
@@ -1715,7 +1718,7 @@ enet_protocol_send_outgoing_commands (ENetHost * host, ENetEvent * event, int ch
|
||||
|
||||
sentLength = enet_socket_send (host -> socket, & currentPeer -> address, host -> buffers, host -> bufferCount);
|
||||
|
||||
enet_protocol_remove_sent_unreliable_commands (currentPeer);
|
||||
enet_protocol_remove_sent_unreliable_commands (currentPeer, & sentUnreliableCommands);
|
||||
|
||||
if (sentLength < 0)
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user