1 /* $Id: bm.c,v 1.47 2004-12-19 12:15:34 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 sbyte ObjType[MAX_OBJTYPE];
67 sbyte 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);
139 //-----------------------------------------------------------------
140 // Read data from piggy.
141 // This is called when the editor is OUT.
142 // If editor is in, bm_init_use_table() is called.
145 init_polygon_models();
146 if (! piggy_init()) // This calls bm_read_all
147 Error("Cannot open pig and/or ham file");
151 init_endlevel(); //this is in bm_init_use_tbl(), so I gues it goes here
156 void bm_read_all(CFILE * fp)
160 NumTextures = cfile_read_int(fp);
161 bitmap_index_read_n(Textures, NumTextures, fp );
162 tmap_info_read_n(TmapInfo, NumTextures, fp);
164 t = cfile_read_int(fp);
165 cfread( Sounds, sizeof(ubyte), t, fp );
166 cfread( AltSounds, sizeof(ubyte), t, fp );
168 Num_vclips = cfile_read_int(fp);
169 vclip_read_n(Vclip, Num_vclips, fp);
171 Num_effects = cfile_read_int(fp);
172 eclip_read_n(Effects, Num_effects, fp);
174 Num_wall_anims = cfile_read_int(fp);
175 wclip_read_n(WallAnims, Num_wall_anims, fp);
177 N_robot_types = cfile_read_int(fp);
178 robot_info_read_n(Robot_info, N_robot_types, fp);
180 N_robot_joints = cfile_read_int(fp);
181 jointpos_read_n(Robot_joints, N_robot_joints, fp);
183 N_weapon_types = cfile_read_int(fp);
184 weapon_info_read_n(Weapon_info, N_weapon_types, fp, Piggy_hamfile_version);
186 N_powerup_types = cfile_read_int(fp);
187 powerup_type_info_read_n(Powerup_info, N_powerup_types, fp);
189 N_polygon_models = cfile_read_int(fp);
190 polymodel_read_n(Polygon_models, N_polygon_models, fp);
192 for (i=0; i<N_polygon_models; i++ )
193 polygon_model_data_read(&Polygon_models[i], fp);
195 for (i = 0; i < N_polygon_models; i++)
196 Dying_modelnums[i] = cfile_read_int(fp);
197 for (i = 0; i < N_polygon_models; i++)
198 Dead_modelnums[i] = cfile_read_int(fp);
200 t = cfile_read_int(fp);
201 bitmap_index_read_n(Gauges, t, fp);
202 bitmap_index_read_n(Gauges_hires, t, fp);
204 N_ObjBitmaps = cfile_read_int(fp);
205 bitmap_index_read_n(ObjBitmaps, N_ObjBitmaps, fp);
206 for (i = 0; i < N_ObjBitmaps; i++)
207 ObjBitmapPtrs[i] = cfile_read_short(fp);
209 player_ship_read(&only_player_ship, fp);
211 Num_cockpits = cfile_read_int(fp);
212 bitmap_index_read_n(cockpit_bitmap, Num_cockpits, fp);
214 //@@ cfread( &Num_total_object_types, sizeof(int), 1, fp );
215 //@@ cfread( ObjType, sizeof(byte), Num_total_object_types, fp );
216 //@@ cfread( ObjId, sizeof(byte), Num_total_object_types, fp );
217 //@@ cfread( ObjStrength, sizeof(fix), Num_total_object_types, fp );
219 First_multi_bitmap_num = cfile_read_int(fp);
221 Num_reactors = cfile_read_int(fp);
222 reactor_read_n(Reactors, Num_reactors, fp);
224 Marker_model_num = cfile_read_int(fp);
226 //@@cfread( &N_controlcen_guns, sizeof(int), 1, fp );
227 //@@cfread( controlcen_gun_points, sizeof(vms_vector), N_controlcen_guns, fp );
228 //@@cfread( controlcen_gun_dirs, sizeof(vms_vector), N_controlcen_guns, fp );
230 if (Piggy_hamfile_version < 3) {
231 exit_modelnum = cfile_read_int(fp);
232 destroyed_exit_modelnum = cfile_read_int(fp);
235 exit_modelnum = destroyed_exit_modelnum = N_polygon_models;
238 // the following is old code for reading descent 1 textures.
241 #define D1_MAX_TEXTURES 800
242 #define D1_MAX_SOUNDS 250
243 #define D1_MAX_VCLIPS 70
244 #define D1_MAX_EFFECTS 60
245 #define D1_MAX_WALL_ANIMS 30
246 #define D1_MAX_ROBOT_TYPES 30
247 #define D1_MAX_ROBOT_JOINTS 600
248 #define D1_MAX_WEAPON_TYPES 30
249 #define D1_MAX_POWERUP_TYPES 29
250 #define D1_MAX_GAUGE_BMS 80
251 #define D1_MAX_OBJ_BITMAPS 210
252 #define D1_MAX_COCKPIT_BITMAPS 4
253 #define D1_MAX_OBJTYPE 100
254 #define D1_MAX_POLYGON_MODELS 85
256 #define D1_TMAP_INFO_SIZE 26
257 #define D1_VCLIP_SIZE 66
258 #define D1_ROBOT_INFO_SIZE 486
259 #define D1_WEAPON_INFO_SIZE 115
261 #define D1_LAST_STATIC_TMAP_NUM 324
263 // store the Textures[] array as read from the descent 2 pig.
264 short *d2_Textures_backup = NULL;
266 void undo_bm_read_all_d1() {
267 if (d2_Textures_backup) {
269 for (i = 0; i < D1_LAST_STATIC_TMAP_NUM; i++)
270 Textures[i].index = d2_Textures_backup[i];
271 d_free(d2_Textures_backup);
272 d2_Textures_backup = NULL;
277 * used by piggy_d1_init to read in descent 1 pigfile
279 void bm_read_all_d1(CFILE * fp)
283 atexit(undo_bm_read_all_d1);
285 /*NumTextures = */ cfile_read_int(fp);
286 //bitmap_index_read_n(Textures, D1_MAX_TEXTURES, fp );
287 //for (i = 0; i < D1_MAX_TEXTURES; i++)
288 // Textures[i].index = cfile_read_short(fp) + 600;
289 //cfseek(fp, D1_MAX_TEXTURES * sizeof(short), SEEK_CUR);
290 MALLOC(d2_Textures_backup, short, D1_LAST_STATIC_TMAP_NUM);
291 for (i = 0; i < D1_LAST_STATIC_TMAP_NUM; i++) {
292 d2_Textures_backup[i] = Textures[i].index;
293 Textures[i].index = cfile_read_short(fp) + 521;
295 cfseek(fp, (D1_MAX_TEXTURES - D1_LAST_STATIC_TMAP_NUM) * sizeof(short), SEEK_CUR);
297 //tmap_info_read_n_d1(TmapInfo, D1_MAX_TEXTURES, fp);
298 cfseek(fp, D1_MAX_TEXTURES * D1_TMAP_INFO_SIZE, SEEK_CUR);
301 cfread( Sounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
302 cfread( AltSounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
303 */cfseek(fp, D1_MAX_SOUNDS * 2, SEEK_CUR);
305 /*Num_vclips = */ cfile_read_int(fp);
306 //vclip_read_n(Vclip, D1_MAX_VCLIPS, fp);
307 cfseek(fp, D1_MAX_VCLIPS * D1_VCLIP_SIZE, SEEK_CUR);
310 Num_effects = cfile_read_int(fp);
311 eclip_read_n(Effects, D1_MAX_EFFECTS, fp);
313 Num_wall_anims = cfile_read_int(fp);
314 wclip_read_n_d1(WallAnims, D1_MAX_WALL_ANIMS, fp);
318 N_robot_types = cfile_read_int(fp);
319 //robot_info_read_n(Robot_info, D1_MAX_ROBOT_TYPES, fp);
320 cfseek(fp, D1_MAX_ROBOT_TYPES * D1_ROBOT_INFO_SIZE, SEEK_CUR);
322 N_robot_joints = cfile_read_int(fp);
323 jointpos_read_n(Robot_joints, D1_MAX_ROBOT_JOINTS, fp);
325 N_weapon_types = cfile_read_int(fp);
326 //weapon_info_read_n(Weapon_info, D1_MAX_WEAPON_TYPES, fp, Piggy_hamfile_version);
327 cfseek(fp, D1_MAX_WEAPON_TYPES * D1_WEAPON_INFO_SIZE, SEEK_CUR);
329 N_powerup_types = cfile_read_int(fp);
330 powerup_type_info_read_n(Powerup_info, D1_MAX_POWERUP_TYPES, fp);
333 /* in the following code are bugs, solved by hack
334 N_polygon_models = cfile_read_int(fp);
335 polymodel_read_n(Polygon_models, N_polygon_models, fp);
336 for (i=0; i<N_polygon_models; i++ )
337 polygon_model_data_read(&Polygon_models[i], fp);
338 */cfseek(fp, 521490-160, SEEK_SET); // OK, I admit, this is a dirty hack
339 //bitmap_index_read_n(Gauges, D1_MAX_GAUGE_BMS, fp);
340 cfseek(fp, D1_MAX_GAUGE_BMS * sizeof(bitmap_index), SEEK_CUR);
343 for (i = 0; i < D1_MAX_POLYGON_MODELS; i++)
344 Dying_modelnums[i] = cfile_read_int(fp);
345 for (i = 0; i < D1_MAX_POLYGON_MODELS; i++)
346 Dead_modelnums[i] = cfile_read_int(fp);
347 */ cfseek(fp, D1_MAX_POLYGON_MODELS * 8, SEEK_CUR);
349 //bitmap_index_read_n(ObjBitmaps, D1_MAX_OBJ_BITMAPS, fp);
350 cfseek(fp, D1_MAX_OBJ_BITMAPS * sizeof(bitmap_index), SEEK_CUR);
351 for (i = 0; i < D1_MAX_OBJ_BITMAPS; i++)
352 cfseek(fp, 2, SEEK_CUR);//ObjBitmapPtrs[i] = cfile_read_short(fp);
354 //player_ship_read(&only_player_ship, fp);
355 cfseek(fp, sizeof(player_ship), SEEK_CUR);
357 /*Num_cockpits = */ cfile_read_int(fp);
358 //bitmap_index_read_n(cockpit_bitmap, D1_MAX_COCKPIT_BITMAPS, fp);
359 cfseek(fp, D1_MAX_COCKPIT_BITMAPS * sizeof(bitmap_index), SEEK_CUR);
362 cfread( Sounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
363 cfread( AltSounds, sizeof(ubyte), D1_MAX_SOUNDS, fp );
364 */cfseek(fp, D1_MAX_SOUNDS * 2, SEEK_CUR);
366 /*Num_total_object_types = */ cfile_read_int( fp );
368 cfread( ObjType, sizeof(byte), D1_MAX_OBJTYPE, fp );
369 cfread( ObjId, sizeof(byte), D1_MAX_OBJTYPE, fp );
370 for (i=0; i<D1_MAX_OBJTYPE; i++ )
371 ObjStrength[i] = cfile_read_int( fp );
372 */ cfseek(fp, D1_MAX_OBJTYPE * 6, SEEK_CUR);
374 /*First_multi_bitmap_num =*/ cfile_read_int(fp);
375 /*Reactors[0].n_guns = */ cfile_read_int( fp );
376 /*for (i=0; i<4; i++)
377 cfile_read_vector(&(Reactors[0].gun_points[i]), fp);
379 cfile_read_vector(&(Reactors[0].gun_dirs[i]), fp);
380 */cfseek(fp, 8 * 12, SEEK_CUR);
382 /*exit_modelnum = */ cfile_read_int(fp);
383 /*destroyed_exit_modelnum = */ cfile_read_int(fp);
386 #endif // if 0, old code for reading descent 1 textures
388 //these values are the number of each item in the release of d2
389 //extra items added after the release get written in an additional hamfile
390 #define N_D2_ROBOT_TYPES 66
391 #define N_D2_ROBOT_JOINTS 1145
392 #define N_D2_POLYGON_MODELS 166
393 #define N_D2_OBJBITMAPS 422
394 #define N_D2_OBJBITMAPPTRS 502
395 #define N_D2_WEAPON_TYPES 62
397 extern int Num_bitmap_files;
398 int extra_bitmap_num = 0;
400 void bm_free_extra_objbitmaps()
404 if (!extra_bitmap_num)
405 extra_bitmap_num = Num_bitmap_files;
407 for (i = Num_bitmap_files; i < extra_bitmap_num; i++)
410 d_free(GameBitmaps[i].bm_data);
412 extra_bitmap_num = Num_bitmap_files;
415 void bm_free_extra_models()
417 while (N_polygon_models > N_D2_POLYGON_MODELS)
418 free_model(&Polygon_models[--N_polygon_models]);
419 while (N_polygon_models > exit_modelnum)
420 free_model(&Polygon_models[--N_polygon_models]);
423 //type==1 means 1.1, type==2 means 1.2 (with weapons)
424 void bm_read_extra_robots(char *fname,int type)
430 fp = cfopen(fname,"rb");
435 sig = cfile_read_int(fp);
436 if (sig != MAKE_SIG('X','H','A','M'))
438 version = cfile_read_int(fp);
443 bm_free_extra_models();
444 bm_free_extra_objbitmaps();
448 t = cfile_read_int(fp);
449 N_weapon_types = N_D2_WEAPON_TYPES+t;
450 if (N_weapon_types >= MAX_WEAPON_TYPES)
451 Error("Too many weapons (%d) in <%s>. Max is %d.",t,fname,MAX_WEAPON_TYPES-N_D2_WEAPON_TYPES);
452 weapon_info_read_n(&Weapon_info[N_D2_WEAPON_TYPES], t, fp, 3);
454 //now read robot info
456 t = cfile_read_int(fp);
457 N_robot_types = N_D2_ROBOT_TYPES+t;
458 if (N_robot_types >= MAX_ROBOT_TYPES)
459 Error("Too many robots (%d) in <%s>. Max is %d.",t,fname,MAX_ROBOT_TYPES-N_D2_ROBOT_TYPES);
460 robot_info_read_n(&Robot_info[N_D2_ROBOT_TYPES], t, fp);
462 t = cfile_read_int(fp);
463 N_robot_joints = N_D2_ROBOT_JOINTS+t;
464 if (N_robot_joints >= MAX_ROBOT_JOINTS)
465 Error("Too many robot joints (%d) in <%s>. Max is %d.",t,fname,MAX_ROBOT_JOINTS-N_D2_ROBOT_JOINTS);
466 jointpos_read_n(&Robot_joints[N_D2_ROBOT_JOINTS], t, fp);
468 t = cfile_read_int(fp);
469 N_polygon_models = N_D2_POLYGON_MODELS+t;
470 if (N_polygon_models >= MAX_POLYGON_MODELS)
471 Error("Too many polygon models (%d) in <%s>. Max is %d.",t,fname,MAX_POLYGON_MODELS-N_D2_POLYGON_MODELS);
472 polymodel_read_n(&Polygon_models[N_D2_POLYGON_MODELS], t, fp);
474 for (i=N_D2_POLYGON_MODELS; i<N_polygon_models; i++ )
475 polygon_model_data_read(&Polygon_models[i], fp);
477 for (i = N_D2_POLYGON_MODELS; i < N_polygon_models; i++)
478 Dying_modelnums[i] = cfile_read_int(fp);
479 for (i = N_D2_POLYGON_MODELS; i < N_polygon_models; i++)
480 Dead_modelnums[i] = cfile_read_int(fp);
482 t = cfile_read_int(fp);
483 if (N_D2_OBJBITMAPS+t >= MAX_OBJ_BITMAPS)
484 Error("Too many object bitmaps (%d) in <%s>. Max is %d.",t,fname,MAX_OBJ_BITMAPS-N_D2_OBJBITMAPS);
485 bitmap_index_read_n(&ObjBitmaps[N_D2_OBJBITMAPS], t, fp);
487 t = cfile_read_int(fp);
488 if (N_D2_OBJBITMAPPTRS+t >= MAX_OBJ_BITMAPS)
489 Error("Too many object bitmap pointers (%d) in <%s>. Max is %d.",t,fname,MAX_OBJ_BITMAPS-N_D2_OBJBITMAPPTRS);
490 for (i = N_D2_OBJBITMAPPTRS; i < (N_D2_OBJBITMAPPTRS + t); i++)
491 ObjBitmapPtrs[i] = cfile_read_short(fp);
496 extern void change_filename_extension( char *dest, char *src, char *new_ext );
498 int Robot_replacements_loaded = 0;
500 void load_robot_replacements(char *level_name)
504 char ifile_name[FILENAME_LEN];
506 change_filename_extension(ifile_name, level_name, ".HXM" );
508 fp = cfopen(ifile_name,"rb");
510 if (!fp) //no robot replacement file
513 t = cfile_read_int(fp); //read id "HXM!"
515 Error("ID of HXM! file incorrect");
517 t = cfile_read_int(fp); //read version
519 Error("HXM! version too old (%d)",t);
521 t = cfile_read_int(fp); //read number of robots
523 i = cfile_read_int(fp); //read robot number
524 if (i<0 || i>=N_robot_types)
525 Error("Robots number (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_robot_types-1);
526 robot_info_read_n(&Robot_info[i], 1, fp);
529 t = cfile_read_int(fp); //read number of joints
531 i = cfile_read_int(fp); //read joint number
532 if (i<0 || i>=N_robot_joints)
533 Error("Robots joint (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_robot_joints-1);
534 jointpos_read_n(&Robot_joints[i], 1, fp);
537 t = cfile_read_int(fp); //read number of polygon models
540 i = cfile_read_int(fp); //read model number
541 if (i<0 || i>=N_polygon_models)
542 Error("Polygon model (%d) out of range in (%s). Range = [0..%d].",i,level_name,N_polygon_models-1);
544 free_model(&Polygon_models[i]);
545 polymodel_read(&Polygon_models[i], fp);
546 polygon_model_data_read(&Polygon_models[i], fp);
548 Dying_modelnums[i] = cfile_read_int(fp);
549 Dead_modelnums[i] = cfile_read_int(fp);
552 t = cfile_read_int(fp); //read number of objbitmaps
554 i = cfile_read_int(fp); //read objbitmap number
555 if (i<0 || i>=MAX_OBJ_BITMAPS)
556 Error("Object bitmap number (%d) out of range in (%s). Range = [0..%d].",i,level_name,MAX_OBJ_BITMAPS-1);
557 bitmap_index_read(&ObjBitmaps[i], fp);
560 t = cfile_read_int(fp); //read number of objbitmapptrs
562 i = cfile_read_int(fp); //read objbitmapptr number
563 if (i<0 || i>=MAX_OBJ_BITMAPS)
564 Error("Object bitmap pointer (%d) out of range in (%s). Range = [0..%d].",i,level_name,MAX_OBJ_BITMAPS-1);
565 ObjBitmapPtrs[i] = cfile_read_short(fp);
569 Robot_replacements_loaded = 1;
574 * Routines for loading exit models
576 * Used by d1 levels (including some add-ons), and by d2 shareware.
577 * Could potentially be used by d2 add-on levels, but only if they
578 * don't use "extra" robots...
581 // formerly exitmodel_bm_load_sub
582 bitmap_index read_extra_bitmap_iff( char * filename )
584 bitmap_index bitmap_num;
585 grs_bitmap * new = &GameBitmaps[extra_bitmap_num];
587 int iff_error; //reference parm to avoid warning message
589 bitmap_num.index = 0;
591 //MALLOC( new, grs_bitmap, 1 );
592 iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal);
594 if (iff_error != IFF_NO_ERROR) {
595 con_printf(CON_DEBUG, "Error loading exit model bitmap <%s> - IFF error: %s\n", filename, iff_errormsg(iff_error));
599 if ( iff_has_transparency )
600 gr_remap_bitmap_good( new, newpal, iff_transparent_color, 254 );
602 gr_remap_bitmap_good( new, newpal, -1, 254 );
604 new->avg_color = 0; //compute_average_pixel(new);
606 bitmap_num.index = extra_bitmap_num;
608 GameBitmaps[extra_bitmap_num++] = *new;
614 // formerly load_exit_model_bitmap
615 grs_bitmap *bm_load_extra_objbitmap(char *name)
617 Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
620 ObjBitmaps[N_ObjBitmaps] = read_extra_bitmap_iff(name);
622 if (ObjBitmaps[N_ObjBitmaps].index == 0)
624 char *name2 = d_strdup(name);
625 *strrchr(name2, '.') = '\0';
626 ObjBitmaps[N_ObjBitmaps] = read_extra_bitmap_d1_pig(name2);
629 if (ObjBitmaps[N_ObjBitmaps].index == 0)
632 if (GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_w!=64 || GameBitmaps[ObjBitmaps[N_ObjBitmaps].index].bm_h!=64)
633 Error("Bitmap <%s> is not 64x64",name);
634 ObjBitmapPtrs[N_ObjBitmaps] = N_ObjBitmaps;
636 Assert(N_ObjBitmaps < MAX_OBJ_BITMAPS);
637 return &GameBitmaps[ObjBitmaps[N_ObjBitmaps-1].index];
642 void ogl_cache_polymodel_textures(int model_num);
645 int load_exit_models()
650 bm_free_extra_models();
651 bm_free_extra_objbitmaps();
653 start_num = N_ObjBitmaps;
654 if (!bm_load_extra_objbitmap("steel1.bbm") ||
655 !bm_load_extra_objbitmap("rbot061.bbm") ||
656 !bm_load_extra_objbitmap("rbot062.bbm") ||
657 !bm_load_extra_objbitmap("steel1.bbm") ||
658 !bm_load_extra_objbitmap("rbot061.bbm") ||
659 !bm_load_extra_objbitmap("rbot063.bbm"))
661 con_printf(CON_NORMAL, "Can't load exit models!\n");
666 exit_hamfile = cfopen("exit.ham","rb");
668 exit_hamfile = cfopen(":Data:exit.ham","rb");
671 exit_modelnum = N_polygon_models++;
672 destroyed_exit_modelnum = N_polygon_models++;
673 polymodel_read(&Polygon_models[exit_modelnum], exit_hamfile);
674 polymodel_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
675 Polygon_models[exit_modelnum].first_texture = start_num;
676 Polygon_models[destroyed_exit_modelnum].first_texture = start_num+3;
678 polygon_model_data_read(&Polygon_models[exit_modelnum], exit_hamfile);
680 polygon_model_data_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
682 cfclose(exit_hamfile);
684 } else if (cfexist("exit01.pof") && cfexist("exit01d.pof")) {
686 exit_modelnum = load_polygon_model("exit01.pof", 3, start_num, NULL);
687 destroyed_exit_modelnum = load_polygon_model("exit01d.pof", 3, start_num + 3, NULL);
690 ogl_cache_polymodel_textures(exit_modelnum);
691 ogl_cache_polymodel_textures(destroyed_exit_modelnum);
694 else if (cfexist(D1_PIGFILE))
699 exit_hamfile = cfopen(D1_PIGFILE, "rb");
700 hamsize = cfilelength(exit_hamfile);
701 switch (hamsize) { //total hack for loading models
703 offset = 91848; /* and 92582 */
704 offset2 = 383390; /* and 394022 */
707 case D1_SHARE_BIG_PIGSIZE:
708 case D1_SHARE_10_PIGSIZE:
709 case D1_SHARE_PIGSIZE:
710 case D1_10_BIG_PIGSIZE:
712 Int3(); /* exit models should be in .pofs */
715 case D1_MAC_SHARE_PIGSIZE:
716 con_printf(CON_NORMAL, "Can't load exit models!\n");
719 cfseek(exit_hamfile, offset, SEEK_SET);
720 exit_modelnum = N_polygon_models++;
721 destroyed_exit_modelnum = N_polygon_models++;
722 polymodel_read(&Polygon_models[exit_modelnum], exit_hamfile);
723 polymodel_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
724 Polygon_models[exit_modelnum].first_texture = start_num;
725 Polygon_models[destroyed_exit_modelnum].first_texture = start_num+3;
727 cfseek(exit_hamfile, offset2, SEEK_SET);
728 polygon_model_data_read(&Polygon_models[exit_modelnum], exit_hamfile);
729 polygon_model_data_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
731 cfclose(exit_hamfile);
733 con_printf(CON_NORMAL, "Can't load exit models!\n");
737 atexit(bm_free_extra_objbitmaps);