]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add roundStart function to round_handler, useful in Arena and CA
authorterencehill <piuntn@gmail.com>
Wed, 2 Jan 2013 23:19:24 +0000 (00:19 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 21 Jan 2013 18:50:27 +0000 (19:50 +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 352f342f7b73b4c8b4d94a09def7b6f7a62819be..21576bdf6038bc5b08b969d7577c15810c6e88c0 100644 (file)
@@ -51,10 +51,6 @@ float Arena_CheckWinner()
 {
        entity e;
 
-       // FIXME do this only once (on round start)
-       FOR_EACH_PLAYER(e)
-               e.player_blocked = 0;
-
        if(round_handler_GetTimeLeft() <= 0)
        {
                FOR_EACH_REALCLIENT(e)
@@ -89,6 +85,7 @@ float Arena_CheckWinner()
        }
        return 1;
 }
+
 void Arena_AddChallengers()
 {
        entity e;
@@ -136,6 +133,13 @@ float Arena_CheckPlayers()
        return 0;
 }
 
+void Arena_RoundStart()
+{
+       entity e;
+       FOR_EACH_PLAYER(e)
+               e.player_blocked = 0;
+}
+
 MUTATOR_HOOKFUNCTION(arena_ClientDisconnect)
 {
        Spawnqueue_Unmark(self);
@@ -232,7 +236,7 @@ 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, 5, autocvar_g_arena_warmup, autocvar_g_arena_round_timelimit);
+               round_handler_Spawn(Arena_CheckPlayers, Arena_CheckWinner, Arena_RoundStart, 5, autocvar_g_arena_warmup, autocvar_g_arena_round_timelimit);
 }
 
 MUTATOR_DEFINITION(gamemode_arena)
index 330659572f6bcd3b289bee4bc7abb0d9dc6d5515..d8ecf4c481a9220132d0f03d8f3bf873b2e54749 100644 (file)
@@ -69,11 +69,6 @@ float CA_CheckWinner()
                return 1;
        }
 
-       if(inWarmupStage)
-               allowed_to_spawn = TRUE;
-       else
-               allowed_to_spawn = FALSE;
-
        CA_count_alive_players();
        if(CA_ALIVE_TEAMS() > 1)
                return 0;
@@ -100,6 +95,14 @@ float CA_CheckWinner()
        return 1;
 }
 
+void CA_RoundStart()
+{
+       if(inWarmupStage)
+               allowed_to_spawn = TRUE;
+       else
+               allowed_to_spawn = FALSE;
+}
+
 float prev_total_players;
 float CA_CheckTeams()
 {
@@ -206,7 +209,7 @@ void ca_Initialize()
 {
        allowed_to_spawn = TRUE;
 
-       round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, 5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
+       round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, CA_RoundStart, 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 f2e624c56325826affe75d0f4420d4ef43b71c48..42c6b04ddda491dd3350a6d1bc3e2d76bb6baed5 100644 (file)
@@ -6,7 +6,7 @@ void freezetag_Initialize()
        precache_model("models/ice/ice.md3");
        ScoreRules_freezetag();
 
-       round_handler_Spawn(freezetag_CheckTeams, freezetag_CheckWinner, 5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
+       round_handler_Spawn(freezetag_CheckTeams, freezetag_CheckWinner, func_null, 5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
 
        addstat(STAT_REDALIVE, AS_INT, redalive_stat);
        addstat(STAT_BLUEALIVE, AS_INT, bluealive_stat);
index 5fbe24ead3f83b171fa6d07489a2d4f107eb225d..d94d9b9cd4104a307c896cfdf1e91d953097f6f7 100644 (file)
@@ -40,6 +40,8 @@ void round_handler_Think()
                                self.cnt = 0;
                                self.round_endtime = time + self.round_timelimit;
                                self.nextthink = time;
+                               if(self.roundStart != func_null)
+                                       self.roundStart();
                                return;
                        }
 
@@ -68,7 +70,7 @@ void round_handler_Think()
        }
 }
 
-void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, float the_delay, float the_count, float the_round_timelimit)
+void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, void() roundStart_func, float the_delay, float the_count, float the_round_timelimit)
 {
        if(round_handler)
        {
@@ -81,6 +83,7 @@ void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, f
        round_handler.think = round_handler_Think;
        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;
index 3ab61bc3e2763baf3189ef0459c9f2fdb2f30224..1d3ea773364fa5ffc4c8cefa02065ba79029b114 100644 (file)
@@ -8,8 +8,9 @@ entity round_handler;
 .float round_endtime;
 .float() canRoundStart;
 .float() canRoundEnd;
+.void() roundStart;
 
-void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, float the_delay, float the_count, float the_round_timelimit);
+void round_handler_Spawn(float() canRoundStart_func, float() canRoundEnd_func, void() roundStart_func, float the_delay, float the_count, float the_round_timelimit);
 float round_handler_IsActive();
 float round_handler_AwaitingNextRound();
 float round_handler_CountdownRunning();