Skip to content

Commit 12f5169

Browse files
authored
True match sub_080784E4
1 parent 6fb8b41 commit 12f5169

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

src/playerUtils.c

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,9 +1158,29 @@ void ResetPossibleInteraction(void) {
11581158
gPossibleInteraction.currentObject = (InteractableObject*)&gNoInteraction;
11591159
}
11601160

1161+
static inline bool32 InlinePlayerStateCheck() {
1162+
u8 frameState;
1163+
if ((gPlayerState.field_0x27[0] | gPlayerState.swim_state) != 0) {
1164+
return TRUE;
1165+
}
1166+
if (gPlayerState.framestate == 0) {
1167+
frameState = gPlayerState.framestate_last;
1168+
} else {
1169+
frameState = gPlayerState.framestate;
1170+
}
1171+
switch (frameState) {
1172+
case PL_STATE_SWORD:
1173+
case PL_STATE_GUSTJAR:
1174+
case PL_STATE_DIE:
1175+
case PL_STATE_ITEMGET:
1176+
case PL_STATE_DROWN:
1177+
return TRUE;
1178+
}
1179+
return FALSE;
1180+
}
1181+
11611182
// determines which (if any) object the player is currently able to interact with
11621183
InteractableObject* sub_080784E4(void) {
1163-
u8 frameState;
11641184
PlayerFlags r7;
11651185
s32 r3;
11661186
PlayerFlags PVar4;
@@ -1177,26 +1197,12 @@ InteractableObject* sub_080784E4(void) {
11771197
if (gPossibleInteraction.isUpdated != 0) {
11781198
return gPossibleInteraction.currentObject;
11791199
}
1180-
if ((gPlayerState.field_0x27[0] | gPlayerState.swim_state) != 0) {
1181-
goto l;
1182-
}
11831200

1184-
if (gPlayerState.framestate == 0) {
1185-
frameState = gPlayerState.framestate_last;
1186-
} else {
1187-
frameState = gPlayerState.framestate;
1188-
}
1189-
switch (frameState) {
1190-
case PL_STATE_SWORD:
1191-
case PL_STATE_GUSTJAR:
1192-
case PL_STATE_DIE:
1193-
case PL_STATE_ITEMGET:
1194-
case PL_STATE_DROWN:
1195-
l:
1196-
gPossibleInteraction.currentIndex = 0xFF;
1197-
gPossibleInteraction.currentObject = (InteractableObject*)&gNoInteraction;
1198-
gPossibleInteraction.isUpdated = 1;
1199-
return gPossibleInteraction.currentObject;
1201+
if (InlinePlayerStateCheck()) {
1202+
gPossibleInteraction.currentIndex = 0xFF;
1203+
gPossibleInteraction.currentObject = (InteractableObject*)&gNoInteraction;
1204+
gPossibleInteraction.isUpdated = 1;
1205+
return gPossibleInteraction.currentObject;
12001206
}
12011207

12021208
if (!(gPlayerState.flags & PL_MINISH)) {

0 commit comments

Comments
 (0)