]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/spawnpoints.qc
Phase out miscfunctions.qc from the server codebase, preferring more fitting location...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / spawnpoints.qc
index 616824bbcbb78b4c0ebe2f2a67cd1ca65d54fc90..4bcffe68a4c2b5a0a762edbafa7eb75eff3cd506 100644 (file)
@@ -1,19 +1,23 @@
 #include "spawnpoints.qh"
 
 #include <server/mutators/_mod.qh>
-#include "g_world.qh"
+#include <server/world.qh>
 #include "race.qh"
-#include "defs.qh"
+#include <common/weapons/_all.qh>
+#include <common/stats.qh>
 #include "../common/constants.qh"
 #include <common/net_linked.qh>
 #include "../common/teams.qh"
-#include <common/mapinfo.qh>
+#include <common/gamemodes/_mod.qh>
 #include "../common/mapobjects/subs.qh"
 #include "../common/mapobjects/target/spawnpoint.qh"
+#include <common/mapobjects/triggers.qh>
 #include "../common/util.qh"
 #include "../lib/warpzone/common.qh"
 #include "../lib/warpzone/util_server.qh"
+#include <server/intermission.qh>
 #include <server/utils.qh>
+#include <server/command/vote.qh>
 
 bool SpawnPoint_Send(entity this, entity to, int sf)
 {
@@ -75,6 +79,17 @@ void spawnpoint_reset(entity this)
        this.SendFlags |= 1; // update team since it was restored during reset
 }
 
+void link_spawnpoint(entity this)
+{
+       bool anypoint = (autocvar_g_spawn_useallspawns || (teamplay && have_team_spawns <= 0)); // TODO: check if available teams is equal to spawnpoints available
+
+       // Don't show team spawns in non-team matches,
+       // and don't show non-team spawns in team matches.
+       // (Unless useallspawns is activated)
+       if(anypoint || !((teamplay && !Team_IsValidTeam(this.team)) || (!teamplay && Team_IsValidTeam(this.team))))
+               Net_LinkEntity(this, false, 0, SpawnPoint_Send);
+}
+
 void relocate_spawnpoint(entity this)
 {
     // nudge off the floor
@@ -134,34 +149,8 @@ void relocate_spawnpoint(entity this)
         e.solid = SOLID_TRIGGER;
     }
 
-       // Don't show team spawns in non-team matches,
-       // and don't show non-team spawns in team matches.
-       // (Unless useallspawns is activated)
-       if(
-               !(
-                       ( // if this passes, there is a DM spawn on a team match
-                               teamplay
-                               && (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
-                               &&
-                               (
-                                       (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(this, false, 0, SpawnPoint_Send); }
+    // network it after all spawnpoints are setup, so that we can check if team spawnpoints are used
+       InitializeEntity(this, link_spawnpoint, INITPRIO_FINDTARGET);
 }
 
 spawnfunc(info_player_survivor)
@@ -246,7 +235,7 @@ vector Spawn_Score(entity this, entity spot, float mindist, float teamcheck, boo
 
        float prio = 0;
        float shortest = vlen(world.maxs - world.mins);
-       FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
+       FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it) && it != this, {
                float thisdist = vlen(it.origin - spot.origin);
                if (thisdist < shortest)
                        shortest = thisdist;