/* 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-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* * $Source: /cvsroot/dxx-rebirth/d1x-rebirth/editor/mine.c,v $ * $Revision: 1.1.1.1 $ * $Author: zicodxx $ * $Date: 2006/03/17 19:45:37 $ * * Mine specific editing functions, such as load_mine, save_mine * * $Log: mine.c,v $ * Revision 1.1.1.1 2006/03/17 19:45:37 zicodxx * initial import * * Revision 1.1.1.1 1999/06/14 22:04:07 donut * Import of d1x 1.37 source. * * Revision 2.0 1995/02/27 11:34:38 john * Version 2.0! No anonymous unions, Watcom 10.0, with no need * for bitmaps.tbl. * * Revision 1.82 1995/01/19 15:19:42 mike * New super-compressed registered file format. * * Revision 1.81 1994/12/15 16:51:39 mike * fix error message. * * Revision 1.80 1994/12/09 22:52:27 yuan * *** empty log message *** * * Revision 1.79 1994/11/27 23:17:14 matt * Made changes for new mprintf calling convention * * Revision 1.78 1994/11/26 21:48:24 matt * Fixed saturation in short light value * * Revision 1.77 1994/11/18 09:43:22 mike * mprintf and clean up instead of Assert on values which don't fit in a short. * * Revision 1.76 1994/11/17 20:37:37 john * Added comment to get mike or john. * * Revision 1.75 1994/11/17 20:08:51 john * Added new compiled level format. * * Revision 1.74 1994/11/17 11:39:00 matt * Ripped out code to load old mines * * Revision 1.73 1994/10/20 12:47:47 matt * Replaced old save files (MIN/SAV/HOT) with new LVL files * * Revision 1.72 1994/09/23 22:13:58 matt * Tooks out references to obsolete structure fields * * Revision 1.71 1994/09/22 18:39:40 john * *** empty log message *** * * Revision 1.70 1994/09/22 18:38:09 john * Added better help for locked files. * * Revision 1.69 1994/08/01 11:04:44 yuan * New materialization centers. * * Revision 1.68 1994/06/08 14:29:35 matt * Took out support for old mine versions * * Revision 1.67 1994/05/27 10:34:37 yuan * Added new Dialog boxes for Walls and Triggers. * * Revision 1.66 1994/05/23 14:48:08 mike * make current segment be add segment. * * Revision 1.65 1994/05/17 10:34:52 matt * New parm to reset_objects; Num_objects no longer global * * Revision 1.64 1994/05/12 14:46:46 mike * Load previous mine type. * * Revision 1.63 1994/05/06 12:52:13 yuan * Adding some gamesave checks... * * Revision 1.62 1994/05/05 12:56:32 yuan * Fixed a bunch of group bugs. * * Revision 1.61 1994/05/03 11:36:55 yuan * Fixing mine save. * * Revision 1.60 1994/03/19 17:22:14 yuan * Wall system implemented until specific features need to be added... * (Needs to be hammered on though.) * * Revision 1.59 1994/03/17 18:08:32 yuan * New wall stuff... Cut out switches.... * * Revision 1.58 1994/03/15 16:34:15 yuan * Fixed bm loader (might have some changes in walls and switches) * * Revision 1.57 1994/03/01 18:14:09 yuan * Added new walls, switches, and triggers. * */ #ifdef RCS static char rcsid[] = "$Id: mine.c,v 1.1.1.1 2006/03/17 19:45:37 zicodxx Exp $"; #endif #include #include #include #include #include "mono.h" #include "key.h" #include "gr.h" #include "bm.h" // for MAX_TEXTURES #include "inferno.h" #include "segment.h" #include "editor.h" #include "error.h" #include "textures.h" #include "object.h" #include "gamemine.h" #include "gameseg.h" #include "ui.h" // Because texpage.h need UI_WINDOW type #include "texpage.h" // For texpage_goto_first #include "medwall.h" #include "switch.h" #include "nocfile.h" #include "fuelcen.h" #define REMOVE_EXT(s) (*(strchr( (s), '.' ))='\0') int CreateDefaultNewSegment(); int save_mine_data(CFILE * SaveFile); int save_mine_data_compiled_new(FILE * SaveFile); static char current_tmap_list[MAX_TEXTURES][13]; // ----------------------------------------------------------------------------- // Save mine will: // 1. Write file info, header info, editor info, vertex data, segment data, // and new_segment in that order, marking their file offset. // 2. Go through all the fields and fill in the offset, size, and sizeof // values in the headers. int med_save_mine(char * filename) { FILE * SaveFile; char ErrorMessage[256]; SaveFile = cfopen( filename, CF_WRITE_MODE ); if (!SaveFile) { #ifndef __LINUX__ char fname[20]; _splitpath( filename, NULL, NULL, fname, NULL ); sprintf( ErrorMessage, \ "ERROR: Cannot write to '%s'.\nYou probably need to check out a locked\nversion of the file. You should save\nthis under a different filename, and then\ncheck out a locked copy by typing\n\'co -l %s.lvl'\nat the DOS prompt.\n" , filename, fname); #endif sprintf( ErrorMessage, "ERROR: Unable to open %s\n", filename ); MessageBox( -2, -2, 1, ErrorMessage, "Ok" ); return 1; } save_mine_data(SaveFile); //==================== CLOSE THE FILE ============================= cfclose(SaveFile); return 0; } // ----------------------------------------------------------------------------- // saves to an already-open file int save_mine_data(CFILE * SaveFile) { int header_offset, editor_offset, vertex_offset, segment_offset, doors_offset, texture_offset, walls_offset, triggers_offset; //, links_offset; int newseg_verts_offset; int newsegment_offset; int i; med_compress_mine(); warn_if_concave_segments(); for (i=0;i>nbits); if( int_value > 0x7fff ) { short_value = 0x7fff; mprintf((1, "Warning: Fix (%8x) won't fit in short. Saturating to %8x.\n", int_value, short_value<> nbits; if( int_value > 0xffff ) { short_value = 0xffff; mprintf((1, "Warning: Fix (%8x) won't fit in unsigned short. Saturating to %8x.\n", int_value, short_value<= MAX_GAME_SEGMENTS) { char message[128]; sprintf(message, "Error: Too many segments (%i > %i) for game (not editor)", Highest_segment_index+1, MAX_GAME_SEGMENTS); MessageBox( -2, -2, 1, message, "Ok" ); } if (Highest_vertex_index >= MAX_GAME_VERTICES) { char message[128]; sprintf(message, "Error: Too many vertices (%i > %i) for game (not editor)", Highest_vertex_index+1, MAX_GAME_VERTICES); MessageBox( -2, -2, 1, message, "Ok" ); } //=============================== Writing part ============================== cfwrite( &version, sizeof(ubyte), 1, SaveFile ); // 1 byte = compiled version cfwrite( &Num_vertices, sizeof(int), 1, SaveFile ); // 4 bytes = Num_vertices cfwrite( &Num_segments, sizeof(int), 1, SaveFile ); // 4 bytes = Num_segments cfwrite( Vertices, sizeof(vms_vector), Num_vertices, SaveFile ); for (segnum=0; segnum>5, write as short, l>>1 write as short) for (i=0; i<4; i++ ) { dump_fix_as_short( Segments[segnum].sides[sidenum].uvls[i].u, 5, SaveFile ); dump_fix_as_short( Segments[segnum].sides[sidenum].uvls[i].v, 5, SaveFile ); dump_fix_as_ushort( Segments[segnum].sides[sidenum].uvls[i].l, 1, SaveFile ); //cfwrite( &Segments[segnum].sides[sidenum].uvls[i].l, sizeof(fix), 1, SaveFile ); } } } } return 0; } // ----------------------------------------------------------------------------- // saves compiled mine data to an already-open file... int save_mine_data_compiled_new(FILE * SaveFile) { short i, segnum, sidenum, temp_short; ubyte version = COMPILED_MINE_VERSION; ubyte bit_mask = 0; med_compress_mine(); warn_if_concave_segments(); if (Highest_segment_index >= MAX_GAME_SEGMENTS) { char message[128]; sprintf(message, "Error: Too many segments (%i > %i) for game (not editor)", Highest_segment_index+1, MAX_GAME_SEGMENTS); MessageBox( -2, -2, 1, message, "Ok" ); } if (Highest_vertex_index >= MAX_GAME_VERTICES) { char message[128]; sprintf(message, "Error: Too many vertices (%i > %i) for game (not editor)", Highest_vertex_index+1, MAX_GAME_VERTICES); MessageBox( -2, -2, 1, message, "Ok" ); } //=============================== Writing part ============================== cfwrite( &version, sizeof(ubyte), 1, SaveFile ); // 1 byte = compiled version temp_short = Num_vertices; cfwrite( &temp_short, sizeof(short), 1, SaveFile ); // 2 bytes = Num_vertices temp_short = Num_segments; cfwrite( &temp_short, sizeof(short), 1, SaveFile ); // 2 bytes = Num_segments cfwrite( Vertices, sizeof(vms_vector), Num_vertices, SaveFile ); for (segnum=0; segnum= 0) { bit_mask |= (1 << sidenum); wallnum = Segments[segnum].sides[sidenum].wall_num; Assert( wallnum < 255 ); // Get John or Mike.. can only store up to 255 walls!!! } } cfwrite( &bit_mask, sizeof(ubyte), 1, SaveFile ); for (sidenum=0; sidenum