diff options
-rw-r--r-- | common/module.mk | 5 | ||||
-rw-r--r-- | common/winexe.cpp | 84 | ||||
-rw-r--r-- | common/winexe.h | 74 | ||||
-rw-r--r-- | common/winexe_ne.cpp (renamed from common/ne_exe.cpp) | 63 | ||||
-rw-r--r-- | common/winexe_ne.h (renamed from common/ne_exe.h) | 46 | ||||
-rw-r--r-- | common/winexe_pe.cpp (renamed from common/pe_exe.cpp) | 75 | ||||
-rw-r--r-- | common/winexe_pe.h (renamed from common/pe_exe.h) | 61 | ||||
-rw-r--r-- | engines/mohawk/cursors.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/he/resource_he.h | 2 | ||||
-rw-r--r-- | graphics/fonts/winfont.cpp | 2 |
10 files changed, 201 insertions, 213 deletions
diff --git a/common/module.mk b/common/module.mk index 6cbb40e282..a57de6a4b8 100644 --- a/common/module.mk +++ b/common/module.mk @@ -17,8 +17,6 @@ MODULE_OBJS := \ memorypool.o \ md5.o \ mutex.o \ - ne_exe.o \ - pe_exe.o \ random.o \ rational.o \ str.o \ @@ -30,6 +28,9 @@ MODULE_OBJS := \ unarj.o \ unzip.o \ util.o \ + winexe.o \ + winexe_ne.o \ + winexe_pe.o \ xmlparser.o \ zlib.o diff --git a/common/winexe.cpp b/common/winexe.cpp new file mode 100644 index 0000000000..de53ae6490 --- /dev/null +++ b/common/winexe.cpp @@ -0,0 +1,84 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +#include "common/str.h" +#include "common/winexe.h" + +namespace Common { + +WinResourceID &WinResourceID::operator=(String string) { + _name = string; + _idType = kIDTypeString; + return *this; +} + +WinResourceID &WinResourceID::operator=(uint32 x) { + _id = x; + _idType = kIDTypeNumerical; + return *this; +} + +bool WinResourceID::operator==(const String &x) const { + return _idType == kIDTypeString && _name.equalsIgnoreCase(x); +} + +bool WinResourceID::operator==(const uint32 &x) const { + return _idType == kIDTypeNumerical && _id == x; +} + +bool WinResourceID::operator==(const WinResourceID &x) const { + if (_idType != x._idType) + return false; + if (_idType == kIDTypeString) + return _name.equalsIgnoreCase(x._name); + if (_idType == kIDTypeNumerical) + return _id == x._id; + return true; +} + +String WinResourceID::getString() const { + if (_idType != kIDTypeString) + return ""; + + return _name; +} + +uint32 WinResourceID::getID() const { + if (_idType != kIDTypeNumerical) + return 0xffffffff; + + return _idType; +} + +String WinResourceID::toString() const { + if (_idType == kIDTypeString) + return _name; + else if (_idType == kIDTypeNumerical) + return String::format("%08x", _id); + + return ""; +} + +} // End of namespace Common diff --git a/common/winexe.h b/common/winexe.h new file mode 100644 index 0000000000..3567a037e1 --- /dev/null +++ b/common/winexe.h @@ -0,0 +1,74 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +#ifndef COMMON_WINEXE_H +#define COMMON_WINEXE_H + +#include "common/hash-str.h" + +namespace Common { + +class String; + +class WinResourceID { +public: + WinResourceID() { _idType = kIDTypeNull; } + WinResourceID(String x) { _idType = kIDTypeString; _name = x; } + WinResourceID(uint32 x) { _idType = kIDTypeNumerical; _id = x; } + + WinResourceID &operator=(String string); + WinResourceID &operator=(uint32 x); + + bool operator==(const String &x) const; + bool operator==(const uint32 &x) const; + bool operator==(const WinResourceID &x) const; + + String getString() const; + uint32 getID() const; + String toString() const; + +private: + /** An ID Type. */ + enum IDType { + kIDTypeNull, ///< No type set + kIDTypeNumerical, ///< A numerical ID. + kIDTypeString ///< A string ID. + } _idType; + + String _name; ///< The resource's string ID. + uint32 _id; ///< The resource's numerical ID. +}; + +struct WinResourceID_Hash { + uint operator()(const WinResourceID &id) const { return hashit(id.toString()); } +}; + +struct WinResourceID_EqualTo { + bool operator()(const WinResourceID &id1, const WinResourceID &id2) const { return id1 == id2; } +}; + +} // End of namespace Common + +#endif diff --git a/common/ne_exe.cpp b/common/winexe_ne.cpp index 34bb551b06..8a2b07b4d0 100644 --- a/common/ne_exe.cpp +++ b/common/winexe_ne.cpp @@ -26,9 +26,9 @@ #include "common/debug.h" #include "common/file.h" #include "common/memstream.h" -#include "common/ne_exe.h" #include "common/str.h" #include "common/stream.h" +#include "common/winexe_ne.h" namespace Common { @@ -174,59 +174,6 @@ void NECursor::clear() { delete[] _surface; _surface = 0; } -NEResourceID &NEResourceID::operator=(String string) { - _name = string; - _idType = kIDTypeString; - return *this; -} - -NEResourceID &NEResourceID::operator=(uint16 x) { - _id = x; - _idType = kIDTypeNumerical; - return *this; -} - -bool NEResourceID::operator==(const String &x) const { - return _idType == kIDTypeString && _name.equalsIgnoreCase(x); -} - -bool NEResourceID::operator==(const uint16 &x) const { - return _idType == kIDTypeNumerical && _id == x; -} - -bool NEResourceID::operator==(const NEResourceID &x) const { - if (_idType != x._idType) - return false; - if (_idType == kIDTypeString) - return _name.equalsIgnoreCase(x._name); - if (_idType == kIDTypeNumerical) - return _id == x._id; - return true; -} - -String NEResourceID::getString() const { - if (_idType != kIDTypeString) - return ""; - - return _name; -} - -uint16 NEResourceID::getID() const { - if (_idType != kIDTypeNumerical) - return 0xffff; - - return _idType; -} - -String NEResourceID::toString() const { - if (_idType == kIDTypeString) - return _name; - else if (_idType == kIDTypeNumerical) - return String::format("%04x", _id); - - return ""; -} - NEResources::NEResources() { _exe = 0; } @@ -464,7 +411,7 @@ String NEResources::getResourceString(SeekableReadStream &exe, uint32 offset) { return string; } -const NEResources::Resource *NEResources::findResource(uint16 type, NEResourceID id) const { +const NEResources::Resource *NEResources::findResource(uint16 type, WinResourceID id) const { for (List<Resource>::const_iterator it = _resources.begin(); it != _resources.end(); ++it) if (it->type == type && it->id == id) return &*it; @@ -472,7 +419,7 @@ const NEResources::Resource *NEResources::findResource(uint16 type, NEResourceID return 0; } -SeekableReadStream *NEResources::getResource(uint16 type, NEResourceID id) { +SeekableReadStream *NEResources::getResource(uint16 type, WinResourceID id) { const Resource *res = findResource(type, id); if (!res) @@ -482,8 +429,8 @@ SeekableReadStream *NEResources::getResource(uint16 type, NEResourceID id) { return _exe->readStream(res->size); } -const Array<NEResourceID> NEResources::getIDList(uint16 type) const { - Array<NEResourceID> idArray; +const Array<WinResourceID> NEResources::getIDList(uint16 type) const { + Array<WinResourceID> idArray; for (List<Resource>::const_iterator it = _resources.begin(); it != _resources.end(); ++it) if (it->type == type) diff --git a/common/ne_exe.h b/common/winexe_ne.h index 545c8e5eff..0c3d5293ab 100644 --- a/common/ne_exe.h +++ b/common/winexe_ne.h @@ -23,11 +23,12 @@ * */ -#ifndef COMMON_NE_EXE_H -#define COMMON_NE_EXE_H +#ifndef COMMON_WINEXE_NE_H +#define COMMON_WINEXE_NE_H #include "common/array.h" #include "common/list.h" +#include "common/winexe.h" namespace Common { @@ -74,38 +75,9 @@ private: void clear(); }; -class NEResourceID { -public: - NEResourceID() { _idType = kIDTypeNull; } - NEResourceID(String x) { _idType = kIDTypeString; _name = x; } - NEResourceID(uint16 x) { _idType = kIDTypeNumerical; _id = x; } - - NEResourceID &operator=(String string); - NEResourceID &operator=(uint16 x); - - bool operator==(const String &x) const; - bool operator==(const uint16 &x) const; - bool operator==(const NEResourceID &x) const; - - String getString() const; - uint16 getID() const; - String toString() const; - -private: - /** An ID Type. */ - enum IDType { - kIDTypeNull, ///< No type set - kIDTypeNumerical, ///< A numerical ID. - kIDTypeString ///< A string ID. - } _idType; - - String _name; ///< The resource's string ID. - uint16 _id; ///< The resource's numerical ID. -}; - /** A New Executable cursor group. */ struct NECursorGroup { - NEResourceID id; + WinResourceID id; Array<NECursor *> cursors; ///< The cursors. }; @@ -161,15 +133,15 @@ public: const Array<NECursorGroup> &getCursors() const; /** Return a list of resources for a given type. */ - const Array<NEResourceID> getIDList(uint16 type) const; + const Array<WinResourceID> getIDList(uint16 type) const; /** Return a stream to the specified resource (or 0 if non-existent). */ - SeekableReadStream *getResource(uint16 type, NEResourceID id); + SeekableReadStream *getResource(uint16 type, WinResourceID id); private: /** A resource. */ struct Resource { - NEResourceID id; + WinResourceID id; uint16 type; ///< Type of the resource. @@ -200,7 +172,7 @@ private: bool readCursor(NECursor &cursor, const Resource &resource, uint32 size); /** Find a specific resource. */ - const Resource *findResource(uint16 type, NEResourceID id) const; + const Resource *findResource(uint16 type, WinResourceID id) const; /** Read a resource string. */ static String getResourceString(SeekableReadStream &exe, uint32 offset); @@ -208,4 +180,4 @@ private: } // End of namespace Common -#endif // COMMON_NE_EXE_H +#endif diff --git a/common/pe_exe.cpp b/common/winexe_pe.cpp index fc35c0fcb2..456093f5b4 100644 --- a/common/pe_exe.cpp +++ b/common/winexe_pe.cpp @@ -26,65 +26,12 @@ #include "common/debug.h" #include "common/file.h" #include "common/memstream.h" -#include "common/pe_exe.h" #include "common/str.h" #include "common/stream.h" +#include "common/winexe_pe.h" namespace Common { -PEResourceID &PEResourceID::operator=(String string) { - _name = string; - _idType = kIDTypeString; - return *this; -} - -PEResourceID &PEResourceID::operator=(uint32 x) { - _id = x; - _idType = kIDTypeNumerical; - return *this; -} - -bool PEResourceID::operator==(const String &x) const { - return _idType == kIDTypeString && _name.equalsIgnoreCase(x); -} - -bool PEResourceID::operator==(const uint32 &x) const { - return _idType == kIDTypeNumerical && _id == x; -} - -bool PEResourceID::operator==(const PEResourceID &x) const { - if (_idType != x._idType) - return false; - if (_idType == kIDTypeString) - return _name.equalsIgnoreCase(x._name); - if (_idType == kIDTypeNumerical) - return _id == x._id; - return true; -} - -String PEResourceID::getString() const { - if (_idType != kIDTypeString) - return ""; - - return _name; -} - -uint32 PEResourceID::getID() const { - if (_idType != kIDTypeNumerical) - return 0xffffffff; - - return _idType; -} - -String PEResourceID::toString() const { - if (_idType == kIDTypeString) - return _name; - else if (_idType == kIDTypeNumerical) - return String::format("%08x", _id); - - return ""; -} - PEResources::PEResources() { _exe = 0; } @@ -179,7 +126,7 @@ void PEResources::parseResourceLevel(Section §ion, uint32 offset, int level) for (uint32 i = 0; i < namedEntryCount + intEntryCount; i++) { uint32 value = _exe->readUint32LE(); - PEResourceID id; + WinResourceID id; if (value & 0x80000000) { value &= 0x7fffffff; @@ -230,8 +177,8 @@ void PEResources::parseResourceLevel(Section §ion, uint32 offset, int level) } } -const Array<PEResourceID> PEResources::getTypeList() const { - Array<PEResourceID> array; +const Array<WinResourceID> PEResources::getTypeList() const { + Array<WinResourceID> array; if (!_exe) return array; @@ -242,8 +189,8 @@ const Array<PEResourceID> PEResources::getTypeList() const { return array; } -const Array<PEResourceID> PEResources::getNameList(const PEResourceID &type) const { - Array<PEResourceID> array; +const Array<WinResourceID> PEResources::getNameList(const WinResourceID &type) const { + Array<WinResourceID> array; if (!_exe || !_resources.contains(type)) return array; @@ -256,8 +203,8 @@ const Array<PEResourceID> PEResources::getNameList(const PEResourceID &type) con return array; } -const Array<PEResourceID> PEResources::getLangList(const PEResourceID &type, const PEResourceID &name) const { - Array<PEResourceID> array; +const Array<WinResourceID> PEResources::getLangList(const WinResourceID &type, const WinResourceID &name) const { + Array<WinResourceID> array; if (!_exe || !_resources.contains(type)) return array; @@ -275,8 +222,8 @@ const Array<PEResourceID> PEResources::getLangList(const PEResourceID &type, con return array; } -SeekableReadStream *PEResources::getResource(const PEResourceID &type, const PEResourceID &name) { - Array<PEResourceID> langList = getLangList(type, name); +SeekableReadStream *PEResources::getResource(const WinResourceID &type, const WinResourceID &name) { + Array<WinResourceID> langList = getLangList(type, name); if (langList.empty()) return 0; @@ -286,7 +233,7 @@ SeekableReadStream *PEResources::getResource(const PEResourceID &type, const PER return _exe->readStream(resource.size); } -SeekableReadStream *PEResources::getResource(const PEResourceID &type, const PEResourceID &name, const PEResourceID &lang) { +SeekableReadStream *PEResources::getResource(const WinResourceID &type, const WinResourceID &name, const WinResourceID &lang) { if (!_exe || !_resources.contains(type)) return 0; diff --git a/common/pe_exe.h b/common/winexe_pe.h index c86058fb4f..5298e993ad 100644 --- a/common/pe_exe.h +++ b/common/winexe_pe.h @@ -23,55 +23,18 @@ * */ -#ifndef COMMON_PE_EXE_H -#define COMMON_PE_EXE_H +#ifndef COMMON_WINEXE_PE_H +#define COMMON_WINEXE_PE_H #include "common/array.h" #include "common/hashmap.h" -#include "common/hash-str.h" +#include "common/winexe.h" namespace Common { class SeekableReadStream; class String; -class PEResourceID { -public: - PEResourceID() { _idType = kIDTypeNull; } - PEResourceID(String x) { _idType = kIDTypeString; _name = x; } - PEResourceID(uint32 x) { _idType = kIDTypeNumerical; _id = x; } - - PEResourceID &operator=(String string); - PEResourceID &operator=(uint32 x); - - bool operator==(const String &x) const; - bool operator==(const uint32 &x) const; - bool operator==(const PEResourceID &x) const; - - String getString() const; - uint32 getID() const; - String toString() const; - -private: - /** An ID Type. */ - enum IDType { - kIDTypeNull, ///< No type set - kIDTypeNumerical, ///< A numerical ID. - kIDTypeString ///< A string ID. - } _idType; - - String _name; ///< The resource's string ID. - uint32 _id; ///< The resource's numerical ID. -}; - -struct PEResourceID_Hash { - uint operator()(const PEResourceID &id) const { return hashit(id.toString()); } -}; - -struct PEResourceID_EqualTo { - bool operator()(const PEResourceID &id1, const PEResourceID &id2) const { return id1 == id2; } -}; - /** The default Windows PE resources. */ enum PEResourceType { kPECursor = 0x01, @@ -114,19 +77,19 @@ public: bool loadFromEXE(SeekableReadStream *stream); /** Return a list of resource types. */ - const Array<PEResourceID> getTypeList() const; + const Array<WinResourceID> getTypeList() const; /** Return a list of names for a given type. */ - const Array<PEResourceID> getNameList(const PEResourceID &type) const; + const Array<WinResourceID> getNameList(const WinResourceID &type) const; /** Return a list of languages for a given type and name. */ - const Array<PEResourceID> getLangList(const PEResourceID &type, const PEResourceID &name) const; + const Array<WinResourceID> getLangList(const WinResourceID &type, const WinResourceID &name) const; /** Return a stream to the specified resource, taking the first language found (or 0 if non-existent). */ - SeekableReadStream *getResource(const PEResourceID &type, const PEResourceID &name); + SeekableReadStream *getResource(const WinResourceID &type, const WinResourceID &name); /** Return a stream to the specified resource (or 0 if non-existent). */ - SeekableReadStream *getResource(const PEResourceID &type, const PEResourceID &name, const PEResourceID &lang); + SeekableReadStream *getResource(const WinResourceID &type, const WinResourceID &name, const WinResourceID &lang); private: struct Section { @@ -140,16 +103,16 @@ private: SeekableReadStream *_exe; void parseResourceLevel(Section §ion, uint32 offset, int level); - PEResourceID _curType, _curName, _curLang; + WinResourceID _curType, _curName, _curLang; struct Resource { uint32 offset; uint32 size; }; - typedef HashMap<PEResourceID, Resource, PEResourceID_Hash, PEResourceID_EqualTo> LangMap; - typedef HashMap<PEResourceID, LangMap, PEResourceID_Hash, PEResourceID_EqualTo> NameMap; - typedef HashMap<PEResourceID, NameMap, PEResourceID_Hash, PEResourceID_EqualTo> TypeMap; + typedef HashMap<WinResourceID, Resource, WinResourceID_Hash, WinResourceID_EqualTo> LangMap; + typedef HashMap<WinResourceID, LangMap, WinResourceID_Hash, WinResourceID_EqualTo> NameMap; + typedef HashMap<WinResourceID, NameMap, WinResourceID_Hash, WinResourceID_EqualTo> TypeMap; TypeMap _resources; }; diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp index eb11eb175e..ebc8d1ea8a 100644 --- a/engines/mohawk/cursors.cpp +++ b/engines/mohawk/cursors.cpp @@ -31,8 +31,8 @@ #include "mohawk/riven_cursors.h" #include "common/macresman.h" -#include "common/ne_exe.h" #include "common/system.h" +#include "common/winexe_ne.h" #include "graphics/cursorman.h" namespace Mohawk { diff --git a/engines/scumm/he/resource_he.h b/engines/scumm/he/resource_he.h index 9dddc96f23..f81dd713f1 100644 --- a/engines/scumm/he/resource_he.h +++ b/engines/scumm/he/resource_he.h @@ -31,7 +31,7 @@ #define SCUMM_HE_RESOURCE_HE_H #include "common/macresman.h" -#include "common/pe_exe.h" +#include "common/winexe_pe.h" namespace Scumm { diff --git a/graphics/fonts/winfont.cpp b/graphics/fonts/winfont.cpp index fb37c8ddef..449a1de83e 100644 --- a/graphics/fonts/winfont.cpp +++ b/graphics/fonts/winfont.cpp @@ -23,8 +23,8 @@ */ #include "common/file.h" -#include "common/ne_exe.h" #include "common/str.h" +#include "common/winexe_ne.h" #include "graphics/fonts/winfont.h" namespace Graphics { |