diff options
| author | Ralphie Morell <stratomaster64@gmail.com> | 2023-04-03 00:06:55 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-03 00:06:55 -0400 |
| commit | ff1d8a9e9d27de17b0718ef31f2ad6ac0fab3874 (patch) | |
| tree | b50e6743f7064369b6ba9032b819fc3f1d729cb9 /soh/src/code | |
| parent | 0f40472c1abe188ad1ae90d99c835775542e406b (diff) | |
Enhancement: Room/Scene Timers (#2478)
* Groundwork on scene/room timers; naming changes
* added to save manager; reworked storing timestamps
* actually saved stuff to savemanager;
accounted for null playstate
* finally fixed the fucking timers
* Added scene mapping
* Added CVar for room/scene level; fixed some displays
* reworked logic
* increase name spec for scene timestamps
* Actually save item timestamps when loading v3 save
* Cleanup
* fix merge artifact
* apply suggestions
Diffstat (limited to 'soh/src/code')
| -rw-r--r-- | soh/src/code/z_parameter.c | 28 | ||||
| -rw-r--r-- | soh/src/code/z_play.c | 29 | ||||
| -rw-r--r-- | soh/src/code/z_room.c | 12 |
3 files changed, 54 insertions, 15 deletions
diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 488c9a320..f1a0eb36a 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -1625,7 +1625,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.timestamp[item] != 0){ + if (gSaveContext.sohStats.itemTimestamp[item] != 0){ return; } // Use ITEM_KEY_BOSS only for Ganon's boss key - not any other boss keys @@ -1644,20 +1644,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.timestamp[ITEM_BOTTLE] == 0) { - gSaveContext.sohStats.timestamp[ITEM_BOTTLE] = time; + if (gSaveContext.sohStats.itemTimestamp[ITEM_BOTTLE] == 0) { + gSaveContext.sohStats.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.timestamp[ITEM_BOMBCHU] == 0) { - gSaveContext.sohStats.timestamp[ITEM_BOMBCHU] = time; + if (gSaveContext.sohStats.itemTimestamp[ITEM_BOMBCHU] == 0) { + gSaveContext.sohStats.itemTimestamp[ITEM_BOMBCHU] = time; } return; } - gSaveContext.sohStats.timestamp[item] = time; + gSaveContext.sohStats.itemTimestamp[item] = time; } // Gameplay stat tracking: Update time the item was acquired @@ -1673,28 +1673,28 @@ void Randomizer_GameplayStats_SetTimestamp(uint16_t item) { // Use ITEM_KEY_BOSS to timestamp Ganon's boss key if (item == RG_GANONS_CASTLE_BOSS_KEY) { - gSaveContext.sohStats.timestamp[ITEM_KEY_BOSS] = time; + gSaveContext.sohStats.itemTimestamp[ITEM_KEY_BOSS] = time; } // Count any bottled item as a bottle if (item >= RG_EMPTY_BOTTLE && item <= RG_BOTTLE_WITH_BIG_POE) { - if (gSaveContext.sohStats.timestamp[ITEM_BOTTLE] == 0) { - gSaveContext.sohStats.timestamp[ITEM_BOTTLE] = time; + if (gSaveContext.sohStats.itemTimestamp[ITEM_BOTTLE] == 0) { + gSaveContext.sohStats.itemTimestamp[ITEM_BOTTLE] = time; } return; } // Count any bombchu pack as bombchus if (item >= RG_BOMBCHU_5 && item <= RG_BOMBCHU_DROP) { - if (gSaveContext.sohStats.timestamp[ITEM_BOMBCHU] = 0) { - gSaveContext.sohStats.timestamp[ITEM_BOMBCHU] = time; + if (gSaveContext.sohStats.itemTimestamp[ITEM_BOMBCHU] = 0) { + gSaveContext.sohStats.itemTimestamp[ITEM_BOMBCHU] = time; } return; } if (item == RG_MAGIC_SINGLE) { - gSaveContext.sohStats.timestamp[ITEM_SINGLE_MAGIC] = time; + gSaveContext.sohStats.itemTimestamp[ITEM_SINGLE_MAGIC] = time; } if (item == RG_DOUBLE_DEFENSE) { - gSaveContext.sohStats.timestamp[ITEM_DOUBLE_DEFENSE] = time; + gSaveContext.sohStats.itemTimestamp[ITEM_DOUBLE_DEFENSE] = time; } } @@ -2525,7 +2525,7 @@ u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) { if (item == RG_GREG_RUPEE) { Rupees_ChangeBy(1); Flags_SetRandomizerInf(RAND_INF_GREG_FOUND); - gSaveContext.sohStats.timestamp[TIMESTAMP_FOUND_GREG] = GAMEPLAYSTAT_TOTAL_TIME; + gSaveContext.sohStats.itemTimestamp[TIMESTAMP_FOUND_GREG] = GAMEPLAYSTAT_TOTAL_TIME; return Return_Item_Entry(giEntry, RG_NONE); } diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index 5d280ca0b..488207a97 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -647,6 +647,33 @@ void Play_Init(GameState* thisx) { gSaveContext.natureAmbienceId = play->sequenceCtx.natureAmbienceId; func_8002DF18(play, GET_PLAYER(play)); AnimationContext_Update(play, &play->animationCtx); + + 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; gSaveContext.respawnFlag = 0; #if 0 if (dREG(95) != 0) { @@ -1085,6 +1112,8 @@ void Play_Update(PlayState* play) { // Gameplay stat tracking if (!gSaveContext.sohStats.gameComplete) { gSaveContext.sohStats.playTimer++; + gSaveContext.sohStats.sceneTimer++; + gSaveContext.sohStats.roomTimer++; if (CVarGetInteger("gMMBunnyHood", 0) && Player_GetMask(play) == PLAYER_MASK_BUNNY) { gSaveContext.sohStats.count[COUNT_TIME_BUNNY_HOOD]++; diff --git a/soh/src/code/z_room.c b/soh/src/code/z_room.c index 23fb6a4d7..59dea1ab3 100644 --- a/soh/src/code/z_room.c +++ b/soh/src/code/z_room.c @@ -641,11 +641,21 @@ void Room_Draw(PlayState* play, Room* room, u32 flags) { void func_80097534(PlayState* play, RoomContext* roomCtx) { roomCtx->prevRoom.num = -1; roomCtx->prevRoom.segment = NULL; - func_80031B14(play, &play->actorCtx); + func_80031B14(play, &play->actorCtx); //kills all actors without room num set to -1 Actor_SpawnTransitionActors(play, &play->actorCtx); Map_InitRoomData(play, roomCtx->curRoom.num); if (!((play->sceneNum >= SCENE_SPOT00) && (play->sceneNum <= SCENE_SPOT20))) { 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; } |
