implemented reference record deleting

deque
Marc Zinnschlag 11 years ago
parent d8440e1fdc
commit e0b6bf6aeb

@ -539,7 +539,7 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Stage::Messages& messages)
{
mCells.load (*mReader, mBase);
std::string cellId = Misc::StringUtils::lowerCase (mCells.getId (mCells.getSize()-1));
mRefs.load (*mReader, mCells.getSize()-1, mBase, mRefLoadCache[cellId]);
mRefs.load (*mReader, mCells.getSize()-1, mBase, mRefLoadCache[cellId], messages);
break;
}

@ -11,7 +11,7 @@
#include "record.hpp"
void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool base,
std::map<ESM::CellRef::RefNum, std::string>& cache)
std::map<ESM::CellRef::RefNum, std::string>& cache, CSMDoc::Stage::Messages& messages)
{
Record<Cell> cell = mCells.getRecord (cellIndex);
@ -27,14 +27,39 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
/// \todo handle moved references
std::map<ESM::CellRef::RefNum, std::string>::iterator iter = cache.find (ref.mRefNum);
if (deleted)
{
/// \todo handle deleted references
if (iter==cache.end())
{
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Cell,
mCells.getId (cellIndex));
messages.push_back (std::make_pair (id,
"Attempt to delete a non-existing reference"));
continue;
}
int index = getIndex (iter->second);
Record<CellRef> record = getRecord (index);
if (record.mState==RecordBase::State_BaseOnly)
{
removeRows (index, 1);
cache.erase (iter);
}
else
{
record.mState = RecordBase::State_Deleted;
setRecord (index, record);
}
continue;
}
std::map<ESM::CellRef::RefNum, std::string>::iterator iter = cache.find (ref.mRefNum);
if (iter==cache.end())
{
// new reference

@ -3,6 +3,8 @@
#include <map>
#include "../doc/stage.hpp"
#include "collection.hpp"
#include "ref.hpp"
#include "record.hpp"
@ -25,7 +27,8 @@ namespace CSMWorld
{}
void load (ESM::ESMReader& reader, int cellIndex, bool base,
std::map<ESM::CellRef::RefNum, std::string>& cache);
std::map<ESM::CellRef::RefNum, std::string>& cache,
CSMDoc::Stage::Messages& messages);
///< Load a sequence of references.
std::string getNewId();

Loading…
Cancel
Save