diff --git a/CHANGELOG.md b/CHANGELOG.md index 860477345f..f2cb02f6d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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" diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index a5ab0a6ae6..c88ba070fd 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -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); + + // -1 is infinite light source. Other negative values are treated as 0. + if (timeRemaining != -1.0f) { - float timeRemaining = heldIter->getClass().getRemainingUsageTime(*heldIter); - - // -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); } }