diff --git a/src/combat.cpp b/src/combat.cpp index a7998dfe452..892a7e150f8 100644 --- a/src/combat.cpp +++ b/src/combat.cpp @@ -540,7 +540,7 @@ int32_t objDamage(BASE_OBJECT *psObj, PROJECTILE *psProjectile, unsigned damage, Vector3i dv; dv.y = psProjectile->pos.z; - for (uint32_t i = 0; i < DROID_SHIELD_PARTICLES; i++) + for (int i = 0; i < DROID_SHIELD_PARTICLES; i++) { dv.x = psProjectile->pos.x + DROID_SHIELD_DAMAGE_SPREAD; dv.z = psProjectile->pos.y + DROID_SHIELD_DAMAGE_SPREAD; diff --git a/src/component.cpp b/src/component.cpp index f1dc4dba2bb..84941598cb8 100644 --- a/src/component.cpp +++ b/src/component.cpp @@ -435,7 +435,7 @@ static bool displayCompObj(DROID *psDroid, bool bButton, const glm::mat4& modelM if (!bButton && psDroid->shieldPoints > 0 && droidGetMaxShieldPoints(psDroid) > 0) { - double factor = static_cast(psDroid->shieldPoints) / droidGetMaxShieldPoints(psDroid); + float factor = static_cast(psDroid->shieldPoints) / droidGetMaxShieldPoints(psDroid); iShieldPieData = static_cast(std::round(255.0f * factor)); shieldPieFlag = pie_FORCELIGHT | pie_TRANSLUCENT | pie_SHIELD; } diff --git a/src/droid.cpp b/src/droid.cpp index b1e301d8ea5..c72c704c9d4 100644 --- a/src/droid.cpp +++ b/src/droid.cpp @@ -974,12 +974,12 @@ void droidUpdateShields(DROID *psDroid) gameTime - psDroid->shieldInterruptRegenTime > droidCalculateShieldInterruptRegenTime(psDroid) && gameTime - psDroid->shieldRegenTime > droidCalculateShieldRegenTime(psDroid)) { - for (int i = 0; i < psDroid->getBrainStats()->shield.shieldPointsPerStep; i++) + auto availableShieldPoints = droidGetMaxShieldPoints(psDroid) - psDroid->shieldPoints; + + if (availableShieldPoints > 0) { - if (psDroid->shieldPoints < droidGetMaxShieldPoints(psDroid)) - { - psDroid->shieldPoints += 1; - } + auto pointsToAdd = std::min(psDroid->getBrainStats()->shield.shieldPointsPerStep, availableShieldPoints); + psDroid->shieldPoints += pointsToAdd; } psDroid->shieldRegenTime = gameTime; }