From b6a34dc838763a87c285482ecee9f130f687deaa Mon Sep 17 00:00:00 2001
From: TimePath <andrew.hardaker1995@gmail.com>
Date: Thu, 5 Nov 2015 18:32:07 +1100
Subject: [PATCH] Cleanup

---
 qcsrc/client/main.qc                         |  1 -
 qcsrc/client/miscfunctions.qc                | 26 +----------------
 qcsrc/client/miscfunctions.qh                | 10 ++-----
 qcsrc/client/particles.qc                    | 30 --------------------
 qcsrc/client/particles.qh                    | 24 ----------------
 qcsrc/client/progs.inc                       |  1 -
 qcsrc/client/teamradar.qc                    |  6 ----
 qcsrc/client/teamradar.qh                    |  2 --
 qcsrc/common/physics.qh                      |  1 +
 qcsrc/common/triggers/func/pointparticles.qc | 19 ++++++++++---
 qcsrc/common/weapons/weapon/vortex.qc        | 30 ++++++++++++++++++--
 qcsrc/lib/vector.qh                          | 15 ++++++++++
 qcsrc/menu/xonotic/util.qc                   |  1 +
 qcsrc/menu/xonotic/util.qh                   |  2 --
 qcsrc/server/miscfunctions.qc                |  2 +-
 15 files changed, 63 insertions(+), 107 deletions(-)
 delete mode 100644 qcsrc/client/particles.qc
 delete mode 100644 qcsrc/client/particles.qh

diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc
index 71765f5e06..af1da5c210 100644
--- a/qcsrc/client/main.qc
+++ b/qcsrc/client/main.qc
@@ -8,7 +8,6 @@
 #include "mapvoting.qh"
 #include "modeleffects.qh"
 #include "mutators/events.qh"
-#include "particles.qh"
 #include "quickmenu.qh"
 #include "scoreboard.qh"
 #include "shownames.qh"
diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc
index e8808e2129..ab4cb1f156 100644
--- a/qcsrc/client/miscfunctions.qc
+++ b/qcsrc/client/miscfunctions.qc
@@ -156,15 +156,6 @@ float PreviewExists(string name)
 	return false;
 }
 
-vector rotate(vector v, float a)
-{
-	vector w = '0 0 0';
-	// FTEQCC SUCKS AGAIN
-	w.x =      v.x * cos(a) + v.y * sin(a);
-	w.y = -1 * v.x * sin(a) + v.y * cos(a);
-	return w;
-}
-
 // decolorizes and team colors the player name when needed
 string playername(string thename, float teamid)
 {
@@ -199,10 +190,6 @@ vector project_3d_to_2d(vector vec)
 	return vec;
 }
 
-void dummyfunction(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8)
-{
-}
-
 float expandingbox_sizefactor_from_fadelerp(float fadelerp)
 {
 	return 1.2 / (1.2 - fadelerp);
@@ -287,7 +274,6 @@ void drawstring_expanding(vector position, string text, vector theScale, vector
 	sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
 
 	drawfontscale = sz * '1 1 0';
-	dummyfunction(0, 0, 0, 0, 0, 0, 0, 0);
 	drawstring(position + expandingbox_resize_centered_box_offset(sz, theScale, stringwidth(text, false, theScale * (sz / drawfontscale.x)) / (theScale.x * sz)), text, theScale * (sz / drawfontscale.x), rgb, theAlpha * (1 - fadelerp), flag);
 	// width parameter:
 	//    (scale_x * sz / drawfontscale_x) * drawfontscale_x * SIZE1 / (scale_x * sz)
@@ -307,7 +293,6 @@ void drawcolorcodedstring_expanding(vector position, string text, vector theScal
 	sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
 
 	drawfontscale = sz * '1 1 0';
-	dummyfunction(0, 0, 0, 0, 0, 0, 0, 0);
 	drawcolorcodedstring(position + expandingbox_resize_centered_box_offset(sz, theScale, stringwidth(text, true, theScale * (sz / drawfontscale.x)) / (theScale.x * sz)), text, theScale * (sz / drawfontscale.x), theAlpha * (1 - fadelerp), flag);
 	drawfontscale = '1 1 0';
 }
@@ -548,6 +533,7 @@ float getplayerisdead(float pl)
 	return false;
 }
 
+/** engine callback */
 void URI_Get_Callback(int id, float status, string data)
 {
 	if(url_URI_Get_Callback(id, status, data))
@@ -569,16 +555,6 @@ void URI_Get_Callback(int id, float status, string data)
 	}
 }
 
-void draw_beginBoldFont()
-{
-	drawfont = FONT_USER+2;
-}
-
-void draw_endBoldFont()
-{
-	drawfont = FONT_USER+1;
-}
-
 void Accuracy_LoadLevels()
 {
 	if(autocvar_accuracy_color_levels != acc_color_levels)
diff --git a/qcsrc/client/miscfunctions.qh b/qcsrc/client/miscfunctions.qh
index b223d88b9e..60048d0497 100644
--- a/qcsrc/client/miscfunctions.qh
+++ b/qcsrc/client/miscfunctions.qh
@@ -44,7 +44,8 @@ float cvar_or(string cv, float v);
 
 vector project_3d_to_2d(vector vec);
 
-void dummyfunction(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8);
+#define draw_beginBoldFont()    do { drawfont = FONT_USER + 2; } while (0)
+#define draw_endBoldFont()      do { drawfont = FONT_USER + 1; } while (0)
 
 float expandingbox_sizefactor_from_fadelerp(float fadelerp);
 
@@ -151,13 +152,6 @@ vector getcsqcplayercolor(float pl);
 
 float getplayerisdead(float pl);
 
-void URI_Get_Callback(int id, float status, string data);
-
-void draw_beginBoldFont();
-
-void draw_endBoldFont();
-
-
 const int MAX_ACCURACY_LEVELS = 10;
 float acc_lev[MAX_ACCURACY_LEVELS];
 vector acc_col[MAX_ACCURACY_LEVELS];
diff --git a/qcsrc/client/particles.qc b/qcsrc/client/particles.qc
deleted file mode 100644
index 4c9ff2011f..0000000000
--- a/qcsrc/client/particles.qc
+++ /dev/null
@@ -1,30 +0,0 @@
-#include "particles.qh"
-
-#include "../common/stats.qh"
-
-#include "../lib/warpzone/common.qh"
-
-void Net_ReadVortexBeamParticle()
-{
-	vector shotorg, endpos;
-	float charge;
-	shotorg.x = ReadCoord(); shotorg.y = ReadCoord(); shotorg.z = ReadCoord();
-	endpos.x = ReadCoord(); endpos.y = ReadCoord(); endpos.z = ReadCoord();
-	charge = ReadByte() / 255.0;
-
-	pointparticles(EFFECT_VORTEX_MUZZLEFLASH, shotorg, normalize(endpos - shotorg) * 1000, 1);
-
-	//draw either the old v2.3 beam or the new beam
-	charge = sqrt(charge); // divide evenly among trail spacing and alpha
-	particles_alphamin = particles_alphamax = particles_fade = charge;
-
-	if (autocvar_cl_particles_oldvortexbeam && (getstati(STAT_ALLOW_OLDVORTEXBEAM) || isdemo()))
-		WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM_OLD), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
-	else
-		WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
-}
-NET_HANDLE(TE_CSQC_VORTEXBEAMPARTICLE, bool isNew)
-{
-	Net_ReadVortexBeamParticle();
-	return true;
-}
diff --git a/qcsrc/client/particles.qh b/qcsrc/client/particles.qh
deleted file mode 100644
index a35866c6ba..0000000000
--- a/qcsrc/client/particles.qh
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef CLIENT_PARTICLES_H
-#define CLIENT_PARTICLES_H
-.int dphitcontentsmask;
-
-entityclass(PointParticles);
-class(PointParticles) .int cnt; // effect number
-class(PointParticles) .vector velocity; // particle velocity
-class(PointParticles) .float waterlevel; // direction jitter
-class(PointParticles) .int count; // count multiplier
-class(PointParticles) .int impulse; // density
-class(PointParticles) .string noise; // sound
-class(PointParticles) .float atten;
-class(PointParticles) .float volume;
-class(PointParticles) .float absolute; // 1 = count per second is absolute, 2 = only spawn at toggle
-class(PointParticles) .vector movedir; // trace direction
-
-void Draw_PointParticles(entity this);
-
-void Ent_PointParticles_Remove();
-
-class(PointParticles) .float glow_color; // palette index
-
-void Net_ReadVortexBeamParticle();
-#endif
diff --git a/qcsrc/client/progs.inc b/qcsrc/client/progs.inc
index e72a127944..17cde57b87 100644
--- a/qcsrc/client/progs.inc
+++ b/qcsrc/client/progs.inc
@@ -14,7 +14,6 @@
 #include "miscfunctions.qc"
 #include "modeleffects.qc"
 #include "movelib.qc"
-#include "particles.qc"
 #include "player_skeleton.qc"
 #include "rubble.qc"
 #include "scoreboard.qc"
diff --git a/qcsrc/client/teamradar.qc b/qcsrc/client/teamradar.qc
index 80f25fbb0b..af43dae037 100644
--- a/qcsrc/client/teamradar.qc
+++ b/qcsrc/client/teamradar.qc
@@ -58,12 +58,6 @@ vector teamradar_texcoord_to_3dcoord(vector in,float z)
 	return out;
 }
 
-vector yinvert(vector v)
-{
-	v.y = 1 - v.y;
-	return v;
-}
-
 void draw_teamradar_background(float fg)
 {
 	float fga;
diff --git a/qcsrc/client/teamradar.qh b/qcsrc/client/teamradar.qh
index 0f51a2a0dd..ca7ec87b59 100644
--- a/qcsrc/client/teamradar.qh
+++ b/qcsrc/client/teamradar.qh
@@ -35,8 +35,6 @@ vector teamradar_texcoord_to_2dcoord(vector in);
 
 vector teamradar_texcoord_to_3dcoord(vector in,float z);
 
-vector yinvert(vector v);
-
 void draw_teamradar_background(float fg);
 
 void draw_teamradar_player(vector coord3d, vector pangles, vector rgb);
diff --git a/qcsrc/common/physics.qh b/qcsrc/common/physics.qh
index d1f82991cd..5ee8954d0c 100644
--- a/qcsrc/common/physics.qh
+++ b/qcsrc/common/physics.qh
@@ -33,6 +33,7 @@ bool IsFlying(entity a);
 	void PM_multijump();
 
 	.float watertype;
+	.float waterlevel;
 	.int items;
 
 	.vector movement;
diff --git a/qcsrc/common/triggers/func/pointparticles.qc b/qcsrc/common/triggers/func/pointparticles.qc
index 5e8636729c..470e5ff5ba 100644
--- a/qcsrc/common/triggers/func/pointparticles.qc
+++ b/qcsrc/common/triggers/func/pointparticles.qc
@@ -1,7 +1,3 @@
-#ifdef CSQC
-	#include "../../../client/particles.qh"
-#endif
-
 #ifdef SVQC
 // NOTE: also contains func_sparks
 
@@ -183,6 +179,21 @@ spawnfunc(func_sparks)
 }
 #elif defined(CSQC)
 
+.int dphitcontentsmask;
+
+entityclass(PointParticles);
+class(PointParticles) .int cnt; // effect number
+class(PointParticles) .vector velocity; // particle velocity
+class(PointParticles) .float waterlevel; // direction jitter
+class(PointParticles) .int count; // count multiplier
+class(PointParticles) .int impulse; // density
+class(PointParticles) .string noise; // sound
+class(PointParticles) .float atten;
+class(PointParticles) .float volume;
+class(PointParticles) .float absolute; // 1 = count per second is absolute, 2 = only spawn at toggle
+class(PointParticles) .vector movedir; // trace direction
+class(PointParticles) .float glow_color; // palette index
+
 void Draw_PointParticles(entity this)
 {
 	float n, i, fail;
diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc
index 705bf66443..b5e81c8e6d 100644
--- a/qcsrc/common/weapons/weapon/vortex.qc
+++ b/qcsrc/common/weapons/weapon/vortex.qc
@@ -60,10 +60,8 @@ VORTEX_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 #endif
 #endif
 #ifdef IMPLEMENTATION
-#ifdef SVQC
-spawnfunc(weapon_vortex) { weapon_defaultspawnfunc(this, WEP_VORTEX); }
-spawnfunc(weapon_nex) { spawnfunc_weapon_vortex(this); }
 
+#if defined(SVQC)
 void SendCSQCVortexBeamParticle(float charge) {
 	vector v;
 	v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
@@ -76,6 +74,32 @@ void SendCSQCVortexBeamParticle(float charge) {
 	WriteCoord(MSG_BROADCAST, v.z);
 	WriteByte(MSG_BROADCAST, bound(0, 255 * charge, 255));
 }
+#elif defined(CSQC)
+NET_HANDLE(TE_CSQC_VORTEXBEAMPARTICLE, bool isNew)
+{
+	vector shotorg, endpos;
+	float charge;
+	shotorg.x = ReadCoord(); shotorg.y = ReadCoord(); shotorg.z = ReadCoord();
+	endpos.x = ReadCoord(); endpos.y = ReadCoord(); endpos.z = ReadCoord();
+	charge = ReadByte() / 255.0;
+
+	pointparticles(EFFECT_VORTEX_MUZZLEFLASH, shotorg, normalize(endpos - shotorg) * 1000, 1);
+
+	//draw either the old v2.3 beam or the new beam
+	charge = sqrt(charge); // divide evenly among trail spacing and alpha
+	particles_alphamin = particles_alphamax = particles_fade = charge;
+
+	if (autocvar_cl_particles_oldvortexbeam && (getstati(STAT_ALLOW_OLDVORTEXBEAM) || isdemo()))
+		WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM_OLD), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
+	else
+		WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
+	return true;
+}
+#endif
+
+#ifdef SVQC
+spawnfunc(weapon_vortex) { weapon_defaultspawnfunc(this, WEP_VORTEX); }
+spawnfunc(weapon_nex) { spawnfunc_weapon_vortex(this); }
 
 void W_Vortex_Attack(Weapon thiswep, float issecondary)
 {SELFPARAM();
diff --git a/qcsrc/lib/vector.qh b/qcsrc/lib/vector.qh
index de32d206f3..6cbaebdcdb 100644
--- a/qcsrc/lib/vector.qh
+++ b/qcsrc/lib/vector.qh
@@ -63,6 +63,21 @@ vector vec3(float x, float y, float z)
 	return v;
 }
 
+vector rotate(vector v, float a)
+{
+	float a_sin = sin(a), a_cos = cos(a);
+	vector r = '0 0 0';
+	r.x =      v.x * a_cos + v.y * a_sin;
+	r.y = -1 * v.x * a_sin + v.y * a_cos;
+	return r;
+}
+
+vector yinvert(vector v)
+{
+	v.y = 1 - v.y;
+	return v;
+}
+
 #ifndef MENUQC
 	vector get_corner_position(entity box, int corner)
 	{
diff --git a/qcsrc/menu/xonotic/util.qc b/qcsrc/menu/xonotic/util.qc
index 146075ecae..4260480022 100644
--- a/qcsrc/menu/xonotic/util.qc
+++ b/qcsrc/menu/xonotic/util.qc
@@ -277,6 +277,7 @@ string _Nex_ExtResponseSystem_UpdateToURL;
 string _Nex_ExtResponseSystem_Packs;
 float _Nex_ExtResponseSystem_PacksStep;
 
+/** engine callback */
 void URI_Get_Callback(float id, float status, string data)
 {
 	if(url_URI_Get_Callback(id, status, data))
diff --git a/qcsrc/menu/xonotic/util.qh b/qcsrc/menu/xonotic/util.qh
index 9e989a4662..79ce7c5eef 100644
--- a/qcsrc/menu/xonotic/util.qh
+++ b/qcsrc/menu/xonotic/util.qh
@@ -28,8 +28,6 @@ float updateCompression();
 
 void UpdateNotification_URI_Get_Callback(float id, float status, string data);
 
-void URI_Get_Callback(float id, float status, string data);
-
 // game type list box stuff (does not NEED to contain all game types, other
 // types stay available via console)
 int GameType_GetID(int cnt);
diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc
index 623387b579..de75592227 100644
--- a/qcsrc/server/miscfunctions.qc
+++ b/qcsrc/server/miscfunctions.qc
@@ -1341,7 +1341,7 @@ float WarpZone_Projectile_Touch_ImpactFilter_Callback()
 	return false;
 }
 
-
+/** engine callback */
 void URI_Get_Callback(float id, float status, string data)
 {
 	if(url_URI_Get_Callback(id, status, data))
-- 
2.39.5