/* $Id: dumpmine.c,v 1.1.1.1 2006/03/17 19:54:55 zicodxx Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* * * Functions to dump text description of mine. * An editor-only function, called at mine load time. * To be read by a human to verify the correctness and completeness of a mine. * */ #ifdef HAVE_CONFIG_H #include #endif #ifdef RCS static char rcsid[] = "$Id: dumpmine.c,v 1.1.1.1 2006/03/17 19:54:55 zicodxx Exp $"; #endif #include #include #include #include #include "pstypes.h" #include "mono.h" #include "key.h" #include "gr.h" #include "palette.h" #include "inferno.h" #ifdef EDITOR #include "editor/editor.h" #endif #include "error.h" #include "object.h" #include "wall.h" #include "gamemine.h" #include "robot.h" #include "player.h" #include "newmenu.h" #include "textures.h" #include "bm.h" #include "menu.h" #include "switch.h" #include "fuelcen.h" #include "powerup.h" #include "gameseq.h" #include "polyobj.h" #include "gamesave.h" #ifdef EDITOR extern ubyte bogus_data[64*64]; void dump_used_textures_level(FILE *my_file, int level_num); void say_totals(FILE *my_file, char *level_name); // ---------------------------------------------------------------------------- char *object_types(int objnum) { int type = Objects[objnum].type; Assert((type >= 0) && (type < MAX_OBJECT_TYPES)); return Object_type_names[type]; } // ---------------------------------------------------------------------------- char *object_ids(int objnum) { int type = Objects[objnum].type; int id = Objects[objnum].id; switch (type) { case OBJ_ROBOT: return Robot_names[id]; break; case OBJ_POWERUP: return Powerup_names[id]; break; } return NULL; } void err_printf(FILE *my_file, char * format, ... ) { va_list args; char message[256]; va_start(args, format ); vsprintf(message,format,args); va_end(args); mprintf((1, "%s", message)); fprintf(my_file, "%s", message); Errors_in_mine++; } void warning_printf(FILE *my_file, char * format, ... ) { va_list args; char message[256]; va_start(args, format ); vsprintf(message,format,args); va_end(args); mprintf((0, "%s", message)); fprintf(my_file, "%s", message); } // ---------------------------------------------------------------------------- void write_exit_text(FILE *my_file) { int i, j, count; fprintf(my_file, "-----------------------------------------------------------------------------\n"); fprintf(my_file, "Exit stuff\n"); // ---------- Find exit triggers ---------- count=0; for (i=0; i 1) err_printf(my_file, "Error: Trigger %i is bound to %i walls.\n", i, count2); } if (count == 0) err_printf(my_file, "Error: No exit trigger in this mine.\n"); else if (count != 1) err_printf(my_file, "Error: More than one exit trigger in this mine.\n"); else fprintf(my_file, "\n"); // ---------- Find exit doors ---------- count = 0; for (i=0; i<=Highest_segment_index; i++) for (j=0; j 1) warning_printf(my_file, "Warning: %i doors are keyed to the blue key.\n", blue_count); if (red_count > 1) warning_printf(my_file, "Warning: %i doors are keyed to the red key.\n", red_count); if (gold_count > 1) warning_printf(my_file, "Warning: %i doors are keyed to the gold key.\n", gold_count); red_count2 = 0; blue_count2 = 0; gold_count2 = 0; for (i=0; i<=Highest_object_index; i++) { if (Objects[i].type == OBJ_POWERUP) if (Objects[i].id == POW_KEY_BLUE) { fprintf(my_file, "The BLUE key is object %i in segment %i\n", i, Objects[i].segnum); blue_count2++; } if (Objects[i].type == OBJ_POWERUP) if (Objects[i].id == POW_KEY_RED) { fprintf(my_file, "The RED key is object %i in segment %i\n", i, Objects[i].segnum); red_count2++; } if (Objects[i].type == OBJ_POWERUP) if (Objects[i].id == POW_KEY_GOLD) { fprintf(my_file, "The GOLD key is object %i in segment %i\n", i, Objects[i].segnum); gold_count2++; } if (Objects[i].contains_count) { if (Objects[i].contains_type == OBJ_POWERUP) { switch (Objects[i].contains_id) { case POW_KEY_BLUE: 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); blue_count2 += Objects[i].contains_count; break; case POW_KEY_GOLD: 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); gold_count2 += Objects[i].contains_count; break; case POW_KEY_RED: 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); red_count2 += Objects[i].contains_count; break; default: break; } } } } if (blue_count) if (blue_count2 == 0) err_printf(my_file, "Error: There is a door keyed to the blue key, but no blue key!\n"); if (red_count) if (red_count2 == 0) err_printf(my_file, "Error: There is a door keyed to the red key, but no red key!\n"); if (gold_count) if (gold_count2 == 0) err_printf(my_file, "Error: There is a door keyed to the gold key, but no gold key!\n"); if (blue_count2 > 1) err_printf(my_file, "Error: There are %i blue keys!\n", blue_count2); if (red_count2 > 1) err_printf(my_file, "Error: There are %i red keys!\n", red_count2); if (gold_count2 > 1) err_printf(my_file, "Error: There are %i gold keys!\n", gold_count2); } // ---------------------------------------------------------------------------- void write_control_center_text(FILE *my_file) { int i, count, objnum, count2; fprintf(my_file, "-----------------------------------------------------------------------------\n"); fprintf(my_file, "Control Center stuff:\n"); count = 0; for (i=0; i<=Highest_segment_index; i++) if (Segment2s[i].special == SEGMENT_IS_CONTROLCEN) { count++; fprintf(my_file, "Segment %3i is a control center.\n", i); objnum = Segments[i].objects; count2 = 0; while (objnum != -1) { if (Objects[objnum].type == OBJ_CNTRLCEN) count2++; objnum = Objects[objnum].next; } if (count2 == 0) fprintf(my_file, "No control center object in control center segment.\n"); else if (count2 != 1) fprintf(my_file, "%i control center objects in control center segment.\n", count2); } if (count == 0) err_printf(my_file, "Error: No control center in this mine.\n"); else if (count != 1) err_printf(my_file, "Error: More than one control center in this mine.\n"); } // ---------------------------------------------------------------------------- void write_fuelcen_text(FILE *my_file) { int i; fprintf(my_file, "-----------------------------------------------------------------------------\n"); fprintf(my_file, "Fuel Center stuff: (Note: This means fuel, repair, materialize, control centers!)\n"); for (i=0; i 30) { fprintf(my_file, "\nAborted after %i links\n", depth); break; } } } fprintf(my_file, "\n"); } } // ---------------------------------------------------------------------------- // This routine is bogus. It assumes that all centers are matcens, // which is not true. The setting of segnum is bogus. void write_matcen_text(FILE *my_file) { int i, j, k; fprintf(my_file, "-----------------------------------------------------------------------------\n"); fprintf(my_file, "Materialization centers:\n"); for (i=0; i> 16, Walls[i].trigger, Walls[i].clip_num, Walls[i].keys, Walls[i].state); if (Walls[i].trigger >= Num_triggers) fprintf(my_file, "Wall %03d points to invalid trigger %d\n",i,Walls[i].trigger); segnum = Walls[i].segnum; sidenum = Walls[i].sidenum; if (Segments[segnum].sides[sidenum].wall_num != i) 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); } for (i=0; isides[j]; if (sidep->wall_num != -1) { if (wall_flags[sidep->wall_num]) err_printf(my_file, "Error: Wall %i appears in two or more segments, including segment %i, side %i.\n", sidep->wall_num, i, j); else wall_flags[sidep->wall_num] = 1; } } } } //typedef struct trigger { // sbyte type; // short flags; // fix value; // fix time; // sbyte link_num; // short num_links; // short seg[MAX_WALLS_PER_LINK]; // short side[MAX_WALLS_PER_LINK]; // } trigger; // ---------------------------------------------------------------------------- void write_player_text(FILE *my_file) { int i, num_players=0; fprintf(my_file, "-----------------------------------------------------------------------------\n"); fprintf(my_file, "Players:\n"); for (i=0; i<=Highest_object_index; i++) { if (Objects[i].type == OBJ_PLAYER) { num_players++; fprintf(my_file, "Player %2i is object #%3i in segment #%3i.\n", Objects[i].id, i, Objects[i].segnum); } } if (num_players != MAX_PLAYERS) err_printf(my_file, "Error: %i player objects. %i are required.\n", num_players, MAX_PLAYERS); if (num_players > MAX_MULTI_PLAYERS) err_printf(my_file, "Error: %i player objects. %i are required.\n", num_players, MAX_PLAYERS); } // ---------------------------------------------------------------------------- void write_trigger_text(FILE *my_file) { int i, j, w; fprintf(my_file, "-----------------------------------------------------------------------------\n"); fprintf(my_file, "Triggers:\n"); for (i=0; i 4); Assert (filename[namelen-4] == '.'); strcpy(my_filename, filename); strcpy( &my_filename[namelen-4], ".txm"); // mprintf((0, "Writing text file [%s]\n", my_filename)); my_file = fopen( my_filename, "wt" ); // -- mprintf((1, "Fileno = %i\n", fileno(my_file))); if (!my_file) { char ErrorMessage[200]; sprintf(ErrorMessage, "ERROR: Unable to open %s\nErrno = %i", my_filename, errno); stop_time(); gr_palette_load(gr_palette); nm_messagebox( NULL, 1, "Ok", ErrorMessage ); start_time(); return; } dump_used_textures_level(my_file, 0); say_totals(my_file, Gamesave_current_filename); fprintf(my_file, "\nNumber of segments: %4i\n", Highest_segment_index+1); fprintf(my_file, "Number of objects: %4i\n", Highest_object_index+1); fprintf(my_file, "Number of walls: %4i\n", Num_walls); fprintf(my_file, "Number of open doors: %4i\n", Num_open_doors); fprintf(my_file, "Number of triggers: %4i\n", Num_triggers); fprintf(my_file, "Number of matcens: %4i\n", Num_robot_centers); fprintf(my_file, "\n"); write_segment_text(my_file); write_fuelcen_text(my_file); write_matcen_text(my_file); write_player_text(my_file); write_wall_text(my_file); write_trigger_text(my_file); write_exit_text(my_file); // ---------- Find control center segment ---------- write_control_center_text(my_file); // ---------- Show keyed walls ---------- write_key_text(my_file); { int r; r = fclose(my_file); mprintf((1, "Close value = %i\n", r)); if (r) Int3(); } } // -- // --------------- // -- // Note: This only works for a loaded level because the objects array must be valid. // -- void determine_used_textures_robots(int *tmap_buf) // -- { // -- int i, objnum; // -- polymodel *po; // -- // -- Assert(N_polygon_models); // -- // -- for (objnum=0; objnum <= Highest_object_index; objnum++) { // -- int model_num; // -- // -- if (Objects[objnum].render_type == RT_POLYOBJ) { // -- model_num = Objects[objnum].rtype.pobj_info.model_num; // -- // -- po=&Polygon_models[model_num]; // -- // -- for (i=0;in_textures;i++) { // -- int tli; // -- // -- tli = ObjBitmaps[ObjBitmapPtrs[po->first_texture+i]]; // -- Assert((tli>=0) && (tli<= Num_tmaps)); // -- tmap_buf[tli]++; // -- } // -- } // -- } // -- // -- } // --05/17/95--// ----------------------------------------------------------------------------- // --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) // --05/17/95--{ // --05/17/95-- int segnum, sidenum; // --05/17/95-- int i, j; // --05/17/95-- // --05/17/95-- for (i=0; isides[sidenum]; // --05/17/95-- // --05/17/95-- if (sidep->wall_num != -1) { // --05/17/95-- int clip_num = Walls[sidep->wall_num].clip_num; // --05/17/95-- if (clip_num != -1) { // --05/17/95-- // --05/17/95-- int num_frames = WallAnims[clip_num].num_frames; // --05/17/95-- // --05/17/95-- wall_buf[clip_num] = 1; // --05/17/95-- // --05/17/95-- for (j=0; jtmap_num >= 0) // --05/17/95-- if (sidep->tmap_num < max_tmap) { // --05/17/95-- tmap_buf[sidep->tmap_num]++; // --05/17/95-- if (level_tmap_buf[sidep->tmap_num] == -1) // --05/17/95-- level_tmap_buf[sidep->tmap_num] = level_num + (!shareware_flag) * NUM_SHAREWARE_LEVELS; // --05/17/95-- } else // --05/17/95-- Int3(); // Error, bogus texture map. Should not be greater than max_tmap. // --05/17/95-- // --05/17/95-- if ((sidep->tmap_num2 & 0x3fff) != 0) // --05/17/95-- if ((sidep->tmap_num2 & 0x3fff) < max_tmap) { // --05/17/95-- tmap_buf[sidep->tmap_num2 & 0x3fff]++; // --05/17/95-- if (level_tmap_buf[sidep->tmap_num2 & 0x3fff] == -1) // --05/17/95-- level_tmap_buf[sidep->tmap_num2 & 0x3fff] = level_num + (!shareware_flag) * NUM_SHAREWARE_LEVELS; // --05/17/95-- } else // --05/17/95-- Int3(); // Error, bogus texture map. Should not be greater than max_tmap. // --05/17/95-- } // --05/17/95-- } // --05/17/95--} // Adam: Change NUM_ADAM_LEVELS to the number of levels. #define NUM_ADAM_LEVELS 30 // Adam: Stick the names here. char *Adam_level_names[NUM_ADAM_LEVELS] = { "D2LEVA-1.LVL", "D2LEVA-2.LVL", "D2LEVA-3.LVL", "D2LEVA-4.LVL", "D2LEVA-S.LVL", "D2LEVB-1.LVL", "D2LEVB-2.LVL", "D2LEVB-3.LVL", "D2LEVB-4.LVL", "D2LEVB-S.LVL", "D2LEVC-1.LVL", "D2LEVC-2.LVL", "D2LEVC-3.LVL", "D2LEVC-4.LVL", "D2LEVC-S.LVL", "D2LEVD-1.LVL", "D2LEVD-2.LVL", "D2LEVD-3.LVL", "D2LEVD-4.LVL", "D2LEVD-S.LVL", "D2LEVE-1.LVL", "D2LEVE-2.LVL", "D2LEVE-3.LVL", "D2LEVE-4.LVL", "D2LEVE-S.LVL", "D2LEVF-1.LVL", "D2LEVF-2.LVL", "D2LEVF-3.LVL", "D2LEVF-4.LVL", "D2LEVF-S.LVL", }; typedef struct BitmapFile { char name[15]; } BitmapFile; extern BitmapFile AllBitmaps[ MAX_BITMAP_FILES ]; int Ignore_tmap_num2_error; // ---------------------------------------------------------------------------- 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) { int segnum, sidenum, objnum=max_tmap; int i, j; Assert(shareware_flag != -17); for (i=0; irender_type == RT_POLYOBJ) { polymodel *po = &Polygon_models[objp->rtype.pobj_info.model_num]; for (i=0; in_textures; i++) { int tli = ObjBitmaps[ObjBitmapPtrs[po->first_texture+i]].index; // -- mprintf((0, "%s ", AllBitmaps[ObjBitmaps[ObjBitmapPtrs[po->first_texture+i]].index].name)); if ((tli < MAX_BITMAP_FILES) && (tli >= 0)) { tmap_buf[tli]++; if (level_tmap_buf[tli] == -1) level_tmap_buf[tli] = level_num; } else Int3(); // Hmm, It seems this texture is bogus! } } } Ignore_tmap_num2_error = 0; // Process walls and segment sides. for (segnum=0; segnum<=Highest_segment_index; segnum++) { segment *segp = &Segments[segnum]; for (sidenum=0; sidenumsides[sidenum]; if (sidep->wall_num != -1) { int clip_num = Walls[sidep->wall_num].clip_num; if (clip_num != -1) { // -- int num_frames = WallAnims[clip_num].num_frames; wall_buf[clip_num] = 1; for (j=0; j<1; j++) { // Used to do through num_frames, but don't really want all the door01#3 stuff. int tmap_num; tmap_num = Textures[WallAnims[clip_num].frames[j]].index; Assert((tmap_num >= 0) && (tmap_num < MAX_BITMAP_FILES)); tmap_buf[tmap_num]++; if (level_tmap_buf[tmap_num] == -1) level_tmap_buf[tmap_num] = level_num; } } } else if (segp->children[sidenum] == -1) { if (sidep->tmap_num >= 0) { if (sidep->tmap_num < MAX_BITMAP_FILES) { Assert(Textures[sidep->tmap_num].index < MAX_BITMAP_FILES); tmap_buf[Textures[sidep->tmap_num].index]++; if (level_tmap_buf[Textures[sidep->tmap_num].index] == -1) level_tmap_buf[Textures[sidep->tmap_num].index] = level_num; } else Int3(); // Error, bogus texture map. Should not be greater than max_tmap. } if ((sidep->tmap_num2 & 0x3fff) != 0) { if ((sidep->tmap_num2 & 0x3fff) < MAX_BITMAP_FILES) { Assert(Textures[sidep->tmap_num2 & 0x3fff].index < MAX_BITMAP_FILES); tmap_buf[Textures[sidep->tmap_num2 & 0x3fff].index]++; if (level_tmap_buf[Textures[sidep->tmap_num2 & 0x3fff].index] == -1) level_tmap_buf[Textures[sidep->tmap_num2 & 0x3fff].index] = level_num; } else { if (!Ignore_tmap_num2_error) Int3(); // Error, bogus texture map. Should not be greater than max_tmap. Ignore_tmap_num2_error = 1; sidep->tmap_num2 = 0; } } } } } } // ---------------------------------------------------------------------------- void merge_buffers(int *dest, int *src, int num) { int i; for (i=0; i= 4) { // -- mk, 08/14/95 -- fprintf(my_file, "\n"); // -- mk, 08/14/95 -- count = 0; // -- mk, 08/14/95 -- } } } // --05/17/95--// ----------------------------------------------------------------------------- // --05/17/95--void say_used_once_tmaps(FILE *my_file, int *tb, sbyte *tb_lnum) // --05/17/95--{ // --05/17/95-- int i; // --05/17/95-- char *level_name; // --05/17/95-- // --05/17/95-- for (i=0; i= NUM_SHAREWARE_LEVELS) { // --05/17/95-- Assert((level_num - NUM_SHAREWARE_LEVELS >= 0) && (level_num - NUM_SHAREWARE_LEVELS < NUM_REGISTERED_LEVELS)); // --05/17/95-- level_name = Registered_level_names[level_num - NUM_SHAREWARE_LEVELS]; // --05/17/95-- } else { // --05/17/95-- Assert((level_num >= 0) && (level_num < NUM_SHAREWARE_LEVELS)); // --05/17/95-- level_name = Shareware_level_names[level_num]; // --05/17/95-- } // --05/17/95-- // --05/17/95-- fprintf(my_file, "Texture %3i %8s used only once on level %s\n", i, TmapInfo[i].filename, level_name); // --05/17/95-- } // --05/17/95--} // ---------------------------------------------------------------------------- void say_used_once_tmaps(FILE *my_file, int *tb, sbyte *tb_lnum) { int i; char *level_name; for (i=0; i= 4) { fprintf(my_file, "\n"); count = 0; } } } // ---------------------------------------------------------------------------- void say_unused_walls(FILE *my_file, int *tb) { int i; for (i=0; i