fix change age cheat causing link to spawn in the wrong spot (#2573)

This commit is contained in:
Adam Bird 2023-03-02 17:12:46 -05:00 committed by GitHub
parent 0d54cb15df
commit a5bf135541
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 40 deletions

View File

@ -89,13 +89,13 @@ void RegisterInfiniteNayrusLove() {
void RegisterMoonJumpOnL() { void RegisterMoonJumpOnL() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() { GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!gPlayState) return;
if (CVarGetInteger("gMoonJumpOnL", 0) != 0) { if (CVarGetInteger("gMoonJumpOnL", 0) != 0) {
if (gPlayState) { Player* player = GET_PLAYER(gPlayState);
Player* player = GET_PLAYER(gPlayState);
if (CHECK_BTN_ANY(gPlayState->state.input[0].cur.button, BTN_L)) { if (CHECK_BTN_ANY(gPlayState->state.input[0].cur.button, BTN_L)) {
player->actor.velocity.y = 6.34375f; player->actor.velocity.y = 6.34375f;
}
} }
} }
}); });
@ -104,23 +104,23 @@ void RegisterMoonJumpOnL() {
void RegisterInfiniteISG() { void RegisterInfiniteISG() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() { GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!gPlayState) return;
if (CVarGetInteger("gEzISG", 0) != 0) { if (CVarGetInteger("gEzISG", 0) != 0) {
if (gPlayState) { Player* player = GET_PLAYER(gPlayState);
Player* player = GET_PLAYER(gPlayState); player->swordState = 1;
player->swordState = 1;
}
} }
}); });
} }
void RegisterUnrestrictedItems() { void RegisterUnrestrictedItems() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() { GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
if (!gPlayState) return;
if (CVarGetInteger("gNoRestrictItems", 0) != 0) { if (CVarGetInteger("gNoRestrictItems", 0) != 0) {
if (gPlayState) { u8 sunsBackup = gPlayState->interfaceCtx.restrictions.sunsSong;
u8 sunsBackup = gPlayState->interfaceCtx.restrictions.sunsSong; memset(&gPlayState->interfaceCtx.restrictions, 0, sizeof(gPlayState->interfaceCtx.restrictions));
memset(&gPlayState->interfaceCtx.restrictions, 0, sizeof(gPlayState->interfaceCtx.restrictions)); gPlayState->interfaceCtx.restrictions.sunsSong = sunsBackup;
gPlayState->interfaceCtx.restrictions.sunsSong = sunsBackup;
}
} }
}); });
} }
@ -142,35 +142,31 @@ 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() {
bool warped = false; GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
Vec3f playerPos; static bool warped = false;
int16_t playerYaw; static Vec3f playerPos;
static int16_t playerYaw;
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([&warped, &playerPos, &playerYaw]() {
if (!gPlayState) return;
if (CVarGetInteger("gSwitchAge", 0) != 0) { if (CVarGetInteger("gSwitchAge", 0) != 0) {
CVarSetInteger("gSwitchAge", 0); CVarSetInteger("gSwitchAge", 0);
if (gPlayState) { playerPos = GET_PLAYER(gPlayState)->actor.world.pos;
playerPos = GET_PLAYER(gPlayState)->actor.world.pos; playerYaw = GET_PLAYER(gPlayState)->actor.shape.rot.y;
playerYaw = GET_PLAYER(gPlayState)->actor.shape.rot.y;
gPlayState->nextEntranceIndex = gSaveContext.entranceIndex; gPlayState->nextEntranceIndex = gSaveContext.entranceIndex;
gPlayState->sceneLoadFlag = 0x14; gPlayState->sceneLoadFlag = 0x14;
gPlayState->fadeTransition = 11; gPlayState->fadeTransition = 11;
gSaveContext.nextTransitionType = 11; gSaveContext.nextTransitionType = 11;
warped = true; gPlayState->linkAgeOnLoad ^= 1;
if (gPlayState->linkAgeOnLoad == 1) {
gPlayState->linkAgeOnLoad = 0; warped = true;
} else {
gPlayState->linkAgeOnLoad = 1;
}
}
} }
if (gPlayState) { if (warped && gPlayState->sceneLoadFlag != 0x0014 && gSaveContext.nextTransitionType == 255) {
if (warped && gPlayState->sceneLoadFlag != 0x0014 && gSaveContext.nextTransitionType == 255) { GET_PLAYER(gPlayState)->actor.shape.rot.y = playerYaw;
GET_PLAYER(gPlayState)->actor.shape.rot.y = playerYaw; GET_PLAYER(gPlayState)->actor.world.pos = playerPos;
GET_PLAYER(gPlayState)->actor.world.pos = playerPos; warped = false;
warped = false;
}
} }
}); });
} }