[Game Interactor] Add LoadGame and ExitGame hooks (#2542)

* add loadgame/exitgame GI hooks

* implement loadgame/exitgame hooks in game code

* move entrance tracker data lifecycle to hooks

* update cosmetic editor to update onloadgame hook
This commit is contained in:
Adam Bird 2023-02-26 23:04:57 -05:00 committed by GitHub
commit f7bb807940
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 47 additions and 21 deletions

View file

@ -7,6 +7,7 @@
#include <ImGuiImpl.h>
#include "soh/frame_interpolation.h"
#include "soh/Enhancements/debugconsole.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/randomizer/randomizer_entrance.h"
#include <overlays/actors/ovl_En_Niw/z_en_niw.h>
@ -427,10 +428,12 @@ void Play_Init(GameState* thisx) {
}
}
// Invalid entrance, so immediately exit the game to opening title
if (gSaveContext.entranceIndex == -1) {
gSaveContext.entranceIndex = 0;
play->state.running = false;
SET_NEXT_GAMESTATE(&play->state, Opening_Init, OpeningContext);
GameInteractor_ExecuteOnExitGame(gSaveContext.fileNum);
return;
}

View file

@ -611,6 +611,4 @@ void Sram_InitSram(GameState* gameState) {
// When going from a rando save to a vanilla save within the same game instance
// we need to reset the entrance table back to its vanilla state
Entrance_ResetEntranceTable();
// Clear out the entrance tracker
Entrance_ClearEntranceTrackingData();
}

View file

@ -9,6 +9,7 @@
#include <GameVersions.h>
#include "objects/object_mag/object_mag.h"
#include "objects/gameplay_keep/gameplay_keep.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#define NORMAL_QUEST 0
#define MASTER_QUEST 1
@ -2148,7 +2149,6 @@ void FileChoose_LoadGame(GameState* thisx) {
if (gSaveContext.n64ddFlag) {
// Setup the modified entrance table and entrance shuffle table for rando
Entrance_Init();
Entrance_InitEntranceTrackingData();
// Handle randomized spawn positions after the save context has been setup from load
// When remeber save location is on, set save warp if the save was in an a grotto, or
@ -2159,6 +2159,8 @@ void FileChoose_LoadGame(GameState* thisx) {
Entrance_SetSavewarpEntrance();
}
}
GameInteractor_ExecuteOnLoadGame(gSaveContext.fileNum);
}
static void (*gSelectModeUpdateFuncs[])(GameState*) = {

View file

@ -14,6 +14,7 @@
#include "vt.h"
#include "soh/frame_interpolation.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/randomizer/randomizer_entrance.h"
static void* sEquipmentFRATexs[] = {
@ -4180,6 +4181,7 @@ void KaleidoScope_Update(PlayState* play)
} else {
play->state.running = 0;
SET_NEXT_GAMESTATE(&play->state, Opening_Init, OpeningContext);
GameInteractor_ExecuteOnExitGame(gSaveContext.fileNum);
}
}
}