From 948c555ea616821ed7c2678ad406ed5bea392339 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Tue, 31 Dec 2019 19:19:42 +0000 Subject: ALL: Create all instances of NEResources and PEResources using new instead of on the stack Also adapted WinCursorGroup and MacMenu to reflect this. --- graphics/wincursor.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'graphics/wincursor.cpp') diff --git a/graphics/wincursor.cpp b/graphics/wincursor.cpp index 13d9bebfba..4cade1f5e2 100644 --- a/graphics/wincursor.cpp +++ b/graphics/wincursor.cpp @@ -242,8 +242,8 @@ WinCursorGroup::~WinCursorGroup() { delete cursors[i].cursor; } -WinCursorGroup *WinCursorGroup::createCursorGroup(Common::NEResources &exe, const Common::WinResourceID &id) { - Common::ScopedPtr stream(exe.getResource(Common::kWinGroupCursor, id)); +WinCursorGroup *WinCursorGroup::createCursorGroup(Common::NEResources *exe, const Common::WinResourceID &id) { + Common::ScopedPtr stream(exe->getResource(Common::kWinGroupCursor, id)); if (!stream || stream->size() <= 6) return 0; @@ -276,7 +276,7 @@ WinCursorGroup *WinCursorGroup::createCursorGroup(Common::NEResources &exe, cons stream->readUint32LE(); // data size uint32 cursorId = stream->readUint16LE(); - Common::ScopedPtr cursorStream(exe.getResource(Common::kWinCursor, cursorId)); + Common::ScopedPtr cursorStream(exe->getResource(Common::kWinCursor, cursorId)); if (!cursorStream) { delete group; return 0; @@ -298,8 +298,8 @@ WinCursorGroup *WinCursorGroup::createCursorGroup(Common::NEResources &exe, cons return group; } -WinCursorGroup *WinCursorGroup::createCursorGroup(Common::PEResources &exe, const Common::WinResourceID &id) { - Common::ScopedPtr stream(exe.getResource(Common::kWinGroupCursor, id)); +WinCursorGroup *WinCursorGroup::createCursorGroup(Common::PEResources *exe, const Common::WinResourceID &id) { + Common::ScopedPtr stream(exe->getResource(Common::kWinGroupCursor, id)); if (!stream || stream->size() <= 6) return 0; @@ -325,7 +325,7 @@ WinCursorGroup *WinCursorGroup::createCursorGroup(Common::PEResources &exe, cons stream->readUint32LE(); // data size uint32 cursorId = stream->readUint16LE(); - Common::ScopedPtr cursorStream(exe.getResource(Common::kWinCursor, cursorId)); + Common::ScopedPtr cursorStream(exe->getResource(Common::kWinCursor, cursorId)); if (!cursorStream) { delete group; return 0; -- cgit v1.2.3 From 5cd6812b9d53d532d12cfc81b6df144dc0e89d48 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Thu, 2 Jan 2020 22:32:03 +0000 Subject: GRAPHICS: Unify loading Windows cursor groups --- graphics/wincursor.cpp | 60 +------------------------------------------------- 1 file changed, 1 insertion(+), 59 deletions(-) (limited to 'graphics/wincursor.cpp') diff --git a/graphics/wincursor.cpp b/graphics/wincursor.cpp index 4cade1f5e2..7abd1a33ad 100644 --- a/graphics/wincursor.cpp +++ b/graphics/wincursor.cpp @@ -23,8 +23,6 @@ #include "common/ptr.h" #include "common/stream.h" #include "common/textconsole.h" -#include "common/winexe_ne.h" -#include "common/winexe_pe.h" #include "graphics/wincursor.h" @@ -242,63 +240,7 @@ WinCursorGroup::~WinCursorGroup() { delete cursors[i].cursor; } -WinCursorGroup *WinCursorGroup::createCursorGroup(Common::NEResources *exe, const Common::WinResourceID &id) { - Common::ScopedPtr stream(exe->getResource(Common::kWinGroupCursor, id)); - - if (!stream || stream->size() <= 6) - return 0; - - stream->skip(4); - uint32 cursorCount = stream->readUint16LE(); - if ((uint32)stream->size() < (6 + cursorCount * 14)) - return 0; - - WinCursorGroup *group = new WinCursorGroup(); - group->cursors.reserve(cursorCount); - - for (uint32 i = 0; i < cursorCount; i++) { - stream->readUint16LE(); // width - stream->readUint16LE(); // height - - // Plane count - if (stream->readUint16LE() != 1) { - delete group; - return 0; - } - - // Bits per pixel - // NE cursors can only be 1bpp - if (stream->readUint16LE() != 1) { - delete group; - return 0; - } - - stream->readUint32LE(); // data size - uint32 cursorId = stream->readUint16LE(); - - Common::ScopedPtr cursorStream(exe->getResource(Common::kWinCursor, cursorId)); - if (!cursorStream) { - delete group; - return 0; - } - - WinCursor *cursor = new WinCursor(); - if (!cursor->readFromStream(*cursorStream)) { - delete cursor; - delete group; - return 0; - } - - CursorItem item; - item.id = cursorId; - item.cursor = cursor; - group->cursors.push_back(item); - } - - return group; -} - -WinCursorGroup *WinCursorGroup::createCursorGroup(Common::PEResources *exe, const Common::WinResourceID &id) { +WinCursorGroup *WinCursorGroup::createCursorGroup(Common::WinResources *exe, const Common::WinResourceID &id) { Common::ScopedPtr stream(exe->getResource(Common::kWinGroupCursor, id)); if (!stream || stream->size() <= 6) -- cgit v1.2.3