]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean out self uses from spawnpoint code
authorMario <mario@smbclan.net>
Thu, 19 May 2016 19:29:23 +0000 (05:29 +1000)
committerMario <mario@smbclan.net>
Thu, 19 May 2016 19:29:23 +0000 (05:29 +1000)
qcsrc/common/mutators/mutator/buffs/buffs.qc
qcsrc/server/cl_client.qc
qcsrc/server/defs.qh
qcsrc/server/g_damage.qc
qcsrc/server/mutators/mutator/gamemode_assault.qc
qcsrc/server/mutators/mutator/gamemode_keepaway.qc
qcsrc/server/portals.qc
qcsrc/server/race.qc
qcsrc/server/spawnpoints.qc
qcsrc/server/spawnpoints.qh

index 5ed63b538a7715d654e9f7f2871ca4ae5684f2ee..3ab9bc1cd0f962e0e5982c790d3dcfa6f23069ea 100644 (file)
@@ -197,7 +197,7 @@ void buff_Respawn(entity this)
        if(!MoveToRandomMapLocation(this, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY,
                ((autocvar_g_buffs_random_location_attempts > 0) ? autocvar_g_buffs_random_location_attempts : 10), 1024, 256))
        {
-               entity spot = SelectSpawnPoint(true);
+               entity spot = SelectSpawnPoint(this, true);
                setorigin(this, spot.origin);
                this.velocity = ((randomvec() * 100) + '0 0 200');
                this.angles = spot.angles;
index c157530fa7d39b9cbbb1e7597ce03aba5db0aa58..3ffc73820f186749499eaae5d3dfc73cbe992f5e 100644 (file)
@@ -196,7 +196,7 @@ void PutObserverInServer()
     }
 
     {
-        entity spot = SelectSpawnPoint(true);
+        entity spot = SelectSpawnPoint(this, true);
         if (!spot) LOG_FATAL("No spawnpoints for observers?!?");
         this.angles = spot.angles;
         this.angles_z = 0;
@@ -471,7 +471,7 @@ void PutClientInServer()
                if (this.team < 0)
                        JoinBestTeam(this, false, true);
 
-               entity spot = SelectSpawnPoint(false);
+               entity spot = SelectSpawnPoint(this, false);
                if (!spot) {
                        Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_JOIN_NOSPAWNS);
                        return; // spawn failed
index 29374036cf4c4d5e7007b1d261ef1e2166e73563..1ad60e8685c844bf7a7980e1635c4a3d7cd22d6c 100644 (file)
@@ -408,7 +408,7 @@ const float ACTIVE_TOGGLE   = 3;
 
 void PlayerUseKey();
 
-USING(spawn_evalfunc_t, vector(entity player, entity spot, vector current));
+USING(spawn_evalfunc_t, vector(entity this, entity player, entity spot, vector current));
 .spawn_evalfunc_t spawn_evalfunc;
 
 string modname;
index 675b794ecdb902b73e018f3ccaad6356e4feeb42..b30f2353ba726989d4ba13c4e13696e8cad84c2f 100644 (file)
@@ -726,37 +726,34 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
                {
                        Send_Effect(EFFECT_TELEPORT, targ.origin, '0 0 0', 1);
 
-                       setself(targ);
-                       entity spot = SelectSpawnPoint (false);
+                       entity spot = SelectSpawnPoint (targ, false);
 
                        if(spot)
                        {
                                damage = 0;
-                               self.deadflag = DEAD_NO;
+                               targ.deadflag = DEAD_NO;
 
-                               self.angles = spot.angles;
+                               targ.angles = spot.angles;
 
-                               self.effects = 0;
-                               self.effects |= EF_TELEPORT_BIT;
+                               targ.effects = 0;
+                               targ.effects |= EF_TELEPORT_BIT;
 
-                               self.angles_z = 0; // never spawn tilted even if the spot says to
-                               self.fixangle = true; // turn this way immediately
-                               self.velocity = '0 0 0';
-                               self.avelocity = '0 0 0';
-                               self.punchangle = '0 0 0';
-                               self.punchvector = '0 0 0';
-                               self.oldvelocity = self.velocity;
+                               targ.angles_z = 0; // never spawn tilted even if the spot says to
+                               targ.fixangle = true; // turn this way immediately
+                               targ.velocity = '0 0 0';
+                               targ.avelocity = '0 0 0';
+                               targ.punchangle = '0 0 0';
+                               targ.punchvector = '0 0 0';
+                               targ.oldvelocity = targ.velocity;
 
-                               self.spawnorigin = spot.origin;
-                               setorigin (self, spot.origin + '0 0 1' * (1 - self.mins.z - 24));
+                               targ.spawnorigin = spot.origin;
+                               setorigin (targ, spot.origin + '0 0 1' * (1 - targ.mins.z - 24));
                                // don't reset back to last position, even if new position is stuck in solid
-                               self.oldorigin = self.origin;
-                               self.prevorigin = self.origin;
+                               targ.oldorigin = targ.origin;
+                               targ.prevorigin = targ.origin;
 
-                               Send_Effect(EFFECT_TELEPORT, self.origin, '0 0 0', 1);
+                               Send_Effect(EFFECT_TELEPORT, targ.origin, '0 0 0', 1);
                        }
-
-                       setself(this);
                }
 
                if(!g_instagib)
index 26038b2bb3cf46a16e6ea597d3caaf4ac17dc25f..d961fa14d7f6b601c816b276809491c4334d58d8 100644 (file)
@@ -85,9 +85,9 @@ void assault_objective_use(entity this, entity actor, entity trigger)
        }
 }
 
-vector target_objective_spawn_evalfunc(entity player, entity spot, vector current)
-{SELFPARAM();
-       if(self.health < 0 || self.health >= ASSAULT_VALUE_INACTIVE)
+vector target_objective_spawn_evalfunc(entity this, entity player, entity spot, vector current)
+{
+       if(this.health < 0 || this.health >= ASSAULT_VALUE_INACTIVE)
                return '-1 0 0';
        return current;
 }
index 5bc93fb33fc4e1d9bbcfe5f955ab7378aeec0681..4bed375b42d554e5816e01fb01c40b36dcd4ef47 100644 (file)
@@ -89,7 +89,7 @@ void ka_RespawnBall(entity this) // runs whenever the ball needs to be relocated
 
        if(!MoveToRandomMapLocation(self, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 10, 1024, 256))
        {
-               entity spot = SelectSpawnPoint(true);
+               entity spot = SelectSpawnPoint(this, true);
                setorigin(self, spot.origin);
                self.angles = spot.angles;
        }
index e3cba938335f83b3752732db2bdbe7f8bebe95a1..00cc50238dd86833cee339cfe3a307c3fbb38c1a 100644 (file)
@@ -440,16 +440,16 @@ void Portal_Damage(entity this, entity inflictor, entity attacker, float damage,
                Portal_Remove(this, 1);
 }
 
-void Portal_Think_TryTeleportPlayer(entity e, vector g)
-{SELFPARAM();
-       if(!Portal_WillHitPlane(e.origin, e.mins, e.maxs, e.velocity + g, self.origin, v_forward, self.maxs.x))
+void Portal_Think_TryTeleportPlayer(entity this, entity e, vector g)
+{
+       if(!Portal_WillHitPlane(e.origin, e.mins, e.maxs, e.velocity + g, this.origin, v_forward, this.maxs.x))
                return;
 
        // if e would hit the portal in a frame...
        // already teleport him
        tracebox(e.origin, e.mins, e.maxs, e.origin + e.velocity * 2 * frametime, MOVE_NORMAL, e);
-       if(trace_ent == self)
-               Portal_TeleportPlayer(self, e);
+       if(trace_ent == this)
+               Portal_TeleportPlayer(this, e);
 }
 
 void Portal_Think()
@@ -479,10 +479,10 @@ void Portal_Think()
                                continue; // cannot go through someone else's portal
 
                if(it != o || time >= self.portal_activatetime)
-                       Portal_Think_TryTeleportPlayer(it, g);
+                       Portal_Think_TryTeleportPlayer(self, it, g);
 
                if(it.hook)
-                       Portal_Think_TryTeleportPlayer(it.hook, g);
+                       Portal_Think_TryTeleportPlayer(self, it.hook, g);
        ));
        self.solid = SOLID_TRIGGER;
        self.aiment = o;
index ba13b14a95a64275b38a4290f3504f650c71652e..6fb39f6ce71cac1007025543fc982cbf2a9f8258 100644 (file)
@@ -741,7 +741,7 @@ void trigger_race_checkpoint_verify(entity this)
                        // race only (middle of the race)
                        g_race_qualifying = false;
                        pl_race_place = 0;
-                       if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+                       if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) {
                                error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for respawning in race) - bailing out"));
             }
 
@@ -749,7 +749,7 @@ void trigger_race_checkpoint_verify(entity this)
                                // qualifying only
                                g_race_qualifying = 1;
                                pl_race_place = race_lowest_place_spawn;
-                               if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+                               if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) {
                                        error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for qualifying) - bailing out"));
                 }
 
@@ -757,7 +757,7 @@ void trigger_race_checkpoint_verify(entity this)
                                g_race_qualifying = 0;
                                for (int p = 1; p <= race_highest_place_spawn; ++p) {
                                        pl_race_place = p;
-                                       if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+                                       if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) {
                                                error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for initially spawning in race) - bailing out"));
                     }
                                }
@@ -768,7 +768,7 @@ void trigger_race_checkpoint_verify(entity this)
                pl_race_checkpoint = race_NextCheckpoint(0);
                g_race_qualifying = 1;
                pl_race_place = race_lowest_place_spawn;
-               if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) {
+               if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) {
                        error(strcat("Checkpoint 0 misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for qualifying) - bailing out"));
         }
        } else {
@@ -872,27 +872,26 @@ void trigger_race_checkpoint_verify(entity this)
        }
 }
 
-vector trigger_race_checkpoint_spawn_evalfunc(entity player, entity spot, vector current)
-{SELFPARAM();
+vector trigger_race_checkpoint_spawn_evalfunc(entity this, entity player, entity spot, vector current)
+{
        if(g_race_qualifying)
        {
                // spawn at first
-               if(self.race_checkpoint != 0)
+               if(this.race_checkpoint != 0)
                        return '-1 0 0';
                if(spot.race_place != race_lowest_place_spawn)
                        return '-1 0 0';
        }
        else
        {
-               if(self.race_checkpoint != player.race_respawn_checkpoint)
+               if(this.race_checkpoint != player.race_respawn_checkpoint)
                        return '-1 0 0';
                // try reusing the previous spawn
-               if(self == player.race_respawn_spotref || spot == player.race_respawn_spotref)
+               if(this == player.race_respawn_spotref || spot == player.race_respawn_spotref)
                        current.x += SPAWN_PRIO_RACE_PREVIOUS_SPAWN;
-               if(self.race_checkpoint == 0)
+               if(this.race_checkpoint == 0)
                {
-                       float pl;
-                       pl = player.race_place;
+                       int pl = player.race_place;
                        if(pl > race_highest_place_spawn)
                                pl = 0;
                        if(pl == 0 && !player.race_started)
index 711b15df560536d11057ff34b19ef5b506253559..e7268a88f36c5ed50a3aa47a1b7afeba2532005d 100644 (file)
@@ -14,10 +14,10 @@ bool SpawnPoint_Send(entity this, entity to, int sf)
 {
        WriteHeader(MSG_ENTITY, ENT_CLIENT_SPAWNPOINT);
 
-       WriteByte(MSG_ENTITY, self.team);
-       WriteCoord(MSG_ENTITY, self.origin.x);
-       WriteCoord(MSG_ENTITY, self.origin.y);
-       WriteCoord(MSG_ENTITY, self.origin.z);
+       WriteByte(MSG_ENTITY, this.team);
+       WriteCoord(MSG_ENTITY, this.origin.x);
+       WriteCoord(MSG_ENTITY, this.origin.y);
+       WriteCoord(MSG_ENTITY, this.origin.z);
 
        return true;
 }
@@ -69,24 +69,24 @@ void spawnpoint_use(entity this, entity actor, entity trigger)
        //LOG_INFO("spawnpoint was used!\n");
 }
 
-void relocate_spawnpoint()
-{SELFPARAM();
+void relocate_spawnpoint(entity this)
+{
     // nudge off the floor
-    setorigin(self, self.origin + '0 0 1');
+    setorigin(this, this.origin + '0 0 1');
 
-    tracebox(self.origin, PL_MIN_CONST, PL_MAX_CONST, self.origin, true, self);
+    tracebox(this.origin, PL_MIN_CONST, PL_MAX_CONST, this.origin, true, this);
     if (trace_startsolid)
     {
         vector o;
-        o = self.origin;
-        self.mins = PL_MIN_CONST;
-        self.maxs = PL_MAX_CONST;
-        if (!move_out_of_solid(self))
+        o = this.origin;
+        this.mins = PL_MIN_CONST;
+        this.maxs = PL_MAX_CONST;
+        if (!move_out_of_solid(this))
             objerror("could not get out of solid at all!");
         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");
+        LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(this.origin.x - o.x));
+        LOG_INFO(" ", ftos(this.origin.y - o.y));
+        LOG_INFO(" ", ftos(this.origin.z - o.z), "'\n");
         if (autocvar_g_spawnpoints_auto_move_out_of_solid)
         {
             if (!spawnpoint_nag)
@@ -95,31 +95,31 @@ void relocate_spawnpoint()
         }
         else
         {
-            setorigin(self, o);
-            self.mins = self.maxs = '0 0 0';
+            setorigin(this, o);
+            this.mins = this.maxs = '0 0 0';
             objerror("player spawn point in solid, mapper sucks!\n");
             return;
         }
     }
 
-    self.use = spawnpoint_use;
-    self.think = spawnpoint_think;
-    self.nextthink = time + 0.5 + random() * 2; // shouldn't need it for a little second
-    self.team_saved = self.team;
-    if (!self.cnt)
-        self.cnt = 1;
+    this.use = spawnpoint_use;
+    this.think = spawnpoint_think;
+    this.nextthink = time + 0.5 + random() * 2; // shouldn't need it for a little second
+    this.team_saved = this.team;
+    if (!this.cnt)
+        this.cnt = 1;
 
     if (have_team_spawns != 0)
-        if (self.team)
+        if (this.team)
             have_team_spawns = 1;
-    have_team_spawns_forteam[self.team] = 1;
+    have_team_spawns_forteam[this.team] = 1;
 
     if (autocvar_r_showbboxes)
     {
         // show where spawnpoints point at too
-        makevectors(self.angles);
+        makevectors(this.angles);
         entity e = new(info_player_foo);
-        setorigin(e, self.origin + v_forward * 24);
+        setorigin(e, this.origin + v_forward * 24);
         setsize(e, '-8 -8 -8', '8 8 8');
         e.solid = SOLID_TRIGGER;
     }
@@ -131,27 +131,27 @@ void relocate_spawnpoint()
                !(
                        ( // if this passes, there is a DM spawn on a team match
                                teamplay
-                               && (self.team != NUM_TEAM_1)
-                               && (self.team != NUM_TEAM_2)
-                               && (self.team != NUM_TEAM_3)
-                               && (self.team != NUM_TEAM_4)
+                               && (this.team != NUM_TEAM_1)
+                               && (this.team != NUM_TEAM_2)
+                               && (this.team != NUM_TEAM_3)
+                               && (this.team != NUM_TEAM_4)
                        )
                        ||
                        ( // if this passes, there is a team spawn on a DM match
                                !teamplay
                                &&
                                (
-                                       (self.team == NUM_TEAM_1)
-                                       || (self.team == NUM_TEAM_2)
-                                       || (self.team == NUM_TEAM_3)
-                                       || (self.team == NUM_TEAM_4)
+                                       (this.team == NUM_TEAM_1)
+                                       || (this.team == NUM_TEAM_2)
+                                       || (this.team == NUM_TEAM_3)
+                                       || (this.team == NUM_TEAM_4)
                                )
                        )
                )
                ||
                autocvar_g_spawn_useallspawns
        )
-       { Net_LinkEntity(self, false, 0, SpawnPoint_Send); }
+       { Net_LinkEntity(this, false, 0, SpawnPoint_Send); }
 }
 
 spawnfunc(info_player_survivor)
@@ -166,8 +166,8 @@ spawnfunc(info_player_start)
 
 spawnfunc(info_player_deathmatch)
 {
-       self.classname = "info_player_deathmatch";
-       relocate_spawnpoint();
+       this.classname = "info_player_deathmatch";
+       relocate_spawnpoint(this);
 }
 
 /*QUAKED spawnfunc_info_player_team1 (1 0 0) (-16 -16 -24) (16 16 24)
@@ -211,8 +211,8 @@ spawnfunc(info_player_team4)
 // Returns:
 //   _x: prio (-1 if unusable)
 //   _y: weight
-vector Spawn_Score(entity spot, float mindist, float teamcheck)
-{SELFPARAM();
+vector Spawn_Score(entity this, entity spot, float mindist, float teamcheck)
+{
        float shortest, thisdist;
        float prio;
 
@@ -227,7 +227,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
                if(spot.target == "")
                        return '-1 0 0';
 
-       if(IS_REAL_CLIENT(self))
+       if(IS_REAL_CLIENT(this))
        {
                if(spot.restriction == 1)
                        return '-1 0 0';
@@ -239,7 +239,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
        }
 
        shortest = vlen(world.maxs - world.mins);
-       FOREACH_CLIENT(IS_PLAYER(it) && it != self, LAMBDA(
+       FOREACH_CLIENT(IS_PLAYER(it) && it != this, LAMBDA(
                thisdist = vlen(it.origin - spot.origin);
                if (thisdist < shortest)
                        shortest = thisdist;
@@ -261,7 +261,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
                        ++found;
                        if(ent.spawn_evalfunc)
                        {
-                               WITHSELF(ent, spawn_score = ent.spawn_evalfunc(this, spot, spawn_score));
+                               spawn_score = ent.spawn_evalfunc(ent, this, spot, spawn_score);
                                if(spawn_score.x < 0)
                                        return spawn_score;
                        }
@@ -274,25 +274,25 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
                }
        }
 
-       MUTATOR_CALLHOOK(Spawn_Score, self, spawn_spot, spawn_score);
+       MUTATOR_CALLHOOK(Spawn_Score, this, spawn_spot, spawn_score);
        return spawn_score;
 }
 
-void Spawn_ScoreAll(entity firstspot, float mindist, float teamcheck)
+void Spawn_ScoreAll(entity this, entity firstspot, float mindist, float teamcheck)
 {
        entity spot;
        for(spot = firstspot; spot; spot = spot.chain)
-               spot.spawnpoint_score = Spawn_Score(spot, mindist, teamcheck);
+               spot.spawnpoint_score = Spawn_Score(this, spot, mindist, teamcheck);
 }
 
-entity Spawn_FilterOutBadSpots(entity firstspot, float mindist, float teamcheck)
+entity Spawn_FilterOutBadSpots(entity this, entity firstspot, float mindist, float teamcheck)
 {
        entity spot, spotlist, spotlistend;
 
        spotlist = world;
        spotlistend = world;
 
-       Spawn_ScoreAll(firstspot, mindist, teamcheck);
+       Spawn_ScoreAll(this, firstspot, mindist, teamcheck);
 
        for(spot = firstspot; spot; spot = spot.chain)
        {
@@ -331,8 +331,8 @@ SelectSpawnPoint
 Finds a point to respawn
 =============
 */
-entity SelectSpawnPoint (float anypoint)
-{SELFPARAM();
+entity SelectSpawnPoint(entity this, bool anypoint)
+{
        float teamcheck;
        entity spot, firstspot;
 
@@ -344,7 +344,7 @@ entity SelectSpawnPoint (float anypoint)
                teamcheck = -1;
        else if(have_team_spawns > 0)
        {
-               if(have_team_spawns_forteam[self.team] == 0)
+               if(have_team_spawns_forteam[this.team] == 0)
                {
                        // we request a spawn for a team, and we have team
                        // spawns, but that team has no spawns?
@@ -356,7 +356,7 @@ entity SelectSpawnPoint (float anypoint)
                                teamcheck = -1;
                }
                else
-                       teamcheck = self.team; // MUST be team
+                       teamcheck = this.team; // MUST be team
        }
        else if(have_team_spawns == 0 && have_team_spawns_forteam[0])
                teamcheck = 0; // MUST be noteam
@@ -375,7 +375,7 @@ entity SelectSpawnPoint (float anypoint)
        }
        else
        {
-               firstspot = Spawn_FilterOutBadSpots(firstspot, 100, teamcheck);
+               firstspot = Spawn_FilterOutBadSpots(this, firstspot, 100, teamcheck);
 
                // there is 50/50 chance of choosing a random spot or the furthest spot
                // (this means that roughly every other spawn will be furthest, so you
index a22ebb60c82323c89b018d40447ccef70bd0710a..56e00b5ac5258c7bc7b8f8a82bea0a0f75eb8bf3 100644 (file)
@@ -3,7 +3,7 @@
 .vector spawnpoint_score;
 float spawnpoint_nag;
 bool SpawnEvent_Send(entity this, entity to, int sf);
-entity Spawn_FilterOutBadSpots(entity firstspot, float mindist, float teamcheck);
-entity SelectSpawnPoint (float anypoint);
+entity Spawn_FilterOutBadSpots(entity this, entity firstspot, float mindist, float teamcheck);
+entity SelectSpawnPoint(entity this, bool anypoint);
 spawnfunc(info_player_deathmatch);
 void spawnpoint_use(entity this, entity actor, entity trigger);