mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 08:53:52 +00:00
Merge remote-tracking branch 'cc9cii/editor-clone-fix'
This commit is contained in:
commit
8a8db8bc24
2 changed files with 55 additions and 2 deletions
|
@ -22,6 +22,8 @@ namespace CSMWorld
|
||||||
|
|
||||||
virtual RecordBase *clone() const = 0;
|
virtual RecordBase *clone() const = 0;
|
||||||
|
|
||||||
|
virtual RecordBase *modifiedCopy() const = 0;
|
||||||
|
|
||||||
virtual void assign (const RecordBase& record) = 0;
|
virtual void assign (const RecordBase& record) = 0;
|
||||||
///< Will throw an exception if the types don't match.
|
///< Will throw an exception if the types don't match.
|
||||||
|
|
||||||
|
@ -38,8 +40,17 @@ namespace CSMWorld
|
||||||
ESXRecordT mBase;
|
ESXRecordT mBase;
|
||||||
ESXRecordT mModified;
|
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 *clone() const;
|
||||||
|
|
||||||
|
virtual RecordBase *modifiedCopy() const;
|
||||||
|
|
||||||
virtual void assign (const RecordBase& record);
|
virtual void assign (const RecordBase& record);
|
||||||
|
|
||||||
const ESXRecordT& get() const;
|
const ESXRecordT& get() const;
|
||||||
|
@ -58,6 +69,49 @@ namespace CSMWorld
|
||||||
///< Merge modified into base.
|
///< 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>
|
template <typename ESXRecordT>
|
||||||
RecordBase *Record<ESXRecordT>::clone() const
|
RecordBase *Record<ESXRecordT>::clone() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -470,8 +470,7 @@ void CSMWorld::RefIdCollection::cloneRecord(const std::string& origin,
|
||||||
const std::string& destination,
|
const std::string& destination,
|
||||||
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)).modifiedCopy());
|
||||||
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