Remove redundancy in berry.c

This commit is contained in:
Slawter666 2018-11-06 23:15:57 +00:00
parent bd766b9049
commit 15117a8d09
2 changed files with 3 additions and 8 deletions

View File

@ -2,11 +2,6 @@
#define GUARD_BERRY_H #define GUARD_BERRY_H
#define BERRY_NONE 0 #define BERRY_NONE 0
#define FIRST_BERRY ITEM_CHERI_BERRY
#define LAST_BERRY ITEM_ENIGMA_BERRY
#define GETBERRYID(berry) ((berry - FIRST_BERRY) + 1)
#define GETITEMID(berry) ((berry + FIRST_BERRY) - 1)
enum enum
{ {

View File

@ -902,12 +902,12 @@ bool32 IsEnigmaBerryValid(void)
const struct Berry *GetBerryInfo(u8 berry) const struct Berry *GetBerryInfo(u8 berry)
{ {
if (berry == GETBERRYID(ITEM_ENIGMA_BERRY) && IsEnigmaBerryValid()) if (berry == ITEM_TO_BERRY(ITEM_ENIGMA_BERRY) && IsEnigmaBerryValid())
return (struct Berry*)(&gSaveBlock1Ptr->enigmaBerry.berry); return (struct Berry*)(&gSaveBlock1Ptr->enigmaBerry.berry);
else else
{ {
if (berry == BERRY_NONE || berry > GETBERRYID(LAST_BERRY)) if (berry == BERRY_NONE || berry > ITEM_TO_BERRY(LAST_BERRY_INDEX))
berry = GETBERRYID(FIRST_BERRY); berry = ITEM_TO_BERRY(FIRST_BERRY_INDEX);
return &gBerries[berry - 1]; return &gBerries[berry - 1];
} }
} }