diff options
| author | Pepe20129 <72659707+Pepe20129@users.noreply.github.com> | 2025-01-15 13:04:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-15 13:04:47 +0100 |
| commit | 7f31fd2e4ee0f2facafec4aaba5591fed52da9f5 (patch) | |
| tree | a27c54a9c8de4abea16192f93d2f18f43b6c47eb /soh/src/code | |
| parent | 0d80c4695f1ca275167821b42377741fc0828c58 (diff) | |
Organize ship specific save context additions (#4597)
* Basic restructure
* Undo most randomizerInf changes for now
* Small fixes
* Fix linux & mac builds?
* Fix remnants of randomizerInf changes
* Post-merge fix
* Post-merge fix
Diffstat (limited to 'soh/src/code')
| -rw-r--r-- | soh/src/code/z_actor.c | 33 | ||||
| -rw-r--r-- | soh/src/code/z_demo.c | 4 | ||||
| -rw-r--r-- | soh/src/code/z_draw.c | 2 | ||||
| -rw-r--r-- | soh/src/code/z_kaleido_scope_call.c | 8 | ||||
| -rw-r--r-- | soh/src/code/z_parameter.c | 58 | ||||
| -rw-r--r-- | soh/src/code/z_play.c | 100 | ||||
| -rw-r--r-- | soh/src/code/z_room.c | 20 | ||||
| -rw-r--r-- | soh/src/code/z_sram.c | 6 |
8 files changed, 129 insertions, 102 deletions
diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index 70c7a3233..306a4f89c 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -4982,15 +4982,33 @@ void Flags_UnsetEventInf(s32 flag) { * Tests if "randomizerInf" flag is set. */ s32 Flags_GetRandomizerInf(RandomizerInf flag) { - return gSaveContext.randomizerInf[flag >> 4] & (1 << (flag & 0xF)); + // Randomizer flags are currently accessible from any quest (boss rush as an example) + /* + if (!IS_RANDO) { + LUSLOG_ERROR("Tried to get randomizerInf flag \"%d\" outside of rando", flag); + assert(false); + return 0; + } + */ + + return gSaveContext.ship.randomizerInf[flag >> 4] & (1 << (flag & 0xF)); } /** * Sets "randomizerInf" flag. */ void Flags_SetRandomizerInf(RandomizerInf flag) { + // Randomizer flags are currently accessible from any quest (boss rush as an example) + /* + if (!IS_RANDO) { + LUSLOG_ERROR("Tried to set randomizerInf flag \"%d\" outside of rando", flag); + assert(false); + return; + } + */ + s32 previouslyOff = !Flags_GetRandomizerInf(flag); - gSaveContext.randomizerInf[flag >> 4] |= (1 << (flag & 0xF)); + gSaveContext.ship.randomizerInf[flag >> 4] |= (1 << (flag & 0xF)); if (previouslyOff) { LUSLOG_INFO("RandomizerInf Flag Set - %#x", flag); GameInteractor_ExecuteOnFlagSet(FLAG_RANDOMIZER_INF, flag); @@ -5001,8 +5019,17 @@ void Flags_SetRandomizerInf(RandomizerInf flag) { * Unsets "randomizerInf" flag. */ void Flags_UnsetRandomizerInf(RandomizerInf flag) { + // Randomizer flags are currently accessible from any quest (boss rush as an example) + /* + if (!IS_RANDO) { + LUSLOG_ERROR("Tried to unset randomizerInf flag \"%d\" outside of rando", flag); + assert(false); + return; + } + */ + s32 previouslyOn = Flags_GetRandomizerInf(flag); - gSaveContext.randomizerInf[flag >> 4] &= ~(1 << (flag & 0xF)); + gSaveContext.ship.randomizerInf[flag >> 4] &= ~(1 << (flag & 0xF)); if (previouslyOn) { LUSLOG_INFO("RandomizerInf Flag Unset - %#x", flag); GameInteractor_ExecuteOnFlagUnset(FLAG_RANDOMIZER_INF, flag); diff --git a/soh/src/code/z_demo.c b/soh/src/code/z_demo.c index 4943b8390..9821b8d26 100644 --- a/soh/src/code/z_demo.c +++ b/soh/src/code/z_demo.c @@ -626,8 +626,8 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB break; case 8: if (CVarGetInteger(CVAR_ENHANCEMENT("BetterFarore"), 0)) { - FaroresWindData tempFW = gSaveContext.backupFW; - gSaveContext.backupFW = gSaveContext.fw; + FaroresWindData tempFW = gSaveContext.ship.backupFW; + gSaveContext.ship.backupFW = gSaveContext.fw; gSaveContext.fw = tempFW; } else { gSaveContext.fw.set = 0; diff --git a/soh/src/code/z_draw.c b/soh/src/code/z_draw.c index e27f230b1..523f65bbd 100644 --- a/soh/src/code/z_draw.c +++ b/soh/src/code/z_draw.c @@ -1046,7 +1046,7 @@ void GetItem_DrawTriforcePiece(PlayState* play, s16 drawId) { Matrix_Scale(0.035f, 0.035f, 0.035f, MTXMODE_APPLY); - uint8_t index = gSaveContext.triforcePiecesCollected % 3; + uint8_t index = gSaveContext.ship.quest.data.randomizer.triforcePiecesCollected % 3; Gfx* triforcePieceDL; switch (index) { diff --git a/soh/src/code/z_kaleido_scope_call.c b/soh/src/code/z_kaleido_scope_call.c index 196e20041..bc21b9b55 100644 --- a/soh/src/code/z_kaleido_scope_call.c +++ b/soh/src/code/z_kaleido_scope_call.c @@ -59,9 +59,9 @@ void KaleidoScopeCall_Update(PlayState* play) { GameInteractor_ExecuteOnKaleidoUpdate(); - if (!gSaveContext.sohStats.gameComplete && - (!IS_BOSS_RUSH || !gSaveContext.isBossRushPaused)) { - gSaveContext.sohStats.pauseTimer++; + if (!gSaveContext.ship.stats.gameComplete && + (!IS_BOSS_RUSH || !gSaveContext.ship.quest.data.bossRush.isPaused)) { + gSaveContext.ship.stats.pauseTimer++; } if ((pauseCtx->state != 0) || (pauseCtx->debugState != 0)) { @@ -73,7 +73,7 @@ void KaleidoScopeCall_Update(PlayState* play) { pauseCtx->unk_1E4 = 0; pauseCtx->unk_1EC = 0; pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; - gSaveContext.sohStats.count[COUNT_PAUSES]++; + gSaveContext.ship.stats.count[COUNT_PAUSES]++; } } else if (pauseCtx->state == 8) { HREG(80) = 7; diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 396188b48..39c6e111d 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -1812,7 +1812,7 @@ void func_80084BF4(PlayState* play, u16 flag) { void GameplayStats_SetTimestamp(PlayState* play, u8 item) { // If we already have a timestamp for this item, do nothing - if (gSaveContext.sohStats.itemTimestamp[item] != 0){ + if (gSaveContext.ship.stats.itemTimestamp[item] != 0){ return; } // Use ITEM_KEY_BOSS only for Ganon's boss key - not any other boss keys @@ -1831,20 +1831,20 @@ void GameplayStats_SetTimestamp(PlayState* play, u8 item) { // Count any bottled item as a bottle if (item >= ITEM_BOTTLE && item <= ITEM_POE) { - if (gSaveContext.sohStats.itemTimestamp[ITEM_BOTTLE] == 0) { - gSaveContext.sohStats.itemTimestamp[ITEM_BOTTLE] = time; + if (gSaveContext.ship.stats.itemTimestamp[ITEM_BOTTLE] == 0) { + gSaveContext.ship.stats.itemTimestamp[ITEM_BOTTLE] = time; } return; } // Count any bombchu pack as bombchus if (item == ITEM_BOMBCHU || (item >= ITEM_BOMBCHUS_5 && item <= ITEM_BOMBCHUS_20)) { - if (gSaveContext.sohStats.itemTimestamp[ITEM_BOMBCHU] == 0) { - gSaveContext.sohStats.itemTimestamp[ITEM_BOMBCHU] = time; + if (gSaveContext.ship.stats.itemTimestamp[ITEM_BOMBCHU] == 0) { + gSaveContext.ship.stats.itemTimestamp[ITEM_BOMBCHU] = time; } return; } - gSaveContext.sohStats.itemTimestamp[item] = time; + gSaveContext.ship.stats.itemTimestamp[item] = time; GameInteractor_ExecuteOnTimestamp(item); } @@ -2338,7 +2338,7 @@ u8 Item_Give(PlayState* play, u8 item) { return Return_Item(item, MOD_NONE, ITEM_NONE); } else if ((item == ITEM_HEART_PIECE_2) || (item == ITEM_HEART_PIECE)) { gSaveContext.inventory.questItems += 1 << (QUEST_HEART_PIECE + 4); - gSaveContext.sohStats.heartPieces++; + gSaveContext.ship.stats.heartPieces++; return Return_Item(item, MOD_NONE, ITEM_NONE); } else if (item == ITEM_HEART_CONTAINER) { if (!CVarGetInteger(CVAR_ENHANCEMENT("HurtContainer"), 0)) { @@ -2348,7 +2348,7 @@ u8 Item_Give(PlayState* play, u8 item) { gSaveContext.healthCapacity -= 0x10; gSaveContext.health -= 0x10; } - gSaveContext.sohStats.heartContainers++; + gSaveContext.ship.stats.heartContainers++; return Return_Item(item, MOD_NONE, ITEM_NONE); } else if (item == ITEM_HEART) { osSyncPrintf("回復ハート回復ハート回復ハート\n"); // "Recovery Heart" @@ -2447,7 +2447,7 @@ u8 Item_Give(PlayState* play, u8 item) { } if (item >= ITEM_POCKET_EGG) { - gSaveContext.adultTradeItems |= ADULT_TRADE_FLAG(item); + gSaveContext.ship.quest.data.randomizer.adultTradeItems |= ADULT_TRADE_FLAG(item); } temp = INV_CONTENT(item); @@ -2763,8 +2763,8 @@ bool Inventory_HatchPocketCucco(PlayState* play) { return 0; } - gSaveContext.adultTradeItems &= ~ADULT_TRADE_FLAG(ITEM_POCKET_EGG); - gSaveContext.adultTradeItems |= ADULT_TRADE_FLAG(ITEM_POCKET_CUCCO); + gSaveContext.ship.quest.data.randomizer.adultTradeItems &= ~ADULT_TRADE_FLAG(ITEM_POCKET_EGG); + gSaveContext.ship.quest.data.randomizer.adultTradeItems |= ADULT_TRADE_FLAG(ITEM_POCKET_CUCCO); Inventory_ReplaceItem(play, ITEM_POCKET_EGG, ITEM_POCKET_CUCCO); return 1; } @@ -2882,7 +2882,7 @@ s32 Health_ChangeBy(PlayState* play, s16 healthChange) { gSaveContext.healthCapacity); if (healthChange < 0) { - gSaveContext.sohStats.count[COUNT_DAMAGE_TAKEN] += -healthChange; + gSaveContext.ship.stats.count[COUNT_DAMAGE_TAKEN] += -healthChange; } // If one-hit ko mode is on, any damage kills you and you cannot gain health. @@ -2952,10 +2952,10 @@ void Rupees_ChangeBy(s16 rupeeChange) { } if (rupeeChange > 0) { - gSaveContext.sohStats.count[COUNT_RUPEES_COLLECTED] += rupeeChange; + gSaveContext.ship.stats.count[COUNT_RUPEES_COLLECTED] += rupeeChange; } if (rupeeChange < 0) { - gSaveContext.sohStats.count[COUNT_RUPEES_SPENT] += -rupeeChange; + gSaveContext.ship.stats.count[COUNT_RUPEES_SPENT] += -rupeeChange; } } @@ -2963,25 +2963,25 @@ void GameplayStats_UpdateAmmoUsed(s16 item, s16 ammoUsed) { switch (item) { case ITEM_STICK: - gSaveContext.sohStats.count[COUNT_AMMO_USED_STICK] += ammoUsed; + gSaveContext.ship.stats.count[COUNT_AMMO_USED_STICK] += ammoUsed; break; case ITEM_NUT: - gSaveContext.sohStats.count[COUNT_AMMO_USED_NUT] += ammoUsed; + gSaveContext.ship.stats.count[COUNT_AMMO_USED_NUT] += ammoUsed; break; case ITEM_BOMB: - gSaveContext.sohStats.count[COUNT_AMMO_USED_BOMB] += ammoUsed; + gSaveContext.ship.stats.count[COUNT_AMMO_USED_BOMB] += ammoUsed; break; case ITEM_BOW: - gSaveContext.sohStats.count[COUNT_AMMO_USED_ARROW] += ammoUsed; + gSaveContext.ship.stats.count[COUNT_AMMO_USED_ARROW] += ammoUsed; break; case ITEM_SLINGSHOT: - gSaveContext.sohStats.count[COUNT_AMMO_USED_SEED] += ammoUsed; + gSaveContext.ship.stats.count[COUNT_AMMO_USED_SEED] += ammoUsed; break; case ITEM_BOMBCHU: - gSaveContext.sohStats.count[COUNT_AMMO_USED_BOMBCHU] += ammoUsed; + gSaveContext.ship.stats.count[COUNT_AMMO_USED_BOMBCHU] += ammoUsed; break; case ITEM_BEAN: - gSaveContext.sohStats.count[COUNT_AMMO_USED_BEAN] += ammoUsed; + gSaveContext.ship.stats.count[COUNT_AMMO_USED_BEAN] += ammoUsed; break; default: break; @@ -6122,7 +6122,7 @@ void Interface_Draw(PlayState* play) { void Interface_DrawTotalGameplayTimer(PlayState* play) { // Draw timer based on the Gameplay Stats total time. - if ((IS_BOSS_RUSH && gSaveContext.bossRushOptions[BR_OPTIONS_TIMER] == BR_CHOICE_TIMER_YES) || + if ((IS_BOSS_RUSH && gSaveContext.ship.quest.data.bossRush.options[BR_OPTIONS_TIMER] == BR_CHOICE_TIMER_YES) || (CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.ShowIngameTimer"), 0) && gSaveContext.fileNum >= 0 && gSaveContext.fileNum <= 2)) { s32 X_Margins_Timer = 0; @@ -6202,9 +6202,9 @@ void Interface_DrawTotalGameplayTimer(PlayState* play) { (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); // Draw regular text. Change color based on if the timer is paused, running or the game is completed. - if (gSaveContext.sohStats.gameComplete) { + if (gSaveContext.ship.stats.gameComplete) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 120, 255, 0, 255); - } else if (gSaveContext.isBossRushPaused && !gSaveContext.sohStats.rtaTiming) { + } else if (IS_BOSS_RUSH && gSaveContext.ship.quest.data.bossRush.isPaused && !gSaveContext.ship.stats.rtaTiming) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 150, 150, 150, 255); } else { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); @@ -6429,11 +6429,11 @@ void Interface_Update(PlayState* play) { } else { gSaveContext.rupeeAccumulator = 0; } - if (gSaveContext.rupeeAccumulator == 0 && gSaveContext.pendingSale != ITEM_NONE) { - u16 tempSaleItem = gSaveContext.pendingSale; - u16 tempSaleMod = gSaveContext.pendingSaleMod; - gSaveContext.pendingSale = ITEM_NONE; - gSaveContext.pendingSaleMod = MOD_NONE; + if (gSaveContext.rupeeAccumulator == 0 && gSaveContext.ship.pendingSale != ITEM_NONE) { + u16 tempSaleItem = gSaveContext.ship.pendingSale; + u16 tempSaleMod = gSaveContext.ship.pendingSaleMod; + gSaveContext.ship.pendingSale = ITEM_NONE; + gSaveContext.ship.pendingSaleMod = MOD_NONE; if (tempSaleMod == MOD_NONE) { GetItemID getItemID = RetrieveGetItemIDFromItemID(tempSaleItem); RandomizerGet randomizerGet = RetrieveRandomizerGetFromItemID(tempSaleItem); diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index df1314e71..cc7af190d 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -646,32 +646,32 @@ void Play_Init(GameState* thisx) { gSaveContext.respawnFlag = 0; // #region SOH [Stats] - if (gSaveContext.sohStats.sceneNum != gPlayState->sceneNum) { - u16 idx = gSaveContext.sohStats.tsIdx; - gSaveContext.sohStats.sceneTimestamps[idx].sceneTime = gSaveContext.sohStats.sceneTimer / 2; - gSaveContext.sohStats.sceneTimestamps[idx].roomTime = gSaveContext.sohStats.roomTimer / 2; - gSaveContext.sohStats.sceneTimestamps[idx].scene = gSaveContext.sohStats.sceneNum; - gSaveContext.sohStats.sceneTimestamps[idx].room = gSaveContext.sohStats.roomNum; - gSaveContext.sohStats.sceneTimestamps[idx].isRoom = - gPlayState->sceneNum == gSaveContext.sohStats.sceneTimestamps[idx].scene && - gPlayState->roomCtx.curRoom.num != gSaveContext.sohStats.sceneTimestamps[idx].room; - gSaveContext.sohStats.tsIdx++; - gSaveContext.sohStats.sceneTimer = 0; - gSaveContext.sohStats.roomTimer = 0; - } else if (gSaveContext.sohStats.roomNum != gPlayState->roomCtx.curRoom.num) { - u16 idx = gSaveContext.sohStats.tsIdx; - gSaveContext.sohStats.sceneTimestamps[idx].roomTime = gSaveContext.sohStats.roomTimer / 2; - gSaveContext.sohStats.sceneTimestamps[idx].scene = gSaveContext.sohStats.sceneNum; - gSaveContext.sohStats.sceneTimestamps[idx].room = gSaveContext.sohStats.roomNum; - gSaveContext.sohStats.sceneTimestamps[idx].isRoom = - gPlayState->sceneNum == gSaveContext.sohStats.sceneTimestamps[idx].scene && - gPlayState->roomCtx.curRoom.num != gSaveContext.sohStats.sceneTimestamps[idx].room; - gSaveContext.sohStats.tsIdx++; - gSaveContext.sohStats.roomTimer = 0; - } - - gSaveContext.sohStats.sceneNum = gPlayState->sceneNum; - gSaveContext.sohStats.roomNum = gPlayState->roomCtx.curRoom.num; + if (gSaveContext.ship.stats.sceneNum != gPlayState->sceneNum) { + u16 idx = gSaveContext.ship.stats.tsIdx; + gSaveContext.ship.stats.sceneTimestamps[idx].sceneTime = gSaveContext.ship.stats.sceneTimer / 2; + gSaveContext.ship.stats.sceneTimestamps[idx].roomTime = gSaveContext.ship.stats.roomTimer / 2; + gSaveContext.ship.stats.sceneTimestamps[idx].scene = gSaveContext.ship.stats.sceneNum; + gSaveContext.ship.stats.sceneTimestamps[idx].room = gSaveContext.ship.stats.roomNum; + gSaveContext.ship.stats.sceneTimestamps[idx].isRoom = + gPlayState->sceneNum == gSaveContext.ship.stats.sceneTimestamps[idx].scene && + gPlayState->roomCtx.curRoom.num != gSaveContext.ship.stats.sceneTimestamps[idx].room; + gSaveContext.ship.stats.tsIdx++; + gSaveContext.ship.stats.sceneTimer = 0; + gSaveContext.ship.stats.roomTimer = 0; + } else if (gSaveContext.ship.stats.roomNum != gPlayState->roomCtx.curRoom.num) { + u16 idx = gSaveContext.ship.stats.tsIdx; + gSaveContext.ship.stats.sceneTimestamps[idx].roomTime = gSaveContext.ship.stats.roomTimer / 2; + gSaveContext.ship.stats.sceneTimestamps[idx].scene = gSaveContext.ship.stats.sceneNum; + gSaveContext.ship.stats.sceneTimestamps[idx].room = gSaveContext.ship.stats.roomNum; + gSaveContext.ship.stats.sceneTimestamps[idx].isRoom = + gPlayState->sceneNum == gSaveContext.ship.stats.sceneTimestamps[idx].scene && + gPlayState->roomCtx.curRoom.num != gSaveContext.ship.stats.sceneTimestamps[idx].room; + gSaveContext.ship.stats.tsIdx++; + gSaveContext.ship.stats.roomTimer = 0; + } + + gSaveContext.ship.stats.sceneNum = gPlayState->sceneNum; + gSaveContext.ship.stats.roomNum = gPlayState->roomCtx.curRoom.num; // #endregion #if 0 @@ -741,28 +741,28 @@ void Play_Update(PlayState* play) { } // #region SOH [Stats] Gameplay stats: Count button presses - if (!gSaveContext.sohStats.gameComplete) { - if (CHECK_BTN_ALL(input[0].press.button, BTN_A)) {gSaveContext.sohStats.count[COUNT_BUTTON_PRESSES_A]++;} - if (CHECK_BTN_ALL(input[0].press.button, BTN_B)) {gSaveContext.sohStats.count[COUNT_BUTTON_PRESSES_B]++;} - if (CHECK_BTN_ALL(input[0].press.button, BTN_CUP)) {gSaveContext.sohStats.count[COUNT_BUTTON_PRESSES_CUP]++;} - if (CHECK_BTN_ALL(input[0].press.button, BTN_CRIGHT)) {gSaveContext.sohStats.count[COUNT_BUTTON_PRESSES_CRIGHT]++;} - if (CHECK_BTN_ALL(input[0].press.button, BTN_CLEFT)) {gSaveContext.sohStats.count[COUNT_BUTTON_PRESSES_CLEFT]++;} - if (CHECK_BTN_ALL(input[0].press.button, BTN_CDOWN)) {gSaveContext.sohStats.count[COUNT_BUTTON_PRESSES_CDOWN]++;} - if (CHECK_BTN_ALL(input[0].press.button, BTN_DUP)) {gSaveContext.sohStats.count[COUNT_BUTTON_PRESSES_DUP]++;} - if (CHECK_BTN_ALL(input[0].press.button, BTN_DRIGHT)) {gSaveContext.sohStats.count[COUNT_BUTTON_PRESSES_DRIGHT]++;} - if (CHECK_BTN_ALL(input[0].press.button, BTN_DDOWN)) {gSaveContext.sohStats.count[COUNT_BUTTON_PRESSES_DDOWN]++;} - if (CHECK_BTN_ALL(input[0].press.button, BTN_DLEFT)) {gSaveContext.sohStats.count[COUNT_BUTTON_PRESSES_DLEFT]++;} - if (CHECK_BTN_ALL(input[0].press.button, BTN_L)) {gSaveContext.sohStats.count[COUNT_BUTTON_PRESSES_L]++;} - if (CHECK_BTN_ALL(input[0].press.button, BTN_R)) {gSaveContext.sohStats.count[COUNT_BUTTON_PRESSES_R]++;} - if (CHECK_BTN_ALL(input[0].press.button, BTN_Z)) {gSaveContext.sohStats.count[COUNT_BUTTON_PRESSES_Z]++;} - if (CHECK_BTN_ALL(input[0].press.button, BTN_START)) {gSaveContext.sohStats.count[COUNT_BUTTON_PRESSES_START]++;} + if (!gSaveContext.ship.stats.gameComplete) { + if (CHECK_BTN_ALL(input[0].press.button, BTN_A)) {gSaveContext.ship.stats.count[COUNT_BUTTON_PRESSES_A]++;} + if (CHECK_BTN_ALL(input[0].press.button, BTN_B)) {gSaveContext.ship.stats.count[COUNT_BUTTON_PRESSES_B]++;} + if (CHECK_BTN_ALL(input[0].press.button, BTN_CUP)) {gSaveContext.ship.stats.count[COUNT_BUTTON_PRESSES_CUP]++;} + if (CHECK_BTN_ALL(input[0].press.button, BTN_CRIGHT)) {gSaveContext.ship.stats.count[COUNT_BUTTON_PRESSES_CRIGHT]++;} + if (CHECK_BTN_ALL(input[0].press.button, BTN_CLEFT)) {gSaveContext.ship.stats.count[COUNT_BUTTON_PRESSES_CLEFT]++;} + if (CHECK_BTN_ALL(input[0].press.button, BTN_CDOWN)) {gSaveContext.ship.stats.count[COUNT_BUTTON_PRESSES_CDOWN]++;} + if (CHECK_BTN_ALL(input[0].press.button, BTN_DUP)) {gSaveContext.ship.stats.count[COUNT_BUTTON_PRESSES_DUP]++;} + if (CHECK_BTN_ALL(input[0].press.button, BTN_DRIGHT)) {gSaveContext.ship.stats.count[COUNT_BUTTON_PRESSES_DRIGHT]++;} + if (CHECK_BTN_ALL(input[0].press.button, BTN_DDOWN)) {gSaveContext.ship.stats.count[COUNT_BUTTON_PRESSES_DDOWN]++;} + if (CHECK_BTN_ALL(input[0].press.button, BTN_DLEFT)) {gSaveContext.ship.stats.count[COUNT_BUTTON_PRESSES_DLEFT]++;} + if (CHECK_BTN_ALL(input[0].press.button, BTN_L)) {gSaveContext.ship.stats.count[COUNT_BUTTON_PRESSES_L]++;} + if (CHECK_BTN_ALL(input[0].press.button, BTN_R)) {gSaveContext.ship.stats.count[COUNT_BUTTON_PRESSES_R]++;} + if (CHECK_BTN_ALL(input[0].press.button, BTN_Z)) {gSaveContext.ship.stats.count[COUNT_BUTTON_PRESSES_Z]++;} + if (CHECK_BTN_ALL(input[0].press.button, BTN_START)) {gSaveContext.ship.stats.count[COUNT_BUTTON_PRESSES_START]++;} // Start RTA timing on first non-c-up input after intro cutscene if ( - !gSaveContext.sohStats.fileCreatedAt && !Player_InCsMode(play) && + !gSaveContext.ship.stats.fileCreatedAt && !Player_InCsMode(play) && ((input[0].press.button && input[0].press.button != 0x8) || input[0].rel.stick_x != 0 || input[0].rel.stick_y != 0) ) { - gSaveContext.sohStats.fileCreatedAt = GetUnixTimestamp(); + gSaveContext.ship.stats.fileCreatedAt = GetUnixTimestamp(); } } // #endregion @@ -1146,14 +1146,14 @@ void Play_Update(PlayState* play) { func_800AA178(true); // Gameplay stat tracking - if (!gSaveContext.sohStats.gameComplete && - (!IS_BOSS_RUSH || !gSaveContext.isBossRushPaused)) { - gSaveContext.sohStats.playTimer++; - gSaveContext.sohStats.sceneTimer++; - gSaveContext.sohStats.roomTimer++; + if (!gSaveContext.ship.stats.gameComplete && + (!IS_BOSS_RUSH || !gSaveContext.ship.quest.data.bossRush.isPaused)) { + gSaveContext.ship.stats.playTimer++; + gSaveContext.ship.stats.sceneTimer++; + gSaveContext.ship.stats.roomTimer++; if (CVarGetInteger(CVAR_ENHANCEMENT("MMBunnyHood"), BUNNY_HOOD_VANILLA) != BUNNY_HOOD_VANILLA && Player_GetMask(play) == PLAYER_MASK_BUNNY) { - gSaveContext.sohStats.count[COUNT_TIME_BUNNY_HOOD]++; + gSaveContext.ship.stats.count[COUNT_TIME_BUNNY_HOOD]++; } } @@ -2220,7 +2220,7 @@ void Play_PerformSave(PlayState* play) { uint8_t triforceHuntCompleted = IS_RANDO && - gSaveContext.triforcePiecesCollected == (Randomizer_GetSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED) + 1) && + gSaveContext.ship.quest.data.randomizer.triforcePiecesCollected == (Randomizer_GetSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED) + 1) && Randomizer_GetSettingValue(RSK_TRIFORCE_HUNT); if (CVarGetInteger(CVAR_ENHANCEMENT("Autosave"), AUTOSAVE_OFF) != AUTOSAVE_OFF || triforceHuntCompleted) { Overlay_DisplayText(3.0f, "Game Saved"); diff --git a/soh/src/code/z_room.c b/soh/src/code/z_room.c index 2e8cdc655..fdd8f78f8 100644 --- a/soh/src/code/z_room.c +++ b/soh/src/code/z_room.c @@ -653,14 +653,14 @@ void func_80097534(PlayState* play, RoomContext* roomCtx) { Map_SavePlayerInitialInfo(play); } Audio_SetEnvReverb(play->roomCtx.curRoom.echo); - u8 idx = gSaveContext.sohStats.tsIdx; - gSaveContext.sohStats.sceneTimestamps[idx].scene = gSaveContext.sohStats.sceneNum; - gSaveContext.sohStats.sceneTimestamps[idx].room = gSaveContext.sohStats.roomNum; - gSaveContext.sohStats.sceneTimestamps[idx].roomTime = gSaveContext.sohStats.roomTimer / 2; - gSaveContext.sohStats.sceneTimestamps[idx].isRoom = - gPlayState->sceneNum == gSaveContext.sohStats.sceneTimestamps[idx].scene && - gPlayState->roomCtx.curRoom.num != gSaveContext.sohStats.sceneTimestamps[idx].room; - gSaveContext.sohStats.tsIdx++; - gSaveContext.sohStats.roomNum = roomCtx->curRoom.num; - gSaveContext.sohStats.roomTimer = 0; + u8 idx = gSaveContext.ship.stats.tsIdx; + gSaveContext.ship.stats.sceneTimestamps[idx].scene = gSaveContext.ship.stats.sceneNum; + gSaveContext.ship.stats.sceneTimestamps[idx].room = gSaveContext.ship.stats.roomNum; + gSaveContext.ship.stats.sceneTimestamps[idx].roomTime = gSaveContext.ship.stats.roomTimer / 2; + gSaveContext.ship.stats.sceneTimestamps[idx].isRoom = + gPlayState->sceneNum == gSaveContext.ship.stats.sceneTimestamps[idx].scene && + gPlayState->roomCtx.curRoom.num != gSaveContext.ship.stats.sceneTimestamps[idx].room; + gSaveContext.ship.stats.tsIdx++; + gSaveContext.ship.stats.roomNum = roomCtx->curRoom.num; + gSaveContext.ship.stats.roomTimer = 0; } diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index adea0cbbf..d6141d78b 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -142,7 +142,7 @@ void Sram_OpenSave() { } if (!CVarGetInteger(CVAR_ENHANCEMENT("PersistentMasks"), 0)) { - gSaveContext.maskMemory = PLAYER_MASK_NONE; + gSaveContext.ship.maskMemory = PLAYER_MASK_NONE; } osSyncPrintf("scene_no = %d\n", gSaveContext.entranceIndex); @@ -252,11 +252,11 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) { u8 currentQuest = fileChooseCtx->questType[fileChooseCtx->buttonIndex]; if (currentQuest == QUEST_RANDOMIZER && (Randomizer_IsSeedGenerated() || Randomizer_IsSpoilerLoaded())) { - gSaveContext.questId = QUEST_RANDOMIZER; + gSaveContext.ship.quest.id = QUEST_RANDOMIZER; Randomizer_InitSaveFile(); } else { - gSaveContext.questId = currentQuest; + gSaveContext.ship.quest.id = currentQuest; } Save_SaveFile(); |
