diff options
author | Filippos Karapetis | 2010-08-05 21:48:30 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-08-05 21:48:30 +0000 |
commit | 4ae7427eed781613e2cda096d0f61c77883bca05 (patch) | |
tree | 0bcfb7501e99e713136a67db2d27ea15d37d925c | |
parent | b69469a75d6a4247df0632fa8862398179540704 (diff) | |
download | scummvm-rg350-4ae7427eed781613e2cda096d0f61c77883bca05.tar.gz scummvm-rg350-4ae7427eed781613e2cda096d0f61c77883bca05.tar.bz2 scummvm-rg350-4ae7427eed781613e2cda096d0f61c77883bca05.zip |
Added a sanity check inside kDoBresen, thanks to lskovlun. Fixes the random crashes in the floor scrubbing scene in SQ5
svn-id: r51768
-rw-r--r-- | engines/sci/engine/kmovement.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index 7f3439331e..4becc6f415 100644 --- a/engines/sci/engine/kmovement.cpp +++ b/engines/sci/engine/kmovement.cpp @@ -30,6 +30,7 @@ #include "sci/engine/selector.h" #include "sci/engine/kernel.h" #include "sci/graphics/animate.h" +#include "sci/graphics/screen.h" namespace Sci { @@ -313,8 +314,15 @@ reg_t kDoBresen(EngineState *s, int argc, reg_t *argv) { || ((y == desty) && (abs(dy) >= abs(dx))) /* Moving fast, reached? */ ))) { // Whew... in short: If we have reached or passed our target position - x = destx; - y = desty; + + // Sanity check: make sure that destx, desty are inside the screen coordinates. + // They can go off screen in some cases, e.g. in SQ5 while scrubbing the floor + if (destx < g_sci->_gfxScreen->getWidth() && desty < g_sci->_gfxScreen->getHeight()) { + x = destx; + y = desty; + } else { + warning("kDoBresen: destination x, y would be off-screen(%d, %d)", destx, desty); + } completed = 1; debugC(2, kDebugLevelBresen, "Finished mover %04x:%04x", PRINT_REG(mover)); |