]> 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 7f852782c18f1b49c04fd8c05eb07b5041d4695a..804165cd93b523f40994afebcafec03323038830 100644 (file)
@@ -84,6 +84,13 @@ void dedicated_print(string input)
        if (server_is_dedicated) print(input);
 }
 
+string GameLog_ProcessIP(string s)
+{
+       if(!autocvar_sv_eventlog_ipv6_delimiter)
+               return s;
+       return strreplace(":", "_", s);
+}
+
 void GameLogEcho(string s)
 {
     string fn;
@@ -849,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")
@@ -894,10 +906,8 @@ void precache_playermodels(string s)
        FOREACH_WORD(s, true, { precache_playermodel(it); });
 }
 
-void precache()
+PRECACHE(PlayerModels)
 {
-    // gamemode related things
-
     // Precache all player models if desired
     if (autocvar_sv_precacheplayermodels)
     {
@@ -917,20 +927,6 @@ void precache()
                precache_playermodels(autocvar_sv_defaultplayermodel_pink);
                precache_playermodels(autocvar_sv_defaultplayermodel);
     }
-
-#if 0
-    // Disabled this code because it simply does not work (e.g. ignores bgmvolume, overlaps with "cd loop" controlled tracks).
-
-    if (!this.noise && this.music) // quake 3 uses the music field
-        this.noise = this.music;
-
-    // plays music for the level if there is any
-    if (this.noise)
-    {
-        precache_sound (this.noise);
-        ambientsound ('0 0 0', this.noise, VOL_BASE, ATTEN_NONE);
-    }
-#endif
 }
 
 
@@ -1267,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;
@@ -1325,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;
@@ -1389,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)