2017-05-26 05:24:38 +02:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
*/
|
2017-06-05 19:10:47 +02:00
|
|
|
|
|
|
|
#include "sludge/allfiles.h"
|
|
|
|
#include "sludge/objtypes.h"
|
|
|
|
#include "sludge/variable.h"
|
|
|
|
#include "sludge/newfatal.h"
|
|
|
|
#include "sludge/moreio.h"
|
|
|
|
#include "sludge/fileset.h"
|
2017-07-13 18:08:30 +02:00
|
|
|
#include "sludge/version.h"
|
2017-05-26 05:24:38 +02:00
|
|
|
|
2017-05-26 21:25:11 +02:00
|
|
|
namespace Sludge {
|
|
|
|
|
2017-05-26 05:24:38 +02:00
|
|
|
objectType *allObjectTypes = NULL;
|
|
|
|
|
|
|
|
#define DEBUG_COMBINATIONS 0
|
|
|
|
|
|
|
|
bool initObjectTypes() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
objectType *findObjectType(int i) {
|
|
|
|
objectType *huntType = allObjectTypes;
|
|
|
|
|
|
|
|
while (huntType) {
|
2017-05-29 08:02:59 +02:00
|
|
|
if (huntType->objectNum == i)
|
|
|
|
return huntType;
|
|
|
|
huntType = huntType->next;
|
2017-05-26 05:24:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return loadObjectType(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
objectType *loadObjectType(int i) {
|
|
|
|
int a, nameNum;
|
|
|
|
objectType *newType = new objectType;
|
|
|
|
|
|
|
|
if (checkNew(newType)) {
|
|
|
|
if (openObjectSlice(i)) {
|
2017-05-30 09:59:56 +02:00
|
|
|
nameNum = bigDataFile->readUint16BE();
|
|
|
|
newType->r = (byte)bigDataFile->readByte();
|
|
|
|
newType->g = (byte)bigDataFile->readByte();
|
|
|
|
newType->b = (byte)bigDataFile->readByte();
|
|
|
|
newType->speechGap = bigDataFile->readByte();
|
|
|
|
newType->walkSpeed = bigDataFile->readByte();
|
|
|
|
newType->wrapSpeech = bigDataFile->readUint32LE();
|
|
|
|
newType->spinSpeed = bigDataFile->readUint16BE();
|
2017-05-26 05:24:38 +02:00
|
|
|
|
|
|
|
if (gameVersion >= VERSION(1, 6)) {
|
|
|
|
// aaLoad
|
2017-05-30 09:59:56 +02:00
|
|
|
bigDataFile->readByte();
|
2017-07-11 00:02:46 +02:00
|
|
|
bigDataFile->readFloatLE();
|
|
|
|
bigDataFile->readFloatLE();
|
2017-05-26 05:24:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gameVersion >= VERSION(1, 4)) {
|
2017-05-30 09:59:56 +02:00
|
|
|
newType->flags = bigDataFile->readUint16BE();
|
2017-05-26 05:24:38 +02:00
|
|
|
} else {
|
2017-05-29 08:02:59 +02:00
|
|
|
newType->flags = 0;
|
2017-05-26 05:24:38 +02:00
|
|
|
}
|
|
|
|
|
2017-05-30 09:59:56 +02:00
|
|
|
newType->numCom = bigDataFile->readUint16BE();
|
2017-06-05 11:49:19 +02:00
|
|
|
newType->allCombis = (newType->numCom) ? new combination[newType->numCom] : NULL;
|
2017-05-26 05:24:38 +02:00
|
|
|
|
|
|
|
|
2017-05-29 08:02:59 +02:00
|
|
|
for (a = 0; a < newType->numCom; a++) {
|
2017-05-30 09:59:56 +02:00
|
|
|
newType->allCombis[a].withObj = bigDataFile->readUint16BE();
|
|
|
|
newType->allCombis[a].funcNum = bigDataFile->readUint16BE();
|
2017-05-26 05:24:38 +02:00
|
|
|
}
|
2017-07-15 17:33:10 +02:00
|
|
|
|
2017-05-26 05:24:38 +02:00
|
|
|
finishAccess();
|
2017-05-29 08:02:59 +02:00
|
|
|
newType->screenName = getNumberedString(nameNum);
|
|
|
|
newType->objectNum = i;
|
|
|
|
newType->next = allObjectTypes;
|
2017-05-26 05:24:38 +02:00
|
|
|
allObjectTypes = newType;
|
|
|
|
return newType;
|
|
|
|
}
|
|
|
|
}
|
2017-05-27 20:16:54 +02:00
|
|
|
|
2017-05-26 05:24:38 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-05-27 20:16:54 +02:00
|
|
|
objectType *loadObjectRef(Common::SeekableReadStream *stream) {
|
2017-05-30 09:59:56 +02:00
|
|
|
objectType *r = loadObjectType(stream->readUint16BE());
|
2017-07-11 14:57:31 +02:00
|
|
|
r->screenName.clear();
|
2017-05-29 08:02:59 +02:00
|
|
|
r->screenName = readString(stream);
|
2017-05-26 05:24:38 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2017-05-27 20:16:54 +02:00
|
|
|
void saveObjectRef(objectType *r, Common::WriteStream *stream) {
|
2017-05-30 09:59:56 +02:00
|
|
|
stream->writeUint16BE(r->objectNum);
|
2017-05-29 08:02:59 +02:00
|
|
|
writeString(r->screenName, stream);
|
2017-05-26 05:24:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int getCombinationFunction(int withThis, int thisObject) {
|
|
|
|
int i, num = 0;
|
|
|
|
objectType *obj = findObjectType(thisObject);
|
|
|
|
|
2017-05-29 08:02:59 +02:00
|
|
|
for (i = 0; i < obj->numCom; i++) {
|
|
|
|
if (obj->allCombis[i].withObj == withThis) {
|
|
|
|
num = obj->allCombis[i].funcNum;
|
2017-05-26 05:24:38 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
|
|
|
void removeObjectType(objectType *oT) {
|
2017-07-11 00:07:40 +02:00
|
|
|
objectType **huntRegion = &allObjectTypes;
|
2017-05-26 05:24:38 +02:00
|
|
|
|
2017-05-29 08:02:59 +02:00
|
|
|
while (*huntRegion) {
|
|
|
|
if ((*huntRegion) == oT) {
|
|
|
|
*huntRegion = oT->next;
|
2017-07-01 22:01:47 +02:00
|
|
|
delete []oT->allCombis;
|
2017-05-26 05:24:38 +02:00
|
|
|
delete oT;
|
|
|
|
return;
|
|
|
|
} else {
|
2017-05-29 08:02:59 +02:00
|
|
|
huntRegion = &((*huntRegion)->next);
|
2017-05-26 05:24:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
fatal("Can't delete object type: bad pointer");
|
|
|
|
}
|
2017-05-26 21:25:11 +02:00
|
|
|
|
|
|
|
} // End of namespace Sludge
|