From dab34697e79f5d6a97462b24249ef7c5b0f1813a Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Sun, 28 Oct 2007 19:28:09 +0000 Subject: [PATCH] added nameplates --- src/engine/interface.h | 1 - src/game/client/game_client.cpp | 22 ++++++++++++++++++++-- src/game/game_variables.h | 2 ++ src/tools/crapnet.cpp | 4 ++-- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/engine/interface.h b/src/engine/interface.h index 635bd757b..cf667cc3b 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 ef96b749e..471cb6049 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 a72f79dc1..352675bae 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 a12b4ba4f..842a602d2 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;