forked from teamnwah/openmw-tes3coop
merge referenceables table
This commit is contained in:
parent
9cf793c0b5
commit
f95950e8d8
7 changed files with 51 additions and 5 deletions
|
@ -34,8 +34,9 @@ CSMTools::MergeOperation::MergeOperation (CSMDoc::Document& document, ToUTF8::Fr
|
|||
appendStage (new MergeIdCollectionStage<CSMWorld::Pathgrid, CSMWorld::SubCellCollection<CSMWorld::Pathgrid> > (mState, &CSMWorld::Data::getPathgrids));
|
||||
appendStage (new MergeIdCollectionStage<CSMWorld::Info, CSMWorld::InfoCollection> (mState, &CSMWorld::Data::getTopicInfos));
|
||||
appendStage (new MergeIdCollectionStage<CSMWorld::Info, CSMWorld::InfoCollection> (mState, &CSMWorld::Data::getJournalInfos));
|
||||
appendStage (new MergeRefIdsStage (mState));
|
||||
|
||||
/// \todo Referencables, References, Land, LandTextures
|
||||
/// \todo References, Land, LandTextures
|
||||
}
|
||||
|
||||
void CSMTools::MergeOperation::setTarget (std::auto_ptr<CSMDoc::Document> document)
|
||||
|
|
|
@ -39,3 +39,17 @@ void CSMTools::FinishMergedDocumentStage::perform (int stage, CSMDoc::Messages&
|
|||
|
||||
mState.mCompleted = true;
|
||||
}
|
||||
|
||||
|
||||
CSMTools::MergeRefIdsStage::MergeRefIdsStage (MergeState& state) : mState (state) {}
|
||||
|
||||
int CSMTools::MergeRefIdsStage::setup()
|
||||
{
|
||||
return mState.mSource.getData().getReferenceables().getSize();
|
||||
}
|
||||
|
||||
void CSMTools::MergeRefIdsStage::perform (int stage, CSMDoc::Messages& messages)
|
||||
{
|
||||
mState.mSource.getData().getReferenceables().copyTo (
|
||||
stage, mState.mTarget->getData().getReferenceables());
|
||||
}
|
||||
|
|
|
@ -68,6 +68,22 @@ namespace CSMTools
|
|||
if (!record.isDeleted())
|
||||
target.appendRecord (CSMWorld::Record<RecordType> (CSMWorld::RecordBase::State_BaseOnly, &record.get()));
|
||||
}
|
||||
|
||||
|
||||
class MergeRefIdsStage : public CSMDoc::Stage
|
||||
{
|
||||
MergeState& mState;
|
||||
|
||||
public:
|
||||
|
||||
MergeRefIdsStage (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
|
||||
|
|
|
@ -914,3 +914,8 @@ const CSMWorld::NestedRefIdAdapterBase& CSMWorld::RefIdCollection::getNestedAdap
|
|||
}
|
||||
throw std::runtime_error("No such column in the nestedadapters");
|
||||
}
|
||||
|
||||
void CSMWorld::RefIdCollection::copyTo (int index, RefIdCollection& target) const
|
||||
{
|
||||
mData.copyTo (index, target.mData);
|
||||
}
|
||||
|
|
|
@ -138,6 +138,7 @@ namespace CSMWorld
|
|||
void save (int index, ESM::ESMWriter& writer) const;
|
||||
|
||||
const RefIdData& getDataSet() const; //I can't figure out a better name for this one :(
|
||||
void copyTo (int index, RefIdCollection& target) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -358,3 +358,14 @@ void CSMWorld::RefIdData::insertRecord(CSMWorld::RecordBase& record, CSMWorld::U
|
|||
mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (id),
|
||||
LocalIndex (iter->second->getSize()-1, type)));
|
||||
}
|
||||
|
||||
void CSMWorld::RefIdData::copyTo (int index, RefIdData& target) const
|
||||
{
|
||||
LocalIndex localIndex = globalToLocalIndex (index);
|
||||
|
||||
RefIdDataContainerBase *source = mRecordContainers.find (localIndex.second)->second;
|
||||
|
||||
std::string id = source->getId (localIndex.first);
|
||||
|
||||
target.insertRecord (source->getRecord (localIndex.first), localIndex.second, id);
|
||||
}
|
||||
|
|
|
@ -252,11 +252,9 @@ namespace CSMWorld
|
|||
const RefIdDataContainer<ESM::Probe >& getProbes() const;
|
||||
const RefIdDataContainer<ESM::Repair>& getRepairs() const;
|
||||
const RefIdDataContainer<ESM::Static>& getStatics() const;
|
||||
|
||||
void copyTo (int index, RefIdData& target) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue