mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Merge remote-tracking branch 'cc9cii/editor-clone-fix'
This commit is contained in:
commit
8a8db8bc24
@ -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,8 +40,17 @@ namespace CSMWorld
|
||||
ESXRecordT mBase;
|
||||
ESXRecordT mModified;
|
||||
|
||||
Record();
|
||||
Record(const Record& record);
|
||||
Record& operator= (const Record& record);
|
||||
|
||||
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;
|
||||
@ -58,6 +69,49 @@ namespace CSMWorld
|
||||
///< Merge modified into base.
|
||||
};
|
||||
|
||||
template <typename ESXRecordT>
|
||||
Record<ESXRecordT>::Record()
|
||||
: mBase(), mModified()
|
||||
{ }
|
||||
|
||||
template <typename ESXRecordT>
|
||||
Record<ESXRecordT>::Record(const Record& record)
|
||||
: mBase(record.mBase), mModified(record.mModified)
|
||||
{
|
||||
mState = record.mState;
|
||||
}
|
||||
|
||||
template <typename ESXRecordT>
|
||||
Record<ESXRecordT>& Record<ESXRecordT>::operator= (const Record& record)
|
||||
{
|
||||
if(this != &record)
|
||||
{
|
||||
mBase = record.mBase;
|
||||
mModified = record.mModified;
|
||||
mState = record.mState;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename ESXRecordT>
|
||||
Record<ESXRecordT>::Record(State state, const ESXRecordT *base, const ESXRecordT *modified)
|
||||
{
|
||||
if(base)
|
||||
mBase = *base;
|
||||
|
||||
if(modified)
|
||||
mModified = *modified;
|
||||
|
||||
this->mState = state;
|
||||
}
|
||||
|
||||
template <typename ESXRecordT>
|
||||
RecordBase *Record<ESXRecordT>::modifiedCopy() const
|
||||
{
|
||||
return new Record<ESXRecordT> (State_ModifiedOnly, 0, &(this->get()));
|
||||
}
|
||||
|
||||
template <typename ESXRecordT>
|
||||
RecordBase *Record<ESXRecordT>::clone() const
|
||||
{
|
||||
|
@ -470,8 +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());
|
||||
newRecord->mState = RecordBase::State_ModifiedOnly;
|
||||
std::auto_ptr<RecordBase> newRecord(mData.getRecord(mData.searchId(origin)).modifiedCopy());
|
||||
mAdapters.find(type)->second->setId(*newRecord, destination);
|
||||
mData.insertRecord(*newRecord, type, destination);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user