From 41498663d9feacb0ca16320e42795a8c480be735 Mon Sep 17 00:00:00 2001 From: terencehill Date: Thu, 23 Jun 2011 19:28:27 +0200 Subject: [PATCH] Duration -1 makes the centerprint msg last for ever; actually until another msg with same id and duration >= 0 is centerprinted --- qcsrc/client/hud.qc | 45 ++++++++++++----------- qcsrc/server/cl_client.qc | 4 +- qcsrc/server/mutators/gamemode_keyhunt.qc | 6 +-- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 5b73c5f96..9f4f12160 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -4371,28 +4371,29 @@ void centerprint_generic(float new_id, string strMessage, float duration, float if (j == CENTERPRINT_MAX_MSGS) j = 0; if (new_id && new_id == centerprint_msgID[j]) - { - if(centerprint_messages[j]) - strunzone(centerprint_messages[j]); - centerprint_messages[j] = strzone(strMessage); - - centerprint_time[j] = duration; - centerprint_expire_time[j] = time + duration; - centerprint_countdown_num[j] = countdown_num; - return; - } + break; // found a msg with the same id, at position j } - --cpm_index; - if (cpm_index == -1) - cpm_index = CENTERPRINT_MAX_MSGS - 1; - if(centerprint_messages[cpm_index]) - strunzone(centerprint_messages[cpm_index]); - centerprint_messages[cpm_index] = strzone(strMessage); - centerprint_msgID[cpm_index] = new_id; - centerprint_time[cpm_index] = duration; - centerprint_expire_time[cpm_index] = time + duration; - centerprint_countdown_num[cpm_index] = countdown_num; + if (i == CENTERPRINT_MAX_MSGS) + { + // a msg with the same id was not found, add the msg at the next position + --cpm_index; + if (cpm_index == -1) + cpm_index = CENTERPRINT_MAX_MSGS - 1; + j = cpm_index; + } + if(centerprint_messages[j]) + strunzone(centerprint_messages[j]); + centerprint_messages[j] = strzone(strMessage); + centerprint_msgID[j] = new_id; + if (duration < 0) + centerprint_time[j] = -1; + else + { + centerprint_time[j] = duration; + centerprint_expire_time[j] = time + duration; + } + centerprint_countdown_num[j] = countdown_num; } void centerprint(string strMessage) @@ -4462,7 +4463,7 @@ void HUD_CenterPrint (void) { if (j == CENTERPRINT_MAX_MSGS) j = 0; - if (centerprint_expire_time[j] < time) + if (centerprint_time[j] > 0 && centerprint_expire_time[j] < time) { if (centerprint_countdown_num[j]) { @@ -4474,7 +4475,7 @@ void HUD_CenterPrint (void) else continue; } - if (centerprint_expire_time[j] - fade > time) + if (centerprint_time[j] < 0 || centerprint_expire_time[j] - fade > time) { a = 1 * alpha_factor; sz = 1; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 078828f58..f4c1d009d 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2708,12 +2708,12 @@ void PlayerPreThink (void) if (autocvar_g_campaign) { if (self.classname == "player" && self.BUTTON_INFO) { self.motd_actived_time = time; - Send_CSQC_Centerprint_Generic(self, CPID_MOTD, campaign_message, 999, 0); + Send_CSQC_Centerprint_Generic(self, CPID_MOTD, campaign_message, -1, 0); } } else { if ((self.classname == "player" || time - self.jointime > autocvar_welcome_message_time) && self.BUTTON_INFO) { self.motd_actived_time = time; - Send_CSQC_Centerprint_Generic(self, CPID_MOTD, getwelcomemessage(), 999, 0); + Send_CSQC_Centerprint_Generic(self, CPID_MOTD, getwelcomemessage(), -1, 0); } } } else { // showing MOTD or campaign message diff --git a/qcsrc/server/mutators/gamemode_keyhunt.qc b/qcsrc/server/mutators/gamemode_keyhunt.qc index 39c1eb9a2..0dec6f485 100644 --- a/qcsrc/server/mutators/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/gamemode_keyhunt.qc @@ -878,7 +878,7 @@ void kh_WaitForPlayers() // delay start of the round until enough players are p if(teams_missing == "") kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round, "Round starts in ", 1, kh_StartRound); else - kh_Controller_SetThink(1, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), 999, kh_WaitForPlayers); + kh_Controller_SetThink(1, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), -1, kh_WaitForPlayers); } void kh_EnableTrackingDevice() // runs after each round @@ -907,7 +907,7 @@ void kh_StartRound() // runs at the start of each round teams_missing = kh_CheckEnoughPlayers(); if(teams_missing != "") { - kh_Controller_SetThink(1, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), 999, kh_WaitForPlayers); + kh_Controller_SetThink(1, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), -1, kh_WaitForPlayers); return; } @@ -933,7 +933,7 @@ void kh_StartRound() // runs at the start of each round } kh_tracking_enabled = FALSE; - kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_tracking, "Scanning frequency range...", 999, kh_EnableTrackingDevice); + kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_tracking, "Scanning frequency range...", -1, kh_EnableTrackingDevice); } float kh_HandleFrags(entity attacker, entity targ, float f) // adds to the player score -- 2.39.2