summaryrefslogtreecommitdiff
path: root/src/KingSystem
diff options
context:
space:
mode:
authorBriggs Baltzell <b3apollo13@gmail.com>2023-01-25 05:48:06 -0600
committerGitHub <noreply@github.com>2023-01-25 12:48:06 +0100
commit969b1c3f33b4edb3ed4cf74af063c371280a8fe9 (patch)
treebfd12bdcf9a3899fc1e78cbc66d7614be6138f9d /src/KingSystem
parent6198143b5fa84c57b99b946bfc4068e137c592f9 (diff)
Match ShootingStarMgr::initSchedule (#114)
Diffstat (limited to 'src/KingSystem')
-rw-r--r--src/KingSystem/World/worldShootingStarMgr.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/KingSystem/World/worldShootingStarMgr.cpp b/src/KingSystem/World/worldShootingStarMgr.cpp
index b1d0066c..03920fd3 100644
--- a/src/KingSystem/World/worldShootingStarMgr.cpp
+++ b/src/KingSystem/World/worldShootingStarMgr.cpp
@@ -30,27 +30,32 @@ void ShootingStarMgr::init_(sead::Heap* heap) {
initSchedule();
}
-// NON_MATCHING
void ShootingStarMgr::initSchedule() {
- if (sHours.start >= sHours.end) {
- sead::FixedObjArray<u32, 24> validHours;
+ const s32& start_hour = sHours.start;
+ const s32 end_hour = sHours.end - 1;
- if (sHours.start <= 23) {
- for (int i = 0; i < 24; ++i) {
- validHours.emplaceBack(sHours.start);
- }
+ s32 fall_hour;
+
+ if (start_hour <= end_hour) {
+ // Time range is continuous.
+ fall_hour = sead::GlobalRandom::instance()->getS32Range(start_hour, end_hour);
+ } else {
+ // Time range is discontinuous.
+ // Fill an array with valid hours, shuffle it, and take the first.
+ sead::FixedObjArray<s32, 24> valid_hours;
+
+ for (int i = start_hour; i < 24; ++i) {
+ valid_hours.emplaceBack(i);
}
- if (sHours.end > 1) {
- for (int i = 0; i < 23; ++i) {
- validHours.emplaceBack(i);
- }
+ for (int i = 0; i < end_hour; ++i) {
+ valid_hours.emplaceBack(i);
}
- auto rand = sead::Random();
- validHours.shuffle(&rand);
- mFallHour = *validHours[0];
- } else {
- mFallHour = sead::GlobalRandom::instance()->getS32Range(sHours.start, sHours.end - 1);
+
+ valid_hours.shuffle();
+ fall_hour = *valid_hours[0];
}
+
+ mFallHour = fall_hour;
mFallMinute = sead::GlobalRandom::instance()->getU32(59);
mInitialised = true;
}