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
This commit is contained in:
@@ -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;
|
||||
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.sohStats.sceneNum = gPlayState->sceneNum;
|
||||
gSaveContext.sohStats.roomNum = gPlayState->roomCtx.curRoom.num;
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user