From 31d800de1904dc46de1a233a53315af51ffd319c Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Fri, 2 Aug 2002 04:57:19 +0000 Subject: [PATCH] fast i/o macros --- configure.ac | 8 ++ include/pstypes.h | 14 +- main/bm.c | 95 +++++++------ main/bm.h | 4 +- main/effects.c | 41 +++--- main/effects.h | 41 +++--- main/piggy.c | 30 +++-- main/piggy.h | 25 +++- main/powerup.c | 19 ++- main/powerup.h | 133 ++++++++++--------- main/robot.c | 277 ++++++++++++++++++++------------------ main/robot.h | 218 +++++++++++++++--------------- main/vclip.c | 31 +++-- main/vclip.h | 50 +++---- main/wall.c | 36 ++--- main/wall.h | 168 ++++++++++++----------- main/weapon.c | 130 +++++++++--------- main/weapon.h | 332 ++++++++++++++++++++++++++-------------------- 18 files changed, 905 insertions(+), 747 deletions(-) diff --git a/configure.ac b/configure.ac index 29504684..4c3ce88f 100644 --- a/configure.ac +++ b/configure.ac @@ -115,6 +115,14 @@ if test x$enable_release = xyes; then D2X_FEATURES="release ${D2X_FEATURES}" fi +dnl Build with FAST_FILE_IO? +AC_ARG_ENABLE(fastfileio, + [ --enable-fastfileio Fast file i/o build. little-endian only ],,) +if test x$enable_fastfileio = xyes; then + AC_DEFINE(FAST_FILE_IO,,[Define for a faster file i/o on little-endian machines]) + D2X_FEATURES="fastfileio ${D2X_FEATURES}" +fi + AC_ARG_WITH(sharepath, [[ --with-sharepath=DIR Use DIR for shared game data (unix only) [DATADIR/games/d2x]]], sharepath=$withval, sharepath="auto") diff --git a/include/pstypes.h b/include/pstypes.h index c240a0a0..04c3d768 100644 --- a/include/pstypes.h +++ b/include/pstypes.h @@ -8,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. */ @@ -18,7 +18,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. // define a dboolean typedef int dboolean; -//define a byte +//define a byte typedef signed char byte; //define unsigned types; @@ -70,10 +70,14 @@ typedef ubyte bool; #define NULL 0 #endif -#ifdef __GNUC__ -#define __pack__ __attribute__((packed)) +#ifdef FAST_FILE_IO +# ifdef __GNUC__ +# define __pack__ __attribute__((packed)) +# else +# define __pack__ +# endif #else -#define __pack__ +# define __pack__ #endif #endif diff --git a/main/bm.c b/main/bm.c index ea4f49ef..e2a0b568 100644 --- a/main/bm.c +++ b/main/bm.c @@ -1,4 +1,4 @@ -/* $ Id: $ */ +/* $Id: bm.c,v 1.12 2002-08-02 04:57:19 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -94,22 +94,31 @@ int First_multi_bitmap_num=-1; bitmap_index ObjBitmaps[MAX_OBJ_BITMAPS]; ushort ObjBitmapPtrs[MAX_OBJ_BITMAPS]; // These point back into ObjBitmaps, since some are used twice. +#ifdef FAST_FILE_IO +#define tmap_info_read_n(ti, n, fp) cfread(ti, sizeof(tmap_info), n, fp) +#else /* - * reads a tmap_info structure from a CFILE + * reads n tmap_info structs from a CFILE */ -void tmap_info_read(tmap_info *ti, CFILE *fp) +int tmap_info_read_n(tmap_info *ti, int n, CFILE *fp) { - ti->flags = cfile_read_byte(fp); - ti->pad[0] = cfile_read_byte(fp); - ti->pad[1] = cfile_read_byte(fp); - ti->pad[2] = cfile_read_byte(fp); - ti->lighting = cfile_read_fix(fp); - ti->damage = cfile_read_fix(fp); - ti->eclip_num = cfile_read_short(fp); - ti->destroyed = cfile_read_short(fp); - ti->slide_u = cfile_read_short(fp); - ti->slide_v = cfile_read_short(fp); + int i; + + for (i = 0; i < n; i++) { + ti[i].flags = cfile_read_byte(fp); + ti[i].pad[0] = cfile_read_byte(fp); + ti[i].pad[1] = cfile_read_byte(fp); + ti[i].pad[2] = cfile_read_byte(fp); + ti[i].lighting = cfile_read_fix(fp); + ti[i].damage = cfile_read_fix(fp); + ti[i].eclip_num = cfile_read_short(fp); + ti[i].destroyed = cfile_read_short(fp); + ti[i].slide_u = cfile_read_short(fp); + ti[i].slide_v = cfile_read_short(fp); + } + return i; } +#endif //#ifdef MACINTOSH @@ -232,48 +241,39 @@ int bm_init() return 0; } -void bm_read_all(CFILE * fp) +void bm_read_all(CFILE * fp, int hamfile_version) { int i,t; NumTextures = cfile_read_int(fp); - for (i = 0; i < NumTextures; i++) - bitmap_index_read(&Textures[i], fp); - for (i = 0; i < NumTextures; i++) - tmap_info_read(&TmapInfo[i], fp); + bitmap_index_read_n(Textures, NumTextures, fp ); + tmap_info_read_n(TmapInfo, NumTextures, fp); - t = cfile_read_int(fp); + t = cfile_read_int(fp); cfread( Sounds, sizeof(ubyte), t, fp ); cfread( AltSounds, sizeof(ubyte), t, fp ); Num_vclips = cfile_read_int(fp); - for (i = 0; i < Num_vclips; i++) - vclip_read(&Vclip[i], fp); + vclip_read_n(Vclip, Num_vclips, fp); Num_effects = cfile_read_int(fp); - for (i = 0; i < Num_effects; i++) - eclip_read(&Effects[i], fp); + eclip_read_n(Effects, Num_effects, fp); Num_wall_anims = cfile_read_int(fp); - for (i = 0; i < Num_wall_anims; i++) - wclip_read(&WallAnims[i], fp); + wclip_read_n(WallAnims, Num_wall_anims, fp); N_robot_types = cfile_read_int(fp); - for (i = 0; i < N_robot_types; i++) - robot_info_read(&Robot_info[i], fp); + robot_info_read_n(Robot_info, N_robot_types, fp); N_robot_joints = cfile_read_int(fp); - for (i = 0; i < N_robot_joints; i++) - jointpos_read(&Robot_joints[i], fp); + jointpos_read_n(Robot_joints, N_robot_joints, fp); N_weapon_types = cfile_read_int(fp); - for (i = 0; i < N_weapon_types; i++) - weapon_info_read(&Weapon_info[i], fp); + weapon_info_read_n(Weapon_info, N_weapon_types, fp, hamfile_version); N_powerup_types = cfile_read_int(fp); - for (i = 0; i < N_powerup_types; i++) - powerup_type_info_read(&Powerup_info[i], fp); - + powerup_type_info_read_n(Powerup_info, N_powerup_types, fp); + N_polygon_models = cfile_read_int(fp); for (i = 0; i < N_polygon_models; i++) polymodel_read(&Polygon_models[i], fp); @@ -355,7 +355,7 @@ void bm_read_extra_robots(char *fname,int type) CFILE *fp; int t,i; int version; - + #ifdef MACINTOSH ulong varSave = 0; #endif @@ -379,8 +379,7 @@ void bm_read_extra_robots(char *fname,int type) N_weapon_types = N_D2_WEAPON_TYPES+t; if (N_weapon_types >= MAX_WEAPON_TYPES) Error("Too many weapons (%d) in <%s>. Max is %d.",t,fname,MAX_WEAPON_TYPES-N_D2_WEAPON_TYPES); - for (i = N_D2_WEAPON_TYPES; i < t + N_D2_WEAPON_TYPES; i++) - weapon_info_read(&Weapon_info[i], fp); + weapon_info_read_n(&Weapon_info[N_D2_WEAPON_TYPES], t, fp, version); //now read robot info @@ -388,16 +387,14 @@ void bm_read_extra_robots(char *fname,int type) N_robot_types = N_D2_ROBOT_TYPES+t; if (N_robot_types >= MAX_ROBOT_TYPES) Error("Too many robots (%d) in <%s>. Max is %d.",t,fname,MAX_ROBOT_TYPES-N_D2_ROBOT_TYPES); - for (i = N_D2_ROBOT_TYPES; i < t + N_D2_ROBOT_TYPES; i++) - robot_info_read(&Robot_info[i], fp); - + robot_info_read_n(&Robot_info[N_D2_ROBOT_TYPES], t, fp); + t = cfile_read_int(fp); N_robot_joints = N_D2_ROBOT_JOINTS+t; if (N_robot_joints >= MAX_ROBOT_JOINTS) Error("Too many robot joints (%d) in <%s>. Max is %d.",t,fname,MAX_ROBOT_JOINTS-N_D2_ROBOT_JOINTS); - for (i = N_D2_ROBOT_JOINTS; i < t + N_D2_ROBOT_JOINTS; i++) - jointpos_read(&Robot_joints[i], fp); - + jointpos_read_n(&Robot_joints[N_D2_ROBOT_JOINTS], t, fp); + t = cfile_read_int(fp); N_polygon_models = N_D2_POLYGON_MODELS+t; if (N_polygon_models >= MAX_POLYGON_MODELS) @@ -410,11 +407,9 @@ void bm_read_extra_robots(char *fname,int type) Polygon_models[i].model_data = d_malloc(Polygon_models[i].model_data_size); Assert( Polygon_models[i].model_data != NULL ); cfread( Polygon_models[i].model_data, sizeof(ubyte), Polygon_models[i].model_data_size, fp ); - #ifdef WORDS_BIGENDIAN swap_polygon_model_data(Polygon_models[i].model_data); #endif - g3_init_polygon_model(Polygon_models[i].model_data); } @@ -449,26 +444,26 @@ void load_robot_replacements(char *level_name) char ifile_name[FILENAME_LEN]; change_filename_extension(ifile_name, level_name, ".HXM" ); - + fp = cfopen(ifile_name,"rb"); if (!fp) //no robot replacement file return; t = cfile_read_int(fp); //read id "HXM!" - if (t!= 0x21584d48) + if (t!= 0x21584d48) Error("ID of HXM! file incorrect"); t = cfile_read_int(fp); //read version if (t<1) - Error("HXM! version too old (%d)",t); + Error("HXM! version too old (%d)",t); t = cfile_read_int(fp); //read number of robots for (j=0;j=N_robot_types) Error("Robots number (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_robot_types-1); - robot_info_read(&Robot_info[i], fp); + robot_info_read_n(&Robot_info[i], 1, fp); } t = cfile_read_int(fp); //read number of joints @@ -476,7 +471,7 @@ void load_robot_replacements(char *level_name) i = cfile_read_int(fp); //read joint number if (i<0 || i>=N_robot_joints) Error("Robots joint (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_robot_joints-1); - jointpos_read(&Robot_joints[i], fp); + jointpos_read_n(&Robot_joints[i], 1, fp); } t = cfile_read_int(fp); //read number of polygon models diff --git a/main/bm.h b/main/bm.h index 8222a856..cc077c33 100644 --- a/main/bm.h +++ b/main/bm.h @@ -39,7 +39,7 @@ typedef struct { char filename[13]; //used by editor to remap textures char pad2[3]; #endif -} tmap_info; +} __pack__ tmap_info; extern int Num_object_types; @@ -96,5 +96,7 @@ extern int First_multi_bitmap_num; // Initializes all bitmaps from BITMAPS.TBL file. int bm_init_use_tbl(void); +extern void bm_read_all(CFILE * fp, int hamfile_version); + #endif diff --git a/main/effects.c b/main/effects.c index dcc1ad4c..b8044b2f 100644 --- a/main/effects.c +++ b/main/effects.c @@ -16,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: effects.c,v 1.3 2002-07-26 09:22:05 btb Exp $"; +static char rcsid[] = "$Id: effects.c,v 1.4 2002-08-02 04:57:19 btb Exp $"; #endif #include @@ -169,23 +169,30 @@ void restart_effect(int effect_num) //Assert(Effects[effect_num].bm_ptr != -1); } +#ifndef FAST_FILE_IO /* - * reads an eclip structure from a CFILE + * reads n eclip structs from a CFILE */ -void eclip_read(eclip *ec, CFILE *fp) +int eclip_read_n(eclip *ec, int n, CFILE *fp) { - vclip_read(&ec->vc, fp); - ec->time_left = cfile_read_fix(fp); - ec->frame_count = cfile_read_int(fp); - ec->changing_wall_texture = cfile_read_short(fp); - ec->changing_object_texture = cfile_read_short(fp); - ec->flags = cfile_read_int(fp); - ec->crit_clip = cfile_read_int(fp); - ec->dest_bm_num = cfile_read_int(fp); - ec->dest_vclip = cfile_read_int(fp); - ec->dest_eclip = cfile_read_int(fp); - ec->dest_size = cfile_read_fix(fp); - ec->sound_num = cfile_read_int(fp); - ec->segnum = cfile_read_int(fp); - ec->sidenum = cfile_read_int(fp); + int i; + + for (i = 0; i < n; i++) { + vclip_read_n(&ec[i].vc, 1, fp); + ec[i].time_left = cfile_read_fix(fp); + ec[i].frame_count = cfile_read_int(fp); + ec[i].changing_wall_texture = cfile_read_short(fp); + ec[i].changing_object_texture = cfile_read_short(fp); + ec[i].flags = cfile_read_int(fp); + ec[i].crit_clip = cfile_read_int(fp); + ec[i].dest_bm_num = cfile_read_int(fp); + ec[i].dest_vclip = cfile_read_int(fp); + ec[i].dest_eclip = cfile_read_int(fp); + ec[i].dest_size = cfile_read_fix(fp); + ec[i].sound_num = cfile_read_int(fp); + ec[i].segnum = cfile_read_int(fp); + ec[i].sidenum = cfile_read_int(fp); + } + return i; } +#endif diff --git a/main/effects.h b/main/effects.h index af8135d8..aa7815ec 100644 --- a/main/effects.h +++ b/main/effects.h @@ -1,3 +1,4 @@ +/* $Id: effects.h,v 1.3 2002-08-02 04:57:19 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. */ @@ -27,26 +28,26 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define EF_STOPPED 4 //this has been stopped typedef struct eclip { - vclip vc; //imbedded vclip - fix time_left; //for sequencing - int frame_count; //for sequencing - short changing_wall_texture; //Which element of Textures array to replace. - short changing_object_texture; //Which element of ObjBitmapPtrs array to replace. - int flags; //see above - int crit_clip; //use this clip instead of above one when mine critical - int dest_bm_num; //use this bitmap when monitor destroyed - int dest_vclip; //what vclip to play when exploding - int dest_eclip; //what eclip to play when exploding - fix dest_size; //3d size of explosion - int sound_num; //what sound this makes - int segnum,sidenum; //what seg & side, for one-shot clips -} eclip; + vclip vc; //imbedded vclip + fix time_left; //for sequencing + int frame_count; //for sequencing + short changing_wall_texture; //Which element of Textures array to replace. + short changing_object_texture; //Which element of ObjBitmapPtrs array to replace. + int flags; //see above + int crit_clip; //use this clip instead of above one when mine critical + int dest_bm_num; //use this bitmap when monitor destroyed + int dest_vclip; //what vclip to play when exploding + int dest_eclip; //what eclip to play when exploding + fix dest_size; //3d size of explosion + int sound_num; //what sound this makes + int segnum,sidenum; //what seg & side, for one-shot clips +} __pack__ eclip; extern int Num_effects; extern eclip Effects[MAX_EFFECTS]; // Set up special effects. -extern void init_special_effects(); +extern void init_special_effects(); // Clear any active one-shots void reset_special_effects(); @@ -63,9 +64,13 @@ void stop_effect(int effect_num); //restart a stopped effect void restart_effect(int effect_num); +#ifdef FAST_FILE_IO +#define eclip_read_n(ec, n, fp) cfread(ec, sizeof(eclip), n, fp) +#else /* - * reads an eclip structure from a CFILE + * reads n eclip structs from a CFILE */ -extern void eclip_read(eclip *ec, CFILE *fp); +extern int eclip_read_n(eclip *ec, int n, CFILE *fp); +#endif #endif diff --git a/main/piggy.c b/main/piggy.c index 21675a1b..74dcdff8 100644 --- a/main/piggy.c +++ b/main/piggy.c @@ -16,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: piggy.c,v 1.13 2002-07-30 11:05:53 btb Exp $"; +static char rcsid[] = "$Id: piggy.c,v 1.14 2002-08-02 04:57:19 btb Exp $"; #endif @@ -905,7 +905,7 @@ void piggy_new_pigfile(char *pigname) piggy_write_pigfile(pigname); Current_pigfile[0] = 0; //say no pig, to force reload - + piggy_new_pigfile(pigname); //read in just-generated pig @@ -919,8 +919,6 @@ grs_bitmap bogus_bitmap; ubyte bogus_bitmap_initialized=0; digi_sound bogus_sound; -extern void bm_read_all(CFILE * fp); - #define HAMFILE_ID MAKE_SIG('!','M','A','H') //HAM! #ifdef SHAREWARE #define HAMFILE_VERSION 2 @@ -941,14 +939,14 @@ int read_hamfile() #ifdef MACINTOSH char name[255]; #endif - + #ifndef MACINTOSH ham_fp = cfopen( DEFAULT_HAMFILE, "rb" ); #else sprintf(name, ":Data:%s", DEFAULT_HAMFILE ); ham_fp = cfopen( name, "rb" ); #endif - + if (ham_fp == NULL) { Must_write_hamfile = 1; return 0; @@ -965,12 +963,12 @@ int read_hamfile() if (ham_version < 3) // hamfile contains sound info sound_offset = cfile_read_int(ham_fp); - + #ifndef EDITOR { //int i; - bm_read_all( ham_fp ); // Note connection to above if!!! + bm_read_all(ham_fp, ham_version); cfread( GameBitmapXlat, sizeof(ushort)*MAX_BITMAP_FILES, 1, ham_fp ); // no swap here? //for (i = 0; i < MAX_BITMAP_FILES; i++) { @@ -1159,7 +1157,7 @@ int piggy_init(void) gr_set_fontcolor(gr_find_closest_color_current( 20, 20, 20 ),-1 ); gr_printf( 0x8000, grd_curcanv->cv_h-20, "%s...", TXT_LOADING_DATA ); WIN(DDGRUNLOCK(dd_grd_curcanv)); - + #ifdef EDITOR piggy_init_pigfile(DEFAULT_PIGFILE); #endif @@ -1735,6 +1733,7 @@ void piggy_bitmap_page_out_all_w() #endif +#ifndef FAST_FILE_IO /* * reads a bitmap_index structure from a CFILE */ @@ -1743,6 +1742,18 @@ void bitmap_index_read(bitmap_index *bi, CFILE *fp) bi->index = cfile_read_short(fp); } +/* + * reads n bitmap_index structs from a CFILE + */ +int bitmap_index_read_n(bitmap_index *bi, int n, CFILE *fp) +{ + int i; + + for (i = 0; i < n; i++) + bi[i].index = cfile_read_short(fp); + return i; +} + /* * reads a DiskBitmapHeader structure from a CFILE */ @@ -1768,3 +1779,4 @@ void DiskSoundHeader_read(DiskSoundHeader *dsh, CFILE *fp) dsh->data_length = cfile_read_int(fp); dsh->offset = cfile_read_int(fp); } +#endif diff --git a/main/piggy.h b/main/piggy.h index b0379680..19cb3a48 100644 --- a/main/piggy.h +++ b/main/piggy.h @@ -1,3 +1,4 @@ +/* $Id: piggy.h,v 1.7 2002-08-02 04:57:19 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. */ @@ -33,7 +34,7 @@ extern int Num_aliases; typedef struct bitmap_index { ushort index; -} bitmap_index; +} __pack__ bitmap_index; typedef struct DiskBitmapHeader { char name[8]; @@ -44,7 +45,7 @@ typedef struct DiskBitmapHeader { ubyte flags; ubyte avg_color; int offset; -} DiskBitmapHeader; +} __pack__ DiskBitmapHeader; #define DISKBITMAPHEADER_SIZE 18 // for disk i/o @@ -53,7 +54,7 @@ typedef struct DiskSoundHeader { int length; int data_length; int offset; -} DiskSoundHeader; +} __pack__ DiskSoundHeader; #define DISKSOUNDHEADER_SIZE 20 // for disk i/o @@ -94,7 +95,7 @@ static inline void _piggy_page_in(bitmap_index bmp) { } # else /* __GNUC__ */ - + #define PIGGY_PAGE_IN(bmp) \ do { \ if ( GameBitmaps[(bmp).index].bm_flags & BM_FLAG_PAGED_OUT ) {\ @@ -104,7 +105,7 @@ do { \ /* mprintf(( 0, "Paging in '%s' from file '%s', line %d\n", #bmp, __FILE__,__LINE__ )); \ */ # endif /* __GNUC__ */ #else - #define PIGGY_PAGE_IN(bmp) + #define PIGGY_PAGE_IN(bmp) #endif void piggy_read_sounds(); @@ -113,11 +114,22 @@ void piggy_read_sounds(); //returns the size of all the bitmap data void piggy_new_pigfile(char *pigname); +#ifdef FAST_FILE_IO +#define bitmap_index_read(bi, fp) cfread(bi, sizeof(bitmap_index), 1, fp) +#define bitmap_index_read_n(bi, n, fp) cfread(bi, sizeof(bitmap_index), n, fp) +#define DiskBitmapHeader_read(dbh, fp) cfread(dbh, sizeof(DiskBitmapHeader), 1, fp) +#define DiskSoundHeader_read(dsh, fp) cfread(dsh, sizeof(DiskSoundHeader), 1, fp) +#else /* * reads a bitmap_index structure from a CFILE */ void bitmap_index_read(bitmap_index *bi, CFILE *fp); +/* + * reads n bitmap_index structs from a CFILE + */ +int bitmap_index_read_n(bitmap_index *bi, int n, CFILE *fp); + /* * reads a DiskBitmapHeader structure from a CFILE */ @@ -127,5 +139,6 @@ void DiskBitmapHeader_read(DiskBitmapHeader *dbh, CFILE *fp); * reads a DiskSoundHeader structure from a CFILE */ void DiskSoundHeader_read(DiskSoundHeader *dsh, CFILE *fp); +#endif #endif diff --git a/main/powerup.c b/main/powerup.c index 15ad48f3..34108d72 100644 --- a/main/powerup.c +++ b/main/powerup.c @@ -701,13 +701,20 @@ int do_powerup(object *obj) } +#ifndef FAST_FILE_IO /* - * reads a powerup_type_info structure from a CFILE + * reads n powerup_type_info structs from a CFILE */ -extern void powerup_type_info_read(powerup_type_info *pti, CFILE *fp) +extern int powerup_type_info_read_n(powerup_type_info *pti, int n, CFILE *fp) { - pti->vclip_num = cfile_read_int(fp); - pti->hit_sound = cfile_read_int(fp); - pti->size = cfile_read_fix(fp); - pti->light = cfile_read_fix(fp); + int i; + + for (i = 0; i < n; i++) { + pti[i].vclip_num = cfile_read_int(fp); + pti[i].hit_sound = cfile_read_int(fp); + pti[i].size = cfile_read_fix(fp); + pti[i].light = cfile_read_fix(fp); + } + return i; } +#endif diff --git a/main/powerup.h b/main/powerup.h index c485200b..01661653 100644 --- a/main/powerup.h +++ b/main/powerup.h @@ -1,3 +1,4 @@ +/* $Id: powerup.h,v 1.3 2002-08-02 04:57:19 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. */ @@ -18,84 +19,84 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "vclip.h" -#define POW_EXTRA_LIFE 0 -#define POW_ENERGY 1 -#define POW_SHIELD_BOOST 2 -#define POW_LASER 3 +#define POW_EXTRA_LIFE 0 +#define POW_ENERGY 1 +#define POW_SHIELD_BOOST 2 +#define POW_LASER 3 -#define POW_KEY_BLUE 4 -#define POW_KEY_RED 5 -#define POW_KEY_GOLD 6 +#define POW_KEY_BLUE 4 +#define POW_KEY_RED 5 +#define POW_KEY_GOLD 6 -//#define POW_RADAR_ROBOTS 7 -//#define POW_RADAR_POWERUPS 8 +//#define POW_RADAR_ROBOTS 7 +//#define POW_RADAR_POWERUPS 8 -#define POW_MISSILE_1 10 -#define POW_MISSILE_4 11 //4-pack MUST follow single missile +#define POW_MISSILE_1 10 +#define POW_MISSILE_4 11 //4-pack MUST follow single missile -#define POW_QUAD_FIRE 12 +#define POW_QUAD_FIRE 12 -#define POW_VULCAN_WEAPON 13 -#define POW_SPREADFIRE_WEAPON 14 -#define POW_PLASMA_WEAPON 15 -#define POW_FUSION_WEAPON 16 -#define POW_PROXIMITY_WEAPON 17 -#define POW_SMARTBOMB_WEAPON 20 -#define POW_MEGA_WEAPON 21 -#define POW_VULCAN_AMMO 22 -#define POW_HOMING_AMMO_1 18 -#define POW_HOMING_AMMO_4 19 //4-pack MUST follow single missile -#define POW_CLOAK 23 -#define POW_TURBO 24 -#define POW_INVULNERABILITY 25 -#define POW_MEGAWOW 27 +#define POW_VULCAN_WEAPON 13 +#define POW_SPREADFIRE_WEAPON 14 +#define POW_PLASMA_WEAPON 15 +#define POW_FUSION_WEAPON 16 +#define POW_PROXIMITY_WEAPON 17 +#define POW_SMARTBOMB_WEAPON 20 +#define POW_MEGA_WEAPON 21 +#define POW_VULCAN_AMMO 22 +#define POW_HOMING_AMMO_1 18 +#define POW_HOMING_AMMO_4 19 //4-pack MUST follow single missile +#define POW_CLOAK 23 +#define POW_TURBO 24 +#define POW_INVULNERABILITY 25 +#define POW_MEGAWOW 27 -#define POW_GAUSS_WEAPON 28 -#define POW_HELIX_WEAPON 29 -#define POW_PHOENIX_WEAPON 30 -#define POW_OMEGA_WEAPON 31 +#define POW_GAUSS_WEAPON 28 +#define POW_HELIX_WEAPON 29 +#define POW_PHOENIX_WEAPON 30 +#define POW_OMEGA_WEAPON 31 -#define POW_SUPER_LASER 32 -#define POW_FULL_MAP 33 -#define POW_CONVERTER 34 -#define POW_AMMO_RACK 35 -#define POW_AFTERBURNER 36 -#define POW_HEADLIGHT 37 +#define POW_SUPER_LASER 32 +#define POW_FULL_MAP 33 +#define POW_CONVERTER 34 +#define POW_AMMO_RACK 35 +#define POW_AFTERBURNER 36 +#define POW_HEADLIGHT 37 -#define POW_SMISSILE1_1 38 -#define POW_SMISSILE1_4 39 //4-pack MUST follow single missile -#define POW_GUIDED_MISSILE_1 40 -#define POW_GUIDED_MISSILE_4 41 //4-pack MUST follow single missile -#define POW_SMART_MINE 42 -#define POW_MERCURY_MISSILE_1 43 -#define POW_MERCURY_MISSILE_4 44 //4-pack MUST follow single missile -#define POW_EARTHSHAKER_MISSILE 45 +#define POW_SMISSILE1_1 38 +#define POW_SMISSILE1_4 39 //4-pack MUST follow single missile +#define POW_GUIDED_MISSILE_1 40 +#define POW_GUIDED_MISSILE_4 41 //4-pack MUST follow single missile +#define POW_SMART_MINE 42 +#define POW_MERCURY_MISSILE_1 43 +#define POW_MERCURY_MISSILE_4 44 //4-pack MUST follow single missile +#define POW_EARTHSHAKER_MISSILE 45 -#define POW_FLAG_BLUE 46 -#define POW_FLAG_RED 47 +#define POW_FLAG_BLUE 46 +#define POW_FLAG_RED 47 -#define POW_HOARD_ORB 7 //use unused slot +#define POW_HOARD_ORB 7 //use unused slot -#define VULCAN_AMMO_MAX (392*4) -#define VULCAN_WEAPON_AMMO_AMOUNT 196 -#define VULCAN_AMMO_AMOUNT (49*2) +#define VULCAN_AMMO_MAX (392*4) +#define VULCAN_WEAPON_AMMO_AMOUNT 196 +#define VULCAN_AMMO_AMOUNT (49*2) -#define GAUSS_WEAPON_AMMO_AMOUNT 392 +#define GAUSS_WEAPON_AMMO_AMOUNT 392 -#define MAX_POWERUP_TYPES 50 +#define MAX_POWERUP_TYPES 50 -#define POWERUP_NAME_LENGTH 16 // Length of a robot or powerup name. -extern char Powerup_names[MAX_POWERUP_TYPES][POWERUP_NAME_LENGTH]; +#define POWERUP_NAME_LENGTH 16 // Length of a robot or powerup name. +extern char Powerup_names[MAX_POWERUP_TYPES][POWERUP_NAME_LENGTH]; -extern int Headlight_active_default; //is headlight on when picked up? +extern int Headlight_active_default; //is headlight on when picked up? typedef struct powerup_type_info { - int vclip_num; - int hit_sound; - fix size; //3d size of longest dimension - fix light; // amount of light cast by this powerup, set in bitmaps.tbl -} powerup_type_info; + int vclip_num; + int hit_sound; + fix size; // 3d size of longest dimension + fix light; // amount of light cast by this powerup, set in bitmaps.tbl +} __pack__ powerup_type_info; extern int N_powerup_types; extern powerup_type_info Powerup_info[MAX_POWERUP_TYPES]; @@ -108,16 +109,20 @@ int do_powerup(object *obj); //process (animate) a powerup for one frame void do_powerup_frame(object *obj); -// Diminish shields and energy towards max in case they exceeded it. +// Diminish shields and energy towards max in case they exceeded it. extern void diminish_towards_max(void); extern void do_megawow_powerup(int quantity); extern void powerup_basic(int redadd, int greenadd, int blueadd, int score, char *format, ...); +#ifdef FAST_FILE_IO +#define powerup_type_info_read_n(pti, n, fp) cfread(pti, sizeof(powerup_type_info), n, fp) +#else /* - * reads a powerup_type_info structure from a CFILE + * reads n powerup_type_info structs from a CFILE */ -extern void powerup_type_info_read(powerup_type_info *pti, CFILE *fp); +extern int powerup_type_info_read_n(powerup_type_info *pti, int n, CFILE *fp); +#endif #endif diff --git a/main/robot.c b/main/robot.c index 4a47d35f..073ef013 100644 --- a/main/robot.c +++ b/main/robot.c @@ -1,3 +1,4 @@ +/* $Id: robot.c,v 1.4 2002-08-02 04:57:19 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. */ @@ -40,49 +41,48 @@ robot_info Robot_info[MAX_ROBOT_TYPES]; jointpos Robot_joints[MAX_ROBOT_JOINTS] = { //gun 0 - {2,{deg(-30),0,0}}, //rest (2 joints) - {3,{deg(-40),0,0}}, - - {2,{deg(0),0,0}}, //alert - {3,{deg(0),0,0}}, - - {2,{deg(0),0,0}}, //fire - {3,{deg(0),0,0}}, - - {2,{deg(50),0,0}}, //recoil - {3,{deg(-50),0,0}}, - - {2,{deg(10),0,deg(70)}}, //flinch - {3,{deg(0),deg(20),0}}, - + {2,{deg(-30),0,0}}, //rest (2 joints) + {3,{deg(-40),0,0}}, + + {2,{deg(0),0,0}}, //alert + {3,{deg(0),0,0}}, + + {2,{deg(0),0,0}}, //fire + {3,{deg(0),0,0}}, + + {2,{deg(50),0,0}}, //recoil + {3,{deg(-50),0,0}}, + + {2,{deg(10),0,deg(70)}}, //flinch + {3,{deg(0),deg(20),0}}, + //gun 1 - {4,{deg(-30),0,0}}, //rest (2 joints) - {5,{deg(-40),0,0}}, - - {4,{deg(0),0,0}}, //alert - {5,{deg(0),0,0}}, - - {4,{deg(0),0,0}}, //fire - {5,{deg(0),0,0}}, - - {4,{deg(50),0,0}}, //recoil - {5,{deg(-50),0,0}}, - - {4,{deg(20),0,deg(-50)}}, //flinch - {5,{deg(0),0,deg(20)}}, - + {4,{deg(-30),0,0}}, //rest (2 joints) + {5,{deg(-40),0,0}}, + + {4,{deg(0),0,0}}, //alert + {5,{deg(0),0,0}}, + + {4,{deg(0),0,0}}, //fire + {5,{deg(0),0,0}}, + + {4,{deg(50),0,0}}, //recoil + {5,{deg(-50),0,0}}, + + {4,{deg(20),0,deg(-50)}}, //flinch + {5,{deg(0),0,deg(20)}}, + //rest of body (the head) - {1,{deg(70),0,0}}, //rest (1 joint, head) + {1,{deg(70),0,0}}, //rest (1 joint, head) - {1,{deg(0),0,0}}, //alert - - {1,{deg(0),0,0}}, //fire - - {1,{deg(0),0,0}}, //recoil + {1,{deg(0),0,0}}, //alert - {1,{deg(-20),deg(15),0}}, //flinch + {1,{deg(0),0,0}}, //fire + {1,{deg(0),0,0}}, //recoil + + {1,{deg(-20),deg(15),0}}, //flinch }; @@ -132,7 +132,7 @@ void calc_gun_point(vms_vector *gun_point,object *obj,int gun_num) vm_copy_transpose_matrix(&m,&obj->orient); vm_vec_rotate(gun_point,&pnt,&m); vm_vec_add2(gun_point,&obj->pos); - + } //fills in ptr to list of joints, and returns the number of joints in list @@ -184,11 +184,11 @@ void set_robot_state(object *obj,int state) //--unused-- test_anim_states() //--unused-- { //--unused-- set_robot_state(&Objects[1],cur_state); -//--unused-- +//--unused-- //--unused-- mprintf(0,"Robot in state %d\n",cur_state); -//--unused-- +//--unused-- //--unused-- cur_state = (cur_state+1)%N_ANIM_STATES; -//--unused-- +//--unused-- //--unused-- } //set the animation angles for this robot. Gun fields of robot info must @@ -238,108 +238,121 @@ void robot_set_angles(robot_info *r,polymodel *pm,vms_angvec angs[N_ANIM_STATES] } +#ifndef FAST_FILE_IO /* - * reads a jointlist structure from a CFILE + * reads n jointlist structs from a CFILE */ -static void jointlist_read(jointlist *jl, CFILE *fp) +static int jointlist_read_n(jointlist *jl, int n, CFILE *fp) { - jl->n_joints = cfile_read_short(fp); - jl->offset = cfile_read_short(fp); + int i; + + for (i = 0; i < n; i++) { + jl[i].n_joints = cfile_read_short(fp); + jl[i].offset = cfile_read_short(fp); + } + return i; } /* - * reads a robot_info structure from a CFILE + * reads n robot_info structs from a CFILE */ -void robot_info_read(robot_info *ri, CFILE *fp) +int robot_info_read_n(robot_info *ri, int n, CFILE *fp) { int i, j; - - ri->model_num = cfile_read_int(fp); - for (i = 0; i < MAX_GUNS; i++) - cfile_read_vector(&(ri->gun_points[i]), fp); - cfread(ri->gun_submodels, MAX_GUNS, 1, fp); - - ri->exp1_vclip_num = cfile_read_short(fp); - ri->exp1_sound_num = cfile_read_short(fp); - - ri->exp2_vclip_num = cfile_read_short(fp); - ri->exp2_sound_num = cfile_read_short(fp); - - ri->weapon_type = cfile_read_byte(fp); - ri->weapon_type2 = cfile_read_byte(fp); - ri->n_guns = cfile_read_byte(fp); - ri->contains_id = cfile_read_byte(fp); - - ri->contains_count = cfile_read_byte(fp); - ri->contains_prob = cfile_read_byte(fp); - ri->contains_type = cfile_read_byte(fp); - ri->kamikaze = cfile_read_byte(fp); - - ri->score_value = cfile_read_short(fp); - ri->badass = cfile_read_byte(fp); - ri->energy_drain = cfile_read_byte(fp); - - ri->lighting = cfile_read_fix(fp); - ri->strength = cfile_read_fix(fp); - - ri->mass = cfile_read_fix(fp); - ri->drag = cfile_read_fix(fp); - - for (i = 0; i < NDL; i++) - ri->field_of_view[i] = cfile_read_fix(fp); - for (i = 0; i < NDL; i++) - ri->firing_wait[i] = cfile_read_fix(fp); - for (i = 0; i < NDL; i++) - ri->firing_wait2[i] = cfile_read_fix(fp); - for (i = 0; i < NDL; i++) - ri->turn_time[i] = cfile_read_fix(fp); - for (i = 0; i < NDL; i++) - ri->max_speed[i] = cfile_read_fix(fp); - for (i = 0; i < NDL; i++) - ri->circle_distance[i] = cfile_read_fix(fp); - cfread(ri->rapidfire_count, NDL, 1, fp); - - cfread(ri->evade_speed, NDL, 1, fp); - - ri->cloak_type = cfile_read_byte(fp); - ri->attack_type = cfile_read_byte(fp); - - ri->see_sound = cfile_read_byte(fp); - ri->attack_sound = cfile_read_byte(fp); - ri->claw_sound = cfile_read_byte(fp); - ri->taunt_sound = cfile_read_byte(fp); - - ri->boss_flag = cfile_read_byte(fp); - ri->companion = cfile_read_byte(fp); - ri->smart_blobs = cfile_read_byte(fp); - ri->energy_blobs = cfile_read_byte(fp); - - ri->thief = cfile_read_byte(fp); - ri->pursuit = cfile_read_byte(fp); - ri->lightcast = cfile_read_byte(fp); - ri->death_roll = cfile_read_byte(fp); - - ri->flags = cfile_read_byte(fp); - cfread(ri->pad, 3, 1, fp); - - ri->deathroll_sound = cfile_read_byte(fp); - ri->glow = cfile_read_byte(fp); - ri->behavior = cfile_read_byte(fp); - ri->aim = cfile_read_byte(fp); - - for (i = 0; i < MAX_GUNS + 1; i++) - for (j = 0; j < N_ANIM_STATES; j++) - jointlist_read(&ri->anim_states[i][j], fp); - - ri->always_0xabcd = cfile_read_int(fp); + + for (i = 0; i < n; i++) { + ri[i].model_num = cfile_read_int(fp); + for (j = 0; j < MAX_GUNS; j++) + cfile_read_vector(&(ri[i].gun_points[j]), fp); + cfread(ri[i].gun_submodels, MAX_GUNS, 1, fp); + + ri[i].exp1_vclip_num = cfile_read_short(fp); + ri[i].exp1_sound_num = cfile_read_short(fp); + + ri[i].exp2_vclip_num = cfile_read_short(fp); + ri[i].exp2_sound_num = cfile_read_short(fp); + + ri[i].weapon_type = cfile_read_byte(fp); + ri[i].weapon_type2 = cfile_read_byte(fp); + ri[i].n_guns = cfile_read_byte(fp); + ri[i].contains_id = cfile_read_byte(fp); + + ri[i].contains_count = cfile_read_byte(fp); + ri[i].contains_prob = cfile_read_byte(fp); + ri[i].contains_type = cfile_read_byte(fp); + ri[i].kamikaze = cfile_read_byte(fp); + + ri[i].score_value = cfile_read_short(fp); + ri[i].badass = cfile_read_byte(fp); + ri[i].energy_drain = cfile_read_byte(fp); + + ri[i].lighting = cfile_read_fix(fp); + ri[i].strength = cfile_read_fix(fp); + + ri[i].mass = cfile_read_fix(fp); + ri[i].drag = cfile_read_fix(fp); + + for (j = 0; j < NDL; j++) + ri[i].field_of_view[j] = cfile_read_fix(fp); + for (j = 0; j < NDL; j++) + ri[i].firing_wait[j] = cfile_read_fix(fp); + for (j = 0; j < NDL; j++) + ri[i].firing_wait2[j] = cfile_read_fix(fp); + for (j = 0; j < NDL; j++) + ri[i].turn_time[j] = cfile_read_fix(fp); + for (j = 0; j < NDL; j++) + ri[i].max_speed[j] = cfile_read_fix(fp); + for (j = 0; j < NDL; j++) + ri[i].circle_distance[i] = cfile_read_fix(fp); + cfread(ri[i].rapidfire_count, NDL, 1, fp); + + cfread(ri[i].evade_speed, NDL, 1, fp); + + ri[i].cloak_type = cfile_read_byte(fp); + ri[i].attack_type = cfile_read_byte(fp); + + ri[i].see_sound = cfile_read_byte(fp); + ri[i].attack_sound = cfile_read_byte(fp); + ri[i].claw_sound = cfile_read_byte(fp); + ri[i].taunt_sound = cfile_read_byte(fp); + + ri[i].boss_flag = cfile_read_byte(fp); + ri[i].companion = cfile_read_byte(fp); + ri[i].smart_blobs = cfile_read_byte(fp); + ri[i].energy_blobs = cfile_read_byte(fp); + + ri[i].thief = cfile_read_byte(fp); + ri[i].pursuit = cfile_read_byte(fp); + ri[i].lightcast = cfile_read_byte(fp); + ri[i].death_roll = cfile_read_byte(fp); + + ri[i].flags = cfile_read_byte(fp); + cfread(ri[i].pad, 3, 1, fp); + + ri[i].deathroll_sound = cfile_read_byte(fp); + ri[i].glow = cfile_read_byte(fp); + ri[i].behavior = cfile_read_byte(fp); + ri[i].aim = cfile_read_byte(fp); + + for (j = 0; j < MAX_GUNS + 1; j++) + jointlist_read_n(ri[i].anim_states[j], N_ANIM_STATES, fp); + + ri[i].always_0xabcd = cfile_read_int(fp); + } + return i; } /* - * reads a jointpos structure from a CFILE + * reads n jointpos structs from a CFILE */ -void jointpos_read(jointpos *jp, CFILE *fp) +int jointpos_read_n(jointpos *jp, int n, CFILE *fp) { - jp->jointnum = cfile_read_short(fp); - cfile_read_angvec(&jp->angles, fp); -} + int i; + for (i = 0; i < n; i++) { + jp[i].jointnum = cfile_read_short(fp); + cfile_read_angvec(&jp[i].angles, fp); + } + return i; +} +#endif diff --git a/main/robot.h b/main/robot.h index 781cd39e..1f0a6ac2 100644 --- a/main/robot.h +++ b/main/robot.h @@ -1,3 +1,4 @@ +/* $Id: robot.h,v 1.3 2002-08-02 04:57:19 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. */ @@ -21,25 +22,25 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "game.h" #include "cfile.h" -#define MAX_GUNS 8 //should be multiple of 4 for ubyte array +#define MAX_GUNS 8 //should be multiple of 4 for ubyte array //Animation states -#define AS_REST 0 +#define AS_REST 0 #define AS_ALERT 1 -#define AS_FIRE 2 +#define AS_FIRE 2 #define AS_RECOIL 3 #define AS_FLINCH 4 #define N_ANIM_STATES 5 -#define RI_CLOAKED_NEVER 0 -#define RI_CLOAKED_ALWAYS 1 -#define RI_CLOAKED_EXCEPT_FIRING 2 +#define RI_CLOAKED_NEVER 0 +#define RI_CLOAKED_ALWAYS 1 +#define RI_CLOAKED_EXCEPT_FIRING 2 //describes the position of a certain joint typedef struct jointpos { short jointnum; vms_angvec angles; -} jointpos; +} __pack__ jointpos; //describes a list of joint positions typedef struct jointlist { @@ -48,137 +49,142 @@ typedef struct jointlist { } jointlist; //robot info flags -#define RIF_BIG_RADIUS 1 //pad the radius to fix robots firing through walls -#define RIF_THIEF 2 //this guy steals! +#define RIF_BIG_RADIUS 1 //pad the radius to fix robots firing through walls +#define RIF_THIEF 2 //this guy steals! -// Robot information +// Robot information typedef struct robot_info { - int model_num; // which polygon model? - vms_vector gun_points[MAX_GUNS]; // where each gun model is - ubyte gun_submodels[MAX_GUNS]; // which submodel is each gun in? - - short exp1_vclip_num; - short exp1_sound_num; - - short exp2_vclip_num; - short exp2_sound_num; - - byte weapon_type; - byte weapon_type2; // Secondary weapon number, -1 means none, otherwise gun #0 fires this weapon. - byte n_guns; // how many different gun positions - byte contains_id; // ID of powerup this robot can contain. - - byte contains_count; // Max number of things this instance can contain. - byte contains_prob; // Probability that this instance will contain something in N/16 - byte contains_type; // Type of thing contained, robot or powerup, in bitmaps.tbl, !0=robot, 0=powerup - byte kamikaze; // !0 means commits suicide when hits you, strength thereof. 0 means no. - - short score_value; // Score from this robot. - byte badass; // Dies with badass explosion, and strength thereof, 0 means NO. - byte energy_drain; // Points of energy drained at each collision. - - fix lighting; // should this be here or with polygon model? - fix strength; // Initial shields of robot - - fix mass; // how heavy is this thing? - fix drag; // how much drag does it have? - - fix field_of_view[NDL]; // compare this value with forward_vector.dot.vector_to_player, if field_of_view <, then robot can see player - fix firing_wait[NDL]; // time in seconds between shots - fix firing_wait2[NDL]; // time in seconds between shots - fix turn_time[NDL]; // time in seconds to rotate 360 degrees in a dimension -// -- unused, mk, 05/25/95 fix fire_power[NDL]; // damage done by a hit from this robot -// -- unused, mk, 05/25/95 fix shield[NDL]; // shield strength of this robot - fix max_speed[NDL]; // maximum speed attainable by this robot - fix circle_distance[NDL]; // distance at which robot circles player - - byte rapidfire_count[NDL]; // number of shots fired rapidly - byte evade_speed[NDL]; // rate at which robot can evade shots, 0=none, 4=very fast - byte cloak_type; // 0=never, 1=always, 2=except-when-firing - byte attack_type; // 0=firing, 1=charge (like green guy) - - ubyte see_sound; // sound robot makes when it first sees the player - ubyte attack_sound; // sound robot makes when it attacks the player - ubyte claw_sound; // sound robot makes as it claws you (attack_type should be 1) - ubyte taunt_sound; // sound robot makes after you die - - byte boss_flag; // 0 = not boss, 1 = boss. Is that surprising? - byte companion; // Companion robot, leads you to things. - byte smart_blobs; // how many smart blobs are emitted when this guy dies! - byte energy_blobs; // how many smart blobs are emitted when this guy gets hit by energy weapon! - - byte thief; // !0 means this guy can steal when he collides with you! - byte pursuit; // !0 means pursues player after he goes around a corner. 4 = 4/2 pursue up to 4/2 seconds after becoming invisible if up to 4 segments away - byte lightcast; // Amount of light cast. 1 is default. 10 is very large. - byte death_roll; // 0 = dies without death roll. !0 means does death roll, larger = faster and louder + int model_num; // which polygon model? + vms_vector gun_points[MAX_GUNS]; // where each gun model is + ubyte gun_submodels[MAX_GUNS]; // which submodel is each gun in? + + short exp1_vclip_num; + short exp1_sound_num; + + short exp2_vclip_num; + short exp2_sound_num; + + byte weapon_type; + byte weapon_type2; // Secondary weapon number, -1 means none, otherwise gun #0 fires this weapon. + byte n_guns; // how many different gun positions + byte contains_id; // ID of powerup this robot can contain. + + byte contains_count; // Max number of things this instance can contain. + byte contains_prob; // Probability that this instance will contain something in N/16 + byte contains_type; // Type of thing contained, robot or powerup, in bitmaps.tbl, !0=robot, 0=powerup + byte kamikaze; // !0 means commits suicide when hits you, strength thereof. 0 means no. + + short score_value; // Score from this robot. + byte badass; // Dies with badass explosion, and strength thereof, 0 means NO. + byte energy_drain; // Points of energy drained at each collision. + + fix lighting; // should this be here or with polygon model? + fix strength; // Initial shields of robot + + fix mass; // how heavy is this thing? + fix drag; // how much drag does it have? + + fix field_of_view[NDL]; // compare this value with forward_vector.dot.vector_to_player, if field_of_view <, then robot can see player + fix firing_wait[NDL]; // time in seconds between shots + fix firing_wait2[NDL]; // time in seconds between shots + fix turn_time[NDL]; // time in seconds to rotate 360 degrees in a dimension +// -- unused, mk, 05/25/95 fix fire_power[NDL]; // damage done by a hit from this robot +// -- unused, mk, 05/25/95 fix shield[NDL]; // shield strength of this robot + fix max_speed[NDL]; // maximum speed attainable by this robot + fix circle_distance[NDL]; // distance at which robot circles player + + byte rapidfire_count[NDL]; // number of shots fired rapidly + byte evade_speed[NDL]; // rate at which robot can evade shots, 0=none, 4=very fast + byte cloak_type; // 0=never, 1=always, 2=except-when-firing + byte attack_type; // 0=firing, 1=charge (like green guy) + + ubyte see_sound; // sound robot makes when it first sees the player + ubyte attack_sound; // sound robot makes when it attacks the player + ubyte claw_sound; // sound robot makes as it claws you (attack_type should be 1) + ubyte taunt_sound; // sound robot makes after you die + + byte boss_flag; // 0 = not boss, 1 = boss. Is that surprising? + byte companion; // Companion robot, leads you to things. + byte smart_blobs; // how many smart blobs are emitted when this guy dies! + byte energy_blobs; // how many smart blobs are emitted when this guy gets hit by energy weapon! + + byte thief; // !0 means this guy can steal when he collides with you! + byte pursuit; // !0 means pursues player after he goes around a corner. 4 = 4/2 pursue up to 4/2 seconds after becoming invisible if up to 4 segments away + byte lightcast; // Amount of light cast. 1 is default. 10 is very large. + byte death_roll; // 0 = dies without death roll. !0 means does death roll, larger = faster and louder //boss_flag, companion, thief, & pursuit probably should also be bits in the flags byte. - ubyte flags; // misc properties - ubyte pad[3]; // alignment + ubyte flags; // misc properties + ubyte pad[3]; // alignment - ubyte deathroll_sound; // if has deathroll, what sound? - ubyte glow; // apply this light to robot itself. stored as 4:4 fixed-point - ubyte behavior; // Default behavior. - ubyte aim; // 255 = perfect, less = more likely to miss. 0 != random, would look stupid. 0=45 degree spread. Specify in bitmaps.tbl in range 0.0..1.0 + ubyte deathroll_sound; // if has deathroll, what sound? + ubyte glow; // apply this light to robot itself. stored as 4:4 fixed-point + ubyte behavior; // Default behavior. + ubyte aim; // 255 = perfect, less = more likely to miss. 0 != random, would look stupid. 0=45 degree spread. Specify in bitmaps.tbl in range 0.0..1.0 //animation info jointlist anim_states[MAX_GUNS+1][N_ANIM_STATES]; - int always_0xabcd; // debugging + int always_0xabcd; // debugging -} robot_info; +} __pack__ robot_info; -#define MAX_ROBOT_TYPES 85 // maximum number of robot types +#define MAX_ROBOT_TYPES 85 // maximum number of robot types -#define ROBOT_NAME_LENGTH 16 -extern char Robot_names[MAX_ROBOT_TYPES][ROBOT_NAME_LENGTH]; +#define ROBOT_NAME_LENGTH 16 +extern char Robot_names[MAX_ROBOT_TYPES][ROBOT_NAME_LENGTH]; //the array of robots types -extern robot_info Robot_info[]; // Robot info for AI system, loaded from bitmaps.tbl. +extern robot_info Robot_info[]; // Robot info for AI system, loaded from bitmaps.tbl. //how many kinds of robots -extern int N_robot_types; // Number of robot types. We used to assume this was the same as N_polygon_models. +extern int N_robot_types; // Number of robot types. We used to assume this was the same as N_polygon_models. //test data for one robot #define MAX_ROBOT_JOINTS 1600 extern jointpos Robot_joints[MAX_ROBOT_JOINTS]; -extern int N_robot_joints; +extern int N_robot_joints; //given an object and a gun number, return position in 3-space of gun //fills in gun_point void calc_gun_point(vms_vector *gun_point,object *obj,int gun_num); //void calc_gun_point(vms_vector *gun_point,int objnum,int gun_num); -// Tells joint positions for a gun to be in a specified state. -// A gun can have associated with it any number of joints. In order to tell whether a gun is a certain -// state (such as FIRE or ALERT), you should call this function and check the returned joint positions -// against the robot's gun's joint positions. This function should also be called to determine how to -// move a gun into a desired position. -// For now (May 30, 1994), it is assumed that guns will linearly interpolate from one joint position to another. -// There is no ordering of joint movement, so it's impossible to guarantee that a strange starting position won't -// cause a gun to move through a robot's body, for example. - -// Given: -// jp_list_ptr pointer to list of joint angles, on exit, this is pointing at a static array -// robot_type type of robot for which to get joint information. A particular type, not an instance of a robot. -// gun_num gun number. If in 0..Robot_info[robot_type].n_guns-1, then it is a gun, else it refers to non-animating parts of robot. -// state state about which to get information. Legal states in range 0..N_ANIM_STATES-1, defined in robot.h, are: -// AS_REST, AS_ALERT, AS_FIRE, AS_RECOIL, AS_FLINCH - -// On exit: -// Returns number of joints in list. -// jp_list_ptr is stuffed with a pointer to a static array of joint positions. This pointer is valid forever. +// Tells joint positions for a gun to be in a specified state. +// A gun can have associated with it any number of joints. In order to tell whether a gun is a certain +// state (such as FIRE or ALERT), you should call this function and check the returned joint positions +// against the robot's gun's joint positions. This function should also be called to determine how to +// move a gun into a desired position. +// For now (May 30, 1994), it is assumed that guns will linearly interpolate from one joint position to another. +// There is no ordering of joint movement, so it's impossible to guarantee that a strange starting position won't +// cause a gun to move through a robot's body, for example. + +// Given: +// jp_list_ptr pointer to list of joint angles, on exit, this is pointing at a static array +// robot_type type of robot for which to get joint information. A particular type, not an instance of a robot. +// gun_num gun number. If in 0..Robot_info[robot_type].n_guns-1, then it is a gun, else it refers to non-animating parts of robot. +// state state about which to get information. Legal states in range 0..N_ANIM_STATES-1, defined in robot.h, are: +// AS_REST, AS_ALERT, AS_FIRE, AS_RECOIL, AS_FLINCH + +// On exit: +// Returns number of joints in list. +// jp_list_ptr is stuffed with a pointer to a static array of joint positions. This pointer is valid forever. extern int robot_get_anim_state(jointpos **jp_list_ptr,int robot_type,int gun_num,int state); +#ifdef FAST_FILE_IO +#define robot_info_read_n(ri, n, fp) cfread(ri, sizeof(robot_info), n, fp) +#define jointpos_read_n(jp, n, fp) cfread(jp, sizeof(jointpos), n, fp) +#else /* - * reads a robot_info structure from a CFILE + * reads n robot_info structs from a CFILE */ -extern void robot_info_read(robot_info *ri, CFILE *fp); +extern int robot_info_read_n(robot_info *ri, int n, CFILE *fp); /* - * reads a jointpos structure from a CFILE + * reads n jointpos structs from a CFILE */ -extern void jointpos_read(jointpos *jp, CFILE *fp); +extern int jointpos_read_n(jointpos *jp, int n, CFILE *fp); +#endif #endif diff --git a/main/vclip.c b/main/vclip.c index 3e90f9b5..ae728d2f 100644 --- a/main/vclip.c +++ b/main/vclip.c @@ -16,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: vclip.c,v 1.3 2002-07-26 09:22:05 btb Exp $"; +static char rcsid[] = "$Id: vclip.c,v 1.4 2002-08-02 04:57:19 btb Exp $"; #endif #include @@ -101,19 +101,24 @@ void draw_weapon_vclip(object *obj) } +#ifndef FAST_FILE_IO /* - * reads a vclip structure from a CFILE + * reads n vclip structs from a CFILE */ -void vclip_read(vclip *vc, CFILE *fp) +int vclip_read_n(vclip *vc, int n, CFILE *fp) { - int i; - - vc->play_time = cfile_read_fix(fp); - vc->num_frames = cfile_read_int(fp); - vc->frame_time = cfile_read_fix(fp); - vc->flags = cfile_read_int(fp); - vc->sound_num = cfile_read_short(fp); - for (i = 0; i < VCLIP_MAX_FRAMES; i++) - vc->frames[i].index = cfile_read_short(fp); - vc->light_value = cfile_read_fix(fp); + int i, j; + + for (i = 0; i < n; i++) { + vc[i].play_time = cfile_read_fix(fp); + vc[i].num_frames = cfile_read_int(fp); + vc[i].frame_time = cfile_read_fix(fp); + vc[i].flags = cfile_read_int(fp); + vc[i].sound_num = cfile_read_short(fp); + for (j = 0; j < VCLIP_MAX_FRAMES; j++) + vc[i].frames[j].index = cfile_read_short(fp); + vc[i].light_value = cfile_read_fix(fp); + } + return i; } +#endif diff --git a/main/vclip.h b/main/vclip.h index c9e88f30..01fa19c6 100644 --- a/main/vclip.h +++ b/main/vclip.h @@ -7,7 +7,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. */ @@ -19,31 +19,31 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "piggy.h" #include "cfile.h" -#define VCLIP_SMALL_EXPLOSION 2 -#define VCLIP_PLAYER_HIT 1 -#define VCLIP_MORPHING_ROBOT 10 -#define VCLIP_PLAYER_APPEARANCE 61 -#define VCLIP_POWERUP_DISAPPEARANCE 62 -#define VCLIP_VOLATILE_WALL_HIT 5 -#define VCLIP_WATER_HIT 84 -#define VCLIP_AFTERBURNER_BLOB 95 -#define VCLIP_MONITOR_STATIC 99 +#define VCLIP_SMALL_EXPLOSION 2 +#define VCLIP_PLAYER_HIT 1 +#define VCLIP_MORPHING_ROBOT 10 +#define VCLIP_PLAYER_APPEARANCE 61 +#define VCLIP_POWERUP_DISAPPEARANCE 62 +#define VCLIP_VOLATILE_WALL_HIT 5 +#define VCLIP_WATER_HIT 84 +#define VCLIP_AFTERBURNER_BLOB 95 +#define VCLIP_MONITOR_STATIC 99 -#define VCLIP_MAXNUM 110 -#define VCLIP_MAX_FRAMES 30 +#define VCLIP_MAXNUM 110 +#define VCLIP_MAX_FRAMES 30 //vclip flags -#define VF_ROD 1 //draw as a rod, not a blob +#define VF_ROD 1 //draw as a rod, not a blob typedef struct { - fix play_time; //total time (in seconds) of clip - int num_frames; - fix frame_time; //time (in seconds) of each frame - int flags; - short sound_num; - bitmap_index frames[VCLIP_MAX_FRAMES]; - fix light_value; -} vclip; + fix play_time; //total time (in seconds) of clip + int num_frames; + fix frame_time; //time (in seconds) of each frame + int flags; + short sound_num; + bitmap_index frames[VCLIP_MAX_FRAMES]; + fix light_value; +} __pack__ vclip; extern int Num_vclips; extern vclip Vclip[VCLIP_MAXNUM]; @@ -52,9 +52,13 @@ extern vclip Vclip[VCLIP_MAXNUM]; void draw_vclip_object(object *obj,fix timeleft,int lighted, int vclip_num); extern void draw_weapon_vclip(object *obj); +#ifdef FAST_FILE_IO +#define vclip_read_n(vc, n, fp) cfread(vc, sizeof(vclip), n, fp) +#else /* - * reads a vclip structure from a CFILE + * reads n vclip structs from a CFILE */ -extern void vclip_read(vclip *vc, CFILE *fp); +extern int vclip_read_n(vclip *vc, int n, CFILE *fp); +#endif #endif diff --git a/main/wall.c b/main/wall.c index 2e386b8e..2c3ac24a 100644 --- a/main/wall.c +++ b/main/wall.c @@ -1,3 +1,4 @@ +/* $Id: wall.c,v 1.7 2002-08-02 04:57:19 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. */ @@ -16,7 +17,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: wall.c,v 1.6 2002-07-27 04:39:23 btb Exp $"; +static char rcsid[] = "$Id: wall.c,v 1.7 2002-08-02 04:57:19 btb Exp $"; #endif #include @@ -102,7 +103,7 @@ void kill_stuck_objects(int wallnum); // 1 = YES // 0 = NO int check_transparency( segment * seg, int side ) -{ +{ if ( (seg->sides[side].tmap_num2 & 0x3FFF) == 0) { if (GameBitmaps[Textures[seg->sides[side].tmap_num].index].bm_flags & BM_FLAG_TRANSPARENT ) return 1; @@ -1544,22 +1545,26 @@ void blast_nearby_glass(object *objp, fix damage) } +#ifndef FAST_FILE_IO /* * reads a wclip structure from a CFILE */ -void wclip_read(wclip *wc, CFILE *fp) +int wclip_read_n(wclip *wc, int n, CFILE *fp) { - int i; - - wc->play_time = cfile_read_fix(fp); - wc->num_frames = cfile_read_short(fp); - for (i = 0; i < MAX_CLIP_FRAMES; i++) - wc->frames[i] = cfile_read_short(fp); - wc->open_sound = cfile_read_short(fp); - wc->close_sound = cfile_read_short(fp); - wc->flags = cfile_read_short(fp); - cfread(wc->filename, 13, 1, fp); - wc->pad = cfile_read_byte(fp); + int i, j; + + for (i = 0; i < n; i++) { + wc[i].play_time = cfile_read_fix(fp); + wc[i].num_frames = cfile_read_short(fp); + for (j = 0; j < MAX_CLIP_FRAMES; j++) + wc[i].frames[j] = cfile_read_short(fp); + wc[i].open_sound = cfile_read_short(fp); + wc[i].close_sound = cfile_read_short(fp); + wc[i].flags = cfile_read_short(fp); + cfread(wc[i].filename, 13, 1, fp); + wc[i].pad = cfile_read_byte(fp); + } + return i; } /* @@ -1637,3 +1642,4 @@ extern void active_door_read(active_door *ad, CFILE *fp) ad->back_wallnum[1] = cfile_read_short(fp); ad->time = cfile_read_fix(fp); } +#endif diff --git a/main/wall.h b/main/wall.h index 0ffbef0f..0b897104 100644 --- a/main/wall.h +++ b/main/wall.h @@ -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. */ @@ -21,75 +22,75 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. //#include "vclip.h" -#define MAX_WALLS 254 // Maximum number of walls -#define MAX_WALL_ANIMS 60 // Maximum different types of doors -#define MAX_DOORS 90 // Maximum number of open doors +#define MAX_WALLS 254 // Maximum number of walls +#define MAX_WALL_ANIMS 60 // Maximum different types of doors +#define MAX_DOORS 90 // Maximum number of open doors // Various wall types. -#define WALL_NORMAL 0 // Normal wall -#define WALL_BLASTABLE 1 // Removable (by shooting) wall -#define WALL_DOOR 2 // Door -#define WALL_ILLUSION 3 // Wall that appears to be there, but you can fly thru -#define WALL_OPEN 4 // Just an open side. (Trigger) -#define WALL_CLOSED 5 // Wall. Used for transparent walls. -#define WALL_OVERLAY 6 // Goes over an actual solid side. For triggers -#define WALL_CLOAKED 7 // Can see it, and see through it +#define WALL_NORMAL 0 // Normal wall +#define WALL_BLASTABLE 1 // Removable (by shooting) wall +#define WALL_DOOR 2 // Door +#define WALL_ILLUSION 3 // Wall that appears to be there, but you can fly thru +#define WALL_OPEN 4 // Just an open side. (Trigger) +#define WALL_CLOSED 5 // Wall. Used for transparent walls. +#define WALL_OVERLAY 6 // Goes over an actual solid side. For triggers +#define WALL_CLOAKED 7 // Can see it, and see through it // Various wall flags. -#define WALL_BLASTED 1 // Blasted out wall. -#define WALL_DOOR_OPENED 2 // Open door. -#define WALL_DOOR_LOCKED 8 // Door is locked. -#define WALL_DOOR_AUTO 16 // Door automatically closes after time. -#define WALL_ILLUSION_OFF 32 // Illusionary wall is shut off. -#define WALL_WALL_SWITCH 64 // This wall is openable by a wall switch. -#define WALL_BUDDY_PROOF 128 // Buddy assumes he cannot get through this wall. +#define WALL_BLASTED 1 // Blasted out wall. +#define WALL_DOOR_OPENED 2 // Open door. +#define WALL_DOOR_LOCKED 8 // Door is locked. +#define WALL_DOOR_AUTO 16 // Door automatically closes after time. +#define WALL_ILLUSION_OFF 32 // Illusionary wall is shut off. +#define WALL_WALL_SWITCH 64 // This wall is openable by a wall switch. +#define WALL_BUDDY_PROOF 128 // Buddy assumes he cannot get through this wall. // Wall states -#define WALL_DOOR_CLOSED 0 // Door is closed -#define WALL_DOOR_OPENING 1 // Door is opening. -#define WALL_DOOR_WAITING 2 // Waiting to close -#define WALL_DOOR_CLOSING 3 // Door is closing -#define WALL_DOOR_OPEN 4 // Door is open, and staying open -#define WALL_DOOR_CLOAKING 5 // Wall is going from closed -> open -#define WALL_DOOR_DECLOAKING 6 // Wall is going from open -> closed - -//note: a door is considered opened (i.e., it has WALL_OPENED set) when it -//is more than half way open. Thus, it can have any of OPENING, CLOSING, +#define WALL_DOOR_CLOSED 0 // Door is closed +#define WALL_DOOR_OPENING 1 // Door is opening. +#define WALL_DOOR_WAITING 2 // Waiting to close +#define WALL_DOOR_CLOSING 3 // Door is closing +#define WALL_DOOR_OPEN 4 // Door is open, and staying open +#define WALL_DOOR_CLOAKING 5 // Wall is going from closed -> open +#define WALL_DOOR_DECLOAKING 6 // Wall is going from open -> closed + +//note: a door is considered opened (i.e., it has WALL_OPENED set) when it +//is more than half way open. Thus, it can have any of OPENING, CLOSING, //or WAITING bits set when OPENED is set. -#define KEY_NONE 1 -#define KEY_BLUE 2 -#define KEY_RED 4 -#define KEY_GOLD 8 +#define KEY_NONE 1 +#define KEY_BLUE 2 +#define KEY_RED 4 +#define KEY_GOLD 8 -#define WALL_HPS 100*F1_0 // Normal wall's hp -#define WALL_DOOR_INTERVAL 5*F1_0 // How many seconds a door is open +#define WALL_HPS 100*F1_0 // Normal wall's hp +#define WALL_DOOR_INTERVAL 5*F1_0 // How many seconds a door is open -#define DOOR_OPEN_TIME i2f(2) // How long takes to open -#define DOOR_WAIT_TIME i2f(5) // How long before auto door closes +#define DOOR_OPEN_TIME i2f(2) // How long takes to open +#define DOOR_WAIT_TIME i2f(5) // How long before auto door closes -#define MAX_CLIP_FRAMES 50 +#define MAX_CLIP_FRAMES 50 // WALL_IS_DOORWAY flags. -#define WID_FLY_FLAG 1 -#define WID_RENDER_FLAG 2 -#define WID_RENDPAST_FLAG 4 -#define WID_EXTERNAL_FLAG 8 -#define WID_CLOAKED_FLAG 16 - -//@@// WALL_IS_DOORWAY return values F/R/RP -//@@#define WID_WALL 2 // 0/1/0 wall -//@@#define WID_TRANSPARENT_WALL 6 // 0/1/1 transparent wall -//@@#define WID_ILLUSORY_WALL 3 // 1/1/0 illusory wall -//@@#define WID_TRANSILLUSORY_WALL 7 // 1/1/1 transparent illusory wall -//@@#define WID_NO_WALL 5 // 1/0/1 no wall, can fly through -//@@#define WID_EXTERNAL 8 // 0/0/0/1 don't see it, dont fly through it - -#define MAX_STUCK_OBJECTS 32 +#define WID_FLY_FLAG 1 +#define WID_RENDER_FLAG 2 +#define WID_RENDPAST_FLAG 4 +#define WID_EXTERNAL_FLAG 8 +#define WID_CLOAKED_FLAG 16 + +//@@// WALL_IS_DOORWAY return values F/R/RP +//@@#define WID_WALL 2 // 0/1/0 wall +//@@#define WID_TRANSPARENT_WALL 6 // 0/1/1 transparent wall +//@@#define WID_ILLUSORY_WALL 3 // 1/1/0 illusory wall +//@@#define WID_TRANSILLUSORY_WALL 7 // 1/1/1 transparent illusory wall +//@@#define WID_NO_WALL 5 // 1/0/1 no wall, can fly through +//@@#define WID_EXTERNAL 8 // 0/0/0/1 don't see it, dont fly through it + +#define MAX_STUCK_OBJECTS 32 typedef struct stuckobj { - short objnum, wallnum; - int signature; + short objnum, wallnum; + int signature; } stuckobj; //Start old wall structures @@ -101,7 +102,7 @@ typedef struct v16_wall { byte trigger; // Which trigger is associated with the wall. byte clip_num; // Which animation associated with the wall. byte keys; -} v16_wall; +} __pack__ v16_wall; typedef struct v19_wall { int segnum,sidenum; // Seg & side for this wall @@ -112,7 +113,7 @@ typedef struct v19_wall { byte clip_num; // Which animation associated with the wall. byte keys; int linked_wall; // number of linked wall -} v19_wall; +} __pack__ v19_wall; typedef struct v19_door { int n_parts; // for linked walls @@ -120,7 +121,7 @@ typedef struct v19_door { short side[2]; // Side number of door. short type[2]; // What kind of door animation. fix open; // How long it has been open. -} v19_door; +} __pack__ v19_door; //End old wall structures @@ -137,14 +138,14 @@ typedef struct wall { byte controlling_trigger;// which trigger causes something to happen here. Not like "trigger" above, which is the trigger on this wall. // Note: This gets stuffed at load time in gamemine.c. Don't try to use it in the editor. You will be sorry! byte cloak_value; // if this wall is cloaked, the fade value -} wall; +} __pack__ wall; typedef struct active_door { int n_parts; // for linked walls short front_wallnum[2]; // front wall numbers for this door short back_wallnum[2]; // back wall numbers for this door fix time; // how long been opening, closing, waiting -} active_door; +} __pack__ active_door; typedef struct cloaking_wall { short front_wallnum; // front wall numbers for this door @@ -169,19 +170,19 @@ typedef struct { short flags; char filename[13]; char pad; -} wclip; +} __pack__ wclip; -extern char Wall_names[7][10]; +extern char Wall_names[7][10]; //#define WALL_IS_DOORWAY(seg,side) wall_is_doorway(seg, side) #define WALL_IS_DOORWAY(seg,side) (((seg)->children[(side)] == -1) ? WID_RENDER_FLAG : ((seg)->children[(side)] == -2) ? WID_EXTERNAL_FLAG : ((seg)->sides[(side)].wall_num == -1) ? (WID_FLY_FLAG|WID_RENDPAST_FLAG) : wall_is_doorway((seg), (side))) -extern wall Walls[MAX_WALLS]; // Master walls array -extern int Num_walls; // Number of walls +extern wall Walls[MAX_WALLS]; // Master walls array +extern int Num_walls; // Number of walls -extern active_door ActiveDoors[MAX_DOORS]; // Master doors array -extern int Num_open_doors; // Number of open doors +extern active_door ActiveDoors[MAX_DOORS]; // Master doors array +extern int Num_open_doors; // Number of open doors extern cloaking_wall CloakingWalls[]; extern int Num_cloaking_walls; @@ -193,11 +194,11 @@ extern int walls_bm_num[MAX_WALL_ANIMS]; // Initializes all walls (i.e. no special walls.) extern void wall_init(); - + // Automatically checks if a there is a doorway (i.e. can fly through) extern int wall_is_doorway ( segment *seg, int side ); -// Deteriorate appearance of wall. (Changes bitmap (paste-ons)) +// Deteriorate appearance of wall. (Changes bitmap (paste-ons)) extern void wall_damage(segment *seg, int side, fix damage); // Destroys a blastable wall. (So it is an opening afterwards) @@ -213,17 +214,17 @@ void do_door_open(int door_num); // Closes a door, including animation and other processing. void do_door_close(int door_num); -// Opens a door +// Opens a door extern void wall_open_door(segment *seg, int side); -// Closes a door +// Closes a door extern void wall_close_door(segment *seg, int side); //return codes for wall_hit_process() -#define WHP_NOT_SPECIAL 0 //wasn't a quote-wall-unquote -#define WHP_NO_KEY 1 //hit door, but didn't have key -#define WHP_BLASTABLE 2 //hit blastable wall -#define WHP_DOOR 3 //a door (which will now be opening) +#define WHP_NOT_SPECIAL 0 //wasn't a quote-wall-unquote +#define WHP_NO_KEY 1 //hit door, but didn't have key +#define WHP_BLASTABLE 2 //hit blastable wall +#define WHP_DOOR 3 //a door (which will now be opening) // Determines what happens when a wall is shot //obj is the object that hit...either a weapon or the player himself @@ -238,10 +239,10 @@ extern void reset_walls(); // Called once per frame.. void wall_frame_process(); -extern stuckobj Stuck_objects[MAX_STUCK_OBJECTS]; +extern stuckobj Stuck_objects[MAX_STUCK_OBJECTS]; -// An object got stuck in a door (like a flare). -// Add global entry. +// An object got stuck in a door (like a flare). +// Add global entry. extern void add_stuck_object(object *objp, int segnum, int sidenum); extern void remove_obsolete_stuck_objects(void); @@ -255,10 +256,18 @@ void kill_stuck_objects(int wallnum); void start_wall_cloak(segment *seg, int side); void start_wall_decloak(segment *seg, int side); +#ifdef FAST_FILE_IO +#define wclip_read_n(wc, n, fp) cfread(wc, sizeof(wclip), n, fp) +#define v16_wall_read(w, fp) cfread(w, sizeof(v16_wall), 1, fp) +#define v19_wall_read(w, fp) cfread(w, sizeof(v19_wall), 1, fp) +#define wall_read(w, fp) cfread(w, sizeof(wall), 1, fp) +#define v19_door_read(d, fp) cfread(d, sizeof(v19_door), 1, fp) +#define active_door_read(d, fp) cfread(d, sizeof(active_door), 1, fp) +#else /* - * reads a wclip structure from a CFILE + * reads n wclip structs from a CFILE */ -extern void wclip_read(wclip *wc, CFILE *fp); +extern int wclip_read_n(wclip *wc, int n, CFILE *fp); /* * reads a v16_wall structure from a CFILE @@ -284,5 +293,6 @@ extern void v19_door_read(v19_door *d, CFILE *fp); * reads an active_door structure from a CFILE */ extern void active_door_read(active_door *ad, CFILE *fp); +#endif #endif diff --git a/main/weapon.c b/main/weapon.c index e7c07418..f9c99e16 100644 --- a/main/weapon.c +++ b/main/weapon.c @@ -16,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #ifdef RCS -static char rcsid[] = "$Id: weapon.c,v 1.4 2002-07-30 04:52:01 btb Exp $"; +static char rcsid[] = "$Id: weapon.c,v 1.5 2002-08-02 04:57:19 btb Exp $"; #endif #include @@ -1301,68 +1301,74 @@ void tactile_set_button_jolt () } /* - * reads a weapon_info structure from a CFILE + * reads n weapon_info structs from a CFILE */ -extern void weapon_info_read(weapon_info *wi, CFILE *fp) +extern int weapon_info_read_n(weapon_info *wi, int n, CFILE *fp, int file_version) { - int i; - - wi->render_type = cfile_read_byte(fp); - wi->persistent = cfile_read_byte(fp); - wi->model_num = cfile_read_short(fp); - wi->model_num_inner = cfile_read_short(fp); - - wi->flash_vclip = cfile_read_byte(fp); - wi->robot_hit_vclip = cfile_read_byte(fp); - wi->flash_sound = cfile_read_short(fp); - - wi->wall_hit_vclip = cfile_read_byte(fp); - wi->fire_count = cfile_read_byte(fp); - wi->robot_hit_sound = cfile_read_short(fp); - - wi->ammo_usage = cfile_read_byte(fp); - wi->weapon_vclip = cfile_read_byte(fp); - wi->wall_hit_sound = cfile_read_short(fp); - - wi->destroyable = cfile_read_byte(fp); - wi->matter = cfile_read_byte(fp); - wi->bounce = cfile_read_byte(fp); - wi->homing_flag = cfile_read_byte(fp); - - wi->speedvar = cfile_read_byte(fp); - wi->flags = cfile_read_byte(fp); - wi->flash = cfile_read_byte(fp); - wi->afterburner_size = cfile_read_byte(fp); - -#ifndef SHAREWARE - wi->children = cfile_read_byte(fp); -#endif + int i, j; + + for (i = 0; i < n; i++) { + wi[i].render_type = cfile_read_byte(fp); + wi[i].persistent = cfile_read_byte(fp); + wi[i].model_num = cfile_read_short(fp); + wi[i].model_num_inner = cfile_read_short(fp); + + wi[i].flash_vclip = cfile_read_byte(fp); + wi[i].robot_hit_vclip = cfile_read_byte(fp); + wi[i].flash_sound = cfile_read_short(fp); + + wi[i].wall_hit_vclip = cfile_read_byte(fp); + wi[i].fire_count = cfile_read_byte(fp); + wi[i].robot_hit_sound = cfile_read_short(fp); + + wi[i].ammo_usage = cfile_read_byte(fp); + wi[i].weapon_vclip = cfile_read_byte(fp); + wi[i].wall_hit_sound = cfile_read_short(fp); + + wi[i].destroyable = cfile_read_byte(fp); + wi[i].matter = cfile_read_byte(fp); + wi[i].bounce = cfile_read_byte(fp); + wi[i].homing_flag = cfile_read_byte(fp); + + wi[i].speedvar = cfile_read_byte(fp); + wi[i].flags = cfile_read_byte(fp); + wi[i].flash = cfile_read_byte(fp); + wi[i].afterburner_size = cfile_read_byte(fp); + + if (file_version >= 3) + wi[i].children = cfile_read_byte(fp); + else + wi[i].children = -1; - wi->energy_usage = cfile_read_fix(fp); - wi->fire_wait = cfile_read_fix(fp); - -#ifndef SHAREWARE - wi->multi_damage_scale = cfile_read_fix(fp); -#endif - - wi->bitmap.index = cfile_read_short(fp); // bitmap_index = short - - wi->blob_size = cfile_read_fix(fp); - wi->flash_size = cfile_read_fix(fp); - wi->impact_size = cfile_read_fix(fp); - for (i = 0; i < NDL; i++) - wi->strength[i] = cfile_read_fix(fp); - for (i = 0; i < NDL; i++) - wi->speed[i] = cfile_read_fix(fp); - wi->mass = cfile_read_fix(fp); - wi->drag = cfile_read_fix(fp); - wi->thrust = cfile_read_fix(fp); - wi->po_len_to_width_ratio = cfile_read_fix(fp); - wi->light = cfile_read_fix(fp); - wi->lifetime = cfile_read_fix(fp); - wi->damage_radius = cfile_read_fix(fp); - wi->picture.index = cfile_read_short(fp); // bitmap_index is a short -#ifndef SHAREWARE - wi->hires_picture.index = cfile_read_short(fp); // bitmap_index is a short -#endif + wi[i].energy_usage = cfile_read_fix(fp); + wi[i].fire_wait = cfile_read_fix(fp); + + if (file_version >= 3) + wi[i].multi_damage_scale = cfile_read_fix(fp); + else + wi[i].multi_damage_scale = F1_0; + + bitmap_index_read(&wi[i].bitmap, fp); + + wi[i].blob_size = cfile_read_fix(fp); + wi[i].flash_size = cfile_read_fix(fp); + wi[i].impact_size = cfile_read_fix(fp); + for (j = 0; j < NDL; j++) + wi[i].strength[j] = cfile_read_fix(fp); + for (j = 0; j < NDL; j++) + wi[i].speed[j] = cfile_read_fix(fp); + wi[i].mass = cfile_read_fix(fp); + wi[i].drag = cfile_read_fix(fp); + wi[i].thrust = cfile_read_fix(fp); + wi[i].po_len_to_width_ratio = cfile_read_fix(fp); + wi[i].light = cfile_read_fix(fp); + wi[i].lifetime = cfile_read_fix(fp); + wi[i].damage_radius = cfile_read_fix(fp); + bitmap_index_read(&wi[i].picture, fp); + if (file_version >= 3) + bitmap_index_read(&wi[i].hires_picture, fp); + else + wi[i].hires_picture.index = wi[i].picture.index; + } + return i; } diff --git a/main/weapon.h b/main/weapon.h index 6bc8c73d..a68024ee 100644 --- a/main/weapon.h +++ b/main/weapon.h @@ -1,3 +1,4 @@ +/* $Id: weapon.h,v 1.4 2002-08-02 04:57:19 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. */ @@ -21,144 +22,193 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "cfile.h" //weapon info flags -#define WIF_PLACABLE 1 //can be placed by level designer +#define WIF_PLACABLE 1 //can be placed by level designer + +typedef struct v2_weapon_info { + byte render_type; // How to draw 0=laser, 1=blob, 2=object + byte persistent; // 0 = dies when it hits something, 1 = continues (eg, fusion cannon) + short model_num; // Model num if rendertype==2. + short model_num_inner; // Model num of inner part if rendertype==2. + + byte flash_vclip; // What vclip to use for muzzle flash + byte robot_hit_vclip; // What vclip for impact with robot + short flash_sound; // What sound to play when fired + + byte wall_hit_vclip; // What vclip for impact with wall + byte fire_count; // Number of bursts fired from EACH GUN per firing. For weapons which fire from both sides, 3*fire_count shots will be fired. + short robot_hit_sound; // What sound for impact with robot + + byte ammo_usage; // How many units of ammunition it uses. + byte weapon_vclip; // Vclip to render for the weapon, itself. + short wall_hit_sound; // What sound for impact with wall + + byte destroyable; // If !0, this weapon can be destroyed by another weapon. + byte matter; // Flag: set if this object is matter (as opposed to energy) + byte bounce; // 1==always bounces, 2=bounces twice + byte homing_flag; // Set if this weapon can home in on a target. + + ubyte speedvar; // allowed variance in speed below average, /128: 64 = 50% meaning if speed = 100, can be 50..100 + + ubyte flags; // see values above + + byte flash; // Flash effect + byte afterburner_size; // Size of blobs in F1_0/16 units, specify in bitmaps.tbl as floating point. Player afterburner size = 2.5. + + fix energy_usage; // How much fuel is consumed to fire this weapon. + fix fire_wait; // Time until this weapon can be fired again. + + bitmap_index bitmap; // Pointer to bitmap if rendertype==0 or 1. + + fix blob_size; // Size of blob if blob type + fix flash_size; // How big to draw the flash + fix impact_size; // How big of an impact + fix strength[NDL]; // How much damage it can inflict + fix speed[NDL]; // How fast it can move, difficulty level based. + fix mass; // How much mass it has + fix drag; // How much drag it has + fix thrust; // How much thrust it has + fix po_len_to_width_ratio; // For polyobjects, the ratio of len/width. (10 maybe?) + fix light; // Amount of light this weapon casts. + fix lifetime; // Lifetime in seconds of this weapon. + fix damage_radius; // Radius of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit +//-- unused-- fix damage_force; // Force of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit +// damage_force was a real mess. Wasn't Difficulty_level based, and was being applied instead of weapon's actual strength. Now use 2*strength instead. --MK, 01/19/95 + bitmap_index picture; // a picture of the weapon for the cockpit +} v2_weapon_info; typedef struct weapon_info { - byte render_type; // How to draw 0=laser, 1=blob, 2=object - byte persistent; // 0 = dies when it hits something, 1 = continues (eg, fusion cannon) - short model_num; // Model num if rendertype==2. - short model_num_inner; // Model num of inner part if rendertype==2. - - byte flash_vclip; // What vclip to use for muzzle flash - byte robot_hit_vclip; // What vclip for impact with robot - short flash_sound; // What sound to play when fired - - byte wall_hit_vclip; // What vclip for impact with wall - byte fire_count; // Number of bursts fired from EACH GUN per firing. For weapons which fire from both sides, 3*fire_count shots will be fired. - short robot_hit_sound; // What sound for impact with robot - - byte ammo_usage; // How many units of ammunition it uses. - byte weapon_vclip; // Vclip to render for the weapon, itself. - short wall_hit_sound; // What sound for impact with wall - - byte destroyable; // If !0, this weapon can be destroyed by another weapon. - byte matter; // Flag: set if this object is matter (as opposed to energy) - byte bounce; // 1==always bounces, 2=bounces twice - byte homing_flag; // Set if this weapon can home in on a target. - - ubyte speedvar; // allowed variance in speed below average, /128: 64 = 50% meaning if speed = 100, can be 50..100 - - ubyte flags; // see values above - - byte flash; // Flash effect - byte afterburner_size; // Size of blobs in F1_0/16 units, specify in bitmaps.tbl as floating point. Player afterburner size = 2.5. - -#ifndef SHAREWARE - byte children; // ID of weapon to drop if this contains children. -1 means no children. -#endif - - fix energy_usage; // How much fuel is consumed to fire this weapon. - fix fire_wait; // Time until this weapon can be fired again. - -#ifndef SHAREWARE - fix multi_damage_scale; // Scale damage by this amount when applying to player in multiplayer. F1_0 means no change. -#endif - - bitmap_index bitmap; // Pointer to bitmap if rendertype==0 or 1. - - fix blob_size; // Size of blob if blob type - fix flash_size; // How big to draw the flash - fix impact_size; // How big of an impact - fix strength[NDL]; // How much damage it can inflict - fix speed[NDL]; // How fast it can move, difficulty level based. - fix mass; // How much mass it has - fix drag; // How much drag it has - fix thrust; // How much thrust it has - fix po_len_to_width_ratio; // For polyobjects, the ratio of len/width. (10 maybe?) - fix light; // Amount of light this weapon casts. - fix lifetime; // Lifetime in seconds of this weapon. - fix damage_radius; // Radius of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit -//-- unused-- fix damage_force; // Force of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit + byte render_type; // How to draw 0=laser, 1=blob, 2=object + byte persistent; // 0 = dies when it hits something, 1 = continues (eg, fusion cannon) + short model_num; // Model num if rendertype==2. + short model_num_inner; // Model num of inner part if rendertype==2. + + byte flash_vclip; // What vclip to use for muzzle flash + byte robot_hit_vclip; // What vclip for impact with robot + short flash_sound; // What sound to play when fired + + byte wall_hit_vclip; // What vclip for impact with wall + byte fire_count; // Number of bursts fired from EACH GUN per firing. For weapons which fire from both sides, 3*fire_count shots will be fired. + short robot_hit_sound; // What sound for impact with robot + + byte ammo_usage; // How many units of ammunition it uses. + byte weapon_vclip; // Vclip to render for the weapon, itself. + short wall_hit_sound; // What sound for impact with wall + + byte destroyable; // If !0, this weapon can be destroyed by another weapon. + byte matter; // Flag: set if this object is matter (as opposed to energy) + byte bounce; // 1==always bounces, 2=bounces twice + byte homing_flag; // Set if this weapon can home in on a target. + + ubyte speedvar; // allowed variance in speed below average, /128: 64 = 50% meaning if speed = 100, can be 50..100 + + ubyte flags; // see values above + + byte flash; // Flash effect + byte afterburner_size; // Size of blobs in F1_0/16 units, specify in bitmaps.tbl as floating point. Player afterburner size = 2.5. + + /* not present in shareware datafiles */ + byte children; // ID of weapon to drop if this contains children. -1 means no children. + + fix energy_usage; // How much fuel is consumed to fire this weapon. + fix fire_wait; // Time until this weapon can be fired again. + + /* not present in shareware datafiles */ + fix multi_damage_scale; // Scale damage by this amount when applying to player in multiplayer. F1_0 means no change. + + bitmap_index bitmap; // Pointer to bitmap if rendertype==0 or 1. + + fix blob_size; // Size of blob if blob type + fix flash_size; // How big to draw the flash + fix impact_size; // How big of an impact + fix strength[NDL]; // How much damage it can inflict + fix speed[NDL]; // How fast it can move, difficulty level based. + fix mass; // How much mass it has + fix drag; // How much drag it has + fix thrust; // How much thrust it has + fix po_len_to_width_ratio; // For polyobjects, the ratio of len/width. (10 maybe?) + fix light; // Amount of light this weapon casts. + fix lifetime; // Lifetime in seconds of this weapon. + fix damage_radius; // Radius of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit +//-- unused-- fix damage_force; // Force of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit // damage_force was a real mess. Wasn't Difficulty_level based, and was being applied instead of weapon's actual strength. Now use 2*strength instead. --MK, 01/19/95 - bitmap_index picture; // a picture of the weapon for the cockpit -#ifndef SHAREWARE - bitmap_index hires_picture; // a hires picture of the above -#endif -} weapon_info; + bitmap_index picture; // a picture of the weapon for the cockpit + /* not present in shareware datafiles */ + bitmap_index hires_picture; // a hires picture of the above +} __pack__ weapon_info; -#define REARM_TIME (F1_0) +#define REARM_TIME (F1_0) -#define WEAPON_DEFAULT_LIFETIME (F1_0*12) // Lifetime of an object if a bozo forgets to define it. +#define WEAPON_DEFAULT_LIFETIME (F1_0*12) // Lifetime of an object if a bozo forgets to define it. -#define WEAPON_TYPE_WEAK_LASER 0 -#define WEAPON_TYPE_STRONG_LASER 1 -#define WEAPON_TYPE_CANNON_BALL 2 -#define WEAPON_TYPE_MISSILE 3 +#define WEAPON_TYPE_WEAK_LASER 0 +#define WEAPON_TYPE_STRONG_LASER 1 +#define WEAPON_TYPE_CANNON_BALL 2 +#define WEAPON_TYPE_MISSILE 3 -#define MAX_WEAPON_TYPES 70 +#define MAX_WEAPON_TYPES 70 -#define WEAPON_RENDER_NONE -1 -#define WEAPON_RENDER_LASER 0 -#define WEAPON_RENDER_BLOB 1 -#define WEAPON_RENDER_POLYMODEL 2 -#define WEAPON_RENDER_VCLIP 3 +#define WEAPON_RENDER_NONE -1 +#define WEAPON_RENDER_LASER 0 +#define WEAPON_RENDER_BLOB 1 +#define WEAPON_RENDER_POLYMODEL 2 +#define WEAPON_RENDER_VCLIP 3 -#define MAX_PRIMARY_WEAPONS 10 -#define MAX_SECONDARY_WEAPONS 10 +#define MAX_PRIMARY_WEAPONS 10 +#define MAX_SECONDARY_WEAPONS 10 //given a weapon index, return the flag value #define HAS_FLAG(index) (1<<(index)) -// Weapon flags, if player->weapon_flags & WEAPON_FLAG is set, then the player has this weapon -#define HAS_LASER_FLAG HAS_FLAG(LASER_INDEX) -#define HAS_VULCAN_FLAG HAS_FLAG(VULCAN_INDEX) -#define HAS_SPREADFIRE_FLAG HAS_FLAG(SPREADFIRE_INDEX) -#define HAS_PLASMA_FLAG HAS_FLAG(PLASMA_INDEX) -#define HAS_FUSION_FLAG HAS_FLAG(FUSION_INDEX) - -#define HAS_CONCUSSION_FLAG HAS_FLAG(CONCUSSION_INDEX) -#define HAS_HOMING_FLAG HAS_FLAG(HOMING_INDEX) -#define HAS_PROXIMITY_FLAG HAS_FLAG(PROXIMITY_INDEX) -#define HAS_SMART_FLAG HAS_FLAG(SMART_INDEX) -#define HAS_MEGA_FLAG HAS_FLAG(MEGA_INDEX) - -#define CLASS_PRIMARY 0 -#define CLASS_SECONDARY 1 - -#define LASER_INDEX 0 -#define VULCAN_INDEX 1 -#define SPREADFIRE_INDEX 2 -#define PLASMA_INDEX 3 -#define FUSION_INDEX 4 -#define SUPER_LASER_INDEX 5 -#define GAUSS_INDEX 6 -#define HELIX_INDEX 7 -#define PHOENIX_INDEX 8 -#define OMEGA_INDEX 9 - -#define CONCUSSION_INDEX 0 -#define HOMING_INDEX 1 -#define PROXIMITY_INDEX 2 -#define SMART_INDEX 3 -#define MEGA_INDEX 4 -#define SMISSILE1_INDEX 5 -#define GUIDED_INDEX 6 -#define SMART_MINE_INDEX 7 -#define SMISSILE4_INDEX 8 -#define SMISSILE5_INDEX 9 - -#define SUPER_WEAPON 5 - -#define VULCAN_AMMO_SCALE 0xcc163 //(0x198300/2) //multiply ammo by this before displaying - -#define NUM_SMART_CHILDREN 6 // Number of smart children created by default. +// Weapon flags, if player->weapon_flags & WEAPON_FLAG is set, then the player has this weapon +#define HAS_LASER_FLAG HAS_FLAG(LASER_INDEX) +#define HAS_VULCAN_FLAG HAS_FLAG(VULCAN_INDEX) +#define HAS_SPREADFIRE_FLAG HAS_FLAG(SPREADFIRE_INDEX) +#define HAS_PLASMA_FLAG HAS_FLAG(PLASMA_INDEX) +#define HAS_FUSION_FLAG HAS_FLAG(FUSION_INDEX) + +#define HAS_CONCUSSION_FLAG HAS_FLAG(CONCUSSION_INDEX) +#define HAS_HOMING_FLAG HAS_FLAG(HOMING_INDEX) +#define HAS_PROXIMITY_FLAG HAS_FLAG(PROXIMITY_INDEX) +#define HAS_SMART_FLAG HAS_FLAG(SMART_INDEX) +#define HAS_MEGA_FLAG HAS_FLAG(MEGA_INDEX) + +#define CLASS_PRIMARY 0 +#define CLASS_SECONDARY 1 + +#define LASER_INDEX 0 +#define VULCAN_INDEX 1 +#define SPREADFIRE_INDEX 2 +#define PLASMA_INDEX 3 +#define FUSION_INDEX 4 +#define SUPER_LASER_INDEX 5 +#define GAUSS_INDEX 6 +#define HELIX_INDEX 7 +#define PHOENIX_INDEX 8 +#define OMEGA_INDEX 9 + +#define CONCUSSION_INDEX 0 +#define HOMING_INDEX 1 +#define PROXIMITY_INDEX 2 +#define SMART_INDEX 3 +#define MEGA_INDEX 4 +#define SMISSILE1_INDEX 5 +#define GUIDED_INDEX 6 +#define SMART_MINE_INDEX 7 +#define SMISSILE4_INDEX 8 +#define SMISSILE5_INDEX 9 + +#define SUPER_WEAPON 5 + +#define VULCAN_AMMO_SCALE 0xcc163 //(0x198300/2) //multiply ammo by this before displaying + +#define NUM_SMART_CHILDREN 6 // Number of smart children created by default. extern weapon_info Weapon_info[]; extern int N_weapon_types; extern void do_weapon_select(int weapon_num, int secondary_flag); extern void show_weapon_status(void); -extern byte Primary_weapon, Secondary_weapon; +extern byte Primary_weapon, Secondary_weapon; extern ubyte Primary_weapon_to_weapon_info[MAX_PRIMARY_WEAPONS]; extern ubyte Secondary_weapon_to_weapon_info[MAX_SECONDARY_WEAPONS]; @@ -176,29 +226,29 @@ extern ubyte Secondary_weapon_to_powerup[MAX_SECONDARY_WEAPONS]; extern ubyte Primary_last_was_super[MAX_PRIMARY_WEAPONS]; extern ubyte Secondary_last_was_super[MAX_SECONDARY_WEAPONS]; -extern void auto_select_weapon(int weapon_type); //parm is primary or secondary +extern void auto_select_weapon(int weapon_type); //parm is primary or secondary extern void select_weapon(int weapon_num, int secondary_flag, int print_message,int wait_for_rearm); -extern char *Primary_weapon_names_short[]; -extern char *Secondary_weapon_names_short[]; -extern char *Primary_weapon_names[]; -extern char *Secondary_weapon_names[]; -extern int Primary_ammo_max[MAX_PRIMARY_WEAPONS]; -extern ubyte Secondary_ammo_max[MAX_SECONDARY_WEAPONS]; -extern byte Weapon_is_energy[MAX_WEAPON_TYPES]; - -#define HAS_WEAPON_FLAG 1 -#define HAS_ENERGY_FLAG 2 -#define HAS_AMMO_FLAG 4 +extern char *Primary_weapon_names_short[]; +extern char *Secondary_weapon_names_short[]; +extern char *Primary_weapon_names[]; +extern char *Secondary_weapon_names[]; +extern int Primary_ammo_max[MAX_PRIMARY_WEAPONS]; +extern ubyte Secondary_ammo_max[MAX_SECONDARY_WEAPONS]; +extern byte Weapon_is_energy[MAX_WEAPON_TYPES]; + +#define HAS_WEAPON_FLAG 1 +#define HAS_ENERGY_FLAG 2 +#define HAS_AMMO_FLAG 4 #define HAS_ALL (HAS_WEAPON_FLAG|HAS_ENERGY_FLAG|HAS_AMMO_FLAG) -// ------------------------------------------------------------------------------------ -// Return: +//----------------------------------------------------------------------------- +// Return: // Bits set: -// HAS_WEAPON_FLAG -// HAS_ENERGY_FLAG -// HAS_AMMO_FLAG -// HAS_SUPER_FLAG +// HAS_WEAPON_FLAG +// HAS_ENERGY_FLAG +// HAS_AMMO_FLAG +// HAS_SUPER_FLAG extern int player_has_weapon(int weapon_num, int secondary_flag); //called when one of these weapons is picked up @@ -217,7 +267,7 @@ extern int attempt_to_steal_item(object *objp, int player_num); //this function is for when the player intentionally drops a powerup extern int spit_powerup(object *spitter, int id, int seed); -#define SMEGA_ID 40 +#define SMEGA_ID 40 extern void rock_the_mine_frame(void); extern void smega_rock_stuff(void); @@ -225,8 +275,8 @@ extern void init_smega_detonates(void); extern void tactile_set_button_jolt (void); /* - * reads a weapon_info structure from a CFILE + * reads n weapon_info structs from a CFILE */ -extern void weapon_info_read(weapon_info *wi, CFILE *fp); +extern int weapon_info_read_n(weapon_info *wi, int n, CFILE *fp, int file_version); #endif -- 2.39.2