summaryrefslogtreecommitdiff
path: root/soh/src/code
diff options
context:
space:
mode:
authorDavid Chavez <david@dcvz.io>2023-02-28 11:20:43 +0100
committerGitHub <noreply@github.com>2023-02-28 11:20:43 +0100
commitc91a044d4635b86381e5dea05c38a356b684b638 (patch)
tree3f6b6051d4486242cd325b8c7ec34c3fe2159ecf /soh/src/code
parentafc61e65ee904523d355bc4a8f3d34dd66e5d576 (diff)
[GameInteractor] Introduce GameFrameUpdate Hook and Migrate Cheats (#2554)
Diffstat (limited to 'soh/src/code')
-rw-r--r--soh/src/code/game.c136
1 files changed, 2 insertions, 134 deletions
diff --git a/soh/src/code/game.c b/soh/src/code/game.c
index cdb36787e..546901d3e 100644
--- a/soh/src/code/game.c
+++ b/soh/src/code/game.c
@@ -1,6 +1,7 @@
#include <string.h>
#include "global.h"
#include "vt.h"
+#include "soh/Enhancements/game-interactor/GameInteractor.h"
SpeedMeter D_801664D0;
struct_801664F0 D_801664F0;
@@ -9,10 +10,6 @@ VisMono sMonoColors;
ViMode sViMode;
FaultClient sGameFaultClient;
u16 sLastButtonPressed;
-int32_t warpTime = 0;
-bool warped = false;
-Vec3f playerPos;
-int16_t playerYaw;
// Forward declared, because this in a C++ header.
int gfx_create_framebuffer(uint32_t width, uint32_t height);
@@ -328,138 +325,9 @@ void GameState_Update(GameState* gameState) {
func_800C49F4(gfxCtx);
}
- // -----------------------
- // Cheats hooks
- // -----------------------
-
- // Inf Money
- if (CVarGetInteger("gInfiniteMoney", 0) != 0) {
- if (gSaveContext.rupees < CUR_CAPACITY(UPG_WALLET)) {
- gSaveContext.rupees = CUR_CAPACITY(UPG_WALLET);
- }
- }
-
- // Inf Health
- if (CVarGetInteger("gInfiniteHealth", 0) != 0) {
- if (gSaveContext.health < gSaveContext.healthCapacity) {
- gSaveContext.health = gSaveContext.healthCapacity;
- }
- }
-
- // Inf Ammo
- if (CVarGetInteger("gInfiniteAmmo", 0) != 0) {
- // Deku Sticks
- if (AMMO(ITEM_STICK) < CUR_CAPACITY(UPG_STICKS)) {
- AMMO(ITEM_STICK) = CUR_CAPACITY(UPG_STICKS);
- }
-
- // Deku Nuts
- if (AMMO(ITEM_NUT) < CUR_CAPACITY(UPG_NUTS)) {
- AMMO(ITEM_NUT) = CUR_CAPACITY(UPG_NUTS);
- }
-
- // Bombs
- if (AMMO(ITEM_BOMB) < CUR_CAPACITY(UPG_BOMB_BAG)) {
- AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG);
- }
-
- // Fairy Bow (Ammo)
- if (AMMO(ITEM_BOW) < CUR_CAPACITY(UPG_QUIVER)) {
- AMMO(ITEM_BOW) = CUR_CAPACITY(UPG_QUIVER);
- }
-
- // Fairy Slingshot (Ammo)
- if (AMMO(ITEM_SLINGSHOT) < CUR_CAPACITY(UPG_BULLET_BAG)) {
- AMMO(ITEM_SLINGSHOT) = CUR_CAPACITY(UPG_BULLET_BAG);
- }
-
- // Bombchus (max: 50, no upgrades)
- if (INV_CONTENT(ITEM_BOMBCHU) == ITEM_BOMBCHU && AMMO(ITEM_BOMBCHU) < 50) {
- AMMO(ITEM_BOMBCHU) = 50;
- }
- }
-
- // Inf Magic
- if (CVarGetInteger("gInfiniteMagic", 0) != 0) {
- if (gSaveContext.isMagicAcquired && gSaveContext.magic != (gSaveContext.isDoubleMagicAcquired + 1) * 0x30) {
- gSaveContext.magic = (gSaveContext.isDoubleMagicAcquired + 1) * 0x30;
- }
- }
-
- // Inf Nayru's Love Timer
- if (CVarGetInteger("gInfiniteNayru", 0) != 0) {
- gSaveContext.nayrusLoveTimer = 0x44B;
- }
-
- // Moon Jump On L
- if (CVarGetInteger("gMoonJumpOnL", 0) != 0) {
- if (gPlayState) {
- Player* player = GET_PLAYER(gPlayState);
-
- if (CHECK_BTN_ANY(gPlayState->state.input[0].cur.button, BTN_L)) {
- player->actor.velocity.y = 6.34375f;
- }
- }
- }
-
- // Permanent infinite sword glitch (ISG)
- if (CVarGetInteger("gEzISG", 0) != 0) {
- if (gPlayState) {
- Player* player = GET_PLAYER(gPlayState);
- player->swordState = 1;
- }
- }
-
- // Unrestricted Items
- if (CVarGetInteger("gNoRestrictItems", 0) != 0) {
- if (gPlayState) {
- u8 sunsBackup = gPlayState->interfaceCtx.restrictions.sunsSong;
- memset(&gPlayState->interfaceCtx.restrictions, 0, sizeof(gPlayState->interfaceCtx.restrictions));
- gPlayState->interfaceCtx.restrictions.sunsSong = sunsBackup;
- }
- }
-
- // Freeze Time
- if (CVarGetInteger("gFreezeTime", 0) != 0) {
- if (CVarGetInteger("gPrevTime", -1) == -1) {
- CVarSetInteger("gPrevTime", gSaveContext.dayTime);
- }
-
- int32_t prevTime = CVarGetInteger("gPrevTime", gSaveContext.dayTime);
- gSaveContext.dayTime = prevTime;
- } else {
- CVarSetInteger("gPrevTime", -1);
- }
-
- //Switches Link's age and respawns him at the last entrance he entered.
- if (CVarGetInteger("gSwitchAge", 0) != 0) {
- CVarSetInteger("gSwitchAge", 0);
- if (gPlayState) {
- playerPos = GET_PLAYER(gPlayState)->actor.world.pos;
- playerYaw = GET_PLAYER(gPlayState)->actor.shape.rot.y;
- gPlayState->nextEntranceIndex = gSaveContext.entranceIndex;
- gPlayState->sceneLoadFlag = 0x14;
- gPlayState->fadeTransition = 11;
- gSaveContext.nextTransitionType = 11;
- warped = true;
- if (gPlayState->linkAgeOnLoad == 1) {
- gPlayState->linkAgeOnLoad = 0;
- } else {
- gPlayState->linkAgeOnLoad = 1;
- }
- }
- }
-
- if (gPlayState) {
- if (warped && gPlayState->sceneLoadFlag != 0x0014 && gSaveContext.nextTransitionType == 255) {
- GET_PLAYER(gPlayState)->actor.shape.rot.y = playerYaw;
- GET_PLAYER(gPlayState)->actor.world.pos = playerPos;
- warped = false;
- }
- }
-
gSaveContext.language = CVarGetInteger("gLanguages", LANGUAGE_ENG);
+ GameInteractor_ExecuteOnGameFrameUpdate();
gameState->frames++;
}