forked from teamnwah/openmw-tes3coop
Add saving land and land textures. Should resolve Bug #2447.
This commit is contained in:
parent
8e37e9a14a
commit
589b0b9171
3 changed files with 104 additions and 0 deletions
|
@ -93,6 +93,10 @@ CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& proje
|
||||||
|
|
||||||
appendStage (new WritePathgridCollectionStage (mDocument, mState));
|
appendStage (new WritePathgridCollectionStage (mDocument, mState));
|
||||||
|
|
||||||
|
appendStage (new WriteLandCollectionStage (mDocument, mState));
|
||||||
|
|
||||||
|
appendStage (new WriteLandTextureCollectionStage (mDocument, mState));
|
||||||
|
|
||||||
// close file and clean up
|
// close file and clean up
|
||||||
appendStage (new CloseSaveStage (mState));
|
appendStage (new CloseSaveStage (mState));
|
||||||
|
|
||||||
|
|
|
@ -353,6 +353,72 @@ void CSMDoc::WritePathgridCollectionStage::perform (int stage, Messages& message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CSMDoc::WriteLandCollectionStage::WriteLandCollectionStage (Document& document,
|
||||||
|
SavingState& state)
|
||||||
|
: mDocument (document), mState (state)
|
||||||
|
{}
|
||||||
|
|
||||||
|
int CSMDoc::WriteLandCollectionStage::setup()
|
||||||
|
{
|
||||||
|
return mDocument.getData().getLand().getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMDoc::WriteLandCollectionStage::perform (int stage, Messages& messages)
|
||||||
|
{
|
||||||
|
const CSMWorld::Record<CSMWorld::Land>& land =
|
||||||
|
mDocument.getData().getLand().getRecord (stage);
|
||||||
|
|
||||||
|
if (land.mState==CSMWorld::RecordBase::State_Modified ||
|
||||||
|
land.mState==CSMWorld::RecordBase::State_ModifiedOnly)
|
||||||
|
{
|
||||||
|
CSMWorld::Land record = land.get();
|
||||||
|
|
||||||
|
mState.getWriter().startRecord (record.mLand->sRecordId);
|
||||||
|
|
||||||
|
record.mLand->save (mState.getWriter());
|
||||||
|
|
||||||
|
mState.getWriter().endRecord (record.mLand->sRecordId);
|
||||||
|
}
|
||||||
|
else if (land.mState==CSMWorld::RecordBase::State_Deleted)
|
||||||
|
{
|
||||||
|
/// \todo write record with delete flag
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CSMDoc::WriteLandTextureCollectionStage::WriteLandTextureCollectionStage (Document& document,
|
||||||
|
SavingState& state)
|
||||||
|
: mDocument (document), mState (state)
|
||||||
|
{}
|
||||||
|
|
||||||
|
int CSMDoc::WriteLandTextureCollectionStage::setup()
|
||||||
|
{
|
||||||
|
return mDocument.getData().getLandTextures().getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMDoc::WriteLandTextureCollectionStage::perform (int stage, Messages& messages)
|
||||||
|
{
|
||||||
|
const CSMWorld::Record<CSMWorld::LandTexture>& landTexture =
|
||||||
|
mDocument.getData().getLandTextures().getRecord (stage);
|
||||||
|
|
||||||
|
if (landTexture.mState==CSMWorld::RecordBase::State_Modified ||
|
||||||
|
landTexture.mState==CSMWorld::RecordBase::State_ModifiedOnly)
|
||||||
|
{
|
||||||
|
CSMWorld::LandTexture record = landTexture.get();
|
||||||
|
|
||||||
|
mState.getWriter().startRecord (record.sRecordId);
|
||||||
|
|
||||||
|
record.save (mState.getWriter());
|
||||||
|
|
||||||
|
mState.getWriter().endRecord (record.sRecordId);
|
||||||
|
}
|
||||||
|
else if (landTexture.mState==CSMWorld::RecordBase::State_Deleted)
|
||||||
|
{
|
||||||
|
/// \todo write record with delete flag
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CSMDoc::CloseSaveStage::CloseSaveStage (SavingState& state)
|
CSMDoc::CloseSaveStage::CloseSaveStage (SavingState& state)
|
||||||
: mState (state)
|
: mState (state)
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -209,6 +209,40 @@ namespace CSMDoc
|
||||||
///< Messages resulting from this stage will be appended to \a messages.
|
///< Messages resulting from this stage will be appended to \a messages.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class WriteLandCollectionStage : public Stage
|
||||||
|
{
|
||||||
|
Document& mDocument;
|
||||||
|
SavingState& mState;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
WriteLandCollectionStage (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 WriteLandTextureCollectionStage : public Stage
|
||||||
|
{
|
||||||
|
Document& mDocument;
|
||||||
|
SavingState& mState;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
WriteLandTextureCollectionStage (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
|
class CloseSaveStage : public Stage
|
||||||
{
|
{
|
||||||
SavingState& mState;
|
SavingState& mState;
|
||||||
|
|
Loading…
Reference in a new issue