From 6560bf5632d59e74a9875323a3f47311152901ca Mon Sep 17 00:00:00 2001 From: cypress Date: Tue, 21 Nov 2023 22:35:13 -0500 Subject: [PATCH] Draw character name on match start --- source/cl_hud.c | 21 +++++++++++++++++++++ source/cl_hud.h | 2 ++ source/cl_parse.c | 5 +++++ source/pr_cmds.c | 30 ++++++++++++++++++++++++++++++ source/protocol.h | 1 + 5 files changed, 59 insertions(+) diff --git a/source/cl_hud.c b/source/cl_hud.c index 5baf1d9..710c675 100644 --- a/source/cl_hud.c +++ b/source/cl_hud.c @@ -67,6 +67,9 @@ void M_DrawPic (int x, int y, qpic_t *pic); double HUD_Change_time;//hide hud when not chagned double bettyprompt_time; +double nameprint_time; + +char player_name[16]; extern cvar_t waypoint_mode; @@ -1392,6 +1395,21 @@ void HUD_BettyPrompt (void) Draw_Pic (x + 20*8 - 4, 56, GetButtonIcon("+grenade")); } +/* +=============== +HUD_PlayerName +=============== +*/ +void HUD_PlayerName (void) +{ + int alpha = 255; + + if (nameprint_time - sv.time < 1) + alpha = (int)((nameprint_time - sv.time)*255); + + Draw_ColoredString(70, 170, player_name, 255, 255, 255, alpha, 1); +} + /* =============== HUD_Draw @@ -1430,6 +1448,9 @@ void HUD_Draw (void) if (bettyprompt_time > sv.time) HUD_BettyPrompt(); + if (nameprint_time > sv.time) + HUD_PlayerName(); + HUD_Blood(); HUD_Rounds(); HUD_Perks(); diff --git a/source/cl_hud.h b/source/cl_hud.h index ac41220..aeb6cdb 100644 --- a/source/cl_hud.h +++ b/source/cl_hud.h @@ -49,5 +49,7 @@ typedef struct achievement_list_s void Achievement_Init (void); extern achievement_list_t achievement_list[MAX_ACHIEVEMENTS]; extern qpic_t *achievement_locked; +extern char player_name[16]; +extern double nameprint_time; void HUD_Parse_Achievement (int ach); diff --git a/source/cl_parse.c b/source/cl_parse.c index b0b1e2a..3eed900 100644 --- a/source/cl_parse.c +++ b/source/cl_parse.c @@ -1118,6 +1118,11 @@ void CL_ParseServerMessage (void) case svc_bettyprompt: bettyprompt_time = sv.time + 4; break; + + case svc_playername: + nameprint_time = sv.time + 11; + strcpy(player_name, MSG_ReadString()); + break; case svc_stufftext: Cbuf_AddText (MSG_ReadString ()); diff --git a/source/pr_cmds.c b/source/pr_cmds.c index 199b9e1..a52cd5d 100644 --- a/source/pr_cmds.c +++ b/source/pr_cmds.c @@ -3300,6 +3300,35 @@ void PF_BettyPrompt(void) MSG_WriteByte (&client->message, svc_bettyprompt); } +/* +================= +PF_SetPlayerName + +sends the name string to +the client, avoids making +a protocol extension and +spamming strings. + +nzp_setplayername() +================= +*/ +void PF_SetPlayerName(void) +{ + client_t *client; + int entnum; + char* s; + + entnum = G_EDICTNUM(OFS_PARM0); + s = G_STRING(OFS_PARM1); + + if (entnum < 1 || entnum > svs.maxclients) + return; + + client = &svs.clients[entnum-1]; + MSG_WriteByte (&client->message, svc_playername); + MSG_WriteString (&client->message, s); +} + /* ================= PF_MaxZombies @@ -3918,6 +3947,7 @@ PF_MaxAmmo, // #501 PF_GrenadePulse, // #502 PF_MaxZombies, // #503 PF_BettyPrompt, // #504 +PF_SetPlayerName, // #505 PF_Fixme, }; diff --git a/source/protocol.h b/source/protocol.h index aa1f73f..42c97fc 100644 --- a/source/protocol.h +++ b/source/protocol.h @@ -152,6 +152,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define svc_maxammo 45 #define svc_pulse 46 #define svc_bettyprompt 47 +#define svc_playername 48 // // client to server