Replace watered bits with a single equivalent field

This commit is contained in:
Bassoonian 2023-12-05 20:24:03 +01:00
parent e4fd7845ee
commit 5f2c8dfb0b
2 changed files with 10 additions and 16 deletions

View file

@ -76,10 +76,7 @@ struct BerryTree
u8 pests:1; u8 pests:1;
u8 mutationB:2; u8 mutationB:2;
u8 regrowthCount:4; u8 regrowthCount:4;
u8 watered1:1; u8 watered:4;
u8 watered2:1;
u8 watered3:1;
u8 watered4:1;
u16 moistureLevel:7; u16 moistureLevel:7;
u16 moistureClock:6; u16 moistureClock:6;
u16 padding:3; u16 padding:3;

View file

@ -1637,16 +1637,16 @@ bool32 ObjectEventInteractionWaterBerryTree(void)
switch (tree->stage) switch (tree->stage)
{ {
case BERRY_STAGE_PLANTED: case BERRY_STAGE_PLANTED:
tree->watered1 = TRUE; tree->watered |= (1 << 0);
break; break;
case BERRY_STAGE_SPROUTED: case BERRY_STAGE_SPROUTED:
tree->watered2 = TRUE; tree->watered |= (1 << 1);
break; break;
case BERRY_STAGE_TALLER: case BERRY_STAGE_TALLER:
tree->watered3 = TRUE; tree->watered |= (1 << 2);
break; break;
case BERRY_STAGE_FLOWERING: case BERRY_STAGE_FLOWERING:
tree->watered4 = TRUE; tree->watered |= (1 << 3);
break; break;
default: default:
return FALSE; return FALSE;
@ -1696,10 +1696,7 @@ static bool32 BerryTreeGrow(struct BerryTree *tree)
tree->stage++; tree->stage++;
break; break;
case BERRY_STAGE_BERRIES: case BERRY_STAGE_BERRIES:
tree->watered1 = 0; tree->watered = 0;
tree->watered2 = 0;
tree->watered3 = 0;
tree->watered4 = 0;
tree->berryYield = 0; tree->berryYield = 0;
tree->stage = BERRY_STAGE_SPROUTED; tree->stage = BERRY_STAGE_SPROUTED;
if (++tree->regrowthCount == ((tree->mulch == ITEM_TO_MULCH(ITEM_GOOEY_MULCH)) ? 15 : 10)) if (++tree->regrowthCount == ((tree->mulch == ITEM_TO_MULCH(ITEM_GOOEY_MULCH)) ? 15 : 10))
@ -1839,13 +1836,13 @@ static u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree)
{ {
u8 count = 0; u8 count = 0;
if (tree->watered1) if (tree->watered & (1 << 0))
count++; count++;
if (tree->watered2) if (tree->watered & (1 << 1))
count++; count++;
if (tree->watered3) if (tree->watered & (1 << 2))
count++; count++;
if (tree->watered4) if (tree->watered & (1 << 3))
count++; count++;
return count; return count;
} }