]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Gametypes: invert control
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 18 Oct 2015 05:28:48 +0000 (16:28 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 18 Oct 2015 05:28:48 +0000 (16:28 +1100)
20 files changed:
qcsrc/common/mapinfo.qc
qcsrc/common/mutators/base.qh
qcsrc/server/mutators/all.qc
qcsrc/server/mutators/all.qh
qcsrc/server/mutators/mutator/gamemode_assault.qc
qcsrc/server/mutators/mutator/gamemode_ca.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_cts.qc
qcsrc/server/mutators/mutator/gamemode_deathmatch.qc
qcsrc/server/mutators/mutator/gamemode_domination.qc
qcsrc/server/mutators/mutator/gamemode_freezetag.qc
qcsrc/server/mutators/mutator/gamemode_invasion.qc
qcsrc/server/mutators/mutator/gamemode_keepaway.qc
qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
qcsrc/server/mutators/mutator/gamemode_lms.qc
qcsrc/server/mutators/mutator/gamemode_onslaught.qc
qcsrc/server/mutators/mutator/gamemode_race.qc
qcsrc/server/mutators/mutator/gamemode_tdm.qc
qcsrc/server/race.qh
qcsrc/server/teamplay.qh

index 46c2edc9e32e0da36780b0065d694a97eed3f955..2faf4b7ec9518f0a51bc0c5f3a2ff2d7fe98e712 100644 (file)
@@ -640,10 +640,12 @@ void _MapInfo_Map_ApplyGametypeEx(string s, int pWantedType, int pThisType)
                        case "timelimit":
                        {
                                cvar_set("timelimit", v);
+                               break;
                        }
                        case "leadlimit":
                        {
                                cvar_set("leadlimit", v);
+                               break;
                        }
                        case "pointlimit":
                        case "fraglimit":
@@ -652,15 +654,18 @@ void _MapInfo_Map_ApplyGametypeEx(string s, int pWantedType, int pThisType)
                        case "caplimit":
                        {
                                fraglimit_normal = v;
+                               break;
                        }
                        case "teampointlimit":
                        case "teamlaplimit":
                        {
                                fraglimit_teams = v;
+                               break;
                        }
                        default:
                        {
                            handled = false;
+                           break;
                        }
                }
                FOREACH(Gametypes, true, LAMBDA(handled |= it.m_parse_mapinfo(k, v)));
index 07620bd4458d759946c0d0cfca9b622c11d36171..ce98cd508e90a9fe0314e70d1baaa09a0cecc8e8 100644 (file)
@@ -144,12 +144,12 @@ typedef bool(int) mutatorfunc_t;
 
 CLASS(Mutator, Object)
     ATTRIB(Mutator, m_id, int, 0)
-    ATTRIB(Mutator, mutatorname, string, string_null)
+    ATTRIB(Mutator, m_name, string, string_null)
     ATTRIB(Mutator, mutatorfunc, mutatorfunc_t, func_null)
     ATTRIB(Mutator, mutatorcheck, bool(), func_null)
     CONSTRUCTOR(Mutator, string _name, mutatorfunc_t func) {
         CONSTRUCT(Mutator);
-        this.mutatorname = _name;
+        this.m_name = _name;
         this.mutatorfunc = func;
     }
 ENDCLASS(Mutator)
index 7ad372629965f9685c06ef5ecd9cdd656b725ac3..0e73189074722ce4450ddcf5c57df2653cba478b 100644 (file)
 
 #include "all.qh"
 
-#include "mutator.qh"
-#include "gamemode.qh"
+STATIC_INIT_LATE(Gametype) {
+    string s = GetGametype();
+    FOREACH(Mutators, it.m_name == s, LAMBDA(Mutator_Add(it); break));
+}
 
 #define IMPLEMENTATION
 #include "all.inc"
index ad4a5b9f5e66e46df335664d8b002941287651ba..e586ec74e925a77d8d614048bf2936b0c27a0cda 100644 (file)
@@ -1,3 +1,6 @@
+#include "mutator.qh"
+#include "gamemode.qh"
+
 #ifndef SERVER_MUTATORS_H
 #define SERVER_MUTATORS_H
 
index 52fb40fea57189f5b01e222f08d7b3ae5754456f..fdc26626591835ca51246ecaad36d79b897bde75 100644 (file)
@@ -1,6 +1,36 @@
 #ifndef GAMEMODE_ASSAULT_H
 #define GAMEMODE_ASSAULT_H
 
+void assault_ScoreRules();
+
+REGISTER_MUTATOR(as, false)
+{
+       ActivateTeamplay();
+       have_team_spawns = -1; // request team spawns
+
+       MUTATOR_ONADD
+       {
+               if (time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");
+               assault_ScoreRules();
+       }
+
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               // we actually cannot roll back assault_Initialize here
+               // BUT: we don't need to! If this gets called, adding always
+               // succeeds.
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
+               return -1;
+       }
+
+       return 0;
+}
+
 // sprites
 .entity assault_decreaser;
 .entity assault_sprite;
@@ -641,31 +671,4 @@ void assault_ScoreRules()
        ScoreRules_basics_end();
 }
 
-REGISTER_MUTATOR(as, g_assault)
-{
-       ActivateTeamplay();
-       have_team_spawns = -1; // request team spawns
-
-       MUTATOR_ONADD
-       {
-               if(time > 1) // game loads at time 1
-                       error("This is a game type and it cannot be added at runtime.");
-               assault_ScoreRules();
-       }
-
-       MUTATOR_ONROLLBACK_OR_REMOVE
-       {
-               // we actually cannot roll back assault_Initialize here
-               // BUT: we don't need to! If this gets called, adding always
-               // succeeds.
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               LOG_INFO("This is a game type and it cannot be removed at runtime.");
-               return -1;
-       }
-
-       return 0;
-}
 #endif
index 20330b7579133e14cd3dac28ab0c0c16e9b36b0e..88e56bb9d208fc8ce49d397c7341d2c86a9d8dab 100644 (file)
@@ -1,19 +1,46 @@
 #ifndef GAMEMODE_CA_H
 #define GAMEMODE_CA_H
 
+int autocvar_g_ca_point_limit;
+int autocvar_g_ca_point_leadlimit;
+bool autocvar_g_ca_team_spawns;
+
+void ca_Initialize();
+
+REGISTER_MUTATOR(ca, false)
+{
+       ActivateTeamplay();
+       SetLimits(autocvar_g_ca_point_limit, autocvar_g_ca_point_leadlimit, -1, -1);
+
+       if (autocvar_g_ca_team_spawns)
+               have_team_spawns = -1; // request team spawns
+
+       MUTATOR_ONADD
+       {
+               if (time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");
+               ca_Initialize();
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
+               return -1;
+       }
+
+       return 0;
+}
+
 // should be removed in the future, as other code should not have to care
 .float caplayer; // 0.5 if scheduled to join the next round
 #endif
 
 #ifdef IMPLEMENTATION
 float autocvar_g_ca_damage2score_multiplier;
-int autocvar_g_ca_point_leadlimit;
-int autocvar_g_ca_point_limit;
 float autocvar_g_ca_round_timelimit;
 bool autocvar_g_ca_spectate_enemies;
 int autocvar_g_ca_teams;
 int autocvar_g_ca_teams_override;
-bool autocvar_g_ca_team_spawns;
 float autocvar_g_ca_warmup;
 
 float ca_teams;
@@ -503,27 +530,4 @@ void ca_Initialize()
        EliminatedPlayers_Init(ca_isEliminated);
 }
 
-REGISTER_MUTATOR(ca, g_ca)
-{
-       ActivateTeamplay();
-       SetLimits(autocvar_g_ca_point_limit, autocvar_g_ca_point_leadlimit, -1, -1);
-
-       if(autocvar_g_ca_team_spawns)
-               have_team_spawns = -1; // request team spawns
-
-       MUTATOR_ONADD
-       {
-               if(time > 1) // game loads at time 1
-                       error("This is a game type and it cannot be added at runtime.");
-               ca_Initialize();
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               LOG_INFO("This is a game type and it cannot be removed at runtime.");
-               return -1;
-       }
-
-       return 0;
-}
 #endif
index e2eb898effb6d5fa6bd80504fd71ac343545350b..73e992c95b0d54c862dbd61dd9037a7564ad70d0 100644 (file)
@@ -1,6 +1,39 @@
 #ifndef GAMEMODE_CTF_H
 #define GAMEMODE_CTF_H
 
+#ifndef CSQC
+void ctf_Initialize();
+
+REGISTER_MUTATOR(ctf, false)
+{
+       ActivateTeamplay();
+       SetLimits(autocvar_capturelimit_override, -1, autocvar_captureleadlimit_override, -1);
+       have_team_spawns = -1; // request team spawns
+
+       MUTATOR_ONADD
+       {
+               if (time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");
+               ctf_Initialize();
+       }
+
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               // we actually cannot roll back ctf_Initialize here
+               // BUT: we don't need to! If this gets called, adding always
+               // succeeds.
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
+               return -1;
+       }
+
+       return 0;
+}
+#endif
+
 #ifdef SVQC
 // used in cheats.qc
 void ctf_RespawnFlag(entity flag);
@@ -2741,32 +2774,4 @@ void ctf_Initialize()
        InitializeEntity(world, ctf_DelayedInit, INITPRIO_GAMETYPE);
 }
 
-REGISTER_MUTATOR(ctf, g_ctf)
-{
-       ActivateTeamplay();
-       SetLimits(autocvar_capturelimit_override, -1, autocvar_captureleadlimit_override, -1);
-       have_team_spawns = -1; // request team spawns
-
-       MUTATOR_ONADD
-       {
-               if(time > 1) // game loads at time 1
-                       error("This is a game type and it cannot be added at runtime.");
-               ctf_Initialize();
-       }
-
-       MUTATOR_ONROLLBACK_OR_REMOVE
-       {
-               // we actually cannot roll back ctf_Initialize here
-               // BUT: we don't need to! If this gets called, adding always
-               // succeeds.
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               LOG_INFO("This is a game type and it cannot be removed at runtime.");
-               return -1;
-       }
-
-       return 0;
-}
 #endif
index 1414fe0655241beba97fbb0ec370371bc0e897bc..064031153cd2a6974e6f95ce5a8b2045b4800ffa 100644 (file)
@@ -1,6 +1,39 @@
+#include "../../race.qh"
+
 #ifndef GAMEMODE_CTS_H
 #define GAMEMODE_CTS_H
 
+void cts_Initialize();
+
+REGISTER_MUTATOR(cts, false)
+{
+       g_race_qualifying = true;
+       independent_players = 1;
+       SetLimits(0, 0, 0, -1);
+
+       MUTATOR_ONADD
+       {
+               if (time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");
+               cts_Initialize();
+       }
+
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               // we actually cannot roll back cts_Initialize here
+               // BUT: we don't need to! If this gets called, adding always
+               // succeeds.
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
+               return -1;
+       }
+
+       return 0;
+}
+
 // scores
 const float ST_CTS_LAPS = 1;
 const float SP_CTS_LAPS = 4;
@@ -414,32 +447,4 @@ void cts_Initialize()
        cts_ScoreRules();
 }
 
-REGISTER_MUTATOR(cts, g_cts)
-{
-       g_race_qualifying = 1;
-       independent_players = 1;
-       SetLimits(0, 0, 0, -1);
-
-       MUTATOR_ONADD
-       {
-               if(time > 1) // game loads at time 1
-                       error("This is a game type and it cannot be added at runtime.");
-               cts_Initialize();
-       }
-
-       MUTATOR_ONROLLBACK_OR_REMOVE
-       {
-               // we actually cannot roll back cts_Initialize here
-               // BUT: we don't need to! If this gets called, adding always
-               // succeeds.
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               LOG_INFO("This is a game type and it cannot be removed at runtime.");
-               return -1;
-       }
-
-       return 0;
-}
 #endif
index ac7ea21b2653ebf595c9aba21e8801baf06eb4c1..5ebd7c6b6e65b477ac711cb21fb1c54dc93adca5 100644 (file)
@@ -1,15 +1,11 @@
-#ifdef IMPLEMENTATION
-MUTATOR_HOOKFUNCTION(dm, Scores_CountFragsRemaining)
-{
-       // announce remaining frags
-       return true;
-}
+#ifndef GAMEMODE_DEATHMATCH_H
+#define GAMEMODE_DEATHMATCH_H
 
-REGISTER_MUTATOR(dm, IS_GAMETYPE(DEATHMATCH))
+REGISTER_MUTATOR(dm, false)
 {
        MUTATOR_ONADD
        {
-               if(time > 1) // game loads at time 1
+               if (time > 1) // game loads at time 1
                        error("This is a game type and it cannot be added at runtime.");
        }
 
@@ -28,4 +24,13 @@ REGISTER_MUTATOR(dm, IS_GAMETYPE(DEATHMATCH))
 
        return 0;
 }
+
+#endif
+
+#ifdef IMPLEMENTATION
+MUTATOR_HOOKFUNCTION(dm, Scores_CountFragsRemaining)
+{
+       // announce remaining frags
+       return true;
+}
 #endif
index 75d0d7dc3ca21808ba3b43664c641b8a86c75741..5195177dfcb1b493093e7ad385b590158c2f02ad 100644 (file)
@@ -1,6 +1,39 @@
 #ifndef GAMEMODE_DOMINATION_H
 #define GAMEMODE_DOMINATION_H
 
+#define autocvar_g_domination_point_limit cvar("g_domination_point_limit")
+bool autocvar_g_domination_roundbased;
+int autocvar_g_domination_roundbased_point_limit;
+int autocvar_g_domination_point_leadlimit;
+
+void dom_Initialize();
+
+REGISTER_MUTATOR(dom, false)
+{
+       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;
+
+       ActivateTeamplay();
+       SetLimits(fraglimit_override, autocvar_g_domination_point_leadlimit, -1, -1);
+       have_team_spawns = -1; // request team spawns
+
+       MUTATOR_ONADD
+       {
+               if (time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");
+               dom_Initialize();
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
+               return -1;
+       }
+
+       return 0;
+}
+
 // score rule declarations
 const float ST_DOM_TICKS = 1;
 const float SP_DOM_TICKS = 4;
@@ -40,12 +73,8 @@ int autocvar_g_domination_default_teams;
 bool autocvar_g_domination_disable_frags;
 int autocvar_g_domination_point_amt;
 bool autocvar_g_domination_point_fullbright;
-int autocvar_g_domination_point_leadlimit;
-bool autocvar_g_domination_roundbased;
-int autocvar_g_domination_roundbased_point_limit;
 float autocvar_g_domination_round_timelimit;
 float autocvar_g_domination_warmup;
-#define autocvar_g_domination_point_limit cvar("g_domination_point_limit")
 float autocvar_g_domination_point_rate;
 int autocvar_g_domination_teams_override;
 
@@ -695,30 +724,4 @@ void dom_Initialize()
        InitializeEntity(world, dom_DelayedInit, INITPRIO_GAMETYPE);
 }
 
-
-REGISTER_MUTATOR(dom, IS_GAMETYPE(DOMINATION))
-{
-       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;
-
-       ActivateTeamplay();
-       SetLimits(fraglimit_override, autocvar_g_domination_point_leadlimit, -1, -1);
-       have_team_spawns = -1; // request team spawns
-
-       MUTATOR_ONADD
-       {
-               if(time > 1) // game loads at time 1
-                       error("This is a game type and it cannot be added at runtime.");
-               dom_Initialize();
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               LOG_INFO("This is a game type and it cannot be removed at runtime.");
-               return -1;
-       }
-
-       return 0;
-}
 #endif
index 912df1575d30cb36a2debeb5f351e6ce3b3e1b77..c392c4be58dc40675a157cd6868ef12a053a7f95 100644 (file)
@@ -1,6 +1,42 @@
 #ifndef GAMEMODE_FREEZETAG_H
 #define GAMEMODE_FREEZETAG_H
 
+int autocvar_g_freezetag_point_limit;
+int autocvar_g_freezetag_point_leadlimit;
+bool autocvar_g_freezetag_team_spawns;
+void freezetag_Initialize();
+
+REGISTER_MUTATOR(ft, false)
+{
+       ActivateTeamplay();
+       SetLimits(autocvar_g_freezetag_point_limit, autocvar_g_freezetag_point_leadlimit, -1, -1);
+
+       if (autocvar_g_freezetag_team_spawns)
+               have_team_spawns = -1; // request team spawns
+
+       MUTATOR_ONADD
+       {
+               if (time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");
+               freezetag_Initialize();
+       }
+
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               // we actually cannot roll back freezetag_Initialize here
+               // BUT: we don't need to! If this gets called, adding always
+               // succeeds.
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
+               return -1;
+       }
+
+       return 0;
+}
+
 .float freezetag_frozen_time;
 .float freezetag_frozen_timeout;
 const float ICE_MAX_ALPHA = 1;
@@ -15,15 +51,12 @@ float freezetag_teams;
 float autocvar_g_freezetag_frozen_maxtime;
 bool autocvar_g_freezetag_revive_nade;
 float autocvar_g_freezetag_revive_nade_health;
-int autocvar_g_freezetag_point_leadlimit;
-int autocvar_g_freezetag_point_limit;
 float autocvar_g_freezetag_revive_extra_size;
 float autocvar_g_freezetag_revive_speed;
 float autocvar_g_freezetag_revive_clearspeed;
 float autocvar_g_freezetag_round_timelimit;
 int autocvar_g_freezetag_teams;
 int autocvar_g_freezetag_teams_override;
-bool autocvar_g_freezetag_team_spawns;
 float autocvar_g_freezetag_warmup;
 
 const float SP_FREEZETAG_REVIVALS = 4;
@@ -621,34 +654,4 @@ void freezetag_Initialize()
        EliminatedPlayers_Init(freezetag_isEliminated);
 }
 
-REGISTER_MUTATOR(ft, g_freezetag)
-{
-       ActivateTeamplay();
-       SetLimits(autocvar_g_freezetag_point_limit, autocvar_g_freezetag_point_leadlimit, -1, -1);
-
-       if(autocvar_g_freezetag_team_spawns)
-               have_team_spawns = -1; // request team spawns
-
-       MUTATOR_ONADD
-       {
-               if(time > 1) // game loads at time 1
-                       error("This is a game type and it cannot be added at runtime.");
-               freezetag_Initialize();
-       }
-
-       MUTATOR_ONROLLBACK_OR_REMOVE
-       {
-               // we actually cannot roll back freezetag_Initialize here
-               // BUT: we don't need to! If this gets called, adding always
-               // succeeds.
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               LOG_INFO("This is a game type and it cannot be removed at runtime.");
-               return -1;
-       }
-
-       return 0;
-}
 #endif
index 4dc5ed63ab2d5a8acaf6835e49f6130adf94a1ff..f52afb9e2fcbcf73ee87e75ae945d17bae23577f 100644 (file)
@@ -1,6 +1,48 @@
 #ifndef GAMEMODE_INVASION_H
 #define GAMEMODE_INVASION_H
 
+#define autocvar_g_invasion_point_limit cvar("g_invasion_point_limit")
+int autocvar_g_invasion_teams;
+bool autocvar_g_invasion_team_spawns;
+bool g_invasion;
+void invasion_Initialize();
+
+REGISTER_MUTATOR(inv, false)
+{
+       SetLimits(autocvar_g_invasion_point_limit, -1, -1, -1);
+       if (autocvar_g_invasion_teams >= 2)
+       {
+               ActivateTeamplay();
+               if (autocvar_g_invasion_team_spawns)
+                       have_team_spawns = -1; // request team spawns
+       }
+
+       MUTATOR_ONADD
+       {
+               if (time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");
+               g_invasion = true;
+               invasion_Initialize();
+
+               cvar_settemp("g_monsters", "1");
+       }
+
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               // we actually cannot roll back invasion_Initialize here
+               // BUT: we don't need to! If this gets called, adding always
+               // succeeds.
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
+               return -1;
+       }
+
+       return 0;
+}
+
 float inv_numspawned;
 float inv_maxspawned;
 float inv_roundcnt;
@@ -24,13 +66,9 @@ const float ST_INV_KILLS = 1;
 
 #include "../../teamplay.qh"
 
-bool g_invasion;
 
 float autocvar_g_invasion_round_timelimit;
-int autocvar_g_invasion_teams;
-bool autocvar_g_invasion_team_spawns;
 float autocvar_g_invasion_spawnpoint_spawn_delay;
-#define autocvar_g_invasion_point_limit cvar("g_invasion_point_limit")
 float autocvar_g_invasion_warmup;
 int autocvar_g_invasion_monster_count;
 bool autocvar_g_invasion_zombies_only;
@@ -487,39 +525,4 @@ void invasion_Initialize()
        InitializeEntity(world, invasion_DelayedInit, INITPRIO_GAMETYPE);
 }
 
-REGISTER_MUTATOR(inv, IS_GAMETYPE(INVASION))
-{
-       SetLimits(autocvar_g_invasion_point_limit, -1, -1, -1);
-       if(autocvar_g_invasion_teams >= 2)
-       {
-               ActivateTeamplay();
-               if(autocvar_g_invasion_team_spawns)
-                       have_team_spawns = -1; // request team spawns
-       }
-
-       MUTATOR_ONADD
-       {
-               if(time > 1) // game loads at time 1
-                       error("This is a game type and it cannot be added at runtime.");
-               g_invasion = true;
-               invasion_Initialize();
-
-               cvar_settemp("g_monsters", "1");
-       }
-
-       MUTATOR_ONROLLBACK_OR_REMOVE
-       {
-               // we actually cannot roll back invasion_Initialize here
-               // BUT: we don't need to! If this gets called, adding always
-               // succeeds.
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               LOG_INFO("This is a game type and it cannot be removed at runtime.");
-               return -1;
-       }
-
-       return 0;
-}
 #endif
index 855b766a9d04cbc9d8fd1a69bd16c1fb884a0534..8961e6bf0027398d159f1d3b266b8d19ee0934dd 100644 (file)
@@ -1,6 +1,33 @@
 #ifndef GAMEMODE_KEEPAWAY_H
 #define GAMEMODE_KEEPAWAY_H
 
+void ka_Initialize();
+
+REGISTER_MUTATOR(ka, false)
+{
+       MUTATOR_ONADD
+       {
+               if (time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");
+               ka_Initialize();
+       }
+
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               // we actually cannot roll back ka_Initialize here
+               // BUT: we don't need to! If this gets called, adding always
+               // succeeds.
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
+               return -1;
+       }
+
+       return 0;
+}
+
 
 entity ka_ball;
 
@@ -472,29 +499,4 @@ void ka_Initialize() // run at the start of a match, initiates game mode
        ka_SpawnBall();
 }
 
-
-REGISTER_MUTATOR(ka, IS_GAMETYPE(KEEPAWAY))
-{
-       MUTATOR_ONADD
-       {
-               if(time > 1) // game loads at time 1
-                       error("This is a game type and it cannot be added at runtime.");
-               ka_Initialize();
-       }
-
-       MUTATOR_ONROLLBACK_OR_REMOVE
-       {
-               // we actually cannot roll back ka_Initialize here
-               // BUT: we don't need to! If this gets called, adding always
-               // succeeds.
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               LOG_INFO("This is a game type and it cannot be removed at runtime.");
-               return -1;
-       }
-
-       return 0;
-}
 #endif
index 3b86b664186e3625cac2d65a7df3ec5f842de044..5982cf2085436442543488477e823925958eeb52 100644 (file)
@@ -1,6 +1,41 @@
 #ifndef GAMEMODE_KEYHUNT_H
 #define GAMEMODE_KEYHUNT_H
 
+#define autocvar_g_keyhunt_point_limit cvar("g_keyhunt_point_limit")
+int autocvar_g_keyhunt_point_leadlimit;
+bool autocvar_g_keyhunt_team_spawns;
+void kh_Initialize();
+
+REGISTER_MUTATOR(kh, false)
+{
+       ActivateTeamplay();
+       SetLimits(autocvar_g_keyhunt_point_limit, autocvar_g_keyhunt_point_leadlimit, -1, -1);
+       if (autocvar_g_keyhunt_team_spawns)
+               have_team_spawns = -1; // request team spawns
+
+       MUTATOR_ONADD
+       {
+               if (time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");
+               kh_Initialize();
+       }
+
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               // we actually cannot roll back kh_Initialize here
+               // BUT: we don't need to! If this gets called, adding always
+               // succeeds.
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
+               return -1;
+       }
+
+       return 0;
+}
+
 #define FOR_EACH_KH_KEY(v) for(v = kh_worldkeylist; v; v = v.kh_worldkeynext )
 
 // ALL OF THESE should be removed in the future, as other code should not have to care
@@ -37,9 +72,6 @@ int autocvar_g_balance_keyhunt_score_destroyed_ownfactor;
 int autocvar_g_balance_keyhunt_score_push;
 float autocvar_g_balance_keyhunt_throwvelocity;
 
-int autocvar_g_keyhunt_point_leadlimit;
-bool autocvar_g_keyhunt_team_spawns;
-#define autocvar_g_keyhunt_point_limit cvar("g_keyhunt_point_limit")
 int autocvar_g_keyhunt_teams;
 int autocvar_g_keyhunt_teams_override;
 
@@ -1367,33 +1399,4 @@ MUTATOR_HOOKFUNCTION(kh, reset_map_global)
        return false;
 }
 
-REGISTER_MUTATOR(kh, IS_GAMETYPE(KEYHUNT))
-{
-       ActivateTeamplay();
-       SetLimits(autocvar_g_keyhunt_point_limit, autocvar_g_keyhunt_point_leadlimit, -1, -1);
-       if(autocvar_g_keyhunt_team_spawns)
-               have_team_spawns = -1; // request team spawns
-
-       MUTATOR_ONADD
-       {
-               if(time > 1) // game loads at time 1
-                       error("This is a game type and it cannot be added at runtime.");
-               kh_Initialize();
-       }
-
-       MUTATOR_ONROLLBACK_OR_REMOVE
-       {
-               // we actually cannot roll back kh_Initialize here
-               // BUT: we don't need to! If this gets called, adding always
-               // succeeds.
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               LOG_INFO("This is a game type and it cannot be removed at runtime.");
-               return -1;
-       }
-
-       return 0;
-}
 #endif
index 30789a520c97d72075fb41d21c673340df79b569..efab45e3fa817be6fbc02eb316167b47b7f8c34f 100644 (file)
@@ -1,6 +1,36 @@
 #ifndef GAMEMODE_LMS_H
 #define GAMEMODE_LMS_H
 
+#define autocvar_g_lms_lives_override cvar("g_lms_lives_override")
+void lms_Initialize();
+
+REGISTER_MUTATOR(lms, false)
+{
+       SetLimits(((!autocvar_g_lms_lives_override) ? -1 : autocvar_g_lms_lives_override), 0, -1, -1);
+
+       MUTATOR_ONADD
+       {
+               if (time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");
+               lms_Initialize();
+       }
+
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               // we actually cannot roll back lms_Initialize here
+               // BUT: we don't need to! If this gets called, adding always
+               // succeeds.
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
+               return -1;
+       }
+
+       return 0;
+}
+
 // scoreboard stuff
 const float SP_LMS_LIVES = 4;
 const float SP_LMS_RANK = 5;
@@ -20,7 +50,6 @@ float LMS_NewPlayerLives();
 int autocvar_g_lms_extra_lives;
 bool autocvar_g_lms_join_anytime;
 int autocvar_g_lms_last_join;
-#define autocvar_g_lms_lives_override cvar("g_lms_lives_override")
 bool autocvar_g_lms_regenerate;
 
 // main functions
@@ -284,30 +313,5 @@ void lms_Initialize()
        lms_ScoreRules();
 }
 
-REGISTER_MUTATOR(lms, IS_GAMETYPE(LMS))
-{
-       SetLimits(((!autocvar_g_lms_lives_override) ? -1 : autocvar_g_lms_lives_override), 0, -1, -1);
 
-       MUTATOR_ONADD
-       {
-               if(time > 1) // game loads at time 1
-                       error("This is a game type and it cannot be added at runtime.");
-               lms_Initialize();
-       }
-
-       MUTATOR_ONROLLBACK_OR_REMOVE
-       {
-               // we actually cannot roll back lms_Initialize here
-               // BUT: we don't need to! If this gets called, adding always
-               // succeeds.
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               LOG_INFO("This is a game type and it cannot be removed at runtime.");
-               return -1;
-       }
-
-       return 0;
-}
 #endif
index d01b48ca497586fa31189757d01ef69beb28088d..4cda650826f3ced566d46ebf984425c6430abca9 100644 (file)
@@ -1,6 +1,38 @@
 #ifndef GAMEMODE_ONSLAUGHT_H
 #define GAMEMODE_ONSLAUGHT_H
 
+float autocvar_g_onslaught_point_limit;
+void ons_Initialize();
+
+REGISTER_MUTATOR(ons, false)
+{
+       ActivateTeamplay();
+       SetLimits(autocvar_g_onslaught_point_limit, -1, -1, -1);
+       have_team_spawns = -1; // request team spawns
+
+       MUTATOR_ONADD
+       {
+               if (time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");
+               ons_Initialize();
+       }
+
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               // we actually cannot roll back ons_Initialize here
+               // BUT: we don't need to! If this gets called, adding always
+               // succeeds.
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
+               return -1;
+       }
+
+       return false;
+}
+
 #ifdef SVQC
 
 .entity ons_toucher; // player who touched the control point
@@ -120,7 +152,6 @@ float autocvar_g_onslaught_gen_health;
 float autocvar_g_onslaught_shield_force = 100;
 float autocvar_g_onslaught_allow_vehicle_touch;
 float autocvar_g_onslaught_round_timelimit;
-float autocvar_g_onslaught_point_limit;
 float autocvar_g_onslaught_warmup;
 float autocvar_g_onslaught_teleport_radius;
 float autocvar_g_onslaught_spawn_choose;
@@ -2284,32 +2315,4 @@ void ons_Initialize()
        InitializeEntity(world, ons_DelayedInit, INITPRIO_GAMETYPE);
 }
 
-REGISTER_MUTATOR(ons, IS_GAMETYPE(ONSLAUGHT))
-{
-       ActivateTeamplay();
-       SetLimits(autocvar_g_onslaught_point_limit, -1, -1, -1);
-       have_team_spawns = -1; // request team spawns
-
-       MUTATOR_ONADD
-       {
-               if(time > 1) // game loads at time 1
-                       error("This is a game type and it cannot be added at runtime.");
-               ons_Initialize();
-       }
-
-       MUTATOR_ONROLLBACK_OR_REMOVE
-       {
-               // we actually cannot roll back ons_Initialize here
-               // BUT: we don't need to! If this gets called, adding always
-               // succeeds.
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               LOG_INFO("This is a game type and it cannot be removed at runtime.");
-               return -1;
-       }
-
-       return false;
-}
 #endif
index 4b9201d4597eb4aa4c7a9db4e9fb09f8d4ba844b..cc250dfc73e75f870ee649071ac9e2d6c3655b41 100644 (file)
@@ -1,7 +1,36 @@
 #ifndef GAMEMODE_RACE_H
 #define GAMEMODE_RACE_H
 
-float g_race_qualifying;
+void rc_SetLimits();
+void race_Initialize();
+
+REGISTER_MUTATOR(rc, false)
+{
+       rc_SetLimits();
+
+       MUTATOR_ONADD
+       {
+               if (time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");
+               race_Initialize();
+       }
+
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               // we actually cannot roll back race_Initialize here
+               // BUT: we don't need to! If this gets called, adding always
+               // succeeds.
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
+               return -1;
+       }
+
+       return 0;
+}
+
 float race_teams;
 
 // scores
@@ -437,30 +466,4 @@ void rc_SetLimits()
        SetLimits(fraglimit_override, leadlimit_override, timelimit_override, qualifying_override);
 }
 
-REGISTER_MUTATOR(rc, g_race)
-{
-       rc_SetLimits();
-
-       MUTATOR_ONADD
-       {
-               if(time > 1) // game loads at time 1
-                       error("This is a game type and it cannot be added at runtime.");
-               race_Initialize();
-       }
-
-       MUTATOR_ONROLLBACK_OR_REMOVE
-       {
-               // we actually cannot roll back race_Initialize here
-               // BUT: we don't need to! If this gets called, adding always
-               // succeeds.
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               LOG_INFO("This is a game type and it cannot be removed at runtime.");
-               return -1;
-       }
-
-       return 0;
-}
 #endif
index aaa3d516311265b65065e99e9edfa392957cb70a..49ec0acc9f5e3dd90be9013a671ba107f93cc827 100644 (file)
@@ -1,7 +1,44 @@
-#ifdef IMPLEMENTATION
-bool autocvar_g_tdm_team_spawns;
+#ifndef GAMEMODE_TDM_H
+#define GAMEMODE_TDM_H
+
 int autocvar_g_tdm_point_limit;
 int autocvar_g_tdm_point_leadlimit;
+bool autocvar_g_tdm_team_spawns;
+void tdm_DelayedInit();
+
+REGISTER_MUTATOR(tdm, false)
+{
+       ActivateTeamplay();
+       SetLimits(autocvar_g_tdm_point_limit, autocvar_g_tdm_point_leadlimit, -1, -1);
+       if (autocvar_g_tdm_team_spawns)
+               have_team_spawns = -1; // request team spawns
+
+       MUTATOR_ONADD
+       {
+               if (time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");
+               InitializeEntity(world, tdm_DelayedInit, INITPRIO_GAMETYPE);
+       }
+
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               // we actually cannot roll back tdm_Initialize here
+               // BUT: we don't need to! If this gets called, adding always
+               // succeeds.
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
+               return -1;
+       }
+
+       return 0;
+}
+
+#endif
+
+#ifdef IMPLEMENTATION
 int autocvar_g_tdm_teams;
 int autocvar_g_tdm_teams_override;
 
@@ -59,33 +96,4 @@ MUTATOR_HOOKFUNCTION(tdm, Scores_CountFragsRemaining)
        return true;
 }
 
-REGISTER_MUTATOR(tdm, g_tdm)
-{
-       ActivateTeamplay();
-       SetLimits(autocvar_g_tdm_point_limit, autocvar_g_tdm_point_leadlimit, -1, -1);
-       if(autocvar_g_tdm_team_spawns)
-               have_team_spawns = -1; // request team spawns
-
-       MUTATOR_ONADD
-       {
-               if(time > 1) // game loads at time 1
-                       error("This is a game type and it cannot be added at runtime.");
-               InitializeEntity(world, tdm_DelayedInit, INITPRIO_GAMETYPE);
-       }
-
-       MUTATOR_ONROLLBACK_OR_REMOVE
-       {
-               // we actually cannot roll back tdm_Initialize here
-               // BUT: we don't need to! If this gets called, adding always
-               // succeeds.
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               LOG_INFO("This is a game type and it cannot be removed at runtime.");
-               return -1;
-       }
-
-       return 0;
-}
 #endif
index 5e9f0cf85c2513a0364a894af003badad78cb622..03e8a54aba2747e2f04f6f0914d7e23a2717fccb 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef RACE_H
 #define RACE_H
 
+bool g_race_qualifying;
+
 float speedaward_lastsent;
 float speedaward_lastupdate;
 
index 5664d261daa1a6b26376899369562fe9abc51132..b934993235d4c130ad9b24ad55081922acabdd39 100644 (file)
@@ -21,6 +21,8 @@ void default_delayedinit();
 
 void ActivateTeamplay();
 
+void SetLimits(int fraglimit_override, int leadlimit_override, float timelimit_override, float qualifying_override);
+
 void InitGameplayMode();
 
 string GetClientVersionMessage();