mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 19:24:16 +01:00
Minor berry.c cleanup
This commit is contained in:
parent
fb2d1591c1
commit
b6ee970e7a
@ -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);
|
||||
|
18
src/berry.c
18
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,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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user