From 622636b5e63aa636416631828ec407cba6863cf5 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 9 Mar 2013 17:13:18 +0100 Subject: [PATCH] Fix other round countdown issues by improving workaround for uninitialized game_starttime in round_handler --- qcsrc/server/command/cmd.qc | 2 +- qcsrc/server/command/vote.qc | 2 +- qcsrc/server/round_handler.qc | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 4cb665089..0d7733687 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -195,7 +195,7 @@ void ClientCommand_ready(float request) // todo: anti-spam for toggling readynes { if(!readyrestart_happened || autocvar_sv_ready_restart_repeatable) { - if(time < game_starttime + 1) // game is already restarting + if(time < game_starttime) // game is already restarting return; if (self.ready) // toggle { diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 507fcfe28..a296c7a1d 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -326,7 +326,7 @@ void reset_map(float dorespawn) oldself = self; if(time <= game_starttime && round_handler_IsActive()) - round_handler_Reset(game_starttime + 1); + round_handler_Reset(game_starttime); if(g_race || g_cts) race_ReadyRestart(); diff --git a/qcsrc/server/round_handler.qc b/qcsrc/server/round_handler.qc index 15c0c4924..65de5b44f 100644 --- a/qcsrc/server/round_handler.qc +++ b/qcsrc/server/round_handler.qc @@ -2,12 +2,6 @@ void round_handler_Think() { float f; - if(time < game_starttime) - { - round_handler_Reset(game_starttime); - return; - } - if(gameover) { round_handler_Reset(0); @@ -70,6 +64,15 @@ void round_handler_Init(float the_delay, float the_count, float the_round_timeli round_handler.round_timelimit = max(10, the_round_timelimit); } +// NOTE: this is only needed because if round_handler spawns at time 1 +// gamestarttime isn't initialized yet +void round_handler_FirstThink() +{ + round_starttime = max(time, game_starttime) + round_handler.count; + round_handler.think = round_handler_Think; + round_handler.nextthink = max(time, game_starttime); +} + void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, void() roundStart_func) { if(round_handler) @@ -80,16 +83,13 @@ void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, v round_handler = spawn(); round_handler.classname = "round_handler"; - round_handler.think = round_handler_Think; + round_handler.think = round_handler_FirstThink; round_handler.canRoundStart = canRoundStart_func; round_handler.canRoundEnd = canRoundEnd_func; round_handler.roundStart = roundStart_func; round_handler.wait = FALSE; round_handler_Init(5, 5, 180); - // 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; } void round_handler_Reset(float next_think) -- 2.39.2