]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
GameRules: initialize as early as possible 472/head
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 27 Aug 2017 10:11:26 +0000 (20:11 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 27 Aug 2017 10:11:26 +0000 (20:11 +1000)
18 files changed:
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qh
qcsrc/server/mutators/mutator/gamemode_assault.qc
qcsrc/server/mutators/mutator/gamemode_assault.qh
qcsrc/server/mutators/mutator/gamemode_ca.qh
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qh
qcsrc/server/mutators/mutator/gamemode_domination.qh
qcsrc/server/mutators/mutator/gamemode_freezetag.qh
qcsrc/server/mutators/mutator/gamemode_invasion.qh
qcsrc/server/mutators/mutator/gamemode_keepaway.qc
qcsrc/server/mutators/mutator/gamemode_keepaway.qh
qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
qcsrc/server/mutators/mutator/gamemode_keyhunt.qh
qcsrc/server/mutators/mutator/gamemode_lms.qc
qcsrc/server/mutators/mutator/gamemode_lms.qh
qcsrc/server/mutators/mutator/gamemode_race.qh
qcsrc/server/mutators/mutator/gamemode_tdm.qh

index 4f8d6b55922b38e7cc467781d40b8700c8dda2a0..5a0ff2a2c22ade90150d22cad3fbcfdb8be07f3b 100644 (file)
@@ -71,7 +71,7 @@ float OtherTeam(float t)  //works only if there are two teams on the map!
        return e.team;
 }
 
-const float ST_NEXBALL_GOALS = 1;
+const int ST_NEXBALL_GOALS = 1;
 void nb_ScoreRules(int teams)
 {
     GameRules_scoring(teams, 0, 0, {
index c1cce29be7ec8b7bf051e8b49577e9600f99bd25..5c7fd469735b1e38cad2abdf8e11165d9ffb3d66 100644 (file)
@@ -8,10 +8,10 @@ REGISTER_MUTATOR(ons, false)
     MUTATOR_STATIC();
        MUTATOR_ONADD
        {
-               ons_Initialize();
-
                GameRules_teams(true);
                GameRules_limit_score(autocvar_g_onslaught_point_limit);
+
+               ons_Initialize();
        }
        return false;
 }
index e839546d8dbe34390e5fa171f40bd54b442492b2..affa033de1da73e3082bd12b1c8925cf7ac85330 100644 (file)
@@ -614,13 +614,3 @@ MUTATOR_HOOKFUNCTION(as, ReadyRestart_Deny)
        // readyrestart not supported (yet)
        return true;
 }
-
-// scoreboard setup
-void assault_ScoreRules()
-{
-       int teams = BITS(2); // always red vs blue
-    GameRules_scoring(teams, SFL_SORT_PRIO_SECONDARY, SFL_SORT_PRIO_SECONDARY, {
-        field_team(ST_ASSAULT_OBJECTIVES, "objectives", SFL_SORT_PRIO_PRIMARY);
-        field(SP_ASSAULT_OBJECTIVES, "objectives", SFL_SORT_PRIO_PRIMARY);
-    });
-}
index 0e279b8dc6254fa9d3b0122b0997db9d9a96471c..f437d98b52c837c6db59520c37d840660ece1003 100644 (file)
@@ -2,7 +2,7 @@
 
 #include "../gamemode.qh"
 
-void assault_ScoreRules();
+const int ST_ASSAULT_OBJECTIVES = 1;
 
 REGISTER_MUTATOR(as, false)
 {
@@ -10,7 +10,11 @@ REGISTER_MUTATOR(as, false)
        MUTATOR_ONADD
        {
         GameRules_teams(true);
-               assault_ScoreRules();
+        int teams = BITS(2); // always red vs blue
+        GameRules_scoring(teams, SFL_SORT_PRIO_SECONDARY, SFL_SORT_PRIO_SECONDARY, {
+            field_team(ST_ASSAULT_OBJECTIVES, "objectives", SFL_SORT_PRIO_PRIMARY);
+            field(SP_ASSAULT_OBJECTIVES, "objectives", SFL_SORT_PRIO_PRIMARY);
+        });
        }
        return 0;
 }
@@ -38,8 +42,5 @@ void(entity bot) havocbot_ast_reset_role;
 void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_items;
 void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplayers;
 
-// scoreboard stuff
-const float ST_ASSAULT_OBJECTIVES = 1;
-
 // predefined spawnfuncs
 void target_objective_decrease_activate(entity this);
index bf4a453a3bf9d4fadbce34403be210ff8c3773c0..0982fcca8fb35e34fd71152cc81815b0282f6b7a 100644 (file)
@@ -26,7 +26,10 @@ REGISTER_MUTATOR(ca, false)
     MUTATOR_STATIC();
        MUTATOR_ONADD
        {
-               allowed_to_spawn = true;
+               GameRules_teams(true);
+        GameRules_spawning_teams(autocvar_g_ca_team_spawns);
+        GameRules_limit_score(autocvar_g_ca_point_limit);
+        GameRules_limit_lead(autocvar_g_ca_point_leadlimit);
 
                ca_teams = autocvar_g_ca_teams_override;
                if (ca_teams < 2)
@@ -37,16 +40,10 @@ REGISTER_MUTATOR(ca, false)
             field_team(ST_CA_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY);
         });
 
+               allowed_to_spawn = true;
                round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, CA_RoundStart);
                round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
-
                EliminatedPlayers_Init(ca_isEliminated);
-
-               GameRules_teams(true);
-        GameRules_limit_score(autocvar_g_ca_point_limit);
-        GameRules_limit_lead(autocvar_g_ca_point_leadlimit);
-
-        GameRules_spawning_teams(autocvar_g_ca_team_spawns);
        }
        return 0;
 }
index 8e11e1d7890d61cfe3e53b0b40e9bf1abb2e6fd8..3cf560ebedf752c3fc99b33cfc2aa3248bcaad2b 100644 (file)
@@ -1,28 +1,8 @@
 #include "gamemode_ctf.qh"
 
-#ifndef CSQC
 #include <common/effects/all.qh>
-void ctf_Initialize();
-
-REGISTER_MUTATOR(ctf, false)
-{
-    MUTATOR_STATIC();
-       MUTATOR_ONADD
-       {
-               ctf_Initialize();
-
-               GameRules_teams(true);
-        GameRules_limit_score(autocvar_capturelimit_override);
-        GameRules_limit_lead(autocvar_captureleadlimit_override);
-       }
-       return 0;
-}
-#endif
-
-#ifdef SVQC
 #include <common/vehicles/all.qh>
 #include <server/teamplay.qh>
-#endif
 
 #include <lib/warpzone/common.qh>
 
index 8ef860846e45d08077bbcc14259f77484dab207c..0b86a57f809936604fd51a5514b899108558dcac 100644 (file)
@@ -3,6 +3,23 @@
 #ifdef SVQC
 
 #include "../gamemode.qh"
+
+void ctf_Initialize();
+
+REGISTER_MUTATOR(ctf, false)
+{
+    MUTATOR_STATIC();
+    MUTATOR_ONADD
+    {
+        GameRules_teams(true);
+        GameRules_limit_score(autocvar_capturelimit_override);
+        GameRules_limit_lead(autocvar_captureleadlimit_override);
+
+        ctf_Initialize();
+    }
+    return 0;
+}
+
 // used in cheats.qc
 void ctf_RespawnFlag(entity flag);
 
index 8b4ca399bae9de5a5e0c200d4d934448f9db0b7d..cf5e54f6d53d00946779e981aee6db592cc83c0e 100644 (file)
@@ -14,8 +14,6 @@ REGISTER_MUTATOR(dom, false)
     MUTATOR_STATIC();
        MUTATOR_ONADD
        {
-               dom_Initialize();
-
                int fraglimit_override = autocvar_g_domination_point_limit;
                if (autocvar_g_domination_roundbased && autocvar_g_domination_roundbased_point_limit)
                        fraglimit_override = autocvar_g_domination_roundbased_point_limit;
@@ -23,6 +21,8 @@ REGISTER_MUTATOR(dom, false)
                GameRules_teams(true);
         GameRules_limit_score(fraglimit_override);
         GameRules_limit_lead(autocvar_g_domination_point_leadlimit);
+
+               dom_Initialize();
        }
        return 0;
 }
index b84a62201dc3fe100bdbb40773c7226bb6218548..a258d82eab508576040c5e27f1b8431657772d8b 100644 (file)
@@ -12,13 +12,12 @@ REGISTER_MUTATOR(ft, false)
     MUTATOR_STATIC();
        MUTATOR_ONADD
        {
-               freezetag_Initialize();
-
                GameRules_teams(true);
+        GameRules_spawning_teams(autocvar_g_freezetag_team_spawns);
         GameRules_limit_score(autocvar_g_freezetag_point_limit);
         GameRules_limit_lead(autocvar_g_freezetag_point_leadlimit);
 
-        GameRules_spawning_teams(autocvar_g_freezetag_team_spawns);
+               freezetag_Initialize();
        }
        return 0;
 }
index e902b5ee60e5b9465449f77c3a193836e4a7cd0f..0ea0e82c4c8266ad31bff1db48f2ceeb6be03416 100644 (file)
@@ -14,18 +14,15 @@ REGISTER_MUTATOR(inv, false)
     MUTATOR_STATIC();
        MUTATOR_ONADD
        {
-               g_invasion = true;
-               invasion_Initialize();
-
-               cvar_settemp("g_monsters", "1");
-
-        GameRules_limit_score(autocvar_g_invasion_point_limit);
-
-               if (autocvar_g_invasion_teams >= 2)
-               {
+               if (autocvar_g_invasion_teams >= 2) {
                        GameRules_teams(true);
                        GameRules_spawning_teams(autocvar_g_invasion_team_spawns);
                }
+        GameRules_limit_score(autocvar_g_invasion_point_limit);
+
+               g_invasion = true;
+               cvar_settemp("g_monsters", "1");
+               invasion_Initialize();
        }
        return 0;
 }
index 727324268d3e890b245d5ae907792f9b618af611..7b33bea6f374dd585755e6a31f572830b514b73d 100644 (file)
@@ -472,10 +472,5 @@ void ka_SpawnBall() // loads various values for the ball, runs only once at star
 
 void ka_Initialize() // run at the start of a match, initiates game mode
 {
-       GameRules_scoring(0, SFL_SORT_PRIO_PRIMARY, 0, {
-        field(SP_KEEPAWAY_PICKUPS, "pickups", 0);
-        field(SP_KEEPAWAY_CARRIERKILLS, "bckills", 0);
-        field(SP_KEEPAWAY_BCTIME, "bctime", SFL_SORT_PRIO_SECONDARY);
-    });
        ka_SpawnBall();
 }
index 21cc3e46d3b62cc90dc610b7dc9bd71da1bf519c..abbabbd5bbf16202cc68a23ab69d5fc65af4a584 100644 (file)
@@ -9,6 +9,12 @@ REGISTER_MUTATOR(ka, false)
     MUTATOR_STATIC();
        MUTATOR_ONADD
        {
+           GameRules_scoring(0, SFL_SORT_PRIO_PRIMARY, 0, {
+            field(SP_KEEPAWAY_PICKUPS, "pickups", 0);
+            field(SP_KEEPAWAY_CARRIERKILLS, "bckills", 0);
+            field(SP_KEEPAWAY_BCTIME, "bctime", SFL_SORT_PRIO_SECONDARY);
+        });
+
                ka_Initialize();
        }
        return false;
index 864290301dc6c4d2a52cf0f4b1010077ec5b5516..15b6e0f4a6251d81a94d9501858abca0ee0ae602 100644 (file)
@@ -85,7 +85,7 @@ int kh_key_dropped, kh_key_carried;
 
 int kh_Key_AllOwnedByWhichTeam();
 
-const float ST_KH_CAPS = 1;
+const int ST_KH_CAPS = 1;
 void kh_ScoreRules(int teams)
 {
        GameRules_scoring(teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, {
index 9e8ded5ac875095bb5ed8c7117c5a41160b9948f..77d7c06fcf055fa1e5d83da36767e23a10688746 100644 (file)
@@ -12,12 +12,12 @@ REGISTER_MUTATOR(kh, false)
     MUTATOR_STATIC();
        MUTATOR_ONADD
        {
-               kh_Initialize();
-
                GameRules_teams(true);
+        GameRules_spawning_teams(autocvar_g_keyhunt_team_spawns);
         GameRules_limit_score(autocvar_g_keyhunt_point_limit);
         GameRules_limit_lead(autocvar_g_keyhunt_point_leadlimit);
-        GameRules_spawning_teams(autocvar_g_keyhunt_team_spawns);
+
+               kh_Initialize();
        }
        return 0;
 }
index 354c1e15f4637d221058b1fbb6891998e1b0dcda..4d6f70438583b0f805b40070754e303b1a3f4726 100644 (file)
@@ -419,19 +419,7 @@ MUTATOR_HOOKFUNCTION(lms, AddPlayerScore)
                return true; // allow writing to this field in intermission as it is needed for newly joining players
 }
 
-// scoreboard stuff
-void lms_ScoreRules()
-{
-    GameRules_score_enabled(false);
-       GameRules_scoring(0, 0, 0, {
-        field(SP_LMS_LIVES, "lives", SFL_SORT_PRIO_SECONDARY);
-        field(SP_LMS_RANK, "rank", SFL_LOWER_IS_BETTER | SFL_RANK | SFL_SORT_PRIO_PRIMARY | SFL_ALLOW_HIDE);
-       });
-}
-
 void lms_Initialize()
 {
        lms_lowest_lives = 9999;
-
-       lms_ScoreRules();
 }
index 303dd3bd2f52993d75130d3c7b10c4c07594bff5..c69113a0c2188b0d711d19cf4f52f875b7456427 100644 (file)
@@ -11,10 +11,15 @@ REGISTER_MUTATOR(lms, false)
     MUTATOR_STATIC();
        MUTATOR_ONADD
        {
-               lms_Initialize();
-
         GameRules_limit_score(((!autocvar_g_lms_lives_override) ? -1 : autocvar_g_lms_lives_override));
         GameRules_limit_lead(0);
+        GameRules_score_enabled(false);
+        GameRules_scoring(0, 0, 0, {
+            field(SP_LMS_LIVES, "lives", SFL_SORT_PRIO_SECONDARY);
+            field(SP_LMS_RANK, "rank", SFL_LOWER_IS_BETTER | SFL_RANK | SFL_SORT_PRIO_PRIMARY | SFL_ALLOW_HIDE);
+        });
+
+               lms_Initialize();
        }
        return 0;
 }
index c1b700442fa13912c1e6075fbf48edb2a0be6849..1e475e3ce6f76988ba28f50f1e74e6afb92049de 100644 (file)
@@ -11,6 +11,7 @@ REGISTER_MUTATOR(rc, false)
        MUTATOR_ONADD
        {
                rc_SetLimits();
+
                race_Initialize();
        }
        return 0;
index 28331dfefc625f1278d33dad334600a6cf44a8a6..c163962faf1b71c1cad060af1b9d7f8554ffec02 100644 (file)
@@ -12,12 +12,12 @@ REGISTER_MUTATOR(tdm, false)
     MUTATOR_STATIC();
        MUTATOR_ONADD
        {
-               InitializeEntity(NULL, tdm_DelayedInit, INITPRIO_GAMETYPE);
-
                GameRules_teams(true);
+        GameRules_spawning_teams(autocvar_g_tdm_team_spawns);
                GameRules_limit_score(autocvar_g_tdm_point_limit);
         GameRules_limit_lead(autocvar_g_tdm_point_leadlimit);
-        GameRules_spawning_teams(autocvar_g_tdm_team_spawns);
+
+               InitializeEntity(NULL, tdm_DelayedInit, INITPRIO_GAMETYPE);
        }
        return 0;
 }