Skip to content

Commit

Permalink
Merge branch 'unsave' into 'master'
Browse files Browse the repository at this point in the history
Drop support for saves made prior to 0.40

See merge request OpenMW/openmw!3645
  • Loading branch information
Capostrophic committed Dec 13, 2023
2 parents abbb620 + 7b8c0d1 commit 7e3270a
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 75 deletions.
47 changes: 19 additions & 28 deletions apps/openmw/mwworld/weather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,36 +898,27 @@ namespace MWWorld
{
if (ESM::REC_WTHR == type)
{
if (reader.getFormatVersion() <= ESM::MaxOldWeatherFormatVersion)
ESM::WeatherState state;
state.load(reader);

std::swap(mCurrentRegion, state.mCurrentRegion);
mTimePassed = state.mTimePassed;
mFastForward = state.mFastForward;
mWeatherUpdateTime = state.mWeatherUpdateTime;
mTransitionFactor = state.mTransitionFactor;
mCurrentWeather = state.mCurrentWeather;
mNextWeather = state.mNextWeather;
mQueuedWeather = state.mQueuedWeather;

mRegions.clear();
importRegions();

for (auto it = state.mRegions.begin(); it != state.mRegions.end(); ++it)
{
// Weather state isn't really all that important, so to preserve older save games, we'll just discard
// the older weather records, rather than fail to handle the record.
reader.skipRecord();
}
else
{
ESM::WeatherState state;
state.load(reader);

std::swap(mCurrentRegion, state.mCurrentRegion);
mTimePassed = state.mTimePassed;
mFastForward = state.mFastForward;
mWeatherUpdateTime = state.mWeatherUpdateTime;
mTransitionFactor = state.mTransitionFactor;
mCurrentWeather = state.mCurrentWeather;
mNextWeather = state.mNextWeather;
mQueuedWeather = state.mQueuedWeather;

mRegions.clear();
importRegions();

for (auto it = state.mRegions.begin(); it != state.mRegions.end(); ++it)
auto found = mRegions.find(it->first);
if (found != mRegions.end())
{
auto found = mRegions.find(it->first);
if (found != mRegions.end())
{
found->second = RegionWeather(it->second);
}
found->second = RegionWeather(it->second);
}
}

Expand Down
2 changes: 0 additions & 2 deletions apps/openmw_test_suite/mwworld/test_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ namespace
std::vector<ESM::FormatVersion> result({
ESM::DefaultFormatVersion,
ESM::CurrentContentFormatVersion,
ESM::MaxOldWeatherFormatVersion,
ESM::MaxOldDeathAnimationFormatVersion,
ESM::MaxOldFogOfWarFormatVersion,
ESM::MaxUnoptimizedCharacterDataFormatVersion,
ESM::MaxOldTimeLeftFormatVersion,
Expand Down
13 changes: 1 addition & 12 deletions components/esm3/animationstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,7 @@ namespace ESM
anim.mGroup = esm.getHString();
esm.getHNOT(anim.mTime, "TIME");
esm.getHNOT(anim.mAbsolute, "ABST");

esm.getSubNameIs("COUN");
// workaround bug in earlier version where size_t was used
esm.getSubHeader();
if (esm.getSubSize() == 8)
esm.getT(anim.mLoopCount);
else
{
uint32_t loopcount;
esm.getT(loopcount);
anim.mLoopCount = (uint64_t)loopcount;
}
esm.getHNT(anim.mLoopCount, "COUN");

mScriptedAnims.push_back(anim);
}
Expand Down
4 changes: 0 additions & 4 deletions components/esm3/creaturestats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,11 @@ namespace ESM
{
esm.getHNOT(mDead, "DEAD");
esm.getHNOT(mDeathAnimationFinished, "DFNT");
if (esm.getFormatVersion() <= MaxOldDeathAnimationFormatVersion && mDead)
mDeathAnimationFinished = true;
esm.getHNOT(mDied, "DIED");
esm.getHNOT(mMurdered, "MURD");
esm.getHNOT(mTalkedTo, "TALK");
esm.getHNOT(mAlarmed, "ALRM");
esm.getHNOT(mAttacked, "ATKD");
if (esm.isNextSub("ATCK"))
esm.skipHSub(); // attackingOrSpell, no longer used
esm.getHNOT(mKnockdown, "KNCK");
esm.getHNOT(mKnockdownOneFrame, "KNC1");
esm.getHNOT(mKnockdownOverOneFrame, "KNCO");
Expand Down
4 changes: 1 addition & 3 deletions components/esm3/formatversion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ namespace ESM

inline constexpr FormatVersion DefaultFormatVersion = 0;
inline constexpr FormatVersion CurrentContentFormatVersion = 1;
inline constexpr FormatVersion MaxOldWeatherFormatVersion = 1;
inline constexpr FormatVersion MaxOldDeathAnimationFormatVersion = 2;
inline constexpr FormatVersion MaxOldFogOfWarFormatVersion = 6;
inline constexpr FormatVersion MaxUnoptimizedCharacterDataFormatVersion = 7;
inline constexpr FormatVersion MaxOldTimeLeftFormatVersion = 8;
Expand All @@ -28,7 +26,7 @@ namespace ESM
inline constexpr FormatVersion MaxActiveSpellSlotIndexFormatVersion = 27;
inline constexpr FormatVersion CurrentSaveGameFormatVersion = 29;

inline constexpr FormatVersion MinSupportedSaveGameFormatVersion = 1;
inline constexpr FormatVersion MinSupportedSaveGameFormatVersion = 4;
inline constexpr FormatVersion OpenMW0_48SaveGameFormatVersion = 21;
inline constexpr FormatVersion OpenMW0_49SaveGameFormatVersion = CurrentSaveGameFormatVersion;
}
Expand Down
18 changes: 4 additions & 14 deletions components/esm3/inventorystate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,17 @@ namespace ESM
mItems.push_back(state);
}

std::map<std::pair<ESM::RefId, std::string>, int32_t> levelledItemMap;
// Next item is Levelled item
while (esm.isNextSub("LEVM"))
{
// Get its name
ESM::RefId id = esm.getRefId();
int32_t count;
std::string parentGroup;
// Then get its count
esm.getHNT(count, "COUN");
// Old save formats don't have information about parent group; check for that
if (esm.isNextSub("LGRP"))
// Newest saves contain parent group
parentGroup = esm.getHString();
mLevelledItemMap[std::make_pair(id, parentGroup)] = count;
std::string parentGroup = esm.getHNString("LGRP");
levelledItemMap[std::make_pair(id, parentGroup)] = count;
}

while (esm.isNextSub("MAGI"))
Expand Down Expand Up @@ -117,7 +114,7 @@ namespace ESM

// Old saves had restocking levelled items in a special map
// This turns items from that map into negative quantities
for (const auto& entry : mLevelledItemMap)
for (const auto& entry : levelledItemMap)
{
const ESM::RefId& id = entry.first.first;
const int count = entry.second;
Expand All @@ -141,13 +138,6 @@ namespace ESM
}
}

for (auto it = mLevelledItemMap.begin(); it != mLevelledItemMap.end(); ++it)
{
esm.writeHNRefId("LEVM", it->first.first);
esm.writeHNT("COUN", it->second);
esm.writeHNString("LGRP", it->first.second);
}

for (const auto& [id, params] : mPermanentMagicEffectMagnitudes)
{
esm.writeHNRefId("MAGI", id);
Expand Down
2 changes: 0 additions & 2 deletions components/esm3/inventorystate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ namespace ESM
// <Index in mItems, equipment slot>
std::map<uint32_t, int32_t> mEquipmentSlots;

std::map<std::pair<ESM::RefId, std::string>, int32_t> mLevelledItemMap;

std::map<ESM::RefId, std::vector<std::pair<float, float>>> mPermanentMagicEffectMagnitudes;

std::optional<uint32_t> mSelectedEnchantItem; // For inventories only
Expand Down
3 changes: 0 additions & 3 deletions components/esm3/objectstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ namespace ESM
else
mPosition = mRef.mPos;

if (esm.isNextSub("LROT"))
esm.skipHSub(); // local rotation, no longer used

mFlags = 0;
esm.getHNOT(mFlags, "FLAG");

Expand Down
7 changes: 0 additions & 7 deletions components/esm3/projectilestate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,11 @@ namespace ESM
BaseProjectileState::load(esm);

mSpellId = esm.getHNRefId("SPEL");
if (esm.isNextSub("SRCN")) // for backwards compatibility
esm.skipHSub();
EffectList().load(esm); // for backwards compatibility
esm.getHNT(mSpeed, "SPED");
if (esm.peekNextSub("ITEM"))
mItem = esm.getFormId(true, "ITEM");
if (esm.isNextSub("SLOT")) // for backwards compatibility
esm.skipHSub();
if (esm.isNextSub("STCK")) // for backwards compatibility
esm.skipHSub();
if (esm.isNextSub("SOUN")) // for backwards compatibility
esm.skipHSub();
}

void ProjectileState::save(ESMWriter& esm) const
Expand Down

0 comments on commit 7e3270a

Please sign in to comment.