diff --git a/include/berry.h b/include/berry.h index bef56ae41..ee581b9c1 100644 --- a/include/berry.h +++ b/include/berry.h @@ -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); diff --git a/src/berry.c b/src/berry.c index 24ed370c3..bd596db7f 100644 --- a/src/berry.c +++ b/src/berry.c @@ -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,10 +1043,9 @@ 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); } diff --git a/src/item_use.c b/src/item_use.c index 91fdc81c8..6a7f6cec0 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -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;