Don't extinguish held light sources when they're hidden (bug #6910)

check_span
Alexei Kotov 2 years ago
parent a9c1fe3ee9
commit 94dfcdd062

@ -136,6 +136,7 @@
Bug #6898: Accessing the Quick Inventory menu does not work while in menu mode
Bug #6901: Morrowind.exe soul gem usage discrepancy
Bug #6909: Using enchanted items has no animation
Bug #6910: Torches should not be extinguished when not being held
Feature #890: OpenMW-CS: Column filtering
Feature #1465: "Reset" argument for AI functions
Feature #2491: Ability to make OpenMW "portable"

@ -988,30 +988,26 @@ namespace MWMechanics
heldIter = inventoryStore.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
//If holding a light...
if(heldIter.getType() == MWWorld::ContainerStore::Type_Light)
const auto world = MWBase::Environment::get().getWorld();
MWRender::Animation *anim = world->getAnimation(ptr);
if (heldIter.getType() == MWWorld::ContainerStore::Type_Light && anim && anim->getCarriedLeftShown())
{
const auto world = MWBase::Environment::get().getWorld();
// Use time from the player's light
if(isPlayer)
{
// But avoid using it up if the light source is hidden
MWRender::Animation *anim = world->getAnimation(ptr);
if (anim && anim->getCarriedLeftShown())
{
float timeRemaining = heldIter->getClass().getRemainingUsageTime(*heldIter);
float timeRemaining = heldIter->getClass().getRemainingUsageTime(*heldIter);
// -1 is infinite light source. Other negative values are treated as 0.
if (timeRemaining != -1.0f)
// -1 is infinite light source. Other negative values are treated as 0.
if (timeRemaining != -1.0f)
{
timeRemaining -= duration;
if (timeRemaining <= 0.f)
{
timeRemaining -= duration;
if (timeRemaining <= 0.f)
{
inventoryStore.remove(*heldIter, 1, ptr); // remove it
return;
}
heldIter->getClass().setRemainingUsageTime(*heldIter, timeRemaining);
inventoryStore.remove(*heldIter, 1, ptr); // remove it
return;
}
heldIter->getClass().setRemainingUsageTime(*heldIter, timeRemaining);
}
}

Loading…
Cancel
Save