Browse Source

Minor formatting

NX 6 years ago
parent
commit
ef35905df9
1 changed files with 18 additions and 20 deletions
  1. 18 20
      Source/Native/enet.h

+ 18 - 20
Source/Native/enet.h

@@ -1876,24 +1876,24 @@ extern "C" {
 				--startCommand->fragmentsRemaining;
 				--startCommand->fragmentsRemaining;
 				startCommand->fragments[fragmentNumber / 32] |= (1 << (fragmentNumber % 32));
 				startCommand->fragments[fragmentNumber / 32] |= (1 << (fragmentNumber % 32));
 
 
-				if (fragmentOffset + fragmentLength > startCommand->packet->dataLength)
-					fragmentLength = startCommand->packet->dataLength - fragmentOffset;
-
-				memcpy(startCommand->packet->data + fragmentOffset, (enet_uint8*)command + sizeof(ENetProtocolSendFragment), fragmentLength);
+			if (fragmentOffset + fragmentLength > startCommand->packet->dataLength)
+				fragmentLength = startCommand->packet->dataLength - fragmentOffset;
 
 
-				if (startCommand->fragmentsRemaining <= 0)
-					enet_peer_dispatch_incoming_unreliable_commands(peer, channel);
-			}
+			memcpy(startCommand->packet->data + fragmentOffset, (enet_uint8*)command + sizeof(ENetProtocolSendFragment), fragmentLength);
 
 
-			return 0;
+			if (startCommand->fragmentsRemaining <= 0)
+				enet_peer_dispatch_incoming_unreliable_commands(peer, channel);
 		}
 		}
 
 
-		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;
+	}
 
 
-			return 0;
-		}
+	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) {
 	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)
 		if (peer->state != ENET_PEER_STATE_CONNECTED && peer->state != ENET_PEER_STATE_DISCONNECT_LATER)
@@ -2005,9 +2005,7 @@ extern "C" {
 		if (peer->roundTripTimeVariance > peer->highestRoundTripTimeVariance)
 		if (peer->roundTripTimeVariance > peer->highestRoundTripTimeVariance)
 			peer->highestRoundTripTimeVariance = peer->roundTripTimeVariance;
 			peer->highestRoundTripTimeVariance = peer->roundTripTimeVariance;
 
 
-		if (peer->packetThrottleEpoch == 0 ||
-			ENET_TIME_DIFFERENCE(host->serviceTime, peer->packetThrottleEpoch) >= peer->packetThrottleInterval) {
-
+		if (peer->packetThrottleEpoch == 0 || ENET_TIME_DIFFERENCE(host->serviceTime, peer->packetThrottleEpoch) >= peer->packetThrottleInterval) {
 			peer->lastRoundTripTime            = peer->lowestRoundTripTime;
 			peer->lastRoundTripTime            = peer->lowestRoundTripTime;
 			peer->lastRoundTripTimeVariance    = peer->highestRoundTripTimeVariance;
 			peer->lastRoundTripTimeVariance    = peer->highestRoundTripTimeVariance;
 			peer->lowestRoundTripTime          = peer->roundTripTime;
 			peer->lowestRoundTripTime          = peer->roundTripTime;
@@ -4553,8 +4551,8 @@ extern "C" {
 		}
 		}
 
 
 		int enet_socket_connect(ENetSocket socket, const ENetAddress* address) {
 		int enet_socket_connect(ENetSocket socket, const ENetAddress* address) {
+			int result = -1;
 			struct sockaddr_in6 sin;
 			struct sockaddr_in6 sin;
-			int result;
 
 
 			memset(&sin, 0, sizeof(struct sockaddr_in6));
 			memset(&sin, 0, sizeof(struct sockaddr_in6));
 
 
@@ -4571,7 +4569,7 @@ extern "C" {
 		}
 		}
 
 
 		ENetSocket enet_socket_accept(ENetSocket socket, ENetAddress* address) {
 		ENetSocket enet_socket_accept(ENetSocket socket, ENetAddress* address) {
-			int result;
+			int result = -1;
 			struct sockaddr_in6 sin;
 			struct sockaddr_in6 sin;
 			socklen_t sinLength = sizeof(struct sockaddr_in6);
 			socklen_t sinLength = sizeof(struct sockaddr_in6);
 
 
@@ -4594,7 +4592,7 @@ extern "C" {
 		}
 		}
 
 
 		void enet_socket_destroy(ENetSocket socket) {
 		void enet_socket_destroy(ENetSocket socket) {
-			if (socket != -1)
+			if (socket != ENET_SOCKET_NULL)
 				close(socket);
 				close(socket);
 		}
 		}
 
 
@@ -4941,8 +4939,8 @@ extern "C" {
 		}
 		}
 
 
 		int enet_socket_connect(ENetSocket socket, const ENetAddress* address) {
 		int enet_socket_connect(ENetSocket socket, const ENetAddress* address) {
+			int result = -1;
 			struct sockaddr_in6 sin;
 			struct sockaddr_in6 sin;
-			int result;
 
 
 			memset(&sin, 0, sizeof(struct sockaddr_in6));
 			memset(&sin, 0, sizeof(struct sockaddr_in6));