]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator/gamemode_tdm.qc
Remove uses of WITHSELF
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_tdm.qc
index aaa3d516311265b65065e99e9edfa392957cb70a..d245721cb8dc5dcf9f19221cc05876fe291ed6ee 100644 (file)
@@ -1,7 +1,45 @@
-#ifdef IMPLEMENTATION
-bool autocvar_g_tdm_team_spawns;
+#include "gamemode_tdm.qh"
+#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(entity this);
+
+REGISTER_MUTATOR(tdm, false)
+{
+       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);
+
+               ActivateTeamplay();
+               SetLimits(autocvar_g_tdm_point_limit, autocvar_g_tdm_point_leadlimit, autocvar_timelimit_override, -1);
+               if (autocvar_g_tdm_team_spawns)
+                       have_team_spawns = -1; // request team spawns
+       }
+
+       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;
 
@@ -13,10 +51,10 @@ Keys:
 "cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */
 spawnfunc(tdm_team)
 {
-       if(!g_tdm || !self.cnt) { remove(self); return; }
+       if(!g_tdm || !this.cnt) { remove(this); return; }
 
-       self.classname = "tdm_team";
-       self.team = self.cnt + 1;
+       this.classname = "tdm_team";
+       this.team = this.cnt + 1;
 }
 
 // code from here on is just to support maps that don't have team entities
@@ -26,15 +64,15 @@ void tdm_SpawnTeam (string teamname, float teamcolor)
        this.netname = teamname;
        this.cnt = teamcolor;
        this.spawnfunc_checked = true;
-       WITH(entity, self, this, spawnfunc_tdm_team(this));
+       spawnfunc_tdm_team(this);
 }
 
-void tdm_DelayedInit()
+void tdm_DelayedInit(entity this)
 {
        // if no teams are found, spawn defaults
        if(find(world, classname, "tdm_team") == world)
        {
-               LOG_INFO("No ""tdm_team"" entities found on this map, creating them anyway.\n");
+               LOG_TRACE("No \"tdm_team\" entities found on this map, creating them anyway.\n");
 
                int numteams = min(4, autocvar_g_tdm_teams_override);
 
@@ -49,7 +87,7 @@ void tdm_DelayedInit()
 
 MUTATOR_HOOKFUNCTION(tdm, GetTeamCount, CBC_ORDER_EXCLUSIVE)
 {
-       ret_string = "tdm_team";
+       M_ARGV(1, string) = "tdm_team";
        return true;
 }
 
@@ -59,33 +97,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