Minor berry.c cleanup

This commit is contained in:
Marcus Huderle 2018-12-31 11:16:45 -06:00
parent fb2d1591c1
commit b6ee970e7a
3 changed files with 9 additions and 13 deletions

View File

@ -46,7 +46,7 @@ bool32 IsEnigmaBerryValid(void);
const struct Berry *GetBerryInfo(u8 berry);
struct BerryTree *GetBerryTreeInfo(u8 id);
bool32 EventObjectInteractionWaterBerryTree(void);
bool8 IsPlayerFacingPlantedBerryTree(void);
bool8 IsPlayerFacingEmptyBerryTreePatch(void);
bool8 TryToWaterBerryTree(void);
void ClearBerryTrees(void);
void BerryTreeTimeUpdate(s32 minutes);

View File

@ -857,11 +857,10 @@ const struct UnkStruct_0858AB24 gUnknown_0858AB24[] = {
const struct BerryTree gBlankBerryTree = {};
//.text
// unused
void ClearEnigmaBerries(void)
{
CpuFill16(0, &gSaveBlock1Ptr->enigmaBerry, 52);
CpuFill16(0, &gSaveBlock1Ptr->enigmaBerry, sizeof(gSaveBlock1Ptr->enigmaBerry));
}
void SetEnigmaBerry(u8 *src)
@ -869,7 +868,7 @@ void SetEnigmaBerry(u8 *src)
u32 i;
u8 *dest = (u8*)&gSaveBlock1Ptr->enigmaBerry;
for (i = 0; i < 52; i++)
for (i = 0; i < sizeof(gSaveBlock1Ptr->enigmaBerry); i++)
dest[i] = src[i];
}
@ -881,10 +880,8 @@ static u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry)
dest = (u8*)enigmaBerry;
checksum = 0;
for (i = 0; i < 52 - sizeof(gSaveBlock1Ptr->enigmaBerry.checksum); i++)
{
for (i = 0; i < sizeof(gSaveBlock1Ptr->enigmaBerry) - sizeof(gSaveBlock1Ptr->enigmaBerry.checksum); i++)
checksum += dest[i];
}
return checksum;
}
@ -941,10 +938,10 @@ bool32 EventObjectInteractionWaterBerryTree(void)
return TRUE;
}
bool8 IsPlayerFacingPlantedBerryTree(void)
bool8 IsPlayerFacingEmptyBerryTreePatch(void)
{
if (GetEventObjectScriptPointerPlayerFacing() == BerryTreeScript
&& GetStageByBerryTreeId(EventObjectGetBerryTreeId(gSelectedEventObject)) == 0)
&& GetStageByBerryTreeId(EventObjectGetBerryTreeId(gSelectedEventObject)) == BERRY_STAGE_NO_BERRY)
return TRUE;
else
return FALSE;
@ -1046,11 +1043,10 @@ void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle)
tree->berryYield = CalcBerryYield(tree);
tree->minutesUntilNextStage *= 4;
}
if (!sparkle)
{
tree->growthSparkle = TRUE;
}
}
void RemoveBerryTree(u8 id)
{
@ -1072,7 +1068,7 @@ u8 ItemIdToBerryType(u16 item)
u16 berry = item - FIRST_BERRY_INDEX;
if (berry > LAST_BERRY_INDEX - FIRST_BERRY_INDEX)
return 1;
return ITEM_TO_BERRY(FIRST_BERRY_INDEX);
else
return ITEM_TO_BERRY(item);
}

View File

@ -666,7 +666,7 @@ void ItemUseOutOfBattle_PowderJar(u8 taskId)
void sub_80FDD10(u8 taskId)
{
if (IsPlayerFacingPlantedBerryTree() == TRUE)
if (IsPlayerFacingEmptyBerryTreePatch() == TRUE)
{
gUnknown_0203A0F4 = sub_80FDD74;
gFieldCallback = MapPostLoadHook_UseItem;