]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/miscfunctions.qc
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / miscfunctions.qc
index 4e2113f53fe3baf148c7c7308c371c51efc45c87..804165cd93b523f40994afebcafec03323038830 100644 (file)
@@ -856,9 +856,14 @@ void readplayerstartcvars()
 
 void precache_playermodel(string m)
 {
-       float globhandle, i, n;
+       int globhandle, i, n;
        string f;
 
+       // remove :<skinnumber> suffix
+       int j = strstrofs(m, ":", 0);
+       if(j >= 0)
+               m = substring(m, 0, j);
+
        if(substring(m, -9, 5) == "_lod1")
                return;
        if(substring(m, -9, 5) == "_lod2")
@@ -1258,7 +1263,7 @@ string uid2name(string myuid)
        return s;
 }
 
-bool MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, int attempts, float maxaboveground, float minviewdistance)
+bool MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax, float goodcontents, float badcontents, float badsurfaceflags, int attempts, float maxaboveground, float minviewdistance, bool frompos)
 {
     float m = e.dphitcontentsmask;
     e.dphitcontentsmask = goodcontents | badcontents;
@@ -1316,14 +1321,22 @@ bool MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax
 
                // rule 4: we must "see" some spawnpoint or item
            entity sp = NULL;
-           IL_EACH(g_spawnpoints, checkpvs(mstart, it),
+           if(frompos)
+           {
+               if((traceline(mstart, e.origin, MOVE_NORMAL, e), trace_fraction) >= 1)
+                       sp = e;
+           }
+           if(!sp)
            {
-               if((traceline(mstart, it.origin, MOVE_NORMAL, e), trace_fraction) >= 1)
-               {
-                       sp = it;
-                       break;
-               }
-           });
+                   IL_EACH(g_spawnpoints, checkpvs(mstart, it),
+                   {
+                       if((traceline(mstart, it.origin, MOVE_NORMAL, e), trace_fraction) >= 1)
+                       {
+                               sp = it;
+                               break;
+                       }
+                   });
+               }
                if(!sp)
                {
                        int items_checked = 0;
@@ -1380,9 +1393,9 @@ bool MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundmax
     return false;
 }
 
-float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance)
+bool MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, int attempts, float maxaboveground, float minviewdistance)
 {
-       return MoveToRandomLocationWithinBounds(e, world.mins, world.maxs, goodcontents, badcontents, badsurfaceflags, attempts, maxaboveground, minviewdistance);
+       return MoveToRandomLocationWithinBounds(e, world.mins, world.maxs, goodcontents, badcontents, badsurfaceflags, attempts, maxaboveground, minviewdistance, false);
 }
 
 void write_recordmarker(entity pl, float tstart, float dt)