From fb751716fdf7dd23eeb67d5427f66d089747295b Mon Sep 17 00:00:00 2001 From: twincannon Date: Mon, 30 Jun 2025 12:42:19 -0400 Subject: [PATCH 1/2] Fix manual and auto reload to work when you have ammo left but less than clipsize, and fix reloading to not reload past your reserve ammo --- code/game/bg_pmove.c | 10 +++++----- code/game/bg_q3f_weapon.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/code/game/bg_pmove.c b/code/game/bg_pmove.c index 4ae2c03..f3bf624 100644 --- a/code/game/bg_pmove.c +++ b/code/game/bg_pmove.c @@ -2079,17 +2079,17 @@ static void PM_FinishWeaponReload( void ) { if (ammo > pm->ps->ammo[wp->ammotype]) { ammo = pm->ps->ammo[wp->ammotype]; } - + curammo = Q3F_GetClipValue(pm->ps->weapon, pm->ps); // Not actually done reloading singly - go back to RDROPPING - if (curammo < wp->clipsize && pm->ps->ammo[wp->ammotype] >= wp->numammo) + if (curammo < wp->clipsize && curammo < pm->ps->ammo[wp->ammotype] && pm->ps->ammo[wp->ammotype] >= wp->numammo) { reloadtime = wp->clipsize > 0 ? wp->reloadtime / wp->clipsize : wp->reloadtime; //(wp->reloadtime)*((float)(ammo-curammo)/(float)ammo); pm->ps->weaponTime = reloadtime; Q3F_SetClipValue(pm->ps->weapon, curammo + ammo, pm->ps); - if (curammo + ammo >= wp->clipsize) + if ((curammo + ammo >= wp->clipsize) || (curammo + ammo >= pm->ps->ammo[wp->ammotype])) { // Finished reloading so transition to the next state immediately pm->ps->weaponTime = 0; @@ -2224,7 +2224,7 @@ static void PM_Weapon( void ) { // JT -> if( pm->ps->weaponstate == WEAPON_READY && (pm->ps->stats[STAT_Q3F_FLAGS] & (1 << Q3F_WEAPON_RELOAD)) - && wp->clipsize && pm->ps->ammo[wp->ammotype] >= wp->numammo && pm->ps->ammo[wp->ammotype] >= wp->clipsize) + && wp->clipsize && pm->ps->ammo[wp->ammotype] >= wp->numammo && pm->ps->ammo[wp->ammotype] >= Q3F_GetClipValue(pm->ps->weapon, pm->ps)) { PM_BeginWeaponReload(); return; @@ -2367,7 +2367,7 @@ static void PM_Weapon( void ) { && pm->ps->weaponstate == WEAPON_READY && pm->ps->ammo[wp->ammotype] >= wp->numammo && pm->ps->ammo[wp->ammotype] > curammo - && pm->ps->ammo[wp->ammotype] >= wp->clipsize + && pm->ps->ammo[wp->ammotype] >= Q3F_GetClipValue(pm->ps->weapon, pm->ps) && pm->autoreload == 1) { PM_BeginWeaponReload(); // Automatically start reloading if we need to diff --git a/code/game/bg_q3f_weapon.c b/code/game/bg_q3f_weapon.c index c89409d..cfb062b 100644 --- a/code/game/bg_q3f_weapon.c +++ b/code/game/bg_q3f_weapon.c @@ -391,7 +391,7 @@ void BG_Q3F_Request_Reload(playerState_t *ps) // RR2DO2 : if we don't have enough ammo to reload, return if(Q3F_GetClipValue( ps->weapon,ps ) >= ps->ammo[ wp->ammotype ] ) return; - if (ps->ammo[wp->ammotype] < wp->clipsize) + if (ps->ammo[wp->ammotype] < Q3F_GetClipValue(ps->weapon, ps)) return; ps->stats[STAT_Q3F_FLAGS] |= (1<< Q3F_WEAPON_RELOAD); From 2920b8dcd714960e4fd64d6a175264e512c356a0 Mon Sep 17 00:00:00 2001 From: twincannon Date: Mon, 30 Jun 2025 12:49:02 -0400 Subject: [PATCH 2/2] Remove redundant if statement --- code/game/bg_q3f_weapon.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/game/bg_q3f_weapon.c b/code/game/bg_q3f_weapon.c index cfb062b..736c07f 100644 --- a/code/game/bg_q3f_weapon.c +++ b/code/game/bg_q3f_weapon.c @@ -391,8 +391,6 @@ void BG_Q3F_Request_Reload(playerState_t *ps) // RR2DO2 : if we don't have enough ammo to reload, return if(Q3F_GetClipValue( ps->weapon,ps ) >= ps->ammo[ wp->ammotype ] ) return; - if (ps->ammo[wp->ammotype] < Q3F_GetClipValue(ps->weapon, ps)) - return; ps->stats[STAT_Q3F_FLAGS] |= (1<< Q3F_WEAPON_RELOAD); }