diff --git a/data/demo.map b/data/demo.map index 18b242ba1..8aa7ced83 100644 Binary files a/data/demo.map and b/data/demo.map differ diff --git a/data/dm2.map b/data/dm2.map index 050af41f6..9ec08c7c7 100644 Binary files a/data/dm2.map and b/data/dm2.map differ diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 55646b35d..ac41350ef 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -601,6 +601,15 @@ void client::run(const char *direct_connect_server) // panic button if(input::pressed(input::lctrl) && input::pressed('Q')) break; + + if(input::pressed(input::f5)) + { + // ack snapshot + msg_pack_start_system(NETMSG_SNAPACK, 0); + msg_pack_int(-1); + msg_pack_end(); + client_send_msg(); + } // pump the network pump_network(); @@ -794,7 +803,7 @@ void client::process_packet(NETPACKET *packet) error("failure to load map"); } } - else if(msg == NETMSG_SNAP || msg == NETMSG_SNAPSMALL || msg == NETMSG_SNAPEMPTY) + else if(msg == NETMSG_SNAP || msg == NETMSG_SNAPEMPTY) //|| msg == NETMSG_SNAPSMALL || msg == NETMSG_SNAPEMPTY) { //dbg_msg("client/network", "got snapshot"); int game_tick = msg_unpack_int(); @@ -802,15 +811,19 @@ void client::process_packet(NETPACKET *packet) int num_parts = 1; int part = 0; int part_size = 0; + int crc = 0; - if(msg == NETMSG_SNAP) + //if(msg == NETMSG_SNAP) { - num_parts = msg_unpack_int(); - part = msg_unpack_int(); + //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) { @@ -831,6 +844,8 @@ 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; @@ -857,6 +872,8 @@ void client::process_packet(NETPACKET *packet) dbg_msg("client", "error, couldn't find the delta snapshot"); } } + + //dbg_msg("UNPACK", "%d unpacked with %d", game_tick, delta_tick); unsigned char tmpbuffer3[MAX_SNAPSHOT_SIZE]; int snapsize = snapshot_unpack_delta(deltashot, (snapshot*)tmpbuffer3, deltadata, deltasize); @@ -873,6 +890,10 @@ void client::process_packet(NETPACKET *packet) // add new snapshot_info *snap = client_snapshot_add(game_tick, time_get(), tmpbuffer3, snapsize); + //int ncrc = snapshot_crc((snapshot*)tmpbuffer3); + //if(crc != ncrc) + //dbg_msg("client", "client snapshot crc failure %d %d", crc, ncrc); + // apply snapshot, cycle pointers recived_snapshots++; @@ -908,10 +929,13 @@ void client::process_packet(NETPACKET *packet) snapshot_part = 0; // ack snapshot - msg_pack_start_system(NETMSG_SNAPACK, 0); - msg_pack_int(game_tick); - msg_pack_end(); - client_send_msg(); + //if((rand()%10)==0) + { + msg_pack_start_system(NETMSG_SNAPACK, 0); + msg_pack_int(game_tick); + msg_pack_end(); + client_send_msg(); + } } } else diff --git a/src/engine/client/gfx.cpp b/src/engine/client/gfx.cpp index 819061ba0..61369106a 100644 --- a/src/engine/client/gfx.cpp +++ b/src/engine/client/gfx.cpp @@ -175,7 +175,8 @@ bool gfx_init() indecies[i*6 + 5] = i+2; }*/ - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // create null texture, will get id=0 gfx_load_texture_raw(4,4,IMG_RGBA,null_texture_data); diff --git a/src/engine/packet.h b/src/engine/packet.h index 9c3bb4229..1700665d6 100644 --- a/src/engine/packet.h +++ b/src/engine/packet.h @@ -164,10 +164,12 @@ public: void *new_item(int type, int id, int size) { snapshot::item *obj = (snapshot::item *)(data+data_size); + mem_zero(obj, sizeof(snapshot::item) + size); obj->type_and_id = (type<<16)|id; offsets[num_items] = data_size; data_size += sizeof(snapshot::item) + size; num_items++; + dbg_assert(data_size < MAX_SNAPSHOT_SIZE, "too much data"); dbg_assert(num_items < MAX_ITEMS, "too many items"); diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 86806c2ad..dd5caf7b1 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -300,10 +300,13 @@ public: delta_tick = clients[i].last_acked_snapshot; deltashot = (snapshot *)delta_data; } + else + dbg_msg("server", "no delta, sending full snapshot"); } // create delta int deltasize = snapshot_create_delta(deltashot, (snapshot*)data, deltadata); + //dbg_msg("PACK", "%d unpacked with %d", current_tick, delta_tick); if(deltasize) { @@ -327,13 +330,14 @@ public: int chunk = left < max_size ? left : max_size; left -= chunk; - if(numpackets == 1) - msg_pack_start_system(NETMSG_SNAPSMALL, 0); - else - msg_pack_start_system(NETMSG_SNAP, 0); + //if(numpackets == 1) + // msg_pack_start_system(NETMSG_SNAPSMALL, 0); + //else + msg_pack_start_system(NETMSG_SNAP, 0); 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(); diff --git a/src/engine/snapshot.cpp b/src/engine/snapshot.cpp index 2f6f1f36e..2e68df722 100644 --- a/src/engine/snapshot.cpp +++ b/src/engine/snapshot.cpp @@ -27,6 +27,21 @@ void *snapshot_empty_delta() return ∅ } +int snapshot_crc(snapshot *snap) +{ + int crc = 0; + + for(int i = 0; i < snap->num_items; i++) + { + snapshot::item *item = snap->get_item(i); + int size = snap->get_item_datasize(i); + + for(int b = 0; b < size/4; b++) + crc += item->data()[b]; + } + return crc; +} + static int diff_item(int *past, int *current, int *out, int size) { /* diff --git a/src/engine/snapshot.h b/src/engine/snapshot.h index 9af94a3bd..b0ffc768c 100644 --- a/src/engine/snapshot.h +++ b/src/engine/snapshot.h @@ -41,6 +41,7 @@ struct snapshot }; void *snapshot_empty_delta(); +int snapshot_crc(snapshot *snap); int snapshot_create_delta(snapshot *from, snapshot *to, void *data); int snapshot_unpack_delta(snapshot *from, snapshot *to, void *data, int data_size); diff --git a/src/game/client/mapres_tilemap.cpp b/src/game/client/mapres_tilemap.cpp index 032238bf9..f4088fa8e 100644 --- a/src/game/client/mapres_tilemap.cpp +++ b/src/game/client/mapres_tilemap.cpp @@ -46,7 +46,7 @@ void tilemap_render(float scale, int fg) int endy = (int)(screen_y1/scale)+1; int endx = (int)(screen_x1/scale)+1; - float frac = (1.0f/1024.0f);//2.0f; //2.0f; + float frac = (1.25f/1024.0f);//2.0f; //2.0f; float texsize = 1024.0f; float nudge = 0.5f/texsize; for(int y = starty; y < endy; y++) diff --git a/src/tools/crapnet.cpp b/src/tools/crapnet.cpp index ba7b55b9a..cbea7d5e3 100644 --- a/src/tools/crapnet.cpp +++ b/src/tools/crapnet.cpp @@ -40,6 +40,9 @@ int run(int port, netaddr4 dest) int bytes = socket.recv(&from, buffer, 1024*2); if(bytes <= 0) break; + + if((rand()%10) == 0) // drop the packet + continue; // create new packet packet *p = (packet *)mem_alloc(sizeof(packet)+bytes, 1); diff --git a/src/tools/tileset_borderfix.c b/src/tools/tileset_borderfix.c index ba7a40f0d..4b31c2f0e 100644 --- a/src/tools/tileset_borderfix.c +++ b/src/tools/tileset_borderfix.c @@ -75,7 +75,7 @@ int main(int argc, char **argv) tilemap_borderfix(w, h, buffer[0], buffer[1]); // save here - png_open_file_write(&png, "output.png"); + png_open_file_write(&png, argv[1]); png_set_data(&png, w, h, 8, PNG_TRUECOLOR_ALPHA, (unsigned char *)buffer[1]); png_close_file(&png); diff --git a/tilesets/shadows.png b/tilesets/shadows.png index 54eb49151..70287c932 100644 Binary files a/tilesets/shadows.png and b/tilesets/shadows.png differ diff --git a/tilesets/tilemap_old.png b/tilesets/tilemap_old.png index 9baa7e18d..2a3a9707a 100644 Binary files a/tilesets/tilemap_old.png and b/tilesets/tilemap_old.png differ diff --git a/tilesets/tilemap_old_caves.png b/tilesets/tilemap_old_caves.png index dba457504..e9edde510 100644 Binary files a/tilesets/tilemap_old_caves.png and b/tilesets/tilemap_old_caves.png differ