This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
*/
-// upper design bounds
-
#define MAX_MAP_HULLS 4
-
-#define MAX_MAP_MODELS 256
-#define MAX_MAP_BRUSHES 4096
-#define MAX_MAP_ENTITIES 1024
-#define MAX_MAP_ENTSTRING 65536
-
-#define MAX_MAP_PLANES 32767
-#define MAX_MAP_NODES 32767 // because negative shorts are contents
-#define MAX_MAP_CLIPNODES 32767 //
-#define MAX_MAP_LEAFS 32767 // was 8192
-#define MAX_MAP_VERTS 65535
-#define MAX_MAP_FACES 65535
-#define MAX_MAP_MARKSURFACES 65535
-#define MAX_MAP_TEXINFO 4096
-#define MAX_MAP_EDGES 256000
-#define MAX_MAP_SURFEDGES 512000
-#define MAX_MAP_TEXTURES 512
-#define MAX_MAP_MIPTEX 0x200000
-#define MAX_MAP_LIGHTING 0x100000
-#define MAX_MAP_VISIBILITY 0x100000
-
-#define MAX_MAP_PORTALS 65536
+#define MAX_MAP_LEAFS 65536 // was 8192
// key / value pair sizes
#define LUMP_EDGES 12
#define LUMP_SURFEDGES 13
#define LUMP_MODELS 14
-
#define HEADER_LUMPS 15
typedef struct
typedef struct
{
- int version;
+ int version;
lump_t lumps[HEADER_LUMPS];
} dheader_t;
} dclipnode_t;
-typedef struct texinfo_s
+typedef struct
{
float vecs[2][4]; // [s/t][xyz offset]
int miptex;
#define MAXLIGHTMAPS 4
typedef struct
{
- short planenum;
+ // LordHavoc: changed from short to unsigned short for q2 support
+ unsigned short planenum;
short side;
int firstedge; // we must support > 64k edges
- short numedges;
+ short numedges;
short texinfo;
// lighting info
qbyte ambient_level[NUM_AMBIENTS];
} dleaf_t;
-
-//============================================================================
-
-#ifndef QUAKE_GAME
-
-#define ANGLE_UP -1
-#define ANGLE_DOWN -2
-
-
-// the utilities get to be lazy and just use large static arrays
-
-extern int nummodels;
-extern dmodel_t dmodels[MAX_MAP_MODELS];
-
-extern int visdatasize;
-extern qbyte dvisdata[MAX_MAP_VISIBILITY];
-
-extern int lightdatasize;
-extern qbyte dlightdata[MAX_MAP_LIGHTING];
-
-extern int texdatasize;
-extern qbyte dtexdata[MAX_MAP_MIPTEX]; // (dmiptexlump_t)
-
-extern int entdatasize;
-extern char dentdata[MAX_MAP_ENTSTRING];
-
-extern int numleafs;
-extern dleaf_t dleafs[MAX_MAP_LEAFS];
-
-extern int numplanes;
-extern dplane_t dplanes[MAX_MAP_PLANES];
-
-extern int numvertexes;
-extern dvertex_t dvertexes[MAX_MAP_VERTS];
-
-extern int numnodes;
-extern dnode_t dnodes[MAX_MAP_NODES];
-
-extern int numtexinfo;
-extern texinfo_t texinfo[MAX_MAP_TEXINFO];
-
-extern int numfaces;
-extern dface_t dfaces[MAX_MAP_FACES];
-
-extern int numclipnodes;
-extern dclipnode_t dclipnodes[MAX_MAP_CLIPNODES];
-
-extern int numedges;
-extern dedge_t dedges[MAX_MAP_EDGES];
-
-extern int nummarksurfaces;
-extern unsigned short dmarksurfaces[MAX_MAP_MARKSURFACES];
-
-extern int numsurfedges;
-extern int dsurfedges[MAX_MAP_SURFEDGES];
-
-
-void DecompressVis (qbyte *in, qbyte *decompressed);
-int CompressVis (qbyte *vis, qbyte *dest);
-
-void LoadBSPFile (char *filename);
-void WriteBSPFile (char *filename);
-void PrintBSPFileSizes (void);
-
-//===============
-
-
-typedef struct epair_s
-{
- struct epair_s *next;
- char *key;
- char *value;
-} epair_t;
-
-typedef struct
-{
- vec3_t origin;
- int firstbrush;
- int numbrushes;
- epair_t *epairs;
-} entity_t;
-
-extern entity_t entities[MAX_MAP_ENTITIES];
-
-void ParseEntities (void);
-void UnparseEntities (void);
-
-void SetKeyValue (entity_t *ent, char *key, char *value);
-char *ValueForKey (entity_t *ent, char *key);
-// will return "" if not present
-
-vec_t FloatForKey (entity_t *ent, char *key);
-void GetVectorForKey (entity_t *ent, char *key, vec3_t vec);
-
-epair_t *ParseEpair (void);
-
-#endif
-
//Mod_ProcessLightList ();
}
+static void Mod_Q2LoadEntities (lump_t *l)
+{
+}
+
+static void Mod_Q2LoadPlanes (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadVertices (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadVisibility (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadNodes (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadTexInfo (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadFaces (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadLighting (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadLeafs (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadLeafFaces (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadLeafBrushes (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadEdges (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadSurfEdges (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadBrushes (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadBrushSides (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadAreas (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadAreaPortals (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
+static void Mod_Q2LoadModels (lump_t *l)
+{
+/*
+ d_t *in;
+ m_t *out;
+ int i, count;
+
+ in = (void *)(mod_base + l->fileofs);
+ if (l->filelen % sizeof(*in))
+ Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
+ count = l->filelen / sizeof(*in);
+ out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out));
+
+ loadmodel-> = out;
+ loadmodel->num = count;
+
+ for (i = 0;i < count;i++, in++, out++)
+ {
+ }
+*/
+}
+
void Mod_LoadBrushModelQ2 (model_t *mod, void *buffer)
{
- Host_Error("Mod_LoadBrushModelQ2: not yet implemented\n");
+ int i;
+ q2dheader_t *header;
+
+ mod->type = mod_brushq2;
+
+ header = (q2dheader_t *)buffer;
+
+ i = LittleLong (header->version);
+ if (i != Q2BSPVERSION)
+ Host_Error ("Mod_LoadBrushModelQ2: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION);
+ mod->ishlbsp = false;
+ if (loadmodel->isworldmodel)
+ {
+ Cvar_SetValue("halflifebsp", mod->ishlbsp);
+ // until we get a texture for it...
+ R_ResetQuakeSky();
+ }
+
+ mod_base = (qbyte *)header;
+
+ // swap all the lumps
+ for (i = 0;i < (int) sizeof(dheader_t) / 4;i++)
+ ((int *)header)[i] = LittleLong ( ((int *)header)[i]);
+
+ // store which lightmap format to use
+ mod->lightmaprgba = r_lightmaprgba.integer;
+
+ Mod_Q2LoadEntities(&header->lumps[Q2LUMP_ENTITIES]);
+ Mod_Q2LoadPlanes(&header->lumps[Q2LUMP_PLANES]);
+ Mod_Q2LoadVertices(&header->lumps[Q2LUMP_VERTEXES]);
+ Mod_Q2LoadVisibility(&header->lumps[Q2LUMP_VISIBILITY]);
+ Mod_Q2LoadNodes(&header->lumps[Q2LUMP_NODES]);
+ Mod_Q2LoadTexInfo(&header->lumps[Q2LUMP_TEXINFO]);
+ Mod_Q2LoadFaces(&header->lumps[Q2LUMP_FACES]);
+ Mod_Q2LoadLighting(&header->lumps[Q2LUMP_LIGHTING]);
+ Mod_Q2LoadLeafs(&header->lumps[Q2LUMP_LEAFS]);
+ Mod_Q2LoadLeafFaces(&header->lumps[Q2LUMP_LEAFFACES]);
+ Mod_Q2LoadLeafBrushes(&header->lumps[Q2LUMP_LEAFBRUSHES]);
+ Mod_Q2LoadEdges(&header->lumps[Q2LUMP_EDGES]);
+ Mod_Q2LoadSurfEdges(&header->lumps[Q2LUMP_SURFEDGES]);
+ Mod_Q2LoadBrushes(&header->lumps[Q2LUMP_BRUSHES]);
+ Mod_Q2LoadBrushSides(&header->lumps[Q2LUMP_BRUSHSIDES]);
+ Mod_Q2LoadAreas(&header->lumps[Q2LUMP_AREAS]);
+ Mod_Q2LoadAreaPortals(&header->lumps[Q2LUMP_AREAPORTALS]);
+ // LordHavoc: must go last because this makes the submodels
+ Mod_Q2LoadModels(&header->lumps[Q2LUMP_MODELS]);
}
void Mod_LoadBrushModelQ3 (model_t *mod, void *buffer)