Don't allocate the mark if the number of allocated polys is insufficient

There was a very rare occurrence where it would hang trying to find a free mark poly, when the number of specified polys was more than the number of allocated polys. This bug also occurs in the original game
This commit is contained in:
smallmodel 2024-11-11 15:08:08 +01:00
parent 5edee7d12e
commit 7bcb91bbb5
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512

View file

@ -425,6 +425,8 @@ void CG_FreeMarkObj(markObj_t *pMark)
markPoly_t *pPoly;
markPoly_t *pNextPoly;
assert(pMark != &cg_activeMarkObjs);
for (pPoly = pMark->markPolys; pPoly; pPoly = pNextPoly) {
pNextPoly = pPoly->nextPoly;
CG_FreeMarkPoly(pPoly);
@ -489,6 +491,12 @@ markObj_t *CG_AllocMark(int iNumPolys)
return NULL;
}
if (iNumPolys > cg_iNumMarkPolys) {
// Added in OPM
// Make sure to not over allocate polys
return NULL;
}
if (cg_iNumFreeMarkObjs <= cg_iMinFreeMarkObjs) {
CG_FreeBestMarkObj(1);
}