2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
16 char bmread_rcsid[] = "$Id: bmread.c,v 1.1.1.1 2001-01-19 03:30:01 bradleyb Exp $";
66 #include "editor\texpage.h"
78 #define BM_WALL_ANIMS 12
82 #define BM_GAUGES_HIRES 21
84 #define MAX_BITMAPS_PER_BRUSH 30
86 extern player_ship only_player_ship; // In bm.c
89 short N_ObjBitmapPtrs=0;
90 static int Num_robot_ais = 0;
91 int TmapList[MAX_TEXTURES];
92 char Powerup_names[MAX_POWERUP_TYPES][POWERUP_NAME_LENGTH];
93 char Robot_names[MAX_ROBOT_TYPES][ROBOT_NAME_LENGTH];
95 //---------------- Internal variables ---------------------------
96 static int Registered_only = 0; // Gets set by ! in column 1.
97 static int SuperX = -1;
98 static int Installed=0;
100 static short tmap_count = 0;
101 static short texture_count = 0;
102 static short clip_count = 0;
103 static short clip_num;
104 static short sound_num;
107 static int hit_sound = -1;
108 static byte bm_flag = BM_NONE;
109 static int abm_flag = 0;
110 static int rod_flag = 0;
111 static short wall_open_sound, wall_close_sound,wall_explodes,wall_blastable, wall_hidden;
113 static int obj_eclip;
114 static char *dest_bm; //clip number to play when destroyed
115 static int dest_vclip; //what vclip to play when exploding
116 static int dest_eclip; //what eclip to play when exploding
117 static fix dest_size; //3d size of explosion
118 static int crit_clip; //clip number to play when destroyed
119 static int crit_flag; //flag if this is a destroyed eclip
120 static int tmap1_flag; //flag if this is used as tmap_num (not tmap_num2)
121 static int num_sounds=0;
123 int linenum; //line int table currently being parsed
125 //------------------- Useful macros and variables ---------------
126 #define REMOVE_EOL(s) remove_char((s),'\n')
127 #define REMOVE_COMMENTS(s) remove_char((s),';')
128 #define REMOVE_DOTS(s) remove_char((s),'.')
130 #define IFTOK(str) if (!strcmp(arg, str))
131 char *space = { " \t" };
132 //--unused-- char *equal = { "=" };
133 char *equal_space = { " \t=" };
136 // For the sake of LINT, defining prototypes to module's functions
137 void bm_read_robot_ai(void);
138 void bm_read_powerup(int unused_flag);
139 void bm_read_hostage(void);
140 void bm_read_robot(void);
141 void bm_read_weapon(int unused_flag);
142 void bm_read_reactor(void);
143 void bm_read_exitmodel(void);
144 void bm_read_player_ship(void);
145 void bm_read_some_file(void);
146 void bm_read_sound(void);
147 void verify_textures(void);
150 //----------------------------------------------------------------------
151 void remove_char( char * s, char c )
158 //---------------------------------------------------------------
159 int compute_average_pixel(grs_bitmap *new)
161 int row, column, color;
163 int total_red, total_green, total_blue;
165 pptr = (char *)new->bm_data;
171 for (row=0; row<new->bm_h; row++)
172 for (column=0; column<new->bm_w; column++) {
174 total_red += gr_palette[color*3];
175 total_green += gr_palette[color*3+1];
176 total_blue += gr_palette[color*3+2];
179 total_red /= (new->bm_h * new->bm_w);
180 total_green /= (new->bm_h * new->bm_w);
181 total_blue /= (new->bm_h * new->bm_w);
183 return BM_XRGB(total_red/2, total_green/2, total_blue/2);
186 //---------------------------------------------------------------
187 // Loads a bitmap from either the piggy file, a r64 file, or a
188 // whatever extension is passed.
190 bitmap_index bm_load_sub( char * filename )
192 bitmap_index bitmap_num;
195 int iff_error; //reference parm to avoid warning message
198 bitmap_num.index = 0;
201 if (Registered_only) {
202 //mprintf( 0, "Skipping registered-only bitmap '%s'\n", filename );
207 _splitpath( filename, NULL, NULL, fname, NULL );
209 bitmap_num=piggy_find_bitmap( fname );
210 if (bitmap_num.index) {
211 //mprintf(( 0, "Found bitmap '%s' in pig!\n", fname ));
215 MALLOC( new, grs_bitmap, 1 );
216 iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal);
218 if (iff_error != IFF_NO_ERROR) {
219 mprintf((1, "File %s - IFF error: %s",filename,iff_errormsg(iff_error)));
220 Error("File <%s> - IFF error: %s, line %d",filename,iff_errormsg(iff_error),linenum);
223 if ( iff_has_transparency )
224 gr_remap_bitmap_good( new, newpal, iff_transparent_color, SuperX );
226 gr_remap_bitmap_good( new, newpal, -1, SuperX );
228 new->avg_color = compute_average_pixel(new);
230 // -- mprintf((0, "N" ));
231 bitmap_num = piggy_register_bitmap( new, fname, 0 );
236 extern grs_bitmap bogus_bitmap;
237 extern ubyte bogus_bitmap_initialized;
238 extern digi_sound bogus_sound;
240 void ab_load( char * filename, bitmap_index bmp[], int *nframes )
242 grs_bitmap * bm[MAX_BITMAPS_PER_BRUSH];
245 int iff_error; //reference parm to avoid warning message
251 if (Registered_only) {
252 Assert( bogus_bitmap_initialized != 0 );
253 mprintf(( 0, "Skipping registered-only animation '%s'\n", filename ));
254 bmp[0].index = 0; //index of bogus bitmap==0 (I think) //&bogus_bitmap;
261 _splitpath( filename, NULL, NULL, fname, NULL );
263 for (i=0; i<MAX_BITMAPS_PER_BRUSH; i++ ) {
264 sprintf( tempname, "%s#%d", fname, i );
265 bi = piggy_find_bitmap( tempname );
269 //mprintf(( 0, "Found animation frame %d, %s, in piggy file\n", i, tempname ));
277 // Note that last argument passes an address to the array newpal (which is a pointer).
278 // type mismatch found using lint, will substitute this line with an adjusted
279 // one. If fatal error, then it can be easily changed.
280 // iff_error = iff_read_animbrush(filename,bm,MAX_BITMAPS_PER_BRUSH,nframes,&newpal);
281 iff_error = iff_read_animbrush(filename,bm,MAX_BITMAPS_PER_BRUSH,nframes,newpal);
282 if (iff_error != IFF_NO_ERROR) {
283 mprintf((1,"File %s - IFF error: %s",filename,iff_errormsg(iff_error)));
284 Error("File <%s> - IFF error: %s, line %d",filename,iff_errormsg(iff_error),linenum);
287 for (i=0;i< *nframes; i++) {
288 bitmap_index new_bmp;
289 sprintf( tempname, "%s#%d", fname, i );
290 if ( iff_has_transparency )
291 gr_remap_bitmap_good( bm[i], newpal, iff_transparent_color, SuperX );
293 gr_remap_bitmap_good( bm[i], newpal, -1, SuperX );
295 bm[i]->avg_color = compute_average_pixel(bm[i]);
297 new_bmp = piggy_register_bitmap( bm[i], tempname, 0 );
301 mprintf((0, "Registering %s in piggy file.", tempname ));
308 int ds_load( char * filename ) {
316 if (Registered_only) {
317 //mprintf( 0, "Skipping registered-only sound '%s'\n", filename );
318 return 0; //don't know what I should return here //&bogus_sound;
322 _splitpath( filename, NULL, NULL, fname, NULL );
323 _makepath( rawname, NULL, NULL,fname, (digi_sample_rate==SAMPLE_RATE_22K)?".R22":".RAW" );
325 i=piggy_find_sound( fname );
330 cfp = cfopen( rawname, "rb" );
333 new.length = cfilelength( cfp );
334 MALLOC( new.data, ubyte, new.length );
335 cfread( new.data, 1, new.length, cfp );
337 // -- mprintf( (0, "S" ));
338 // -- mprintf( (0, "<%s>", rawname ));
340 mprintf( (1, "Warning: Couldn't find '%s'\n", filename ));
343 i = piggy_register_sound( &new, fname, 0 );
352 xarg = strtok( NULL, space );
361 xarg = strtok( NULL, space );
365 // rotates a byte left one bit, preserving the bit falling off the right
367 //rotate_left(char *c)
379 //loads a texture and returns the texture num
380 int get_texture(char *name)
382 char short_name[FILENAME_LEN];
385 strcpy(short_name,name);
386 REMOVE_DOTS(short_name);
387 for (i=0;i<texture_count;i++)
388 if (!stricmp(TmapInfo[i].filename,short_name))
390 if (i==texture_count) {
391 Textures[texture_count] = bm_load_sub(name);
392 strcpy( TmapInfo[texture_count].filename, short_name);
394 Assert(texture_count < MAX_TEXTURES);
395 NumTextures = texture_count;
401 #define LINEBUF_SIZE 600
403 #define DEFAULT_PIG_PALETTE "groupa.256"
405 //-----------------------------------------------------------------
406 // Initializes all bitmaps from BITMAPS.TBL file.
407 // This is called when the editor is IN.
408 // If no editor, bm_init() is called.
409 int bm_init_use_tbl()
412 char inputline[LINEBUF_SIZE];
415 gr_use_palette_table(DEFAULT_PIG_PALETTE);
417 load_palette(DEFAULT_PIG_PALETTE,-2,0); //special: tell palette code which pig is loaded
419 init_polygon_models();
421 ObjType[0] = OL_PLAYER;
423 Num_total_object_types = 1;
425 for (i=0; i<MAX_SOUNDS; i++ ) {
430 for (i=0; i<MAX_TEXTURES; i++ ) {
431 TmapInfo[i].eclip_num = -1;
432 TmapInfo[i].flags = 0;
433 TmapInfo[i].slide_u = TmapInfo[i].slide_v = 0;
434 TmapInfo[i].destroyed = -1;
437 for (i=0;i<MAX_REACTORS;i++)
438 Reactors[i].model_num = -1;
441 for (i=0; i<MAX_EFFECTS; i++ ) {
442 //Effects[i].bm_ptr = (grs_bitmap **) -1;
443 Effects[i].changing_wall_texture = -1;
444 Effects[i].changing_object_texture = -1;
445 Effects[i].segnum = -1;
446 Effects[i].vc.num_frames = -1; //another mark of being unused
449 for (i=0;i<MAX_POLYGON_MODELS;i++)
450 Dying_modelnums[i] = Dead_modelnums[i] = -1;
453 for (i=0; i<VCLIP_MAXNUM; i++ ) {
454 Vclip[i].num_frames = -1;
458 for (i=0; i<MAX_WALL_ANIMS; i++ )
459 WallAnims[i].num_frames = -1;
462 setbuf(stdout, NULL); // unbuffered output via printf
469 piggy_init(); //don't care about error, since no pig is ok for editor
471 // if ( FindArg( "-nobm" ) ) {
472 // piggy_read_sounds();
476 // Open BITMAPS.TBL for reading.
478 InfoFile = cfopen( "BITMAPS.TBL", "rb" );
479 if (InfoFile == NULL) {
480 InfoFile = cfopen("BITMAPS.BIN", "rb");
481 if (InfoFile == NULL)
482 Error("Missing BITMAPS.TBL and BITMAPS.BIN file\n");
487 cfseek( InfoFile, 0L, SEEK_SET);
489 while (cfgets(inputline, LINEBUF_SIZE, InfoFile)) {
495 if (inputline[0]==' ' || inputline[0]=='\t') {
497 for (t=inputline;*t && *t!='\n';t++)
498 if (! (*t==' ' || *t=='\t')) {
499 mprintf((1,"Suspicious: line %d of BITMAPS.TBL starts with whitespace\n",linenum));
504 if (have_bin_tbl) { // is this a binary tbl file
505 for (i = 0; i < strlen(inputline) - 1; i++) {
506 encode_rotate_left(&(inputline[i]));
507 inputline[i] = inputline[i] ^ BITMAP_TBL_XOR;
508 encode_rotate_left(&(inputline[i]));
511 while (inputline[(l=strlen(inputline))-2]=='\\') {
512 if (!isspace(inputline[l-3])) { //if not space before backslash...
513 inputline[l-2] = ' '; //add one
516 cfgets(inputline+l-2,LINEBUF_SIZE-(l-2), InfoFile);
521 REMOVE_EOL(inputline);
522 if (strchr(inputline, ';')!=NULL) REMOVE_COMMENTS(inputline);
524 if (strlen(inputline) == LINEBUF_SIZE-1)
525 Error("Possible line truncation in BITMAPS.TBL on line %d\n",linenum);
529 if ( (temp_ptr=strstr( inputline, "superx=" )) ) {
530 SuperX = atoi( &temp_ptr[7] );
531 Assert(SuperX == 254);
532 //the superx color isn't kept around, so the new piggy regeneration
533 //code doesn't know what it is, so it assumes that it's 254, so
534 //this code requires that it be 254
538 arg = strtok( inputline, space );
547 // Check all possible flags and defines.
548 if (*arg == '$') bm_flag = BM_NONE; // reset to no flags as default.
550 IFTOK("$COCKPIT") bm_flag = BM_COCKPIT;
551 else IFTOK("$GAUGES") {bm_flag = BM_GAUGES; clip_count = 0;}
552 else IFTOK("$GAUGES_HIRES"){bm_flag = BM_GAUGES_HIRES; clip_count = 0;}
553 else IFTOK("$SOUND") bm_read_sound();
554 else IFTOK("$DOOR_ANIMS") bm_flag = BM_WALL_ANIMS;
555 else IFTOK("$WALL_ANIMS") bm_flag = BM_WALL_ANIMS;
556 else IFTOK("$TEXTURES") bm_flag = BM_TEXTURES;
557 else IFTOK("$VCLIP") {bm_flag = BM_VCLIP; vlighting = 0; clip_count = 0;}
558 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;}
559 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;}
561 else IFTOK("$EFFECTS") {bm_flag = BM_EFFECTS; clip_num = 0;}
562 else IFTOK("$ALIAS") bm_read_alias();
565 else IFTOK("!METALS_FLAG") TextureMetals = texture_count;
566 else IFTOK("!LIGHTS_FLAG") TextureLights = texture_count;
567 else IFTOK("!EFFECTS_FLAG") TextureEffects = texture_count;
570 else IFTOK("lighting") TmapInfo[texture_count-1].lighting = fl2f(get_float());
571 else IFTOK("damage") TmapInfo[texture_count-1].damage = fl2f(get_float());
572 else IFTOK("volatile") TmapInfo[texture_count-1].flags |= TMI_VOLATILE;
573 else IFTOK("goal_blue") TmapInfo[texture_count-1].flags |= TMI_GOAL_BLUE;
574 else IFTOK("goal_red") TmapInfo[texture_count-1].flags |= TMI_GOAL_RED;
575 else IFTOK("water") TmapInfo[texture_count-1].flags |= TMI_WATER;
576 else IFTOK("force_field") TmapInfo[texture_count-1].flags |= TMI_FORCE_FIELD;
577 else IFTOK("slide") {TmapInfo[texture_count-1].slide_u = fl2f(get_float())>>8; TmapInfo[texture_count-1].slide_v = fl2f(get_float())>>8;}
578 else IFTOK("destroyed") {int t=texture_count-1; TmapInfo[t].destroyed = get_texture(strtok( NULL, space ));}
579 //else IFTOK("Num_effects") Num_effects = get_int();
580 else IFTOK("Num_wall_anims") Num_wall_anims = get_int();
581 else IFTOK("clip_num") clip_num = get_int();
582 else IFTOK("dest_bm") dest_bm = strtok( NULL, space );
583 else IFTOK("dest_vclip") dest_vclip = get_int();
584 else IFTOK("dest_eclip") dest_eclip = get_int();
585 else IFTOK("dest_size") dest_size = fl2f(get_float());
586 else IFTOK("crit_clip") crit_clip = get_int();
587 else IFTOK("crit_flag") crit_flag = get_int();
588 else IFTOK("sound_num") sound_num = get_int();
589 else IFTOK("frames") frames = get_int();
590 else IFTOK("time") time = get_float();
591 else IFTOK("obj_eclip") obj_eclip = get_int();
592 else IFTOK("hit_sound") hit_sound = get_int();
593 else IFTOK("abm_flag") abm_flag = get_int();
594 else IFTOK("tmap1_flag") tmap1_flag = get_int();
595 else IFTOK("vlighting") vlighting = get_float();
596 else IFTOK("rod_flag") rod_flag = get_int();
597 else IFTOK("superx") get_int();
598 else IFTOK("open_sound") wall_open_sound = get_int();
599 else IFTOK("close_sound") wall_close_sound = get_int();
600 else IFTOK("explodes") wall_explodes = get_int();
601 else IFTOK("blastable") wall_blastable = get_int();
602 else IFTOK("hidden") wall_hidden = get_int();
603 else IFTOK("$ROBOT_AI") bm_read_robot_ai();
605 else IFTOK("$POWERUP") {bm_read_powerup(0); continue;}
606 else IFTOK("$POWERUP_UNUSED") {bm_read_powerup(1); continue;}
607 else IFTOK("$HOSTAGE") {bm_read_hostage(); continue;}
608 else IFTOK("$ROBOT") {bm_read_robot(); continue;}
609 else IFTOK("$WEAPON") {bm_read_weapon(0); continue;}
610 else IFTOK("$WEAPON_UNUSED") {bm_read_weapon(1); continue;}
611 else IFTOK("$REACTOR") {bm_read_reactor(); continue;}
612 else IFTOK("$MARKER") {bm_read_marker(); continue;}
613 else IFTOK("$PLAYER_SHIP") {bm_read_player_ship(); continue;}
614 else IFTOK("$EXIT") {
618 clear_to_end_of_line();
622 else { //not a special token, must be a bitmap!
624 // Remove any illegal/unwanted spaces and tabs at this point.
625 while ((*arg=='\t') || (*arg==' ')) arg++;
626 if (*arg == '\0') { break; }
628 //check for '=' in token, indicating error
630 Error("Unknown token <'%s'> on line %d of BITMAPS.TBL",arg,linenum);
632 // Otherwise, 'arg' is apparently a bitmap filename.
633 // Load bitmap and process it below:
638 arg = strtok( NULL, equal_space );
643 NumTextures = texture_count;
644 Num_tmaps = tmap_count;
646 Textures[NumTextures++].index = 0; //entry for bogus tmap
652 Assert(N_robot_types == Num_robot_ais); //should be one ai info per robot
655 init_endlevel(); //this is here so endlevel bitmaps go into pig
660 //check for refereced but unused clip count
661 for (i=0; i<MAX_EFFECTS; i++ )
663 (Effects[i].changing_wall_texture!=-1) ||
664 (Effects[i].changing_object_texture!=-1)
666 && (Effects[i].vc.num_frames==-1) )
667 Error("EClip %d referenced (by polygon object?), but not defined",i);
672 for (i=used=0; i<num_sounds; i++ )
673 if (Sounds[i] != 255)
675 mprintf((0,"Sound slots used: %d of %d, highest index %d\n",used,MAX_SOUNDS,num_sounds));
677 //make sure all alt sounds refer to valid main sounds
678 for (i=used=0; i<num_sounds; i++ ) {
679 int alt = AltSounds[i];
680 Assert(alt==0 || alt==-1 || Sounds[alt]!=255);
691 gr_use_palette_table(DEFAULT_PALETTE);
696 void verify_textures()
701 for (i=0; i<Num_tmaps; i++ ) {
702 bmp = &GameBitmaps[Textures[i].index];
703 if ( (bmp->bm_w!=64)||(bmp->bm_h!=64)||(bmp->bm_rowsize!=64) ) {
704 mprintf( (1, "ERROR: Texture '%s' isn't 64x64 !\n", TmapInfo[i].filename ));
709 Error("%d textures were not 64x64. See mono screen for list.",j);
711 for (i=0;i<Num_effects;i++)
712 if (Effects[i].changing_object_texture != -1)
713 if (GameBitmaps[ObjBitmaps[Effects[i].changing_object_texture].index].bm_w!=64 || GameBitmaps[ObjBitmaps[Effects[i].changing_object_texture].index].bm_h!=64)
714 Error("Effect %d is used on object, but is not 64x64",i);
722 Assert(Num_aliases < MAX_ALIASES);
724 t = strtok( NULL, space ); strncpy(alias_list[Num_aliases].alias_name,t,sizeof(alias_list[Num_aliases].alias_name));
725 t = strtok( NULL, space ); strncpy(alias_list[Num_aliases].file_name,t,sizeof(alias_list[Num_aliases].file_name));
730 //--unused-- void dump_all_transparent_textures()
732 //--unused-- FILE * fp;
733 //--unused-- int i,j,k;
734 //--unused-- ubyte * p;
735 //--unused-- fp = fopen( "XPARENT.LST", "wt" );
736 //--unused-- for (i=0; i<Num_tmaps; i++ ) {
738 //--unused-- p = Textures[i]->bm_data;
739 //--unused-- for (j=0; j<64*64; j++ )
740 //--unused-- if ( (*p++)==255 ) k++;
741 //--unused-- if ( k ) {
742 //--unused-- fprintf( fp, "'%s' has %d transparent pixels\n", TmapInfo[i].filename, k );
745 //--unused-- fclose(fp);
757 void set_lighting_flag(byte *bp)
760 *bp |= BM_FLAG_NO_LIGHTING;
762 *bp &= (0xff ^ BM_FLAG_NO_LIGHTING);
765 void set_texture_name(char *name)
767 strcpy ( TmapInfo[texture_count].filename, name );
768 REMOVE_DOTS(TmapInfo[texture_count].filename);
776 Assert(clip_num < MAX_EFFECTS);
778 if (clip_num+1 > Num_effects)
779 Num_effects = clip_num+1;
781 Effects[clip_num].flags = 0;
783 //load the dest bitmap first, so that after this routine, the last-loaded
784 //texture will be the monitor, so that lighting parameter will be applied
785 //to the correct texture
786 if (dest_bm) { //deal with bitmap for blown up clip
787 char short_name[FILENAME_LEN];
789 strcpy(short_name,dest_bm);
790 REMOVE_DOTS(short_name);
791 for (i=0;i<texture_count;i++)
792 if (!stricmp(TmapInfo[i].filename,short_name))
794 if (i==texture_count) {
795 Textures[texture_count] = bm_load_sub(dest_bm);
796 strcpy( TmapInfo[texture_count].filename, short_name);
798 Assert(texture_count < MAX_TEXTURES);
799 NumTextures = texture_count;
801 else if (Textures[i].index == 0) //was found, but registered out
802 Textures[i] = bm_load_sub(dest_bm);
807 bitmap = bm_load_sub(arg);
809 Effects[clip_num].vc.play_time = fl2f(time);
810 Effects[clip_num].vc.num_frames = frames;
811 Effects[clip_num].vc.frame_time = fl2f(time)/frames;
813 Assert(clip_count < frames);
814 Effects[clip_num].vc.frames[clip_count] = bitmap;
815 set_lighting_flag(&GameBitmaps[bitmap.index].bm_flags);
817 Assert(!obj_eclip); //obj eclips for non-abm files not supported!
818 Assert(crit_flag==0);
820 if (clip_count == 0) {
821 Effects[clip_num].changing_wall_texture = texture_count;
822 Assert(tmap_count < MAX_TEXTURES);
823 TmapList[tmap_count++] = texture_count;
824 Textures[texture_count] = bitmap;
825 set_texture_name(arg);
826 Assert(texture_count < MAX_TEXTURES);
828 TmapInfo[texture_count].eclip_num = clip_num;
829 NumTextures = texture_count;
835 bitmap_index bm[MAX_BITMAPS_PER_BRUSH];
838 ab_load( arg, bm, &Effects[clip_num].vc.num_frames );
840 //printf("EC%d.", clip_num);
841 Effects[clip_num].vc.play_time = fl2f(time);
842 Effects[clip_num].vc.frame_time = Effects[clip_num].vc.play_time/Effects[clip_num].vc.num_frames;
845 set_lighting_flag( &GameBitmaps[bm[clip_count].index].bm_flags);
846 Effects[clip_num].vc.frames[clip_count] = bm[clip_count];
848 if (!obj_eclip && !crit_flag) {
849 Effects[clip_num].changing_wall_texture = texture_count;
850 Assert(tmap_count < MAX_TEXTURES);
851 TmapList[tmap_count++] = texture_count;
852 Textures[texture_count] = bm[clip_count];
853 set_texture_name( arg );
854 Assert(texture_count < MAX_TEXTURES);
855 TmapInfo[texture_count].eclip_num = clip_num;
857 NumTextures = texture_count;
862 if (Effects[clip_num].changing_object_texture == -1) { //first time referenced
863 Effects[clip_num].changing_object_texture = N_ObjBitmaps; // XChange ObjectBitmaps
867 ObjBitmaps[Effects[clip_num].changing_object_texture] = Effects[clip_num].vc.frames[0];
870 //if for an object, Effects_bm_ptrs set in object load
872 for(clip_count=1;clip_count < Effects[clip_num].vc.num_frames; clip_count++) {
873 set_lighting_flag( &GameBitmaps[bm[clip_count].index].bm_flags);
874 Effects[clip_num].vc.frames[clip_count] = bm[clip_count];
879 Effects[clip_num].crit_clip = crit_clip;
880 Effects[clip_num].sound_num = sound_num;
882 if (dest_bm) { //deal with bitmap for blown up clip
884 Effects[clip_num].dest_bm_num = dest_bm_num;
887 Error("Desctuction vclip missing on line %d",linenum);
889 Error("Desctuction vclip missing on line %d",linenum);
891 Effects[clip_num].dest_vclip = dest_vclip;
892 Effects[clip_num].dest_size = dest_size;
894 Effects[clip_num].dest_eclip = dest_eclip;
897 Effects[clip_num].dest_bm_num = -1;
898 Effects[clip_num].dest_eclip = -1;
902 Effects[clip_num].flags |= EF_CRITICAL;
906 void bm_read_gauges()
909 int i, num_abm_frames;
912 bitmap = bm_load_sub(arg);
913 Assert(clip_count < MAX_GAUGE_BMS);
914 Gauges[clip_count] = bitmap;
917 bitmap_index bm[MAX_BITMAPS_PER_BRUSH];
919 ab_load( arg, bm, &num_abm_frames );
920 for (i=clip_count; i<clip_count+num_abm_frames; i++) {
921 Assert(i < MAX_GAUGE_BMS);
922 Gauges[i] = bm[i-clip_count];
924 clip_count += num_abm_frames;
928 void bm_read_gauges_hires()
931 int i, num_abm_frames;
934 bitmap = bm_load_sub(arg);
935 Assert(clip_count < MAX_GAUGE_BMS);
936 Gauges_hires[clip_count] = bitmap;
939 bitmap_index bm[MAX_BITMAPS_PER_BRUSH];
941 ab_load( arg, bm, &num_abm_frames );
942 for (i=clip_count; i<clip_count+num_abm_frames; i++) {
943 Assert(i < MAX_GAUGE_BMS);
944 Gauges_hires[i] = bm[i-clip_count];
946 clip_count += num_abm_frames;
953 Assert(clip_num < MAX_WALL_ANIMS);
955 WallAnims[clip_num].flags = 0;
957 if (wall_explodes) WallAnims[clip_num].flags |= WCF_EXPLODES;
958 if (wall_blastable) WallAnims[clip_num].flags |= WCF_BLASTABLE;
959 if (wall_hidden) WallAnims[clip_num].flags |= WCF_HIDDEN;
960 if (tmap1_flag) WallAnims[clip_num].flags |= WCF_TMAP1;
963 bitmap = bm_load_sub(arg);
964 if ( (WallAnims[clip_num].num_frames>-1) && (clip_count==0) )
965 Error( "Wall Clip %d is already used!", clip_num );
966 WallAnims[clip_num].play_time = fl2f(time);
967 WallAnims[clip_num].num_frames = frames;
968 //WallAnims[clip_num].frame_time = fl2f(time)/frames;
969 Assert(clip_count < frames);
970 WallAnims[clip_num].frames[clip_count++] = texture_count;
971 WallAnims[clip_num].open_sound = wall_open_sound;
972 WallAnims[clip_num].close_sound = wall_close_sound;
973 Textures[texture_count] = bitmap;
974 set_lighting_flag(&GameBitmaps[bitmap.index].bm_flags);
975 set_texture_name( arg );
976 Assert(texture_count < MAX_TEXTURES);
978 NumTextures = texture_count;
979 if (clip_num >= Num_wall_anims) Num_wall_anims = clip_num+1;
981 bitmap_index bm[MAX_BITMAPS_PER_BRUSH];
983 if ( (WallAnims[clip_num].num_frames>-1) )
984 Error( "AB_Wall clip %d is already used!", clip_num );
986 ab_load( arg, bm, &nframes );
987 WallAnims[clip_num].num_frames = nframes;
989 WallAnims[clip_num].play_time = fl2f(time);
990 //WallAnims[clip_num].frame_time = fl2f(time)/nframes;
991 WallAnims[clip_num].open_sound = wall_open_sound;
992 WallAnims[clip_num].close_sound = wall_close_sound;
994 WallAnims[clip_num].close_sound = wall_close_sound;
995 strcpy(WallAnims[clip_num].filename, arg);
996 REMOVE_DOTS(WallAnims[clip_num].filename);
998 if (clip_num >= Num_wall_anims) Num_wall_anims = clip_num+1;
1000 set_lighting_flag(&GameBitmaps[bm[clip_count].index].bm_flags);
1002 for (clip_count=0;clip_count < WallAnims[clip_num].num_frames; clip_count++) {
1003 //printf("%d", clip_count);
1004 Textures[texture_count] = bm[clip_count];
1005 set_lighting_flag(&GameBitmaps[bm[clip_count].index].bm_flags);
1006 WallAnims[clip_num].frames[clip_count] = texture_count;
1008 sprintf( TmapInfo[texture_count].filename, "%s#%d", arg, clip_count);
1009 Assert(texture_count < MAX_TEXTURES);
1011 NumTextures = texture_count;
1016 void bm_read_vclip()
1019 Assert(clip_num < VCLIP_MAXNUM);
1021 if (clip_num >= Num_vclips)
1022 Num_vclips = clip_num+1;
1025 if ( (Vclip[clip_num].num_frames>-1) && (clip_count==0) )
1026 Error( "Vclip %d is already used!", clip_num );
1027 bi = bm_load_sub(arg);
1028 Vclip[clip_num].play_time = fl2f(time);
1029 Vclip[clip_num].num_frames = frames;
1030 Vclip[clip_num].frame_time = fl2f(time)/frames;
1031 Vclip[clip_num].light_value = fl2f(vlighting);
1032 Vclip[clip_num].sound_num = sound_num;
1033 set_lighting_flag(&GameBitmaps[bi.index].bm_flags);
1034 Assert(clip_count < frames);
1035 Vclip[clip_num].frames[clip_count++] = bi;
1038 Vclip[clip_num].flags |= VF_ROD;
1042 bitmap_index bm[MAX_BITMAPS_PER_BRUSH];
1044 if ( (Vclip[clip_num].num_frames>-1) )
1045 Error( "AB_Vclip %d is already used!", clip_num );
1046 ab_load( arg, bm, &Vclip[clip_num].num_frames );
1051 Vclip[clip_num].flags |= VF_ROD;
1054 Vclip[clip_num].play_time = fl2f(time);
1055 Vclip[clip_num].frame_time = fl2f(time)/Vclip[clip_num].num_frames;
1056 Vclip[clip_num].light_value = fl2f(vlighting);
1057 Vclip[clip_num].sound_num = sound_num;
1058 set_lighting_flag(&GameBitmaps[bm[clip_count].index].bm_flags);
1060 for (clip_count=0;clip_count < Vclip[clip_num].num_frames; clip_count++) {
1061 //printf("%d", clip_count);
1062 set_lighting_flag(&GameBitmaps[bm[clip_count].index].bm_flags);
1063 Vclip[clip_num].frames[clip_count] = bm[clip_count];
1068 // ------------------------------------------------------------------------------
1069 void get4fix(fix *fixp)
1074 for (i=0; i<NDL; i++) {
1075 curtext = strtok(NULL, space);
1076 fixp[i] = fl2f(atof(curtext));
1080 // ------------------------------------------------------------------------------
1081 void get4byte(byte *bytep)
1086 for (i=0; i<NDL; i++) {
1087 curtext = strtok(NULL, space);
1088 bytep[i] = atoi(curtext);
1092 // ------------------------------------------------------------------------------
1093 // Convert field of view from an angle in 0..360 to cosine.
1094 void adjust_field_of_view(fix *fovp)
1101 for (i=0; i<NDL; i++) {
1102 ff = - f2fl(fovp[i]);
1104 mprintf((1, "Warning: Bogus field of view (%7.3f). Must be in 0..179.\n", ff));
1109 fix_sincos(tt, &temp, &fovp[i]);
1113 void clear_to_end_of_line(void)
1115 arg = strtok( NULL, space );
1117 arg = strtok( NULL, space );
1120 void bm_read_sound()
1125 sound_num = get_int();
1126 alt_sound_num = get_int();
1128 if ( sound_num>=MAX_SOUNDS )
1129 Error( "Too many sound files.\n" );
1131 if (sound_num >= num_sounds)
1132 num_sounds = sound_num+1;
1134 if (Sounds[sound_num] != 255)
1135 Error("Sound num %d already used, bitmaps.tbl, line %d\n",sound_num,linenum);
1137 arg = strtok(NULL, space);
1139 Sounds[sound_num] = ds_load(arg);
1141 if ( alt_sound_num == 0 )
1142 AltSounds[sound_num] = sound_num;
1143 else if (alt_sound_num < 0 )
1144 AltSounds[sound_num] = 255;
1146 AltSounds[sound_num] = alt_sound_num;
1148 if (Sounds[sound_num] == 255)
1149 Error("Can't load soundfile <%s>",arg);
1152 // ------------------------------------------------------------------------------
1153 void bm_read_robot_ai()
1155 char *robotnum_text;
1159 robotnum_text = strtok(NULL, space);
1160 robotnum = atoi(robotnum_text);
1161 Assert(robotnum < MAX_ROBOT_TYPES);
1162 robptr = &Robot_info[robotnum];
1164 Assert(robotnum == Num_robot_ais); //make sure valid number
1167 if (Registered_only) {
1169 clear_to_end_of_line();
1176 get4fix(robptr->field_of_view);
1177 get4fix(robptr->firing_wait);
1178 get4fix(robptr->firing_wait2);
1179 get4byte(robptr->rapidfire_count);
1180 get4fix(robptr->turn_time);
1181 // get4fix(robptr->fire_power);
1182 // get4fix(robptr->shield);
1183 get4fix(robptr->max_speed);
1184 get4fix(robptr->circle_distance);
1185 get4byte(robptr->evade_speed);
1187 robptr->always_0xabcd = 0xabcd;
1189 adjust_field_of_view(robptr->field_of_view);
1193 // ----------------------------------------------------------------------------------------------
1194 //this will load a bitmap for a polygon models. it puts the bitmap into
1195 //the array ObjBitmaps[], and also deals with animating bitmaps
1196 //returns a pointer to the bitmap
1197 grs_bitmap *load_polymodel_bitmap(char *name)
1199 Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
1201 // Assert( N_ObjBitmaps == N_ObjBitmapPtrs );
1203 if (name[0] == '%') { //an animating bitmap!
1206 eclip_num = atoi(name+1);
1208 if (Effects[eclip_num].changing_object_texture == -1) { //first time referenced
1209 Effects[eclip_num].changing_object_texture = N_ObjBitmaps;
1210 ObjBitmapPtrs[N_ObjBitmapPtrs++] = N_ObjBitmaps;
1213 ObjBitmapPtrs[N_ObjBitmapPtrs++] = Effects[eclip_num].changing_object_texture;
1215 Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
1216 Assert(N_ObjBitmapPtrs < MAX_OBJ_BITMAPS);
1220 ObjBitmaps[N_ObjBitmaps] = bm_load_sub(name);
1221 if (GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_w!=64 || GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_h!=64)
1222 Error("Bitmap <%s> is not 64x64",name);
1223 ObjBitmapPtrs[N_ObjBitmapPtrs++] = N_ObjBitmaps;
1225 Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
1226 Assert(N_ObjBitmapPtrs < MAX_OBJ_BITMAPS);
1227 return &GameBitmaps[ObjBitmaps[N_ObjBitmaps-1].index];
1231 #define MAX_MODEL_VARIANTS 4
1233 // ------------------------------------------------------------------------------
1234 void bm_read_robot()
1236 char *model_name[MAX_MODEL_VARIANTS];
1238 int first_bitmap_num[MAX_MODEL_VARIANTS];
1240 int exp1_vclip_num=-1;
1241 int exp1_sound_num=-1;
1242 int exp2_vclip_num=-1;
1243 int exp2_sound_num=-1;
1244 fix lighting = F1_0/2; // Default
1245 fix strength = F1_0*10; // Default strength
1248 short weapon_type = 0, weapon_type2 = -1;
1250 char name[ROBOT_NAME_LENGTH];
1251 int contains_count=0, contains_id=0, contains_prob=0, contains_type=0, behavior=AIB_NORMAL;
1252 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;
1253 fix glow=0, aim=F1_0;
1254 int deathroll_sound = SOUND_BOSS_SHARE_DIE; //default
1255 int score_value=1000;
1256 int cloak_type=0; // Default = this robot does not cloak
1257 int attack_type=0; // Default = this robot attacks by firing (1=lunge)
1258 int boss_flag=0; // Default = robot is not a boss.
1259 int see_sound = ROBOT_SEE_SOUND_DEFAULT;
1260 int attack_sound = ROBOT_ATTACK_SOUND_DEFAULT;
1261 int claw_sound = ROBOT_CLAW_SOUND_DEFAULT;
1262 int taunt_sound = ROBOT_SEE_SOUND_DEFAULT;
1265 Assert(N_robot_types < MAX_ROBOT_TYPES);
1268 if (Registered_only) {
1269 Robot_info[N_robot_types].model_num = -1;
1271 Assert(N_robot_types < MAX_ROBOT_TYPES);
1272 Num_total_object_types++;
1273 Assert(Num_total_object_types < MAX_OBJTYPE);
1274 clear_to_end_of_line();
1279 model_name[0] = strtok( NULL, space );
1280 first_bitmap_num[0] = N_ObjBitmapPtrs;
1285 arg = strtok( NULL, space );
1287 equal_ptr = strchr( arg, '=' );
1291 // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
1292 if (!stricmp( arg, "exp1_vclip" )) {
1293 exp1_vclip_num = atoi(equal_ptr);
1294 } else if (!stricmp( arg, "exp2_vclip" )) {
1295 exp2_vclip_num = atoi(equal_ptr);
1296 } else if (!stricmp( arg, "exp1_sound" )) {
1297 exp1_sound_num = atoi(equal_ptr);
1298 } else if (!stricmp( arg, "exp2_sound" )) {
1299 exp2_sound_num = atoi(equal_ptr);
1300 } else if (!stricmp( arg, "lighting" )) {
1301 lighting = fl2f(atof(equal_ptr));
1302 if ( (lighting < 0) || (lighting > F1_0 )) {
1303 mprintf( (1, "In bitmaps.tbl, lighting value of %.2f is out of range 0..1.\n", f2fl(lighting)));
1304 Error( "In bitmaps.tbl, lighting value of %.2f is out of range 0..1.\n", f2fl(lighting));
1306 } else if (!stricmp( arg, "weapon_type" )) {
1307 weapon_type = atoi(equal_ptr);
1308 } else if (!stricmp( arg, "weapon_type2" )) {
1309 weapon_type2 = atoi(equal_ptr);
1310 } else if (!stricmp( arg, "strength" )) {
1311 strength = i2f(atoi(equal_ptr));
1312 } else if (!stricmp( arg, "mass" )) {
1313 mass = fl2f(atof(equal_ptr));
1314 } else if (!stricmp( arg, "drag" )) {
1315 drag = fl2f(atof(equal_ptr));
1316 } else if (!stricmp( arg, "contains_id" )) {
1317 contains_id = atoi(equal_ptr);
1318 } else if (!stricmp( arg, "contains_type" )) {
1319 contains_type = atoi(equal_ptr);
1320 } else if (!stricmp( arg, "contains_count" )) {
1321 contains_count = atoi(equal_ptr);
1322 } else if (!stricmp( arg, "companion" )) {
1323 companion = atoi(equal_ptr);
1324 } else if (!stricmp( arg, "badass" )) {
1325 badass = atoi(equal_ptr);
1326 } else if (!stricmp( arg, "lightcast" )) {
1327 lightcast = atoi(equal_ptr);
1328 } else if (!stricmp( arg, "glow" )) {
1329 glow = fl2f(atof(equal_ptr));
1330 } else if (!stricmp( arg, "death_roll" )) {
1331 death_roll = atoi(equal_ptr);
1332 } else if (!stricmp( arg, "deathroll_sound" )) {
1333 deathroll_sound = atoi(equal_ptr);
1334 } else if (!stricmp( arg, "thief" )) {
1335 thief = atoi(equal_ptr);
1336 } else if (!stricmp( arg, "kamikaze" )) {
1337 kamikaze = atoi(equal_ptr);
1338 } else if (!stricmp( arg, "pursuit" )) {
1339 pursuit = atoi(equal_ptr);
1340 } else if (!stricmp( arg, "smart_blobs" )) {
1341 smart_blobs = atoi(equal_ptr);
1342 } else if (!stricmp( arg, "energy_blobs" )) {
1343 energy_blobs = atoi(equal_ptr);
1344 } else if (!stricmp( arg, "energy_drain" )) {
1345 energy_drain = atoi(equal_ptr);
1346 } else if (!stricmp( arg, "contains_prob" )) {
1347 contains_prob = atoi(equal_ptr);
1348 } else if (!stricmp( arg, "cloak_type" )) {
1349 cloak_type = atoi(equal_ptr);
1350 } else if (!stricmp( arg, "attack_type" )) {
1351 attack_type = atoi(equal_ptr);
1352 } else if (!stricmp( arg, "boss" )) {
1353 boss_flag = atoi(equal_ptr);
1354 } else if (!stricmp( arg, "score_value" )) {
1355 score_value = atoi(equal_ptr);
1356 } else if (!stricmp( arg, "see_sound" )) {
1357 see_sound = atoi(equal_ptr);
1358 } else if (!stricmp( arg, "attack_sound" )) {
1359 attack_sound = atoi(equal_ptr);
1360 } else if (!stricmp( arg, "claw_sound" )) {
1361 claw_sound = atoi(equal_ptr);
1362 } else if (!stricmp( arg, "taunt_sound" )) {
1363 taunt_sound = atoi(equal_ptr);
1364 } else if (!stricmp( arg, "aim" )) {
1365 aim = fl2f(atof(equal_ptr));
1366 } else if (!stricmp( arg, "big_radius" )) {
1367 if (atoi(equal_ptr))
1368 flags |= RIF_BIG_RADIUS;
1369 } else if (!stricmp( arg, "behavior" )) {
1370 if (!stricmp(equal_ptr, "STILL"))
1371 behavior = AIB_STILL;
1372 else if (!stricmp(equal_ptr, "NORMAL"))
1373 behavior = AIB_NORMAL;
1374 else if (!stricmp(equal_ptr, "BEHIND"))
1375 behavior = AIB_BEHIND;
1376 else if (!stricmp(equal_ptr, "RUN_FROM"))
1377 behavior = AIB_RUN_FROM;
1378 else if (!stricmp(equal_ptr, "SNIPE"))
1379 behavior = AIB_SNIPE;
1380 else if (!stricmp(equal_ptr, "STATION"))
1381 behavior = AIB_STATION;
1382 else if (!stricmp(equal_ptr, "FOLLOW"))
1383 behavior = AIB_FOLLOW;
1385 Int3(); // Error. Illegal behavior type for current robot.
1386 } else if (!stricmp( arg, "name" )) {
1387 Assert(strlen(equal_ptr) < ROBOT_NAME_LENGTH); // Oops, name too long.
1388 strcpy(name, &equal_ptr[1]);
1389 name[strlen(name)-1] = 0;
1390 } else if (!stricmp( arg, "simple_model" )) {
1391 model_name[n_models] = equal_ptr;
1392 first_bitmap_num[n_models] = N_ObjBitmapPtrs;
1394 Assert(n_models < MAX_MODEL_VARIANTS);
1397 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
1399 } else { // Must be a texture specification...
1400 load_polymodel_bitmap(arg);
1402 arg = strtok( NULL, space );
1405 //clear out anim info
1406 for (g=0;g<MAX_GUNS+1;g++)
1407 for (s=0;s<N_ANIM_STATES;s++)
1408 Robot_info[N_robot_types].anim_states[g][s].n_joints = 0; //inialize to zero
1410 first_bitmap_num[n_models] = N_ObjBitmapPtrs;
1412 for (i=0;i<n_models;i++) {
1414 int model_num,last_model_num;
1416 n_textures = first_bitmap_num[i+1] - first_bitmap_num[i];
1418 model_num = load_polygon_model(model_name[i],n_textures,first_bitmap_num[i],(i==0)?&Robot_info[N_robot_types]:NULL);
1421 Robot_info[N_robot_types].model_num = model_num;
1423 Polygon_models[last_model_num].simpler_model = model_num+1;
1425 last_model_num = model_num;
1428 if ((glow > i2f(15)) || (glow < 0) || (glow != 0 && glow < 0x1000)) {
1429 mprintf((0,"Invalid glow value %x for robot %d\n",glow,N_robot_types));
1433 ObjType[Num_total_object_types] = OL_ROBOT;
1434 ObjId[Num_total_object_types] = N_robot_types;
1436 Robot_info[N_robot_types].exp1_vclip_num = exp1_vclip_num;
1437 Robot_info[N_robot_types].exp2_vclip_num = exp2_vclip_num;
1438 Robot_info[N_robot_types].exp1_sound_num = exp1_sound_num;
1439 Robot_info[N_robot_types].exp2_sound_num = exp2_sound_num;
1440 Robot_info[N_robot_types].lighting = lighting;
1441 Robot_info[N_robot_types].weapon_type = weapon_type;
1442 Robot_info[N_robot_types].weapon_type2 = weapon_type2;
1443 Robot_info[N_robot_types].strength = strength;
1444 Robot_info[N_robot_types].mass = mass;
1445 Robot_info[N_robot_types].drag = drag;
1446 Robot_info[N_robot_types].cloak_type = cloak_type;
1447 Robot_info[N_robot_types].attack_type = attack_type;
1448 Robot_info[N_robot_types].boss_flag = boss_flag;
1450 Robot_info[N_robot_types].contains_id = contains_id;
1451 Robot_info[N_robot_types].contains_count = contains_count;
1452 Robot_info[N_robot_types].contains_prob = contains_prob;
1453 Robot_info[N_robot_types].companion = companion;
1454 Robot_info[N_robot_types].badass = badass;
1455 Robot_info[N_robot_types].lightcast = lightcast;
1456 Robot_info[N_robot_types].glow = (glow>>12); //convert to 4:4
1457 Robot_info[N_robot_types].death_roll = death_roll;
1458 Robot_info[N_robot_types].deathroll_sound = deathroll_sound;
1459 Robot_info[N_robot_types].thief = thief;
1460 Robot_info[N_robot_types].flags = flags;
1461 Robot_info[N_robot_types].kamikaze = kamikaze;
1462 Robot_info[N_robot_types].pursuit = pursuit;
1463 Robot_info[N_robot_types].smart_blobs = smart_blobs;
1464 Robot_info[N_robot_types].energy_blobs = energy_blobs;
1465 Robot_info[N_robot_types].energy_drain = energy_drain;
1466 Robot_info[N_robot_types].score_value = score_value;
1467 Robot_info[N_robot_types].see_sound = see_sound;
1468 Robot_info[N_robot_types].attack_sound = attack_sound;
1469 Robot_info[N_robot_types].claw_sound = claw_sound;
1470 Robot_info[N_robot_types].taunt_sound = taunt_sound;
1471 Robot_info[N_robot_types].behavior = behavior; // Default behavior for this robot, if coming out of matcen.
1472 Robot_info[N_robot_types].aim = min(f2i(aim*255), 255); // how well this robot type can aim. 255=perfect
1475 Robot_info[N_robot_types].contains_type = OBJ_ROBOT;
1477 Robot_info[N_robot_types].contains_type = OBJ_POWERUP;
1479 strcpy(Robot_names[N_robot_types], name);
1482 Num_total_object_types++;
1484 Assert(N_robot_types < MAX_ROBOT_TYPES);
1485 Assert(Num_total_object_types < MAX_OBJTYPE);
1490 //read a reactor model
1491 void bm_read_reactor()
1493 char *model_name, *model_name_dead=NULL;
1494 int first_bitmap_num, first_bitmap_num_dead, n_normal_bitmaps;
1497 short explosion_vclip_num = -1;
1498 short explosion_sound_num = SOUND_ROBOT_DESTROYED;
1499 fix lighting = F1_0/2; // Default
1503 Assert(Num_reactors < MAX_REACTORS);
1506 if (Registered_only) {
1508 clear_to_end_of_line();
1513 model_name = strtok( NULL, space );
1517 arg = strtok( NULL, space );
1518 first_bitmap_num = N_ObjBitmapPtrs;
1520 type = OL_CONTROL_CENTER;
1524 equal_ptr = strchr( arg, '=' );
1530 // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
1532 //@@if (!stricmp(arg,"type")) {
1533 //@@ if (!stricmp(equal_ptr,"controlcen"))
1534 //@@ type = OL_CONTROL_CENTER;
1535 //@@ else if (!stricmp(equal_ptr,"clutter"))
1536 //@@ type = OL_CLUTTER;
1539 if (!stricmp( arg, "exp_vclip" )) {
1540 explosion_vclip_num = atoi(equal_ptr);
1541 } else if (!stricmp( arg, "dead_pof" )) {
1542 model_name_dead = equal_ptr;
1543 first_bitmap_num_dead=N_ObjBitmapPtrs;
1544 } else if (!stricmp( arg, "exp_sound" )) {
1545 explosion_sound_num = atoi(equal_ptr);
1546 } else if (!stricmp( arg, "lighting" )) {
1547 lighting = fl2f(atof(equal_ptr));
1548 if ( (lighting < 0) || (lighting > F1_0 )) {
1549 mprintf( (1, "In bitmaps.tbl, lighting value of %.2f is out of range 0..1.\n", f2fl(lighting)));
1550 Error( "In bitmaps.tbl, lighting value of %.2f is out of range 0..1.\n", f2fl(lighting));
1552 } else if (!stricmp( arg, "strength" )) {
1553 strength = fl2f(atof(equal_ptr));
1556 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
1558 } else { // Must be a texture specification...
1559 load_polymodel_bitmap(arg);
1561 arg = strtok( NULL, space );
1564 if ( model_name_dead )
1565 n_normal_bitmaps = first_bitmap_num_dead-first_bitmap_num;
1567 n_normal_bitmaps = N_ObjBitmapPtrs-first_bitmap_num;
1569 model_num = load_polygon_model(model_name,n_normal_bitmaps,first_bitmap_num,NULL);
1571 if ( model_name_dead )
1572 Dead_modelnums[model_num] = load_polygon_model(model_name_dead,N_ObjBitmapPtrs-first_bitmap_num_dead,first_bitmap_num_dead,NULL);
1574 Dead_modelnums[model_num] = -1;
1577 Error("No object type specfied for object in BITMAPS.TBL on line %d\n",linenum);
1579 Reactors[Num_reactors].model_num = model_num;
1580 Reactors[Num_reactors].n_guns = read_model_guns(model_name,Reactors[Num_reactors].gun_points,Reactors[Num_reactors].gun_dirs,NULL);
1582 ObjType[Num_total_object_types] = type;
1583 ObjId[Num_total_object_types] = Num_reactors;
1584 ObjStrength[Num_total_object_types] = strength;
1586 //printf( "Object type %d is a control center\n", Num_total_object_types );
1587 Num_total_object_types++;
1588 Assert(Num_total_object_types < MAX_OBJTYPE);
1593 //read the marker object
1594 void bm_read_marker()
1597 int first_bitmap_num, n_normal_bitmaps;
1600 model_name = strtok( NULL, space );
1604 arg = strtok( NULL, space );
1605 first_bitmap_num = N_ObjBitmapPtrs;
1609 equal_ptr = strchr( arg, '=' );
1615 // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
1616 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
1619 } else { // Must be a texture specification...
1620 load_polymodel_bitmap(arg);
1622 arg = strtok( NULL, space );
1625 n_normal_bitmaps = N_ObjBitmapPtrs-first_bitmap_num;
1627 Marker_model_num = load_polygon_model(model_name,n_normal_bitmaps,first_bitmap_num,NULL);
1631 //read the exit model
1632 void bm_read_exitmodel()
1634 char *model_name, *model_name_dead=NULL;
1635 int first_bitmap_num, first_bitmap_num_dead, n_normal_bitmaps;
1639 model_name = strtok( NULL, space );
1643 arg = strtok( NULL, space );
1644 first_bitmap_num = N_ObjBitmapPtrs;
1648 equal_ptr = strchr( arg, '=' );
1654 // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
1656 if (!stricmp( arg, "dead_pof" )) {
1657 model_name_dead = equal_ptr;
1658 first_bitmap_num_dead=N_ObjBitmapPtrs;
1661 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
1663 } else { // Must be a texture specification...
1664 load_polymodel_bitmap(arg);
1666 arg = strtok( NULL, space );
1669 if ( model_name_dead )
1670 n_normal_bitmaps = first_bitmap_num_dead-first_bitmap_num;
1672 n_normal_bitmaps = N_ObjBitmapPtrs-first_bitmap_num;
1674 model_num = load_polygon_model(model_name,n_normal_bitmaps,first_bitmap_num,NULL);
1676 if ( model_name_dead )
1677 Dead_modelnums[model_num] = load_polygon_model(model_name_dead,N_ObjBitmapPtrs-first_bitmap_num_dead,first_bitmap_num_dead,NULL);
1679 Dead_modelnums[model_num] = -1;
1681 //@@ ObjType[Num_total_object_types] = type;
1682 //@@ ObjId[Num_total_object_types] = model_num;
1683 //@@ ObjStrength[Num_total_object_types] = strength;
1685 //@@ //printf( "Object type %d is a control center\n", Num_total_object_types );
1686 //@@ Num_total_object_types++;
1687 //@@ Assert(Num_total_object_types < MAX_OBJTYPE);
1689 exit_modelnum = model_num;
1690 destroyed_exit_modelnum = Dead_modelnums[model_num];
1695 void bm_read_player_ship()
1697 char *model_name_dying=NULL;
1698 char *model_name[MAX_MODEL_VARIANTS];
1700 int first_bitmap_num[MAX_MODEL_VARIANTS];
1703 int last_multi_bitmap_num=-1;
1708 arg = strtok( NULL, space );
1710 Player_ship->mass = Player_ship->drag = 0; //stupid defaults
1711 Player_ship->expl_vclip_num = -1;
1715 equal_ptr = strchr( arg, '=' );
1722 // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
1724 if (!stricmp( arg, "model" )) {
1725 Assert(n_models==0);
1726 model_name[0] = equal_ptr;
1727 first_bitmap_num[0] = N_ObjBitmapPtrs;
1729 } else if (!stricmp( arg, "simple_model" )) {
1730 model_name[n_models] = equal_ptr;
1731 first_bitmap_num[n_models] = N_ObjBitmapPtrs;
1733 Assert(n_models < MAX_MODEL_VARIANTS);
1735 if (First_multi_bitmap_num!=-1 && last_multi_bitmap_num==-1)
1736 last_multi_bitmap_num=N_ObjBitmapPtrs;
1738 else if (!stricmp( arg, "mass" ))
1739 Player_ship->mass = fl2f(atof(equal_ptr));
1740 else if (!stricmp( arg, "drag" ))
1741 Player_ship->drag = fl2f(atof(equal_ptr));
1742 // else if (!stricmp( arg, "low_thrust" ))
1743 // Player_ship->low_thrust = fl2f(atof(equal_ptr));
1744 else if (!stricmp( arg, "max_thrust" ))
1745 Player_ship->max_thrust = fl2f(atof(equal_ptr));
1746 else if (!stricmp( arg, "reverse_thrust" ))
1747 Player_ship->reverse_thrust = fl2f(atof(equal_ptr));
1748 else if (!stricmp( arg, "brakes" ))
1749 Player_ship->brakes = fl2f(atof(equal_ptr));
1750 else if (!stricmp( arg, "wiggle" ))
1751 Player_ship->wiggle = fl2f(atof(equal_ptr));
1752 else if (!stricmp( arg, "max_rotthrust" ))
1753 Player_ship->max_rotthrust = fl2f(atof(equal_ptr));
1754 else if (!stricmp( arg, "dying_pof" ))
1755 model_name_dying = equal_ptr;
1756 else if (!stricmp( arg, "expl_vclip_num" ))
1757 Player_ship->expl_vclip_num=atoi(equal_ptr);
1760 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
1763 else if (!stricmp( arg, "multi_textures" )) {
1765 First_multi_bitmap_num = N_ObjBitmapPtrs;
1766 first_bitmap_num[n_models] = N_ObjBitmapPtrs;
1769 else // Must be a texture specification...
1771 load_polymodel_bitmap(arg);
1773 arg = strtok( NULL, space );
1776 Assert(model_name != NULL);
1778 if (First_multi_bitmap_num!=-1 && last_multi_bitmap_num==-1)
1779 last_multi_bitmap_num=N_ObjBitmapPtrs;
1781 if (First_multi_bitmap_num==-1)
1782 first_bitmap_num[n_models] = N_ObjBitmapPtrs;
1784 Assert(last_multi_bitmap_num-First_multi_bitmap_num == (MAX_NUM_NET_PLAYERS-1)*2);
1786 for (i=0;i<n_models;i++) {
1788 int model_num,last_model_num;
1790 n_textures = first_bitmap_num[i+1] - first_bitmap_num[i];
1792 model_num = load_polygon_model(model_name[i],n_textures,first_bitmap_num[i],(i==0)?&ri:NULL);
1795 Player_ship->model_num = model_num;
1797 Polygon_models[last_model_num].simpler_model = model_num+1;
1799 last_model_num = model_num;
1802 if ( model_name_dying ) {
1804 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);
1807 Assert(ri.n_guns == N_PLAYER_GUNS);
1809 //calc player gun positions
1815 int mn; //submodel number
1819 pm = &Polygon_models[Player_ship->model_num];
1821 for (gun_num=0;gun_num<r->n_guns;gun_num++) {
1823 pnt = r->gun_points[gun_num];
1824 mn = r->gun_submodels[gun_num];
1826 //instance up the tree for this gun
1828 vm_vec_add2(&pnt,&pm->submodel_offsets[mn]);
1829 mn = pm->submodel_parents[mn];
1832 Player_ship->gun_points[gun_num] = pnt;
1840 void bm_read_some_file()
1845 Error("Trying to read bitmap <%s> with bm_flag==BM_NONE on line %d of BITMAPS.TBL",arg,linenum);
1848 bitmap_index bitmap;
1849 bitmap = bm_load_sub(arg);
1850 Assert( Num_cockpits < N_COCKPIT_BITMAPS );
1851 cockpit_bitmap[Num_cockpits++] = bitmap;
1852 //bm_flag = BM_NONE;
1860 case BM_GAUGES_HIRES:
1861 bm_read_gauges_hires();
1877 bitmap_index bitmap;
1878 bitmap = bm_load_sub(arg);
1879 Assert(tmap_count < MAX_TEXTURES);
1880 TmapList[tmap_count++] = texture_count;
1881 Textures[texture_count] = bitmap;
1882 set_texture_name( arg );
1883 Assert(texture_count < MAX_TEXTURES);
1885 NumTextures = texture_count;
1895 Error("Trying to read bitmap <%s> with unknown bm_flag <%x> on line %d of BITMAPS.TBL",arg,bm_flag,linenum);
1898 // ------------------------------------------------------------------------------
1899 // If unused_flag is set, then this is just a placeholder. Don't actually reference vclips or load bbms.
1900 void bm_read_weapon(int unused_flag)
1905 char *pof_file_inner=NULL;
1906 char *model_name[MAX_MODEL_VARIANTS];
1907 int first_bitmap_num[MAX_MODEL_VARIANTS];
1908 int lighted; //flag for whether is a texture is lighted
1910 Assert(N_weapon_types < MAX_WEAPON_TYPES);
1914 Assert(N_weapon_types <= MAX_WEAPON_TYPES);
1917 clear_to_end_of_line();
1922 if (Registered_only) {
1923 clear_to_end_of_line();
1928 // Initialize weapon array
1929 Weapon_info[n].render_type = WEAPON_RENDER_NONE; // 0=laser, 1=blob, 2=object
1930 Weapon_info[n].bitmap.index = 0;
1931 Weapon_info[n].model_num = -1;
1932 Weapon_info[n].model_num_inner = -1;
1933 Weapon_info[n].blob_size = 0x1000; // size of blob
1934 Weapon_info[n].flash_vclip = -1;
1935 Weapon_info[n].flash_sound = SOUND_LASER_FIRED;
1936 Weapon_info[n].flash_size = 0;
1937 Weapon_info[n].robot_hit_vclip = -1;
1938 Weapon_info[n].robot_hit_sound = -1;
1939 Weapon_info[n].wall_hit_vclip = -1;
1940 Weapon_info[n].wall_hit_sound = -1;
1941 Weapon_info[n].impact_size = 0;
1942 for (i=0; i<NDL; i++) {
1943 Weapon_info[n].strength[i] = F1_0;
1944 Weapon_info[n].speed[i] = F1_0*10;
1946 Weapon_info[n].mass = F1_0;
1947 Weapon_info[n].thrust = 0;
1948 Weapon_info[n].drag = 0;
1949 Weapon_info[n].persistent = 0;
1951 Weapon_info[n].energy_usage = 0; // How much fuel is consumed to fire this weapon.
1952 Weapon_info[n].ammo_usage = 0; // How many units of ammunition it uses.
1953 Weapon_info[n].fire_wait = F1_0/4; // Time until this weapon can be fired again.
1954 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.
1955 Weapon_info[n].damage_radius = 0; // Radius of damage for missiles, not lasers. Does damage to objects within this radius of hit point.
1956 //--01/19/95, mk-- Weapon_info[n].damage_force = 0; // Force (movement) due to explosion
1957 Weapon_info[n].destroyable = 1; // Weapons default to destroyable
1958 Weapon_info[n].matter = 0; // Weapons default to not being constructed of matter (they are energy!)
1959 Weapon_info[n].bounce = 0; // Weapons default to not bouncing off walls
1961 Weapon_info[n].flags = 0;
1963 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.
1965 Weapon_info[n].po_len_to_width_ratio = F1_0*10;
1967 Weapon_info[n].picture.index = 0;
1968 Weapon_info[n].hires_picture.index = 0;
1969 Weapon_info[n].homing_flag = 0;
1971 Weapon_info[n].flash = 0;
1972 Weapon_info[n].multi_damage_scale = F1_0;
1973 Weapon_info[n].afterburner_size = 0;
1974 Weapon_info[n].children = -1;
1976 // Process arguments
1977 arg = strtok( NULL, space );
1979 lighted = 1; //assume first texture is lighted
1981 Weapon_info[n].speedvar = 128;
1984 equal_ptr = strchr( arg, '=' );
1988 // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
1989 if (!stricmp( arg, "laser_bmp" )) {
1990 // Load bitmap with name equal_ptr
1992 Weapon_info[n].bitmap = bm_load_sub(equal_ptr); //load_polymodel_bitmap(equal_ptr);
1993 Weapon_info[n].render_type = WEAPON_RENDER_LASER;
1995 } else if (!stricmp( arg, "blob_bmp" )) {
1996 // Load bitmap with name equal_ptr
1998 Weapon_info[n].bitmap = bm_load_sub(equal_ptr); //load_polymodel_bitmap(equal_ptr);
1999 Weapon_info[n].render_type = WEAPON_RENDER_BLOB;
2001 } else if (!stricmp( arg, "weapon_vclip" )) {
2002 // Set vclip to play for this weapon.
2003 Weapon_info[n].bitmap.index = 0;
2004 Weapon_info[n].render_type = WEAPON_RENDER_VCLIP;
2005 Weapon_info[n].weapon_vclip = atoi(equal_ptr);
2007 } else if (!stricmp( arg, "none_bmp" )) {
2008 Weapon_info[n].bitmap = bm_load_sub(equal_ptr);
2009 Weapon_info[n].render_type = WEAPON_RENDER_NONE;
2011 } else if (!stricmp( arg, "weapon_pof" )) {
2013 Assert(n_models==0);
2014 model_name[0] = equal_ptr;
2015 first_bitmap_num[0] = N_ObjBitmapPtrs;
2017 } else if (!stricmp( arg, "simple_model" )) {
2018 model_name[n_models] = equal_ptr;
2019 first_bitmap_num[n_models] = N_ObjBitmapPtrs;
2021 Assert(n_models < MAX_MODEL_VARIANTS);
2022 } else if (!stricmp( arg, "weapon_pof_inner" )) {
2024 pof_file_inner = equal_ptr;
2025 } else if (!stricmp( arg, "strength" )) {
2026 for (i=0; i<NDL-1; i++) {
2027 Weapon_info[n].strength[i] = fl2f(atof(equal_ptr));
2028 equal_ptr = strtok(NULL, space);
2030 Weapon_info[n].strength[i] = i2f(atoi(equal_ptr));
2031 } else if (!stricmp( arg, "mass" )) {
2032 Weapon_info[n].mass = fl2f(atof(equal_ptr));
2033 } else if (!stricmp( arg, "drag" )) {
2034 Weapon_info[n].drag = fl2f(atof(equal_ptr));
2035 } else if (!stricmp( arg, "thrust" )) {
2036 Weapon_info[n].thrust = fl2f(atof(equal_ptr));
2037 } else if (!stricmp( arg, "matter" )) {
2038 Weapon_info[n].matter = atoi(equal_ptr);
2039 } else if (!stricmp( arg, "bounce" )) {
2040 Weapon_info[n].bounce = atoi(equal_ptr);
2041 } else if (!stricmp( arg, "speed" )) {
2042 for (i=0; i<NDL-1; i++) {
2043 Weapon_info[n].speed[i] = i2f(atoi(equal_ptr));
2044 equal_ptr = strtok(NULL, space);
2046 Weapon_info[n].speed[i] = i2f(atoi(equal_ptr));
2047 } else if (!stricmp( arg, "speedvar" )) {
2048 Weapon_info[n].speedvar = (atoi(equal_ptr) * 128) / 100;
2049 } else if (!stricmp( arg, "flash_vclip" )) {
2050 Weapon_info[n].flash_vclip = atoi(equal_ptr);
2051 } else if (!stricmp( arg, "flash_sound" )) {
2052 Weapon_info[n].flash_sound = atoi(equal_ptr);
2053 } else if (!stricmp( arg, "flash_size" )) {
2054 Weapon_info[n].flash_size = fl2f(atof(equal_ptr));
2055 } else if (!stricmp( arg, "blob_size" )) {
2056 Weapon_info[n].blob_size = fl2f(atof(equal_ptr));
2057 } else if (!stricmp( arg, "robot_hit_vclip" )) {
2058 Weapon_info[n].robot_hit_vclip = atoi(equal_ptr);
2059 } else if (!stricmp( arg, "robot_hit_sound" )) {
2060 Weapon_info[n].robot_hit_sound = atoi(equal_ptr);
2061 } else if (!stricmp( arg, "wall_hit_vclip" )) {
2062 Weapon_info[n].wall_hit_vclip = atoi(equal_ptr);
2063 } else if (!stricmp( arg, "wall_hit_sound" )) {
2064 Weapon_info[n].wall_hit_sound = atoi(equal_ptr);
2065 } else if (!stricmp( arg, "impact_size" )) {
2066 Weapon_info[n].impact_size = fl2f(atof(equal_ptr));
2067 } else if (!stricmp( arg, "lighted" )) {
2068 lighted = atoi(equal_ptr);
2069 } else if (!stricmp( arg, "lw_ratio" )) {
2070 Weapon_info[n].po_len_to_width_ratio = fl2f(atof(equal_ptr));
2071 } else if (!stricmp( arg, "lightcast" )) {
2072 Weapon_info[n].light = fl2f(atof(equal_ptr));
2073 } else if (!stricmp( arg, "persistent" )) {
2074 Weapon_info[n].persistent = atoi(equal_ptr);
2075 } else if (!stricmp(arg, "energy_usage" )) {
2076 Weapon_info[n].energy_usage = fl2f(atof(equal_ptr));
2077 } else if (!stricmp(arg, "ammo_usage" )) {
2078 Weapon_info[n].ammo_usage = atoi(equal_ptr);
2079 } else if (!stricmp(arg, "fire_wait" )) {
2080 Weapon_info[n].fire_wait = fl2f(atof(equal_ptr));
2081 } else if (!stricmp(arg, "fire_count" )) {
2082 Weapon_info[n].fire_count = atoi(equal_ptr);
2083 } else if (!stricmp(arg, "damage_radius" )) {
2084 Weapon_info[n].damage_radius = fl2f(atof(equal_ptr));
2085 //--01/19/95, mk-- } else if (!stricmp(arg, "damage_force" )) {
2086 //--01/19/95, mk-- Weapon_info[n].damage_force = fl2f(atof(equal_ptr));
2087 } else if (!stricmp(arg, "lifetime" )) {
2088 Weapon_info[n].lifetime = fl2f(atof(equal_ptr));
2089 } else if (!stricmp(arg, "destroyable" )) {
2090 Weapon_info[n].destroyable = atoi(equal_ptr);
2091 } else if (!stricmp(arg, "picture" )) {
2092 Weapon_info[n].picture = bm_load_sub(equal_ptr);
2093 } else if (!stricmp(arg, "hires_picture" )) {
2094 Weapon_info[n].hires_picture = bm_load_sub(equal_ptr);
2095 } else if (!stricmp(arg, "homing" )) {
2096 Weapon_info[n].homing_flag = !!atoi(equal_ptr);
2097 } else if (!stricmp(arg, "flash" )) {
2098 Weapon_info[n].flash = atoi(equal_ptr);
2099 } else if (!stricmp(arg, "multi_damage_scale" )) {
2100 Weapon_info[n].multi_damage_scale = fl2f(atof(equal_ptr));
2101 } else if (!stricmp(arg, "afterburner_size" )) {
2102 Weapon_info[n].afterburner_size = f2i(16*fl2f(atof(equal_ptr)));
2103 } else if (!stricmp(arg, "children" )) {
2104 Weapon_info[n].children = atoi(equal_ptr);
2105 } else if (!stricmp(arg, "placable" )) {
2106 if (atoi(equal_ptr)) {
2107 Weapon_info[n].flags |= WIF_PLACABLE;
2109 Assert(Num_total_object_types < MAX_OBJTYPE);
2110 ObjType[Num_total_object_types] = OL_WEAPON;
2111 ObjId[Num_total_object_types] = n;
2112 Num_total_object_types++;
2116 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
2118 } else { // Must be a texture specification...
2121 bm = load_polymodel_bitmap(arg);
2123 bm->bm_flags |= BM_FLAG_NO_LIGHTING;
2125 lighted = 1; //default for next bitmap is lighted
2127 arg = strtok( NULL, space );
2130 first_bitmap_num[n_models] = N_ObjBitmapPtrs;
2132 for (i=0;i<n_models;i++) {
2134 int model_num,last_model_num;
2136 n_textures = first_bitmap_num[i+1] - first_bitmap_num[i];
2138 model_num = load_polygon_model(model_name[i],n_textures,first_bitmap_num[i],NULL);
2141 Weapon_info[n].render_type = WEAPON_RENDER_POLYMODEL;
2142 Weapon_info[n].model_num = model_num;
2145 Polygon_models[last_model_num].simpler_model = model_num+1;
2147 last_model_num = model_num;
2150 if ( pof_file_inner ) {
2152 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);
2155 if ((Weapon_info[n].ammo_usage == 0) && (Weapon_info[n].energy_usage == 0))
2156 mprintf((1, "Warning: Weapon %i has ammo and energy usage of 0.\n", n));
2158 // -- render type of none is now legal -- Assert( Weapon_info[n].render_type != WEAPON_RENDER_NONE );
2165 // ------------------------------------------------------------------------------
2166 #define DEFAULT_POWERUP_SIZE i2f(3)
2168 void bm_read_powerup(int unused_flag)
2173 Assert(N_powerup_types < MAX_POWERUP_TYPES);
2175 n = N_powerup_types;
2179 clear_to_end_of_line();
2183 // Initialize powerup array
2184 Powerup_info[n].light = F1_0/3; // Default lighting value.
2185 Powerup_info[n].vclip_num = -1;
2186 Powerup_info[n].hit_sound = -1;
2187 Powerup_info[n].size = DEFAULT_POWERUP_SIZE;
2188 Powerup_names[n][0] = 0;
2190 // Process arguments
2191 arg = strtok( NULL, space );
2194 equal_ptr = strchr( arg, '=' );
2198 // if we have john=cool, arg is 'john' and equal_ptr is 'cool'
2199 if (!stricmp( arg, "vclip_num" )) {
2200 Powerup_info[n].vclip_num = atoi(equal_ptr);
2201 } else if (!stricmp( arg, "light" )) {
2202 Powerup_info[n].light = fl2f(atof(equal_ptr));
2203 } else if (!stricmp( arg, "hit_sound" )) {
2204 Powerup_info[n].hit_sound = atoi(equal_ptr);
2205 } else if (!stricmp( arg, "name" )) {
2206 Assert(strlen(equal_ptr) < POWERUP_NAME_LENGTH); // Oops, name too long.
2207 strcpy(Powerup_names[n], &equal_ptr[1]);
2208 Powerup_names[n][strlen(Powerup_names[n])-1] = 0;
2209 } else if (!stricmp( arg, "size" )) {
2210 Powerup_info[n].size = fl2f(atof(equal_ptr));
2213 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
2215 } else { // Must be a texture specification...
2217 mprintf( (1, "Invalid argument, %s in bitmaps.tbl\n", arg ));
2219 arg = strtok( NULL, space );
2222 ObjType[Num_total_object_types] = OL_POWERUP;
2223 ObjId[Num_total_object_types] = n;
2224 //printf( "Object type %d is a powerup\n", Num_total_object_types );
2225 Num_total_object_types++;
2226 Assert(Num_total_object_types < MAX_OBJTYPE);
2230 void bm_read_hostage()
2235 Assert(N_hostage_types < MAX_HOSTAGE_TYPES);
2237 n = N_hostage_types;
2240 // Process arguments
2241 arg = strtok( NULL, space );
2244 equal_ptr = strchr( arg, '=' );
2249 if (!stricmp( arg, "vclip_num" ))
2251 Hostage_vclip_num[n] = atoi(equal_ptr);
2255 mprintf( (1, "Invalid parameter, %s=%s in bitmaps.tbl\n", arg, equal_ptr ));
2260 mprintf( (1, "Invalid argument, %s in bitmaps.tbl at line %d\n", arg, linenum ));
2262 arg = strtok( NULL, space );
2265 ObjType[Num_total_object_types] = OL_HOSTAGE;
2266 ObjId[Num_total_object_types] = n;
2267 //printf( "Object type %d is a hostage\n", Num_total_object_types );
2268 Num_total_object_types++;
2269 Assert(Num_total_object_types < MAX_OBJTYPE);
2273 //these values are the number of each item in the release of d2
2274 //extra items added after the release get written in an additional hamfile
2275 #define N_D2_ROBOT_TYPES 66
2276 #define N_D2_ROBOT_JOINTS 1145
2277 #define N_D2_POLYGON_MODELS 166
2278 #define N_D2_OBJBITMAPS 422
2279 #define N_D2_OBJBITMAPPTRS 502
2280 #define N_D2_WEAPON_TYPES 62
2282 void bm_write_all(FILE *fp)
2288 tfile = fopen("hamfile.lst","wt");
2290 t = NumTextures-1; //don't save bogus texture
2291 fwrite( &t, sizeof(int), 1, fp );
2292 fwrite( Textures, sizeof(bitmap_index), t, fp );
2294 fwrite( &TmapInfo[i], sizeof(*TmapInfo)-sizeof(TmapInfo->filename)-sizeof(TmapInfo->pad2), 1, fp );
2296 fprintf(tfile,"NumTextures = %d, Textures array = %d, TmapInfo array = %d\n",NumTextures,sizeof(bitmap_index)*NumTextures,sizeof(tmap_info)*NumTextures);
2299 fwrite( &t, sizeof(int), 1, fp );
2300 fwrite( Sounds, sizeof(ubyte), t, fp );
2301 fwrite( AltSounds, sizeof(ubyte), t, fp );
2303 fprintf(tfile,"Num Sounds = %d, Sounds array = %d, AltSounds array = %d\n",t,t,t);
2305 fwrite( &Num_vclips, sizeof(int), 1, fp );
2306 fwrite( Vclip, sizeof(vclip), Num_vclips, fp );
2308 fprintf(tfile,"Num_vclips = %d, Vclip array = %d\n",Num_vclips,sizeof(vclip)*Num_vclips);
2310 fwrite( &Num_effects, sizeof(int), 1, fp );
2311 fwrite( Effects, sizeof(eclip), Num_effects, fp );
2313 fprintf(tfile,"Num_effects = %d, Effects array = %d\n",Num_effects,sizeof(eclip)*Num_effects);
2315 fwrite( &Num_wall_anims, sizeof(int), 1, fp );
2316 fwrite( WallAnims, sizeof(wclip), Num_wall_anims, fp );
2318 fprintf(tfile,"Num_wall_anims = %d, WallAnims array = %d\n",Num_wall_anims,sizeof(wclip)*Num_wall_anims);
2320 t = N_D2_ROBOT_TYPES;
2321 fwrite( &t, sizeof(int), 1, fp );
2322 fwrite( Robot_info, sizeof(robot_info), t, fp );
2324 fprintf(tfile,"N_robot_types = %d, Robot_info array = %d\n",t,sizeof(robot_info)*N_robot_types);
2326 t = N_D2_ROBOT_JOINTS;
2327 fwrite( &t, sizeof(int), 1, fp );
2328 fwrite( Robot_joints, sizeof(jointpos), t, fp );
2330 fprintf(tfile,"N_robot_joints = %d, Robot_joints array = %d\n",t,sizeof(jointpos)*N_robot_joints);
2332 t = N_D2_WEAPON_TYPES;
2333 fwrite( &t, sizeof(int), 1, fp );
2334 fwrite( Weapon_info, sizeof(weapon_info), t, fp );
2336 fprintf(tfile,"N_weapon_types = %d, Weapon_info array = %d\n",N_weapon_types,sizeof(weapon_info)*N_weapon_types);
2338 fwrite( &N_powerup_types, sizeof(int), 1, fp );
2339 fwrite( Powerup_info, sizeof(powerup_type_info), N_powerup_types, fp );
2341 fprintf(tfile,"N_powerup_types = %d, Powerup_info array = %d\n",N_powerup_types,sizeof(powerup_info)*N_powerup_types);
2343 t = N_D2_POLYGON_MODELS;
2344 fwrite( &t, sizeof(int), 1, fp );
2345 fwrite( Polygon_models, sizeof(polymodel), t, fp );
2347 fprintf(tfile,"N_polygon_models = %d, Polygon_models array = %d\n",t,sizeof(polymodel)*t);
2349 for (i=0; i<t; i++ ) {
2350 g3_uninit_polygon_model(Polygon_models[i].model_data); //get RGB colors
2351 fwrite( Polygon_models[i].model_data, sizeof(ubyte), Polygon_models[i].model_data_size, fp );
2352 fprintf(tfile," Model %d, data size = %d\n",i,Polygon_models[i].model_data_size); s+=Polygon_models[i].model_data_size;
2353 g3_init_polygon_model(Polygon_models[i].model_data); //map colors again
2355 fprintf(tfile,"Total model size = %d\n",s);
2357 fwrite( Dying_modelnums, sizeof(int), t, fp );
2358 fwrite( Dead_modelnums, sizeof(int), t, fp );
2360 fprintf(tfile,"Dying_modelnums array = %d, Dead_modelnums array = %d\n",sizeof(int)*t,sizeof(int)*t);
2363 fwrite( &t, sizeof(int), 1, fp );
2364 fwrite( Gauges, sizeof(bitmap_index), t, fp );
2365 fwrite( Gauges_hires, sizeof(bitmap_index), t, fp );
2367 fprintf(tfile,"Num gauge bitmaps = %d, Gauges array = %d, Gauges_hires array = %d\n",t,sizeof(bitmap_index)*t,sizeof(bitmap_index)*t);
2369 t = MAX_OBJ_BITMAPS;
2370 fwrite( &t, sizeof(int), 1, fp );
2371 fwrite( ObjBitmaps, sizeof(bitmap_index), t, fp );
2372 fwrite( ObjBitmapPtrs, sizeof(ushort), t, fp );
2374 fprintf(tfile,"Num obj bitmaps = %d, ObjBitmaps array = %d, ObjBitmapPtrs array = %d\n",t,sizeof(bitmap_index)*t,sizeof(ushort)*t);
2376 fwrite( &only_player_ship, sizeof(player_ship), 1, fp );
2378 fprintf(tfile,"player_ship size = %d\n",sizeof(player_ship));
2380 fwrite( &Num_cockpits, sizeof(int), 1, fp );
2381 fwrite( cockpit_bitmap, sizeof(bitmap_index), Num_cockpits, fp );
2383 fprintf(tfile,"Num_cockpits = %d, cockpit_bitmaps array = %d\n",Num_cockpits,sizeof(bitmap_index)*Num_cockpits);
2385 //@@ fwrite( &Num_total_object_types, sizeof(int), 1, fp );
2386 //@@ fwrite( ObjType, sizeof(byte), Num_total_object_types, fp );
2387 //@@ fwrite( ObjId, sizeof(byte), Num_total_object_types, fp );
2388 //@@ fwrite( ObjStrength, sizeof(fix), Num_total_object_types, fp );
2390 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);
2392 fwrite( &First_multi_bitmap_num, sizeof(int), 1, fp );
2394 fwrite( &Num_reactors, sizeof(Num_reactors), 1, fp );
2395 fwrite( Reactors, sizeof(*Reactors), Num_reactors, fp);
2397 fprintf(tfile,"Num_reactors = %d, Reactors array = %d\n",Num_reactors,sizeof(*Reactors)*Num_reactors);
2399 fwrite( &Marker_model_num, sizeof(Marker_model_num), 1, fp);
2401 //@@fwrite( &N_controlcen_guns, sizeof(int), 1, fp );
2402 //@@fwrite( controlcen_gun_points, sizeof(vms_vector), N_controlcen_guns, fp );
2403 //@@fwrite( controlcen_gun_dirs, sizeof(vms_vector), N_controlcen_guns, fp );
2406 fwrite( &exit_modelnum, sizeof(int), 1, fp );
2407 fwrite( &destroyed_exit_modelnum, sizeof(int), 1, fp );
2412 bm_write_extra_robots();
2415 bm_write_extra_robots()
2420 fp = fopen("robots.ham","wb");
2423 fwrite( &t, sizeof(int), 1, fp );
2425 fwrite( &t, sizeof(int), 1, fp );
2428 t = N_weapon_types - N_D2_WEAPON_TYPES;
2429 fwrite( &t, sizeof(int), 1, fp );
2430 fwrite( &Weapon_info[N_D2_WEAPON_TYPES], sizeof(weapon_info), t, fp );
2432 //now write robot info
2434 t = N_robot_types - N_D2_ROBOT_TYPES;
2435 fwrite( &t, sizeof(int), 1, fp );
2436 fwrite( &Robot_info[N_D2_ROBOT_TYPES], sizeof(robot_info), t, fp );
2438 t = N_robot_joints - N_D2_ROBOT_JOINTS;
2439 fwrite( &t, sizeof(int), 1, fp );
2440 fwrite( &Robot_joints[N_D2_ROBOT_JOINTS], sizeof(jointpos), t, fp );
2442 t = N_polygon_models - N_D2_POLYGON_MODELS;
2443 fwrite( &t, sizeof(int), 1, fp );
2444 fwrite( &Polygon_models[N_D2_POLYGON_MODELS], sizeof(polymodel), t, fp );
2446 for (i=N_D2_POLYGON_MODELS; i<N_polygon_models; i++ ) {
2447 g3_uninit_polygon_model(Polygon_models[i].model_data); //get RGB colors
2448 fwrite( Polygon_models[i].model_data, sizeof(ubyte), Polygon_models[i].model_data_size, fp );
2449 g3_init_polygon_model(Polygon_models[i].model_data); //map colors again
2452 fwrite( &Dying_modelnums[N_D2_POLYGON_MODELS], sizeof(int), t, fp );
2453 fwrite( &Dead_modelnums[N_D2_POLYGON_MODELS], sizeof(int), t, fp );
2455 t = N_ObjBitmaps - N_D2_OBJBITMAPS;
2456 fwrite( &t, sizeof(int), 1, fp );
2457 fwrite( &ObjBitmaps[N_D2_OBJBITMAPS], sizeof(bitmap_index), t, fp );
2459 t = N_ObjBitmapPtrs - N_D2_OBJBITMAPPTRS;
2460 fwrite( &t, sizeof(int), 1, fp );
2461 fwrite( &ObjBitmapPtrs[N_D2_OBJBITMAPPTRS], sizeof(ushort), t, fp );
2463 fwrite( ObjBitmapPtrs, sizeof(ushort), t, fp );