1 /* $Id: bm.c,v 1.49 2005-03-31 09:38:53 chris 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_object_subtypes = 1;
68 //for each model, a model number for dying & dead variants, or -1 if none
69 int Dying_modelnums[MAX_POLYGON_MODELS];
70 int Dead_modelnums[MAX_POLYGON_MODELS];
72 //the polygon model number to use for the marker
73 int Marker_model_num = -1;
75 //right now there's only one player ship, but we can have another by
76 //adding an array and setting the pointer to the active ship.
77 player_ship only_player_ship,*Player_ship=&only_player_ship;
79 //----------------- Miscellaneous bitmap pointers ---------------
81 bitmap_index cockpit_bitmap[N_COCKPIT_BITMAPS];
83 //---------------- Variables for wall textures ------------------
85 tmap_info TmapInfo[MAX_TEXTURES];
87 //---------------- Variables for object textures ----------------
89 int First_multi_bitmap_num=-1;
92 bitmap_index ObjBitmaps[MAX_OBJ_BITMAPS];
93 ushort ObjBitmapPtrs[MAX_OBJ_BITMAPS]; // These point back into ObjBitmaps, since some are used twice.
96 #define tmap_info_read_n(ti, n, fp) cfread(ti, TMAP_INFO_SIZE, n, fp)
99 * reads n tmap_info structs from a CFILE
101 int tmap_info_read_n(tmap_info *ti, int n, CFILE *fp)
105 for (i = 0; i < n; i++) {
106 ti[i].flags = cfile_read_byte(fp);
107 ti[i].pad[0] = cfile_read_byte(fp);
108 ti[i].pad[1] = cfile_read_byte(fp);
109 ti[i].pad[2] = cfile_read_byte(fp);
110 ti[i].lighting = cfile_read_fix(fp);
111 ti[i].damage = cfile_read_fix(fp);
112 ti[i].eclip_num = cfile_read_short(fp);
113 ti[i].destroyed = cfile_read_short(fp);
114 ti[i].slide_u = cfile_read_short(fp);
115 ti[i].slide_v = cfile_read_short(fp);
121 int tmap_info_read_n_d1(tmap_info *ti, int n, CFILE *fp)
125 for (i = 0; i < n; i++) {
126 cfseek(fp, 13, SEEK_CUR);// skip filename
127 ti[i].flags = cfile_read_byte(fp);
128 ti[i].lighting = cfile_read_fix(fp);
129 ti[i].damage = cfile_read_fix(fp);
130 ti[i].eclip_num = cfile_read_int(fp);
136 //-----------------------------------------------------------------
137 // Read data from piggy.
138 // This is called when the editor is OUT.
139 // If editor is in, bm_init_use_table() is called.
142 init_polygon_models();
143 if (! piggy_init()) // This calls bm_read_all
144 Error("Cannot open pig and/or ham file");
148 init_endlevel(); //this is in bm_init_use_tbl(), so I gues it goes here
153 void bm_read_all(CFILE * fp)
157 NumTextures = cfile_read_int(fp);
158 bitmap_index_read_n(Textures, NumTextures, fp );
159 tmap_info_read_n(TmapInfo, NumTextures, fp);
161 t = cfile_read_int(fp);
162 cfread( Sounds, sizeof(ubyte), t, fp );
163 cfread( AltSounds, sizeof(ubyte), t, fp );
165 Num_vclips = cfile_read_int(fp);
166 vclip_read_n(Vclip, Num_vclips, fp);
168 Num_effects = cfile_read_int(fp);
169 eclip_read_n(Effects, Num_effects, fp);
171 Num_wall_anims = cfile_read_int(fp);
172 wclip_read_n(WallAnims, Num_wall_anims, fp);
174 N_robot_types = cfile_read_int(fp);
175 robot_info_read_n(Robot_info, N_robot_types, fp);
177 N_robot_joints = cfile_read_int(fp);
178 jointpos_read_n(Robot_joints, N_robot_joints, fp);
180 N_weapon_types = cfile_read_int(fp);
181 weapon_info_read_n(Weapon_info, N_weapon_types, fp, Piggy_hamfile_version);
183 N_powerup_types = cfile_read_int(fp);
184 powerup_type_info_read_n(Powerup_info, N_powerup_types, fp);
186 N_polygon_models = cfile_read_int(fp);
187 polymodel_read_n(Polygon_models, N_polygon_models, fp);
189 for (i=0; i<N_polygon_models; i++ )
190 polygon_model_data_read(&Polygon_models[i], fp);
192 for (i = 0; i < N_polygon_models; i++)
193 Dying_modelnums[i] = cfile_read_int(fp);
194 for (i = 0; i < N_polygon_models; i++)
195 Dead_modelnums[i] = cfile_read_int(fp);
197 t = cfile_read_int(fp);
198 bitmap_index_read_n(Gauges, t, fp);
199 bitmap_index_read_n(Gauges_hires, t, fp);
201 N_ObjBitmaps = cfile_read_int(fp);
202 bitmap_index_read_n(ObjBitmaps, N_ObjBitmaps, fp);
203 for (i = 0; i < N_ObjBitmaps; i++)
204 ObjBitmapPtrs[i] = cfile_read_short(fp);
206 player_ship_read(&only_player_ship, fp);
208 Num_cockpits = cfile_read_int(fp);
209 bitmap_index_read_n(cockpit_bitmap, Num_cockpits, fp);
211 //@@ cfread( &Num_total_object_types, sizeof(int), 1, fp );
212 //@@ cfread( ObjType, sizeof(byte), Num_total_object_types, fp );
213 //@@ cfread( ObjId, sizeof(byte), Num_total_object_types, fp );
214 //@@ cfread( ObjStrength, sizeof(fix), Num_total_object_types, fp );
216 First_multi_bitmap_num = cfile_read_int(fp);
218 Num_reactors = cfile_read_int(fp);
219 reactor_read_n(Reactors, Num_reactors, fp);
221 Marker_model_num = cfile_read_int(fp);
223 //@@cfread( &N_controlcen_guns, sizeof(int), 1, fp );
224 //@@cfread( controlcen_gun_points, sizeof(vms_vector), N_controlcen_guns, fp );
225 //@@cfread( controlcen_gun_dirs, sizeof(vms_vector), N_controlcen_guns, fp );
227 if (Piggy_hamfile_version < 3) {
228 exit_modelnum = cfile_read_int(fp);
229 destroyed_exit_modelnum = cfile_read_int(fp);
232 exit_modelnum = destroyed_exit_modelnum = N_polygon_models;
235 // the following is old code for reading descent 1 textures.
238 #define D1_MAX_TEXTURES 800
239 #define D1_MAX_SOUNDS 250
240 #define D1_MAX_VCLIPS 70
241 #define D1_MAX_EFFECTS 60
242 #define D1_MAX_WALL_ANIMS 30
243 #define D1_MAX_ROBOT_TYPES 30
244 #define D1_MAX_ROBOT_JOINTS 600
245 #define D1_MAX_WEAPON_TYPES 30
246 #define D1_MAX_POWERUP_TYPES 29
247 #define D1_MAX_GAUGE_BMS 80
248 #define D1_MAX_OBJ_BITMAPS 210
249 #define D1_MAX_COCKPIT_BITMAPS 4
250 #define D1_MAX_OBJTYPE 100
251 #define D1_MAX_POLYGON_MODELS 85
253 #define D1_TMAP_INFO_SIZE 26
254 #define D1_VCLIP_SIZE 66
255 #define D1_ROBOT_INFO_SIZE 486
256 #define D1_WEAPON_INFO_SIZE 115
258 #define D1_LAST_STATIC_TMAP_NUM 324
260 // store the Textures[] array as read from the descent 2 pig.
261 short *d2_Textures_backup = NULL;
263 void undo_bm_read_all_d1() {
264 if (d2_Textures_backup) {
266 for (i = 0; i < D1_LAST_STATIC_TMAP_NUM; i++)
267 Textures[i].index = d2_Textures_backup[i];
268 d_free(d2_Textures_backup);
269 d2_Textures_backup = NULL;
274 * used by piggy_d1_init to read in descent 1 pigfile
276 void bm_read_all_d1(CFILE * fp)
280 atexit(undo_bm_read_all_d1);
282 /*NumTextures = */ cfile_read_int(fp);
283 //bitmap_index_read_n(Textures, D1_MAX_TEXTURES, fp );
284 //for (i = 0; i < D1_MAX_TEXTURES; i++)
285 // Textures[i].index = cfile_read_short(fp) + 600;
286 //cfseek(fp, D1_MAX_TEXTURES * sizeof(short), SEEK_CUR);
287 MALLOC(d2_Textures_backup, short, D1_LAST_STATIC_TMAP_NUM);
288 for (i = 0; i < D1_LAST_STATIC_TMAP_NUM; i++) {
289 d2_Textures_backup[i] = Textures[i].index;
290 Textures[i].index = cfile_read_short(fp) + 521;
292 cfseek(fp, (D1_MAX_TEXTURES - D1_LAST_STATIC_TMAP_NUM) * sizeof(short), SEEK_CUR);
294 //tmap_info_read_n_d1(TmapInfo, D1_MAX_TEXTURES, fp);
295 cfseek(fp, D1_MAX_TEXTURES * D1_TMAP_INFO_SIZE, SEEK_CUR);
298 cfread( Sounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
299 cfread( AltSounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
300 */cfseek(fp, D1_MAX_SOUNDS * 2, SEEK_CUR);
302 /*Num_vclips = */ cfile_read_int(fp);
303 //vclip_read_n(Vclip, D1_MAX_VCLIPS, fp);
304 cfseek(fp, D1_MAX_VCLIPS * D1_VCLIP_SIZE, SEEK_CUR);
307 Num_effects = cfile_read_int(fp);
308 eclip_read_n(Effects, D1_MAX_EFFECTS, fp);
310 Num_wall_anims = cfile_read_int(fp);
311 wclip_read_n_d1(WallAnims, D1_MAX_WALL_ANIMS, fp);
315 N_robot_types = cfile_read_int(fp);
316 //robot_info_read_n(Robot_info, D1_MAX_ROBOT_TYPES, fp);
317 cfseek(fp, D1_MAX_ROBOT_TYPES * D1_ROBOT_INFO_SIZE, SEEK_CUR);
319 N_robot_joints = cfile_read_int(fp);
320 jointpos_read_n(Robot_joints, D1_MAX_ROBOT_JOINTS, fp);
322 N_weapon_types = cfile_read_int(fp);
323 //weapon_info_read_n(Weapon_info, D1_MAX_WEAPON_TYPES, fp, Piggy_hamfile_version);
324 cfseek(fp, D1_MAX_WEAPON_TYPES * D1_WEAPON_INFO_SIZE, SEEK_CUR);
326 N_powerup_types = cfile_read_int(fp);
327 powerup_type_info_read_n(Powerup_info, D1_MAX_POWERUP_TYPES, fp);
330 /* in the following code are bugs, solved by hack
331 N_polygon_models = cfile_read_int(fp);
332 polymodel_read_n(Polygon_models, N_polygon_models, fp);
333 for (i=0; i<N_polygon_models; i++ )
334 polygon_model_data_read(&Polygon_models[i], fp);
335 */cfseek(fp, 521490-160, SEEK_SET); // OK, I admit, this is a dirty hack
336 //bitmap_index_read_n(Gauges, D1_MAX_GAUGE_BMS, fp);
337 cfseek(fp, D1_MAX_GAUGE_BMS * sizeof(bitmap_index), SEEK_CUR);
340 for (i = 0; i < D1_MAX_POLYGON_MODELS; i++)
341 Dying_modelnums[i] = cfile_read_int(fp);
342 for (i = 0; i < D1_MAX_POLYGON_MODELS; i++)
343 Dead_modelnums[i] = cfile_read_int(fp);
344 */ cfseek(fp, D1_MAX_POLYGON_MODELS * 8, SEEK_CUR);
346 //bitmap_index_read_n(ObjBitmaps, D1_MAX_OBJ_BITMAPS, fp);
347 cfseek(fp, D1_MAX_OBJ_BITMAPS * sizeof(bitmap_index), SEEK_CUR);
348 for (i = 0; i < D1_MAX_OBJ_BITMAPS; i++)
349 cfseek(fp, 2, SEEK_CUR);//ObjBitmapPtrs[i] = cfile_read_short(fp);
351 //player_ship_read(&only_player_ship, fp);
352 cfseek(fp, sizeof(player_ship), SEEK_CUR);
354 /*Num_cockpits = */ cfile_read_int(fp);
355 //bitmap_index_read_n(cockpit_bitmap, D1_MAX_COCKPIT_BITMAPS, fp);
356 cfseek(fp, D1_MAX_COCKPIT_BITMAPS * sizeof(bitmap_index), SEEK_CUR);
359 cfread( Sounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
360 cfread( AltSounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
361 */cfseek(fp, D1_MAX_SOUNDS * 2, SEEK_CUR);
363 /*Num_total_object_types = */ cfile_read_int( fp );
365 cfread( ObjType, sizeof(byte), D1_MAX_OBJTYPE, fp );
366 cfread( ObjId, sizeof(byte), D1_MAX_OBJTYPE, fp );
367 for (i=0; i<D1_MAX_OBJTYPE; i++ )
368 ObjStrength[i] = cfile_read_int( fp );
369 */ cfseek(fp, D1_MAX_OBJTYPE * 6, SEEK_CUR);
371 /*First_multi_bitmap_num =*/ cfile_read_int(fp);
372 /*Reactors[0].n_guns = */ cfile_read_int( fp );
373 /*for (i=0; i<4; i++)
374 cfile_read_vector(&(Reactors[0].gun_points[i]), fp);
376 cfile_read_vector(&(Reactors[0].gun_dirs[i]), fp);
377 */cfseek(fp, 8 * 12, SEEK_CUR);
379 /*exit_modelnum = */ cfile_read_int(fp);
380 /*destroyed_exit_modelnum = */ cfile_read_int(fp);
383 #endif // if 0, old code for reading descent 1 textures
385 //these values are the number of each item in the release of d2
386 //extra items added after the release get written in an additional hamfile
387 #define N_D2_ROBOT_TYPES 66
388 #define N_D2_ROBOT_JOINTS 1145
389 #define N_D2_POLYGON_MODELS 166
390 #define N_D2_OBJBITMAPS 422
391 #define N_D2_OBJBITMAPPTRS 502
392 #define N_D2_WEAPON_TYPES 62
394 extern int Num_bitmap_files;
395 int extra_bitmap_num = 0;
397 void bm_free_extra_objbitmaps()
401 if (!extra_bitmap_num)
402 extra_bitmap_num = Num_bitmap_files;
404 for (i = Num_bitmap_files; i < extra_bitmap_num; i++)
407 d_free(GameBitmaps[i].bm_data);
409 extra_bitmap_num = Num_bitmap_files;
412 void bm_free_extra_models()
414 while (N_polygon_models > N_D2_POLYGON_MODELS)
415 free_model(&Polygon_models[--N_polygon_models]);
416 while (N_polygon_models > exit_modelnum)
417 free_model(&Polygon_models[--N_polygon_models]);
420 //type==1 means 1.1, type==2 means 1.2 (with weapons)
421 void bm_read_extra_robots(char *fname,int type)
427 fp = cfopen(fname,"rb");
432 sig = cfile_read_int(fp);
433 if (sig != MAKE_SIG('X','H','A','M'))
435 version = cfile_read_int(fp);
440 bm_free_extra_models();
441 bm_free_extra_objbitmaps();
445 t = cfile_read_int(fp);
446 N_weapon_types = N_D2_WEAPON_TYPES+t;
447 if (N_weapon_types >= MAX_WEAPON_TYPES)
448 Error("Too many weapons (%d) in <%s>. Max is %d.",t,fname,MAX_WEAPON_TYPES-N_D2_WEAPON_TYPES);
449 weapon_info_read_n(&Weapon_info[N_D2_WEAPON_TYPES], t, fp, 3);
451 //now read robot info
453 t = cfile_read_int(fp);
454 N_robot_types = N_D2_ROBOT_TYPES+t;
455 if (N_robot_types >= MAX_ROBOT_TYPES)
456 Error("Too many robots (%d) in <%s>. Max is %d.",t,fname,MAX_ROBOT_TYPES-N_D2_ROBOT_TYPES);
457 robot_info_read_n(&Robot_info[N_D2_ROBOT_TYPES], t, fp);
459 t = cfile_read_int(fp);
460 N_robot_joints = N_D2_ROBOT_JOINTS+t;
461 if (N_robot_joints >= MAX_ROBOT_JOINTS)
462 Error("Too many robot joints (%d) in <%s>. Max is %d.",t,fname,MAX_ROBOT_JOINTS-N_D2_ROBOT_JOINTS);
463 jointpos_read_n(&Robot_joints[N_D2_ROBOT_JOINTS], t, fp);
465 t = cfile_read_int(fp);
466 N_polygon_models = N_D2_POLYGON_MODELS+t;
467 if (N_polygon_models >= MAX_POLYGON_MODELS)
468 Error("Too many polygon models (%d) in <%s>. Max is %d.",t,fname,MAX_POLYGON_MODELS-N_D2_POLYGON_MODELS);
469 polymodel_read_n(&Polygon_models[N_D2_POLYGON_MODELS], t, fp);
471 for (i=N_D2_POLYGON_MODELS; i<N_polygon_models; i++ )
472 polygon_model_data_read(&Polygon_models[i], fp);
474 for (i = N_D2_POLYGON_MODELS; i < N_polygon_models; i++)
475 Dying_modelnums[i] = cfile_read_int(fp);
476 for (i = N_D2_POLYGON_MODELS; i < N_polygon_models; i++)
477 Dead_modelnums[i] = cfile_read_int(fp);
479 t = cfile_read_int(fp);
480 if (N_D2_OBJBITMAPS+t >= MAX_OBJ_BITMAPS)
481 Error("Too many object bitmaps (%d) in <%s>. Max is %d.",t,fname,MAX_OBJ_BITMAPS-N_D2_OBJBITMAPS);
482 bitmap_index_read_n(&ObjBitmaps[N_D2_OBJBITMAPS], t, fp);
484 t = cfile_read_int(fp);
485 if (N_D2_OBJBITMAPPTRS+t >= MAX_OBJ_BITMAPS)
486 Error("Too many object bitmap pointers (%d) in <%s>. Max is %d.",t,fname,MAX_OBJ_BITMAPS-N_D2_OBJBITMAPPTRS);
487 for (i = N_D2_OBJBITMAPPTRS; i < (N_D2_OBJBITMAPPTRS + t); i++)
488 ObjBitmapPtrs[i] = cfile_read_short(fp);
493 extern void change_filename_extension( char *dest, char *src, char *new_ext );
495 int Robot_replacements_loaded = 0;
497 void load_robot_replacements(char *level_name)
501 char ifile_name[FILENAME_LEN];
503 change_filename_extension(ifile_name, level_name, ".HXM" );
505 fp = cfopen(ifile_name,"rb");
507 if (!fp) //no robot replacement file
510 t = cfile_read_int(fp); //read id "HXM!"
512 Error("ID of HXM! file incorrect");
514 t = cfile_read_int(fp); //read version
516 Error("HXM! version too old (%d)",t);
518 t = cfile_read_int(fp); //read number of robots
520 i = cfile_read_int(fp); //read robot number
521 if (i<0 || i>=N_robot_types)
522 Error("Robots number (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_robot_types-1);
523 robot_info_read_n(&Robot_info[i], 1, fp);
526 t = cfile_read_int(fp); //read number of joints
528 i = cfile_read_int(fp); //read joint number
529 if (i<0 || i>=N_robot_joints)
530 Error("Robots joint (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_robot_joints-1);
531 jointpos_read_n(&Robot_joints[i], 1, fp);
534 t = cfile_read_int(fp); //read number of polygon models
537 i = cfile_read_int(fp); //read model number
538 if (i<0 || i>=N_polygon_models)
539 Error("Polygon model (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_polygon_models-1);
541 free_model(&Polygon_models[i]);
542 polymodel_read(&Polygon_models[i], fp);
543 polygon_model_data_read(&Polygon_models[i], fp);
545 Dying_modelnums[i] = cfile_read_int(fp);
546 Dead_modelnums[i] = cfile_read_int(fp);
549 t = cfile_read_int(fp); //read number of objbitmaps
551 i = cfile_read_int(fp); //read objbitmap number
552 if (i<0 || i>=MAX_OBJ_BITMAPS)
553 Error("Object bitmap number (%d) out of range in (%s). Range = [0..%d].",i,level_name,MAX_OBJ_BITMAPS-1);
554 bitmap_index_read(&ObjBitmaps[i], fp);
557 t = cfile_read_int(fp); //read number of objbitmapptrs
559 i = cfile_read_int(fp); //read objbitmapptr number
560 if (i<0 || i>=MAX_OBJ_BITMAPS)
561 Error("Object bitmap pointer (%d) out of range in (%s). Range = [0..%d].",i,level_name,MAX_OBJ_BITMAPS-1);
562 ObjBitmapPtrs[i] = cfile_read_short(fp);
566 Robot_replacements_loaded = 1;
571 * Routines for loading exit models
573 * Used by d1 levels (including some add-ons), and by d2 shareware.
574 * Could potentially be used by d2 add-on levels, but only if they
575 * don't use "extra" robots...
578 // formerly exitmodel_bm_load_sub
579 bitmap_index read_extra_bitmap_iff( char * filename )
581 bitmap_index bitmap_num;
582 grs_bitmap * new = &GameBitmaps[extra_bitmap_num];
584 int iff_error; //reference parm to avoid warning message
586 bitmap_num.index = 0;
588 //MALLOC( new, grs_bitmap, 1 );
589 iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal);
591 if (iff_error != IFF_NO_ERROR) {
592 con_printf(CON_DEBUG, "Error loading exit model bitmap <%s> - IFF error: %s\n", filename, iff_errormsg(iff_error));
596 if ( iff_has_transparency )
597 gr_remap_bitmap_good( new, newpal, iff_transparent_color, 254 );
599 gr_remap_bitmap_good( new, newpal, -1, 254 );
601 new->avg_color = 0; //compute_average_pixel(new);
603 bitmap_num.index = extra_bitmap_num;
605 GameBitmaps[extra_bitmap_num++] = *new;
611 // formerly load_exit_model_bitmap
612 grs_bitmap *bm_load_extra_objbitmap(char *name)
614 Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
617 ObjBitmaps[N_ObjBitmaps] = read_extra_bitmap_iff(name);
619 if (ObjBitmaps[N_ObjBitmaps].index == 0)
621 char *name2 = d_strdup(name);
622 *strrchr(name2, '.') = '\0';
623 ObjBitmaps[N_ObjBitmaps] = read_extra_bitmap_d1_pig(name2);
626 if (ObjBitmaps[N_ObjBitmaps].index == 0)
629 if (GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_w!=64 || GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_h!=64)
630 Error("Bitmap <%s> is not 64x64",name);
631 ObjBitmapPtrs[N_ObjBitmaps] = N_ObjBitmaps;
633 Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
634 return &GameBitmaps[ObjBitmaps[N_ObjBitmaps-1].index];
639 void ogl_cache_polymodel_textures(int model_num);
642 int load_exit_models()
647 bm_free_extra_models();
648 bm_free_extra_objbitmaps();
650 start_num = N_ObjBitmaps;
651 if (!bm_load_extra_objbitmap("steel1.bbm") ||
652 !bm_load_extra_objbitmap("rbot061.bbm") ||
653 !bm_load_extra_objbitmap("rbot062.bbm") ||
654 !bm_load_extra_objbitmap("steel1.bbm") ||
655 !bm_load_extra_objbitmap("rbot061.bbm") ||
656 !bm_load_extra_objbitmap("rbot063.bbm"))
658 con_printf(CON_NORMAL, "Can't load exit models!\n");
663 exit_hamfile = cfopen("exit.ham","rb");
665 exit_hamfile = cfopen(":Data:exit.ham","rb");
668 exit_modelnum = N_polygon_models++;
669 destroyed_exit_modelnum = N_polygon_models++;
670 polymodel_read(&Polygon_models[exit_modelnum], exit_hamfile);
671 polymodel_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
672 Polygon_models[exit_modelnum].first_texture = start_num;
673 Polygon_models[destroyed_exit_modelnum].first_texture = start_num+3;
675 polygon_model_data_read(&Polygon_models[exit_modelnum], exit_hamfile);
677 polygon_model_data_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
679 cfclose(exit_hamfile);
681 } else if (cfexist("exit01.pof") && cfexist("exit01d.pof")) {
683 exit_modelnum = load_polygon_model("exit01.pof", 3, start_num, NULL);
684 destroyed_exit_modelnum = load_polygon_model("exit01d.pof", 3, start_num + 3, NULL);
687 ogl_cache_polymodel_textures(exit_modelnum);
688 ogl_cache_polymodel_textures(destroyed_exit_modelnum);
691 else if (cfexist(D1_PIGFILE))
696 exit_hamfile = cfopen(D1_PIGFILE, "rb");
697 hamsize = cfilelength(exit_hamfile);
698 switch (hamsize) { //total hack for loading models
700 offset = 91848; /* and 92582 */
701 offset2 = 383390; /* and 394022 */
704 case D1_SHARE_BIG_PIGSIZE:
705 case D1_SHARE_10_PIGSIZE:
706 case D1_SHARE_PIGSIZE:
707 case D1_10_BIG_PIGSIZE:
709 Int3(); /* exit models should be in .pofs */
712 case D1_MAC_SHARE_PIGSIZE:
713 con_printf(CON_NORMAL, "Can't load exit models!\n");
716 cfseek(exit_hamfile, offset, SEEK_SET);
717 exit_modelnum = N_polygon_models++;
718 destroyed_exit_modelnum = N_polygon_models++;
719 polymodel_read(&Polygon_models[exit_modelnum], exit_hamfile);
720 polymodel_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
721 Polygon_models[exit_modelnum].first_texture = start_num;
722 Polygon_models[destroyed_exit_modelnum].first_texture = start_num+3;
724 cfseek(exit_hamfile, offset2, SEEK_SET);
725 polygon_model_data_read(&Polygon_models[exit_modelnum], exit_hamfile);
726 polygon_model_data_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
728 cfclose(exit_hamfile);
730 con_printf(CON_NORMAL, "Can't load exit models!\n");
734 atexit(bm_free_extra_objbitmaps);