]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Duration -1 makes the centerprint msg last for ever; actually until another msg with...
authorterencehill <piuntn@gmail.com>
Thu, 23 Jun 2011 17:28:27 +0000 (19:28 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 23 Jun 2011 17:28:27 +0000 (19:28 +0200)
qcsrc/client/hud.qc
qcsrc/server/cl_client.qc
qcsrc/server/mutators/gamemode_keyhunt.qc

index 5b73c5f96983c02d571d774588b6477c107d3ad5..9f4f1216060b924d207955951045b9fd38627dd9 100644 (file)
@@ -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;
index 078828f58ae64fd9b6a32d737cbeaf4d557c539d..f4c1d009def9ee411f04034ede149f81abafb930 100644 (file)
@@ -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
index 39c1eb9a2e1cc1c42885b07eb3ad35b57f9f6220..0dec6f485d8bfe3bbc44675aa2fee64020bacdaa 100644 (file)
@@ -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