Skip to content

Commit

Permalink
Merge pull request #688 from KEKW555/KEKW555-patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
hytopoulos committed Jan 21, 2024
2 parents a804fd3 + 12f5169 commit eaaeb3a
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions src/playerUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1179,9 +1179,29 @@ void ResetPossibleInteraction(void) {
gPossibleInteraction.currentObject = (InteractableObject*)&gNoInteraction;
}

static inline bool32 InlinePlayerStateCheck() {
u8 frameState;
if ((gPlayerState.field_0x27[0] | gPlayerState.swim_state) != 0) {
return TRUE;
}
if (gPlayerState.framestate == 0) {
frameState = gPlayerState.framestate_last;
} else {
frameState = gPlayerState.framestate;
}
switch (frameState) {
case PL_STATE_SWORD:
case PL_STATE_GUSTJAR:
case PL_STATE_DIE:
case PL_STATE_ITEMGET:
case PL_STATE_DROWN:
return TRUE;
}
return FALSE;
}

// determines which (if any) object the player is currently able to interact with
InteractableObject* sub_080784E4(void) {
u8 frameState;
PlayerFlags r7;
s32 r3;
PlayerFlags PVar4;
Expand All @@ -1198,26 +1218,12 @@ InteractableObject* sub_080784E4(void) {
if (gPossibleInteraction.isUpdated != 0) {
return gPossibleInteraction.currentObject;
}
if ((gPlayerState.field_0x27[0] | gPlayerState.swim_state) != 0) {
goto l;
}

if (gPlayerState.framestate == 0) {
frameState = gPlayerState.framestate_last;
} else {
frameState = gPlayerState.framestate;
}
switch (frameState) {
case PL_STATE_SWORD:
case PL_STATE_GUSTJAR:
case PL_STATE_DIE:
case PL_STATE_ITEMGET:
case PL_STATE_DROWN:
l:
gPossibleInteraction.currentIndex = 0xFF;
gPossibleInteraction.currentObject = (InteractableObject*)&gNoInteraction;
gPossibleInteraction.isUpdated = 1;
return gPossibleInteraction.currentObject;
if (InlinePlayerStateCheck()) {
gPossibleInteraction.currentIndex = 0xFF;
gPossibleInteraction.currentObject = (InteractableObject*)&gNoInteraction;
gPossibleInteraction.isUpdated = 1;
return gPossibleInteraction.currentObject;
}

if (!(gPlayerState.flags & PL_MINISH)) {
Expand Down

0 comments on commit eaaeb3a

Please sign in to comment.