mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 21:45:32 +00:00
Implement deletion of moved references (Bug #3471)
This commit is contained in:
parent
4ac5174d89
commit
d790747389
3 changed files with 26 additions and 18 deletions
|
@ -497,9 +497,11 @@ namespace MWWorld
|
|||
// List moved references, from separately tracked list.
|
||||
for (ESM::CellRefTracker::const_iterator it = mCell->mLeasedRefs.begin(); it != mCell->mLeasedRefs.end(); ++it)
|
||||
{
|
||||
const ESM::CellRef &ref = *it;
|
||||
const ESM::CellRef &ref = it->first;
|
||||
bool deleted = it->second;
|
||||
|
||||
mIds.push_back(Misc::StringUtils::lowerCase(ref.mRefID));
|
||||
if (!deleted)
|
||||
mIds.push_back(Misc::StringUtils::lowerCase(ref.mRefID));
|
||||
}
|
||||
|
||||
std::sort (mIds.begin(), mIds.end());
|
||||
|
@ -549,9 +551,10 @@ namespace MWWorld
|
|||
// Load moved references, from separately tracked list.
|
||||
for (ESM::CellRefTracker::const_iterator it = mCell->mLeasedRefs.begin(); it != mCell->mLeasedRefs.end(); ++it)
|
||||
{
|
||||
ESM::CellRef &ref = const_cast<ESM::CellRef&>(*it);
|
||||
ESM::CellRef &ref = const_cast<ESM::CellRef&>(it->first);
|
||||
bool deleted = it->second;
|
||||
|
||||
loadRef (ref, false);
|
||||
loadRef (ref, deleted);
|
||||
}
|
||||
|
||||
updateMergedRefs();
|
||||
|
|
|
@ -513,19 +513,16 @@ namespace MWWorld
|
|||
bool deleted = false;
|
||||
cell->getNextRef(esm, ref, deleted);
|
||||
|
||||
if (!deleted)
|
||||
{
|
||||
// Add data required to make reference appear in the correct cell.
|
||||
// We should not need to test for duplicates, as this part of the code is pre-cell merge.
|
||||
cell->mMovedRefs.push_back(cMRef);
|
||||
// Add data required to make reference appear in the correct cell.
|
||||
// We should not need to test for duplicates, as this part of the code is pre-cell merge.
|
||||
cell->mMovedRefs.push_back(cMRef);
|
||||
|
||||
// But there may be duplicates here!
|
||||
ESM::CellRefTracker::iterator iter = std::find(cellAlt->mLeasedRefs.begin(), cellAlt->mLeasedRefs.end(), ref.mRefNum);
|
||||
if (iter == cellAlt->mLeasedRefs.end())
|
||||
cellAlt->mLeasedRefs.push_back(ref);
|
||||
else
|
||||
*iter = ref;
|
||||
}
|
||||
// But there may be duplicates here!
|
||||
ESM::CellRefTracker::iterator iter = std::find_if(cellAlt->mLeasedRefs.begin(), cellAlt->mLeasedRefs.end(), ESM::CellRefTrackerPredicate(ref.mRefNum));
|
||||
if (iter == cellAlt->mLeasedRefs.end())
|
||||
cellAlt->mLeasedRefs.push_back(std::make_pair(ref, deleted));
|
||||
else
|
||||
*iter = std::make_pair(ref, deleted);
|
||||
}
|
||||
}
|
||||
const ESM::Cell *Store<ESM::Cell>::search(const std::string &id) const
|
||||
|
@ -681,7 +678,7 @@ namespace MWWorld
|
|||
if (itold != oldcell->mMovedRefs.end()) {
|
||||
ESM::MovedCellRef target0 = *itold;
|
||||
ESM::Cell *wipecell = const_cast<ESM::Cell*>(search(target0.mTarget[0], target0.mTarget[1]));
|
||||
ESM::CellRefTracker::iterator it_lease = std::find(wipecell->mLeasedRefs.begin(), wipecell->mLeasedRefs.end(), it->mRefNum);
|
||||
ESM::CellRefTracker::iterator it_lease = std::find_if(wipecell->mLeasedRefs.begin(), wipecell->mLeasedRefs.end(), ESM::CellRefTrackerPredicate(it->mRefNum));
|
||||
if (it_lease != wipecell->mLeasedRefs.end())
|
||||
wipecell->mLeasedRefs.erase(it_lease);
|
||||
else
|
||||
|
|
|
@ -43,7 +43,15 @@ bool operator==(const MovedCellRef& ref, const RefNum& refNum);
|
|||
bool operator==(const CellRef& ref, const RefNum& refNum);
|
||||
|
||||
typedef std::list<MovedCellRef> MovedCellRefTracker;
|
||||
typedef std::list<CellRef> CellRefTracker;
|
||||
typedef std::list<std::pair<CellRef, bool> > CellRefTracker;
|
||||
|
||||
struct CellRefTrackerPredicate
|
||||
{
|
||||
RefNum mRefNum;
|
||||
|
||||
CellRefTrackerPredicate(const RefNum& refNum) : mRefNum(refNum) {}
|
||||
bool operator() (const std::pair<CellRef, bool>& refdelPair) { return refdelPair.first == mRefNum; }
|
||||
};
|
||||
|
||||
/* Cells hold data about objects, creatures, statics (rocks, walls,
|
||||
buildings) and landscape (for exterior cells). Cells frequently
|
||||
|
|
Loading…
Reference in a new issue