about summary refs log tree commit diff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/client/gc_client.cpp4
-rw-r--r--src/game/client/gc_client.hpp3
-rw-r--r--src/game/client/gc_console.cpp3
-rw-r--r--src/game/client/gc_map_image.cpp3
-rw-r--r--src/game/client/gc_menu.cpp7
-rw-r--r--src/game/client/gc_render.cpp4
-rw-r--r--src/game/client/gc_render.hpp3
-rw-r--r--src/game/client/gc_render_map.cpp2
-rw-r--r--src/game/client/gc_render_obj.cpp4
-rw-r--r--src/game/client/gc_skin.cpp6
-rw-r--r--src/game/client/gc_skin.hpp2
-rw-r--r--src/game/client/gc_ui.cpp3
-rw-r--r--src/game/editor/ed_editor.cpp3
-rw-r--r--src/game/editor/ed_editor.hpp5
-rw-r--r--src/game/editor/ed_layer_quads.cpp3
-rw-r--r--src/game/editor/ed_layer_tiles.cpp3
-rw-r--r--src/game/g_collision.cpp7
-rw-r--r--src/game/g_collision.hpp3
-rw-r--r--src/game/g_game.hpp5
-rw-r--r--src/game/g_math.hpp61
-rw-r--r--src/game/g_vmath.hpp198
-rw-r--r--src/game/server/gs_server.cpp4
22 files changed, 48 insertions, 288 deletions
diff --git a/src/game/client/gc_client.cpp b/src/game/client/gc_client.cpp
index f0195a47..2be38637 100644
--- a/src/game/client/gc_client.cpp
+++ b/src/game/client/gc_client.cpp
@@ -1,5 +1,6 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include <game/g_math.hpp>
+#include <base/math.hpp>
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -13,7 +14,6 @@ extern "C" {
 #include "../g_game.hpp"
 #include "../g_version.hpp"
 #include "../g_layers.hpp"
-#include "../g_math.hpp"
 #include "gc_map_image.hpp"
 #include "../generated/gc_data.hpp"
 #include "gc_menu.hpp"
diff --git a/src/game/client/gc_client.hpp b/src/game/client/gc_client.hpp
index f19766bf..4634aa58 100644
--- a/src/game/client/gc_client.hpp
+++ b/src/game/client/gc_client.hpp
@@ -1,4 +1,5 @@
-#include <game/g_vmath.hpp>
+#include <base/vmath.hpp>
+
 #include <game/generated/g_protocol.hpp>
 #include <game/g_game.hpp>
 
diff --git a/src/game/client/gc_console.cpp b/src/game/client/gc_console.cpp
index 45666a01..d1e517de 100644
--- a/src/game/client/gc_console.cpp
+++ b/src/game/client/gc_console.cpp
@@ -1,8 +1,9 @@
 #include "gc_console.hpp"
 #include "../generated/gc_data.hpp"
 
+#include <base/system.h>
+
 extern "C" {
-	#include <engine/e_system.h>
 	#include <engine/e_client_interface.h>
 	#include <engine/e_config.h>
 	#include <engine/e_console.h>
diff --git a/src/game/client/gc_map_image.cpp b/src/game/client/gc_map_image.cpp
index 63a57c70..b48b6b1d 100644
--- a/src/game/client/gc_map_image.cpp
+++ b/src/game/client/gc_map_image.cpp
@@ -1,6 +1,7 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
+#include <base/system.h>
+
 #include <stdio.h>
-#include <engine/e_system.h>
 #include <engine/e_client_interface.h>
 #include <game/g_mapitems.hpp>
 #include "gc_map_image.hpp"
diff --git a/src/game/client/gc_menu.cpp b/src/game/client/gc_menu.cpp
index 3a1e9cee..c867720b 100644
--- a/src/game/client/gc_menu.cpp
+++ b/src/game/client/gc_menu.cpp
@@ -4,11 +4,12 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include <game/g_math.hpp>
-#include <game/g_vmath.hpp>
+#include <base/system.h>
+#include <base/math.hpp>
+#include <base/vmath.hpp>
+
 
 extern "C" {
-	#include <engine/e_system.h>
 	#include <engine/e_client_interface.h>
 	#include <engine/e_config.h>
 	#include <engine/client/ec_font.h>
diff --git a/src/game/client/gc_render.cpp b/src/game/client/gc_render.cpp
index afb827fb..5a2af697 100644
--- a/src/game/client/gc_render.cpp
+++ b/src/game/client/gc_render.cpp
@@ -1,10 +1,12 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
 #include <math.h>
+
+#include <base/math.hpp>
+
 #include <engine/e_client_interface.h>
 #include <engine/e_config.h>
 #include <game/generated/gc_data.hpp>
 #include <game/generated/g_protocol.hpp>
-#include <game/g_math.hpp>
 #include <game/g_layers.hpp>
 #include "gc_render.hpp"
 #include "gc_anim.hpp"
diff --git a/src/game/client/gc_render.hpp b/src/game/client/gc_render.hpp
index d819c194..faaff094 100644
--- a/src/game/client/gc_render.hpp
+++ b/src/game/client/gc_render.hpp
@@ -2,7 +2,8 @@
 #ifndef GAME_CLIENT_RENDER_H
 #define GAME_CLIENT_RENDER_H
 
-#include "../g_vmath.hpp"
+#include <base/vmath.hpp>
+
 #include "../g_mapitems.hpp"
 #include "gc_ui.hpp"
 
diff --git a/src/game/client/gc_render_map.cpp b/src/game/client/gc_render_map.cpp
index 90579aa7..bbd9f7b1 100644
--- a/src/game/client/gc_render_map.cpp
+++ b/src/game/client/gc_render_map.cpp
@@ -1,6 +1,6 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
+#include <base/math.hpp>
 #include <engine/e_client_interface.h>
-#include "../g_math.hpp"
 #include "gc_client.hpp"
 
 void render_eval_envelope(ENVPOINT *points, int num_points, int channels, float time, float *result)
diff --git a/src/game/client/gc_render_obj.cpp b/src/game/client/gc_render_obj.cpp
index daba5ceb..aa64a127 100644
--- a/src/game/client/gc_render_obj.cpp
+++ b/src/game/client/gc_render_obj.cpp
@@ -1,11 +1,13 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
 #include <math.h>
 #include <stdio.h>
+
+#include <base/math.hpp>
+
 #include <engine/e_client_interface.h>
 #include <engine/e_config.h>
 #include <game/generated/gc_data.hpp>
 #include <game/generated/g_protocol.hpp>
-#include "../g_math.hpp"
 #include "gc_render.hpp"
 #include "gc_anim.hpp"
 #include "gc_client.hpp"
diff --git a/src/game/client/gc_skin.cpp b/src/game/client/gc_skin.cpp
index 2bd2d4ff..e0aa2c84 100644
--- a/src/game/client/gc_skin.cpp
+++ b/src/game/client/gc_skin.cpp
@@ -2,10 +2,12 @@
 #include <string.h>
 #include <stdio.h>
 #include <math.h>
-#include <engine/e_system.h>
+
+#include <base/system.h>
+#include <base/math.hpp>
+
 #include <engine/e_client_interface.h>
 #include "gc_skin.hpp"
-#include "../g_math.hpp"
 
 enum
 {
diff --git a/src/game/client/gc_skin.hpp b/src/game/client/gc_skin.hpp
index 3a746589..786f6768 100644
--- a/src/game/client/gc_skin.hpp
+++ b/src/game/client/gc_skin.hpp
@@ -1,5 +1,5 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include "../g_vmath.hpp"
+#include <base/vmath.hpp>
 
 // do this better and nicer
 typedef struct 
diff --git a/src/game/client/gc_ui.cpp b/src/game/client/gc_ui.cpp
index a344d661..e873cc86 100644
--- a/src/game/client/gc_ui.cpp
+++ b/src/game/client/gc_ui.cpp
@@ -1,5 +1,6 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include <engine/e_system.h>
+#include <base/system.h>
+
 #include <engine/e_client_interface.h>
 #include <engine/e_config.h>
 #include "gc_ui.hpp"
diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp
index 731d4f4a..429c88db 100644
--- a/src/game/editor/ed_editor.cpp
+++ b/src/game/editor/ed_editor.cpp
@@ -1,11 +1,12 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
 
+#include <base/system.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 extern "C" {
-	#include <engine/e_system.h>
 	#include <engine/e_common_interface.h>
 	#include <engine/e_datafile.h>
 	#include <engine/e_config.h>
diff --git a/src/game/editor/ed_editor.hpp b/src/game/editor/ed_editor.hpp
index dbca4a0e..a8e8815b 100644
--- a/src/game/editor/ed_editor.hpp
+++ b/src/game/editor/ed_editor.hpp
@@ -1,14 +1,15 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
 
+#include <base/system.h>
+#include <base/math.hpp>
+
 #include <stdlib.h>
 #include <math.h>
 #include "array.hpp"
 #include "../g_mapitems.hpp"
-#include "../g_math.hpp"
 #include "../client/gc_render.hpp"
 
 extern "C" {
-	#include <engine/e_system.h>
 	#include <engine/e_client_interface.h>
 	#include <engine/e_datafile.h>
 	#include <engine/e_config.h>
diff --git a/src/game/editor/ed_layer_quads.cpp b/src/game/editor/ed_layer_quads.cpp
index 8c8a47a7..a6e49248 100644
--- a/src/game/editor/ed_layer_quads.cpp
+++ b/src/game/editor/ed_layer_quads.cpp
@@ -1,5 +1,6 @@
+#include <base/math.hpp>
+
 #include "ed_editor.hpp"
-#include <game/g_math.hpp>
 #include <game/generated/gc_data.hpp>
 #include <game/client/gc_render.hpp>
 
diff --git a/src/game/editor/ed_layer_tiles.cpp b/src/game/editor/ed_layer_tiles.cpp
index d77f0970..cae47acb 100644
--- a/src/game/editor/ed_layer_tiles.cpp
+++ b/src/game/editor/ed_layer_tiles.cpp
@@ -1,4 +1,5 @@
-#include <game/g_math.hpp>
+#include <base/math.hpp>
+
 #include <game/generated/gc_data.hpp>
 #include <game/client/gc_render.hpp>
 #include "ed_editor.hpp"
diff --git a/src/game/g_collision.cpp b/src/game/g_collision.cpp
index b91c0e29..510cfba6 100644
--- a/src/game/g_collision.cpp
+++ b/src/game/g_collision.cpp
@@ -1,9 +1,10 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include <engine/e_system.h>
-#include <game/g_vmath.hpp>
+#include <base/system.h>
+#include <base/math.hpp>
+#include <base/vmath.hpp>
+
 #include <math.h>
 #include <engine/e_common_interface.h>
-#include <game/g_math.hpp>
 #include <game/g_mapitems.hpp>
 #include <game/g_layers.hpp>
 
diff --git a/src/game/g_collision.hpp b/src/game/g_collision.hpp
index e42764c1..735e26c5 100644
--- a/src/game/g_collision.hpp
+++ b/src/game/g_collision.hpp
@@ -2,8 +2,7 @@
 #ifndef GAME_MAPRES_COL_H
 #define GAME_MAPRES_COL_H
 
-
-#include <game/g_vmath.hpp>
+#include <base/vmath.hpp>
 
 int col_init();
 int col_is_solid(int x, int y);
diff --git a/src/game/g_game.hpp b/src/game/g_game.hpp
index 61342d76..29c948b9 100644
--- a/src/game/g_game.hpp
+++ b/src/game/g_game.hpp
@@ -2,10 +2,11 @@
 #ifndef GAME_GAME_H
 #define GAME_GAME_H
 
-#include <engine/e_system.h>
+#include <base/system.h>
+#include <base/math.hpp>
+
 #include <engine/e_common_interface.h>
 #include <math.h>
-#include "g_math.hpp"
 #include "g_collision.hpp"
 #include <game/generated/g_protocol.hpp>
 
diff --git a/src/game/g_math.hpp b/src/game/g_math.hpp
deleted file mode 100644
index 5e3f7ede..00000000
--- a/src/game/g_math.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#ifndef BASE_MATH_H
-#define BASE_MATH_H
-
-#include <stdlib.h>
-
-template <typename T>
-inline T clamp(T val, T min, T max)
-{
-	if(val < min)
-		return min;
-	if(val > max)
-		return max;
-	return val;
-}
-
-inline float sign(float f)
-{
-	return f<0.0f?-1.0f:1.0f;
-}
-
-template<typename T, typename TB>
-inline T mix(const T a, const T b, TB amount)
-{
-	return a + (b-a)*amount;
-}
-
-inline float frandom() { return rand()/(float)(RAND_MAX); }
-
-// float to fixed
-inline int f2fx(float v) { return (int)(v*(float)(1<<10)); }
-inline float fx2f(int v) { return v*(1.0f/(1<<10)); }
-
-class fxp
-{
-	int value;
-public:
-	void set(int v) { value = v; }
-	int get() const { return value; }
-	fxp &operator = (int v) { value = v<<10; return *this; }
-	fxp &operator = (float v) { value = (int)(v*(float)(1<<10)); return *this; }
-	operator float() const { return value/(float)(1<<10); }
-};
-
-class tune_param
-{
-	int value;
-public:
-	void set(int v) { value = v; }
-	int get() const { return value; }
-	tune_param &operator = (int v) { value = (int)(v*100.0f); return *this; }
-	tune_param &operator = (float v) { value = (int)(v*100.0f); return *this; }
-	operator float() const { return value/100.0f; }
-};
-
-const float pi = 3.1415926535897932384626433f;
-
-template <typename T> inline T min(T a, T b) { return a<b?a:b; }
-template <typename T> inline T max(T a, T b) { return a>b?a:b; }
-
-#endif // BASE_MATH_H
diff --git a/src/game/g_vmath.hpp b/src/game/g_vmath.hpp
deleted file mode 100644
index ac3e1870..00000000
--- a/src/game/g_vmath.hpp
+++ /dev/null
@@ -1,198 +0,0 @@
-/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#ifndef BASE_VMATH_H
-#define BASE_VMATH_H
-
-//#include <engine/system.h>
-
-// ------------------------------------
-
-template<typename T>
-class vector2_base
-{
-public:
-	union { T x,u; };
-	union { T y,v; };
-	
-	vector2_base() {}
-	vector2_base(float nx, float ny)
-	{
-		x = nx;
-		y = ny;
-	}
-	
-	vector2_base operator -() const { return vector2_base(-x, -y); }
-	vector2_base operator -(const vector2_base &v) const { return vector2_base(x-v.x, y-v.y); }
-	vector2_base operator +(const vector2_base &v) const { return vector2_base(x+v.x, y+v.y); }
-	vector2_base operator *(const T v) const { return vector2_base(x*v, y*v); }
-	
-	const vector2_base &operator =(const vector2_base &v) { x = v.x; y = v.y; return *this; }
-
-	const vector2_base &operator +=(const vector2_base &v) { x += v.x; y += v.y; return *this; }
-	const vector2_base &operator -=(const vector2_base &v) { x -= v.x; y -= v.y; return *this; }
-	const vector2_base &operator *=(const T v) { x *= v; y *= v; return *this;	}
-
-	bool operator ==(const vector2_base &v) const { return x == v.x && y == v.y; } //TODO: do this with an eps instead
-
-	operator const T* () { return &x; }
-};
-
-
-template<typename T>
-inline T length(const vector2_base<T> &a)
-{
-	return sqrtf(a.x*a.x + a.y*a.y);
-}
-
-template<typename T>
-inline T distance(const vector2_base<T> a, const vector2_base<T> &b)
-{
-	return length(a-b);
-}
-
-template<typename T>
-inline T dot(const vector2_base<T> a, const vector2_base<T> &b)
-{
-	return a.x*b.x + a.y*b.y;
-}
-
-template<typename T>
-inline vector2_base<T> normalize(const vector2_base<T> &v)
-{
-	T l = (T)(1.0f/sqrtf(v.x*v.x + v.y*v.y));
-	return vector2_base<T>(v.x*l, v.y*l);
-}
-
-typedef vector2_base<float> vec2;
-typedef vector2_base<bool> bvec2;
-typedef vector2_base<int> ivec2;
-
-template<typename T>
-inline vector2_base<T> closest_point_on_line(vector2_base<T> line_point0, vector2_base<T> line_point1, vector2_base<T> target_point)
-{
-	vector2_base<T> c = target_point - line_point0;
-	vector2_base<T> v = (line_point1 - line_point0);
-	v = normalize(v);
-	T d = length(line_point0-line_point1);
-	T t = dot(v, c)/d;
-	return mix(line_point0, line_point1, clamp(t, (T)0, (T)1));
-	/*
-	if (t < 0) t = 0;
-	if (t > 1.0f) return 1.0f;
-	return t;*/
-}
-	
-// ------------------------------------
-template<typename T>
-class vector3_base
-{
-public:
-	union { T x,r,h; };
-	union { T y,g,s; };
-	union { T z,b,v,l; };
-
-	vector3_base() {}
-	vector3_base(float nx, float ny, float nz)
-	{
-		x = nx;
-		y = ny;
-		z = nz;
-	}
-	
-	const vector3_base &operator =(const vector3_base &v) { x = v.x; y = v.y; z = v.z; return *this; }
-
-	vector3_base operator -(const vector3_base &v) const { return vector3_base(x-v.x, y-v.y, z-v.z); }
-	vector3_base operator -() const { return vector3_base(-x, -y, -z); }
-	vector3_base operator +(const vector3_base &v) const { return vector3_base(x+v.x, y+v.y, z+v.z); }
-	vector3_base operator *(const T v) const { return vector3_base(x*v, y*v, z*v); }
-	vector3_base operator *(const vector3_base &v) const { return vector3_base(x*v.x, y*v.y, z*v.z); }
-	vector3_base operator /(const T v) const { return vector3_base(x/v, y/v, z/v); }
-	
-	const vector3_base &operator +=(const vector3_base &v) { x += v.x; y += v.y; z += v.z; return *this; }
-	const vector3_base &operator -=(const vector3_base &v) { x -= v.x; y -= v.y; z -= v.z; return *this; }
-	const vector3_base &operator *=(const T v) { x *= v; y *= v; z *= v; return *this;	}
-
-	bool operator ==(const vector3_base &v) const { return x == v.x && y == v.y && z == v.z; } //TODO: do this with an eps instead
-
-	operator const T* () { return &x; }
-};
-
-template<typename T>
-inline T length(const vector3_base<T> &a)
-{
-	return sqrtf(a.x*a.x + a.y*a.y + a.z*a.z);
-}
-
-template<typename T>
-inline T distance(const vector3_base<T> &a, const vector3_base<T> &b)
-{
-	return length(a-b);
-}
-
-template<typename T>
-inline T dot(const vector3_base<T> &a, const vector3_base<T> &b)
-{
-	return a.x*b.x + a.y*b.y + a.z*b.z;
-}
-
-template<typename T>
-inline vector3_base<T> normalize(const vector3_base<T> &v)
-{
-	T l = (T)(1.0f/sqrtf(v.x*v.x + v.y*v.y + v.z*v.z));
-	return vector3_base<T>(v.x*l, v.y*l, v.z*l);
-}
-
-template<typename T>
-inline vector3_base<T> cross(const vector3_base<T> &a, const vector3_base<T> &b)
-{
-	return vector3_base<T>(
-		a.y*b.z - a.z*b.y,
-		a.z*b.x - a.x*b.z,
-		a.x*b.y - a.y*b.x);
-}
-
-typedef vector3_base<float> vec3;
-typedef vector3_base<bool> bvec3;
-typedef vector3_base<int> ivec3;
-
-// ------------------------------------
-
-template<typename T>
-class vector4_base
-{
-public:
-	union { T x,r; };
-	union { T y,g; };
-	union { T z,b; };
-	union { T w,a; };
-
-	vector4_base() {}
-	vector4_base(float nx, float ny, float nz, float nw)
-	{
-		x = nx;
-		y = ny;
-		z = nz;
-		w = nw;
-	}
-	
-	vector4_base operator +(const vector4_base &v) const { return vector4_base(x+v.x, y+v.y, z+v.z, w+v.w); }
-	vector4_base operator -(const vector4_base &v) const { return vector4_base(x-v.x, y-v.y, z-v.z, w-v.w); }
-	vector4_base operator -() const { return vector4_base(-x, -y, -z, -w); }
-	vector4_base operator *(const vector4_base &v) const { return vector4_base(x*v.x, y*v.y, z*v.z, w*v.w); }
-	vector4_base operator *(const T v) const { return vector4_base(x*v, y*v, z*v, w*v); }
-	
-	const vector4_base &operator =(const vector4_base &v) { x = v.x; y = v.y; z = v.z; w = v.w; return *this; }
-
-	const vector4_base &operator +=(const vector4_base &v) { x += v.x; y += v.y; z += v.z; w += v.w; return *this; }
-	const vector4_base &operator -=(const vector4_base &v) { x -= v.x; y -= v.y; z -= v.z; w -= v.w; return *this; }
-	const vector4_base &operator *=(const T v) { x *= v; y *= v; z *= v; w *= v; return *this;	}
-
-	bool operator ==(const vector4_base &v) const { return x == v.x && y == v.y && z == v.z && w == v.w; } //TODO: do this with an eps instead
-
-	operator const T* () { return &x; }
-};
-
-typedef vector4_base<float> vec4;
-typedef vector4_base<bool> bvec4;
-typedef vector4_base<int> ivec4;
-
-#endif
diff --git a/src/game/server/gs_server.cpp b/src/game/server/gs_server.cpp
index a4176003..5af6758b 100644
--- a/src/game/server/gs_server.cpp
+++ b/src/game/server/gs_server.cpp
@@ -2,12 +2,14 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+
+#include <base/math.hpp>
+
 #include <engine/e_config.h>
 #include <engine/e_server_interface.h>
 #include <game/g_version.hpp>
 #include <game/g_collision.hpp>
 #include <game/g_layers.hpp>
-#include <game/g_math.hpp>
 #include "gs_common.hpp"
 #include "gs_game_ctf.hpp"
 #include "gs_game_tdm.hpp"