[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.141,1.142 boxes.cpp,1.48,1.49 scummvm.cpp,2.293,2.294
Max Horn
fingolfin at users.sourceforge.net
Mon Jul 21 15:00:04 CEST 2003
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv18047
Modified Files:
actor.cpp boxes.cpp scummvm.cpp
Log Message:
Fix for bug #770690 and bug #774783
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -d -r1.141 -r1.142
--- actor.cpp 19 Jul 2003 18:18:01 -0000 1.141
+++ actor.cpp 21 Jul 2003 21:59:07 -0000 1.142
@@ -1409,14 +1409,12 @@
break;
next_box = _vm->getPathToDestBox(walkbox, walkdata.destbox);
-
if (next_box < 0) {
moving |= MF_LAST_LEG;
return;
}
- // FIXME: not sure if this is needed in non-Zak games, but I think it shouldn't
- // hurt there either.
+ // Can't walk through locked boxes
int flags = _vm->getBoxFlags(next_box);
if (flags & kBoxLocked && !(flags & kBoxPlayerOnly && !isPlayer())) {
moving |= MF_LAST_LEG;
Index: boxes.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/boxes.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- boxes.cpp 19 Jul 2003 18:18:01 -0000 1.48
+++ boxes.cpp 21 Jul 2003 21:59:07 -0000 1.49
@@ -600,6 +600,7 @@
byte *Scumm::getBoxMatrixBaseAddr() {
byte *ptr = getResourceAddress(rtMatrix, 1);
+ assert(ptr);
if (*ptr == 0xFF)
ptr++;
return ptr;
@@ -612,9 +613,8 @@
* If there is no connection -1 is return.
*/
int Scumm::getPathToDestBox(byte from, byte to) {
- byte *boxm;
+ const byte *boxm;
byte i;
- int dest = -1;
const int numOfBoxes = getNumBoxes();
if (from == to)
@@ -636,24 +636,46 @@
// The first numOfBoxes bytes contain indices to the start of the corresponding
// row (although that seems unnecessary to me - the value is easily computable.
boxm += numOfBoxes + boxm[from];
- return boxm[to];
+ return (int8)boxm[to];
}
+ // WORKAROUND #1: It seems that in some cases, the box matrix is corrupt
+ // (more precisely, is too short) in the datafiles already. In
+ // particular this seems to be the case in room 46 of Indy3 EGA (see
+ // also bug #770690). This didn't cause problems in the original
+ // engine, because there, the memory layout is different. After the
+ // walkbox would follow the rest of the room file, thus the program
+ // always behaved the same (and by chance, correct). Not so for us,
+ // since random data may follow after the resource in ScummVM.
+ //
+ // As a workaround, we add a check for the end of the box matrix
+ // resource, and abort the search once we reach the end.
+ const byte *end = boxm + getResourceSize(rtMatrix, 1);
+
+ // WORKAROUND #2: In addition to the above, we have to add this special
+ // case to fix the scene in Indy3 where Indy meets Hitler in Berlin.
+ // It's one of the places (or maybe even the only one?). See bug #770690
+ if (_gameId == GID_INDY3 && _roomResource == 46 && from == 1 && to == 0)
+ return 0;
+
// Skip up to the matrix data for box 'from'
- for (i = 0; i < from; i++) {
+ for (i = 0; i < from && boxm < end; i++) {
while (*boxm != 0xFF)
boxm += 3;
boxm++;
}
// Now search for the entry for box 'to'
- while (boxm[0] != 0xFF) {
+ while (boxm < end && boxm[0] != 0xFF) {
if (boxm[0] <= to && to <= boxm[1])
- dest = boxm[2];
+ return (int8)boxm[2];
boxm += 3;
}
+
+ if (boxm >= end)
+ warning("The box matrix apparently is truncated (room %d)", _roomResource);
- return dest;
+ return -1;
}
/*
Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.293
retrieving revision 2.294
diff -u -d -r2.293 -r2.294
--- scummvm.cpp 20 Jul 2003 19:19:45 -0000 2.293
+++ scummvm.cpp 21 Jul 2003 21:59:07 -0000 2.294
@@ -2012,7 +2012,7 @@
else
size = getResourceDataSize(ptr - size - 6) - size;
- if (size >= 0) { // do this :)
+ if (size > 0) { // do this :)
createResource(rtMatrix, 1, size);
memcpy(getResourceAddress(rtMatrix, 1), ptr, size);
}
More information about the Scummvm-git-logs
mailing list