about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-10-28 19:28:09 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-10-28 19:28:09 +0000
commitdab34697e79f5d6a97462b24249ef7c5b0f1813a (patch)
tree2b990c00e5c243a7904819bd46d8d33e2cbea93a
parent3bae4dd0e104dc2ccb2864eda995de3adde6aba5 (diff)
downloadzcatch-dab34697e79f5d6a97462b24249ef7c5b0f1813a.tar.gz
zcatch-dab34697e79f5d6a97462b24249ef7c5b0f1813a.zip
added nameplates
-rw-r--r--src/engine/interface.h1
-rw-r--r--src/game/client/game_client.cpp22
-rw-r--r--src/game/game_variables.h2
-rw-r--r--src/tools/crapnet.cpp4
4 files changed, 24 insertions, 5 deletions
diff --git a/src/engine/interface.h b/src/engine/interface.h
index 635bd757..cf667cc3 100644
--- a/src/engine/interface.h
+++ b/src/engine/interface.h
@@ -857,7 +857,6 @@ void gfx_lines_end();
 void gfx_mask_op(int mask, int write);
 void gfx_clear_mask(int fill);
 
-
 /* server snap id */
 int snap_new_id();
 void snap_free_id(int id);
diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp
index ef96b749..471cb604 100644
--- a/src/game/client/game_client.cpp
+++ b/src/game/client/game_client.cpp
@@ -47,6 +47,7 @@ static bool emoticon_selector_active = false;
 
 static vec2 mouse_pos;
 static vec2 local_character_pos;
+static vec2 local_target_pos;
 static const obj_player_character *local_character = 0;
 static const obj_player_character *local_prev_character = 0;
 static const obj_player_info *local_info = 0;
@@ -1443,13 +1444,14 @@ static void render_player(
 
 	}
 
-	// render the tee
+	// render the "shadow" tee
 	if(info.local && config.debug)
 	{
 		vec2 ghost_position = mix(vec2(prev_char->x, prev_char->y), vec2(player_char->x, player_char->y), client_intratick());
 		render_tee(&state, 15, player.emote, direction, ghost_position); // render ghost
 	}
 
+	// render the tee
 	render_tee(&state, skin, player.emote, direction, position);
 
 	if(player.state == STATE_CHATTING)
@@ -1492,6 +1494,20 @@ static void render_player(
 		gfx_quads_draw(position.x, position.y - 23 - 32*h, 64, 64*h);
 		gfx_quads_end();
 	}
+	
+	// render name plate
+	if(!info.local && config.cl_nameplates)
+	{
+		//gfx_pretty_text_color
+		float a = 1;
+		if(config.cl_nameplates == 1)
+			a = clamp(1-powf(distance(local_target_pos, position)/200.0f,16.0f), 0.0f, 1.0f);
+			
+		const char *name = client_datas[info.clientid].name;
+		float tw = gfx_pretty_text_width(28.0f, name, -1);
+		gfx_pretty_text_color(1,1,1,a);
+		gfx_pretty_text(position.x-tw/2.0f, position.y-60, 28.0f, name, -1);
+	}
 }
 
 void render_sun(float x, float y)
@@ -2025,6 +2041,8 @@ void render_game()
 		}
 	}
 
+	local_target_pos = local_character_pos + mouse_pos;
+
 	// snap input
 	{
 		static player_input input = {0};
@@ -2233,7 +2251,7 @@ void render_game()
 		{
 			select_sprite(data->weapons[local_character->weapon%data->num_weapons].sprite_cursor);
 			float cursorsize = 64;
-			draw_sprite(local_character_pos.x+mouse_pos.x, local_character_pos.y+mouse_pos.y, cursorsize);
+			draw_sprite(local_target_pos.x, local_target_pos.y, cursorsize);
 		}
 
 		// render ammo count
diff --git a/src/game/game_variables.h b/src/game/game_variables.h
index a72f79dc..352675ba 100644
--- a/src/game/game_variables.h
+++ b/src/game/game_variables.h
@@ -29,6 +29,8 @@ MACRO_CONFIG_INT(restart, 0, 0, 120)
 MACRO_CONFIG_INT(dbg_bots, 0, 0, 7)
 MACRO_CONFIG_INT(cl_predict, 1, 0, 1)
 
+MACRO_CONFIG_INT(cl_nameplates, 0, 0, 2)
+
 
 MACRO_CONFIG_STR(sv_maprotation, 512, "")
 
diff --git a/src/tools/crapnet.cpp b/src/tools/crapnet.cpp
index a12b4ba4..842a602d 100644
--- a/src/tools/crapnet.cpp
+++ b/src/tools/crapnet.cpp
@@ -96,8 +96,8 @@ int run(int port, NETADDR4 dest)
 				}
 				
 				// send and remove packet
-				//if((rand()%10) != 0) // heavy packetloss
-				net_udp4_send(socket, &p->send_to, p->data, p->data_size);
+				//if((rand()%20) != 0) // heavy packetloss
+				//	net_udp4_send(socket, &p->send_to, p->data, p->data_size);
 				
 				// update lag
 				double flux = rand()/(double)RAND_MAX;