forked from mirror/openmw-tes3mp
fixed pathgrid saving
This commit is contained in:
parent
be3b229a5f
commit
2d3ffc4483
3 changed files with 58 additions and 2 deletions
|
@ -78,8 +78,7 @@ CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& proje
|
|||
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::MagicEffect> >
|
||||
(mDocument.getData().getMagicEffects(), mState));
|
||||
|
||||
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<CSMWorld::Pathgrid> >
|
||||
(mDocument.getData().getPathgrids(), mState));
|
||||
appendStage (new WritePathgridCollectionStage (mDocument, mState));
|
||||
|
||||
appendStage (new WriteDialogueCollectionStage (mDocument, mState, false));
|
||||
|
||||
|
|
|
@ -311,6 +311,46 @@ void CSMDoc::WriteCellCollectionStage::perform (int stage, Messages& messages)
|
|||
}
|
||||
|
||||
|
||||
CSMDoc::WritePathgridCollectionStage::WritePathgridCollectionStage (Document& document,
|
||||
SavingState& state)
|
||||
: mDocument (document), mState (state)
|
||||
{}
|
||||
|
||||
int CSMDoc::WritePathgridCollectionStage::setup()
|
||||
{
|
||||
return mDocument.getData().getPathgrids().getSize();
|
||||
}
|
||||
|
||||
void CSMDoc::WritePathgridCollectionStage::perform (int stage, Messages& messages)
|
||||
{
|
||||
const CSMWorld::Record<CSMWorld::Pathgrid>& pathgrid =
|
||||
mDocument.getData().getPathgrids().getRecord (stage);
|
||||
|
||||
if (pathgrid.mState==CSMWorld::RecordBase::State_Modified ||
|
||||
pathgrid.mState==CSMWorld::RecordBase::State_ModifiedOnly)
|
||||
{
|
||||
CSMWorld::Pathgrid record = pathgrid.get();
|
||||
|
||||
if (record.mId.substr (0, 1)=="#")
|
||||
{
|
||||
std::istringstream stream (record.mId.c_str());
|
||||
char ignore;
|
||||
stream >> ignore >> record.mData.mX >> record.mData.mY;
|
||||
}
|
||||
|
||||
mState.getWriter().startRecord (record.sRecordId);
|
||||
|
||||
record.save (mState.getWriter());
|
||||
|
||||
mState.getWriter().endRecord (record.sRecordId);
|
||||
}
|
||||
else if (pathgrid.mState==CSMWorld::RecordBase::State_Deleted)
|
||||
{
|
||||
/// \todo write record with delete flag
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CSMDoc::CloseSaveStage::CloseSaveStage (SavingState& state)
|
||||
: mState (state)
|
||||
{}
|
||||
|
|
|
@ -183,6 +183,23 @@ namespace CSMDoc
|
|||
///< Messages resulting from this stage will be appended to \a messages.
|
||||
};
|
||||
|
||||
|
||||
class WritePathgridCollectionStage : public Stage
|
||||
{
|
||||
Document& mDocument;
|
||||
SavingState& mState;
|
||||
|
||||
public:
|
||||
|
||||
WritePathgridCollectionStage (Document& document, SavingState& state);
|
||||
|
||||
virtual int setup();
|
||||
///< \return number of steps
|
||||
|
||||
virtual void perform (int stage, Messages& messages);
|
||||
///< Messages resulting from this stage will be appended to \a messages.
|
||||
};
|
||||
|
||||
class CloseSaveStage : public Stage
|
||||
{
|
||||
SavingState& mState;
|
||||
|
|
Loading…
Reference in a new issue