about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-04-06 11:52:00 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-04-06 11:52:00 +0000
commitd15bef7ede6b07dbbc2f6b6a3e23b1ed83e6b6ea (patch)
treef5c299c768a761177065855c25be7506488b95b4
parent34c3a1c1426e6443ba30b8e2852b73bf92757dff (diff)
downloadzcatch-d15bef7ede6b07dbbc2f6b6a3e23b1ed83e6b6ea.tar.gz
zcatch-d15bef7ede6b07dbbc2f6b6a3e23b1ed83e6b6ea.zip
loads of changes here and there. added flushing of packets when connection is started
-rw-r--r--src/engine/client/ec_client.c7
-rw-r--r--src/engine/client/ec_gfx.c32
-rw-r--r--src/engine/e_network.c17
-rw-r--r--src/engine/e_network.h1
-rw-r--r--src/engine/server/es_server.c4
-rw-r--r--src/game/client/gc_client.cpp2
-rw-r--r--src/game/client/gc_client.h4
-rw-r--r--src/game/client/gc_hooks.cpp19
-rw-r--r--src/game/client/gc_render_obj.cpp13
-rw-r--r--src/game/server/gs_server.cpp2
10 files changed, 51 insertions, 50 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);
diff --git a/src/game/client/gc_client.cpp b/src/game/client/gc_client.cpp
index bcacfd17..005e9026 100644
--- a/src/game/client/gc_client.cpp
+++ b/src/game/client/gc_client.cpp
@@ -442,7 +442,7 @@ void send_info(bool start)
 		msg.use_custom_color = config.player_use_custom_color;
 		msg.color_body = config.player_color_body;
 		msg.color_feet = config.player_color_feet;
-		msg.pack(MSGFLAG_VITAL);
+		msg.pack(MSGFLAG_VITAL|MSGFLAG_FLUSH);
 	}
 	else
 	{
diff --git a/src/game/client/gc_client.h b/src/game/client/gc_client.h
index bb684830..2ab558f3 100644
--- a/src/game/client/gc_client.h
+++ b/src/game/client/gc_client.h
@@ -50,9 +50,7 @@ extern player_core predicted_prev_player;
 extern player_core predicted_player;
 
 // input
-extern int picked_up_weapon;
 extern NETOBJ_PLAYER_INPUT input_data;
-extern int input_target_lock;
 
 // debug
 extern int64 debug_firedelay;
@@ -153,6 +151,8 @@ struct client_data
 	tee_render_info skin_info; // this is what the server reports
 	tee_render_info render_info; // this is what we use
 	
+	float angle;
+	
 	void update_render_info();
 };
 
diff --git a/src/game/client/gc_hooks.cpp b/src/game/client/gc_hooks.cpp
index 72c94abc..81090ca4 100644
--- a/src/game/client/gc_hooks.cpp
+++ b/src/game/client/gc_hooks.cpp
@@ -386,18 +386,11 @@ extern "C" int modc_snap_input(int *data)
 		return sizeof(input_data);
 	}
 	
-	picked_up_weapon = -1;
-
-	if(!input_target_lock)
-	{
-		input_data.target_x = (int)mouse_pos.x;
-		input_data.target_y = (int)mouse_pos.y;
-		
-		if(!input_data.target_x && !input_data.target_y)
-			input_data.target_y = 1;
-	}
-
-	input_target_lock = 0;
+	input_data.target_x = (int)mouse_pos.x;
+	input_data.target_y = (int)mouse_pos.y;
+	if(!input_data.target_x && !input_data.target_y)
+		input_data.target_y = 1;
+	
 
 	// stress testing
 	if(config.dbg_stress)
@@ -518,6 +511,7 @@ extern "C" void modc_message(int msgtype)
 			
 		// apply new tuning
 		tuning = new_tuning;
+		return;
 	}
 	
 	// normal 
@@ -663,6 +657,7 @@ extern "C" void modc_connected()
 		client_datas[i].name[0] = 0;
 		client_datas[i].skin_id = 0;
 		client_datas[i].team = 0;
+		client_datas[i].angle = 0;
 		client_datas[i].emoticon = 0;
 		client_datas[i].emoticon_start = -1;
 		client_datas[i].skin_info.texture = skin_get(0)->color_texture;
diff --git a/src/game/client/gc_render_obj.cpp b/src/game/client/gc_render_obj.cpp
index 0bfb902c..580ca259 100644
--- a/src/game/client/gc_render_obj.cpp
+++ b/src/game/client/gc_render_obj.cpp
@@ -312,6 +312,17 @@ void render_player(
 	if(player.health < 0) // dont render dead players
 		return;
 
+	//float angle = mix((float)prev.angle, (float)player.angle, intratick)/256.0f;
+	
+	// TODO: fix this good!
+	float mixspeed = 0.05f;
+	if(player.attacktick != prev.attacktick)
+		mixspeed = 0.1f;
+	
+	float angle = mix(client_datas[info.cid].angle, player.angle/256.0f, mixspeed);
+	client_datas[info.cid].angle = angle;
+	vec2 direction = get_direction((int)(angle*256.0f));
+	
 	if(info.local && config.cl_predict)
 	{
 		if(!netobjects.local_character || (netobjects.local_character->health < 0) || (netobjects.gameobj && netobjects.gameobj->game_over))
@@ -326,8 +337,6 @@ void render_player(
 		}
 	}
 
-	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), intratick);
 	vec2 vel = mix(vec2(prev.vx/256.0f, prev.vy/256.0f), vec2(player.vx/256.0f, player.vy/256.0f), intratick);
 	
diff --git a/src/game/server/gs_server.cpp b/src/game/server/gs_server.cpp
index e46001ee..78ad3f9f 100644
--- a/src/game/server/gs_server.cpp
+++ b/src/game/server/gs_server.cpp
@@ -2189,7 +2189,7 @@ void mods_message(int msgtype, int client_id)
 			
 			//
 			NETMSG_SV_READY_TO_ENTER m;
-			m.pack(MSGFLAG_VITAL);
+			m.pack(MSGFLAG_VITAL|MSGFLAG_FLUSH);
 			server_send_msg(client_id);			
 		}