|
@@ -742,12 +742,18 @@ enet_protocol_handle_send_unreliable_fragment (ENetHost * host, ENetPeer * peer,
|
|
|
static int
|
|
|
enet_protocol_handle_ping (ENetHost * host, ENetPeer * peer, const ENetProtocol * command)
|
|
|
{
|
|
|
+ if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)
|
|
|
+ return -1;
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
static int
|
|
|
enet_protocol_handle_bandwidth_limit (ENetHost * host, ENetPeer * peer, const ENetProtocol * command)
|
|
|
{
|
|
|
+ if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)
|
|
|
+ return -1;
|
|
|
+
|
|
|
peer -> incomingBandwidth = ENET_NET_TO_HOST_32 (command -> bandwidthLimit.incomingBandwidth);
|
|
|
peer -> outgoingBandwidth = ENET_NET_TO_HOST_32 (command -> bandwidthLimit.outgoingBandwidth);
|
|
|
|
|
@@ -769,6 +775,9 @@ enet_protocol_handle_bandwidth_limit (ENetHost * host, ENetPeer * peer, const EN
|
|
|
static int
|
|
|
enet_protocol_handle_throttle_configure (ENetHost * host, ENetPeer * peer, const ENetProtocol * command)
|
|
|
{
|
|
|
+ if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)
|
|
|
+ return -1;
|
|
|
+
|
|
|
peer -> packetThrottleInterval = ENET_NET_TO_HOST_32 (command -> throttleConfigure.packetThrottleInterval);
|
|
|
peer -> packetThrottleAcceleration = ENET_NET_TO_HOST_32 (command -> throttleConfigure.packetThrottleAcceleration);
|
|
|
peer -> packetThrottleDeceleration = ENET_NET_TO_HOST_32 (command -> throttleConfigure.packetThrottleDeceleration);
|
|
@@ -779,7 +788,7 @@ enet_protocol_handle_throttle_configure (ENetHost * host, ENetPeer * peer, const
|
|
|
static int
|
|
|
enet_protocol_handle_disconnect (ENetHost * host, ENetPeer * peer, const ENetProtocol * command)
|
|
|
{
|
|
|
- if (peer -> state == ENET_PEER_STATE_ZOMBIE || peer -> state == ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT)
|
|
|
+ if (peer -> state == ENET_PEER_STATE_DISCONNECTED || peer -> state == ENET_PEER_STATE_ZOMBIE || peer -> state == ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT)
|
|
|
return 0;
|
|
|
|
|
|
enet_peer_reset_queues (peer);
|
|
@@ -813,6 +822,9 @@ enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer *
|
|
|
receivedReliableSequenceNumber;
|
|
|
ENetProtocolCommand commandNumber;
|
|
|
|
|
|
+ if (peer -> state == ENET_PEER_STATE_DISCONNECTED || peer -> state == ENET_PEER_STATE_ZOMBIE)
|
|
|
+ return 0;
|
|
|
+
|
|
|
receivedSentTime = ENET_NET_TO_HOST_16 (command -> acknowledge.receivedSentTime);
|
|
|
receivedSentTime |= host -> serviceTime & 0xFFFF0000;
|
|
|
if ((receivedSentTime & 0x8000) > (host -> serviceTime & 0x8000))
|
|
@@ -1065,7 +1077,7 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)
|
|
|
|
|
|
command -> header.reliableSequenceNumber = ENET_NET_TO_HOST_16 (command -> header.reliableSequenceNumber);
|
|
|
|
|
|
- switch (command -> header.command & ENET_PROTOCOL_COMMAND_MASK)
|
|
|
+ switch (commandNumber)
|
|
|
{
|
|
|
case ENET_PROTOCOL_COMMAND_ACKNOWLEDGE:
|
|
|
if (enet_protocol_handle_acknowledge (host, event, peer, command))
|
|
@@ -1073,6 +1085,8 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)
|
|
|
break;
|
|
|
|
|
|
case ENET_PROTOCOL_COMMAND_CONNECT:
|
|
|
+ if (peer != NULL)
|
|
|
+ goto commandError;
|
|
|
peer = enet_protocol_handle_connect (host, header, command);
|
|
|
if (peer == NULL)
|
|
|
goto commandError;
|
|
@@ -1146,6 +1160,8 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)
|
|
|
{
|
|
|
case ENET_PEER_STATE_DISCONNECTING:
|
|
|
case ENET_PEER_STATE_ACKNOWLEDGING_CONNECT:
|
|
|
+ case ENET_PEER_STATE_DISCONNECTED:
|
|
|
+ case ENET_PEER_STATE_ZOMBIE:
|
|
|
break;
|
|
|
|
|
|
case ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT:
|