summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorludde <ludde@openttd.org>2005-07-16 15:05:52 +0000
committerludde <ludde@openttd.org>2005-07-16 15:05:52 +0000
commit11d9f5011562541eff281e4529f77dfea6bf18ee (patch)
tree78c10a10b9a90a900fddec14375581f6f53999f1
parentbd974bb4431a7b130bb233fc40f9b0ef3b8c86d3 (diff)
downloadopenttd-11d9f5011562541eff281e4529f77dfea6bf18ee.tar.xz
(svn r2591) Codechange: [network] Cleanup NetworkHandleCommandQueue
-rw-r--r--network_server.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/network_server.c b/network_server.c
index ca8bd2e8f..45f40bcc8 100644
--- a/network_server.c
+++ b/network_server.c
@@ -1485,27 +1485,13 @@ bool NetworkServer_ReadPackets(NetworkClientState *cs)
// Handle the local command-queue
void NetworkHandleCommandQueue(NetworkClientState *cs) {
- if (cs->command_queue != NULL) {
- CommandPacket *cp;
- CommandPacket *cp_prev;
+ CommandPacket *cp;
- cp = cs->command_queue;
- cp_prev = NULL;
+ while ( (cp = cs->command_queue) != NULL) {
+ SEND_COMMAND(PACKET_SERVER_COMMAND)(cs, cp);
- while (cp != NULL) {
- SEND_COMMAND(PACKET_SERVER_COMMAND)(cs, cp);
-
- if (cp_prev != NULL) {
- cp_prev->next = cp->next;
- free(cp);
- cp = cp_prev->next;
- } else {
- // This means we are at our first packet
- cs->command_queue = cp->next;
- free(cp);
- cp = cs->command_queue;
- }
- }
+ cs->command_queue = cp->next;
+ free(cp);
}
}