1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "bladerunner/game_info.h"
24
25 #include "bladerunner/bladerunner.h"
26
27 #include "common/debug.h"
28 #include "common/substream.h"
29
30 namespace BladeRunner {
31
GameInfo(BladeRunnerEngine * vm)32 GameInfo::GameInfo(BladeRunnerEngine *vm) {
33 _vm = vm;
34 _actorCount = 0;
35 _playerId = 0;
36 _flagCount = 0;
37 _clueCount = 0;
38 _globalVarCount = 0;
39 _sceneNamesCount = 0;
40 _initialSceneId = 0;
41 _initialSetId = 0;
42 _waypointCount = 0;
43 _sfxTrackCount = 0;
44 _musicTrackCount = 0;
45 _outtakeCount = 0;
46 _crimeCount = 0;
47 _suspectCount = 0;
48 _coverWaypointCount = 0;
49 _fleeWaypointCount = 0;
50 }
51
open(const Common::String & name)52 bool GameInfo::open(const Common::String &name) {
53 Common::SeekableReadStream *s = _vm->getResourceStream(name);
54
55 if (!s) {
56 return false;
57 }
58
59 _actorCount = s->readUint32LE(); /* 00 */
60 _playerId = s->readUint32LE(); /* 01 */
61 _flagCount = s->readUint32LE(); /* 02 */
62 _clueCount = s->readUint32LE(); /* 03 */
63 _globalVarCount = s->readUint32LE(); /* 04 */
64 _sceneNamesCount = s->readUint32LE(); /* 05 */
65 _initialSceneId = s->readUint32LE(); /* 06 */
66 s->skip(4); /* 07 */
67 _initialSetId = s->readUint32LE(); /* 08 */
68 s->skip(4); /* 09 */
69 _waypointCount = s->readUint32LE(); /* 10 */
70 _sfxTrackCount = s->readUint32LE(); /* 11 */
71 _musicTrackCount = s->readUint32LE(); /* 12 */
72 _outtakeCount = s->readUint32LE(); /* 13 */
73 _crimeCount = s->readUint32LE(); /* 14 */
74 _suspectCount = s->readUint32LE(); /* 15 */
75 _coverWaypointCount = s->readUint32LE(); /* 16 */
76 _fleeWaypointCount = s->readUint32LE(); /* 17 */
77
78 char buf[9];
79
80 _sceneNames.resize(_sceneNamesCount);
81 for (uint32 i = 0; i != _sceneNamesCount; ++i) {
82 s->read(buf, 5);
83 _sceneNames[i] = buf;
84 }
85
86 _sfxTracks.resize(_sfxTrackCount);
87 for (uint32 i = 0; i != _sfxTrackCount; ++i) {
88 s->read(buf, 9);
89 _sfxTracks[i] = buf;
90 _sfxTracks[i] += ".AUD";
91 }
92
93 _musicTracks.resize(_musicTrackCount);
94 for (uint32 i = 0; i != _musicTrackCount; ++i) {
95 s->read(buf, 9);
96 _musicTracks[i] = buf;
97 _musicTracks[i] += ".AUD";
98 }
99
100 _outtakes.resize(_outtakeCount);
101 for (uint32 i = 0; i != _outtakeCount; ++i) {
102 s->read(buf, 9);
103 _outtakes[i] = buf;
104 }
105
106 #if BLADERUNNER_DEBUG_CONSOLE
107 debug("\nScene names\n----------------");
108 for (uint32 i = 0; i != _sceneNamesCount; ++i) {
109 debug("%3d: %s", i, _sceneNames[i].c_str());
110 }
111
112 debug("\nSfx tracks\n----------------");
113 for (uint32 i = 0; i != _sfxTrackCount; ++i) {
114 debug("%3d: %s", i, _sfxTracks[i].c_str());
115 }
116
117 debug("\nMusic tracks\n----------------");
118 for (uint32 i = 0; i != _musicTrackCount; ++i) {
119 debug("%3d: %s", i, _musicTracks[i].c_str());
120 }
121
122 debug("\nOuttakes\n----------------");
123 for (uint32 i = 0; i != _outtakeCount; ++i) {
124 debug("%2d: %s.VQA", i, _outtakes[i].c_str());
125 }
126
127 debug("Clue Count: %d ", _clueCount);
128 debug("Crime Count: %d ", _crimeCount);
129 debug("Suspect Count: %d ", _suspectCount);
130 #endif
131
132 bool err = s->err();
133 delete s;
134 return !err;
135 }
136
getSceneName(int i) const137 const Common::String &GameInfo::getSceneName(int i) const {
138 if (i < 0 || i >= (int)_sceneNamesCount) {
139 warning("GameInfo::getSceneName: unknown id \"%i\"", i);
140 static Common::String str("UNKNOWN_SCENE");
141 return str;
142 }
143 return _sceneNames[i];
144 }
145
getSfxTrack(int i) const146 const Common::String &GameInfo::getSfxTrack(int i) const {
147 if (i < 0 || i >= (int)_sfxTrackCount) {
148 warning("GameInfo::getSfxTrack: unknown id \"%i\"", i);
149 static Common::String str("UNKNOWN_SFX_TRACK");
150 return str;
151 }
152 return _sfxTracks[i];
153 }
154
getMusicTrack(int i) const155 const Common::String &GameInfo::getMusicTrack(int i) const {
156 if (i < 0 || i >= (int)_musicTrackCount) {
157 warning("GameInfo::getMusicTrack: unknown id \"%i\"", i);
158 static Common::String str("UNKNOWN_MUSIC_TRACK");
159 return str;
160 }
161 return _musicTracks[i];
162 }
163
getOuttake(int i) const164 const Common::String &GameInfo::getOuttake(int i) const {
165 if (i < 0 || i >= (int)_outtakeCount) {
166 warning("GameInfo::getOuttake: unknown id \"%i\"", i);
167 static Common::String str("UNKNOWN_OUTTAKE");
168 return str;
169 }
170 return _outtakes[i];
171 }
172
173 } // End of namespace BladeRunner
174