]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Mutators: inline InitializeEntity(_, _, INITPRIO_GAMETYPE)
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 2 Sep 2017 03:01:47 +0000 (13:01 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 2 Sep 2017 03:01:47 +0000 (13:01 +1000)
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc
qcsrc/server/g_world.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_domination.qc
qcsrc/server/mutators/mutator/gamemode_invasion.qc
qcsrc/server/mutators/mutator/gamemode_tdm.qc
qcsrc/server/mutators/mutator/gamemode_tdm.qh

index 5a0ff2a2c22ade90150d22cad3fbcfdb8be07f3b..64fd392bd81566830af76ccd32ecc85f7a690685 100644 (file)
@@ -72,14 +72,6 @@ float OtherTeam(float t)  //works only if there are two teams on the map!
 }
 
 const int ST_NEXBALL_GOALS = 1;
-void nb_ScoreRules(int teams)
-{
-    GameRules_scoring(teams, 0, 0, {
-        field_team(ST_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
-        field(SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
-        field(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
-    });
-}
 
 void LogNB(string mode, entity actor)
 {
@@ -475,58 +467,6 @@ void nb_spawnteam(string teamname, float teamcolor)
        //nb_teams += 1;
 }
 
-void nb_spawnteams()
-{
-       bool t_red = false, t_blue = false, t_yellow = false, t_pink = false;
-       entity e;
-       for(e = NULL; (e = find(e, classname, "nexball_goal"));)
-       {
-               switch(e.team)
-               {
-               case NUM_TEAM_1:
-                       if(!t_red)
-                       {
-                               nb_spawnteam("Red", e.team-1)   ;
-                               nb_teams |= BIT(0);
-                               t_red = true;
-                       }
-                       break;
-               case NUM_TEAM_2:
-                       if(!t_blue)
-                       {
-                               nb_spawnteam("Blue", e.team-1)  ;
-                               t_blue = true;
-                               nb_teams |= BIT(1);
-                       }
-                       break;
-               case NUM_TEAM_3:
-                       if(!t_yellow)
-                       {
-                               nb_spawnteam("Yellow", e.team-1);
-                               t_yellow = true;
-                               nb_teams |= BIT(2);
-                       }
-                       break;
-               case NUM_TEAM_4:
-                       if(!t_pink)
-                       {
-                               nb_spawnteam("Pink", e.team-1)  ;
-                               t_pink = true;
-                               nb_teams |= BIT(3);
-                       }
-                       break;
-               }
-       }
-}
-
-void nb_delayedinit(entity this)
-{
-       if(find(NULL, classname, "nexball_team") == NULL)
-               nb_spawnteams();
-       nb_ScoreRules(nb_teams);
-}
-
-
 //=======================//
 //       spawnfuncs       //
 //=======================//
@@ -973,7 +913,22 @@ REGISTER_MUTATOR(nb, g_nexball)
                */
                radar_showennemies = autocvar_g_nexball_radar_showallplayers;
 
-               InitializeEntity(NULL, nb_delayedinit, INITPRIO_GAMETYPE);
+           if (find(NULL, classname, "nexball_team") == NULL) {
+               int t_1 = 0, t_2 = 0, t_3 = 0, t_4 = 0;
+            for (entity e = NULL; (e = find(e, classname, "nexball_goal")); ) {
+                switch (e.team) {
+                       case NUM_TEAM_1: if (!t_1++) { nb_spawnteam("Red",    e.team - 1); nb_teams |= BIT(0); } break;
+                       case NUM_TEAM_2: if (!t_2++) { nb_spawnteam("Blue",   e.team - 1); nb_teams |= BIT(1); } break;
+                       case NUM_TEAM_3: if (!t_3++) { nb_spawnteam("Yellow", e.team - 1); nb_teams |= BIT(2); } break;
+                       case NUM_TEAM_4: if (!t_4++) { nb_spawnteam("Pink",   e.team - 1); nb_teams |= BIT(3); } break;
+                }
+            }
+           }
+        GameRules_scoring(nb_teams, 0, 0, {
+            field_team(ST_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
+            field(SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
+            field(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
+        });
                WEP_NEXBALL.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
 
                GameRules_teams(true);
index 0150de3925ee90072b040e2f5d132cd301a736ad..cf86a834ff83811caf3efda432ba9176cae6cf04 100644 (file)
@@ -2165,30 +2165,6 @@ spawnfunc(onslaught_generator)
        ons_GeneratorSetup(this);
 }
 
-// scoreboard setup
-void ons_ScoreRules()
-{
-       CheckAllowedTeams(NULL);
-       int teams = 0;
-       if(c1 >= 0) teams |= BIT(0);
-       if(c2 >= 0) teams |= BIT(1);
-       if(c3 >= 0) teams |= BIT(2);
-       if(c4 >= 0) teams |= BIT(3);
-       GameRules_scoring(teams, SFL_SORT_PRIO_PRIMARY, 0, {
-           field_team(ST_ONS_CAPS, "destroyed", SFL_SORT_PRIO_PRIMARY);
-           field(SP_ONS_CAPS, "caps", SFL_SORT_PRIO_SECONDARY);
-           field(SP_ONS_TAKES, "takes", 0);
-       });
-}
-
-void ons_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up
-{
-       ons_ScoreRules();
-
-       round_handler_Spawn(Onslaught_CheckPlayers, Onslaught_CheckWinner, Onslaught_RoundStart);
-       round_handler_Init(5, autocvar_g_onslaught_warmup, autocvar_g_onslaught_round_timelimit);
-}
-
 void ons_Initialize()
 {
        g_onslaught = true;
@@ -2196,5 +2172,18 @@ void ons_Initialize()
 
        cam = new(objective_camera);
 
-       InitializeEntity(NULL, ons_DelayedInit, INITPRIO_GAMETYPE);
+       CheckAllowedTeams(NULL);
+    int teams = 0;
+    if (c1 >= 0) teams |= BIT(0);
+    if (c2 >= 0) teams |= BIT(1);
+    if (c3 >= 0) teams |= BIT(2);
+    if (c4 >= 0) teams |= BIT(3);
+    GameRules_scoring(teams, SFL_SORT_PRIO_PRIMARY, 0, {
+        field_team(ST_ONS_CAPS, "destroyed", SFL_SORT_PRIO_PRIMARY);
+        field(SP_ONS_CAPS, "caps", SFL_SORT_PRIO_SECONDARY);
+        field(SP_ONS_TAKES,    "takes", 0);
+    });
+
+    round_handler_Spawn(Onslaught_CheckPlayers, Onslaught_CheckWinner, Onslaught_RoundStart);
+    round_handler_Init(5, autocvar_g_onslaught_warmup, autocvar_g_onslaught_round_timelimit);
 }
index c47952c5d99f0c83231c5916c6f47e0fcfb13183..b53d90a2ef93869787bc55dfec276f8e48da5dc6 100644 (file)
@@ -742,6 +742,7 @@ spawnfunc(worldspawn)
        PlayerStats_GameReport_Init(); // we need this to be initiated before InitGameplayMode
 
        InitGameplayMode();
+    __spawnfunc_spawn_all();
        static_init_late();
        static_init_precache();
        readlevelcvars();
@@ -936,7 +937,6 @@ spawnfunc(worldspawn)
        WinningConditionHelper(this); // set worldstatus
 
        world_initialized = 1;
-       __spawnfunc_spawn_all();
 }
 
 spawnfunc(light)
index 3cf560ebedf752c3fc99b33cfc2aa3248bcaad2b..3e18048785738a98e9dac486e09e34ea6c4f0402 100644 (file)
@@ -2655,21 +2655,6 @@ spawnfunc(team_CTL_bluelolly)  { spawnfunc_item_flag_team2(this);    }
 // Initialization
 // ==============
 
-// scoreboard setup
-void ctf_ScoreRules(int teams)
-{
-       CheckAllowedTeams(NULL);
-       GameRules_scoring(teams, SFL_SORT_PRIO_PRIMARY, 0, {
-        field_team(ST_CTF_CAPS, "caps", SFL_SORT_PRIO_PRIMARY);
-        field(SP_CTF_CAPS, "caps", SFL_SORT_PRIO_SECONDARY);
-        field(SP_CTF_CAPTIME, "captime", SFL_LOWER_IS_BETTER | SFL_TIME);
-        field(SP_CTF_PICKUPS, "pickups", 0);
-        field(SP_CTF_FCKILLS, "fckills", 0);
-        field(SP_CTF_RETURNS, "returns", 0);
-        field(SP_CTF_DROPS, "drops", SFL_LOWER_IS_BETTER);
-       });
-}
-
 // code from here on is just to support maps that don't have flag and team entities
 void ctf_SpawnTeam (string teamname, int teamcolor)
 {
@@ -2680,54 +2665,6 @@ void ctf_SpawnTeam (string teamname, int teamcolor)
        this.team = teamcolor;
 }
 
-void ctf_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up.
-{
-       ctf_teams = 0;
-
-       entity tmp_entity;
-       for(tmp_entity = ctf_worldflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_worldflagnext)
-       {
-               //if(tmp_entity.team == NUM_TEAM_3) { ctf_teams = max(3, ctf_teams); }
-               //if(tmp_entity.team == NUM_TEAM_4) { ctf_teams = max(4, ctf_teams); }
-
-               switch(tmp_entity.team)
-               {
-                       case NUM_TEAM_1: BITSET_ASSIGN(ctf_teams, BIT(0)); break;
-                       case NUM_TEAM_2: BITSET_ASSIGN(ctf_teams, BIT(1)); break;
-                       case NUM_TEAM_3: BITSET_ASSIGN(ctf_teams, BIT(2)); break;
-                       case NUM_TEAM_4: BITSET_ASSIGN(ctf_teams, BIT(3)); break;
-               }
-               if(tmp_entity.team == 0) { ctf_oneflag = true; }
-       }
-
-       havocbot_ctf_calculate_middlepoint();
-
-       if(NumTeams(ctf_teams) < 2) // somehow, there's not enough flags!
-       {
-               ctf_teams = 0; // so set the default red and blue teams
-               BITSET_ASSIGN(ctf_teams, BIT(0));
-               BITSET_ASSIGN(ctf_teams, BIT(1));
-       }
-
-       //ctf_teams = bound(2, ctf_teams, 4);
-
-       // if no teams are found, spawn defaults
-       if(find(NULL, classname, "ctf_team") == NULL)
-       {
-               LOG_TRACE("No \"ctf_team\" entities found on this map, creating them anyway.");
-               if(ctf_teams & BIT(0))
-                       ctf_SpawnTeam("Red", NUM_TEAM_1);
-               if(ctf_teams & BIT(1))
-                       ctf_SpawnTeam("Blue", NUM_TEAM_2);
-               if(ctf_teams & BIT(2))
-                       ctf_SpawnTeam("Yellow", NUM_TEAM_3);
-               if(ctf_teams & BIT(3))
-                       ctf_SpawnTeam("Pink", NUM_TEAM_4);
-       }
-
-       ctf_ScoreRules(ctf_teams);
-}
-
 void ctf_Initialize()
 {
        ctf_captimerecord = stof(db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time")));
@@ -2736,5 +2673,48 @@ void ctf_Initialize()
        ctf_captureshield_max_ratio = autocvar_g_ctf_shield_max_ratio;
        ctf_captureshield_force = autocvar_g_ctf_shield_force;
 
-       InitializeEntity(NULL, ctf_DelayedInit, INITPRIO_GAMETYPE);
+       ctf_teams = 0;
+
+    for (entity tmp_entity = ctf_worldflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_worldflagnext) {
+        //if(tmp_entity.team == NUM_TEAM_3) { ctf_teams = max(3, ctf_teams); }
+        //if(tmp_entity.team == NUM_TEAM_4) { ctf_teams = max(4, ctf_teams); }
+
+        switch (tmp_entity.team) {
+            case NUM_TEAM_1: BITSET_ASSIGN(ctf_teams, BIT(0)); break;
+            case NUM_TEAM_2: BITSET_ASSIGN(ctf_teams, BIT(1)); break;
+            case NUM_TEAM_3: BITSET_ASSIGN(ctf_teams, BIT(2)); break;
+            case NUM_TEAM_4: BITSET_ASSIGN(ctf_teams, BIT(3)); break;
+        }
+        if (tmp_entity.team == 0) { ctf_oneflag = true; }
+    }
+
+    havocbot_ctf_calculate_middlepoint();
+
+    if (NumTeams(ctf_teams) < 2) { // somehow, there's not enough flags!
+        ctf_teams = 0; // so set the default red and blue teams
+        BITSET_ASSIGN(ctf_teams, BIT(0));
+        BITSET_ASSIGN(ctf_teams, BIT(1));
+    }
+
+    //ctf_teams = bound(2, ctf_teams, 4);
+
+    // if no teams are found, spawn defaults
+    if (find(NULL, classname, "ctf_team") == NULL) {
+        LOG_TRACE("No \"ctf_team\" entities found on this map, creating them anyway.");
+        if (ctf_teams & BIT(0)) ctf_SpawnTeam("Red", NUM_TEAM_1);
+        if (ctf_teams & BIT(1)) ctf_SpawnTeam("Blue", NUM_TEAM_2);
+        if (ctf_teams & BIT(2)) ctf_SpawnTeam("Yellow", NUM_TEAM_3);
+        if (ctf_teams & BIT(3)) ctf_SpawnTeam("Pink", NUM_TEAM_4);
+    }
+
+    CheckAllowedTeams(NULL);
+    GameRules_scoring(ctf_teams, SFL_SORT_PRIO_PRIMARY, 0, {
+        field_team(ST_CTF_CAPS, "caps", SFL_SORT_PRIO_PRIMARY);
+        field(SP_CTF_CAPS, "caps", SFL_SORT_PRIO_SECONDARY);
+        field(SP_CTF_CAPTIME, "captime", SFL_LOWER_IS_BETTER | SFL_TIME);
+        field(SP_CTF_PICKUPS, "pickups", 0);
+        field(SP_CTF_FCKILLS, "fckills", 0);
+        field(SP_CTF_RETURNS, "returns", 0);
+        field(SP_CTF_DROPS, "drops", SFL_LOWER_IS_BETTER);
+    });
 }
index be38553c9588bcd4ba1bfd79042432f79aebd583..ff7af5ddf2fd6baa83b927bb9a2d1382d2519eb3 100644 (file)
@@ -554,32 +554,6 @@ spawnfunc(dom_team)
                this.team = this.cnt + 1; // WHY are these different anyway?
 }
 
-// scoreboard setup
-void ScoreRules_dom(int teams)
-{
-       if(domination_roundbased)
-       {
-           GameRules_scoring(teams, SFL_SORT_PRIO_PRIMARY, 0, {
-            field_team(ST_DOM_CAPS, "caps", SFL_SORT_PRIO_PRIMARY);
-            field(SP_DOM_TAKES, "takes", 0);
-           });
-       }
-       else
-       {
-               float sp_domticks, sp_score;
-               sp_score = sp_domticks = 0;
-               if(autocvar_g_domination_disable_frags)
-                       sp_domticks = SFL_SORT_PRIO_PRIMARY;
-               else
-                       sp_score = SFL_SORT_PRIO_PRIMARY;
-               GameRules_scoring(teams, sp_score, sp_score, {
-            field_team(ST_DOM_TICKS, "ticks", sp_domticks);
-            field(SP_DOM_TICKS, "ticks", sp_domticks);
-            field(SP_DOM_TAKES, "takes", 0);
-               });
-       }
-}
-
 // code from here on is just to support maps that don't have control point and team entities
 void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float pointskin, Sound capsound, string capnarration, string capmessage)
 {
@@ -628,8 +602,9 @@ void dom_spawnteams(int teams)
        dom_spawnteam("", 0, "models/domination/dom_unclaimed.md3", 0, SND_Null, "", "");
 }
 
-void dom_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up.
+void dom_Initialize()
 {
+       g_domination = true;
        // if no teams are found, spawn defaults
        if(find(NULL, classname, "dom_team") == NULL || autocvar_g_domination_teams_override >= 2)
        {
@@ -653,17 +628,23 @@ void dom_DelayedInit(entity this) // Do this check with a delay so we can wait f
 
        domination_roundbased = autocvar_g_domination_roundbased;
 
-       ScoreRules_dom(domination_teams);
+       if (domination_roundbased) {
+           GameRules_scoring(teams, SFL_SORT_PRIO_PRIMARY, 0, {
+            field_team(ST_DOM_CAPS, "caps", SFL_SORT_PRIO_PRIMARY);
+            field(SP_DOM_TAKES, "takes", 0);
+           });
+       } else {
+               float sp_score = autocvar_g_domination_disable_frags ? 0 : SFL_SORT_PRIO_PRIMARY;
+               float sp_domticks = autocvar_g_domination_disable_frags ? SFL_SORT_PRIO_PRIMARY : 0;
+               GameRules_scoring(teams, sp_score, sp_score, {
+            field_team(ST_DOM_TICKS, "ticks", sp_domticks);
+            field(SP_DOM_TICKS, "ticks", sp_domticks);
+            field(SP_DOM_TAKES, "takes", 0);
+               });
+       }
 
-       if(domination_roundbased)
-       {
+       if (domination_roundbased) {
                round_handler_Spawn(Domination_CheckPlayers, Domination_CheckWinner, Domination_RoundStart);
                round_handler_Init(5, autocvar_g_domination_warmup, autocvar_g_domination_round_timelimit);
        }
 }
-
-void dom_Initialize()
-{
-       g_domination = true;
-       InitializeEntity(NULL, dom_DelayedInit, INITPRIO_GAMETYPE);
-}
index 1b8b77ae078158e566fb34a87c754701436175d3..42389b1c4cf338ba8c297b249904301bed68e808 100644 (file)
@@ -557,38 +557,27 @@ MUTATOR_HOOKFUNCTION(inv, AllowMobButcher)
        return true;
 }
 
-void invasion_ScoreRules(int inv_teams)
-{
-       if(inv_teams) { CheckAllowedTeams(NULL); }
-       GameRules_score_enabled(false);
-       GameRules_scoring(inv_teams, 0, 0, {
-           if (inv_teams) {
-            field_team(ST_INV_KILLS, "frags", SFL_SORT_PRIO_PRIMARY);
-           }
-           field(SP_KILLS, "frags", ((inv_teams) ? SFL_SORT_PRIO_SECONDARY : SFL_SORT_PRIO_PRIMARY));
-       });
-}
-
-void invasion_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up.
+void invasion_Initialize()
 {
        if(autocvar_g_invasion_type == INV_TYPE_HUNT || autocvar_g_invasion_type == INV_TYPE_STAGE)
                cvar_set("fraglimit", "0");
 
-       if(autocvar_g_invasion_teams)
-       {
-               invasion_teams = BITS(bound(2, autocvar_g_invasion_teams, 4));
-       }
-       else
-               invasion_teams = 0;
+    invasion_teams = autocvar_g_invasion_teams ? BITS(bound(2, autocvar_g_invasion_teams, 4)) : 0;
 
        independent_players = 1; // to disable extra useless scores
 
-       invasion_ScoreRules(invasion_teams);
+    if (invasion_teams) { CheckAllowedTeams(NULL); }
+       GameRules_score_enabled(false);
+       GameRules_scoring(invasion_teams, 0, 0, {
+           if (invasion_teams) {
+            field_team(ST_INV_KILLS, "frags", SFL_SORT_PRIO_PRIMARY);
+           }
+           field(SP_KILLS, "frags", ((invasion_teams) ? SFL_SORT_PRIO_SECONDARY : SFL_SORT_PRIO_PRIMARY));
+       });
 
        independent_players = 0;
 
-       if(autocvar_g_invasion_type == INV_TYPE_ROUND)
-       {
+       if (autocvar_g_invasion_type == INV_TYPE_ROUND) {
                round_handler_Spawn(Invasion_CheckPlayers, Invasion_CheckWinner, Invasion_RoundStart);
                round_handler_Init(5, autocvar_g_invasion_warmup, autocvar_g_invasion_round_timelimit);
 
@@ -596,8 +585,3 @@ void invasion_DelayedInit(entity this) // Do this check with a delay so we can w
                inv_maxrounds = 15; // 15?
        }
 }
-
-void invasion_Initialize()
-{
-       InitializeEntity(NULL, invasion_DelayedInit, INITPRIO_GAMETYPE);
-}
index aad31932884556dff7b4a7b6f1a186dcbf15e44c..3df28b969eb8fceaed492a09a17521db20bcae0f 100644 (file)
@@ -1,8 +1,5 @@
 #include "gamemode_tdm.qh"
 
-int autocvar_g_tdm_teams;
-int autocvar_g_tdm_teams_override;
-
 /*QUAKED spawnfunc_tdm_team (0 .5 .8) (-16 -16 -24) (16 16 32)
 Team declaration for TDM gameplay, this allows you to decide what team names and control point models are used in your map.
 Note: If you use spawnfunc_tdm_team entities you must define at least 2!  However, unlike domination, you don't need to make a blank one too.
@@ -28,28 +25,6 @@ void tdm_SpawnTeam (string teamname, int teamcolor)
        //spawnfunc_tdm_team(this);
 }
 
-void tdm_DelayedInit(entity this)
-{
-       // if no teams are found, spawn defaults
-       if(find(NULL, classname, "tdm_team") == NULL)
-       {
-               LOG_TRACE("No \"tdm_team\" entities found on this map, creating them anyway.");
-
-               int numteams = autocvar_g_tdm_teams_override;
-               if(numteams < 2) { numteams = autocvar_g_tdm_teams; }
-
-               int teams = BITS(bound(2, numteams, 4));
-               if(teams & BIT(0))
-                       tdm_SpawnTeam("Red", NUM_TEAM_1);
-               if(teams & BIT(1))
-                       tdm_SpawnTeam("Blue", NUM_TEAM_2);
-               if(teams & BIT(2))
-                       tdm_SpawnTeam("Yellow", NUM_TEAM_3);
-               if(teams & BIT(3))
-                       tdm_SpawnTeam("Pink", NUM_TEAM_4);
-       }
-}
-
 MUTATOR_HOOKFUNCTION(tdm, CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
 {
        M_ARGV(1, string) = "tdm_team";
index c163962faf1b71c1cad060af1b9d7f8554ffec02..3f0a79b0c26c344ef71969ae97bd5645714fad88 100644 (file)
@@ -5,7 +5,10 @@
 int autocvar_g_tdm_point_limit;
 int autocvar_g_tdm_point_leadlimit;
 bool autocvar_g_tdm_team_spawns;
-void tdm_DelayedInit(entity this);
+int autocvar_g_tdm_teams;
+int autocvar_g_tdm_teams_override;
+
+void tdm_SpawnTeam (string teamname, int teamcolor);
 
 REGISTER_MUTATOR(tdm, false)
 {
@@ -17,7 +20,19 @@ REGISTER_MUTATOR(tdm, false)
                GameRules_limit_score(autocvar_g_tdm_point_limit);
         GameRules_limit_lead(autocvar_g_tdm_point_leadlimit);
 
-               InitializeEntity(NULL, tdm_DelayedInit, INITPRIO_GAMETYPE);
+        // if no teams are found, spawn defaults
+        if (find(NULL, classname, "tdm_team") == NULL) {
+            LOG_TRACE("No \"tdm_team\" entities found on this map, creating them anyway.");
+
+            int numteams = autocvar_g_tdm_teams_override;
+            if (numteams < 2) { numteams = autocvar_g_tdm_teams; }
+
+            int teams = BITS(bound(2, numteams, 4));
+            if (teams & BIT(0)) tdm_SpawnTeam("Red", NUM_TEAM_1);
+            if (teams & BIT(1)) tdm_SpawnTeam("Blue", NUM_TEAM_2);
+            if (teams & BIT(2)) tdm_SpawnTeam("Yellow", NUM_TEAM_3);
+            if (teams & BIT(3)) tdm_SpawnTeam("Pink", NUM_TEAM_4);
+        }
        }
        return 0;
 }