renders: Add autodetect Daikatana maps bsp format

This commit is contained in:
Denis Pauk 2024-04-01 01:19:57 +03:00
parent 2c0fca8458
commit f54aea1361
12 changed files with 351 additions and 54 deletions

View file

@ -960,6 +960,56 @@ Mod_LoadLeafs(const char *name, mleaf_t **leafs, int *numleafs,
}
}
static void
Mod_LoadDKLeafs(const char *name, mleaf_t **leafs, int *numleafs,
msurface_t **marksurfaces, unsigned int nummarksurfaces,
const byte *mod_base, const lump_t *l)
{
ddkleaf_t *in;
mleaf_t *out;
int i, j, count;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
{
Com_Error(ERR_DROP, "%s: funny lump size in %s",
__func__, name);
}
count = l->filelen / sizeof(*in);
out = Hunk_Alloc((count + EXTRA_LUMP_LEAFS) * sizeof(*out));
*leafs = out;
*numleafs = count;
for (i = 0; i < count; i++, in++, out++)
{
unsigned int firstleafface;
for (j = 0; j < 3; j++)
{
out->minmaxs[j] = LittleShort(in->mins[j]);
out->minmaxs[3 + j] = LittleShort(in->maxs[j]);
}
out->contents = LittleLong(in->contents);
out->cluster = LittleShort(in->cluster);
out->area = LittleShort(in->area);
// make unsigned long from signed short
firstleafface = LittleShort(in->firstleafface) & 0xFFFF;
out->nummarksurfaces = LittleShort(in->numleaffaces) & 0xFFFF;
out->firstmarksurface = marksurfaces + firstleafface;
if ((firstleafface + out->nummarksurfaces) > nummarksurfaces)
{
Com_Error(ERR_DROP, "%s: wrong marksurfaces position in %s",
__func__, name);
}
}
}
static void
Mod_LoadQLeafs(const char *name, mleaf_t **leafs, int *numleafs,
msurface_t **marksurfaces, unsigned int nummarksurfaces,
@ -1013,12 +1063,21 @@ Mod_LoadQLeafs(const char *name, mleaf_t **leafs, int *numleafs,
void
Mod_LoadQBSPLeafs(const char *name, mleaf_t **leafs, int *numleafs,
msurface_t **marksurfaces, unsigned int nummarksurfaces,
const byte *mod_base, const lump_t *l, int ident)
const byte *mod_base, const lump_t *l, int ident, maptype_t maptype)
{
if (ident == IDBSPHEADER)
{
Mod_LoadLeafs(name, leafs, numleafs, marksurfaces, nummarksurfaces,
mod_base, l);
if ((maptype == map_daikatana) &&
(l->filelen % sizeof(ddkleaf_t) == 0))
{
Mod_LoadDKLeafs(name, leafs, numleafs, marksurfaces, nummarksurfaces,
mod_base, l);
}
else
{
Mod_LoadLeafs(name, leafs, numleafs, marksurfaces, nummarksurfaces,
mod_base, l);
}
}
else
{

View file

@ -680,6 +680,14 @@ GetSkyImage(const char *skyname, const char* surfname, qboolean palettedtexture,
image = find_image(pathname, it_sky);
}
/* Daikatana */
if (!image)
{
Com_sprintf(pathname, sizeof(pathname), "env/32bit/%s%s.tga",
skyname, surfname);
image = find_image(pathname, it_sky);
}
return image;
}

View file

@ -592,6 +592,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
{
const bspx_header_t *bspx_header;
int i, lightgridsize = 0;
maptype_t maptype;
dheader_t *header;
byte *mod_base;
@ -626,6 +627,13 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
((int *)header)[i] = LittleLong(((int *)header)[i]);
}
maptype = Mod_LoadValidateLumps(mod->name, header);
if (maptype == map_quake2)
{
/* Can't detect use provided */
maptype = r_maptype->value;
}
/* check for BSPX extensions */
bspx_header = Mod_LoadBSPX(modfilelen, (byte*)header);
@ -667,8 +675,18 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
1, 1, 0);
if (header->ident == IDBSPHEADER)
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
if ((maptype == map_daikatana) &&
(header->lumps[LUMP_LEAFS].filelen % sizeof(ddkleaf_t) == 0))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(ddkleaf_t), sizeof(mleaf_t), 0);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
@ -713,7 +731,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
mod_base, &header->lumps[LUMP_PLANES]);
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)R_FindImage,
r_notexture, r_maptype->value);
r_notexture, maptype);
if (header->ident == IDBSPHEADER)
{
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
@ -729,7 +747,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
&header->lumps[LUMP_VISIBILITY]);
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
mod->marksurfaces, mod->nummarksurfaces, mod_base,
&header->lumps[LUMP_LEAFS], header->ident);
&header->lumps[LUMP_LEAFS], header->ident, maptype);
Mod_LoadQBSPNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
&header->lumps[LUMP_NODES], header->ident);

View file

@ -593,6 +593,7 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
{
const bspx_header_t *bspx_header;
int i, lightgridsize = 0;
maptype_t maptype;
dheader_t *header;
byte *mod_base;
@ -627,6 +628,13 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
((int *)header)[i] = LittleLong(((int *)header)[i]);
}
maptype = Mod_LoadValidateLumps(mod->name, header);
if (maptype == map_quake2)
{
/* Can't detect use provided */
maptype = r_maptype->value;
}
/* check for BSPX extensions */
bspx_header = Mod_LoadBSPX(modfilelen, (byte*)header);
@ -668,8 +676,18 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
1, 1, 0);
if (header->ident == IDBSPHEADER)
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
if ((maptype == map_daikatana) &&
(header->lumps[LUMP_LEAFS].filelen % sizeof(ddkleaf_t) == 0))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(ddkleaf_t), sizeof(mleaf_t), 0);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
@ -714,7 +732,7 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
mod_base, &header->lumps[LUMP_PLANES]);
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)GL3_FindImage,
gl3_notexture, r_maptype->value);
gl3_notexture, maptype);
if (header->ident == IDBSPHEADER)
{
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
@ -730,7 +748,7 @@ Mod_LoadBrushModel(gl3model_t *mod, const void *buffer, int modfilelen)
&header->lumps[LUMP_VISIBILITY]);
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
mod->marksurfaces, mod->nummarksurfaces, mod_base,
&header->lumps[LUMP_LEAFS], header->ident);
&header->lumps[LUMP_LEAFS], header->ident, maptype);
Mod_LoadQBSPNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
&header->lumps[LUMP_NODES], header->ident);

View file

@ -593,6 +593,7 @@ Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int modfilelen)
{
const bspx_header_t *bspx_header;
int i, lightgridsize = 0;
maptype_t maptype;
dheader_t *header;
byte *mod_base;
@ -627,6 +628,13 @@ Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int modfilelen)
((int *)header)[i] = LittleLong(((int *)header)[i]);
}
maptype = Mod_LoadValidateLumps(mod->name, header);
if (maptype == map_quake2)
{
/* Can't detect use provided */
maptype = r_maptype->value;
}
/* check for BSPX extensions */
bspx_header = Mod_LoadBSPX(modfilelen, (byte*)header);
@ -668,8 +676,18 @@ Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int modfilelen)
1, 1, 0);
if (header->ident == IDBSPHEADER)
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
if ((maptype == map_daikatana) &&
(header->lumps[LUMP_LEAFS].filelen % sizeof(ddkleaf_t) == 0))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(ddkleaf_t), sizeof(mleaf_t), 0);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
@ -714,7 +732,7 @@ Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int modfilelen)
mod_base, &header->lumps[LUMP_PLANES]);
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)GL4_FindImage,
gl4_notexture, r_maptype->value);
gl4_notexture, maptype);
if (header->ident == IDBSPHEADER)
{
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
@ -730,7 +748,7 @@ Mod_LoadBrushModel(gl4model_t *mod, const void *buffer, int modfilelen)
&header->lumps[LUMP_VISIBILITY]);
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
mod->marksurfaces, mod->nummarksurfaces, mod_base,
&header->lumps[LUMP_LEAFS], header->ident);
&header->lumps[LUMP_LEAFS], header->ident, maptype);
Mod_LoadQBSPNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
&header->lumps[LUMP_NODES], header->ident);

View file

@ -344,7 +344,7 @@ extern void Mod_LoadQBSPNodes(const char *name, cplane_t *planes, int numplanes,
const byte *mod_base, const lump_t *l, int ident);
extern void Mod_LoadQBSPLeafs(const char *name, mleaf_t **leafs, int *numleafs,
msurface_t **marksurfaces, unsigned int nummarksurfaces,
const byte *mod_base, const lump_t *l, int ident);
const byte *mod_base, const lump_t *l, int ident, maptype_t maptype);
extern void Mod_LoadQBSPEdges(const char *name, medge_t **edges, int *numedges,
const byte *mod_base, const lump_t *l, int ident);
extern void Mod_LoadVertexes(const char *name, mvertex_t **vertexes, int *numvertexes,

View file

@ -425,6 +425,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
{
const bspx_header_t *bspx_header;
int i, lightgridsize = 0;
maptype_t maptype;
dheader_t *header;
byte *mod_base;
@ -459,6 +460,13 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
((int *)header)[i] = LittleLong(((int *)header)[i]);
}
maptype = Mod_LoadValidateLumps(mod->name, header);
if (maptype == map_quake2)
{
/* Can't detect use provided */
maptype = r_maptype->value;
}
/* check for BSPX extensions */
bspx_header = Mod_LoadBSPX(modfilelen, (byte*)header);
@ -502,8 +510,18 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
1, 1, 0);
if (header->ident == IDBSPHEADER)
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
if ((maptype == map_daikatana) &&
(header->lumps[LUMP_LEAFS].filelen % sizeof(ddkleaf_t) == 0))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(ddkleaf_t), sizeof(mleaf_t), 0);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
@ -550,7 +568,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
mod_base, &header->lumps[LUMP_PLANES]);
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)R_FindImage,
r_notexture_mip, r_maptype->value);
r_notexture_mip, maptype);
if (header->ident == IDBSPHEADER)
{
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
@ -566,7 +584,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
&header->lumps[LUMP_VISIBILITY]);
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
mod->marksurfaces, mod->nummarksurfaces, mod_base,
&header->lumps[LUMP_LEAFS], header->ident);
&header->lumps[LUMP_LEAFS], header->ident, maptype);
Mod_LoadQBSPNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
&header->lumps[LUMP_NODES], header->ident);

View file

@ -567,6 +567,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
{
const bspx_header_t *bspx_header;
int i, lightgridsize = 0;
maptype_t maptype;
dheader_t *header;
byte *mod_base;
@ -601,6 +602,13 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
((int *)header)[i] = LittleLong(((int *)header)[i]);
}
maptype = Mod_LoadValidateLumps(mod->name, header);
if (maptype == map_quake2)
{
/* Can't detect use provided */
maptype = r_maptype->value;
}
/* check for BSPX extensions */
bspx_header = Mod_LoadBSPX(modfilelen, (byte*)header);
@ -642,8 +650,18 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
1, 1, 0);
if (header->ident == IDBSPHEADER)
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
if ((maptype == map_daikatana) &&
(header->lumps[LUMP_LEAFS].filelen % sizeof(ddkleaf_t) == 0))
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(ddkleaf_t), sizeof(mleaf_t), 0);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(mleaf_t), 0);
}
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_NODES],
sizeof(dnode_t), sizeof(mnode_t), EXTRA_LUMP_NODES);
}
@ -688,7 +706,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
mod_base, &header->lumps[LUMP_PLANES]);
Mod_LoadTexinfo(mod->name, &mod->texinfo, &mod->numtexinfo,
mod_base, &header->lumps[LUMP_TEXINFO], (findimage_t)Vk_FindImage,
r_notexture, r_maptype->value);
r_notexture, maptype);
if (header->ident == IDBSPHEADER)
{
Mod_LoadFaces(mod, mod_base, &header->lumps[LUMP_FACES], bspx_header);
@ -704,7 +722,7 @@ Mod_LoadBrushModel(model_t *mod, const void *buffer, int modfilelen)
&header->lumps[LUMP_VISIBILITY]);
Mod_LoadQBSPLeafs(mod->name, &mod->leafs, &mod->numleafs,
mod->marksurfaces, mod->nummarksurfaces, mod_base,
&header->lumps[LUMP_LEAFS], header->ident);
&header->lumps[LUMP_LEAFS], header->ident, maptype);
Mod_LoadQBSPNodes(mod->name, mod->planes, mod->numplanes, mod->leafs,
mod->numleafs, &mod->nodes, &mod->numnodes, mod_base,
&header->lumps[LUMP_NODES], header->ident);

View file

@ -189,49 +189,93 @@ static const size_t qbsplumps[HEADER_LUMPS] = {
sizeof(dareaportal_t), // LUMP_AREAPORTALS
};
void
static const char*
Mod_MaptypeName(maptype_t maptype)
{
const char* maptypename;
switch(maptype)
{
case map_quake2: maptypename = "Quake2"; break;
case map_heretic2: maptypename = "Heretic 2"; break;
case map_daikatana: maptypename = "Daikatana"; break;
case map_kingpin: maptypename = "Kingpin"; break;
case map_anachronox: maptypename = "Anachronox"; break;
default: maptypename = "Unknown"; break;
}
return maptypename;
}
maptype_t
Mod_LoadValidateLumps(const char *name, const dheader_t *header)
{
const size_t *rules = NULL;
qboolean error = false;
int s;
maptype_t maptype;
if (header->ident == IDBSPHEADER)
{
rules = idbsplumps;
if (header->version == BSPDKMVERSION)
{
maptype = map_daikatana;
}
else
{
maptype = map_quake2;
}
}
else if (header->ident == QBSPHEADER)
{
rules = qbsplumps;
maptype = map_quake2;
}
else
{
return;
rules = NULL;
maptype = map_quake2;
}
for (s = 0; s < HEADER_LUMPS; s++)
if (rules)
{
if (rules[s])
int s;
for (s = 0; s < HEADER_LUMPS; s++)
{
if (header->lumps[s].filelen % rules[s])
if (rules[s])
{
Com_Printf("%s: Map %s lump #%d: incorrect size %d / " YQ2_COM_PRIdS "\n",
__func__, name, s, header->lumps[s].filelen, rules[s]);
error = true;
if ((maptype == map_daikatana) &&
(s == LUMP_LEAFS) &&
(header->lumps[s].filelen % sizeof(ddkleaf_t) == 0))
{
/* Small hack for daikatana,
* bsp could have two different sizes of LUMP_LEAFS
*/
continue;
}
else if (header->lumps[s].filelen % rules[s])
{
Com_Printf("%s: Map %s lump #%d: incorrect size %d / " YQ2_COM_PRIdS "\n",
__func__, name, s, header->lumps[s].filelen, rules[s]);
error = true;
}
}
#ifdef DEBUG
else
{
Com_Printf("%s: Map %s lump #%d: correct size %d / " YQ2_COM_PRIdS "\n",
__func__, name, s, header->lumps[s].filelen, rules[s]);
}
#endif
}
}
Com_Printf("Map %s %c%c%c%c with version %d (%s)\n",
name,
(header->ident >> 0) & 0xFF,
(header->ident >> 8) & 0xFF,
(header->ident >> 16) & 0xFF,
(header->ident >> 24) & 0xFF,
header->version, Mod_MaptypeName(maptype));
if (error)
{
Com_Error(ERR_DROP, "%s: Map %s has incorrect lumps",
__func__, name);
}
return maptype;
}

View file

@ -1549,6 +1549,69 @@ CMod_LoadLeafs(const char *name, cleaf_t **map_leafs, int *numleafs, int *emptyl
}
}
static void
CMod_LoadDKLeafs(const char *name, cleaf_t **map_leafs, int *numleafs, int *emptyleaf,
int *numclusters, const byte *cmod_base, const lump_t *l)
{
int i;
cleaf_t *out;
ddkleaf_t *in;
int count;
in = (void *)(cmod_base + l->fileofs);
if (l->filelen % sizeof(*in))
{
Com_Error(ERR_DROP, "%s: Map %s funny lump size", __func__, name);
}
count = l->filelen / sizeof(*in);
if (count < 1)
{
Com_Error(ERR_DROP, "%s: Map %s with no leafs", __func__, name);
}
out = *map_leafs = Hunk_Alloc((count + EXTRA_LUMP_LEAFS) * sizeof(*out));
*numleafs = count;
*numclusters = 0;
for (i = 0; i < count; i++, in++, out++)
{
out->contents = LittleLong(in->contents);
out->cluster = LittleShort(in->cluster);
out->area = LittleShort(in->area);
out->firstleafbrush = LittleShort(in->firstleafbrush) & 0xFFFF;
out->numleafbrushes = LittleShort(in->numleafbrushes) & 0xFFFF;
if (out->cluster >= *numclusters)
{
*numclusters = out->cluster + 1;
}
}
if ((*map_leafs)[0].contents != CONTENTS_SOLID)
{
Com_Error(ERR_DROP, "%s: Map leaf 0 is not CONTENTS_SOLID", __func__);
}
*emptyleaf = -1;
for (i = 1; i < count; i++)
{
if (!(*map_leafs)[i].contents)
{
*emptyleaf = i;
break;
}
}
if (*emptyleaf == -1)
{
Com_Error(ERR_DROP, "%s: Map does not have an empty leaf", __func__);
}
}
static void
CMod_LoadQLeafs(const char *name, cleaf_t **map_leafs, int *numleafs, int *emptyleaf,
int *numclusters, const byte *cmod_base, const lump_t *l)
@ -1929,6 +1992,7 @@ CM_LoadCachedMap(const char *name, model_t *mod)
{
int i, length, hunkSize = 0;
const byte *cmod_base;
maptype_t maptype;
dheader_t header;
unsigned *buf;
@ -1972,15 +2036,7 @@ CM_LoadCachedMap(const char *name, model_t *mod)
__func__, name, header.version, BSPVERSION);
}
Com_DPrintf("%s: Map %s ident %c%c%c%c version %d\n",
__func__, name,
(header.ident >> 0) & 0xFF,
(header.ident >> 8) & 0xFF,
(header.ident >> 16) & 0xFF,
(header.ident >> 24) & 0xFF,
header.version);
Mod_LoadValidateLumps(name, &header);
maptype = Mod_LoadValidateLumps(name, &header);
cmod_base = (byte *)buf;
@ -1992,8 +2048,18 @@ CM_LoadCachedMap(const char *name, model_t *mod)
if (header.ident == IDBSPHEADER)
{
hunkSize += Mod_CalcLumpHunkSize(&header.lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(cleaf_t), 0);
if ((maptype == map_daikatana) &&
(header.lumps[LUMP_LEAFS].filelen % sizeof(ddkleaf_t) == 0))
{
hunkSize += Mod_CalcLumpHunkSize(&header.lumps[LUMP_LEAFS],
sizeof(ddkleaf_t), sizeof(cleaf_t), 0);
}
else
{
hunkSize += Mod_CalcLumpHunkSize(&header.lumps[LUMP_LEAFS],
sizeof(dleaf_t), sizeof(cleaf_t), 0);
}
hunkSize += Mod_CalcLumpHunkSize(&header.lumps[LUMP_LEAFBRUSHES],
sizeof(short), sizeof(int), EXTRA_LUMP_LEAFBRUSHES);
}
@ -2042,8 +2108,17 @@ CM_LoadCachedMap(const char *name, model_t *mod)
cmod_base, &header.lumps[LUMP_TEXINFO]);
if (header.ident == IDBSPHEADER)
{
CMod_LoadLeafs(mod->name, &mod->map_leafs, &mod->numleafs, &mod->emptyleaf,
&mod->numclusters, cmod_base, &header.lumps[LUMP_LEAFS]);
if ((maptype == map_daikatana) &&
(header.lumps[LUMP_LEAFS].filelen % sizeof(ddkleaf_t) == 0))
{
CMod_LoadDKLeafs(mod->name, &mod->map_leafs, &mod->numleafs, &mod->emptyleaf,
&mod->numclusters, cmod_base, &header.lumps[LUMP_LEAFS]);
}
else
{
CMod_LoadLeafs(mod->name, &mod->map_leafs, &mod->numleafs, &mod->emptyleaf,
&mod->numclusters, cmod_base, &header.lumps[LUMP_LEAFS]);
}
CMod_LoadLeafBrushes(mod->name, &mod->map_leafbrushes, &mod->numleafbrushes,
cmod_base, &header.lumps[LUMP_LEAFBRUSHES]);
}

View file

@ -53,6 +53,6 @@ extern void Mod_LoadVisibility(const char *name, dvis_t **vis, int *numvisibilit
const byte *mod_base, const lump_t *l);
extern void Mod_LoadPlanes(const char *name, cplane_t **planes, int *numplanes,
const byte *mod_base, const lump_t *l);
extern void Mod_LoadValidateLumps(const char *name, const dheader_t *header);
extern maptype_t Mod_LoadValidateLumps(const char *name, const dheader_t *header);
#endif

View file

@ -832,6 +832,7 @@ typedef struct {
float vecs[2][4];
} dlminfo_t;
/* Quake2 Leafs struct */
typedef struct
{
int contents; /* OR of all brushes (not needed?) */
@ -849,6 +850,26 @@ typedef struct
unsigned short numleafbrushes;
} dleaf_t;
/* Daikatana Leafs struct */
typedef struct
{
int contents; /* OR of all brushes (not needed?) */
short cluster;
short area;
short mins[3]; /* for frustum culling */
short maxs[3];
unsigned short firstleafface;
unsigned short numleaffaces;
unsigned short firstleafbrush;
unsigned short numleafbrushes;
int unknow; /* some unused additional field */
} ddkleaf_t;
typedef struct
{
int contents; /* OR of all brushes (not needed?) */