maps: Use LUMP defines instead numbers in rules

This commit is contained in:
Denis Pauk 2024-05-05 15:55:23 +03:00
parent 1b73b4ea5b
commit e463721665
3 changed files with 99 additions and 97 deletions

View file

@ -739,7 +739,6 @@ Mod_LoadQBSPLeafs(const char *name, mleaf_t **leafs, int *numleafs,
out->cluster = in->cluster;
out->area = in->area;
// make unsigned long from signed short
firstleafface = in->firstleafface;
out->nummarksurfaces = in->numleaffaces;

View file

@ -1530,7 +1530,7 @@ CMod_LoadLeafBrushes(const char *name, unsigned int **map_leafbrushes,
if (count < 1)
{
Com_Error(ERR_DROP, "%s: Map %s with no planes", __func__, name);
Com_Error(ERR_DROP, "%s: Map %s with no leaf brushes", __func__, name);
}
out = *map_leafbrushes = Hunk_Alloc((count + EXTRA_LUMP_LEAFBRUSHES) * sizeof(*out));
@ -1561,7 +1561,7 @@ CMod_LoadBrushSides(const char *name, cbrushside_t **map_brushsides, int *numbru
/* need to save space for box planes */
if (count < 1)
{
Com_Error(ERR_DROP, "%s: Map %s with no planes", __func__, name);
Com_Error(ERR_DROP, "%s: Map %s with no brush sides", __func__, name);
}
out = *map_brushsides = Hunk_Alloc((count + EXTRA_LUMP_BRUSHSIDES) * sizeof(*out));

View file

@ -812,114 +812,114 @@ typedef struct
} rule_t;
static const rule_t idq2bsplumps[HEADER_LUMPS] = {
{0, sizeof(char), Mod_Load2QBSP_IBSP_ENTITIES},
{1, sizeof(dplane_t), Mod_Load2QBSP_IBSP_PLANES},
{2, sizeof(dvertex_t), Mod_Load2QBSP_IBSP_VERTEXES},
{3, sizeof(char), Mod_Load2QBSP_IBSP_VISIBILITY},
{4, sizeof(dnode_t), Mod_Load2QBSP_IBSP_NODES},
{5, sizeof(texinfo_t), Mod_Load2QBSP_IBSP_TEXINFO},
{6, sizeof(dface_t), Mod_Load2QBSP_IBSP_FACES},
{7, sizeof(char), Mod_Load2QBSP_IBSP_LIGHTING},
{8, sizeof(dleaf_t), Mod_Load2QBSP_IBSP_LEAFS},
{9, sizeof(short), Mod_Load2QBSP_IBSP_LEAFFACES},
{10, sizeof(short), Mod_Load2QBSP_IBSP_LEAFBRUSHES},
{11, sizeof(dedge_t), Mod_Load2QBSP_IBSP_EDGES},
{12, sizeof(int), Mod_Load2QBSP_IBSP_SURFEDGES},
{13, sizeof(dmodel_t), Mod_Load2QBSP_IBSP_MODELS},
{14, sizeof(dbrush_t), Mod_Load2QBSP_IBSP_BRUSHES},
{15, sizeof(dbrushside_t), Mod_Load2QBSP_IBSP_BRUSHSIDES},
{LUMP_ENTITIES, sizeof(char), Mod_Load2QBSP_IBSP_ENTITIES},
{LUMP_PLANES, sizeof(dplane_t), Mod_Load2QBSP_IBSP_PLANES},
{LUMP_VERTEXES, sizeof(dvertex_t), Mod_Load2QBSP_IBSP_VERTEXES},
{LUMP_VISIBILITY, sizeof(char), Mod_Load2QBSP_IBSP_VISIBILITY},
{LUMP_NODES, sizeof(dnode_t), Mod_Load2QBSP_IBSP_NODES},
{LUMP_TEXINFO, sizeof(texinfo_t), Mod_Load2QBSP_IBSP_TEXINFO},
{LUMP_FACES, sizeof(dface_t), Mod_Load2QBSP_IBSP_FACES},
{LUMP_LIGHTING, sizeof(char), Mod_Load2QBSP_IBSP_LIGHTING},
{LUMP_LEAFS, sizeof(dleaf_t), Mod_Load2QBSP_IBSP_LEAFS},
{LUMP_LEAFFACES, sizeof(short), Mod_Load2QBSP_IBSP_LEAFFACES},
{LUMP_LEAFBRUSHES, sizeof(short), Mod_Load2QBSP_IBSP_LEAFBRUSHES},
{LUMP_EDGES, sizeof(dedge_t), Mod_Load2QBSP_IBSP_EDGES},
{LUMP_SURFEDGES, sizeof(int), Mod_Load2QBSP_IBSP_SURFEDGES},
{LUMP_MODELS, sizeof(dmodel_t), Mod_Load2QBSP_IBSP_MODELS},
{LUMP_BRUSHES, sizeof(dbrush_t), Mod_Load2QBSP_IBSP_BRUSHES},
{LUMP_BRUSHSIDES, sizeof(dbrushside_t), Mod_Load2QBSP_IBSP_BRUSHSIDES},
{-1, 0, NULL}, // LUMP_POP
{17, sizeof(darea_t), Mod_Load2QBSP_IBSP_AREAS},
{18, sizeof(dareaportal_t), Mod_Load2QBSP_IBSP_AREAPORTALS},
{LUMP_AREAS, sizeof(darea_t), Mod_Load2QBSP_IBSP_AREAS},
{LUMP_AREAPORTALS, sizeof(dareaportal_t), Mod_Load2QBSP_IBSP_AREAPORTALS},
};
static const rule_t dkbsplumps[HEADER_LUMPS] = {
{0, sizeof(char), Mod_Load2QBSP_IBSP_ENTITIES},
{1, sizeof(dplane_t), Mod_Load2QBSP_IBSP_PLANES},
{2, sizeof(dvertex_t), Mod_Load2QBSP_IBSP_VERTEXES},
{3, sizeof(char), Mod_Load2QBSP_IBSP_VISIBILITY},
{4, sizeof(dnode_t), Mod_Load2QBSP_IBSP_NODES},
{5, sizeof(texinfo_t), Mod_Load2QBSP_IBSP_TEXINFO},
{6, sizeof(dface_t), Mod_Load2QBSP_IBSP_FACES},
{7, sizeof(char), Mod_Load2QBSP_IBSP_LIGHTING},
{8, sizeof(ddkleaf_t), Mod_Load2QBSP_DKBSP_LEAFS},
{9, sizeof(short), Mod_Load2QBSP_IBSP_LEAFFACES},
{10, sizeof(short), Mod_Load2QBSP_IBSP_LEAFBRUSHES},
{11, sizeof(dedge_t), Mod_Load2QBSP_IBSP_EDGES},
{12, sizeof(int), Mod_Load2QBSP_IBSP_SURFEDGES},
{13, sizeof(dmodel_t), Mod_Load2QBSP_IBSP_MODELS},
{14, sizeof(dbrush_t), Mod_Load2QBSP_IBSP_BRUSHES},
{15, sizeof(dbrushside_t), Mod_Load2QBSP_IBSP_BRUSHSIDES},
{LUMP_ENTITIES, sizeof(char), Mod_Load2QBSP_IBSP_ENTITIES},
{LUMP_PLANES, sizeof(dplane_t), Mod_Load2QBSP_IBSP_PLANES},
{LUMP_VERTEXES, sizeof(dvertex_t), Mod_Load2QBSP_IBSP_VERTEXES},
{LUMP_VISIBILITY, sizeof(char), Mod_Load2QBSP_IBSP_VISIBILITY},
{LUMP_NODES, sizeof(dnode_t), Mod_Load2QBSP_IBSP_NODES},
{LUMP_TEXINFO, sizeof(texinfo_t), Mod_Load2QBSP_IBSP_TEXINFO},
{LUMP_FACES, sizeof(dface_t), Mod_Load2QBSP_IBSP_FACES},
{LUMP_LIGHTING, sizeof(char), Mod_Load2QBSP_IBSP_LIGHTING},
{LUMP_LEAFS, sizeof(ddkleaf_t), Mod_Load2QBSP_DKBSP_LEAFS},
{LUMP_LEAFFACES, sizeof(short), Mod_Load2QBSP_IBSP_LEAFFACES},
{LUMP_LEAFBRUSHES, sizeof(short), Mod_Load2QBSP_IBSP_LEAFBRUSHES},
{LUMP_EDGES, sizeof(dedge_t), Mod_Load2QBSP_IBSP_EDGES},
{LUMP_SURFEDGES, sizeof(int), Mod_Load2QBSP_IBSP_SURFEDGES},
{LUMP_MODELS, sizeof(dmodel_t), Mod_Load2QBSP_IBSP_MODELS},
{LUMP_BRUSHES, sizeof(dbrush_t), Mod_Load2QBSP_IBSP_BRUSHES},
{LUMP_BRUSHSIDES, sizeof(dbrushside_t), Mod_Load2QBSP_IBSP_BRUSHSIDES},
{-1, 0, NULL}, // LUMP_POP
{17, sizeof(darea_t), Mod_Load2QBSP_IBSP_AREAS},
{18, sizeof(dareaportal_t), Mod_Load2QBSP_IBSP_AREAPORTALS},
{LUMP_AREAS, sizeof(darea_t), Mod_Load2QBSP_IBSP_AREAS},
{LUMP_AREAPORTALS, sizeof(dareaportal_t), Mod_Load2QBSP_IBSP_AREAPORTALS},
};
static const rule_t rbsplumps[HEADER_LUMPS] = {
{0, sizeof(char), Mod_Load2QBSP_IBSP_ENTITIES},
{1, sizeof(dplane_t), Mod_Load2QBSP_IBSP_PLANES},
{2, sizeof(dvertex_t), Mod_Load2QBSP_IBSP_VERTEXES},
{3, sizeof(char), Mod_Load2QBSP_IBSP_VISIBILITY},
{4, sizeof(dnode_t), Mod_Load2QBSP_IBSP_NODES},
{5, sizeof(texrinfo_t), Mod_Load2QBSP_RBSP_TEXINFO},
{6, sizeof(drface_t), Mod_Load2QBSP_RBSP_FACES},
{7, sizeof(char), Mod_Load2QBSP_IBSP_LIGHTING},
{8, sizeof(dleaf_t), Mod_Load2QBSP_IBSP_LEAFS},
{9, sizeof(short), Mod_Load2QBSP_IBSP_LEAFFACES},
{10, sizeof(short), Mod_Load2QBSP_IBSP_LEAFBRUSHES},
{11, sizeof(dedge_t), Mod_Load2QBSP_IBSP_EDGES},
{12, sizeof(int), Mod_Load2QBSP_IBSP_SURFEDGES},
{13, sizeof(dmodel_t), Mod_Load2QBSP_IBSP_MODELS},
{14, sizeof(dbrush_t), Mod_Load2QBSP_IBSP_BRUSHES},
{15, sizeof(drbrushside_t), Mod_Load2QBSP_RBSP_BRUSHSIDES},
{LUMP_ENTITIES, sizeof(char), Mod_Load2QBSP_IBSP_ENTITIES},
{LUMP_PLANES, sizeof(dplane_t), Mod_Load2QBSP_IBSP_PLANES},
{LUMP_VERTEXES, sizeof(dvertex_t), Mod_Load2QBSP_IBSP_VERTEXES},
{LUMP_VISIBILITY, sizeof(char), Mod_Load2QBSP_IBSP_VISIBILITY},
{LUMP_NODES, sizeof(dnode_t), Mod_Load2QBSP_IBSP_NODES},
{LUMP_TEXINFO, sizeof(texrinfo_t), Mod_Load2QBSP_RBSP_TEXINFO},
{LUMP_FACES, sizeof(drface_t), Mod_Load2QBSP_RBSP_FACES},
{LUMP_LIGHTING, sizeof(char), Mod_Load2QBSP_IBSP_LIGHTING},
{LUMP_LEAFS, sizeof(dleaf_t), Mod_Load2QBSP_IBSP_LEAFS},
{LUMP_LEAFFACES, sizeof(short), Mod_Load2QBSP_IBSP_LEAFFACES},
{LUMP_LEAFBRUSHES, sizeof(short), Mod_Load2QBSP_IBSP_LEAFBRUSHES},
{LUMP_EDGES, sizeof(dedge_t), Mod_Load2QBSP_IBSP_EDGES},
{LUMP_SURFEDGES, sizeof(int), Mod_Load2QBSP_IBSP_SURFEDGES},
{LUMP_MODELS, sizeof(dmodel_t), Mod_Load2QBSP_IBSP_MODELS},
{LUMP_BRUSHES, sizeof(dbrush_t), Mod_Load2QBSP_IBSP_BRUSHES},
{LUMP_BRUSHSIDES, sizeof(drbrushside_t), Mod_Load2QBSP_RBSP_BRUSHSIDES},
{-1, 0, NULL}, // LUMP_POP
{17, sizeof(darea_t), Mod_Load2QBSP_IBSP_AREAS},
{18, sizeof(dareaportal_t), Mod_Load2QBSP_IBSP_AREAPORTALS},
{LUMP_AREAS, sizeof(darea_t), Mod_Load2QBSP_IBSP_AREAS},
{LUMP_AREAPORTALS, sizeof(dareaportal_t), Mod_Load2QBSP_IBSP_AREAPORTALS},
};
static const rule_t qbsplumps[HEADER_LUMPS] = {
{0, sizeof(char), Mod_Load2QBSP_IBSP_ENTITIES},
{1, sizeof(dplane_t), Mod_Load2QBSP_IBSP_PLANES},
{2, sizeof(dvertex_t), Mod_Load2QBSP_IBSP_VERTEXES},
{3, sizeof(char), Mod_Load2QBSP_IBSP_VISIBILITY},
{4, sizeof(dqnode_t), Mod_Load2QBSP_QBSP_NODES},
{5, sizeof(texinfo_t), Mod_Load2QBSP_IBSP_TEXINFO},
{6, sizeof(dqface_t), Mod_Load2QBSP_QBSP_FACES},
{7, sizeof(char), Mod_Load2QBSP_IBSP_LIGHTING},
{8, sizeof(dqleaf_t), Mod_Load2QBSP_QBSP_LEAFS},
{9, sizeof(int), Mod_Load2QBSP_QBSP_LEAFFACES},
{10, sizeof(int), Mod_Load2QBSP_QBSP_LEAFBRUSHES},
{11, sizeof(dqedge_t), Mod_Load2QBSP_QBSP_EDGES},
{12, sizeof(int), Mod_Load2QBSP_IBSP_SURFEDGES},
{13, sizeof(dmodel_t), Mod_Load2QBSP_IBSP_MODELS},
{14, sizeof(dbrush_t), Mod_Load2QBSP_IBSP_BRUSHES},
{15, sizeof(dqbrushside_t), Mod_Load2QBSP_QBSP_BRUSHSIDES},
{LUMP_ENTITIES, sizeof(char), Mod_Load2QBSP_IBSP_ENTITIES},
{LUMP_PLANES, sizeof(dplane_t), Mod_Load2QBSP_IBSP_PLANES},
{LUMP_VERTEXES, sizeof(dvertex_t), Mod_Load2QBSP_IBSP_VERTEXES},
{LUMP_VISIBILITY, sizeof(char), Mod_Load2QBSP_IBSP_VISIBILITY},
{LUMP_NODES, sizeof(dqnode_t), Mod_Load2QBSP_QBSP_NODES},
{LUMP_TEXINFO, sizeof(texinfo_t), Mod_Load2QBSP_IBSP_TEXINFO},
{LUMP_FACES, sizeof(dqface_t), Mod_Load2QBSP_QBSP_FACES},
{LUMP_LIGHTING, sizeof(char), Mod_Load2QBSP_IBSP_LIGHTING},
{LUMP_LEAFS, sizeof(dqleaf_t), Mod_Load2QBSP_QBSP_LEAFS},
{LUMP_LEAFFACES, sizeof(int), Mod_Load2QBSP_QBSP_LEAFFACES},
{LUMP_LEAFBRUSHES, sizeof(int), Mod_Load2QBSP_QBSP_LEAFBRUSHES},
{LUMP_EDGES, sizeof(dqedge_t), Mod_Load2QBSP_QBSP_EDGES},
{LUMP_SURFEDGES, sizeof(int), Mod_Load2QBSP_IBSP_SURFEDGES},
{LUMP_MODELS, sizeof(dmodel_t), Mod_Load2QBSP_IBSP_MODELS},
{LUMP_BRUSHES, sizeof(dbrush_t), Mod_Load2QBSP_IBSP_BRUSHES},
{LUMP_BRUSHSIDES, sizeof(dqbrushside_t), Mod_Load2QBSP_QBSP_BRUSHSIDES},
{-1, 0, NULL}, // LUMP_POP
{17, sizeof(darea_t), Mod_Load2QBSP_IBSP_AREAS},
{18, sizeof(dareaportal_t), Mod_Load2QBSP_IBSP_AREAPORTALS},
{LUMP_AREAS, sizeof(darea_t), Mod_Load2QBSP_IBSP_AREAS},
{LUMP_AREAPORTALS, sizeof(dareaportal_t), Mod_Load2QBSP_IBSP_AREAPORTALS},
};
/* custom format with extended texture name */
static const rule_t xbsplumps[HEADER_LUMPS] = {
{0, sizeof(char), Mod_Load2QBSP_IBSP_ENTITIES},
{1, sizeof(dplane_t), Mod_Load2QBSP_IBSP_PLANES},
{2, sizeof(dvertex_t), Mod_Load2QBSP_IBSP_VERTEXES},
{3, sizeof(char), Mod_Load2QBSP_IBSP_VISIBILITY},
{4, sizeof(dqnode_t), Mod_Load2QBSP_QBSP_NODES},
{5, sizeof(xtexinfo_t), Mod_Load2QBSP_IBSP_TEXINFO},
{6, sizeof(dqface_t), Mod_Load2QBSP_QBSP_FACES},
{7, sizeof(char), Mod_Load2QBSP_IBSP_LIGHTING},
{8, sizeof(dqleaf_t), Mod_Load2QBSP_QBSP_LEAFS},
{9, sizeof(int), Mod_Load2QBSP_QBSP_LEAFFACES},
{10, sizeof(int), Mod_Load2QBSP_QBSP_LEAFBRUSHES},
{11, sizeof(dqedge_t), Mod_Load2QBSP_QBSP_EDGES},
{12, sizeof(int), Mod_Load2QBSP_IBSP_SURFEDGES},
{13, sizeof(dmodel_t), Mod_Load2QBSP_IBSP_MODELS},
{14, sizeof(dbrush_t), Mod_Load2QBSP_IBSP_BRUSHES},
{15, sizeof(dqbrushside_t), Mod_Load2QBSP_QBSP_BRUSHSIDES},
{LUMP_ENTITIES, sizeof(char), Mod_Load2QBSP_IBSP_ENTITIES},
{LUMP_PLANES, sizeof(dplane_t), Mod_Load2QBSP_IBSP_PLANES},
{LUMP_VERTEXES, sizeof(dvertex_t), Mod_Load2QBSP_IBSP_VERTEXES},
{LUMP_VISIBILITY, sizeof(char), Mod_Load2QBSP_IBSP_VISIBILITY},
{LUMP_NODES, sizeof(dqnode_t), Mod_Load2QBSP_QBSP_NODES},
{LUMP_TEXINFO, sizeof(xtexinfo_t), Mod_Load2QBSP_IBSP_TEXINFO},
{LUMP_FACES, sizeof(dqface_t), Mod_Load2QBSP_QBSP_FACES},
{LUMP_LIGHTING, sizeof(char), Mod_Load2QBSP_IBSP_LIGHTING},
{LUMP_LEAFS, sizeof(dqleaf_t), Mod_Load2QBSP_QBSP_LEAFS},
{LUMP_LEAFFACES, sizeof(int), Mod_Load2QBSP_QBSP_LEAFFACES},
{LUMP_LEAFBRUSHES, sizeof(int), Mod_Load2QBSP_QBSP_LEAFBRUSHES},
{LUMP_EDGES, sizeof(dqedge_t), Mod_Load2QBSP_QBSP_EDGES},
{LUMP_SURFEDGES, sizeof(int), Mod_Load2QBSP_IBSP_SURFEDGES},
{LUMP_MODELS, sizeof(dmodel_t), Mod_Load2QBSP_IBSP_MODELS},
{LUMP_BRUSHES, sizeof(dbrush_t), Mod_Load2QBSP_IBSP_BRUSHES},
{LUMP_BRUSHSIDES, sizeof(dqbrushside_t), Mod_Load2QBSP_QBSP_BRUSHSIDES},
{-1, 0, NULL}, // LUMP_POP
{17, sizeof(darea_t), Mod_Load2QBSP_IBSP_AREAS},
{18, sizeof(dareaportal_t), Mod_Load2QBSP_IBSP_AREAPORTALS},
{LUMP_AREAS, sizeof(darea_t), Mod_Load2QBSP_IBSP_AREAS},
{LUMP_AREAPORTALS, sizeof(dareaportal_t), Mod_Load2QBSP_IBSP_AREAPORTALS},
};
static const char*
@ -1105,11 +1105,14 @@ Mod_Load2QBSP(const char *name, byte *inbuf, size_t filesize, size_t *out_len,
{
if (rules[s].size && (rules[s].pos >= 0))
{
outheader->lumps[rules[s].pos].fileofs = ofs;
outheader->lumps[rules[s].pos].filelen = (
xbsplumps[s].size * header->lumps[s].filelen / rules[s].size
int pos;
pos = rules[s].pos;
outheader->lumps[pos].fileofs = ofs;
outheader->lumps[pos].filelen = (
xbsplumps[pos].size * header->lumps[s].filelen / rules[s].size
);
ofs += outheader->lumps[rules[s].pos].filelen;
ofs += outheader->lumps[pos].filelen;
}
}