mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 03:15:32 +00:00
parent
ce34daa64b
commit
25952369ae
5 changed files with 115 additions and 4 deletions
|
@ -40,10 +40,9 @@ CSMTools::MergeOperation::MergeOperation (CSMDoc::Document& document, ToUTF8::Fr
|
|||
appendStage (new MergeReferencesStage (mState));
|
||||
appendStage (new ListLandTexturesMergeStage (mState));
|
||||
appendStage (new MergeLandTexturesStage (mState));
|
||||
appendStage (new MergeLandStage (mState));
|
||||
|
||||
appendStage (new FinishMergedDocumentStage (mState, encoding));
|
||||
|
||||
/// \todo Land
|
||||
}
|
||||
|
||||
void CSMTools::MergeOperation::setTarget (std::auto_ptr<CSMDoc::Document> document)
|
||||
|
|
|
@ -153,12 +153,20 @@ CSMTools::MergeLandTexturesStage::MergeLandTexturesStage (MergeState& state)
|
|||
|
||||
int CSMTools::MergeLandTexturesStage::setup()
|
||||
{
|
||||
mNext = mState.mTextureIndices.begin();
|
||||
return mState.mTextureIndices.size();
|
||||
// Should use the size of mState.mTextureIndices instead, but that is not available at this
|
||||
// point. Unless there are any errors in the land and land texture records this will not
|
||||
// make a difference.
|
||||
return mState.mSource.getData().getLandTextures().getSize();
|
||||
}
|
||||
|
||||
void CSMTools::MergeLandTexturesStage::perform (int stage, CSMDoc::Messages& messages)
|
||||
{
|
||||
if (stage==0)
|
||||
mNext = mState.mTextureIndices.begin();
|
||||
|
||||
if (mNext==mState.mTextureIndices.end())
|
||||
return;
|
||||
|
||||
mNext->second = stage;
|
||||
|
||||
std::ostringstream stream;
|
||||
|
@ -183,3 +191,55 @@ void CSMTools::MergeLandTexturesStage::perform (int stage, CSMDoc::Messages& mes
|
|||
|
||||
++mNext;
|
||||
}
|
||||
|
||||
|
||||
CSMTools::MergeLandStage::MergeLandStage (MergeState& state) : mState (state) {}
|
||||
|
||||
int CSMTools::MergeLandStage::setup()
|
||||
{
|
||||
return mState.mSource.getData().getLand().getSize();
|
||||
}
|
||||
|
||||
void CSMTools::MergeLandStage::perform (int stage, CSMDoc::Messages& messages)
|
||||
{
|
||||
const CSMWorld::Record<CSMWorld::Land>& record =
|
||||
mState.mSource.getData().getLand().getRecord (stage);
|
||||
|
||||
if (!record.isDeleted())
|
||||
{
|
||||
const CSMWorld::Land& land = record.get();
|
||||
|
||||
land.loadData (ESM::Land::DATA_VCLR | ESM::Land::DATA_VHGT | ESM::Land::DATA_VNML |
|
||||
ESM::Land::DATA_VTEX | ESM::Land::DATA_WNAM);
|
||||
|
||||
CSMWorld::Land newLand (land);
|
||||
|
||||
newLand.mEsm = 0; // avoid potential dangling pointer (ESMReader isn't needed anyway,
|
||||
// because record is already fully loaded)
|
||||
newLand.mPlugin = 0;
|
||||
|
||||
// adjust land texture references
|
||||
if (ESM::Land::LandData *data = newLand.getLandData())
|
||||
{
|
||||
std::pair<uint16_t, int> key;
|
||||
key.second = land.mPlugin;
|
||||
|
||||
for (int i=0; i<ESM::Land::LAND_NUM_TEXTURES; ++i)
|
||||
{
|
||||
key.first = data->mTextures[i];
|
||||
std::map<std::pair<uint16_t, int>, int>::const_iterator iter =
|
||||
mState.mTextureIndices.find (key);
|
||||
|
||||
if (iter!=mState.mTextureIndices.end())
|
||||
data->mTextures[i] = iter->second;
|
||||
else
|
||||
data->mTextures[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
CSMWorld::Record<CSMWorld::Land> newRecord (
|
||||
CSMWorld::RecordBase::State_ModifiedOnly, 0, &newLand);
|
||||
|
||||
mState.mTarget->getData().getLand().appendRecord (newRecord);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,6 +146,21 @@ namespace CSMTools
|
|||
virtual void perform (int stage, CSMDoc::Messages& messages);
|
||||
///< Messages resulting from this stage will be appended to \a messages.
|
||||
};
|
||||
|
||||
class MergeLandStage : public CSMDoc::Stage
|
||||
{
|
||||
MergeState& mState;
|
||||
|
||||
public:
|
||||
|
||||
MergeLandStage (MergeState& state);
|
||||
|
||||
virtual int setup();
|
||||
///< \return number of steps
|
||||
|
||||
virtual void perform (int stage, CSMDoc::Messages& messages);
|
||||
///< Messages resulting from this stage will be appended to \a messages.
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -256,4 +256,30 @@ bool Land::isDataLoaded(int flags) const
|
|||
{
|
||||
return mLandData;
|
||||
}
|
||||
|
||||
Land::LandData *Land::getLandData()
|
||||
{
|
||||
return mLandData;
|
||||
}
|
||||
|
||||
void Land::add (int flags)
|
||||
{
|
||||
if (!mLandData)
|
||||
mLandData = new LandData;
|
||||
|
||||
mDataTypes |= flags;
|
||||
mDataLoaded |= flags;
|
||||
}
|
||||
|
||||
void Land::remove (int flags)
|
||||
{
|
||||
mDataTypes &= ~flags;
|
||||
mDataLoaded &= ~flags;
|
||||
|
||||
if (!mDataLoaded)
|
||||
{
|
||||
delete mLandData;
|
||||
mLandData = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,6 +127,17 @@ struct Land
|
|||
/// Return land data without loading first anything. Can return a 0-pointer.
|
||||
const LandData *getLandData() const;
|
||||
|
||||
/// Return land data without loading first anything. Can return a 0-pointer.
|
||||
LandData *getLandData();
|
||||
|
||||
/// \attention Must not be called on objects that aren't fully loaded.
|
||||
///
|
||||
/// \note Added data fields will be uninitialised
|
||||
void add (int flags);
|
||||
|
||||
/// \attention Must not be called on objects that aren't fully loaded.
|
||||
void remove (int flags);
|
||||
|
||||
private:
|
||||
|
||||
/// Loads data and marks it as loaded
|
||||
|
|
Loading…
Reference in a new issue