forked from teamnwah/openmw-tes3coop
merge references tables
This commit is contained in:
parent
845cafd61c
commit
a97a632aa7
3 changed files with 53 additions and 2 deletions
|
@ -35,8 +35,9 @@ CSMTools::MergeOperation::MergeOperation (CSMDoc::Document& document, ToUTF8::Fr
|
||||||
appendStage (new MergeIdCollectionStage<CSMWorld::Info, CSMWorld::InfoCollection> (mState, &CSMWorld::Data::getTopicInfos));
|
appendStage (new MergeIdCollectionStage<CSMWorld::Info, CSMWorld::InfoCollection> (mState, &CSMWorld::Data::getTopicInfos));
|
||||||
appendStage (new MergeIdCollectionStage<CSMWorld::Info, CSMWorld::InfoCollection> (mState, &CSMWorld::Data::getJournalInfos));
|
appendStage (new MergeIdCollectionStage<CSMWorld::Info, CSMWorld::InfoCollection> (mState, &CSMWorld::Data::getJournalInfos));
|
||||||
appendStage (new MergeRefIdsStage (mState));
|
appendStage (new MergeRefIdsStage (mState));
|
||||||
|
appendStage (new MergeReferencesStage (mState));
|
||||||
|
|
||||||
/// \todo References, Land, LandTextures
|
/// \todo Land, LandTextures
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMTools::MergeOperation::setTarget (std::auto_ptr<CSMDoc::Document> document)
|
void CSMTools::MergeOperation::setTarget (std::auto_ptr<CSMDoc::Document> document)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
#include "mergestages.hpp"
|
#include "mergestages.hpp"
|
||||||
|
|
||||||
|
#include <components/misc/stringops.hpp>
|
||||||
|
|
||||||
#include "mergestate.hpp"
|
#include "mergestate.hpp"
|
||||||
|
|
||||||
#include "../doc/document.hpp"
|
#include "../doc/document.hpp"
|
||||||
|
@ -53,3 +55,35 @@ void CSMTools::MergeRefIdsStage::perform (int stage, CSMDoc::Messages& messages)
|
||||||
mState.mSource.getData().getReferenceables().copyTo (
|
mState.mSource.getData().getReferenceables().copyTo (
|
||||||
stage, mState.mTarget->getData().getReferenceables());
|
stage, mState.mTarget->getData().getReferenceables());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CSMTools::MergeReferencesStage::MergeReferencesStage (MergeState& state)
|
||||||
|
: mState (state)
|
||||||
|
{}
|
||||||
|
|
||||||
|
int CSMTools::MergeReferencesStage::setup()
|
||||||
|
{
|
||||||
|
mIndex.clear();
|
||||||
|
return mState.mSource.getData().getReferences().getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMTools::MergeReferencesStage::perform (int stage, CSMDoc::Messages& messages)
|
||||||
|
{
|
||||||
|
const CSMWorld::Record<CSMWorld::CellRef>& record =
|
||||||
|
mState.mSource.getData().getReferences().getRecord (stage);
|
||||||
|
|
||||||
|
if (!record.isDeleted())
|
||||||
|
{
|
||||||
|
CSMWorld::CellRef ref = record.get();
|
||||||
|
|
||||||
|
ref.mOriginalCell = ref.mCell;
|
||||||
|
|
||||||
|
ref.mRefNum.mIndex = mIndex[Misc::StringUtils::lowerCase (ref.mCell)]++;
|
||||||
|
ref.mRefNum.mContentFile = 0;
|
||||||
|
|
||||||
|
CSMWorld::Record<CSMWorld::CellRef> newRecord (
|
||||||
|
CSMWorld::RecordBase::State_ModifiedOnly, 0, &ref);
|
||||||
|
|
||||||
|
mState.mTarget->getData().getReferences().appendRecord (newRecord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define CSM_TOOLS_MERGESTAGES_H
|
#define CSM_TOOLS_MERGESTAGES_H
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include <components/to_utf8/to_utf8.hpp>
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
|
@ -69,7 +70,6 @@ namespace CSMTools
|
||||||
target.appendRecord (CSMWorld::Record<RecordType> (CSMWorld::RecordBase::State_ModifiedOnly, 0, &record.get()));
|
target.appendRecord (CSMWorld::Record<RecordType> (CSMWorld::RecordBase::State_ModifiedOnly, 0, &record.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class MergeRefIdsStage : public CSMDoc::Stage
|
class MergeRefIdsStage : public CSMDoc::Stage
|
||||||
{
|
{
|
||||||
MergeState& mState;
|
MergeState& mState;
|
||||||
|
@ -84,6 +84,22 @@ namespace CSMTools
|
||||||
virtual void perform (int stage, CSMDoc::Messages& messages);
|
virtual void perform (int stage, CSMDoc::Messages& messages);
|
||||||
///< Messages resulting from this stage will be appended to \a messages.
|
///< Messages resulting from this stage will be appended to \a messages.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MergeReferencesStage : public CSMDoc::Stage
|
||||||
|
{
|
||||||
|
MergeState& mState;
|
||||||
|
std::map<std::string, int> mIndex;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
MergeReferencesStage (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
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue