1 /* $Id: bm.c,v 1.22 2003-03-19 22:44:15 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
383 short *d2_Textures_backup = NULL;
385 void undo_bm_read_all_d1() {
386 if (d2_Textures_backup) {
388 for (i = 0; i < D1_LAST_STATIC_TMAP_NUM; i++)
389 Textures[i].index = d2_Textures_backup[i];
390 d_free(d2_Textures_backup);
391 d2_Textures_backup = NULL;
396 * used by piggy_d1_init to read in descent 1 pigfile
398 void bm_read_all_d1(CFILE * fp)
402 /*NumTextures = */ cfile_read_int(fp);
403 //bitmap_index_read_n(Textures, D1_MAX_TEXTURES, fp );
404 //for (i = 0; i < D1_MAX_TEXTURES; i++)
405 // Textures[i].index = cfile_read_short(fp) + 600;
406 //cfseek(fp, D1_MAX_TEXTURES * sizeof(short), SEEK_CUR);
407 MALLOC(d2_Textures_backup, short, D1_LAST_STATIC_TMAP_NUM);
408 for (i = 0; i < D1_LAST_STATIC_TMAP_NUM; i++) {
409 d2_Textures_backup[i] = Textures[i].index;
410 Textures[i].index = cfile_read_short(fp) + 521;
412 cfseek(fp, (D1_MAX_TEXTURES - D1_LAST_STATIC_TMAP_NUM) * sizeof(short), SEEK_CUR);
414 //tmap_info_read_n_d1(TmapInfo, D1_MAX_TEXTURES, fp);
415 cfseek(fp, D1_MAX_TEXTURES * D1_TMAP_INFO_SIZE, SEEK_CUR);
418 cfread( Sounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
419 cfread( AltSounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
420 */cfseek(fp, D1_MAX_SOUNDS * 2, SEEK_CUR);
422 /*Num_vclips = */ cfile_read_int(fp);
423 //vclip_read_n(Vclip, D1_MAX_VCLIPS, fp);
424 cfseek(fp, D1_MAX_VCLIPS * D1_VCLIP_SIZE, SEEK_CUR);
427 Num_effects = cfile_read_int(fp);
428 eclip_read_n(Effects, D1_MAX_EFFECTS, fp);
430 Num_wall_anims = cfile_read_int(fp);
431 wclip_read_n_d1(WallAnims, D1_MAX_WALL_ANIMS, fp);
435 N_robot_types = cfile_read_int(fp);
436 //robot_info_read_n(Robot_info, D1_MAX_ROBOT_TYPES, fp);
437 cfseek(fp, D1_MAX_ROBOT_TYPES * D1_ROBOT_INFO_SIZE, SEEK_CUR);
439 N_robot_joints = cfile_read_int(fp);
440 jointpos_read_n(Robot_joints, D1_MAX_ROBOT_JOINTS, fp);
442 N_weapon_types = cfile_read_int(fp);
443 //weapon_info_read_n(Weapon_info, D1_MAX_WEAPON_TYPES, fp, Piggy_hamfile_version);
444 cfseek(fp, D1_MAX_WEAPON_TYPES * D1_WEAPON_INFO_SIZE, SEEK_CUR);
446 N_powerup_types = cfile_read_int(fp);
447 powerup_type_info_read_n(Powerup_info, D1_MAX_POWERUP_TYPES, fp);
450 /* in the following code are bugs, solved by hack
451 N_polygon_models = cfile_read_int(fp);
452 polymodel_read_n(Polygon_models, N_polygon_models, fp);
453 for (i=0; i<N_polygon_models; i++ )
454 polygon_model_data_read(&Polygon_models[i], fp);
455 */cfseek(fp, 521490-160, SEEK_SET); // OK, I admit, this is a dirty hack
456 //bitmap_index_read_n(Gauges, D1_MAX_GAUGE_BMS, fp);
457 cfseek(fp, D1_MAX_GAUGE_BMS * sizeof(bitmap_index), SEEK_CUR);
460 for (i = 0; i < D1_MAX_POLYGON_MODELS; i++)
461 Dying_modelnums[i] = cfile_read_int(fp);
462 for (i = 0; i < D1_MAX_POLYGON_MODELS; i++)
463 Dead_modelnums[i] = cfile_read_int(fp);
464 */ cfseek(fp, D1_MAX_POLYGON_MODELS * 8, SEEK_CUR);
466 //bitmap_index_read_n(ObjBitmaps, D1_MAX_OBJ_BITMAPS, fp);
467 cfseek(fp, D1_MAX_OBJ_BITMAPS * sizeof(bitmap_index), SEEK_CUR);
468 for (i = 0; i < D1_MAX_OBJ_BITMAPS; i++)
469 cfseek(fp, 2, SEEK_CUR);//ObjBitmapPtrs[i] = cfile_read_short(fp);
471 //player_ship_read(&only_player_ship, fp);
472 cfseek(fp, sizeof(player_ship), SEEK_CUR);
474 /*Num_cockpits = */ cfile_read_int(fp);
475 //bitmap_index_read_n(cockpit_bitmap, D1_MAX_COCKPIT_BITMAPS, fp);
476 cfseek(fp, D1_MAX_COCKPIT_BITMAPS * sizeof(bitmap_index), SEEK_CUR);
479 cfread( Sounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
480 cfread( AltSounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
481 */cfseek(fp, D1_MAX_SOUNDS * 2, SEEK_CUR);
483 /*Num_total_object_types = */ cfile_read_int( fp );
485 cfread( ObjType, sizeof(byte), D1_MAX_OBJTYPE, fp );
486 cfread( ObjId, sizeof(byte), D1_MAX_OBJTYPE, fp );
487 for (i=0; i<D1_MAX_OBJTYPE; i++ )
488 ObjStrength[i] = cfile_read_int( fp );
489 */ cfseek(fp, D1_MAX_OBJTYPE * 6, SEEK_CUR);
491 /*First_multi_bitmap_num =*/ cfile_read_int(fp);
492 /*Reactors[0].n_guns = */ cfile_read_int( fp );
493 /*for (i=0; i<4; i++)
494 cfile_read_vector(&(Reactors[0].gun_points[i]), fp);
496 cfile_read_vector(&(Reactors[0].gun_dirs[i]), fp);
497 */cfseek(fp, 8 * 12, SEEK_CUR);
499 /*exit_modelnum = */ cfile_read_int(fp);
500 /*destroyed_exit_modelnum = */ cfile_read_int(fp);
503 //these values are the number of each item in the release of d2
504 //extra items added after the release get written in an additional hamfile
505 #define N_D2_ROBOT_TYPES 66
506 #define N_D2_ROBOT_JOINTS 1145
507 #define N_D2_POLYGON_MODELS 166
508 #define N_D2_OBJBITMAPS 422
509 #define N_D2_OBJBITMAPPTRS 502
510 #define N_D2_WEAPON_TYPES 62
512 //type==1 means 1.1, type==2 means 1.2 (with weapons)
513 void bm_read_extra_robots(char *fname,int type)
519 fp = cfopen(fname,"rb");
524 sig = cfile_read_int(fp);
525 if (sig != MAKE_SIG('X','H','A','M'))
527 version = cfile_read_int(fp);
534 t = cfile_read_int(fp);
535 N_weapon_types = N_D2_WEAPON_TYPES+t;
536 if (N_weapon_types >= MAX_WEAPON_TYPES)
537 Error("Too many weapons (%d) in <%s>. Max is %d.",t,fname,MAX_WEAPON_TYPES-N_D2_WEAPON_TYPES);
538 weapon_info_read_n(&Weapon_info[N_D2_WEAPON_TYPES], t, fp, 3);
540 //now read robot info
542 t = cfile_read_int(fp);
543 N_robot_types = N_D2_ROBOT_TYPES+t;
544 if (N_robot_types >= MAX_ROBOT_TYPES)
545 Error("Too many robots (%d) in <%s>. Max is %d.",t,fname,MAX_ROBOT_TYPES-N_D2_ROBOT_TYPES);
546 robot_info_read_n(&Robot_info[N_D2_ROBOT_TYPES], t, fp);
548 t = cfile_read_int(fp);
549 N_robot_joints = N_D2_ROBOT_JOINTS+t;
550 if (N_robot_joints >= MAX_ROBOT_JOINTS)
551 Error("Too many robot joints (%d) in <%s>. Max is %d.",t,fname,MAX_ROBOT_JOINTS-N_D2_ROBOT_JOINTS);
552 jointpos_read_n(&Robot_joints[N_D2_ROBOT_JOINTS], t, fp);
554 t = cfile_read_int(fp);
555 N_polygon_models = N_D2_POLYGON_MODELS+t;
556 if (N_polygon_models >= MAX_POLYGON_MODELS)
557 Error("Too many polygon models (%d) in <%s>. Max is %d.",t,fname,MAX_POLYGON_MODELS-N_D2_POLYGON_MODELS);
558 polymodel_read_n(&Polygon_models[N_D2_POLYGON_MODELS], t, fp);
560 for (i=N_D2_POLYGON_MODELS; i<N_polygon_models; i++ )
562 polygon_model_data_read(&Polygon_models[i], fp);
565 for (i = N_D2_POLYGON_MODELS; i < N_polygon_models; i++)
566 Dying_modelnums[i] = cfile_read_int(fp);
567 for (i = N_D2_POLYGON_MODELS; i < N_polygon_models; i++)
568 Dead_modelnums[i] = cfile_read_int(fp);
570 t = cfile_read_int(fp);
571 if (N_D2_OBJBITMAPS+t >= MAX_OBJ_BITMAPS)
572 Error("Too many object bitmaps (%d) in <%s>. Max is %d.",t,fname,MAX_OBJ_BITMAPS-N_D2_OBJBITMAPS);
573 bitmap_index_read_n(&ObjBitmaps[N_D2_OBJBITMAPS], t, fp);
575 t = cfile_read_int(fp);
576 if (N_D2_OBJBITMAPPTRS+t >= MAX_OBJ_BITMAPS)
577 Error("Too many object bitmap pointers (%d) in <%s>. Max is %d.",t,fname,MAX_OBJ_BITMAPS-N_D2_OBJBITMAPPTRS);
578 for (i = N_D2_OBJBITMAPPTRS; i < (N_D2_OBJBITMAPPTRS + t); i++)
579 ObjBitmapPtrs[i] = cfile_read_short(fp);
584 extern void change_filename_extension( char *dest, char *src, char *new_ext );
586 int Robot_replacements_loaded = 0;
588 void load_robot_replacements(char *level_name)
592 char ifile_name[FILENAME_LEN];
594 change_filename_extension(ifile_name, level_name, ".HXM" );
596 fp = cfopen(ifile_name,"rb");
598 if (!fp) //no robot replacement file
601 t = cfile_read_int(fp); //read id "HXM!"
603 Error("ID of HXM! file incorrect");
605 t = cfile_read_int(fp); //read version
607 Error("HXM! version too old (%d)",t);
609 t = cfile_read_int(fp); //read number of robots
611 i = cfile_read_int(fp); //read robot number
612 if (i<0 || i>=N_robot_types)
613 Error("Robots number (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_robot_types-1);
614 robot_info_read_n(&Robot_info[i], 1, fp);
617 t = cfile_read_int(fp); //read number of joints
619 i = cfile_read_int(fp); //read joint number
620 if (i<0 || i>=N_robot_joints)
621 Error("Robots joint (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_robot_joints-1);
622 jointpos_read_n(&Robot_joints[i], 1, fp);
625 t = cfile_read_int(fp); //read number of polygon models
628 i = cfile_read_int(fp); //read model number
629 if (i<0 || i>=N_polygon_models)
630 Error("Polygon model (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_polygon_models-1);
631 polymodel_read(&Polygon_models[i], fp);
633 d_free(Polygon_models[i].model_data);
634 polygon_model_data_read(&Polygon_models[i], fp);
636 Dying_modelnums[i] = cfile_read_int(fp);
637 Dead_modelnums[i] = cfile_read_int(fp);
640 t = cfile_read_int(fp); //read number of objbitmaps
642 i = cfile_read_int(fp); //read objbitmap number
643 if (i<0 || i>=MAX_OBJ_BITMAPS)
644 Error("Object bitmap number (%d) out of range in (%s). Range = [0..%d].",i,level_name,MAX_OBJ_BITMAPS-1);
645 bitmap_index_read(&ObjBitmaps[i], fp);
648 t = cfile_read_int(fp); //read number of objbitmapptrs
650 i = cfile_read_int(fp); //read objbitmapptr number
651 if (i<0 || i>=MAX_OBJ_BITMAPS)
652 Error("Object bitmap pointer (%d) out of range in (%s). Range = [0..%d].",i,level_name,MAX_OBJ_BITMAPS-1);
653 ObjBitmapPtrs[i] = cfile_read_short(fp);