]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/miscfunctions.qc
Fix it properly (hopefully)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / miscfunctions.qc
index d5e41b9477edd9a15888aac9faad631c8c527667..9bd602426614ee8107ddf49517e4afc68fa4336d 100644 (file)
@@ -5,7 +5,7 @@
 #include "g_hook.qh"
 #include "ipban.qh"
 #include "mutators/all.qh"
-#include "t_items.qh"
+#include "../common/t_items.qh"
 #include "weapons/accuracy.qh"
 #include "weapons/csqcprojectile.qh"
 #include "weapons/selection.qh"
@@ -417,7 +417,6 @@ void GetCvars(int f)
        GetCvars_handleFloat(s, f, cvar_cl_voice_directional, "cl_voice_directional");
        GetCvars_handleFloat(s, f, cvar_cl_voice_directional_taunt_attenuation, "cl_voice_directional_taunt_attenuation");
 
-       GetCvars_handleFloatOnce(s, f, cvar_cl_gunalign, "cl_gunalign");
        GetCvars_handleFloat(s, f, cvar_cl_allow_uid2name, "cl_allow_uid2name");
        GetCvars_handleFloat(s, f, cvar_cl_allow_uidtracking, "cl_allow_uidtracking");
        GetCvars_handleFloat(s, f, cvar_cl_movement_track_canjump, "cl_movement_track_canjump");
@@ -491,8 +490,7 @@ float want_weapon(entity weaponinfo, float allguns) // WEAPONTODO: what still ne
 
 void readplayerstartcvars()
 {
-       entity e;
-       float i, j, t;
+       float i, t;
        string s;
 
        // initialize starting values for players
@@ -528,24 +526,20 @@ void readplayerstartcvars()
        {
                g_weaponarena = 1;
                g_weaponarena_list = "All Weapons";
-               for (j = WEP_FIRST; j <= WEP_LAST; ++j)
-               {
-                       e = Weapons_from(j);
-                       if (!(e.spawnflags & WEP_FLAG_MUTATORBLOCKED))
-                               g_weaponarena_weapons |= (e.m_wepset);
-               }
+               FOREACH(Weapons, it != WEP_Null, LAMBDA(
+                       if(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED))
+                               g_weaponarena_weapons |= (it.m_wepset);
+               ));
        }
        else if (s == "most")
        {
                g_weaponarena = 1;
                g_weaponarena_list = "Most Weapons";
-               for (j = WEP_FIRST; j <= WEP_LAST; ++j)
-               {
-                       e = Weapons_from(j);
-                       if (!(e.spawnflags & WEP_FLAG_MUTATORBLOCKED))
-                               if (e.spawnflags & WEP_FLAG_NORMAL)
-                                       g_weaponarena_weapons |= (e.m_wepset);
-               }
+               FOREACH(Weapons, it != WEP_Null, LAMBDA(
+                       if(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED))
+                               if(it.spawnflags & WEP_FLAG_NORMAL)
+                                       g_weaponarena_weapons |= (it.m_wepset);
+               ));
        }
        else if (s == "none")
        {
@@ -560,20 +554,14 @@ void readplayerstartcvars()
                for (i = 0; i < t; ++i)
                {
                        s = argv(i);
-                       for (j = WEP_FIRST; j <= WEP_LAST; ++j)
-                       {
-                               e = Weapons_from(j);
-                               if (e.netname == s)
+                       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+                               if(it.netname == s)
                                {
-                                       g_weaponarena_weapons |= (e.m_wepset);
-                                       g_weaponarena_list = strcat(g_weaponarena_list, e.m_name, " & ");
+                                       g_weaponarena_weapons |= (it.m_wepset);
+                                       g_weaponarena_list = strcat(g_weaponarena_list, it.m_name, " & ");
                                        break;
                                }
-                       }
-                       if (j > WEP_LAST)
-                       {
-                               LOG_INFO("The weapon mutator list contains an unknown weapon ", s, ". Skipped.\n");
-                       }
+                       ));
                }
                g_weaponarena_list = strzone(substring(g_weaponarena_list, 0, strlen(g_weaponarena_list) - 3));
        }
@@ -592,18 +580,16 @@ void readplayerstartcvars()
        }
        else
        {
-               for (i = WEP_FIRST; i <= WEP_LAST; ++i)
-               {
-                       e = Weapons_from(i);
-                       int w = want_weapon(e, false);
-                       WepSet s = e.m_wepset;
+               FOREACH(Weapons, it != WEP_Null, LAMBDA(
+                       int w = want_weapon(it, false);
+                       WepSet s = it.m_wepset;
                        if(w & 1)
                                start_weapons |= s;
                        if(w & 2)
                                start_weapons_default |= s;
                        if(w & 4)
                                start_weapons_defaultmask |= s;
-               }
+               ));
        }
 
        if(!cvar("g_use_ammunition"))
@@ -655,18 +641,16 @@ void readplayerstartcvars()
                        warmup_start_weapons = '0 0 0';
                        warmup_start_weapons_default = '0 0 0';
                        warmup_start_weapons_defaultmask = '0 0 0';
-                       for (i = WEP_FIRST; i <= WEP_LAST; ++i)
-                       {
-                               e = Weapons_from(i);
-                               int w = want_weapon(e, g_warmup_allguns);
-                               WepSet s = (e.m_wepset);
+                       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+                               int w = want_weapon(it, g_warmup_allguns);
+                               WepSet s = (it.m_wepset);
                                if(w & 1)
                                        warmup_start_weapons |= s;
                                if(w & 2)
                                        warmup_start_weapons_default |= s;
                                if(w & 4)
                                        warmup_start_weapons_defaultmask |= s;
-                       }
+                       ));
                }
        }
 
@@ -685,13 +669,10 @@ void readplayerstartcvars()
        WepSet precache_weapons = start_weapons;
        if (g_warmup_allguns != 1)
                precache_weapons |= warmup_start_weapons;
-       for (i = WEP_FIRST; i <= WEP_LAST; ++i)
-       {
-               e = Weapons_from(i);
-               if(precache_weapons & (e.m_wepset)) {
-                       e.wr_init(e);
-               }
-       }
+       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+               if(precache_weapons & (it.m_wepset))
+                       it.wr_init(it);
+       ));
 
        start_ammo_shells = max(0, start_ammo_shells);
        start_ammo_nails = max(0, start_ammo_nails);
@@ -983,7 +964,7 @@ void adaptor_think2use()
 
 void adaptor_think2use_hittype_splash() // for timed projectile detonation
 {SELFPARAM();
-       if(!(self.flags & FL_ONGROUND)) // if onground, we ARE touching something, but HITTYPE_SPLASH is to be networked if the damage causing projectile is not touching ANYTHING
+       if(!(IS_ONGROUND(self))) // if onground, we ARE touching something, but HITTYPE_SPLASH is to be networked if the damage causing projectile is not touching ANYTHING
                self.projectiledeathtype |= HITTYPE_SPLASH;
        adaptor_think2use();
 }
@@ -1060,7 +1041,7 @@ float SUB_NoImpactCheck()
        if(trace_dphitcontents == 0)
        {
                //dprint("A hit happened with zero hit contents... DEBUG THIS, this should never happen for projectiles! Projectile will self-destruct.\n");
-               LOG_TRACEF("A hit from a projectile happened with no hit contents! DEBUG THIS, this should never happen for projectiles! Profectile will self-destruct. (edict: %d, classname: %s, origin: %s)\n", num_for_edict(self), self.classname, vtos(self.origin));
+               LOG_TRACEF("A hit from a projectile happened with no hit contents! DEBUG THIS, this should never happen for projectiles! Profectile will self-destruct. (edict: %d, classname: %s, origin: %s)\n", etof(self), self.classname, vtos(self.origin));
                checkclient();
        }
     if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)