]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/miscfunctions.qc
Merge branch 'master' into Mario/wepent_experimental
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / miscfunctions.qc
index fb782ed5c6a242efbba13f0bc72dcb7f9676d9ea..220ebc3af1c800006a7c34efd9641b12e5f8b758 100644 (file)
@@ -4,13 +4,14 @@
 #include "constants.qh"
 #include "g_hook.qh"
 #include "ipban.qh"
-#include "mutators/all.qh"
+#include "mutators/_mod.qh"
 #include "../common/t_items.qh"
 #include "weapons/accuracy.qh"
 #include "weapons/csqcprojectile.qh"
 #include "weapons/selection.qh"
-#include "../common/command/generic.qh"
+#include "../common/command/_mod.qh"
 #include "../common/constants.qh"
+#include <common/net_linked.qh>
 #include "../common/deathtypes/all.qh"
 #include "../common/mapinfo.qh"
 #include "../common/notifications/all.qh"
 #include "../common/triggers/subs.qh"
 #include "../common/util.qh"
 #include "../common/turrets/sv_turrets.qh"
-#include "../common/weapons/all.qh"
+#include <common/weapons/_all.qh>
 #include "../common/vehicles/sv_vehicles.qh"
 #include "../common/vehicles/vehicle.qh"
-#include "../common/items/all.qc"
+#include "../common/items/_mod.qh"
 #include "../common/state.qh"
 #include "../common/effects/qc/globalsound.qh"
+#include "../common/wepent.qh"
 #include "../lib/csqcmodel/sv_model.qh"
 #include "../lib/warpzone/anglestransform.qh"
 #include "../lib/warpzone/server.qh"
@@ -97,7 +99,7 @@ void GameLogEcho(string s)
     }
     if (autocvar_sv_eventlog_console)
     {
-        LOG_INFO(s, "\n");
+        dedicated_print(strcat(s, "\n"));
     }
 }
 
@@ -259,6 +261,8 @@ string formatmessage(entity this, string msg)
                replacement = substring(msg, p, 2);
                escape = substring(msg, p + 1, 1);
 
+               .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+
                switch(escape)
                {
                        case "%": replacement = "%"; break;
@@ -269,7 +273,7 @@ string formatmessage(entity this, string msg)
                        case "l": replacement = NearestLocation(this.origin); break;
                        case "y": replacement = NearestLocation(cursor); break;
                        case "d": replacement = NearestLocation(this.death_origin); break;
-                       case "w": replacement = ((PS(this).m_weapon == WEP_Null) ? ((PS(this).m_switchweapon == WEP_Null) ? Weapons_from(this.cnt) : PS(this).m_switchweapon) : PS(this).m_weapon).m_name; break;
+                       case "w": replacement = ((this.(weaponentity).m_weapon == WEP_Null) ? ((this.(weaponentity).m_switchweapon == WEP_Null) ? Weapons_from(this.(weaponentity).cnt) : this.(weaponentity).m_switchweapon) : this.(weaponentity).m_weapon).m_name; break;
                        case "W": replacement = ammoitems; break;
                        case "x": replacement = ((cursor_ent.netname == "" || !cursor_ent) ? "nothing" : cursor_ent.netname); break;
                        case "s": replacement = ftos(vlen(this.velocity - this.velocity_z * '0 0 1')); break;
@@ -447,7 +451,14 @@ void GetCvars(entity this, int f)
        if (f > 0)
        {
                if (s == "cl_weaponpriority")
-                       if (PS(this)) PS(this).m_switchweapon = w_getbestweapon(this);
+               {
+                       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+                       {
+                               .entity weaponentity = weaponentities[slot];
+                               if (this.(weaponentity) && (this.(weaponentity).m_weapon != WEP_Null || slot == 0))
+                                       this.(weaponentity).m_switchweapon = w_getbestweapon(this, weaponentity);
+                       }
+               }
                if (s == "cl_allow_uidtracking")
                        PlayerStats_GameReport_AddPlayer(this);
        }
@@ -1073,7 +1084,7 @@ bool WarpZone_Projectile_Touch_ImpactFilter_Callback(entity this, entity toucher
                if(this.classname == "nade")
                        return false; // no checks here
                else if(this.classname == "grapplinghook")
-                       RemoveGrapplingHook(this.realowner);
+                       RemoveHook(this);
                else if(this.classname == "spike")
                {
                        W_Crylink_Dequeue(this);
@@ -1144,7 +1155,6 @@ float MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundma
 {
     float m, i;
     vector start, org, delta, end, enddown, mstart;
-    entity sp;
 
     m = e.dphitcontentsmask;
     e.dphitcontentsmask = goodcontents | badcontents;
@@ -1200,16 +1210,26 @@ float MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundma
             continue;
 
        // rule 4: we must "see" some spawnpoint or item
-       for(sp = NULL; (sp = find(sp, classname, "info_player_deathmatch")); )
-               if(checkpvs(mstart, sp))
-                       if((traceline(mstart, sp.origin, MOVE_NORMAL, e), trace_fraction) >= 1)
-                               break;
+    entity sp = NULL;
+    IL_EACH(g_spawnpoints, checkpvs(mstart, it),
+    {
+       if((traceline(mstart, it.origin, MOVE_NORMAL, e), trace_fraction) >= 1)
+       {
+               sp = it;
+               break;
+       }
+    });
        if(!sp)
        {
-               for(sp = NULL; (sp = findflags(sp, flags, FL_ITEM)); )
-                       if(checkpvs(mstart, sp))
-                               if((traceline(mstart, sp.origin + (sp.mins + sp.maxs) * 0.5, MOVE_NORMAL, e), trace_fraction) >= 1)
-                                       break;
+               IL_EACH(g_items, checkpvs(mstart, it),
+               {
+                       if((traceline(mstart, it.origin + (it.mins + it.maxs) * 0.5, MOVE_NORMAL, e), trace_fraction) >= 1)
+                       {
+                               sp = it;
+                               break;
+                       }
+               });
+
                if(!sp)
                        continue;
        }