From f13871ddbf58894b830da744d1fe93b7a743790c Mon Sep 17 00:00:00 2001 From: Eidolon Date: Thu, 28 Sep 2023 11:44:55 -0500 Subject: [PATCH] Conditionally randomize precip height --- src/p_mobj.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 504077f99..984a9bfa8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11640,6 +11640,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) @@ -11658,8 +11661,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; + } } } }