Magic number + more modular

This commit is contained in:
PurpleHato 2025-08-02 18:27:53 +02:00
commit faa96b30c2
3 changed files with 11 additions and 6 deletions

View file

@ -112,7 +112,9 @@ typedef enum {
typedef enum {
TIME_TRAVEL_DISABLED,
TIME_TRAVEL_OOT,
TIME_TRAVEL_OOT_MS,
TIME_TRAVEL_ANY,
TIME_TRAVEL_ANY_MS
} TimeTravelType;
typedef enum {

View file

@ -131,10 +131,11 @@ void RegisterOcarinaTimeTravel() {
bool notNearAnySource = !nearbyTimeBlockEmpty && !nearbyTimeBlock && !nearbyOcarinaSpot && !nearbyDoorOfTime &&
!nearbyFrogs && !nearbyGossipStone;
bool hasOcarinaOfTime = (INV_CONTENT(ITEM_OCARINA_TIME) == ITEM_OCARINA_TIME);
bool doesntNeedOcarinaOfTime = CVarGetInteger(CVAR_ENHANCEMENT("TimeTravel"), 0) == 2;
bool hasMasterSword = CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER);
// TODO: Once Swordless Adult is fixed: Remove the Master Sword check
if (justPlayedSoT && notNearAnySource && (hasOcarinaOfTime || doesntNeedOcarinaOfTime) && hasMasterSword) {
int timeTravelSetting = CVarGetInteger(CVAR_ENHANCEMENT("TimeTravel"), 0);
bool doesntNeedOcarinaOfTime = timeTravelSetting == TIME_TRAVEL_ANY || timeTravelSetting == TIME_TRAVEL_ANY_MS;
bool needMasterSwordAndOcarina = timeTravelSetting == TIME_TRAVEL_ANY_MS || timeTravelSetting == TIME_TRAVEL_OOT_MS;
if (justPlayedSoT && notNearAnySource && (hasOcarinaOfTime || doesntNeedOcarinaOfTime || needMasterSwordAndOcarina)) {
SwitchAge();
}
});

View file

@ -56,7 +56,9 @@ static const std::unordered_map<int32_t, const char*> chestStyleMatchesContentsO
static const std::unordered_map<int32_t, const char*> timeTravelOptions = {
{ TIME_TRAVEL_DISABLED, "Disabled" },
{ TIME_TRAVEL_OOT, "Ocarina of Time" },
{ TIME_TRAVEL_OOT_MS, "Ocarina of Time + Master Sword" },
{ TIME_TRAVEL_ANY, "Any Ocarina" },
{ TIME_TRAVEL_ANY_MS, "Any Ocarina + Master Sword" },
};
static const std::unordered_map<int32_t, const char*> sleepingWaterfallOptions = {
@ -783,9 +785,9 @@ void SohMenu::AddMenuEnhancements() {
.Tooltip("Allows Link to freely change age by playing the Song of Time.\n"
"Time Blocks can still be used properly.\n\n"
"Requirements:\n"
" - Obtained the Ocarina of Time (depends on selection)\n"
" - Obtained the Song of Time\n"
" - Obtained the Master Sword\n"
" - Obtained the Ocarina of Time (depends on selection)\n"
" - Obtained the Master Sword (depends on selection)\n"
" - Not within range of a Time Block\n"
" - Not within range of Ocarina Playing spots"));