mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 09:23:52 +00:00
Cloning works for referencables as well.
This commit is contained in:
parent
7594bcf97a
commit
9b56b6585b
3 changed files with 31 additions and 2 deletions
|
@ -457,7 +457,8 @@ void CSMWorld::RefIdCollection::cloneRecord(const std::string& origin,
|
||||||
RecordBase *newRecord = mData.getRecord(mData.searchId(origin)).clone();
|
RecordBase *newRecord = mData.getRecord(mData.searchId(origin)).clone();
|
||||||
newRecord->mState = RecordBase::State_ModifiedOnly;
|
newRecord->mState = RecordBase::State_ModifiedOnly;
|
||||||
mAdapters.find(type)->second->setId(*newRecord, destination);
|
mAdapters.find(type)->second->setId(*newRecord, destination);
|
||||||
mData.getAppendIndex(type);
|
mData.insertRecord(*newRecord, type, destination);
|
||||||
|
delete newRecord;
|
||||||
//WIP
|
//WIP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,3 +231,18 @@ void CSMWorld::RefIdData::save (int index, ESM::ESMWriter& writer) const
|
||||||
|
|
||||||
iter->second->save (localIndex.first, writer);
|
iter->second->save (localIndex.first, writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CSMWorld::RefIdData::insertRecord(CSMWorld::RecordBase& record, CSMWorld::UniversalId::Type type, const std::string& id)
|
||||||
|
{
|
||||||
|
std::map<UniversalId::Type, RefIdDataContainerBase *>::iterator iter =
|
||||||
|
mRecordContainers.find (type);
|
||||||
|
|
||||||
|
if (iter==mRecordContainers.end())
|
||||||
|
throw std::logic_error ("invalid local index type");
|
||||||
|
|
||||||
|
iter->second->insertRecord(record);
|
||||||
|
|
||||||
|
mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (id),
|
||||||
|
LocalIndex (iter->second->getSize()-1, type)));
|
||||||
|
}
|
||||||
|
|
|
@ -47,6 +47,8 @@ namespace CSMWorld
|
||||||
|
|
||||||
virtual void appendRecord (const std::string& id) = 0;
|
virtual void appendRecord (const std::string& id) = 0;
|
||||||
|
|
||||||
|
virtual void insertRecord (RecordBase& record) = 0;
|
||||||
|
|
||||||
virtual void load (int index, ESM::ESMReader& reader, bool base) = 0;
|
virtual void load (int index, ESM::ESMReader& reader, bool base) = 0;
|
||||||
|
|
||||||
virtual void erase (int index, int count) = 0;
|
virtual void erase (int index, int count) = 0;
|
||||||
|
@ -69,6 +71,8 @@ namespace CSMWorld
|
||||||
|
|
||||||
virtual void appendRecord (const std::string& id);
|
virtual void appendRecord (const std::string& id);
|
||||||
|
|
||||||
|
virtual void insertRecord (RecordBase& record);
|
||||||
|
|
||||||
virtual void load (int index, ESM::ESMReader& reader, bool base);
|
virtual void load (int index, ESM::ESMReader& reader, bool base);
|
||||||
|
|
||||||
virtual void erase (int index, int count);
|
virtual void erase (int index, int count);
|
||||||
|
@ -78,6 +82,13 @@ namespace CSMWorld
|
||||||
virtual void save (int index, ESM::ESMWriter& writer) const;
|
virtual void save (int index, ESM::ESMWriter& writer) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename RecordT>
|
||||||
|
void RefIdDataContainer<RecordT>::insertRecord(RecordBase& record)
|
||||||
|
{
|
||||||
|
Record<RecordT>& newRecord = dynamic_cast<Record<RecordT>& >(record);
|
||||||
|
mContainer.push_back(newRecord);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename RecordT>
|
template<typename RecordT>
|
||||||
int RefIdDataContainer<RecordT>::getSize() const
|
int RefIdDataContainer<RecordT>::getSize() const
|
||||||
{
|
{
|
||||||
|
@ -201,6 +212,8 @@ namespace CSMWorld
|
||||||
|
|
||||||
void erase (int index, int count);
|
void erase (int index, int count);
|
||||||
|
|
||||||
|
void insertRecord(CSMWorld::RecordBase& record, CSMWorld::UniversalId::Type type, const std::string& id);
|
||||||
|
|
||||||
const RecordBase& getRecord (const LocalIndex& index) const;
|
const RecordBase& getRecord (const LocalIndex& index) const;
|
||||||
|
|
||||||
RecordBase& getRecord (const LocalIndex& index);
|
RecordBase& getRecord (const LocalIndex& index);
|
||||||
|
|
Loading…
Reference in a new issue