[battle_controller_player.c] refactor and fix buffer overread (#3792)
Co-authored-by: sbird <sbird@no.tld>
This commit is contained in:
parent
38d67d9051
commit
5651bea82b
@ -225,16 +225,16 @@ static u16 GetPrevBall(u16 ballId)
|
||||
return gBagPockets[BALLS_POCKET].itemSlots[i].itemId;
|
||||
}
|
||||
|
||||
static u16 GetNextBall(u16 ballId)
|
||||
static u32 GetNextBall(u32 ballId)
|
||||
{
|
||||
u16 ballNext = 0;
|
||||
u32 ballNext = ITEM_NONE;
|
||||
s32 i;
|
||||
CompactItemsInBagPocket(&gBagPockets[BALLS_POCKET]);
|
||||
for (i = 0; i < gBagPockets[BALLS_POCKET].capacity; i++)
|
||||
for (i = 1; i < gBagPockets[BALLS_POCKET].capacity; i++)
|
||||
{
|
||||
if (ballId == gBagPockets[BALLS_POCKET].itemSlots[i].itemId)
|
||||
if (ballId == gBagPockets[BALLS_POCKET].itemSlots[i-1].itemId)
|
||||
{
|
||||
ballNext = gBagPockets[BALLS_POCKET].itemSlots[i+1].itemId;
|
||||
ballNext = gBagPockets[BALLS_POCKET].itemSlots[i].itemId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user