Write moved references to the save game file (not resolved on loading yet)

This commit is contained in:
scrawl 2015-12-06 19:11:25 +01:00
parent 2219231230
commit 671561ea37
5 changed files with 27 additions and 6 deletions

View file

@ -119,7 +119,6 @@ MWWorld::CellStore *MWWorld::Cells::getExterior (int x, int y)
if (result->second.getState()!=CellStore::State_Loaded)
{
// Multiple plugin support for landscape data is much easier than for references. The last plugin wins.
result->second.load ();
}

View file

@ -636,7 +636,15 @@ namespace MWWorld
writeReferenceCollection<ESM::ObjectState> (writer, mStatics);
writeReferenceCollection<ESM::ObjectState> (writer, mWeapons);
// TODO: write moved references
for (MovedRefTracker::const_iterator it = mMovedToAnotherCell.begin(); it != mMovedToAnotherCell.end(); ++it)
{
LiveCellRefBase* base = it->first;
ESM::RefNum refNum = base->mRef.getRefNum();
ESM::CellId movedTo = it->second->getCell()->getCellId();
refNum.save(writer, true, "MVRF");
movedTo.save(writer);
}
}
void CellStore::readReferences (ESM::ESMReader& reader,
@ -770,6 +778,18 @@ namespace MWWorld
throw std::runtime_error ("unknown type in cell reference section");
}
}
while (reader.isNextSub("MVRF"))
{
reader.cacheSubName();
ESM::RefNum refnum;
ESM::CellId movedTo;
refnum.load(reader, true, "MVRF");
movedTo.load(reader);
std::cout << "moved to " << movedTo.mWorldspace << " " << movedTo.mIndex.mX << " " << movedTo.mIndex.mY << std::endl;
}
updateMergedRefs();
}

View file

@ -12,6 +12,8 @@
#include "livecellref.hpp"
#include "cellreflist.hpp"
#include <components/esm/cellid.hpp>
#include <components/esm/loadacti.hpp>
#include <components/esm/loadalch.hpp>
#include <components/esm/loadappa.hpp>

View file

@ -3,12 +3,12 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
void ESM::RefNum::load (ESMReader& esm, bool wide)
void ESM::RefNum::load (ESMReader& esm, bool wide, const std::string& tag)
{
if (wide)
esm.getHNT (*this, "FRMR", 8);
esm.getHNT (*this, tag.c_str(), 8);
else
esm.getHNT (mIndex, "FRMR");
esm.getHNT (mIndex, tag.c_str());
}
void ESM::RefNum::save (ESMWriter &esm, bool wide, const std::string& tag) const

View file

@ -16,7 +16,7 @@ namespace ESM
unsigned int mIndex;
int mContentFile;
void load (ESMReader& esm, bool wide = false);
void load (ESMReader& esm, bool wide = false, const std::string& tag = "FRMR");
void save (ESMWriter &esm, bool wide = false, const std::string& tag = "FRMR") const;