about summary refs log tree commit diff
path: root/src/engine/client/client.c
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-12-10 18:21:22 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-12-10 18:21:22 +0000
commitfbfd169581af5495f72af8693561dd6a221702b8 (patch)
treed29d5537998e84cba7dd1845958e71813fb9fcb0 /src/engine/client/client.c
parent2219b61920d0148e77790eb0294212c058863de9 (diff)
downloadzcatch-fbfd169581af5495f72af8693561dd6a221702b8.tar.gz
zcatch-fbfd169581af5495f72af8693561dd6a221702b8.zip
crash fix that occurs when compressed snapshot spans several packets. crash fix caused but ids running out when chaning maps often
Diffstat (limited to 'src/engine/client/client.c')
-rw-r--r--src/engine/client/client.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/engine/client/client.c b/src/engine/client/client.c
index b862e65a..b3cc57ec 100644
--- a/src/engine/client/client.c
+++ b/src/engine/client/client.c
@@ -645,17 +645,24 @@ static void client_process_packet(NETPACKET *packet)
 					client_disconnect_with_reason(error);
 				}
 			}
-			else if(msg == NETMSG_SNAP || msg == NETMSG_SNAPEMPTY)
+			else if(msg == NETMSG_SNAP || msg == NETMSG_SNAPSINGLE || msg == NETMSG_SNAPEMPTY)
 			{
 				/*dbg_msg("client/network", "got snapshot"); */
+				int num_parts = 1;
+				int part = 0;
 				int game_tick = msg_unpack_int();
 				int delta_tick = game_tick-msg_unpack_int();
 				int input_predtick = msg_unpack_int();
 				int time_left = msg_unpack_int();
-				int num_parts = 1;
-				int part = 0;
 				int part_size = 0;
 				int crc = 0;
+				int complete_size = 0;
+				
+				if(msg == NETMSG_SNAP)
+				{
+					num_parts = msg_unpack_int();
+					part = msg_unpack_int();
+				}
 				
 				if(msg != NETMSG_SNAPEMPTY)
 				{
@@ -703,6 +710,8 @@ static void client_process_packet(NETPACKET *packet)
 						unsigned char tmpbuffer2[MAX_SNAPSHOT_SIZE];
 						unsigned char tmpbuffer3[MAX_SNAPSHOT_SIZE];
 						int snapsize;
+						
+						complete_size = (num_parts-1) * MAX_SNAPSHOT_PACKSIZE + part_size;
 
 						snapshot_part = 0;
 						
@@ -733,9 +742,9 @@ static void client_process_packet(NETPACKET *packet)
 						deltadata = snapshot_empty_delta();
 						deltasize = sizeof(int)*3;
 
-						if(part_size)
+						if(complete_size)
 						{
-							int compsize = zerobit_decompress(snapshot_incomming_data, part_size, tmpbuffer);
+							int compsize = zerobit_decompress(snapshot_incomming_data, complete_size, tmpbuffer);
 							int intsize = intpack_decompress(tmpbuffer, compsize, tmpbuffer2);
 							deltadata = tmpbuffer2;
 							deltasize = intsize;