1 /* $Id: bm.c,v 1.23 2003-03-22 02:26:10 btb 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 * Bitmap and palette loading functions.
61 ubyte Sounds[MAX_SOUNDS];
62 ubyte AltSounds[MAX_SOUNDS];
65 int Num_total_object_types;
66 byte ObjType[MAX_OBJTYPE];
67 byte ObjId[MAX_OBJTYPE];
68 fix ObjStrength[MAX_OBJTYPE];
71 //for each model, a model number for dying & dead variants, or -1 if none
72 int Dying_modelnums[MAX_POLYGON_MODELS];
73 int Dead_modelnums[MAX_POLYGON_MODELS];
75 //the polygon model number to use for the marker
76 int Marker_model_num = -1;
78 //right now there's only one player ship, but we can have another by
79 //adding an array and setting the pointer to the active ship.
80 player_ship only_player_ship,*Player_ship=&only_player_ship;
82 //----------------- Miscellaneous bitmap pointers ---------------
84 bitmap_index cockpit_bitmap[N_COCKPIT_BITMAPS];
86 //---------------- Variables for wall textures ------------------
88 tmap_info TmapInfo[MAX_TEXTURES];
90 //---------------- Variables for object textures ----------------
92 int First_multi_bitmap_num=-1;
95 bitmap_index ObjBitmaps[MAX_OBJ_BITMAPS];
96 ushort ObjBitmapPtrs[MAX_OBJ_BITMAPS]; // These point back into ObjBitmaps, since some are used twice.
99 #define tmap_info_read_n(ti, n, fp) cfread(ti, sizeof(tmap_info), n, fp)
102 * reads n tmap_info structs from a CFILE
104 int tmap_info_read_n(tmap_info *ti, int n, CFILE *fp)
108 for (i = 0; i < n; i++) {
109 ti[i].flags = cfile_read_byte(fp);
110 ti[i].pad[0] = cfile_read_byte(fp);
111 ti[i].pad[1] = cfile_read_byte(fp);
112 ti[i].pad[2] = cfile_read_byte(fp);
113 ti[i].lighting = cfile_read_fix(fp);
114 ti[i].damage = cfile_read_fix(fp);
115 ti[i].eclip_num = cfile_read_short(fp);
116 ti[i].destroyed = cfile_read_short(fp);
117 ti[i].slide_u = cfile_read_short(fp);
118 ti[i].slide_v = cfile_read_short(fp);
124 int tmap_info_read_n_d1(tmap_info *ti, int n, CFILE *fp)
128 for (i = 0; i < n; i++) {
129 cfseek(fp, 13, SEEK_CUR);// skip filename
130 ti[i].flags = cfile_read_byte(fp);
131 ti[i].lighting = cfile_read_fix(fp);
132 ti[i].damage = cfile_read_fix(fp);
133 ti[i].eclip_num = cfile_read_int(fp);
138 extern int Num_bitmap_files;
139 int extra_bitmap_num;
141 bitmap_index exitmodel_bm_load_sub( char * filename )
143 bitmap_index bitmap_num;
144 grs_bitmap * new = &GameBitmaps[extra_bitmap_num];
146 int iff_error; //reference parm to avoid warning message
148 bitmap_num.index = 0;
150 //MALLOC( new, grs_bitmap, 1 );
151 iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal);
153 if (iff_error != IFF_NO_ERROR) {
154 Error("Error loading exit model bitmap <%s> - IFF error: %s",filename,iff_errormsg(iff_error));
157 if ( iff_has_transparency )
158 gr_remap_bitmap_good( new, newpal, iff_transparent_color, 254 );
160 gr_remap_bitmap_good( new, newpal, -1, 254 );
162 new->avg_color = 0; //compute_average_pixel(new);
164 bitmap_num.index = extra_bitmap_num;
166 GameBitmaps[extra_bitmap_num++] = *new;
172 grs_bitmap *load_exit_model_bitmap(char *name)
174 Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
177 ObjBitmaps[N_ObjBitmaps] = exitmodel_bm_load_sub(name);
178 if (GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_w!=64 || GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_h!=64)
179 Error("Bitmap <%s> is not 64x64",name);
180 ObjBitmapPtrs[N_ObjBitmaps] = N_ObjBitmaps;
182 Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
183 return &GameBitmaps[ObjBitmaps[N_ObjBitmaps-1].index];
188 free_exit_model_data()
192 for (i = Num_bitmap_files; i < extra_bitmap_num; i++)
193 d_free(GameBitmaps[i].bm_data);
194 extra_bitmap_num = Num_bitmap_files;
199 void ogl_cache_polymodel_textures(int model_num);
202 int load_exit_models()
207 if (!cfexist("steel1.bbm") ||
208 !cfexist("rbot061.bbm") ||
209 !cfexist("rbot062.bbm") ||
210 !cfexist("rbot063.bbm")) {
211 Warning("Can't load exit models!\n");
215 start_num = N_ObjBitmaps;
216 extra_bitmap_num = Num_bitmap_files;
217 load_exit_model_bitmap("steel1.bbm");
218 load_exit_model_bitmap("rbot061.bbm");
219 load_exit_model_bitmap("rbot062.bbm");
221 load_exit_model_bitmap("steel1.bbm");
222 load_exit_model_bitmap("rbot061.bbm");
223 load_exit_model_bitmap("rbot063.bbm");
225 if (cfexist("exit.ham")) {
227 exit_hamfile = cfopen("exit.ham","rb");
229 exit_hamfile = cfopen(":Data:exit.ham","rb");
232 exit_modelnum = N_polygon_models++;
233 destroyed_exit_modelnum = N_polygon_models++;
234 polymodel_read(&Polygon_models[exit_modelnum], exit_hamfile);
235 polymodel_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
236 Polygon_models[exit_modelnum].first_texture = start_num;
237 Polygon_models[destroyed_exit_modelnum].first_texture = start_num+3;
239 polygon_model_data_read(&Polygon_models[exit_modelnum], exit_hamfile);
241 polygon_model_data_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
243 cfclose(exit_hamfile);
245 } else if (cfexist("exit01.pof") && cfexist("exit01d.pof")) {
247 exit_modelnum = load_polygon_model("exit01.pof", 3, start_num, NULL);
248 destroyed_exit_modelnum = load_polygon_model("exit01d.pof", 3, start_num + 3, NULL);
251 ogl_cache_polymodel_textures(exit_modelnum);
252 ogl_cache_polymodel_textures(destroyed_exit_modelnum);
256 Warning("Can't load exit models!\n");
264 //-----------------------------------------------------------------
265 // Read data from piggy.
266 // This is called when the editor is OUT.
267 // If editor is in, bm_init_use_table() is called.
270 init_polygon_models();
271 if (! piggy_init()) // This calls bm_read_all
272 Error("Cannot open pig and/or ham file");
276 init_endlevel(); //this is in bm_init_use_tbl(), so I gues it goes here
281 void bm_read_all(CFILE * fp)
285 NumTextures = cfile_read_int(fp);
286 bitmap_index_read_n(Textures, NumTextures, fp );
287 tmap_info_read_n(TmapInfo, NumTextures, fp);
289 t = cfile_read_int(fp);
290 cfread( Sounds, sizeof(ubyte), t, fp );
291 cfread( AltSounds, sizeof(ubyte), t, fp );
293 Num_vclips = cfile_read_int(fp);
294 vclip_read_n(Vclip, Num_vclips, fp);
296 Num_effects = cfile_read_int(fp);
297 eclip_read_n(Effects, Num_effects, fp);
299 Num_wall_anims = cfile_read_int(fp);
300 wclip_read_n(WallAnims, Num_wall_anims, fp);
302 N_robot_types = cfile_read_int(fp);
303 robot_info_read_n(Robot_info, N_robot_types, fp);
305 N_robot_joints = cfile_read_int(fp);
306 jointpos_read_n(Robot_joints, N_robot_joints, fp);
308 N_weapon_types = cfile_read_int(fp);
309 weapon_info_read_n(Weapon_info, N_weapon_types, fp, Piggy_hamfile_version);
311 N_powerup_types = cfile_read_int(fp);
312 powerup_type_info_read_n(Powerup_info, N_powerup_types, fp);
314 N_polygon_models = cfile_read_int(fp);
315 polymodel_read_n(Polygon_models, N_polygon_models, fp);
317 for (i=0; i<N_polygon_models; i++ )
318 polygon_model_data_read(&Polygon_models[i], fp);
320 for (i = 0; i < N_polygon_models; i++)
321 Dying_modelnums[i] = cfile_read_int(fp);
322 for (i = 0; i < N_polygon_models; i++)
323 Dead_modelnums[i] = cfile_read_int(fp);
325 t = cfile_read_int(fp);
326 bitmap_index_read_n(Gauges, t, fp);
327 bitmap_index_read_n(Gauges_hires, t, fp);
329 N_ObjBitmaps = cfile_read_int(fp);
330 bitmap_index_read_n(ObjBitmaps, N_ObjBitmaps, fp);
331 for (i = 0; i < N_ObjBitmaps; i++)
332 ObjBitmapPtrs[i] = cfile_read_short(fp);
334 player_ship_read(&only_player_ship, fp);
336 Num_cockpits = cfile_read_int(fp);
337 bitmap_index_read_n(cockpit_bitmap, Num_cockpits, fp);
339 //@@ cfread( &Num_total_object_types, sizeof(int), 1, fp );
340 //@@ cfread( ObjType, sizeof(byte), Num_total_object_types, fp );
341 //@@ cfread( ObjId, sizeof(byte), Num_total_object_types, fp );
342 //@@ cfread( ObjStrength, sizeof(fix), Num_total_object_types, fp );
344 First_multi_bitmap_num = cfile_read_int(fp);
346 Num_reactors = cfile_read_int(fp);
347 reactor_read_n(Reactors, Num_reactors, fp);
349 Marker_model_num = cfile_read_int(fp);
351 //@@cfread( &N_controlcen_guns, sizeof(int), 1, fp );
352 //@@cfread( controlcen_gun_points, sizeof(vms_vector), N_controlcen_guns, fp );
353 //@@cfread( controlcen_gun_dirs, sizeof(vms_vector), N_controlcen_guns, fp );
355 if (Piggy_hamfile_version < 3) {
356 exit_modelnum = cfile_read_int(fp);
357 destroyed_exit_modelnum = cfile_read_int(fp);
362 #define D1_MAX_TEXTURES 800
363 #define D1_MAX_SOUNDS 250
364 #define D1_MAX_VCLIPS 70
365 #define D1_MAX_EFFECTS 60
366 #define D1_MAX_WALL_ANIMS 30
367 #define D1_MAX_ROBOT_TYPES 30
368 #define D1_MAX_ROBOT_JOINTS 600
369 #define D1_MAX_WEAPON_TYPES 30
370 #define D1_MAX_POWERUP_TYPES 29
371 #define D1_MAX_GAUGE_BMS 80
372 #define D1_MAX_OBJ_BITMAPS 210
373 #define D1_MAX_COCKPIT_BITMAPS 4
374 #define D1_MAX_OBJTYPE 100
375 #define D1_MAX_POLYGON_MODELS 85
377 #define D1_TMAP_INFO_SIZE 26
378 #define D1_VCLIP_SIZE 66
379 #define D1_ROBOT_INFO_SIZE 486
380 #define D1_WEAPON_INFO_SIZE 115
382 #define D1_LAST_STATIC_TMAP_NUM 324
384 // store the Textures[] array as read from the descent 2 pig.
385 short *d2_Textures_backup = NULL;
387 void undo_bm_read_all_d1() {
388 if (d2_Textures_backup) {
390 for (i = 0; i < D1_LAST_STATIC_TMAP_NUM; i++)
391 Textures[i].index = d2_Textures_backup[i];
392 d_free(d2_Textures_backup);
393 d2_Textures_backup = NULL;
398 * used by piggy_d1_init to read in descent 1 pigfile
400 void bm_read_all_d1(CFILE * fp)
404 atexit(undo_bm_read_all_d1);
406 /*NumTextures = */ cfile_read_int(fp);
407 //bitmap_index_read_n(Textures, D1_MAX_TEXTURES, fp );
408 //for (i = 0; i < D1_MAX_TEXTURES; i++)
409 // Textures[i].index = cfile_read_short(fp) + 600;
410 //cfseek(fp, D1_MAX_TEXTURES * sizeof(short), SEEK_CUR);
411 MALLOC(d2_Textures_backup, short, D1_LAST_STATIC_TMAP_NUM);
412 for (i = 0; i < D1_LAST_STATIC_TMAP_NUM; i++) {
413 d2_Textures_backup[i] = Textures[i].index;
414 Textures[i].index = cfile_read_short(fp) + 521;
416 cfseek(fp, (D1_MAX_TEXTURES - D1_LAST_STATIC_TMAP_NUM) * sizeof(short), SEEK_CUR);
418 //tmap_info_read_n_d1(TmapInfo, D1_MAX_TEXTURES, fp);
419 cfseek(fp, D1_MAX_TEXTURES * D1_TMAP_INFO_SIZE, SEEK_CUR);
422 cfread( Sounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
423 cfread( AltSounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
424 */cfseek(fp, D1_MAX_SOUNDS * 2, SEEK_CUR);
426 /*Num_vclips = */ cfile_read_int(fp);
427 //vclip_read_n(Vclip, D1_MAX_VCLIPS, fp);
428 cfseek(fp, D1_MAX_VCLIPS * D1_VCLIP_SIZE, SEEK_CUR);
431 Num_effects = cfile_read_int(fp);
432 eclip_read_n(Effects, D1_MAX_EFFECTS, fp);
434 Num_wall_anims = cfile_read_int(fp);
435 wclip_read_n_d1(WallAnims, D1_MAX_WALL_ANIMS, fp);
439 N_robot_types = cfile_read_int(fp);
440 //robot_info_read_n(Robot_info, D1_MAX_ROBOT_TYPES, fp);
441 cfseek(fp, D1_MAX_ROBOT_TYPES * D1_ROBOT_INFO_SIZE, SEEK_CUR);
443 N_robot_joints = cfile_read_int(fp);
444 jointpos_read_n(Robot_joints, D1_MAX_ROBOT_JOINTS, fp);
446 N_weapon_types = cfile_read_int(fp);
447 //weapon_info_read_n(Weapon_info, D1_MAX_WEAPON_TYPES, fp, Piggy_hamfile_version);
448 cfseek(fp, D1_MAX_WEAPON_TYPES * D1_WEAPON_INFO_SIZE, SEEK_CUR);
450 N_powerup_types = cfile_read_int(fp);
451 powerup_type_info_read_n(Powerup_info, D1_MAX_POWERUP_TYPES, fp);
454 /* in the following code are bugs, solved by hack
455 N_polygon_models = cfile_read_int(fp);
456 polymodel_read_n(Polygon_models, N_polygon_models, fp);
457 for (i=0; i<N_polygon_models; i++ )
458 polygon_model_data_read(&Polygon_models[i], fp);
459 */cfseek(fp, 521490-160, SEEK_SET); // OK, I admit, this is a dirty hack
460 //bitmap_index_read_n(Gauges, D1_MAX_GAUGE_BMS, fp);
461 cfseek(fp, D1_MAX_GAUGE_BMS * sizeof(bitmap_index), SEEK_CUR);
464 for (i = 0; i < D1_MAX_POLYGON_MODELS; i++)
465 Dying_modelnums[i] = cfile_read_int(fp);
466 for (i = 0; i < D1_MAX_POLYGON_MODELS; i++)
467 Dead_modelnums[i] = cfile_read_int(fp);
468 */ cfseek(fp, D1_MAX_POLYGON_MODELS * 8, SEEK_CUR);
470 //bitmap_index_read_n(ObjBitmaps, D1_MAX_OBJ_BITMAPS, fp);
471 cfseek(fp, D1_MAX_OBJ_BITMAPS * sizeof(bitmap_index), SEEK_CUR);
472 for (i = 0; i < D1_MAX_OBJ_BITMAPS; i++)
473 cfseek(fp, 2, SEEK_CUR);//ObjBitmapPtrs[i] = cfile_read_short(fp);
475 //player_ship_read(&only_player_ship, fp);
476 cfseek(fp, sizeof(player_ship), SEEK_CUR);
478 /*Num_cockpits = */ cfile_read_int(fp);
479 //bitmap_index_read_n(cockpit_bitmap, D1_MAX_COCKPIT_BITMAPS, fp);
480 cfseek(fp, D1_MAX_COCKPIT_BITMAPS * sizeof(bitmap_index), SEEK_CUR);
483 cfread( Sounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
484 cfread( AltSounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
485 */cfseek(fp, D1_MAX_SOUNDS * 2, SEEK_CUR);
487 /*Num_total_object_types = */ cfile_read_int( fp );
489 cfread( ObjType, sizeof(byte), D1_MAX_OBJTYPE, fp );
490 cfread( ObjId, sizeof(byte), D1_MAX_OBJTYPE, fp );
491 for (i=0; i<D1_MAX_OBJTYPE; i++ )
492 ObjStrength[i] = cfile_read_int( fp );
493 */ cfseek(fp, D1_MAX_OBJTYPE * 6, SEEK_CUR);
495 /*First_multi_bitmap_num =*/ cfile_read_int(fp);
496 /*Reactors[0].n_guns = */ cfile_read_int( fp );
497 /*for (i=0; i<4; i++)
498 cfile_read_vector(&(Reactors[0].gun_points[i]), fp);
500 cfile_read_vector(&(Reactors[0].gun_dirs[i]), fp);
501 */cfseek(fp, 8 * 12, SEEK_CUR);
503 /*exit_modelnum = */ cfile_read_int(fp);
504 /*destroyed_exit_modelnum = */ cfile_read_int(fp);
507 //these values are the number of each item in the release of d2
508 //extra items added after the release get written in an additional hamfile
509 #define N_D2_ROBOT_TYPES 66
510 #define N_D2_ROBOT_JOINTS 1145
511 #define N_D2_POLYGON_MODELS 166
512 #define N_D2_OBJBITMAPS 422
513 #define N_D2_OBJBITMAPPTRS 502
514 #define N_D2_WEAPON_TYPES 62
516 //type==1 means 1.1, type==2 means 1.2 (with weapons)
517 void bm_read_extra_robots(char *fname,int type)
523 fp = cfopen(fname,"rb");
528 sig = cfile_read_int(fp);
529 if (sig != MAKE_SIG('X','H','A','M'))
531 version = cfile_read_int(fp);
538 t = cfile_read_int(fp);
539 N_weapon_types = N_D2_WEAPON_TYPES+t;
540 if (N_weapon_types >= MAX_WEAPON_TYPES)
541 Error("Too many weapons (%d) in <%s>. Max is %d.",t,fname,MAX_WEAPON_TYPES-N_D2_WEAPON_TYPES);
542 weapon_info_read_n(&Weapon_info[N_D2_WEAPON_TYPES], t, fp, 3);
544 //now read robot info
546 t = cfile_read_int(fp);
547 N_robot_types = N_D2_ROBOT_TYPES+t;
548 if (N_robot_types >= MAX_ROBOT_TYPES)
549 Error("Too many robots (%d) in <%s>. Max is %d.",t,fname,MAX_ROBOT_TYPES-N_D2_ROBOT_TYPES);
550 robot_info_read_n(&Robot_info[N_D2_ROBOT_TYPES], t, fp);
552 t = cfile_read_int(fp);
553 N_robot_joints = N_D2_ROBOT_JOINTS+t;
554 if (N_robot_joints >= MAX_ROBOT_JOINTS)
555 Error("Too many robot joints (%d) in <%s>. Max is %d.",t,fname,MAX_ROBOT_JOINTS-N_D2_ROBOT_JOINTS);
556 jointpos_read_n(&Robot_joints[N_D2_ROBOT_JOINTS], t, fp);
558 t = cfile_read_int(fp);
559 N_polygon_models = N_D2_POLYGON_MODELS+t;
560 if (N_polygon_models >= MAX_POLYGON_MODELS)
561 Error("Too many polygon models (%d) in <%s>. Max is %d.",t,fname,MAX_POLYGON_MODELS-N_D2_POLYGON_MODELS);
562 polymodel_read_n(&Polygon_models[N_D2_POLYGON_MODELS], t, fp);
564 for (i=N_D2_POLYGON_MODELS; i<N_polygon_models; i++ )
566 polygon_model_data_read(&Polygon_models[i], fp);
569 for (i = N_D2_POLYGON_MODELS; i < N_polygon_models; i++)
570 Dying_modelnums[i] = cfile_read_int(fp);
571 for (i = N_D2_POLYGON_MODELS; i < N_polygon_models; i++)
572 Dead_modelnums[i] = cfile_read_int(fp);
574 t = cfile_read_int(fp);
575 if (N_D2_OBJBITMAPS+t >= MAX_OBJ_BITMAPS)
576 Error("Too many object bitmaps (%d) in <%s>. Max is %d.",t,fname,MAX_OBJ_BITMAPS-N_D2_OBJBITMAPS);
577 bitmap_index_read_n(&ObjBitmaps[N_D2_OBJBITMAPS], t, fp);
579 t = cfile_read_int(fp);
580 if (N_D2_OBJBITMAPPTRS+t >= MAX_OBJ_BITMAPS)
581 Error("Too many object bitmap pointers (%d) in <%s>. Max is %d.",t,fname,MAX_OBJ_BITMAPS-N_D2_OBJBITMAPPTRS);
582 for (i = N_D2_OBJBITMAPPTRS; i < (N_D2_OBJBITMAPPTRS + t); i++)
583 ObjBitmapPtrs[i] = cfile_read_short(fp);
588 extern void change_filename_extension( char *dest, char *src, char *new_ext );
590 int Robot_replacements_loaded = 0;
592 void load_robot_replacements(char *level_name)
596 char ifile_name[FILENAME_LEN];
598 change_filename_extension(ifile_name, level_name, ".HXM" );
600 fp = cfopen(ifile_name,"rb");
602 if (!fp) //no robot replacement file
605 t = cfile_read_int(fp); //read id "HXM!"
607 Error("ID of HXM! file incorrect");
609 t = cfile_read_int(fp); //read version
611 Error("HXM! version too old (%d)",t);
613 t = cfile_read_int(fp); //read number of robots
615 i = cfile_read_int(fp); //read robot number
616 if (i<0 || i>=N_robot_types)
617 Error("Robots number (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_robot_types-1);
618 robot_info_read_n(&Robot_info[i], 1, fp);
621 t = cfile_read_int(fp); //read number of joints
623 i = cfile_read_int(fp); //read joint number
624 if (i<0 || i>=N_robot_joints)
625 Error("Robots joint (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_robot_joints-1);
626 jointpos_read_n(&Robot_joints[i], 1, fp);
629 t = cfile_read_int(fp); //read number of polygon models
632 i = cfile_read_int(fp); //read model number
633 if (i<0 || i>=N_polygon_models)
634 Error("Polygon model (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_polygon_models-1);
635 polymodel_read(&Polygon_models[i], fp);
637 d_free(Polygon_models[i].model_data);
638 polygon_model_data_read(&Polygon_models[i], fp);
640 Dying_modelnums[i] = cfile_read_int(fp);
641 Dead_modelnums[i] = cfile_read_int(fp);
644 t = cfile_read_int(fp); //read number of objbitmaps
646 i = cfile_read_int(fp); //read objbitmap number
647 if (i<0 || i>=MAX_OBJ_BITMAPS)
648 Error("Object bitmap number (%d) out of range in (%s). Range = [0..%d].",i,level_name,MAX_OBJ_BITMAPS-1);
649 bitmap_index_read(&ObjBitmaps[i], fp);
652 t = cfile_read_int(fp); //read number of objbitmapptrs
654 i = cfile_read_int(fp); //read objbitmapptr number
655 if (i<0 || i>=MAX_OBJ_BITMAPS)
656 Error("Object bitmap pointer (%d) out of range in (%s). Range = [0..%d].",i,level_name,MAX_OBJ_BITMAPS-1);
657 ObjBitmapPtrs[i] = cfile_read_short(fp);