network_data.c
changeset 4077 d3022f976946
parent 3547 a4584d709460
child 4826 63b1eb7c966b
--- a/network_data.c	Tue Jun 27 18:27:58 2006 +0000
+++ b/network_data.c	Tue Jun 27 21:25:53 2006 +0000
@@ -178,8 +178,9 @@
 			cs->packet_queue = p->next;
 			free(p);
 			p = cs->packet_queue;
-		} else
+		} else {
 			return true;
+		}
 	}
 
 	return true;
@@ -192,8 +193,7 @@
 uint8 NetworkRecv_uint8(NetworkClientState *cs, Packet *packet)
 {
 	/* Don't allow reading from a closed socket */
-	if (cs->quited)
-		return 0;
+	if (cs->quited) return 0;
 
 	/* Check if variable is within packet-size */
 	if (packet->pos + 1 > packet->size) {
@@ -209,8 +209,7 @@
 	uint16 n;
 
 	/* Don't allow reading from a closed socket */
-	if (cs->quited)
-		return 0;
+	if (cs->quited) return 0;
 
 	/* Check if variable is within packet-size */
 	if (packet->pos + 2 > packet->size) {
@@ -228,8 +227,7 @@
 	uint32 n;
 
 	/* Don't allow reading from a closed socket */
-	if (cs->quited)
-		return 0;
+	if (cs->quited) return 0;
 
 	/* Check if variable is within packet-size */
 	if (packet->pos + 4 > packet->size) {
@@ -249,8 +247,7 @@
 	uint64 n;
 
 	/* Don't allow reading from a closed socket */
-	if (cs->quited)
-		return 0;
+	if (cs->quited) return 0;
 
 	/* Check if variable is within packet-size */
 	if (packet->pos + 8 > packet->size) {
@@ -388,13 +385,13 @@
 // Add a command to the local command queue
 void NetworkAddCommandQueue(NetworkClientState *cs, CommandPacket *cp)
 {
-	CommandPacket *new_cp = malloc(sizeof(CommandPacket));
+	CommandPacket* new_cp = malloc(sizeof(*new_cp));
 
 	*new_cp = *cp;
 
-	if (cs->command_queue == NULL)
+	if (cs->command_queue == NULL) {
 		cs->command_queue = new_cp;
-	else {
+	} else {
 		CommandPacket *c = cs->command_queue;
 		while (c->next != NULL) c = c->next;
 		c->next = new_cp;
@@ -443,9 +440,7 @@
 
 		// And we queue it for delivery to the clients
 		FOR_ALL_CLIENTS(cs) {
-			if (cs->status > STATUS_AUTH) {
-				NetworkAddCommandQueue(cs, c);
-			}
+			if (cs->status > STATUS_AUTH) NetworkAddCommandQueue(cs, c);
 		}
 
 		// Only the server gets the callback, because clients should not get them