]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add ability to reload round times cvars every round
authorterencehill <piuntn@gmail.com>
Sun, 3 Mar 2013 18:28:36 +0000 (19:28 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 3 Mar 2013 18:28:36 +0000 (19:28 +0100)
qcsrc/server/mutators/gamemode_arena.qc
qcsrc/server/mutators/gamemode_ca.qc
qcsrc/server/mutators/gamemode_freezetag.qc
qcsrc/server/round_handler.qc
qcsrc/server/round_handler.qh

index 6e4d8e39dcc47ae0ce9e93411a8e4b4056345d12..8b7c9135ad2cbe8d95ebee0e1f6c144295839f38 100644 (file)
@@ -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)
index 15ed4fa7117af4b19a4735a56612413fb051fb8f..56172096336c07803ad830808b7f9a08925f11a2 100644 (file)
@@ -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);
index 2aa7a621e9b508e5586199cd3e5a59ffcbc8dc7c..c7b5f2a898cd40d2690679cbdc078e94945de93a 100644 (file)
@@ -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;
 }
 
index f30ea02fe2dda2a8d1b663c3f434f0f0a2f32aaa..70a19f684fa0df18d6f847bc2a66a007d93b5541 100644 (file)
@@ -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;
index 1d3ea773364fa5ffc4c8cefa02065ba79029b114..d369ff9213a907bde423065a3b4cb66df31f80b6 100644 (file)
@@ -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();