Merge pull request #3945 from HarbourMasters/develop-macready

macready -> develop
This commit is contained in:
Garrett Cox 2024-02-15 21:21:18 -06:00 committed by GitHub
commit 10b6f8cf80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 74 additions and 38 deletions

View File

@ -37,12 +37,19 @@ GameInteractionEffectQueryResult GameInteractor::RemoveEffect(RemovableGameInter
// MARK: - Helpers // MARK: - Helpers
bool GameInteractor::IsSaveLoaded() { bool GameInteractor::IsSaveLoaded(bool allowDbgSave) {
Player* player; Player* player;
if (gPlayState != NULL) { if (gPlayState != NULL) {
player = GET_PLAYER(gPlayState); player = GET_PLAYER(gPlayState);
} }
return (gPlayState == NULL || player == NULL || gSaveContext.fileNum < 0 || gSaveContext.fileNum > 2) ? false : true;
// Checking for normal game mode prevents debug saves from reporting true on title screen
if (gPlayState == NULL || player == NULL || gSaveContext.gameMode != GAMEMODE_NORMAL) {
return false;
}
// Valid save file or debug save
return (gSaveContext.fileNum >= 0 && gSaveContext.fileNum <= 2) || (allowDbgSave && gSaveContext.fileNum == 0xFF);
} }
bool GameInteractor::IsGameplayPaused() { bool GameInteractor::IsGameplayPaused() {

View File

@ -243,7 +243,7 @@ public:
DEFINE_HOOK(OnKaleidoUpdate, void()); DEFINE_HOOK(OnKaleidoUpdate, void());
// Helpers // Helpers
static bool IsSaveLoaded(); static bool IsSaveLoaded(bool allowDbgSave = false);
static bool IsGameplayPaused(); static bool IsGameplayPaused();
static bool CanSpawnActor(); static bool CanSpawnActor();
static bool CanAddOrTakeAmmo(int16_t amount, int16_t item); static bool CanAddOrTakeAmmo(int16_t amount, int16_t item);

View File

@ -64,7 +64,7 @@ void ReloadSceneTogglingLinkAge() {
void RegisterInfiniteMoney() { void RegisterInfiniteMoney() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() { GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded()) return; if (!GameInteractor::IsSaveLoaded(true)) return;
if (CVarGetInteger("gInfiniteMoney", 0) != 0) { if (CVarGetInteger("gInfiniteMoney", 0) != 0) {
if (gSaveContext.rupees < CUR_CAPACITY(UPG_WALLET)) { if (gSaveContext.rupees < CUR_CAPACITY(UPG_WALLET)) {
gSaveContext.rupees = CUR_CAPACITY(UPG_WALLET); gSaveContext.rupees = CUR_CAPACITY(UPG_WALLET);
@ -75,7 +75,7 @@ void RegisterInfiniteMoney() {
void RegisterInfiniteHealth() { void RegisterInfiniteHealth() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() { GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded()) return; if (!GameInteractor::IsSaveLoaded(true)) return;
if (CVarGetInteger("gInfiniteHealth", 0) != 0) { if (CVarGetInteger("gInfiniteHealth", 0) != 0) {
if (gSaveContext.health < gSaveContext.healthCapacity) { if (gSaveContext.health < gSaveContext.healthCapacity) {
gSaveContext.health = gSaveContext.healthCapacity; gSaveContext.health = gSaveContext.healthCapacity;
@ -86,7 +86,7 @@ void RegisterInfiniteHealth() {
void RegisterInfiniteAmmo() { void RegisterInfiniteAmmo() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() { GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded()) return; if (!GameInteractor::IsSaveLoaded(true)) return;
if (CVarGetInteger("gInfiniteAmmo", 0) != 0) { if (CVarGetInteger("gInfiniteAmmo", 0) != 0) {
// Deku Sticks // Deku Sticks
if (AMMO(ITEM_STICK) < CUR_CAPACITY(UPG_STICKS)) { if (AMMO(ITEM_STICK) < CUR_CAPACITY(UPG_STICKS)) {
@ -123,7 +123,7 @@ void RegisterInfiniteAmmo() {
void RegisterInfiniteMagic() { void RegisterInfiniteMagic() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() { GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded()) return; if (!GameInteractor::IsSaveLoaded(true)) return;
if (CVarGetInteger("gInfiniteMagic", 0) != 0) { if (CVarGetInteger("gInfiniteMagic", 0) != 0) {
if (gSaveContext.isMagicAcquired && gSaveContext.magic != (gSaveContext.isDoubleMagicAcquired + 1) * 0x30) { if (gSaveContext.isMagicAcquired && gSaveContext.magic != (gSaveContext.isDoubleMagicAcquired + 1) * 0x30) {
gSaveContext.magic = (gSaveContext.isDoubleMagicAcquired + 1) * 0x30; gSaveContext.magic = (gSaveContext.isDoubleMagicAcquired + 1) * 0x30;
@ -134,7 +134,7 @@ void RegisterInfiniteMagic() {
void RegisterInfiniteNayrusLove() { void RegisterInfiniteNayrusLove() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() { GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded()) return; if (!GameInteractor::IsSaveLoaded(true)) return;
if (CVarGetInteger("gInfiniteNayru", 0) != 0) { if (CVarGetInteger("gInfiniteNayru", 0) != 0) {
gSaveContext.nayrusLoveTimer = 0x44B; gSaveContext.nayrusLoveTimer = 0x44B;
} }
@ -143,7 +143,7 @@ void RegisterInfiniteNayrusLove() {
void RegisterMoonJumpOnL() { void RegisterMoonJumpOnL() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() { GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded()) return; if (!GameInteractor::IsSaveLoaded(true)) return;
if (CVarGetInteger("gMoonJumpOnL", 0) != 0) { if (CVarGetInteger("gMoonJumpOnL", 0) != 0) {
Player* player = GET_PLAYER(gPlayState); Player* player = GET_PLAYER(gPlayState);
@ -158,7 +158,7 @@ void RegisterMoonJumpOnL() {
void RegisterInfiniteISG() { void RegisterInfiniteISG() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() { GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded()) return; if (!GameInteractor::IsSaveLoaded(true)) return;
if (CVarGetInteger("gEzISG", 0) != 0) { if (CVarGetInteger("gEzISG", 0) != 0) {
Player* player = GET_PLAYER(gPlayState); Player* player = GET_PLAYER(gPlayState);
@ -170,7 +170,7 @@ void RegisterInfiniteISG() {
//Permanent quick put away (QPA) glitched damage value //Permanent quick put away (QPA) glitched damage value
void RegisterEzQPA() { void RegisterEzQPA() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() { GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded()) return; if (!GameInteractor::IsSaveLoaded(true)) return;
if (CVarGetInteger("gEzQPA", 0) != 0) { if (CVarGetInteger("gEzQPA", 0) != 0) {
Player* player = GET_PLAYER(gPlayState); Player* player = GET_PLAYER(gPlayState);
@ -182,7 +182,7 @@ void RegisterEzQPA() {
void RegisterUnrestrictedItems() { void RegisterUnrestrictedItems() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() { GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded()) return; if (!GameInteractor::IsSaveLoaded(true)) return;
if (CVarGetInteger("gNoRestrictItems", 0) != 0) { if (CVarGetInteger("gNoRestrictItems", 0) != 0) {
u8 sunsBackup = gPlayState->interfaceCtx.restrictions.sunsSong; u8 sunsBackup = gPlayState->interfaceCtx.restrictions.sunsSong;
@ -210,11 +210,14 @@ void RegisterFreezeTime() {
/// Switches Link's age and respawns him at the last entrance he entered. /// Switches Link's age and respawns him at the last entrance he entered.
void RegisterSwitchAge() { void RegisterSwitchAge() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() { GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!GameInteractor::IsSaveLoaded()) { static bool warped = false;
if (!GameInteractor::IsSaveLoaded(true)) {
CVarClear("gSwitchAge"); CVarClear("gSwitchAge");
warped = false;
return; return;
} }
static bool warped = false;
static Vec3f playerPos; static Vec3f playerPos;
static int16_t playerYaw; static int16_t playerYaw;
static RoomContext* roomCtx; static RoomContext* roomCtx;
@ -248,7 +251,7 @@ void RegisterSwitchAge() {
void RegisterOcarinaTimeTravel() { void RegisterOcarinaTimeTravel() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnOcarinaSongAction>([]() { GameInteractor::Instance->RegisterGameHook<GameInteractor::OnOcarinaSongAction>([]() {
if (!GameInteractor::IsSaveLoaded()) { if (!GameInteractor::IsSaveLoaded(true)) {
CVarClear("gTimeTravel"); CVarClear("gTimeTravel");
return; return;
} }

View File

@ -172,7 +172,7 @@ void AreaTable_Init_ForestTemple() {
Entrance(FOREST_TEMPLE_WEST_CORRIDOR, {[]{return true;}}), Entrance(FOREST_TEMPLE_WEST_CORRIDOR, {[]{return true;}}),
Entrance(FOREST_TEMPLE_NW_OUTDOORS_UPPER, {[]{return CanUse(HOVER_BOOTS) || (LogicForestOutsideBackdoor && CanJumpslash && GoronBracelet);}}), Entrance(FOREST_TEMPLE_NW_OUTDOORS_UPPER, {[]{return CanUse(HOVER_BOOTS) || (LogicForestOutsideBackdoor && CanJumpslash && GoronBracelet);}}),
Entrance(FOREST_TEMPLE_NW_CORRIDOR_TWISTED, {[]{return IsAdult && GoronBracelet && SmallKeys(FOREST_TEMPLE, 2);}}), Entrance(FOREST_TEMPLE_NW_CORRIDOR_TWISTED, {[]{return IsAdult && GoronBracelet && SmallKeys(FOREST_TEMPLE, 2);}}),
Entrance(FOREST_TEMPLE_NW_CORRIDOR_STRAIGHTENED, {[]{return (CanUse(BOW) || CanUse(SLINGSHOT)) && GoronBracelet && SmallKeys(FOREST_TEMPLE, 2);}}), Entrance(FOREST_TEMPLE_NW_CORRIDOR_STRAIGHTENED, {[]{return IsAdult && (CanUse(BOW) || CanUse(SLINGSHOT)) && GoronBracelet && SmallKeys(FOREST_TEMPLE, 2);}}),
}); });
areaTable[FOREST_TEMPLE_NW_CORRIDOR_TWISTED] = Area("Forest Temple NW Corridor Twisted", "Forest Temple", FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, {}, { areaTable[FOREST_TEMPLE_NW_CORRIDOR_TWISTED] = Area("Forest Temple NW Corridor Twisted", "Forest Temple", FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, {}, {

View File

@ -4723,7 +4723,11 @@ void RandomizerSettingsWindow::DrawElement() {
excludedLocationString += std::to_string(excludedLocationIt); excludedLocationString += std::to_string(excludedLocationIt);
excludedLocationString += ","; excludedLocationString += ",";
} }
if (excludedLocationString == "") {
CVarClear("gRandomizeExcludedLocations");
} else {
CVarSetString("gRandomizeExcludedLocations", excludedLocationString.c_str()); CVarSetString("gRandomizeExcludedLocations", excludedLocationString.c_str());
}
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
} }
ImGui::SameLine(); ImGui::SameLine();
@ -4909,7 +4913,7 @@ void RandomizerSettingsWindow::DrawElement() {
enabledTrickString += std::to_string(enabledTrickIt); enabledTrickString += std::to_string(enabledTrickIt);
enabledTrickString += ","; enabledTrickString += ",";
} }
CVarSetString("gRandomizeEnabledTricks", enabledTrickString.c_str()); CVarClear("gRandomizeEnabledTricks");
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
} }
ImGui::SameLine(); ImGui::SameLine();
@ -5113,7 +5117,7 @@ void RandomizerSettingsWindow::DrawElement() {
enabledTrickString += std::to_string(enabledTrickIt); enabledTrickString += std::to_string(enabledTrickIt);
enabledTrickString += ","; enabledTrickString += ",";
} }
CVarSetString("gRandomizeEnabledTricks", enabledTrickString.c_str()); CVarClear("gRandomizeEnabledTricks");
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
} }
@ -5151,7 +5155,11 @@ void RandomizerSettingsWindow::DrawElement() {
enabledTrickString += std::to_string(enabledTrickIt); enabledTrickString += std::to_string(enabledTrickIt);
enabledTrickString += ","; enabledTrickString += ",";
} }
if (enabledTrickString == "") {
CVarClear("gRandomizeEnabledTricks");
} else {
CVarSetString("gRandomizeEnabledTricks", enabledTrickString.c_str()); CVarSetString("gRandomizeEnabledTricks", enabledTrickString.c_str());
}
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
} }
DrawTagChips(*rtObject.rtTags); DrawTagChips(*rtObject.rtTags);

View File

@ -30,6 +30,8 @@ void DrawBottle(ItemTrackerItem item);
void DrawQuest(ItemTrackerItem item); void DrawQuest(ItemTrackerItem item);
void DrawSong(ItemTrackerItem item); void DrawSong(ItemTrackerItem item);
int itemTrackerSectionId;
bool shouldUpdateVectors = true; bool shouldUpdateVectors = true;
std::vector<ItemTrackerItem> mainWindowItems = {}; std::vector<ItemTrackerItem> mainWindowItems = {};
@ -282,11 +284,6 @@ void ItemTrackerOnFrame() {
} }
} }
void SaveNotes(uint32_t fileNum) {
CVarSetString(("gItemTrackerNotes" + std::to_string(fileNum)).c_str(), std::string(std::begin(itemTrackerNotes), std::end(itemTrackerNotes)).c_str());
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
}
bool IsValidSaveFile() { bool IsValidSaveFile() {
bool validSave = gSaveContext.fileNum >= 0 && gSaveContext.fileNum <= 2; bool validSave = gSaveContext.fileNum >= 0 && gSaveContext.fileNum <= 2;
return validSave; return validSave;
@ -755,7 +752,7 @@ void DrawNotes(bool resizeable = false) {
} }
if ((ImGui::IsItemDeactivatedAfterEdit() || (notesNeedSave && notesIdleFrames > notesMaxIdleFrames)) && IsValidSaveFile()) { if ((ImGui::IsItemDeactivatedAfterEdit() || (notesNeedSave && notesIdleFrames > notesMaxIdleFrames)) && IsValidSaveFile()) {
notesNeedSave = false; notesNeedSave = false;
SaveNotes(gSaveContext.fileNum); SaveManager::Instance->SaveSection(gSaveContext.fileNum, itemTrackerSectionId, true);
} }
ImGui::EndGroup(); ImGui::EndGroup();
} }
@ -980,6 +977,26 @@ void UpdateVectors() {
shouldUpdateVectors = false; shouldUpdateVectors = false;
} }
void ItemTrackerInitFile(bool isDebug) {
itemTrackerNotes.clear();
itemTrackerNotes.push_back(0);
}
void ItemTrackerSaveFile(SaveContext* saveContext, int sectionID, bool fullSave) {
SaveManager::Instance->SaveData("personalNotes", std::string(std::begin(itemTrackerNotes), std::end(itemTrackerNotes)).c_str());
}
void ItemTrackerLoadFile() {
std::string initialTrackerNotes = "";
SaveManager::Instance->LoadData("personalNotes", initialTrackerNotes);
itemTrackerNotes.resize(initialTrackerNotes.length() + 1);
if (initialTrackerNotes != "") {
SohUtils::CopyStringToCharArray(itemTrackerNotes.Data, initialTrackerNotes.c_str(), itemTrackerNotes.size());
} else {
itemTrackerNotes.push_back(0);
}
}
void ItemTrackerWindow::DrawElement() { void ItemTrackerWindow::DrawElement() {
UpdateVectors(); UpdateVectors();
@ -1249,14 +1266,9 @@ void ItemTrackerWindow::InitElement() {
itemTrackerNotes.push_back(0); itemTrackerNotes.push_back(0);
} }
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnLoadFile>([](uint32_t fileNum) { SaveManager::Instance->AddInitFunction(ItemTrackerInitFile);
const char* initialTrackerNotes = CVarGetString(("gItemTrackerNotes" + std::to_string(fileNum)).c_str(), ""); itemTrackerSectionId = SaveManager::Instance->AddSaveFunction("itemTrackerData", 1, ItemTrackerSaveFile, true, -1);
itemTrackerNotes.resize(strlen(initialTrackerNotes) + 1); SaveManager::Instance->AddLoadFunction("itemTrackerData", 1, ItemTrackerLoadFile);
strcpy(itemTrackerNotes.Data, initialTrackerNotes);
});
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnDeleteFile>([](uint32_t fileNum) {
CVarSetString(("gItemTrackerNotes" + std::to_string(fileNum)).c_str(), "");
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
});
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>(ItemTrackerOnFrame); GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>(ItemTrackerOnFrame);
} }

View File

@ -168,7 +168,7 @@ void RegisterOnInterfaceUpdateHook() {
prevTimer = timer; prevTimer = timer;
if (!GameInteractor::IsSaveLoaded()) return; if (!GameInteractor::IsSaveLoaded(true)) return;
static int16_t lostHealth = 0; static int16_t lostHealth = 0;
static int16_t prevHealth = 0; static int16_t prevHealth = 0;

View File

@ -178,7 +178,7 @@ bool Scene_CommandObjectList(PlayState* play, SOH::ISceneCommand* cmd) {
// Loop until a mismatch in the object lists // Loop until a mismatch in the object lists
// Then clear all object ids past that in the context object list and kill actors for those objects // Then clear all object ids past that in the context object list and kill actors for those objects
for (i = play->objectCtx.unk_09, k = 0; i < play->objectCtx.num; i++, k++) { for (i = play->objectCtx.unk_09, k = 0; i < play->objectCtx.num; i++, k++) {
if (play->objectCtx.status[i].id != cmdObj->objects[k]) { if (i >= cmdObj->objects.size() || play->objectCtx.status[i].id != cmdObj->objects[k]) {
for (j = i; j < play->objectCtx.num; j++) { for (j = i; j < play->objectCtx.num; j++) {
play->objectCtx.status[j].id = OBJECT_INVALID; play->objectCtx.status[j].id = OBJECT_INVALID;
} }

View File

@ -16,6 +16,7 @@ void EnSi_Init(Actor* thisx, PlayState* play);
void EnSi_Destroy(Actor* thisx, PlayState* play); void EnSi_Destroy(Actor* thisx, PlayState* play);
void EnSi_Update(Actor* thisx, PlayState* play); void EnSi_Update(Actor* thisx, PlayState* play);
void EnSi_Draw(Actor* thisx, PlayState* play); void EnSi_Draw(Actor* thisx, PlayState* play);
void EnSi_Reset();
s32 func_80AFB748(EnSi* this, PlayState* play); s32 func_80AFB748(EnSi* this, PlayState* play);
void func_80AFB768(EnSi* this, PlayState* play); void func_80AFB768(EnSi* this, PlayState* play);
@ -61,7 +62,7 @@ const ActorInit En_Si_InitVars = {
(ActorFunc)EnSi_Destroy, (ActorFunc)EnSi_Destroy,
(ActorFunc)EnSi_Update, (ActorFunc)EnSi_Update,
(ActorFunc)EnSi_Draw, (ActorFunc)EnSi_Draw,
NULL, (ActorResetFunc)EnSi_Reset,
}; };
void EnSi_Init(Actor* thisx, PlayState* play) { void EnSi_Init(Actor* thisx, PlayState* play) {
@ -224,6 +225,11 @@ void EnSi_Draw(Actor* thisx, PlayState* play) {
} }
} }
void EnSi_Reset() {
textId = 0xB4;
giveItemId = ITEM_SKULL_TOKEN;
}
void Randomizer_UpdateSkullReward(EnSi* this, PlayState* play) { void Randomizer_UpdateSkullReward(EnSi* this, PlayState* play) {
Player* player = GET_PLAYER(play); Player* player = GET_PLAYER(play);