From 57ad566681f43d71df7de84cc5363df67353d8d2 Mon Sep 17 00:00:00 2001 From: vflyson Date: Sun, 19 Feb 2017 00:13:31 -0500 Subject: [PATCH] improve the ammo count display logic --- rwgame/DrawUI.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/rwgame/DrawUI.cpp b/rwgame/DrawUI.cpp index b7e45936..807bcb99 100644 --- a/rwgame/DrawUI.cpp +++ b/rwgame/DrawUI.cpp @@ -185,18 +185,27 @@ void drawPlayerInfo(PlayerController* player, GameWorld* world, const CharacterState& cs = player->getCharacter()->getCurrentState(); const CharacterWeaponSlot& slotInfo = cs.weapons[cs.currentWeapon]; - bool isProjectile = weapon->fireType == WeaponData::PROJECTILE; - bool isShotgun = weapon->modelID == 176; - bool isSniper = weapon->modelID == 177; - bool noClip = isProjectile || isShotgun || isSniper; + // In weapon.dat clip size of 0 or 1000+ indicates no reload + // Clip size of 1 is being visually omitted as well + bool noClip = weapon->clipSize < 2 || weapon->clipSize > 999; + + uint32_t displayBulletsTotal = slotInfo.bulletsTotal; if (noClip) { + // The clip is actually there, but it holds just one shot/charge + displayBulletsTotal += slotInfo.bulletsClip; + ti.text = GameStringUtil::fromString( - std::to_string(slotInfo.bulletsTotal)); + std::to_string(displayBulletsTotal)); } else { + // Limit the maximal displayed length for the total bullet count + if (slotInfo.bulletsTotal > 9999) { + displayBulletsTotal = 9999; + } + ti.text = GameStringUtil::fromString( - std::to_string(slotInfo.bulletsClip) + "-" + - std::to_string(slotInfo.bulletsTotal)); + std::to_string(displayBulletsTotal) + "-" + + std::to_string(slotInfo.bulletsClip)); } ti.baseColour = ui_shadowColour;