]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/spawnpoints.qc
Merge branch 'master' into Mirio/balance
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / spawnpoints.qc
index 36b08008e8b7dedfa643c1b931a60187c18a7e82..711b15df560536d11057ff34b19ef5b506253559 100644 (file)
@@ -15,9 +15,9 @@ bool SpawnPoint_Send(entity this, entity to, int sf)
        WriteHeader(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);
+       WriteCoord(MSG_ENTITY, self.origin.x);
+       WriteCoord(MSG_ENTITY, self.origin.y);
+       WriteCoord(MSG_ENTITY, self.origin.z);
 
        return true;
 }
@@ -30,13 +30,13 @@ bool SpawnEvent_Send(entity this, entity to, int 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);
+               WriteByte(MSG_ENTITY, etof(this.owner));
+               WriteCoord(MSG_ENTITY, this.owner.origin.x);
+               WriteCoord(MSG_ENTITY, this.owner.origin.y);
+               WriteCoord(MSG_ENTITY, this.owner.origin.z);
                send = true;
        }
-       else if((to == self.owner) || (IS_SPEC(to) && (to.enemy == self.owner)) )
+       else if((to == this.owner) || (IS_SPEC(to) && (to.enemy == this.owner)) )
        {
                WriteByte(MSG_ENTITY, 0);
                send = true;
@@ -49,20 +49,21 @@ bool SpawnEvent_Send(entity this, entity to, int sf)
 .vector spawnpoint_prevorigin;
 void spawnpoint_think()
 {
-       self.nextthink = time + 0.1;
-       if(self.origin != self.spawnpoint_prevorigin)
+    SELFPARAM();
+       this.nextthink = time + 0.1;
+       if(this.origin != this.spawnpoint_prevorigin)
        {
-               self.spawnpoint_prevorigin = self.origin;
-               self.SendFlags |= 1;
+               this.spawnpoint_prevorigin = this.origin;
+               this.SendFlags |= 1;
        }
 }
 
-void spawnpoint_use()
-{SELFPARAM();
+void spawnpoint_use(entity this, entity actor, entity trigger)
+{
        if(teamplay)
        if(have_team_spawns > 0)
        {
-               self.team = activator.team;
+               this.team = actor.team;
                some_spawn_has_been_used = 1;
        }
        //LOG_INFO("spawnpoint was used!\n");
@@ -214,7 +215,6 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
 {SELFPARAM();
        float shortest, thisdist;
        float prio;
-       entity player;
 
        prio = 0;
 
@@ -239,12 +239,11 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
        }
 
        shortest = vlen(world.maxs - world.mins);
-       FOR_EACH_PLAYER(player) if (player != self)
-       {
-               thisdist = vlen(player.origin - spot.origin);
+       FOREACH_CLIENT(IS_PLAYER(it) && it != self, LAMBDA(
+               thisdist = vlen(it.origin - spot.origin);
                if (thisdist < shortest)
                        shortest = thisdist;
-       }
+       ));
        if(shortest > mindist)
                prio += SPAWN_PRIO_GOOD_DISTANCE;
 
@@ -262,9 +261,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
                        ++found;
                        if(ent.spawn_evalfunc)
                        {
-                               WITH(entity, self, ent, {
-                                       spawn_score = ent.spawn_evalfunc(this, spot, spawn_score);
-                               });
+                               WITHSELF(ent, spawn_score = ent.spawn_evalfunc(this, spot, spawn_score));
                                if(spawn_score.x < 0)
                                        return spawn_score;
                        }