Don't use up light duration if the held light is hidden (bug #5352)

pull/578/head
Capostrophic 5 years ago
parent 0ce953ff7d
commit 1928bebe98

@ -211,6 +211,7 @@
Bug #5326: Formatting issues in the settings.cfg Bug #5326: Formatting issues in the settings.cfg
Bug #5328: Skills aren't properly reset for dead actors Bug #5328: Skills aren't properly reset for dead actors
Bug #5345: Dopey Necromancy does not work due to a missing quote Bug #5345: Dopey Necromancy does not work due to a missing quote
Bug #5352: Light source items' duration is decremented while they aren't visible
Feature #1774: Handle AvoidNode Feature #1774: Handle AvoidNode
Feature #2229: Improve pathfinding AI Feature #2229: Improve pathfinding AI
Feature #3025: Analogue gamepad movement controls Feature #3025: Analogue gamepad movement controls

@ -1268,19 +1268,23 @@ namespace MWMechanics
// Use time from the player's light // Use time from the player's light
if(isPlayer) if(isPlayer)
{ {
float timeRemaining = heldIter->getClass().getRemainingUsageTime(*heldIter); // But avoid using it up if the light source is hidden
MWRender::Animation *anim = MWBase::Environment::get().getWorld()->getAnimation(ptr);
// -1 is infinite light source. Other negative values are treated as 0. if (anim && anim->getCarriedLeftShown())
if(timeRemaining != -1.0f)
{ {
timeRemaining -= duration; float timeRemaining = heldIter->getClass().getRemainingUsageTime(*heldIter);
if(timeRemaining > 0.0f) // -1 is infinite light source. Other negative values are treated as 0.
heldIter->getClass().setRemainingUsageTime(*heldIter, timeRemaining); if (timeRemaining != -1.0f)
else
{ {
inventoryStore.remove(*heldIter, 1, ptr); // remove it timeRemaining -= duration;
return; if (timeRemaining <= 0.f)
{
inventoryStore.remove(*heldIter, 1, ptr); // remove it
return;
}
heldIter->getClass().setRemainingUsageTime(*heldIter, timeRemaining);
} }
} }
} }

@ -459,6 +459,7 @@ public:
virtual bool useShieldAnimations() const { return false; } virtual bool useShieldAnimations() const { return false; }
virtual void showWeapons(bool showWeapon) {} virtual void showWeapons(bool showWeapon) {}
virtual bool getCarriedLeftShown() const { return false; }
virtual void showCarriedLeft(bool show) {} virtual void showCarriedLeft(bool show) {}
virtual void setWeaponGroup(const std::string& group, bool relativeDuration) {} virtual void setWeaponGroup(const std::string& group, bool relativeDuration) {}
virtual void setVampire(bool vampire) {} virtual void setVampire(bool vampire) {}

@ -31,6 +31,8 @@ namespace MWRender
virtual void equipmentChanged() { updateParts(); } virtual void equipmentChanged() { updateParts(); }
virtual void showWeapons(bool showWeapon); virtual void showWeapons(bool showWeapon);
virtual bool getCarriedLeftShown() const { return mShowCarriedLeft; }
virtual void showCarriedLeft(bool show); virtual void showCarriedLeft(bool show);
void updateParts(); void updateParts();

@ -129,6 +129,8 @@ public:
virtual void setPitchFactor(float factor) { mPitchFactor = factor; } virtual void setPitchFactor(float factor) { mPitchFactor = factor; }
virtual void showWeapons(bool showWeapon); virtual void showWeapons(bool showWeapon);
virtual bool getCarriedLeftShown() const { return mShowCarriedLeft; }
virtual void showCarriedLeft(bool show); virtual void showCarriedLeft(bool show);
virtual void attachArrow(); virtual void attachArrow();

Loading…
Cancel
Save