mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 22:45:34 +00:00
Merge remote-tracking branch 'aesylwinn/ContentNumberFix'
This commit is contained in:
commit
48c257b939
3 changed files with 24 additions and 2 deletions
|
@ -321,6 +321,10 @@ void CSMDoc::WriteCellCollectionStage::perform (int stage, Messages& messages)
|
|||
{
|
||||
CSMWorld::CellRef refRecord = ref.get();
|
||||
|
||||
// Check for uninitialized content file
|
||||
if (!refRecord.mRefNum.hasContentFile())
|
||||
refRecord.mRefNum.mContentFile = 0;
|
||||
|
||||
// recalculate the ref's cell location
|
||||
std::ostringstream stream;
|
||||
if (!interior)
|
||||
|
|
|
@ -64,7 +64,7 @@ int CSMWorld::Data::count (RecordBase::State state, const CollectionBase& collec
|
|||
CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourcesManager, const Fallback::Map* fallback, const boost::filesystem::path& resDir)
|
||||
: mEncoder (encoding), mPathgrids (mCells), mRefs (mCells),
|
||||
mResourcesManager (resourcesManager), mFallbackMap(fallback),
|
||||
mReader (0), mDialogue (0), mReaderIndex(0), mResourceSystem(new Resource::ResourceSystem(resourcesManager.getVFS()))
|
||||
mReader (0), mDialogue (0), mReaderIndex(1), mResourceSystem(new Resource::ResourceSystem(resourcesManager.getVFS()))
|
||||
{
|
||||
mResourceSystem->getSceneManager()->setShaderPath((resDir / "shaders").string());
|
||||
|
||||
|
@ -899,9 +899,11 @@ int CSMWorld::Data::startLoading (const boost::filesystem::path& path, bool base
|
|||
|
||||
mReader = new ESM::ESMReader;
|
||||
mReader->setEncoder (&mEncoder);
|
||||
mReader->setIndex(mReaderIndex++);
|
||||
mReader->setIndex((project || !base) ? 0 : mReaderIndex++);
|
||||
mReader->open (path.string());
|
||||
|
||||
mContentFileNames.insert(std::make_pair(path.filename().string(), mReader->getIndex()));
|
||||
|
||||
mBase = base;
|
||||
mProject = project;
|
||||
|
||||
|
@ -914,6 +916,20 @@ int CSMWorld::Data::startLoading (const boost::filesystem::path& path, bool base
|
|||
mMetaData.setRecord (0, Record<MetaData> (RecordBase::State_ModifiedOnly, 0, &metaData));
|
||||
}
|
||||
|
||||
// Fix uninitialized master data index
|
||||
for (std::vector<ESM::Header::MasterData>::const_iterator masterData = mReader->getGameFiles().begin();
|
||||
masterData != mReader->getGameFiles().end(); ++masterData)
|
||||
{
|
||||
std::map<std::string, int>::iterator nameResult = mContentFileNames.find(masterData->name);
|
||||
if (nameResult != mContentFileNames.end())
|
||||
{
|
||||
ESM::Header::MasterData& hackedMasterData = const_cast<ESM::Header::MasterData&>(*masterData);
|
||||
|
||||
|
||||
hackedMasterData.index = nameResult->second;
|
||||
}
|
||||
}
|
||||
|
||||
return mReader->getRecordCount();
|
||||
}
|
||||
|
||||
|
|
|
@ -123,6 +123,8 @@ namespace CSMWorld
|
|||
|
||||
std::vector<boost::shared_ptr<ESM::ESMReader> > mReaders;
|
||||
|
||||
std::map<std::string, int> mContentFileNames;
|
||||
|
||||
// not implemented
|
||||
Data (const Data&);
|
||||
Data& operator= (const Data&);
|
||||
|
|
Loading…
Reference in a new issue