From 4042fb3a621d65eea36c3f75cee2e4dbaa6ebe83 Mon Sep 17 00:00:00 2001 From: Raf <> Date: Thu, 31 Aug 2023 14:29:29 +0800 Subject: [PATCH 1/2] Bug fix: double reload --- src/game/lv.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/game/lv.c b/src/game/lv.c index 75e7ecc3e..3095156a5 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -1291,13 +1291,19 @@ Gfx *lvRender(Gfx *gdl) // Handle opening doors and reloading if (g_Vars.currentplayer->bondactivateorreload & JO_ACTION_RELOAD) { - if (g_Vars.currentplayer->hands[HAND_RIGHT].state != HANDSTATE_RELOAD){ + struct hand* hand = &g_Vars.currentplayer->hands[HAND_RIGHT]; + struct weaponfunc* func = weaponGetFunction(&hand->gset, hand->gset.weaponfunc); + // ignore the player's request to reload here if the last bullet in the clip was just fired + if (hand->state != HANDSTATE_RELOAD && !(hand->state == HANDSTATE_ATTACK && hand->loadedammo[func->ammoindex] == 0)) { bgunReloadIfPossible(HAND_RIGHT); - } - if (g_Vars.currentplayer->hands[HAND_LEFT].state != HANDSTATE_RELOAD) { + + hand = &g_Vars.currentplayer->hands[HAND_LEFT]; + func = weaponGetFunction(&hand->gset, hand->gset.weaponfunc); + if (hand->state != HANDSTATE_RELOAD && !(hand->state == HANDSTATE_ATTACK && hand->loadedammo[func->ammoindex] == 0)) { bgunReloadIfPossible(HAND_LEFT); } + g_Vars.currentplayer->bondactivateorreload = (g_Vars.currentplayer->bondactivateorreload & ~JO_ACTION_RELOAD) | (g_Vars.currentplayer->bondactivateorreload & 0x0); } if (g_Vars.currentplayer->bondactivateorreload & JO_ACTION_ACTIVATE) { From 84331c4d08a0299072efe79dea236108c99857d0 Mon Sep 17 00:00:00 2001 From: Raf <> Date: Tue, 5 Sep 2023 22:27:24 +0800 Subject: [PATCH 2/2] Bug fix: double reload, new approach Reverted the previous changes, no longer necessary --- src/game/bondgun.c | 1 + src/game/lv.c | 9 ++------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/game/bondgun.c b/src/game/bondgun.c index 81472dbb9..ac599ade4 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -1310,6 +1310,7 @@ s32 bgunTickIncIdle(struct handweaponinfo *info, s32 handnum, struct hand *hand, hand->count = 0; if (bgunSetState(handnum, HANDSTATE_RELOAD)) { + hand->modenext = HANDMODE_NONE; return lvupdate; } } diff --git a/src/game/lv.c b/src/game/lv.c index 3095156a5..97b74e1de 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -1291,16 +1291,11 @@ Gfx *lvRender(Gfx *gdl) // Handle opening doors and reloading if (g_Vars.currentplayer->bondactivateorreload & JO_ACTION_RELOAD) { - struct hand* hand = &g_Vars.currentplayer->hands[HAND_RIGHT]; - struct weaponfunc* func = weaponGetFunction(&hand->gset, hand->gset.weaponfunc); - // ignore the player's request to reload here if the last bullet in the clip was just fired - if (hand->state != HANDSTATE_RELOAD && !(hand->state == HANDSTATE_ATTACK && hand->loadedammo[func->ammoindex] == 0)) { + if (g_Vars.currentplayer->hands[HAND_RIGHT].state != HANDSTATE_RELOAD) { bgunReloadIfPossible(HAND_RIGHT); } - hand = &g_Vars.currentplayer->hands[HAND_LEFT]; - func = weaponGetFunction(&hand->gset, hand->gset.weaponfunc); - if (hand->state != HANDSTATE_RELOAD && !(hand->state == HANDSTATE_ATTACK && hand->loadedammo[func->ammoindex] == 0)) { + if (g_Vars.currentplayer->hands[HAND_LEFT].state != HANDSTATE_RELOAD) { bgunReloadIfPossible(HAND_LEFT); }