about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-14 17:19:13 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-14 17:19:13 +0000
commit817f431377c7f1545621ff597c018b133651e991 (patch)
tree03fe513c4cc7d34ce9537f81375251ba86b33950
parent0fceb1cf1ab9887040f08f0abf646ef318a65ae3 (diff)
downloadzcatch-817f431377c7f1545621ff597c018b133651e991.tar.gz
zcatch-817f431377c7f1545621ff597c018b133651e991.zip
moved out e_system, e_detect, vmath and math to a little base library
-rw-r--r--default.bam2
-rw-r--r--src/base/detect.h (renamed from src/engine/e_detect.h)0
-rw-r--r--src/base/math.hpp (renamed from src/game/g_math.hpp)0
-rw-r--r--src/base/system.c (renamed from src/engine/e_system.c)6
-rw-r--r--src/base/system.h (renamed from src/engine/e_system.h)2
-rw-r--r--src/base/vmath.hpp (renamed from src/game/g_vmath.hpp)2
-rw-r--r--src/engine/client/ec_client.c2
-rw-r--r--src/engine/client/ec_font.c2
-rw-r--r--src/engine/client/ec_gfx.c2
-rw-r--r--src/engine/client/ec_inp.c2
-rw-r--r--src/engine/client/ec_snd.c2
-rw-r--r--src/engine/client/ec_srvbrowse.c2
-rw-r--r--src/engine/e_compression.c3
-rw-r--r--src/engine/e_config.c2
-rw-r--r--src/engine/e_console.c2
-rw-r--r--src/engine/e_datafile.c2
-rw-r--r--src/engine/e_engine.c3
-rw-r--r--src/engine/e_huffman.c9
-rw-r--r--src/engine/e_if_other.h2
-rw-r--r--src/engine/e_linereader.h2
-rw-r--r--src/engine/e_map.c2
-rw-r--r--src/engine/e_memheap.c2
-rw-r--r--src/engine/e_network.c10
-rw-r--r--src/engine/e_packer.c4
-rw-r--r--src/engine/e_protocol.h2
-rw-r--r--src/engine/e_ringbuffer.c2
-rw-r--r--src/engine/e_snapshot.h2
-rw-r--r--src/engine/external/glfw/lib/x11/x11_window.c2
-rw-r--r--src/engine/server/es_register.c2
-rw-r--r--src/engine/server/es_server.c3
-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/server/gs_server.cpp4
-rw-r--r--src/mastersrv/mastersrv.cpp2
-rw-r--r--src/tools/crapnet.cpp2
-rw-r--r--src/tools/fake_server.c2
-rw-r--r--src/tools/packetgen.c2
54 files changed, 93 insertions, 72 deletions
diff --git a/default.bam b/default.bam
index f79b20ae..2d10baf2 100644
--- a/default.bam
+++ b/default.bam
@@ -295,7 +295,7 @@ function build(settings)
 		end
 	end
 
-	engine = Compile(engine_settings, Collect("src/engine/*.c"))
+	engine = Compile(engine_settings, Collect("src/engine/*.c", "src/base/*.c"))
 	client = Compile(client_settings, Collect("src/engine/client/*.c"))
 	server = Compile(server_settings, Collect("src/engine/server/*.c"))
 	
diff --git a/src/engine/e_detect.h b/src/base/detect.h
index 04cca2d9..04cca2d9 100644
--- a/src/engine/e_detect.h
+++ b/src/base/detect.h
diff --git a/src/game/g_math.hpp b/src/base/math.hpp
index 5e3f7ede..5e3f7ede 100644
--- a/src/game/g_math.hpp
+++ b/src/base/math.hpp
diff --git a/src/engine/e_system.c b/src/base/system.c
index 1be7ea30..1ac5f296 100644
--- a/src/engine/e_system.c
+++ b/src/base/system.c
@@ -6,9 +6,9 @@
 #include <ctype.h>
 #include <time.h>
 
-#include "e_detect.h"
-#include "e_system.h"
-#include "e_console.h"
+/*#include "detect.h"*/
+#include "system.h"
+/*#include "e_console.h"*/
 
 #if defined(CONF_FAMILY_UNIX)
 	#include <sys/time.h>
diff --git a/src/engine/e_system.h b/src/base/system.h
index ac9e7cc6..4449907c 100644
--- a/src/engine/e_system.h
+++ b/src/base/system.h
@@ -7,7 +7,7 @@
 #ifndef BASE_SYSTEM_H
 #define BASE_SYSTEM_H
 
-#include "e_detect.h"
+#include "detect.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/game/g_vmath.hpp b/src/base/vmath.hpp
index ac3e1870..49dd26d1 100644
--- a/src/game/g_vmath.hpp
+++ b/src/base/vmath.hpp
@@ -2,8 +2,6 @@
 #ifndef BASE_VMATH_H
 #define BASE_VMATH_H
 
-//#include <engine/system.h>
-
 // ------------------------------------
 
 template<typename T>
diff --git a/src/engine/client/ec_client.c b/src/engine/client/ec_client.c
index b8439194..5f213ac6 100644
--- a/src/engine/client/ec_client.c
+++ b/src/engine/client/ec_client.c
@@ -6,7 +6,7 @@
 #include <stdio.h>
 #include <math.h>
 
-#include <engine/e_system.h>
+#include <base/system.h>
 #include <engine/e_engine.h>
 #include <engine/e_client_interface.h>
 
diff --git a/src/engine/client/ec_font.c b/src/engine/client/ec_font.c
index 5d5c6df4..af9c612a 100644
--- a/src/engine/client/ec_font.c
+++ b/src/engine/client/ec_font.c
@@ -2,7 +2,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
-#include <engine/e_system.h>
+#include <base/system.h>
 #include <engine/e_client_interface.h>
 #include "ec_font.h"
 
diff --git a/src/engine/client/ec_gfx.c b/src/engine/client/ec_gfx.c
index f3488196..4f258d11 100644
--- a/src/engine/client/ec_gfx.c
+++ b/src/engine/client/ec_gfx.c
@@ -2,7 +2,7 @@
 #include <GL/glfw.h>
 #include <engine/external/pnglite/pnglite.h>
 
-#include <engine/e_system.h>
+#include <base/system.h>
 #include <engine/e_client_interface.h>
 #include <engine/e_engine.h>
 #include <engine/e_config.h>
diff --git a/src/engine/client/ec_inp.c b/src/engine/client/ec_inp.c
index 56b5fd1f..00468434 100644
--- a/src/engine/client/ec_inp.c
+++ b/src/engine/client/ec_inp.c
@@ -2,7 +2,7 @@
 #include <string.h>
 #include <GL/glfw.h>
 
-#include <engine/e_system.h>
+#include <base/system.h>
 #include <engine/e_client_interface.h>
 #include <engine/e_config.h>
 
diff --git a/src/engine/client/ec_snd.c b/src/engine/client/ec_snd.c
index a3b687a7..f7ab6639 100644
--- a/src/engine/client/ec_snd.c
+++ b/src/engine/client/ec_snd.c
@@ -1,5 +1,5 @@
 /* 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>
 
diff --git a/src/engine/client/ec_srvbrowse.c b/src/engine/client/ec_srvbrowse.c
index 41c6a7a0..07e2d227 100644
--- a/src/engine/client/ec_srvbrowse.c
+++ b/src/engine/client/ec_srvbrowse.c
@@ -1,5 +1,5 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include <engine/e_system.h>
+#include <base/system.h>
 #include <engine/e_network.h>
 #include <engine/e_client_interface.h>
 #include <engine/e_config.h>
diff --git a/src/engine/e_compression.c b/src/engine/e_compression.c
index 0a16d0b4..6a534feb 100644
--- a/src/engine/e_compression.c
+++ b/src/engine/e_compression.c
@@ -1,6 +1,5 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include "e_system.h"
-#include <string.h>
+#include <base/system.h>
 
 /* Format: ESDDDDDD EDDDDDDD EDD...  Extended, Data, Sign */
 unsigned char *vint_pack(unsigned char *dst, int i) 
diff --git a/src/engine/e_config.c b/src/engine/e_config.c
index 858cec59..426bbd78 100644
--- a/src/engine/e_config.c
+++ b/src/engine/e_config.c
@@ -4,7 +4,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "e_system.h"
+#include <base/system.h>
 #include "e_config.h"
 #include "e_linereader.h"
 #include "e_engine.h"
diff --git a/src/engine/e_console.c b/src/engine/e_console.c
index 71631bfa..8dd9dbcd 100644
--- a/src/engine/e_console.c
+++ b/src/engine/e_console.c
@@ -1,4 +1,4 @@
-#include "e_system.h"
+#include <base/system.h>
 #include "e_console.h"
 #include "e_config.h"
 #include "e_linereader.h"
diff --git a/src/engine/e_datafile.c b/src/engine/e_datafile.c
index 59858eda..8f684827 100644
--- a/src/engine/e_datafile.c
+++ b/src/engine/e_datafile.c
@@ -1,5 +1,5 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include "e_system.h"
+#include <base/system.h>
 #include "e_datafile.h"
 #include <zlib.h>
 
diff --git a/src/engine/e_engine.c b/src/engine/e_engine.c
index f71b7b6e..3c3c1d62 100644
--- a/src/engine/e_engine.c
+++ b/src/engine/e_engine.c
@@ -3,7 +3,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <engine/e_system.h>
+#include <base/system.h>
+
 #include <engine/e_server_interface.h>
 /*#include <engine/e_client_interface.h>*/
 #include <engine/e_config.h>
diff --git a/src/engine/e_huffman.c b/src/engine/e_huffman.c
index f2e58f0c..dfb5c817 100644
--- a/src/engine/e_huffman.c
+++ b/src/engine/e_huffman.c
@@ -1,11 +1,11 @@
+#include <base/system.h>
 #include <stdlib.h>
 #include <string.h>
-#include <engine/e_system.h>
 #include <engine/e_huffman.h>
 
 void huffman_init(HUFFSTATE *huff)
 {
-	mem_zero(huff, sizeof(huff));
+	mem_zero(huff, sizeof(HUFFSTATE));
 	huff->nodes[0].frequency = 1;
 	huff->nodes[0].symbol_size = -1;
 	huff->num_symbols++;
@@ -160,7 +160,10 @@ static void bitio_init(HUFFBITIO *bitio, unsigned char *data)
 
 static void bitio_flush(HUFFBITIO *bitio)
 {
-	*bitio->data = bitio->current_bits;
+	if(bitio->num == 8)
+		*bitio->data = bitio->current_bits << (8-bitio->num);
+	else
+		*bitio->data = bitio->current_bits;
 	bitio->data++;
 	bitio->num = 0;
 	bitio->current_bits = 0;
diff --git a/src/engine/e_if_other.h b/src/engine/e_if_other.h
index 3d43533d..d2726a7b 100644
--- a/src/engine/e_if_other.h
+++ b/src/engine/e_if_other.h
@@ -6,8 +6,8 @@
 	Title: Engine Interface
 */
 
+#include <base/system.h>
 #include "e_keys.h"
-#include "e_system.h"
 
 enum 
 {
diff --git a/src/engine/e_linereader.h b/src/engine/e_linereader.h
index d9d050d0..ca84960a 100644
--- a/src/engine/e_linereader.h
+++ b/src/engine/e_linereader.h
@@ -1,4 +1,4 @@
-#include "e_system.h"
+#include <base/system.h>
 
 /* buffered stream for reading lines, should perhaps be something smaller */
 typedef struct
diff --git a/src/engine/e_map.c b/src/engine/e_map.c
index 4240225a..c33868d7 100644
--- a/src/engine/e_map.c
+++ b/src/engine/e_map.c
@@ -1,5 +1,5 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include "e_system.h"
+#include <base/system.h>
 #include "e_datafile.h"
 
 static DATAFILE *map = 0;
diff --git a/src/engine/e_memheap.c b/src/engine/e_memheap.c
index a4b9bf37..7589e2c1 100644
--- a/src/engine/e_memheap.c
+++ b/src/engine/e_memheap.c
@@ -1,5 +1,5 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include "e_system.h"
+#include <base/system.h>
 
 typedef struct CHUNK_t
 {
diff --git a/src/engine/e_network.c b/src/engine/e_network.c
index 2eef9006..1e320293 100644
--- a/src/engine/e_network.c
+++ b/src/engine/e_network.c
@@ -1,8 +1,8 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include <string.h>
-#include <stdio.h>
+#include <base/system.h>
+
+#include <string.h> /* strlen */
 
-#include "e_system.h"
 #include "e_config.h"
 #include "e_network.h"
 #include "e_huffman.h"
@@ -134,9 +134,9 @@ static void rb_pop_first(RINGBUFFER *rb)
 		mem_free(rb->first);
 		rb->first = next;
 		if(rb->first)
-			rb->first->prev = NULL;
+			rb->first->prev = (void*)0;
 		else
-			rb->last = NULL;
+			rb->last = (void*)0;
 	}
 }
 
diff --git a/src/engine/e_packer.c b/src/engine/e_packer.c
index 07b9bc51..aee08aed 100644
--- a/src/engine/e_packer.c
+++ b/src/engine/e_packer.c
@@ -1,7 +1,7 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include <stdlib.h>
+#include <stdlib.h> /* rand() */
+#include <base/system.h>
 
-#include "e_system.h"
 #include "e_packer.h"
 #include "e_compression.h"
 #include "e_engine.h"
diff --git a/src/engine/e_protocol.h b/src/engine/e_protocol.h
index 46e1b8c2..93441fe7 100644
--- a/src/engine/e_protocol.h
+++ b/src/engine/e_protocol.h
@@ -1,5 +1,5 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include "e_system.h"
+#include <base/system.h>
 
 /*
 	Connection diagram - How the initilization works.
diff --git a/src/engine/e_ringbuffer.c b/src/engine/e_ringbuffer.c
index cfb2926b..281c3751 100644
--- a/src/engine/e_ringbuffer.c
+++ b/src/engine/e_ringbuffer.c
@@ -1,4 +1,4 @@
-#include <engine/e_system.h>
+#include <base/system.h>
 
 enum
 {
diff --git a/src/engine/e_snapshot.h b/src/engine/e_snapshot.h
index 9527cb24..f57c95c0 100644
--- a/src/engine/e_snapshot.h
+++ b/src/engine/e_snapshot.h
@@ -2,7 +2,7 @@
 #ifndef ENGINE_SNAPSHOT_H
 #define ENGINE_SNAPSHOT_H
 
-#include "e_system.h"
+#include <base/system.h>
 
 /* SNAPSHOT */
 
diff --git a/src/engine/external/glfw/lib/x11/x11_window.c b/src/engine/external/glfw/lib/x11/x11_window.c
index 056991b4..ed4c42f5 100644
--- a/src/engine/external/glfw/lib/x11/x11_window.c
+++ b/src/engine/external/glfw/lib/x11/x11_window.c
@@ -1521,7 +1521,7 @@ void _glfwPlatformPollEvents( void )
     // or without XSync, but when the GL window is rendered over a slow

     // network I have noticed bad event syncronisation problems when XSync

     // is not used, so I decided to use it.

-    XSync( _glfwLibrary.Dpy, False );

+    //XSync( _glfwLibrary.Dpy, False );

 

     // Empty the window event queue

     while( XPending( _glfwLibrary.Dpy ) )

diff --git a/src/engine/server/es_register.c b/src/engine/server/es_register.c
index a85900aa..a51b66b3 100644
--- a/src/engine/server/es_register.c
+++ b/src/engine/server/es_register.c
@@ -1,5 +1,5 @@
 #include <string.h>
-#include <engine/e_system.h>
+#include <base/system.h>
 #include <engine/e_network.h>
 #include <engine/e_config.h>
 #include <engine/e_engine.h>
diff --git a/src/engine/server/es_server.c b/src/engine/server/es_server.c
index 72da4f5d..7ed8712b 100644
--- a/src/engine/server/es_server.c
+++ b/src/engine/server/es_server.c
@@ -3,7 +3,8 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include <engine/e_system.h>
+#include <base/system.h>
+
 #include <engine/e_config.h>
 #include <engine/e_engine.h>
 #include <engine/e_server_interface.h>
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/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"
diff --git a/src/mastersrv/mastersrv.cpp b/src/mastersrv/mastersrv.cpp
index c27bb03c..95d34b20 100644
--- a/src/mastersrv/mastersrv.cpp
+++ b/src/mastersrv/mastersrv.cpp
@@ -1,8 +1,8 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
 #include <string.h>
+#include <base/system.h>
 
 extern "C" {
-	#include <engine/e_system.h>
 	#include <engine/e_network.h>
 }
 
diff --git a/src/tools/crapnet.cpp b/src/tools/crapnet.cpp
index f807bb61..cae2b7eb 100644
--- a/src/tools/crapnet.cpp
+++ b/src/tools/crapnet.cpp
@@ -1,5 +1,5 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include <engine/e_system.h>
+#include <base/system.h>
 
 #include <cstdlib>
 
diff --git a/src/tools/fake_server.c b/src/tools/fake_server.c
index 763caa73..602617ad 100644
--- a/src/tools/fake_server.c
+++ b/src/tools/fake_server.c
@@ -1,6 +1,6 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
+#include <base/system.h>
 #include <engine/e_config.h>
-#include <engine/e_system.h>
 #include <engine/e_network.h>
 #include <mastersrv/mastersrv.h>
 #include <stdlib.h>
diff --git a/src/tools/packetgen.c b/src/tools/packetgen.c
index 9e46c44d..0911c749 100644
--- a/src/tools/packetgen.c
+++ b/src/tools/packetgen.c
@@ -1,5 +1,5 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include <engine/e_system.h>
+#include <base/system.h>
 
 enum { NUM_SOCKETS = 64 };