Thomas Buck пре 10 година
родитељ
комит
f83243f887
10 измењених фајлова са 842 додато и 758 уклоњено
  1. 5
    0
      ChangeLog
  2. 9
    7
      Makefile
  3. 47
    58
      include/memory_test.h
  4. 0
    88
      src/Network.cpp
  5. 0
    562
      src/TombRaider.cpp
  6. 3
    3
      src/memory_test.cpp
  7. 13
    14
      test/GLString.cpp
  8. 110
    0
      test/Network.cpp
  9. 618
    0
      test/TombRaider.cpp
  10. 37
    26
      test/memory_test.cpp

+ 5
- 0
ChangeLog Прегледај датотеку

@@ -5,6 +5,11 @@
5 5
 
6 6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
7 7
 
8
+	[ 20140110 ]
9
+	* Moved remaining Unit Tests (Network & TombRaider)
10
+	* memory_test Unit Test no longer produces warnings
11
+	* Building a memory test build no longer produces warnings
12
+
8 13
 	[ 20140109 ]
9 14
 	* Added greatest Test Framework, rewrote Sound Test
10 15
 	* Renamed all memeory references to memory

+ 9
- 7
Makefile Прегледај датотеку

@@ -296,12 +296,14 @@ TombRaider.reg_test:
296 296
 	$(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR4) > /tmp/log.tr4
297 297
 	$(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR5) > /tmp/log.tr5
298 298
 
299
+TR_FLAGS = -D__TEST_TR5_DUMP_TGA -D__TEST_32BIT_TEXTILES -DDEBUG_MEMORY
299 300
 
300 301
 TombRaider.test:
301 302
 	@-mkdir -p $(BUILD_TEST_DIR)
303
+	$(CC) -Wall -Iinclude $(TR_FLAGS) -o $(BUILD_TEST_DIR)/TombRaiderTest.o -c test/TombRaider.cpp
302 304
 	$(MAKE) targets NAME=TombRaider.test BUILDDIR=$(BUILD_TEST_DIR) \
303
-	OBJS="$(BUILD_TEST_DIR)/TombRaider.o $(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/memory_test.o" \
304
-	CFLAGS="$(BASE_CFLAGS) -g -D__TOMBRAIDER_TEST__ -D__TEST_TR5_DUMP_TGA -D__TEST_32BIT_TEXTILES -DDEBUG_MEMORY" \
305
+	OBJS="$(BUILD_TEST_DIR)/TombRaiderTest.o $(BUILD_TEST_DIR)/TombRaider.o $(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/memory_test.o" \
306
+	CFLAGS="$(BASE_CFLAGS) -g $(TR_FLAGS)" \
305 307
 	LD_FLAGS="-lz -lstdc++"
306 308
 
307 309
 #################################################################
@@ -321,7 +323,7 @@ Hel.test: Quaternion.test Matrix.test Math.test
321 323
 Matrix.test:
322 324
 	@-echo "Building Matrix unit test"
323 325
 	mkdir -p $(BUILD_TEST_DIR)
324
-	$(CC) -Wall -g -DMATRIX_UNIT_TEST -lm -lstdc++ -Iinclude \
326
+	$(CC) -Wall -g -lm -lstdc++ -Iinclude \
325 327
 	src/hel/Matrix.cpp src/hel/Quaternion.cpp src/hel/Vector3d.cpp \
326 328
 	test/hel/Matrix.cpp -o $(BUILD_TEST_DIR)/Matrix.test
327 329
 	@-echo "================================================="
@@ -331,7 +333,7 @@ Matrix.test:
331 333
 Quaternion.test:
332 334
 	@-echo "Building Quaternion unit test"
333 335
 	mkdir -p $(BUILD_TEST_DIR)
334
-	$(CC) -Wall -g -DUNIT_TEST_QUATERNION -lm -lstdc++ -Iinclude \
336
+	$(CC) -Wall -g -lm -lstdc++ -Iinclude \
335 337
 	src/hel/Quaternion.cpp test/hel/Quaternion.cpp -o $(BUILD_TEST_DIR)/Quaternion.test
336 338
 	@-echo "================================================="
337 339
 	@-echo "Running Quaternion unit test"
@@ -340,7 +342,7 @@ Quaternion.test:
340 342
 Math.test:
341 343
 	@-echo "Building Math unit test"
342 344
 	mkdir -p $(BUILD_TEST_DIR)
343
-	$(CC) -Wall -g -DMATH_UNIT_TEST -lm -lstdc++ -Iinclude \
345
+	$(CC) -Wall -g -lm -lstdc++ -Iinclude \
344 346
 	src/hel/math.cpp src/hel/Vector3d.cpp test/hel/math.cpp -o $(BUILD_TEST_DIR)/Math.test
345 347
 	@-echo "================================================="
346 348
 	@-echo "Running hel unit test"
@@ -358,8 +360,8 @@ Memory.test:
358 360
 
359 361
 Network.test:
360 362
 	mkdir -p $(BUILD_TEST_DIR)
361
-	$(CC) $(TEST_FLAGS) -DUNIT_TEST_NETWORK \
362
-	src/Network.cpp -o $(BUILD_TEST_DIR)/Network.test
363
+	$(CC) $(TEST_FLAGS) \
364
+	src/Network.cpp test/Network.cpp -o $(BUILD_TEST_DIR)/Network.test
363 365
 
364 366
 #################################################################
365 367
 

+ 47
- 58
include/memory_test.h Прегледај датотеку

@@ -45,67 +45,56 @@ void operator delete [](void *p);
45 45
 #define delete DEBUG_DELETE
46 46
 
47 47
 
48
-	void delete_check(const char *file, int line, int print);
49
-
50
-	void display_memory_usage();
51
-
52
-	long memory_used();
53
-	/*------------------------------------------------------
54
-	 * Pre  :
55
-	 * Post : Returns amount of total memory used
56
-	 *
57
-	 *-- History ------------------------------------------
58
-	 *
59
-	 * 2002.03.27:
60
-	 * Mongoose - Created
61
-	 ------------------------------------------------------*/
62
-
63
-	void dump_memory_report();
64
-	/*------------------------------------------------------
65
-	 * Pre  :
66
-	 * Post : Dumps raw Tree holding memory accounting
67
-	 *
68
-	 *-- History ------------------------------------------
69
-	 *
70
-	 * 2002.03.27:
71
-	 * Mongoose - Created
72
-	 ------------------------------------------------------*/
48
+void delete_check(const char *file, int line, int print);
49
+
50
+void display_memory_usage();
51
+
52
+long memory_used();
53
+/*------------------------------------------------------
54
+ * Pre  :
55
+ * Post : Returns amount of total memory used
56
+ *
57
+ *-- History ------------------------------------------
58
+ *
59
+ * 2002.03.27:
60
+ * Mongoose - Created
61
+ ------------------------------------------------------*/
62
+
63
+void dump_memory_report();
64
+/*------------------------------------------------------
65
+ * Pre  :
66
+ * Post : Dumps raw Tree holding memory accounting
67
+ *
68
+ *-- History ------------------------------------------
69
+ *
70
+ * 2002.03.27:
71
+ * Mongoose - Created
72
+ ------------------------------------------------------*/
73 73
 
74 74
 #ifdef DEBUG_MEMORY
75 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);
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;
109 98
 
110 99
 #endif
111 100
 

+ 0
- 88
src/Network.cpp Прегледај датотеку

@@ -701,91 +701,3 @@ void Network::runClient()
701 701
 // Private Mutators
702 702
 ////////////////////////////////////////////////////////////
703 703
 
704
-
705
-
706
-////////////////////////////////////////////////////////////
707
-// Unit Test code
708
-////////////////////////////////////////////////////////////
709
-
710
-#ifdef UNIT_TEST_NETWORK
711
-void from_network_layer(network_packet_t *p, unsigned int *last_id)
712
-{
713
-	static unsigned int i = 0;
714
-
715
-
716
-	if (!p)
717
-	{
718
-		return;
719
-	}
720
-
721
-	*last_id = i++;
722
-
723
-	sleep(1);
724
-
725
-	p->send = 1;
726
-	p->pos[0] = i*3;
727
-	p->pos[1] = i*3+1;
728
-	p->pos[2] = i*3+2;
729
-
730
-	printf("<S>ending { %f %f %f }\n", p->pos[0], p->pos[1], p->pos[2]);
731
-}
732
-
733
-
734
-void to_network_layer(network_packet_t p)
735
-{
736
-	printf("<R>ecieved { %f %f %f }\n", p.pos[0], p.pos[1], p.pos[2]);
737
-
738
-	gPiggyBack.data.pos[0] = gPiggyBack.seq*4;
739
-	gPiggyBack.data.pos[1] = gPiggyBack.seq*4+1;
740
-	gPiggyBack.data.pos[2] = gPiggyBack.seq*4+2;
741
-	gPiggyBack.data.send = 1;
742
-	gPiggyBack.data.yaw = 90.0f;
743
-}
744
-
745
-
746
-int main(int argc, char *argv[])
747
-{
748
-	printf("\n\n[Network class test]\n");
749
-	Network &test = *Network::Instance();
750
-
751
-
752
-	if (argc > 3)
753
-	{
754
-		if (argv[1][1] == 'v')
755
-		{
756
-			test.setDebug(true);
757
-		}
758
-
759
-		switch (argv[1][0])
760
-		{
761
-		case 'c':
762
-			test.setRemoteHost(argv[2]);
763
-			test.setPort(atoi(argv[3]));
764
-			test.runClient();
765
-			break;
766
-		case 's':
767
-			test.setBindHost(argv[2]);
768
-			test.setPort(atoi(argv[3]));
769
-			test.runServer();
770
-			break;
771
-		default:
772
-			printf("Error in command line, run %s for help\n", argv[0]);
773
-		}
774
-	}
775
-	else if (argc > 2)
776
-	{
777
-		test.setPort(atoi(argv[2]));
778
-		test.runServer();
779
-	}
780
-	else
781
-	{
782
-		printf("Server: %s s [bind_host_name] port\n", argv[0]);
783
-		printf("Client: %s c remote_host_name remote_host_port\n", argv[0]);
784
-		printf("Append 'v' behind c/s option for verbose. eg cv\n");
785
-	}
786
-
787
-	killNetworkSingleton();
788
-
789
-	return 0;
790
-}
791
-#endif

+ 0
- 562
src/TombRaider.cpp Прегледај датотеку

@@ -6274,565 +6274,3 @@ void TombRaider::printDebug(const char *methodName, const char *s, ...)
6274 6274
 // Private Mutators
6275 6275
 ////////////////////////////////////////////////////////////
6276 6276
 
6277
-
6278
-
6279
-////////////////////////////////////////////////////////////
6280
-// Unit Test code
6281
-////////////////////////////////////////////////////////////
6282
-#ifdef __TOMBRAIDER_TEST__
6283
-
6284
-void dump_textures(TombRaider *tr, char *mapname)
6285
-{
6286
-#ifdef __TEST_TR5_DUMP_TGA
6287
-	int i;
6288
-	unsigned char *image;
6289
-	unsigned char *bumpmap;
6290
-	char buffer[128];
6291
-	FILE *f;
6292
-
6293
-
6294
-	if (!tr || !mapname)
6295
-		return;
6296
-
6297
-	// Dump textures
6298
-	printf("\n\t[Texture dumping for '%s']\n", mapname);
6299
-
6300
-	for (i = 0; i < tr->NumTextures(); i++)
6301
-   {
6302
-		tr->Texture(i, &image, &bumpmap);
6303
-
6304
-		if (image)
6305
-		{
6306
-			snprintf(buffer, 128, "%s-%03i-texture.tga", mapname, i);
6307
-
6308
-			f = fopen(buffer, "wb");
6309
-
6310
-			if (f)
6311
-			{
6312
-				if (!mtk_image__tga_save(f, image, 256, 256, 4))
6313
-					printf("\tWrote texture %s\n", buffer);
6314
-
6315
-				fclose(f);
6316
-			}
6317
-
6318
-			snprintf(buffer, 128, "%s.lst", mapname);
6319
-
6320
-			f = fopen(buffer, "a");
6321
-
6322
-			if (f)
6323
-			{
6324
-				fprintf(f, "%s-%03i-texture.tga;\n", mapname, i);
6325
-				fclose(f);
6326
-			}
6327
-
6328
-			delete [] image;
6329
-		}
6330
-
6331
-		if (bumpmap)
6332
-		{
6333
-			snprintf(buffer, 64, "%s-%03i-bumpmap.tga", mapname, i);
6334
-
6335
-			f = fopen(buffer, "wb");
6336
-
6337
-			if (f)
6338
-			{
6339
-				if (!mtk_image__tga_save(f, bumpmap, 256, 256, 4))
6340
-					printf("\tWrote texture %s\n", buffer);
6341
-
6342
-				fclose(f);
6343
-			}
6344
-
6345
-			delete [] bumpmap;
6346
-		}
6347
-	}
6348
-
6349
-	for (i = 0; i < tr->NumSpecialTextures(); i++)
6350
-   {
6351
-		image = tr->SpecialTexTile(i);
6352
-
6353
-		snprintf(buffer, 128, "%s-%03i-special.tga", mapname, i);
6354
-
6355
-		f = fopen(buffer, "wb");
6356
-
6357
-		if (f)
6358
-		{
6359
-			if (!mtk_image__tga_save(f, image, 256, 256, 4))
6360
-				printf("\tWrote texture %s\n", buffer);
6361
-
6362
-			fclose(f);
6363
-		}
6364
-		else
6365
-		{
6366
-			printf("\tFailed to write texture %s\n", buffer);
6367
-		}
6368
-
6369
-		delete [] image;
6370
-	}
6371
-#else
6372
-	printf("Texture dumping not in this build\n");
6373
-#endif
6374
-}
6375
-
6376
-
6377
-void dump_mesh(TombRaider *tr, char *mapname, int index)
6378
-{
6379
-	tr2_object_texture_t *object_texture = NULL;
6380
-	tr2_mesh_t *meshes = NULL;
6381
-	unsigned int v, check;
6382
-   int i, triangles, rectangles, t_index;
6383
-	char buffer[128];
6384
-	float rgba[4];
6385
-	float s, t;
6386
-	char id[8];
6387
-	FILE *f;
6388
-
6389
-
6390
-	if (!mapname || !tr)
6391
-	{
6392
-		return;
6393
-	}
6394
-
6395
-	snprintf(buffer, 128, "%s-%03i.mesh", mapname, index);
6396
-
6397
-	object_texture = tr->ObjectTextures();
6398
-	meshes = tr->Mesh();
6399
-
6400
-
6401
-	f = fopen(buffer, "wb");
6402
-
6403
-	if (!f)
6404
-	{
6405
-		perror("Failed to write mesh :");
6406
-		return;
6407
-	}
6408
-
6409
-	// Setup header id and check points
6410
-	strncpy(id, "TRMESH", 7);
6411
-	id[7] = 0;
6412
-	check = 0xcdcdcdcd;
6413
-
6414
-
6415
-	fwrite(id, 8, 1, f);
6416
-	fwrite(&meshes[index].num_vertices, 2, 1, f);
6417
-	fwrite(&meshes[index].num_textured_triangles, 2, 1, f);
6418
-	fwrite(&meshes[index].num_textured_rectangles, 2, 1, f);
6419
-	fwrite(&meshes[index].num_coloured_triangles, 2, 1, f);
6420
-	fwrite(&meshes[index].num_coloured_rectangles, 2, 1, f);
6421
-	fwrite(&meshes[index].collision_size, 4, 1, f);
6422
-
6423
-
6424
-   // Textured triangles ////////////////////////
6425
-	fwrite(&check, 4, 1, f);
6426
-	triangles = meshes[index].num_textured_triangles;
6427
-
6428
-	for (i = 0; triangles > 0 && i < triangles; i++)
6429
-   {
6430
-		t_index = meshes[index].textured_triangles[i].texture;
6431
-
6432
-		// Store texture info
6433
-		fwrite(&object_texture[t_index].tile, 2, 1, f);
6434
-		fwrite(&object_texture[t_index].transparency_flags, 2, 1, f);
6435
-
6436
-		// Store vertices
6437
-		v = meshes[index].textured_triangles[i].vertices[0];
6438
-		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
6439
-		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
6440
-		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
6441
-
6442
-		v = meshes[index].textured_triangles[i].vertices[1];
6443
-		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
6444
-		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
6445
-		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
6446
-
6447
-		v = meshes[index].textured_triangles[i].vertices[2];
6448
-		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
6449
-		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
6450
-		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
6451
-
6452
-		// Store texels
6453
-		s = tr->adjustTexel(object_texture[t_index].vertices[0].xpixel,
6454
-								  object_texture[t_index].vertices[0].xcoordinate);
6455
-		t = tr->adjustTexel(object_texture[t_index].vertices[0].ypixel,
6456
-								  object_texture[t_index].vertices[0].ycoordinate);
6457
-		fwrite(&s, 4, 1, f);
6458
-		fwrite(&t, 4, 1, f);
6459
-
6460
-
6461
-		s = tr->adjustTexel(object_texture[t_index].vertices[1].xpixel,
6462
-								  object_texture[t_index].vertices[1].xcoordinate);
6463
-		t = tr->adjustTexel(object_texture[t_index].vertices[1].ypixel,
6464
-								  object_texture[t_index].vertices[1].ycoordinate);
6465
-		fwrite(&s, 4, 1, f);
6466
-		fwrite(&t, 4, 1, f);
6467
-
6468
-		s = tr->adjustTexel(object_texture[t_index].vertices[2].xpixel,
6469
-								  object_texture[t_index].vertices[2].xcoordinate);
6470
-		t = tr->adjustTexel(object_texture[t_index].vertices[2].ypixel,
6471
-								  object_texture[t_index].vertices[2].ycoordinate);
6472
-		fwrite(&s, 4, 1, f);
6473
-		fwrite(&t, 4, 1, f);
6474
-	}
6475
-
6476
-	fwrite(&check, 4, 1, f);
6477
-
6478
-
6479
-   // Textured rectangles ////////////////////////
6480
-	fwrite(&check, 4, 1, f);
6481
-	rectangles = meshes[index].num_textured_rectangles;
6482
-
6483
-	for (i = 0; rectangles > 0 && i < rectangles; i++)
6484
-   {
6485
-		t_index = meshes[index].textured_rectangles[i].texture;
6486
-
6487
-		// Store texture info
6488
-		fwrite(&object_texture[t_index].tile, 2, 1, f);
6489
-		fwrite(&object_texture[t_index].transparency_flags, 2, 1, f);
6490
-
6491
-		// Store vertices
6492
-		v = meshes[index].textured_rectangles[i].vertices[0];
6493
-		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
6494
-		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
6495
-		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
6496
-
6497
-		v = meshes[index].textured_rectangles[i].vertices[1];
6498
-		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
6499
-		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
6500
-		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
6501
-
6502
-		v = meshes[index].textured_rectangles[i].vertices[2];
6503
-		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
6504
-		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
6505
-		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
6506
-
6507
-		v = meshes[index].textured_rectangles[i].vertices[3];
6508
-		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
6509
-		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
6510
-		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
6511
-
6512
-		// Store texels
6513
-		s = tr->adjustTexel(object_texture[t_index].vertices[0].xpixel,
6514
-								  object_texture[t_index].vertices[0].xcoordinate);
6515
-		t = tr->adjustTexel(object_texture[t_index].vertices[0].ypixel,
6516
-								  object_texture[t_index].vertices[0].ycoordinate);
6517
-		fwrite(&s, 4, 1, f);
6518
-		fwrite(&t, 4, 1, f);
6519
-
6520
-
6521
-		s = tr->adjustTexel(object_texture[t_index].vertices[1].xpixel,
6522
-								  object_texture[t_index].vertices[1].xcoordinate);
6523
-		t = tr->adjustTexel(object_texture[t_index].vertices[1].ypixel,
6524
-								  object_texture[t_index].vertices[1].ycoordinate);
6525
-		fwrite(&s, 4, 1, f);
6526
-		fwrite(&t, 4, 1, f);
6527
-
6528
-		s = tr->adjustTexel(object_texture[t_index].vertices[2].xpixel,
6529
-								  object_texture[t_index].vertices[2].xcoordinate);
6530
-		t = tr->adjustTexel(object_texture[t_index].vertices[2].ypixel,
6531
-								  object_texture[t_index].vertices[2].ycoordinate);
6532
-		fwrite(&s, 4, 1, f);
6533
-		fwrite(&t, 4, 1, f);
6534
-
6535
-		s = tr->adjustTexel(object_texture[t_index].vertices[3].xpixel,
6536
-								  object_texture[t_index].vertices[3].xcoordinate);
6537
-		t = tr->adjustTexel(object_texture[t_index].vertices[3].ypixel,
6538
-								  object_texture[t_index].vertices[3].ycoordinate);
6539
-		fwrite(&s, 4, 1, f);
6540
-		fwrite(&t, 4, 1, f);
6541
-	}
6542
-
6543
-	fwrite(&check, 4, 1, f);
6544
-
6545
-   // Coloured triangles ////////////////////////
6546
-	fwrite(&check, 4, 1, f);
6547
-	triangles = meshes[index].num_coloured_triangles;
6548
-
6549
-	for (i = 0; triangles > 0 && i < triangles; i++)
6550
-   {
6551
-		// Store vertices
6552
-		v = meshes[index].coloured_triangles[i].vertices[0];
6553
-		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
6554
-		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
6555
-		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
6556
-
6557
-		v = meshes[index].coloured_triangles[i].vertices[1];
6558
-		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
6559
-		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
6560
-		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
6561
-
6562
-		v = meshes[index].coloured_triangles[i].vertices[2];
6563
-		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
6564
-		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
6565
-		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
6566
-
6567
-		// Store color
6568
-		switch (tr->Engine())
6569
-		{
6570
-		case TR_VERSION_1:
6571
-			tr->getColor(meshes[index].coloured_triangles[i].texture
6572
-								 & 0xff, rgba);
6573
-			break;
6574
-		default:
6575
-			tr->getColor((meshes[index].coloured_triangles[i].texture>>8)
6576
-								 & 0xff, rgba);
6577
-		}
6578
-
6579
-		s = rgba[0];
6580
-		t = rgba[1];
6581
-		fwrite(&s, 4, 1, f);
6582
-		fwrite(&t, 4, 1, f);
6583
-
6584
-		s = rgba[2];
6585
-		t = rgba[3];
6586
-		fwrite(&s, 4, 1, f);
6587
-		fwrite(&t, 4, 1, f);
6588
-	}
6589
-
6590
-	fwrite(&check, 4, 1, f);
6591
-
6592
-   // Coloured rectangles ////////////////////////
6593
-	fwrite(&check, 4, 1, f);
6594
-	rectangles = meshes[index].num_coloured_rectangles;
6595
-
6596
-	for (i = 0; rectangles > 0 && i < rectangles; i++)
6597
-   {
6598
-		// Store vertices
6599
-		v = meshes[index].coloured_rectangles[i].vertices[0];
6600
-		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
6601
-		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
6602
-		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
6603
-
6604
-		v = meshes[index].coloured_rectangles[i].vertices[1];
6605
-		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
6606
-		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
6607
-		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
6608
-
6609
-		v = meshes[index].coloured_rectangles[i].vertices[2];
6610
-		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
6611
-		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
6612
-		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
6613
-
6614
-		v = meshes[index].coloured_rectangles[i].vertices[3];
6615
-		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
6616
-		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
6617
-		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
6618
-
6619
-		// Store color
6620
-		switch (tr->Engine())
6621
-		{
6622
-		case TR_VERSION_1:
6623
-			tr->getColor(meshes[index].coloured_rectangles[i].texture
6624
-								 & 0xff, rgba);
6625
-			break;
6626
-		default:
6627
-			tr->getColor((meshes[index].coloured_rectangles[i].texture>>8)
6628
-								 & 0xff, rgba);
6629
-		}
6630
-
6631
-		s = rgba[0];
6632
-		t = rgba[1];
6633
-		fwrite(&s, 4, 1, f);
6634
-		fwrite(&t, 4, 1, f);
6635
-
6636
-		s = rgba[2];
6637
-		t = rgba[3];
6638
-		fwrite(&s, 4, 1, f);
6639
-		fwrite(&t, 4, 1, f);
6640
-	}
6641
-
6642
-	fwrite(&check, 4, 1, f);
6643
-	fclose(f);
6644
-
6645
-	printf(".");
6646
-	fflush(stdout);
6647
-}
6648
-
6649
-
6650
-void dump_lara_stuff(char *mapname, TombRaider &tr)
6651
-{
6652
-	unsigned int i, j, k, n;
6653
-	tr2_moveable_t *moveable = tr.Moveable();
6654
-	unsigned int numMoveables = tr.NumMoveables();
6655
-	char filename[64];
6656
-	unsigned char *riff;
6657
-	unsigned int riffSz, total = 0;
6658
-	FILE *f;
6659
-
6660
-
6661
-	snprintf(filename, 63, "%s-lara.nfo", mapname);
6662
-	f = fopen(filename, "w");
6663
-
6664
-	if (!f)
6665
-	{
6666
-		perror("Failed to write lara.nfo: ");
6667
-		return;
6668
-	}
6669
-
6670
-	for (i = 0; i < numMoveables; ++i)
6671
-	{
6672
-		j = n = 0;
6673
-
6674
-		if (moveable[i].object_id == 0)
6675
-		{
6676
-			j = moveable[i].starting_mesh;
6677
-			n = moveable[i].num_meshes + j;
6678
-
6679
-			fprintf(f, "Lara (%i)\n", i);
6680
-		}
6681
-		else if (moveable[i].object_id == 30)
6682
-		{
6683
-			j = moveable[i].starting_mesh;
6684
-			n = moveable[i].num_meshes + j;
6685
-
6686
-			fprintf(f, "Lara ponytail\n");
6687
-		}
6688
-		else if (tr.Engine() == TR_VERSION_4)
6689
-		{
6690
-			switch (moveable[i].object_id)
6691
-			{
6692
-			case 8: // Joints, ( interconnecting skin/ploys )
6693
-			case 9:
6694
-				fprintf(f, "TR4 lara joints (%i)\n", i);
6695
-				j = moveable[i].starting_mesh;
6696
-				n = moveable[i].num_meshes + j;
6697
-			}
6698
-		}
6699
-
6700
-		for (k = j; j < n; ++j)
6701
-		{
6702
-			fprintf(f, "\tMesh[%i] = %i\n", (j - k), j);
6703
-		}
6704
-	}
6705
-
6706
-	fclose(f);
6707
-
6708
-	printf("\nDumping %i audio samples: ", tr.getSoundSamplesCount());
6709
-
6710
-	for (i = 0, j = 0; i < tr.getSoundSamplesCount(); ++i)
6711
-	{
6712
-		tr.getSoundSample(i, &riffSz, &riff);
6713
-
6714
-		total += riffSz;
6715
-
6716
-		snprintf(filename, 63, "%s-%03i.wav", mapname, j++);
6717
-		f = fopen(filename, "wb");
6718
-
6719
-		if (!f)
6720
-		{
6721
-			perror("Failed to write riff.wav: ");
6722
-			continue;
6723
-		}
6724
-
6725
-		fwrite(riff, 1, riffSz, f);
6726
-		fclose(f);
6727
-
6728
-		delete [] riff;
6729
-
6730
-		printf(".");
6731
-		fflush(stdout);
6732
-	}
6733
-
6734
-	printf("\n");
6735
-
6736
-	if (total)
6737
-	{
6738
-		printf("Dumped %ibytes (%.2f MB) of audio samples\n",
6739
-				 total, (float)total/1024000.0);
6740
-	}
6741
-}
6742
-
6743
-
6744
-void percent_callback(int p)
6745
-{
6746
-	printf("Level %i%% loaded\n", p);
6747
-}
6748
-
6749
-
6750
-int test_main(int argc, char *argv[])
6751
-{
6752
-  TombRaider tr;
6753
-  char mapname[128];
6754
-  int len, i, j;
6755
-
6756
-
6757
-  printf("[TombRaider class test]\n");
6758
-
6759
-  tr.setDebug(true);
6760
-
6761
-  if (argc > 2)
6762
-  {
6763
-	  // Strip for mapname //////////////////////////////
6764
-	  len = strlen(argv[2]);
6765
-
6766
-	  for (i = len, j = 0; i > 0; i--, j++)
6767
-		  if (argv[2][i] == '/' || argv[2][i] == '\\')
6768
-			  break;
6769
-
6770
-	  j--;
6771
-
6772
-	  memset(mapname, 0, 128);
6773
-
6774
-	  for (i = 0; i < len - j && i < 30; i++)
6775
-		  mapname[i] = argv[2][i + len - j];
6776
-
6777
-	  ////////////////////////////////////////////////////
6778
-
6779
-
6780
-    if (strncmp(argv[1], "load", 4) == 0)
6781
-    {
6782
-      if (!tr.Load(argv[2], percent_callback))
6783
-		{
6784
-        printf("\nmain: Load reports success.\n");
6785
-		}
6786
-    }
6787
-    else if (strncmp(argv[1], "dump", 4) == 0)
6788
-    {
6789
-      if (!tr.Load(argv[2], percent_callback))
6790
-		{
6791
-        printf("\nmain: Load reports success.\n");
6792
-
6793
-		  dump_textures(&tr, mapname);
6794
-
6795
-		  printf("Mesh dumping: ");
6796
-		  for (i = 0; i < tr.getMeshCount(); i++)
6797
-		  {
6798
-			  dump_mesh(&tr, mapname, i);
6799
-		  }
6800
-
6801
-		  if (argc > 3)
6802
-		  {
6803
-			  printf("\nLoading external sound SFX.\n");
6804
-			  tr.loadSFX(argv[3]);
6805
-		  }
6806
-
6807
-		  dump_lara_stuff(mapname, tr);
6808
-
6809
-		  printf("\n");
6810
-		}
6811
-		else
6812
-		{
6813
-			printf("\nmain: Load failed.\n");
6814
-		}
6815
-    }
6816
-    else
6817
-      printf("\n\n%s [ load | dump ] filename [sound.sfx]\n", argv[0]);
6818
-  }
6819
-  else
6820
-  {
6821
-    printf("\n\n%s [ load | dump ] filename [sound.sfx]\n", argv[0]);
6822
-  }
6823
-
6824
-  return 0;
6825
-}
6826
-
6827
-
6828
-int main(int argc, char *argv[])
6829
-{
6830
-	test_main(argc, argv);
6831
-
6832
-#ifdef DEBUG_MEMORY
6833
-  dump_memory_report();
6834
-#endif
6835
-
6836
-  return 0;
6837
-}
6838
-#endif

+ 3
- 3
src/memory_test.cpp Прегледај датотеку

@@ -29,7 +29,7 @@
29 29
 #define USE_ITERATIVE_TREE_INSERT
30 30
 
31 31
 
32
-bool tree_check(rbtree_t *tree, char *file, int line)
32
+bool tree_check(rbtree_t *tree, const char *file, int line)
33 33
 {
34 34
 	bool ret = true;
35 35
 
@@ -456,7 +456,7 @@ int tree_print(rbtree_t *tree, void (*print_func)(void *))
456 456
 
457 457
 	if (!tree->parent)
458 458
 	{
459
-		printf("\n%i nodes, %u bytes each : %i bytes\n",
459
+		printf("\n%i nodes, %lu bytes each : %lu bytes\n",
460 460
 				 i, sizeof(rbtree_t), i * sizeof(rbtree_t));
461 461
 	}
462 462
 
@@ -904,7 +904,7 @@ void dump_memory_report()
904 904
 	printf("============================================================\n");
905 905
 	printf("Memory tracking table:\n");
906 906
 	i = tree_print(MEMORY_INFO, (void (*)(void *))&__print_meminfo);
907
-	printf("%i records, %u bytes each : %i bytes\n",
907
+	printf("%i records, %lu bytes each : %lu bytes\n",
908 908
 			 i, sizeof(meminfo_t), i * sizeof(meminfo_t));
909 909
 	display_memory_usage();
910 910
 	printf("============================================================\n\n");

+ 13
- 14
test/GLString.cpp Прегледај датотеку

@@ -128,20 +128,19 @@ void init_gl(unsigned int width, unsigned int height,
128 128
 		{
129 129
 			if (j < 4)
130 130
 			{
131
-				id[j++] = gTexture.loadTGA(argv[i]);
131
+				id[j] = gTexture.loadTGA(argv[i]);
132 132
 			}
133 133
 		}
134 134
 	}
135 135
 	else
136 136
 	{
137
-		id[0] = gTexture.loadTGA("data/font-0.tga");
138
-		id[1] = gTexture.loadTGA("data/font-0.tga");
139
-		id[2] = gTexture.loadTGA("data/font-0.tga");
140
-		id[3] = gTexture.loadTGA("data/font-0.tga");
137
+		// id[0] = gTexture.loadTGA("data/font-0.tga");
138
+		// id[1] = gTexture.loadTGA("data/font-1.tga");
139
+		// id[2] = gTexture.loadTGA("data/font-2.tga");
140
+		// id[3] = gTexture.loadTGA("data/font-3.tga");
141
+        id[0] = id[1] = id[2] = id[3] = gTexture.loadTGA("data/font-0.tga");
141 142
 	}
142 143
 
143
-	printf("%i %i %i %i\n", id[0], id[1], id[2], id[3]);
144
-
145 144
 	TEXT->Init(4, 4, id);
146 145
 	i = TEXT->glPrintf((width/2)-12*5, height/2, 0,
147 146
 							 "[font %i] GLString Test", id[0]);
@@ -150,9 +149,8 @@ void init_gl(unsigned int width, unsigned int height,
150 149
 		printf("TEXT->glPrintf> ERROR code %i ( 0 means no error )\n", i);
151 150
 	}
152 151
 
153
-	i = TEXT->glPrintf((width/2)-10*7, height/2+32, 1,
152
+	i = TEXT->glPrintf((width/2)-12*5, height/2+32, 1,
154 153
 							 "[font %i] GLString Test", id[1]);
155
-
156 154
 	if (i)
157 155
 	{
158 156
 		printf("TEXT->glPrintf> ERROR code %i ( 0 means no error )\n", i);
@@ -162,15 +160,14 @@ void init_gl(unsigned int width, unsigned int height,
162 160
 	TEXT->Scale(s);
163 161
 
164 162
 	i = TEXT->glPrintf((width/2)-10*7, height/2+64, 1,
165
-							 "[font %i] Scaled by %.3f", id[1], s);
166
-
163
+							 "[font %i] Scaled by %.1f", id[2], s);
167 164
 	if (i)
168 165
 	{
169 166
 		printf("TEXT->glPrintf> ERROR code %i ( 0 means no error )\n", i);
170 167
 	}
171
-	i = TEXT->glPrintf((width/2)-10*7, height/2-32, 0,
172
-							 "[font %i] Scaled by %.3f", id[0], s);
173 168
 
169
+	i = TEXT->glPrintf((width/2)-10*7, height/2-32, 0,
170
+							 "[font %i] Scaled by %.1f", id[3], s);
174 171
 	if (i)
175 172
 	{
176 173
 		printf("TEXT->glPrintf> ERROR code %i ( 0 means no error )\n", i);
@@ -184,9 +181,11 @@ int main_gl(int argc, char *argv[])
184 181
   unsigned int mkeys, mod, key;
185 182
   int flags;
186 183
   unsigned int width = 640;
187
-  unsigned int height = 460;
184
+  unsigned int height = 480;
188 185
   bool fullscreen = false;
186
+#ifndef __APPLE__
189 187
   char *driver = NULL;
188
+#endif
190 189
 
191 190
 
192 191
   // Setup clean up on exit

+ 110
- 0
test/Network.cpp Прегледај датотеку

@@ -0,0 +1,110 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ *
4
+ * Project : UnRaider
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Network
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments:
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ *
16
+ *-- History -------------------------------------------------
17
+ *
18
+ * 2002.06.21:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#include <Network.h>
23
+
24
+#include <stdlib.h>
25
+#include <stdio.h>
26
+#include <unistd.h>
27
+
28
+extern network_frame_t gPiggyBack;
29
+
30
+void from_network_layer(network_packet_t *p, unsigned int *last_id)
31
+{
32
+	static unsigned int i = 0;
33
+
34
+
35
+	if (!p)
36
+	{
37
+		return;
38
+	}
39
+
40
+	*last_id = i++;
41
+
42
+	sleep(1);
43
+
44
+	p->send = 1;
45
+	p->pos[0] = i*3;
46
+	p->pos[1] = i*3+1;
47
+	p->pos[2] = i*3+2;
48
+
49
+	printf("<S>ending { %f %f %f }\n", p->pos[0], p->pos[1], p->pos[2]);
50
+}
51
+
52
+
53
+void to_network_layer(network_packet_t p)
54
+{
55
+	printf("<R>ecieved { %f %f %f }\n", p.pos[0], p.pos[1], p.pos[2]);
56
+
57
+	gPiggyBack.data.pos[0] = gPiggyBack.seq*4;
58
+	gPiggyBack.data.pos[1] = gPiggyBack.seq*4+1;
59
+	gPiggyBack.data.pos[2] = gPiggyBack.seq*4+2;
60
+	gPiggyBack.data.send = 1;
61
+	gPiggyBack.data.yaw = 90.0f;
62
+}
63
+
64
+
65
+int main(int argc, char *argv[])
66
+{
67
+	printf("\n\n[Network class test]\n");
68
+	Network &test = *Network::Instance();
69
+
70
+
71
+	if (argc > 3)
72
+	{
73
+		if (argv[1][1] == 'v')
74
+		{
75
+			test.setDebug(true);
76
+		}
77
+
78
+		switch (argv[1][0])
79
+		{
80
+		case 'c':
81
+			test.setRemoteHost(argv[2]);
82
+			test.setPort(atoi(argv[3]));
83
+			test.runClient();
84
+			break;
85
+		case 's':
86
+			test.setBindHost(argv[2]);
87
+			test.setPort(atoi(argv[3]));
88
+			test.runServer();
89
+			break;
90
+		default:
91
+			printf("Error in command line, run %s for help\n", argv[0]);
92
+		}
93
+	}
94
+	else if (argc > 2)
95
+	{
96
+		test.setPort(atoi(argv[2]));
97
+		test.runServer();
98
+	}
99
+	else
100
+	{
101
+		printf("Server: %s s [bind_host_name] port\n", argv[0]);
102
+		printf("Client: %s c remote_host_name remote_host_port\n", argv[0]);
103
+		printf("Append 'v' behind c/s option for verbose. eg cv\n");
104
+	}
105
+
106
+	killNetworkSingleton();
107
+
108
+	return 0;
109
+}
110
+

+ 618
- 0
test/TombRaider.cpp Прегледај датотеку

@@ -0,0 +1,618 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ *
4
+ * Project : OpenRaider
5
+ * Author  : Mongoose
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : OpenRaider
9
+ * License : No use w/o permission (C) 2001 Mongoose
10
+ * Comments: Loads TR 1, 2, 3, and 4 maps, meshes, and textures
11
+ *
12
+ *           This file was generated using Mongoose's C++
13
+ *           template generator script.  <stu7440@westga.edu>
14
+ *
15
+ *-- History ------------------------------------------------
16
+ *
17
+ * 2003.05.13:
18
+ * Mongoose - New API, maintance cost was becoming so high
19
+ *            it was needed to sort out methods in groups
20
+ *            like my newer source code -- of course some
21
+ *            methods were altered or removed ( clean up )
22
+ *
23
+ * 2001.06.19:
24
+ * Mongoose - New texture API for the new TR4/TR5 bump map
25
+ *            support, also purged textile exposure
26
+ *
27
+ * 2001.05.21:
28
+ * Mongoose - Added to project OpenRaider, more documentation
29
+ *            than Freyja version I wrote ( 3d modeler )
30
+ *
31
+ *
32
+ * 2000-05-13:
33
+ * Mongoose - Added gcc and VC++ pragmas for packing
34
+ *
35
+ *            id style typedefs for structs
36
+ *
37
+ *            Heavy clean up and ported to C++
38
+ *
39
+ *            I saved yuri's notes as best I could and
40
+ *            reformatted and corected as needed
41
+ *
42
+ * Mongoose - Created, based on:
43
+ *                tr_view's tr2io.c by Yuri Zhivago, PhD,
44
+ *                TR Rosetta Stone ( TombRaider pak format specs )
45
+ ================================================================*/
46
+
47
+#include <stdlib.h>
48
+#include <stdio.h>
49
+#include <math.h>
50
+#include <string.h>
51
+#include <stdarg.h>
52
+
53
+#include <TombRaider.h>
54
+
55
+#ifdef __TEST_TR5_DUMP_TGA
56
+#include <mtk_tga.h>
57
+#endif
58
+
59
+#ifdef DEBUG_MEMORY
60
+#include <memory_test.h>
61
+#endif
62
+
63
+
64
+void dump_textures(TombRaider *tr, char *mapname)
65
+{
66
+#ifdef __TEST_TR5_DUMP_TGA
67
+	int i;
68
+	unsigned char *image;
69
+	unsigned char *bumpmap;
70
+	char buffer[128];
71
+	FILE *f;
72
+
73
+
74
+	if (!tr || !mapname)
75
+		return;
76
+
77
+	// Dump textures
78
+	printf("\n\t[Texture dumping for '%s']\n", mapname);
79
+
80
+	for (i = 0; i < tr->NumTextures(); i++)
81
+   {
82
+		tr->Texture(i, &image, &bumpmap);
83
+
84
+		if (image)
85
+		{
86
+			snprintf(buffer, 128, "%s-%03i-texture.tga", mapname, i);
87
+
88
+			f = fopen(buffer, "wb");
89
+
90
+			if (f)
91
+			{
92
+				if (!mtk_image__tga_save(f, image, 256, 256, 4))
93
+					printf("\tWrote texture %s\n", buffer);
94
+
95
+				fclose(f);
96
+			}
97
+
98
+			snprintf(buffer, 128, "%s.lst", mapname);
99
+
100
+			f = fopen(buffer, "a");
101
+
102
+			if (f)
103
+			{
104
+				fprintf(f, "%s-%03i-texture.tga;\n", mapname, i);
105
+				fclose(f);
106
+			}
107
+
108
+			delete [] image;
109
+		}
110
+
111
+		if (bumpmap)
112
+		{
113
+			snprintf(buffer, 64, "%s-%03i-bumpmap.tga", mapname, i);
114
+
115
+			f = fopen(buffer, "wb");
116
+
117
+			if (f)
118
+			{
119
+				if (!mtk_image__tga_save(f, bumpmap, 256, 256, 4))
120
+					printf("\tWrote texture %s\n", buffer);
121
+
122
+				fclose(f);
123
+			}
124
+
125
+			delete [] bumpmap;
126
+		}
127
+	}
128
+
129
+	for (i = 0; i < tr->NumSpecialTextures(); i++)
130
+   {
131
+		image = tr->SpecialTexTile(i);
132
+
133
+		snprintf(buffer, 128, "%s-%03i-special.tga", mapname, i);
134
+
135
+		f = fopen(buffer, "wb");
136
+
137
+		if (f)
138
+		{
139
+			if (!mtk_image__tga_save(f, image, 256, 256, 4))
140
+				printf("\tWrote texture %s\n", buffer);
141
+
142
+			fclose(f);
143
+		}
144
+		else
145
+		{
146
+			printf("\tFailed to write texture %s\n", buffer);
147
+		}
148
+
149
+		delete [] image;
150
+	}
151
+#else
152
+	printf("Texture dumping not in this build\n");
153
+#endif
154
+}
155
+
156
+
157
+void dump_mesh(TombRaider *tr, char *mapname, int index)
158
+{
159
+	tr2_object_texture_t *object_texture = NULL;
160
+	tr2_mesh_t *meshes = NULL;
161
+	unsigned int v, check;
162
+   int i, triangles, rectangles, t_index;
163
+	char buffer[128];
164
+	float rgba[4];
165
+	float s, t;
166
+	char id[8];
167
+	FILE *f;
168
+
169
+
170
+	if (!mapname || !tr)
171
+	{
172
+		return;
173
+	}
174
+
175
+	snprintf(buffer, 128, "%s-%03i.mesh", mapname, index);
176
+
177
+	object_texture = tr->ObjectTextures();
178
+	meshes = tr->Mesh();
179
+
180
+
181
+	f = fopen(buffer, "wb");
182
+
183
+	if (!f)
184
+	{
185
+		perror("Failed to write mesh :");
186
+		return;
187
+	}
188
+
189
+	// Setup header id and check points
190
+	strncpy(id, "TRMESH", 7);
191
+	id[7] = 0;
192
+	check = 0xcdcdcdcd;
193
+
194
+
195
+	fwrite(id, 8, 1, f);
196
+	fwrite(&meshes[index].num_vertices, 2, 1, f);
197
+	fwrite(&meshes[index].num_textured_triangles, 2, 1, f);
198
+	fwrite(&meshes[index].num_textured_rectangles, 2, 1, f);
199
+	fwrite(&meshes[index].num_coloured_triangles, 2, 1, f);
200
+	fwrite(&meshes[index].num_coloured_rectangles, 2, 1, f);
201
+	fwrite(&meshes[index].collision_size, 4, 1, f);
202
+
203
+
204
+   // Textured triangles ////////////////////////
205
+	fwrite(&check, 4, 1, f);
206
+	triangles = meshes[index].num_textured_triangles;
207
+
208
+	for (i = 0; triangles > 0 && i < triangles; i++)
209
+   {
210
+		t_index = meshes[index].textured_triangles[i].texture;
211
+
212
+		// Store texture info
213
+		fwrite(&object_texture[t_index].tile, 2, 1, f);
214
+		fwrite(&object_texture[t_index].transparency_flags, 2, 1, f);
215
+
216
+		// Store vertices
217
+		v = meshes[index].textured_triangles[i].vertices[0];
218
+		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
219
+		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
220
+		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
221
+
222
+		v = meshes[index].textured_triangles[i].vertices[1];
223
+		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
224
+		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
225
+		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
226
+
227
+		v = meshes[index].textured_triangles[i].vertices[2];
228
+		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
229
+		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
230
+		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
231
+
232
+		// Store texels
233
+		s = tr->adjustTexel(object_texture[t_index].vertices[0].xpixel,
234
+								  object_texture[t_index].vertices[0].xcoordinate);
235
+		t = tr->adjustTexel(object_texture[t_index].vertices[0].ypixel,
236
+								  object_texture[t_index].vertices[0].ycoordinate);
237
+		fwrite(&s, 4, 1, f);
238
+		fwrite(&t, 4, 1, f);
239
+
240
+
241
+		s = tr->adjustTexel(object_texture[t_index].vertices[1].xpixel,
242
+								  object_texture[t_index].vertices[1].xcoordinate);
243
+		t = tr->adjustTexel(object_texture[t_index].vertices[1].ypixel,
244
+								  object_texture[t_index].vertices[1].ycoordinate);
245
+		fwrite(&s, 4, 1, f);
246
+		fwrite(&t, 4, 1, f);
247
+
248
+		s = tr->adjustTexel(object_texture[t_index].vertices[2].xpixel,
249
+								  object_texture[t_index].vertices[2].xcoordinate);
250
+		t = tr->adjustTexel(object_texture[t_index].vertices[2].ypixel,
251
+								  object_texture[t_index].vertices[2].ycoordinate);
252
+		fwrite(&s, 4, 1, f);
253
+		fwrite(&t, 4, 1, f);
254
+	}
255
+
256
+	fwrite(&check, 4, 1, f);
257
+
258
+
259
+   // Textured rectangles ////////////////////////
260
+	fwrite(&check, 4, 1, f);
261
+	rectangles = meshes[index].num_textured_rectangles;
262
+
263
+	for (i = 0; rectangles > 0 && i < rectangles; i++)
264
+   {
265
+		t_index = meshes[index].textured_rectangles[i].texture;
266
+
267
+		// Store texture info
268
+		fwrite(&object_texture[t_index].tile, 2, 1, f);
269
+		fwrite(&object_texture[t_index].transparency_flags, 2, 1, f);
270
+
271
+		// Store vertices
272
+		v = meshes[index].textured_rectangles[i].vertices[0];
273
+		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
274
+		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
275
+		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
276
+
277
+		v = meshes[index].textured_rectangles[i].vertices[1];
278
+		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
279
+		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
280
+		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
281
+
282
+		v = meshes[index].textured_rectangles[i].vertices[2];
283
+		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
284
+		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
285
+		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
286
+
287
+		v = meshes[index].textured_rectangles[i].vertices[3];
288
+		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
289
+		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
290
+		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
291
+
292
+		// Store texels
293
+		s = tr->adjustTexel(object_texture[t_index].vertices[0].xpixel,
294
+								  object_texture[t_index].vertices[0].xcoordinate);
295
+		t = tr->adjustTexel(object_texture[t_index].vertices[0].ypixel,
296
+								  object_texture[t_index].vertices[0].ycoordinate);
297
+		fwrite(&s, 4, 1, f);
298
+		fwrite(&t, 4, 1, f);
299
+
300
+
301
+		s = tr->adjustTexel(object_texture[t_index].vertices[1].xpixel,
302
+								  object_texture[t_index].vertices[1].xcoordinate);
303
+		t = tr->adjustTexel(object_texture[t_index].vertices[1].ypixel,
304
+								  object_texture[t_index].vertices[1].ycoordinate);
305
+		fwrite(&s, 4, 1, f);
306
+		fwrite(&t, 4, 1, f);
307
+
308
+		s = tr->adjustTexel(object_texture[t_index].vertices[2].xpixel,
309
+								  object_texture[t_index].vertices[2].xcoordinate);
310
+		t = tr->adjustTexel(object_texture[t_index].vertices[2].ypixel,
311
+								  object_texture[t_index].vertices[2].ycoordinate);
312
+		fwrite(&s, 4, 1, f);
313
+		fwrite(&t, 4, 1, f);
314
+
315
+		s = tr->adjustTexel(object_texture[t_index].vertices[3].xpixel,
316
+								  object_texture[t_index].vertices[3].xcoordinate);
317
+		t = tr->adjustTexel(object_texture[t_index].vertices[3].ypixel,
318
+								  object_texture[t_index].vertices[3].ycoordinate);
319
+		fwrite(&s, 4, 1, f);
320
+		fwrite(&t, 4, 1, f);
321
+	}
322
+
323
+	fwrite(&check, 4, 1, f);
324
+
325
+   // Coloured triangles ////////////////////////
326
+	fwrite(&check, 4, 1, f);
327
+	triangles = meshes[index].num_coloured_triangles;
328
+
329
+	for (i = 0; triangles > 0 && i < triangles; i++)
330
+   {
331
+		// Store vertices
332
+		v = meshes[index].coloured_triangles[i].vertices[0];
333
+		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
334
+		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
335
+		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
336
+
337
+		v = meshes[index].coloured_triangles[i].vertices[1];
338
+		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
339
+		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
340
+		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
341
+
342
+		v = meshes[index].coloured_triangles[i].vertices[2];
343
+		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
344
+		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
345
+		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
346
+
347
+		// Store color
348
+		switch (tr->Engine())
349
+		{
350
+		case TR_VERSION_1:
351
+			tr->getColor(meshes[index].coloured_triangles[i].texture
352
+								 & 0xff, rgba);
353
+			break;
354
+		default:
355
+			tr->getColor((meshes[index].coloured_triangles[i].texture>>8)
356
+								 & 0xff, rgba);
357
+		}
358
+
359
+		s = rgba[0];
360
+		t = rgba[1];
361
+		fwrite(&s, 4, 1, f);
362
+		fwrite(&t, 4, 1, f);
363
+
364
+		s = rgba[2];
365
+		t = rgba[3];
366
+		fwrite(&s, 4, 1, f);
367
+		fwrite(&t, 4, 1, f);
368
+	}
369
+
370
+	fwrite(&check, 4, 1, f);
371
+
372
+   // Coloured rectangles ////////////////////////
373
+	fwrite(&check, 4, 1, f);
374
+	rectangles = meshes[index].num_coloured_rectangles;
375
+
376
+	for (i = 0; rectangles > 0 && i < rectangles; i++)
377
+   {
378
+		// Store vertices
379
+		v = meshes[index].coloured_rectangles[i].vertices[0];
380
+		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
381
+		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
382
+		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
383
+
384
+		v = meshes[index].coloured_rectangles[i].vertices[1];
385
+		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
386
+		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
387
+		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
388
+
389
+		v = meshes[index].coloured_rectangles[i].vertices[2];
390
+		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
391
+		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
392
+		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
393
+
394
+		v = meshes[index].coloured_rectangles[i].vertices[3];
395
+		fwrite(&meshes[index].vertices[v].x, 2, 1, f);
396
+		fwrite(&meshes[index].vertices[v].y, 2, 1, f);
397
+		fwrite(&meshes[index].vertices[v].z, 2, 1, f);
398
+
399
+		// Store color
400
+		switch (tr->Engine())
401
+		{
402
+		case TR_VERSION_1:
403
+			tr->getColor(meshes[index].coloured_rectangles[i].texture
404
+								 & 0xff, rgba);
405
+			break;
406
+		default:
407
+			tr->getColor((meshes[index].coloured_rectangles[i].texture>>8)
408
+								 & 0xff, rgba);
409
+		}
410
+
411
+		s = rgba[0];
412
+		t = rgba[1];
413
+		fwrite(&s, 4, 1, f);
414
+		fwrite(&t, 4, 1, f);
415
+
416
+		s = rgba[2];
417
+		t = rgba[3];
418
+		fwrite(&s, 4, 1, f);
419
+		fwrite(&t, 4, 1, f);
420
+	}
421
+
422
+	fwrite(&check, 4, 1, f);
423
+	fclose(f);
424
+
425
+	printf(".");
426
+	fflush(stdout);
427
+}
428
+
429
+
430
+void dump_lara_stuff(char *mapname, TombRaider &tr)
431
+{
432
+	unsigned int i, j, k, n;
433
+	tr2_moveable_t *moveable = tr.Moveable();
434
+	unsigned int numMoveables = tr.NumMoveables();
435
+	char filename[64];
436
+	unsigned char *riff;
437
+	unsigned int riffSz, total = 0;
438
+	FILE *f;
439
+
440
+
441
+	snprintf(filename, 63, "%s-lara.nfo", mapname);
442
+	f = fopen(filename, "w");
443
+
444
+	if (!f)
445
+	{
446
+		perror("Failed to write lara.nfo: ");
447
+		return;
448
+	}
449
+
450
+	for (i = 0; i < numMoveables; ++i)
451
+	{
452
+		j = n = 0;
453
+
454
+		if (moveable[i].object_id == 0)
455
+		{
456
+			j = moveable[i].starting_mesh;
457
+			n = moveable[i].num_meshes + j;
458
+
459
+			fprintf(f, "Lara (%i)\n", i);
460
+		}
461
+		else if (moveable[i].object_id == 30)
462
+		{
463
+			j = moveable[i].starting_mesh;
464
+			n = moveable[i].num_meshes + j;
465
+
466
+			fprintf(f, "Lara ponytail\n");
467
+		}
468
+		else if (tr.Engine() == TR_VERSION_4)
469
+		{
470
+			switch (moveable[i].object_id)
471
+			{
472
+			case 8: // Joints, ( interconnecting skin/ploys )
473
+			case 9:
474
+				fprintf(f, "TR4 lara joints (%i)\n", i);
475
+				j = moveable[i].starting_mesh;
476
+				n = moveable[i].num_meshes + j;
477
+			}
478
+		}
479
+
480
+		for (k = j; j < n; ++j)
481
+		{
482
+			fprintf(f, "\tMesh[%i] = %i\n", (j - k), j);
483
+		}
484
+	}
485
+
486
+	fclose(f);
487
+
488
+	printf("\nDumping %i audio samples: ", tr.getSoundSamplesCount());
489
+
490
+	for (i = 0, j = 0; i < tr.getSoundSamplesCount(); ++i)
491
+	{
492
+		tr.getSoundSample(i, &riffSz, &riff);
493
+
494
+		total += riffSz;
495
+
496
+		snprintf(filename, 63, "%s-%03i.wav", mapname, j++);
497
+		f = fopen(filename, "wb");
498
+
499
+		if (!f)
500
+		{
501
+			perror("Failed to write riff.wav: ");
502
+			continue;
503
+		}
504
+
505
+		fwrite(riff, 1, riffSz, f);
506
+		fclose(f);
507
+
508
+		delete [] riff;
509
+
510
+		printf(".");
511
+		fflush(stdout);
512
+	}
513
+
514
+	printf("\n");
515
+
516
+	if (total)
517
+	{
518
+		printf("Dumped %ibytes (%.2f MB) of audio samples\n",
519
+				 total, (float)total/1024000.0);
520
+	}
521
+}
522
+
523
+
524
+void percent_callback(int p)
525
+{
526
+	printf("Level %i%% loaded\n", p);
527
+}
528
+
529
+
530
+int test_main(int argc, char *argv[])
531
+{
532
+  TombRaider tr;
533
+  char mapname[128];
534
+  int len, i, j;
535
+
536
+
537
+  printf("[TombRaider class test]\n");
538
+
539
+  tr.setDebug(true);
540
+
541
+  if (argc > 2)
542
+  {
543
+	  // Strip for mapname //////////////////////////////
544
+	  len = strlen(argv[2]);
545
+
546
+	  for (i = len, j = 0; i > 0; i--, j++)
547
+		  if (argv[2][i] == '/' || argv[2][i] == '\\')
548
+			  break;
549
+
550
+	  j--;
551
+
552
+	  memset(mapname, 0, 128);
553
+
554
+	  for (i = 0; i < len - j && i < 30; i++)
555
+		  mapname[i] = argv[2][i + len - j];
556
+
557
+	  ////////////////////////////////////////////////////
558
+
559
+
560
+    if (strncmp(argv[1], "load", 4) == 0)
561
+    {
562
+      if (!tr.Load(argv[2], percent_callback))
563
+		{
564
+        printf("\nmain: Load reports success.\n");
565
+		}
566
+    }
567
+    else if (strncmp(argv[1], "dump", 4) == 0)
568
+    {
569
+      if (!tr.Load(argv[2], percent_callback))
570
+		{
571
+        printf("\nmain: Load reports success.\n");
572
+
573
+		  dump_textures(&tr, mapname);
574
+
575
+		  printf("Mesh dumping: ");
576
+		  for (i = 0; i < tr.getMeshCount(); i++)
577
+		  {
578
+			  dump_mesh(&tr, mapname, i);
579
+		  }
580
+
581
+		  if (argc > 3)
582
+		  {
583
+			  printf("\nLoading external sound SFX.\n");
584
+			  tr.loadSFX(argv[3]);
585
+		  }
586
+
587
+		  dump_lara_stuff(mapname, tr);
588
+
589
+		  printf("\n");
590
+		}
591
+		else
592
+		{
593
+			printf("\nmain: Load failed.\n");
594
+		}
595
+    }
596
+    else
597
+      printf("\n\n%s [ load | dump ] filename [sound.sfx]\n", argv[0]);
598
+  }
599
+  else
600
+  {
601
+    printf("\n\n%s [ load | dump ] filename [sound.sfx]\n", argv[0]);
602
+  }
603
+
604
+  return 0;
605
+}
606
+
607
+
608
+int main(int argc, char *argv[])
609
+{
610
+	test_main(argc, argv);
611
+
612
+#ifdef DEBUG_MEMORY
613
+  dump_memory_report();
614
+#endif
615
+
616
+  return 0;
617
+}
618
+

+ 37
- 26
test/memory_test.cpp Прегледај датотеку

@@ -25,6 +25,17 @@
25 25
 
26 26
 #include <memory_test.h>
27 27
 
28
+extern rbtree_t *MEMORY_INFO;
29
+extern meminfo_filename_t *MEMORY_FILENAME;
30
+extern long MEMORY_USED;
31
+extern long MEMORYA_USED;
32
+extern long MEMORYC_USED;
33
+extern long MAX_MEMORY_USED;
34
+extern long MAX_MEMORYA_USED;
35
+extern long MAX_MEMORYC_USED;
36
+
37
+void tree_valid_report(rbtree_t *root);
38
+
28 39
 #define PRINT_TEST_BREAK_LINE	printf("\n############################################################\n\n");
29 40
 
30 41
 int memory_test_unit_test(int argc, char *argv[])
@@ -36,116 +47,116 @@ int memory_test_unit_test(int argc, char *argv[])
36 47
 	printf("Memory test\n");
37 48
 	PRINT_TEST_BREAK_LINE
38 49
 
39
-	printf(">\ti = new int;  %s:%i\n", __FILE__, __LINE__);
40 50
 	i = new int;
51
+	printf(">\ti = new int; (%p)  %s:%i\n", i, __FILE__, __LINE__);
41 52
 	dump_memory_report();
42 53
 	tree_valid_report(MEMORY_INFO);
43 54
 
44
-	printf(">\tdelete i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
45 55
 	delete i;
56
+	printf(">\tdelete i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
46 57
 	dump_memory_report();
47 58
 	tree_valid_report(MEMORY_INFO);
48 59
 
49 60
 	PRINT_TEST_BREAK_LINE
50 61
 
51
-	printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
52 62
 	i = new int[3];
63
+	printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
53 64
 	dump_memory_report();
54 65
 	tree_valid_report(MEMORY_INFO);
55 66
 
56
-	printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
57 67
 	delete [] i;
68
+	printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
58 69
 	dump_memory_report();
59 70
 	tree_valid_report(MEMORY_INFO);
60 71
 
61 72
 	PRINT_TEST_BREAK_LINE
62 73
 
63
-	printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
64 74
 	i = new int[3];
65
-	printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
75
+	printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
66 76
 	j = new int;
67
-	printf(">\tk = new int[3]; (%p)  %s:%i\n", k, __FILE__, __LINE__);
77
+	printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
68 78
 	k = new int[3];
79
+	printf(">\tk = new int[3]; (%p)  %s:%i\n", k, __FILE__, __LINE__);
69 80
 	dump_memory_report();
70 81
 	tree_valid_report(MEMORY_INFO);
71
-	printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
72 82
 	delete [] i;
73
-	printf(">\tdelete j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
83
+	printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
74 84
 	delete j;
75
-	printf(">\tdelete [] k; (%p)  %s:%i\n", k, __FILE__, __LINE__);
85
+	printf(">\tdelete j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
76 86
 	delete [] k;
87
+	printf(">\tdelete [] k; (%p)  %s:%i\n", k, __FILE__, __LINE__);
77 88
 	dump_memory_report();
78 89
 	tree_valid_report(MEMORY_INFO);
79 90
 
80 91
 	PRINT_TEST_BREAK_LINE
81 92
 
82
-	printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
83 93
 	i = new int[3];
84
-	printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
94
+	printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
85 95
 	j = new int;
86
-	printf(">\tk = new int[3]; (%p)  %s:%i\n", k, __FILE__, __LINE__);
96
+	printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
87 97
 	k = new int[3];
98
+	printf(">\tk = new int[3]; (%p)  %s:%i\n", k, __FILE__, __LINE__);
88 99
 	dump_memory_report();
89 100
 	tree_valid_report(MEMORY_INFO);
90
-	printf(">\tdelete j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
91 101
 	delete j;
102
+	printf(">\tdelete j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
92 103
 	dump_memory_report();
93 104
 	tree_valid_report(MEMORY_INFO);
94
-	printf(">\tj = new int[3]; (%p)  %s:%i\n", j, __FILE__, __LINE__);
95 105
 	j = new int[3];
106
+	printf(">\tj = new int[3]; (%p)  %s:%i\n", j, __FILE__, __LINE__);
96 107
 	dump_memory_report();
97 108
 	tree_valid_report(MEMORY_INFO);
98
-	printf(">\tl = new int[3]; (%p)  %s:%i\n", l, __FILE__, __LINE__);
99 109
 	l = new int[3];
110
+	printf(">\tl = new int[3]; (%p)  %s:%i\n", l, __FILE__, __LINE__);
100 111
 	dump_memory_report();
101 112
 	tree_valid_report(MEMORY_INFO);
102
-	printf(">\tm = new int[3]; (%p)  %s:%i\n", m, __FILE__, __LINE__);
103 113
 	m = new int[3];
114
+	printf(">\tm = new int[3]; (%p)  %s:%i\n", m, __FILE__, __LINE__);
104 115
 	dump_memory_report();
105 116
 	tree_valid_report(MEMORY_INFO);
106 117
 
107
-	printf(">\tn = new int[3]; (%p)  %s:%i\n", n, __FILE__, __LINE__);
108 118
 	n = new int[3];
119
+	printf(">\tn = new int[3]; (%p)  %s:%i\n", n, __FILE__, __LINE__);
109 120
 	dump_memory_report();
110 121
 	tree_valid_report(MEMORY_INFO);
111 122
 
112
-	printf(">\to = new int[3]; (%p)  %s:%i\n", o, __FILE__, __LINE__);
113 123
 	o = new int[3];
124
+	printf(">\to = new int[3]; (%p)  %s:%i\n", o, __FILE__, __LINE__);
114 125
 	dump_memory_report();
115 126
 	tree_valid_report(MEMORY_INFO);
116 127
 
117
-	printf(">\tdelete [] k; (%p)  %s:%i\n", k, __FILE__, __LINE__);
118 128
 	delete [] k;
129
+	printf(">\tdelete [] k; (%p)  %s:%i\n", k, __FILE__, __LINE__);
119 130
 	dump_memory_report();
120 131
 	tree_valid_report(MEMORY_INFO);
121 132
 
122
-	printf(">\tdelete [] j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
123 133
 	delete [] j;
134
+	printf(">\tdelete [] j; (%p)  %s:%i\n", j, __FILE__, __LINE__);
124 135
 	dump_memory_report();
125 136
 	tree_valid_report(MEMORY_INFO);
126 137
 
127
-	printf(">\tdelete [] l; (%p)  %s:%i\n", l, __FILE__, __LINE__);
128 138
 	delete [] l;
139
+	printf(">\tdelete [] l; (%p)  %s:%i\n", l, __FILE__, __LINE__);
129 140
 	dump_memory_report();
130 141
 	tree_valid_report(MEMORY_INFO);
131 142
 
132
-	printf(">\tdelete [] m; (%p)  %s:%i\n", m, __FILE__, __LINE__);
133 143
 	delete [] m;
144
+	printf(">\tdelete [] m; (%p)  %s:%i\n", m, __FILE__, __LINE__);
134 145
 	dump_memory_report();
135 146
 	tree_valid_report(MEMORY_INFO);
136 147
 
137
-	printf(">\tdelete [] n; (%p)  %s:%i\n", n, __FILE__, __LINE__);
138 148
 	delete [] n;
149
+	printf(">\tdelete [] n; (%p)  %s:%i\n", n, __FILE__, __LINE__);
139 150
 	dump_memory_report();
140 151
 	tree_valid_report(MEMORY_INFO);
141 152
 
142
-	printf(">\tdelete [] o; (%p)  %s:%i\n", o, __FILE__, __LINE__);
143 153
 	delete [] o;
154
+	printf(">\tdelete [] o; (%p)  %s:%i\n", o, __FILE__, __LINE__);
144 155
 	dump_memory_report();
145 156
 	tree_valid_report(MEMORY_INFO);
146 157
 
147
-	printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
148 158
 	delete [] i;
159
+	printf(">\tdelete [] i; (%p)  %s:%i\n", i, __FILE__, __LINE__);
149 160
 	dump_memory_report();
150 161
 	tree_valid_report(MEMORY_INFO);
151 162
 

Loading…
Откажи
Сачувај