Calculate buffer size manually

(Yes, I checked; this always outputs "3" for its current usage.)
This commit is contained in:
TehRealSalt 2018-11-26 05:09:56 -05:00
parent 494fa55390
commit 4bd6ae3f04

View file

@ -3273,11 +3273,20 @@ INT16 G_RandMap(INT16 tolflags, INT16 pprevmap, boolean ignorebuffer, UINT8 maph
{ {
INT32 numokmaps = 0; INT32 numokmaps = 0;
INT16 ix, bufx; INT16 ix, bufx;
UINT16 extbufsize = 0;
boolean usehellmaps; // Only consider Hell maps in this pick boolean usehellmaps; // Only consider Hell maps in this pick
if (!okmaps) if (!okmaps)
okmaps = Z_Malloc(NUMMAPS * sizeof(INT16), PU_STATIC, NULL); okmaps = Z_Malloc(NUMMAPS * sizeof(INT16), PU_STATIC, NULL);
if (extbuffer != NULL)
{
bufx = 0;
while (extbuffer[bufx]) {
extbufsize++; bufx++;
}
}
tryagain: tryagain:
usehellmaps = (maphell == 0 ? false : (maphell == 2 || M_RandomChance(FRACUNIT/100))); // 1% chance of Hell usehellmaps = (maphell == 0 ? false : (maphell == 2 || M_RandomChance(FRACUNIT/100))); // 1% chance of Hell
@ -3298,9 +3307,9 @@ tryagain:
if (!ignorebuffer) if (!ignorebuffer)
{ {
if (extbuffer != NULL) if (extbufsize > 0)
{ {
for (bufx = 0; bufx < (INT16)(sizeof extbuffer); bufx++) for (bufx = 0; bufx < extbufsize; bufx++)
{ {
if (extbuffer[bufx] == -1) // Rest of buffer SHOULD be empty if (extbuffer[bufx] == -1) // Rest of buffer SHOULD be empty
break; break;