diff --git a/lib/ivis_opengl/piedraw.cpp b/lib/ivis_opengl/piedraw.cpp index 661dcc46bc8..13f6e8f429a 100644 --- a/lib/ivis_opengl/piedraw.cpp +++ b/lib/ivis_opengl/piedraw.cpp @@ -1115,7 +1115,8 @@ bool InstancedMeshRenderer::Draw3DShape(iIMDShape *shape, int frame, PIELIGHT te tshape.stretch = stretchDepth; tshape.modelMatrix = modelMatrix; - if (pieFlag & pie_SHIELD) { + if (pieFlag & pie_SHIELD) + { tshape.modelMatrix = glm::scale(tshape.modelMatrix, glm::vec3(pie_SHIELD_FACTOR, pie_SHIELD_FACTOR, pie_SHIELD_FACTOR)); } diff --git a/src/combat.cpp b/src/combat.cpp index 8b905373c81..d9b7a1e8053 100644 --- a/src/combat.cpp +++ b/src/combat.cpp @@ -497,14 +497,19 @@ int32_t objDamage(BASE_OBJECT *psObj, unsigned damage, unsigned originalhp, WEAP } // Drain shields first - if (psObj->type == OBJ_DROID) { + if (psObj->type == OBJ_DROID) + { DROID *psDroid = castDroid(psObj); - if (psDroid->shieldPoints > 0) { - if (psDroid->shieldPoints > actualDamage) { + if (psDroid->shieldPoints > 0) + { + if (psDroid->shieldPoints > actualDamage) + { psDroid->shieldPoints -= actualDamage; actualDamage = 0; - } else { + } + else + { actualDamage -= psDroid->shieldPoints; psDroid->shieldPoints = 0; // shields are interrupted, wait for a while until regeneration starts again @@ -516,7 +521,8 @@ int32_t objDamage(BASE_OBJECT *psObj, unsigned damage, unsigned originalhp, WEAP dv.y = psDroid->pos.z; dv.y += (psDroid->sDisplay.imd->max.y * 2); - for (uint32_t i = 0; i < DROID_SHIELD_PARTICLES; i++) { + for (uint32_t i = 0; i < DROID_SHIELD_PARTICLES; i++) + { dv.x = psDroid->pos.x + DROID_SHIELD_DAMAGE_SPREAD; dv.z = psDroid->pos.y + DROID_SHIELD_DAMAGE_SPREAD; addEffect(&dv, EFFECT_FIREWORK, FIREWORK_TYPE_STARBURST, false, nullptr, 0, gameTime - deltaGameTime + 1); diff --git a/src/component.cpp b/src/component.cpp index 783b5f6fa0e..6691a881d8f 100644 --- a/src/component.cpp +++ b/src/component.cpp @@ -433,7 +433,8 @@ static bool displayCompObj(DROID *psDroid, bool bButton, const glm::mat4& modelM size_t i = 0; bool didDrawSomething = false; - if (!bButton && psDroid->shieldPoints > 0) { + if (!bButton && psDroid->shieldPoints > 0) + { double factor = static_cast(psDroid->shieldPoints) / droidGetMaxShieldPoints(psDroid); iShieldPieData = static_cast(std::round(255.0f * factor)); shieldPieFlag = pie_FORCELIGHT | pie_TRANSLUCENT | pie_SHIELD; @@ -499,7 +500,8 @@ static bool displayCompObj(DROID *psDroid, bool bButton, const glm::mat4& modelM { didDrawSomething = true; } - if (!bButton && psDroid->shieldPoints > 0) { + if (!bButton && psDroid->shieldPoints > 0) + { if (pie_Draw3DShape(psShapeProp->displayModel(), 0, colour, brightness, shieldPieFlag, iShieldPieData, modifiedModelMatrix, viewMatrix, -(psDroid->heightAboveMap))) { didDrawSomething = true; @@ -539,7 +541,8 @@ static bool displayCompObj(DROID *psDroid, bool bButton, const glm::mat4& modelM { didDrawSomething = true; } - if (!bButton && psDroid->shieldPoints > 0) { + if (!bButton && psDroid->shieldPoints > 0) + { if (drawShape(strImd, psDroid->timeAnimationStarted, colour, brightness, shieldPieFlag, iShieldPieData, modifiedModelMatrix, viewMatrix, -(psDroid->heightAboveMap))) { didDrawSomething = true; @@ -659,7 +662,8 @@ static bool displayCompObj(DROID *psDroid, bool bButton, const glm::mat4& modelM { didDrawSomething = true; } - if (!bButton && psDroid->shieldPoints > 0) { + if (!bButton && psDroid->shieldPoints > 0) + { if (pie_Draw3DShape(psShape, 0, colour, brightness, shieldPieFlag, iShieldPieData, localModelMatrix, viewMatrix, -localHeightAboveTerrain)) { didDrawSomething = true; @@ -698,7 +702,8 @@ static bool displayCompObj(DROID *psDroid, bool bButton, const glm::mat4& modelM { didDrawSomething = true; } - if (!bButton && psDroid->shieldPoints > 0) { + if (!bButton && psDroid->shieldPoints > 0) + { if (pie_Draw3DShape(psShape, 0, colour, brightness, shieldPieFlag, iShieldPieData, localModelMatrix, viewMatrix, -localHeightAboveTerrain)) { didDrawSomething = true; @@ -858,7 +863,8 @@ static bool displayCompObj(DROID *psDroid, bool bButton, const glm::mat4& modelM { didDrawSomething = true; } - if (!bButton && psDroid->shieldPoints > 0) { + if (!bButton && psDroid->shieldPoints > 0) + { if (pie_Draw3DShape(psShapeProp->displayModel(), 0, colour, brightness, shieldPieFlag, iShieldPieData, modifiedModelMatrix, viewMatrix, -(psDroid->heightAboveMap))) { didDrawSomething = true; diff --git a/src/display3d.cpp b/src/display3d.cpp index 22d1348ab48..1092ef7fdb5 100644 --- a/src/display3d.cpp +++ b/src/display3d.cpp @@ -3426,7 +3426,8 @@ static void queueDroidPowerBarsRects(DROID *psDroid, bool drawBox, BatchedMultiR UDWORD damage = PERCENT(psDroid->body, psDroid->originalBody); UDWORD shields = 0; - if (psDroid->shieldPoints >= 0) { + if (psDroid->shieldPoints >= 0) + { int maxShieldPoints = droidGetMaxShieldPoints(psDroid); shields = PERCENT(psDroid->shieldPoints, maxShieldPoints); shields = static_cast((float)psDroid->shieldPoints / (float)maxShieldPoints * (float)psDroid->sDisplay.screenR); diff --git a/src/droid.cpp b/src/droid.cpp index 270e14f7eec..6ee9ed81136 100644 --- a/src/droid.cpp +++ b/src/droid.cpp @@ -956,18 +956,26 @@ void droidUpdate(DROID *psDroid) CHECK_DROID(psDroid); } -void droidUpdateShields(DROID *psDroid) { - if (hasCommander(psDroid) || psDroid->droidType == DROID_COMMAND) { - if (psDroid->shieldPoints < 0) { +void droidUpdateShields(DROID *psDroid) +{ + if (hasCommander(psDroid) || psDroid->droidType == DROID_COMMAND) + { + if (psDroid->shieldPoints < 0) + { psDroid->shieldPoints = 0; psDroid->shieldRegenTime = gameTime; psDroid->shieldInterruptRegenTime = gameTime; - - } else { - if (gameTime - psDroid->shieldInterruptRegenTime >= droidCalculateShieldInterruptRegenTime(psDroid)) { - if (gameTime - psDroid->shieldRegenTime >= droidCalculateShieldRegenTime(psDroid)) { - for (uint32_t i = 0; i < DROID_SHIELD_POINTS_STEP; i++) { - if (psDroid->shieldPoints < droidGetMaxShieldPoints(psDroid)) { + } + else + { + if (gameTime - psDroid->shieldInterruptRegenTime >= droidCalculateShieldInterruptRegenTime(psDroid)) + { + if (gameTime - psDroid->shieldRegenTime >= droidCalculateShieldRegenTime(psDroid)) + { + for (uint32_t i = 0; i < DROID_SHIELD_POINTS_STEP; i++) + { + if (psDroid->shieldPoints < droidGetMaxShieldPoints(psDroid)) + { psDroid->shieldPoints += 1; } } @@ -975,7 +983,8 @@ void droidUpdateShields(DROID *psDroid) { } } } - } else { + } else + { // unit has lost commander, shields are down! psDroid->shieldPoints = -1; }