Berry stuck (temporal?) fix

This commit is contained in:
resetes12
2023-07-01 10:10:14 +02:00
parent 241518c8ea
commit 4664ef8ab3
3 changed files with 20 additions and 0 deletions

View File

@@ -4,5 +4,6 @@
// TODO: time of day and seconds in a day defines
void DoTimeBasedEvents(void);
void FastForwardTime(s16, s16);
#endif // GUARD_CLOCK_H

View File

@@ -84,3 +84,17 @@ void StartWallClock(void)
SetMainCallback2(CB2_StartWallClock);
gMain.savedCallback = ReturnFromStartWallClock;
}
void FastForwardTime(s16 daysToUpdateDay, s16 hoursToGrowBerries){
// Runs the UpdatePerDay function as if daysToUpdateDay days have passed and grows the berries by hoursToGrowBerries
s16 daysBerry = hoursToGrowBerries / 24;
s8 hoursBerry = hoursToGrowBerries % 24;
struct Time localTimeOffset;
localTimeOffset.days = *GetVarPointer(VAR_DAYS) + daysToUpdateDay;
UpdatePerDay(&localTimeOffset);
localTimeOffset = gSaveBlock2Ptr->lastBerryTreeUpdate;
localTimeOffset.days += daysBerry;
localTimeOffset.hours += hoursBerry;
UpdatePerMinute(&localTimeOffset);
}

View File

@@ -890,6 +890,11 @@ static void Task_ViewClock_HandleInput(u8 taskId)
ScheduleBgCopyTilemapToVram(2);
gTasks[taskId].func = Task_SetClock_HandleInput;
}
if ((VarGet(VAR_DEBUG_OPTIONS) == 1) && (JOY_HELD(SELECT_BUTTON) && JOY_NEW(L_BUTTON)))
{
PlaySE(SE_SELECT);
FastForwardTime(10, 4);
}
}
static void Task_ViewClock_FadeOut(u8 taskId)