1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
/* 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.
*
*/
#include "fullpipe/fullpipe.h"
#include "common/file.h"
#include "common/array.h"
#include "common/list.h"
#include "fullpipe/objects.h"
#include "fullpipe/gameloader.h"
#include "fullpipe/scene.h"
#include "fullpipe/statics.h"
#include "fullpipe/interaction.h"
#include "fullpipe/constants.h"
namespace Fullpipe {
bool FullpipeEngine::loadGam(const char *fname, int scene) {
_gameLoader = new GameLoader();
if (!_gameLoader->loadFile(fname))
return false;
_currSoundListCount = 0;
initObjectStates();
// set_g_messageQueueCallback1(messageQueueCallback1); // substituted with direct call
addMessageHandlerByIndex(global_messageHandler1, 0, 4);
_inventory = getGameLoaderInventory();
_inventory->setItemFlags(ANI_INV_MAP, 0x10003);
_inventory->addItem(ANI_INV_MAP, 1);
_inventory->rebuildItemRects();
for (PtrList::iterator p = _inventory->getScene()->_picObjList.begin(); p != _inventory->getScene()->_picObjList.end(); ++p) {
((MemoryObject *)((PictureObject *)*p)->_picture)->load();
}
// _sceneSwitcher = sceneSwitcher; // substituted with direct call
_gameLoader->_preloadCallback = preloadCallback;
// _readSavegameCallback = gameLoaderReadSavegameCallback; // TODO
_aniMan = accessScene(SC_COMMON)->getAniMan();
_scene2 = 0;
_movTable = _aniMan->countMovements();
_aniMan->setSpeed(1);
PictureObject *pic = accessScene(SC_INV)->getPictureObjectById(PIC_INV_MENU, 0);
pic->setFlags(pic->_flags & 0xFFFB);
// Not used in full game
//_evalVersionPic = accessScene(SC_COMMON)->getPictureObjectById(PIC_CMN_EVAL, 0);
initMap();
initCursors();
setMusicAllowed(_gameLoader->_gameVar->getSubVarAsInt("MUSIC_ALLOWED"));
if (scene) {
_gameLoader->loadScene(scene);
_gameLoader->gotoScene(scene, TrubaLeft);
} else {
if (_flgPlayIntro) {
_gameLoader->loadScene(SC_INTRO1);
_gameLoader->gotoScene(SC_INTRO1, TrubaUp);
} else {
_gameLoader->loadScene(SC_1);
_gameLoader->gotoScene(SC_1, TrubaLeft);
}
}
if (!_currentScene)
return false;
return true;
}
GameProject::GameProject() {
_field_4 = 0;
_headerFilename = 0;
_field_10 = 12;
_sceneTagList = 0;
}
bool GameProject::load(MfcArchive &file) {
debug(5, "GameProject::load()");
_field_4 = 0;
_headerFilename = 0;
_field_10 = 12;
g_fullpipe->_gameProjectVersion = file.readUint32LE();
g_fullpipe->_pictureScale = file.readUint16LE();
g_fullpipe->_scrollSpeed = file.readUint32LE();
_headerFilename = file.readPascalString();
debug(1, "_gameProjectVersion = %d", g_fullpipe->_gameProjectVersion);
debug(1, "_pictureScale = %d", g_fullpipe->_pictureScale);
debug(1, "_scrollSpeed = %d", g_fullpipe->_scrollSpeed);
debug(1, "_headerFilename = %s", _headerFilename);
_sceneTagList = new SceneTagList();
_sceneTagList->load(file);
if (g_fullpipe->_gameProjectVersion >= 3)
_field_4 = file.readUint32LE();
if (g_fullpipe->_gameProjectVersion >= 5) {
file.readUint32LE();
file.readUint32LE();
}
return true;
}
GameProject::~GameProject() {
free(_headerFilename);
}
GameVar::GameVar() {
_subVars = 0;
_parentVarObj = 0;
_nextVarObj = 0;
_prevVarObj = 0;
_field_14 = 0;
_varType = 0;
_value.floatValue = 0;
_varName = 0;
}
bool GameVar::load(MfcArchive &file) {
_varName = file.readPascalString();
_varType = file.readUint32LE();
debugN(6, "[%03d] ", file.getLevel());
for (int i = 0; i < file.getLevel(); i++)
debugN(6, " ");
debugN(6, "<%s>: ", transCyrillic((byte *)_varName));
switch (_varType) {
case 0:
_value.intValue = file.readUint32LE();
debug(6, "d --> %d", _value.intValue);
break;
case 1:
_value.intValue = file.readUint32LE(); // FIXME
debug(6, "f --> %f", _value.floatValue);
break;
case 2:
_value.stringValue = file.readPascalString();
debug(6, "s --> %s", _value.stringValue);
break;
default:
error("Unknown var type: %d (0x%x)", _varType, _varType);
}
file.incLevel();
_parentVarObj = (GameVar *)file.readClass();
_prevVarObj = (GameVar *)file.readClass();
_nextVarObj = (GameVar *)file.readClass();
_field_14 = (GameVar *)file.readClass();
_subVars = (GameVar *)file.readClass();
file.decLevel();
return true;
}
GameVar *GameVar::getSubVarByName(const char *name) {
GameVar *sv = 0;
if (_subVars != 0) {
sv = _subVars;
for (;sv && scumm_stricmp(sv->_varName, name); sv = sv->_nextVarObj)
;
}
return sv;
}
bool GameVar::setSubVarAsInt(const char *name, int value) {
GameVar *var = getSubVarByName(name);
if (var) {
if (var->_varType == 0) {
var->_value.intValue = value;
return true;
}
return false;
}
var = new GameVar();
var->_varType = 0;
var->_value.intValue = value;
var->_varName = (char *)calloc(strlen(name) + 1, 1);
strcpy(var->_varName, name);
return addSubVar(var);
}
int GameVar::getSubVarAsInt(const char *name) {
GameVar *var = getSubVarByName(name);
if (var)
return var->_value.intValue;
else
return 0;
}
GameVar *GameVar::addSubVarAsInt(const char *name, int value) {
if (getSubVarByName(name)) {
return 0;
} else {
GameVar *var = new GameVar();
var->_varType = 0;
var->_value.intValue = value;
var->_varName = (char *)calloc(strlen(name) + 1, 1);
strcpy(var->_varName, name);
return (addSubVar(var) != 0) ? var : 0;
}
}
bool GameVar::addSubVar(GameVar *subvar) {
GameVar *var = _subVars;
if (var) {
for (GameVar *i = var->_nextVarObj; i; i = i->_nextVarObj)
var = i;
var->_nextVarObj = subvar;
subvar->_prevVarObj = var;
subvar->_parentVarObj = this;
return true;
} else {
_subVars = subvar;
subvar->_parentVarObj = this;
return true;
}
return false;
}
int GameVar::getSubVarsCount() {
int res;
GameVar *sub = _subVars;
for (res = 0; sub; res++)
sub = sub->_nextVarObj;
return res;
}
GameVar *GameVar::getSubVarByIndex(int idx) {
GameVar *sub = _subVars;
while (idx--) {
sub = sub->_nextVarObj;
if (!sub)
return 0;
}
return sub;
}
bool PicAniInfo::load(MfcArchive &file) {
debug(5, "PicAniInfo::load()");
type = file.readUint32LE();
objectId = file.readUint16LE();
field_6 = file.readUint16LE();
field_8 = file.readUint32LE();
sceneId = file.readUint16LE();
field_E = file.readUint16LE();
ox = file.readUint32LE();
oy = file.readUint32LE();
priority = file.readUint32LE();
staticsId = file.readUint16LE();
movementId = file.readUint16LE();
dynamicPhaseIndex = file.readUint16LE();
flags = file.readUint16LE();
field_24 = file.readUint32LE();
someDynamicPhaseIndex = file.readUint32LE();
return true;
}
} // End of namespace Fullpipe
|