1 /* $Id: bmread.c,v 1.6 2004-08-28 23:17:45 schaffner Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Routines to parse bitmaps.tbl
69 #include "editor/texpage.h"
81 #define BM_WALL_ANIMS 12
85 #define BM_GAUGES_HIRES 21
87 #define MAX_BITMAPS_PER_BRUSH 30
89 extern player_ship only_player_ship; // In bm.c
92 short N_ObjBitmapPtrs=0;
93 static int Num_robot_ais = 0;
94 int TmapList[MAX_TEXTURES];
95 char Powerup_names[MAX_POWERUP_TYPES][POWERUP_NAME_LENGTH];
96 char Robot_names[MAX_ROBOT_TYPES][ROBOT_NAME_LENGTH];
98 //---------------- Internal variables ---------------------------
99 static int Registered_only = 0; // Gets set by ! in column 1.
100 static int SuperX = -1;
101 static int Installed=0;
103 static short tmap_count = 0;
104 static short texture_count = 0;
105 static short clip_count = 0;
106 static short clip_num;
107 static short sound_num;
110 static int hit_sound = -1;
111 static sbyte bm_flag = BM_NONE;
112 static int abm_flag = 0;
113 static int rod_flag = 0;
114 static short wall_open_sound, wall_close_sound,wall_explodes,wall_blastable, wall_hidden;
116 static int obj_eclip;
117 static char *dest_bm; //clip number to play when destroyed
118 static int dest_vclip; //what vclip to play when exploding
119 static int dest_eclip; //what eclip to play when exploding
120 static fix dest_size; //3d size of explosion
121 static int crit_clip; //clip number to play when destroyed
122 static int crit_flag; //flag if this is a destroyed eclip
123 static int tmap1_flag; //flag if this is used as tmap_num (not tmap_num2)
124 static int num_sounds=0;
126 int linenum; //line int table currently being parsed
128 //------------------- Useful macros and variables ---------------
129 #define REMOVE_EOL(s) remove_char((s),'\n')
130 #define REMOVE_COMMENTS(s) remove_char((s),';')
131 #define REMOVE_DOTS(s) remove_char((s),'.')
133 #define IFTOK(str) if (!strcmp(arg, str))
134 char *space = { " \t" };
135 //--unused-- char *equal = { "=" };
136 char *equal_space = { " \t=" };
139 // For the sake of LINT, defining prototypes to module's functions
140 void bm_read_alias(void);
141 void bm_read_marker(void);
142 void bm_read_robot_ai(void);
143 void bm_read_powerup(int unused_flag);
144 void bm_read_hostage(void);
145 void bm_read_robot(void);
146 void bm_read_weapon(int unused_flag);
147 void bm_read_reactor(void);
148 void bm_read_exitmodel(void);
149 void bm_read_player_ship(void);
150 void bm_read_some_file(void);
151 void bm_read_sound(void);
152 void bm_write_extra_robots(void);
153 void clear_to_end_of_line(void);
154 void verify_textures(void);
157 //----------------------------------------------------------------------
158 void remove_char( char * s, char c )
165 //---------------------------------------------------------------
166 int compute_average_pixel(grs_bitmap *new)
168 int row, column, color;
170 int total_red, total_green, total_blue;
172 pptr = (char *)new->bm_data;
178 for (row=0; row<new->bm_h; row++)
179 for (column=0; column<new->bm_w; column++) {
181 total_red += gr_palette[color*3];
182 total_green += gr_palette[color*3+1];
183 total_blue += gr_palette[color*3+2];
186 total_red /= (new->bm_h * new->bm_w);
187 total_green /= (new->bm_h * new->bm_w);
188 total_blue /= (new->bm_h * new->bm_w);
190 return BM_XRGB(total_red/2, total_green/2, total_blue/2);
193 //---------------------------------------------------------------
194 // Loads a bitmap from either the piggy file, a r64 file, or a
195 // whatever extension is passed.
197 bitmap_index bm_load_sub( char * filename )
199 bitmap_index bitmap_num;
202 int iff_error; //reference parm to avoid warning message
205 bitmap_num.index = 0;
208 if (Registered_only) {
209 //mprintf( 0, "Skipping registered-only bitmap '%s'\n", filename );
214 _splitpath( filename, NULL, NULL, fname, NULL );
216 bitmap_num=piggy_find_bitmap( fname );
217 if (bitmap_num.index) {
218 //mprintf(( 0, "Found bitmap '%s' in pig!\n", fname ));
222 MALLOC( new, grs_bitmap, 1 );
223 iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal);
225 if (iff_error != IFF_NO_ERROR) {
226 mprintf((1, "File %s - IFF error: %s",filename,iff_errormsg(iff_error)));
227 Error("File <%s> - IFF error: %s, line %d",filename,iff_errormsg(iff_error),linenum);
230 if ( iff_has_transparency )
231 gr_remap_bitmap_good( new, newpal, iff_transparent_color, SuperX );
233 gr_remap_bitmap_good( new, newpal, -1, SuperX );
235 new->avg_color = compute_average_pixel(new);
237 // -- mprintf((0, "N" ));
238 bitmap_num = piggy_register_bitmap( new, fname, 0 );
243 extern grs_bitmap bogus_bitmap;
244 extern ubyte bogus_bitmap_initialized;
245 extern digi_sound bogus_sound;
247 void ab_load( char * filename, bitmap_index bmp[], int *nframes )
249 grs_bitmap * bm[MAX_BITMAPS_PER_BRUSH];
252 int iff_error; //reference parm to avoid warning message
258 if (Registered_only) {
259 Assert( bogus_bitmap_initialized != 0 );
260 mprintf(( 0, "Skipping registered-only animation '%s'\n", filename ));
261 bmp[0].index = 0; //index of bogus bitmap==0 (I think) //&bogus_bitmap;
268 _splitpath( filename, NULL, NULL, fname, NULL );
270 for (i=0; i<MAX_BITMAPS_PER_BRUSH; i++ ) {
271 sprintf( tempname, "%s#%d", fname, i );
272 bi = piggy_find_bitmap( tempname );
276 //mprintf(( 0, "Found animation frame %d, %s, in piggy file\n", i, tempname ));
284 // Note that last argument passes an address to the array newpal (which is a pointer).
285 // type mismatch found using lint, will substitute this line with an adjusted
286 // one. If fatal error, then it can be easily changed.
287 // iff_error = iff_read_animbrush(filename,bm,MAX_BITMAPS_PER_BRUSH,nframes,&newpal);
288 iff_error = iff_read_animbrush(filename,bm,MAX_BITMAPS_PER_BRUSH,nframes,newpal);
289 if (iff_error != IFF_NO_ERROR) {
290 mprintf((1,"File %s - IFF error: %s",filename,iff_errormsg(iff_error)));
291 Error("File <%s> - IFF error: %s, line %d",filename,iff_errormsg(iff_error),linenum);
294 for (i=0;i< *nframes; i++) {
295 bitmap_index new_bmp;
296 sprintf( tempname, "%s#%d", fname, i );
297 if ( iff_has_transparency )
298 gr_remap_bitmap_good( bm[i], newpal, iff_transparent_color, SuperX );
300 gr_remap_bitmap_good( bm[i], newpal, -1, SuperX );
302 bm[i]->avg_color = compute_average_pixel(bm[i]);
304 new_bmp = piggy_register_bitmap( bm[i], tempname, 0 );
308 mprintf((0, "Registering %s in piggy file.", tempname ));
315 int ds_load( char * filename ) {
323 if (Registered_only) {
324 //mprintf( 0, "Skipping registered-only sound '%s'\n", filename );
325 return 0; //don't know what I should return here //&bogus_sound;
329 _splitpath( filename, NULL, NULL, fname, NULL );
330 _makepath( rawname, NULL, NULL,fname, (digi_sample_rate==SAMPLE_RATE_22K)?".R22":".RAW" );
332 i=piggy_find_sound( fname );
337 cfp = cfopen( rawname, "rb" );
340 new.length = cfilelength( cfp );
341 MALLOC( new.data, ubyte, new.length );
342 cfread( new.data, 1, new.length, cfp );
344 // -- mprintf( (0, "S" ));
345 // -- mprintf( (0, "<%s>", rawname ));
347 mprintf( (1, "Warning: Couldn't find '%s'\n", filename ));
350 i = piggy_register_sound( &new, fname, 0 );
359 xarg = strtok( NULL, space );
368 xarg = strtok( NULL, space );
372 // rotates a byte left one bit, preserving the bit falling off the right
374 //rotate_left(char *c)
386 //loads a texture and returns the texture num
387 int get_texture(char *name)
389 char short_name[FILENAME_LEN];
392 strcpy(short_name,name);
393 REMOVE_DOTS(short_name);
394 for (i=0;i<texture_count;i++)
395 if (!stricmp(TmapInfo[i].filename,short_name))
397 if (i==texture_count) {
398 Textures[texture_count] = bm_load_sub(name);
399 strcpy( TmapInfo[texture_count].filename, short_name);
401 Assert(texture_count < MAX_TEXTURES);
402 NumTextures = texture_count;
408 #define LINEBUF_SIZE 600
410 #define DEFAULT_PIG_PALETTE "groupa.256"
412 //-----------------------------------------------------------------
413 // Initializes all bitmaps from BITMAPS.TBL file.
414 // This is called when the editor is IN.
415 // If no editor, bm_init() is called.
416 int bm_init_use_tbl()
419 char inputline[LINEBUF_SIZE];
422 gr_use_palette_table(DEFAULT_PIG_PALETTE);
424 load_palette(DEFAULT_PIG_PALETTE,-2,0); //special: tell palette code which pig is loaded
426 init_polygon_models();
428 ObjType[0] = OL_PLAYER;
430 Num_total_object_types = 1;
432 for (i=0; i<MAX_SOUNDS; i++ ) {
437 for (i=0; i<MAX_TEXTURES; i++ ) {
438 TmapInfo[i].eclip_num = -1;
439 TmapInfo[i].flags = 0;
440 TmapInfo[i].slide_u = TmapInfo[i].slide_v = 0;
441 TmapInfo[i].destroyed = -1;
444 for (i=0;i<MAX_REACTORS;i++)
445 Reactors[i].model_num = -1;
448 for (i=0; i<MAX_EFFECTS; i++ ) {
449 //Effects[i].bm_ptr = (grs_bitmap **) -1;
450 Effects[i].changing_wall_texture = -1;
451 Effects[i].changing_object_texture = -1;
452 Effects[i].segnum = -1;
453 Effects[i].vc.num_frames = -1; //another mark of being unused
456 for (i=0;i<MAX_POLYGON_MODELS;i++)
457 Dying_modelnums[i] = Dead_modelnums[i] = -1;
460 for (i=0; i<VCLIP_MAXNUM; i++ ) {
461 Vclip[i].num_frames = -1;
465 for (i=0; i<MAX_WALL_ANIMS; i++ )
466 WallAnims[i].num_frames = -1;
469 setbuf(stdout, NULL); // unbuffered output via printf
476 piggy_init(); //don't care about error, since no pig is ok for editor
478 // if ( FindArg( "-nobm" ) ) {
479 // piggy_read_sounds();
483 // Open BITMAPS.TBL for reading.
485 InfoFile = cfopen( "BITMAPS.TBL", "rb" );
486 if (InfoFile == NULL) {
487 InfoFile = cfopen("BITMAPS.BIN", "rb");
488 if (InfoFile == NULL)
489 Error("Missing BITMAPS.TBL and BITMAPS.BIN file\n");
494 cfseek( InfoFile, 0L, SEEK_SET);
496 while (cfgets(inputline, LINEBUF_SIZE, InfoFile)) {
502 if (inputline[0]==' ' || inputline[0]=='\t') {
504 for (t=inputline;*t && *t!='\n';t++)
505 if (! (*t==' ' || *t=='\t')) {
506 mprintf((1,"Suspicious: line %d of BITMAPS.TBL starts with whitespace\n",linenum));
511 if (have_bin_tbl) { // is this a binary tbl file
512 for (i = 0; i < strlen(inputline) - 1; i++) {
513 encode_rotate_left(&(inputline[i]));
514 inputline[i] = inputline[i] ^ BITMAP_TBL_XOR;
515 encode_rotate_left(&(inputline[i]));
518 while (inputline[(l=strlen(inputline))-2]=='\\') {
519 if (!isspace(inputline[l-3])) { //if not space before backslash...
520 inputline[l-2] = ' '; //add one
523 cfgets(inputline+l-2,LINEBUF_SIZE-(l-2), InfoFile);
528 REMOVE_EOL(inputline);
529 if (strchr(inputline, ';')!=NULL) REMOVE_COMMENTS(inputline);
531 if (strlen(inputline) == LINEBUF_SIZE-1)
532 Error("Possible line truncation in BITMAPS.TBL on line %d\n",linenum);
536 if ( (temp_ptr=strstr( inputline, "superx=" )) ) {
537 SuperX = atoi( &temp_ptr[7] );
538 Assert(SuperX == 254);
539 //the superx color isn't kept around, so the new piggy regeneration
540 //code doesn't know what it is, so it assumes that it's 254, so
541 //this code requires that it be 254
545 arg = strtok( inputline, space );
554 // Check all possible flags and defines.
555 if (*arg == '$') bm_flag = BM_NONE; // reset to no flags as default.
557 IFTOK("$COCKPIT") bm_flag = BM_COCKPIT;
558 else IFTOK("$GAUGES") {bm_flag = BM_GAUGES; clip_count = 0;}
559 else IFTOK("$GAUGES_HIRES"){bm_flag = BM_GAUGES_HIRES; clip_count = 0;}
560 else IFTOK("$SOUND") bm_read_sound();
561 else IFTOK("$DOOR_ANIMS") bm_flag = BM_WALL_ANIMS;
562 else IFTOK("$WALL_ANIMS") bm_flag = BM_WALL_ANIMS;
563 else IFTOK("$TEXTURES") bm_flag = BM_TEXTURES;
564 else IFTOK("$VCLIP") {bm_flag = BM_VCLIP; vlighting = 0; clip_count = 0;}
565 else IFTOK("$ECLIP") {bm_flag = BM_ECLIP; vlighting = 0; clip_count = 0; obj_eclip=0; dest_bm=NULL; dest_vclip=-1; dest_eclip=-1; dest_size=-1; crit_clip=-1; crit_flag=0; sound_num=-1;}
566 else IFTOK("$WCLIP") {bm_flag = BM_WCLIP; vlighting = 0; clip_count = 0; wall_explodes = wall_blastable = 0; wall_open_sound=wall_close_sound=-1; tmap1_flag=0; wall_hidden=0;}
568 else IFTOK("$EFFECTS") {bm_flag = BM_EFFECTS; clip_num = 0;}
569 else IFTOK("$ALIAS") bm_read_alias();
572 else IFTOK("!METALS_FLAG") TextureMetals = texture_count;
573 else IFTOK("!LIGHTS_FLAG") TextureLights = texture_count;
574 else IFTOK("!EFFECTS_FLAG") TextureEffects = texture_count;
577 else IFTOK("lighting") TmapInfo[texture_count-1].lighting = fl2f(get_float());
578 else IFTOK("damage") TmapInfo[texture_count-1].damage = fl2f(get_float());
579 else IFTOK("volatile") TmapInfo[texture_count-1].flags |= TMI_VOLATILE;
580 else IFTOK("goal_blue") TmapInfo[texture_count-1].flags |= TMI_GOAL_BLUE;
581 else IFTOK("goal_red") TmapInfo[texture_count-1].flags |= TMI_GOAL_RED;
582 else IFTOK("water") TmapInfo[texture_count-1].flags |= TMI_WATER;
583 else IFTOK("force_field") TmapInfo[texture_count-1].flags |= TMI_FORCE_FIELD;
584 else IFTOK("slide") {TmapInfo[texture_count-1].slide_u = fl2f(get_float())>>8; TmapInfo[texture_count-1].slide_v = fl2f(get_float())>>8;}
585 else IFTOK("destroyed") {int t=texture_count-1; TmapInfo[t].destroyed = get_texture(strtok( NULL, space ));}
586 //else IFTOK("Num_effects") Num_effects = get_int();
587 else IFTOK("Num_wall_anims") Num_wall_anims = get_int();
588 else IFTOK("clip_num") clip_num = get_int();
589 else IFTOK("dest_bm") dest_bm = strtok( NULL, space );
590 else IFTOK("dest_vclip") dest_vclip = get_int();
591 else IFTOK("dest_eclip") dest_eclip = get_int();
592 else IFTOK("dest_size") dest_size = fl2f(get_float());
593 else IFTOK("crit_clip") crit_clip = get_int();
594 else IFTOK("crit_flag") crit_flag = get_int();
595 else IFTOK("sound_num") sound_num = get_int();
596 else IFTOK("frames") frames = get_int();
597 else IFTOK("time") time = get_float();
598 else IFTOK("obj_eclip") obj_eclip = get_int();
599 else IFTOK("hit_sound") hit_sound = get_int();
600 else IFTOK("abm_flag") abm_flag = get_int();
601 else IFTOK("tmap1_flag") tmap1_flag = get_int();
602 else IFTOK("vlighting") vlighting = get_float();
603 else IFTOK("rod_flag") rod_flag = get_int();
604 else IFTOK("superx") get_int();
605 else IFTOK("open_sound") wall_open_sound = get_int();
606 else IFTOK("close_sound") wall_close_sound = get_int();
607 else IFTOK("explodes") wall_explodes = get_int();
608 else IFTOK("blastable") wall_blastable = get_int();
609 else IFTOK("hidden") wall_hidden = get_int();
610 else IFTOK("$ROBOT_AI") bm_read_robot_ai();
612 else IFTOK("$POWERUP") {bm_read_powerup(0); continue;}
613 else IFTOK("$POWERUP_UNUSED") {bm_read_powerup(1); continue;}
614 else IFTOK("$HOSTAGE") {bm_read_hostage(); continue;}
615 else IFTOK("$ROBOT") {bm_read_robot(); continue;}
616 else IFTOK("$WEAPON") {bm_read_weapon(0); continue;}
617 else IFTOK("$WEAPON_UNUSED") {bm_read_weapon(1); continue;}
618 else IFTOK("$REACTOR") {bm_read_reactor(); continue;}
619 else IFTOK("$MARKER") {bm_read_marker(); continue;}
620 else IFTOK("$PLAYER_SHIP") {bm_read_player_ship(); continue;}
621 else IFTOK("$EXIT") {
625 clear_to_end_of_line();
629 else { //not a special token, must be a bitmap!
631 // Remove any illegal/unwanted spaces and tabs at this point.
632 while ((*arg=='\t') || (*arg==' ')) arg++;
633 if (*arg == '\0') { break; }
635 //check for '=' in token, indicating error
637 Error("Unknown token <'%s'> on line %d of BITMAPS.TBL",arg,linenum);
639 // Otherwise, 'arg' is apparently a bitmap filename.
640 // Load bitmap and process it below:
645 arg = strtok( NULL, equal_space );
650 NumTextures = texture_count;
651 Num_tmaps = tmap_count;
653 Textures[NumTextures++].index = 0; //entry for bogus tmap
659 Assert(N_robot_types == Num_robot_ais); //should be one ai info per robot
662 init_endlevel(); //this is here so endlevel bitmaps go into pig
667 //check for refereced but unused clip count
668 for (i=0; i<MAX_EFFECTS; i++ )
670 (Effects[i].changing_wall_texture!=-1) ||
671 (Effects[i].changing_object_texture!=-1)
673 && (Effects[i].vc.num_frames==-1) )
674 Error("EClip %d referenced (by polygon object?), but not defined",i);
679 for (i=used=0; i<num_sounds; i++ )
680 if (Sounds[i] != 255)
682 mprintf((0,"Sound slots used: %d of %d, highest index %d\n",used,MAX_SOUNDS,num_sounds));
684 //make sure all alt sounds refer to valid main sounds
685 for (i=used=0; i<num_sounds; i++ ) {
686 int alt = AltSounds[i];
687 Assert(alt==0 || alt==-1 || Sounds[alt]!=255);
698 gr_use_palette_table(DEFAULT_PALETTE);
703 void verify_textures()
708 for (i=0; i<Num_tmaps; i++ ) {
709 bmp = &GameBitmaps[Textures[i].index];
710 if ( (bmp->bm_w!=64)||(bmp->bm_h!=64)||(bmp->bm_rowsize!=64) ) {
711 mprintf( (1, "ERROR: Texture '%s' isn't 64x64 !\n", TmapInfo[i].filename ));
716 Error("%d textures were not 64x64. See mono screen for list.",j);
718 for (i=0;i<Num_effects;i++)
719 if (Effects[i].changing_object_texture != -1)
720 if (GameBitmaps[ObjBitmaps[Effects[i].changing_object_texture].index].bm_w!=64 || GameBitmaps[ObjBitmaps[Effects[i].changing_object_texture].index].bm_h!=64)
721 Error("Effect %d is used on object, but is not 64x64",i);
729 Assert(Num_aliases < MAX_ALIASES);
731 t = strtok( NULL, space ); strncpy(alias_list[Num_aliases].alias_name,t,sizeof(alias_list[Num_aliases].alias_name));
732 t = strtok( NULL, space ); strncpy(alias_list[Num_aliases].file_name,t,sizeof(alias_list[Num_aliases].file_name));
737 //--unused-- void dump_all_transparent_textures()
739 //--unused-- FILE * fp;
740 //--unused-- int i,j,k;
741 //--unused-- ubyte * p;
742 //--unused-- fp = fopen( "XPARENT.LST", "wt" );
743 //--unused-- for (i=0; i<Num_tmaps; i++ ) {
745 //--unused-- p = Textures[i]->bm_data;
746 //--unused-- for (j=0; j<64*64; j++ )
747 //--unused-- if ( (*p++)==255 ) k++;
748 //--unused-- if ( k ) {
749 //--unused-- fprintf( fp, "'%s' has %d transparent pixels\n", TmapInfo[i].filename, k );
752 //--unused-- fclose(fp);
764 void set_lighting_flag(sbyte *bp)
767 *bp |= BM_FLAG_NO_LIGHTING;
769 *bp &= (0xff ^ BM_FLAG_NO_LIGHTING);
772 void set_texture_name(char *name)
774 strcpy ( TmapInfo[texture_count].filename, name );
775 REMOVE_DOTS(TmapInfo[texture_count].filename);
783 Assert(clip_num < MAX_EFFECTS);
785 if (clip_num+1 > Num_effects)
786 Num_effects = clip_num+1;
788 Effects[clip_num].flags = 0;
790 //load the dest bitmap first, so that after this routine, the last-loaded
791 //texture will be the monitor, so that lighting parameter will be applied
792 //to the correct texture
793 if (dest_bm) { //deal with bitmap for blown up clip
794 char short_name[FILENAME_LEN];
796 strcpy(short_name,dest_bm);
797 REMOVE_DOTS(short_name);
798 for (i=0;i<texture_count;i++)
799 if (!stricmp(TmapInfo[i].filename,short_name))
801 if (i==texture_count) {
802 Textures[texture_count] = bm_load_sub(dest_bm);
803 strcpy( TmapInfo[texture_count].filename, short_name);
805 Assert(texture_count < MAX_TEXTURES);
806 NumTextures = texture_count;
808 else if (Textures[i].index == 0) //was found, but registered out
809 Textures[i] = bm_load_sub(dest_bm);
814 bitmap = bm_load_sub(arg);
816 Effects[clip_num].vc.play_time = fl2f(time);
817 Effects[clip_num].vc.num_frames = frames;
818 Effects[clip_num].vc.frame_time = fl2f(time)/frames;
820 Assert(clip_count < frames);
821 Effects[clip_num].vc.frames[clip_count] = bitmap;
822 set_lighting_flag(&GameBitmaps[bitmap.index].bm_flags);
824 Assert(!obj_eclip); //obj eclips for non-abm files not supported!
825 Assert(crit_flag==0);
827 if (clip_count == 0) {
828 Effects[clip_num].changing_wall_texture = texture_count;
829 Assert(tmap_count < MAX_TEXTURES);
830 TmapList[tmap_count++] = texture_count;
831 Textures[texture_count] = bitmap;
832 set_texture_name(arg);
833 Assert(texture_count < MAX_TEXTURES);
835 TmapInfo[texture_count].eclip_num = clip_num;
836 NumTextures = texture_count;
842 bitmap_index bm[MAX_BITMAPS_PER_BRUSH];
845 ab_load( arg, bm, &Effects[clip_num].vc.num_frames );
847 //printf("EC%d.", clip_num);
848 Effects[clip_num].vc.play_time = fl2f(time);
849 Effects[clip_num].vc.frame_time = Effects[clip_num].vc.play_time/Effects[clip_num].vc.num_frames;
852 set_lighting_flag( &GameBitmaps[bm[clip_count].index].bm_flags);
853 Effects[clip_num].vc.frames[clip_count] = bm[clip_count];
855 if (!obj_eclip && !crit_flag) {
856 Effects[clip_num].changing_wall_texture = texture_count;
857 Assert(tmap_count < MAX_TEXTURES);
858 TmapList[tmap_count++] = texture_count;
859 Textures[texture_count] = bm[clip_count];
860 set_texture_name( arg );
861 Assert(texture_count < MAX_TEXTURES);
862 TmapInfo[texture_count].eclip_num = clip_num;
864 NumTextures = texture_count;
869 if (Effects[clip_num].changing_object_texture == -1) { //first time referenced
870 Effects[clip_num].changing_object_texture = N_ObjBitmaps; // XChange ObjectBitmaps
874 ObjBitmaps[Effects[clip_num].changing_object_texture] = Effects[clip_num].vc.frames[0];
877 //if for an object, Effects_bm_ptrs set in object load
879 for(clip_count=1;clip_count < Effects[clip_num].vc.num_frames; clip_count++) {
880 set_lighting_flag( &GameBitmaps[bm[clip_count].index].bm_flags);
881 Effects[clip_num].vc.frames[clip_count] = bm[clip_count];
886 Effects[clip_num].crit_clip = crit_clip;
887 Effects[clip_num].sound_num = sound_num;
889 if (dest_bm) { //deal with bitmap for blown up clip
891 Effects[clip_num].dest_bm_num = dest_bm_num;
894 Error("Desctuction vclip missing on line %d",linenum);
896 Error("Desctuction vclip missing on line %d",linenum);
898 Effects[clip_num].dest_vclip = dest_vclip;
899 Effects[clip_num].dest_size = dest_size;
901 Effects[clip_num].dest_eclip = dest_eclip;
904 Effects[clip_num].dest_bm_num = -1;
905 Effects[clip_num].dest_eclip = -1;
909 Effects[clip_num].flags |= EF_CRITICAL;
913 void bm_read_gauges()
916 int i, num_abm_frames;
919 bitmap = bm_load_sub(arg);
920 Assert(clip_count < MAX_GAUGE_BMS);
921 Gauges[clip_count] = bitmap;
924 bitmap_index bm[MAX_BITMAPS_PER_BRUSH];
926 ab_load( arg, bm, &num_abm_frames );
927 for (i=clip_count; i<clip_count+num_abm_frames; i++) {
928 Assert(i < MAX_GAUGE_BMS);
929 Gauges[i] = bm[i-clip_count];
931 clip_count += num_abm_frames;
935 void bm_read_gauges_hires()
938 int i, num_abm_frames;
941 bitmap = bm_load_sub(arg);
942 Assert(clip_count < MAX_GAUGE_BMS);
943 Gauges_hires[clip_count] = bitmap;
946 bitmap_index bm[MAX_BITMAPS_PER_BRUSH];
948 ab_load( arg, bm, &num_abm_frames );
949 for (i=clip_count; i<clip_count+num_abm_frames; i++) {
950 Assert(i < MAX_GAUGE_BMS);
951 Gauges_hires[i] = bm[i-clip_count];
953 clip_count += num_abm_frames;
960 Assert(clip_num < MAX_WALL_ANIMS);
962 WallAnims[clip_num].flags = 0;
964 if (wall_explodes) WallAnims[clip_num].flags |= WCF_EXPLODES;
965 if (wall_blastable) WallAnims[clip_num].flags |= WCF_BLASTABLE;
966 if (wall_hidden) WallAnims[clip_num].flags |= WCF_HIDDEN;
967 if (tmap1_flag) WallAnims[clip_num].flags |= WCF_TMAP1;
970 bitmap = bm_load_sub(arg);
971 if ( (WallAnims[clip_num].num_frames>-1) && (clip_count==0) )
972 Error( "Wall Clip %d is already used!", clip_num );
973 WallAnims[clip_num].play_time = fl2f(time);
974 WallAnims[clip_num].num_frames = frames;
975 //WallAnims[clip_num].frame_time = fl2f(time)/frames;
976 Assert(clip_count < frames);
977 WallAnims[clip_num].frames[clip_count++] = texture_count;
978 WallAnims[clip_num].open_sound = wall_open_sound;
979 WallAnims[clip_num].close_sound = wall_close_sound;
980 Textures[texture_count] = bitmap;
981 set_lighting_flag(&GameBitmaps[bitmap.index].bm_flags);
982 set_texture_name( arg );
983 Assert(texture_count < MAX_TEXTURES);
985 NumTextures = texture_count;
986 if (clip_num >= Num_wall_anims) Num_wall_anims = clip_num+1;
988 bitmap_index bm[MAX_BITMAPS_PER_BRUSH];
990 if ( (WallAnims[clip_num].num_frames>-1) )
991 Error( "AB_Wall clip %d is already used!", clip_num );
993 ab_load( arg, bm, &nframes );
994 WallAnims[clip_num].num_frames = nframes;
996 WallAnims[clip_num].play_time = fl2f(time);
997 //WallAnims[clip_num].frame_time = fl2f(time)/nframes;
998 WallAnims[clip_num].open_sound = wall_open_sound;
999 WallAnims[clip_num].close_sound = wall_close_sound;
1001 WallAnims[clip_num].close_sound = wall_close_sound;
1002 strcpy(WallAnims[clip_num].filename, arg);
1003 REMOVE_DOTS(WallAnims[clip_num].filename);
1005 if (clip_num >= Num_wall_anims) Num_wall_anims = clip_num+1;
1007 set_lighting_flag(&GameBitmaps[bm[clip_count].index].bm_flags);
1009 for (clip_count=0;clip_count < WallAnims[clip_num].num_frames; clip_count++) {
1010 //printf("%d", clip_count);
1011 Textures[texture_count] = bm[clip_count];
1012 set_lighting_flag(&GameBitmaps[bm[clip_count].index].bm_flags);
1013 WallAnims[clip_num].frames[clip_count] = texture_count;
1015 sprintf( TmapInfo[texture_count].filename, "%s#%d", arg, clip_count);
1016 Assert(texture_count < MAX_TEXTURES);
1018 NumTextures = texture_count;
1023 void bm_read_vclip()
1026 Assert(clip_num < VCLIP_MAXNUM);
1028 if (clip_num >= Num_vclips)
1029 Num_vclips = clip_num+1;
1032 if ( (Vclip[clip_num].num_frames>-1) && (clip_count==0) )
1033 Error( "Vclip %d is already used!", clip_num );
1034 bi = bm_load_sub(arg);
1035 Vclip[clip_num].play_time = fl2f(time);
1036 Vclip[clip_num].num_frames = frames;
1037 Vclip[clip_num].frame_time = fl2f(time)/frames;
1038 Vclip[clip_num].light_value = fl2f(vlighting);
1039 Vclip[clip_num].sound_num = sound_num;
1040 set_lighting_flag(&GameBitmaps[bi.index].bm_flags);
1041 Assert(clip_count < frames);
1042 Vclip[clip_num].frames[clip_count++] = bi;
1045 Vclip[clip_num].flags |= VF_ROD;
1049 bitmap_index bm[MAX_BITMAPS_PER_BRUSH];
1051 if ( (Vclip[clip_num].num_frames>-1) )
1052 Error( "AB_Vclip %d is already used!", clip_num );
1053 ab_load( arg, bm, &Vclip[clip_num].num_frames );
1058 Vclip[clip_num].flags |= VF_ROD;
1061 Vclip[clip_num].play_time = fl2f(time);
1062 Vclip[clip_num].frame_time = fl2f(time)/Vclip[clip_num].num_frames;
1063 Vclip[clip_num].light_value = fl2f(vlighting);
1064 Vclip[clip_num].sound_num = sound_num;
1065 set_lighting_flag(&GameBitmaps[bm[clip_count].index].bm_flags);
1067 for (clip_count=0;clip_count < Vclip[clip_num].num_frames; clip_count++) {
1068 //printf("%d", clip_count);
1069 set_lighting_flag(&GameBitmaps[bm[clip_count].index].bm_flags);
1070 Vclip[clip_num].frames[clip_count] = bm[clip_count];
1075 // ------------------------------------------------------------------------------
1076 void get4fix(fix *fixp)
1081 for (i=0; i<NDL; i++) {
1082 curtext = strtok(NULL, space);
1083 fixp[i] = fl2f(atof(curtext));
1087 // ------------------------------------------------------------------------------
1088 void get4byte(sbyte *bytep)
1093 for (i=0; i<NDL; i++) {
1094 curtext = strtok(NULL, space);
1095 bytep[i] = atoi(curtext);
1099 // ------------------------------------------------------------------------------
1100 // Convert field of view from an angle in 0..360 to cosine.
1101 void adjust_field_of_view(fix *fovp)
1108 for (i=0; i<NDL; i++) {
1109 ff = - f2fl(fovp[i]);
1111 mprintf((1, "Warning: Bogus field of view (%7.3f). Must be in 0..179.\n", ff));
1116 fix_sincos(tt, &temp, &fovp[i]);
1120 void clear_to_end_of_line(void)
1122 arg = strtok( NULL, space );
1124 arg = strtok( NULL, space );
1127 void bm_read_sound()
1132 sound_num = get_int();
1133 alt_sound_num = get_int();
1135 if ( sound_num>=MAX_SOUNDS )
1136 Error( "Too many sound files.\n" );
1138 if (sound_num >= num_sounds)
1139 num_sounds = sound_num+1;
1141 if (Sounds[sound_num] != 255)
1142 Error("Sound num %d already used, bitmaps.tbl, line %d\n",sound_num,linenum);
1144 arg = strtok(NULL, space);
1146 Sounds[sound_num] = ds_load(arg);
1148 if ( alt_sound_num == 0 )
1149 AltSounds[sound_num] = sound_num;
1150 else if (alt_sound_num < 0 )
1151 AltSounds[sound_num] = 255;
1153 AltSounds[sound_num] = alt_sound_num;
1155 if (Sounds[sound_num] == 255)
1156 Error("Can't load soundfile <%s>",arg);
1159 // ------------------------------------------------------------------------------
1160 void bm_read_robot_ai()
1162 char *robotnum_text;
1166 robotnum_text = strtok(NULL, space);
1167 robotnum = atoi(robotnum_text);
1168 Assert(robotnum < MAX_ROBOT_TYPES);
1169 robptr = &Robot_info[robotnum];
1171 Assert(robotnum == Num_robot_ais); //make sure valid number
1174 if (Registered_only) {
1176 clear_to_end_of_line();
1183 get4fix(robptr->field_of_view);
1184 get4fix(robptr->firing_wait);
1185 get4fix(robptr->firing_wait2);
1186 get4byte(robptr->rapidfire_count);
1187 get4fix(robptr->turn_time);
1188 // get4fix(robptr->fire_power);
1189 // get4fix(robptr->shield);
1190 get4fix(robptr->max_speed);
1191 get4fix(robptr->circle_distance);
1192 get4byte(robptr->evade_speed);
1194 robptr->always_0xabcd = 0xabcd;
1196 adjust_field_of_view(robptr->field_of_view);
1200 // ----------------------------------------------------------------------------------------------
1201 //this will load a bitmap for a polygon models. it puts the bitmap into
1202 //the array ObjBitmaps[], and also deals with animating bitmaps
1203 //returns a pointer to the bitmap
1204 grs_bitmap *load_polymodel_bitmap(char *name)
1206 Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
1208 // Assert( N_ObjBitmaps == N_ObjBitmapPtrs );
1210 if (name[0] == '%') { //an animating bitmap!
1213 eclip_num = atoi(name+1);
1215 if (Effects[eclip_num].changing_object_texture == -1) { //first time referenced
1216 Effects[eclip_num].changing_object_texture = N_ObjBitmaps;
1217 ObjBitmapPtrs[N_ObjBitmapPtrs++] = N_ObjBitmaps;
1220 ObjBitmapPtrs[N_ObjBitmapPtrs++] = Effects[eclip_num].changing_object_texture;
1222 Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
1223 Assert(N_ObjBitmapPtrs < MAX_OBJ_BITMAPS);
1227 ObjBitmaps[N_ObjBitmaps] = bm_load_sub(name);
1228 if (GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_w!=64 || GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_h!=64)
1229 Error("Bitmap <%s> is not 64x64",name);
1230 ObjBitmapPtrs[N_ObjBitmapPtrs++] = N_ObjBitmaps;
1232 Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
1233 Assert(N_ObjBitmapPtrs < MAX_OBJ_BITMAPS);
1234 return &GameBitmaps[ObjBitmaps[N_ObjBitmaps-1].index];
1238 #define MAX_MODEL_VARIANTS 4
1240 // ------------------------------------------------------------------------------
1241 void bm_read_robot()
1243 char *model_name[MAX_MODEL_VARIANTS];
1245 int first_bitmap_num[MAX_MODEL_VARIANTS];
1247 int exp1_vclip_num=-1;
1248 int exp1_sound_num=-1;
1249 int exp2_vclip_num=-1;
1250 int exp2_sound_num=-1;
1251 fix lighting = F1_0/2; // Default
1252 fix strength = F1_0*10; // Default strength
1255 short weapon_type = 0, weapon_type2 = -1;
1257 char name[ROBOT_NAME_LENGTH];
1258 int contains_count=0, contains_id=0, contains_prob=0, contains_type=0, behavior=AIB_NORMAL;
1259 int companion = 0, smart_blobs=0, energy_blobs=0, badass=0, energy_drain=0, kamikaze=0, thief=0, pursuit=0, lightcast=0, death_roll=0;
1260 fix glow=0, aim=F1_0;
1261 int deathroll_sound = SOUND_BOSS_SHARE_DIE; //default
1262 int score_value=1000;
1263 int cloak_type=0; // Default = this robot does not cloak
1264 int attack_type=0; // Default = this robot attacks by firing (1=lunge)
1265 int boss_flag=0; // Default = robot is not a boss.
1266 int see_sound = ROBOT_SEE_SOUND_DEFAULT;
1267 int attack_sound = ROBOT_ATTACK_SOUND_DEFAULT;
1268 int claw_sound = ROBOT_CLAW_SOUND_DEFAULT;
1269 int taunt_sound = ROBOT_SEE_SOUND_DEFAULT;
1272 Assert(N_robot_types < MAX_ROBOT_TYPES);
1275 if (Registered_only) {
1276 Robot_info[N_robot_types].model_num = -1;
1278 Assert(N_robot_types < MAX_ROBOT_TYPES);
1279 Num_total_object_types++;
1280 Assert(Num_total_object_types < MAX_OBJTYPE);
1281 clear_to_end_of_line();
1286 model_name[0] = strtok( NULL, space );
1287 first_bitmap_num[0] = N_ObjBitmapPtrs;
1292 arg = strtok( NULL, space );
1294 equal_ptr = strchr( arg, '=' );
1298 // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
1299 if (!stricmp( arg, "exp1_vclip" )) {
1300 exp1_vclip_num = atoi(equal_ptr);
1301 } else if (!stricmp( arg, "exp2_vclip" )) {
1302 exp2_vclip_num = atoi(equal_ptr);
1303 } else if (!stricmp( arg, "exp1_sound" )) {
1304 exp1_sound_num = atoi(equal_ptr);
1305 } else if (!stricmp( arg, "exp2_sound" )) {
1306 exp2_sound_num = atoi(equal_ptr);
1307 } else if (!stricmp( arg, "lighting" )) {
1308 lighting = fl2f(atof(equal_ptr));
1309 if ( (lighting < 0) || (lighting > F1_0 )) {
1310 mprintf( (1, "In bitmaps.tbl, lighting value of %.2f is out of range 0..1.\n", f2fl(lighting)));
1311 Error( "In bitmaps.tbl, lighting value of %.2f is out of range 0..1.\n", f2fl(lighting));
1313 } else if (!stricmp( arg, "weapon_type" )) {
1314 weapon_type = atoi(equal_ptr);
1315 } else if (!stricmp( arg, "weapon_type2" )) {
1316 weapon_type2 = atoi(equal_ptr);
1317 } else if (!stricmp( arg, "strength" )) {
1318 strength = i2f(atoi(equal_ptr));
1319 } else if (!stricmp( arg, "mass" )) {
1320 mass = fl2f(atof(equal_ptr));
1321 } else if (!stricmp( arg, "drag" )) {
1322 drag = fl2f(atof(equal_ptr));
1323 } else if (!stricmp( arg, "contains_id" )) {
1324 contains_id = atoi(equal_ptr);
1325 } else if (!stricmp( arg, "contains_type" )) {
1326 contains_type = atoi(equal_ptr);
1327 } else if (!stricmp( arg, "contains_count" )) {
1328 contains_count = atoi(equal_ptr);
1329 } else if (!stricmp( arg, "companion" )) {
1330 companion = atoi(equal_ptr);
1331 } else if (!stricmp( arg, "badass" )) {
1332 badass = atoi(equal_ptr);
1333 } else if (!stricmp( arg, "lightcast" )) {
1334 lightcast = atoi(equal_ptr);
1335 } else if (!stricmp( arg, "glow" )) {
1336 glow = fl2f(atof(equal_ptr));
1337 } else if (!stricmp( arg, "death_roll" )) {
1338 death_roll = atoi(equal_ptr);
1339 } else if (!stricmp( arg, "deathroll_sound" )) {
1340 deathroll_sound = atoi(equal_ptr);
1341 } else if (!stricmp( arg, "thief" )) {
1342 thief = atoi(equal_ptr);
1343 } else if (!stricmp( arg, "kamikaze" )) {
1344 kamikaze = atoi(equal_ptr);
1345 } else if (!stricmp( arg, "pursuit" )) {
1346 pursuit = atoi(equal_ptr);
1347 } else if (!stricmp( arg, "smart_blobs" )) {
1348 smart_blobs = atoi(equal_ptr);
1349 } else if (!stricmp( arg, "energy_blobs" )) {
1350 energy_blobs = atoi(equal_ptr);
1351 } else if (!stricmp( arg, "energy_drain" )) {
1352 energy_drain = atoi(equal_ptr);
1353 } else if (!stricmp( arg, "contains_prob" )) {
1354 contains_prob = atoi(equal_ptr);
1355 } else if (!stricmp( arg, "cloak_type" )) {
1356 cloak_type = atoi(equal_ptr);
1357 } else if (!stricmp( arg, "attack_type" )) {
1358 attack_type = atoi(equal_ptr);
1359 } else if (!stricmp( arg, "boss" )) {
1360 boss_flag = atoi(equal_ptr);
1361 } else if (!stricmp( arg, "score_value" )) {
1362 score_value = atoi(equal_ptr);
1363 } else if (!stricmp( arg, "see_sound" )) {
1364 see_sound = atoi(equal_ptr);
1365 } else if (!stricmp( arg, "attack_sound" )) {
1366 attack_sound = atoi(equal_ptr);
1367 } else if (!stricmp( arg, "claw_sound" )) {
1368 claw_sound = atoi(equal_ptr);
1369 } else if (!stricmp( arg, "taunt_sound" )) {
1370 taunt_sound = atoi(equal_ptr);
1371 } else if (!stricmp( arg, "aim" )) {
1372 aim = fl2f(atof(equal_ptr));
1373 } else if (!stricmp( arg, "big_radius" )) {
1374 if (atoi(equal_ptr))
1375 flags |= RIF_BIG_RADIUS;
1376 } else if (!stricmp( arg, "behavior" )) {
1377 if (!stricmp(equal_ptr, "STILL"))
1378 behavior = AIB_STILL;
1379 else if (!stricmp(equal_ptr, "NORMAL"))
1380 behavior = AIB_NORMAL;
1381 else if (!stricmp(equal_ptr, "BEHIND"))
1382 behavior = AIB_BEHIND;
1383 else if (!stricmp(equal_ptr, "RUN_FROM"))
1384 behavior = AIB_RUN_FROM;
1385 else if (!stricmp(equal_ptr, "SNIPE"))
1386 behavior = AIB_SNIPE;
1387 else if (!stricmp(equal_ptr, "STATION"))
1388 behavior = AIB_STATION;
1389 else if (!stricmp(equal_ptr, "FOLLOW"))
1390 behavior = AIB_FOLLOW;
1392 Int3(); // Error. Illegal behavior type for current robot.
1393 } else if (!stricmp( arg, "name" )) {
1394 Assert(strlen(equal_ptr) < ROBOT_NAME_LENGTH); // Oops, name too long.
1395 strcpy(name, &equal_ptr[1]);
1396 name[strlen(name)-1] = 0;
1397 } else if (!stricmp( arg, "simple_model" )) {
1398 model_name[n_models] = equal_ptr;
1399 first_bitmap_num[n_models] = N_ObjBitmapPtrs;
1401 Assert(n_models < MAX_MODEL_VARIANTS);
1404 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
1406 } else { // Must be a texture specification...
1407 load_polymodel_bitmap(arg);
1409 arg = strtok( NULL, space );
1412 //clear out anim info
1413 for (g=0;g<MAX_GUNS+1;g++)
1414 for (s=0;s<N_ANIM_STATES;s++)
1415 Robot_info[N_robot_types].anim_states[g][s].n_joints = 0; //inialize to zero
1417 first_bitmap_num[n_models] = N_ObjBitmapPtrs;
1419 for (i=0;i<n_models;i++) {
1421 int model_num,last_model_num=0;
1423 n_textures = first_bitmap_num[i+1] - first_bitmap_num[i];
1425 model_num = load_polygon_model(model_name[i],n_textures,first_bitmap_num[i],(i==0)?&Robot_info[N_robot_types]:NULL);
1428 Robot_info[N_robot_types].model_num = model_num;
1430 Polygon_models[last_model_num].simpler_model = model_num+1;
1432 last_model_num = model_num;
1435 if ((glow > i2f(15)) || (glow < 0) || (glow != 0 && glow < 0x1000)) {
1436 mprintf((0,"Invalid glow value %x for robot %d\n",glow,N_robot_types));
1440 ObjType[Num_total_object_types] = OL_ROBOT;
1441 ObjId[Num_total_object_types] = N_robot_types;
1443 Robot_info[N_robot_types].exp1_vclip_num = exp1_vclip_num;
1444 Robot_info[N_robot_types].exp2_vclip_num = exp2_vclip_num;
1445 Robot_info[N_robot_types].exp1_sound_num = exp1_sound_num;
1446 Robot_info[N_robot_types].exp2_sound_num = exp2_sound_num;
1447 Robot_info[N_robot_types].lighting = lighting;
1448 Robot_info[N_robot_types].weapon_type = weapon_type;
1449 Robot_info[N_robot_types].weapon_type2 = weapon_type2;
1450 Robot_info[N_robot_types].strength = strength;
1451 Robot_info[N_robot_types].mass = mass;
1452 Robot_info[N_robot_types].drag = drag;
1453 Robot_info[N_robot_types].cloak_type = cloak_type;
1454 Robot_info[N_robot_types].attack_type = attack_type;
1455 Robot_info[N_robot_types].boss_flag = boss_flag;
1457 Robot_info[N_robot_types].contains_id = contains_id;
1458 Robot_info[N_robot_types].contains_count = contains_count;
1459 Robot_info[N_robot_types].contains_prob = contains_prob;
1460 Robot_info[N_robot_types].companion = companion;
1461 Robot_info[N_robot_types].badass = badass;
1462 Robot_info[N_robot_types].lightcast = lightcast;
1463 Robot_info[N_robot_types].glow = (glow>>12); //convert to 4:4
1464 Robot_info[N_robot_types].death_roll = death_roll;
1465 Robot_info[N_robot_types].deathroll_sound = deathroll_sound;
1466 Robot_info[N_robot_types].thief = thief;
1467 Robot_info[N_robot_types].flags = flags;
1468 Robot_info[N_robot_types].kamikaze = kamikaze;
1469 Robot_info[N_robot_types].pursuit = pursuit;
1470 Robot_info[N_robot_types].smart_blobs = smart_blobs;
1471 Robot_info[N_robot_types].energy_blobs = energy_blobs;
1472 Robot_info[N_robot_types].energy_drain = energy_drain;
1473 Robot_info[N_robot_types].score_value = score_value;
1474 Robot_info[N_robot_types].see_sound = see_sound;
1475 Robot_info[N_robot_types].attack_sound = attack_sound;
1476 Robot_info[N_robot_types].claw_sound = claw_sound;
1477 Robot_info[N_robot_types].taunt_sound = taunt_sound;
1478 Robot_info[N_robot_types].behavior = behavior; // Default behavior for this robot, if coming out of matcen.
1479 Robot_info[N_robot_types].aim = min(f2i(aim*255), 255); // how well this robot type can aim. 255=perfect
1482 Robot_info[N_robot_types].contains_type = OBJ_ROBOT;
1484 Robot_info[N_robot_types].contains_type = OBJ_POWERUP;
1486 strcpy(Robot_names[N_robot_types], name);
1489 Num_total_object_types++;
1491 Assert(N_robot_types < MAX_ROBOT_TYPES);
1492 Assert(Num_total_object_types < MAX_OBJTYPE);
1497 //read a reactor model
1498 void bm_read_reactor()
1500 char *model_name, *model_name_dead=NULL;
1501 int first_bitmap_num, first_bitmap_num_dead=0, n_normal_bitmaps;
1504 short explosion_vclip_num = -1;
1505 short explosion_sound_num = SOUND_ROBOT_DESTROYED;
1506 fix lighting = F1_0/2; // Default
1510 Assert(Num_reactors < MAX_REACTORS);
1513 if (Registered_only) {
1515 clear_to_end_of_line();
1520 model_name = strtok( NULL, space );
1524 arg = strtok( NULL, space );
1525 first_bitmap_num = N_ObjBitmapPtrs;
1527 type = OL_CONTROL_CENTER;
1531 equal_ptr = strchr( arg, '=' );
1537 // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
1539 //@@if (!stricmp(arg,"type")) {
1540 //@@ if (!stricmp(equal_ptr,"controlcen"))
1541 //@@ type = OL_CONTROL_CENTER;
1542 //@@ else if (!stricmp(equal_ptr,"clutter"))
1543 //@@ type = OL_CLUTTER;
1546 if (!stricmp( arg, "exp_vclip" )) {
1547 explosion_vclip_num = atoi(equal_ptr);
1548 } else if (!stricmp( arg, "dead_pof" )) {
1549 model_name_dead = equal_ptr;
1550 first_bitmap_num_dead=N_ObjBitmapPtrs;
1551 } else if (!stricmp( arg, "exp_sound" )) {
1552 explosion_sound_num = atoi(equal_ptr);
1553 } else if (!stricmp( arg, "lighting" )) {
1554 lighting = fl2f(atof(equal_ptr));
1555 if ( (lighting < 0) || (lighting > F1_0 )) {
1556 mprintf( (1, "In bitmaps.tbl, lighting value of %.2f is out of range 0..1.\n", f2fl(lighting)));
1557 Error( "In bitmaps.tbl, lighting value of %.2f is out of range 0..1.\n", f2fl(lighting));
1559 } else if (!stricmp( arg, "strength" )) {
1560 strength = fl2f(atof(equal_ptr));
1563 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
1565 } else { // Must be a texture specification...
1566 load_polymodel_bitmap(arg);
1568 arg = strtok( NULL, space );
1571 if ( model_name_dead )
1572 n_normal_bitmaps = first_bitmap_num_dead-first_bitmap_num;
1574 n_normal_bitmaps = N_ObjBitmapPtrs-first_bitmap_num;
1576 model_num = load_polygon_model(model_name,n_normal_bitmaps,first_bitmap_num,NULL);
1578 if ( model_name_dead )
1579 Dead_modelnums[model_num] = load_polygon_model(model_name_dead,N_ObjBitmapPtrs-first_bitmap_num_dead,first_bitmap_num_dead,NULL);
1581 Dead_modelnums[model_num] = -1;
1584 Error("No object type specfied for object in BITMAPS.TBL on line %d\n",linenum);
1586 Reactors[Num_reactors].model_num = model_num;
1587 Reactors[Num_reactors].n_guns = read_model_guns(model_name,Reactors[Num_reactors].gun_points,Reactors[Num_reactors].gun_dirs,NULL);
1589 ObjType[Num_total_object_types] = type;
1590 ObjId[Num_total_object_types] = Num_reactors;
1591 ObjStrength[Num_total_object_types] = strength;
1593 //printf( "Object type %d is a control center\n", Num_total_object_types );
1594 Num_total_object_types++;
1595 Assert(Num_total_object_types < MAX_OBJTYPE);
1600 //read the marker object
1601 void bm_read_marker()
1604 int first_bitmap_num, n_normal_bitmaps;
1607 model_name = strtok( NULL, space );
1611 arg = strtok( NULL, space );
1612 first_bitmap_num = N_ObjBitmapPtrs;
1616 equal_ptr = strchr( arg, '=' );
1622 // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
1623 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
1626 } else { // Must be a texture specification...
1627 load_polymodel_bitmap(arg);
1629 arg = strtok( NULL, space );
1632 n_normal_bitmaps = N_ObjBitmapPtrs-first_bitmap_num;
1634 Marker_model_num = load_polygon_model(model_name,n_normal_bitmaps,first_bitmap_num,NULL);
1638 //read the exit model
1639 void bm_read_exitmodel()
1641 char *model_name, *model_name_dead=NULL;
1642 int first_bitmap_num, first_bitmap_num_dead, n_normal_bitmaps;
1646 model_name = strtok( NULL, space );
1650 arg = strtok( NULL, space );
1651 first_bitmap_num = N_ObjBitmapPtrs;
1655 equal_ptr = strchr( arg, '=' );
1661 // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
1663 if (!stricmp( arg, "dead_pof" )) {
1664 model_name_dead = equal_ptr;
1665 first_bitmap_num_dead=N_ObjBitmapPtrs;
1668 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
1670 } else { // Must be a texture specification...
1671 load_polymodel_bitmap(arg);
1673 arg = strtok( NULL, space );
1676 if ( model_name_dead )
1677 n_normal_bitmaps = first_bitmap_num_dead-first_bitmap_num;
1679 n_normal_bitmaps = N_ObjBitmapPtrs-first_bitmap_num;
1681 model_num = load_polygon_model(model_name,n_normal_bitmaps,first_bitmap_num,NULL);
1683 if ( model_name_dead )
1684 Dead_modelnums[model_num] = load_polygon_model(model_name_dead,N_ObjBitmapPtrs-first_bitmap_num_dead,first_bitmap_num_dead,NULL);
1686 Dead_modelnums[model_num] = -1;
1688 //@@ ObjType[Num_total_object_types] = type;
1689 //@@ ObjId[Num_total_object_types] = model_num;
1690 //@@ ObjStrength[Num_total_object_types] = strength;
1692 //@@ //printf( "Object type %d is a control center\n", Num_total_object_types );
1693 //@@ Num_total_object_types++;
1694 //@@ Assert(Num_total_object_types < MAX_OBJTYPE);
1696 exit_modelnum = model_num;
1697 destroyed_exit_modelnum = Dead_modelnums[model_num];
1702 void bm_read_player_ship()
1704 char *model_name_dying=NULL;
1705 char *model_name[MAX_MODEL_VARIANTS];
1707 int first_bitmap_num[MAX_MODEL_VARIANTS];
1710 int last_multi_bitmap_num=-1;
1715 arg = strtok( NULL, space );
1717 Player_ship->mass = Player_ship->drag = 0; //stupid defaults
1718 Player_ship->expl_vclip_num = -1;
1722 equal_ptr = strchr( arg, '=' );
1729 // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
1731 if (!stricmp( arg, "model" )) {
1732 Assert(n_models==0);
1733 model_name[0] = equal_ptr;
1734 first_bitmap_num[0] = N_ObjBitmapPtrs;
1736 } else if (!stricmp( arg, "simple_model" )) {
1737 model_name[n_models] = equal_ptr;
1738 first_bitmap_num[n_models] = N_ObjBitmapPtrs;
1740 Assert(n_models < MAX_MODEL_VARIANTS);
1742 if (First_multi_bitmap_num!=-1 && last_multi_bitmap_num==-1)
1743 last_multi_bitmap_num=N_ObjBitmapPtrs;
1745 else if (!stricmp( arg, "mass" ))
1746 Player_ship->mass = fl2f(atof(equal_ptr));
1747 else if (!stricmp( arg, "drag" ))
1748 Player_ship->drag = fl2f(atof(equal_ptr));
1749 // else if (!stricmp( arg, "low_thrust" ))
1750 // Player_ship->low_thrust = fl2f(atof(equal_ptr));
1751 else if (!stricmp( arg, "max_thrust" ))
1752 Player_ship->max_thrust = fl2f(atof(equal_ptr));
1753 else if (!stricmp( arg, "reverse_thrust" ))
1754 Player_ship->reverse_thrust = fl2f(atof(equal_ptr));
1755 else if (!stricmp( arg, "brakes" ))
1756 Player_ship->brakes = fl2f(atof(equal_ptr));
1757 else if (!stricmp( arg, "wiggle" ))
1758 Player_ship->wiggle = fl2f(atof(equal_ptr));
1759 else if (!stricmp( arg, "max_rotthrust" ))
1760 Player_ship->max_rotthrust = fl2f(atof(equal_ptr));
1761 else if (!stricmp( arg, "dying_pof" ))
1762 model_name_dying = equal_ptr;
1763 else if (!stricmp( arg, "expl_vclip_num" ))
1764 Player_ship->expl_vclip_num=atoi(equal_ptr);
1767 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
1770 else if (!stricmp( arg, "multi_textures" )) {
1772 First_multi_bitmap_num = N_ObjBitmapPtrs;
1773 first_bitmap_num[n_models] = N_ObjBitmapPtrs;
1776 else // Must be a texture specification...
1778 load_polymodel_bitmap(arg);
1780 arg = strtok( NULL, space );
1783 Assert(model_name != NULL);
1785 if (First_multi_bitmap_num!=-1 && last_multi_bitmap_num==-1)
1786 last_multi_bitmap_num=N_ObjBitmapPtrs;
1788 if (First_multi_bitmap_num==-1)
1789 first_bitmap_num[n_models] = N_ObjBitmapPtrs;
1792 Assert(last_multi_bitmap_num-First_multi_bitmap_num == (MAX_NUM_NET_PLAYERS-1)*2);
1795 for (i=0;i<n_models;i++) {
1797 int model_num,last_model_num=0;
1799 n_textures = first_bitmap_num[i+1] - first_bitmap_num[i];
1801 model_num = load_polygon_model(model_name[i],n_textures,first_bitmap_num[i],(i==0)?&ri:NULL);
1804 Player_ship->model_num = model_num;
1806 Polygon_models[last_model_num].simpler_model = model_num+1;
1808 last_model_num = model_num;
1811 if ( model_name_dying ) {
1813 Dying_modelnums[Player_ship->model_num] = load_polygon_model(model_name_dying,first_bitmap_num[1]-first_bitmap_num[0],first_bitmap_num[0],NULL);
1816 Assert(ri.n_guns == N_PLAYER_GUNS);
1818 //calc player gun positions
1824 int mn; //submodel number
1828 pm = &Polygon_models[Player_ship->model_num];
1830 for (gun_num=0;gun_num<r->n_guns;gun_num++) {
1832 pnt = r->gun_points[gun_num];
1833 mn = r->gun_submodels[gun_num];
1835 //instance up the tree for this gun
1837 vm_vec_add2(&pnt,&pm->submodel_offsets[mn]);
1838 mn = pm->submodel_parents[mn];
1841 Player_ship->gun_points[gun_num] = pnt;
1849 void bm_read_some_file()
1854 Error("Trying to read bitmap <%s> with bm_flag==BM_NONE on line %d of BITMAPS.TBL",arg,linenum);
1857 bitmap_index bitmap;
1858 bitmap = bm_load_sub(arg);
1859 Assert( Num_cockpits < N_COCKPIT_BITMAPS );
1860 cockpit_bitmap[Num_cockpits++] = bitmap;
1861 //bm_flag = BM_NONE;
1869 case BM_GAUGES_HIRES:
1870 bm_read_gauges_hires();
1886 bitmap_index bitmap;
1887 bitmap = bm_load_sub(arg);
1888 Assert(tmap_count < MAX_TEXTURES);
1889 TmapList[tmap_count++] = texture_count;
1890 Textures[texture_count] = bitmap;
1891 set_texture_name( arg );
1892 Assert(texture_count < MAX_TEXTURES);
1894 NumTextures = texture_count;
1904 Error("Trying to read bitmap <%s> with unknown bm_flag <%x> on line %d of BITMAPS.TBL",arg,bm_flag,linenum);
1907 // ------------------------------------------------------------------------------
1908 // If unused_flag is set, then this is just a placeholder. Don't actually reference vclips or load bbms.
1909 void bm_read_weapon(int unused_flag)
1914 char *pof_file_inner=NULL;
1915 char *model_name[MAX_MODEL_VARIANTS];
1916 int first_bitmap_num[MAX_MODEL_VARIANTS];
1917 int lighted; //flag for whether is a texture is lighted
1919 Assert(N_weapon_types < MAX_WEAPON_TYPES);
1923 Assert(N_weapon_types <= MAX_WEAPON_TYPES);
1926 clear_to_end_of_line();
1931 if (Registered_only) {
1932 clear_to_end_of_line();
1937 // Initialize weapon array
1938 Weapon_info[n].render_type = WEAPON_RENDER_NONE; // 0=laser, 1=blob, 2=object
1939 Weapon_info[n].bitmap.index = 0;
1940 Weapon_info[n].model_num = -1;
1941 Weapon_info[n].model_num_inner = -1;
1942 Weapon_info[n].blob_size = 0x1000; // size of blob
1943 Weapon_info[n].flash_vclip = -1;
1944 Weapon_info[n].flash_sound = SOUND_LASER_FIRED;
1945 Weapon_info[n].flash_size = 0;
1946 Weapon_info[n].robot_hit_vclip = -1;
1947 Weapon_info[n].robot_hit_sound = -1;
1948 Weapon_info[n].wall_hit_vclip = -1;
1949 Weapon_info[n].wall_hit_sound = -1;
1950 Weapon_info[n].impact_size = 0;
1951 for (i=0; i<NDL; i++) {
1952 Weapon_info[n].strength[i] = F1_0;
1953 Weapon_info[n].speed[i] = F1_0*10;
1955 Weapon_info[n].mass = F1_0;
1956 Weapon_info[n].thrust = 0;
1957 Weapon_info[n].drag = 0;
1958 Weapon_info[n].persistent = 0;
1960 Weapon_info[n].energy_usage = 0; // How much fuel is consumed to fire this weapon.
1961 Weapon_info[n].ammo_usage = 0; // How many units of ammunition it uses.
1962 Weapon_info[n].fire_wait = F1_0/4; // Time until this weapon can be fired again.
1963 Weapon_info[n].fire_count = 1; // Number of bursts fired from EACH GUN per firing. For weapons which fire from both sides, 3*fire_count shots will be fired.
1964 Weapon_info[n].damage_radius = 0; // Radius of damage for missiles, not lasers. Does damage to objects within this radius of hit point.
1965 //--01/19/95, mk-- Weapon_info[n].damage_force = 0; // Force (movement) due to explosion
1966 Weapon_info[n].destroyable = 1; // Weapons default to destroyable
1967 Weapon_info[n].matter = 0; // Weapons default to not being constructed of matter (they are energy!)
1968 Weapon_info[n].bounce = 0; // Weapons default to not bouncing off walls
1970 Weapon_info[n].flags = 0;
1972 Weapon_info[n].lifetime = WEAPON_DEFAULT_LIFETIME; // Number of bursts fired from EACH GUN per firing. For weapons which fire from both sides, 3*fire_count shots will be fired.
1974 Weapon_info[n].po_len_to_width_ratio = F1_0*10;
1976 Weapon_info[n].picture.index = 0;
1977 Weapon_info[n].hires_picture.index = 0;
1978 Weapon_info[n].homing_flag = 0;
1980 Weapon_info[n].flash = 0;
1981 Weapon_info[n].multi_damage_scale = F1_0;
1982 Weapon_info[n].afterburner_size = 0;
1983 Weapon_info[n].children = -1;
1985 // Process arguments
1986 arg = strtok( NULL, space );
1988 lighted = 1; //assume first texture is lighted
1990 Weapon_info[n].speedvar = 128;
1993 equal_ptr = strchr( arg, '=' );
1997 // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
1998 if (!stricmp( arg, "laser_bmp" )) {
1999 // Load bitmap with name equal_ptr
2001 Weapon_info[n].bitmap = bm_load_sub(equal_ptr); //load_polymodel_bitmap(equal_ptr);
2002 Weapon_info[n].render_type = WEAPON_RENDER_LASER;
2004 } else if (!stricmp( arg, "blob_bmp" )) {
2005 // Load bitmap with name equal_ptr
2007 Weapon_info[n].bitmap = bm_load_sub(equal_ptr); //load_polymodel_bitmap(equal_ptr);
2008 Weapon_info[n].render_type = WEAPON_RENDER_BLOB;
2010 } else if (!stricmp( arg, "weapon_vclip" )) {
2011 // Set vclip to play for this weapon.
2012 Weapon_info[n].bitmap.index = 0;
2013 Weapon_info[n].render_type = WEAPON_RENDER_VCLIP;
2014 Weapon_info[n].weapon_vclip = atoi(equal_ptr);
2016 } else if (!stricmp( arg, "none_bmp" )) {
2017 Weapon_info[n].bitmap = bm_load_sub(equal_ptr);
2018 Weapon_info[n].render_type = WEAPON_RENDER_NONE;
2020 } else if (!stricmp( arg, "weapon_pof" )) {
2022 Assert(n_models==0);
2023 model_name[0] = equal_ptr;
2024 first_bitmap_num[0] = N_ObjBitmapPtrs;
2026 } else if (!stricmp( arg, "simple_model" )) {
2027 model_name[n_models] = equal_ptr;
2028 first_bitmap_num[n_models] = N_ObjBitmapPtrs;
2030 Assert(n_models < MAX_MODEL_VARIANTS);
2031 } else if (!stricmp( arg, "weapon_pof_inner" )) {
2033 pof_file_inner = equal_ptr;
2034 } else if (!stricmp( arg, "strength" )) {
2035 for (i=0; i<NDL-1; i++) {
2036 Weapon_info[n].strength[i] = fl2f(atof(equal_ptr));
2037 equal_ptr = strtok(NULL, space);
2039 Weapon_info[n].strength[i] = i2f(atoi(equal_ptr));
2040 } else if (!stricmp( arg, "mass" )) {
2041 Weapon_info[n].mass = fl2f(atof(equal_ptr));
2042 } else if (!stricmp( arg, "drag" )) {
2043 Weapon_info[n].drag = fl2f(atof(equal_ptr));
2044 } else if (!stricmp( arg, "thrust" )) {
2045 Weapon_info[n].thrust = fl2f(atof(equal_ptr));
2046 } else if (!stricmp( arg, "matter" )) {
2047 Weapon_info[n].matter = atoi(equal_ptr);
2048 } else if (!stricmp( arg, "bounce" )) {
2049 Weapon_info[n].bounce = atoi(equal_ptr);
2050 } else if (!stricmp( arg, "speed" )) {
2051 for (i=0; i<NDL-1; i++) {
2052 Weapon_info[n].speed[i] = i2f(atoi(equal_ptr));
2053 equal_ptr = strtok(NULL, space);
2055 Weapon_info[n].speed[i] = i2f(atoi(equal_ptr));
2056 } else if (!stricmp( arg, "speedvar" )) {
2057 Weapon_info[n].speedvar = (atoi(equal_ptr) * 128) / 100;
2058 } else if (!stricmp( arg, "flash_vclip" )) {
2059 Weapon_info[n].flash_vclip = atoi(equal_ptr);
2060 } else if (!stricmp( arg, "flash_sound" )) {
2061 Weapon_info[n].flash_sound = atoi(equal_ptr);
2062 } else if (!stricmp( arg, "flash_size" )) {
2063 Weapon_info[n].flash_size = fl2f(atof(equal_ptr));
2064 } else if (!stricmp( arg, "blob_size" )) {
2065 Weapon_info[n].blob_size = fl2f(atof(equal_ptr));
2066 } else if (!stricmp( arg, "robot_hit_vclip" )) {
2067 Weapon_info[n].robot_hit_vclip = atoi(equal_ptr);
2068 } else if (!stricmp( arg, "robot_hit_sound" )) {
2069 Weapon_info[n].robot_hit_sound = atoi(equal_ptr);
2070 } else if (!stricmp( arg, "wall_hit_vclip" )) {
2071 Weapon_info[n].wall_hit_vclip = atoi(equal_ptr);
2072 } else if (!stricmp( arg, "wall_hit_sound" )) {
2073 Weapon_info[n].wall_hit_sound = atoi(equal_ptr);
2074 } else if (!stricmp( arg, "impact_size" )) {
2075 Weapon_info[n].impact_size = fl2f(atof(equal_ptr));
2076 } else if (!stricmp( arg, "lighted" )) {
2077 lighted = atoi(equal_ptr);
2078 } else if (!stricmp( arg, "lw_ratio" )) {
2079 Weapon_info[n].po_len_to_width_ratio = fl2f(atof(equal_ptr));
2080 } else if (!stricmp( arg, "lightcast" )) {
2081 Weapon_info[n].light = fl2f(atof(equal_ptr));
2082 } else if (!stricmp( arg, "persistent" )) {
2083 Weapon_info[n].persistent = atoi(equal_ptr);
2084 } else if (!stricmp(arg, "energy_usage" )) {
2085 Weapon_info[n].energy_usage = fl2f(atof(equal_ptr));
2086 } else if (!stricmp(arg, "ammo_usage" )) {
2087 Weapon_info[n].ammo_usage = atoi(equal_ptr);
2088 } else if (!stricmp(arg, "fire_wait" )) {
2089 Weapon_info[n].fire_wait = fl2f(atof(equal_ptr));
2090 } else if (!stricmp(arg, "fire_count" )) {
2091 Weapon_info[n].fire_count = atoi(equal_ptr);
2092 } else if (!stricmp(arg, "damage_radius" )) {
2093 Weapon_info[n].damage_radius = fl2f(atof(equal_ptr));
2094 //--01/19/95, mk-- } else if (!stricmp(arg, "damage_force" )) {
2095 //--01/19/95, mk-- Weapon_info[n].damage_force = fl2f(atof(equal_ptr));
2096 } else if (!stricmp(arg, "lifetime" )) {
2097 Weapon_info[n].lifetime = fl2f(atof(equal_ptr));
2098 } else if (!stricmp(arg, "destroyable" )) {
2099 Weapon_info[n].destroyable = atoi(equal_ptr);
2100 } else if (!stricmp(arg, "picture" )) {
2101 Weapon_info[n].picture = bm_load_sub(equal_ptr);
2102 } else if (!stricmp(arg, "hires_picture" )) {
2103 Weapon_info[n].hires_picture = bm_load_sub(equal_ptr);
2104 } else if (!stricmp(arg, "homing" )) {
2105 Weapon_info[n].homing_flag = !!atoi(equal_ptr);
2106 } else if (!stricmp(arg, "flash" )) {
2107 Weapon_info[n].flash = atoi(equal_ptr);
2108 } else if (!stricmp(arg, "multi_damage_scale" )) {
2109 Weapon_info[n].multi_damage_scale = fl2f(atof(equal_ptr));
2110 } else if (!stricmp(arg, "afterburner_size" )) {
2111 Weapon_info[n].afterburner_size = f2i(16*fl2f(atof(equal_ptr)));
2112 } else if (!stricmp(arg, "children" )) {
2113 Weapon_info[n].children = atoi(equal_ptr);
2114 } else if (!stricmp(arg, "placable" )) {
2115 if (atoi(equal_ptr)) {
2116 Weapon_info[n].flags |= WIF_PLACABLE;
2118 Assert(Num_total_object_types < MAX_OBJTYPE);
2119 ObjType[Num_total_object_types] = OL_WEAPON;
2120 ObjId[Num_total_object_types] = n;
2121 Num_total_object_types++;
2125 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
2127 } else { // Must be a texture specification...
2130 bm = load_polymodel_bitmap(arg);
2132 bm->bm_flags |= BM_FLAG_NO_LIGHTING;
2134 lighted = 1; //default for next bitmap is lighted
2136 arg = strtok( NULL, space );
2139 first_bitmap_num[n_models] = N_ObjBitmapPtrs;
2141 for (i=0;i<n_models;i++) {
2143 int model_num,last_model_num=0;
2145 n_textures = first_bitmap_num[i+1] - first_bitmap_num[i];
2147 model_num = load_polygon_model(model_name[i],n_textures,first_bitmap_num[i],NULL);
2150 Weapon_info[n].render_type = WEAPON_RENDER_POLYMODEL;
2151 Weapon_info[n].model_num = model_num;
2154 Polygon_models[last_model_num].simpler_model = model_num+1;
2156 last_model_num = model_num;
2159 if ( pof_file_inner ) {
2161 Weapon_info[n].model_num_inner = load_polygon_model(pof_file_inner,first_bitmap_num[1]-first_bitmap_num[0],first_bitmap_num[0],NULL);
2164 if ((Weapon_info[n].ammo_usage == 0) && (Weapon_info[n].energy_usage == 0))
2165 mprintf((1, "Warning: Weapon %i has ammo and energy usage of 0.\n", n));
2167 // -- render type of none is now legal -- Assert( Weapon_info[n].render_type != WEAPON_RENDER_NONE );
2174 // ------------------------------------------------------------------------------
2175 #define DEFAULT_POWERUP_SIZE i2f(3)
2177 void bm_read_powerup(int unused_flag)
2182 Assert(N_powerup_types < MAX_POWERUP_TYPES);
2184 n = N_powerup_types;
2188 clear_to_end_of_line();
2192 // Initialize powerup array
2193 Powerup_info[n].light = F1_0/3; // Default lighting value.
2194 Powerup_info[n].vclip_num = -1;
2195 Powerup_info[n].hit_sound = -1;
2196 Powerup_info[n].size = DEFAULT_POWERUP_SIZE;
2197 Powerup_names[n][0] = 0;
2199 // Process arguments
2200 arg = strtok( NULL, space );
2203 equal_ptr = strchr( arg, '=' );
2207 // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
2208 if (!stricmp( arg, "vclip_num" )) {
2209 Powerup_info[n].vclip_num = atoi(equal_ptr);
2210 } else if (!stricmp( arg, "light" )) {
2211 Powerup_info[n].light = fl2f(atof(equal_ptr));
2212 } else if (!stricmp( arg, "hit_sound" )) {
2213 Powerup_info[n].hit_sound = atoi(equal_ptr);
2214 } else if (!stricmp( arg, "name" )) {
2215 Assert(strlen(equal_ptr) < POWERUP_NAME_LENGTH); // Oops, name too long.
2216 strcpy(Powerup_names[n], &equal_ptr[1]);
2217 Powerup_names[n][strlen(Powerup_names[n])-1] = 0;
2218 } else if (!stricmp( arg, "size" )) {
2219 Powerup_info[n].size = fl2f(atof(equal_ptr));
2222 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
2224 } else { // Must be a texture specification...
2226 mprintf( (1, "Invalid argument, %s in bitmaps.tbl\n", arg ));
2228 arg = strtok( NULL, space );
2231 ObjType[Num_total_object_types] = OL_POWERUP;
2232 ObjId[Num_total_object_types] = n;
2233 //printf( "Object type %d is a powerup\n", Num_total_object_types );
2234 Num_total_object_types++;
2235 Assert(Num_total_object_types < MAX_OBJTYPE);
2239 void bm_read_hostage()
2244 Assert(N_hostage_types < MAX_HOSTAGE_TYPES);
2246 n = N_hostage_types;
2249 // Process arguments
2250 arg = strtok( NULL, space );
2253 equal_ptr = strchr( arg, '=' );
2258 if (!stricmp( arg, "vclip_num" ))
2260 Hostage_vclip_num[n] = atoi(equal_ptr);
2264 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
2269 mprintf( (1, "Invalid argument, %s in bitmaps.tbl at line %d\n", arg, linenum ));
2271 arg = strtok( NULL, space );
2274 ObjType[Num_total_object_types] = OL_HOSTAGE;
2275 ObjId[Num_total_object_types] = n;
2276 //printf( "Object type %d is a hostage\n", Num_total_object_types );
2277 Num_total_object_types++;
2278 Assert(Num_total_object_types < MAX_OBJTYPE);
2282 //these values are the number of each item in the release of d2
2283 //extra items added after the release get written in an additional hamfile
2284 #define N_D2_ROBOT_TYPES 66
2285 #define N_D2_ROBOT_JOINTS 1145
2286 #define N_D2_POLYGON_MODELS 166
2287 #define N_D2_OBJBITMAPS 422
2288 #define N_D2_OBJBITMAPPTRS 502
2289 #define N_D2_WEAPON_TYPES 62
2291 void bm_write_all(FILE *fp)
2297 tfile = fopen("hamfile.lst","wt");
2299 t = NumTextures-1; //don't save bogus texture
2300 fwrite( &t, sizeof(int), 1, fp );
2301 fwrite( Textures, sizeof(bitmap_index), t, fp );
2303 fwrite( &TmapInfo[i], sizeof(*TmapInfo)-sizeof(TmapInfo->filename)-sizeof(TmapInfo->pad2), 1, fp );
2305 fprintf(tfile,"NumTextures = %d, Textures array = %d, TmapInfo array = %d\n",NumTextures,sizeof(bitmap_index)*NumTextures,sizeof(tmap_info)*NumTextures);
2308 fwrite( &t, sizeof(int), 1, fp );
2309 fwrite( Sounds, sizeof(ubyte), t, fp );
2310 fwrite( AltSounds, sizeof(ubyte), t, fp );
2312 fprintf(tfile,"Num Sounds = %d, Sounds array = %d, AltSounds array = %d\n",t,t,t);
2314 fwrite( &Num_vclips, sizeof(int), 1, fp );
2315 fwrite( Vclip, sizeof(vclip), Num_vclips, fp );
2317 fprintf(tfile,"Num_vclips = %d, Vclip array = %d\n",Num_vclips,sizeof(vclip)*Num_vclips);
2319 fwrite( &Num_effects, sizeof(int), 1, fp );
2320 fwrite( Effects, sizeof(eclip), Num_effects, fp );
2322 fprintf(tfile,"Num_effects = %d, Effects array = %d\n",Num_effects,sizeof(eclip)*Num_effects);
2324 fwrite( &Num_wall_anims, sizeof(int), 1, fp );
2325 fwrite( WallAnims, sizeof(wclip), Num_wall_anims, fp );
2327 fprintf(tfile,"Num_wall_anims = %d, WallAnims array = %d\n",Num_wall_anims,sizeof(wclip)*Num_wall_anims);
2329 t = N_D2_ROBOT_TYPES;
2330 fwrite( &t, sizeof(int), 1, fp );
2331 fwrite( Robot_info, sizeof(robot_info), t, fp );
2333 fprintf(tfile,"N_robot_types = %d, Robot_info array = %d\n",t,sizeof(robot_info)*N_robot_types);
2335 t = N_D2_ROBOT_JOINTS;
2336 fwrite( &t, sizeof(int), 1, fp );
2337 fwrite( Robot_joints, sizeof(jointpos), t, fp );
2339 fprintf(tfile,"N_robot_joints = %d, Robot_joints array = %d\n",t,sizeof(jointpos)*N_robot_joints);
2341 t = N_D2_WEAPON_TYPES;
2342 fwrite( &t, sizeof(int), 1, fp );
2343 fwrite( Weapon_info, sizeof(weapon_info), t, fp );
2345 fprintf(tfile,"N_weapon_types = %d, Weapon_info array = %d\n",N_weapon_types,sizeof(weapon_info)*N_weapon_types);
2347 fwrite( &N_powerup_types, sizeof(int), 1, fp );
2348 fwrite( Powerup_info, sizeof(powerup_type_info), N_powerup_types, fp );
2350 fprintf(tfile,"N_powerup_types = %d, Powerup_info array = %d\n",N_powerup_types,sizeof(powerup_info)*N_powerup_types);
2352 t = N_D2_POLYGON_MODELS;
2353 fwrite( &t, sizeof(int), 1, fp );
2354 fwrite( Polygon_models, sizeof(polymodel), t, fp );
2356 fprintf(tfile,"N_polygon_models = %d, Polygon_models array = %d\n",t,sizeof(polymodel)*t);
2358 for (i=0; i<t; i++ ) {
2359 g3_uninit_polygon_model(Polygon_models[i].model_data); //get RGB colors
2360 fwrite( Polygon_models[i].model_data, sizeof(ubyte), Polygon_models[i].model_data_size, fp );
2361 fprintf(tfile," Model %d, data size = %d\n",i,Polygon_models[i].model_data_size); s+=Polygon_models[i].model_data_size;
2362 g3_init_polygon_model(Polygon_models[i].model_data); //map colors again
2364 fprintf(tfile,"Total model size = %d\n",s);
2366 fwrite( Dying_modelnums, sizeof(int), t, fp );
2367 fwrite( Dead_modelnums, sizeof(int), t, fp );
2369 fprintf(tfile,"Dying_modelnums array = %d, Dead_modelnums array = %d\n",sizeof(int)*t,sizeof(int)*t);
2372 fwrite( &t, sizeof(int), 1, fp );
2373 fwrite( Gauges, sizeof(bitmap_index), t, fp );
2374 fwrite( Gauges_hires, sizeof(bitmap_index), t, fp );
2376 fprintf(tfile,"Num gauge bitmaps = %d, Gauges array = %d, Gauges_hires array = %d\n",t,sizeof(bitmap_index)*t,sizeof(bitmap_index)*t);
2378 t = MAX_OBJ_BITMAPS;
2379 fwrite( &t, sizeof(int), 1, fp );
2380 fwrite( ObjBitmaps, sizeof(bitmap_index), t, fp );
2381 fwrite( ObjBitmapPtrs, sizeof(ushort), t, fp );
2383 fprintf(tfile,"Num obj bitmaps = %d, ObjBitmaps array = %d, ObjBitmapPtrs array = %d\n",t,sizeof(bitmap_index)*t,sizeof(ushort)*t);
2385 fwrite( &only_player_ship, sizeof(player_ship), 1, fp );
2387 fprintf(tfile,"player_ship size = %d\n",sizeof(player_ship));
2389 fwrite( &Num_cockpits, sizeof(int), 1, fp );
2390 fwrite( cockpit_bitmap, sizeof(bitmap_index), Num_cockpits, fp );
2392 fprintf(tfile,"Num_cockpits = %d, cockpit_bitmaps array = %d\n",Num_cockpits,sizeof(bitmap_index)*Num_cockpits);
2394 //@@ fwrite( &Num_total_object_types, sizeof(int), 1, fp );
2395 //@@ fwrite( ObjType, sizeof(sbyte), Num_total_object_types, fp );
2396 //@@ fwrite( ObjId, sizeof(sbyte), Num_total_object_types, fp );
2397 //@@ fwrite( ObjStrength, sizeof(fix), Num_total_object_types, fp );
2399 fprintf(tfile,"Num_total_object_types = %d, ObjType array = %d, ObjId array = %d, ObjStrength array = %d\n",Num_total_object_types,Num_total_object_types,Num_total_object_types,sizeof(fix)*Num_total_object_types);
2401 fwrite( &First_multi_bitmap_num, sizeof(int), 1, fp );
2403 fwrite( &Num_reactors, sizeof(Num_reactors), 1, fp );
2404 fwrite( Reactors, sizeof(*Reactors), Num_reactors, fp);
2406 fprintf(tfile,"Num_reactors = %d, Reactors array = %d\n",Num_reactors,sizeof(*Reactors)*Num_reactors);
2408 fwrite( &Marker_model_num, sizeof(Marker_model_num), 1, fp);
2410 //@@fwrite( &N_controlcen_guns, sizeof(int), 1, fp );
2411 //@@fwrite( controlcen_gun_points, sizeof(vms_vector), N_controlcen_guns, fp );
2412 //@@fwrite( controlcen_gun_dirs, sizeof(vms_vector), N_controlcen_guns, fp );
2415 fwrite( &exit_modelnum, sizeof(int), 1, fp );
2416 fwrite( &destroyed_exit_modelnum, sizeof(int), 1, fp );
2421 bm_write_extra_robots();
2424 void bm_write_extra_robots()
2430 fp = fopen("robots.ham","wb");
2432 t = 0x5848414d; /* 'XHAM' */
2433 fwrite( &t, sizeof(int), 1, fp );
2435 fwrite( &t, sizeof(int), 1, fp );
2438 t = N_weapon_types - N_D2_WEAPON_TYPES;
2439 fwrite( &t, sizeof(int), 1, fp );
2440 fwrite( &Weapon_info[N_D2_WEAPON_TYPES], sizeof(weapon_info), t, fp );
2442 //now write robot info
2444 t = N_robot_types - N_D2_ROBOT_TYPES;
2445 fwrite( &t, sizeof(int), 1, fp );
2446 fwrite( &Robot_info[N_D2_ROBOT_TYPES], sizeof(robot_info), t, fp );
2448 t = N_robot_joints - N_D2_ROBOT_JOINTS;
2449 fwrite( &t, sizeof(int), 1, fp );
2450 fwrite( &Robot_joints[N_D2_ROBOT_JOINTS], sizeof(jointpos), t, fp );
2452 t = N_polygon_models - N_D2_POLYGON_MODELS;
2453 fwrite( &t, sizeof(int), 1, fp );
2454 fwrite( &Polygon_models[N_D2_POLYGON_MODELS], sizeof(polymodel), t, fp );
2456 for (i=N_D2_POLYGON_MODELS; i<N_polygon_models; i++ ) {
2457 g3_uninit_polygon_model(Polygon_models[i].model_data); //get RGB colors
2458 fwrite( Polygon_models[i].model_data, sizeof(ubyte), Polygon_models[i].model_data_size, fp );
2459 g3_init_polygon_model(Polygon_models[i].model_data); //map colors again
2462 fwrite( &Dying_modelnums[N_D2_POLYGON_MODELS], sizeof(int), t, fp );
2463 fwrite( &Dead_modelnums[N_D2_POLYGON_MODELS], sizeof(int), t, fp );
2465 t = N_ObjBitmaps - N_D2_OBJBITMAPS;
2466 fwrite( &t, sizeof(int), 1, fp );
2467 fwrite( &ObjBitmaps[N_D2_OBJBITMAPS], sizeof(bitmap_index), t, fp );
2469 t = N_ObjBitmapPtrs - N_D2_OBJBITMAPPTRS;
2470 fwrite( &t, sizeof(int), 1, fp );
2471 fwrite( &ObjBitmapPtrs[N_D2_OBJBITMAPPTRS], sizeof(ushort), t, fp );
2473 fwrite( ObjBitmapPtrs, sizeof(ushort), t, fp );