[Scummvm-git-logs] scummvm master -> fe6772a9e5cedcfd4bc17ac74fef021eeb2e20d9
sev-
sev at scummvm.org
Thu Mar 25 19:52:32 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
fe6772a9e5 BURIED: Simplify the executable loading code
Commit: fe6772a9e5cedcfd4bc17ac74fef021eeb2e20d9
https://github.com/scummvm/scummvm/commit/fe6772a9e5cedcfd4bc17ac74fef021eeb2e20d9
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2021-03-25T20:52:28+01:00
Commit Message:
BURIED: Simplify the executable loading code
Changed paths:
R engines/buried/database.cpp
R engines/buried/database.h
engines/buried/buried.cpp
engines/buried/buried.h
engines/buried/graphics.cpp
engines/buried/module.mk
diff --git a/engines/buried/buried.cpp b/engines/buried/buried.cpp
index 2c60f49862..d07b1da606 100644
--- a/engines/buried/buried.cpp
+++ b/engines/buried/buried.cpp
@@ -32,12 +32,14 @@
#include "common/system.h"
#include "common/textconsole.h"
#include "common/translation.h"
+#include "common/winexe_ne.h"
+#include "common/winexe_pe.h"
#include "engines/util.h"
+#include "graphics/wincursor.h"
#include "gui/message.h"
#include "buried/buried.h"
#include "buried/console.h"
-#include "buried/database.h"
#include "buried/frame_window.h"
#include "buried/graphics.h"
#include "buried/message.h"
@@ -99,24 +101,29 @@ Common::Error BuriedEngine::run() {
}
if (isWin95()) {
- _mainEXE = new DatabasePE();
- _library = new DatabasePE();
- } else if (isCompressed()) {
- _mainEXE = new DatabaseNECompressed();
- _library = new DatabaseNECompressed();
+ _mainEXE = new Common::PEResources();
+ _library = new Common::PEResources();
} else {
- _mainEXE = new DatabaseNE();
+ _mainEXE = new Common::NEResources();
// Demo only uses the main EXE
if (!isDemo())
- _library = new DatabaseNE();
+ _library = new Common::NEResources();
}
- if (!_mainEXE->load(getEXEName()))
- error("Failed to load main EXE '%s'", getEXEName().c_str());
+ if (isCompressed()) {
+ if (!_mainEXE->loadFromCompressedEXE(getEXEName()))
+ error("Failed to load main EXE '%s'", getEXEName().c_str());
- if (_library && !_library->load(getLibraryName()))
- error("Failed to load library DLL '%s'", getLibraryName().c_str());
+ if (_library && !_library->loadFromCompressedEXE(getLibraryName()))
+ error("Failed to load library DLL '%s'", getLibraryName().c_str());
+ } else {
+ if (!_mainEXE->loadFromEXE(getEXEName()))
+ error("Failed to load main EXE '%s'", getEXEName().c_str());
+
+ if (_library && !_library->loadFromEXE(getLibraryName()))
+ error("Failed to load library DLL '%s'", getLibraryName().c_str());
+ }
syncSoundSettings();
@@ -161,7 +168,31 @@ Common::Error BuriedEngine::run() {
}
Common::String BuriedEngine::getString(uint32 stringID) {
- return _mainEXE->loadString(stringID);
+ bool continueReading = true;
+ Common::String result;
+
+ while (continueReading) {
+ Common::String string = _mainEXE->loadString(stringID);
+
+ if (string.empty())
+ return "";
+
+ if (string[0] == '!') {
+ string.deleteChar(0);
+ stringID++;
+ } else {
+ continueReading = false;
+ }
+
+ result += string;
+ }
+
+ // Change any \r to \n
+ for (uint32 i = 0; i < result.size(); i++)
+ if (result[i] == '\r')
+ result.setChar('\n', i);
+
+ return result;
}
Common::String BuriedEngine::getFilePath(uint32 stringID) {
@@ -192,45 +223,49 @@ Common::String BuriedEngine::getFilePath(uint32 stringID) {
return output;
}
+Graphics::WinCursorGroup *BuriedEngine::getCursorGroup(uint32 cursorGroupID) {
+ return Graphics::WinCursorGroup::createCursorGroup(_mainEXE, cursorGroupID);
+}
+
Common::SeekableReadStream *BuriedEngine::getBitmapStream(uint32 bitmapID) {
// The demo's bitmaps are in the main EXE
if (isDemo())
- return _mainEXE->getBitmapStream(bitmapID);
+ return _mainEXE->getResource(Common::kWinBitmap, bitmapID);
// The rest in the database library
- return _library->getBitmapStream(bitmapID);
+ return _library->getResource(Common::kWinBitmap, bitmapID);
}
Common::SeekableReadStream *BuriedEngine::getNavData(uint32 resourceID) {
- return _mainEXE->getResourceStream("NAVDATA", resourceID);
+ return _mainEXE->getResource(Common::String("NAVDATA"), resourceID);
}
Common::SeekableReadStream *BuriedEngine::getSndData(uint32 resourceID) {
- return _mainEXE->getResourceStream("SNDDATA", resourceID);
+ return _mainEXE->getResource(Common::String("SNDDATA"), resourceID);
}
Common::SeekableReadStream *BuriedEngine::getAnimData(uint32 resourceID) {
- return _mainEXE->getResourceStream("ANIMDATA", resourceID);
+ return _mainEXE->getResource(Common::String("ANIMDATA"), resourceID);
}
Common::SeekableReadStream *BuriedEngine::getAIData(uint32 resourceID) {
- return _mainEXE->getResourceStream("AIDATA", resourceID);
+ return _mainEXE->getResource(Common::String("AIDATA"), resourceID);
}
Common::SeekableReadStream *BuriedEngine::getItemData(uint32 resourceID) {
- return _mainEXE->getResourceStream("ITEMDATA", resourceID);
+ return _mainEXE->getResource(Common::String("ITEMDATA"), resourceID);
}
Common::SeekableReadStream *BuriedEngine::getBookData(uint32 resourceID) {
- return _mainEXE->getResourceStream("BOOKDATA", resourceID);
+ return _mainEXE->getResource(Common::String("BOOKDATA"), resourceID);
}
Common::SeekableReadStream *BuriedEngine::getFileBCData(uint32 resourceID) {
- return _mainEXE->getResourceStream("FILEBCDATA", resourceID);
+ return _mainEXE->getResource(Common::String("FILEBCDATA"), resourceID);
}
Common::SeekableReadStream *BuriedEngine::getINNData(uint32 resourceID) {
- return _mainEXE->getResourceStream("INNDATA", resourceID);
+ return _mainEXE->getResource(Common::String("INNDATA"), resourceID);
}
uint BuriedEngine::createTimer(Window *window, uint period) {
@@ -442,7 +477,19 @@ void BuriedEngine::setTransitionSpeed(int newSpeed) {
}
uint32 BuriedEngine::getVersion() {
- return _mainEXE->getVersion();
+ if (isWin95()) {
+ // Not really needed, it should only be 1.1
+ return MAKEVERSION(1, 1, 0, 0);
+ }
+
+ Common::SeekableReadStream *res = _mainEXE->getResource(Common::kWinVersion, 1);
+ Common::WinResources::VersionInfo *versionInfo = _mainEXE->parseVersionInfo(res);
+
+ uint32 result = MAKEVERSION(versionInfo->fileVersion[0], versionInfo->fileVersion[1], versionInfo->fileVersion[2], versionInfo->fileVersion[3]);
+ delete versionInfo;
+ delete res;
+
+ return result;
}
Common::String BuriedEngine::getFilePath(int timeZone, int environment, int fileOffset) {
diff --git a/engines/buried/buried.h b/engines/buried/buried.h
index 5c087cd943..5c3000b509 100644
--- a/engines/buried/buried.h
+++ b/engines/buried/buried.h
@@ -38,9 +38,14 @@ struct ADGameDescription;
namespace Common {
class SeekableReadStream;
class Serializer;
+class WinResources;
class WriteStream;
}
+namespace Graphics {
+struct WinCursorGroup;
+}
+
namespace Buried {
enum {
@@ -51,7 +56,6 @@ enum {
};
class BuriedConsole;
-class Database;
struct GlobalFlags;
class GraphicsManager;
struct Location;
@@ -86,6 +90,7 @@ public:
Common::String getString(uint32 stringID);
Common::String getFilePath(uint32 stringID);
Common::String getFilePath(int timeZone, int environment, int fileOffset);
+ Graphics::WinCursorGroup *getCursorGroup(uint32 cursorGroupID);
Common::SeekableReadStream *getBitmapStream(uint32 bitmapID);
Common::SeekableReadStream *getNavData(uint32 resourceID);
Common::SeekableReadStream *getSndData(uint32 resourceID);
@@ -102,7 +107,6 @@ public:
uint32 computeFileNameResourceID(int timeZone, int environment, int fileOffset);
GraphicsManager *_gfx;
- Database *_mainEXE;
SoundManager *_sound;
Window *_mainWindow; // Only one main window is supported.
Window *_focusedWindow;
@@ -147,7 +151,7 @@ public:
Common::Error runLoadDialog();
private:
- Database *_library;
+ Common::WinResources *_mainEXE, *_library;
struct Timer {
Window *owner;
diff --git a/engines/buried/database.cpp b/engines/buried/database.cpp
deleted file mode 100644
index 1fc3d7e918..0000000000
--- a/engines/buried/database.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/stream.h"
-#include "common/winexe.h"
-#include "common/winexe_ne.h"
-#include "common/winexe_pe.h"
-#include "graphics/wincursor.h"
-
-#include "buried/buried.h"
-#include "buried/database.h"
-
-namespace Buried {
-
-DatabaseNE::DatabaseNE() {
- _exe = new Common::NEResources();
-}
-
-DatabaseNE::~DatabaseNE() {
- delete _exe;
-}
-
-bool DatabaseNE::load(const Common::String &fileName) {
- return _exe->loadFromEXE(fileName);
-}
-
-void DatabaseNE::close() {
- _exe->clear();
-}
-
-Common::String DatabaseNE::loadString(uint32 stringID) {
- bool continueReading = true;
- Common::String result;
-
- while (continueReading) {
- Common::String string = _exe->loadString(stringID);
-
- if (string.empty())
- return "";
-
- if (string[0] == '!') {
- string.deleteChar(0);
- stringID++;
- } else {
- continueReading = false;
- }
-
- result += string;
- }
-
- // Change any \r to \n
- for (uint32 i = 0; i < result.size(); i++)
- if (result[i] == '\r')
- result.setChar('\n', i);
-
- return result;
-}
-
-Common::SeekableReadStream *DatabaseNE::getBitmapStream(uint32 bitmapID) {
- return _exe->getResource(Common::kWinBitmap, bitmapID);
-}
-
-Graphics::WinCursorGroup *DatabaseNE::getCursorGroup(uint32 cursorGroupID) {
- return Graphics::WinCursorGroup::createCursorGroup(_exe, cursorGroupID);
-}
-
-Common::SeekableReadStream *DatabaseNE::getResourceStream(const Common::String &resourceType, uint32 resourceID) {
- return _exe->getResource(resourceType, resourceID);
-}
-
-uint32 DatabaseNE::getVersion() {
- Common::SeekableReadStream *res = _exe->getResource(Common::kWinVersion, 1);
- Common::WinResources::VersionInfo *versionInfo = _exe->parseVersionInfo(res);
-
- uint32 result = MAKEVERSION(versionInfo->fileVersion[0], versionInfo->fileVersion[1], versionInfo->fileVersion[2], versionInfo->fileVersion[3]);
- delete versionInfo;
- delete res;
-
- return result;
-}
-
-bool DatabaseNECompressed::load(const Common::String &fileName) {
- return _exe->loadFromCompressedEXE(fileName);
-}
-
-DatabasePE::DatabasePE() {
- _exe = new Common::PEResources();
-}
-
-DatabasePE::~DatabasePE() {
- delete _exe;
-}
-
-bool DatabasePE::load(const Common::String &fileName) {
- return _exe->loadFromEXE(fileName);
-}
-
-void DatabasePE::close() {
- _exe->clear();
-}
-
-Common::String DatabasePE::loadString(uint32 stringID) {
- bool continueReading = true;
- Common::String result;
-
- while (continueReading) {
- Common::String string = _exe->loadString(stringID);
-
- if (string.empty())
- return "";
-
- if (string[0] == '!') {
- string.deleteChar(0);
- stringID++;
- } else {
- continueReading = false;
- }
-
- result += string;
- }
-
- // Change any \r to \n
- for (uint32 i = 0; i < result.size(); i++)
- if (result[i] == '\r')
- result.setChar('\n', i);
-
- return result;
-}
-
-Common::SeekableReadStream *DatabasePE::getBitmapStream(uint32 bitmapID) {
- return _exe->getResource(Common::kWinBitmap, bitmapID);
-}
-
-Graphics::WinCursorGroup *DatabasePE::getCursorGroup(uint32 cursorGroupID) {
- return Graphics::WinCursorGroup::createCursorGroup(_exe, cursorGroupID);
-}
-
-Common::SeekableReadStream *DatabasePE::getResourceStream(const Common::String &resourceType, uint32 resourceID) {
- return _exe->getResource(resourceType, resourceID);
-}
-
-uint32 DatabasePE::getVersion() {
- // Not really needed, it should only be 1.1
- return MAKEVERSION(1, 1, 0, 0);
-}
-
-} // End of namespace Buried
diff --git a/engines/buried/database.h b/engines/buried/database.h
deleted file mode 100644
index 0559e3339e..0000000000
--- a/engines/buried/database.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef BURIED_DATABASE_H
-#define BURIED_DATABASE_H
-
-namespace Common {
-class WinResources;
-class String;
-}
-
-namespace Graphics {
-struct WinCursorGroup;
-}
-
-namespace Buried {
-
-/**
- * Simple wrapper class around the game's binaries to load
- * data between them (without needing too much code different
- * between Win16 and Win32 versions).
- */
-class Database {
-public:
- virtual ~Database() {}
-
- virtual bool load(const Common::String &fileName) = 0;
- virtual void close() = 0;
-
- virtual Common::String loadString(uint32 stringID) = 0;
- virtual Common::SeekableReadStream *getBitmapStream(uint32 bitmapID) = 0;
- virtual Graphics::WinCursorGroup *getCursorGroup(uint32 cursorGroupID) = 0;
- virtual Common::SeekableReadStream *getResourceStream(const Common::String &resourceType, uint32 resourceID) = 0;
- virtual uint32 getVersion() = 0;
-};
-
-/**
- * A database loaded from an NE executable/library
- */
-class DatabaseNE : public Database {
-public:
- DatabaseNE();
- virtual ~DatabaseNE();
-
- virtual bool load(const Common::String &fileName);
- void close();
-
- Common::String loadString(uint32 stringID);
- Common::SeekableReadStream *getBitmapStream(uint32 bitmapID);
- Graphics::WinCursorGroup *getCursorGroup(uint32 cursorGroupID);
- Common::SeekableReadStream *getResourceStream(const Common::String &resourceType, uint32 resourceID);
- uint32 getVersion();
-
-protected:
- Common::WinResources *_exe;
-};
-
-/**
- * A database loaded from a compressed NE executable/library
- */
-class DatabaseNECompressed : public DatabaseNE {
-public:
- bool load(const Common::String &fileName);
-};
-
-class DatabasePE : public Database {
-public:
- DatabasePE();
- ~DatabasePE();
-
- bool load(const Common::String &fileName);
- void close();
-
- Common::String loadString(uint32 stringID);
- Common::SeekableReadStream *getBitmapStream(uint32 bitmapID);
- Graphics::WinCursorGroup *getCursorGroup(uint32 cursorGroupID);
- Common::SeekableReadStream *getResourceStream(const Common::String &resourceType, uint32 resourceID);
- uint32 getVersion();
-
-private:
- Common::WinResources *_exe;
-};
-
-} // End of namespace Buried
-
-#endif
diff --git a/engines/buried/graphics.cpp b/engines/buried/graphics.cpp
index e6e42ff42d..9e6a404932 100644
--- a/engines/buried/graphics.cpp
+++ b/engines/buried/graphics.cpp
@@ -40,7 +40,6 @@
#include "image/bmp.h"
#include "buried/buried.h"
-#include "buried/database.h"
#include "buried/graphics.h"
#include "buried/window.h"
@@ -237,7 +236,7 @@ Cursor GraphicsManager::setCursor(Cursor newCursor) {
} else if (newCursor == kCursorWait) {
cursor = Graphics::makeBusyWinCursor();
} else {
- cursorGroup = _vm->_mainEXE->getCursorGroup(newCursor);
+ cursorGroup = _vm->getCursorGroup(newCursor);
if (!cursorGroup)
return kCursorNone;
diff --git a/engines/buried/module.mk b/engines/buried/module.mk
index e9ef3eda5b..5e004ab62b 100644
--- a/engines/buried/module.mk
+++ b/engines/buried/module.mk
@@ -8,7 +8,6 @@ MODULE_OBJS = \
complete.o \
console.o \
credits.o \
- database.o \
death.o \
frame_window.o \
gameui.o \
More information about the Scummvm-git-logs
mailing list