mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +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);
|
const struct Berry *GetBerryInfo(u8 berry);
|
||||||
struct BerryTree *GetBerryTreeInfo(u8 id);
|
struct BerryTree *GetBerryTreeInfo(u8 id);
|
||||||
bool32 EventObjectInteractionWaterBerryTree(void);
|
bool32 EventObjectInteractionWaterBerryTree(void);
|
||||||
bool8 IsPlayerFacingPlantedBerryTree(void);
|
bool8 IsPlayerFacingEmptyBerryTreePatch(void);
|
||||||
bool8 TryToWaterBerryTree(void);
|
bool8 TryToWaterBerryTree(void);
|
||||||
void ClearBerryTrees(void);
|
void ClearBerryTrees(void);
|
||||||
void BerryTreeTimeUpdate(s32 minutes);
|
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 = {};
|
const struct BerryTree gBlankBerryTree = {};
|
||||||
|
|
||||||
//.text
|
|
||||||
// unused
|
// unused
|
||||||
void ClearEnigmaBerries(void)
|
void ClearEnigmaBerries(void)
|
||||||
{
|
{
|
||||||
CpuFill16(0, &gSaveBlock1Ptr->enigmaBerry, 52);
|
CpuFill16(0, &gSaveBlock1Ptr->enigmaBerry, sizeof(gSaveBlock1Ptr->enigmaBerry));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetEnigmaBerry(u8 *src)
|
void SetEnigmaBerry(u8 *src)
|
||||||
@ -869,7 +868,7 @@ void SetEnigmaBerry(u8 *src)
|
|||||||
u32 i;
|
u32 i;
|
||||||
u8 *dest = (u8*)&gSaveBlock1Ptr->enigmaBerry;
|
u8 *dest = (u8*)&gSaveBlock1Ptr->enigmaBerry;
|
||||||
|
|
||||||
for (i = 0; i < 52; i++)
|
for (i = 0; i < sizeof(gSaveBlock1Ptr->enigmaBerry); i++)
|
||||||
dest[i] = src[i];
|
dest[i] = src[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -881,10 +880,8 @@ static u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry)
|
|||||||
|
|
||||||
dest = (u8*)enigmaBerry;
|
dest = (u8*)enigmaBerry;
|
||||||
checksum = 0;
|
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];
|
checksum += dest[i];
|
||||||
}
|
|
||||||
|
|
||||||
return checksum;
|
return checksum;
|
||||||
}
|
}
|
||||||
@ -941,10 +938,10 @@ bool32 EventObjectInteractionWaterBerryTree(void)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool8 IsPlayerFacingPlantedBerryTree(void)
|
bool8 IsPlayerFacingEmptyBerryTreePatch(void)
|
||||||
{
|
{
|
||||||
if (GetEventObjectScriptPointerPlayerFacing() == BerryTreeScript
|
if (GetEventObjectScriptPointerPlayerFacing() == BerryTreeScript
|
||||||
&& GetStageByBerryTreeId(EventObjectGetBerryTreeId(gSelectedEventObject)) == 0)
|
&& GetStageByBerryTreeId(EventObjectGetBerryTreeId(gSelectedEventObject)) == BERRY_STAGE_NO_BERRY)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1046,11 +1043,10 @@ void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle)
|
|||||||
tree->berryYield = CalcBerryYield(tree);
|
tree->berryYield = CalcBerryYield(tree);
|
||||||
tree->minutesUntilNextStage *= 4;
|
tree->minutesUntilNextStage *= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sparkle)
|
if (!sparkle)
|
||||||
{
|
|
||||||
tree->growthSparkle = TRUE;
|
tree->growthSparkle = TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void RemoveBerryTree(u8 id)
|
void RemoveBerryTree(u8 id)
|
||||||
{
|
{
|
||||||
@ -1072,7 +1068,7 @@ u8 ItemIdToBerryType(u16 item)
|
|||||||
u16 berry = item - FIRST_BERRY_INDEX;
|
u16 berry = item - FIRST_BERRY_INDEX;
|
||||||
|
|
||||||
if (berry > LAST_BERRY_INDEX - FIRST_BERRY_INDEX)
|
if (berry > LAST_BERRY_INDEX - FIRST_BERRY_INDEX)
|
||||||
return 1;
|
return ITEM_TO_BERRY(FIRST_BERRY_INDEX);
|
||||||
else
|
else
|
||||||
return ITEM_TO_BERRY(item);
|
return ITEM_TO_BERRY(item);
|
||||||
}
|
}
|
||||||
|
@ -666,7 +666,7 @@ void ItemUseOutOfBattle_PowderJar(u8 taskId)
|
|||||||
|
|
||||||
void sub_80FDD10(u8 taskId)
|
void sub_80FDD10(u8 taskId)
|
||||||
{
|
{
|
||||||
if (IsPlayerFacingPlantedBerryTree() == TRUE)
|
if (IsPlayerFacingEmptyBerryTreePatch() == TRUE)
|
||||||
{
|
{
|
||||||
gUnknown_0203A0F4 = sub_80FDD74;
|
gUnknown_0203A0F4 = sub_80FDD74;
|
||||||
gFieldCallback = MapPostLoadHook_UseItem;
|
gFieldCallback = MapPostLoadHook_UseItem;
|
||||||
|
Loading…
Reference in New Issue
Block a user