aboutsummaryrefslogtreecommitdiff
path: root/engines/draci
diff options
context:
space:
mode:
authorDenis Kasak2009-08-06 03:52:08 +0000
committerDenis Kasak2009-08-06 03:52:08 +0000
commitda8bad0ef528ecb23dc82bcd3c1e30aef0a3b6ed (patch)
tree46bf33f0ed515b0187e03bfb23b61d3578e6db57 /engines/draci
parente63210616972e59d6e9e98989c489cbf760bcb79 (diff)
downloadscummvm-rg350-da8bad0ef528ecb23dc82bcd3c1e30aef0a3b6ed.tar.gz
scummvm-rg350-da8bad0ef528ecb23dc82bcd3c1e30aef0a3b6ed.tar.bz2
scummvm-rg350-da8bad0ef528ecb23dc82bcd3c1e30aef0a3b6ed.zip
Made the game behave properly and safe when clicking on objects multiple times during talking or executing look/use scripts. Previously, the loop could be called nested arbitrarily many times.
svn-id: r43081
Diffstat (limited to 'engines/draci')
-rw-r--r--engines/draci/game.cpp60
1 files changed, 32 insertions, 28 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index d8152b0fcb..3e3162e543 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -262,37 +262,41 @@ void Game::loop() {
Animation *titleAnim = _vm->_anims->getAnimation(kTitleText);
Text *title = reinterpret_cast<Text *>(titleAnim->getFrame());
- // If there is an object under the cursor, display its title and enable
- // executing its look and use scripts
- if (curObject != kObjectNotFound) {
- // Mark dirty rectangle to update the text
- titleAnim->markDirtyRect(surface);
-
- // Set the title for the current object
- title->setText(obj->_title);
-
- // Move the title to the correct place (just above the cursor)
- int newX = surface->centerOnX(x, title->getWidth());
- int newY = surface->centerOnY(y - smallFontHeight / 2, title->getHeight() * 2);
- titleAnim->setRelative(newX, newY);
-
- // HACK: Test running look and use scripts
- if (_vm->_mouse->lButtonPressed()) {
- _vm->_mouse->lButtonSet(false);
- _vm->_script->run(obj->_program, obj->_look);
+ if (_loopStatus == kStatusOrdinary) {
+ // If there is an object under the cursor, display its title and enable
+ // executing its look and use scripts
+ if (curObject != kObjectNotFound) {
+ // Mark dirty rectangle to update the text
+ titleAnim->markDirtyRect(surface);
+
+ // Set the title for the current object
+ title->setText(obj->_title);
+
+ // Move the title to the correct place (just above the cursor)
+ int newX = surface->centerOnX(x, title->getWidth());
+ int newY = surface->centerOnY(y - smallFontHeight / 2, title->getHeight() * 2);
+ titleAnim->setRelative(newX, newY);
+
+ if (_loopSubstatus == kStatusOrdinary) {
+ // HACK: Test running look and use scripts
+ if (_vm->_mouse->lButtonPressed()) {
+ _vm->_mouse->lButtonSet(false);
+ _vm->_script->run(obj->_program, obj->_look);
+ }
+
+ if (_vm->_mouse->rButtonPressed()) {
+ _vm->_mouse->rButtonSet(false);
+ _vm->_script->run(obj->_program, obj->_use);
+ }
+ }
+ } else {
+ // If there is no object under the cursor, just delete the previous title
+ titleAnim->markDirtyRect(surface);
+ title->setText("");
}
- if (_vm->_mouse->rButtonPressed()) {
- _vm->_mouse->rButtonSet(false);
- _vm->_script->run(obj->_program, obj->_use);
- }
- } else {
- // If there is no object under the cursor, just delete the previous title
- titleAnim->markDirtyRect(surface);
- title->setText("");
+ debugC(2, kDraciAnimationDebugLevel, "Anim under cursor: %d", animUnderCursor);
}
-
- debugC(2, kDraciAnimationDebugLevel, "Anim under cursor: %d", animUnderCursor);
}
// Handle character talking (if there is any)