ability to load exit models from d1 pig file
authorBradley Bell <btb@icculus.org>
Tue, 25 Mar 2003 09:54:12 +0000 (09:54 +0000)
committerBradley Bell <btb@icculus.org>
Tue, 25 Mar 2003 09:54:12 +0000 (09:54 +0000)
ChangeLog
main/bm.c
main/piggy.c
main/piggy.h

index 1c1961f..1d2ea09 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2003-03-25  Bradley Bell  <btb@icculus.org>
 
+       * main/bm.c, main/piggy.c, main/piggy.h: ability to load exit
+       models from d1 pig file
+
        * main/bm.c, main/bm.h, main/endlevel.c, main/piggy.c,
        main/piggy.h: ability to load exit model bitmaps (or any bitmap,
        really) from d1 pig file
index c3a0d21..a2b1072 100644 (file)
--- a/main/bm.c
+++ b/main/bm.c
@@ -1,4 +1,4 @@
-/* $Id: bm.c,v 1.27 2003-03-25 08:19:12 btb Exp $ */
+/* $Id: bm.c,v 1.28 2003-03-25 09:54:12 btb Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -272,7 +272,40 @@ int load_exit_models()
                ogl_cache_polymodel_textures(exit_modelnum);
                ogl_cache_polymodel_textures(destroyed_exit_modelnum);
 #endif
+       }
+       else if (cfexist("descent.pig"))
+       {
+               int offset, offset2;
+
+               exit_hamfile = cfopen("descent.pig", "rb");
+               switch (cfilelength(exit_hamfile)) { //total hack for loading models
+               case D1_PIGSIZE:
+                       offset = 91848;     /* and 92582  */
+                       offset2 = 383390;   /* and 394022 */
+                       break;
+               default:
+                       Int3();
+               case D1_SHAREWARE_10_PIGSIZE:
+               case D1_SHAREWARE_PIGSIZE:
+                       Int3();             /* exit models should be in .pofs */
+               case D1_OEM_PIGSIZE:
+               case D1_MAC_PIGSIZE:
+               case D1_MAC_SHARE_PIGSIZE:
+                       Warning("Can't load exit models!\n");
+                       return 0;
+                       break;
+               }
+               cfseek(exit_hamfile, offset, SEEK_SET);
+               polymodel_read(&Polygon_models[exit_modelnum], exit_hamfile);
+               polymodel_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
+               Polygon_models[exit_modelnum].first_texture = start_num;
+               Polygon_models[destroyed_exit_modelnum].first_texture = start_num+3;
 
+               cfseek(exit_hamfile, offset2, SEEK_SET);
+               polygon_model_data_read(&Polygon_models[exit_modelnum], exit_hamfile);
+               polygon_model_data_read(&Polygon_models[destroyed_exit_modelnum], exit_hamfile);
+
+               cfclose(exit_hamfile);
        } else {
                Warning("Can't load exit models!\n");
                return 0;
index 4e5d75c..85c9844 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: piggy.c,v 1.27 2003-03-25 08:19:12 btb Exp $ */
+/* $Id: piggy.c,v 1.28 2003-03-25 09:54:12 btb Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -386,7 +386,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 #endif
 
 #ifdef RCS
-static char rcsid[] = "$Id: piggy.c,v 1.27 2003-03-25 08:19:12 btb Exp $";
+static char rcsid[] = "$Id: piggy.c,v 1.28 2003-03-25 09:54:12 btb Exp $";
 #endif
 
 
@@ -441,19 +441,6 @@ static char rcsid[] = "$Id: piggy.c,v 1.27 2003-03-25 08:19:12 btb Exp $";
 #define DEFAULT_HAMFILE (cfexist(DEFAULT_HAMFILE_REGISTERED)?DEFAULT_HAMFILE_REGISTERED:DEFAULT_HAMFILE_SHAREWARE)
 #define DEFAULT_SNDFILE ((Piggy_hamfile_version < 3)?DEFAULT_HAMFILE_SHAREWARE:(digi_sample_rate==SAMPLE_RATE_22K)?"descent2.s22":"descent2.s11")
 
-#define D1_SHAREWARE_10_PIGSIZE 2529454 // v1.0 - 1.2
-#define D1_SHAREWARE_PIGSIZE    2509799 // v1.4
-#define D1_PIGSIZE              4920305
-#define D1_OEM_PIGSIZE          5039735 // Destination: Saturn
-#define D1_MAC_PIGSIZE          3975533
-#define D1_MAC_SHARE_PIGSIZE    2714487
-#define MAC_ALIEN1_PIGSIZE      5013035
-#define MAC_ALIEN2_PIGSIZE      4909916
-#define MAC_FIRE_PIGSIZE        4969035
-#define MAC_GROUPA_PIGSIZE      4929684 // also used for mac shareware
-#define MAC_ICE_PIGSIZE         4923425
-#define MAC_WATER_PIGSIZE       4832403
-
 ubyte *BitmapBits = NULL;
 ubyte *SoundBits = NULL;
 
@@ -2284,15 +2271,24 @@ void load_d1_bitmap_replacements()
                colormap[255] = 255;
        }
 
-
-       if (0) //TODO: put here cfilelength(d1_Piggy_fp) == D1_PIG_SHARE
+       switch (cfilelength(d1_Piggy_fp)) {
+       case D1_SHAREWARE_10_PIGSIZE:
+       case D1_SHAREWARE_PIGSIZE:
                pig_data_start = 0;
-       else {
+               break;
+       default:
+               Int3();
+       case D1_PIGSIZE:
+       case D1_OEM_PIGSIZE:
+       case D1_MAC_PIGSIZE:
+       case D1_MAC_SHARE_PIGSIZE:
                //int i;
                pig_data_start = cfile_read_int(d1_Piggy_fp );
                bm_read_all_d1( d1_Piggy_fp );
                //for (i = 0; i < 1800; i++) GameBitmapXlat[i] = cfile_read_short(d1_Piggy_fp);
+               break;
        }
+
        cfseek( d1_Piggy_fp, pig_data_start, SEEK_SET );
        N_bitmaps = cfile_read_int(d1_Piggy_fp);
        {
@@ -2409,7 +2405,21 @@ bitmap_index read_extra_d1_bitmap(char *name)
                        colormap[255] = 255;
                }
 
-               pig_data_start = cfile_read_int(d1_Piggy_fp);
+               switch (cfilelength(d1_Piggy_fp)) {
+               case D1_SHAREWARE_10_PIGSIZE:
+               case D1_SHAREWARE_PIGSIZE:
+                       pig_data_start = 0;
+                       break;
+               default:
+                       Int3();
+               case D1_PIGSIZE:
+               case D1_OEM_PIGSIZE:
+               case D1_MAC_PIGSIZE:
+               case D1_MAC_SHARE_PIGSIZE:
+                       pig_data_start = cfile_read_int(d1_Piggy_fp);
+                       break;
+               }
+
                cfseek(d1_Piggy_fp, pig_data_start, SEEK_SET);
                N_bitmaps = cfile_read_int(d1_Piggy_fp);
                {
index f5ca733..d7e56c7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: piggy.h,v 1.13 2003-03-25 08:19:12 btb Exp $ */
+/* $Id: piggy.h,v 1.14 2003-03-25 09:54:12 btb Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -20,6 +20,19 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 #include "inferno.h"
 #include "cfile.h"
 
+#define D1_SHAREWARE_10_PIGSIZE 2529454 // v1.0 - 1.2
+#define D1_SHAREWARE_PIGSIZE    2509799 // v1.4
+#define D1_PIGSIZE              4920305
+#define D1_OEM_PIGSIZE          5039735 // Destination: Saturn
+#define D1_MAC_PIGSIZE          3975533
+#define D1_MAC_SHARE_PIGSIZE    2714487
+#define MAC_ALIEN1_PIGSIZE      5013035
+#define MAC_ALIEN2_PIGSIZE      4909916
+#define MAC_FIRE_PIGSIZE        4969035
+#define MAC_GROUPA_PIGSIZE      4929684 // also used for mac shareware
+#define MAC_ICE_PIGSIZE         4923425
+#define MAC_WATER_PIGSIZE       4832403
+
 #define MAX_ALIASES 20
 
 typedef struct alias {