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 * Bitmap and palette loading functions.
38 ubyte Sounds[MAX_SOUNDS];
39 ubyte AltSounds[MAX_SOUNDS];
42 int Num_object_subtypes = 1;
45 //for each model, a model number for dying & dead variants, or -1 if none
46 int Dying_modelnums[MAX_POLYGON_MODELS];
47 int Dead_modelnums[MAX_POLYGON_MODELS];
49 //the polygon model number to use for the marker
50 int Marker_model_num = -1;
52 //right now there's only one player ship, but we can have another by
53 //adding an array and setting the pointer to the active ship.
54 player_ship only_player_ship,*Player_ship=&only_player_ship;
56 //----------------- Miscellaneous bitmap pointers ---------------
58 bitmap_index cockpit_bitmap[N_COCKPIT_BITMAPS];
60 //---------------- Variables for wall textures ------------------
62 tmap_info TmapInfo[MAX_TEXTURES];
64 //---------------- Variables for object textures ----------------
66 int First_multi_bitmap_num=-1;
69 bitmap_index ObjBitmaps[MAX_OBJ_BITMAPS];
70 ushort ObjBitmapPtrs[MAX_OBJ_BITMAPS]; // These point back into ObjBitmaps, since some are used twice.
73 #define tmap_info_read_n(ti, n, fp) cfread(ti, TMAP_INFO_SIZE, n, fp)
76 * reads n tmap_info structs from a CFILE
78 int tmap_info_read_n(tmap_info *ti, int n, CFILE *fp)
82 for (i = 0; i < n; i++) {
83 ti[i].flags = cfile_read_byte(fp);
84 ti[i].pad[0] = cfile_read_byte(fp);
85 ti[i].pad[1] = cfile_read_byte(fp);
86 ti[i].pad[2] = cfile_read_byte(fp);
87 ti[i].lighting = cfile_read_fix(fp);
88 ti[i].damage = cfile_read_fix(fp);
89 ti[i].eclip_num = cfile_read_short(fp);
90 ti[i].destroyed = cfile_read_short(fp);
91 ti[i].slide_u = cfile_read_short(fp);
92 ti[i].slide_v = cfile_read_short(fp);
98 int tmap_info_read_n_d1(tmap_info *ti, int n, CFILE *fp)
102 for (i = 0; i < n; i++) {
103 cfseek(fp, 13, SEEK_CUR);// skip filename
104 ti[i].flags = cfile_read_byte(fp);
105 ti[i].lighting = cfile_read_fix(fp);
106 ti[i].damage = cfile_read_fix(fp);
107 ti[i].eclip_num = cfile_read_int(fp);
113 //-----------------------------------------------------------------
114 // Read data from piggy.
115 // This is called when the editor is OUT.
116 // If editor is in, bm_init_use_table() is called.
119 init_polygon_models();
120 if (! piggy_init()) // This calls bm_read_all
121 Error("Cannot open pig and/or ham file");
125 init_endlevel(); //this is in bm_init_use_tbl(), so I gues it goes here
130 void bm_read_all(CFILE * fp)
134 NumTextures = cfile_read_int(fp);
135 bitmap_index_read_n(Textures, NumTextures, fp );
136 tmap_info_read_n(TmapInfo, NumTextures, fp);
138 t = cfile_read_int(fp);
139 cfread( Sounds, sizeof(ubyte), t, fp );
140 cfread( AltSounds, sizeof(ubyte), t, fp );
142 Num_vclips = cfile_read_int(fp);
143 vclip_read_n(Vclip, Num_vclips, fp);
145 Num_effects = cfile_read_int(fp);
146 eclip_read_n(Effects, Num_effects, fp);
148 Num_wall_anims = cfile_read_int(fp);
149 wclip_read_n(WallAnims, Num_wall_anims, fp);
151 N_robot_types = cfile_read_int(fp);
152 robot_info_read_n(Robot_info, N_robot_types, fp);
154 N_robot_joints = cfile_read_int(fp);
155 jointpos_read_n(Robot_joints, N_robot_joints, fp);
157 N_weapon_types = cfile_read_int(fp);
158 weapon_info_read_n(Weapon_info, N_weapon_types, fp, Piggy_hamfile_version);
160 N_powerup_types = cfile_read_int(fp);
161 powerup_type_info_read_n(Powerup_info, N_powerup_types, fp);
163 N_polygon_models = cfile_read_int(fp);
164 polymodel_read_n(Polygon_models, N_polygon_models, fp);
166 for (i=0; i<N_polygon_models; i++ )
167 polygon_model_data_read(&Polygon_models[i], fp);
169 for (i = 0; i < N_polygon_models; i++)
170 Dying_modelnums[i] = cfile_read_int(fp);
171 for (i = 0; i < N_polygon_models; i++)
172 Dead_modelnums[i] = cfile_read_int(fp);
174 t = cfile_read_int(fp);
175 bitmap_index_read_n(Gauges, t, fp);
176 bitmap_index_read_n(Gauges_hires, t, fp);
178 N_ObjBitmaps = cfile_read_int(fp);
179 bitmap_index_read_n(ObjBitmaps, N_ObjBitmaps, fp);
180 for (i = 0; i < N_ObjBitmaps; i++)
181 ObjBitmapPtrs[i] = cfile_read_short(fp);
183 player_ship_read(&only_player_ship, fp);
185 Num_cockpits = cfile_read_int(fp);
186 bitmap_index_read_n(cockpit_bitmap, Num_cockpits, fp);
188 //@@ cfread( &Num_total_object_types, sizeof(int), 1, fp );
189 //@@ cfread( ObjType, sizeof(byte), Num_total_object_types, fp );
190 //@@ cfread( ObjId, sizeof(byte), Num_total_object_types, fp );
191 //@@ cfread( ObjStrength, sizeof(fix), Num_total_object_types, fp );
193 First_multi_bitmap_num = cfile_read_int(fp);
195 Num_reactors = cfile_read_int(fp);
196 reactor_read_n(Reactors, Num_reactors, fp);
198 Marker_model_num = cfile_read_int(fp);
200 //@@cfread( &N_controlcen_guns, sizeof(int), 1, fp );
201 //@@cfread( controlcen_gun_points, sizeof(vms_vector), N_controlcen_guns, fp );
202 //@@cfread( controlcen_gun_dirs, sizeof(vms_vector), N_controlcen_guns, fp );
204 if (Piggy_hamfile_version < 3) {
205 exit_modelnum = cfile_read_int(fp);
206 destroyed_exit_modelnum = cfile_read_int(fp);
209 exit_modelnum = destroyed_exit_modelnum = N_polygon_models;
212 // the following is old code for reading descent 1 textures.
215 #define D1_MAX_TEXTURES 800
216 #define D1_MAX_SOUNDS 250
217 #define D1_MAX_VCLIPS 70
218 #define D1_MAX_EFFECTS 60
219 #define D1_MAX_WALL_ANIMS 30
220 #define D1_MAX_ROBOT_TYPES 30
221 #define D1_MAX_ROBOT_JOINTS 600
222 #define D1_MAX_WEAPON_TYPES 30
223 #define D1_MAX_POWERUP_TYPES 29
224 #define D1_MAX_GAUGE_BMS 80
225 #define D1_MAX_OBJ_BITMAPS 210
226 #define D1_MAX_COCKPIT_BITMAPS 4
227 #define D1_MAX_OBJTYPE 100
228 #define D1_MAX_POLYGON_MODELS 85
230 #define D1_TMAP_INFO_SIZE 26
231 #define D1_VCLIP_SIZE 66
232 #define D1_ROBOT_INFO_SIZE 486
233 #define D1_WEAPON_INFO_SIZE 115
235 #define D1_LAST_STATIC_TMAP_NUM 324
237 // store the Textures[] array as read from the descent 2 pig.
238 short *d2_Textures_backup = NULL;
240 void undo_bm_read_all_d1() {
241 if (d2_Textures_backup) {
243 for (i = 0; i < D1_LAST_STATIC_TMAP_NUM; i++)
244 Textures[i].index = d2_Textures_backup[i];
245 d_free(d2_Textures_backup);
246 d2_Textures_backup = NULL;
251 * used by piggy_d1_init to read in descent 1 pigfile
253 void bm_read_all_d1(CFILE * fp)
257 atexit(undo_bm_read_all_d1);
259 /*NumTextures = */ cfile_read_int(fp);
260 //bitmap_index_read_n(Textures, D1_MAX_TEXTURES, fp );
261 //for (i = 0; i < D1_MAX_TEXTURES; i++)
262 // Textures[i].index = cfile_read_short(fp) + 600;
263 //cfseek(fp, D1_MAX_TEXTURES * sizeof(short), SEEK_CUR);
264 MALLOC(d2_Textures_backup, short, D1_LAST_STATIC_TMAP_NUM);
265 for (i = 0; i < D1_LAST_STATIC_TMAP_NUM; i++) {
266 d2_Textures_backup[i] = Textures[i].index;
267 Textures[i].index = cfile_read_short(fp) + 521;
269 cfseek(fp, (D1_MAX_TEXTURES - D1_LAST_STATIC_TMAP_NUM) * sizeof(short), SEEK_CUR);
271 //tmap_info_read_n_d1(TmapInfo, D1_MAX_TEXTURES, fp);
272 cfseek(fp, D1_MAX_TEXTURES * D1_TMAP_INFO_SIZE, SEEK_CUR);
275 cfread( Sounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
276 cfread( AltSounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
277 */cfseek(fp, D1_MAX_SOUNDS * 2, SEEK_CUR);
279 /*Num_vclips = */ cfile_read_int(fp);
280 //vclip_read_n(Vclip, D1_MAX_VCLIPS, fp);
281 cfseek(fp, D1_MAX_VCLIPS * D1_VCLIP_SIZE, SEEK_CUR);
284 Num_effects = cfile_read_int(fp);
285 eclip_read_n(Effects, D1_MAX_EFFECTS, fp);
287 Num_wall_anims = cfile_read_int(fp);
288 wclip_read_n_d1(WallAnims, D1_MAX_WALL_ANIMS, fp);
292 N_robot_types = cfile_read_int(fp);
293 //robot_info_read_n(Robot_info, D1_MAX_ROBOT_TYPES, fp);
294 cfseek(fp, D1_MAX_ROBOT_TYPES * D1_ROBOT_INFO_SIZE, SEEK_CUR);
296 N_robot_joints = cfile_read_int(fp);
297 jointpos_read_n(Robot_joints, D1_MAX_ROBOT_JOINTS, fp);
299 N_weapon_types = cfile_read_int(fp);
300 //weapon_info_read_n(Weapon_info, D1_MAX_WEAPON_TYPES, fp, Piggy_hamfile_version);
301 cfseek(fp, D1_MAX_WEAPON_TYPES * D1_WEAPON_INFO_SIZE, SEEK_CUR);
303 N_powerup_types = cfile_read_int(fp);
304 powerup_type_info_read_n(Powerup_info, D1_MAX_POWERUP_TYPES, fp);
307 /* in the following code are bugs, solved by hack
308 N_polygon_models = cfile_read_int(fp);
309 polymodel_read_n(Polygon_models, N_polygon_models, fp);
310 for (i=0; i<N_polygon_models; i++ )
311 polygon_model_data_read(&Polygon_models[i], fp);
312 */cfseek(fp, 521490-160, SEEK_SET); // OK, I admit, this is a dirty hack
313 //bitmap_index_read_n(Gauges, D1_MAX_GAUGE_BMS, fp);
314 cfseek(fp, D1_MAX_GAUGE_BMS * sizeof(bitmap_index), SEEK_CUR);
317 for (i = 0; i < D1_MAX_POLYGON_MODELS; i++)
318 Dying_modelnums[i] = cfile_read_int(fp);
319 for (i = 0; i < D1_MAX_POLYGON_MODELS; i++)
320 Dead_modelnums[i] = cfile_read_int(fp);
321 */ cfseek(fp, D1_MAX_POLYGON_MODELS * 8, SEEK_CUR);
323 //bitmap_index_read_n(ObjBitmaps, D1_MAX_OBJ_BITMAPS, fp);
324 cfseek(fp, D1_MAX_OBJ_BITMAPS * sizeof(bitmap_index), SEEK_CUR);
325 for (i = 0; i < D1_MAX_OBJ_BITMAPS; i++)
326 cfseek(fp, 2, SEEK_CUR);//ObjBitmapPtrs[i] = cfile_read_short(fp);
328 //player_ship_read(&only_player_ship, fp);
329 cfseek(fp, sizeof(player_ship), SEEK_CUR);
331 /*Num_cockpits = */ cfile_read_int(fp);
332 //bitmap_index_read_n(cockpit_bitmap, D1_MAX_COCKPIT_BITMAPS, fp);
333 cfseek(fp, D1_MAX_COCKPIT_BITMAPS * sizeof(bitmap_index), SEEK_CUR);
336 cfread( Sounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
337 cfread( AltSounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
338 */cfseek(fp, D1_MAX_SOUNDS * 2, SEEK_CUR);
340 /*Num_total_object_types = */ cfile_read_int( fp );
342 cfread( ObjType, sizeof(byte), D1_MAX_OBJTYPE, fp );
343 cfread( ObjId, sizeof(byte), D1_MAX_OBJTYPE, fp );
344 for (i=0; i<D1_MAX_OBJTYPE; i++ )
345 ObjStrength[i] = cfile_read_int( fp );
346 */ cfseek(fp, D1_MAX_OBJTYPE * 6, SEEK_CUR);
348 /*First_multi_bitmap_num =*/ cfile_read_int(fp);
349 /*Reactors[0].n_guns = */ cfile_read_int( fp );
350 /*for (i=0; i<4; i++)
351 cfile_read_vector(&(Reactors[0].gun_points[i]), fp);
353 cfile_read_vector(&(Reactors[0].gun_dirs[i]), fp);
354 */cfseek(fp, 8 * 12, SEEK_CUR);
356 /*exit_modelnum = */ cfile_read_int(fp);
357 /*destroyed_exit_modelnum = */ cfile_read_int(fp);
360 #endif // if 0, old code for reading descent 1 textures
362 //these values are the number of each item in the release of d2
363 //extra items added after the release get written in an additional hamfile
364 #define N_D2_ROBOT_TYPES 66
365 #define N_D2_ROBOT_JOINTS 1145
366 #define N_D2_POLYGON_MODELS 166
367 #define N_D2_OBJBITMAPS 422
368 #define N_D2_OBJBITMAPPTRS 502
369 #define N_D2_WEAPON_TYPES 62
371 extern int Num_bitmap_files;
372 int extra_bitmap_num = 0;
374 void bm_free_extra_objbitmaps()
378 if (!extra_bitmap_num)
379 extra_bitmap_num = Num_bitmap_files;
381 for (i = Num_bitmap_files; i < extra_bitmap_num; i++)
384 d_free(GameBitmaps[i].bm_data);
386 extra_bitmap_num = Num_bitmap_files;
389 void bm_free_extra_models()
391 while (N_polygon_models > N_D2_POLYGON_MODELS)
392 free_model(&Polygon_models[--N_polygon_models]);
393 while (N_polygon_models > exit_modelnum)
394 free_model(&Polygon_models[--N_polygon_models]);
397 //type==1 means 1.1, type==2 means 1.2 (with weapons)
398 void bm_read_extra_robots(char *fname,int type)
404 fp = cfopen(fname,"rb");
409 sig = cfile_read_int(fp);
410 if (sig != MAKE_SIG('X','H','A','M'))
412 version = cfile_read_int(fp);
417 bm_free_extra_models();
418 bm_free_extra_objbitmaps();
422 t = cfile_read_int(fp);
423 N_weapon_types = N_D2_WEAPON_TYPES+t;
424 if (N_weapon_types >= MAX_WEAPON_TYPES)
425 Error("Too many weapons (%d) in <%s>. Max is %d.",t,fname,MAX_WEAPON_TYPES-N_D2_WEAPON_TYPES);
426 weapon_info_read_n(&Weapon_info[N_D2_WEAPON_TYPES], t, fp, 3);
428 //now read robot info
430 t = cfile_read_int(fp);
431 N_robot_types = N_D2_ROBOT_TYPES+t;
432 if (N_robot_types >= MAX_ROBOT_TYPES)
433 Error("Too many robots (%d) in <%s>. Max is %d.",t,fname,MAX_ROBOT_TYPES-N_D2_ROBOT_TYPES);
434 robot_info_read_n(&Robot_info[N_D2_ROBOT_TYPES], t, fp);
435 for (i = N_D2_ROBOT_TYPES; i < N_robot_types; i++)
436 entity_add(OBJ_ROBOT, i, Robot_names[i]);
438 t = cfile_read_int(fp);
439 N_robot_joints = N_D2_ROBOT_JOINTS+t;
440 if (N_robot_joints >= MAX_ROBOT_JOINTS)
441 Error("Too many robot joints (%d) in <%s>. Max is %d.",t,fname,MAX_ROBOT_JOINTS-N_D2_ROBOT_JOINTS);
442 jointpos_read_n(&Robot_joints[N_D2_ROBOT_JOINTS], t, fp);
444 t = cfile_read_int(fp);
445 N_polygon_models = N_D2_POLYGON_MODELS+t;
446 if (N_polygon_models >= MAX_POLYGON_MODELS)
447 Error("Too many polygon models (%d) in <%s>. Max is %d.",t,fname,MAX_POLYGON_MODELS-N_D2_POLYGON_MODELS);
448 polymodel_read_n(&Polygon_models[N_D2_POLYGON_MODELS], t, fp);
450 for (i=N_D2_POLYGON_MODELS; i<N_polygon_models; i++ )
451 polygon_model_data_read(&Polygon_models[i], fp);
453 for (i = N_D2_POLYGON_MODELS; i < N_polygon_models; i++)
454 Dying_modelnums[i] = cfile_read_int(fp);
455 for (i = N_D2_POLYGON_MODELS; i < N_polygon_models; i++)
456 Dead_modelnums[i] = cfile_read_int(fp);
458 t = cfile_read_int(fp);
459 if (N_D2_OBJBITMAPS+t >= MAX_OBJ_BITMAPS)
460 Error("Too many object bitmaps (%d) in <%s>. Max is %d.",t,fname,MAX_OBJ_BITMAPS-N_D2_OBJBITMAPS);
461 bitmap_index_read_n(&ObjBitmaps[N_D2_OBJBITMAPS], t, fp);
463 t = cfile_read_int(fp);
464 if (N_D2_OBJBITMAPPTRS+t >= MAX_OBJ_BITMAPS)
465 Error("Too many object bitmap pointers (%d) in <%s>. Max is %d.",t,fname,MAX_OBJ_BITMAPS-N_D2_OBJBITMAPPTRS);
466 for (i = N_D2_OBJBITMAPPTRS; i < (N_D2_OBJBITMAPPTRS + t); i++)
467 ObjBitmapPtrs[i] = cfile_read_short(fp);
472 int Robot_replacements_loaded = 0;
474 void load_robot_replacements(char *level_name)
478 char ifile_name[FILENAME_LEN];
480 change_filename_extension(ifile_name, level_name, ".HXM" );
482 fp = cfopen(ifile_name,"rb");
484 if (!fp) //no robot replacement file
487 t = cfile_read_int(fp); //read id "HXM!"
489 Error("ID of HXM! file incorrect");
491 t = cfile_read_int(fp); //read version
493 Error("HXM! version too old (%d)",t);
495 t = cfile_read_int(fp); //read number of robots
497 i = cfile_read_int(fp); //read robot number
498 if (i<0 || i>=N_robot_types)
499 Error("Robots number (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_robot_types-1);
500 robot_info_read_n(&Robot_info[i], 1, fp);
503 t = cfile_read_int(fp); //read number of joints
505 i = cfile_read_int(fp); //read joint number
506 if (i<0 || i>=N_robot_joints)
507 Error("Robots joint (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_robot_joints-1);
508 jointpos_read_n(&Robot_joints[i], 1, fp);
511 t = cfile_read_int(fp); //read number of polygon models
514 i = cfile_read_int(fp); //read model number
515 if (i<0 || i>=N_polygon_models)
516 Error("Polygon model (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_polygon_models-1);
518 free_model(&Polygon_models[i]);
519 polymodel_read(&Polygon_models[i], fp);
520 polygon_model_data_read(&Polygon_models[i], fp);
522 Dying_modelnums[i] = cfile_read_int(fp);
523 Dead_modelnums[i] = cfile_read_int(fp);
526 t = cfile_read_int(fp); //read number of objbitmaps
528 i = cfile_read_int(fp); //read objbitmap number
529 if (i<0 || i>=MAX_OBJ_BITMAPS)
530 Error("Object bitmap number (%d) out of range in (%s). Range = [0..%d].",i,level_name,MAX_OBJ_BITMAPS-1);
531 bitmap_index_read(&ObjBitmaps[i], fp);
534 t = cfile_read_int(fp); //read number of objbitmapptrs
536 i = cfile_read_int(fp); //read objbitmapptr number
537 if (i<0 || i>=MAX_OBJ_BITMAPS)
538 Error("Object bitmap pointer (%d) out of range in (%s). Range = [0..%d].",i,level_name,MAX_OBJ_BITMAPS-1);
539 ObjBitmapPtrs[i] = cfile_read_short(fp);
543 Robot_replacements_loaded = 1;
548 * Routines for loading exit models
550 * Used by d1 levels (including some add-ons), and by d2 shareware.
551 * Could potentially be used by d2 add-on levels, but only if they
552 * don't use "extra" robots...
555 // formerly exitmodel_bm_load_sub
556 bitmap_index read_extra_bitmap_iff( char * filename )
558 bitmap_index bitmap_num;
559 grs_bitmap * new = &GameBitmaps[extra_bitmap_num];
561 int iff_error; //reference parm to avoid warning message
563 bitmap_num.index = 0;
565 //MALLOC( new, grs_bitmap, 1 );
566 iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal);
568 if (iff_error != IFF_NO_ERROR) {
569 con_printf(CON_DEBUG, "Error loading exit model bitmap <%s> - IFF error: %s\n", filename, iff_errormsg(iff_error));
573 if ( iff_has_transparency )
574 gr_remap_bitmap_good( new, newpal, iff_transparent_color, 254 );
576 gr_remap_bitmap_good( new, newpal, -1, 254 );
578 new->avg_color = 0; //compute_average_pixel(new);
580 bitmap_num.index = extra_bitmap_num;
582 GameBitmaps[extra_bitmap_num++] = *new;
588 // formerly load_exit_model_bitmap
589 grs_bitmap *bm_load_extra_objbitmap(char *name)
591 Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
594 ObjBitmaps[N_ObjBitmaps] = read_extra_bitmap_iff(name);
596 if (ObjBitmaps[N_ObjBitmaps].index == 0)
598 char *name2 = d_strdup(name);
599 *strrchr(name2, '.') = '\0';
600 ObjBitmaps[N_ObjBitmaps] = read_extra_bitmap_d1_pig(name2);
603 if (ObjBitmaps[N_ObjBitmaps].index == 0)
606 if (GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_w!=64 || GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_h!=64)
607 Error("Bitmap <%s> is not 64x64",name);
608 ObjBitmapPtrs[N_ObjBitmaps] = N_ObjBitmaps;
610 Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
611 return &GameBitmaps[ObjBitmaps[N_ObjBitmaps-1].index];
616 void ogl_cache_polymodel_textures(int model_num);
619 int load_exit_models()
624 bm_free_extra_models();
625 bm_free_extra_objbitmaps();
627 start_num = N_ObjBitmaps;
628 if (!bm_load_extra_objbitmap("steel1.bbm") ||
629 !bm_load_extra_objbitmap("rbot061.bbm") ||
630 !bm_load_extra_objbitmap("rbot062.bbm") ||
631 !bm_load_extra_objbitmap("steel1.bbm") ||
632 !bm_load_extra_objbitmap("rbot061.bbm") ||
633 !bm_load_extra_objbitmap("rbot063.bbm"))
635 con_printf(CON_NORMAL, "Can't load exit models!\n");
639 exit_hamfile = cfopen("exit.ham","rb");
641 exit_modelnum = N_polygon_models++;
642 destroyed_exit_modelnum = N_polygon_models++;
643 polymodel_read(&Polygon_models[exit_modelnum], exit_hamfile);
644 polymodel_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
645 Polygon_models[exit_modelnum].first_texture = start_num;
646 Polygon_models[destroyed_exit_modelnum].first_texture = start_num+3;
648 polygon_model_data_read(&Polygon_models[exit_modelnum], exit_hamfile);
650 polygon_model_data_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
652 cfclose(exit_hamfile);
654 } else if (cfexist("exit01.pof") && cfexist("exit01d.pof")) {
656 exit_modelnum = load_polygon_model("exit01.pof", 3, start_num, NULL);
657 destroyed_exit_modelnum = load_polygon_model("exit01d.pof", 3, start_num + 3, NULL);
660 ogl_cache_polymodel_textures(exit_modelnum);
661 ogl_cache_polymodel_textures(destroyed_exit_modelnum);
664 else if (cfexist(D1_PIGFILE))
669 exit_hamfile = cfopen(D1_PIGFILE, "rb");
670 hamsize = cfilelength(exit_hamfile);
671 switch (hamsize) { //total hack for loading models
673 offset = 91848; /* and 92582 */
674 offset2 = 383390; /* and 394022 */
677 case D1_SHARE_BIG_PIGSIZE:
678 case D1_SHARE_10_PIGSIZE:
679 case D1_SHARE_PIGSIZE:
680 case D1_10_BIG_PIGSIZE:
682 Int3(); /* exit models should be in .pofs */
685 case D1_MAC_SHARE_PIGSIZE:
686 con_printf(CON_NORMAL, "Can't load exit models!\n");
689 cfseek(exit_hamfile, offset, SEEK_SET);
690 exit_modelnum = N_polygon_models++;
691 destroyed_exit_modelnum = N_polygon_models++;
692 polymodel_read(&Polygon_models[exit_modelnum], exit_hamfile);
693 polymodel_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
694 Polygon_models[exit_modelnum].first_texture = start_num;
695 Polygon_models[destroyed_exit_modelnum].first_texture = start_num+3;
697 cfseek(exit_hamfile, offset2, SEEK_SET);
698 polygon_model_data_read(&Polygon_models[exit_modelnum], exit_hamfile);
699 polygon_model_data_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
701 cfclose(exit_hamfile);
703 con_printf(CON_NORMAL, "Can't load exit models!\n");
707 atexit(bm_free_extra_objbitmaps);