diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-04-06 11:52:00 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-04-06 11:52:00 +0000 |
| commit | d15bef7ede6b07dbbc2f6b6a3e23b1ed83e6b6ea (patch) | |
| tree | f5c299c768a761177065855c25be7506488b95b4 /src/engine | |
| parent | 34c3a1c1426e6443ba30b8e2852b73bf92757dff (diff) | |
| download | zcatch-d15bef7ede6b07dbbc2f6b6a3e23b1ed83e6b6ea.tar.gz zcatch-d15bef7ede6b07dbbc2f6b6a3e23b1ed83e6b6ea.zip | |
loads of changes here and there. added flushing of packets when connection is started
Diffstat (limited to 'src/engine')
| -rw-r--r-- | src/engine/client/ec_client.c | 7 | ||||
| -rw-r--r-- | src/engine/client/ec_gfx.c | 32 | ||||
| -rw-r--r-- | src/engine/e_network.c | 17 | ||||
| -rw-r--r-- | src/engine/e_network.h | 1 | ||||
| -rw-r--r-- | src/engine/server/es_server.c | 4 |
5 files changed, 29 insertions, 32 deletions
diff --git a/src/engine/client/ec_client.c b/src/engine/client/ec_client.c index c2143121..6faf0f25 100644 --- a/src/engine/client/ec_client.c +++ b/src/engine/client/ec_client.c @@ -304,7 +304,7 @@ int client_send_msg() static void client_send_info() { - msg_pack_start_system(NETMSG_INFO, MSGFLAG_VITAL); + msg_pack_start_system(NETMSG_INFO, MSGFLAG_VITAL|MSGFLAG_FLUSH); msg_pack_string(modc_net_version(), 128); msg_pack_string(config.player_name, 128); msg_pack_string(config.clan_name, 128); @@ -316,14 +316,14 @@ static void client_send_info() static void client_send_entergame() { - msg_pack_start_system(NETMSG_ENTERGAME, MSGFLAG_VITAL); + msg_pack_start_system(NETMSG_ENTERGAME, MSGFLAG_VITAL|MSGFLAG_FLUSH); msg_pack_end(); client_send_msg(); } static void client_send_ready() { - msg_pack_start_system(NETMSG_READY, MSGFLAG_VITAL); + msg_pack_start_system(NETMSG_READY, MSGFLAG_VITAL|MSGFLAG_FLUSH); msg_pack_end(); client_send_msg(); } @@ -461,6 +461,7 @@ void client_entergame() /* to finish the connection */ client_send_entergame(); client_on_enter_game(); + /*netclient_flush(net);*/ } void client_connect(const char *server_address_str) diff --git a/src/engine/client/ec_gfx.c b/src/engine/client/ec_gfx.c index 18b17a74..3a9f11d1 100644 --- a/src/engine/client/ec_gfx.c +++ b/src/engine/client/ec_gfx.c @@ -47,6 +47,7 @@ static COLOR color[4]; static TEXCOORD texture[4]; static int do_screenshot = 0; +static int render_enable = 1; static int screen_width = -1; static int screen_height = -1; @@ -104,10 +105,13 @@ static void flush() glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_COLOR_ARRAY); - if(drawing == DRAWING_QUADS) - glDrawArrays(GL_QUADS, 0, num_vertices); - else if(drawing == DRAWING_LINES) - glDrawArrays(GL_LINES, 0, num_vertices); + if(render_enable) + { + if(drawing == DRAWING_QUADS) + glDrawArrays(GL_QUADS, 0, num_vertices); + else if(drawing == DRAWING_LINES) + glDrawArrays(GL_LINES, 0, num_vertices); + } /* Reset pointer */ num_vertices = 0; @@ -651,27 +655,9 @@ void gfx_swap() perf_end(); } - if(config.gfx_finish) + if(render_enable && config.gfx_finish) glFinish(); - /* - if(inp_key_pressed('P')) - { - { - static PERFORMACE_INFO pscope = {"glFlush", 0}; - perf_start(&pscope); - glFlush(); - perf_end(); - } - - { - static PERFORMACE_INFO pscope = {"glFinish", 0}; - perf_start(&pscope); - glFinish(); - perf_end(); - } - }*/ - { static PERFORMACE_INFO pscope = {"glfwPollEvents", 0}; perf_start(&pscope); diff --git a/src/engine/e_network.c b/src/engine/e_network.c index b523e73b..d4e41a08 100644 --- a/src/engine/e_network.c +++ b/src/engine/e_network.c @@ -355,7 +355,8 @@ static void conn_want_resend(NETCONNECTION *conn) static int conn_flush(NETCONNECTION *conn) { - if(!conn->construct.num_chunks && !conn->construct.flags) + int num_chunks = conn->construct.num_chunks; + if(!num_chunks && !conn->construct.flags) return 0; conn->construct.ack = conn->ack; @@ -364,7 +365,7 @@ static int conn_flush(NETCONNECTION *conn) /* clear construct so we can start building a new package */ mem_zero(&conn->construct, sizeof(conn->construct)); - return 1; + return num_chunks; } /*NETCHUNKDATA *data*/ @@ -620,10 +621,13 @@ static int conn_update(NETCONNECTION *conn) if(conn->state == NET_CONNSTATE_ONLINE) { if(time_get()-conn->last_send_time > time_freq()/2) /* flush connection after 250ms if needed */ - if(conn_flush(conn)) + { + int num_flushed_chunks = conn_flush(conn); + if(num_flushed_chunks) { - dbg_msg("connection", "flushed connection due to timeout"); + dbg_msg("connection", "flushed connection due to timeout. %d chunks.", num_flushed_chunks); } + } if(time_get()-conn->last_send_time > time_freq()) conn_send_control(conn, NET_CTRLMSG_KEEPALIVE, 0, 0); @@ -1044,6 +1048,11 @@ int netclient_state(NETCLIENT *c) return NETSTATE_CONNECTING; } +int netclient_flush(NETCLIENT *c) +{ + return conn_flush(&c->conn); +} + int netclient_gotproblems(NETCLIENT *c) { if(time_get() - c->conn.last_recv_time > time_freq()) diff --git a/src/engine/e_network.h b/src/engine/e_network.h index cfa59d84..746230a7 100644 --- a/src/engine/e_network.h +++ b/src/engine/e_network.h @@ -66,6 +66,7 @@ int netclient_send(NETCLIENT *c, NETCHUNK *chunk); int netclient_close(NETCLIENT *c); int netclient_update(NETCLIENT *c); int netclient_state(NETCLIENT *c); +int netclient_flush(NETCLIENT *c); int netclient_gotproblems(NETCLIENT *c); /*void netclient_stats(NETCLIENT *c, NETSTATS *stats);*/ const char *netclient_error_string(NETCLIENT *c); diff --git a/src/engine/server/es_server.c b/src/engine/server/es_server.c index a64bbd46..ca8ab25b 100644 --- a/src/engine/server/es_server.c +++ b/src/engine/server/es_server.c @@ -567,7 +567,7 @@ static int del_client_callback(int cid, void *user) static void server_send_map(int cid) { - msg_pack_start_system(NETMSG_MAP_CHANGE, MSGFLAG_VITAL); + msg_pack_start_system(NETMSG_MAP_CHANGE, MSGFLAG_VITAL|MSGFLAG_FLUSH); msg_pack_string(config.sv_map, 0); msg_pack_int(current_map_crc); msg_pack_end(); @@ -649,7 +649,7 @@ static void server_process_client_packet(NETCHUNK *packet) last = 1; } - msg_pack_start_system(NETMSG_MAP_DATA, MSGFLAG_VITAL); + msg_pack_start_system(NETMSG_MAP_DATA, MSGFLAG_VITAL|MSGFLAG_FLUSH); msg_pack_int(last); msg_pack_int(current_map_size); msg_pack_int(chunk_size); |