aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/draci/game.cpp')
-rw-r--r--engines/draci/game.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index 1f3245a31b..82bddb6f9d 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -24,6 +24,7 @@
*/
#include "common/stream.h"
+#include "common/util.h"
#include "draci/draci.h"
#include "draci/game.h"
@@ -332,12 +333,12 @@ void Game::handleInventoryLoop() {
// Otherwise, if we are holding an item, try to place it inside the
// inventory
} else if (_currentItem) {
- const int column = scummvm_lround(
+ const int column = CLIP(scummvm_lround(
(_vm->_mouse->getPosX() - kInventoryX + kInventoryItemWidth / 2.) /
- kInventoryItemWidth) - 1;
- const int line = scummvm_lround(
+ kInventoryItemWidth) - 1, 0L, (long) kInventoryColumns - 1);
+ const int line = CLIP(scummvm_lround(
(_vm->_mouse->getPosY() - kInventoryY + kInventoryItemHeight / 2.) /
- kInventoryItemHeight) - 1;
+ kInventoryItemHeight) - 1, 0L, (long) kInventoryLines - 1);
const int index = line * kInventoryColumns + column;
putItem(_currentItem, index);