]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/teleporters.qc
Move some variables out of constants.qh
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / teleporters.qc
index a1a38d39e1a95e24459d2a2c4c1a5bb857c7de27..451afa95b4a3d4d0500064d55e219ca94cc822a5 100644 (file)
@@ -20,6 +20,7 @@
     #include <server/anticheat.qh>
 #endif
 
+#ifdef SVQC
 float check_tdeath(entity player, vector org, vector telefragmin, vector telefragmax)
 {
        if (IS_PLAYER(player) && !IS_DEAD(player))
@@ -37,8 +38,6 @@ float check_tdeath(entity player, vector org, vector telefragmin, vector telefra
        return 0;
 }
 
-#ifdef SVQC
-
 void trigger_teleport_link(entity this);
 
 void tdeath(entity player, entity teleporter, entity telefragger, vector telefragmin, vector telefragmax)
@@ -64,7 +63,6 @@ void spawn_tdeath(vector v0, entity e, vector v)
 {
        tdeath(e, e, e, '0 0 0', '0 0 0');
 }
-
 #endif
 
 void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity, vector telefragmin, vector telefragmax, float tflags)
@@ -92,7 +90,7 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle
                                        RandomSelection_Init();
                                        FOREACH_WORD(teleporter.noise, true,
                                        {
-                                               RandomSelection_Add(NULL, 0, it, 1, 1);
+                                               RandomSelection_AddString(it, 1, 1);
                                        });
                                        thesound = RandomSelection_chosen_string;
                                }
@@ -174,8 +172,7 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle
 entity Simple_TeleportPlayer(entity teleporter, entity player)
 {
        vector locout;
-       entity e;
-       float p;
+       entity e = NULL;
 
        // Find the output teleporter
        if(teleporter.enemy)
@@ -184,10 +181,12 @@ entity Simple_TeleportPlayer(entity teleporter, entity player)
        }
        else
        {
+               // sorry CSQC, random stuff ain't gonna happen
+#ifdef SVQC
                RandomSelection_Init();
                FOREACH_ENTITY_STRING(targetname, teleporter.target,
                {
-                       p = 1;
+                       bool p = true;
                        if(STAT(TELEPORT_TELEFRAG_AVOID, player))
                        {
                        #ifdef SVQC
@@ -196,11 +195,12 @@ entity Simple_TeleportPlayer(entity teleporter, entity player)
                                locout = it.origin + '0 0 1' * (1 - player.mins.z - 24);
                        #endif
                                if(check_tdeath(player, locout, '0 0 0', '0 0 0'))
-                                       p = 0;
+                                       p = false;
                        }
-                       RandomSelection_Add(it, 0, string_null, (it.cnt ? it.cnt : 1), p);
+                       RandomSelection_AddEnt(it, (it.cnt ? it.cnt : 1), p);
                });
                e = RandomSelection_chosen_ent;
+#endif
        }
 
 #ifdef SVQC
@@ -267,10 +267,10 @@ void teleport_findtarget(entity this)
 
 entity Teleport_Find(vector mi, vector ma)
 {
-       entity e;
-       for(e = NULL; (e = find(e, classname, "trigger_teleport")); )
-               if(WarpZoneLib_BoxTouchesBrush(mi, ma, e, NULL))
-                       return e;
+       IL_EACH(g_teleporters, WarpZoneLib_BoxTouchesBrush(mi, ma, it, NULL),
+       {
+               return it;
+       });
        return NULL;
 }