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
This commit is contained in:
Ralphie Morell
2023-04-03 00:06:55 -04:00
committed by GitHub
parent 0f40472c1a
commit ff1d8a9e9d
17 changed files with 591 additions and 318 deletions

View File

@@ -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]++;