mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-25 22:10:59 +00:00
cmodels: extend texture name size to 64
This commit is contained in:
parent
cca9317a55
commit
119e1f6993
4 changed files with 51 additions and 12 deletions
|
@ -332,7 +332,7 @@ Mod_LoadTexinfoQ2(const char *name, mtexinfo_t **texinfo, int *numtexinfo,
|
||||||
const byte *mod_base, const lump_t *l, findimage_t find_image,
|
const byte *mod_base, const lump_t *l, findimage_t find_image,
|
||||||
struct image_s *notexture)
|
struct image_s *notexture)
|
||||||
{
|
{
|
||||||
texinfo_t *in;
|
xtexinfo_t *in;
|
||||||
mtexinfo_t *out;
|
mtexinfo_t *out;
|
||||||
int i, count;
|
int i, count;
|
||||||
|
|
||||||
|
@ -946,7 +946,7 @@ static int
|
||||||
calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl)
|
calcTexinfoAndQFacesSize(const byte *mod_base, const lump_t *fl, const lump_t *tl)
|
||||||
{
|
{
|
||||||
dqface_t* face_in = (void *)(mod_base + fl->fileofs);
|
dqface_t* face_in = (void *)(mod_base + fl->fileofs);
|
||||||
const texinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
|
const xtexinfo_t* texinfo_in = (void *)(mod_base + tl->fileofs);
|
||||||
|
|
||||||
if (fl->filelen % sizeof(*face_in) || tl->filelen % sizeof(*texinfo_in))
|
if (fl->filelen % sizeof(*face_in) || tl->filelen % sizeof(*texinfo_in))
|
||||||
{
|
{
|
||||||
|
|
|
@ -359,12 +359,13 @@ static void
|
||||||
Mod_Load2QBSP_IBSP_TEXINFO(byte *outbuf, dheader_t *outheader, const byte *inbuf,
|
Mod_Load2QBSP_IBSP_TEXINFO(byte *outbuf, dheader_t *outheader, const byte *inbuf,
|
||||||
const dheader_t *inheader, size_t rule_size, maptype_t maptype)
|
const dheader_t *inheader, size_t rule_size, maptype_t maptype)
|
||||||
{
|
{
|
||||||
texinfo_t *in, *out;
|
texinfo_t *in;
|
||||||
|
xtexinfo_t *out;
|
||||||
int i, count;
|
int i, count;
|
||||||
|
|
||||||
count = inheader->lumps[LUMP_TEXINFO].filelen / rule_size;
|
count = inheader->lumps[LUMP_TEXINFO].filelen / rule_size;
|
||||||
in = (texinfo_t *)(inbuf + inheader->lumps[LUMP_TEXINFO].fileofs);
|
in = (texinfo_t *)(inbuf + inheader->lumps[LUMP_TEXINFO].fileofs);
|
||||||
out = (texinfo_t *)(outbuf + outheader->lumps[LUMP_TEXINFO].fileofs);
|
out = (xtexinfo_t *)(outbuf + outheader->lumps[LUMP_TEXINFO].fileofs);
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -391,12 +392,12 @@ Mod_Load2QBSP_RBSP_TEXINFO(byte *outbuf, dheader_t *outheader, const byte *inbuf
|
||||||
const dheader_t *inheader, size_t rule_size, maptype_t maptype)
|
const dheader_t *inheader, size_t rule_size, maptype_t maptype)
|
||||||
{
|
{
|
||||||
texrinfo_t *in;
|
texrinfo_t *in;
|
||||||
texinfo_t *out;
|
xtexinfo_t *out;
|
||||||
int i, count;
|
int i, count;
|
||||||
|
|
||||||
count = inheader->lumps[LUMP_TEXINFO].filelen / rule_size;
|
count = inheader->lumps[LUMP_TEXINFO].filelen / rule_size;
|
||||||
in = (texrinfo_t *)(inbuf + inheader->lumps[LUMP_TEXINFO].fileofs);
|
in = (texrinfo_t *)(inbuf + inheader->lumps[LUMP_TEXINFO].fileofs);
|
||||||
out = (texinfo_t *)(outbuf + outheader->lumps[LUMP_TEXINFO].fileofs);
|
out = (xtexinfo_t *)(outbuf + outheader->lumps[LUMP_TEXINFO].fileofs);
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -1014,6 +1015,29 @@ static const rule_t qbsplumps[HEADER_LUMPS] = {
|
||||||
{sizeof(dareaportal_t), Mod_Load2QBSP_IBSP_AREAPORTALS},
|
{sizeof(dareaportal_t), Mod_Load2QBSP_IBSP_AREAPORTALS},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* custom format with extended texture name */
|
||||||
|
static const rule_t xbsplumps[HEADER_LUMPS] = {
|
||||||
|
{sizeof(char), Mod_Load2QBSP_IBSP_ENTITIES},
|
||||||
|
{sizeof(dplane_t), Mod_Load2QBSP_IBSP_PLANES},
|
||||||
|
{sizeof(dvertex_t), Mod_Load2QBSP_IBSP_VERTEXES},
|
||||||
|
{sizeof(char), Mod_Load2QBSP_IBSP_VISIBILITY},
|
||||||
|
{sizeof(dqnode_t), Mod_Load2QBSP_QBSP_NODES},
|
||||||
|
{sizeof(xtexinfo_t), Mod_Load2QBSP_IBSP_TEXINFO},
|
||||||
|
{sizeof(dqface_t), Mod_Load2QBSP_QBSP_FACES},
|
||||||
|
{sizeof(char), Mod_Load2QBSP_IBSP_LIGHTING},
|
||||||
|
{sizeof(dqleaf_t), Mod_Load2QBSP_QBSP_LEAFS},
|
||||||
|
{sizeof(int), Mod_Load2QBSP_QBSP_LEAFFACES},
|
||||||
|
{sizeof(int), Mod_Load2QBSP_QBSP_LEAFBRUSHES},
|
||||||
|
{sizeof(dqedge_t), Mod_Load2QBSP_QBSP_EDGES},
|
||||||
|
{sizeof(int), Mod_Load2QBSP_IBSP_SURFEDGES},
|
||||||
|
{sizeof(dmodel_t), Mod_Load2QBSP_IBSP_MODELS},
|
||||||
|
{sizeof(dbrush_t), Mod_Load2QBSP_IBSP_BRUSHES},
|
||||||
|
{sizeof(dqbrushside_t), Mod_Load2QBSP_QBSP_BRUSHSIDES},
|
||||||
|
{0, NULL}, // LUMP_POP
|
||||||
|
{sizeof(darea_t), Mod_Load2QBSP_IBSP_AREAS},
|
||||||
|
{sizeof(dareaportal_t), Mod_Load2QBSP_IBSP_AREAPORTALS},
|
||||||
|
};
|
||||||
|
|
||||||
static const char*
|
static const char*
|
||||||
Mod_MaptypeName(maptype_t maptype)
|
Mod_MaptypeName(maptype_t maptype)
|
||||||
{
|
{
|
||||||
|
@ -1122,7 +1146,7 @@ Mod_Load2QBSP(const char *name, byte *inbuf, size_t filesize, size_t *out_len,
|
||||||
}
|
}
|
||||||
|
|
||||||
result_size += (
|
result_size += (
|
||||||
qbsplumps[s].size * header.lumps[s].filelen / rules[s].size
|
xbsplumps[s].size * header.lumps[s].filelen / rules[s].size
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1189,13 +1213,13 @@ Mod_Load2QBSP(const char *name, byte *inbuf, size_t filesize, size_t *out_len,
|
||||||
{
|
{
|
||||||
outheader->lumps[s].fileofs = ofs;
|
outheader->lumps[s].fileofs = ofs;
|
||||||
outheader->lumps[s].filelen = (
|
outheader->lumps[s].filelen = (
|
||||||
qbsplumps[s].size * header.lumps[s].filelen / rules[s].size
|
xbsplumps[s].size * header.lumps[s].filelen / rules[s].size
|
||||||
);
|
);
|
||||||
ofs += outheader->lumps[s].filelen;
|
ofs += outheader->lumps[s].filelen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((filesize - xofs) > 0)
|
if (filesize > xofs)
|
||||||
{
|
{
|
||||||
bspx_header_t *bspx_header;
|
bspx_header_t *bspx_header;
|
||||||
bspx_lump_t *lump;
|
bspx_lump_t *lump;
|
||||||
|
@ -1209,6 +1233,11 @@ Mod_Load2QBSP(const char *name, byte *inbuf, size_t filesize, size_t *out_len,
|
||||||
|
|
||||||
/* fix positions */
|
/* fix positions */
|
||||||
numlumps = LittleLong(bspx_header->numlumps);
|
numlumps = LittleLong(bspx_header->numlumps);
|
||||||
|
if ((numlumps * sizeof(*lump)) >= (filesize - xofs))
|
||||||
|
{
|
||||||
|
Com_Error(ERR_DROP, "%s: Map %s has incorrect bspx lumps",
|
||||||
|
__func__, name);
|
||||||
|
}
|
||||||
|
|
||||||
lump = (bspx_lump_t*)(bspx_header + 1);
|
lump = (bspx_lump_t*)(bspx_header + 1);
|
||||||
for (i = 0; i < numlumps; i++, lump++)
|
for (i = 0; i < numlumps; i++, lump++)
|
||||||
|
|
|
@ -1343,7 +1343,7 @@ static void
|
||||||
CMod_LoadSurfaces(const char *name, mapsurface_t **map_surfaces, int *numtexinfo,
|
CMod_LoadSurfaces(const char *name, mapsurface_t **map_surfaces, int *numtexinfo,
|
||||||
const byte *cmod_base, const lump_t *l)
|
const byte *cmod_base, const lump_t *l)
|
||||||
{
|
{
|
||||||
texinfo_t *in;
|
xtexinfo_t *in;
|
||||||
mapsurface_t *out;
|
mapsurface_t *out;
|
||||||
int i, count;
|
int i, count;
|
||||||
|
|
||||||
|
@ -1765,7 +1765,7 @@ CM_LoadCachedMap(const char *name, model_t *mod)
|
||||||
strcpy(mod->name, name);
|
strcpy(mod->name, name);
|
||||||
|
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_TEXINFO],
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_TEXINFO],
|
||||||
sizeof(texinfo_t), sizeof(mapsurface_t), EXTRA_LUMP_TEXINFO);
|
sizeof(xtexinfo_t), sizeof(mapsurface_t), EXTRA_LUMP_TEXINFO);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFS],
|
||||||
sizeof(dqleaf_t), sizeof(cleaf_t), 0);
|
sizeof(dqleaf_t), sizeof(cleaf_t), 0);
|
||||||
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFBRUSHES],
|
hunkSize += Mod_CalcLumpHunkSize(&header->lumps[LUMP_LEAFBRUSHES],
|
||||||
|
|
|
@ -801,7 +801,7 @@ typedef struct
|
||||||
unsigned int numfaces; /* counting both sides */
|
unsigned int numfaces; /* counting both sides */
|
||||||
} dqnode_t;
|
} dqnode_t;
|
||||||
|
|
||||||
typedef struct texinfo_s
|
typedef struct
|
||||||
{
|
{
|
||||||
float vecs[2][4]; /* [s/t][xyz offset] */
|
float vecs[2][4]; /* [s/t][xyz offset] */
|
||||||
int flags; /* miptex flags + overrides light emission, etc */
|
int flags; /* miptex flags + overrides light emission, etc */
|
||||||
|
@ -810,6 +810,16 @@ typedef struct texinfo_s
|
||||||
int nexttexinfo; /* for animations, -1 = end of chain */
|
int nexttexinfo; /* for animations, -1 = end of chain */
|
||||||
} texinfo_t;
|
} texinfo_t;
|
||||||
|
|
||||||
|
/* custom extended textinfo */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
float vecs[2][4]; /* [s/t][xyz offset] */
|
||||||
|
int flags; /* miptex flags + overrides light emission, etc */
|
||||||
|
int value; /* used with some flags, unused in Quake2 */
|
||||||
|
char texture[64]; /* texture name (textures*.wal) */
|
||||||
|
int nexttexinfo; /* for animations, -1 = end of chain */
|
||||||
|
} xtexinfo_t;
|
||||||
|
|
||||||
/* note that edge 0 is never used, because negative edge
|
/* note that edge 0 is never used, because negative edge
|
||||||
nums are used for counterclockwise use of the edge in
|
nums are used for counterclockwise use of the edge in
|
||||||
a face */
|
a face */
|
||||||
|
|
Loading…
Reference in a new issue