From: terencehill Date: Sun, 3 Mar 2013 18:28:36 +0000 (+0100) Subject: Add ability to reload round times cvars every round X-Git-Tag: xonotic-v0.7.0~61^2~34 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=db50aba615d33214f6a6661cc5c762d68f92e344;p=xonotic%2Fxonotic-data.pk3dir.git Add ability to reload round times cvars every round --- diff --git a/qcsrc/server/mutators/gamemode_arena.qc b/qcsrc/server/mutators/gamemode_arena.qc index 6e4d8e39d..8b7c9135a 100644 --- a/qcsrc/server/mutators/gamemode_arena.qc +++ b/qcsrc/server/mutators/gamemode_arena.qc @@ -65,6 +65,7 @@ float Arena_CheckWinner() FOR_EACH_REALCLIENT(e) centerprint(e, "Round over, there's no winner"); bprint("Round over, there's no winner\n"); + round_handler_Init(5, autocvar_g_arena_warmup, autocvar_g_arena_round_timelimit); return 1; } @@ -92,6 +93,7 @@ float Arena_CheckWinner() centerprint(e, "Round tied"); bprint("Round tied\n"); } + round_handler_Init(5, autocvar_g_arena_warmup, autocvar_g_arena_round_timelimit); return 1; } @@ -255,7 +257,10 @@ void arena_Initialize() maxspawned = max(2, autocvar_g_arena_maxspawned); arena_roundbased = autocvar_g_arena_roundbased; if(arena_roundbased) - round_handler_Spawn(Arena_CheckPlayers, Arena_CheckWinner, Arena_RoundStart, 5, autocvar_g_arena_warmup, autocvar_g_arena_round_timelimit); + { + round_handler_Spawn(Arena_CheckPlayers, Arena_CheckWinner, Arena_RoundStart); + round_handler_Init(5, autocvar_g_arena_warmup, autocvar_g_arena_round_timelimit); + } } MUTATOR_DEFINITION(gamemode_arena) diff --git a/qcsrc/server/mutators/gamemode_ca.qc b/qcsrc/server/mutators/gamemode_ca.qc index 15ed4fa71..561720963 100644 --- a/qcsrc/server/mutators/gamemode_ca.qc +++ b/qcsrc/server/mutators/gamemode_ca.qc @@ -74,6 +74,7 @@ float CA_CheckWinner() centerprint(e, "Round over, there's no winner"); bprint("Round over, there's no winner.\n"); allowed_to_spawn = FALSE; + round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit); return 1; } @@ -100,6 +101,7 @@ float CA_CheckWinner() } allowed_to_spawn = FALSE; + round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit); return 1; } @@ -238,7 +240,8 @@ void ca_Initialize() { allowed_to_spawn = TRUE; - round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, CA_RoundStart, 5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit); + round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, CA_RoundStart); + round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit); addstat(STAT_REDALIVE, AS_INT, redalive_stat); addstat(STAT_BLUEALIVE, AS_INT, bluealive_stat); diff --git a/qcsrc/server/mutators/gamemode_freezetag.qc b/qcsrc/server/mutators/gamemode_freezetag.qc index 2aa7a621e..c7b5f2a89 100644 --- a/qcsrc/server/mutators/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/gamemode_freezetag.qc @@ -13,7 +13,8 @@ void freezetag_Initialize() precache_model("models/ice/ice.md3"); ScoreRules_freezetag(); - round_handler_Spawn(freezetag_CheckTeams, freezetag_CheckWinner, func_null, 5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit); + round_handler_Spawn(freezetag_CheckTeams, freezetag_CheckWinner, func_null); + round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit); addstat(STAT_REDALIVE, AS_INT, redalive_stat); addstat(STAT_BLUEALIVE, AS_INT, bluealive_stat); @@ -127,6 +128,7 @@ float freezetag_CheckWinner() bprint("Round over, there's no winner.\n"); FOR_EACH_PLAYER(e) e.freezetag_frozen_timeout = 0; + round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit); return 1; } @@ -153,6 +155,7 @@ float freezetag_CheckWinner() FOR_EACH_PLAYER(e) e.freezetag_frozen_timeout = 0; + round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit); return 1; } diff --git a/qcsrc/server/round_handler.qc b/qcsrc/server/round_handler.qc index f30ea02fe..70a19f684 100644 --- a/qcsrc/server/round_handler.qc +++ b/qcsrc/server/round_handler.qc @@ -62,7 +62,14 @@ void round_handler_Think() } } -void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, void() roundStart_func, float the_delay, float the_count, float the_round_timelimit) +void round_handler_Init(float the_delay, float the_count, float the_round_timelimit) +{ + round_handler.delay = (the_delay > 0) ? the_delay : 0; + round_handler.count = fabs(floor(the_count)); + round_handler.round_timelimit = max(10, the_round_timelimit); +} + +void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, void() roundStart_func) { if(round_handler) { @@ -76,11 +83,9 @@ void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, v round_handler.canRoundStart = canRoundStart_func; round_handler.canRoundEnd = canRoundEnd_func; round_handler.roundStart = roundStart_func; - round_handler.delay = (the_delay > 0) ? the_delay : 0; - round_handler.count = fabs(floor(the_count)); round_handler.wait = FALSE; + round_handler_Init(5, 5, 180); round_handler.cnt = round_handler.count + 1; - round_handler.round_timelimit = the_round_timelimit; // if round_handler spawns at time 1 gamestarttime isn't initialized yet //round_handler.nextthink = max(time, game_starttime + 1); round_handler.nextthink = time; diff --git a/qcsrc/server/round_handler.qh b/qcsrc/server/round_handler.qh index 1d3ea7733..d369ff921 100644 --- a/qcsrc/server/round_handler.qh +++ b/qcsrc/server/round_handler.qh @@ -10,7 +10,8 @@ entity round_handler; .float() canRoundEnd; .void() roundStart; -void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, void() roundStart_func, float the_delay, float the_count, float the_round_timelimit); +void round_handler_Init(float the_delay, float the_count, float the_round_timelimit); +void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, void() roundStart_func); float round_handler_IsActive(); float round_handler_AwaitingNextRound(); float round_handler_CountdownRunning();