Fix crash in DDays "wake" map, #978

the HunkAlloc size calculated in calTexinfoAndFacesSize() was too
small because that map has a *massive* water poly.
Unfortunately it's not feasible to calculate the correct size
(it depends on the size of the poly, for which I'd need the vertex
coordinates, but to get them I'd have to load them first, which requires
the allocation...), but allocating 5MB extra (instead of 1) made it work

c2d80c64ee
This commit is contained in:
Daniel Gibson 2023-03-26 00:37:37 +02:00 committed by Denis Pauk
parent 3950773186
commit ca801b6445

View file

@ -352,7 +352,7 @@ calcTexinfoAndFacesSize(const lump_t *fl, const byte *mod_base, const lump_t *tl
// 256-55000 bytes are allocated (usually on the lower end),
// so just assume 48k per face to be safe
ret += numWarpFaces * 49152;
ret += 1000000; // and 1MB extra just in case
ret += 5000000; // and 5MB extra just in case
return ret;
}
@ -624,7 +624,7 @@ Mod_LoadBrushModel (model_t *mod, const void *buffer, int modfilelen)
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LIGHTING], 1, 1);
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_PLANES], sizeof(dplane_t), sizeof(cplane_t)*2);
hunkSize += calcTexinfoAndFacesSize(&header->lumps[LUMP_FACES], mod_base, &header->lumps[LUMP_TEXINFO]);
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LEAFFACES], sizeof(short), sizeof(msurface_t *)); // yes, out is indeeed a pointer!
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LEAFFACES], sizeof(short), sizeof(msurface_t *)); // yes, out is indeed a pointer!
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_VISIBILITY], 1, 1);
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LEAFS], sizeof(dleaf_t), sizeof(mleaf_t));
hunkSize += calcLumpHunkSize(&header->lumps[LUMP_NODES], sizeof(dnode_t), sizeof(mnode_t));