diff --git a/apps/opencs/model/world/record.hpp b/apps/opencs/model/world/record.hpp index 2b556636f..1f97ece93 100644 --- a/apps/opencs/model/world/record.hpp +++ b/apps/opencs/model/world/record.hpp @@ -38,6 +38,10 @@ namespace CSMWorld ESXRecordT mBase; ESXRecordT mModified; + Record() {} + Record(State state, + const ESXRecordT *base = 0, const ESXRecordT *modified = 0); + virtual RecordBase *clone() const; virtual void assign (const RecordBase& record); @@ -58,12 +62,22 @@ namespace CSMWorld ///< Merge modified into base. }; + template + Record::Record(State state, const ESXRecordT *base = 0, const ESXRecordT *modified = 0) + { + if(base) + mBase = *base; + + if(modified) + mModified = *modified; + + this->mState = state; + } + template RecordBase *Record::clone() const { - Record *copy = new Record (*this); - copy->mModified = (*this).get(); - return copy; + return new Record (State_ModifiedOnly, 0, &(this->get())); } template diff --git a/apps/opencs/model/world/refidcollection.cpp b/apps/opencs/model/world/refidcollection.cpp index 779d5a40c..011b5cc0e 100644 --- a/apps/opencs/model/world/refidcollection.cpp +++ b/apps/opencs/model/world/refidcollection.cpp @@ -471,7 +471,6 @@ void CSMWorld::RefIdCollection::cloneRecord(const std::string& origin, const CSMWorld::UniversalId::Type type) { std::auto_ptr newRecord(mData.getRecord(mData.searchId(origin)).clone()); - newRecord->mState = RecordBase::State_ModifiedOnly; mAdapters.find(type)->second->setId(*newRecord, destination); mData.insertRecord(*newRecord, type, destination); }