Fix off-by-one errors in item odds, and add a little assert to make an assumption in this function that was being violated more explicit.

This commit is contained in:
toaster 2019-02-06 13:28:21 +00:00
parent 1c3fe3ce83
commit 970a8ee89d
1 changed files with 5 additions and 3 deletions

View File

@ -616,7 +616,7 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed)
UINT8 pingame = 0, pexiting = 0, pinvin = 0;
SINT8 first = -1, second = -1;
INT32 secondist = 0;
boolean itemenabled[NUMKARTRESULTS] = {
boolean itemenabled[NUMKARTRESULTS-1] = {
cv_sneaker.value,
cv_rocketsneaker.value,
cv_invincibility.value,
@ -640,7 +640,9 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed)
cv_dualjawz.value
};
if (!itemenabled[item] && !modeattacking)
I_Assert(item > KITEM_NONE); // too many off by one scenarioes.
if (!itemenabled[item-1] && !modeattacking)
return 0;
if (G_BattleGametype())
@ -761,7 +763,7 @@ static INT32 K_FindUseodds(player_t *player, fixed_t mashed, INT32 pingame, INT3
break;
}
for (j = 0; j < NUMKARTRESULTS; j++)
for (j = 1; j < NUMKARTRESULTS; j++)
{
if (K_KartGetItemOdds(i, j, mashed) > 0)
{