From 0bab37327c0055120687d9db64ac04de99fd3249 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Thu, 22 Feb 2024 20:23:21 +0100 Subject: [PATCH] Account for pre-0.46 saves storing a gold value of 0 for everything --- components/esm3/formatversion.hpp | 1 + components/esm3/objectstate.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/components/esm3/formatversion.hpp b/components/esm3/formatversion.hpp index 9f499a7231..d90742a512 100644 --- a/components/esm3/formatversion.hpp +++ b/components/esm3/formatversion.hpp @@ -9,6 +9,7 @@ namespace ESM inline constexpr FormatVersion DefaultFormatVersion = 0; inline constexpr FormatVersion CurrentContentFormatVersion = 1; + inline constexpr FormatVersion MaxOldGoldValueFormatVersion = 5; inline constexpr FormatVersion MaxOldFogOfWarFormatVersion = 6; inline constexpr FormatVersion MaxUnoptimizedCharacterDataFormatVersion = 7; inline constexpr FormatVersion MaxOldTimeLeftFormatVersion = 8; diff --git a/components/esm3/objectstate.cpp b/components/esm3/objectstate.cpp index 25cbdc9a98..f8905cfaea 100644 --- a/components/esm3/objectstate.cpp +++ b/components/esm3/objectstate.cpp @@ -30,7 +30,11 @@ namespace ESM esm.getHNOT(mEnabled, "ENAB"); if (mVersion <= MaxOldCountFormatVersion) - esm.getHNOT(mRef.mCount, "COUN"); + { + if (mVersion <= MaxOldGoldValueFormatVersion) + mRef.mCount = std::max(1, mRef.mCount); + esm.getHNOT("COUN", mRef.mCount); + } mPosition = mRef.mPos; esm.getHNOT("POS_", mPosition.pos, mPosition.rot);