From 0b72dcfff1e119f39468d1653ce1ee3aca4cac69 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Fri, 2 Aug 2002 23:28:40 +0000 Subject: [PATCH] more d1 level loading stuff --- main/gamemine.c | 16 ++-- main/gamemine.h | 33 ++++---- main/gamesave.c | 215 +++++++++++++++++++++++++----------------------- main/gamesave.h | 9 +- 4 files changed, 144 insertions(+), 129 deletions(-) diff --git a/main/gamemine.c b/main/gamemine.c index d1a87bdd..4a38ba15 100644 --- a/main/gamemine.c +++ b/main/gamemine.c @@ -1,3 +1,4 @@ +/* $Id: */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -7,7 +8,7 @@ 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. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -16,7 +17,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: gamemine.c,v 1.8 2002-08-01 23:28:57 btb Exp $"; +static char rcsid[] = "$Id: gamemine.c,v 1.9 2002-08-02 23:28:40 btb Exp $"; #endif #include @@ -44,7 +45,7 @@ static char rcsid[] = "$Id: gamemine.c,v 1.8 2002-08-01 23:28:57 btb Exp $"; #include "editor/editor.h" #endif -#include "cfile.h" +#include "cfile.h" #include "fuelcen.h" #include "hash.h" @@ -52,6 +53,7 @@ static char rcsid[] = "$Id: gamemine.c,v 1.8 2002-08-01 23:28:57 btb Exp $"; #include "piggy.h" #include "byteswap.h" +#include "gamesave.h" #define REMOVE_EXT(s) (*(strchr( (s), '.' ))='\0') @@ -626,7 +628,7 @@ void read_special(int segnum,ubyte bit_mask,CFILE *LoadFile) } } -int load_mine_data_compiled(CFILE *LoadFile, int file_version) +int load_mine_data_compiled(CFILE *LoadFile) { int i, segnum, sidenum; ubyte compiled_version; @@ -673,7 +675,7 @@ int load_mine_data_compiled(CFILE *LoadFile, int file_version) #else read_children(segnum,bit_mask,LoadFile); read_verts(segnum,LoadFile); - if (file_version <= 1) { // descent 1 level + if (Gamesave_current_version <= 1) { // descent 1 level read_special(segnum,bit_mask,LoadFile); } #endif @@ -681,7 +683,7 @@ int load_mine_data_compiled(CFILE *LoadFile, int file_version) Segments[segnum].objects = -1; #ifndef SHAREWARE - if (file_version <= 1) { // descent 1 level + if (Gamesave_current_version <= 1) { // descent 1 level #endif // Read fix Segments[segnum].static_light (shift down 5 bits, write as short) temp_ushort = cfile_read_short(LoadFile); @@ -783,7 +785,7 @@ int load_mine_data_compiled(CFILE *LoadFile, int file_version) for (i=0; i 1) + if (Gamesave_current_version > 1) segment2_read(&Segment2s[i], LoadFile); #endif fuelcen_activate( &Segments[i], Segment2s[i].special ); diff --git a/main/gamemine.h b/main/gamemine.h index a3ac8399..c70b7479 100644 --- a/main/gamemine.h +++ b/main/gamemine.h @@ -1,3 +1,4 @@ +/* $Id: gamemine.h,v 1.3 2002-08-02 23:28:40 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -7,7 +8,7 @@ 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. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -58,12 +59,12 @@ struct mfi { int links_howmany; int links_sizeof; int object_offset; // Object info - int object_howmany; - int object_sizeof; + int object_howmany; + int object_sizeof; int unused_offset; //was: doors_offset int unused_howmamy; //was: doors_howmany int unused_sizeof; //was: doors_sizeof - short level_shake_frequency, level_shake_duration; // Shakes every level_shake_frequency seconds + short level_shake_frequency, level_shake_duration; // Shakes every level_shake_frequency seconds // for level_shake_duration seconds (on average, random). In 16ths second. int secret_return_segment; vms_matrix secret_return_orient; @@ -88,17 +89,17 @@ struct mh { }; struct me { - int current_seg; - int newsegment_offset; - int newsegment_size; - int Curside; - int Markedsegp; - int Markedside; - int Groupsegp[10]; - int Groupside[10]; - int num_groups; - int current_group; -// int num_objects; + int current_seg; + int newsegment_offset; + int newsegment_size; + int Curside; + int Markedsegp; + int Markedside; + int Groupsegp[10]; + int Groupside[10]; + int num_groups; + int current_group; +// int num_objects; }; extern struct mtfi mine_top_fileinfo; // Should be same as first two fields below... @@ -112,7 +113,7 @@ int game_load_mine(char * filename); //loads from an already-open file // returns 0=everything ok, 1=old version, -1=error int load_mine_data(CFILE *LoadFile); -int load_mine_data_compiled(CFILE *LoadFile, int file_version); +int load_mine_data_compiled(CFILE *LoadFile); extern short tmap_xlate_table[]; extern fix Level_shake_frequency, Level_shake_duration; diff --git a/main/gamesave.c b/main/gamesave.c index 9dc93976..be2ae8a6 100644 --- a/main/gamesave.c +++ b/main/gamesave.c @@ -24,7 +24,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -char gamesave_rcsid[] = "$Id: gamesave.c,v 1.9 2002-08-01 23:28:57 btb Exp $"; +char gamesave_rcsid[] = "$Id: gamesave.c,v 1.10 2002-08-02 23:28:40 btb Exp $"; #endif #include @@ -74,63 +74,65 @@ char gamesave_rcsid[] = "$Id: gamesave.c,v 1.9 2002-08-01 23:28:57 btb Exp $"; char Gamesave_current_filename[128]; -#define GAME_VERSION 32 -#define GAME_COMPATIBLE_VERSION 22 +int Gamesave_current_version; -//version 28->29 add delta light support +#define GAME_VERSION 32 +#define GAME_COMPATIBLE_VERSION 22 + +//version 28->29 add delta light support //version 27->28 controlcen id now is reactor number, not model number //version 28->29 ?? -//version 29->30 changed trigger structure -//version 30->31 changed trigger structure some more -//version 31->32 change segment structure, make it 512 bytes w/o editor, add Segment2s array. +//version 29->30 changed trigger structure +//version 30->31 changed trigger structure some more +//version 31->32 change segment structure, make it 512 bytes w/o editor, add Segment2s array. -#define MENU_CURSOR_X_MIN MENU_X -#define MENU_CURSOR_X_MAX MENU_X+6 +#define MENU_CURSOR_X_MIN MENU_X +#define MENU_CURSOR_X_MAX MENU_X+6 struct { - ushort fileinfo_signature; - ushort fileinfo_version; - int fileinfo_sizeof; + ushort fileinfo_signature; + ushort fileinfo_version; + int fileinfo_sizeof; } game_top_fileinfo; // Should be same as first two fields below... struct { - ushort fileinfo_signature; - ushort fileinfo_version; - int fileinfo_sizeof; - char mine_filename[15]; - int level; - int player_offset; // Player info - int player_sizeof; - int object_offset; // Object info - int object_howmany; - int object_sizeof; - int walls_offset; - int walls_howmany; - int walls_sizeof; - int doors_offset; - int doors_howmany; - int doors_sizeof; - int triggers_offset; - int triggers_howmany; - int triggers_sizeof; - int links_offset; - int links_howmany; - int links_sizeof; - int control_offset; - int control_howmany; - int control_sizeof; - int matcen_offset; - int matcen_howmany; - int matcen_sizeof; - int dl_indices_offset; - int dl_indices_howmany; - int dl_indices_sizeof; - int delta_light_offset; - int delta_light_howmany; - int delta_light_sizeof; + ushort fileinfo_signature; + ushort fileinfo_version; + int fileinfo_sizeof; + char mine_filename[15]; + int level; + int player_offset; // Player info + int player_sizeof; + int object_offset; // Object info + int object_howmany; + int object_sizeof; + int walls_offset; + int walls_howmany; + int walls_sizeof; + int doors_offset; + int doors_howmany; + int doors_sizeof; + int triggers_offset; + int triggers_howmany; + int triggers_sizeof; + int links_offset; + int links_howmany; + int links_sizeof; + int control_offset; + int control_howmany; + int control_sizeof; + int matcen_offset; + int matcen_howmany; + int matcen_sizeof; + int dl_indices_offset; + int dl_indices_howmany; + int dl_indices_sizeof; + int delta_light_offset; + int delta_light_howmany; + int delta_light_sizeof; } game_fileinfo; -// LINT: adding function prototypes +// LINT: adding function prototypes void read_object(object *obj, CFILE *f, int version); void write_object(object *obj, FILE *f); void do_load_save_levels(int save); @@ -150,11 +152,11 @@ int Gamesave_num_org_robots = 0; //--unused-- grs_bitmap * Gamesave_saved_bitmap = NULL; #ifdef EDITOR -// Return true if this level has a name of the form "level??" -// Note that a pathspec can appear at the beginning of the filename. +// Return true if this level has a name of the form "level??" +// Note that a pathspec can appear at the beginning of the filename. int is_real_level(char *filename) { - int len = strlen(filename); + int len = strlen(filename); if (len < 6) return 0; @@ -310,17 +312,21 @@ void verify_object( object * obj ) { } } - if ( obj->type == OBJ_CNTRLCEN ) { + if ( obj->type == OBJ_CNTRLCEN ) { obj->render_type = RT_POLYOBJ; obj->control_type = CT_CNTRLCEN; - //@@// Make model number is correct... - //@@for (i=0; iid = 0; // used to be only one kind of reactor + obj->rtype.pobj_info.model_num = 97; // approximately descent 1 type + } + //@@// Make model number is correct... + //@@for (i=0; irtype.pobj_info.model_num = ObjId[i]; //@@ obj->shields = ObjStrength[i]; - //@@ break; + //@@ break; //@@ } #ifdef EDITOR @@ -435,32 +441,29 @@ extern int multi_powerup_is_4pack(int); //reads one object of the given version from the given file void read_object(object *obj,CFILE *f,int version) { - - obj->type = cfile_read_byte(f); - obj->id = cfile_read_byte(f); - if (obj->type == OBJ_CNTRLCEN && version<28) - obj->id = 0; //used to be only one kind of reactor + obj->type = cfile_read_byte(f); + obj->id = cfile_read_byte(f); - obj->control_type = cfile_read_byte(f); - obj->movement_type = cfile_read_byte(f); - obj->render_type = cfile_read_byte(f); - obj->flags = cfile_read_byte(f); + obj->control_type = cfile_read_byte(f); + obj->movement_type = cfile_read_byte(f); + obj->render_type = cfile_read_byte(f); + obj->flags = cfile_read_byte(f); - obj->segnum = cfile_read_short(f); - obj->attached_obj = -1; + obj->segnum = cfile_read_short(f); + obj->attached_obj = -1; cfile_read_vector(&obj->pos,f); cfile_read_matrix(&obj->orient,f); - obj->size = cfile_read_fix(f); - obj->shields = cfile_read_fix(f); + obj->size = cfile_read_fix(f); + obj->shields = cfile_read_fix(f); cfile_read_vector(&obj->last_pos,f); - obj->contains_type = cfile_read_byte(f); - obj->contains_id = cfile_read_byte(f); - obj->contains_count = cfile_read_byte(f); + obj->contains_type = cfile_read_byte(f); + obj->contains_id = cfile_read_byte(f); + obj->contains_count = cfile_read_byte(f); switch (obj->movement_type) { @@ -950,12 +953,12 @@ int load_game_data(CFILE *LoadFile) Gamesave_num_players = 0; if (game_fileinfo.object_offset > -1) { - if (cfseek( LoadFile, game_fileinfo.object_offset, SEEK_SET )) + if (cfseek( LoadFile, game_fileinfo.object_offset, SEEK_SET )) Error( "Error seeking to object_offset in gamesave.c" ); - - for (i=0;i= 8) { //read dummy data + if (Gamesave_current_version >= 8) { //read dummy data #ifdef NETWORK if (HoardEquipped()) { @@ -1474,28 +1477,28 @@ int load_level(char * filename_passed) } - if (version < 5) - cfile_read_int(LoadFile); //was hostagetext_offset + if (Gamesave_current_version < 5) + cfile_read_int(LoadFile); //was hostagetext_offset - if (version > 1) { + if (Gamesave_current_version > 1) { cfgets(Current_level_palette,sizeof(Current_level_palette),LoadFile); if (Current_level_palette[strlen(Current_level_palette)-1] == '\n') Current_level_palette[strlen(Current_level_palette)-1] = 0; } - if (version <= 1 || Current_level_palette[0]==0) // descent 1 level + if (Gamesave_current_version <= 1 || Current_level_palette[0]==0) // descent 1 level strcpy(Current_level_palette,"groupa.256"); - if (version >= 3) + if (Gamesave_current_version >= 3) Base_control_center_explosion_time = cfile_read_int(LoadFile); else Base_control_center_explosion_time = DEFAULT_CONTROL_CENTER_EXPLOSION_TIME; - if (version >= 4) + if (Gamesave_current_version >= 4) Reactor_strength = cfile_read_int(LoadFile); else - Reactor_strength = -1; //use old defaults + Reactor_strength = -1; //use old defaults - if (version >= 7) { + if (Gamesave_current_version >= 7) { int i; Num_flickering_lights = cfile_read_int(LoadFile); @@ -1506,11 +1509,17 @@ int load_level(char * filename_passed) else Num_flickering_lights = 0; - if (version < 6) { + if (Gamesave_current_version < 6) { Secret_return_segment = 0; - Secret_return_orient.rvec.x = F1_0; Secret_return_orient.rvec.y = 0; Secret_return_orient.rvec.z = 0; - Secret_return_orient.fvec.x = 0; Secret_return_orient.fvec.y = F1_0; Secret_return_orient.fvec.z = 0; - Secret_return_orient.uvec.x = 0; Secret_return_orient.uvec.y = 0; Secret_return_orient.uvec.z = F1_0; + Secret_return_orient.rvec.x = F1_0; + Secret_return_orient.rvec.y = 0; + Secret_return_orient.rvec.z = 0; + Secret_return_orient.fvec.x = 0; + Secret_return_orient.fvec.y = F1_0; + Secret_return_orient.fvec.z = 0; + Secret_return_orient.uvec.x = 0; + Secret_return_orient.uvec.y = 0; + Secret_return_orient.uvec.z = F1_0; } else { Secret_return_segment = cfile_read_int(LoadFile); Secret_return_orient.rvec.x = cfile_read_int(LoadFile); @@ -1529,15 +1538,15 @@ int load_level(char * filename_passed) if (!use_compiled_level) { mine_err = load_mine_data(LoadFile); #if 0 //dunno - 3rd party stuff? - // Compress all uv coordinates in mine, improves texmap precision. --MK, 02/19/96 + // Compress all uv coordinates in mine, improves texmap precision. --MK, 02/19/96 compress_uv_coordinates_all(); #endif } else #endif //NOTE LINK TO ABOVE!! - mine_err = load_mine_data_compiled(LoadFile, version); + mine_err = load_mine_data_compiled(LoadFile); - if (mine_err == -1) { //error!! + if (mine_err == -1) { //error!! cfclose(LoadFile); return 2; } @@ -1545,7 +1554,7 @@ int load_level(char * filename_passed) cfseek(LoadFile,gamedata_offset,SEEK_SET); game_err = load_game_data(LoadFile); - if (game_err == -1) { //error!! + if (game_err == -1) { //error!! cfclose(LoadFile); return 3; } @@ -1574,10 +1583,10 @@ int load_level(char * filename_passed) #ifdef EDITOR //If an old version, ask the use if he wants to save as new version - if (!no_old_level_file_error && (Function_mode == FMODE_EDITOR) && (((LEVEL_FILE_VERSION>3) && version 3) && Gamesave_current_version < LEVEL_FILE_VERSION) || mine_err == 1 || game_err == 1)) { char ErrorMessage[200]; - sprintf( ErrorMessage, + sprintf( ErrorMessage, "You just loaded a old version\n" "level. Would you like to save\n" "it as a current version level?"); diff --git a/main/gamesave.h b/main/gamesave.h index 0510b234..be1bf9dc 100644 --- a/main/gamesave.h +++ b/main/gamesave.h @@ -1,3 +1,4 @@ +/* $Id: gamesave.h,v 1.2 2002-08-02 23:28:40 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -7,7 +8,7 @@ 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. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ @@ -28,11 +29,13 @@ extern void load_mine_only(char * filename); extern char Gamesave_current_filename[]; +extern int Gamesave_current_version; + extern int Gamesave_num_org_robots; -// In dumpmine.c +// In dumpmine.c extern void write_game_text_file(char *filename); -extern int Errors_in_mine; +extern int Errors_in_mine; #endif -- 2.39.2