1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-04-02 14:36:42 +00:00

fixed moved reference loading

This commit is contained in:
Marc Zinnschlag 2015-01-24 15:01:38 +01:00
parent 89998a6a03
commit 7f905470fa
4 changed files with 21 additions and 10 deletions
apps/opencs/model/world
components/esm

View file

@ -21,7 +21,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
bool deleted = false; bool deleted = false;
while (ESM::Cell::getNextRef (reader, ref, deleted)) while (ESM::Cell::getNextRef (reader, ref, deleted, true))
{ {
// Keep mOriginalCell empty when in modified (as an indicator that the // Keep mOriginalCell empty when in modified (as an indicator that the
// original cell will always be equal the current cell). // original cell will always be equal the current cell).
@ -29,7 +29,6 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
if (cell.get().isExterior()) if (cell.get().isExterior())
{ {
// ignoring moved references sub-record; instead calculate cell from coordinates // ignoring moved references sub-record; instead calculate cell from coordinates
std::pair<int, int> index = ref.getCellIndex(); std::pair<int, int> index = ref.getCellIndex();

View file

@ -25,7 +25,7 @@ void ESM::RefNum::save (ESMWriter &esm, bool wide, const std::string& tag) const
} }
void ESM::CellRef::load (ESMReader& esm, bool wideRefNum) void ESM::CellRef::load (ESMReader& esm, bool wideRefNum, bool ignoreRefNum)
{ {
// According to Hrnchamd, this does not belong to the actual ref. Instead, it is a marker indicating that // According to Hrnchamd, this does not belong to the actual ref. Instead, it is a marker indicating that
// the following refs are part of a "temp refs" section. A temp ref is not being tracked by the moved references system. // the following refs are part of a "temp refs" section. A temp ref is not being tracked by the moved references system.
@ -34,7 +34,8 @@ void ESM::CellRef::load (ESMReader& esm, bool wideRefNum)
if (esm.isNextSub ("NAM0")) if (esm.isNextSub ("NAM0"))
esm.skipHSub(); esm.skipHSub();
mRefNum.load (esm, wideRefNum); if (!ignoreRefNum)
mRefNum.load (esm, wideRefNum);
mRefID = esm.getHNString ("NAME"); mRefID = esm.getHNString ("NAME");

View file

@ -168,7 +168,7 @@ std::string Cell::getDescription() const
} }
} }
bool Cell::getNextRef(ESMReader &esm, CellRef &ref, bool& deleted) bool Cell::getNextRef(ESMReader &esm, CellRef &ref, bool& deleted, bool ignoreMoves)
{ {
// TODO: Try and document reference numbering, I don't think this has been done anywhere else. // TODO: Try and document reference numbering, I don't think this has been done anywhere else.
if (!esm.hasMoreSubs()) if (!esm.hasMoreSubs())
@ -176,10 +176,20 @@ bool Cell::getNextRef(ESMReader &esm, CellRef &ref, bool& deleted)
// NOTE: We should not need this check. It is a safety check until we have checked // NOTE: We should not need this check. It is a safety check until we have checked
// more plugins, and how they treat these moved references. // more plugins, and how they treat these moved references.
if (esm.isNextSub("MVRF")) { if (esm.isNextSub("MVRF"))
// skip rest of cell record (moved references), they are handled elsewhere {
esm.skipRecord(); // skip MVRF, CNDT if (ignoreMoves)
return false; {
MovedCellRef mref;
esm.getHT (mref.mRefNum.mIndex);
esm.getHNOT (mref.mTarget, "CNDT");
}
else
{
// skip rest of cell record (moved references), they are handled elsewhere
esm.skipRecord(); // skip MVRF, CNDT
return false;
}
} }
ref.load (esm); ref.load (esm);

View file

@ -156,7 +156,8 @@ struct Cell
All fields of the CellRef struct are overwritten. You can safely All fields of the CellRef struct are overwritten. You can safely
reuse one memory location without blanking it between calls. reuse one memory location without blanking it between calls.
*/ */
static bool getNextRef(ESMReader &esm, CellRef &ref, bool& deleted); /// \param ignoreMoves ignore MVRF record and read reference like a regular CellRef.
static bool getNextRef(ESMReader &esm, CellRef &ref, bool& deleted, bool ignoreMoves = false);
/* This fetches an MVRF record, which is used to track moved references. /* This fetches an MVRF record, which is used to track moved references.
* Since they are comparably rare, we use a separate method for this. * Since they are comparably rare, we use a separate method for this.