mirror of https://github.com/OpenMW/openmw.git
added references table
parent
94ec05c2c6
commit
9a49125281
@ -0,0 +1,39 @@
|
||||
|
||||
#include "refcollection.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "ref.hpp"
|
||||
#include "cell.hpp"
|
||||
|
||||
CSMWorld::RefCollection::RefCollection (Collection<Cell>& cells)
|
||||
: mCells (cells), mNextId (0)
|
||||
{}
|
||||
|
||||
void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base)
|
||||
{
|
||||
Record<Cell> cell = mCells.getRecord (cellIndex);
|
||||
|
||||
Cell& cell2 = base ? cell.mBase : cell.mModified;
|
||||
|
||||
cell2.restore (reader, 0); /// \todo fix the index
|
||||
|
||||
CellRef ref;
|
||||
|
||||
while (cell2.getNextRef (reader, ref))
|
||||
{
|
||||
/// \todo handle deleted and moved references
|
||||
std::ostringstream stream;
|
||||
stream << "ref#" << mNextId++;
|
||||
|
||||
ref.load (reader, cell2, stream.str());
|
||||
|
||||
Record<CellRef> record2;
|
||||
record2.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
|
||||
(base ? record2.mBase : record2.mModified) = ref;
|
||||
|
||||
appendRecord (record2);
|
||||
}
|
||||
|
||||
mCells.setRecord (cellIndex, cell);
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
#ifndef CSM_WOLRD_REFCOLLECTION_H
|
||||
#define CSM_WOLRD_REFCOLLECTION_H
|
||||
|
||||
#include "collection.hpp"
|
||||
#include "ref.hpp"
|
||||
#include "record.hpp"
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
struct Cell;
|
||||
|
||||
/// \brief References in cells
|
||||
class RefCollection : public Collection<CellRef>
|
||||
{
|
||||
Collection<Cell>& mCells;
|
||||
int mNextId;
|
||||
|
||||
public:
|
||||
|
||||
RefCollection (Collection<Cell>& cells);
|
||||
|
||||
void load (ESM::ESMReader& reader, int cellIndex, bool base);
|
||||
///< Load a sequence of references.
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue