mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-02-16 07:10:34 -05:00
Allow IsSaveLoaded to consider debug saves (#3929)
This commit is contained in:
parent
0cb4cd158a
commit
3d3b8bfc5b
@ -37,12 +37,19 @@ GameInteractionEffectQueryResult GameInteractor::RemoveEffect(GameInteractionEff
|
|||||||
|
|
||||||
// MARK: - Helpers
|
// MARK: - Helpers
|
||||||
|
|
||||||
bool GameInteractor::IsSaveLoaded() {
|
bool GameInteractor::IsSaveLoaded(bool allowDbgSave) {
|
||||||
Player* player;
|
Player* player;
|
||||||
if (gPlayState != NULL) {
|
if (gPlayState != NULL) {
|
||||||
player = GET_PLAYER(gPlayState);
|
player = GET_PLAYER(gPlayState);
|
||||||
}
|
}
|
||||||
return (gPlayState == NULL || player == NULL || gSaveContext.fileNum < 0 || gSaveContext.fileNum > 2) ? false : true;
|
|
||||||
|
// Checking for normal game mode prevents debug saves from reporting true on title screen
|
||||||
|
if (gPlayState == NULL || player == NULL || gSaveContext.gameMode != GAMEMODE_NORMAL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Valid save file or debug save
|
||||||
|
return (gSaveContext.fileNum >= 0 && gSaveContext.fileNum <= 2) || (allowDbgSave && gSaveContext.fileNum == 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameInteractor::IsGameplayPaused() {
|
bool GameInteractor::IsGameplayPaused() {
|
||||||
|
@ -198,7 +198,7 @@ public:
|
|||||||
DEFINE_HOOK(OnAssetAltChange, void());
|
DEFINE_HOOK(OnAssetAltChange, void());
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
static bool IsSaveLoaded();
|
static bool IsSaveLoaded(bool allowDbgSave = false);
|
||||||
static bool IsGameplayPaused();
|
static bool IsGameplayPaused();
|
||||||
static bool CanSpawnActor();
|
static bool CanSpawnActor();
|
||||||
static bool CanAddOrTakeAmmo(int16_t amount, int16_t item);
|
static bool CanAddOrTakeAmmo(int16_t amount, int16_t item);
|
||||||
|
@ -47,7 +47,7 @@ void ReloadSceneTogglingLinkAge() {
|
|||||||
|
|
||||||
void RegisterInfiniteMoney() {
|
void RegisterInfiniteMoney() {
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
||||||
if (!GameInteractor::IsSaveLoaded()) return;
|
if (!GameInteractor::IsSaveLoaded(true)) return;
|
||||||
if (CVarGetInteger("gInfiniteMoney", 0) != 0) {
|
if (CVarGetInteger("gInfiniteMoney", 0) != 0) {
|
||||||
if (gSaveContext.rupees < CUR_CAPACITY(UPG_WALLET)) {
|
if (gSaveContext.rupees < CUR_CAPACITY(UPG_WALLET)) {
|
||||||
gSaveContext.rupees = CUR_CAPACITY(UPG_WALLET);
|
gSaveContext.rupees = CUR_CAPACITY(UPG_WALLET);
|
||||||
@ -58,7 +58,7 @@ void RegisterInfiniteMoney() {
|
|||||||
|
|
||||||
void RegisterInfiniteHealth() {
|
void RegisterInfiniteHealth() {
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
||||||
if (!GameInteractor::IsSaveLoaded()) return;
|
if (!GameInteractor::IsSaveLoaded(true)) return;
|
||||||
if (CVarGetInteger("gInfiniteHealth", 0) != 0) {
|
if (CVarGetInteger("gInfiniteHealth", 0) != 0) {
|
||||||
if (gSaveContext.health < gSaveContext.healthCapacity) {
|
if (gSaveContext.health < gSaveContext.healthCapacity) {
|
||||||
gSaveContext.health = gSaveContext.healthCapacity;
|
gSaveContext.health = gSaveContext.healthCapacity;
|
||||||
@ -69,7 +69,7 @@ void RegisterInfiniteHealth() {
|
|||||||
|
|
||||||
void RegisterInfiniteAmmo() {
|
void RegisterInfiniteAmmo() {
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
||||||
if (!GameInteractor::IsSaveLoaded()) return;
|
if (!GameInteractor::IsSaveLoaded(true)) return;
|
||||||
if (CVarGetInteger("gInfiniteAmmo", 0) != 0) {
|
if (CVarGetInteger("gInfiniteAmmo", 0) != 0) {
|
||||||
// Deku Sticks
|
// Deku Sticks
|
||||||
if (AMMO(ITEM_STICK) < CUR_CAPACITY(UPG_STICKS)) {
|
if (AMMO(ITEM_STICK) < CUR_CAPACITY(UPG_STICKS)) {
|
||||||
@ -106,7 +106,7 @@ void RegisterInfiniteAmmo() {
|
|||||||
|
|
||||||
void RegisterInfiniteMagic() {
|
void RegisterInfiniteMagic() {
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
||||||
if (!GameInteractor::IsSaveLoaded()) return;
|
if (!GameInteractor::IsSaveLoaded(true)) return;
|
||||||
if (CVarGetInteger("gInfiniteMagic", 0) != 0) {
|
if (CVarGetInteger("gInfiniteMagic", 0) != 0) {
|
||||||
if (gSaveContext.isMagicAcquired && gSaveContext.magic != (gSaveContext.isDoubleMagicAcquired + 1) * 0x30) {
|
if (gSaveContext.isMagicAcquired && gSaveContext.magic != (gSaveContext.isDoubleMagicAcquired + 1) * 0x30) {
|
||||||
gSaveContext.magic = (gSaveContext.isDoubleMagicAcquired + 1) * 0x30;
|
gSaveContext.magic = (gSaveContext.isDoubleMagicAcquired + 1) * 0x30;
|
||||||
@ -117,7 +117,7 @@ void RegisterInfiniteMagic() {
|
|||||||
|
|
||||||
void RegisterInfiniteNayrusLove() {
|
void RegisterInfiniteNayrusLove() {
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
||||||
if (!GameInteractor::IsSaveLoaded()) return;
|
if (!GameInteractor::IsSaveLoaded(true)) return;
|
||||||
if (CVarGetInteger("gInfiniteNayru", 0) != 0) {
|
if (CVarGetInteger("gInfiniteNayru", 0) != 0) {
|
||||||
gSaveContext.nayrusLoveTimer = 0x44B;
|
gSaveContext.nayrusLoveTimer = 0x44B;
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ void RegisterInfiniteNayrusLove() {
|
|||||||
|
|
||||||
void RegisterMoonJumpOnL() {
|
void RegisterMoonJumpOnL() {
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
||||||
if (!GameInteractor::IsSaveLoaded()) return;
|
if (!GameInteractor::IsSaveLoaded(true)) return;
|
||||||
|
|
||||||
if (CVarGetInteger("gMoonJumpOnL", 0) != 0) {
|
if (CVarGetInteger("gMoonJumpOnL", 0) != 0) {
|
||||||
Player* player = GET_PLAYER(gPlayState);
|
Player* player = GET_PLAYER(gPlayState);
|
||||||
@ -141,7 +141,7 @@ void RegisterMoonJumpOnL() {
|
|||||||
|
|
||||||
void RegisterInfiniteISG() {
|
void RegisterInfiniteISG() {
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
||||||
if (!GameInteractor::IsSaveLoaded()) return;
|
if (!GameInteractor::IsSaveLoaded(true)) return;
|
||||||
|
|
||||||
if (CVarGetInteger("gEzISG", 0) != 0) {
|
if (CVarGetInteger("gEzISG", 0) != 0) {
|
||||||
Player* player = GET_PLAYER(gPlayState);
|
Player* player = GET_PLAYER(gPlayState);
|
||||||
@ -153,7 +153,7 @@ void RegisterInfiniteISG() {
|
|||||||
//Permanent quick put away (QPA) glitched damage value
|
//Permanent quick put away (QPA) glitched damage value
|
||||||
void RegisterEzQPA() {
|
void RegisterEzQPA() {
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
||||||
if (!GameInteractor::IsSaveLoaded()) return;
|
if (!GameInteractor::IsSaveLoaded(true)) return;
|
||||||
|
|
||||||
if (CVarGetInteger("gEzQPA", 0) != 0) {
|
if (CVarGetInteger("gEzQPA", 0) != 0) {
|
||||||
Player* player = GET_PLAYER(gPlayState);
|
Player* player = GET_PLAYER(gPlayState);
|
||||||
@ -165,7 +165,7 @@ void RegisterEzQPA() {
|
|||||||
|
|
||||||
void RegisterUnrestrictedItems() {
|
void RegisterUnrestrictedItems() {
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
||||||
if (!GameInteractor::IsSaveLoaded()) return;
|
if (!GameInteractor::IsSaveLoaded(true)) return;
|
||||||
|
|
||||||
if (CVarGetInteger("gNoRestrictItems", 0) != 0) {
|
if (CVarGetInteger("gNoRestrictItems", 0) != 0) {
|
||||||
u8 sunsBackup = gPlayState->interfaceCtx.restrictions.sunsSong;
|
u8 sunsBackup = gPlayState->interfaceCtx.restrictions.sunsSong;
|
||||||
@ -193,11 +193,14 @@ void RegisterFreezeTime() {
|
|||||||
/// Switches Link's age and respawns him at the last entrance he entered.
|
/// Switches Link's age and respawns him at the last entrance he entered.
|
||||||
void RegisterSwitchAge() {
|
void RegisterSwitchAge() {
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
|
||||||
if (!GameInteractor::IsSaveLoaded()) {
|
static bool warped = false;
|
||||||
|
|
||||||
|
if (!GameInteractor::IsSaveLoaded(true)) {
|
||||||
CVarClear("gSwitchAge");
|
CVarClear("gSwitchAge");
|
||||||
|
warped = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
static bool warped = false;
|
|
||||||
static Vec3f playerPos;
|
static Vec3f playerPos;
|
||||||
static int16_t playerYaw;
|
static int16_t playerYaw;
|
||||||
static RoomContext* roomCtx;
|
static RoomContext* roomCtx;
|
||||||
@ -231,7 +234,7 @@ void RegisterSwitchAge() {
|
|||||||
void RegisterOcarinaTimeTravel() {
|
void RegisterOcarinaTimeTravel() {
|
||||||
|
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnOcarinaSongAction>([]() {
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnOcarinaSongAction>([]() {
|
||||||
if (!GameInteractor::IsSaveLoaded()) {
|
if (!GameInteractor::IsSaveLoaded(true)) {
|
||||||
CVarClear("gTimeTravel");
|
CVarClear("gTimeTravel");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ void RegisterOnInterfaceUpdateHook() {
|
|||||||
|
|
||||||
prevTimer = timer;
|
prevTimer = timer;
|
||||||
|
|
||||||
if (!GameInteractor::IsSaveLoaded()) return;
|
if (!GameInteractor::IsSaveLoaded(true)) return;
|
||||||
|
|
||||||
static int16_t lostHealth = 0;
|
static int16_t lostHealth = 0;
|
||||||
static int16_t prevHealth = 0;
|
static int16_t prevHealth = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user