mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 11:23:51 +00:00
Merge remote-tracking branch 'glorf/bugfix-4'
This commit is contained in:
commit
f2a5377b2b
3 changed files with 41 additions and 36 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -8,9 +8,6 @@
|
|||
#include "esmreader.hpp"
|
||||
#include "esmwriter.hpp"
|
||||
|
||||
#include <apps/openmw/mwworld/store.hpp>
|
||||
#include <apps/openmw/mwworld/cellstore.hpp>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
||||
|
@ -132,38 +129,13 @@ void Cell::load(ESMReader &esm, bool saveContext)
|
|||
}
|
||||
}
|
||||
|
||||
void Cell::load(ESMReader &esm, MWWorld::ESMStore &store)
|
||||
void Cell::preLoad(ESMReader &esm) //Can't be "load" because it conflicts with function in esmtool
|
||||
{
|
||||
this->load(esm, false);
|
||||
|
||||
// preload moved references
|
||||
while (esm.isNextSub("MVRF")) {
|
||||
CellRef ref;
|
||||
MovedCellRef cMRef;
|
||||
getNextMVRF(esm, cMRef);
|
||||
|
||||
MWWorld::Store<ESM::Cell> &cStore = const_cast<MWWorld::Store<ESM::Cell>&>(store.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.
|
||||
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.
|
||||
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;
|
||||
}
|
||||
|
||||
void Cell::postLoad(ESMReader &esm)
|
||||
{
|
||||
// Save position of the cell references and move on
|
||||
mContextList.push_back(esm.getContext());
|
||||
esm.skipRecord();
|
||||
|
|
|
@ -96,7 +96,8 @@ struct Cell
|
|||
CellRefTracker mLeasedRefs;
|
||||
MovedCellRefTracker mMovedRefs;
|
||||
|
||||
void load(ESMReader &esm, MWWorld::ESMStore &store);
|
||||
void preLoad(ESMReader &esm);
|
||||
void postLoad(ESMReader &esm);
|
||||
|
||||
// This method is left in for compatibility with esmtool. Parsing moved references currently requires
|
||||
// passing ESMStore, bit it does not know about this parameter, so we do it this way.
|
||||
|
|
Loading…
Reference in a new issue