1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-04 02:41:19 +00:00

Rebuild ESMStore indices before loading any cell or player state

This commit is contained in:
Evil Eye 2024-07-25 22:22:23 +02:00
parent 11c21c28bf
commit 68be9a9544
2 changed files with 20 additions and 7 deletions

View File

@ -436,6 +436,7 @@ namespace MWWorld
mLevitationEnabled = true;
mPlayerTraveling = false;
mPlayerInJail = false;
mIdsRebuilt = false;
fillGlobalVariables();
}
@ -507,11 +508,13 @@ namespace MWWorld
}
break;
case ESM::REC_PLAY:
// World::write always puts `ESM::REC_PLAY` between ESMStore (that contains dynamic records)
// and WorldModel (that can contain instances of dynamic records). Here we need to rebuild
// ESMStore index in order to be able to lookup dynamic records while loading the player and
// WorldModel.
mStore.rebuildIdsIndex();
if (!mIdsRebuilt)
{
// FIME this can be removed when MinSupportedSaveGameFormatVersion > 32
// Older saves have the player before the WorldModel.
mStore.rebuildIdsIndex();
mIdsRebuilt = true;
}
mStore.checkPlayer();
mPlayer->readRecord(reader, type);
@ -523,10 +526,19 @@ namespace MWWorld
mWorldScene->preloadCellWithSurroundings(*getPlayerPtr().getCell());
}
break;
case ESM::REC_CSTA:
// We need to rebuild the ESMStore index in order to be able to lookup dynamic records while loading the
// WorldModel and, afterwards, the player.
if (!mIdsRebuilt)
{
mStore.rebuildIdsIndex();
mIdsRebuilt = true;
}
mWorldModel.readRecord(reader, type);
break;
default:
if (!mStore.readRecord(reader, type) && !mGlobalVariables.readRecord(reader, type)
&& !mWeatherManager->readRecord(reader, type) && !mWorldModel.readRecord(reader, type)
&& !mProjectileManager->readRecord(reader, type))
&& !mWeatherManager->readRecord(reader, type) && !mProjectileManager->readRecord(reader, type))
{
throw std::runtime_error("unknown record in saved game");
}

View File

@ -134,6 +134,7 @@ namespace MWWorld
///< only holds doors that are currently moving. 1 = opening, 2 = closing
uint32_t mRandomSeed{};
bool mIdsRebuilt{};
// not implemented
World(const World&) = delete;