forked from teamnwah/openmw-tes3coop
Pass the ESM reader list to CellStore constructor
This commit is contained in:
parent
3dcefd17fc
commit
811df1e97b
3 changed files with 39 additions and 27 deletions
|
@ -23,7 +23,7 @@ MWWorld::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell)
|
||||||
|
|
||||||
if (result==mInteriors.end())
|
if (result==mInteriors.end())
|
||||||
{
|
{
|
||||||
result = mInteriors.insert (std::make_pair (lowerName, CellStore (cell))).first;
|
result = mInteriors.insert (std::make_pair (lowerName, CellStore (cell, mStore, mReader))).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
return &result->second;
|
return &result->second;
|
||||||
|
@ -36,7 +36,7 @@ MWWorld::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell)
|
||||||
if (result==mExteriors.end())
|
if (result==mExteriors.end())
|
||||||
{
|
{
|
||||||
result = mExteriors.insert (std::make_pair (
|
result = mExteriors.insert (std::make_pair (
|
||||||
std::make_pair (cell->getGridX(), cell->getGridY()), CellStore (cell))).first;
|
std::make_pair (cell->getGridX(), cell->getGridY()), CellStore (cell, mStore, mReader))).first;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ MWWorld::Ptr MWWorld::Cells::getPtrAndCache (const std::string& name, CellStore&
|
||||||
void MWWorld::Cells::writeCell (ESM::ESMWriter& writer, CellStore& cell) const
|
void MWWorld::Cells::writeCell (ESM::ESMWriter& writer, CellStore& cell) const
|
||||||
{
|
{
|
||||||
if (cell.getState()!=CellStore::State_Loaded)
|
if (cell.getState()!=CellStore::State_Loaded)
|
||||||
cell.load (mStore, mReader);
|
cell.load ();
|
||||||
|
|
||||||
ESM::CellState cellState;
|
ESM::CellState cellState;
|
||||||
|
|
||||||
|
@ -114,13 +114,13 @@ MWWorld::CellStore *MWWorld::Cells::getExterior (int x, int y)
|
||||||
}
|
}
|
||||||
|
|
||||||
result = mExteriors.insert (std::make_pair (
|
result = mExteriors.insert (std::make_pair (
|
||||||
std::make_pair (x, y), CellStore (cell))).first;
|
std::make_pair (x, y), CellStore (cell, mStore, mReader))).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result->second.getState()!=CellStore::State_Loaded)
|
if (result->second.getState()!=CellStore::State_Loaded)
|
||||||
{
|
{
|
||||||
// Multiple plugin support for landscape data is much easier than for references. The last plugin wins.
|
// Multiple plugin support for landscape data is much easier than for references. The last plugin wins.
|
||||||
result->second.load (mStore, mReader);
|
result->second.load ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return &result->second;
|
return &result->second;
|
||||||
|
@ -135,12 +135,12 @@ MWWorld::CellStore *MWWorld::Cells::getInterior (const std::string& name)
|
||||||
{
|
{
|
||||||
const ESM::Cell *cell = mStore.get<ESM::Cell>().find(lowerName);
|
const ESM::Cell *cell = mStore.get<ESM::Cell>().find(lowerName);
|
||||||
|
|
||||||
result = mInteriors.insert (std::make_pair (lowerName, CellStore (cell))).first;
|
result = mInteriors.insert (std::make_pair (lowerName, CellStore (cell, mStore, mReader))).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result->second.getState()!=CellStore::State_Loaded)
|
if (result->second.getState()!=CellStore::State_Loaded)
|
||||||
{
|
{
|
||||||
result->second.load (mStore, mReader);
|
result->second.load ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return &result->second;
|
return &result->second;
|
||||||
|
@ -158,13 +158,13 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, CellStore& cell,
|
||||||
bool searchInContainers)
|
bool searchInContainers)
|
||||||
{
|
{
|
||||||
if (cell.getState()==CellStore::State_Unloaded)
|
if (cell.getState()==CellStore::State_Unloaded)
|
||||||
cell.preload (mStore, mReader);
|
cell.preload ();
|
||||||
|
|
||||||
if (cell.getState()==CellStore::State_Preloaded)
|
if (cell.getState()==CellStore::State_Preloaded)
|
||||||
{
|
{
|
||||||
if (cell.hasId (name))
|
if (cell.hasId (name))
|
||||||
{
|
{
|
||||||
cell.load (mStore, mReader);
|
cell.load ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return Ptr();
|
return Ptr();
|
||||||
|
@ -333,7 +333,7 @@ bool MWWorld::Cells::readRecord (ESM::ESMReader& reader, uint32_t type,
|
||||||
cellStore->readFog(reader);
|
cellStore->readFog(reader);
|
||||||
|
|
||||||
if (cellStore->getState()!=CellStore::State_Loaded)
|
if (cellStore->getState()!=CellStore::State_Loaded)
|
||||||
cellStore->load (mStore, mReader);
|
cellStore->load ();
|
||||||
|
|
||||||
cellStore->readReferences (reader, contentFileMap);
|
cellStore->readReferences (reader, contentFileMap);
|
||||||
|
|
||||||
|
|
|
@ -284,8 +284,8 @@ namespace MWWorld
|
||||||
functor.merge();
|
functor.merge();
|
||||||
}
|
}
|
||||||
|
|
||||||
CellStore::CellStore (const ESM::Cell *cell)
|
CellStore::CellStore (const ESM::Cell *cell, const MWWorld::ESMStore& esmStore, std::vector<ESM::ESMReader>& readerList)
|
||||||
: mCell (cell), mState (State_Unloaded), mHasState (false), mLastRespawn(0,0)
|
: mStore(esmStore), mReader(readerList), mCell (cell), mState (State_Unloaded), mHasState (false), mLastRespawn(0,0)
|
||||||
{
|
{
|
||||||
mWaterLevel = cell->mWater;
|
mWaterLevel = cell->mWater;
|
||||||
}
|
}
|
||||||
|
@ -382,14 +382,14 @@ namespace MWWorld
|
||||||
return mMergedRefs.size();
|
return mMergedRefs.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellStore::load (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm)
|
void CellStore::load ()
|
||||||
{
|
{
|
||||||
if (mState!=State_Loaded)
|
if (mState!=State_Loaded)
|
||||||
{
|
{
|
||||||
if (mState==State_Preloaded)
|
if (mState==State_Preloaded)
|
||||||
mIds.clear();
|
mIds.clear();
|
||||||
|
|
||||||
loadRefs (store, esm);
|
loadRefs ();
|
||||||
|
|
||||||
mState = State_Loaded;
|
mState = State_Loaded;
|
||||||
|
|
||||||
|
@ -399,18 +399,20 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellStore::preload (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm)
|
void CellStore::preload ()
|
||||||
{
|
{
|
||||||
if (mState==State_Unloaded)
|
if (mState==State_Unloaded)
|
||||||
{
|
{
|
||||||
listRefs (store, esm);
|
listRefs ();
|
||||||
|
|
||||||
mState = State_Preloaded;
|
mState = State_Preloaded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellStore::listRefs(const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm)
|
void CellStore::listRefs()
|
||||||
{
|
{
|
||||||
|
std::vector<ESM::ESMReader>& esm = mReader;
|
||||||
|
|
||||||
assert (mCell);
|
assert (mCell);
|
||||||
|
|
||||||
if (mCell->mContextList.empty())
|
if (mCell->mContextList.empty())
|
||||||
|
@ -462,8 +464,10 @@ namespace MWWorld
|
||||||
std::sort (mIds.begin(), mIds.end());
|
std::sort (mIds.begin(), mIds.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellStore::loadRefs(const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm)
|
void CellStore::loadRefs()
|
||||||
{
|
{
|
||||||
|
std::vector<ESM::ESMReader>& esm = mReader;
|
||||||
|
|
||||||
assert (mCell);
|
assert (mCell);
|
||||||
|
|
||||||
if (mCell->mContextList.empty())
|
if (mCell->mContextList.empty())
|
||||||
|
@ -490,7 +494,7 @@ namespace MWWorld
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadRef (ref, deleted, store);
|
loadRef (ref, deleted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,7 +503,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
ESM::CellRef &ref = const_cast<ESM::CellRef&>(*it);
|
ESM::CellRef &ref = const_cast<ESM::CellRef&>(*it);
|
||||||
|
|
||||||
loadRef (ref, false, store);
|
loadRef (ref, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMergedRefs();
|
updateMergedRefs();
|
||||||
|
@ -530,10 +534,12 @@ namespace MWWorld
|
||||||
return Ptr();
|
return Ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellStore::loadRef (ESM::CellRef& ref, bool deleted, const ESMStore& store)
|
void CellStore::loadRef (ESM::CellRef& ref, bool deleted)
|
||||||
{
|
{
|
||||||
Misc::StringUtils::toLower (ref.mRefID);
|
Misc::StringUtils::toLower (ref.mRefID);
|
||||||
|
|
||||||
|
const MWWorld::ESMStore& store = mStore;
|
||||||
|
|
||||||
switch (store.find (ref.mRefID))
|
switch (store.find (ref.mRefID))
|
||||||
{
|
{
|
||||||
case ESM::REC_ACTI: mActivators.load(ref, deleted, store); break;
|
case ESM::REC_ACTI: mActivators.load(ref, deleted, store); break;
|
||||||
|
|
|
@ -60,6 +60,9 @@ namespace MWWorld
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
const MWWorld::ESMStore& mStore;
|
||||||
|
std::vector<ESM::ESMReader>& mReader;
|
||||||
|
|
||||||
// Even though fog actually belongs to the player and not cells,
|
// Even though fog actually belongs to the player and not cells,
|
||||||
// it makes sense to store it here since we need it once for each cell.
|
// it makes sense to store it here since we need it once for each cell.
|
||||||
// Note this is NULL until the cell is explored to save some memory
|
// Note this is NULL until the cell is explored to save some memory
|
||||||
|
@ -177,7 +180,10 @@ namespace MWWorld
|
||||||
template <typename T>
|
template <typename T>
|
||||||
LiveCellRefBase* insert(const LiveCellRef<T>* ref);
|
LiveCellRefBase* insert(const LiveCellRef<T>* ref);
|
||||||
|
|
||||||
CellStore (const ESM::Cell *cell_);
|
/// @param readerList The readers to use for loading of the cell on-demand.
|
||||||
|
CellStore (const ESM::Cell *cell_,
|
||||||
|
const MWWorld::ESMStore& store,
|
||||||
|
std::vector<ESM::ESMReader>& readerList);
|
||||||
|
|
||||||
const ESM::Cell *getCell() const;
|
const ESM::Cell *getCell() const;
|
||||||
|
|
||||||
|
@ -210,10 +216,10 @@ namespace MWWorld
|
||||||
int count() const;
|
int count() const;
|
||||||
///< Return total number of references, including deleted ones.
|
///< Return total number of references, including deleted ones.
|
||||||
|
|
||||||
void load (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
|
void load ();
|
||||||
///< Load references from content file.
|
///< Load references from content file.
|
||||||
|
|
||||||
void preload (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
|
void preload ();
|
||||||
///< Build ID list from content file.
|
///< Build ID list from content file.
|
||||||
|
|
||||||
/// Call functor (ref) for each reference. functor must return a bool. Returning
|
/// Call functor (ref) for each reference. functor must return a bool. Returning
|
||||||
|
@ -267,11 +273,11 @@ namespace MWWorld
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/// Run through references and store IDs
|
/// Run through references and store IDs
|
||||||
void listRefs(const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
|
void listRefs();
|
||||||
|
|
||||||
void loadRefs(const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
|
void loadRefs();
|
||||||
|
|
||||||
void loadRef (ESM::CellRef& ref, bool deleted, const ESMStore& store);
|
void loadRef (ESM::CellRef& ref, bool deleted);
|
||||||
///< Make case-adjustments to \a ref and insert it into the respective container.
|
///< Make case-adjustments to \a ref and insert it into the respective container.
|
||||||
///
|
///
|
||||||
/// Invalid \a ref objects are silently dropped.
|
/// Invalid \a ref objects are silently dropped.
|
||||||
|
|
Loading…
Reference in a new issue