diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-10-20 19:59:03 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-10-20 19:59:03 +0000 |
| commit | d9e34b6cfc94c2f123ff118e627f6ca245e10349 (patch) | |
| tree | ad387b5554da4909cc7641b46775b8b9b38d9528 /src/engine/client/ec_client.c | |
| parent | 1675c9f09896c432b44e021d8ec2adabeedcecc8 (diff) | |
| download | zcatch-d9e34b6cfc94c2f123ff118e627f6ca245e10349.tar.gz zcatch-d9e34b6cfc94c2f123ff118e627f6ca245e10349.zip | |
improved the snapshot handling to handle packet reorders and fixed a crash.
Diffstat (limited to 'src/engine/client/ec_client.c')
| -rw-r--r-- | src/engine/client/ec_client.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/engine/client/ec_client.c b/src/engine/client/ec_client.c index 23790068..5c91fd32 100644 --- a/src/engine/client/ec_client.c +++ b/src/engine/client/ec_client.c @@ -49,7 +49,7 @@ NETCLIENT *net; extern void client_serverbrowse_set(NETADDR *addr, int request, int token, SERVER_INFO *info); extern void client_serverbrowse_save(); -static int snapshot_part; +static unsigned snapshot_parts; static int64 local_start_time; static int debug_font; @@ -484,6 +484,7 @@ static void client_on_enter_game() snapshots[SNAP_PREV] = 0; snapstorage_purge_all(&snapshot_storage); recived_snapshots = 0; + snapshot_parts = 0; current_predtick = 0; current_recv_tick = 0; } @@ -1050,13 +1051,19 @@ static void client_process_packet(NETCHUNK *packet) } } - if(snapshot_part == part && game_tick > current_recv_tick) + if(game_tick >= current_recv_tick) { + if(game_tick != current_recv_tick) + { + snapshot_parts = 0; + current_recv_tick = game_tick; + } + /* TODO: clean this up abit */ mem_copy((char*)snapshot_incomming_data + part*MAX_SNAPSHOT_PACKSIZE, data, part_size); - snapshot_part++; + snapshot_parts |= 1<<part; - if(snapshot_part == num_parts) + if(snapshot_parts == (1<<num_parts)-1) { static SNAPSHOT emptysnap; SNAPSHOT *deltashot = &emptysnap; @@ -1070,7 +1077,7 @@ static void client_process_packet(NETCHUNK *packet) complete_size = (num_parts-1) * MAX_SNAPSHOT_PACKSIZE + part_size; /* reset snapshoting */ - snapshot_part = 0; + snapshot_parts = 0; /* find snapshot that we should use as delta */ emptysnap.data_size = 0; @@ -1201,11 +1208,6 @@ static void client_process_packet(NETCHUNK *packet) ack_game_tick = game_tick; } } - else - { - dbg_msg("client", "snapsht reset!"); - snapshot_part = 0; - } } } else @@ -1507,7 +1509,7 @@ static void client_run() perf_start(&rootscope); local_start_time = time_get(); - snapshot_part = 0; + snapshot_parts = 0; /* init graphics and sound */ if(!gfx_init()) |