From ff8e9d6aadcbb08def41c10fe1abe99bc86b5172 Mon Sep 17 00:00:00 2001 From: Ian Curtis Date: Mon, 30 May 2016 23:10:56 +0000 Subject: [PATCH] Check for overflow. Fixes some fade effects --- Src/Graphics/New3D/PolyHeader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Src/Graphics/New3D/PolyHeader.cpp b/Src/Graphics/New3D/PolyHeader.cpp index 9cfa079..ab37e89 100644 --- a/Src/Graphics/New3D/PolyHeader.cpp +++ b/Src/Graphics/New3D/PolyHeader.cpp @@ -320,6 +320,10 @@ bool PolyHeader::AlphaTest() UINT8 PolyHeader::Transparency() { + if (header[6] & 0x800000) { // check top bit to see if its 1. Star wars is writing 1 for opaque, but the rest of the bits are garbage and are ignored + return 255; // without this check we get overflow. In the SDK, values are explicitly clamped to 0-32. + } + return (UINT8)((((header[6] >> 18) & 0x3F) * 255) / 32.f); }