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

Savegame: Don't write stat modifiers that are zero

This commit is contained in:
scrawl 2014-06-19 17:17:26 +02:00
parent 11b05c352f
commit 218f916d6d

View File

@ -12,7 +12,8 @@ namespace ESM
struct StatState struct StatState
{ {
T mBase; T mBase;
T mMod; T mMod; // Note: can either be the modifier, or the modified value.
// A bit inconsistent, but we can't fix this without breaking compatibility.
T mCurrent; T mCurrent;
T mDamage; T mDamage;
float mProgress; float mProgress;
@ -30,7 +31,9 @@ namespace ESM
void StatState<T>::load (ESMReader &esm) void StatState<T>::load (ESMReader &esm)
{ {
esm.getHNT (mBase, "STBA"); esm.getHNT (mBase, "STBA");
esm.getHNT (mMod, "STMO");
mMod = 0;
esm.getHNOT (mMod, "STMO");
mCurrent = 0; mCurrent = 0;
esm.getHNOT (mCurrent, "STCU"); esm.getHNOT (mCurrent, "STCU");
mDamage = 0; mDamage = 0;
@ -43,7 +46,9 @@ namespace ESM
void StatState<T>::save (ESMWriter &esm) const void StatState<T>::save (ESMWriter &esm) const
{ {
esm.writeHNT ("STBA", mBase); esm.writeHNT ("STBA", mBase);
esm.writeHNT ("STMO", mMod);
if (mMod != 0)
esm.writeHNT ("STMO", mMod);
if (mCurrent) if (mCurrent)
esm.writeHNT ("STCU", mCurrent); esm.writeHNT ("STCU", mCurrent);
@ -56,4 +61,4 @@ namespace ESM
} }
} }
#endif #endif