Revert to the original clone() method. Create a new copy method for modified records.

celladd
cc9cii 10 years ago
parent 8b3adec3ec
commit 43ec933b7b

@ -22,6 +22,8 @@ namespace CSMWorld
virtual RecordBase *clone() const = 0;
virtual RecordBase *modifiedCopy() const = 0;
virtual void assign (const RecordBase& record) = 0;
///< Will throw an exception if the types don't match.
@ -38,13 +40,10 @@ namespace CSMWorld
ESXRecordT mBase;
ESXRecordT mModified;
Record() = default;
Record(const Record&) = default;
Record(State state,
const ESXRecordT *base = 0, const ESXRecordT *modified = 0);
virtual RecordBase *clone() const;
virtual RecordBase *modifiedCopy() const;
virtual void assign (const RecordBase& record);
const ESXRecordT& get() const;
@ -64,21 +63,19 @@ namespace CSMWorld
};
template <typename ESXRecordT>
Record<ESXRecordT>::Record(State state, const ESXRecordT *base, const ESXRecordT *modified)
RecordBase *Record<ESXRecordT>::modifiedCopy() const
{
if(base)
mBase = *base;
if(modified)
mModified = *modified;
this->mState = state;
Record<ESXRecordT> *record = new Record<ESXRecordT> (*this);
record->mModified = record->mBase;
record->mBase = ESXRecordT();
record->mState = RecordBase::State_ModifiedOnly;
return record;
}
template <typename ESXRecordT>
RecordBase *Record<ESXRecordT>::clone() const
{
return new Record<ESXRecordT> (State_ModifiedOnly, 0, &(this->get()));
return new Record<ESXRecordT> (*this);
}
template <typename ESXRecordT>

@ -470,7 +470,7 @@ void CSMWorld::RefIdCollection::cloneRecord(const std::string& origin,
const std::string& destination,
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)).modifiedCopy());
mAdapters.find(type)->second->setId(*newRecord, destination);
mData.insertRecord(*newRecord, type, destination);
}

Loading…
Cancel
Save