mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:23:53 +00:00
Fix moved references disappearing when modified by a plugin
This commit is contained in:
parent
d790747389
commit
dafe184220
1 changed files with 11 additions and 8 deletions
|
@ -675,14 +675,17 @@ namespace MWWorld
|
|||
for (ESM::MovedCellRefTracker::const_iterator it = cell.mMovedRefs.begin(); it != cell.mMovedRefs.end(); ++it) {
|
||||
// remove reference from current leased ref tracker and add it to new cell
|
||||
ESM::MovedCellRefTracker::iterator itold = std::find(oldcell->mMovedRefs.begin(), oldcell->mMovedRefs.end(), it->mRefNum);
|
||||
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_if(wipecell->mLeasedRefs.begin(), wipecell->mLeasedRefs.end(), ESM::CellRefTrackerPredicate(it->mRefNum));
|
||||
if (it_lease != wipecell->mLeasedRefs.end())
|
||||
wipecell->mLeasedRefs.erase(it_lease);
|
||||
else
|
||||
std::cerr << "can't find " << it->mRefNum.mIndex << " " << it->mRefNum.mContentFile << " in leasedRefs " << std::endl;
|
||||
if (itold != oldcell->mMovedRefs.end())
|
||||
{
|
||||
if (it->mTarget[0] != itold->mTarget[0] || it->mTarget[1] != itold->mTarget[1])
|
||||
{
|
||||
ESM::Cell *wipecell = const_cast<ESM::Cell*>(search(itold->mTarget[0], itold->mTarget[1]));
|
||||
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
|
||||
std::cerr << "can't find " << it->mRefNum.mIndex << " " << it->mRefNum.mContentFile << " in leasedRefs " << std::endl;
|
||||
}
|
||||
*itold = *it;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue