]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Let CSQC handle countdown to round start by integrating it with the countdown to...
authorterencehill <piuntn@gmail.com>
Thu, 7 Feb 2013 17:25:01 +0000 (18:25 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 8 Feb 2013 13:37:09 +0000 (14:37 +0100)
qcsrc/client/announcer.qc
qcsrc/common/constants.qh
qcsrc/server/cl_client.qc
qcsrc/server/defs.qh
qcsrc/server/g_world.qc
qcsrc/server/round_handler.qc

index ec4cc78f6a06da63fa26b78cc92a2d414d1575b2..fad42592e1299cbf1916a6a9492678972eb85b6e 100644 (file)
@@ -22,23 +22,40 @@ void Announcer_Play(string announcement)
 void Announcer_Countdown() 
 {
        float starttime = getstatf(STAT_GAMESTARTTIME);
+       float roundstarttime = getstatf(STAT_ROUNDSTARTTIME);
+       if(starttime <= time) // game start time has passed
+               announcer_5min = announcer_1min = FALSE; // reset maptime announcers now as well
+       if(roundstarttime == -1)
+       {
+               // stop countdown immediately
+               centerprint_generic(CPID_GAME_STARTING, "", 1, 0);
+               remove(self);
+               return;
+       }
+       if(roundstarttime >= starttime)
+               starttime = roundstarttime;
+
        float countdown = (starttime - time);
        float countdown_rounded = floor(0.5 + countdown);
-       
+
        if(countdown <= 0) // countdown has finished, starttime is now
        {
                if (!spectatee_status) 
                        centerprint_generic(CPID_GAME_STARTING, _("^1Begin!"), 1, 0);
 
                Announcer_Play("begin");
-               announcer_5min = announcer_1min = FALSE; // reset maptime announcers now as well
                remove(self);
                return;
        }
        else // countdown is still going
        {
                if (!spectatee_status)
-                       centerprint_generic(CPID_GAME_STARTING, _("^1Game starts in %d seconds"), 1, countdown_rounded);
+               {
+                       if(roundstarttime == starttime)
+                               centerprint_generic(CPID_GAME_STARTING, _("^1Round starts in %d seconds"), 1, countdown_rounded);
+                       else
+                               centerprint_generic(CPID_GAME_STARTING, _("^1Game starts in %d seconds"), 1, countdown_rounded);
+               }
 
                if(countdown_rounded <= 3 && countdown_rounded >= 1) 
                        Announcer_Play(ftos(countdown_rounded));
@@ -57,12 +74,15 @@ void Announcer_Countdown()
 void Announcer_Gamestart() 
 {
        float startTime = getstatf(STAT_GAMESTARTTIME);
-       
+       float roundstarttime = getstatf(STAT_ROUNDSTARTTIME);
+       if(roundstarttime > startTime)
+               startTime = roundstarttime;
+
        if(previous_game_starttime != startTime) 
        {
                if((time + 5.0) < startTime) // if connecting to server while restart was active don't always play prepareforbattle
                        Announcer_Play("prepareforbattle");
-               
+
                if(time < startTime) 
                {
                        entity e;
index 83063cf6975bf45412e4b3cb77468f46be79c306..d84be976b0ddf282f1d45c5a8ccaee198c49b48c 100644 (file)
@@ -180,6 +180,7 @@ const float STAT_SECRETS_TOTAL = 70;
 const float STAT_SECRETS_FOUND = 71;
 
 const float STAT_RESPAWN_TIME = 72;
+const float STAT_ROUNDSTARTTIME = 73;
 
 // mod stats (1xx)
 const float STAT_REDALIVE = 100;
@@ -463,7 +464,7 @@ float CPID_CTF_CAPTURESHIELD = 2;
 float CPID_MINSTA_FINDAMMO = 3;
 float CPID_NIX_WPNCHANGE = 4;
 float CPID_DISCONNECT_IDLING = 5;
-float CPID_ROUND_STARTING = 6;
+
 float CPID_GAME_STARTING = 7;
 float CPID_TIMEOUT_COUNTDOWN = 8;
 float CPID_MOTD = 9;
index 6493069fa9518b5000347135ca71998e814994b3..fc29da99e7e716a4cae1fb192a3ed4045e39c6c4 100644 (file)
@@ -2501,6 +2501,7 @@ void PlayerPreThink (void)
        WarpZone_PlayerPhysics_FixVAngle();
 
        self.stat_game_starttime = game_starttime;
+       self.stat_round_starttime = round_starttime;
        self.stat_allow_oldnexbeam = autocvar_g_allow_oldnexbeam;
        self.stat_leadlimit = autocvar_leadlimit;
 
index 90701b588431b28b988345fcb4284a0f3b775cd9..991ad214787a071e02627d22e361545338b8b3b9 100644 (file)
@@ -500,8 +500,10 @@ string cvar_changes;
 string cvar_purechanges;
 float cvar_purechanges_count;
 
-float game_starttime; //point in time when the countdown is over
+float game_starttime; //point in time when the countdown to game start is over
+float round_starttime; //point in time when the countdown to round start is over
 .float stat_game_starttime;
+.float stat_round_starttime;
 
 .float stat_sv_airaccel_qw;
 .float stat_sv_airstrafeaccel_qw;
index 4a575e75ba9c39faa40ee9f21cd7e5c2df4411d3..bbca5e6001a3106f0b0c09dc881c56554199ce8f 100644 (file)
@@ -784,6 +784,7 @@ void spawnfunc_worldspawn (void)
        addstat(STAT_SWITCHWEAPON, AS_INT, switchweapon);
        addstat(STAT_SWITCHINGWEAPON, AS_INT, switchingweapon);
        addstat(STAT_GAMESTARTTIME, AS_FLOAT, stat_game_starttime);
+       addstat(STAT_ROUNDSTARTTIME, AS_FLOAT, stat_round_starttime);
        addstat(STAT_ALLOW_OLDNEXBEAM, AS_INT, stat_allow_oldnexbeam);
        Nagger_Init();
 
index 96d3dc896ab28dbf42735d8f03b62b39b600c9ea..0883847815cf2cb348ea7265732d2e2bab7263d4 100644 (file)
@@ -1,11 +1,10 @@
 void round_handler_Think()
 {
-       entity e;
        float f;
 
-       if(time <= game_starttime)
+       if(time < game_starttime)
        {
-               round_handler_Reset(game_starttime + 1);
+               round_handler_Reset(game_starttime);
                return;
        }
 
@@ -21,22 +20,18 @@ void round_handler_Think()
                reset_map(TRUE);
                self.wait = FALSE;
                self.cnt = self.count + 1; // init countdown
+               round_starttime = time + self.count;
        }
 
        if(self.cnt > 0) // countdown running
        {
                if(self.canRoundStart())
                {
+                       if(self.cnt == self.count + 1)
+                               round_starttime = time + self.count;
                        f = self.cnt - 1;
-                       if(f == 5) Announce("prepareforbattle");
-                       else if(f == 3) Announce("3");
-                       else if(f == 2) Announce("2");
-                       else if(f == 1) Announce("1");
-                       else if(f == 0)
+                       if(f == 0)
                        {
-                               Announce("begin");
-                               FOR_EACH_REALCLIENT(e)
-                                       Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "^1Begin!", 1, 0);
                                self.cnt = 0;
                                self.round_endtime = time + self.round_timelimit;
                                self.nextthink = time;
@@ -44,9 +39,6 @@ void round_handler_Think()
                                        self.roundStart();
                                return;
                        }
-
-                       FOR_EACH_REALCLIENT(e)
-                               Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "Round will start in %d", 1, f);
                        self.cnt = self.cnt - 1;
                }
                else
@@ -89,7 +81,10 @@ void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, v
        round_handler.wait = FALSE;
        round_handler.cnt = round_handler.count + 1;
        round_handler.round_timelimit = the_round_timelimit;
-       round_handler.nextthink = max(time, game_starttime + 1);
+       // if round_handler spawns at time 1 gamestarttime isn't initialized yet
+       //round_handler.nextthink = max(time, game_starttime + 1);
+       round_handler.nextthink = time;
+       round_starttime = time + round_handler.count;
 }
 
 float round_handler_IsActive()
@@ -119,16 +114,12 @@ float round_handler_GetTimeLeft()
 
 void round_handler_Reset(float next_think)
 {
-       entity e;
        round_handler.wait = FALSE;
        if(round_handler.count)
        if(round_handler.cnt < round_handler.count + 1)
-       {
-               FOR_EACH_REALCLIENT(e)
-                       Send_CSQC_Centerprint_Generic_Expire(e, CPID_ROUND_STARTING);
                round_handler.cnt = round_handler.count + 1;
-       }
        round_handler.nextthink = next_think;
+       round_starttime = (next_think) ? (next_think + round_handler.count) : -1;
 }
 
 void round_handler_Remove()