Exemplo n.º 1
0
int MfcArchive::readCount() {
	int count = readUint16LE();

	if (count == 0xffff)
		count = readUint32LE();

	return count;
}
Exemplo n.º 2
0
Common::String MfcArchive::readPascalString(bool twoByte) {
	char *tmp;
	int len;
	Common::String result;

	if (twoByte)
		len = readUint16LE();
	else
		len = readByte();

	tmp = (char *)calloc(len + 1, 1);
	read(tmp, len);
	result = tmp;
	free(tmp);

	debugC(9, kDebugLoading, "readPascalString: %d <%s>", len, transCyrillic(result));

	return result;
}
Exemplo n.º 3
0
uint32 readUint32LE(FILE *file) {
	uint16 x = readUint16LE(file);
	return x | readUint16LE(file) << 16;
}
Exemplo n.º 4
0
uint32_t File::readUint32LE() {
	uint16_t lo = readUint16LE();
	uint16_t hi = readUint16LE();
	return (hi << 16) | lo;
}
Exemplo n.º 5
0
CObject *MfcArchive::parseClass(bool *isCopyReturned) {
	Common::String name;
	int objectId = 0;
	CObject *res = 0;

	uint obTag = readUint16LE();

	debugC(7, kDebugLoading, "parseClass::obTag = %d (%04x)  at 0x%08x", obTag, obTag, pos() - 2);

	if (obTag == 0x0000) {
		return NULL;
	} else if (obTag == 0xffff) {
		int schema = readUint16LE();

		debugC(7, kDebugLoading, "parseClass::schema = %d", schema);

		name = readPascalString(true);
		debugC(7, kDebugLoading, "parseClass::class <%s>", name.c_str());

		if (!_classMap.contains(name.c_str())) {
			error("Unknown class in MfcArchive: <%s>", name.c_str());
		}

		objectId = _classMap[name.c_str()];

		debugC(7, kDebugLoading, "tag: %d 0x%x (%x)", _objectMap.size() - 1, _objectMap.size() - 1, objectId);

		res = createObject(objectId);
		_objectMap.push_back(res);
		_objectIdMap.push_back(objectId);

		_objectMap.push_back(res); // Basically a hack, but behavior is all correct
		_objectIdMap.push_back(objectId);

		*isCopyReturned = false;
	} else if ((obTag & 0x8000) == 0) {
		if (_objectMap.size() < obTag) {
			error("Object index too big: %d  at 0x%08x", obTag, pos() - 2);
		}
		debugC(7, kDebugLoading, "parseClass::obTag <%s>", lookupObjectId(_objectIdMap[obTag]));

		res = _objectMap[obTag];

		*isCopyReturned = true;
	} else {

		obTag &= ~0x8000;

		if (_objectMap.size() < obTag) {
			error("Object index too big: %d  at 0x%08x", obTag, pos() - 2);
		}

		debugC(7, kDebugLoading, "parseClass::obTag <%s>", lookupObjectId(_objectIdMap[obTag]));

		objectId = _objectIdMap[obTag];

		res = createObject(objectId);
		_objectMap.push_back(res);
		_objectIdMap.push_back(objectId);

		*isCopyReturned = false;
	}

	return res;
}