aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/scumm/he/resource_he.cpp2
-rw-r--r--engines/scumm/resource.cpp22
-rw-r--r--engines/scumm/resource_v2.cpp16
-rw-r--r--engines/scumm/resource_v3.cpp4
-rw-r--r--engines/scumm/resource_v4.cpp2
-rw-r--r--engines/scumm/script.cpp1
-rw-r--r--engines/scumm/scumm.h7
-rw-r--r--engines/scumm/sound.cpp6
8 files changed, 36 insertions, 24 deletions
diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp
index abff7b479e..9f372f0c1a 100644
--- a/engines/scumm/he/resource_he.cpp
+++ b/engines/scumm/he/resource_he.cpp
@@ -1497,7 +1497,7 @@ void ScummEngine_v70he::readRoomsOffsets() {
num = READ_LE_UINT16(_heV7RoomOffsets);
ptr = _heV7RoomOffsets + 2;
for (i = 0; i < num; i++) {
- _res->roomoffs[rtRoom][i] = (int32)READ_LE_UINT32(ptr);
+ _res->roomoffs[rtRoom][i] = READ_LE_UINT32(ptr);
ptr += 4;
}
}
diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp
index ffacd8c461..6d2bf76592 100644
--- a/engines/scumm/resource.cpp
+++ b/engines/scumm/resource.cpp
@@ -86,14 +86,14 @@ void ScummEngine::openRoom(const int room) {
// room 0 contains the data which is used to create the roomno / roomoffs
// tables -- hence obviously we mustn't use those when loading room 0.
const uint32 diskNumber = room ? _res->roomno[rtRoom][room] : 0;
- const int32 room_offs = room ? _res->roomoffs[rtRoom][room] : 0;
+ const uint32 room_offs = room ? _res->roomoffs[rtRoom][room] : 0;
// FIXME: Since room_offs is const, clearly the following loop either
// is never entered, or loops forever (if it wasn't for the return/error
// statements in it, that is). -> This should be cleaned up!
// Maybe we should re-enabled the looping properly, to deal with disc
// changes in COMI ?
- while (room_offs != -1) {
+ while (room_offs != RES_INVALID_OFFSET) {
if (room_offs != 0 && room != 0 && _game.heversion < 98) {
_fileOffset = _res->roomoffs[rtRoom][room];
@@ -159,7 +159,7 @@ void ScummEngine::closeRoom() {
/** Delete the currently loaded room offsets. */
void ScummEngine::deleteRoomOffsets() {
for (int i = 0; i < _numRooms; i++) {
- if (_res->roomoffs[rtRoom][i] != -1)
+ if (_res->roomoffs[rtRoom][i] != RES_INVALID_OFFSET)
_res->roomoffs[rtRoom][i] = 0;
}
}
@@ -179,10 +179,10 @@ void ScummEngine::readRoomsOffsets() {
num = _fileHandle->readByte();
while (num--) {
room = _fileHandle->readByte();
- if (_res->roomoffs[rtRoom][room] != -1) {
- _res->roomoffs[rtRoom][room] = _fileHandle->readSint32LE();
+ if (_res->roomoffs[rtRoom][room] != RES_INVALID_OFFSET) {
+ _res->roomoffs[rtRoom][room] = _fileHandle->readUint32LE();
} else {
- _fileHandle->readSint32LE();
+ _fileHandle->readUint32LE();
}
}
}
@@ -516,7 +516,7 @@ void ScummEngine::readResTypeList(int id) {
_res->roomno[id][i] = _fileHandle->readByte();
}
for (i = 0; i < num; i++) {
- _res->roomoffs[id][i] = _fileHandle->readSint32LE();
+ _res->roomoffs[id][i] = _fileHandle->readUint32LE();
if (id == rtRoom && _game.heversion >= 70)
_heV7RoomIntOffsets[i] = _res->roomoffs[id][i];
@@ -546,7 +546,7 @@ void ResourceManager::allocResTypeData(int id, uint32 tag, int num_, const char
if (mode_) {
roomno[id] = (byte *)calloc(num_, sizeof(byte));
- roomoffs[id] = (int32 *)calloc(num_, sizeof(int32));
+ roomoffs[id] = (uint32 *)calloc(num_, sizeof(uint32));
}
if (_vm->_game.heversion >= 70) {
@@ -623,7 +623,7 @@ void ScummEngine::ensureResourceLoaded(int type, int i) {
int ScummEngine::loadResource(int type, int idx) {
int roomNr;
- int32 fileOffs;
+ uint32 fileOffs;
uint32 size, tag;
debugC(DEBUG_RESOURCE, "loadResource(%s,%d)", resTypeFromId(type), idx);
@@ -650,7 +650,7 @@ int ScummEngine::loadResource(int type, int idx) {
fileOffs = 0;
} else {
fileOffs = _res->roomoffs[type][idx];
- if (fileOffs < 0)
+ if (fileOffs == RES_INVALID_OFFSET)
return 0;
}
@@ -1301,7 +1301,7 @@ void ScummEngine::allocateArrays() {
if (_game.heversion >= 70) {
_res->allocResTypeData(rtSpoolBuffer, 0, 9, "spool buffer", 1);
- _heV7RoomIntOffsets = (int32 *)calloc(_numRooms, sizeof(uint32));
+ _heV7RoomIntOffsets = (uint32 *)calloc(_numRooms, sizeof(uint32));
}
}
diff --git a/engines/scumm/resource_v2.cpp b/engines/scumm/resource_v2.cpp
index 3e14f5a6ff..08393da708 100644
--- a/engines/scumm/resource_v2.cpp
+++ b/engines/scumm/resource_v2.cpp
@@ -91,28 +91,36 @@ void ScummEngine_v2::readClassicIndexFile() {
}
_fileHandle->seek(_numRooms, SEEK_CUR);
for (i = 0; i < _numRooms; i++) {
- _res->roomoffs[rtRoom][i] = _fileHandle->readSint16LE();
+ _res->roomoffs[rtRoom][i] = _fileHandle->readUint16LE();
+ if (_res->roomoffs[rtRoom][i] == 0xFFFF)
+ _res->roomoffs[rtRoom][i] = RES_INVALID_OFFSET;
}
for (i = 0; i < _numCostumes; i++) {
_res->roomno[rtCostume][i] = _fileHandle->readByte();
}
for (i = 0; i < _numCostumes; i++) {
- _res->roomoffs[rtCostume][i] = _fileHandle->readSint16LE();
+ _res->roomoffs[rtCostume][i] = _fileHandle->readUint16LE();
+ if (_res->roomoffs[rtCostume][i] == 0xFFFF)
+ _res->roomoffs[rtCostume][i] = RES_INVALID_OFFSET;
}
for (i = 0; i < _numScripts; i++) {
_res->roomno[rtScript][i] = _fileHandle->readByte();
}
for (i = 0; i < _numScripts; i++) {
- _res->roomoffs[rtScript][i] = _fileHandle->readSint16LE();
+ _res->roomoffs[rtScript][i] = _fileHandle->readUint16LE();
+ if (_res->roomoffs[rtScript][i] == 0xFFFF)
+ _res->roomoffs[rtScript][i] = RES_INVALID_OFFSET;
}
for (i = 0; i < _numSounds; i++) {
_res->roomno[rtSound][i] = _fileHandle->readByte();
}
for (i = 0; i < _numSounds; i++) {
- _res->roomoffs[rtSound][i] = _fileHandle->readSint16LE();
+ _res->roomoffs[rtSound][i] = _fileHandle->readUint16LE();
+ if (_res->roomoffs[rtSound][i] == 0xFFFF)
+ _res->roomoffs[rtSound][i] = RES_INVALID_OFFSET;
}
}
diff --git a/engines/scumm/resource_v3.cpp b/engines/scumm/resource_v3.cpp
index b35e13ceab..1ac159c9a5 100644
--- a/engines/scumm/resource_v3.cpp
+++ b/engines/scumm/resource_v3.cpp
@@ -52,7 +52,9 @@ void ScummEngine_v3old::readResTypeList(int id) {
_res->roomno[id][i] = _fileHandle->readByte();
}
for (i = 0; i < num; i++) {
- _res->roomoffs[id][i] = _fileHandle->readSint16LE();
+ _res->roomoffs[id][i] = _fileHandle->readUint16LE();
+ if (_res->roomoffs[id][i] == 0xFFFF)
+ _res->roomoffs[id][i] = RES_INVALID_OFFSET;
}
}
diff --git a/engines/scumm/resource_v4.cpp b/engines/scumm/resource_v4.cpp
index 4bfe5c70bb..6b02494856 100644
--- a/engines/scumm/resource_v4.cpp
+++ b/engines/scumm/resource_v4.cpp
@@ -46,7 +46,7 @@ void ScummEngine_v4::readResTypeList(int id) {
for (i = 0; i < num; i++) {
_res->roomno[id][i] = _fileHandle->readByte();
- _res->roomoffs[id][i] = _fileHandle->readSint32LE();
+ _res->roomoffs[id][i] = _fileHandle->readUint32LE();
}
}
diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp
index b820c4742c..a0e48bc4a1 100644
--- a/engines/scumm/script.cpp
+++ b/engines/scumm/script.cpp
@@ -152,7 +152,6 @@ int ScummEngine::getVerbEntrypoint(int obj, int entry) {
// WORKAROUND for bug #1555938: Disallow pulling the rope if it's
// already in the player's inventory.
-
if (_game.id == GID_MONKEY2 && obj == 1047 && entry == 6 && whereIsObject(obj) == WIO_INVENTORY) {
return 0;
}
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index d4eff5a972..90cb14de1f 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -328,6 +328,9 @@ enum ResTypes {
rtNumTypes = 22
};
+enum {
+ RES_INVALID_OFFSET = 0xFFFFFFFF
+};
/**
* The 'resource manager' class. Currently doesn't really deserve to be called
@@ -350,7 +353,7 @@ protected:
byte *status[rtNumTypes];
public:
byte *roomno[rtNumTypes];
- int32 *roomoffs[rtNumTypes];
+ uint32 *roomoffs[rtNumTypes];
uint32 *globsize[rtNumTypes];
protected:
@@ -723,7 +726,7 @@ protected:
int _resourceHeaderSize;
byte _resourceMapper[128];
byte *_heV7DiskOffsets;
- int32 *_heV7RoomIntOffsets;
+ uint32 *_heV7RoomIntOffsets;
const byte *_resourceLastSearchBuf; // FIXME: need to put it to savefile?
uint32 _resourceLastSearchSize; // FIXME: need to put it to savefile?
diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index c2fb48a653..9f29418ca6 100644
--- a/engines/scumm/sound.cpp
+++ b/engines/scumm/sound.cpp
@@ -1221,7 +1221,7 @@ int ScummEngine::readSoundResource(int type, int idx) {
debugC(DEBUG_SOUND, "FMUS file %s", buffer);
if (dmuFile.open(buffer) == false) {
error("Can't open music file %s*", buffer);
- _res->roomoffs[type][idx] = -1;
+ _res->roomoffs[type][idx] = RES_INVALID_OFFSET;
return 0;
}
dmuFile.seek(4, SEEK_SET);
@@ -1245,7 +1245,7 @@ int ScummEngine::readSoundResource(int type, int idx) {
}
error("Unrecognized base tag 0x%08x in sound %d", basetag, idx);
}
- _res->roomoffs[type][idx] = -1;
+ _res->roomoffs[type][idx] = RES_INVALID_OFFSET;
return 0;
}
@@ -2107,7 +2107,7 @@ int ScummEngine::readSoundResourceSmallHeader(int type, int idx) {
_fileHandle->read(_res->createResource(type, idx, ro_size - 4), ro_size - 4);
return 1;
}
- _res->roomoffs[type][idx] = -1;
+ _res->roomoffs[type][idx] = RES_INVALID_OFFSET;
return 0;
}