fixed problem with server and client getting out of sync

This commit is contained in:
Magnus Auvinen 2007-07-30 22:57:35 +00:00
parent f826bc6cac
commit 3014707fe5
4 changed files with 9 additions and 31 deletions

View file

@ -102,7 +102,6 @@ static snapshot_info *client_snapshot_add(int tick, int64 time, void *data, int
holder->snap = (snapshot *)(holder+1);
mem_copy(holder->snap, data, data_size);
holder->next =0x0;
holder->prev = last_snapshot;
if(last_snapshot)
@ -644,19 +643,9 @@ static void client_process_packet(NETPACKET *packet)
int num_parts = 1;
int part = 0;
int part_size = 0;
int crc = 0;
//if(msg == NETMSG_SNAP)
{
//num_parts = msg_unpack_int();
//part = msg_unpack_int();
}
if(msg != NETMSG_SNAPEMPTY)
{
part_size = msg_unpack_int();
crc = msg_unpack_int();
}
if(snapshot_part == part)
{
@ -677,8 +666,6 @@ static void client_process_packet(NETPACKET *packet)
unsigned char tmpbuffer2[MAX_SNAPSHOT_SIZE];
if(part_size)
{
if(msg == NETMSG_SNAPEMPTY)
dbg_msg("client", "FAILURE!");
int compsize = zerobit_decompress(snapshot_incomming_data, part_size, tmpbuffer);
int intsize = intpack_decompress(tmpbuffer, compsize, tmpbuffer2);
deltadata = tmpbuffer2;
@ -762,13 +749,10 @@ static void client_process_packet(NETPACKET *packet)
snapshot_part = 0;
// ack snapshot
//if((rand()%10)==0)
{
msg_pack_start_system(NETMSG_SNAPACK, 0);
msg_pack_int(game_tick);
msg_pack_end();
client_send_msg();
}
msg_pack_start_system(NETMSG_SNAPACK, 0);
msg_pack_int(game_tick);
msg_pack_end();
client_send_msg();
}
}
else

View file

@ -303,7 +303,7 @@ static int conn_feed(NETCONNECTION *conn, NETPACKETDATA *p, NETADDR4 *addr)
else
{
// out of sequence, request resend
dbg_msg("conn", "asking for resend");
//dbg_msg("conn", "asking for resend");
conn_send(conn, NETWORK_PACKETFLAG_RESEND, 0, 0);
return 0;
}
@ -312,7 +312,7 @@ static int conn_feed(NETCONNECTION *conn, NETPACKETDATA *p, NETADDR4 *addr)
{
if(p->seq > conn->ack)
{
dbg_msg("conn", "asking for resend");
//dbg_msg("conn", "asking for resend");
conn_send(conn, NETWORK_PACKETFLAG_RESEND, 0, 0);
}
}

View file

@ -306,7 +306,6 @@ public:
// create delta
int deltasize = snapshot_create_delta(deltashot, (snapshot*)data, deltadata);
//dbg_msg("PACK", "%d unpacked with %d", current_tick, delta_tick);
if(deltasize)
{
@ -337,7 +336,6 @@ public:
msg_pack_int(current_tick);
msg_pack_int(current_tick-delta_tick); // compressed with
msg_pack_int(chunk);
msg_pack_int(snapshot_crc((snapshot*)data));
msg_pack_raw(&compdata[n*max_size], chunk);
msg_pack_end();
//const msg_info *info = msg_get_info();

View file

@ -882,17 +882,13 @@ static void render_player(obj_player *prev, obj_player *player)
if(player->health < 0) // dont render dead players
return;
if (prev->health < 0)
{
// Don't flicker from previous position
prev->x = player->x;
prev->y = player->y;
}
vec2 direction = get_direction(player->angle);
float angle = player->angle/256.0f;
vec2 position = mix(vec2(prev->x, prev->y), vec2(player->x, player->y), client_intratick());
if(prev->health < 0) // Don't flicker from previous position
position = vec2(player->x, player->y);
bool stationary = player->vx < 1 && player->vx > -1;
bool inair = col_check_point(player->x, player->y+16) == 0;