diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 2628cd3905..ed601a9255 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -779,32 +779,26 @@ namespace MWClass const ESM::CreatureState& creatureState = state.asCreatureState(); - if (state.mVersion > 0) + if (!ptr.getRefData().getCustomData()) { - if (!ptr.getRefData().getCustomData()) + if (creatureState.mCreatureStats.mMissingACDT) + ensureCustomData(ptr); + else { - if (creatureState.mCreatureStats.mMissingACDT) - ensureCustomData(ptr); - else - { - // Create a CustomData, but don't fill it from ESM records (not needed) - auto data = std::make_unique(); + // Create a CustomData, but don't fill it from ESM records (not needed) + auto data = std::make_unique(); - if (hasInventoryStore(ptr)) - data->mContainerStore = std::make_unique(); - else - data->mContainerStore = std::make_unique(); + if (hasInventoryStore(ptr)) + data->mContainerStore = std::make_unique(); + else + data->mContainerStore = std::make_unique(); - MWBase::Environment::get().getWorldModel()->registerPtr(ptr); - data->mContainerStore->setPtr(ptr); + MWBase::Environment::get().getWorldModel()->registerPtr(ptr); + data->mContainerStore->setPtr(ptr); - ptr.getRefData().setCustomData(std::move(data)); - } + ptr.getRefData().setCustomData(std::move(data)); } } - else - ensureCustomData( - ptr); // in openmw 0.30 savegames not all state was saved yet, so need to load it regardless. CreatureCustomData& customData = ptr.getRefData().getCustomData()->asCreatureCustomData(); diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index b9e8bc8dfb..95a3b713fa 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -1333,25 +1333,19 @@ namespace MWClass const ESM::NpcState& npcState = state.asNpcState(); - if (state.mVersion > 0) + if (!ptr.getRefData().getCustomData()) { - if (!ptr.getRefData().getCustomData()) + if (npcState.mCreatureStats.mMissingACDT) + ensureCustomData(ptr); + else { - if (npcState.mCreatureStats.mMissingACDT) - ensureCustomData(ptr); - else - { - // Create a CustomData, but don't fill it from ESM records (not needed) - auto data = std::make_unique(); - MWBase::Environment::get().getWorldModel()->registerPtr(ptr); - data->mInventoryStore.setPtr(ptr); - ptr.getRefData().setCustomData(std::move(data)); - } + // Create a CustomData, but don't fill it from ESM records (not needed) + auto data = std::make_unique(); + MWBase::Environment::get().getWorldModel()->registerPtr(ptr); + data->mInventoryStore.setPtr(ptr); + ptr.getRefData().setCustomData(std::move(data)); } } - else - ensureCustomData( - ptr); // in openmw 0.30 savegames not all state was saved yet, so need to load it regardless. NpcCustomData& customData = ptr.getRefData().getCustomData()->asNpcCustomData(); diff --git a/apps/openmw/mwdialogue/journalimp.cpp b/apps/openmw/mwdialogue/journalimp.cpp index e4d9453c83..28a2e16699 100644 --- a/apps/openmw/mwdialogue/journalimp.cpp +++ b/apps/openmw/mwdialogue/journalimp.cpp @@ -250,7 +250,7 @@ namespace MWDialogue void Journal::readRecord(ESM::ESMReader& reader, uint32_t type) { - if (type == ESM::REC_JOUR || type == ESM::REC_JOUR_LEGACY) + if (type == ESM::REC_JOUR) { ESM::JournalEntry record; record.load(reader); diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index c040dca8dd..89b63c35e4 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -472,7 +472,6 @@ void MWState::StateManager::loadGame(const Character* character, const std::file break; case ESM::REC_JOUR: - case ESM::REC_JOUR_LEGACY: case ESM::REC_QUES: MWBase::Environment::get().getJournal()->readRecord(reader, n.toInt()); diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index 340def5859..930f26c1cc 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -252,16 +252,16 @@ namespace if (!record) return; - if (state.mVersion < 15) + if (state.mVersion <= ESM::MaxOldRestockingFormatVersion) fixRestocking(record, state); - if (state.mVersion < 17) + if (state.mVersion <= ESM::MaxClearModifiersFormatVersion) { if constexpr (std::is_same_v) MWWorld::convertMagicEffects(state.mCreatureStats, state.mInventory); else if constexpr (std::is_same_v) MWWorld::convertMagicEffects(state.mCreatureStats, state.mInventory, &state.mNpcStats); } - else if (state.mVersion < 20) + else if (state.mVersion <= ESM::MaxOldCreatureStatsFormatVersion) { if constexpr (std::is_same_v || std::is_same_v) MWWorld::convertStats(state.mCreatureStats); diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 0d7afb559f..b498bb488b 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -334,12 +334,7 @@ namespace MWWorld if (player.mObject.mNpcStats.mIsWerewolf) { - if (player.mObject.mNpcStats.mWerewolfDeprecatedData) - { - saveStats(); - setWerewolfStats(); - } - else if (reader.getFormatVersion() <= ESM::MaxOldSkillsAndAttributesFormatVersion) + if (reader.getFormatVersion() <= ESM::MaxOldSkillsAndAttributesFormatVersion) { setWerewolfStats(); if (player.mSetWerewolfAcrobatics) diff --git a/apps/openmw_test_suite/mwworld/test_store.cpp b/apps/openmw_test_suite/mwworld/test_store.cpp index d8890bc5ab..f80c12917c 100644 --- a/apps/openmw_test_suite/mwworld/test_store.cpp +++ b/apps/openmw_test_suite/mwworld/test_store.cpp @@ -272,8 +272,8 @@ namespace ESM::CurrentContentFormatVersion, ESM::MaxOldWeatherFormatVersion, ESM::MaxOldDeathAnimationFormatVersion, - ESM::MaxOldForOfWarFormatVersion, - ESM::MaxWerewolfDeprecatedDataFormatVersion, + ESM::MaxOldFogOfWarFormatVersion, + ESM::MaxUnoptimizedCharacterDataFormatVersion, ESM::MaxOldTimeLeftFormatVersion, ESM::MaxIntFallbackFormatVersion, ESM::MaxClearModifiersFormatVersion, diff --git a/components/esm/defs.hpp b/components/esm/defs.hpp index 96d70f6fea..55404ee768 100644 --- a/components/esm/defs.hpp +++ b/components/esm/defs.hpp @@ -146,8 +146,6 @@ namespace ESM // format 0 - saved games REC_SAVE = esm3Recname("SAVE"), - REC_JOUR_LEGACY = esm3Recname("\xa4UOR"), // "\xa4UOR", rather than "JOUR", little oversight when magic numbers - // were calculated by hand, needs to be supported for older files now REC_JOUR = esm3Recname("JOUR"), REC_QUES = esm3Recname("QUES"), REC_GSCR = esm3Recname("GSCR"), diff --git a/components/esm3/creaturestats.cpp b/components/esm3/creaturestats.cpp index d8fb0d6969..8281916e30 100644 --- a/components/esm3/creaturestats.cpp +++ b/components/esm3/creaturestats.cpp @@ -38,7 +38,7 @@ namespace ESM mHitRecovery = false; mBlock = false; mRecalcDynamicStats = false; - if (esm.getFormatVersion() <= MaxWerewolfDeprecatedDataFormatVersion) + if (esm.getFormatVersion() <= MaxUnoptimizedCharacterDataFormatVersion) { esm.getHNOT(mDead, "DEAD"); esm.getHNOT(mDeathAnimationFinished, "DFNT"); @@ -46,13 +46,9 @@ namespace ESM mDeathAnimationFinished = true; esm.getHNOT(mDied, "DIED"); esm.getHNOT(mMurdered, "MURD"); - if (esm.isNextSub("FRHT")) - esm.skipHSub(); // Friendly hits, no longer used esm.getHNOT(mTalkedTo, "TALK"); esm.getHNOT(mAlarmed, "ALRM"); esm.getHNOT(mAttacked, "ATKD"); - if (esm.isNextSub("HOST")) - esm.skipHSub(); // Hostile, no longer used if (esm.isNextSub("ATCK")) esm.skipHSub(); // attackingOrSpell, no longer used esm.getHNOT(mKnockdown, "KNCK"); @@ -82,9 +78,6 @@ namespace ESM mMovementFlags = 0; esm.getHNOT(mMovementFlags, "MOVE"); - if (esm.isNextSub("ASTR")) - esm.skipHSub(); // attackStrength, no longer used - mFallHeight = 0; esm.getHNOT(mFallHeight, "FALL"); @@ -92,7 +85,7 @@ namespace ESM mLastHitAttemptObject = esm.getHNORefId("LHAT"); - if (esm.getFormatVersion() <= MaxWerewolfDeprecatedDataFormatVersion) + if (esm.getFormatVersion() <= MaxUnoptimizedCharacterDataFormatVersion) esm.getHNOT(mRecalcDynamicStats, "CALC"); mDrawState = 0; diff --git a/components/esm3/dialoguestate.cpp b/components/esm3/dialoguestate.cpp index 88fbe9659a..7095e096cb 100644 --- a/components/esm3/dialoguestate.cpp +++ b/components/esm3/dialoguestate.cpp @@ -22,14 +22,6 @@ namespace ESM esm.getHNT(reaction, "INTV"); mChangedFactionReaction[faction][faction2] = reaction; } - - // no longer used - while (esm.isNextSub("REAC")) - { - esm.skipHSub(); - esm.getSubName(); - esm.skipHSub(); - } } } diff --git a/components/esm3/fogstate.cpp b/components/esm3/fogstate.cpp index 3ee4600c90..2c07438070 100644 --- a/components/esm3/fogstate.cpp +++ b/components/esm3/fogstate.cpp @@ -74,7 +74,7 @@ namespace ESM tex.mImageData.resize(imageSize); esm.getExact(tex.mImageData.data(), imageSize); - if (dataFormat <= MaxOldForOfWarFormatVersion) + if (dataFormat <= MaxOldFogOfWarFormatVersion) convertFogOfWar(tex.mImageData); mFogTextures.push_back(tex); diff --git a/components/esm3/formatversion.hpp b/components/esm3/formatversion.hpp index 1b4bee0bc5..e02e0176a9 100644 --- a/components/esm3/formatversion.hpp +++ b/components/esm3/formatversion.hpp @@ -11,10 +11,11 @@ namespace ESM inline constexpr FormatVersion CurrentContentFormatVersion = 1; inline constexpr FormatVersion MaxOldWeatherFormatVersion = 1; inline constexpr FormatVersion MaxOldDeathAnimationFormatVersion = 2; - inline constexpr FormatVersion MaxOldForOfWarFormatVersion = 6; - inline constexpr FormatVersion MaxWerewolfDeprecatedDataFormatVersion = 7; + inline constexpr FormatVersion MaxOldFogOfWarFormatVersion = 6; + inline constexpr FormatVersion MaxUnoptimizedCharacterDataFormatVersion = 7; inline constexpr FormatVersion MaxOldTimeLeftFormatVersion = 8; inline constexpr FormatVersion MaxIntFallbackFormatVersion = 10; + inline constexpr FormatVersion MaxOldRestockingFormatVersion = 14; inline constexpr FormatVersion MaxClearModifiersFormatVersion = 16; inline constexpr FormatVersion MaxOldAiPackageFormatVersion = 17; inline constexpr FormatVersion MaxOldSkillsAndAttributesFormatVersion = 18; @@ -27,7 +28,7 @@ namespace ESM inline constexpr FormatVersion MaxActiveSpellSlotIndexFormatVersion = 27; inline constexpr FormatVersion CurrentSaveGameFormatVersion = 29; - inline constexpr FormatVersion MinSupportedSaveGameFormatVersion = 0; + inline constexpr FormatVersion MinSupportedSaveGameFormatVersion = 1; inline constexpr FormatVersion OpenMW0_48SaveGameFormatVersion = 21; inline constexpr FormatVersion OpenMW0_49SaveGameFormatVersion = CurrentSaveGameFormatVersion; } diff --git a/components/esm3/inventorystate.cpp b/components/esm3/inventorystate.cpp index 84a52ff518..a6130af473 100644 --- a/components/esm3/inventorystate.cpp +++ b/components/esm3/inventorystate.cpp @@ -22,14 +22,6 @@ namespace ESM ObjectState state; - // obsolete - if (esm.isNextSub("SLOT")) - { - int32_t slot; - esm.getHT(slot); - mEquipmentSlots[index] = slot; - } - state.mRef.loadId(esm, true); state.load(esm); diff --git a/components/esm3/npcstats.cpp b/components/esm3/npcstats.cpp index a21ba807e4..dc221a5b43 100644 --- a/components/esm3/npcstats.cpp +++ b/components/esm3/npcstats.cpp @@ -41,46 +41,6 @@ namespace ESM for (auto& skill : mSkills) skill.load(esm, intFallback); - mWerewolfDeprecatedData = false; - if (esm.getFormatVersion() <= MaxWerewolfDeprecatedDataFormatVersion && esm.peekNextSub("STBA")) - { - // we have deprecated werewolf skills, stored interleaved - // Load into one big vector, then remove every 2nd value - mWerewolfDeprecatedData = true; - std::vector> skills(mSkills.begin(), mSkills.end()); - - for (size_t i = 0; i < std::size(mSkills); ++i) - { - StatState skill; - skill.load(esm, intFallback); - skills.push_back(skill); - } - - int i = 0; - for (std::vector>::iterator it = skills.begin(); it != skills.end(); ++i) - { - if (i % 2 == 1) - it = skills.erase(it); - else - ++it; - } - if (skills.size() != std::size(mSkills)) - throw std::runtime_error( - "Invalid number of skill for werewolf deprecated data: " + std::to_string(skills.size())); - std::copy(skills.begin(), skills.end(), mSkills.begin()); - } - - // No longer used - bool hasWerewolfAttributes = false; - esm.getHNOT(hasWerewolfAttributes, "HWAT"); - if (hasWerewolfAttributes) - { - StatState dummy; - for (int i = 0; i < ESM::Attribute::Length; ++i) - dummy.load(esm, intFallback); - mWerewolfDeprecatedData = true; - } - mIsWerewolf = false; esm.getHNOT(mIsWerewolf, "WOLF"); @@ -93,14 +53,6 @@ namespace ESM mWerewolfKills = 0; esm.getHNOT(mWerewolfKills, "WKIL"); - // No longer used - if (esm.isNextSub("PROF")) - esm.skipHSub(); // int profit - - // No longer used - if (esm.isNextSub("ASTR")) - esm.skipHSub(); // attackStrength - mLevelProgress = 0; esm.getHNOT(mLevelProgress, "LPRO"); @@ -116,14 +68,6 @@ namespace ESM mTimeToStartDrowning = 0; esm.getHNOT(mTimeToStartDrowning, "DRTI"); - // No longer used - float lastDrowningHit = 0; - esm.getHNOT(lastDrowningHit, "DRLH"); - - // No longer used - float levelHealthBonus = 0; - esm.getHNOT(levelHealthBonus, "LVLH"); - mCrimeId = -1; esm.getHNOT(mCrimeId, "CRID"); } @@ -195,7 +139,6 @@ namespace ESM void NpcStats::blank() { - mWerewolfDeprecatedData = false; mIsWerewolf = false; mDisposition = 0; mBounty = 0; diff --git a/components/esm3/npcstats.hpp b/components/esm3/npcstats.hpp index ccb58a12ad..425a62162b 100644 --- a/components/esm3/npcstats.hpp +++ b/components/esm3/npcstats.hpp @@ -31,8 +31,6 @@ namespace ESM bool mIsWerewolf; - bool mWerewolfDeprecatedData; - std::map mFactions; int32_t mDisposition; std::array, ESM::Skill::Length> mSkills; diff --git a/components/esm3/objectstate.cpp b/components/esm3/objectstate.cpp index a7fe41d66c..fca4c64f5f 100644 --- a/components/esm3/objectstate.cpp +++ b/components/esm3/objectstate.cpp @@ -48,10 +48,6 @@ namespace ESM mFlags = 0; esm.getHNOT(mFlags, "FLAG"); - // obsolete - int32_t unused; - esm.getHNOT(unused, "LTIM"); - mAnimationState.load(esm); // FIXME: assuming "false" as default would make more sense, but also break compatibility with older save files diff --git a/components/esm3/quickkeys.cpp b/components/esm3/quickkeys.cpp index ababa535b7..7477fd24fa 100644 --- a/components/esm3/quickkeys.cpp +++ b/components/esm3/quickkeys.cpp @@ -8,9 +8,6 @@ namespace ESM void QuickKeys::load(ESMReader& esm) { - if (esm.isNextSub("KEY_")) - esm.getSubHeader(); // no longer used, because sub-record hierachies do not work properly in esmreader - while (esm.isNextSub("TYPE")) { QuickKey key; @@ -18,9 +15,6 @@ namespace ESM key.mId = esm.getHNRefId("ID__"); mKeys.push_back(key); - - if (esm.isNextSub("KEY_")) - esm.getSubHeader(); // no longer used, because sub-record hierachies do not work properly in esmreader } } diff --git a/components/esm3/statstate.cpp b/components/esm3/statstate.cpp index 7477d83e2d..b46c2e34fd 100644 --- a/components/esm3/statstate.cpp +++ b/components/esm3/statstate.cpp @@ -32,10 +32,6 @@ namespace ESM int32_t current = 0; esm.getHNOT(current, "STCU"); mCurrent = static_cast(current); - - int32_t oldDamage = 0; - esm.getHNOT(oldDamage, "STDA"); - mDamage = static_cast(oldDamage); } else {