about summary refs log tree commit diff
path: root/src/engine/client/ec_client.c
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-10-16 18:17:35 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-10-16 18:17:35 +0000
commita6be56dbdcbcd7b7a3ebf7dae7cd0537027486ea (patch)
tree14ab77203f3c2def2ec543822089912c00a40757 /src/engine/client/ec_client.c
parent977785b154f4153cc99e5c0ca866c154bb71bfbc (diff)
downloadzcatch-a6be56dbdcbcd7b7a3ebf7dae7cd0537027486ea.tar.gz
zcatch-a6be56dbdcbcd7b7a3ebf7dae7cd0537027486ea.zip
fixed crash bug when connecting/disconnecting
Diffstat (limited to 'src/engine/client/ec_client.c')
-rw-r--r--src/engine/client/ec_client.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/engine/client/ec_client.c b/src/engine/client/ec_client.c
index ef0a25af..3a9390fc 100644
--- a/src/engine/client/ec_client.c
+++ b/src/engine/client/ec_client.c
@@ -234,7 +234,7 @@ enum
 SNAPSTORAGE snapshot_storage;
 static SNAPSTORAGE_HOLDER *snapshots[NUM_SNAPSHOT_TYPES];
 
-static int recived_snapshots;
+static int recived_snapshots = 0;
 static char snapshot_incomming_data[MAX_SNAPSHOT_SIZE];
 
 static SNAPSTORAGE_HOLDER demorec_snapshotholders[NUM_SNAPSHOT_TYPES];
@@ -561,6 +561,11 @@ void client_disconnect_with_reason(const char *reason)
 
 	/* clear the current server info */
 	mem_zero(&current_server_info, sizeof(current_server_info));
+	
+	/* clear snapshots */
+	snapshots[SNAP_CURRENT] = 0;
+	snapshots[SNAP_PREV] = 0;
+	recived_snapshots = 0;
 }
 
 void client_disconnect()
@@ -989,6 +994,10 @@ static void client_process_packet(NETCHUNK *packet)
 				int complete_size = 0;
 				const char *data = 0;
 				
+				/* we are not allowed to process snapshot yet */
+				if(client_state() < CLIENTSTATE_LOADING)
+					return;
+				
 				if(msg == NETMSG_SNAP)
 				{
 					num_parts = msg_unpack_int();