Enable global structs for mine saving functions
[btb/d2x.git] / main / dumpmine.c
1 /* $Id: dumpmine.c,v 1.6 2004-12-19 11:06:38 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Functions to dump text description of mine.
18  * An editor-only function, called at mine load time.
19  * To be read by a human to verify the correctness and completeness of a mine.
20  *
21  */
22
23 #ifdef HAVE_CONFIG_H
24 #include <conf.h>
25 #endif
26
27 #ifdef RCS
28 static char rcsid[] = "$Id: dumpmine.c,v 1.6 2004-12-19 11:06:38 btb Exp $";
29 #endif
30
31 #include <stdio.h>
32 #include <string.h>
33 #include <stdarg.h>
34 #include <errno.h>
35
36 #include "pstypes.h"
37 #include "mono.h"
38 #include "key.h"
39 #include "gr.h"
40 #include "palette.h"
41
42 #include "inferno.h"
43 #ifdef EDITOR
44 #include "editor/editor.h"
45 #endif
46 #include "error.h"
47 #include "object.h"
48 #include "wall.h"
49 #include "gamemine.h"
50 #include "robot.h"
51 #include "player.h"
52 #include "newmenu.h"
53 #include "textures.h"
54
55 #include "bm.h"
56 #include "menu.h"
57 #include "switch.h"
58 #include "fuelcen.h"
59 #include "powerup.h"
60 #include "gameseq.h"
61 #include "polyobj.h"
62 #include "gamesave.h"
63
64
65 #ifdef EDITOR
66
67 extern ubyte bogus_data[64*64];
68 extern grs_bitmap bogus_bitmap;
69
70 // ----------------------------------------------------------------------------
71 char    *object_types(int objnum)
72 {
73         int     type = Objects[objnum].type;
74
75         Assert((type >= 0) && (type < MAX_OBJECT_TYPES));
76         return  &Object_type_names[type];
77 }
78
79 // ----------------------------------------------------------------------------
80 char    *object_ids(int objnum)
81 {
82         int     type = Objects[objnum].type;
83         int     id = Objects[objnum].id;
84
85         switch (type) {
86                 case OBJ_ROBOT:
87                         return &Robot_names[id];
88                         break;
89                 case OBJ_POWERUP:
90                         return &Powerup_names[id];
91                         break;
92         }
93
94         return  NULL;
95 }
96
97 void err_printf(FILE *my_file, char * format, ... )
98 {
99         va_list args;
100         char            message[256];
101
102         va_start(args, format );
103         vsprintf(message,format,args);
104         va_end(args);
105
106         mprintf((1, "%s", message));
107         fprintf(my_file, "%s", message);
108         Errors_in_mine++;
109 }
110
111 void warning_printf(FILE *my_file, char * format, ... )
112 {
113         va_list args;
114         char            message[256];
115
116         va_start(args, format );
117         vsprintf(message,format,args);
118         va_end(args);
119
120         mprintf((0, "%s", message));
121         fprintf(my_file, "%s", message);
122 }
123
124 // ----------------------------------------------------------------------------
125 void write_exit_text(FILE *my_file)
126 {
127         int     i, j, count;
128
129         fprintf(my_file, "-----------------------------------------------------------------------------\n");
130         fprintf(my_file, "Exit stuff\n");
131
132         //      ---------- Find exit triggers ----------
133         count=0;
134         for (i=0; i<Num_triggers; i++)
135                 if (Triggers[i].type == TT_EXIT) {
136                         int     count2;
137
138                         fprintf(my_file, "Trigger %2i, is an exit trigger with %i links.\n", i, Triggers[i].num_links);
139                         count++;
140                         if (Triggers[i].num_links != 0)
141                                 err_printf(my_file, "Error: Exit triggers must have 0 links, this one has %i links.\n", Triggers[i].num_links);
142
143                         //      Find wall pointing to this trigger.
144                         count2 = 0;
145                         for (j=0; j<Num_walls; j++)
146                                 if (Walls[j].trigger == i) {
147                                         count2++;
148                                         fprintf(my_file, "Exit trigger %i is in segment %i, on side %i, bound to wall %i\n", i, Walls[j].segnum, Walls[j].sidenum, j);
149                                 }
150                         if (count2 == 0)
151                                 err_printf(my_file, "Error: Trigger %i is not bound to any wall.\n", i);
152                         else if (count2 > 1)
153                                 err_printf(my_file, "Error: Trigger %i is bound to %i walls.\n", i, count2);
154
155                 }
156
157         if (count == 0)
158                 err_printf(my_file, "Error: No exit trigger in this mine.\n");
159         else if (count != 1)
160                 err_printf(my_file, "Error: More than one exit trigger in this mine.\n");
161         else
162                 fprintf(my_file, "\n");
163
164         //      ---------- Find exit doors ----------
165         count = 0;
166         for (i=0; i<=Highest_segment_index; i++)
167                 for (j=0; j<MAX_SIDES_PER_SEGMENT; j++)
168                         if (Segments[i].children[j] == -2) {
169                                 fprintf(my_file, "Segment %3i, side %i is an exit door.\n", i, j);
170                                 count++;
171                         }
172
173         if (count == 0)
174                 err_printf(my_file, "Error: No external wall in this mine.\n");
175         else if (count != 1) {
176                 // -- warning_printf(my_file, "Warning: %i external walls in this mine.\n", count);
177                 // -- warning_printf(my_file, "(If %i are secret exits, then no problem.)\n", count-1);
178         } else
179                 fprintf(my_file, "\n");
180 }
181
182 // ----------------------------------------------------------------------------
183 void write_key_text(FILE *my_file)
184 {
185         int     i;
186         int     red_count, blue_count, gold_count;
187         int     red_count2, blue_count2, gold_count2;
188         int     blue_segnum=-1, blue_sidenum=-1, red_segnum=-1, red_sidenum=-1, gold_segnum=-1, gold_sidenum=-1;
189         int     connect_side;
190
191         fprintf(my_file, "-----------------------------------------------------------------------------\n");
192         fprintf(my_file, "Key stuff:\n");
193
194         red_count = 0;
195         blue_count = 0;
196         gold_count = 0;
197
198         for (i=0; i<Num_walls; i++) {
199                 if (Walls[i].keys & KEY_BLUE) {
200                         fprintf(my_file, "Wall %i (seg=%i, side=%i) is keyed to the blue key.\n", i, Walls[i].segnum, Walls[i].sidenum);
201                         if (blue_segnum == -1) {
202                                 blue_segnum = Walls[i].segnum;
203                                 blue_sidenum = Walls[i].sidenum;
204                                 blue_count++;
205                         } else {
206                                 connect_side = find_connect_side(&Segments[Walls[i].segnum], &Segments[blue_segnum]);
207                                 if (connect_side != blue_sidenum) {
208                                         warning_printf(my_file, "Warning: This blue door at seg %i, is different than the one at seg %i, side %i\n", Walls[i].segnum, blue_segnum, blue_sidenum);
209                                         blue_count++;
210                                 }
211                         }
212                 }
213                 if (Walls[i].keys & KEY_RED) {
214                         fprintf(my_file, "Wall %i (seg=%i, side=%i) is keyed to the red key.\n", i, Walls[i].segnum, Walls[i].sidenum);
215                         if (red_segnum == -1) {
216                                 red_segnum = Walls[i].segnum;
217                                 red_sidenum = Walls[i].sidenum;
218                                 red_count++;
219                         } else {
220                                 connect_side = find_connect_side(&Segments[Walls[i].segnum], &Segments[red_segnum]);
221                                 if (connect_side != red_sidenum) {
222                                         warning_printf(my_file, "Warning: This red door at seg %i, is different than the one at seg %i, side %i\n", Walls[i].segnum, red_segnum, red_sidenum);
223                                         red_count++;
224                                 }
225                         }
226                 }
227                 if (Walls[i].keys & KEY_GOLD) {
228                         fprintf(my_file, "Wall %i (seg=%i, side=%i) is keyed to the gold key.\n", i, Walls[i].segnum, Walls[i].sidenum);
229                         if (gold_segnum == -1) {
230                                 gold_segnum = Walls[i].segnum;
231                                 gold_sidenum = Walls[i].sidenum;
232                                 gold_count++;
233                         } else {
234                                 connect_side = find_connect_side(&Segments[Walls[i].segnum], &Segments[gold_segnum]);
235                                 if (connect_side != gold_sidenum) {
236                                         warning_printf(my_file, "Warning: This gold door at seg %i, is different than the one at seg %i, side %i\n", Walls[i].segnum, gold_segnum, gold_sidenum);
237                                         gold_count++;
238                                 }
239                         }
240                 }
241         }
242
243         if (blue_count > 1)
244                 warning_printf(my_file, "Warning: %i doors are keyed to the blue key.\n", blue_count);
245
246         if (red_count > 1)
247                 warning_printf(my_file, "Warning: %i doors are keyed to the red key.\n", red_count);
248
249         if (gold_count > 1)
250                 warning_printf(my_file, "Warning: %i doors are keyed to the gold key.\n", gold_count);
251
252         red_count2 = 0;
253         blue_count2 = 0;
254         gold_count2 = 0;
255
256         for (i=0; i<=Highest_object_index; i++) {
257                 if (Objects[i].type == OBJ_POWERUP)
258                         if (Objects[i].id == POW_KEY_BLUE) {
259                                 fprintf(my_file, "The BLUE key is object %i in segment %i\n", i, Objects[i].segnum);
260                                 blue_count2++;
261                         }
262                 if (Objects[i].type == OBJ_POWERUP)
263                         if (Objects[i].id == POW_KEY_RED) {
264                                 fprintf(my_file, "The RED key is object %i in segment %i\n", i, Objects[i].segnum);
265                                 red_count2++;
266                         }
267                 if (Objects[i].type == OBJ_POWERUP)
268                         if (Objects[i].id == POW_KEY_GOLD) {
269                                 fprintf(my_file, "The GOLD key is object %i in segment %i\n", i, Objects[i].segnum);
270                                 gold_count2++;
271                         }
272
273                 if (Objects[i].contains_count) {
274                         if (Objects[i].contains_type == OBJ_POWERUP) {
275                                 switch (Objects[i].contains_id) {
276                                         case POW_KEY_BLUE:
277                                                 fprintf(my_file, "The BLUE key is contained in object %i (a %s %s) in segment %i\n", i, Object_type_names[Objects[i].type], Robot_names[Objects[i].id], Objects[i].segnum);
278                                                 blue_count2 += Objects[i].contains_count;
279                                                 break;
280                                         case POW_KEY_GOLD:
281                                                 fprintf(my_file, "The GOLD key is contained in object %i (a %s %s) in segment %i\n", i, Object_type_names[Objects[i].type], Robot_names[Objects[i].id], Objects[i].segnum);
282                                                 gold_count2 += Objects[i].contains_count;
283                                                 break;
284                                         case POW_KEY_RED:
285                                                 fprintf(my_file, "The RED key is contained in object %i (a %s %s) in segment %i\n", i, Object_type_names[Objects[i].type], Robot_names[Objects[i].id], Objects[i].segnum);
286                                                 red_count2 += Objects[i].contains_count;
287                                                 break;
288                                         default:
289                                                 break;
290                                 }
291                         }
292                 }
293         }
294
295         if (blue_count)
296                 if (blue_count2 == 0)
297                         err_printf(my_file, "Error: There is a door keyed to the blue key, but no blue key!\n");
298
299         if (red_count)
300                 if (red_count2 == 0)
301                         err_printf(my_file, "Error: There is a door keyed to the red key, but no red key!\n");
302
303         if (gold_count)
304                 if (gold_count2 == 0)
305                         err_printf(my_file, "Error: There is a door keyed to the gold key, but no gold key!\n");
306
307         if (blue_count2 > 1)
308                 err_printf(my_file, "Error: There are %i blue keys!\n", blue_count2);
309
310         if (red_count2 > 1)
311                 err_printf(my_file, "Error: There are %i red keys!\n", red_count2);
312
313         if (gold_count2 > 1)
314                 err_printf(my_file, "Error: There are %i gold keys!\n", gold_count2);
315 }
316
317 // ----------------------------------------------------------------------------
318 void write_control_center_text(FILE *my_file)
319 {
320         int     i, count, objnum, count2;
321
322         fprintf(my_file, "-----------------------------------------------------------------------------\n");
323         fprintf(my_file, "Control Center stuff:\n");
324
325         count = 0;
326         for (i=0; i<=Highest_segment_index; i++)
327                 if (Segment2s[i].special == SEGMENT_IS_CONTROLCEN) {
328                         count++;
329                         fprintf(my_file, "Segment %3i is a control center.\n", i);
330                         objnum = Segments[i].objects;
331                         count2 = 0;
332                         while (objnum != -1) {
333                                 if (Objects[objnum].type == OBJ_CNTRLCEN)
334                                         count2++;
335                                 objnum = Objects[objnum].next;
336                         }
337                         if (count2 == 0)
338                                 fprintf(my_file, "No control center object in control center segment.\n");
339                         else if (count2 != 1)
340                                 fprintf(my_file, "%i control center objects in control center segment.\n", count2);
341                 }
342
343         if (count == 0)
344                 err_printf(my_file, "Error: No control center in this mine.\n");
345         else if (count != 1)
346                 err_printf(my_file, "Error: More than one control center in this mine.\n");
347 }
348
349 // ----------------------------------------------------------------------------
350 void write_fuelcen_text(FILE *my_file)
351 {
352         int     i;
353
354         fprintf(my_file, "-----------------------------------------------------------------------------\n");
355         fprintf(my_file, "Fuel Center stuff: (Note: This means fuel, repair, materialize, control centers!)\n");
356
357         for (i=0; i<Num_fuelcenters; i++) {
358                 fprintf(my_file, "Fuelcenter %i: Type=%i (%s), segment = %3i\n", i, Station[i].Type, Special_names[Station[i].Type], Station[i].segnum);
359                 if (Segment2s[Station[i].segnum].special != Station[i].Type)
360                         err_printf(my_file, "Error: Conflicting data: Segment %i has special type %i (%s), expected to be %i\n", Station[i].segnum, Segment2s[Station[i].segnum].special, Special_names[Segment2s[Station[i].segnum].special], Station[i].Type);
361         }
362 }
363
364 // ----------------------------------------------------------------------------
365 void write_segment_text(FILE *my_file)
366 {
367         int     i, objnum;
368
369         fprintf(my_file, "-----------------------------------------------------------------------------\n");
370         fprintf(my_file, "Segment stuff:\n");
371
372         for (i=0; i<=Highest_segment_index; i++) {
373
374                 fprintf(my_file, "Segment %4i: ", i);
375                 if (Segment2s[i].special != 0)
376                         fprintf(my_file, "special = %3i (%s), value = %3i ", Segment2s[i].special, Special_names[Segment2s[i].special], Segment2s[i].value);
377
378                 if (Segment2s[i].matcen_num != -1)
379                         fprintf(my_file, "matcen = %3i, ", Segment2s[i].matcen_num);
380                 
381                 fprintf(my_file, "\n");
382         }
383
384         for (i=0; i<=Highest_segment_index; i++) {
385                 int     depth;
386
387                 objnum = Segments[i].objects;
388                 fprintf(my_file, "Segment %4i: ", i);
389                 depth=0;
390                 if (objnum != -1) {
391                         fprintf(my_file, "Objects: ");
392                         while (objnum != -1) {
393                                 fprintf(my_file, "[%8s %8s %3i] ", object_types(objnum), object_ids(objnum), objnum);
394                                 objnum = Objects[objnum].next;
395                                 if (depth++ > 30) {
396                                         fprintf(my_file, "\nAborted after %i links\n", depth);
397                                         break;
398                                 }
399                         }
400                 }
401                 fprintf(my_file, "\n");
402         }
403 }
404
405 // ----------------------------------------------------------------------------
406 // This routine is bogus.  It assumes that all centers are matcens,
407 // which is not true.  The setting of segnum is bogus.
408 void write_matcen_text(FILE *my_file)
409 {
410         int     i, j, k;
411
412         fprintf(my_file, "-----------------------------------------------------------------------------\n");
413         fprintf(my_file, "Materialization centers:\n");
414         for (i=0; i<Num_robot_centers; i++) {
415                 int     trigger_count=0, segnum, fuelcen_num;
416
417                 fprintf(my_file, "FuelCenter[%02i].Segment = %04i  ", i, Station[i].segnum);
418                 fprintf(my_file, "Segment2[%04i].matcen_num = %02i  ", Station[i].segnum, Segment2s[Station[i].segnum].matcen_num);
419
420                 fuelcen_num = RobotCenters[i].fuelcen_num;
421                 if (Station[fuelcen_num].Type != SEGMENT_IS_ROBOTMAKER)
422                         err_printf(my_file, "Error: Matcen %i corresponds to Station %i, which has type %i (%s).\n", i, fuelcen_num, Station[fuelcen_num].Type, Special_names[Station[fuelcen_num].Type]);
423
424                 segnum = Station[fuelcen_num].segnum;
425
426                 //      Find trigger for this materialization center.
427                 for (j=0; j<Num_triggers; j++) {
428                         if (Triggers[j].type == TT_MATCEN) {
429                                 for (k=0; k<Triggers[j].num_links; k++)
430                                         if (Triggers[j].seg[k] == segnum) {
431                                                 fprintf(my_file, "Trigger = %2i  ", j );
432                                                 trigger_count++;
433                                         }
434                         }
435                 }
436                 fprintf(my_file, "\n");
437
438                 if (trigger_count == 0)
439                         err_printf(my_file, "Error: Matcen %i in segment %i has no trigger!\n", i, segnum);
440
441         }
442 }
443
444 // ----------------------------------------------------------------------------
445 void write_wall_text(FILE *my_file)
446 {
447         int     i, j;
448         sbyte wall_flags[MAX_WALLS];
449
450         fprintf(my_file, "-----------------------------------------------------------------------------\n");
451         fprintf(my_file, "Walls:\n");
452         for (i=0; i<Num_walls; i++) {
453                 int     segnum, sidenum;
454
455                 fprintf(my_file, "Wall %03i: seg=%3i, side=%2i, linked_wall=%3i, type=%s, flags=%4x, hps=%3i, trigger=%2i, clip_num=%2i, keys=%2i, state=%i\n", i,
456                         Walls[i].segnum, Walls[i].sidenum, Walls[i].linked_wall, Wall_names[Walls[i].type], Walls[i].flags, Walls[i].hps >> 16, Walls[i].trigger, Walls[i].clip_num, Walls[i].keys, Walls[i].state);
457
458                 if (Walls[i].trigger >= Num_triggers)
459                         fprintf(my_file, "Wall %03d points to invalid trigger %d\n",i,Walls[i].trigger);
460
461                 segnum = Walls[i].segnum;
462                 sidenum = Walls[i].sidenum;
463
464                 if (Segments[segnum].sides[sidenum].wall_num != i)
465                         err_printf(my_file, "Error: Wall %i points at segment %i, side %i, but that segment doesn't point back (it's wall_num = %i)\n", i, segnum, sidenum, Segments[segnum].sides[sidenum].wall_num);
466         }
467
468         for (i=0; i<MAX_WALLS; i++)
469                 wall_flags[i] = 0;
470
471         for (i=0; i<=Highest_segment_index; i++) {
472                 segment *segp = &Segments[i];
473                 for (j=0; j<MAX_SIDES_PER_SEGMENT; j++) {
474                         side    *sidep = &segp->sides[j];
475                         if (sidep->wall_num != -1)
476                                 if (wall_flags[sidep->wall_num])
477                                         err_printf(my_file, "Error: Wall %i appears in two or more segments, including segment %i, side %i.\n", sidep->wall_num, i, j);
478                                 else
479                                         wall_flags[sidep->wall_num] = 1;
480                 }
481         }
482
483 }
484
485 //typedef struct trigger {
486 //      sbyte   type;
487 //      short           flags;
488 //      fix             value;
489 //      fix             time;
490 //      sbyte   link_num;
491 //      short   num_links;
492 //      short   seg[MAX_WALLS_PER_LINK];
493 //      short           side[MAX_WALLS_PER_LINK];
494 //      } trigger;
495
496 // ----------------------------------------------------------------------------
497 void write_player_text(FILE *my_file)
498 {
499         int     i, num_players=0;
500
501         fprintf(my_file, "-----------------------------------------------------------------------------\n");
502         fprintf(my_file, "Players:\n");
503         for (i=0; i<=Highest_object_index; i++) {
504                 if (Objects[i].type == OBJ_PLAYER) {
505                         num_players++;
506                         fprintf(my_file, "Player %2i is object #%3i in segment #%3i.\n", Objects[i].id, i, Objects[i].segnum);
507                 }
508         }
509
510         if (num_players != MAX_PLAYERS)
511                 err_printf(my_file, "Error: %i player objects.  %i are required.\n", num_players, MAX_PLAYERS);
512         if (num_players > MAX_MULTI_PLAYERS)
513                 err_printf(my_file, "Error: %i player objects.  %i are required.\n", num_players, MAX_PLAYERS);
514 }
515
516 // ----------------------------------------------------------------------------
517 void write_trigger_text(FILE *my_file)
518 {
519         int     i, j, w;
520
521         fprintf(my_file, "-----------------------------------------------------------------------------\n");
522         fprintf(my_file, "Triggers:\n");
523         for (i=0; i<Num_triggers; i++) {
524                 fprintf(my_file, "Trigger %03i: type=%02x flags=%04x, value=%08x, time=%8x, num_links=%i ", i,
525                         Triggers[i].type, Triggers[i].flags, Triggers[i].value, Triggers[i].time, Triggers[i].num_links);
526
527                 for (j=0; j<Triggers[i].num_links; j++)
528                         fprintf(my_file, "[%03i:%i] ", Triggers[i].seg[j], Triggers[i].side[j]);
529
530                 //      Find which wall this trigger is connected to.
531                 for (w=0; w<Num_walls; w++)
532                         if (Walls[w].trigger == i)
533                                 break;
534
535                 if (w == Num_walls)
536                         err_printf(my_file, "\nError: Trigger %i is not connected to any wall, so it can never be triggered.\n", i);
537                 else
538                         fprintf(my_file, "Attached to seg:side = %i:%i, wall %i\n", Walls[w].segnum, Walls[w].sidenum, Segments[Walls[w].segnum].sides[Walls[w].sidenum].wall_num);
539
540         }
541
542 }
543
544 // ----------------------------------------------------------------------------
545 void write_game_text_file(char *filename)
546 {
547         char    my_filename[128];
548         int     namelen;
549         FILE    * my_file;
550
551         Errors_in_mine = 0;
552
553         // mprintf((0, "Writing text file for mine [%s]\n", filename));
554
555         namelen = strlen(filename);
556
557         Assert (namelen > 4);
558
559         Assert (filename[namelen-4] == '.');
560
561         strcpy(my_filename, filename);
562         strcpy( &my_filename[namelen-4], ".txm");
563
564         // mprintf((0, "Writing text file [%s]\n", my_filename));
565
566         my_file = fopen( my_filename, "wt" );
567         // -- mprintf((1, "Fileno = %i\n", fileno(my_file)));
568
569         if (!my_file)   {
570                 char  ErrorMessage[200];
571
572                 sprintf( ErrorMessage, "ERROR: Unable to open %s\nErrno = %i", my_file, errno );
573                 stop_time();
574                 gr_palette_load(gr_palette);
575                 nm_messagebox( NULL, 1, "Ok", ErrorMessage );
576                 start_time();
577
578                 return;
579         }
580
581         dump_used_textures_level(my_file, 0);
582         say_totals(my_file, Gamesave_current_filename);
583
584         fprintf(my_file, "\nNumber of segments:   %4i\n", Highest_segment_index+1);
585         fprintf(my_file, "Number of objects:    %4i\n", Highest_object_index+1);
586         fprintf(my_file, "Number of walls:      %4i\n", Num_walls);
587         fprintf(my_file, "Number of open doors: %4i\n", Num_open_doors);
588         fprintf(my_file, "Number of triggers:   %4i\n", Num_triggers);
589         fprintf(my_file, "Number of matcens:    %4i\n", Num_robot_centers);
590         fprintf(my_file, "\n");
591
592         write_segment_text(my_file);
593
594         write_fuelcen_text(my_file);
595
596         write_matcen_text(my_file);
597
598         write_player_text(my_file);
599
600         write_wall_text(my_file);
601
602         write_trigger_text(my_file);
603
604         write_exit_text(my_file);
605
606         //      ---------- Find control center segment ----------
607         write_control_center_text(my_file);
608
609         //      ---------- Show keyed walls ----------
610         write_key_text(my_file);
611
612 { int r;
613         r = fclose(my_file);
614         mprintf((1, "Close value = %i\n", r));
615         if (r)
616                 Int3();
617 }
618 }
619
620 // -- //        ---------------
621 // -- //        Note: This only works for a loaded level because the objects array must be valid.
622 // -- void determine_used_textures_robots(int *tmap_buf)
623 // -- {
624 // --   int     i, objnum;
625 // --   polymodel       *po;
626 // --
627 // --   Assert(N_polygon_models);
628 // --
629 // --   for (objnum=0; objnum <= Highest_object_index; objnum++) {
630 // --           int     model_num;
631 // --
632 // --           if (Objects[objnum].render_type == RT_POLYOBJ) {
633 // --                   model_num = Objects[objnum].rtype.pobj_info.model_num;
634 // --
635 // --                   po=&Polygon_models[model_num];
636 // --
637 // --                   for (i=0;i<po->n_textures;i++)  {
638 // --                           int     tli;
639 // --
640 // --                           tli = ObjBitmaps[ObjBitmapPtrs[po->first_texture+i]];
641 // --                           Assert((tli>=0) && (tli<= Num_tmaps));
642 // --                           tmap_buf[tli]++;
643 // --                   }
644 // --           }
645 // --   }
646 // --
647 // -- }
648
649 // --05/17/95--//       -----------------------------------------------------------------------------
650 // --05/17/95--void determine_used_textures_level(int load_level_flag, int shareware_flag, int level_num, int *tmap_buf, int *wall_buf, sbyte *level_tmap_buf, int max_tmap)
651 // --05/17/95--{
652 // --05/17/95-- int     segnum, sidenum;
653 // --05/17/95-- int     i, j;
654 // --05/17/95--
655 // --05/17/95-- for (i=0; i<max_tmap; i++)
656 // --05/17/95--         tmap_buf[i] = 0;
657 // --05/17/95--
658 // --05/17/95-- if (load_level_flag) {
659 // --05/17/95--         if (shareware_flag)
660 // --05/17/95--                 load_level(Shareware_level_names[level_num]);
661 // --05/17/95--         else
662 // --05/17/95--                 load_level(Registered_level_names[level_num]);
663 // --05/17/95-- }
664 // --05/17/95--
665 // --05/17/95-- for (segnum=0; segnum<=Highest_segment_index; segnum++) {
666 // --05/17/95--         segment *segp = &Segments[segnum];
667 // --05/17/95--
668 // --05/17/95--         for (sidenum=0; sidenum<MAX_SIDES_PER_SEGMENT; sidenum++) {
669 // --05/17/95--                 side    *sidep = &segp->sides[sidenum];
670 // --05/17/95--
671 // --05/17/95--                 if (sidep->wall_num != -1) {
672 // --05/17/95--                         int clip_num = Walls[sidep->wall_num].clip_num;
673 // --05/17/95--                         if (clip_num != -1) {
674 // --05/17/95--
675 // --05/17/95--                                 int num_frames = WallAnims[clip_num].num_frames;
676 // --05/17/95--
677 // --05/17/95--                                 wall_buf[clip_num] = 1;
678 // --05/17/95--
679 // --05/17/95--                                 for (j=0; j<num_frames; j++) {
680 // --05/17/95--                                         int     tmap_num;
681 // --05/17/95--
682 // --05/17/95--                                         tmap_num = WallAnims[clip_num].frames[j];
683 // --05/17/95--                                         tmap_buf[tmap_num]++;
684 // --05/17/95--                                         if (level_tmap_buf[tmap_num] == -1)
685 // --05/17/95--                                                 level_tmap_buf[tmap_num] = level_num + (!shareware_flag) * NUM_SHAREWARE_LEVELS;
686 // --05/17/95--                                 }
687 // --05/17/95--                         }
688 // --05/17/95--                 }
689 // --05/17/95--
690 // --05/17/95--                 if (sidep->tmap_num >= 0)
691 // --05/17/95--                         if (sidep->tmap_num < max_tmap) {
692 // --05/17/95--                                 tmap_buf[sidep->tmap_num]++;
693 // --05/17/95--                                 if (level_tmap_buf[sidep->tmap_num] == -1)
694 // --05/17/95--                                         level_tmap_buf[sidep->tmap_num] = level_num + (!shareware_flag) * NUM_SHAREWARE_LEVELS;
695 // --05/17/95--                         } else
696 // --05/17/95--                                 Int3(); //      Error, bogus texture map.  Should not be greater than max_tmap.
697 // --05/17/95--
698 // --05/17/95--                 if ((sidep->tmap_num2 & 0x3fff) != 0)
699 // --05/17/95--                         if ((sidep->tmap_num2 & 0x3fff) < max_tmap) {
700 // --05/17/95--                                 tmap_buf[sidep->tmap_num2 & 0x3fff]++;
701 // --05/17/95--                                 if (level_tmap_buf[sidep->tmap_num2 & 0x3fff] == -1)
702 // --05/17/95--                                         level_tmap_buf[sidep->tmap_num2 & 0x3fff] = level_num + (!shareware_flag) * NUM_SHAREWARE_LEVELS;
703 // --05/17/95--                         } else
704 // --05/17/95--                                 Int3(); //      Error, bogus texture map.  Should not be greater than max_tmap.
705 // --05/17/95--         }
706 // --05/17/95-- }
707 // --05/17/95--}
708
709 //      Adam: Change NUM_ADAM_LEVELS to the number of levels.
710 #define NUM_ADAM_LEVELS 30
711
712 //      Adam: Stick the names here.
713 char *Adam_level_names[NUM_ADAM_LEVELS] = {
714         "D2LEVA-1.LVL",
715         "D2LEVA-2.LVL",
716         "D2LEVA-3.LVL",
717         "D2LEVA-4.LVL",
718         "D2LEVA-S.LVL",
719
720         "D2LEVB-1.LVL",
721         "D2LEVB-2.LVL",
722         "D2LEVB-3.LVL",
723         "D2LEVB-4.LVL",
724         "D2LEVB-S.LVL",
725
726         "D2LEVC-1.LVL",
727         "D2LEVC-2.LVL",
728         "D2LEVC-3.LVL",
729         "D2LEVC-4.LVL",
730         "D2LEVC-S.LVL",
731
732         "D2LEVD-1.LVL",
733         "D2LEVD-2.LVL",
734         "D2LEVD-3.LVL",
735         "D2LEVD-4.LVL",
736         "D2LEVD-S.LVL",
737
738         "D2LEVE-1.LVL",
739         "D2LEVE-2.LVL",
740         "D2LEVE-3.LVL",
741         "D2LEVE-4.LVL",
742         "D2LEVE-S.LVL",
743
744         "D2LEVF-1.LVL",
745         "D2LEVF-2.LVL",
746         "D2LEVF-3.LVL",
747         "D2LEVF-4.LVL",
748         "D2LEVF-S.LVL",
749 };
750
751 typedef struct BitmapFile       {
752         char                    name[15];
753 } BitmapFile;
754
755 extern BitmapFile AllBitmaps[ MAX_BITMAP_FILES ];
756
757 int     Ignore_tmap_num2_error;
758
759 // ----------------------------------------------------------------------------
760 void determine_used_textures_level(int load_level_flag, int shareware_flag, int level_num, int *tmap_buf, int *wall_buf, sbyte *level_tmap_buf, int max_tmap)
761 {
762         int     segnum, sidenum, objnum=max_tmap;
763         int     i, j;
764
765         Assert(shareware_flag != -17);
766
767         for (i=0; i<MAX_BITMAP_FILES; i++)
768                 tmap_buf[i] = 0;
769
770         if (load_level_flag) {
771                 load_level(Adam_level_names[level_num]);
772         }
773
774
775         //      Process robots.
776         for (objnum=0; objnum<=Highest_object_index; objnum++) {
777                 object *objp = &Objects[objnum];
778
779                 if (objp->render_type == RT_POLYOBJ) {
780                         polymodel *po = &Polygon_models[objp->rtype.pobj_info.model_num];
781
782                         for (i=0; i<po->n_textures; i++) {
783
784                                 int     tli = ObjBitmaps[ObjBitmapPtrs[po->first_texture+i]].index;
785                                 // -- mprintf((0, "%s  ", AllBitmaps[ObjBitmaps[ObjBitmapPtrs[po->first_texture+i]].index].name));
786
787                                 if ((tli < MAX_BITMAP_FILES) && (tli >= 0)) {
788                                         tmap_buf[tli]++;
789                                         if (level_tmap_buf[tli] == -1)
790                                                 level_tmap_buf[tli] = level_num;
791                                 } else
792                                         Int3(); //      Hmm, It seems this texture is bogus!
793                         }
794
795                 }
796         }
797
798
799         Ignore_tmap_num2_error = 0;
800
801         //      Process walls and segment sides.
802         for (segnum=0; segnum<=Highest_segment_index; segnum++) {
803                 segment *segp = &Segments[segnum];
804
805                 for (sidenum=0; sidenum<MAX_SIDES_PER_SEGMENT; sidenum++) {
806                         side    *sidep = &segp->sides[sidenum];
807
808                         if (sidep->wall_num != -1) {
809                                 int clip_num = Walls[sidep->wall_num].clip_num;
810                                 if (clip_num != -1) {
811
812                                         // -- int num_frames = WallAnims[clip_num].num_frames;
813
814                                         wall_buf[clip_num] = 1;
815
816                                         for (j=0; j<1; j++) {   //      Used to do through num_frames, but don't really want all the door01#3 stuff.
817                                                 int     tmap_num;
818
819                                                 tmap_num = Textures[WallAnims[clip_num].frames[j]].index;
820                                                 Assert((tmap_num >= 0) && (tmap_num < MAX_BITMAP_FILES));
821                                                 tmap_buf[tmap_num]++;
822                                                 if (level_tmap_buf[tmap_num] == -1)
823                                                         level_tmap_buf[tmap_num] = level_num;
824                                         }
825                                 }
826                         } else if (segp->children[sidenum] == -1) {
827
828                                 if (sidep->tmap_num >= 0)
829                                         if (sidep->tmap_num < MAX_BITMAP_FILES) {
830                                                 Assert(Textures[sidep->tmap_num].index < MAX_BITMAP_FILES);
831                                                 tmap_buf[Textures[sidep->tmap_num].index]++;
832                                                 if (level_tmap_buf[Textures[sidep->tmap_num].index] == -1)
833                                                         level_tmap_buf[Textures[sidep->tmap_num].index] = level_num;
834                                         } else
835                                                 Int3(); //      Error, bogus texture map.  Should not be greater than max_tmap.
836
837                                 if ((sidep->tmap_num2 & 0x3fff) != 0)
838                                         if ((sidep->tmap_num2 & 0x3fff) < MAX_BITMAP_FILES) {
839                                                 Assert(Textures[sidep->tmap_num2 & 0x3fff].index < MAX_BITMAP_FILES);
840                                                 tmap_buf[Textures[sidep->tmap_num2 & 0x3fff].index]++;
841                                                 if (level_tmap_buf[Textures[sidep->tmap_num2 & 0x3fff].index] == -1)
842                                                         level_tmap_buf[Textures[sidep->tmap_num2 & 0x3fff].index] = level_num;
843                                         } else {
844                                                 if (!Ignore_tmap_num2_error)
845                                                         Int3(); //      Error, bogus texture map.  Should not be greater than max_tmap.
846                                                 Ignore_tmap_num2_error = 1;
847                                                 sidep->tmap_num2 = 0;
848                                         }
849                         }
850                 }
851         }
852 }
853
854 // ----------------------------------------------------------------------------
855 void merge_buffers(int *dest, int *src, int num)
856 {
857         int     i;
858
859         for (i=0; i<num; i++)
860                 if (src[i])
861                         dest[i] += src[i];
862 }
863
864 // ----------------------------------------------------------------------------
865 void say_used_tmaps(FILE *my_file, int *tb)
866 {
867         int     i;
868 // -- mk, 08/14/95 --   int     count = 0;
869
870         for (i=0; i<MAX_BITMAP_FILES; i++)
871                 if (tb[i]) {
872                         fprintf(my_file, "[%3i %8s (%4i)]\n", i, AllBitmaps[i].name, tb[i]);
873 // -- mk, 08/14/95 --                   if (count++ >= 4) {
874 // -- mk, 08/14/95 --                           fprintf(my_file, "\n");
875 // -- mk, 08/14/95 --                           count = 0;
876 // -- mk, 08/14/95 --                   }
877                 }
878 }
879
880 // --05/17/95--//       -----------------------------------------------------------------------------
881 // --05/17/95--void say_used_once_tmaps(FILE *my_file, int *tb, sbyte *tb_lnum)
882 // --05/17/95--{
883 // --05/17/95-- int     i;
884 // --05/17/95-- char    *level_name;
885 // --05/17/95--
886 // --05/17/95-- for (i=0; i<Num_tmaps; i++)
887 // --05/17/95--         if (tb[i] == 1) {
888 // --05/17/95--                 int     level_num = tb_lnum[i];
889 // --05/17/95--                 if (level_num >= NUM_SHAREWARE_LEVELS) {
890 // --05/17/95--                         Assert((level_num - NUM_SHAREWARE_LEVELS >= 0) && (level_num - NUM_SHAREWARE_LEVELS < NUM_REGISTERED_LEVELS));
891 // --05/17/95--                         level_name = Registered_level_names[level_num - NUM_SHAREWARE_LEVELS];
892 // --05/17/95--                 } else {
893 // --05/17/95--                         Assert((level_num >= 0) && (level_num < NUM_SHAREWARE_LEVELS));
894 // --05/17/95--                         level_name = Shareware_level_names[level_num];
895 // --05/17/95--                 }
896 // --05/17/95--
897 // --05/17/95--                 fprintf(my_file, "Texture %3i %8s used only once on level %s\n", i, TmapInfo[i].filename, level_name);
898 // --05/17/95--         }
899 // --05/17/95--}
900
901 // ----------------------------------------------------------------------------
902 void say_used_once_tmaps(FILE *my_file, int *tb, sbyte *tb_lnum)
903 {
904         int     i;
905         char    *level_name;
906
907         for (i=0; i<MAX_BITMAP_FILES; i++)
908                 if (tb[i] == 1) {
909                         int     level_num = tb_lnum[i];
910                         level_name = Adam_level_names[level_num];
911
912                         fprintf(my_file, "Texture %3i %8s used only once on level %s\n", i, AllBitmaps[i].name, level_name);
913                 }
914 }
915
916 // ----------------------------------------------------------------------------
917 void say_unused_tmaps(FILE *my_file, int *tb)
918 {
919         int     i;
920         int     count = 0;
921
922         for (i=0; i<MAX_BITMAP_FILES; i++)
923                 if (!tb[i]) {
924                         if (GameBitmaps[Textures[i].index].bm_data == &bogus_data)
925                                 fprintf(my_file, "U");
926                         else
927                                 fprintf(my_file, " ");
928
929                         fprintf(my_file, "[%3i %8s] ", i, AllBitmaps[i].name);
930                         if (count++ >= 4) {
931                                 fprintf(my_file, "\n");
932                                 count = 0;
933                         }
934                 }
935 }
936
937 // ----------------------------------------------------------------------------
938 void say_unused_walls(FILE *my_file, int *tb)
939 {
940         int     i;
941
942         for (i=0; i<Num_wall_anims; i++)
943                 if (!tb[i])
944                         fprintf(my_file, "Wall %3i is unused.\n", i);
945 }
946
947 // ----------------------------------------------------------------------------
948 say_totals(FILE *my_file, char *level_name)
949 {
950         int     i;              //, objnum;
951         int     total_robots = 0;
952         int     objects_processed = 0;
953
954         int     used_objects[MAX_OBJECTS];
955
956         fprintf(my_file, "\nLevel %s\n", level_name);
957
958         for (i=0; i<MAX_OBJECTS; i++)
959                 used_objects[i] = 0;
960
961         while (objects_processed < Highest_object_index+1) {
962                 int     j, objtype, objid, objcount, cur_obj_val, min_obj_val, min_objnum;
963
964                 //      Find new min objnum.
965                 min_obj_val = 0x7fff0000;
966                 min_objnum = -1;
967
968                 for (j=0; j<=Highest_object_index; j++) {
969                         if (!used_objects[j] && Objects[j].type!=OBJ_NONE) {
970                                 cur_obj_val = Objects[j].type * 1000 + Objects[j].id;
971                                 if (cur_obj_val < min_obj_val) {
972                                         min_objnum = j;
973                                         min_obj_val = cur_obj_val;
974                                 }
975                         }
976                 }
977                 if ((min_objnum == -1) || (Objects[min_objnum].type == 255))
978                         break;
979
980                 objcount = 0;
981
982                 objtype = Objects[min_objnum].type;
983                 objid = Objects[min_objnum].id;
984
985                 for (i=0; i<=Highest_object_index; i++) {
986                         if (!used_objects[i]) {
987
988                                 if (((Objects[i].type == objtype) && (Objects[i].id == objid)) ||
989                                                 ((Objects[i].type == objtype) && (objtype == OBJ_PLAYER)) ||
990                                                 ((Objects[i].type == objtype) && (objtype == OBJ_COOP)) ||
991                                                 ((Objects[i].type == objtype) && (objtype == OBJ_HOSTAGE))) {
992                                         if (Objects[i].type == OBJ_ROBOT)
993                                                 total_robots++;
994                                         used_objects[i] = 1;
995                                         objcount++;
996                                         objects_processed++;
997                                 }
998                         }
999                 }
1000
1001                 if (objcount) {
1002                         fprintf(my_file, "Object: ");
1003                         fprintf(my_file, "%8s %8s %3i\n", object_types(min_objnum), object_ids(min_objnum), objcount);
1004                 }
1005         }
1006
1007         fprintf(my_file, "Total robots = %3i\n", total_robots);
1008 }
1009
1010 int     First_dump_level = 0;
1011 int     Last_dump_level = NUM_ADAM_LEVELS-1;
1012
1013 // ----------------------------------------------------------------------------
1014 void say_totals_all(void)
1015 {
1016         int     i;
1017         FILE    *my_file;
1018
1019         my_file = fopen( "levels.all", "wt" );
1020         // -- mprintf((1, "Fileno = %i\n", fileno(my_file)));
1021
1022         if (!my_file)   {
1023                 char  ErrorMessage[200];
1024
1025                 sprintf( ErrorMessage, "ERROR: Unable to open levels.all\nErrno=%i", errno );
1026                 stop_time();
1027                 gr_palette_load(gr_palette);
1028                 nm_messagebox( NULL, 1, "Ok", ErrorMessage );
1029                 start_time();
1030
1031                 return;
1032         }
1033
1034         for (i=First_dump_level; i<=Last_dump_level; i++) {
1035                 mprintf((0, "Level %i\n", i+1));
1036                 load_level(Adam_level_names[i]);
1037                 say_totals(my_file, Adam_level_names[i]);
1038         }
1039
1040 //--05/17/95--  for (i=0; i<NUM_SHAREWARE_LEVELS; i++) {
1041 //--05/17/95--          mprintf((0, "Level %i\n", i+1));
1042 //--05/17/95--          load_level(Shareware_level_names[i]);
1043 //--05/17/95--          say_totals(my_file, Shareware_level_names[i]);
1044 //--05/17/95--  }
1045 //--05/17/95--
1046 //--05/17/95--  for (i=0; i<NUM_REGISTERED_LEVELS; i++) {
1047 //--05/17/95--          mprintf((0, "Level %i\n", i+1+NUM_SHAREWARE_LEVELS));
1048 //--05/17/95--          load_level(Registered_level_names[i]);
1049 //--05/17/95--          say_totals(my_file, Registered_level_names[i]);
1050 //--05/17/95--  }
1051
1052         fclose(my_file);
1053
1054 }
1055
1056 void dump_used_textures_level(FILE *my_file, int level_num)
1057 {
1058         int     i;
1059         int     temp_tmap_buf[MAX_BITMAP_FILES];
1060         int     perm_tmap_buf[MAX_BITMAP_FILES];
1061         sbyte level_tmap_buf[MAX_BITMAP_FILES];
1062         int     temp_wall_buf[MAX_BITMAP_FILES];
1063         int     perm_wall_buf[MAX_BITMAP_FILES];
1064
1065         for (i=0; i<MAX_BITMAP_FILES; i++) {
1066                 perm_tmap_buf[i] = 0;
1067                 level_tmap_buf[i] = -1;
1068         }
1069
1070         for (i=0; i<MAX_BITMAP_FILES; i++) {
1071                 perm_wall_buf[i] = 0;
1072         }
1073
1074         determine_used_textures_level(0, 1, level_num, temp_tmap_buf, temp_wall_buf, level_tmap_buf, MAX_BITMAP_FILES);
1075 // --   determine_used_textures_robots(temp_tmap_buf);
1076         fprintf(my_file, "\nTextures used in [%s]\n", Gamesave_current_filename);
1077         say_used_tmaps(my_file, temp_tmap_buf);
1078 }
1079
1080 FILE    *my_file;
1081
1082 // ----------------------------------------------------------------------------
1083 void dump_used_textures_all(void)
1084 {
1085         int     i;
1086         int     temp_tmap_buf[MAX_BITMAP_FILES];
1087         int     perm_tmap_buf[MAX_BITMAP_FILES];
1088         sbyte level_tmap_buf[MAX_BITMAP_FILES];
1089         int     temp_wall_buf[MAX_BITMAP_FILES];
1090         int     perm_wall_buf[MAX_BITMAP_FILES];
1091
1092 say_totals_all();
1093
1094         my_file = fopen( "textures.dmp", "wt" );
1095         // -- mprintf((1, "Fileno = %i\n", fileno(my_file)));
1096
1097         if (!my_file)   {
1098                 char  ErrorMessage[200];
1099
1100                 sprintf( ErrorMessage, "ERROR: Can't open textures.dmp\nErrno=%i", errno);
1101                 stop_time();
1102                 gr_palette_load(gr_palette);
1103                 nm_messagebox( NULL, 1, "Ok", ErrorMessage );
1104                 start_time();
1105
1106                 return;
1107         }
1108
1109         for (i=0; i<MAX_BITMAP_FILES; i++) {
1110                 perm_tmap_buf[i] = 0;
1111                 level_tmap_buf[i] = -1;
1112         }
1113
1114         for (i=0; i<MAX_BITMAP_FILES; i++) {
1115                 perm_wall_buf[i] = 0;
1116         }
1117
1118 // --05/17/95-- for (i=0; i<NUM_SHAREWARE_LEVELS; i++) {
1119 // --05/17/95--         determine_used_textures_level(1, 1, i, temp_tmap_buf, temp_wall_buf, level_tmap_buf, MAX_BITMAP_FILES);
1120 // --05/17/95--         fprintf(my_file, "\nTextures used in [%s]\n", Shareware_level_names[i]);
1121 // --05/17/95--         say_used_tmaps(my_file, temp_tmap_buf);
1122 // --05/17/95--         merge_buffers(perm_tmap_buf, temp_tmap_buf, MAX_BITMAP_FILES);
1123 // --05/17/95--         merge_buffers(perm_wall_buf, temp_wall_buf, MAX_BITMAP_FILES);
1124 // --05/17/95-- }
1125 // --05/17/95--
1126 // --05/17/95-- fprintf(my_file, "\n\nUsed textures in all shareware mines:\n");
1127 // --05/17/95-- say_used_tmaps(my_file, perm_tmap_buf);
1128 // --05/17/95--
1129 // --05/17/95-- fprintf(my_file, "\nUnused textures in all shareware mines:\n");
1130 // --05/17/95-- say_unused_tmaps(my_file, perm_tmap_buf);
1131 // --05/17/95--
1132 // --05/17/95-- fprintf(my_file, "\nTextures used exactly once in all shareware mines:\n");
1133 // --05/17/95-- say_used_once_tmaps(my_file, perm_tmap_buf, level_tmap_buf);
1134 // --05/17/95--
1135 // --05/17/95-- fprintf(my_file, "\nWall anims (eg, doors) unused in all shareware mines:\n");
1136 // --05/17/95-- say_unused_walls(my_file, perm_wall_buf);
1137
1138 // --05/17/95-- for (i=0; i<NUM_REGISTERED_LEVELS; i++) {
1139 // --05/17/95--         determine_used_textures_level(1, 0, i, temp_tmap_buf, temp_wall_buf, level_tmap_buf, MAX_BITMAP_FILES);
1140 // --05/17/95--         fprintf(my_file, "\nTextures used in [%s]\n", Registered_level_names[i]);
1141 // --05/17/95--         say_used_tmaps(my_file, temp_tmap_buf);
1142 // --05/17/95--         merge_buffers(perm_tmap_buf, temp_tmap_buf, MAX_BITMAP_FILES);
1143 // --05/17/95-- }
1144 // --05/17/95--
1145 // --05/17/95-- fprintf(my_file, "\n\nUsed textures in all (including registered) mines:\n");
1146 // --05/17/95-- say_used_tmaps(my_file, perm_tmap_buf);
1147 // --05/17/95--
1148 // --05/17/95-- fprintf(my_file, "\nUnused textures in all (including registered) mines:\n");
1149 // --05/17/95-- say_unused_tmaps(my_file, perm_tmap_buf);
1150
1151         for (i=First_dump_level; i<=Last_dump_level; i++) {
1152                 determine_used_textures_level(1, 0, i, temp_tmap_buf, temp_wall_buf, level_tmap_buf, MAX_BITMAP_FILES);
1153                 fprintf(my_file, "\nTextures used in [%s]\n", Adam_level_names[i]);
1154                 say_used_tmaps(my_file, temp_tmap_buf);
1155                 merge_buffers(perm_tmap_buf, temp_tmap_buf, MAX_BITMAP_FILES);
1156         }
1157
1158         fprintf(my_file, "\n\nUsed textures in all (including registered) mines:\n");
1159         say_used_tmaps(my_file, perm_tmap_buf);
1160
1161         fprintf(my_file, "\nUnused textures in all (including registered) mines:\n");
1162         say_unused_tmaps(my_file, perm_tmap_buf);
1163
1164         fclose(my_file);
1165 }
1166
1167 #endif