@ -387,10 +387,8 @@ namespace MWWorld
void World : : write ( ESM : : ESMWriter & writer , Loading : : Listener & progress ) const
{
// Active cells could have a dirty fog of war, sync it to the CellStore first
for ( Scene : : CellStoreCollection : : const_iterator iter ( mWorldScene - > getActiveCells ( ) . begin ( ) ) ;
iter ! = mWorldScene - > getActiveCells ( ) . end ( ) ; + + iter )
for ( CellStore * cellstore : mWorldScene - > getActiveCells ( ) )
{
CellStore * cellstore = * iter ;
MWBase : : Environment : : get ( ) . getWindowManager ( ) - > writeFog ( cellstore ) ;
}
@ -494,6 +492,17 @@ namespace MWWorld
gmst [ " iWereWolfBounty " ] = ESM : : Variant ( 1000 ) ;
gmst [ " fCombatDistanceWerewolfMod " ] = ESM : : Variant ( 0.3f ) ;
for ( const std : : pair < std : : string , ESM : : Variant > & params : gmst )
{
if ( ! mStore . get < ESM : : GameSetting > ( ) . search ( params . first ) )
{
ESM : : GameSetting record ;
record . mId = params . first ;
record . mValue = params . second ;
mStore . insertStatic ( record ) ;
}
}
std : : map < std : : string , ESM : : Variant > globals ;
// vanilla Morrowind does not define dayspassed.
globals [ " dayspassed " ] = ESM : : Variant ( 1 ) ; // but the addons start counting at 1 :(
@ -513,25 +522,47 @@ namespace MWWorld
globals [ " crimegoldturnin " ] = ESM : : Variant ( 0 ) ;
globals [ " pchasturnin " ] = ESM : : Variant ( 0 ) ;
for ( std : : map < std : : string , ESM : : Variant > : : iterator it = gmst . begin ( ) ; it ! = gmst . end ( ) ; + + it )
for ( const std : : pair < std : : string , ESM : : Variant > & params : globals )
{
if ( ! mStore . get < ESM : : G ameSetting> ( ) . search ( it - > first ) )
if ( ! mStore . get < ESM : : G lobal> ( ) . search ( params . first ) )
{
ESM : : G ameSetting setting ;
setting. mId = it - > first ;
setting. mValue = it - > second ;
mStore . insertStatic ( setting ) ;
ESM : : G lobal record ;
record. mId = params . first ;
record. mValue = params . second ;
mStore . insertStatic ( record ) ;
}
}
for ( std : : map < std : : string , ESM : : Variant > : : iterator it = globals . begin ( ) ; it ! = globals . end ( ) ; + + it )
std : : map < std : : string , std : : string > statics ;
// Total conversions from SureAI lack marker records
statics [ " divinemarker " ] = " marker_divine.nif " ;
statics [ " doormarker " ] = " marker_arrow.nif " ;
statics [ " northmarker " ] = " marker_north.nif " ;
statics [ " templemarker " ] = " marker_temple.nif " ;
statics [ " travelmarker " ] = " marker_travel.nif " ;
for ( const std : : pair < std : : string , std : : string > & params : statics )
{
if ( ! mStore . get < ESM : : Global > ( ) . search ( it - > first ) )
if ( ! mStore . get < ESM : : Static> ( ) . search ( params . first ) )
{
ESM : : Global setting ;
setting . mId = it - > first ;
setting . mValue = it - > second ;
mStore . insertStatic ( setting ) ;
ESM : : Static record ;
record . mId = params . first ;
record . mModel = params . second ;
mStore . insertStatic ( record ) ;
}
}
std : : map < std : : string , std : : string > doors ;
doors [ " prisonmarker " ] = " marker_prison.nif " ;
for ( const std : : pair < std : : string , std : : string > & params : doors )
{
if ( ! mStore . get < ESM : : Door > ( ) . search ( params . first ) )
{
ESM : : Door record ;
record . mId = params . first ;
record . mModel = params . second ;
mStore . insertStatic ( record ) ;
}
}
}
@ -546,22 +577,19 @@ namespace MWWorld
{
// first try named cells
const ESM : : Cell * cell = mStore . get < ESM : : Cell > ( ) . searchExtByName ( cellName ) ;
if ( cell ! = 0 ) {
if ( cell )
return cell ;
}
// didn't work -> now check for regions
const MWWorld : : Store < ESM : : Region > & regions = mStore . get < ESM : : Region > ( ) ;
MWWorld : : Store < ESM : : Region > : : iterator it = regions . begin ( ) ;
for ( ; it ! = regions . end ( ) ; + + it )
for ( const ESM : : Region & region : mStore . get < ESM : : Region > ( ) )
{
if ( Misc : : StringUtils : : ciEqual ( cellName , it- > mName ) )
if ( Misc : : StringUtils : : ciEqual ( cellName , region . mName ) )
{
return mStore . get < ESM : : Cell > ( ) . searchExtByRegion ( it- > mId ) ;
return mStore . get < ESM : : Cell > ( ) . searchExtByRegion ( region. mId ) ;
}
}
return 0 ;
return nullptr ;
}
const Fallback : : Map * World : : getFallback ( ) const
@ -670,10 +698,10 @@ namespace MWWorld
if ( ! cell - > getCell ( ) - > isExterior ( ) | | ! cell - > getCell ( ) - > mName . empty ( ) )
return cell - > getCell ( ) - > mName ;
if ( const ESM : : Region * region = getStore( ) . get < ESM : : Region > ( ) . search ( cell - > getCell ( ) - > mRegion ) )
if ( const ESM : : Region * region = mStore . get < ESM : : Region > ( ) . search ( cell - > getCell ( ) - > mRegion ) )
return region - > mName ;
return getStore ( ) . get < ESM : : GameSetting > ( ) . find ( " sDefaultCellname " ) - > mValue . getString ( ) ;
return mStore . get < ESM : : GameSetting > ( ) . find ( " sDefaultCellname " ) - > mValue . getString ( ) ;
}
void World : : removeRefScript ( MWWorld : : RefData * ref )
@ -692,11 +720,9 @@ namespace MWWorld
std : : string lowerCaseName = Misc : : StringUtils : : lowerCase ( name ) ;
for ( Scene : : CellStoreCollection : : const_iterator iter ( mWorldScene - > getActiveCells ( ) . begin ( ) ) ;
iter ! = mWorldScene - > getActiveCells ( ) . end ( ) ; + + iter )
for ( CellStore * cellstore : mWorldScene - > getActiveCells ( ) )
{
// TODO: caching still doesn't work efficiently here (only works for the one CellStore that the reference is in)
CellStore * cellstore = * iter ;
Ptr ptr = mCells . getPtr ( lowerCaseName , * cellstore , false ) ;
if ( ! ptr . isEmpty ( ) )
@ -710,10 +736,8 @@ namespace MWWorld
return ret ;
}
for ( Scene : : CellStoreCollection : : const_iterator iter ( mWorldScene - > getActiveCells ( ) . begin ( ) ) ;
iter ! = mWorldScene - > getActiveCells ( ) . end ( ) ; + + iter )
for ( CellStore * cellstore : mWorldScene - > getActiveCells ( ) )
{
CellStore * cellstore = * iter ;
Ptr ptr = cellstore - > searchInContainer ( lowerCaseName ) ;
if ( ! ptr . isEmpty ( ) )
return ptr ;
@ -770,15 +794,14 @@ namespace MWWorld
if ( ptr . getContainerStore ( ) = = & player . getClass ( ) . getContainerStore ( player ) )
return player ;
const Scene : : CellStoreCollection & collection = mWorldScene - > getActiveCells ( ) ;
for ( Scene : : CellStoreCollection : : const_iterator cellIt = collection . begin ( ) ; cellIt ! = collection . end ( ) ; + + cellIt )
for ( CellStore * cellstore : mWorldScene - > getActiveCells ( ) )
{
FindContainerVisitor visitor ( ptr ) ;
( * cellIt ) - > forEachType < ESM : : Container > ( visitor ) ;
cellstore - > forEachType < ESM : : Container > ( visitor ) ;
if ( visitor . mResult . isEmpty ( ) )
( * cellIt ) - > forEachType < ESM : : Creature > ( visitor ) ;
cellstore - > forEachType < ESM : : Creature > ( visitor ) ;
if ( visitor . mResult . isEmpty ( ) )
( * cellIt ) - > forEachType < ESM : : NPC > ( visitor ) ;
cellstore - > forEachType < ESM : : NPC > ( visitor ) ;
if ( ! visitor . mResult . isEmpty ( ) )
return visitor . mResult ;
@ -982,7 +1005,7 @@ namespace MWWorld
" sMonthHeartfire " , " sMonthFrostfall " , " sMonthSunsdusk " , " sMonthEveningstar "
} ;
return getStore ( ) . get < ESM : : GameSetting > ( ) . find ( monthNames [ month ] ) - > mValue . getString ( ) ;
return mStore . get < ESM : : GameSetting > ( ) . find ( monthNames [ month ] ) - > mValue . getString ( ) ;
}
TimeStamp World : : getTimeStamp ( ) const
@ -1071,7 +1094,7 @@ namespace MWWorld
if ( mActivationDistanceOverride > = 0 )
return static_cast < float > ( mActivationDistanceOverride ) ;
static const int iMaxActivateDist = getStore( ) . get < ESM : : GameSetting > ( ) . find ( " iMaxActivateDist " ) - > mValue . getInteger ( ) ;
static const int iMaxActivateDist = mStore . get < ESM : : GameSetting > ( ) . find ( " iMaxActivateDist " ) - > mValue . getInteger ( ) ;
return static_cast < float > ( iMaxActivateDist ) ;
}
@ -1291,7 +1314,10 @@ namespace MWWorld
{
mRendering - > moveObject ( newPtr , vec ) ;
if ( movePhysics )
{
mPhysics - > updatePosition ( newPtr ) ;
mPhysics - > updatePtr ( ptr , newPtr ) ;
}
}
if ( isPlayer )
{
@ -1784,7 +1810,6 @@ namespace MWWorld
if ( ! paused )
{
doPhysics ( duration ) ;
updateNavigator ( ) ;
}
@ -1804,6 +1829,14 @@ namespace MWWorld
}
}
void World : : updatePhysics ( float duration , bool paused )
{
if ( ! paused )
{
doPhysics ( duration ) ;
}
}
void World : : updatePlayer ( )
{
MWWorld : : Ptr player = getPlayerPtr ( ) ;
@ -1836,7 +1869,7 @@ namespace MWWorld
bool swimming = isSwimming ( player ) ;
bool flying = isFlying ( player ) ;
static const float i1stPersonSneakDelta = getStore( ) . get < ESM : : GameSetting > ( ) . find ( " i1stPersonSneakDelta " ) - > mValue . getFloat ( ) ;
static const float i1stPersonSneakDelta = mStore . get < ESM : : GameSetting > ( ) . find ( " i1stPersonSneakDelta " ) - > mValue . getFloat ( ) ;
if ( sneaking & & ! swimming & & ! flying )
mRendering - > getCamera ( ) - > setSneakOffset ( i1stPersonSneakDelta ) ;
else
@ -2405,9 +2438,8 @@ namespace MWWorld
player . getClass ( ) . getInventoryStore ( player ) . setInvListener ( anim , player ) ;
player . getClass ( ) . getInventoryStore ( player ) . setContListener ( anim ) ;
scaleObject ( getPlayerPtr ( ) , 1.f ) ; // apply race height
rotateObject ( getPlayerPtr ( ) , 0.f , 0.f , 0.f , true ) ;
scaleObject ( player , player . getCellRef ( ) . getScale ( ) ) ; // apply race height
rotateObject ( player , 0.f , 0.f , 0.f , true ) ;
MWBase : : Environment : : get ( ) . getMechanicsManager ( ) - > add ( getPlayerPtr ( ) ) ;
MWBase : : Environment : : get ( ) . getMechanicsManager ( ) - > watchActor ( getPlayerPtr ( ) ) ;
@ -2535,17 +2567,16 @@ namespace MWWorld
std : : vector < MWWorld : : Ptr > actors ;
mPhysics - > getActorsStandingOn ( object , actors ) ;
for ( std : : vector < MWWorld : : Ptr > : : iterator it = actors . begin ( ) ; it ! = actors . end ( ) ; + + it )
for ( const Ptr & actor : actors )
{
MWWorld : : Ptr actor = * it ;
MWMechanics : : CreatureStats & stats = actor . getClass ( ) . getCreatureStats ( actor ) ;
if ( stats . isDead ( ) )
continue ;
mPhysics - > markAsNonSolid ( object ) ;
if ( actor = = getPlayerPtr ( ) & & MWBase: : Environ ment: : get ( ) . getWorld ( ) - > get GodModeState( ) )
return ;
if ( actor = = getPlayerPtr ( ) & & mGodMode)
continue ;
MWMechanics : : DynamicStat < float > health = stats . getHealth ( ) ;
health . setCurrent ( health . getCurrent ( ) - healthPerSecond * MWBase : : Environment : : get ( ) . getFrameDuration ( ) ) ;
@ -2567,19 +2598,18 @@ namespace MWWorld
if ( MWBase : : Environment : : get ( ) . getWindowManager ( ) - > isGuiMode ( ) )
return ;
std : : vector < MWWorld: : Ptr> actors ;
std : : vector < Ptr> actors ;
mPhysics - > getActorsCollidingWith ( object , actors ) ;
for ( std : : vector < MWWorld : : Ptr > : : iterator it = actors . begin ( ) ; it ! = actors . end ( ) ; + + it )
for ( const Ptr & actor : actors )
{
MWWorld : : Ptr actor = * it ;
MWMechanics : : CreatureStats & stats = actor . getClass ( ) . getCreatureStats ( actor ) ;
if ( stats . isDead ( ) )
continue ;
mPhysics - > markAsNonSolid ( object ) ;
if ( actor = = getPlayerPtr ( ) & & MWBase: : Environ ment: : get ( ) . getWorld ( ) - > get GodModeState( ) )
return ;
if ( actor = = getPlayerPtr ( ) & & mGodMode)
continue ;
MWMechanics : : DynamicStat < float > health = stats . getHealth ( ) ;
health . setCurrent ( health . getCurrent ( ) - healthPerSecond * MWBase : : Environment : : get ( ) . getFrameDuration ( ) ) ;
@ -2649,11 +2679,10 @@ namespace MWWorld
void World : : getContainersOwnedBy ( const MWWorld : : ConstPtr & owner , std : : vector < MWWorld : : Ptr > & out )
{
const Scene : : CellStoreCollection & collection = mWorldScene - > getActiveCells ( ) ;
for ( Scene : : CellStoreCollection : : const_iterator cellIt = collection . begin ( ) ; cellIt ! = collection . end ( ) ; + + cellIt )
for ( CellStore * cellstore : mWorldScene - > getActiveCells ( ) )
{
GetContainersOwnedByVisitor visitor ( owner , out ) ;
( * cellIt ) - > forEachType < ESM : : Container > ( visitor ) ;
cellstore - > forEachType < ESM : : Container > ( visitor ) ;
}
}
@ -2671,15 +2700,14 @@ namespace MWWorld
void World : : getItemsOwnedBy ( const MWWorld : : ConstPtr & npc , std : : vector < MWWorld : : Ptr > & out )
{
const Scene : : CellStoreCollection & collection = mWorldScene - > getActiveCells ( ) ;
for ( Scene : : CellStoreCollection : : const_iterator cellIt = collection . begin ( ) ; cellIt ! = collection . end ( ) ; + + cellIt )
for ( CellStore * cellstore : mWorldScene - > getActiveCells ( ) )
{
ListObjectsVisitor visitor ;
( * cellIt ) - > forEach ( visitor ) ;
cellstore - > forEach ( visitor ) ;
for ( std : : vector < MWWorld : : Ptr > : : iterator it = visitor . mObjects . begin ( ) ; it ! = visitor . mObjects . end ( ) ; + + it )
if ( Misc : : StringUtils : : ciEqual ( it- > getCellRef ( ) . getOwner ( ) , npc . getCellRef ( ) . getRefId ( ) ) )
out . push_back ( * i t) ;
for ( const Ptr & object : visitor . mObjects )
if ( Misc : : StringUtils : : ciEqual ( object. getCellRef ( ) . getOwner ( ) , npc . getCellRef ( ) . getRefId ( ) ) )
out . push_back ( objec t) ;
}
}
@ -2720,28 +2748,21 @@ namespace MWWorld
bool World : : findInteriorPosition ( const std : : string & name , ESM : : Position & pos )
{
typedef MWWorld : : CellRefList < ESM : : Door > : : List DoorList ;
typedef MWWorld : : CellRefList < ESM : : Static > : : List StaticList ;
pos . rot [ 0 ] = pos . rot [ 1 ] = pos . rot [ 2 ] = 0 ;
pos . pos [ 0 ] = pos . pos [ 1 ] = pos . pos [ 2 ] = 0 ;
MWWorld : : CellStore * cellStore = getInterior ( name ) ;
if ( 0 = = cellStore ) {
if ( ! cellStore )
return false ;
}
std : : vector < const MWWorld : : CellRef * > sortedDoors ;
const DoorList & doors = cellStore - > getReadOnlyDoors ( ) . mList ;
for ( DoorList : : const_iterator it = doors . begin ( ) ; it ! = doors . end ( ) ; + + it )
for ( const MWWorld : : LiveCellRef < ESM : : Door > & door : cellStore - > getReadOnlyDoors ( ) . mList )
{
if ( ! it - > mRef . getTeleport ( ) )
{
if ( ! door . mRef . getTeleport ( ) )
continue ;
}
sortedDoors . push_back ( & it- > mRef ) ;
sortedDoors . push_back ( & door. mRef ) ;
}
// Sort teleporting doors alphabetically, first by ID, then by destination cell to make search consistent
@ -2753,44 +2774,43 @@ namespace MWWorld
return lhs - > getDestCell ( ) < rhs - > getDestCell ( ) ;
} ) ;
for ( std : : vector < const MWWorld : : CellRef * > : : const_iterator it = sortedDoors . begin ( ) ; it ! = sortedDoors . end ( ) ; + + it )
for ( const MWWorld : : CellRef * door : sortedDoors )
{
MWWorld : : CellStore * source = 0 ;
MWWorld : : CellStore * source = nullptr ;
// door to exterior
if ( ( * it ) - > getDestCell ( ) . empty ( ) )
if ( door - > getDestCell ( ) . empty ( ) )
{
int x , y ;
ESM : : Position doorDest = ( * it ) - > getDoorDest ( ) ;
ESM : : Position doorDest = door - > getDoorDest ( ) ;
positionToIndex ( doorDest . pos [ 0 ] , doorDest . pos [ 1 ] , x , y ) ;
source = getExterior ( x , y ) ;
}
// door to interior
else
{
source = getInterior ( ( * it ) - > getDestCell ( ) ) ;
source = getInterior ( door - > getDestCell ( ) ) ;
}
if ( 0 ! = source )
if ( source )
{
// Find door leading to our current teleport door
// and use its destination to position inside cell.
const DoorList & destinationDoors = source - > getReadOnlyDoors ( ) . mList ;
for ( DoorList : : const_iterator jt = destinationDoors . begin ( ) ; jt ! = destinationDoors . end ( ) ; + + jt )
for ( const MWWorld : : LiveCellRef < ESM : : Door > & destDoor : source - > getReadOnlyDoors ( ) . mList )
{
if ( ( * it ) - > getTeleport ( ) & &
Misc : : StringUtils : : ciEqual ( name , jt - > mRef . getDestCell ( ) ) )
if ( Misc : : StringUtils : : ciEqual ( name , destDoor . mRef . getDestCell ( ) ) )
{
/// \note Using _any_ door pointed to the interior,
/// not the one pointed to current door.
pos = jt- > mRef . getDoorDest ( ) ;
pos = destDoor. mRef . getDoorDest ( ) ;
return true ;
}
}
}
}
// Fall back to the first static location.
const StaticList & statics = cellStore - > getReadOnlyStatics ( ) . mList ;
if ( statics . begin ( ) ! = statics . end ( ) ) {
const MWWorld : : CellRefList < ESM : : Static > : : List & statics = cellStore - > getReadOnlyStatics ( ) . mList ;
if ( ! statics . empty ( ) )
{
pos = statics . begin ( ) - > mRef . getPosition ( ) ;
return true ;
}
@ -2885,22 +2905,21 @@ namespace MWWorld
void World : : loadContentFiles ( const Files : : Collections & fileCollections ,
const std : : vector < std : : string > & content , ContentLoader & contentLoader )
{
std : : vector < std : : string > : : const_iterator it ( content . begin ( ) ) ;
std : : vector < std : : string > : : const_iterator end ( content . end ( ) ) ;
for ( int idx = 0 ; it ! = end ; + + it , + + idx )
int idx = 0 ;
for ( const std : : string & file : content )
{
boost : : filesystem : : path filename ( * it ) ;
boost : : filesystem : : path filename ( file ) ;
const Files : : MultiDirCollection & col = fileCollections . getCollection ( filename . extension ( ) . string ( ) ) ;
if ( col . doesExist ( * it ) )
if ( col . doesExist ( file ) )
{
contentLoader . load ( col . getPath ( * it ) , idx ) ;
contentLoader . load ( col . getPath ( file ) , idx ) ;
}
else
{
std : : stringstream msg ;
msg < < " Failed loading " < < * it < < " : the content file does not exist " ;
throw std : : runtime_error ( msg . str ( ) ) ;
std : : string message = " Failed loading " + file + " : the content file does not exist " ;
throw std : : runtime_error ( message ) ;
}
idx + + ;
}
}
@ -2916,10 +2935,10 @@ namespace MWWorld
if ( ! selectedSpell . empty ( ) )
{
const ESM : : Spell * spell = getStore( ) . get < ESM : : Spell > ( ) . find ( selectedSpell ) ;
const ESM : : Spell * spell = mStore . get < ESM : : Spell > ( ) . find ( selectedSpell ) ;
// Check mana
bool godmode = ( isPlayer & & getGodModeState( ) ) ;
bool godmode = ( isPlayer & & mGodMode ) ;
MWMechanics : : DynamicStat < float > magicka = stats . getMagicka ( ) ;
if ( magicka . getCurrent ( ) < spell - > mData . mCost & & ! godmode )
{
@ -2957,7 +2976,7 @@ namespace MWWorld
if ( ! actor . isEmpty ( ) & & actor ! = MWMechanics : : getPlayer ( ) & & ! manualSpell )
stats . getAiSequence ( ) . getCombatTargets ( targetActors ) ;
const float fCombatDistance = getStore( ) . get < ESM : : GameSetting > ( ) . find ( " fCombatDistance " ) - > mValue . getFloat ( ) ;
const float fCombatDistance = mStore . get < ESM : : GameSetting > ( ) . find ( " fCombatDistance " ) - > mValue . getFloat ( ) ;
osg : : Vec3f hitPosition = actor . getRefData ( ) . getPosition ( ) . asVec3 ( ) ;
@ -2975,14 +2994,13 @@ namespace MWWorld
// For scripted spells we should not use hit contact
if ( manualSpell )
{
// Actors that are targeted by this actor's Follow or Escort packages also side with them
if ( actor ! = MWMechanics : : getPlayer ( ) )
{
for ( std : : list < MWMechanics : : AiPackage * > : : const_iterator it = stats . getAiSequence ( ) . begin ( ) ; it ! = stats . getAiSequence ( ) . end ( ) ; + + it )
for ( const MWMechanics : : AiPackage * package : stats . getAiSequence ( ) )
{
if ( ( * it ) - > getTypeId ( ) = = MWMechanics : : AiPackage : : TypeIdCast )
if ( package - > getTypeId ( ) = = MWMechanics : : AiPackage : : TypeIdCast )
{
target = ( * it ) - > getTarget ( ) ;
target = package - > getTarget ( ) ;
break ;
}
}
@ -3040,7 +3058,7 @@ namespace MWWorld
if ( ! selectedSpell . empty ( ) )
{
const ESM : : Spell * spell = getStore( ) . get < ESM : : Spell > ( ) . find ( selectedSpell ) ;
const ESM : : Spell * spell = mStore . get < ESM : : Spell > ( ) . find ( selectedSpell ) ;
cast . cast ( spell ) ;
}
else if ( actor . getClass ( ) . hasInventoryStore ( actor ) )
@ -3151,17 +3169,14 @@ namespace MWWorld
while ( ! nextCells . empty ( ) ) {
currentCells = nextCells ;
nextCells . clear ( ) ;
for ( std : : set < std : : string > : : const_iterator i = currentCells . begin ( ) ; i ! = currentCells . end ( ) ; + + i ) {
MWWorld : : CellStore * next = getInterior ( * i ) ;
for ( const std : : string & currentCell : currentCells )
{
MWWorld : : CellStore * next = getInterior ( currentCell ) ;
if ( ! next ) continue ;
const MWWorld : : CellRefList < ESM : : Door > & doors = next - > getReadOnlyDoors ( ) ;
const CellRefList < ESM : : Door > : : List & refList = doors . mList ;
// Check if any door in the cell leads to an exterior directly
for ( CellRefList < ESM : : Door > :: List : : const_iterator it = refList . begin ( ) ; it ! = refList . end ( ) ; + + i t)
for ( const MWWorld : : LiveCellRef < ESM : : Door > & ref : next - > getReadOnlyDoors ( ) . mList )
{
const MWWorld : : LiveCellRef < ESM : : Door > & ref = * it ;
if ( ! ref . mRef . getTeleport ( ) ) continue ;
if ( ref . mRef . getDestCell ( ) . empty ( ) )
@ -3178,7 +3193,7 @@ namespace MWWorld
}
}
checkedCells . insert ( * i ) ;
checkedCells . insert ( currentCell ) ;
}
}
@ -3204,9 +3219,9 @@ namespace MWWorld
while ( ! nextCells . empty ( ) ) {
currentCells = nextCells ;
nextCells . clear ( ) ;
for ( std : : set < std : : string > : : const_iterator i = currentCells . begin ( ) ; i ! = currentCells . end ( ) ; + + i ) {
MWWorld : : CellStore * next = getInterior ( * i ) ;
checkedCells . insert ( * i ) ;
for ( const std : : string & cell : currentCells ) {
MWWorld : : CellStore * next = getInterior ( cell ) ;
checkedCells . insert ( cell ) ;
if ( ! next ) continue ;
closestMarker = next - > searchConst ( id ) ;
@ -3215,14 +3230,9 @@ namespace MWWorld
return closestMarker ;
}
const MWWorld : : CellRefList < ESM : : Door > & doors = next - > getReadOnlyDoors ( ) ;
const CellRefList < ESM : : Door > : : List & doorList = doors . mList ;
// Check if any door in the cell leads to an exterior directly
for ( CellRefList < ESM : : Door > :: List : : const_iterator it = doorList . begin ( ) ; it ! = doorList . end ( ) ; + + i t)
for ( const MWWorld : : LiveCellRef < ESM : : Door > & ref : next - > getReadOnlyDoors ( ) . mList )
{
const MWWorld : : LiveCellRef < ESM : : Door > & ref = * it ;
if ( ! ref . mRef . getTeleport ( ) ) continue ;
if ( ref . mRef . getDestCell ( ) . empty ( ) )
@ -3248,15 +3258,14 @@ namespace MWWorld
std : : vector < MWWorld : : Ptr > markers ;
mCells . getExteriorPtrs ( id , markers ) ;
for ( std : : vector < MWWorld : : Ptr > : : iterator it2 = markers . begin ( ) ; it2 ! = markers . end ( ) ; + + it2 )
for ( const Ptr & marker : markers )
{
ESM : : Position pos = it2 - > getRefData ( ) . getPosition ( ) ;
osg : : Vec3f markerPos = pos . asVec3 ( ) ;
osg : : Vec3f markerPos = marker . getRefData ( ) . getPosition ( ) . asVec3 ( ) ;
float distance = ( worldPos - markerPos ) . length2 ( ) ;
if ( distance < closestDistance )
{
closestDistance = distance ;
closestMarker = * it2 ;
closestMarker = marker ;
}
}
@ -3387,10 +3396,8 @@ namespace MWWorld
AddDetectedReferenceVisitor visitor ( out , ptr , type , dist * dist ) ;
const Scene : : CellStoreCollection & active = mWorldScene - > getActiveCells ( ) ;
for ( Scene : : CellStoreCollection : : const_iterator it = active . begin ( ) ; it ! = active . end ( ) ; + + it )
for ( CellStore * cellStore : mWorldScene - > getActiveCells ( ) )
{
MWWorld : : CellStore * cellStore = * it ;
cellStore - > forEach ( visitor ) ;
}
}
@ -3425,8 +3432,8 @@ namespace MWWorld
int bounty = player . getClass ( ) . getNpcStats ( player ) . getBounty ( ) ;
int playerGold = player . getClass ( ) . getContainerStore ( player ) . count ( ContainerStore : : sGoldId ) ;
float fCrimeGoldDiscountMult = getStore( ) . get < ESM : : GameSetting > ( ) . find ( " fCrimeGoldDiscountMult " ) - > mValue . getFloat ( ) ;
float fCrimeGoldTurnInMult = getStore( ) . get < ESM : : GameSetting > ( ) . find ( " fCrimeGoldTurnInMult " ) - > mValue . getFloat ( ) ;
static float fCrimeGoldDiscountMult = mStore . get < ESM : : GameSetting > ( ) . find ( " fCrimeGoldDiscountMult " ) - > mValue . getFloat ( ) ;
static float fCrimeGoldTurnInMult = mStore . get < ESM : : GameSetting > ( ) . find ( " fCrimeGoldTurnInMult " ) - > mValue . getFloat ( ) ;
int discount = static_cast < int > ( bounty * fCrimeGoldDiscountMult ) ;
int turnIn = static_cast < int > ( bounty * fCrimeGoldTurnInMult ) ;
@ -3491,7 +3498,7 @@ namespace MWWorld
mPlayer - > recordCrimeId ( ) ;
confiscateStolenItems ( player ) ;
int iDaysinPrisonMod = getStore( ) . get < ESM : : GameSetting > ( ) . find ( " iDaysinPrisonMod " ) - > mValue . getInteger ( ) ;
static int iDaysinPrisonMod = mStore . get < ESM : : GameSetting > ( ) . find ( " iDaysinPrisonMod " ) - > mValue . getInteger ( ) ;
mDaysInPrison = std : : max ( 1 , bounty / iDaysinPrisonMod ) ;
return ;
@ -3547,18 +3554,18 @@ namespace MWWorld
void World : : spawnRandomCreature ( const std : : string & creatureList )
{
const ESM : : CreatureLevList * list = getStore( ) . get < ESM : : CreatureLevList > ( ) . find ( creatureList ) ;
const ESM : : CreatureLevList * list = mStore . get < ESM : : CreatureLevList > ( ) . find ( creatureList ) ;
int iNumberCreatures = getStore( ) . get < ESM : : GameSetting > ( ) . find ( " iNumberCreatures " ) - > mValue . getInteger ( ) ;
static int iNumberCreatures = mStore . get < ESM : : GameSetting > ( ) . find ( " iNumberCreatures " ) - > mValue . getInteger ( ) ;
int numCreatures = 1 + Misc : : Rng : : rollDice ( iNumberCreatures ) ; // [1, iNumberCreatures]
for ( int i = 0 ; i < numCreatures ; + + i )
{
std : : string selectedCreature = MWMechanics : : getLevelledItem ( list , true ) ;
if ( selectedCreature . empty ( ) )
return ;
continue ;
MWWorld : : ManualRef ref ( getStore( ) , selectedCreature , 1 ) ;
MWWorld : : ManualRef ref ( mStore , selectedCreature , 1 ) ;
safePlaceObject ( ref . getPtr ( ) , getPlayerPtr ( ) , getPlayerPtr ( ) . getCell ( ) , 0 , 220.f ) ;
}
@ -3569,27 +3576,8 @@ namespace MWWorld
if ( ptr = = getPlayerPtr ( ) & & Settings : : Manager : : getBool ( " hit fader " , " GUI " ) )
return ;
int type = ptr . getClass ( ) . getBloodTexture ( ptr ) ;
std : : string texture ;
switch ( type )
{
case 2 :
texture = getFallback ( ) - > getFallbackString ( " Blood_Texture_2 " ) ;
break ;
case 1 :
texture = getFallback ( ) - > getFallbackString ( " Blood_Texture_1 " ) ;
break ;
case 0 :
default :
texture = getFallback ( ) - > getFallbackString ( " Blood_Texture_0 " ) ;
break ;
}
std : : stringstream modelName ;
modelName < < " Blood_Model_ " ;
int roll = Misc : : Rng : : rollDice ( 3 ) ; // [0, 2]
modelName < < roll ;
std : : string model = " meshes \\ " + getFallback ( ) - > getFallbackString ( modelName . str ( ) ) ;
std : : string texture = getFallback ( ) - > getFallbackString ( " Blood_Texture_ " + std : : to_string ( ptr . getClass ( ) . getBloodTexture ( ptr ) ) ) ;
std : : string model = " meshes \\ " + getFallback ( ) - > getFallbackString ( " Blood_Model_ " + std : : to_string ( Misc : : Rng : : rollDice ( 3 ) ) ) ; // [0, 2]
mRendering - > spawnEffect ( model , texture , worldPosition , 1.0f , false ) ;
}
@ -3606,7 +3594,7 @@ namespace MWWorld
for ( std : : vector < ESM : : ENAMstruct > : : const_iterator effectIt = effects . mList . begin ( ) ;
effectIt ! = effects . mList . end ( ) ; + + effectIt )
{
const ESM : : MagicEffect * effect = getStore( ) . get < ESM : : MagicEffect > ( ) . find ( effectIt - > mEffectID ) ;
const ESM : : MagicEffect * effect = mStore . get < ESM : : MagicEffect > ( ) . find ( effectIt - > mEffectID ) ;
if ( effectIt - > mRange ! = rangeType | | ( effectIt - > mArea < = 0 & & ! ignore . isEmpty ( ) & & ignore . getClass ( ) . isActor ( ) ) )
continue ; // Not right range type, or not area effect and hit an actor
@ -3620,9 +3608,9 @@ namespace MWWorld
// Spawn the explosion orb effect
const ESM : : Static * areaStatic ;
if ( ! effect - > mArea . empty ( ) )
areaStatic = getStore( ) . get < ESM : : Static > ( ) . find ( effect - > mArea ) ;
areaStatic = mStore . get < ESM : : Static > ( ) . find ( effect - > mArea ) ;
else
areaStatic = getStore( ) . get < ESM : : Static > ( ) . find ( " VFX_DefaultArea " ) ;
areaStatic = mStore . get < ESM : : Static > ( ) . find ( " VFX_DefaultArea " ) ;
std : : string texture = effect - > mParticle ;
@ -3650,13 +3638,13 @@ namespace MWWorld
std : : vector < MWWorld : : Ptr > objects ;
MWBase : : Environment : : get ( ) . getMechanicsManager ( ) - > getObjectsInRange (
origin , feetToGameUnits ( static_cast < float > ( effectIt - > mArea ) ) , objects ) ;
for ( std : : vector < MWWorld : : Ptr > : : iterator affected = objects . begin ( ) ; affected ! = objects . end ( ) ; + + affected )
for ( const Ptr & affected : objects )
{
// Ignore actors without collisions here, otherwise it will be possible to hit actors outside processing range.
if ( affected - > getClass ( ) . isActor ( ) & & ! isActorCollisionEnabled ( * affected ) )
if ( affected . getClass ( ) . isActor ( ) & & ! isActorCollisionEnabled ( affected ) )
continue ;
toApply [ * affected ] . push_back ( * effectIt ) ;
toApply [ affected ] . push_back ( * effectIt ) ;
}
}
@ -3716,10 +3704,8 @@ namespace MWWorld
} ;
void World : : resetActors ( )
{
for ( Scene : : CellStoreCollection : : const_iterator iter ( mWorldScene - > getActiveCells ( ) . begin ( ) ) ;
iter ! = mWorldScene - > getActiveCells ( ) . end ( ) ; + + iter )
for ( CellStore * cellstore : mWorldScene - > getActiveCells ( ) )
{
CellStore * cellstore = * iter ;
ResetActorsVisitor visitor ;
cellstore - > forEach ( visitor ) ;
}