Merge branch 'terencehill/respawn_timer_fix' into 'master'
authorMario <zacjardine@y7mail.com>
Wed, 8 Jun 2016 08:38:41 +0000 (08:38 +0000)
committerMario <zacjardine@y7mail.com>
Wed, 8 Jun 2016 08:38:41 +0000 (08:38 +0000)
Respawn timer fix

Improve respawn timer when max respawn delay is higher than respawn delay

Example:
g_forced_respawn 1
g_respawn_delay_max 10
g_respawn_delay_small 7

* Current timer behaviour:

"You are dead, wait 10 seconds before respawning" (and counting down)
if you press the jump key after 4 seconds it changes to:
"Respawning in 6 seconds..."  (and counting down)
but you respawn when it shows:
"Respawning in 3 seconds..."

* New behaviour (fixed):

"You are dead, wait 7 seconds before respawning" (and counting down)
if you press the jump key after 4 seconds it changes to:
"Respawning in 3 seconds..."  (and counting down)
and you respawn when the countdown ends, as expected
if you let pass 7 seconds without pressing the jump key, it shows:
"Respawning in 3 seconds..." (and counting down)
and you respawn when the countdown ends, as expected

See merge request !319

qcsrc/server/cl_client.qc

index 1b40046..ad9a1ec 100644 (file)
@@ -2219,7 +2219,7 @@ void PlayerPreThink ()
                                bool button_pressed = (PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_JUMP(this) || PHYS_INPUT_BUTTON_ATCK2(this) || PHYS_INPUT_BUTTON_HOOK(this) || PHYS_INPUT_BUTTON_USE(this));
 
                                if (this.deadflag == DEAD_DYING) {
-                                       if ((this.respawn_flags & RESPAWN_FORCE) && !autocvar_g_respawn_delay_max) {
+                                       if ((this.respawn_flags & RESPAWN_FORCE) && !(this.respawn_time < this.respawn_time_max)) {
                                                this.deadflag = DEAD_RESPAWNING;
                                        } else if (!button_pressed) {
                                                this.deadflag = DEAD_DEAD;
@@ -2246,8 +2246,13 @@ void PlayerPreThink ()
 
                                if (this.respawn_flags & RESPAWN_SILENT)
                                        STAT(RESPAWN_TIME, this) = 0;
-                               else if ((this.respawn_flags & RESPAWN_FORCE) && autocvar_g_respawn_delay_max)
-                                       STAT(RESPAWN_TIME, this) = this.respawn_time_max;
+                               else if ((this.respawn_flags & RESPAWN_FORCE) && this.respawn_time < this.respawn_time_max)
+                               {
+                                       if (time < this.respawn_time)
+                                               STAT(RESPAWN_TIME, this) = this.respawn_time;
+                                       else if (this.deadflag != DEAD_RESPAWNING)
+                                               STAT(RESPAWN_TIME, this) = -this.respawn_time_max;
+                               }
                                else
                                        STAT(RESPAWN_TIME, this) = this.respawn_time;
                        }