Просмотр исходного кода

Moved headers and started moving tests

Thomas Buck 10 лет назад
Родитель
Сommit
ece6b3ec5a
58 измененных файлов: 543 добавлений и 514 удалений
  1. 5
    0
      ChangeLog
  2. 13
    13
      Makefile
  3. 0
    0
      include/Camera.h
  4. 0
    0
      include/Emitter.h
  5. 0
    0
      include/GLString.h
  6. 0
    0
      include/Light.h
  7. 0
    0
      include/Network.h
  8. 0
    0
      include/OpenGLMesh.h
  9. 0
    0
      include/OpenRaider.h
  10. 0
    0
      include/Particle.h
  11. 0
    0
      include/Render.h
  12. 0
    0
      include/SDLSystem.h
  13. 0
    0
      include/SkeletalModel.h
  14. 0
    0
      include/Sound.h
  15. 0
    0
      include/System.h
  16. 0
    0
      include/Texture.h
  17. 0
    0
      include/TombRaider.h
  18. 0
    0
      include/TombRaider1.h
  19. 0
    0
      include/TombRaider5.h
  20. 0
    0
      include/World.h
  21. 0
    0
      include/endian.h
  22. 0
    0
      include/hel/BoundingVolume.h
  23. 0
    0
      include/hel/Entity.h
  24. 0
    0
      include/hel/Matrix.h
  25. 0
    0
      include/hel/Quaternion.h
  26. 0
    0
      include/hel/Vector3d.h
  27. 0
    0
      include/hel/ViewVolume.h
  28. 0
    0
      include/hel/math.h
  29. 41
    4
      include/memory_test.h
  30. 19
    19
      include/mstl/List.h
  31. 59
    58
      include/mstl/Map.h
  32. 3
    3
      include/mstl/Tree.h
  33. 2
    2
      include/mstl/Vector.h
  34. 0
    0
      include/mtk_tga.h
  35. 5
    4
      src/Camera.cpp
  36. 4
    3
      src/Emitter.cpp
  37. 7
    8
      src/GLString.cpp
  38. 1
    1
      src/Light.cpp
  39. 38
    38
      src/Network.cpp
  40. 2
    1
      src/OpenGLMesh.cpp
  41. 12
    12
      src/OpenRaider.cpp
  42. 4
    3
      src/Particle.cpp
  43. 4
    8
      src/Render.cpp
  44. 5
    9
      src/SDLSystem.cpp
  45. 1
    1
      src/SkeletalModel.cpp
  46. 4
    3
      src/Sound.cpp
  47. 3
    7
      src/System.cpp
  48. 6
    6
      src/Texture.cpp
  49. 7
    6
      src/TombRaider.cpp
  50. 4
    3
      src/World.cpp
  51. 21
    21
      src/endian.cpp
  52. 2
    1
      src/hel/Matrix.cpp
  53. 2
    1
      src/hel/Quaternion.cpp
  54. 2
    1
      src/hel/Vector3d.cpp
  55. 39
    38
      src/hel/ViewVolume.cpp
  56. 61
    237
      src/memory_test.cpp
  57. 3
    3
      src/mtk_tga.cpp
  58. 164
    0
      test/memory_test.cpp

+ 5
- 0
ChangeLog Просмотреть файл

5
 
5
 
6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
7
 
7
 
8
+	[ 20140109 ]
9
+	* Renamed all memeory references to memory
10
+	* Moved headers into include/
11
+	* Put Unit Tests into test/
12
+
8
 	[ 20140107 ]
13
 	[ 20140107 ]
9
 	* Removed hel/Mass. There was an object of this class in World,
14
 	* Removed hel/Mass. There was an object of this class in World,
10
 	  but it was never used!
15
 	  but it was never used!

+ 13
- 13
Makefile Просмотреть файл

29
 # -DUNICODE_SUPPORT			Add unicode/internation keyboard support
29
 # -DUNICODE_SUPPORT			Add unicode/internation keyboard support
30
 # -DUSING_EMITTER_IN_GAME	Run particle test in game
30
 # -DUSING_EMITTER_IN_GAME	Run particle test in game
31
 
31
 
32
-BASE_DEFS=$(shell sdl-config --cflags) -Isrc -DSDL_INTERFACE \
32
+BASE_DEFS=$(shell sdl-config --cflags) -Iinclude -DSDL_INTERFACE \
33
 	-DUSING_OPENGL -DZLIB_SUPPORT -DUSING_EMITTER \
33
 	-DUSING_OPENGL -DZLIB_SUPPORT -DUSING_EMITTER \
34
 	-DUSING_OPENAL -DUSING_MTK_TGA -DUSING_PTHREADS \
34
 	-DUSING_OPENAL -DUSING_MTK_TGA -DUSING_PTHREADS \
35
 	-DUSING_HEL -DHAVE_SDL_TTF
35
 	-DUSING_HEL -DHAVE_SDL_TTF
158
 	CFLAGS="$(DEBUG_CFLAGS) -DDEDICATED_SERVER" \
158
 	CFLAGS="$(DEBUG_CFLAGS) -DDEDICATED_SERVER" \
159
 	LD_FLAGS="$(LD_FLAGS)"
159
 	LD_FLAGS="$(LD_FLAGS)"
160
 
160
 
161
-# -DDEBUG_MEMEORY_VERBOSE
162
-# -DDEBUG_MEMEORY
161
+# -DDEBUG_MEMORY_VERBOSE
162
+# -DDEBUG_MEMORY
163
 memory:
163
 memory:
164
 	@-mkdir -p $(BUILD_MEM_DIR)
164
 	@-mkdir -p $(BUILD_MEM_DIR)
165
 	$(MAKE) targets BUILDDIR=$(BUILD_MEM_DIR) \
165
 	$(MAKE) targets BUILDDIR=$(BUILD_MEM_DIR) \
166
 	DEBUG_OBJ="$(BUILD_MEM_DIR)/memory_test.o" \
166
 	DEBUG_OBJ="$(BUILD_MEM_DIR)/memory_test.o" \
167
-	CFLAGS="$(DEBUG_CFLAGS) -DDEBUG_MEMEORY" \
167
+	CFLAGS="$(DEBUG_CFLAGS) -DDEBUG_MEMORY" \
168
 	LD_FLAGS="$(LD_FLAGS)"
168
 	LD_FLAGS="$(LD_FLAGS)"
169
 
169
 
170
 depend:
170
 depend:
295
 TombRaider.test:
295
 TombRaider.test:
296
 	@-mkdir -p $(BUILD_TEST_DIR)
296
 	@-mkdir -p $(BUILD_TEST_DIR)
297
 	$(MAKE) targets NAME=TombRaider.test BUILDDIR=$(BUILD_TEST_DIR) \
297
 	$(MAKE) targets NAME=TombRaider.test BUILDDIR=$(BUILD_TEST_DIR) \
298
-	OBJS="$(BUILD_TEST_DIR)/TombRaider.o $(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/memeory_test.o" \
299
-	CFLAGS="$(BASE_CFLAGS) -g -D__TOMBRAIDER_TEST__ -D__TEST_TR5_DUMP_TGA -D__TEST_32BIT_TEXTILES -DDEBUG_MEMEORY" \
298
+	OBJS="$(BUILD_TEST_DIR)/TombRaider.o $(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/memory_test.o" \
299
+	CFLAGS="$(BASE_CFLAGS) -g -D__TOMBRAIDER_TEST__ -D__TEST_TR5_DUMP_TGA -D__TEST_32BIT_TEXTILES -DDEBUG_MEMORY" \
300
 	LD_FLAGS="-lz -lstdc++"
300
 	LD_FLAGS="-lz -lstdc++"
301
 
301
 
302
 #################################################################
302
 #################################################################
303
 
303
 
304
 GLString.test:
304
 GLString.test:
305
 	mkdir -p $(BUILD_TEST_DIR)
305
 	mkdir -p $(BUILD_TEST_DIR)
306
-	$(CC) -Wall -Isrc -D__TEST__ -DHAVE_MTK -DHAVE_SDL -DUSING_MTK_TGA \
306
+	$(CC) -Wall -Iinclude -D__TEST__ -DHAVE_MTK -DHAVE_SDL -DUSING_MTK_TGA \
307
 	$(shell sdl-config --cflags) $(shell sdl-config --libs) \
307
 	$(shell sdl-config --cflags) $(shell sdl-config --libs) \
308
 	$(GL_LIBS) $(GL_DEFS) -lm -lstdc++ \
308
 	$(GL_LIBS) $(GL_DEFS) -lm -lstdc++ \
309
 	src/Texture.cpp src/mtk_tga.cpp \
309
 	src/Texture.cpp src/mtk_tga.cpp \
316
 Matrix.test:
316
 Matrix.test:
317
 	@-echo "Building Matrix unit test"
317
 	@-echo "Building Matrix unit test"
318
 	mkdir -p $(BUILD_TEST_DIR)
318
 	mkdir -p $(BUILD_TEST_DIR)
319
-	$(CC) -Wall -g -DMATRIX_UNIT_TEST -lm -lstdc++ -Isrc \
319
+	$(CC) -Wall -g -DMATRIX_UNIT_TEST -lm -lstdc++ -Iinclude \
320
 	src/hel/Matrix.cpp src/hel/Quaternion.cpp src/hel/Vector3d.cpp \
320
 	src/hel/Matrix.cpp src/hel/Quaternion.cpp src/hel/Vector3d.cpp \
321
 	-o $(BUILD_TEST_DIR)/Matrix.test
321
 	-o $(BUILD_TEST_DIR)/Matrix.test
322
 	@-echo "================================================="
322
 	@-echo "================================================="
326
 Quaternion.test:
326
 Quaternion.test:
327
 	@-echo "Building Quaternion unit test"
327
 	@-echo "Building Quaternion unit test"
328
 	mkdir -p $(BUILD_TEST_DIR)
328
 	mkdir -p $(BUILD_TEST_DIR)
329
-	$(CC) -Wall -g -DUNIT_TEST_QUATERNION -lm -lstdc++ -Isrc \
329
+	$(CC) -Wall -g -DUNIT_TEST_QUATERNION -lm -lstdc++ -Iinclude \
330
 	src/hel/Quaternion.cpp -o $(BUILD_TEST_DIR)/Quaternion.test
330
 	src/hel/Quaternion.cpp -o $(BUILD_TEST_DIR)/Quaternion.test
331
 	@-echo "================================================="
331
 	@-echo "================================================="
332
 	@-echo "Running Quaternion unit test"
332
 	@-echo "Running Quaternion unit test"
335
 Math.test:
335
 Math.test:
336
 	@-echo "Building Math unit test"
336
 	@-echo "Building Math unit test"
337
 	mkdir -p $(BUILD_TEST_DIR)
337
 	mkdir -p $(BUILD_TEST_DIR)
338
-	$(CC) -Wall -g -DMATH_UNIT_TEST -lm -lstdc++ -Isrc \
338
+	$(CC) -Wall -g -DMATH_UNIT_TEST -lm -lstdc++ -Iinclude \
339
 	src/hel/math.cpp src/hel/Vector3d.cpp -o $(BUILD_TEST_DIR)/Math.test
339
 	src/hel/math.cpp src/hel/Vector3d.cpp -o $(BUILD_TEST_DIR)/Math.test
340
 	@-echo "================================================="
340
 	@-echo "================================================="
341
 	@-echo "Running hel unit test"
341
 	@-echo "Running hel unit test"
345
 
345
 
346
 Memory.test:
346
 Memory.test:
347
 	mkdir -p $(BUILD_TEST_DIR)
347
 	mkdir -p $(BUILD_TEST_DIR)
348
-	$(CC) -Wall -g -D__TEST__ -lstdc++ \
349
-	-DDEBUG_MEMEORY -DDEBUG_MEMEORY_ERROR \
350
-	src/memeory_test.cpp -o $(BUILD_TEST_DIR)/memory_test.test
348
+	$(CC) -Wall -g -lstdc++ -Iinclude \
349
+	-DDEBUG_MEMORY -DDEBUG_MEMORY_ERROR \
350
+	src/memory_test.cpp test/memory_test.cpp -o $(BUILD_TEST_DIR)/memory_test.test
351
 
351
 
352
 #################################################################
352
 #################################################################
353
 
353
 

src/Camera.h → include/Camera.h Просмотреть файл


src/Emitter.h → include/Emitter.h Просмотреть файл


src/GLString.h → include/GLString.h Просмотреть файл


src/Light.h → include/Light.h Просмотреть файл


src/Network.h → include/Network.h Просмотреть файл


src/OpenGLMesh.h → include/OpenGLMesh.h Просмотреть файл


src/OpenRaider.h → include/OpenRaider.h Просмотреть файл


src/Particle.h → include/Particle.h Просмотреть файл


src/Render.h → include/Render.h Просмотреть файл


src/SDLSystem.h → include/SDLSystem.h Просмотреть файл


src/SkeletalModel.h → include/SkeletalModel.h Просмотреть файл


src/Sound.h → include/Sound.h Просмотреть файл


src/System.h → include/System.h Просмотреть файл


src/Texture.h → include/Texture.h Просмотреть файл


src/TombRaider.h → include/TombRaider.h Просмотреть файл


src/TombRaider1.h → include/TombRaider1.h Просмотреть файл


src/TombRaider5.h → include/TombRaider5.h Просмотреть файл


src/World.h → include/World.h Просмотреть файл


src/endian.h → include/endian.h Просмотреть файл


src/hel/BoundingVolume.h → include/hel/BoundingVolume.h Просмотреть файл


src/hel/Entity.h → include/hel/Entity.h Просмотреть файл


src/hel/Matrix.h → include/hel/Matrix.h Просмотреть файл


src/hel/Quaternion.h → include/hel/Quaternion.h Просмотреть файл


src/hel/Vector3d.h → include/hel/Vector3d.h Просмотреть файл


src/hel/ViewVolume.h → include/hel/ViewVolume.h Просмотреть файл


src/hel/math.h → include/hel/math.h Просмотреть файл


src/memeory_test.h → include/memory_test.h Просмотреть файл

21
 
21
 
22
 #include <cstddef>
22
 #include <cstddef>
23
 
23
 
24
-#ifndef __MTK_MONGOOSE_MEMEORY_TEST_H_
25
-#define __MTK_MONGOOSE_MEMEORY_TEST_H_
24
+#ifndef __MTK_MONGOOSE_MEMORY_TEST_H_
25
+#define __MTK_MONGOOSE_MEMORY_TEST_H_
26
 
26
 
27
-#ifdef DEBUG_MEMEORY
27
+#if defined(DEBUG_MEMORY) && !defined(UNIT_TEST_MEMORY)
28
 
28
 
29
 #define DEBUG_NEW new(__FILE__, __LINE__)
29
 #define DEBUG_NEW new(__FILE__, __LINE__)
30
 void *operator new(size_t size, const char *file, int line);
30
 void *operator new(size_t size, const char *file, int line);
63
 	void dump_memory_report();
63
 	void dump_memory_report();
64
 	/*------------------------------------------------------
64
 	/*------------------------------------------------------
65
 	 * Pre  :
65
 	 * Pre  :
66
-	 * Post : Dumps raw Tree holding memeory accounting
66
+	 * Post : Dumps raw Tree holding memory accounting
67
 	 *
67
 	 *
68
 	 *-- History ------------------------------------------
68
 	 *-- History ------------------------------------------
69
 	 *
69
 	 *
71
 	 * Mongoose - Created
71
 	 * Mongoose - Created
72
 	 ------------------------------------------------------*/
72
 	 ------------------------------------------------------*/
73
 
73
 
74
+#ifdef DEBUG_MEMORY
75
+
76
+    #define DWORD unsigned long
77
+    #define ZERO_ALLOC_SLOTS 3
78
+
79
+    typedef enum { RB_BLACK = 0, RB_RED = 1 } rbtree_color_t;
80
+
81
+    typedef struct rbtree_s {
82
+        void *data;
83
+        DWORD key;
84
+        rbtree_color_t color;
85
+        struct rbtree_s *left;
86
+        struct rbtree_s *right;
87
+        struct rbtree_s *parent;
88
+    } rbtree_t;
89
+
90
+    typedef struct meminfo_filename_s {
91
+        char *filename;
92
+        char filename_len;
93
+        DWORD size;
94
+        unsigned int alloc_zero;
95
+        unsigned short int alloc_zero_at_line[ZERO_ALLOC_SLOTS];
96
+        struct meminfo_filename_s *next;
97
+    } meminfo_filename_t;
98
+
99
+    extern rbtree_t *MEMORY_INFO;
100
+    extern meminfo_filename_t *MEMORY_FILENAME;
101
+    extern long MEMORY_USED;
102
+    extern long MEMORYA_USED;
103
+    extern long MEMORYC_USED;
104
+    extern long MAX_MEMORY_USED;
105
+    extern long MAX_MEMORYA_USED;
106
+    extern long MAX_MEMORYC_USED;
107
+
108
+    void tree_valid_report(rbtree_t *root);
109
+
110
+#endif
74
 
111
 
75
 #endif
112
 #endif

src/mstl/List.h → include/mstl/List.h Просмотреть файл

1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
 /*================================================================
2
 /*================================================================
3
- * 
3
+ *
4
  * Project : Freyja
4
  * Project : Freyja
5
  * Author  : Mongoose
5
  * Author  : Mongoose
6
  * Website : http://www.westga.edu/~stu7440/
6
  * Website : http://www.westga.edu/~stu7440/
10
  * Comments: mtk Template list
10
  * Comments: mtk Template list
11
  *
11
  *
12
  *           UINT_MAX is an error condition, used in place of -1
12
  *           UINT_MAX is an error condition, used in place of -1
13
- * 
14
- *           This file was generated using Mongoose's C++ 
13
+ *
14
+ *           This file was generated using Mongoose's C++
15
  *           template generator script.  <stu7440@westga.edu>
15
  *           template generator script.  <stu7440@westga.edu>
16
- * 
17
- *-- History ------------------------------------------------ 
16
+ *
17
+ *-- History ------------------------------------------------
18
  *
18
  *
19
  * 2000-10-26:
19
  * 2000-10-26:
20
  * Mongoose - Created
20
  * Mongoose - Created
28
 #include <limits.h>
28
 #include <limits.h>
29
 #include <stdio.h>
29
 #include <stdio.h>
30
 
30
 
31
-#ifdef DEBUG_MEMEORY
32
-#   include "memeory_test.h"
31
+#ifdef DEBUG_MEMORY
32
+#include <memory_test.h>
33
 #endif
33
 #endif
34
 
34
 
35
- 
35
+
36
 template <class T> class ListNode
36
 template <class T> class ListNode
37
 {
37
 {
38
  public:
38
  public:
155
 
155
 
156
       last = current;
156
       last = current;
157
       current = current->Next();
157
       current = current->Next();
158
-    }    
158
+    }
159
 
159
 
160
     return 0;
160
     return 0;
161
   }
161
   }
184
 
184
 
185
       last = current;
185
       last = current;
186
       current = current->Next();
186
       current = current->Next();
187
-    }    
187
+    }
188
 
188
 
189
     return UINT_MAX;
189
     return UINT_MAX;
190
   }
190
   }
228
 
228
 
229
 	if (_current == current)
229
 	if (_current == current)
230
 	  _current = NULL;
230
 	  _current = NULL;
231
-	
231
+
232
 	delete current;
232
 	delete current;
233
 	_num_items--;
233
 	_num_items--;
234
 
234
 
237
 
237
 
238
       last = current;
238
       last = current;
239
       current = current->Next();
239
       current = current->Next();
240
-    }    
240
+    }
241
   }
241
   }
242
 
242
 
243
   void Remove(T data)
243
   void Remove(T data)
259
 	{
259
 	{
260
 	  last->Next(current->Next());
260
 	  last->Next(current->Next());
261
 	}
261
 	}
262
-	
262
+
263
 	if (_current == current)
263
 	if (_current == current)
264
 	  _current = NULL;
264
 	  _current = NULL;
265
 
265
 
271
 
271
 
272
       last = current;
272
       last = current;
273
       current = current->Next();
273
       current = current->Next();
274
-    }    
274
+    }
275
   }
275
   }
276
 
276
 
277
   bool Empty()
277
   bool Empty()
291
 
291
 
292
     printf(" [%i] {\n", _num_items);
292
     printf(" [%i] {\n", _num_items);
293
 
293
 
294
-    
294
+
295
     while (current)
295
     while (current)
296
     {
296
     {
297
       printf("#%i, ", current->Id());
297
       printf("#%i, ", current->Id());
304
       fflush(stdout);
304
       fflush(stdout);
305
     }
305
     }
306
 
306
 
307
-    printf(" }\n");    
307
+    printf(" }\n");
308
   }
308
   }
309
 
309
 
310
 
310
 
314
 
314
 
315
     printf("List %i {\n", _num_items);
315
     printf("List %i {\n", _num_items);
316
 
316
 
317
-    
317
+
318
     while (current)
318
     while (current)
319
     {
319
     {
320
       //current->Print();
320
       //current->Print();
354
   {
354
   {
355
     if (!_current)
355
     if (!_current)
356
       return UINT_MAX;
356
       return UINT_MAX;
357
-    
357
+
358
     return _current->Id();
358
     return _current->Id();
359
   }
359
   }
360
 
360
 
407
 	{
407
 	{
408
 	  node->Id(i);
408
 	  node->Id(i);
409
 	  node->Next(current);
409
 	  node->Next(current);
410
-	  
410
+
411
 	  if (current == _head)
411
 	  if (current == _head)
412
 	    _head = node;
412
 	    _head = node;
413
 	  else if (last)
413
 	  else if (last)

src/mstl/Map.h → include/mstl/Map.h Просмотреть файл

1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
 /*================================================================
2
 /*================================================================
3
- * 
3
+ *
4
  * Project : Freyja
4
  * Project : Freyja
5
  * Author  : Mongoose
5
  * Author  : Mongoose
6
  * Website : http://www.westga.edu/~stu7440/
6
  * Website : http://www.westga.edu/~stu7440/
8
  * Object  : Map
8
  * Object  : Map
9
  * License : No use w/o permission (C) 2000-2002 Mongoose
9
  * License : No use w/o permission (C) 2000-2002 Mongoose
10
  * Comments: mtk Template list
10
  * Comments: mtk Template list
11
- * 
12
- *           This file was generated using Mongoose's C++ 
11
+ *
12
+ *           This file was generated using Mongoose's C++
13
  *           template generator script.  <stu7440@westga.edu>
13
  *           template generator script.  <stu7440@westga.edu>
14
- * 
15
- *-- History ------------------------------------------------ 
14
+ *
15
+ *-- History ------------------------------------------------
16
  *
16
  *
17
  * 2002.02.19:
17
  * 2002.02.19:
18
  * Mongoose - Using RBTree and list overlay for faster access
18
  * Mongoose - Using RBTree and list overlay for faster access
25
  * Mongoose - Binary tree overlay started... at 0300  /_\ Zzzz
25
  * Mongoose - Binary tree overlay started... at 0300  /_\ Zzzz
26
  *
26
  *
27
  * 2002.02.01:
27
  * 2002.02.01:
28
- * Mongoose - Dug out of cobwebs and fixed up 
28
+ * Mongoose - Dug out of cobwebs and fixed up
29
  *            Yes, I believe in code reuse!  =)
29
  *            Yes, I believe in code reuse!  =)
30
  *
30
  *
31
  * 2000.10.26:
31
  * 2000.10.26:
38
 
38
 
39
 #include <stdlib.h>
39
 #include <stdlib.h>
40
 #include <stdio.h>
40
 #include <stdio.h>
41
-#include "Tree.h"
42
 
41
 
43
-#ifdef DEBUG_MEMEORY
44
-#   include "memeory_test.h"
42
+#include <mstl/Tree.h>
43
+
44
+#ifdef DEBUG_MEMORY
45
+#include <memory_test.h>
45
 #endif
46
 #endif
46
 
47
 
47
 
48
 
57
 		_next = NULL;
58
 		_next = NULL;
58
 	}
59
 	}
59
 
60
 
60
-	
61
+
61
 	~MapNode()
62
 	~MapNode()
62
 	{
63
 	{
63
 	}
64
 	}
64
-	
65
+
65
 
66
 
66
 	void Key(K key)
67
 	void Key(K key)
67
 	{
68
 	{
68
 		_key = key;
69
 		_key = key;
69
 	}
70
 	}
70
-	
71
+
71
 
72
 
72
 	K Key()
73
 	K Key()
73
 	{
74
 	{
74
 		return _key;
75
 		return _key;
75
 	}
76
 	}
76
-	
77
+
77
 
78
 
78
 	void Data(D data)
79
 	void Data(D data)
79
 	{
80
 	{
80
     _data = data;
81
     _data = data;
81
 	}
82
 	}
82
-	
83
+
83
 
84
 
84
 	D Data()
85
 	D Data()
85
 	{
86
 	{
86
 		return _data;
87
 		return _data;
87
 	}
88
 	}
88
-	
89
+
89
 
90
 
90
 	MapNode<K, D> *Next()
91
 	MapNode<K, D> *Next()
91
 	{
92
 	{
92
 		return _next;
93
 		return _next;
93
 	}
94
 	}
94
-	
95
+
95
 
96
 
96
 	void Next(MapNode<K, D> *next)
97
 	void Next(MapNode<K, D> *next)
97
 	{
98
 	{
98
 		_next = next;
99
 		_next = next;
99
 	}
100
 	}
100
-	
101
+
101
 private:
102
 private:
102
 
103
 
103
 	MapNode<K, D> *_next;
104
 	MapNode<K, D> *_next;
111
 template <class K, class D> class Map
112
 template <class K, class D> class Map
112
 {
113
 {
113
 public:
114
 public:
114
-	
115
+
115
 	Map()
116
 	Map()
116
 	{
117
 	{
117
 		UnSetError();
118
 		UnSetError();
120
 		_current = NULL;
121
 		_current = NULL;
121
 		_cache = NULL;
122
 		_cache = NULL;
122
 	}
123
 	}
123
-	
124
-	
124
+
125
+
125
 	~Map()
126
 	~Map()
126
 	{
127
 	{
127
 		Clear();
128
 		Clear();
128
 	}
129
 	}
129
-	
130
+
130
 
131
 
131
 	void Clear()
132
 	void Clear()
132
 	{
133
 	{
133
 		UnSetError();
134
 		UnSetError();
134
 		_num_items = 0;
135
 		_num_items = 0;
135
 		_cache = NULL;
136
 		_cache = NULL;
136
-		
137
+
137
 		while (_head)
138
 		while (_head)
138
 		{
139
 		{
139
 			_current = _head;
140
 			_current = _head;
149
 	{
150
 	{
150
 		_error = true;
151
 		_error = true;
151
 	}
152
 	}
152
-	
153
+
153
 
154
 
154
 	void UnSetError()
155
 	void UnSetError()
155
 	{
156
 	{
156
 		_error = false;
157
 		_error = false;
157
 	}
158
 	}
158
-	
159
+
159
 
160
 
160
 	bool GetError()
161
 	bool GetError()
161
 	{
162
 	{
167
 	{
168
 	{
168
 		MapNode<K, D> *current = NULL;
169
 		MapNode<K, D> *current = NULL;
169
 		MapNode<K, D> *next = NULL;
170
 		MapNode<K, D> *next = NULL;
170
-		
171
+
171
 
172
 
172
 		if (_head)
173
 		if (_head)
173
 		{
174
 		{
190
 				if (_error)
191
 				if (_error)
191
 					return false;
192
 					return false;
192
 			}
193
 			}
193
-			
194
+
194
 			if (current)
195
 			if (current)
195
 			{
196
 			{
196
 				_cache = _current = current;
197
 				_cache = _current = current;
207
 	{
208
 	{
208
 		return FindDataByKey(key);
209
 		return FindDataByKey(key);
209
 	}
210
 	}
210
-	
211
+
211
 
212
 
212
 	K FindKeyByData(D data)
213
 	K FindKeyByData(D data)
213
 	{
214
 	{
214
 		MapNode<K, D> *current = _head;
215
 		MapNode<K, D> *current = _head;
215
 		MapNode<K, D> *last = NULL;
216
 		MapNode<K, D> *last = NULL;
216
-		
217
+
217
 
218
 
218
 		UnSetError();
219
 		UnSetError();
219
-		
220
+
220
 		while (current)
221
 		while (current)
221
 		{
222
 		{
222
 			// Found
223
 			// Found
225
 				_cache = current;
226
 				_cache = current;
226
 				return current->Key();
227
 				return current->Key();
227
 			}
228
 			}
228
-			
229
+
229
 			last = current;
230
 			last = current;
230
 			current = current->Next();
231
 			current = current->Next();
231
 		}
232
 		}
275
 			{
276
 			{
276
 				current = _tree.SearchByKey(key, &_error);
277
 				current = _tree.SearchByKey(key, &_error);
277
 			}
278
 			}
278
-			
279
+
279
 			if (current)
280
 			if (current)
280
 			{
281
 			{
281
 				_cache = _current = current;
282
 				_cache = _current = current;
288
 		return false;
289
 		return false;
289
 	}
290
 	}
290
 
291
 
291
-	
292
+
292
 	bool Add(K key, D data)
293
 	bool Add(K key, D data)
293
 	{
294
 	{
294
 		MapNode<K, D> *node;
295
 		MapNode<K, D> *node;
295
-		
296
-		
296
+
297
+
297
 		UnSetError();
298
 		UnSetError();
298
 		node = new MapNode<K, D>(key, data);
299
 		node = new MapNode<K, D>(key, data);
299
 		_num_items++;
300
 		_num_items++;
323
 				if (current->Key() > node->Key())
324
 				if (current->Key() > node->Key())
324
 				{
325
 				{
325
 					node->Next(current);
326
 					node->Next(current);
326
-					
327
+
327
 					if (current == _head)
328
 					if (current == _head)
328
 					{
329
 					{
329
 						_head = node;
330
 						_head = node;
340
 				last = current;
341
 				last = current;
341
 				current = current->Next();
342
 				current = current->Next();
342
 			}
343
 			}
343
-			
344
+
344
 			// Append
345
 			// Append
345
 			last->Next(node);
346
 			last->Next(node);
346
 		}
347
 		}
349
 			_head = node;
350
 			_head = node;
350
 		}
351
 		}
351
 
352
 
352
-		_tree.Insert(node->Key(), node);		
353
+		_tree.Insert(node->Key(), node);
353
 		return true;
354
 		return true;
354
 	}
355
 	}
355
 
356
 
358
 	{
359
 	{
359
 		MapNode<K, D> *current = _head;
360
 		MapNode<K, D> *current = _head;
360
 		MapNode<K, D> *last = NULL;
361
 		MapNode<K, D> *last = NULL;
361
-		
362
+
362
 
363
 
363
 		UnSetError();
364
 		UnSetError();
364
 
365
 
377
 				{
378
 				{
378
 					last->Next(current->Next());
379
 					last->Next(current->Next());
379
 				}
380
 				}
380
-				
381
+
381
 				if (_current == current)
382
 				if (_current == current)
382
 				{
383
 				{
383
 					_current = NULL;
384
 					_current = NULL;
386
 				_tree.RemoveByKey(current->Key());
387
 				_tree.RemoveByKey(current->Key());
387
 				delete current;
388
 				delete current;
388
 				_num_items--;
389
 				_num_items--;
389
-				
390
+
390
 				return;
391
 				return;
391
 			}
392
 			}
392
-			
393
+
393
 			last = current;
394
 			last = current;
394
 			current = current->Next();
395
 			current = current->Next();
395
 		}
396
 		}
402
 	{
403
 	{
403
 		MapNode<K, D> *current = _head;
404
 		MapNode<K, D> *current = _head;
404
 		MapNode<K, D> *last = NULL;
405
 		MapNode<K, D> *last = NULL;
405
-		
406
+
406
 
407
 
407
 		UnSetError();
408
 		UnSetError();
408
 
409
 
421
 				{
422
 				{
422
 					last->Next(current->Next());
423
 					last->Next(current->Next());
423
 				}
424
 				}
424
-				
425
+
425
 				if (_current == current)
426
 				if (_current == current)
426
 				{
427
 				{
427
 					_current = NULL;
428
 					_current = NULL;
430
 				_tree.RemoveByKey(current->Key());
431
 				_tree.RemoveByKey(current->Key());
431
 				delete current;
432
 				delete current;
432
 				_num_items--;
433
 				_num_items--;
433
-				
434
+
434
 				return;
435
 				return;
435
 			}
436
 			}
436
-			
437
+
437
 			last = current;
438
 			last = current;
438
 			current = current->Next();
439
 			current = current->Next();
439
 		}
440
 		}
473
 		}
474
 		}
474
 
475
 
475
 		printf(" [%i] {\n", _num_items);
476
 		printf(" [%i] {\n", _num_items);
476
-		
477
+
477
 		while (current)
478
 		while (current)
478
 		{
479
 		{
479
 			printf("(");
480
 			printf("(");
482
 			(*print_data_func)(current->Data());
483
 			(*print_data_func)(current->Data());
483
 			printf("), ");
484
 			printf("), ");
484
 
485
 
485
-			current = current->Next();			
486
+			current = current->Next();
486
 			fflush(stdout);
487
 			fflush(stdout);
487
 		}
488
 		}
488
-		
489
-		printf(" }\n");    
489
+
490
+		printf(" }\n");
490
 	}
491
 	}
491
 
492
 
492
 
493
 
509
 		{
510
 		{
510
 			_current = _current->Next();
511
 			_current = _current->Next();
511
 		}
512
 		}
512
-		
513
+
513
 		return (_current != NULL);
514
 		return (_current != NULL);
514
 	}
515
 	}
515
 
516
 
523
 	K CurrentKey()
524
 	K CurrentKey()
524
 	{
525
 	{
525
 		UnSetError();
526
 		UnSetError();
526
-		
527
+
527
 		if (!_current)
528
 		if (!_current)
528
 		{
529
 		{
529
 			SetError();
530
 			SetError();
530
 			return 0;
531
 			return 0;
531
 		}
532
 		}
532
-		
533
+
533
 		return _current->Key();
534
 		return _current->Key();
534
 	}
535
 	}
535
 
536
 
537
 	D Current()
538
 	D Current()
538
 	{
539
 	{
539
 		UnSetError();
540
 		UnSetError();
540
-		
541
+
541
 		if (!_current)
542
 		if (!_current)
542
 		{
543
 		{
543
 			SetError();
544
 			SetError();
544
 			return 0;
545
 			return 0;
545
 		}
546
 		}
546
-		
547
+
547
 		return _current->Data();
548
 		return _current->Data();
548
 	}
549
 	}
549
 
550
 
550
 private:
551
 private:
551
-	
552
+
552
 	unsigned int _num_items;
553
 	unsigned int _num_items;
553
-	
554
+
554
 	bool _error;
555
 	bool _error;
555
-	
556
+
556
 	Tree<K, MapNode<K, D> *> _tree;
557
 	Tree<K, MapNode<K, D> *> _tree;
557
 
558
 
558
 	MapNode<K, D> *_head;
559
 	MapNode<K, D> *_head;
559
-	
560
+
560
 	MapNode<K, D> *_current;
561
 	MapNode<K, D> *_current;
561
 
562
 
562
 	MapNode<K, D> *_cache;
563
 	MapNode<K, D> *_cache;

src/mstl/Tree.h → include/mstl/Tree.h Просмотреть файл

47
 #include <stdio.h>
47
 #include <stdio.h>
48
 
48
 
49
 #ifdef USE_IOSTREAM
49
 #ifdef USE_IOSTREAM
50
-#   include <iostream.h>
50
+#include <iostream.h>
51
 #endif
51
 #endif
52
 
52
 
53
-#ifdef DEBUG_MEMEORY
54
-#   include "memeory_test.h"
53
+#ifdef DEBUG_MEMORY
54
+#include <memory_test.h>
55
 #endif
55
 #endif
56
 
56
 
57
 
57
 

src/mstl/Vector.h → include/mstl/Vector.h Просмотреть файл

27
 #include <stdlib.h>
27
 #include <stdlib.h>
28
 #include <stdio.h>
28
 #include <stdio.h>
29
 
29
 
30
-#ifdef DEBUG_MEMEORY
31
-#   include "memeory_test.h"
30
+#ifdef DEBUG_MEMORY
31
+#include <memory_test.h>
32
 #endif
32
 #endif
33
 
33
 
34
 
34
 

src/mtk_tga.h → include/mtk_tga.h Просмотреть файл


+ 5
- 4
src/Camera.cpp Просмотреть файл

34
 
34
 
35
 #include <stdio.h>
35
 #include <stdio.h>
36
 #include <math.h>
36
 #include <math.h>
37
-#include "hel/math.h"
38
-#include "Camera.h"
39
 
37
 
40
-#ifdef DEBUG_MEMEORY
41
-#   include "memeory_test.h"
38
+#include <hel/math.h>
39
+#include <Camera.h>
40
+
41
+#ifdef DEBUG_MEMORY
42
+#include <memory_test.h>
42
 #endif
43
 #endif
43
 
44
 
44
 
45
 

+ 4
- 3
src/Emitter.cpp Просмотреть файл

29
 #include <GL/gl.h>
29
 #include <GL/gl.h>
30
 #include <GL/glu.h>
30
 #include <GL/glu.h>
31
 #endif
31
 #endif
32
-#include "Emitter.h"
33
 
32
 
34
-#ifdef DEBUG_MEMEORY
35
-#   include "memeory_test.h"
33
+#include <Emitter.h>
34
+
35
+#ifdef DEBUG_MEMORY
36
+#include <memory_test.h>
36
 #endif
37
 #endif
37
 
38
 
38
 vec_t Emitter::mFrustum[6][4];
39
 vec_t Emitter::mFrustum[6][4];

+ 7
- 8
src/GLString.cpp Просмотреть файл

15
 #include <GL/gl.h>
15
 #include <GL/gl.h>
16
 #endif
16
 #endif
17
 
17
 
18
-#include "Texture.h"
18
+#include <Texture.h>
19
+#include <GLString.h>
19
 
20
 
20
-#include "GLString.h"
21
-
22
-#ifdef DEBUG_MEMEORY
23
-#include "memeory_test.h"
21
+#ifdef DEBUG_MEMORY
22
+#include <memory_test.h>
24
 #endif
23
 #endif
25
 
24
 
26
 
25
 
419
 #endif
418
 #endif
420
 
419
 
421
 #ifdef HAVE_MTK
420
 #ifdef HAVE_MTK
422
-#   include "Texture.h"
423
-#   include "mtk_tga.h"
421
+#include <Texture.h>
422
+#include <mtk_tga.h>
424
 
423
 
425
 Texture gTexture;
424
 Texture gTexture;
426
 #else
425
 #else
427
-#   error "Requires MTK: Texture and mtk_tga"
426
+#error "Requires MTK: Texture and mtk_tga"
428
 #endif
427
 #endif
429
 
428
 
430
 
429
 

+ 1
- 1
src/Light.cpp Просмотреть файл

19
  * Mongoose - Created
19
  * Mongoose - Created
20
  =================================================================*/
20
  =================================================================*/
21
 
21
 
22
-#include "Light.h"
22
+#include <Light.h>
23
 
23
 
24
 
24
 
25
 Light::Light()
25
 Light::Light()

+ 38
- 38
src/Network.cpp Просмотреть файл

1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
 /*================================================================
2
 /*================================================================
3
- * 
3
+ *
4
  * Project : UnRaider
4
  * Project : UnRaider
5
  * Author  : Terry 'Mongoose' Hendrix II
5
  * Author  : Terry 'Mongoose' Hendrix II
6
  * Website : http://www.westga.edu/~stu7440/
6
  * Website : http://www.westga.edu/~stu7440/
7
  * Email   : stu7440@westga.edu
7
  * Email   : stu7440@westga.edu
8
  * Object  : Network
8
  * Object  : Network
9
  * License : No use w/o permission (C) 2002 Mongoose
9
  * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: 
10
+ * Comments:
11
  *
11
  *
12
  *
12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14
  *           template generator script.  <stu7440@westga.edu>
14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------- 
15
+ *
16
+ *-- History -------------------------------------------------
17
  *
17
  *
18
  * 2002.06.21:
18
  * 2002.06.21:
19
  * Mongoose - Created
19
  * Mongoose - Created
20
  =================================================================*/
20
  =================================================================*/
21
 
21
 
22
-#include "Network.h"
22
+#include <Network.h>
23
 
23
 
24
 #include <unistd.h>
24
 #include <unistd.h>
25
 #include <signal.h>
25
 #include <signal.h>
70
 
70
 
71
 Network *Network::Instance()
71
 Network *Network::Instance()
72
 {
72
 {
73
-	if (mInstance == 0x0) 
73
+	if (mInstance == 0x0)
74
 	{
74
 	{
75
 		mInstance = new Network();
75
 		mInstance = new Network();
76
 	}
76
 	}
77
-	
77
+
78
 	return mInstance;
78
 	return mInstance;
79
 }
79
 }
80
 
80
 
82
 void killNetworkSingleton()
82
 void killNetworkSingleton()
83
 {
83
 {
84
 	printf("Shutting down Network...\n");
84
 	printf("Shutting down Network...\n");
85
-	
85
+
86
 	// Requires public deconstructor
86
 	// Requires public deconstructor
87
 	delete Network::Instance();
87
 	delete Network::Instance();
88
 }
88
 }
145
 	srand(tv.tv_usec);
145
 	srand(tv.tv_usec);
146
 
146
 
147
 	return ((unsigned int)(tv.tv_sec * getRandom(2.0, 3.3) -
147
 	return ((unsigned int)(tv.tv_sec * getRandom(2.0, 3.3) -
148
-								  tv.tv_sec * getRandom(1.0, 2.0)) + 
148
+								  tv.tv_sec * getRandom(1.0, 2.0)) +
149
 			  (unsigned int)(tv.tv_usec * getRandom(2.0, 3.3) -
149
 			  (unsigned int)(tv.tv_usec * getRandom(2.0, 3.3) -
150
 								  tv.tv_usec * getRandom(1.0, 2.0)) +
150
 								  tv.tv_usec * getRandom(1.0, 2.0)) +
151
 			  (unsigned int)getRandom(666.0, 5000.0));
151
 			  (unsigned int)getRandom(666.0, 5000.0));
285
 	struct sockaddr_in s_in, from;
285
 	struct sockaddr_in s_in, from;
286
 	char hostid[64];
286
 	char hostid[64];
287
 	network_frame_t f;
287
 	network_frame_t f;
288
-	unsigned int i;	
288
+	unsigned int i;
289
 	unsigned int packetsRecieved = 0;
289
 	unsigned int packetsRecieved = 0;
290
 
290
 
291
 
291
 
309
 			return -1;
309
 			return -1;
310
 		}
310
 		}
311
 
311
 
312
-		printf("Server: gethostname returned '%s'\n", hostid); 
312
+		printf("Server: gethostname returned '%s'\n", hostid);
313
 		fflush(stdout);
313
 		fflush(stdout);
314
 	}
314
 	}
315
 
315
 
346
 
346
 
347
 	cip = ntohl(s_in.sin_addr.s_addr);
347
 	cip = ntohl(s_in.sin_addr.s_addr);
348
 
348
 
349
-	printf("Server: Started on ( %i.%i.%i.%i:%i )\n", 
350
-			 cip >> 24, cip << 8 >> 24, 
349
+	printf("Server: Started on ( %i.%i.%i.%i:%i )\n",
350
+			 cip >> 24, cip << 8 >> 24,
351
 			 cip << 16 >> 24, cip << 24 >> 24, s_in.sin_port);
351
 			 cip << 16 >> 24, cip << 24 >> 24, s_in.sin_port);
352
 
352
 
353
 	for (; !mKillClient;)
353
 	for (; !mKillClient;)
356
 
356
 
357
 		// 1. Wait for event
357
 		// 1. Wait for event
358
 		// 2. Get inbound frame
358
 		// 2. Get inbound frame
359
-		cc = recvfrom(socket_fd, &f, sizeof(network_frame_t), 0, 
359
+		cc = recvfrom(socket_fd, &f, sizeof(network_frame_t), 0,
360
 						  (struct sockaddr *)&from, &fsize);
360
 						  (struct sockaddr *)&from, &fsize);
361
 
361
 
362
 		if (cc < 0)
362
 		if (cc < 0)
396
 					gClients[i].frameExpected = 0;
396
 					gClients[i].frameExpected = 0;
397
 					++gNumClients;
397
 					++gNumClients;
398
 
398
 
399
-					printf("Server: %u made connection, as client %i\n", 
399
+					printf("Server: %u made connection, as client %i\n",
400
 							 gClients[i].uid, i);
400
 							 gClients[i].uid, i);
401
 					break;
401
 					break;
402
 				}
402
 				}
417
 
417
 
418
 		if (mDebug)
418
 		if (mDebug)
419
 		{
419
 		{
420
-			printf("Server: Client (Famliy %d, Address %i.%i.%i.%i:%d)\n", 
421
-					 ntohs(from.sin_family), cip >> 24, cip << 8 >> 24, 
422
-					 cip << 16 >> 24, cip << 24 >> 24, 
420
+			printf("Server: Client (Famliy %d, Address %i.%i.%i.%i:%d)\n",
421
+					 ntohs(from.sin_family), cip >> 24, cip << 8 >> 24,
422
+					 cip << 16 >> 24, cip << 24 >> 24,
423
 					 ntohs(from.sin_port));
423
 					 ntohs(from.sin_port));
424
 
424
 
425
-			printf("Server: Datalink layer recieved: packet seq %i\n", 
425
+			printf("Server: Datalink layer recieved: packet seq %i\n",
426
 					 f.seq);
426
 					 f.seq);
427
 		}
427
 		}
428
 
428
 
453
 			to_network_layer(f.data);
453
 			to_network_layer(f.data);
454
 			gClients[i].frameExpected = !gClients[i].frameExpected;
454
 			gClients[i].frameExpected = !gClients[i].frameExpected;
455
 		}
455
 		}
456
-		
456
+
457
 		fflush(stdout);
457
 		fflush(stdout);
458
-		
458
+
459
 #ifdef UNIT_TEST_NETWORK
459
 #ifdef UNIT_TEST_NETWORK
460
 		if ((rand() % 10 == 0))
460
 		if ((rand() % 10 == 0))
461
 		{
461
 		{
463
 			continue;
463
 			continue;
464
 		}
464
 		}
465
 #endif
465
 #endif
466
-		
466
+
467
 		// 4. Send ACK, w/ piggyback if requested
467
 		// 4. Send ACK, w/ piggyback if requested
468
 		if (mPiggyBack)
468
 		if (mPiggyBack)
469
 		{
469
 		{
476
 				printf("SERVER> Sending data by piggyback\n");
476
 				printf("SERVER> Sending data by piggyback\n");
477
 			}
477
 			}
478
 
478
 
479
-			cc = sendto(socket_fd, &gPiggyBack, sizeof(gPiggyBack), 0, 
479
+			cc = sendto(socket_fd, &gPiggyBack, sizeof(gPiggyBack), 0,
480
 							(struct sockaddr *)&from, sizeof(from));
480
 							(struct sockaddr *)&from, sizeof(from));
481
 		}
481
 		}
482
 		else
482
 		else
485
 			f.seq = 0;
485
 			f.seq = 0;
486
 			f.uid = gUID;
486
 			f.uid = gUID;
487
 
487
 
488
-			cc = sendto(socket_fd, &f, sizeof(f), 0, 
488
+			cc = sendto(socket_fd, &f, sizeof(f), 0,
489
 							(struct sockaddr *)&from, sizeof(from));
489
 							(struct sockaddr *)&from, sizeof(from));
490
 		}
490
 		}
491
-		
491
+
492
 		if (cc < 0)
492
 		if (cc < 0)
493
 		{
493
 		{
494
 			perror("Server: send_udp:sendto");
494
 			perror("Server: send_udp:sendto");
519
 	fd_set  readfds;
519
 	fd_set  readfds;
520
 	unsigned int packetsSent = 0;
520
 	unsigned int packetsSent = 0;
521
 	unsigned int seq = 0;
521
 	unsigned int seq = 0;
522
-	char timedOut = 1;  
522
+	char timedOut = 1;
523
 
523
 
524
 	if (!mRemoteHost || !mRemoteHost[0])
524
 	if (!mRemoteHost || !mRemoteHost[0])
525
 	{
525
 	{
526
 		return;
526
 		return;
527
 	}
527
 	}
528
 
528
 
529
-	memset((char*) &timeout, 0, sizeof(timeout)); 
530
-	timeout.tv_sec = 5; 
529
+	memset((char*) &timeout, 0, sizeof(timeout));
530
+	timeout.tv_sec = 5;
531
 
531
 
532
 	socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
532
 	socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
533
 
533
 
536
 		perror("Client: send_udp: socket");
536
 		perror("Client: send_udp: socket");
537
 		exit(0);
537
 		exit(0);
538
 	}
538
 	}
539
-    
539
+
540
 	if ((hostptr = gethostbyname(mRemoteHost)) == NULL)
540
 	if ((hostptr = gethostbyname(mRemoteHost)) == NULL)
541
 	{
541
 	{
542
-		fprintf(stderr, "Client: send_udp: invalid host name, %s\n", 
542
+		fprintf(stderr, "Client: send_udp: invalid host name, %s\n",
543
 				  mRemoteHost);
543
 				  mRemoteHost);
544
 		exit(0);
544
 		exit(0);
545
 	}
545
 	}
560
 #endif
560
 #endif
561
 
561
 
562
 
562
 
563
-	// init	
563
+	// init
564
 	f.data.send = 0;
564
 	f.data.send = 0;
565
 	f.seq = 0;
565
 	f.seq = 0;
566
 
566
 
608
 				printf("Client: Sending packet %i\n", f.seq);
608
 				printf("Client: Sending packet %i\n", f.seq);
609
 			}
609
 			}
610
 
610
 
611
-			cc = sendto(socket_fd, &f, sizeof(f), 0, 
611
+			cc = sendto(socket_fd, &f, sizeof(f), 0,
612
 							(struct sockaddr *)&dest, sizeof(dest));
612
 							(struct sockaddr *)&dest, sizeof(dest));
613
 
613
 
614
 			if (cc < 0)
614
 			if (cc < 0)
631
 
631
 
632
 		// 4. Wait for +ack or resend
632
 		// 4. Wait for +ack or resend
633
 		FD_ZERO(&readfds);
633
 		FD_ZERO(&readfds);
634
- 
634
+
635
 		// Setup socket to listen on here
635
 		// Setup socket to listen on here
636
 		FD_SET(socket_fd, &readfds);
636
 		FD_SET(socket_fd, &readfds);
637
 
637
 
638
 		// Set timeout in milliseconds
638
 		// Set timeout in milliseconds
639
-		timeout.tv_usec = 850; 
639
+		timeout.tv_usec = 850;
640
 
640
 
641
 		cc = select(socket_fd + 1, &readfds, NULL, NULL, &timeout);
641
 		cc = select(socket_fd + 1, &readfds, NULL, NULL, &timeout);
642
 
642
 
643
-		if ((cc < 0) && (errno != EINTR)) 
643
+		if ((cc < 0) && (errno != EINTR))
644
 		{
644
 		{
645
 			// there was an local error with select
645
 			// there was an local error with select
646
 		}
646
 		}
659
 		f.header = 0;
659
 		f.header = 0;
660
 
660
 
661
 		fsize = sizeof(dest);
661
 		fsize = sizeof(dest);
662
-		cc = recvfrom(socket_fd, &f, sizeof(f), 0, 
663
-						  (struct sockaddr *)&dest, &fsize); 
662
+		cc = recvfrom(socket_fd, &f, sizeof(f), 0,
663
+						  (struct sockaddr *)&dest, &fsize);
664
 
664
 
665
 		if (cc < 0)
665
 		if (cc < 0)
666
 		{
666
 		{

+ 2
- 1
src/OpenGLMesh.cpp Просмотреть файл

10
 #else
10
 #else
11
 #include <GL/gl.h>
11
 #include <GL/gl.h>
12
 #endif
12
 #endif
13
-#include "OpenGLMesh.h"
13
+
14
+#include <OpenGLMesh.h>
14
 
15
 
15
 
16
 
16
 ////////////////////////////////////////////////////////////
17
 ////////////////////////////////////////////////////////////

+ 12
- 12
src/OpenRaider.cpp Просмотреть файл

27
 #include <math.h>
27
 #include <math.h>
28
 #include <sys/types.h>
28
 #include <sys/types.h>
29
 
29
 
30
-#ifdef DEBUG_MEMEORY
31
-#include "memeory_test.h"
30
+#ifdef DEBUG_MEMORY
31
+#include <memory_test.h>
32
 #endif
32
 #endif
33
 
33
 
34
-#include "World.h"
35
-#include "SkeletalModel.h"
36
-#include "TombRaider1.h" // tmp stop-gap
37
-#include "OpenRaider.h"
34
+#include <World.h>
35
+#include <SkeletalModel.h>
36
+#include <TombRaider1.h> // tmp stop-gap
37
+#include <OpenRaider.h>
38
 
38
 
39
 enum OpenRaiderText { textConsole = 2, textMenu = 3, textOutput = 4 };
39
 enum OpenRaiderText { textConsole = 2, textMenu = 3, textOutput = 4 };
40
 
40
 
90
 	//delete OpenRaider::Instance();
90
 	//delete OpenRaider::Instance();
91
 #warning "Can't delete OpenRaider::Instance() without a not-allocated-free error. Something is fishy here..."
91
 #warning "Can't delete OpenRaider::Instance() without a not-allocated-free error. Something is fishy here..."
92
 
92
 
93
-#ifdef DEBUG_MEMEORY
94
-	printf("\n[Mongoose MEMEORY_DEBUG]\nMemory leak table:\n");
93
+#ifdef DEBUG_MEMORY
94
+	printf("\n[Mongoose MEMORY_DEBUG]\nMemory leak table:\n");
95
 	dump_memory_report();
95
 	dump_memory_report();
96
 #endif
96
 #endif
97
 
97
 
1127
 	// Cache/process sound fx
1127
 	// Cache/process sound fx
1128
 	processPakSounds();
1128
 	processPakSounds();
1129
 
1129
 
1130
-#ifdef DEBUG_MEMEORY
1130
+#ifdef DEBUG_MEMORY
1131
 	// Right before pak is cleared will be highest use or memory
1131
 	// Right before pak is cleared will be highest use or memory
1132
 	display_memory_usage();
1132
 	display_memory_usage();
1133
 #endif
1133
 #endif
1137
 
1137
 
1138
 	print(true, "Level pak freed from memory, Starting game...");
1138
 	print(true, "Level pak freed from memory, Starting game...");
1139
 
1139
 
1140
-#ifdef DEBUG_MEMEORY
1140
+#ifdef DEBUG_MEMORY
1141
 	display_memory_usage();
1141
 	display_memory_usage();
1142
 #endif
1142
 #endif
1143
 
1143
 
2895
 	}
2895
 	}
2896
 	else if (rc_command("mem", cmd))
2896
 	else if (rc_command("mem", cmd))
2897
 	{
2897
 	{
2898
-#ifdef DEBUG_MEMEORY
2898
+#ifdef DEBUG_MEMORY
2899
 		if (rc_command("usage", cmd))
2899
 		if (rc_command("usage", cmd))
2900
 		{
2900
 		{
2901
 			display_memory_usage();
2901
 			display_memory_usage();
2905
 			dump_memory_report();
2905
 			dump_memory_report();
2906
 		}
2906
 		}
2907
 #else
2907
 #else
2908
-		printf("This build isn't DEBUG_MEMEORY enabled\n");
2908
+		printf("This build isn't DEBUG_MEMORY enabled\n");
2909
 #endif
2909
 #endif
2910
 	}
2910
 	}
2911
 	else if (rc_command("loadlevel", cmd))
2911
 	else if (rc_command("loadlevel", cmd))

+ 4
- 3
src/Particle.cpp Просмотреть файл

7
 
7
 
8
 #include <stdlib.h>
8
 #include <stdlib.h>
9
 #include <stdio.h>
9
 #include <stdio.h>
10
-#include "Particle.h"
11
 
10
 
12
-#ifdef DEBUG_MEMEORY
13
-#   include "memeory_test.h"
11
+#include <Particle.h>
12
+
13
+#ifdef DEBUG_MEMORY
14
+#include <memory_test.h>
14
 #endif
15
 #endif
15
 
16
 
16
 
17
 

+ 4
- 8
src/Render.cpp Просмотреть файл

31
 #include <string.h>
31
 #include <string.h>
32
 
32
 
33
 #ifdef USING_EMITTER
33
 #ifdef USING_EMITTER
34
-#include "Emitter.h"
34
+#include <Emitter.h>
35
 #endif
35
 #endif
36
 
36
 
37
-#ifdef DEBUG_MEMEORY
38
-#include "memeory_test.h"
37
+#ifdef DEBUG_MEMORY
38
+#include <memory_test.h>
39
 #endif
39
 #endif
40
 
40
 
41
-#ifdef DEBUG_GL
42
-#include "gl_test.cpp"
43
-#endif
44
-
45
-#include "Render.h"
41
+#include <Render.h>
46
 
42
 
47
 extern entity_t *LARA;
43
 extern entity_t *LARA;
48
 extern World gWorld;
44
 extern World gWorld;

+ 5
- 9
src/SDLSystem.cpp Просмотреть файл

32
 #include <string.h>
32
 #include <string.h>
33
 #include <cmath>
33
 #include <cmath>
34
 
34
 
35
-#ifdef MEMEORY_TEST
36
-#include "memeory_test.h"
35
+#ifdef MEMORY_TEST
36
+#include <memory_test.h>
37
 #endif
37
 #endif
38
 
38
 
39
 #ifdef USING_OPENGL
39
 #ifdef USING_OPENGL
42
 #error "SDLSystem requires -DUSING_OPENGL"
42
 #error "SDLSystem requires -DUSING_OPENGL"
43
 #endif
43
 #endif
44
 
44
 
45
-#ifdef PS2_LINUX
46
-#include "ps2.h"
47
-#endif
48
-
49
-#include "SDLSystem.h"
45
+#include <SDLSystem.h>
50
 
46
 
51
 
47
 
52
 unsigned int *gWidth = 0x0;
48
 unsigned int *gWidth = 0x0;
581
 	//SDL_QuitSubSystem(SDL_OPENGL);
577
 	//SDL_QuitSubSystem(SDL_OPENGL);
582
 	//SDL_Quit(); // Moved to atexit() call
578
 	//SDL_Quit(); // Moved to atexit() call
583
 
579
 
584
-	//#ifdef DEBUG_MEMEORY
585
-	//printf("[Mongoose MEMEORY_DEBUG]\nUnfreed memory table:\n");
580
+	//#ifdef DEBUG_MEMORY
581
+	//printf("[Mongoose MEMORY_DEBUG]\nUnfreed memory table:\n");
586
 	//dump_memory_report();
582
 	//dump_memory_report();
587
 	//#endif
583
 	//#endif
588
 
584
 

+ 1
- 1
src/SkeletalModel.cpp Просмотреть файл

19
  * Mongoose - Created
19
  * Mongoose - Created
20
  =================================================================*/
20
  =================================================================*/
21
 
21
 
22
-#include "SkeletalModel.h"
22
+#include <SkeletalModel.h>
23
 
23
 
24
 
24
 
25
 ////////////////////////////////////////////////////////////
25
 ////////////////////////////////////////////////////////////

+ 4
- 3
src/Sound.cpp Просмотреть файл

30
 #include <sys/stat.h>
30
 #include <sys/stat.h>
31
 #include <fcntl.h>
31
 #include <fcntl.h>
32
 #include <unistd.h>
32
 #include <unistd.h>
33
-#include "Sound.h"
34
 
33
 
35
-#ifdef DEBUG_MEMEORY
36
-#include "memeory_test.h"
34
+#include <Sound.h>
35
+
36
+#ifdef DEBUG_MEMORY
37
+#include <memory_test.h>
37
 #endif
38
 #endif
38
 
39
 
39
 
40
 

+ 3
- 7
src/System.cpp Просмотреть файл

37
 #include <sys/time.h>
37
 #include <sys/time.h>
38
 #endif
38
 #endif
39
 
39
 
40
-#ifdef MEMEORY_TEST
41
-#include "memeory_test.h"
40
+#ifdef MEMORY_TEST
41
+#include <memory_test.h>
42
 #endif
42
 #endif
43
 
43
 
44
-#ifdef PS2_LINUX
45
-#include "ps2linux.h"
46
-#endif
47
-
48
-#include "System.h"
44
+#include <System.h>
49
 
45
 
50
 ////////////////////////////////////////////////////////////
46
 ////////////////////////////////////////////////////////////
51
 // Constructors
47
 // Constructors

+ 6
- 6
src/Texture.cpp Просмотреть файл

33
 #include <stdio.h>
33
 #include <stdio.h>
34
 #include <stdarg.h>
34
 #include <stdarg.h>
35
 
35
 
36
-#ifdef DEBUG_MEMEORY
37
-#   include "memeory_test.h"
36
+#ifdef DEBUG_MEMORY
37
+#include <memory_test.h>
38
 #endif
38
 #endif
39
 
39
 
40
 #ifdef USING_MTK_TGA
40
 #ifdef USING_MTK_TGA
41
-#   include "mtk_tga.h"
41
+#include <mtk_tga.h>
42
 #endif
42
 #endif
43
 
43
 
44
 #ifdef USING_MTK_PNG
44
 #ifdef USING_MTK_PNG
45
-#   include "mtk_png.h"
45
+#include <mtk_png.h>
46
 #endif
46
 #endif
47
 
47
 
48
 #ifdef HAVE_SDL_TTF
48
 #ifdef HAVE_SDL_TTF
49
-#   include <SDL/SDL_ttf.h>
49
+#include <SDL/SDL_ttf.h>
50
 #endif
50
 #endif
51
 
51
 
52
 #ifdef __APPLE__
52
 #ifdef __APPLE__
57
 #include <GL/glu.h>
57
 #include <GL/glu.h>
58
 #endif
58
 #endif
59
 
59
 
60
-#include "Texture.h"
60
+#include <Texture.h>
61
 
61
 
62
 //Texture *gTextureManager = 0x0;
62
 //Texture *gTextureManager = 0x0;
63
 gl_font_t *gFontTest = 0x0;
63
 gl_font_t *gFontTest = 0x0;

+ 7
- 6
src/TombRaider.cpp Просмотреть файл

49
 #include <math.h>
49
 #include <math.h>
50
 #include <string.h>
50
 #include <string.h>
51
 #include <stdarg.h>
51
 #include <stdarg.h>
52
-#include "TombRaider.h"
52
+
53
+#include <TombRaider.h>
53
 
54
 
54
 #ifdef ZLIB_SUPPORT
55
 #ifdef ZLIB_SUPPORT
55
-#   include "zlib.h"
56
+#include <zlib.h>
56
 #else
57
 #else
57
 #warning "No zlib. Won't support TR4+ files!"
58
 #warning "No zlib. Won't support TR4+ files!"
58
 #endif
59
 #endif
59
 
60
 
60
 #ifdef __TEST_TR5_DUMP_TGA
61
 #ifdef __TEST_TR5_DUMP_TGA
61
-#   include "mtk_tga.h"
62
+#include <mtk_tga.h>
62
 #endif
63
 #endif
63
 
64
 
64
-#ifdef DEBUG_MEMEORY
65
-#   include "memeory_test.h"
65
+#ifdef DEBUG_MEMORY
66
+#include <memory_test.h>
66
 #endif
67
 #endif
67
 
68
 
68
 
69
 
6828
 {
6829
 {
6829
 	test_main(argc, argv);
6830
 	test_main(argc, argv);
6830
 
6831
 
6831
-#ifdef DEBUG_MEMEORY
6832
+#ifdef DEBUG_MEMORY
6832
   dump_memory_report();
6833
   dump_memory_report();
6833
 #endif
6834
 #endif
6834
 
6835
 

+ 4
- 3
src/World.cpp Просмотреть файл

19
  * Mongoose - Created
19
  * Mongoose - Created
20
  =================================================================*/
20
  =================================================================*/
21
 
21
 
22
-#ifdef DEBUG_MEMEORY
23
-#   include "memeory_test.h"
22
+#ifdef DEBUG_MEMORY
23
+#include <memory_test.h>
24
 #endif
24
 #endif
25
 
25
 
26
 #include <math.h>
26
 #include <math.h>
27
-#include "World.h"
27
+
28
+#include <World.h>
28
 
29
 
29
 
30
 
30
 ////////////////////////////////////////////////////////////
31
 ////////////////////////////////////////////////////////////

+ 21
- 21
src/endian.cpp Просмотреть файл

1
 /*==========================================================================
1
 /*==========================================================================
2
- * 
3
- * Project : MDDC 
2
+ *
3
+ * Project : MDDC
4
  * Author  : Terry 'Mongoose' Hendrix II
4
  * Author  : Terry 'Mongoose' Hendrix II
5
  * Website : http://www.westga.edu/~stu7440
5
  * Website : http://www.westga.edu/~stu7440
6
  * Email   : stu7440@westga.edu
6
  * Email   : stu7440@westga.edu
7
- * Object  : 
7
+ * Object  :
8
  * Comments: This is the endian utils.
8
  * Comments: This is the endian utils.
9
  *
9
  *
10
  *           See file COPYING for license details.
10
  *           See file COPYING for license details.
11
  *
11
  *
12
- *           Based on type converting code by: 
13
- *           Michael Vance <mkv102@psu.edu> 
14
- * 
15
- *-- History ---------------------------------------------------------- 
12
+ *           Based on type converting code by:
13
+ *           Michael Vance <mkv102@psu.edu>
14
+ *
15
+ *-- History ----------------------------------------------------------
16
  *
16
  *
17
  * 2000-03-17:
17
  * 2000-03-17:
18
- * Mongoose: Created, I combined some endian checking with fread wrapper 
18
+ * Mongoose: Created, I combined some endian checking with fread wrapper
19
  ==========================================================================*/
19
  ==========================================================================*/
20
 
20
 
21
-#include "endian.h"
21
+#include <endian.h>
22
 
22
 
23
 
23
 
24
 int fread_u_int_small(unsigned int *ptr, FILE *stream)
24
 int fread_u_int_small(unsigned int *ptr, FILE *stream)
25
-{  
25
+{
26
 #ifdef BIG_ENDIAN
26
 #ifdef BIG_ENDIAN
27
    unsigned char b1, b2, b3, b4;
27
    unsigned char b1, b2, b3, b4;
28
    unsigned int l;
28
    unsigned int l;
29
 #endif
29
 #endif
30
- 
30
+
31
    if (fread(ptr, 4, 1, stream) != 1)
31
    if (fread(ptr, 4, 1, stream) != 1)
32
    {
32
    {
33
       printf("FreadSmallInt> Failed fread.\n");
33
       printf("FreadSmallInt> Failed fread.\n");
35
    }
35
    }
36
 
36
 
37
 #ifdef BIG_ENDIAN
37
 #ifdef BIG_ENDIAN
38
-   l = *ptr; 
38
+   l = *ptr;
39
 
39
 
40
    b1 = l & 255;
40
    b1 = l & 255;
41
    b2 = ( l >> 8 ) & 255;
41
    b2 = ( l >> 8 ) & 255;
49
 
49
 
50
 
50
 
51
 int fread_int_small(int *ptr, FILE *stream)
51
 int fread_int_small(int *ptr, FILE *stream)
52
-{  
52
+{
53
 #ifdef BIG_ENDIAN
53
 #ifdef BIG_ENDIAN
54
    unsigned char b1, b2, b3, b4;
54
    unsigned char b1, b2, b3, b4;
55
    int l;
55
    int l;
56
 #endif
56
 #endif
57
- 
57
+
58
    if (fread(ptr, 4, 1, stream) != 1)
58
    if (fread(ptr, 4, 1, stream) != 1)
59
    {
59
    {
60
       printf("FreadSmallInt> Failed fread.\n");
60
       printf("FreadSmallInt> Failed fread.\n");
62
    }
62
    }
63
 
63
 
64
 #ifdef BIG_ENDIAN
64
 #ifdef BIG_ENDIAN
65
-   l = *ptr; 
65
+   l = *ptr;
66
 
66
 
67
    b1 = l & 255;
67
    b1 = l & 255;
68
    b2 = ( l >> 8 ) & 255;
68
    b2 = ( l >> 8 ) & 255;
75
 }
75
 }
76
 
76
 
77
 int fread_float_small(float *ptr, FILE *stream)
77
 int fread_float_small(float *ptr, FILE *stream)
78
-{  
78
+{
79
 #ifdef BIG_ENDIAN
79
 #ifdef BIG_ENDIAN
80
    union
80
    union
81
    {
81
    {
82
       unsigned char b[4];
82
       unsigned char b[4];
83
-      float f; 
83
+      float f;
84
    } in, out;
84
    } in, out;
85
-	
85
+
86
    float l;
86
    float l;
87
 #endif
87
 #endif
88
- 
88
+
89
    if (fread(ptr, 4, 1, stream) != 1)
89
    if (fread(ptr, 4, 1, stream) != 1)
90
    {
90
    {
91
       printf("FreadSmallFloat> Failed fread.\n");
91
       printf("FreadSmallFloat> Failed fread.\n");
93
    }
93
    }
94
 
94
 
95
 #ifdef BIG_ENDIAN
95
 #ifdef BIG_ENDIAN
96
-   l = *ptr; 
96
+   l = *ptr;
97
 
97
 
98
    in.f = l;
98
    in.f = l;
99
    out.b[0] = in.b[3];
99
    out.b[0] = in.b[3];
100
    out.b[1] = in.b[2];
100
    out.b[1] = in.b[2];
101
    out.b[2] = in.b[1];
101
    out.b[2] = in.b[1];
102
    out.b[3] = in.b[0];
102
    out.b[3] = in.b[0];
103
-	
103
+
104
    *ptr = out.f;
104
    *ptr = out.f;
105
 #endif
105
 #endif
106
 
106
 

+ 2
- 1
src/hel/Matrix.cpp Просмотреть файл

21
 
21
 
22
 #include <stdio.h>
22
 #include <stdio.h>
23
 #include <math.h>
23
 #include <math.h>
24
-#include "Matrix.h"
24
+
25
+#include <hel/Matrix.h>
25
 
26
 
26
 
27
 
27
 ////////////////////////////////////////////////////////////
28
 ////////////////////////////////////////////////////////////

+ 2
- 1
src/hel/Quaternion.cpp Просмотреть файл

20
  =================================================================*/
20
  =================================================================*/
21
 
21
 
22
 #include <math.h>
22
 #include <math.h>
23
-#include "Quaternion.h"
23
+
24
+#include <hel/Quaternion.h>
24
 
25
 
25
 
26
 
26
 ////////////////////////////////////////////////////////////
27
 ////////////////////////////////////////////////////////////

+ 2
- 1
src/hel/Vector3d.cpp Просмотреть файл

20
  =================================================================*/
20
  =================================================================*/
21
 
21
 
22
 #include <math.h>
22
 #include <math.h>
23
-#include "Vector3d.h"
23
+
24
+#include <hel/Vector3d.h>
24
 
25
 
25
 
26
 
26
 ////////////////////////////////////////////////////////////
27
 ////////////////////////////////////////////////////////////

+ 39
- 38
src/hel/ViewVolume.cpp Просмотреть файл

1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
 /*================================================================
2
 /*================================================================
3
- * 
3
+ *
4
  * Project : hel
4
  * Project : hel
5
  * Author  : Terry 'Mongoose' Hendrix II
5
  * Author  : Terry 'Mongoose' Hendrix II
6
  * Website : http://www.westga.edu/~stu7440/
6
  * Website : http://www.westga.edu/~stu7440/
12
  *           Thanks Mark Morley for the article I used
12
  *           Thanks Mark Morley for the article I used
13
  *           to get several algorithms.
13
  *           to get several algorithms.
14
  *
14
  *
15
- *           This file was generated using Mongoose's C++ 
15
+ *           This file was generated using Mongoose's C++
16
  *           template generator script.  <stu7440@westga.edu>
16
  *           template generator script.  <stu7440@westga.edu>
17
- * 
18
- *-- History ------------------------------------------------- 
17
+ *
18
+ *-- History -------------------------------------------------
19
  *
19
  *
20
  * 2002.12.15:
20
  * 2002.12.15:
21
  * Mongoose - Created
21
  * Mongoose - Created
22
  =================================================================*/
22
  =================================================================*/
23
 
23
 
24
 #include <math.h>
24
 #include <math.h>
25
-#include "ViewVolume.h"
25
+
26
+#include <hel/ViewVolume.h>
26
 
27
 
27
 
28
 
28
 ////////////////////////////////////////////////////////////
29
 ////////////////////////////////////////////////////////////
72
 
73
 
73
    for (p = 0; p < 6; ++p)
74
    for (p = 0; p < 6; ++p)
74
 	{
75
 	{
75
-      if (mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z + 
76
+      if (mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z +
76
 			 mFrustum[p][3] <= 0)
77
 			 mFrustum[p][3] <= 0)
77
 		{
78
 		{
78
          return false;
79
          return false;
107
 
108
 
108
    for (p = 0; p < 6; ++p)
109
    for (p = 0; p < 6; ++p)
109
    {
110
    {
110
-      if (mFrustum[p][0] * min[0] + 
111
-			 mFrustum[p][1] * min[1] + 
111
+      if (mFrustum[p][0] * min[0] +
112
+			 mFrustum[p][1] * min[1] +
112
 			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
113
 			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
113
          continue;
114
          continue;
114
 
115
 
115
-      if (mFrustum[p][0] * max[0] + 
116
-			 mFrustum[p][1] * max[1] + 
116
+      if (mFrustum[p][0] * max[0] +
117
+			 mFrustum[p][1] * max[1] +
117
 			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
118
 			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
118
          continue;
119
          continue;
119
 
120
 
120
-      if (mFrustum[p][0] * min[0] + 
121
-			 mFrustum[p][1] * max[1] + 
121
+      if (mFrustum[p][0] * min[0] +
122
+			 mFrustum[p][1] * max[1] +
122
 			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
123
 			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
123
          continue;
124
          continue;
124
 
125
 
125
-      if (mFrustum[p][0] * min[0] + 
126
-			 mFrustum[p][1] * min[1] + 
126
+      if (mFrustum[p][0] * min[0] +
127
+			 mFrustum[p][1] * min[1] +
127
 			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
128
 			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
128
          continue;
129
          continue;
129
 
130
 
130
-      if (mFrustum[p][0] * min[0] + 
131
-			 mFrustum[p][1] * max[1] + 
131
+      if (mFrustum[p][0] * min[0] +
132
+			 mFrustum[p][1] * max[1] +
132
 			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
133
 			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
133
          continue;
134
          continue;
134
 
135
 
135
-      if (mFrustum[p][0] * max[0] + 
136
-			 mFrustum[p][1] * min[1] + 
136
+      if (mFrustum[p][0] * max[0] +
137
+			 mFrustum[p][1] * min[1] +
137
 			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
138
 			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
138
          continue;
139
          continue;
139
 
140
 
140
-      if (mFrustum[p][0] * max[0] + 
141
-			 mFrustum[p][1] * max[1] + 
141
+      if (mFrustum[p][0] * max[0] +
142
+			 mFrustum[p][1] * max[1] +
142
 			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
143
 			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
143
          continue;
144
          continue;
144
 
145
 
145
-      if (mFrustum[p][0] * max[0] + 
146
-			 mFrustum[p][1] * min[1] + 
146
+      if (mFrustum[p][0] * max[0] +
147
+			 mFrustum[p][1] * min[1] +
147
 			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
148
 			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
148
          continue;
149
          continue;
149
 
150
 
154
 }
155
 }
155
 
156
 
156
 
157
 
157
-vec_t ViewVolume::getDistToSphereFromNear(vec_t x, vec_t y, vec_t z, 
158
+vec_t ViewVolume::getDistToSphereFromNear(vec_t x, vec_t y, vec_t z,
158
 														vec_t radius)
159
 														vec_t radius)
159
 {
160
 {
160
    unsigned int p;
161
    unsigned int p;
180
 	helMidpoint3v(min, max, center);
181
 	helMidpoint3v(min, max, center);
181
 
182
 
182
 	// 5 should be near plane
183
 	// 5 should be near plane
183
-	d = (mFrustum[5][0] * center[0] + 
184
-		  mFrustum[5][1] * center[1] + 
185
-		  mFrustum[5][2] * center[2] + 
184
+	d = (mFrustum[5][0] * center[0] +
185
+		  mFrustum[5][1] * center[1] +
186
+		  mFrustum[5][2] * center[2] +
186
 		  mFrustum[5][3]);
187
 		  mFrustum[5][3]);
187
 
188
 
188
 	radius = helDist3v(max, center);
189
 	radius = helDist3v(max, center);
295
    mFrustum[0][3] = clip[15] - clip[12];
296
    mFrustum[0][3] = clip[15] - clip[12];
296
 
297
 
297
    /* Normalize the result */
298
    /* Normalize the result */
298
-   t = sqrt(mFrustum[0][0] * mFrustum[0][0] + 
299
-				mFrustum[0][1] * mFrustum[0][1] + 
299
+   t = sqrt(mFrustum[0][0] * mFrustum[0][0] +
300
+				mFrustum[0][1] * mFrustum[0][1] +
300
 				mFrustum[0][2] * mFrustum[0][2]);
301
 				mFrustum[0][2] * mFrustum[0][2]);
301
    mFrustum[0][0] /= t;
302
    mFrustum[0][0] /= t;
302
    mFrustum[0][1] /= t;
303
    mFrustum[0][1] /= t;
310
    mFrustum[1][3] = clip[15] + clip[12];
311
    mFrustum[1][3] = clip[15] + clip[12];
311
 
312
 
312
    /* Normalize the result */
313
    /* Normalize the result */
313
-   t = sqrt(mFrustum[1][0] * mFrustum[1][0] + 
314
-				mFrustum[1][1] * mFrustum[1][1] + 
314
+   t = sqrt(mFrustum[1][0] * mFrustum[1][0] +
315
+				mFrustum[1][1] * mFrustum[1][1] +
315
 				mFrustum[1][2] * mFrustum[1][2]);
316
 				mFrustum[1][2] * mFrustum[1][2]);
316
    mFrustum[1][0] /= t;
317
    mFrustum[1][0] /= t;
317
    mFrustum[1][1] /= t;
318
    mFrustum[1][1] /= t;
325
    mFrustum[2][3] = clip[15] + clip[13];
326
    mFrustum[2][3] = clip[15] + clip[13];
326
 
327
 
327
    /* Normalize the result */
328
    /* Normalize the result */
328
-   t = sqrt(mFrustum[2][0] * mFrustum[2][0] + 
329
-				mFrustum[2][1] * mFrustum[2][1] + 
329
+   t = sqrt(mFrustum[2][0] * mFrustum[2][0] +
330
+				mFrustum[2][1] * mFrustum[2][1] +
330
 				mFrustum[2][2] * mFrustum[2][2]);
331
 				mFrustum[2][2] * mFrustum[2][2]);
331
    mFrustum[2][0] /= t;
332
    mFrustum[2][0] /= t;
332
    mFrustum[2][1] /= t;
333
    mFrustum[2][1] /= t;
340
    mFrustum[3][3] = clip[15] - clip[13];
341
    mFrustum[3][3] = clip[15] - clip[13];
341
 
342
 
342
    /* Normalize the result */
343
    /* Normalize the result */
343
-   t = sqrt(mFrustum[3][0] * mFrustum[3][0] + 
344
-				mFrustum[3][1] * mFrustum[3][1] + 
344
+   t = sqrt(mFrustum[3][0] * mFrustum[3][0] +
345
+				mFrustum[3][1] * mFrustum[3][1] +
345
 				mFrustum[3][2] * mFrustum[3][2]);
346
 				mFrustum[3][2] * mFrustum[3][2]);
346
    mFrustum[3][0] /= t;
347
    mFrustum[3][0] /= t;
347
    mFrustum[3][1] /= t;
348
    mFrustum[3][1] /= t;
355
    mFrustum[4][3] = clip[15] - clip[14];
356
    mFrustum[4][3] = clip[15] - clip[14];
356
 
357
 
357
    /* Normalize the result */
358
    /* Normalize the result */
358
-   t = sqrt(mFrustum[4][0] * mFrustum[4][0] + 
359
-				mFrustum[4][1] * mFrustum[4][1] + 
359
+   t = sqrt(mFrustum[4][0] * mFrustum[4][0] +
360
+				mFrustum[4][1] * mFrustum[4][1] +
360
 				mFrustum[4][2] * mFrustum[4][2]);
361
 				mFrustum[4][2] * mFrustum[4][2]);
361
    mFrustum[4][0] /= t;
362
    mFrustum[4][0] /= t;
362
    mFrustum[4][1] /= t;
363
    mFrustum[4][1] /= t;
370
    mFrustum[5][3] = clip[15] + clip[14];
371
    mFrustum[5][3] = clip[15] + clip[14];
371
 
372
 
372
    /* Normalize the result */
373
    /* Normalize the result */
373
-   t = sqrt(mFrustum[5][0] * mFrustum[5][0] + 
374
-				mFrustum[5][1] * mFrustum[5][1] + 
374
+   t = sqrt(mFrustum[5][0] * mFrustum[5][0] +
375
+				mFrustum[5][1] * mFrustum[5][1] +
375
 				mFrustum[5][2] * mFrustum[5][2]);
376
 				mFrustum[5][2] * mFrustum[5][2]);
376
    mFrustum[5][0] /= t;
377
    mFrustum[5][0] /= t;
377
    mFrustum[5][1] /= t;
378
    mFrustum[5][1] /= t;

src/memeory_test.cpp → src/memory_test.cpp Просмотреть файл

5
  * Author  : Terry 'Mongoose' Hendrix II
5
  * Author  : Terry 'Mongoose' Hendrix II
6
  * Website : http://www.westga.edu/~stu7440/
6
  * Website : http://www.westga.edu/~stu7440/
7
  * Email   : stu7440@westga.edu
7
  * Email   : stu7440@westga.edu
8
- * Object  : memeory_test
8
+ * Object  : memory_test
9
  * License : No use w/o permission (C) 2002 Mongoose
9
  * License : No use w/o permission (C) 2002 Mongoose
10
  * Comments: Memory testing tool kit
10
  * Comments: Memory testing tool kit
11
  *
11
  *
23
 #include <stdio.h>
23
 #include <stdio.h>
24
 #include <stdlib.h>
24
 #include <stdlib.h>
25
 
25
 
26
+#define UNIT_TEST_MEMORY
27
+#include <memory_test.h>
26
 
28
 
27
-#define DWORD unsigned long
28
 #define USE_ITERATIVE_TREE_INSERT
29
 #define USE_ITERATIVE_TREE_INSERT
29
 
30
 
30
 
31
 
31
-typedef enum { RB_BLACK = 0, RB_RED = 1 } rbtree_color_t;
32
-
33
-typedef struct rbtree_s
34
-{
35
-	void *data;
36
-	DWORD key;
37
-
38
-	rbtree_color_t color;
39
-
40
-	struct rbtree_s *left;
41
-	struct rbtree_s *right;
42
-	struct rbtree_s *parent;
43
-
44
-} rbtree_t;
45
-
46
-
47
-
48
 bool tree_check(rbtree_t *tree, char *file, int line)
32
 bool tree_check(rbtree_t *tree, char *file, int line)
49
 {
33
 {
50
 	bool ret = true;
34
 	bool ret = true;
455
 	{
439
 	{
456
 		(*print_func)(tree->data);
440
 		(*print_func)(tree->data);
457
 
441
 
458
-#ifdef DEBUG_MEMEORY_RBTREE
442
+#ifdef DEBUG_MEMORY_RBTREE
459
 		printf(" :%s%s)",
443
 		printf(" :%s%s)",
460
 				 (!tree->parent) ? " (root, " : " ("),
444
 				 (!tree->parent) ? " (root, " : " ("),
461
 				 (tree->color == RB_BLACK) ? "black" : "red");
445
 				 (tree->color == RB_BLACK) ? "black" : "red");
745
 }
729
 }
746
 
730
 
747
 
731
 
748
-#ifdef DEBUG_MEMEORY
749
-
750
-#define ZERO_ALLOC_SLOTS 3
751
-
752
-typedef struct meminfo_filename_s
753
-{
754
-	char *filename;
755
-	char filename_len;
756
-	DWORD size;
757
-	unsigned int alloc_zero;
758
-	unsigned short int alloc_zero_at_line[ZERO_ALLOC_SLOTS];
759
-
760
-	struct meminfo_filename_s *next;
761
-
762
-} meminfo_filename_t;
732
+#ifdef DEBUG_MEMORY
763
 
733
 
764
 
734
 
765
 typedef struct meminfo_s
735
 typedef struct meminfo_s
793
 ///////////////////////////////////////////////////////////////////
763
 ///////////////////////////////////////////////////////////////////
794
 ///////////////////////////////////////////////////////////////////
764
 ///////////////////////////////////////////////////////////////////
795
 
765
 
796
-rbtree_t *MEMEORY_INFO = 0;
797
-meminfo_filename_t *MEMEORY_FILENAME = 0;
798
-long MEMEORY_USED  = 0L;
799
-long MEMEORYA_USED = 0L;
800
-long MEMEORYC_USED = 0L;
801
-long MAX_MEMEORY_USED = 0L;
802
-long MAX_MEMEORYA_USED = 0L;
803
-long MAX_MEMEORYC_USED = 0L;
766
+rbtree_t *MEMORY_INFO = 0;
767
+meminfo_filename_t *MEMORY_FILENAME = 0;
768
+long MEMORY_USED  = 0L;
769
+long MEMORYA_USED = 0L;
770
+long MEMORYC_USED = 0L;
771
+long MAX_MEMORY_USED = 0L;
772
+long MAX_MEMORYA_USED = 0L;
773
+long MAX_MEMORYC_USED = 0L;
804
 
774
 
805
 
775
 
806
 typedef enum
776
 typedef enum
818
 	switch (query)
788
 	switch (query)
819
 	{
789
 	{
820
 	case MEMORY_USED_BY_PROGRAM:
790
 	case MEMORY_USED_BY_PROGRAM:
821
-		return MEMEORY_USED;
791
+		return MEMORY_USED;
822
 		break;
792
 		break;
823
 	case MAX_MEMORY_USED_BY_PROGRAM:
793
 	case MAX_MEMORY_USED_BY_PROGRAM:
824
-		return MAX_MEMEORY_USED;
794
+		return MAX_MEMORY_USED;
825
 		break;
795
 		break;
826
 	case MAX_MEMORY_USED_BY_OVERHEAD:
796
 	case MAX_MEMORY_USED_BY_OVERHEAD:
827
-		return MAX_MEMEORYA_USED + MAX_MEMEORYC_USED;
797
+		return MAX_MEMORYA_USED + MAX_MEMORYC_USED;
828
 		break;
798
 		break;
829
 	case MEMORY_USED_BY_OVERHEAD:
799
 	case MEMORY_USED_BY_OVERHEAD:
830
-		return MEMEORYA_USED + MEMEORYC_USED;
800
+		return MEMORYA_USED + MEMORYC_USED;
831
 		break;
801
 		break;
832
 	case MEMORY_USED_TOTAL:
802
 	case MEMORY_USED_TOTAL:
833
-		return MEMEORY_USED + MEMEORYA_USED + MEMEORYC_USED;
803
+		return MEMORY_USED + MEMORYA_USED + MEMORYC_USED;
834
 		break;
804
 		break;
835
 	default:
805
 	default:
836
 		;
806
 		;
843
 void display_memory_usage()
813
 void display_memory_usage()
844
 {
814
 {
845
 	unsigned int i;
815
 	unsigned int i;
846
-	meminfo_filename_t *cur = MEMEORY_FILENAME;
816
+	meminfo_filename_t *cur = MEMORY_FILENAME;
847
 
817
 
848
 
818
 
849
 	printf("\n============================================================\n");
819
 	printf("\n============================================================\n");
854
 	{
824
 	{
855
 		printf(" %s : ( %lu bytes, %3.2f%% )\n",
825
 		printf(" %s : ( %lu bytes, %3.2f%% )\n",
856
 				 cur->filename, cur->size,
826
 				 cur->filename, cur->size,
857
-				 100.0 * ((float)cur->size / (float)MEMEORY_USED));
827
+				 100.0 * ((float)cur->size / (float)MEMORY_USED));
858
 
828
 
859
 		cur = cur->next;
829
 		cur = cur->next;
860
 	}
830
 	}
861
 
831
 
862
 	printf("------------------------------------------------------------\n");
832
 	printf("------------------------------------------------------------\n");
863
 
833
 
864
-	cur = MEMEORY_FILENAME;
834
+	cur = MEMORY_FILENAME;
865
 
835
 
866
 	printf("Memory special errors per file:\n");
836
 	printf("Memory special errors per file:\n");
867
 
837
 
895
 	printf("Memory usage summary:\n");
865
 	printf("Memory usage summary:\n");
896
 
866
 
897
 	printf(" Tracked program memory    : %lu bytes \t(%.2f MB)\n",
867
 	printf(" Tracked program memory    : %lu bytes \t(%.2f MB)\n",
898
-			 MEMEORY_USED, (double)MEMEORY_USED / 1024000.0);
868
+			 MEMORY_USED, (double)MEMORY_USED / 1024000.0);
899
 	printf(" Untracked overhead memory : %lu bytes \t(%.2f MB)\n",
869
 	printf(" Untracked overhead memory : %lu bytes \t(%.2f MB)\n",
900
-			 MEMEORYA_USED, (double)MEMEORYA_USED / 1024000.0);
870
+			 MEMORYA_USED, (double)MEMORYA_USED / 1024000.0);
901
 	printf(" Untracked m-string memory : %lu bytes\n",
871
 	printf(" Untracked m-string memory : %lu bytes\n",
902
-			 MEMEORYC_USED);
872
+			 MEMORYC_USED);
903
 
873
 
904
 	printf("\n Total accounted memory    : %lu bytes \t(%.2f MB)\n",
874
 	printf("\n Total accounted memory    : %lu bytes \t(%.2f MB)\n",
905
-			 MEMEORY_USED + MEMEORYA_USED + MEMEORYC_USED,
906
-			 (double)(MEMEORY_USED + MEMEORYA_USED + MEMEORYC_USED) / 1024000.0);
875
+			 MEMORY_USED + MEMORYA_USED + MEMORYC_USED,
876
+			 (double)(MEMORY_USED + MEMORYA_USED + MEMORYC_USED) / 1024000.0);
907
 
877
 
908
 	printf("------------------------------------------------------------\n");
878
 	printf("------------------------------------------------------------\n");
909
 
879
 
910
 	printf("Memory max usage summary:\n");
880
 	printf("Memory max usage summary:\n");
911
 
881
 
912
 	printf(" Tracked program memory    : %lu bytes \t(%.2f MB)\n",
882
 	printf(" Tracked program memory    : %lu bytes \t(%.2f MB)\n",
913
-			 MAX_MEMEORY_USED, (double)MAX_MEMEORY_USED / 1024000.0);
883
+			 MAX_MEMORY_USED, (double)MAX_MEMORY_USED / 1024000.0);
914
 	printf(" Untracked overhead memory : %lu bytes \t(%.2f MB)\n",
884
 	printf(" Untracked overhead memory : %lu bytes \t(%.2f MB)\n",
915
-			 MAX_MEMEORYA_USED, (double)MAX_MEMEORYA_USED / 1024000.0);
885
+			 MAX_MEMORYA_USED, (double)MAX_MEMORYA_USED / 1024000.0);
916
 	printf(" Untracked m-string memory : %lu bytes\n",
886
 	printf(" Untracked m-string memory : %lu bytes\n",
917
-			 MAX_MEMEORYC_USED);
887
+			 MAX_MEMORYC_USED);
918
 
888
 
919
 	printf("\n Total accounted memory    : %lu bytes \t(%.2f MB)\n",
889
 	printf("\n Total accounted memory    : %lu bytes \t(%.2f MB)\n",
920
-			 MAX_MEMEORY_USED + MAX_MEMEORYA_USED + MAX_MEMEORYC_USED,
921
-			 (double)(MAX_MEMEORY_USED + MAX_MEMEORYA_USED + MAX_MEMEORYC_USED) / 1024000.0);
890
+			 MAX_MEMORY_USED + MAX_MEMORYA_USED + MAX_MEMORYC_USED,
891
+			 (double)(MAX_MEMORY_USED + MAX_MEMORYA_USED + MAX_MEMORYC_USED) / 1024000.0);
922
 
892
 
923
 	printf("============================================================\n");
893
 	printf("============================================================\n");
924
 }
894
 }
930
 
900
 
931
 
901
 
932
 	printf("\n============================================================\n");
902
 	printf("\n============================================================\n");
933
-	printf(" Memeory status report\n");
903
+	printf(" Memory status report\n");
934
 	printf("============================================================\n");
904
 	printf("============================================================\n");
935
 	printf("Memory tracking table:\n");
905
 	printf("Memory tracking table:\n");
936
-	i = tree_print(MEMEORY_INFO, (void (*)(void *))&__print_meminfo);
906
+	i = tree_print(MEMORY_INFO, (void (*)(void *))&__print_meminfo);
937
 	printf("%i records, %u bytes each : %i bytes\n",
907
 	printf("%i records, %u bytes each : %i bytes\n",
938
 			 i, sizeof(meminfo_t), i * sizeof(meminfo_t));
908
 			 i, sizeof(meminfo_t), i * sizeof(meminfo_t));
939
 	display_memory_usage();
909
 	display_memory_usage();
953
 	unsigned int len, i;
923
 	unsigned int len, i;
954
 
924
 
955
 
925
 
956
-	MEMEORY_USED += size;
926
+	MEMORY_USED += size;
957
 
927
 
958
-	if (MEMEORY_USED > MAX_MEMEORY_USED)
928
+	if (MEMORY_USED > MAX_MEMORY_USED)
959
 	{
929
 	{
960
-		MAX_MEMEORY_USED = MEMEORY_USED;
930
+		MAX_MEMORY_USED = MEMORY_USED;
961
 	}
931
 	}
962
 
932
 
963
-	MEMEORYA_USED += sizeof(meminfo_t);
933
+	MEMORYA_USED += sizeof(meminfo_t);
964
 
934
 
965
-	if (MEMEORYA_USED > MAX_MEMEORYA_USED)
935
+	if (MEMORYA_USED > MAX_MEMORYA_USED)
966
 	{
936
 	{
967
-		MAX_MEMEORYA_USED = MEMEORYA_USED;
937
+		MAX_MEMORYA_USED = MEMORYA_USED;
968
 	}
938
 	}
969
 
939
 
970
 	meminfo = (meminfo_t *)malloc(sizeof(meminfo_t));
940
 	meminfo = (meminfo_t *)malloc(sizeof(meminfo_t));
985
 
955
 
986
 		memfile = memfile_prev = 0;
956
 		memfile = memfile_prev = 0;
987
 
957
 
988
-		if (MEMEORY_FILENAME)
958
+		if (MEMORY_FILENAME)
989
 		{
959
 		{
990
-			memfile = MEMEORY_FILENAME;
960
+			memfile = MEMORY_FILENAME;
991
 
961
 
992
 			while (memfile)
962
 			while (memfile)
993
 			{
963
 			{
1013
 			memfile->alloc_zero_at_line[1] = 0;
983
 			memfile->alloc_zero_at_line[1] = 0;
1014
 			memfile->alloc_zero_at_line[2] = 0;
984
 			memfile->alloc_zero_at_line[2] = 0;
1015
 
985
 
1016
-			MEMEORYC_USED += sizeof(meminfo_filename_t) + memfile->filename_len;
986
+			MEMORYC_USED += sizeof(meminfo_filename_t) + memfile->filename_len;
1017
 
987
 
1018
-			if (MEMEORYC_USED > MAX_MEMEORYC_USED)
1019
-				MAX_MEMEORYC_USED = MEMEORYC_USED;
988
+			if (MEMORYC_USED > MAX_MEMORYC_USED)
989
+				MAX_MEMORYC_USED = MEMORYC_USED;
1020
 
990
 
1021
 			if (memfile_prev)
991
 			if (memfile_prev)
1022
 			{
992
 			{
1023
 				memfile_prev->next = memfile;
993
 				memfile_prev->next = memfile;
1024
 			}
994
 			}
1025
 
995
 
1026
-			if (!MEMEORY_FILENAME)
996
+			if (!MEMORY_FILENAME)
1027
 			{
997
 			{
1028
-				MEMEORY_FILENAME = memfile;
998
+				MEMORY_FILENAME = memfile;
1029
 			}
999
 			}
1030
 		}
1000
 		}
1031
 
1001
 
1054
 		}
1024
 		}
1055
 	}
1025
 	}
1056
 
1026
 
1057
-	MEMEORYA_USED += sizeof(rbtree_t);
1058
-	tree_insert(&MEMEORY_INFO, meminfo, meminfo->address);
1027
+	MEMORYA_USED += sizeof(rbtree_t);
1028
+	tree_insert(&MEMORY_INFO, meminfo, meminfo->address);
1059
 
1029
 
1060
-#ifdef DEBUG_MEMEORY_VERBOSE
1030
+#ifdef DEBUG_MEMORY_VERBOSE
1061
 	printf("add_track> addr 0x%08lx, size %lu, filename %s, line %lu\n",
1031
 	printf("add_track> addr 0x%08lx, size %lu, filename %s, line %lu\n",
1062
 			 addr, size, filename, line_num);
1032
 			 addr, size, filename, line_num);
1063
 #endif
1033
 #endif
1073
 	rbtree_t *tree = 0;
1043
 	rbtree_t *tree = 0;
1074
 
1044
 
1075
 
1045
 
1076
-	tree = tree_find(MEMEORY_INFO, addr);
1046
+	tree = tree_find(MEMORY_INFO, addr);
1077
 
1047
 
1078
 	if (tree)
1048
 	if (tree)
1079
 	{
1049
 	{
1081
 
1051
 
1082
 		if (meminfo)
1052
 		if (meminfo)
1083
 		{
1053
 		{
1084
-			tree_remove(&MEMEORY_INFO, tree);
1054
+			tree_remove(&MEMORY_INFO, tree);
1085
 
1055
 
1086
 			if (meminfo->filename)
1056
 			if (meminfo->filename)
1087
 			{
1057
 			{
1095
 						 meminfo->line);
1065
 						 meminfo->line);
1096
 			}
1066
 			}
1097
 
1067
 
1098
-			MEMEORY_USED -= meminfo->size;
1099
-			MEMEORYA_USED -= sizeof(meminfo_t);
1100
-			MEMEORYA_USED -= sizeof(rbtree_t);
1068
+			MEMORY_USED -= meminfo->size;
1069
+			MEMORYA_USED -= sizeof(meminfo_t);
1070
+			MEMORYA_USED -= sizeof(rbtree_t);
1101
 
1071
 
1102
 			free(meminfo);
1072
 			free(meminfo);
1103
 		}
1073
 		}
1104
 	}
1074
 	}
1105
 	else
1075
 	else
1106
 	{
1076
 	{
1107
-#ifndef DEBUG_MEMEORY_ERROR_OFF
1077
+#ifndef DEBUG_MEMORY_ERROR_OFF
1108
 		printf("\nERROR: remove_track> Unknown addr 0x%08lx ", addr);
1078
 		printf("\nERROR: remove_track> Unknown addr 0x%08lx ", addr);
1109
 		delete_check(0, 0, 1);
1079
 		delete_check(0, 0, 1);
1110
 		printf("?\n");
1080
 		printf("?\n");
1111
 #endif
1081
 #endif
1112
 	}
1082
 	}
1113
 
1083
 
1114
-	if (!MEMEORY_INFO)
1084
+	if (!MEMORY_INFO)
1115
 	{
1085
 	{
1116
 		meminfo_filename_t *cur;
1086
 		meminfo_filename_t *cur;
1117
 		meminfo_filename_t *del;
1087
 		meminfo_filename_t *del;
1118
 
1088
 
1119
 
1089
 
1120
-		cur = MEMEORY_FILENAME;
1121
-		MEMEORY_FILENAME = 0;
1090
+		cur = MEMORY_FILENAME;
1091
+		MEMORY_FILENAME = 0;
1122
 
1092
 
1123
 		while (cur)
1093
 		while (cur)
1124
 		{
1094
 		{
1125
 			del = cur;
1095
 			del = cur;
1126
 			cur = cur->next;
1096
 			cur = cur->next;
1127
 
1097
 
1128
-			MEMEORYC_USED -= sizeof(meminfo_filename_t);
1098
+			MEMORYC_USED -= sizeof(meminfo_filename_t);
1129
 
1099
 
1130
 			if (del->filename)
1100
 			if (del->filename)
1131
 			{
1101
 			{
1132
-				MEMEORYC_USED -= del->filename_len;
1102
+				MEMORYC_USED -= del->filename_len;
1133
 				free(del->filename);
1103
 				free(del->filename);
1134
 			}
1104
 			}
1135
 
1105
 
1137
 		}
1107
 		}
1138
 	}
1108
 	}
1139
 
1109
 
1140
-#ifdef DEBUG_MEMEORY_VERBOSE
1110
+#ifdef DEBUG_MEMORY_VERBOSE
1141
 	printf("remove_track> addr 0x%lx\n", addr);
1111
 	printf("remove_track> addr 0x%lx\n", addr);
1142
 #endif
1112
 #endif
1143
 }
1113
 }
1211
 };
1181
 };
1212
 #endif
1182
 #endif
1213
 
1183
 
1214
-
1215
-
1216
-////////////////////////////////////////////////////////////
1217
-// Unit Test code
1218
-////////////////////////////////////////////////////////////
1219
-
1220
-#ifdef __TEST__
1221
-#include "memeory_test.h"
1222
-
1223
-#define PRINT_TEST_BREAK_LINE	printf("\n############################################################\n\n");
1224
-
1225
-int memeory_test_unit_test(int argc, char *argv[])
1226
-{
1227
-	int *i, *j, *k, *l, *m, *n, *o;
1228
-
1229
-
1230
-	PRINT_TEST_BREAK_LINE
1231
-	printf("Memeory test\n");
1232
-	PRINT_TEST_BREAK_LINE
1233
-
1234
-	printf(">\ti = new int;  %s:%i\n", __FILE__, __LINE__);
1235
-	i = new int;
1236
-	dump_memory_report();
1237
-	tree_valid_report(MEMEORY_INFO);
1238
-
1239
-	printf(">\tdelete i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
1240
-	delete i;
1241
-	dump_memory_report();
1242
-	tree_valid_report(MEMEORY_INFO);
1243
-
1244
-	PRINT_TEST_BREAK_LINE
1245
-
1246
-	printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
1247
-	i = new int[3];
1248
-	dump_memory_report();
1249
-	tree_valid_report(MEMEORY_INFO);
1250
-
1251
-	printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
1252
-	delete [] i;
1253
-	dump_memory_report();
1254
-	tree_valid_report(MEMEORY_INFO);
1255
-
1256
-	PRINT_TEST_BREAK_LINE
1257
-
1258
-	printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
1259
-	i = new int[3];
1260
-	printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
1261
-	j = new int;
1262
-	printf(">\tk = new int[3]; (%p)  %s:%i\n", k, __FILE__, __LINE__);
1263
-	k = new int[3];
1264
-	dump_memory_report();
1265
-	tree_valid_report(MEMEORY_INFO);
1266
-	printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
1267
-	delete [] i;
1268
-	printf(">\tdelete j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
1269
-	delete j;
1270
-	printf(">\tdelete [] k; (%p)  %s:%i\n", k, __FILE__, __LINE__);
1271
-	delete [] k;
1272
-	dump_memory_report();
1273
-	tree_valid_report(MEMEORY_INFO);
1274
-
1275
-	PRINT_TEST_BREAK_LINE
1276
-
1277
-	printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
1278
-	i = new int[3];
1279
-	printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
1280
-	j = new int;
1281
-	printf(">\tk = new int[3]; (%p)  %s:%i\n", k, __FILE__, __LINE__);
1282
-	k = new int[3];
1283
-	dump_memory_report();
1284
-	tree_valid_report(MEMEORY_INFO);
1285
-	printf(">\tdelete j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
1286
-	delete j;
1287
-	dump_memory_report();
1288
-	tree_valid_report(MEMEORY_INFO);
1289
-	printf(">\tj = new int[3]; (%p)  %s:%i\n", j, __FILE__, __LINE__);
1290
-	j = new int[3];
1291
-	dump_memory_report();
1292
-	tree_valid_report(MEMEORY_INFO);
1293
-	printf(">\tl = new int[3]; (%p)  %s:%i\n", l, __FILE__, __LINE__);
1294
-	l = new int[3];
1295
-	dump_memory_report();
1296
-	tree_valid_report(MEMEORY_INFO);
1297
-	printf(">\tm = new int[3]; (%p)  %s:%i\n", m, __FILE__, __LINE__);
1298
-	m = new int[3];
1299
-	dump_memory_report();
1300
-	tree_valid_report(MEMEORY_INFO);
1301
-
1302
-	printf(">\tn = new int[3]; (%p)  %s:%i\n", n, __FILE__, __LINE__);
1303
-	n = new int[3];
1304
-	dump_memory_report();
1305
-	tree_valid_report(MEMEORY_INFO);
1306
-
1307
-	printf(">\to = new int[3]; (%p)  %s:%i\n", o, __FILE__, __LINE__);
1308
-	o = new int[3];
1309
-	dump_memory_report();
1310
-	tree_valid_report(MEMEORY_INFO);
1311
-
1312
-	printf(">\tdelete [] k; (%p)  %s:%i\n", k, __FILE__, __LINE__);
1313
-	delete [] k;
1314
-	dump_memory_report();
1315
-	tree_valid_report(MEMEORY_INFO);
1316
-
1317
-	printf(">\tdelete [] j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
1318
-	delete [] j;
1319
-	dump_memory_report();
1320
-	tree_valid_report(MEMEORY_INFO);
1321
-
1322
-	printf(">\tdelete [] l; (%p)  %s:%i\n", l, __FILE__, __LINE__);
1323
-	delete [] l;
1324
-	dump_memory_report();
1325
-	tree_valid_report(MEMEORY_INFO);
1326
-
1327
-	printf(">\tdelete [] m; (%p)  %s:%i\n", m, __FILE__, __LINE__);
1328
-	delete [] m;
1329
-	dump_memory_report();
1330
-	tree_valid_report(MEMEORY_INFO);
1331
-
1332
-	printf(">\tdelete [] n; (%p)  %s:%i\n", n, __FILE__, __LINE__);
1333
-	delete [] n;
1334
-	dump_memory_report();
1335
-	tree_valid_report(MEMEORY_INFO);
1336
-
1337
-	printf(">\tdelete [] o; (%p)  %s:%i\n", o, __FILE__, __LINE__);
1338
-	delete [] o;
1339
-	dump_memory_report();
1340
-	tree_valid_report(MEMEORY_INFO);
1341
-
1342
-	printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
1343
-	delete [] i;
1344
-	dump_memory_report();
1345
-	tree_valid_report(MEMEORY_INFO);
1346
-
1347
-	PRINT_TEST_BREAK_LINE
1348
-
1349
-	return 0;
1350
-}
1351
-
1352
-
1353
-int main(int argc, char *argv[])
1354
-{
1355
-	printf("[memeory_test test]\n");
1356
-
1357
-	return memeory_test_unit_test(argc, argv);
1358
-}
1359
-#endif

+ 3
- 3
src/mtk_tga.cpp Просмотреть файл

27
 #include <string.h>
27
 #include <string.h>
28
 #include <stdarg.h>
28
 #include <stdarg.h>
29
 
29
 
30
-#include "mtk_tga.h"
30
+#include <mtk_tga.h>
31
 
31
 
32
-#ifdef DEBUG_MEMEORY
33
-#   include "memeory_test.h"
32
+#ifdef DEBUG_MEMORY
33
+#include <memory_test.h>
34
 #endif
34
 #endif
35
 
35
 
36
 
36
 

+ 164
- 0
test/memory_test.cpp Просмотреть файл

1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ *
4
+ * Project : MTK
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : memory_test
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: Memory testing tool kit
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ *
16
+ *-- History -------------------------------------------------
17
+ *
18
+ * 2002.03.27:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#include <string.h>
23
+#include <stdio.h>
24
+#include <stdlib.h>
25
+
26
+#include <memory_test.h>
27
+
28
+#define PRINT_TEST_BREAK_LINE	printf("\n############################################################\n\n");
29
+
30
+int memory_test_unit_test(int argc, char *argv[])
31
+{
32
+	int *i, *j, *k, *l, *m, *n, *o;
33
+
34
+
35
+	PRINT_TEST_BREAK_LINE
36
+	printf("Memory test\n");
37
+	PRINT_TEST_BREAK_LINE
38
+
39
+	printf(">\ti = new int;  %s:%i\n", __FILE__, __LINE__);
40
+	i = new int;
41
+	dump_memory_report();
42
+	tree_valid_report(MEMORY_INFO);
43
+
44
+	printf(">\tdelete i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
45
+	delete i;
46
+	dump_memory_report();
47
+	tree_valid_report(MEMORY_INFO);
48
+
49
+	PRINT_TEST_BREAK_LINE
50
+
51
+	printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
52
+	i = new int[3];
53
+	dump_memory_report();
54
+	tree_valid_report(MEMORY_INFO);
55
+
56
+	printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
57
+	delete [] i;
58
+	dump_memory_report();
59
+	tree_valid_report(MEMORY_INFO);
60
+
61
+	PRINT_TEST_BREAK_LINE
62
+
63
+	printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
64
+	i = new int[3];
65
+	printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
66
+	j = new int;
67
+	printf(">\tk = new int[3]; (%p)  %s:%i\n", k, __FILE__, __LINE__);
68
+	k = new int[3];
69
+	dump_memory_report();
70
+	tree_valid_report(MEMORY_INFO);
71
+	printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
72
+	delete [] i;
73
+	printf(">\tdelete j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
74
+	delete j;
75
+	printf(">\tdelete [] k; (%p)  %s:%i\n", k, __FILE__, __LINE__);
76
+	delete [] k;
77
+	dump_memory_report();
78
+	tree_valid_report(MEMORY_INFO);
79
+
80
+	PRINT_TEST_BREAK_LINE
81
+
82
+	printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
83
+	i = new int[3];
84
+	printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
85
+	j = new int;
86
+	printf(">\tk = new int[3]; (%p)  %s:%i\n", k, __FILE__, __LINE__);
87
+	k = new int[3];
88
+	dump_memory_report();
89
+	tree_valid_report(MEMORY_INFO);
90
+	printf(">\tdelete j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
91
+	delete j;
92
+	dump_memory_report();
93
+	tree_valid_report(MEMORY_INFO);
94
+	printf(">\tj = new int[3]; (%p)  %s:%i\n", j, __FILE__, __LINE__);
95
+	j = new int[3];
96
+	dump_memory_report();
97
+	tree_valid_report(MEMORY_INFO);
98
+	printf(">\tl = new int[3]; (%p)  %s:%i\n", l, __FILE__, __LINE__);
99
+	l = new int[3];
100
+	dump_memory_report();
101
+	tree_valid_report(MEMORY_INFO);
102
+	printf(">\tm = new int[3]; (%p)  %s:%i\n", m, __FILE__, __LINE__);
103
+	m = new int[3];
104
+	dump_memory_report();
105
+	tree_valid_report(MEMORY_INFO);
106
+
107
+	printf(">\tn = new int[3]; (%p)  %s:%i\n", n, __FILE__, __LINE__);
108
+	n = new int[3];
109
+	dump_memory_report();
110
+	tree_valid_report(MEMORY_INFO);
111
+
112
+	printf(">\to = new int[3]; (%p)  %s:%i\n", o, __FILE__, __LINE__);
113
+	o = new int[3];
114
+	dump_memory_report();
115
+	tree_valid_report(MEMORY_INFO);
116
+
117
+	printf(">\tdelete [] k; (%p)  %s:%i\n", k, __FILE__, __LINE__);
118
+	delete [] k;
119
+	dump_memory_report();
120
+	tree_valid_report(MEMORY_INFO);
121
+
122
+	printf(">\tdelete [] j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
123
+	delete [] j;
124
+	dump_memory_report();
125
+	tree_valid_report(MEMORY_INFO);
126
+
127
+	printf(">\tdelete [] l; (%p)  %s:%i\n", l, __FILE__, __LINE__);
128
+	delete [] l;
129
+	dump_memory_report();
130
+	tree_valid_report(MEMORY_INFO);
131
+
132
+	printf(">\tdelete [] m; (%p)  %s:%i\n", m, __FILE__, __LINE__);
133
+	delete [] m;
134
+	dump_memory_report();
135
+	tree_valid_report(MEMORY_INFO);
136
+
137
+	printf(">\tdelete [] n; (%p)  %s:%i\n", n, __FILE__, __LINE__);
138
+	delete [] n;
139
+	dump_memory_report();
140
+	tree_valid_report(MEMORY_INFO);
141
+
142
+	printf(">\tdelete [] o; (%p)  %s:%i\n", o, __FILE__, __LINE__);
143
+	delete [] o;
144
+	dump_memory_report();
145
+	tree_valid_report(MEMORY_INFO);
146
+
147
+	printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
148
+	delete [] i;
149
+	dump_memory_report();
150
+	tree_valid_report(MEMORY_INFO);
151
+
152
+	PRINT_TEST_BREAK_LINE
153
+
154
+	return 0;
155
+}
156
+
157
+
158
+int main(int argc, char *argv[])
159
+{
160
+	printf("[memory_test test]\n");
161
+
162
+	return memory_test_unit_test(argc, argv);
163
+}
164
+

Загрузка…
Отмена
Сохранить