|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
|
|
|
|
|
#include "mergestages.hpp"
|
|
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
|
|
#include <components/misc/stringops.hpp>
|
|
|
|
|
|
|
|
|
|
#include "mergestate.hpp"
|
|
|
|
@ -104,3 +106,80 @@ void CSMTools::MergeReferencesStage::perform (int stage, CSMDoc::Messages& messa
|
|
|
|
|
mState.mTarget->getData().getReferences().appendRecord (newRecord);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CSMTools::ListLandTexturesMergeStage::ListLandTexturesMergeStage (MergeState& state)
|
|
|
|
|
: mState (state)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
int CSMTools::ListLandTexturesMergeStage::setup()
|
|
|
|
|
{
|
|
|
|
|
return mState.mSource.getData().getLand().getSize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMTools::ListLandTexturesMergeStage::perform (int stage, CSMDoc::Messages& messages)
|
|
|
|
|
{
|
|
|
|
|
const CSMWorld::Record<CSMWorld::Land>& record =
|
|
|
|
|
mState.mSource.getData().getLand().getRecord (stage);
|
|
|
|
|
|
|
|
|
|
if (!record.isDeleted())
|
|
|
|
|
{
|
|
|
|
|
ESM::Land& land = *record.get().mLand;
|
|
|
|
|
|
|
|
|
|
// make sure record is loaded
|
|
|
|
|
land.loadData (ESM::Land::DATA_VHGT | ESM::Land::DATA_VNML |
|
|
|
|
|
ESM::Land::DATA_VCLR | ESM::Land::DATA_VTEX | ESM::Land::DATA_WNAM);
|
|
|
|
|
|
|
|
|
|
if (land.mLandData)
|
|
|
|
|
{
|
|
|
|
|
// list texture indices
|
|
|
|
|
std::pair<uint16_t, int> key;
|
|
|
|
|
key.second = land.mPlugin;
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<ESM::Land::LAND_NUM_TEXTURES; ++i)
|
|
|
|
|
{
|
|
|
|
|
key.first = land.mLandData->mTextures[i];
|
|
|
|
|
|
|
|
|
|
mState.mTextureIndices[key] = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CSMTools::MergeLandTexturesStage::MergeLandTexturesStage (MergeState& state)
|
|
|
|
|
: mState (state), mNext (mState.mTextureIndices.end())
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
int CSMTools::MergeLandTexturesStage::setup()
|
|
|
|
|
{
|
|
|
|
|
mNext = mState.mTextureIndices.begin();
|
|
|
|
|
return mState.mTextureIndices.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMTools::MergeLandTexturesStage::perform (int stage, CSMDoc::Messages& messages)
|
|
|
|
|
{
|
|
|
|
|
mNext->second = stage;
|
|
|
|
|
|
|
|
|
|
std::ostringstream stream;
|
|
|
|
|
stream << mNext->first.first << "_" << mNext->first.second;
|
|
|
|
|
|
|
|
|
|
int index = mState.mSource.getData().getLandTextures().searchId (stream.str());
|
|
|
|
|
|
|
|
|
|
if (index!=-1)
|
|
|
|
|
{
|
|
|
|
|
CSMWorld::LandTexture texture =
|
|
|
|
|
mState.mSource.getData().getLandTextures().getRecord (index).get();
|
|
|
|
|
|
|
|
|
|
texture.mIndex = mNext->second;
|
|
|
|
|
texture.mId = stream.str();
|
|
|
|
|
|
|
|
|
|
CSMWorld::Record<CSMWorld::LandTexture> newRecord (
|
|
|
|
|
CSMWorld::RecordBase::State_ModifiedOnly, 0, &texture);
|
|
|
|
|
|
|
|
|
|
mState.mTarget->getData().getLandTextures().appendRecord (newRecord);
|
|
|
|
|
}
|
|
|
|
|
/// \todo deal with missing textures (either abort merge or report and make sure OpenMW can deal with missing textures)
|
|
|
|
|
|
|
|
|
|
++mNext;
|
|
|
|
|
}
|
|
|
|
|