From 055de8617053af21759351f270de824e7a530170 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 3 Mar 2018 20:15:40 -1000 Subject: [PATCH] ANIM serialization fix --- DataSpec/DNACommon/DNACommon.cpp | 4 ++-- DataSpec/DNACommon/DNACommon.hpp | 2 +- DataSpec/DNAMP1/ANIM.cpp | 6 +++--- DataSpec/DNAMP1/ANIM.hpp | 6 ++---- Runtime/Character/CFBStreamedCompression.cpp | 1 + 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/DataSpec/DNACommon/DNACommon.cpp b/DataSpec/DNACommon/DNACommon.cpp index 039a464c9..10b45f0e0 100644 --- a/DataSpec/DNACommon/DNACommon.cpp +++ b/DataSpec/DNACommon/DNACommon.cpp @@ -268,9 +268,9 @@ void WordBitmap::write(athena::io::IStreamWriter& writer) const for (atUint32 word : m_words) writer.writeUint32Big(word); } -size_t WordBitmap::binarySize(size_t __isz) const +void WordBitmap::binarySize(size_t& __isz) const { - return __isz + m_words.size() * 4; + __isz += m_words.size() * 4; } } diff --git a/DataSpec/DNACommon/DNACommon.hpp b/DataSpec/DNACommon/DNACommon.hpp index f8e10bd5b..182b42d1d 100644 --- a/DataSpec/DNACommon/DNACommon.hpp +++ b/DataSpec/DNACommon/DNACommon.hpp @@ -306,7 +306,7 @@ public: void read(athena::io::IStreamReader& reader, size_t bitCount); void write(athena::io::IStreamWriter& writer) const; void reserve(size_t bitCount) { m_words.reserve((bitCount + 31) / 32); } - size_t binarySize(size_t __isz) const; + void binarySize(size_t& __isz) const; size_t getBitCount() const {return m_bitCount;} bool getBit(size_t idx) const { diff --git a/DataSpec/DNAMP1/ANIM.cpp b/DataSpec/DNAMP1/ANIM.cpp index 9d3b665e3..61d69d622 100644 --- a/DataSpec/DNAMP1/ANIM.cpp +++ b/DataSpec/DNAMP1/ANIM.cpp @@ -459,7 +459,6 @@ void ANIM::ANIM2::Enumerate(athena::io::IStreamWriter& writer) head.binarySize(scratchSize); keyBmp.binarySize(scratchSize); scratchSize += bsSize; - head.scratchSize = scratchSize; if (m_version == 3) { for (const std::pair& bone : bones) @@ -468,7 +467,7 @@ void ANIM::ANIM2::Enumerate(athena::io::IStreamWriter& writer) desc.keyCount1 = keyframeCount; if (bone.second) desc.keyCount2 = keyframeCount; - head.scratchSize = desc.binarySize(head.scratchSize); + desc.binarySize(scratchSize); } } else @@ -479,9 +478,10 @@ void ANIM::ANIM2::Enumerate(athena::io::IStreamWriter& writer) desc.keyCount1 = keyframeCount; if (bone.second) desc.keyCount2 = keyframeCount; - head.scratchSize = desc.binarySize(head.scratchSize); + desc.binarySize(scratchSize); } } + head.scratchSize = scratchSize; head.write(writer); keyBmp.write(writer); diff --git a/DataSpec/DNAMP1/ANIM.hpp b/DataSpec/DNAMP1/ANIM.hpp index 31f1a21e4..353f02d84 100644 --- a/DataSpec/DNAMP1/ANIM.hpp +++ b/DataSpec/DNAMP1/ANIM.hpp @@ -133,12 +133,11 @@ struct ANIM : BigDNA writer.writeUByte(qTZ); } } - size_t binarySize(size_t __isz) const + void binarySize(size_t& __isz) const { __isz += 17; if (keyCount2) __isz += 9; - return __isz; } }; @@ -185,12 +184,11 @@ struct ANIM : BigDNA writer.writeUint32Big(QinitTZ); } } - size_t binarySize(size_t __isz) const + void binarySize(size_t& __isz) const { __isz += 24; if (keyCount2) __isz += 12; - return __isz; } }; }; diff --git a/Runtime/Character/CFBStreamedCompression.cpp b/Runtime/Character/CFBStreamedCompression.cpp index f7c9874ae..99bdaded2 100644 --- a/Runtime/Character/CFBStreamedCompression.cpp +++ b/Runtime/Character/CFBStreamedCompression.cpp @@ -88,6 +88,7 @@ std::unique_ptr CFBStreamedCompression::GetRotationsAndOffsets(u32 words, u32 bsWords = ComputeBitstreamWords(chans); u32* bsPtr = reinterpret_cast(bs); + size_t wordsz = bsPtr - ret.get(); for (u32 w=0 ; w