ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

database.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef DATABASE_H_
00024 #define DATABASE_H_
00025 
00026 #include "engines/myst3/hotspot.h"
00027 
00028 #include "common/scummsys.h"
00029 #include "common/str.h"
00030 #include "common/language.h"
00031 #include "common/platform.h"
00032 #include "common/ptr.h"
00033 #include "common/array.h"
00034 #include "common/hashmap.h"
00035 #include "common/stream.h"
00036 
00037 namespace Myst3 {
00038 
00039 enum GameLocalizationType {
00040     kLocMonolingual,
00041     kLocMulti2,
00042     kLocMulti6
00043 };
00044 
00045 enum MystLanguage {
00046     kEnglish = 0,
00047     kOther   = 1, // Dutch, Japanese or Polish
00048     kDutch   = 1,
00049     kFrench  = 2,
00050     kGerman  = 3,
00051     kItalian = 4,
00052     kSpanish = 5
00053 };
00054 
00055 enum NodeID {
00056     kNodeSharedInit   = 1,
00057     kNodeLogoPlay     = 1,
00058     kNodeMenuNewGame  = 98,
00059     kNodeMenuMain     = 100,
00060     kNodeMenuLoadGame = 200,
00061     kNodeMenuSaveGame = 300
00062 };
00063 
00064 enum RoomID {
00065     kRoomShared        = 101,
00066     kRoomIntro         = 201,
00067     kRoomTomahnaStart  = 301,
00068     kRoomTomahnaReturn = 401,
00069     kJnaninStart       = 501,
00070     kRoomLeos          = 502,
00071     kRoomLeet          = 503,
00072     kRoomLelt          = 504,
00073     kRoomLemt          = 505,
00074     kRoomLeof          = 506,
00075     kRoomEdannaStart   = 601,
00076     kRoomLisw          = 602,
00077     kRoomLifo          = 603,
00078     kRoomLisp          = 604,
00079     kRoomLine          = 605,
00080     kRoomVoltaicStart  = 701,
00081     kRoomEnpp          = 703,
00082     kRoomEnem          = 704,
00083     kRoomEnlc          = 705,
00084     kRoomEndd          = 706,
00085     kRoomEnch          = 707,
00086     kRoomEnli          = 708,
00087     kRoomNarayan       = 801,
00088     kRoomMenu          = 901,
00089     kRoomJournals      = 902,
00090     kRoomDemo          = 903,
00091     kRoomAtix          = 904,
00092     kRoomAmateriaStart = 1001,
00093     kRoomMais          = 1002,
00094     kRoomMall          = 1003,
00095     kRoomMass          = 1004,
00096     kRoomMaww          = 1005,
00097     kRoomMato          = 1006,
00098     kLogo              = 1101
00099 };
00100 
00101 struct NodeData {
00102     int16 id;
00103     int16 zipBitIndex;
00104     Common::Array<CondScript> scripts;
00105     Common::Array<HotSpot> hotspots;
00106     Common::Array<CondScript> soundScripts;
00107     Common::Array<CondScript> backgroundSoundScripts;
00108 };
00109 
00110 // Nodes are using ref counting pointers since they can be
00111 // deleted by a script they own
00112 typedef Common::SharedPtr<NodeData> NodePtr;
00113 
00114 struct RoomData {
00115     uint32 id;
00116     const char *name;
00117 };
00118 
00119 struct RoomKey {
00120     uint16 ageID;
00121     uint16 roomID;
00122 
00123     RoomKey(uint16 room, uint16 age) : roomID(room), ageID(age) {};
00124 
00125     bool operator==(const RoomKey &k) const {
00126         return ageID == k.ageID && roomID == k.roomID;
00127     }
00128 };
00129 
00130 struct AgeData {
00131     uint32 id;
00132     uint32 disk;
00133     uint32 roomCount;
00134     const RoomData *rooms;
00135     uint32 labelId;
00136 };
00137 
00138 struct AmbientCue {
00139     uint16 id;
00140     uint16 minFrames;
00141     uint16 maxFrames;
00142     Common::Array<uint16> tracks;
00143 };
00144 
00148 enum ScriptType {
00149     kScriptTypeNode,
00150     kScriptTypeAmbientSound,
00151     kScriptTypeBackgroundSound,
00152     kScriptTypeNodeInit,
00153     kScriptTypeAmbientCue
00154 };
00155 
00159 struct RoomScripts {
00160     Common::String room;
00161     ScriptType type;
00162     uint offset;
00163     uint size;
00164 };
00165 
00166 class Myst3Engine;
00167 
00168 class Database {
00169 public:
00170     Database(const Common::Platform platform, const Common::Language language, const uint32 localizationType);
00171     ~Database();
00172 
00176     void cacheRoom(uint32 roomID, uint32 ageID);
00177 
00183     bool isCommonRoom(uint32 roomID, uint32 ageID) const;
00184 
00188     NodePtr getNodeData(uint16 nodeID, uint32 roomID, uint32 ageID);
00189 
00193     int32 getNodeZipBitIndex(uint16 nodeID, uint32 roomID, uint32 ageID);
00194 
00198     const Common::Array<Opcode>& getNodeInitScript() { return _nodeInitScript; }
00199 
00203     Common::String getRoomName(uint32 roomID, uint32 ageID) const;
00204 
00208     RoomKey getRoomKey(const char *name);
00209 
00213     Common::Array<uint16> listRoomNodes(uint32 roomID, uint32 ageID);
00214 
00218     uint32 getAgeLabelId(uint32 ageID);
00219 
00223     Common::String getSoundName(uint32 id);
00224 
00226     uint32 getSoundIdMin() const { return _soundIdMin; }
00227     uint32 getSoundIdMax() const { return _soundIdMax; }
00228 
00232     const AmbientCue &getAmbientCue(uint16 id);
00233 
00234     int16 getGameLanguageCode() const;
00235 
00237     bool areRoomsScriptsEqual(uint32 roomID1, uint32 ageID1, uint32 roomID2, uint32 ageID2, ScriptType scriptType);
00238 
00239 private:
00240     struct RoomKeyHash {
00241         uint operator()(const RoomKey &v) const {
00242             return v.ageID + (v.roomID << 16);
00243         }
00244     };
00245 
00246     typedef Common::HashMap<RoomKey, Common::Array<NodePtr>, RoomKeyHash> NodesCache;
00247 
00248     const Common::Platform _platform;
00249     const Common::Language _language;
00250     const uint32 _localizationType;
00251 
00252     static const AgeData _ages[];
00253 
00254     NodesCache _roomNodesCache;
00255 
00256     Common::Array<Opcode> _nodeInitScript;
00257 
00258     uint32 _soundIdMin;
00259     uint32 _soundIdMax;
00260     Common::HashMap<uint32, Common::String> _soundNames;
00261     Common::HashMap<uint16, AmbientCue> _ambientCues;
00262     Common::HashMap<uint32, int16> _roomZipBitIndex;
00263 
00264     // 'myst3.dat' cached data
00265     static const uint kDatVersion = 3;
00266     Common::SeekableReadStream *_datFile;
00267     Common::Array<RoomScripts> _roomScriptsIndex;
00268     int32 _roomScriptsStartOffset;
00269 
00270     const RoomData *findRoomData(uint32 roomID, uint32 ageID) const;
00271     Common::Array<NodePtr> getRoomNodes(uint32 roomID, uint32 ageID) const;
00272 
00273     Common::Array<NodePtr> readRoomScripts(const RoomData *room) const;
00274     void preloadCommonRooms();
00275     void initializeZipBitIndexTable();
00276     void patchLanguageMenu();
00277     void patchNodeScripts(const RoomData *room, Common::Array<NodePtr> &nodes) const;
00278 
00279     // 'myst3.dat' read methods
00280     void readScriptIndex(Common::SeekableReadStream *stream, bool load);
00281     void readSoundNames(Common::SeekableReadStream *stream, bool load);
00282     void loadAmbientCues(Common::ReadStream *s);
00283     Common::SeekableReadStream *getRoomScriptStream(const char *room, ScriptType scriptType) const;
00284 };
00285 
00286 } // End of namespace Myst3
00287 
00288 #endif // DATABASE_H_


Generated on Sat Mar 16 2019 05:01:24 for ResidualVM by doxygen 1.7.1
curved edge   curved edge