fixed referenceable-loading in case of more than one content file

actorid
Marc Zinnschlag 11 years ago
parent 7b8802588e
commit 0afa61eed5

@ -432,7 +432,7 @@ void CSMWorld::RefIdCollection::removeRows (int index, int count)
void CSMWorld::RefIdCollection::appendBlankRecord (const std::string& id, UniversalId::Type type) void CSMWorld::RefIdCollection::appendBlankRecord (const std::string& id, UniversalId::Type type)
{ {
mData.appendRecord (type, id); mData.appendRecord (type, id, false);
} }
int CSMWorld::RefIdCollection::searchId (const std::string& id) const int CSMWorld::RefIdCollection::searchId (const std::string& id) const
@ -450,7 +450,7 @@ void CSMWorld::RefIdCollection::replace (int index, const RecordBase& record)
mData.getRecord (mData.globalToLocalIndex (index)).assign (record); mData.getRecord (mData.globalToLocalIndex (index)).assign (record);
} }
void CSMWorld::RefIdCollection::cloneRecord(const std::string& origin, 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)
{ {
@ -467,7 +467,7 @@ void CSMWorld::RefIdCollection::appendRecord (const RecordBase& record,
int index = mData.getAppendIndex (type); int index = mData.getAppendIndex (type);
mData.appendRecord (type, id); mData.appendRecord (type, id, false);
mData.getRecord (mData.globalToLocalIndex (index)).assign (record); mData.getRecord (mData.globalToLocalIndex (index)).assign (record);
} }
@ -515,7 +515,7 @@ void CSMWorld::RefIdCollection::load (ESM::ESMReader& reader, bool base, Univers
{ {
// new record // new record
int index = mData.getAppendIndex (type); int index = mData.getAppendIndex (type);
mData.appendRecord (type, id); mData.appendRecord (type, id, base);
RefIdData::LocalIndex localIndex = mData.globalToLocalIndex (index); RefIdData::LocalIndex localIndex = mData.globalToLocalIndex (index);

@ -131,7 +131,7 @@ CSMWorld::RecordBase& CSMWorld::RefIdData::getRecord (const LocalIndex& index)
return iter->second->getRecord (index.first); return iter->second->getRecord (index.first);
} }
void CSMWorld::RefIdData::appendRecord (UniversalId::Type type, const std::string& id) void CSMWorld::RefIdData::appendRecord (UniversalId::Type type, const std::string& id, bool base)
{ {
std::map<UniversalId::Type, RefIdDataContainerBase *>::iterator iter = std::map<UniversalId::Type, RefIdDataContainerBase *>::iterator iter =
mRecordContainers.find (type); mRecordContainers.find (type);
@ -139,7 +139,7 @@ void CSMWorld::RefIdData::appendRecord (UniversalId::Type type, const std::strin
if (iter==mRecordContainers.end()) if (iter==mRecordContainers.end())
throw std::logic_error ("invalid local index type"); throw std::logic_error ("invalid local index type");
iter->second->appendRecord (id); iter->second->appendRecord (id, base);
mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (id), mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (id),
LocalIndex (iter->second->getSize()-1, type))); LocalIndex (iter->second->getSize()-1, type)));

@ -45,8 +45,8 @@ namespace CSMWorld
virtual RecordBase& getRecord (int index)= 0; virtual RecordBase& getRecord (int index)= 0;
virtual void appendRecord (const std::string& id) = 0; virtual void appendRecord (const std::string& id, bool base) = 0;
virtual void insertRecord (RecordBase& record) = 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;
@ -69,8 +69,8 @@ namespace CSMWorld
virtual RecordBase& getRecord (int index); virtual RecordBase& getRecord (int index);
virtual void appendRecord (const std::string& id); virtual void appendRecord (const std::string& id, bool base);
virtual void insertRecord (RecordBase& record); 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);
@ -88,7 +88,7 @@ namespace CSMWorld
Record<RecordT>& newRecord = dynamic_cast<Record<RecordT>& >(record); Record<RecordT>& newRecord = dynamic_cast<Record<RecordT>& >(record);
mContainer.push_back(newRecord); mContainer.push_back(newRecord);
} }
template<typename RecordT> template<typename RecordT>
int RefIdDataContainer<RecordT>::getSize() const int RefIdDataContainer<RecordT>::getSize() const
{ {
@ -108,12 +108,15 @@ namespace CSMWorld
} }
template<typename RecordT> template<typename RecordT>
void RefIdDataContainer<RecordT>::appendRecord (const std::string& id) void RefIdDataContainer<RecordT>::appendRecord (const std::string& id, bool base)
{ {
Record<RecordT> record; Record<RecordT> record;
record.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
record.mBase.mId = id;
record.mModified.mId = id; record.mModified.mId = id;
record.mModified.blank(); (base ? record.mBase : record.mModified).blank();
record.mState = RecordBase::State_ModifiedOnly;
mContainer.push_back (record); mContainer.push_back (record);
} }
@ -206,14 +209,14 @@ namespace CSMWorld
LocalIndex searchId (const std::string& id) const; LocalIndex searchId (const std::string& id) const;
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); 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);
void appendRecord (UniversalId::Type type, const std::string& id); void appendRecord (UniversalId::Type type, const std::string& id, bool base);
int getAppendIndex (UniversalId::Type type) const; int getAppendIndex (UniversalId::Type type) const;

Loading…
Cancel
Save