diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 67ee815f..977b2e8a 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -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, 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 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 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; }