From c835373b4523fc731df99fdb81575c2cac8ce3a1 Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Sun, 3 Mar 2013 03:29:31 -0500 Subject: [PATCH] Fix infinite lifetime centerprints --- qcsrc/client/hud.qc | 15 +++++++++++---- qcsrc/common/notifications.qc | 2 +- qcsrc/common/notifications.qh | 2 +- qcsrc/server/cl_client.qc | 6 +++--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 244ba8926..0c162a757 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -4078,6 +4078,7 @@ float centerprint_showing; void centerprint_generic(float new_id, string strMessage, float duration, float countdown_num) { + //print(sprintf("centerprint_generic(%d, '%s^7', %d, %d);\n", new_id, strMessage, duration, countdown_num)); float i, j; if(strMessage == "" && new_id == 0) @@ -4137,7 +4138,10 @@ void centerprint_generic(float new_id, string strMessage, float duration, float centerprint_messages[j] = strzone(strMessage); centerprint_msgID[j] = new_id; if (duration < 0) + { centerprint_time[j] = -1; + centerprint_expire_time[j] = time; + } else { if(duration == 0) @@ -4262,14 +4266,17 @@ void HUD_CenterPrint (void) continue; centerprint_expire_time[j] = centerprint_expire_time[j] + centerprint_time[j]; } - else + else if(centerprint_time[j] != -1) continue; } - + + // fade the centerprint_hud in/out - if (centerprint_time[j] < 0 || centerprint_expire_time[j] - autocvar_hud_panel_centerprint_fade_out > time) + if(centerprint_time[j] < 0) + a = bound(0, (time - centerprint_expire_time[j]) / max(0.0001, autocvar_hud_panel_centerprint_fade_in), 1); + else if(centerprint_expire_time[j] - autocvar_hud_panel_centerprint_fade_out > time) a = bound(0, (time - (centerprint_expire_time[j] - centerprint_time[j])) / max(0.0001, autocvar_hud_panel_centerprint_fade_in), 1); - else if (centerprint_expire_time[j] > time) + else if(centerprint_expire_time[j] > time) a = (centerprint_expire_time[j] - time) / max(0.0001, autocvar_hud_panel_centerprint_fade_out); else a = 0; diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index 9395013f6..a858d9f0e 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -1,6 +1,6 @@ // ================================================ // Unified notification system, written by Samual -// Last updated: February, 2013 +// Last updated: March, 2013 // ================================================ string Get_Notif_TypeName(float net_type) diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index 95b022820..6175b3563 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -1,6 +1,6 @@ // ================================================ // Unified notification system, written by Samual -// Last updated: February, 2013 +// Last updated: March, 2013 // ================================================ // main types/groups of notifications diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index a95ff18c3..1778d78bf 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2339,9 +2339,9 @@ void LeaveSpectatorMode() if(self.classname == STR_PLAYER) Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_JOIN_PLAY, self.netname); - //if(!autocvar_g_campaign) - //if (time < self.jointime + autocvar_welcome_message_time) - // Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_MOTD); + if(!autocvar_g_campaign) + if (time < self.jointime + autocvar_welcome_message_time) + Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_MOTD); if (self.prevent_join_msgtime) { -- 2.39.2