--- a/network_client.c Mon Jan 08 14:01:05 2007 +0000
+++ b/network_client.c Tue Jan 16 23:59:03 2007 +0000
@@ -467,9 +467,18 @@
_frame_counter = _frame_counter_server = _frame_counter_max = NetworkRecv_uint32(MY_CLIENT, p);
- _network_join_status = NETWORK_JOIN_STATUS_DOWNLOADING;
_network_join_kbytes = 0;
_network_join_kbytes_total = NetworkRecv_uint32(MY_CLIENT, p) / 1024;
+
+ /* If the network connection has been closed due to loss of connection
+ * or when _network_join_kbytes_total is 0, the join status window will
+ * do a division by zero. When the connection is lost, we just return
+ * that. If kbytes_total is 0, the packet must be malformed as a
+ * savegame less than 1 kilobyte is practically impossible. */
+ if (MY_CLIENT->has_quit) return NETWORK_RECV_STATUS_CONN_LOST;
+ if (_network_join_kbytes_total == 0) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
+
+ _network_join_status = NETWORK_JOIN_STATUS_DOWNLOADING;
InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
// The first packet does not contain any more data