From debe25907419990337ae1f631fa04c8615fb68a4 Mon Sep 17 00:00:00 2001 From: sluicebox Date: Thu, 12 Sep 2019 12:02:56 -0700 Subject: SCI32: Fix loading system font for Mac games Fixes GK1 Mac crash on load due to reading hard-coded little endian font data as big endian --- engines/sci/graphics/font.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/graphics/font.cpp b/engines/sci/graphics/font.cpp index 8dd6cbde5d..97627ec00b 100644 --- a/engines/sci/graphics/font.cpp +++ b/engines/sci/graphics/font.cpp @@ -185,7 +185,7 @@ static const byte sci32SystemFont[] = { }; #endif - GfxFontFromResource::GfxFontFromResource(ResourceManager *resMan, GfxScreen *screen, GuiResourceId resourceId) +GfxFontFromResource::GfxFontFromResource(ResourceManager *resMan, GfxScreen *screen, GuiResourceId resourceId) : _resourceId(resourceId), _screen(screen), _resMan(resMan) { if (getSciVersion() < SCI_VERSION_2) { assert(resourceId != -1); @@ -211,12 +211,22 @@ static const byte sci32SystemFont[] = { } #endif - _numChars = _resourceData.getUint16SE32At(2); - _fontHeight = _resourceData.getUint16SE32At(4); + if (_resource) { + _numChars = _resourceData.getUint16SE32At(2); + _fontHeight = _resourceData.getUint16SE32At(4); + } else { + _numChars = _resourceData.getUint16LEAt(2); + _fontHeight = _resourceData.getUint16LEAt(4); + } _chars = new Charinfo[_numChars]; // filling info for every char for (int16 i = 0; i < _numChars; i++) { - _chars[i].offset = _resourceData.getUint16SE32At(6 + i * 2); + uint32 charOffsetIndex = 6 + i * 2; + if (_resource) { + _chars[i].offset = _resourceData.getUint16SE32At(charOffsetIndex); + } else { + _chars[i].offset = _resourceData.getUint16LEAt(charOffsetIndex); + } _chars[i].width = _resourceData.getUint8At(_chars[i].offset); _chars[i].height = _resourceData.getUint8At(_chars[i].offset + 1); } -- cgit v1.2.3