Fix the Hanagumi Hall ring vent overflow

The way the cap was being handled was kind of messed up, and was trying to subtract your existing Super Ring count.
But because the datatype doesn't support negative numbers, it rolled under to approx UINT16_MAX!
Fix the datatypes and add the extra over-range check to prevent this from happening again.
This commit is contained in:
toaster 2023-11-02 11:24:54 +00:00
parent 429f84f6b6
commit 263c968cc8
2 changed files with 6 additions and 2 deletions

View file

@ -3650,7 +3650,7 @@ angle_t K_MomentumAngleReal(const mobj_t *mo)
}
}
void K_AwardPlayerRings(player_t *player, INT32 rings, boolean overload)
void K_AwardPlayerRings(player_t *player, UINT16 rings, boolean overload)
{
UINT16 superring;
@ -3661,7 +3661,11 @@ void K_AwardPlayerRings(player_t *player, INT32 rings, boolean overload)
/* capped at 20 rings */
if ((totalrings + rings) > 20)
{
if (totalrings >= 20)
return; // woah dont let that go negative buster
rings = (20 - totalrings);
}
}
superring = player->superring + rings;

View file

@ -105,7 +105,7 @@ void K_KartPlayerAfterThink(player_t *player);
angle_t K_MomentumAngleEx(const mobj_t *mo, const fixed_t threshold);
angle_t K_MomentumAngleReal(const mobj_t *mo);
#define K_MomentumAngle(mo) K_MomentumAngleEx(mo, 6 * mo->scale)
void K_AwardPlayerRings(player_t *player, INT32 rings, boolean overload);
void K_AwardPlayerRings(player_t *player, UINT16 rings, boolean overload);
void K_DoInstashield(player_t *player);
void K_DoPowerClash(mobj_t *t1, mobj_t *t2);
void K_DoGuardBreak(mobj_t *t1, mobj_t *t2);