Convert GameInteractor_Should hook to use variadic arguments (#4383)

* Convert _Should to use variadic args

* Convert everything to use va_arg properly

* Update shop hooks to va_args

* Wrong Function

* Update hook_handlers.cpp

---------

Co-authored-by: Malkierian <malkierian@gmail.com>
Co-authored-by: Malkierian <malkierian@live.com>
This commit is contained in:
Archez 2024-10-08 23:20:09 -04:00 committed by GitHub
commit 5d311fac9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
63 changed files with 308 additions and 270 deletions

View file

@ -1628,23 +1628,23 @@ void func_800ED458(s32 arg0) {
}
Audio_OcaUpdateBtnMap(customControls, dpad, rStick);
if (D_8016BA18 & sOcarinaD4BtnMap && GameInteractor_Should(VB_HAVE_OCARINA_NOTE_D4, true, NULL)) {
if (D_8016BA18 & sOcarinaD4BtnMap && GameInteractor_Should(VB_HAVE_OCARINA_NOTE_D4, true)) {
osSyncPrintf("Presss NA_KEY_D4 %08x\n", sOcarinaD4BtnMap);
sCurOcarinaBtnVal = 2;
sCurOcarinaBtnIdx = 0;
} else if (D_8016BA18 & sOcarinaF4BtnMap && GameInteractor_Should(VB_HAVE_OCARINA_NOTE_F4, true, NULL)) {
} else if (D_8016BA18 & sOcarinaF4BtnMap && GameInteractor_Should(VB_HAVE_OCARINA_NOTE_F4, true)) {
osSyncPrintf("Presss NA_KEY_F4 %08x\n", sOcarinaF4BtnMap);
sCurOcarinaBtnVal = 5;
sCurOcarinaBtnIdx = 1;
} else if (D_8016BA18 & sOcarinaA4BtnMap && GameInteractor_Should(VB_HAVE_OCARINA_NOTE_A4, true, NULL)) {
} else if (D_8016BA18 & sOcarinaA4BtnMap && GameInteractor_Should(VB_HAVE_OCARINA_NOTE_A4, true)) {
osSyncPrintf("Presss NA_KEY_A4 %08x\n", sOcarinaA4BtnMap);
sCurOcarinaBtnVal = 9;
sCurOcarinaBtnIdx = 2;
} else if (D_8016BA18 & sOcarinaB4BtnMap && GameInteractor_Should(VB_HAVE_OCARINA_NOTE_B4, true, NULL)) {
} else if (D_8016BA18 & sOcarinaB4BtnMap && GameInteractor_Should(VB_HAVE_OCARINA_NOTE_B4, true)) {
osSyncPrintf("Presss NA_KEY_B4 %08x\n", sOcarinaA4BtnMap);
sCurOcarinaBtnVal = 0xB;
sCurOcarinaBtnIdx = 3;
} else if (D_8016BA18 & sOcarinaD5BtnMap && GameInteractor_Should(VB_HAVE_OCARINA_NOTE_D5, true, NULL)) {
} else if (D_8016BA18 & sOcarinaD5BtnMap && GameInteractor_Should(VB_HAVE_OCARINA_NOTE_D5, true)) {
osSyncPrintf("Presss NA_KEY_D5 %08x\n", sOcarinaD5BtnMap);
sCurOcarinaBtnVal = 0xE;
sCurOcarinaBtnIdx = 4;

View file

@ -497,11 +497,11 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB
bool shouldSkipCommand = false;
if (cmd->base == 8 && !GameInteractor_Should(VB_PLAY_PULL_MASTER_SWORD_CS, true, NULL)) {
if (cmd->base == 8 && !GameInteractor_Should(VB_PLAY_PULL_MASTER_SWORD_CS, true)) {
shouldSkipCommand = true;
}
if (cmd->base == 24 && !GameInteractor_Should(VB_PLAY_DROP_FISH_FOR_JABU_CS, true, NULL)) {
if (cmd->base == 24 && !GameInteractor_Should(VB_PLAY_DROP_FISH_FOR_JABU_CS, true)) {
shouldSkipCommand = true;
}
@ -631,7 +631,7 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB
gSaveContext.fw.set = 0;
gSaveContext.respawn[RESPAWN_MODE_TOP].data = 0;
}
if (GameInteractor_Should(VB_PLAY_PULL_MASTER_SWORD_CS, !Flags_GetEventChkInf(EVENTCHKINF_PULLED_MASTER_SWORD_FROM_PEDESTAL), NULL)) {
if (GameInteractor_Should(VB_PLAY_PULL_MASTER_SWORD_CS, !Flags_GetEventChkInf(EVENTCHKINF_PULLED_MASTER_SWORD_FROM_PEDESTAL))) {
Flags_SetEventChkInf(EVENTCHKINF_PULLED_MASTER_SWORD_FROM_PEDESTAL);
play->nextEntranceIndex = ENTR_CUTSCENE_MAP_0;
play->transitionTrigger = TRANS_TRIGGER_START;
@ -723,7 +723,7 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB
play->transitionType = TRANS_TYPE_FADE_WHITE;
break;
case 22:
if (GameInteractor_Should(VB_GIVE_ITEM_REQUIEM_OF_SPIRIT, true, NULL)) {
if (GameInteractor_Should(VB_GIVE_ITEM_REQUIEM_OF_SPIRIT, true)) {
Item_Give(play, ITEM_SONG_REQUIEM);
}
play->nextEntranceIndex = ENTR_DESERT_COLOSSUS_0;
@ -777,7 +777,7 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB
play->nextEntranceIndex = ENTR_CHAMBER_OF_THE_SAGES_0;
play->transitionTrigger = TRANS_TRIGGER_START;
play->transitionType = TRANS_TYPE_FADE_WHITE;
if (GameInteractor_Should(VB_GIVE_ITEM_FIRE_MEDALLION, true, NULL)) {
if (GameInteractor_Should(VB_GIVE_ITEM_FIRE_MEDALLION, true)) {
Item_Give(play, ITEM_MEDALLION_FIRE);
}
gSaveContext.chamberCutsceneNum = 1;
@ -859,7 +859,7 @@ void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdB
play->transitionType = TRANS_TYPE_FADE_BLACK_FAST;
break;
case 47:
if (GameInteractor_Should(VB_GIVE_ITEM_NOCTURNE_OF_SHADOW, true, NULL)) {
if (GameInteractor_Should(VB_GIVE_ITEM_NOCTURNE_OF_SHADOW, true)) {
Item_Give(play, ITEM_SONG_NOCTURNE);
}
Flags_SetEventChkInf(EVENTCHKINF_LEARNED_NOCTURNE_OF_SHADOW);
@ -2197,7 +2197,7 @@ void Cutscene_HandleConditionalTriggers(PlayState* play) {
osSyncPrintf("\ngame_info.mode=[%d] restart_flag", ((void)0, gSaveContext.respawnFlag));
LUSLOG_INFO("Cutscene_HandleConditionalTriggers - entranceIndex: %#x cutsceneIndex: %#x", gSaveContext.entranceIndex, gSaveContext.cutsceneIndex);
if (!GameInteractor_Should(VB_PLAY_TRANSITION_CS, true, NULL)) {
if (!GameInteractor_Should(VB_PLAY_TRANSITION_CS, true)) {
return;
}
@ -2213,12 +2213,12 @@ void Cutscene_HandleConditionalTriggers(PlayState* play) {
Flags_GetEventChkInf(EVENTCHKINF_USED_FIRE_TEMPLE_BLUE_WARP) &&
Flags_GetEventChkInf(EVENTCHKINF_USED_WATER_TEMPLE_BLUE_WARP) &&
!Flags_GetEventChkInf(EVENTCHKINF_BONGO_BONGO_ESCAPED_FROM_WELL)
), NULL)) {
))) {
Flags_SetEventChkInf(EVENTCHKINF_BONGO_BONGO_ESCAPED_FROM_WELL);
gSaveContext.cutsceneIndex = 0xFFF0;
} else if ((gSaveContext.entranceIndex == ENTR_LOST_WOODS_9) && !Flags_GetEventChkInf(EVENTCHKINF_SPOKE_TO_SARIA_ON_BRIDGE)) {
Flags_SetEventChkInf(EVENTCHKINF_SPOKE_TO_SARIA_ON_BRIDGE);
if (GameInteractor_Should(VB_GIVE_ITEM_FAIRY_OCARINA, true, NULL)) {
if (GameInteractor_Should(VB_GIVE_ITEM_FAIRY_OCARINA, true)) {
Item_Give(play, ITEM_OCARINA_FAIRY);
}
gSaveContext.entranceIndex = ENTR_LOST_WOODS_0;
@ -2229,7 +2229,7 @@ void Cutscene_HandleConditionalTriggers(PlayState* play) {
LINK_IS_ADULT &&
!Flags_GetEventChkInf(EVENTCHKINF_RETURNED_TO_TEMPLE_OF_TIME_WITH_ALL_MEDALLIONS) &&
(gEntranceTable[((void)0, gSaveContext.entranceIndex)].scene == SCENE_TEMPLE_OF_TIME)
), NULL)) {
))) {
Flags_SetEventChkInf(EVENTCHKINF_RETURNED_TO_TEMPLE_OF_TIME_WITH_ALL_MEDALLIONS);
gSaveContext.entranceIndex = ENTR_TEMPLE_OF_TIME_0;
gSaveContext.cutsceneIndex = 0xFFF8;

View file

@ -77,9 +77,9 @@ void func_8006D0EC(PlayState* play, Player* player) {
} else if ((play->sceneNum == gSaveContext.horseData.scene) &&
(((Flags_GetEventChkInf(EVENTCHKINF_EPONA_OBTAINED) != 0) && (!IS_RANDO ||
(IS_RANDO && CHECK_QUEST_ITEM(QUEST_SONG_EPONA) &&
GameInteractor_Should(VB_HAVE_OCARINA_NOTE_D5, true, NULL) &&
GameInteractor_Should(VB_HAVE_OCARINA_NOTE_B4, true, NULL) &&
GameInteractor_Should(VB_HAVE_OCARINA_NOTE_A4, true, NULL) &&
GameInteractor_Should(VB_HAVE_OCARINA_NOTE_D5, true) &&
GameInteractor_Should(VB_HAVE_OCARINA_NOTE_B4, true) &&
GameInteractor_Should(VB_HAVE_OCARINA_NOTE_A4, true) &&
(INV_CONTENT(ITEM_OCARINA_FAIRY) != ITEM_NONE)))) || DREG(1) != 0)) {
// "Set by existence of horse %d %d %d"
osSyncPrintf("馬存在によるセット %d %d %d\n", gSaveContext.horseData.scene, Flags_GetEventChkInf(EVENTCHKINF_EPONA_OBTAINED),

View file

@ -2610,18 +2610,18 @@ void Message_DrawMain(PlayState* play, Gfx** p) {
u8 songItemId = ITEM_SONG_MINUET + gOcarinaSongItemMap[msgCtx->ocarinaStaff->state];
if (
(songItemId == ITEM_SONG_MINUET && GameInteractor_Should(VB_GIVE_ITEM_MINUET_OF_FOREST, true, NULL)) ||
(songItemId == ITEM_SONG_BOLERO && GameInteractor_Should(VB_GIVE_ITEM_BOLERO_OF_FIRE, true, NULL)) ||
(songItemId == ITEM_SONG_SERENADE && GameInteractor_Should(VB_GIVE_ITEM_SERENADE_OF_WATER, true, NULL)) ||
(songItemId == ITEM_SONG_REQUIEM && GameInteractor_Should(VB_GIVE_ITEM_REQUIEM_OF_SPIRIT, true, NULL)) ||
(songItemId == ITEM_SONG_NOCTURNE && GameInteractor_Should(VB_GIVE_ITEM_NOCTURNE_OF_SHADOW, true, NULL)) ||
(songItemId == ITEM_SONG_PRELUDE && GameInteractor_Should(VB_GIVE_ITEM_PRELUDE_OF_LIGHT, true, NULL)) ||
(songItemId == ITEM_SONG_LULLABY && GameInteractor_Should(VB_GIVE_ITEM_ZELDAS_LULLABY, true, NULL)) ||
(songItemId == ITEM_SONG_EPONA && GameInteractor_Should(VB_GIVE_ITEM_EPONAS_SONG, true, NULL)) ||
(songItemId == ITEM_SONG_SARIA && GameInteractor_Should(VB_GIVE_ITEM_SARIAS_SONG, true, NULL)) ||
(songItemId == ITEM_SONG_SUN && GameInteractor_Should(VB_GIVE_ITEM_SUNS_SONG, true, NULL)) ||
(songItemId == ITEM_SONG_TIME && GameInteractor_Should(VB_GIVE_ITEM_SONG_OF_TIME, true, NULL)) ||
(songItemId == ITEM_SONG_STORMS && GameInteractor_Should(VB_GIVE_ITEM_SONG_OF_STORMS, true, NULL))
(songItemId == ITEM_SONG_MINUET && GameInteractor_Should(VB_GIVE_ITEM_MINUET_OF_FOREST, true)) ||
(songItemId == ITEM_SONG_BOLERO && GameInteractor_Should(VB_GIVE_ITEM_BOLERO_OF_FIRE, true)) ||
(songItemId == ITEM_SONG_SERENADE && GameInteractor_Should(VB_GIVE_ITEM_SERENADE_OF_WATER, true)) ||
(songItemId == ITEM_SONG_REQUIEM && GameInteractor_Should(VB_GIVE_ITEM_REQUIEM_OF_SPIRIT, true)) ||
(songItemId == ITEM_SONG_NOCTURNE && GameInteractor_Should(VB_GIVE_ITEM_NOCTURNE_OF_SHADOW, true)) ||
(songItemId == ITEM_SONG_PRELUDE && GameInteractor_Should(VB_GIVE_ITEM_PRELUDE_OF_LIGHT, true)) ||
(songItemId == ITEM_SONG_LULLABY && GameInteractor_Should(VB_GIVE_ITEM_ZELDAS_LULLABY, true)) ||
(songItemId == ITEM_SONG_EPONA && GameInteractor_Should(VB_GIVE_ITEM_EPONAS_SONG, true)) ||
(songItemId == ITEM_SONG_SARIA && GameInteractor_Should(VB_GIVE_ITEM_SARIAS_SONG, true)) ||
(songItemId == ITEM_SONG_SUN && GameInteractor_Should(VB_GIVE_ITEM_SUNS_SONG, true)) ||
(songItemId == ITEM_SONG_TIME && GameInteractor_Should(VB_GIVE_ITEM_SONG_OF_TIME, true)) ||
(songItemId == ITEM_SONG_STORMS && GameInteractor_Should(VB_GIVE_ITEM_SONG_OF_STORMS, true))
) {
Item_Give(play, songItemId);
}

View file

@ -5372,7 +5372,7 @@ void Interface_Draw(PlayState* play) {
if (fullUi) {
s16 PosX_RC;
s16 PosY_RC;
if (GameInteractor_Should(VB_RENDER_RUPEE_COUNTER, true, NULL)) {
if (GameInteractor_Should(VB_RENDER_RUPEE_COUNTER, true)) {
// Rupee Icon
if (CVarGetInteger(CVAR_ENHANCEMENT("DynamicWalletIcon"), 0)) {
switch (CUR_UPG_VALUE(UPG_WALLET)) {
@ -5446,7 +5446,7 @@ void Interface_Draw(PlayState* play) {
OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, gRupeeCounterIconTex, 16, 16, PosX_RC, PosY_RC, 16, 16, 1 << 10, 1 << 10);
}
if (GameInteractor_Should(VB_RENDER_KEY_COUNTER, true, NULL)) {
if (GameInteractor_Should(VB_RENDER_KEY_COUNTER, true)) {
switch (play->sceneNum) {
case SCENE_FOREST_TEMPLE:
case SCENE_FIRE_TEMPLE:
@ -5527,7 +5527,7 @@ void Interface_Draw(PlayState* play) {
}
}
if (GameInteractor_Should(VB_RENDER_RUPEE_COUNTER, true, NULL)) {
if (GameInteractor_Should(VB_RENDER_RUPEE_COUNTER, true)) {
// Rupee Counter
gDPPipeSync(OVERLAY_DISP++);

View file

@ -200,7 +200,7 @@ void Sram_OpenSave() {
}
}
if (GameInteractor_Should(VB_REVERT_SPOILING_ITEMS, true, NULL)) {
if (GameInteractor_Should(VB_REVERT_SPOILING_ITEMS, true)) {
for (i = 0; i < ARRAY_COUNT(gSpoilingItems); i++) {
if (INV_CONTENT(ITEM_TRADE_ADULT) == gSpoilingItems[i]) {
INV_CONTENT(gSpoilingItemReverts[i]) = gSpoilingItemReverts[i];