2013-07-06 15:03:18 +00:00
|
|
|
|
|
|
|
#include "refcollection.hpp"
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#include "ref.hpp"
|
|
|
|
#include "cell.hpp"
|
2014-01-21 20:37:21 +00:00
|
|
|
#include "universalid.hpp"
|
|
|
|
#include "record.hpp"
|
2013-07-06 15:03:18 +00:00
|
|
|
|
|
|
|
void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base)
|
|
|
|
{
|
|
|
|
Record<Cell> cell = mCells.getRecord (cellIndex);
|
|
|
|
|
|
|
|
Cell& cell2 = base ? cell.mBase : cell.mModified;
|
|
|
|
|
|
|
|
CellRef ref;
|
|
|
|
|
|
|
|
while (cell2.getNextRef (reader, ref))
|
|
|
|
{
|
|
|
|
/// \todo handle deleted and moved references
|
2013-07-30 10:53:03 +00:00
|
|
|
ref.load (reader, cell2, getNewId());
|
2013-07-06 15:03:18 +00:00
|
|
|
|
|
|
|
Record<CellRef> record2;
|
|
|
|
record2.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
|
|
|
|
(base ? record2.mBase : record2.mModified) = ref;
|
|
|
|
|
|
|
|
appendRecord (record2);
|
|
|
|
}
|
|
|
|
|
|
|
|
mCells.setRecord (cellIndex, cell);
|
2013-07-30 10:53:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string CSMWorld::RefCollection::getNewId()
|
|
|
|
{
|
|
|
|
std::ostringstream stream;
|
|
|
|
stream << "ref#" << mNextId++;
|
|
|
|
return stream.str();
|
2014-01-21 20:37:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSMWorld::RefCollection::cloneRecord(const std::string& origin,
|
|
|
|
const std::string& destination,
|
|
|
|
const CSMWorld::UniversalId::Type type,
|
|
|
|
const CSMWorld::UniversalId::ArgumentType argumentType)
|
|
|
|
{
|
2014-01-23 08:40:32 +00:00
|
|
|
Record<CSMWorld::CellRef> clone(getRecord(origin));
|
|
|
|
clone.mState = CSMWorld::RecordBase::State_ModifiedOnly;
|
|
|
|
clone.get().mId = destination;
|
|
|
|
insertRecord(clone, getAppendIndex(destination, type), type);
|
2013-07-06 15:03:18 +00:00
|
|
|
}
|