Merge branch 'precip-height-random-crash' into 'master'

Conditionally randomize precip height

Closes #528

See merge request KartKrew/Kart!1536
This commit is contained in:
James R 2023-10-04 00:12:10 +00:00
commit 6b18563549

View file

@ -11652,6 +11652,9 @@ static void P_SpawnPrecipitationAt(fixed_t basex, fixed_t basey)
for (j = 0; j < numparticles; j++)
{
INT32 floorz;
INT32 ceilingz;
rainmo = P_SpawnPrecipMobj(x, y, z, type);
if (randomstates > 0)
@ -11670,8 +11673,19 @@ static void P_SpawnPrecipitationAt(fixed_t basex, fixed_t basey)
}
}
// Randomly assign a height, now that floorz is set.
rainmo->z = M_RandomRange(rainmo->floorz >> FRACBITS, rainmo->ceilingz >> FRACBITS) << FRACBITS;
floorz = rainmo->floorz >> FRACBITS;
ceilingz = rainmo->ceilingz >> FRACBITS;
if (floorz < ceilingz)
{
// Randomly assign a height, now that floorz is set.
rainmo->z = M_RandomRange(floorz, ceilingz) << FRACBITS;
}
else
{
// ...except if the floor is above the ceiling.
rainmo->z = ceilingz << FRACBITS;
}
}
}
}