- Exhumed: Fix clip calculation setup.

* Since game maintains its own clip capacities, we need to use them instead of the generic handler for the games that do not.
* Clean up the game-side code in `CheckClip()` to use `min()`.
* Repair issue with pistol clip calculation that was using modulo when it shouldn't. A full weapon with 300 will divide into 6 with no remainder, therefore nothing in the clip.
* Fixes #906.
This commit is contained in:
Mitchell Richters 2023-03-27 22:05:25 +11:00
parent 892dde030f
commit 42d791e7c2
2 changed files with 7 additions and 11 deletions

View file

@ -321,17 +321,13 @@ Collision CheckCloseRange(int nPlayer, DVector3& pos, sectortype* *ppSector)
void CheckClip(int nPlayer)
{
if (PlayerList[nPlayer].nPlayerClip <= 0)
{
PlayerList[nPlayer].nPlayerClip = PlayerList[nPlayer].nAmmo[kWeaponM60];
const auto pPlayer = &PlayerList[nPlayer];
if (PlayerList[nPlayer].nPlayerClip > 100) {
PlayerList[nPlayer].nPlayerClip = 100;
}
}
if (pPlayer->nPlayerClip <= 0)
pPlayer->nPlayerClip = min(pPlayer->nAmmo[kWeaponM60], (int16_t)100);
// Reset pistol's clip amount.
PlayerList[nPlayer].nPistolClip = PlayerList[nPlayer].nAmmo[kWeaponPistol] % 6;
if (pPlayer->nPistolClip <= 0)
pPlayer->nPistolClip = min(pPlayer->nAmmo[kWeaponPistol], (int16_t)6);
}
//---------------------------------------------------------------------------

View file

@ -320,12 +320,12 @@ class ExhumedStatusBar : RazeStatusBar
{
if (weapon == kWeaponPistol && cl_showmagamt)
{
int clip = CalcMagazineAmount(ammo, 6, Exhumed.GetPistolClip() == 0);
int clip = Exhumed.GetPistolClip();
format = String.Format("%d/%d", clip, ammo - clip);
}
else if (weapon == kWeaponM60 && cl_showmagamt)
{
int clip = CalcMagazineAmount(ammo, 100, Exhumed.GetPlayerClip() == 0);
int clip = Exhumed.GetPlayerClip();
format = String.Format("%d/%d", clip, ammo - clip);
}
else