forked from mirror/openmw-tes3mp
merge id collections
This commit is contained in:
parent
47dd9505a9
commit
3902513e65
2 changed files with 74 additions and 2 deletions
|
@ -10,6 +10,29 @@ CSMTools::MergeOperation::MergeOperation (CSMDoc::Document& document, ToUTF8::Fr
|
||||||
: CSMDoc::Operation (CSMDoc::State_Merging, true), mState (document)
|
: CSMDoc::Operation (CSMDoc::State_Merging, true), mState (document)
|
||||||
{
|
{
|
||||||
appendStage (new FinishMergedDocumentStage (mState, encoding));
|
appendStage (new FinishMergedDocumentStage (mState, encoding));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::Global> (mState, &CSMWorld::Data::getGlobals));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::GameSetting> (mState, &CSMWorld::Data::getGmsts));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::Skill> (mState, &CSMWorld::Data::getSkills));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::Class> (mState, &CSMWorld::Data::getClasses));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::Faction> (mState, &CSMWorld::Data::getFactions));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::Race> (mState, &CSMWorld::Data::getRaces));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::Sound> (mState, &CSMWorld::Data::getSounds));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::Script> (mState, &CSMWorld::Data::getScripts));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::Region> (mState, &CSMWorld::Data::getRegions));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::BirthSign> (mState, &CSMWorld::Data::getBirthsigns));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::Spell> (mState, &CSMWorld::Data::getSpells));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::Dialogue> (mState, &CSMWorld::Data::getTopics));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::Dialogue> (mState, &CSMWorld::Data::getJournals));
|
||||||
|
appendStage (new MergeIdCollectionStage<CSMWorld::Cell> (mState, &CSMWorld::Data::getCells));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::Filter> (mState, &CSMWorld::Data::getFilters));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::Enchantment> (mState, &CSMWorld::Data::getEnchantments));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::BodyPart> (mState, &CSMWorld::Data::getBodyParts));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::DebugProfile> (mState, &CSMWorld::Data::getDebugProfiles));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::SoundGenerator> (mState, &CSMWorld::Data::getSoundGens));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::MagicEffect> (mState, &CSMWorld::Data::getMagicEffects));
|
||||||
|
appendStage (new MergeIdCollectionStage<ESM::StartScript> (mState, &CSMWorld::Data::getStartScripts));
|
||||||
|
|
||||||
|
/// \todo TopicInfo, JournalInfo, Referencables, References, Land, LandTextures, Pathgrids
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMTools::MergeOperation::setTarget (std::auto_ptr<CSMDoc::Document> document)
|
void CSMTools::MergeOperation::setTarget (std::auto_ptr<CSMDoc::Document> document)
|
||||||
|
|
|
@ -5,10 +5,12 @@
|
||||||
|
|
||||||
#include "../doc/stage.hpp"
|
#include "../doc/stage.hpp"
|
||||||
|
|
||||||
|
#include "../world/data.hpp"
|
||||||
|
|
||||||
|
#include "mergestate.hpp"
|
||||||
|
|
||||||
namespace CSMTools
|
namespace CSMTools
|
||||||
{
|
{
|
||||||
struct MergeState;
|
|
||||||
|
|
||||||
class FinishMergedDocumentStage : public CSMDoc::Stage
|
class FinishMergedDocumentStage : public CSMDoc::Stage
|
||||||
{
|
{
|
||||||
MergeState& mState;
|
MergeState& mState;
|
||||||
|
@ -24,6 +26,53 @@ 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.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename RecordType>
|
||||||
|
class MergeIdCollectionStage : public CSMDoc::Stage
|
||||||
|
{
|
||||||
|
typedef typename CSMWorld::IdCollection<RecordType> Collection;
|
||||||
|
|
||||||
|
MergeState& mState;
|
||||||
|
Collection& (CSMWorld::Data::*mAccessor)();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
MergeIdCollectionStage (MergeState& state, Collection& (CSMWorld::Data::*accessor)());
|
||||||
|
|
||||||
|
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.
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename RecordType>
|
||||||
|
MergeIdCollectionStage<RecordType>::MergeIdCollectionStage (MergeState& state, Collection& (CSMWorld::Data::*accessor)())
|
||||||
|
: mState (state), mAccessor (accessor)
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<typename RecordType>
|
||||||
|
int MergeIdCollectionStage<RecordType>::setup()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename RecordType>
|
||||||
|
void MergeIdCollectionStage<RecordType>::perform (int stage, CSMDoc::Messages& messages)
|
||||||
|
{
|
||||||
|
const Collection& source = (mState.mSource.getData().*mAccessor)();
|
||||||
|
Collection& target = (mState.mTarget->getData().*mAccessor)();
|
||||||
|
|
||||||
|
int size = source.getSize();
|
||||||
|
|
||||||
|
for (int i=0; i<size; ++i)
|
||||||
|
{
|
||||||
|
const CSMWorld::Record<RecordType>& record = source.getRecord (i);
|
||||||
|
|
||||||
|
if (!record.isDeleted())
|
||||||
|
target.appendRecord (CSMWorld::Record<RecordType> (CSMWorld::RecordBase::State_BaseOnly, &record.get()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue