2011-09-08 09:02:55 +00:00
|
|
|
#include "cells.hpp"
|
|
|
|
|
2018-08-14 19:05:43 +00:00
|
|
|
#include <components/debug/debuglog.hpp>
|
2014-01-23 10:29:40 +00:00
|
|
|
#include <components/esm/esmreader.hpp>
|
|
|
|
#include <components/esm/esmwriter.hpp>
|
|
|
|
#include <components/esm/defs.hpp>
|
|
|
|
#include <components/esm/cellstate.hpp>
|
2015-07-09 17:22:04 +00:00
|
|
|
#include <components/loadinglistener/loadinglistener.hpp>
|
2017-05-25 09:09:40 +00:00
|
|
|
#include <components/settings/settings.hpp>
|
2014-01-23 10:29:40 +00:00
|
|
|
|
2012-07-03 10:30:50 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
2012-03-10 11:36:29 +00:00
|
|
|
#include "class.hpp"
|
2012-10-01 15:17:04 +00:00
|
|
|
#include "esmstore.hpp"
|
2012-03-10 11:36:29 +00:00
|
|
|
#include "containerstore.hpp"
|
2014-02-23 19:11:05 +00:00
|
|
|
#include "cellstore.hpp"
|
2011-09-27 08:08:07 +00:00
|
|
|
|
2013-12-05 12:21:26 +00:00
|
|
|
MWWorld::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell)
|
2011-09-22 10:44:17 +00:00
|
|
|
{
|
2012-09-17 07:37:50 +00:00
|
|
|
if (cell->mData.mFlags & ESM::Cell::Interior)
|
2011-09-22 10:44:17 +00:00
|
|
|
{
|
2014-01-14 08:46:53 +00:00
|
|
|
std::string lowerName(Misc::StringUtils::lowerCase(cell->mName));
|
2014-01-24 17:21:52 +00:00
|
|
|
std::map<std::string, CellStore>::iterator result = mInteriors.find (lowerName);
|
2011-09-22 10:44:17 +00:00
|
|
|
|
|
|
|
if (result==mInteriors.end())
|
|
|
|
{
|
2015-12-06 17:03:55 +00:00
|
|
|
result = mInteriors.insert (std::make_pair (lowerName, CellStore (cell, mStore, mReader))).first;
|
2011-09-22 10:44:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return &result->second;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-05 12:21:26 +00:00
|
|
|
std::map<std::pair<int, int>, CellStore>::iterator result =
|
2012-11-05 12:07:59 +00:00
|
|
|
mExteriors.find (std::make_pair (cell->getGridX(), cell->getGridY()));
|
2011-09-22 10:44:17 +00:00
|
|
|
|
|
|
|
if (result==mExteriors.end())
|
|
|
|
{
|
|
|
|
result = mExteriors.insert (std::make_pair (
|
2015-12-06 17:03:55 +00:00
|
|
|
std::make_pair (cell->getGridX(), cell->getGridY()), CellStore (cell, mStore, mReader))).first;
|
2011-09-22 10:44:17 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return &result->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-15 15:54:18 +00:00
|
|
|
void MWWorld::Cells::clear()
|
|
|
|
{
|
|
|
|
mInteriors.clear();
|
|
|
|
mExteriors.clear();
|
2013-12-05 12:21:26 +00:00
|
|
|
std::fill(mIdCache.begin(), mIdCache.end(), std::make_pair("", (MWWorld::CellStore*)0));
|
2013-05-15 15:54:18 +00:00
|
|
|
mIdCacheIndex = 0;
|
|
|
|
}
|
|
|
|
|
2013-12-05 12:21:26 +00:00
|
|
|
MWWorld::Ptr MWWorld::Cells::getPtrAndCache (const std::string& name, CellStore& cellStore)
|
2012-06-21 09:43:18 +00:00
|
|
|
{
|
|
|
|
Ptr ptr = getPtr (name, cellStore);
|
|
|
|
|
2013-08-15 12:45:13 +00:00
|
|
|
if (!ptr.isEmpty() && ptr.isInCell())
|
2012-06-21 09:43:18 +00:00
|
|
|
{
|
|
|
|
mIdCache[mIdCacheIndex].first = name;
|
|
|
|
mIdCache[mIdCacheIndex].second = &cellStore;
|
|
|
|
if (++mIdCacheIndex>=mIdCache.size())
|
|
|
|
mIdCacheIndex = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2014-02-24 09:03:04 +00:00
|
|
|
void MWWorld::Cells::writeCell (ESM::ESMWriter& writer, CellStore& cell) const
|
2014-01-23 10:29:40 +00:00
|
|
|
{
|
2014-02-24 09:03:04 +00:00
|
|
|
if (cell.getState()!=CellStore::State_Loaded)
|
2015-12-06 17:03:55 +00:00
|
|
|
cell.load ();
|
2014-02-24 09:03:04 +00:00
|
|
|
|
2014-01-23 10:29:40 +00:00
|
|
|
ESM::CellState cellState;
|
|
|
|
|
|
|
|
cell.saveState (cellState);
|
|
|
|
|
|
|
|
writer.startRecord (ESM::REC_CSTA);
|
|
|
|
cellState.mId.save (writer);
|
|
|
|
cellState.save (writer);
|
2014-05-11 00:07:28 +00:00
|
|
|
cell.writeFog(writer);
|
2014-01-23 11:51:42 +00:00
|
|
|
cell.writeReferences (writer);
|
2014-01-23 10:29:40 +00:00
|
|
|
writer.endRecord (ESM::REC_CSTA);
|
|
|
|
}
|
|
|
|
|
2012-11-25 13:12:44 +00:00
|
|
|
MWWorld::Cells::Cells (const MWWorld::ESMStore& store, std::vector<ESM::ESMReader>& reader)
|
2012-07-03 10:30:50 +00:00
|
|
|
: mStore (store), mReader (reader),
|
2017-05-25 09:09:40 +00:00
|
|
|
mIdCache (Settings::Manager::getInt("pointers cache size", "Cells"), std::pair<std::string, CellStore *> ("", (CellStore*)0)),
|
2012-06-21 09:43:18 +00:00
|
|
|
mIdCacheIndex (0)
|
|
|
|
{}
|
2011-09-08 09:02:55 +00:00
|
|
|
|
2013-12-05 12:21:26 +00:00
|
|
|
MWWorld::CellStore *MWWorld::Cells::getExterior (int x, int y)
|
2011-09-08 09:02:55 +00:00
|
|
|
{
|
2013-12-05 12:21:26 +00:00
|
|
|
std::map<std::pair<int, int>, CellStore>::iterator result =
|
2011-09-08 09:02:55 +00:00
|
|
|
mExteriors.find (std::make_pair (x, y));
|
|
|
|
|
|
|
|
if (result==mExteriors.end())
|
|
|
|
{
|
2012-11-06 08:36:21 +00:00
|
|
|
const ESM::Cell *cell = mStore.get<ESM::Cell>().search(x, y);
|
2011-09-27 08:08:07 +00:00
|
|
|
|
|
|
|
if (!cell)
|
|
|
|
{
|
|
|
|
// Cell isn't predefined. Make one on the fly.
|
|
|
|
ESM::Cell record;
|
2016-07-02 17:48:11 +00:00
|
|
|
record.mCellId.mWorldspace = ESM::CellId::sDefaultWorldspace;
|
2016-07-02 17:43:08 +00:00
|
|
|
record.mCellId.mPaged = true;
|
|
|
|
record.mCellId.mIndex.mX = x;
|
|
|
|
record.mCellId.mIndex.mY = y;
|
2011-09-27 08:08:07 +00:00
|
|
|
|
2014-01-07 19:43:08 +00:00
|
|
|
record.mData.mFlags = ESM::Cell::HasWater;
|
2012-09-17 07:37:50 +00:00
|
|
|
record.mData.mX = x;
|
|
|
|
record.mData.mY = y;
|
|
|
|
record.mWater = 0;
|
|
|
|
record.mMapColor = 0;
|
2011-09-27 08:08:07 +00:00
|
|
|
|
2012-07-03 10:30:50 +00:00
|
|
|
cell = MWBase::Environment::get().getWorld()->createRecord (record);
|
2011-09-27 08:08:07 +00:00
|
|
|
}
|
2011-09-08 09:02:55 +00:00
|
|
|
|
2011-09-10 09:22:32 +00:00
|
|
|
result = mExteriors.insert (std::make_pair (
|
2015-12-06 17:03:55 +00:00
|
|
|
std::make_pair (x, y), CellStore (cell, mStore, mReader))).first;
|
2012-02-12 11:35:29 +00:00
|
|
|
}
|
2011-09-10 09:22:32 +00:00
|
|
|
|
2014-02-23 13:26:36 +00:00
|
|
|
if (result->second.getState()!=CellStore::State_Loaded)
|
2012-05-25 15:55:00 +00:00
|
|
|
{
|
2015-12-06 17:03:55 +00:00
|
|
|
result->second.load ();
|
2012-05-25 15:55:00 +00:00
|
|
|
}
|
2012-03-10 11:36:29 +00:00
|
|
|
|
2011-09-08 09:02:55 +00:00
|
|
|
return &result->second;
|
|
|
|
}
|
|
|
|
|
2013-12-05 12:21:26 +00:00
|
|
|
MWWorld::CellStore *MWWorld::Cells::getInterior (const std::string& name)
|
2011-09-08 09:02:55 +00:00
|
|
|
{
|
2013-03-07 19:15:01 +00:00
|
|
|
std::string lowerName = Misc::StringUtils::lowerCase(name);
|
2013-12-05 12:21:26 +00:00
|
|
|
std::map<std::string, CellStore>::iterator result = mInteriors.find (lowerName);
|
2011-09-08 09:02:55 +00:00
|
|
|
|
|
|
|
if (result==mInteriors.end())
|
|
|
|
{
|
2013-03-07 19:15:01 +00:00
|
|
|
const ESM::Cell *cell = mStore.get<ESM::Cell>().find(lowerName);
|
2011-09-10 09:22:32 +00:00
|
|
|
|
2015-12-06 17:03:55 +00:00
|
|
|
result = mInteriors.insert (std::make_pair (lowerName, CellStore (cell, mStore, mReader))).first;
|
2012-02-12 11:35:29 +00:00
|
|
|
}
|
2011-09-08 09:02:55 +00:00
|
|
|
|
2014-02-23 13:26:36 +00:00
|
|
|
if (result->second.getState()!=CellStore::State_Loaded)
|
2012-05-25 15:55:00 +00:00
|
|
|
{
|
2015-12-06 17:03:55 +00:00
|
|
|
result->second.load ();
|
2012-05-25 15:55:00 +00:00
|
|
|
}
|
2012-03-10 11:36:29 +00:00
|
|
|
|
2011-09-08 09:02:55 +00:00
|
|
|
return &result->second;
|
|
|
|
}
|
2011-09-22 09:54:08 +00:00
|
|
|
|
2018-09-23 18:03:43 +00:00
|
|
|
void MWWorld::Cells::rest ()
|
|
|
|
{
|
|
|
|
for (auto &interior : mInteriors)
|
|
|
|
{
|
|
|
|
interior.second.rest();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto &exterior : mExteriors)
|
|
|
|
{
|
|
|
|
exterior.second.rest();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-23 10:29:40 +00:00
|
|
|
MWWorld::CellStore *MWWorld::Cells::getCell (const ESM::CellId& id)
|
|
|
|
{
|
|
|
|
if (id.mPaged)
|
|
|
|
return getExterior (id.mIndex.mX, id.mIndex.mY);
|
|
|
|
|
|
|
|
return getInterior (id.mWorldspace);
|
|
|
|
}
|
|
|
|
|
2013-12-05 12:21:26 +00:00
|
|
|
MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, CellStore& cell,
|
2013-08-15 12:45:13 +00:00
|
|
|
bool searchInContainers)
|
2011-09-22 09:54:08 +00:00
|
|
|
{
|
2014-02-23 13:26:36 +00:00
|
|
|
if (cell.getState()==CellStore::State_Unloaded)
|
2015-12-06 17:03:55 +00:00
|
|
|
cell.preload ();
|
2011-09-24 09:45:59 +00:00
|
|
|
|
2014-02-23 13:26:36 +00:00
|
|
|
if (cell.getState()==CellStore::State_Preloaded)
|
2011-09-24 09:45:59 +00:00
|
|
|
{
|
2014-02-23 15:46:07 +00:00
|
|
|
if (cell.hasId (name))
|
2012-06-19 14:42:10 +00:00
|
|
|
{
|
2015-12-06 17:03:55 +00:00
|
|
|
cell.load ();
|
2012-06-19 14:42:10 +00:00
|
|
|
}
|
2011-09-24 09:45:59 +00:00
|
|
|
else
|
|
|
|
return Ptr();
|
|
|
|
}
|
2013-04-14 15:37:39 +00:00
|
|
|
|
2014-02-23 15:46:07 +00:00
|
|
|
Ptr ptr = cell.search (name);
|
2011-09-22 09:54:08 +00:00
|
|
|
|
2015-12-17 19:34:50 +00:00
|
|
|
if (!ptr.isEmpty() && MWWorld::CellStore::isAccessible(ptr.getRefData(), ptr.getCellRef()))
|
2014-02-23 15:46:07 +00:00
|
|
|
return ptr;
|
2013-08-15 12:45:13 +00:00
|
|
|
|
|
|
|
if (searchInContainers)
|
|
|
|
return cell.searchInContainer (name);
|
2011-09-22 09:54:08 +00:00
|
|
|
|
|
|
|
return Ptr();
|
|
|
|
}
|
2011-09-22 10:44:17 +00:00
|
|
|
|
|
|
|
MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name)
|
|
|
|
{
|
2012-06-21 09:43:18 +00:00
|
|
|
// First check the cache
|
2013-12-05 12:21:26 +00:00
|
|
|
for (std::vector<std::pair<std::string, CellStore *> >::iterator iter (mIdCache.begin());
|
2012-06-21 09:43:18 +00:00
|
|
|
iter!=mIdCache.end(); ++iter)
|
|
|
|
if (iter->first==name && iter->second)
|
|
|
|
{
|
|
|
|
Ptr ptr = getPtr (name, *iter->second);
|
|
|
|
if (!ptr.isEmpty())
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Then check cells that are already listed
|
2014-06-28 15:44:52 +00:00
|
|
|
// Search in reverse, this is a workaround for an ambiguous chargen_plank reference in the vanilla game.
|
|
|
|
// there is one at -22,16 and one at -2,-9, the latter should be used.
|
|
|
|
for (std::map<std::pair<int, int>, CellStore>::reverse_iterator iter = mExteriors.rbegin();
|
|
|
|
iter!=mExteriors.rend(); ++iter)
|
2011-09-22 10:44:17 +00:00
|
|
|
{
|
2012-06-21 09:43:18 +00:00
|
|
|
Ptr ptr = getPtrAndCache (name, iter->second);
|
2011-09-22 10:44:17 +00:00
|
|
|
if (!ptr.isEmpty())
|
2013-04-14 15:37:39 +00:00
|
|
|
return ptr;
|
2011-09-22 10:44:17 +00:00
|
|
|
}
|
|
|
|
|
2013-12-05 12:21:26 +00:00
|
|
|
for (std::map<std::string, CellStore>::iterator iter = mInteriors.begin();
|
2013-04-14 15:37:39 +00:00
|
|
|
iter!=mInteriors.end(); ++iter)
|
2011-09-22 10:44:17 +00:00
|
|
|
{
|
2012-06-21 09:43:18 +00:00
|
|
|
Ptr ptr = getPtrAndCache (name, iter->second);
|
2011-09-22 10:44:17 +00:00
|
|
|
if (!ptr.isEmpty())
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now try the other cells
|
2012-11-06 08:36:21 +00:00
|
|
|
const MWWorld::Store<ESM::Cell> &cells = mStore.get<ESM::Cell>();
|
|
|
|
MWWorld::Store<ESM::Cell>::iterator iter;
|
|
|
|
|
2013-04-14 15:37:39 +00:00
|
|
|
for (iter = cells.extBegin(); iter != cells.extEnd(); ++iter)
|
2011-09-22 10:44:17 +00:00
|
|
|
{
|
2013-12-05 12:21:26 +00:00
|
|
|
CellStore *cellStore = getCellStore (&(*iter));
|
2011-09-22 10:44:17 +00:00
|
|
|
|
2012-06-21 09:43:18 +00:00
|
|
|
Ptr ptr = getPtrAndCache (name, *cellStore);
|
2011-09-22 10:44:17 +00:00
|
|
|
|
|
|
|
if (!ptr.isEmpty())
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2013-04-14 15:37:39 +00:00
|
|
|
for (iter = cells.intBegin(); iter != cells.intEnd(); ++iter)
|
2011-09-22 10:44:17 +00:00
|
|
|
{
|
2013-12-05 12:21:26 +00:00
|
|
|
CellStore *cellStore = getCellStore (&(*iter));
|
2011-09-22 10:44:17 +00:00
|
|
|
|
2012-06-21 09:43:18 +00:00
|
|
|
Ptr ptr = getPtrAndCache (name, *cellStore);
|
2011-09-22 10:44:17 +00:00
|
|
|
|
|
|
|
if (!ptr.isEmpty())
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// giving up
|
|
|
|
return Ptr();
|
|
|
|
}
|
2014-01-01 01:22:11 +00:00
|
|
|
|
|
|
|
void MWWorld::Cells::getExteriorPtrs(const std::string &name, std::vector<MWWorld::Ptr> &out)
|
|
|
|
{
|
2015-02-04 15:41:14 +00:00
|
|
|
const MWWorld::Store<ESM::Cell> &cells = mStore.get<ESM::Cell>();
|
|
|
|
for (MWWorld::Store<ESM::Cell>::iterator iter = cells.extBegin(); iter != cells.extEnd(); ++iter)
|
2014-01-01 01:22:11 +00:00
|
|
|
{
|
2015-02-04 15:41:14 +00:00
|
|
|
CellStore *cellStore = getCellStore (&(*iter));
|
|
|
|
|
|
|
|
Ptr ptr = getPtrAndCache (name, *cellStore);
|
|
|
|
|
2014-01-01 01:22:11 +00:00
|
|
|
if (!ptr.isEmpty())
|
|
|
|
out.push_back(ptr);
|
|
|
|
}
|
|
|
|
}
|
2014-01-23 10:29:40 +00:00
|
|
|
|
2014-01-11 02:29:41 +00:00
|
|
|
void MWWorld::Cells::getInteriorPtrs(const std::string &name, std::vector<MWWorld::Ptr> &out)
|
|
|
|
{
|
2015-02-04 15:41:14 +00:00
|
|
|
const MWWorld::Store<ESM::Cell> &cells = mStore.get<ESM::Cell>();
|
|
|
|
for (MWWorld::Store<ESM::Cell>::iterator iter = cells.intBegin(); iter != cells.intEnd(); ++iter)
|
2014-01-11 02:29:41 +00:00
|
|
|
{
|
2015-02-04 15:41:14 +00:00
|
|
|
CellStore *cellStore = getCellStore (&(*iter));
|
|
|
|
|
|
|
|
Ptr ptr = getPtrAndCache (name, *cellStore);
|
|
|
|
|
2014-01-11 02:29:41 +00:00
|
|
|
if (!ptr.isEmpty())
|
|
|
|
out.push_back(ptr);
|
|
|
|
}
|
|
|
|
}
|
2014-01-24 17:21:52 +00:00
|
|
|
|
2014-01-23 10:29:40 +00:00
|
|
|
int MWWorld::Cells::countSavedGameRecords() const
|
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
for (std::map<std::string, CellStore>::const_iterator iter (mInteriors.begin());
|
|
|
|
iter!=mInteriors.end(); ++iter)
|
2014-02-24 09:03:04 +00:00
|
|
|
if (iter->second.hasState())
|
2014-01-23 10:29:40 +00:00
|
|
|
++count;
|
|
|
|
|
|
|
|
for (std::map<std::pair<int, int>, CellStore>::const_iterator iter (mExteriors.begin());
|
|
|
|
iter!=mExteriors.end(); ++iter)
|
2014-02-24 09:03:04 +00:00
|
|
|
if (iter->second.hasState())
|
2014-01-23 10:29:40 +00:00
|
|
|
++count;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2014-04-28 09:29:57 +00:00
|
|
|
void MWWorld::Cells::write (ESM::ESMWriter& writer, Loading::Listener& progress) const
|
2014-01-23 10:29:40 +00:00
|
|
|
{
|
2014-02-24 09:03:04 +00:00
|
|
|
for (std::map<std::pair<int, int>, CellStore>::iterator iter (mExteriors.begin());
|
2014-01-23 10:29:40 +00:00
|
|
|
iter!=mExteriors.end(); ++iter)
|
2014-02-24 09:03:04 +00:00
|
|
|
if (iter->second.hasState())
|
2014-04-28 09:29:57 +00:00
|
|
|
{
|
2014-01-23 10:29:40 +00:00
|
|
|
writeCell (writer, iter->second);
|
2015-01-11 17:01:06 +00:00
|
|
|
progress.increaseProgress();
|
2014-04-28 09:29:57 +00:00
|
|
|
}
|
2014-01-23 10:29:40 +00:00
|
|
|
|
2014-02-24 09:03:04 +00:00
|
|
|
for (std::map<std::string, CellStore>::iterator iter (mInteriors.begin());
|
2014-01-23 10:29:40 +00:00
|
|
|
iter!=mInteriors.end(); ++iter)
|
2014-02-24 09:03:04 +00:00
|
|
|
if (iter->second.hasState())
|
2014-04-28 09:29:57 +00:00
|
|
|
{
|
2014-01-23 10:29:40 +00:00
|
|
|
writeCell (writer, iter->second);
|
2015-01-11 17:01:06 +00:00
|
|
|
progress.increaseProgress();
|
2014-04-28 09:29:57 +00:00
|
|
|
}
|
2014-01-23 10:29:40 +00:00
|
|
|
}
|
|
|
|
|
2015-12-06 18:53:06 +00:00
|
|
|
struct GetCellStoreCallback : public MWWorld::CellStore::GetCellStoreCallback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GetCellStoreCallback(MWWorld::Cells& cells)
|
|
|
|
: mCells(cells)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MWWorld::Cells& mCells;
|
|
|
|
|
|
|
|
virtual MWWorld::CellStore* getCellStore(const ESM::CellId& cellId)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return mCells.getCell(cellId);
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
2018-10-09 06:21:12 +00:00
|
|
|
return nullptr;
|
2015-12-06 18:53:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-01-22 18:04:59 +00:00
|
|
|
bool MWWorld::Cells::readRecord (ESM::ESMReader& reader, uint32_t type,
|
2014-01-27 12:27:42 +00:00
|
|
|
const std::map<int, int>& contentFileMap)
|
2014-01-23 10:29:40 +00:00
|
|
|
{
|
|
|
|
if (type==ESM::REC_CSTA)
|
|
|
|
{
|
|
|
|
ESM::CellState state;
|
|
|
|
state.mId.load (reader);
|
|
|
|
|
|
|
|
CellStore *cellStore = 0;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
cellStore = getCell (state.mId);
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
// silently drop cells that don't exist anymore
|
2018-08-14 19:05:43 +00:00
|
|
|
Log(Debug::Warning) << "Warning: Dropping state for cell " << state.mId.mWorldspace << " (cell no longer exists)";
|
2014-06-01 21:11:38 +00:00
|
|
|
reader.skipRecord();
|
|
|
|
return true;
|
2014-01-23 10:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
state.load (reader);
|
|
|
|
cellStore->loadState (state);
|
2014-01-27 12:27:42 +00:00
|
|
|
|
2014-05-11 00:07:28 +00:00
|
|
|
if (state.mHasFogOfWar)
|
|
|
|
cellStore->readFog(reader);
|
|
|
|
|
2014-02-23 13:26:36 +00:00
|
|
|
if (cellStore->getState()!=CellStore::State_Loaded)
|
2015-12-06 17:03:55 +00:00
|
|
|
cellStore->load ();
|
2014-01-27 12:27:42 +00:00
|
|
|
|
2015-12-06 18:53:06 +00:00
|
|
|
GetCellStoreCallback callback(*this);
|
|
|
|
|
|
|
|
cellStore->readReferences (reader, contentFileMap, &callback);
|
2014-01-23 10:29:40 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2014-01-24 17:21:52 +00:00
|
|
|
}
|