Match ShootingStarMgr::initSchedule (#114)

This commit is contained in:
Briggs Baltzell 2023-01-25 05:48:06 -06:00 committed by GitHub
parent 6198143b5f
commit 969b1c3f33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 18 deletions

View File

@ -89438,7 +89438,7 @@ Address,Quality,Size,Name
0x00000071010dce80,O,000004,_ZN4ksys5world15ShootingStarMgrD1Ev
0x00000071010dce84,O,000036,_ZN4ksys5world15ShootingStarMgrD0Ev
0x00000071010dcea8,O,000036,_ZN4ksys5world15ShootingStarMgr5init_EPN4sead4HeapE
0x00000071010dcecc,M,000620,_ZN4ksys5world15ShootingStarMgr12initScheduleEv
0x00000071010dcecc,O,000620,_ZN4ksys5world15ShootingStarMgr12initScheduleEv
0x00000071010dd138,O,000368,_ZN4ksys5world15ShootingStarMgr5calc_Ev
0x00000071010dd2a8,O,000116,_ZN4ksys5world15ShootingStarMgr15isScheduledTimeEv
0x00000071010dd31c,U,000308,

Can't render this file because it is too large.

View File

@ -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);
}
}
if (sHours.end > 1) {
for (int i = 0; i < 23; ++i) {
validHours.emplaceBack(i);
}
}
auto rand = sead::Random();
validHours.shuffle(&rand);
mFallHour = *validHours[0];
s32 fall_hour;
if (start_hour <= end_hour) {
// Time range is continuous.
fall_hour = sead::GlobalRandom::instance()->getS32Range(start_hour, end_hour);
} else {
mFallHour = sead::GlobalRandom::instance()->getS32Range(sHours.start, sHours.end - 1);
// 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);
}
for (int i = 0; i < end_hour; ++i) {
valid_hours.emplaceBack(i);
}
valid_hours.shuffle();
fall_hour = *valid_hours[0];
}
mFallHour = fall_hour;
mFallMinute = sead::GlobalRandom::instance()->getU32(59);
mInitialised = true;
}