]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/spawnpoints.qc
Replace all direct assignments to self with setself(e)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / spawnpoints.qc
index 3f4e72c3b3f584b67c0cc4de06f9f033d568f6db..177e4bc98ce1a5bb7b58beea21f6bd5e2dc1e5c3 100644 (file)
@@ -1,17 +1,28 @@
-float SpawnPoint_Send(entity to, float sf)
-{
+#include "spawnpoints.qh"
+#include "_all.qh"
+
+#include "mutators/mutators_include.qh"
+#include "g_world.qh"
+#include "race.qh"
+#include "../common/constants.qh"
+#include "../common/teams.qh"
+#include "../common/util.qh"
+#include "../warpzonelib/util_server.qh"
+
+float SpawnPoint_Send(entity to, int sf)
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_SPAWNPOINT);
 
        WriteByte(MSG_ENTITY, self.team);
-       WriteShort(MSG_ENTITY, self.origin_x);
-       WriteShort(MSG_ENTITY, self.origin_y);
-       WriteShort(MSG_ENTITY, self.origin_z);
+       WriteShort(MSG_ENTITY, self.origin.x);
+       WriteShort(MSG_ENTITY, self.origin.y);
+       WriteShort(MSG_ENTITY, self.origin.z);
 
-       return TRUE;
+       return true;
 }
 
-float SpawnEvent_Send(entity to, float sf)
-{
+float SpawnEvent_Send(entity to, int sf)
+{SELFPARAM();
        float send;
 
        WriteByte(MSG_ENTITY, ENT_CLIENT_SPAWNEVENT);
@@ -19,54 +30,54 @@ float SpawnEvent_Send(entity to, float sf)
        if(autocvar_g_spawn_alloweffects)
        {
                WriteByte(MSG_ENTITY, num_for_edict(self.owner));
-               WriteShort(MSG_ENTITY, self.owner.origin_x);
-               WriteShort(MSG_ENTITY, self.owner.origin_y);
-               WriteShort(MSG_ENTITY, self.owner.origin_z);
-               send = TRUE;
+               WriteShort(MSG_ENTITY, self.owner.origin.x);
+               WriteShort(MSG_ENTITY, self.owner.origin.y);
+               WriteShort(MSG_ENTITY, self.owner.origin.z);
+               send = true;
        }
        else if((to == self.owner) || (IS_SPEC(to) && (to.enemy == self.owner)) )
        {
                WriteByte(MSG_ENTITY, 0);
-               send = TRUE;
+               send = true;
        }
-       else { send = FALSE; }
+       else { send = false; }
 
        return send;
 }
 
 void spawnpoint_use()
-{
+{SELFPARAM();
        if(teamplay)
        if(have_team_spawns > 0)
        {
                self.team = activator.team;
                some_spawn_has_been_used = 1;
        }
-       print("spawnpoint was used!\n");
+       LOG_INFO("spawnpoint was used!\n");
 }
 
 void relocate_spawnpoint()
-{
+{SELFPARAM();
     // nudge off the floor
     setorigin(self, self.origin + '0 0 1');
 
-    tracebox(self.origin, PL_MIN, PL_MAX, self.origin, TRUE, self);
+    tracebox(self.origin, PL_MIN_CONST, PL_MAX_CONST, self.origin, true, self);
     if (trace_startsolid)
     {
         vector o;
         o = self.origin;
-        self.mins = PL_MIN;
-        self.maxs = PL_MAX;
+        self.mins = PL_MIN_CONST;
+        self.maxs = PL_MAX_CONST;
         if (!move_out_of_solid(self))
             objerror("could not get out of solid at all!");
-        print("^1NOTE: this map needs FIXING. Spawnpoint at ", vtos(o - '0 0 1'));
-        print(" needs to be moved out of solid, e.g. by '", ftos(self.origin_x - o_x));
-        print(" ", ftos(self.origin_y - o_y));
-        print(" ", ftos(self.origin_z - o_z), "'\n");
+        LOG_INFO("^1NOTE: this map needs FIXING. Spawnpoint at ", vtos(o - '0 0 1'));
+        LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(self.origin.x - o.x));
+        LOG_INFO(" ", ftos(self.origin.y - o.y));
+        LOG_INFO(" ", ftos(self.origin.z - o.z), "'\n");
         if (autocvar_g_spawnpoints_auto_move_out_of_solid)
         {
             if (!spawnpoint_nag)
-                print("\{1}^1NOTE: this map needs FIXING (it contains spawnpoints in solid, see server log)\n");
+                LOG_INFO("\{1}^1NOTE: this map needs FIXING (it contains spawnpoints in solid, see server log)\n");
             spawnpoint_nag = 1;
         }
         else
@@ -127,7 +138,7 @@ void relocate_spawnpoint()
                ||
                autocvar_g_spawn_useallspawns
        )
-       { Net_LinkEntity(self, FALSE, 0, SpawnPoint_Send); }
+       { Net_LinkEntity(self, false, 0, SpawnPoint_Send); }
 }
 
 void spawnfunc_info_player_survivor (void)
@@ -141,16 +152,62 @@ void spawnfunc_info_player_start (void)
 }
 
 void spawnfunc_info_player_deathmatch (void)
-{
+{SELFPARAM();
        self.classname = "info_player_deathmatch";
        relocate_spawnpoint();
 }
 
+/*QUAKED spawnfunc_info_player_team1 (1 0 0) (-16 -16 -24) (16 16 24)
+Starting point for a player in team one (Red).
+Keys: "angle" viewing angle when spawning. */
+void spawnfunc_info_player_team1()
+{SELFPARAM();
+       if(g_assault) { remove(self); return; }
+
+       self.team = NUM_TEAM_1; // red
+       spawnfunc_info_player_deathmatch();
+}
+
+
+/*QUAKED spawnfunc_info_player_team2 (1 0 0) (-16 -16 -24) (16 16 24)
+Starting point for a player in team two (Blue).
+Keys: "angle" viewing angle when spawning. */
+void spawnfunc_info_player_team2()
+{SELFPARAM();
+       if(g_assault) { remove(self); return; }
+
+       self.team = NUM_TEAM_2; // blue
+       spawnfunc_info_player_deathmatch();
+}
+
+/*QUAKED spawnfunc_info_player_team3 (1 0 0) (-16 -16 -24) (16 16 24)
+Starting point for a player in team three (Yellow).
+Keys: "angle" viewing angle when spawning. */
+void spawnfunc_info_player_team3()
+{SELFPARAM();
+       if(g_assault) { remove(self); return; }
+
+       self.team = NUM_TEAM_3; // yellow
+       spawnfunc_info_player_deathmatch();
+}
+
+
+/*QUAKED spawnfunc_info_player_team4 (1 0 0) (-16 -16 -24) (16 16 24)
+Starting point for a player in team four (Purple).
+Keys: "angle" viewing angle when spawning. */
+void spawnfunc_info_player_team4()
+{SELFPARAM();
+       if(g_assault) { remove(self); return; }
+
+       self.team = NUM_TEAM_4; // purple
+       spawnfunc_info_player_deathmatch();
+}
+
 // Returns:
 //   _x: prio (-1 if unusable)
 //   _y: weight
 vector Spawn_Score(entity spot, float mindist, float teamcheck)
-{
+{SELFPARAM();
        float shortest, thisdist;
        float prio;
        entity player;
@@ -201,23 +258,21 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
                        ++found;
                        if(ent.spawn_evalfunc)
                        {
-                               entity oldself = self;
-                               self = ent;
-                               spawn_score = ent.spawn_evalfunc(oldself, spot, spawn_score);
-                               self = oldself;
-                               if(spawn_score_x < 0)
+                               spawn_score = SELFCALL(ent, ent.spawn_evalfunc(this, spot, spawn_score));
+                               SELFCALL_DONE();
+                               if(spawn_score.x < 0)
                                        return spawn_score;
                        }
                }
 
                if(!found)
                {
-                       dprint("WARNING: spawnpoint at ", vtos(spot.origin), " could not find its target ", spot.target, "\n");
+                       LOG_TRACE("WARNING: spawnpoint at ", vtos(spot.origin), " could not find its target ", spot.target, "\n");
                        return '-1 0 0';
                }
        }
 
-       MUTATOR_CALLHOOK(Spawn_Score);
+       MUTATOR_CALLHOOK(Spawn_Score, self, spawn_spot, spawn_score);
        return spawn_score;
 }
 
@@ -239,7 +294,7 @@ entity Spawn_FilterOutBadSpots(entity firstspot, float mindist, float teamcheck)
 
        for(spot = firstspot; spot; spot = spot.chain)
        {
-               if(spot.spawnpoint_score_x >= 0) // spawning allowed here
+               if(spot.spawnpoint_score.x >= 0) // spawning allowed here
                {
                        if(spotlistend)
                                spotlistend.chain = spot;
@@ -262,7 +317,7 @@ entity Spawn_WeightedPoint(entity firstspot, float lower, float upper, float exp
 
        RandomSelection_Init();
        for(spot = firstspot; spot; spot = spot.chain)
-               RandomSelection_Add(spot, 0, string_null, pow(bound(lower, spot.spawnpoint_score_y, upper), exponent) * spot.cnt, (spot.spawnpoint_score_y >= lower) * 0.5 + spot.spawnpoint_score_x);
+               RandomSelection_Add(spot, 0, string_null, pow(bound(lower, spot.spawnpoint_score.y, upper), exponent) * spot.cnt, (spot.spawnpoint_score.y >= lower) * 0.5 + spot.spawnpoint_score.x);
 
        return RandomSelection_chosen_ent;
 }
@@ -275,7 +330,7 @@ Finds a point to respawn
 =============
 */
 entity SelectSpawnPoint (float anypoint)
-{
+{SELFPARAM();
        float teamcheck;
        entity spot, firstspot;