From 5378847f6b3ac586b6319fdde288946b3c22ba8b Mon Sep 17 00:00:00 2001
From: Mario <mario.mario@y7mail.com>
Date: Sat, 25 Jan 2020 16:45:34 +1000
Subject: [PATCH] Remove the precache function, mostly unused (playermodels now
 precache themselves using the standard PRECACHE methods)

---
 qcsrc/server/g_world.qc       | 50 -----------------------------------
 qcsrc/server/miscfunctions.qc | 18 +------------
 qcsrc/server/miscfunctions.qh |  2 --
 qcsrc/server/portals.qc       |  9 +++----
 4 files changed, 5 insertions(+), 74 deletions(-)

diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc
index 2a3ede6b8..5ccfc97cc 100644
--- a/qcsrc/server/g_world.qc
+++ b/qcsrc/server/g_world.qc
@@ -813,8 +813,6 @@ spawnfunc(worldspawn)
 		if(this.spawnflags & SPAWNFLAG_NO_WAYPOINTS_FOR_ITEMS)
 			bot_waypoints_for_items = 0;
 
-	precache();
-
 	WaypointSprite_Init();
 
 	GameLogInit(); // prepare everything
@@ -1418,54 +1416,6 @@ void IntermissionThink(entity this)
 	MapVote_Start();
 }
 
-/*
-============
-FindIntermission
-
-Returns the entity to view from
-============
-*/
-/*
-entity FindIntermission()
-{
-	local	entity spot;
-	local	float cyc;
-
-// look for info_intermission first
-	spot = find(NULL, classname, "info_intermission");
-	if (spot)
-	{	// pick a random one
-		cyc = random() * 4;
-		while (cyc > 1)
-		{
-			spot = find(spot, classname, "info_intermission");
-			if (!spot)
-				spot = find(spot, classname, "info_intermission");
-			cyc = cyc - 1;
-		}
-		return spot;
-	}
-
-// then look for the start position
-	spot = find(NULL, classname, "info_player_start");
-	if (spot)
-		return spot;
-
-// testinfo_player_start is only found in regioned levels
-	spot = find(NULL, classname, "testplayerstart");
-	if (spot)
-		return spot;
-
-// then look for the start position
-	spot = find(NULL, classname, "info_player_deathmatch");
-	if (spot)
-		return spot;
-
-	//objerror ("FindIntermission: no spot");
-	return NULL;
-}
-*/
-
 /*
 ===============================================================================
 
diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc
index 6e2bbb8d7..4e2113f53 100644
--- a/qcsrc/server/miscfunctions.qc
+++ b/qcsrc/server/miscfunctions.qc
@@ -901,10 +901,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)
     {
@@ -924,20 +922,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
 }
 
 
diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh
index aa2f026e6..cb11057ef 100644
--- a/qcsrc/server/miscfunctions.qh
+++ b/qcsrc/server/miscfunctions.qh
@@ -102,8 +102,6 @@ void play2(entity e, string filename);
 
 string playername(entity p, bool team_colorize);
 
-void precache();
-
 void remove_safely(entity e);
 
 void remove_unsafely(entity e);
diff --git a/qcsrc/server/portals.qc b/qcsrc/server/portals.qc
index bd5a8540e..0eb325699 100644
--- a/qcsrc/server/portals.qc
+++ b/qcsrc/server/portals.qc
@@ -31,11 +31,10 @@ const vector SAFERNUDGE = '8 8 8';
 
 float PlayerEdgeDistance(entity p, vector v)
 {
-	vector vbest;
-
-	if(v.x < 0) vbest.x = p.mins.x; else vbest.x = p.maxs.x;
-	if(v.y < 0) vbest.y = p.mins.y; else vbest.y = p.maxs.y;
-	if(v.z < 0) vbest.z = p.mins.z; else vbest.z = p.maxs.z;
+	vector vbest = vec3(
+		((v.x < 0) ? p.mins.x : p.maxs.x),
+		((v.y < 0) ? p.mins.y : p.maxs.y),
+		((v.z < 0) ? p.mins.z : p.maxs.z));
 
 	return vbest * v;
 }
-- 
2.39.5