]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Unify series of countdown messages in one message. Also now the messages can be displ...
authorterencehill <piuntn@gmail.com>
Sun, 22 May 2011 16:57:27 +0000 (18:57 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 22 May 2011 16:57:27 +0000 (18:57 +0200)
qcsrc/client/hud.qc
qcsrc/client/miscfunctions.qc
qcsrc/common/constants.qh
qcsrc/server/arena.qc
qcsrc/server/cl_client.qc
qcsrc/server/mutators/mutator_nix.qc
qcsrc/server/w_minstanex.qc

index fb7ddcf6edaab2310a7b91f232c97587df5e74c6..15ca2b9b6f6ab39b0fac0d7f9e83ec80694c7f62 100644 (file)
@@ -145,13 +145,23 @@ float stringwidth_nocolors(string s, vector theSize)
 #define CENTERPRINT_MAX_LINES 10
 float cpm_index;
 string centerprint_messages[CENTERPRINT_MAX_LINES];
+float centerprint_msgID[CENTERPRINT_MAX_LINES];
 float centerprint_width[CENTERPRINT_MAX_LINES];
 float centerprint_time[CENTERPRINT_MAX_LINES];
 float centerprint_expire;
 float centerprint_num;
-float centerprint_offset_hint;
 vector centerprint_fontsize;
 
+string strip_CPID(string s)
+{
+       return substring(s, strstrofs(s, " ", 0) + 1, strlen(s));
+}
+float get_CPID(string s)
+{
+       if(substring(s, 0, 1) != "#")
+               return 0;
+       return stof(substring(s, 1, strstrofs(s, " ", 0)));
+}
 void centerprint(string strMessage)
 {
        float i, j, n, hcount;
@@ -167,32 +177,24 @@ void centerprint(string strMessage)
        if(strMessage == "")
                return;
 
-       // strip trailing newlines
-       j = strlen(strMessage) - 1;
-       while(substring(strMessage, j, 1) == "\n" && j >= 0)
-               j = j - 1;
-       strMessage = substring(strMessage, 0, j + 1);
-
-       if(strMessage == "")
-               return;
-
-       // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
-       j = 0;
-       while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
-               j = j + 1;
-       strMessage = substring(strMessage, j, strlen(strMessage) - j);
-       centerprint_offset_hint = j;
-
-       if(strMessage == "")
-               return;
+       float new_id = get_CPID(strMessage);
 
        for (i=0, j=cpm_index; i<CENTERPRINT_MAX_LINES; ++i, ++j)
        {
                if (j == CENTERPRINT_MAX_LINES)
                        j = 0;
+               if (new_id && new_id == centerprint_msgID[j])
+               {
+                       if(centerprint_messages[j])
+                               strunzone(centerprint_messages[j]);
+                       centerprint_messages[j] == strzone(strip_CPID(strMessage));
+                       centerprint_time[j] = time;
+                       return;
+               }
                if(centerprint_messages[j] == strMessage)
                {
                        centerprint_time[j] = time;
+                       centerprint_msgID[j] = new_id;
                        return;
                }
        }
@@ -202,7 +204,11 @@ void centerprint(string strMessage)
                cpm_index = CENTERPRINT_MAX_LINES - 1;
        if(centerprint_messages[cpm_index])
                strunzone(centerprint_messages[cpm_index]);
-       centerprint_messages[cpm_index] = strzone(strMessage);
+       if (new_id)
+               centerprint_messages[cpm_index] = strzone(strip_CPID(strMessage));
+       else
+               centerprint_messages[cpm_index] = strzone(strMessage);
+       centerprint_msgID[cpm_index] = new_id;
        centerprint_time[cpm_index] = time;
 
 
index d59c75ba8d81629cfc485bea7499a6fe32a9a60a..e47734cb3d240c58468c964b119b3fca5bf23a04 100644 (file)
@@ -20,7 +20,7 @@ void restartAnnouncer_Think() {
        countdown_rounded = floor(0.5 + countdown);
        if(countdown <= 0) {
                if (!spectatee_status) //do cprint only for players
-                       centerprint(_("^1Begin!"));
+                       centerprint(strcat(CPID_GAME_STARTING, _("^1Begin!")));
 
                sound(world, CHAN_AUTO, strcat("announcer/", autocvar_cl_announcer, "/begin.wav"), VOL_BASEVOICE, ATTN_NONE);
                //reset maptime announcers now as well
@@ -31,7 +31,7 @@ void restartAnnouncer_Think() {
        }
        else {
                if (!spectatee_status) //do cprint only for players
-                       centerprint(sprintf(_("^1Game starts in %d seconds"), countdown_rounded));
+                       centerprint(strcat(CPID_GAME_STARTING, sprintf(_("^1Game starts in %d seconds"), countdown_rounded)));
 
                if(countdown_rounded <= 3 && countdown_rounded >= 1) {
                        sound(world, CHAN_AUTO, strcat("announcer/", autocvar_cl_announcer, "/", ftos(countdown_rounded), ".wav"), VOL_BASEVOICE, ATTN_NONE);
index 507cff85abcdb2780ee6af7054a6500d5f9f18d6..e2f2ac2a6e7ebe96fb115be9bd2178ac18ed52af 100644 (file)
@@ -580,6 +580,16 @@ float WATERLEVEL_SUBMERGED = 3;
 
 float MAX_SHOT_DISTANCE = 32768;
 
+//centerprint ID list
+#define CPID_TEAMCHANGE                        "#1 "
+#define CPID_KILL                              "#2 "
+#define CPID_MINSTA_FINDAMMO   "#3 "
+#define CPID_NIX_WPNCHANGE             "#4 "
+#define CPID_DISCONNECT_IDLING "#5 "
+#define CPID_ROUND_STARTING            "#6 "
+#define CPID_GAME_STARTING             "#7 "
+#define CPID_TIMEOUT_COUNTDOWN "#8 "
+
 // CSQC centerprint/notify message types
 float MSG_SUICIDE = 0;
 float MSG_KILL = 1;
index 681e86fa0f5c08637e32a5308fdfbfea1ca4920c..6072c15121fa037c32a660714328d5394069c0a6 100644 (file)
@@ -231,11 +231,9 @@ void Arena_Warmup()
                        allowed_to_spawn = 1;
                if(champion && g_arena)
                        msg = strcat("The Champion is ", champion_name, "^7\n");
-                       //centerprint(self, strcat(msg, "The Champion is ", champion.netname, "^7\n"));
 
                if(f != roundStartTime_prev) {
-                       msg = strcat(msg, "Round will start in ", ftos(f),"\n");
-                       //centerprint(self, strcat("Round will start in ", ftos(f),"\n"));
+                       msg = strcat(CPID_ROUND_STARTING, msg, "Round will start in ", ftos(f),"\n");
                        roundStartTime_prev = f;
                        if(f == 5)
                                Announce("prepareforbattle");
index 561b755c9694b9d2ff05f95fc946dfbd7df31256..6df11cc02c97dc47111f6f914a0ccb08d4de088b 100644 (file)
@@ -1302,14 +1302,14 @@ void KillIndicator_Think()
                        if(self.owner.killindicator_teamchange)
                        {
                                if(self.owner.killindicator_teamchange == -1)
-                                       centerprint(self.owner, strcat("Changing team in ", ftos(self.cnt), " seconds"));
+                                       centerprint(self.owner, strcat(CPID_TEAMCHANGE, "Changing team in ", ftos(self.cnt), " seconds"));
                                else if(self.owner.killindicator_teamchange == -2)
-                                       centerprint(self.owner, strcat("Spectating in ", ftos(self.cnt), " seconds"));
+                                       centerprint(self.owner, strcat(CPID_TEAMCHANGE, "Spectating in ", ftos(self.cnt), " seconds"));
                                else
-                                       centerprint(self.owner, strcat("Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds"));
+                                       centerprint(self.owner, strcat(CPID_TEAMCHANGE, "Changing to ", ColoredTeamName(self.owner.killindicator_teamchange), " in ", ftos(self.cnt), " seconds"));
                        }
                        else
-                               centerprint(self.owner, strcat("^1Suicide in ", ftos(self.cnt), " seconds"));
+                               centerprint(self.owner, strcat(CPID_KILL, "^1Suicide in ", ftos(self.cnt), " seconds"));
                }
                self.nextthink = time + 1;
                self.cnt -= 1;
@@ -1983,24 +1983,24 @@ string getTimeoutText(float addOneSecond) {
                else {
                        retStr = strcat("Timeout begins in ", ftos(remainingLeadTime), " seconds!\n");
                }
-               return retStr;
+               return strcat(CPID_TIMEOUT_COUNTDOWN, retStr);
        }
        else if (timeoutStatus == 2) {
                if (addOneSecond) {
                        retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime + 1), " seconds!\n");
                        //don't show messages like "Timeout ends in 0 seconds"...
                        if ((remainingTimeoutTime + 1) > 0)
-                               return retStr;
+                               return strcat(CPID_TIMEOUT_COUNTDOWN, retStr);
                        else
-                               return "";
+                               return strcat(CPID_TIMEOUT_COUNTDOWN, "");
                }
                else {
                        retStr = strcat("Timeout ends in ", ftos(remainingTimeoutTime), " seconds!\n");
                        //don't show messages like "Timeout ends in 0 seconds"...
-                       if (remainingTimeoutTime > 0)
-                               return retStr;
+                       if ((remainingTimeoutTime) > 0)
+                               return strcat(CPID_TIMEOUT_COUNTDOWN, retStr);
                        else
-                               return "";
+                               return strcat(CPID_TIMEOUT_COUNTDOWN, "");
                }
        }
        else return "";
@@ -3016,7 +3016,7 @@ void PlayerPostThink (void)
                {
                        if(timeleft != self.idlekick_lasttimeleft)
                        {
-                               centerprint_atprio(self, CENTERPRIO_IDLEKICK, strcat("^3Stop idling!\n^3Disconnecting in ", ftos(timeleft), "..."));
+                               centerprint_atprio(self, CENTERPRIO_IDLEKICK, strcat(CPID_DISCONNECT_IDLING, "^3Stop idling!\n^3Disconnecting in ", ftos(timeleft), "..."));
                                AnnounceTo(self, strcat(ftos(timeleft), ""));
                        }
                }
index a4131af40e8a530f223822db10df609652e6ac29..b306b653cf8fae5fb5a0cad43688e4e5281719e1 100644 (file)
@@ -98,13 +98,13 @@ void NIX_GiveCurrentWeapon()
                if(dt >= 1 && dt <= 5)
                        self.nix_lastinfotime = -42;
                else
-                       centerprint(self, strcat("\n\n^2Active weapon: ^3", W_Name(nix_weapon)));
+                       centerprint(self, strcat(CPID_NIX_WPNCHANGE, "\n\n^2Active weapon: ^3", W_Name(nix_weapon)));
        }
        if(self.nix_lastinfotime != dt)
        {
                self.nix_lastinfotime = dt; // initial value 0 should count as "not seen"
                if(dt >= 1 && dt <= 5)
-                       centerprint(self, strcat("^3", ftos(dt), "^2 seconds until weapon change...\n\nNext weapon: ^3", W_Name(nix_nextweapon), "\n"));
+                       centerprint(self, strcat(CPID_NIX_WPNCHANGE, "^3", ftos(dt), "^2 seconds until weapon change...\n\nNext weapon: ^3", W_Name(nix_nextweapon), "\n"));
        }
 
        if(!(self.items & IT_UNLIMITED_WEAPON_AMMO) && time > self.nix_nextincr)
index 4481178de19b4b3b07a276dae2e6b3f6099058e0..920d03f71be0f6e62ea8328cd0dd166539627b0a 100644 (file)
@@ -98,67 +98,67 @@ void minstagib_ammocheck (void)
        {
                if (self.health == 5)
                {
-                       centerprint(self, "you're dead now...\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "you're dead now...\n"));
                        Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "terminated");
                }
                else if (self.health == 10)
                {
-                       centerprint(self, "^11^7 second left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^11^7 second left to find some ammo\n"));
                        Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "1");
                }
                else if (self.health == 20)
                {
-                       centerprint(self, "^12^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^12^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "2");
                }
                else if (self.health == 30)
                {
-                       centerprint(self, "^13^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^13^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "3");
                }
                else if (self.health == 40)
                {
-                       centerprint(self, "^14^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^14^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "4");
                }
                else if (self.health == 50)
                {
-                       centerprint(self, "^15^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^15^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "5");
                }
                else if (self.health == 60)
                {
-                       centerprint(self, "^36^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^36^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "6");
                }
                else if (self.health == 70)
                {
-                       centerprint(self, "^37^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^37^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "7");
                }
                else if (self.health == 80)
                {
-                       centerprint(self, "^38^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^38^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "8");
                }
                else if (self.health == 90)
                {
-                       centerprint(self, "^39^7 seconds left to find some ammo\n");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "^39^7 seconds left to find some ammo\n"));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        AnnounceTo(self, "9");
                }
                else if (self.health == 100)
                {
-                       centerprint(self, "get some ammo or\nyou'll be dead in ^310^7 seconds...");
+                       centerprint(self, strcat(CPID_MINSTA_FINDAMMO, "get some ammo or\nyou'll be dead in ^310^7 seconds..."));
                        Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
                        if not(self.flags & FL_GODMODE)
                                AnnounceTo(self, "10");