|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
#include "store.hpp"
|
|
|
|
|
#include "esmstore.hpp"
|
|
|
|
|
|
|
|
|
|
namespace MWWorld {
|
|
|
|
|
|
|
|
|
@ -15,8 +16,39 @@ void Store<ESM::Cell>::load(ESM::ESMReader &esm, const std::string &id)
|
|
|
|
|
ESM::Cell *cell = new ESM::Cell;
|
|
|
|
|
cell->mName = id;
|
|
|
|
|
|
|
|
|
|
// The cell itself takes care of some of the hairy details
|
|
|
|
|
cell->load(esm, *mEsmStore);
|
|
|
|
|
//First part of cell loading
|
|
|
|
|
cell->preLoad(esm);
|
|
|
|
|
|
|
|
|
|
//Handling MovedCellRefs, there is no way to do it inside loadcell
|
|
|
|
|
while (esm.isNextSub("MVRF")) {
|
|
|
|
|
ESM::CellRef ref;
|
|
|
|
|
ESM::MovedCellRef cMRef;
|
|
|
|
|
cell->getNextMVRF(esm, cMRef);
|
|
|
|
|
|
|
|
|
|
MWWorld::Store<ESM::Cell> &cStore = const_cast<MWWorld::Store<ESM::Cell>&>(mEsmStore->get<ESM::Cell>());
|
|
|
|
|
ESM::Cell *cellAlt = const_cast<ESM::Cell*>(cStore.searchOrCreate(cMRef.mTarget[0], cMRef.mTarget[1]));
|
|
|
|
|
|
|
|
|
|
// Get regular moved reference data. Adapted from CellStore::loadRefs. Maybe we can optimize the following
|
|
|
|
|
// implementation when the oher implementation works as well.
|
|
|
|
|
cell->getNextRef(esm, ref);
|
|
|
|
|
std::string lowerCase;
|
|
|
|
|
|
|
|
|
|
std::transform (ref.mRefID.begin(), ref.mRefID.end(), std::back_inserter (lowerCase),
|
|
|
|
|
(int(*)(int)) std::tolower);
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Second part of cell loading
|
|
|
|
|
cell->postLoad(esm);
|
|
|
|
|
|
|
|
|
|
if(cell->mData.mFlags & ESM::Cell::Interior)
|
|
|
|
|
{
|
|
|
|
@ -62,4 +94,4 @@ void Store<ESM::Cell>::load(ESM::ESMReader &esm, const std::string &id)
|
|
|
|
|
delete cell;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|