From a692905eb273ae8c33ba1351e519b93dbf10f7fd Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Sat, 4 Jan 2020 15:00:40 +0000 Subject: COMMON: Add a function to simplify loading Windows executables --- graphics/fonts/winfont.cpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'graphics') diff --git a/graphics/fonts/winfont.cpp b/graphics/fonts/winfont.cpp index 6494f006b3..ad5b36ec23 100644 --- a/graphics/fonts/winfont.cpp +++ b/graphics/fonts/winfont.cpp @@ -77,27 +77,13 @@ static WinFontDirEntry readDirEntry(Common::SeekableReadStream &stream) { } bool WinFont::loadFromFON(const Common::String &fileName, const WinFontDirEntry &dirEntry) { - Common::WinResources *exe; - - // First try loading via the NE code - exe = new Common::NEResources(); - if (exe->loadFromEXE(fileName)) { - bool ok = loadFromEXE(exe, fileName, dirEntry); - delete exe; - return ok; - } - delete exe; + Common::WinResources *exe = Common::WinResources::createFromEXE(fileName); + if (!exe) + return false; - // Then try loading via the PE code - exe = new Common::PEResources(); - if (exe->loadFromEXE(fileName)) { - bool ok = loadFromEXE(exe, fileName, dirEntry); - delete exe; - return ok; - } + bool ok = loadFromEXE(exe, fileName, dirEntry); delete exe; - - return false; + return ok; } bool WinFont::loadFromEXE(Common::WinResources *exe, const Common::String &fileName, const WinFontDirEntry &dirEntry) { -- cgit v1.2.3