2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
16 * Functions to dump text description of mine.
17 * An editor-only function, called at mine load time.
18 * To be read by a human to verify the correctness and completeness of a mine.
39 #include "editor/editor.h"
62 extern ubyte bogus_data[64*64];
64 void dump_used_textures_level(FILE *my_file, int level_num);
65 void say_totals(FILE *my_file, char *level_name);
67 // ----------------------------------------------------------------------------
68 char *object_types(int objnum)
70 int type = Objects[objnum].type;
72 Assert((type >= 0) && (type < MAX_OBJECT_TYPES));
73 return Object_type_names[type];
76 // ----------------------------------------------------------------------------
77 char *object_ids(int objnum)
79 int type = Objects[objnum].type;
80 int id = Objects[objnum].id;
84 return Robot_names[id];
87 return Powerup_names[id];
94 void err_printf(FILE *my_file, char * format, ... )
99 va_start(args, format );
100 vsprintf(message,format,args);
103 mprintf((1, "%s", message));
104 fprintf(my_file, "%s", message);
108 void warning_printf(FILE *my_file, char * format, ... )
113 va_start(args, format );
114 vsprintf(message,format,args);
117 mprintf((0, "%s", message));
118 fprintf(my_file, "%s", message);
121 // ----------------------------------------------------------------------------
122 void write_exit_text(FILE *my_file)
126 fprintf(my_file, "-----------------------------------------------------------------------------\n");
127 fprintf(my_file, "Exit stuff\n");
129 // ---------- Find exit triggers ----------
131 for (i=0; i<Num_triggers; i++)
132 if (Triggers[i].type == TT_EXIT) {
135 fprintf(my_file, "Trigger %2i, is an exit trigger with %i links.\n", i, Triggers[i].num_links);
137 if (Triggers[i].num_links != 0)
138 err_printf(my_file, "Error: Exit triggers must have 0 links, this one has %i links.\n", Triggers[i].num_links);
140 // Find wall pointing to this trigger.
142 for (j=0; j<Num_walls; j++)
143 if (Walls[j].trigger == i) {
145 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);
148 err_printf(my_file, "Error: Trigger %i is not bound to any wall.\n", i);
150 err_printf(my_file, "Error: Trigger %i is bound to %i walls.\n", i, count2);
155 err_printf(my_file, "Error: No exit trigger in this mine.\n");
157 err_printf(my_file, "Error: More than one exit trigger in this mine.\n");
159 fprintf(my_file, "\n");
161 // ---------- Find exit doors ----------
163 for (i=0; i<=Highest_segment_index; i++)
164 for (j=0; j<MAX_SIDES_PER_SEGMENT; j++)
165 if (Segments[i].children[j] == -2) {
166 fprintf(my_file, "Segment %3i, side %i is an exit door.\n", i, j);
171 err_printf(my_file, "Error: No external wall in this mine.\n");
172 else if (count != 1) {
173 // -- warning_printf(my_file, "Warning: %i external walls in this mine.\n", count);
174 // -- warning_printf(my_file, "(If %i are secret exits, then no problem.)\n", count-1);
176 fprintf(my_file, "\n");
179 // ----------------------------------------------------------------------------
180 void write_key_text(FILE *my_file)
183 int red_count, blue_count, gold_count;
184 int red_count2, blue_count2, gold_count2;
185 int blue_segnum=-1, blue_sidenum=-1, red_segnum=-1, red_sidenum=-1, gold_segnum=-1, gold_sidenum=-1;
188 fprintf(my_file, "-----------------------------------------------------------------------------\n");
189 fprintf(my_file, "Key stuff:\n");
195 for (i=0; i<Num_walls; i++) {
196 if (Walls[i].keys & KEY_BLUE) {
197 fprintf(my_file, "Wall %i (seg=%i, side=%i) is keyed to the blue key.\n", i, Walls[i].segnum, Walls[i].sidenum);
198 if (blue_segnum == -1) {
199 blue_segnum = Walls[i].segnum;
200 blue_sidenum = Walls[i].sidenum;
203 connect_side = find_connect_side(&Segments[Walls[i].segnum], &Segments[blue_segnum]);
204 if (connect_side != blue_sidenum) {
205 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);
210 if (Walls[i].keys & KEY_RED) {
211 fprintf(my_file, "Wall %i (seg=%i, side=%i) is keyed to the red key.\n", i, Walls[i].segnum, Walls[i].sidenum);
212 if (red_segnum == -1) {
213 red_segnum = Walls[i].segnum;
214 red_sidenum = Walls[i].sidenum;
217 connect_side = find_connect_side(&Segments[Walls[i].segnum], &Segments[red_segnum]);
218 if (connect_side != red_sidenum) {
219 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);
224 if (Walls[i].keys & KEY_GOLD) {
225 fprintf(my_file, "Wall %i (seg=%i, side=%i) is keyed to the gold key.\n", i, Walls[i].segnum, Walls[i].sidenum);
226 if (gold_segnum == -1) {
227 gold_segnum = Walls[i].segnum;
228 gold_sidenum = Walls[i].sidenum;
231 connect_side = find_connect_side(&Segments[Walls[i].segnum], &Segments[gold_segnum]);
232 if (connect_side != gold_sidenum) {
233 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);
241 warning_printf(my_file, "Warning: %i doors are keyed to the blue key.\n", blue_count);
244 warning_printf(my_file, "Warning: %i doors are keyed to the red key.\n", red_count);
247 warning_printf(my_file, "Warning: %i doors are keyed to the gold key.\n", gold_count);
253 for (i=0; i<=Highest_object_index; i++) {
254 if (Objects[i].type == OBJ_POWERUP)
255 if (Objects[i].id == POW_KEY_BLUE) {
256 fprintf(my_file, "The BLUE key is object %i in segment %i\n", i, Objects[i].segnum);
259 if (Objects[i].type == OBJ_POWERUP)
260 if (Objects[i].id == POW_KEY_RED) {
261 fprintf(my_file, "The RED key is object %i in segment %i\n", i, Objects[i].segnum);
264 if (Objects[i].type == OBJ_POWERUP)
265 if (Objects[i].id == POW_KEY_GOLD) {
266 fprintf(my_file, "The GOLD key is object %i in segment %i\n", i, Objects[i].segnum);
270 if (Objects[i].contains_count) {
271 if (Objects[i].contains_type == OBJ_POWERUP) {
272 switch (Objects[i].contains_id) {
274 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);
275 blue_count2 += Objects[i].contains_count;
278 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);
279 gold_count2 += Objects[i].contains_count;
282 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);
283 red_count2 += Objects[i].contains_count;
293 if (blue_count2 == 0)
294 err_printf(my_file, "Error: There is a door keyed to the blue key, but no blue key!\n");
298 err_printf(my_file, "Error: There is a door keyed to the red key, but no red key!\n");
301 if (gold_count2 == 0)
302 err_printf(my_file, "Error: There is a door keyed to the gold key, but no gold key!\n");
305 err_printf(my_file, "Error: There are %i blue keys!\n", blue_count2);
308 err_printf(my_file, "Error: There are %i red keys!\n", red_count2);
311 err_printf(my_file, "Error: There are %i gold keys!\n", gold_count2);
314 // ----------------------------------------------------------------------------
315 void write_control_center_text(FILE *my_file)
317 int i, count, objnum, count2;
319 fprintf(my_file, "-----------------------------------------------------------------------------\n");
320 fprintf(my_file, "Control Center stuff:\n");
323 for (i=0; i<=Highest_segment_index; i++)
324 if (Segment2s[i].special == SEGMENT_IS_CONTROLCEN) {
326 fprintf(my_file, "Segment %3i is a control center.\n", i);
327 objnum = Segments[i].objects;
329 while (objnum != -1) {
330 if (Objects[objnum].type == OBJ_CNTRLCEN)
332 objnum = Objects[objnum].next;
335 fprintf(my_file, "No control center object in control center segment.\n");
336 else if (count2 != 1)
337 fprintf(my_file, "%i control center objects in control center segment.\n", count2);
341 err_printf(my_file, "Error: No control center in this mine.\n");
343 err_printf(my_file, "Error: More than one control center in this mine.\n");
346 // ----------------------------------------------------------------------------
347 void write_fuelcen_text(FILE *my_file)
351 fprintf(my_file, "-----------------------------------------------------------------------------\n");
352 fprintf(my_file, "Fuel Center stuff: (Note: This means fuel, repair, materialize, control centers!)\n");
354 for (i=0; i<Num_fuelcenters; i++) {
355 fprintf(my_file, "Fuelcenter %i: Type=%i (%s), segment = %3i\n", i, Station[i].Type, Special_names[Station[i].Type], Station[i].segnum);
356 if (Segment2s[Station[i].segnum].special != Station[i].Type)
357 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 void write_segment_text(FILE *my_file)
366 fprintf(my_file, "-----------------------------------------------------------------------------\n");
367 fprintf(my_file, "Segment stuff:\n");
369 for (i=0; i<=Highest_segment_index; i++) {
371 fprintf(my_file, "Segment %4i: ", i);
372 if (Segment2s[i].special != 0)
373 fprintf(my_file, "special = %3i (%s), value = %3i ", Segment2s[i].special, Special_names[Segment2s[i].special], Segment2s[i].value);
375 if (Segment2s[i].matcen_num != -1)
376 fprintf(my_file, "matcen = %3i, ", Segment2s[i].matcen_num);
378 fprintf(my_file, "\n");
381 for (i=0; i<=Highest_segment_index; i++) {
384 objnum = Segments[i].objects;
385 fprintf(my_file, "Segment %4i: ", i);
388 fprintf(my_file, "Objects: ");
389 while (objnum != -1) {
390 fprintf(my_file, "[%8s %8s %3i] ", object_types(objnum), object_ids(objnum), objnum);
391 objnum = Objects[objnum].next;
393 fprintf(my_file, "\nAborted after %i links\n", depth);
398 fprintf(my_file, "\n");
402 // ----------------------------------------------------------------------------
403 // This routine is bogus. It assumes that all centers are matcens,
404 // which is not true. The setting of segnum is bogus.
405 void write_matcen_text(FILE *my_file)
409 fprintf(my_file, "-----------------------------------------------------------------------------\n");
410 fprintf(my_file, "Materialization centers:\n");
411 for (i=0; i<Num_robot_centers; i++) {
412 int trigger_count=0, segnum, fuelcen_num;
414 fprintf(my_file, "FuelCenter[%02i].Segment = %04i ", i, Station[i].segnum);
415 fprintf(my_file, "Segment2[%04i].matcen_num = %02i ", Station[i].segnum, Segment2s[Station[i].segnum].matcen_num);
417 fuelcen_num = RobotCenters[i].fuelcen_num;
418 if (Station[fuelcen_num].Type != SEGMENT_IS_ROBOTMAKER)
419 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]);
421 segnum = Station[fuelcen_num].segnum;
423 // Find trigger for this materialization center.
424 for (j=0; j<Num_triggers; j++) {
425 if (Triggers[j].type == TT_MATCEN) {
426 for (k=0; k<Triggers[j].num_links; k++)
427 if (Triggers[j].seg[k] == segnum) {
428 fprintf(my_file, "Trigger = %2i ", j );
433 fprintf(my_file, "\n");
435 if (trigger_count == 0)
436 err_printf(my_file, "Error: Matcen %i in segment %i has no trigger!\n", i, segnum);
441 // ----------------------------------------------------------------------------
442 void write_wall_text(FILE *my_file)
445 sbyte wall_flags[MAX_WALLS];
447 fprintf(my_file, "-----------------------------------------------------------------------------\n");
448 fprintf(my_file, "Walls:\n");
449 for (i=0; i<Num_walls; i++) {
452 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,
453 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);
455 if (Walls[i].trigger >= Num_triggers)
456 fprintf(my_file, "Wall %03d points to invalid trigger %d\n",i,Walls[i].trigger);
458 segnum = Walls[i].segnum;
459 sidenum = Walls[i].sidenum;
461 if (Segments[segnum].sides[sidenum].wall_num != i)
462 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);
465 for (i=0; i<MAX_WALLS; i++)
468 for (i=0; i<=Highest_segment_index; i++) {
469 segment *segp = &Segments[i];
470 for (j=0; j<MAX_SIDES_PER_SEGMENT; j++) {
471 side *sidep = &segp->sides[j];
472 if (sidep->wall_num != -1)
474 if (wall_flags[sidep->wall_num])
475 err_printf(my_file, "Error: Wall %i appears in two or more segments, including segment %i, side %i.\n", sidep->wall_num, i, j);
477 wall_flags[sidep->wall_num] = 1;
484 //typedef struct trigger {
491 // short seg[MAX_WALLS_PER_LINK];
492 // short side[MAX_WALLS_PER_LINK];
495 // ----------------------------------------------------------------------------
496 void write_player_text(FILE *my_file)
498 int i, num_players=0;
500 fprintf(my_file, "-----------------------------------------------------------------------------\n");
501 fprintf(my_file, "Players:\n");
502 for (i=0; i<=Highest_object_index; i++) {
503 if (Objects[i].type == OBJ_PLAYER) {
505 fprintf(my_file, "Player %2i is object #%3i in segment #%3i.\n", Objects[i].id, i, Objects[i].segnum);
509 if (num_players != MAX_PLAYERS)
510 err_printf(my_file, "Error: %i player objects. %i are required.\n", num_players, MAX_PLAYERS);
511 if (num_players > MAX_MULTI_PLAYERS)
512 err_printf(my_file, "Error: %i player objects. %i are required.\n", num_players, MAX_PLAYERS);
515 // ----------------------------------------------------------------------------
516 void write_trigger_text(FILE *my_file)
520 fprintf(my_file, "-----------------------------------------------------------------------------\n");
521 fprintf(my_file, "Triggers:\n");
522 for (i=0; i<Num_triggers; i++) {
523 fprintf(my_file, "Trigger %03i: type=%02x flags=%04x, value=%08x, time=%8x, num_links=%i ", i,
524 Triggers[i].type, Triggers[i].flags, Triggers[i].value, Triggers[i].time, Triggers[i].num_links);
526 for (j=0; j<Triggers[i].num_links; j++)
527 fprintf(my_file, "[%03i:%i] ", Triggers[i].seg[j], Triggers[i].side[j]);
529 // Find which wall this trigger is connected to.
530 for (w=0; w<Num_walls; w++)
531 if (Walls[w].trigger == i)
535 err_printf(my_file, "\nError: Trigger %i is not connected to any wall, so it can never be triggered.\n", i);
537 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);
543 // ----------------------------------------------------------------------------
544 void write_game_text_file(char *filename)
546 char my_filename[128];
552 // mprintf((0, "Writing text file for mine [%s]\n", filename));
554 namelen = strlen(filename);
556 Assert (namelen > 4);
558 Assert (filename[namelen-4] == '.');
560 strcpy(my_filename, filename);
561 strcpy( &my_filename[namelen-4], ".txm");
563 // mprintf((0, "Writing text file [%s]\n", my_filename));
565 my_file = fopen( my_filename, "wt" );
566 // -- mprintf((1, "Fileno = %i\n", fileno(my_file)));
569 char ErrorMessage[200];
571 sprintf(ErrorMessage, "ERROR: Unable to open %s\nErrno = %i", my_filename, errno);
573 gr_palette_load(gr_palette);
574 nm_messagebox( NULL, 1, "Ok", ErrorMessage );
580 dump_used_textures_level(my_file, 0);
581 say_totals(my_file, Gamesave_current_filename);
583 fprintf(my_file, "\nNumber of segments: %4i\n", Highest_segment_index+1);
584 fprintf(my_file, "Number of objects: %4i\n", Highest_object_index+1);
585 fprintf(my_file, "Number of walls: %4i\n", Num_walls);
586 fprintf(my_file, "Number of open doors: %4i\n", Num_open_doors);
587 fprintf(my_file, "Number of triggers: %4i\n", Num_triggers);
588 fprintf(my_file, "Number of matcens: %4i\n", Num_robot_centers);
589 fprintf(my_file, "\n");
591 write_segment_text(my_file);
593 write_fuelcen_text(my_file);
595 write_matcen_text(my_file);
597 write_player_text(my_file);
599 write_wall_text(my_file);
601 write_trigger_text(my_file);
603 write_exit_text(my_file);
605 // ---------- Find control center segment ----------
606 write_control_center_text(my_file);
608 // ---------- Show keyed walls ----------
609 write_key_text(my_file);
613 mprintf((1, "Close value = %i\n", r));
619 // -- // ---------------
620 // -- // Note: This only works for a loaded level because the objects array must be valid.
621 // -- void determine_used_textures_robots(int *tmap_buf)
626 // -- Assert(N_polygon_models);
628 // -- for (objnum=0; objnum <= Highest_object_index; objnum++) {
631 // -- if (Objects[objnum].render_type == RT_POLYOBJ) {
632 // -- model_num = Objects[objnum].rtype.pobj_info.model_num;
634 // -- po=&Polygon_models[model_num];
636 // -- for (i=0;i<po->n_textures;i++) {
639 // -- tli = ObjBitmaps[ObjBitmapPtrs[po->first_texture+i]];
640 // -- Assert((tli>=0) && (tli<= Num_tmaps));
641 // -- tmap_buf[tli]++;
648 // --05/17/95--// -----------------------------------------------------------------------------
649 // --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-- int segnum, sidenum;
652 // --05/17/95-- int i, j;
654 // --05/17/95-- for (i=0; i<max_tmap; i++)
655 // --05/17/95-- tmap_buf[i] = 0;
657 // --05/17/95-- if (load_level_flag) {
658 // --05/17/95-- if (shareware_flag)
659 // --05/17/95-- load_level(Shareware_level_names[level_num]);
661 // --05/17/95-- load_level(Registered_level_names[level_num]);
664 // --05/17/95-- for (segnum=0; segnum<=Highest_segment_index; segnum++) {
665 // --05/17/95-- segment *segp = &Segments[segnum];
667 // --05/17/95-- for (sidenum=0; sidenum<MAX_SIDES_PER_SEGMENT; sidenum++) {
668 // --05/17/95-- side *sidep = &segp->sides[sidenum];
670 // --05/17/95-- if (sidep->wall_num != -1) {
671 // --05/17/95-- int clip_num = Walls[sidep->wall_num].clip_num;
672 // --05/17/95-- if (clip_num != -1) {
674 // --05/17/95-- int num_frames = WallAnims[clip_num].num_frames;
676 // --05/17/95-- wall_buf[clip_num] = 1;
678 // --05/17/95-- for (j=0; j<num_frames; j++) {
679 // --05/17/95-- int tmap_num;
681 // --05/17/95-- tmap_num = WallAnims[clip_num].frames[j];
682 // --05/17/95-- tmap_buf[tmap_num]++;
683 // --05/17/95-- if (level_tmap_buf[tmap_num] == -1)
684 // --05/17/95-- level_tmap_buf[tmap_num] = level_num + (!shareware_flag) * NUM_SHAREWARE_LEVELS;
689 // --05/17/95-- if (sidep->tmap_num >= 0)
690 // --05/17/95-- if (sidep->tmap_num < max_tmap) {
691 // --05/17/95-- tmap_buf[sidep->tmap_num]++;
692 // --05/17/95-- if (level_tmap_buf[sidep->tmap_num] == -1)
693 // --05/17/95-- level_tmap_buf[sidep->tmap_num] = level_num + (!shareware_flag) * NUM_SHAREWARE_LEVELS;
694 // --05/17/95-- } else
695 // --05/17/95-- Int3(); // Error, bogus texture map. Should not be greater than max_tmap.
697 // --05/17/95-- if ((sidep->tmap_num2 & 0x3fff) != 0)
698 // --05/17/95-- if ((sidep->tmap_num2 & 0x3fff) < max_tmap) {
699 // --05/17/95-- tmap_buf[sidep->tmap_num2 & 0x3fff]++;
700 // --05/17/95-- if (level_tmap_buf[sidep->tmap_num2 & 0x3fff] == -1)
701 // --05/17/95-- level_tmap_buf[sidep->tmap_num2 & 0x3fff] = level_num + (!shareware_flag) * NUM_SHAREWARE_LEVELS;
702 // --05/17/95-- } else
703 // --05/17/95-- Int3(); // Error, bogus texture map. Should not be greater than max_tmap.
708 // Adam: Change NUM_ADAM_LEVELS to the number of levels.
709 #define NUM_ADAM_LEVELS 30
711 // Adam: Stick the names here.
712 char *Adam_level_names[NUM_ADAM_LEVELS] = {
750 typedef struct BitmapFile {
754 extern BitmapFile AllBitmaps[ MAX_BITMAP_FILES ];
756 int Ignore_tmap_num2_error;
758 // ----------------------------------------------------------------------------
759 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 int segnum, sidenum, objnum=max_tmap;
764 Assert(shareware_flag != -17);
766 for (i=0; i<MAX_BITMAP_FILES; i++)
769 if (load_level_flag) {
770 load_level(Adam_level_names[level_num]);
775 for (objnum=0; objnum<=Highest_object_index; objnum++) {
776 object *objp = &Objects[objnum];
778 if (objp->render_type == RT_POLYOBJ) {
779 polymodel *po = &Polygon_models[objp->rtype.pobj_info.model_num];
781 for (i=0; i<po->n_textures; i++) {
783 int tli = ObjBitmaps[ObjBitmapPtrs[po->first_texture+i]].index;
784 // -- mprintf((0, "%s ", AllBitmaps[ObjBitmaps[ObjBitmapPtrs[po->first_texture+i]].index].name));
786 if ((tli < MAX_BITMAP_FILES) && (tli >= 0)) {
788 if (level_tmap_buf[tli] == -1)
789 level_tmap_buf[tli] = level_num;
791 Int3(); // Hmm, It seems this texture is bogus!
798 Ignore_tmap_num2_error = 0;
800 // Process walls and segment sides.
801 for (segnum=0; segnum<=Highest_segment_index; segnum++) {
802 segment *segp = &Segments[segnum];
804 for (sidenum=0; sidenum<MAX_SIDES_PER_SEGMENT; sidenum++) {
805 side *sidep = &segp->sides[sidenum];
807 if (sidep->wall_num != -1) {
808 int clip_num = Walls[sidep->wall_num].clip_num;
809 if (clip_num != -1) {
811 // -- int num_frames = WallAnims[clip_num].num_frames;
813 wall_buf[clip_num] = 1;
815 for (j=0; j<1; j++) { // Used to do through num_frames, but don't really want all the door01#3 stuff.
818 tmap_num = Textures[WallAnims[clip_num].frames[j]].index;
819 Assert((tmap_num >= 0) && (tmap_num < MAX_BITMAP_FILES));
820 tmap_buf[tmap_num]++;
821 if (level_tmap_buf[tmap_num] == -1)
822 level_tmap_buf[tmap_num] = level_num;
825 } else if (segp->children[sidenum] == -1) {
827 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;
835 Int3(); // Error, bogus texture map. Should not be greater than max_tmap.
838 if ((sidep->tmap_num2 & 0x3fff) != 0)
840 if ((sidep->tmap_num2 & 0x3fff) < MAX_BITMAP_FILES) {
841 Assert(Textures[sidep->tmap_num2 & 0x3fff].index < MAX_BITMAP_FILES);
842 tmap_buf[Textures[sidep->tmap_num2 & 0x3fff].index]++;
843 if (level_tmap_buf[Textures[sidep->tmap_num2 & 0x3fff].index] == -1)
844 level_tmap_buf[Textures[sidep->tmap_num2 & 0x3fff].index] = level_num;
846 if (!Ignore_tmap_num2_error)
847 Int3(); // Error, bogus texture map. Should not be greater than max_tmap.
848 Ignore_tmap_num2_error = 1;
849 sidep->tmap_num2 = 0;
857 // ----------------------------------------------------------------------------
858 void merge_buffers(int *dest, int *src, int num)
862 for (i=0; i<num; i++)
867 // ----------------------------------------------------------------------------
868 void say_used_tmaps(FILE *my_file, int *tb)
871 // -- mk, 08/14/95 -- int count = 0;
873 for (i=0; i<MAX_BITMAP_FILES; i++)
875 fprintf(my_file, "[%3i %8s (%4i)]\n", i, AllBitmaps[i].name, tb[i]);
876 // -- mk, 08/14/95 -- if (count++ >= 4) {
877 // -- mk, 08/14/95 -- fprintf(my_file, "\n");
878 // -- mk, 08/14/95 -- count = 0;
879 // -- mk, 08/14/95 -- }
883 // --05/17/95--// -----------------------------------------------------------------------------
884 // --05/17/95--void say_used_once_tmaps(FILE *my_file, int *tb, sbyte *tb_lnum)
886 // --05/17/95-- int i;
887 // --05/17/95-- char *level_name;
889 // --05/17/95-- for (i=0; i<Num_tmaps; i++)
890 // --05/17/95-- if (tb[i] == 1) {
891 // --05/17/95-- int level_num = tb_lnum[i];
892 // --05/17/95-- if (level_num >= NUM_SHAREWARE_LEVELS) {
893 // --05/17/95-- Assert((level_num - NUM_SHAREWARE_LEVELS >= 0) && (level_num - NUM_SHAREWARE_LEVELS < NUM_REGISTERED_LEVELS));
894 // --05/17/95-- level_name = Registered_level_names[level_num - NUM_SHAREWARE_LEVELS];
895 // --05/17/95-- } else {
896 // --05/17/95-- Assert((level_num >= 0) && (level_num < NUM_SHAREWARE_LEVELS));
897 // --05/17/95-- level_name = Shareware_level_names[level_num];
900 // --05/17/95-- fprintf(my_file, "Texture %3i %8s used only once on level %s\n", i, TmapInfo[i].filename, level_name);
904 // ----------------------------------------------------------------------------
905 void say_used_once_tmaps(FILE *my_file, int *tb, sbyte *tb_lnum)
910 for (i=0; i<MAX_BITMAP_FILES; i++)
912 int level_num = tb_lnum[i];
913 level_name = Adam_level_names[level_num];
915 fprintf(my_file, "Texture %3i %8s used only once on level %s\n", i, AllBitmaps[i].name, level_name);
919 // ----------------------------------------------------------------------------
920 void say_unused_tmaps(FILE *my_file, int *tb)
925 for (i=0; i<MAX_BITMAP_FILES; i++)
927 if (GameBitmaps[Textures[i].index].bm_data == bogus_data)
928 fprintf(my_file, "U");
930 fprintf(my_file, " ");
932 fprintf(my_file, "[%3i %8s] ", i, AllBitmaps[i].name);
934 fprintf(my_file, "\n");
940 // ----------------------------------------------------------------------------
941 void say_unused_walls(FILE *my_file, int *tb)
945 for (i=0; i<Num_wall_anims; i++)
947 fprintf(my_file, "Wall %3i is unused.\n", i);
950 // ----------------------------------------------------------------------------
951 void say_totals(FILE *my_file, char *level_name)
954 int total_robots = 0;
955 int objects_processed = 0;
957 int used_objects[MAX_OBJECTS];
959 fprintf(my_file, "\nLevel %s\n", level_name);
961 for (i=0; i<MAX_OBJECTS; i++)
964 while (objects_processed < Highest_object_index+1) {
965 int j, objtype, objid, objcount, cur_obj_val, min_obj_val, min_objnum;
967 // Find new min objnum.
968 min_obj_val = 0x7fff0000;
971 for (j=0; j<=Highest_object_index; j++) {
972 if (!used_objects[j] && Objects[j].type!=OBJ_NONE) {
973 cur_obj_val = Objects[j].type * 1000 + Objects[j].id;
974 if (cur_obj_val < min_obj_val) {
976 min_obj_val = cur_obj_val;
980 if ((min_objnum == -1) || (Objects[min_objnum].type == 255))
985 objtype = Objects[min_objnum].type;
986 objid = Objects[min_objnum].id;
988 for (i=0; i<=Highest_object_index; i++) {
989 if (!used_objects[i]) {
991 if (((Objects[i].type == objtype) && (Objects[i].id == objid)) ||
992 ((Objects[i].type == objtype) && (objtype == OBJ_PLAYER)) ||
993 ((Objects[i].type == objtype) && (objtype == OBJ_COOP)) ||
994 ((Objects[i].type == objtype) && (objtype == OBJ_HOSTAGE))) {
995 if (Objects[i].type == OBJ_ROBOT)
1005 fprintf(my_file, "Object: ");
1006 fprintf(my_file, "%8s %8s %3i\n", object_types(min_objnum), object_ids(min_objnum), objcount);
1010 fprintf(my_file, "Total robots = %3i\n", total_robots);
1013 int First_dump_level = 0;
1014 int Last_dump_level = NUM_ADAM_LEVELS-1;
1016 // ----------------------------------------------------------------------------
1017 void say_totals_all(void)
1022 my_file = fopen( "levels.all", "wt" );
1023 // -- mprintf((1, "Fileno = %i\n", fileno(my_file)));
1026 char ErrorMessage[200];
1028 sprintf( ErrorMessage, "ERROR: Unable to open levels.all\nErrno=%i", errno );
1030 gr_palette_load(gr_palette);
1031 nm_messagebox( NULL, 1, "Ok", ErrorMessage );
1037 for (i=First_dump_level; i<=Last_dump_level; i++) {
1038 mprintf((0, "Level %i\n", i+1));
1039 load_level(Adam_level_names[i]);
1040 say_totals(my_file, Adam_level_names[i]);
1043 //--05/17/95-- for (i=0; i<NUM_SHAREWARE_LEVELS; i++) {
1044 //--05/17/95-- mprintf((0, "Level %i\n", i+1));
1045 //--05/17/95-- load_level(Shareware_level_names[i]);
1046 //--05/17/95-- say_totals(my_file, Shareware_level_names[i]);
1049 //--05/17/95-- for (i=0; i<NUM_REGISTERED_LEVELS; i++) {
1050 //--05/17/95-- mprintf((0, "Level %i\n", i+1+NUM_SHAREWARE_LEVELS));
1051 //--05/17/95-- load_level(Registered_level_names[i]);
1052 //--05/17/95-- say_totals(my_file, Registered_level_names[i]);
1059 void dump_used_textures_level(FILE *my_file, int level_num)
1062 int temp_tmap_buf[MAX_BITMAP_FILES];
1063 int perm_tmap_buf[MAX_BITMAP_FILES];
1064 sbyte level_tmap_buf[MAX_BITMAP_FILES];
1065 int temp_wall_buf[MAX_BITMAP_FILES];
1066 int perm_wall_buf[MAX_BITMAP_FILES];
1068 for (i=0; i<MAX_BITMAP_FILES; i++) {
1069 perm_tmap_buf[i] = 0;
1070 level_tmap_buf[i] = -1;
1073 for (i=0; i<MAX_BITMAP_FILES; i++) {
1074 perm_wall_buf[i] = 0;
1077 determine_used_textures_level(0, 1, level_num, temp_tmap_buf, temp_wall_buf, level_tmap_buf, MAX_BITMAP_FILES);
1078 // -- determine_used_textures_robots(temp_tmap_buf);
1079 fprintf(my_file, "\nTextures used in [%s]\n", Gamesave_current_filename);
1080 say_used_tmaps(my_file, temp_tmap_buf);
1085 // ----------------------------------------------------------------------------
1086 void dump_used_textures_all(void)
1089 int temp_tmap_buf[MAX_BITMAP_FILES];
1090 int perm_tmap_buf[MAX_BITMAP_FILES];
1091 sbyte level_tmap_buf[MAX_BITMAP_FILES];
1092 int temp_wall_buf[MAX_BITMAP_FILES];
1093 int perm_wall_buf[MAX_BITMAP_FILES];
1097 my_file = fopen( "textures.dmp", "wt" );
1098 // -- mprintf((1, "Fileno = %i\n", fileno(my_file)));
1101 char ErrorMessage[200];
1103 sprintf( ErrorMessage, "ERROR: Can't open textures.dmp\nErrno=%i", errno);
1105 gr_palette_load(gr_palette);
1106 nm_messagebox( NULL, 1, "Ok", ErrorMessage );
1112 for (i=0; i<MAX_BITMAP_FILES; i++) {
1113 perm_tmap_buf[i] = 0;
1114 level_tmap_buf[i] = -1;
1117 for (i=0; i<MAX_BITMAP_FILES; i++) {
1118 perm_wall_buf[i] = 0;
1121 // --05/17/95-- for (i=0; i<NUM_SHAREWARE_LEVELS; i++) {
1122 // --05/17/95-- determine_used_textures_level(1, 1, i, temp_tmap_buf, temp_wall_buf, level_tmap_buf, MAX_BITMAP_FILES);
1123 // --05/17/95-- fprintf(my_file, "\nTextures used in [%s]\n", Shareware_level_names[i]);
1124 // --05/17/95-- say_used_tmaps(my_file, temp_tmap_buf);
1125 // --05/17/95-- merge_buffers(perm_tmap_buf, temp_tmap_buf, MAX_BITMAP_FILES);
1126 // --05/17/95-- merge_buffers(perm_wall_buf, temp_wall_buf, MAX_BITMAP_FILES);
1129 // --05/17/95-- fprintf(my_file, "\n\nUsed textures in all shareware mines:\n");
1130 // --05/17/95-- say_used_tmaps(my_file, perm_tmap_buf);
1132 // --05/17/95-- fprintf(my_file, "\nUnused textures in all shareware mines:\n");
1133 // --05/17/95-- say_unused_tmaps(my_file, perm_tmap_buf);
1135 // --05/17/95-- fprintf(my_file, "\nTextures used exactly once in all shareware mines:\n");
1136 // --05/17/95-- say_used_once_tmaps(my_file, perm_tmap_buf, level_tmap_buf);
1138 // --05/17/95-- fprintf(my_file, "\nWall anims (eg, doors) unused in all shareware mines:\n");
1139 // --05/17/95-- say_unused_walls(my_file, perm_wall_buf);
1141 // --05/17/95-- for (i=0; i<NUM_REGISTERED_LEVELS; i++) {
1142 // --05/17/95-- determine_used_textures_level(1, 0, i, temp_tmap_buf, temp_wall_buf, level_tmap_buf, MAX_BITMAP_FILES);
1143 // --05/17/95-- fprintf(my_file, "\nTextures used in [%s]\n", Registered_level_names[i]);
1144 // --05/17/95-- say_used_tmaps(my_file, temp_tmap_buf);
1145 // --05/17/95-- merge_buffers(perm_tmap_buf, temp_tmap_buf, MAX_BITMAP_FILES);
1148 // --05/17/95-- fprintf(my_file, "\n\nUsed textures in all (including registered) mines:\n");
1149 // --05/17/95-- say_used_tmaps(my_file, perm_tmap_buf);
1151 // --05/17/95-- fprintf(my_file, "\nUnused textures in all (including registered) mines:\n");
1152 // --05/17/95-- say_unused_tmaps(my_file, perm_tmap_buf);
1154 for (i=First_dump_level; i<=Last_dump_level; i++) {
1155 determine_used_textures_level(1, 0, i, temp_tmap_buf, temp_wall_buf, level_tmap_buf, MAX_BITMAP_FILES);
1156 fprintf(my_file, "\nTextures used in [%s]\n", Adam_level_names[i]);
1157 say_used_tmaps(my_file, temp_tmap_buf);
1158 merge_buffers(perm_tmap_buf, temp_tmap_buf, MAX_BITMAP_FILES);
1161 fprintf(my_file, "\n\nUsed textures in all (including registered) mines:\n");
1162 say_used_tmaps(my_file, perm_tmap_buf);
1164 fprintf(my_file, "\nUnused textures in all (including registered) mines:\n");
1165 say_unused_tmaps(my_file, perm_tmap_buf);