Set the changed flag in CellStore::search (Fixes #3089)

openmw-38
scrawl 9 years ago
parent 04b6571d7d
commit 2fe2f53b02

@ -347,7 +347,7 @@ namespace MWWorld
return std::binary_search (mIds.begin(), mIds.end(), id);
/// \todo address const-issues
return const_cast<CellStore *> (this)->search (id).isEmpty();
return searchConst (id).isEmpty();
}
struct SearchVisitor
@ -367,16 +367,21 @@ namespace MWWorld
Ptr CellStore::search (const std::string& id)
{
bool oldState = mHasState;
SearchVisitor searchVisitor;
searchVisitor.mIdToFind = id;
forEach(searchVisitor);
mHasState = oldState;
return searchVisitor.mFound;
}
Ptr CellStore::searchConst (const std::string& id) const
{
bool oldState = mHasState;
/// \todo address const-issues
Ptr result = const_cast<CellStore*>(this)->search(id);
const_cast<CellStore*>(this)->mHasState = oldState;
return result;
}
Ptr CellStore::searchViaActorId (int id)
{
if (Ptr ptr = ::searchViaActorId (mNpcs, id, this, mMovedToAnotherCell))

@ -212,6 +212,12 @@ namespace MWWorld
Ptr search (const std::string& id);
///< Will return an empty Ptr if cell is not loaded. Does not check references in
/// containers.
/// @note Triggers CellStore hasState flag.
Ptr searchConst (const std::string& id) const;
///< Will return an empty Ptr if cell is not loaded. Does not check references in
/// containers.
/// @note Does not trigger CellStore hasState flag. Do not modify the returned Ptr!
Ptr searchViaActorId (int id);
///< Will return an empty Ptr if cell is not loaded.

@ -166,14 +166,20 @@ namespace MWWorld
void RefData::enable()
{
mChanged = !mEnabled;
mEnabled = true;
if (!mEnabled)
{
mChanged = true;
mEnabled = true;
}
}
void RefData::disable()
{
mChanged = mEnabled;
mEnabled = false;
if (mEnabled)
{
mChanged = true;
mEnabled = false;
}
}
void RefData::setPosition(const ESM::Position& pos)

@ -2828,7 +2828,7 @@ namespace MWWorld
checkedCells.insert( *i );
if ( !next ) continue;
closestMarker = next->search( id );
closestMarker = next->searchConst( id );
if ( !closestMarker.isEmpty() )
{
return closestMarker;

Loading…
Cancel
Save