diff options
author | Strangerke | 2016-05-23 07:52:48 +0200 |
---|---|---|
committer | Strangerke | 2016-05-23 07:52:48 +0200 |
commit | aeb36d4afc0c6b5961adc411dc03b00a96a86f99 (patch) | |
tree | 04d14759f181b1f462e84ac8d579df1ba9d8810a | |
parent | f0f42b05ca0302fc018e5a094cead25096564c77 (diff) | |
download | scummvm-rg350-aeb36d4afc0c6b5961adc411dc03b00a96a86f99.tar.gz scummvm-rg350-aeb36d4afc0c6b5961adc411dc03b00a96a86f99.tar.bz2 scummvm-rg350-aeb36d4afc0c6b5961adc411dc03b00a96a86f99.zip |
GNAP: Add safeguard checks in PlayerGnap's getWalkStopSequenceId and getWalkFacing
-rw-r--r-- | engines/gnap/grid.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/engines/gnap/grid.cpp b/engines/gnap/grid.cpp index 2197317227..aa6da71395 100644 --- a/engines/gnap/grid.cpp +++ b/engines/gnap/grid.cpp @@ -68,8 +68,10 @@ int PlayerGnap::getWalkStopSequenceId(int deltaX, int deltaY) { 0x7BC, 0x000, 0x7BA, 0x7BB, 0x7B9, 0x7B9 }; - // CHECKME This is a little weird - return gnapWalkStopSequenceIds[3 * deltaX + 3 + 1 + deltaY]; + + int id = 3 * (deltaX + 1) + deltaY + 1; + assert (id >= 0 && id < 9 ); + return gnapWalkStopSequenceIds[id]; } Facing PlayerGnap::getWalkFacing(int deltaX, int deltaY) { @@ -78,8 +80,10 @@ Facing PlayerGnap::getWalkFacing(int deltaX, int deltaY) { kDirUpLeft, kDirIdleLeft, kDirBottomLeft, kDirUpRight, kDirBottomRight, kDirBottomRight }; - // CHECKME This is a little weird - return gnapWalkFacings[3 * deltaX + 3 + 1 + deltaY]; + + int id = 3 * (deltaX + 1) + deltaY + 1; + assert (id >= 0 && id < 9 ); + return gnapWalkFacings[id]; } bool PlayerGnap::findPath1(int gridX, int gridY, int index) { |