mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 15:15:31 +00:00
Implement clone() using a new Record constructor.
This commit is contained in:
parent
128371c902
commit
6087a18c94
2 changed files with 17 additions and 4 deletions
|
@ -38,6 +38,10 @@ namespace CSMWorld
|
||||||
ESXRecordT mBase;
|
ESXRecordT mBase;
|
||||||
ESXRecordT mModified;
|
ESXRecordT mModified;
|
||||||
|
|
||||||
|
Record() {}
|
||||||
|
Record(State state,
|
||||||
|
const ESXRecordT *base = 0, const ESXRecordT *modified = 0);
|
||||||
|
|
||||||
virtual RecordBase *clone() const;
|
virtual RecordBase *clone() const;
|
||||||
|
|
||||||
virtual void assign (const RecordBase& record);
|
virtual void assign (const RecordBase& record);
|
||||||
|
@ -58,12 +62,22 @@ namespace CSMWorld
|
||||||
///< Merge modified into base.
|
///< Merge modified into base.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename ESXRecordT>
|
||||||
|
Record<ESXRecordT>::Record(State state, const ESXRecordT *base = 0, const ESXRecordT *modified = 0)
|
||||||
|
{
|
||||||
|
if(base)
|
||||||
|
mBase = *base;
|
||||||
|
|
||||||
|
if(modified)
|
||||||
|
mModified = *modified;
|
||||||
|
|
||||||
|
this->mState = state;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename ESXRecordT>
|
template <typename ESXRecordT>
|
||||||
RecordBase *Record<ESXRecordT>::clone() const
|
RecordBase *Record<ESXRecordT>::clone() const
|
||||||
{
|
{
|
||||||
Record<ESXRecordT> *copy = new Record<ESXRecordT> (*this);
|
return new Record<ESXRecordT> (State_ModifiedOnly, 0, &(this->get()));
|
||||||
copy->mModified = (*this).get();
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ESXRecordT>
|
template <typename ESXRecordT>
|
||||||
|
|
|
@ -471,7 +471,6 @@ void CSMWorld::RefIdCollection::cloneRecord(const std::string& origin,
|
||||||
const CSMWorld::UniversalId::Type type)
|
const CSMWorld::UniversalId::Type type)
|
||||||
{
|
{
|
||||||
std::auto_ptr<RecordBase> newRecord(mData.getRecord(mData.searchId(origin)).clone());
|
std::auto_ptr<RecordBase> newRecord(mData.getRecord(mData.searchId(origin)).clone());
|
||||||
newRecord->mState = RecordBase::State_ModifiedOnly;
|
|
||||||
mAdapters.find(type)->second->setId(*newRecord, destination);
|
mAdapters.find(type)->second->setId(*newRecord, destination);
|
||||||
mData.insertRecord(*newRecord, type, destination);
|
mData.insertRecord(*newRecord, type, destination);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue