fix limb framelist parsing

* negative values mean "don't show cel",
* there's always at least one frame, much like prop's stateCount
This commit is contained in:
Jeremy Penner 2023-12-27 19:20:39 -05:00
parent 60d934509c
commit bf660d76cf

View file

@ -477,13 +477,13 @@ const decodeProp = (data) => {
} }
const decodeLimb = (data, limb) => { const decodeLimb = (data, limb) => {
let frameCount = data.getUint8(0) + 1
limb.frames = [] limb.frames = []
for (let iframe = 0; iframe < data.getUint8(0); iframe ++) { for (let iframe = 0; iframe < frameCount; iframe ++) {
limb.frames.push(data.getUint8(3 + iframe)) limb.frames.push(data.getInt8(3 + iframe))
} }
const celOffsetsOff = 4 + limb.frames.length const celOffsetsOff = 3 + frameCount
// I don't understand this at all, but it seems to be correct? const maxCelIndex = Math.max(...limb.frames)
const maxCelIndex = Math.max(...limb.frames) + 1
limb.cels = [] limb.cels = []
for (let icel = 0; icel <= maxCelIndex; icel ++) { for (let icel = 0; icel <= maxCelIndex; icel ++) {
const celOff = data.getUint16(celOffsetsOff + (icel * 2), LE) const celOff = data.getUint16(celOffsetsOff + (icel * 2), LE)