From 505250f6ecc83bfd62830065d21a46687f1e2bbf Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 22 Nov 2016 15:46:32 +0100 Subject: [PATCH] Do not use architecture dependent type size_t in esm format (Fixes #3633) --- components/esm/animationstate.cpp | 13 ++++++++++++- components/esm/animationstate.hpp | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/components/esm/animationstate.cpp b/components/esm/animationstate.cpp index 79dcad757..37ea0b186 100644 --- a/components/esm/animationstate.cpp +++ b/components/esm/animationstate.cpp @@ -21,7 +21,18 @@ namespace ESM anim.mGroup = esm.getHString(); esm.getHNOT(anim.mTime, "TIME"); esm.getHNOT(anim.mAbsolute, "ABST"); - esm.getHNT(anim.mLoopCount, "COUN"); + + 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; + } mScriptedAnims.push_back(anim); } diff --git a/components/esm/animationstate.hpp b/components/esm/animationstate.hpp index ce2c437df..2a19eff63 100644 --- a/components/esm/animationstate.hpp +++ b/components/esm/animationstate.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace ESM { @@ -20,7 +21,7 @@ namespace ESM std::string mGroup; float mTime; bool mAbsolute; - size_t mLoopCount; + uint64_t mLoopCount; }; typedef std::vector ScriptedAnimations;