@ -949,7 +949,7 @@ namespace MWMechanics
stats . setTimeToStartDrowning ( fHoldBreathTime ) ;
stats . setTimeToStartDrowning ( fHoldBreathTime ) ;
}
}
void Actors : : updateEquippedLight ( const MWWorld : : Ptr & ptr , float duration )
void Actors : : updateEquippedLight ( const MWWorld : : Ptr & ptr , float duration , bool mayEquip )
{
{
bool isPlayer = ( ptr = = getPlayer ( ) ) ;
bool isPlayer = ( ptr = = getPlayer ( ) ) ;
@ -982,7 +982,7 @@ namespace MWMechanics
}
}
}
}
if ( MWBase: : Environment : : get ( ) . getWorld ( ) - > isDark ( ) )
if ( mayEquip )
{
{
if ( torch ! = inventoryStore . end ( ) )
if ( torch ! = inventoryStore . end ( ) )
{
{
@ -991,16 +991,11 @@ namespace MWMechanics
// For non-hostile NPCs, unequip whatever is in the left slot in favor of a light.
// For non-hostile NPCs, unequip whatever is in the left slot in favor of a light.
if ( heldIter ! = inventoryStore . end ( ) & & heldIter - > getTypeName ( ) ! = typeid ( ESM : : Light ) . name ( ) )
if ( heldIter ! = inventoryStore . end ( ) & & heldIter - > getTypeName ( ) ! = typeid ( ESM : : Light ) . name ( ) )
inventoryStore . unequipItem ( * heldIter , ptr ) ;
inventoryStore . unequipItem ( * heldIter , ptr ) ;
// Also unequip twohanded weapons which conflict with anything in CarriedLeft
if ( torch - > getClass ( ) . canBeEquipped ( * torch , ptr ) . first = = 3 )
inventoryStore . unequipSlot ( MWWorld : : InventoryStore : : Slot_CarriedRight , ptr ) ;
}
}
heldIter = inventoryStore . getSlot ( MWWorld : : InventoryStore : : Slot_CarriedLeft ) ;
heldIter = inventoryStore . getSlot ( MWWorld : : InventoryStore : : Slot_CarriedLeft ) ;
// If we have a torch and can equip it (left slot free, no
// If we have a torch and can equip it, then equip it now.
// twohanded weapon in right slot), then equip it now.
if ( heldIter = = inventoryStore . end ( )
if ( heldIter = = inventoryStore . end ( )
& & torch - > getClass ( ) . canBeEquipped ( * torch , ptr ) . first = = 1 )
& & torch - > getClass ( ) . canBeEquipped ( * torch , ptr ) . first = = 1 )
{
{
@ -1057,7 +1052,7 @@ namespace MWMechanics
}
}
}
}
void Actors : : updateCrimeP e rsuit( const MWWorld : : Ptr & ptr , float duration )
void Actors : : updateCrimeP u rsuit( const MWWorld : : Ptr & ptr , float duration )
{
{
MWWorld : : Ptr player = getPlayer ( ) ;
MWWorld : : Ptr player = getPlayer ( ) ;
if ( ptr ! = player & & ptr . getClass ( ) . isNpc ( ) )
if ( ptr ! = player & & ptr . getClass ( ) . isNpc ( ) )
@ -1293,6 +1288,9 @@ namespace MWMechanics
if ( mTimerDisposeSummonsCorpses > = 0.2f ) mTimerDisposeSummonsCorpses = 0 ;
if ( mTimerDisposeSummonsCorpses > = 0.2f ) mTimerDisposeSummonsCorpses = 0 ;
if ( timerUpdateEquippedLight > = updateEquippedLightInterval ) timerUpdateEquippedLight = 0 ;
if ( timerUpdateEquippedLight > = updateEquippedLightInterval ) timerUpdateEquippedLight = 0 ;
// show torches only when there are darkness and no precipitations
bool showTorches = MWBase : : Environment : : get ( ) . getWorld ( ) - > useTorches ( ) ;
MWWorld : : Ptr player = getPlayer ( ) ;
MWWorld : : Ptr player = getPlayer ( ) ;
/// \todo move update logic to Actor class where appropriate
/// \todo move update logic to Actor class where appropriate
@ -1438,7 +1436,7 @@ namespace MWMechanics
}
}
if ( iter - > first . getClass ( ) . isNpc ( ) & & iter - > first ! = player & & ( isLocalActor | | isAIActive ) )
if ( iter - > first . getClass ( ) . isNpc ( ) & & iter - > first ! = player & & ( isLocalActor | | isAIActive ) )
updateCrimeP e rsuit( iter - > first , duration ) ;
updateCrimeP u rsuit( iter - > first , duration ) ;
if ( iter - > first ! = player & & ( isLocalActor | | isAIActive ) )
if ( iter - > first ! = player & & ( isLocalActor | | isAIActive ) )
{
{
@ -1456,7 +1454,7 @@ namespace MWMechanics
updateNpc ( iter - > first , duration ) ;
updateNpc ( iter - > first , duration ) ;
if ( timerUpdateEquippedLight = = 0 )
if ( timerUpdateEquippedLight = = 0 )
updateEquippedLight ( iter - > first , updateEquippedLightInterval );
updateEquippedLight ( iter - > first , updateEquippedLightInterval , showTorches );
}
}
}
}
}
}