forked from mirror/openmw-tes3mp
Fix logic for scripting access of deleted objects
This commit is contained in:
parent
e564c26314
commit
04b6571d7d
3 changed files with 13 additions and 15 deletions
|
@ -24,17 +24,6 @@ namespace MWWorld
|
|||
/// all methods are known.
|
||||
void load (ESM::CellRef &ref, bool deleted, const MWWorld::ESMStore &esmStore);
|
||||
|
||||
LiveRef *find (const std::string& name)
|
||||
{
|
||||
for (typename List::iterator iter (mList.begin()); iter!=mList.end(); ++iter)
|
||||
if (!iter->mData.isDeletedByContentFile()
|
||||
&& (iter->mRef.hasContentFile() || iter->mData.getCount() > 0)
|
||||
&& iter->mRef.getRefId() == name)
|
||||
return &*iter;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LiveRef &insert (const LiveRef &item)
|
||||
{
|
||||
mList.push_back(item);
|
||||
|
|
|
@ -173,7 +173,7 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, CellStore& cell,
|
|||
|
||||
Ptr ptr = cell.search (name);
|
||||
|
||||
if (!ptr.isEmpty() && ptr.getRefData().getCount())
|
||||
if (!ptr.isEmpty() && MWWorld::CellStore::isAccessible(ptr.getRefData(), ptr.getCellRef()))
|
||||
return ptr;
|
||||
|
||||
if (searchInContainers)
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace MWWorld
|
|||
for (typename List::List::iterator iter (list.mList.begin()); iter!=list.mList.end();
|
||||
++iter)
|
||||
{
|
||||
if (iter->mData.isDeletedByContentFile())
|
||||
if (!isAccessible(iter->mData, iter->mRef))
|
||||
continue;
|
||||
if (!visitor (MWWorld::Ptr(&*iter, this)))
|
||||
return false;
|
||||
|
@ -164,6 +164,15 @@ namespace MWWorld
|
|||
|
||||
public:
|
||||
|
||||
/// Should this reference be accessible to the outside world (i.e. to scripts / game logic)?
|
||||
/// Determined based on the deletion flags. By default, objects deleted by content files are never accessible;
|
||||
/// objects deleted by setCount(0) are still accessible *if* they came from a content file (needed for vanilla
|
||||
/// scripting compatibility, and the fact that objects may be "un-deleted" in the original game).
|
||||
static bool isAccessible(const MWWorld::RefData& refdata, const MWWorld::CellRef& cref)
|
||||
{
|
||||
return !refdata.isDeletedByContentFile() && (cref.hasContentFile() || refdata.getCount() > 0);
|
||||
}
|
||||
|
||||
/// Moves object from this cell to the given cell.
|
||||
/// @note automatically updates given cell by calling cellToMoveTo->moveFrom(...)
|
||||
/// @note throws exception if cellToMoveTo == this
|
||||
|
@ -239,7 +248,7 @@ namespace MWWorld
|
|||
|
||||
for (unsigned int i=0; i<mMergedRefs.size(); ++i)
|
||||
{
|
||||
if (mMergedRefs[i]->mData.isDeletedByContentFile())
|
||||
if (!isAccessible(mMergedRefs[i]->mData, mMergedRefs[i]->mRef))
|
||||
continue;
|
||||
|
||||
if (!visitor(MWWorld::Ptr(mMergedRefs[i], this)))
|
||||
|
@ -267,7 +276,7 @@ namespace MWWorld
|
|||
LiveCellRefBase* base = &*it;
|
||||
if (mMovedToAnotherCell.find(base) != mMovedToAnotherCell.end())
|
||||
continue;
|
||||
if (base->mData.isDeletedByContentFile())
|
||||
if (!isAccessible(base->mData, base->mRef))
|
||||
continue;
|
||||
if (!visitor(MWWorld::Ptr(base, this)))
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue