From fd210b4b0b65e5a1e674a78c7c92d380650d0963 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 5 Dec 2020 21:31:34 +0100 Subject: [PATCH] Clean up Cl2ApplyTrans --- Source/engine.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/engine.cpp b/Source/engine.cpp index bd4b7fc29..654a78ee3 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -2701,9 +2701,9 @@ void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel) assert(ttbl != NULL); for (i = 1; i <= nCel; i++) { - pFrameTable = (DWORD *)&p[4 * i]; - dst = &p[pFrameTable[0] + 10]; - nDataSize = CelGetFrameSize(p, i) - 10; + pFrameTable = (DWORD *)p; + dst = &p[SwapLE32(pFrameTable[i]) + 10]; + nDataSize = SwapLE32(pFrameTable[i + 1]) - SwapLE32(pFrameTable[i]) - 10; while (nDataSize) { width = *dst++; nDataSize--; @@ -2718,10 +2718,9 @@ void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel) } else { nDataSize -= width; assert(nDataSize >= 0); - while (width) { + while (width--) { *dst = ttbl[*dst]; dst++; - width--; } } }