use hardcoded value instead of sizeof(tmap_info), since size depends on whether edito...
[btb/d2x.git] / main / bm.c
index 07174e3..2818160 100644 (file)
--- a/main/bm.c
+++ b/main/bm.c
@@ -1,4 +1,4 @@
-/* $Id: bm.c,v 1.34 2003-08-03 22:00:14 btb Exp $ */
+/* $Id: bm.c,v 1.48 2005-03-16 23:06:14 btb Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -16,23 +16,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  *
  * Bitmap and palette loading functions.
  *
- * Old Log:
- * Revision 1.1  1995/05/16  15:23:08  allender
- * Initial revision
- *
- * Revision 2.3  1995/03/14  16:22:04  john
- * Added cdrom alternate directory stuff.
- *
- * Revision 2.2  1995/03/07  16:51:48  john
- * Fixed robots not moving without edtiro bug.
- *
- * Revision 2.1  1995/03/06  15:23:06  john
- * New screen techniques.
- *
- * Revision 2.0  1995/02/27  11:27:05  john
- * New version 2.0, which has no anonymous unions, builds with
- * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
- *
  */
 
 #ifdef HAVE_CONFIG_H
@@ -80,8 +63,8 @@ ubyte AltSounds[MAX_SOUNDS];
 
 #ifdef EDITOR
 int Num_total_object_types;
-byte   ObjType[MAX_OBJTYPE];
-byte   ObjId[MAX_OBJTYPE];
+sbyte ObjType[MAX_OBJTYPE];
+sbyte ObjId[MAX_OBJTYPE];
 fix    ObjStrength[MAX_OBJTYPE];
 #endif
 
@@ -113,7 +96,7 @@ bitmap_index    ObjBitmaps[MAX_OBJ_BITMAPS];
 ushort          ObjBitmapPtrs[MAX_OBJ_BITMAPS];     // These point back into ObjBitmaps, since some are used twice.
 
 #ifdef FAST_FILE_IO
-#define tmap_info_read_n(ti, n, fp) cfread(ti, sizeof(tmap_info), n, fp)
+#define tmap_info_read_n(ti, n, fp) cfread(ti, TMAP_INFO_SIZE, n, fp)
 #else
 /*
  * reads n tmap_info structs from a CFILE
@@ -252,29 +235,6 @@ void bm_read_all(CFILE * fp)
                exit_modelnum = destroyed_exit_modelnum = N_polygon_models;
 }
 
-/* when reading descent.pig of descent 1, we only replace some textures */
-
-#define D1_MAX_TEXTURES 800
-
-short *d1_Texture_indices = NULL; // descent 1 texture bitmap indicies
-
-void free_d1_texture_indices() {
-       if (d1_Texture_indices) {
-               d_free(d1_Texture_indices);
-               d1_Texture_indices = NULL;
-       }
-}
-
-void bm_read_d1_texture_indices(CFILE *d1pig)
-{
-       int i;
-       atexit(free_d1_texture_indices);
-       cfseek(d1pig, 8, SEEK_SET);
-       MALLOC(d1_Texture_indices, short, D1_MAX_TEXTURES);
-       for (i = 0; i < D1_MAX_TEXTURES; i++)
-               d1_Texture_indices[i] = cfile_read_short(d1pig);
-}
-
 // the following is old code for reading descent 1 textures.
 #if 0
 
@@ -580,9 +540,9 @@ void load_robot_replacements(char *level_name)
                i = cfile_read_int(fp);         //read model number
                if (i<0 || i>=N_polygon_models)
                        Error("Polygon model (%d) out of range in (%s).  Range = [0..%d].",i,level_name,N_polygon_models-1);
-               polymodel_read(&Polygon_models[i], fp);
 
                free_model(&Polygon_models[i]);
+               polymodel_read(&Polygon_models[i], fp);
                polygon_model_data_read(&Polygon_models[i], fp);
 
                Dying_modelnums[i] = cfile_read_int(fp);
@@ -606,6 +566,7 @@ void load_robot_replacements(char *level_name)
        }
 
        cfclose(fp);
+       Robot_replacements_loaded = 1;
 }
 
 
@@ -733,16 +694,21 @@ int load_exit_models()
        else if (cfexist(D1_PIGFILE))
        {
                int offset, offset2;
+               int hamsize;
 
                exit_hamfile = cfopen(D1_PIGFILE, "rb");
-               switch (cfilelength(exit_hamfile)) { //total hack for loading models
+               hamsize = cfilelength(exit_hamfile);
+               switch (hamsize) { //total hack for loading models
                case D1_PIGSIZE:
                        offset = 91848;     /* and 92582  */
                        offset2 = 383390;   /* and 394022 */
                        break;
                default:
-               case D1_SHAREWARE_10_PIGSIZE:
-               case D1_SHAREWARE_PIGSIZE:
+               case D1_SHARE_BIG_PIGSIZE:
+               case D1_SHARE_10_PIGSIZE:
+               case D1_SHARE_PIGSIZE:
+               case D1_10_BIG_PIGSIZE:
+               case D1_10_PIGSIZE:
                        Int3();             /* exit models should be in .pofs */
                case D1_OEM_PIGSIZE:
                case D1_MAC_PIGSIZE: