From 4a7cea681360d21a9be983bf75942a1c693cdbb9 Mon Sep 17 00:00:00 2001 From: Robert Špalek Date: Thu, 1 Oct 2009 16:47:34 +0000 Subject: Fixed event handling. ValGrind fixups. My yesterday's fix on handling 1 event per call caused the game to be unbearably slow on Linux. The old way was much faster. I have solved too fast a succession of mouse button down and up by not clearing the mouse flag when the button goes up instead. Fixed a memory leak and uninitialized variable after my refactoring of game location changes; found by ValGrind. svn-id: r44525 --- engines/draci/draci.cpp | 6 ------ engines/draci/game.cpp | 13 +++++++------ engines/draci/mouse.cpp | 6 ++++-- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp index 6290ee01dc..aaf24430ff 100644 --- a/engines/draci/draci.cpp +++ b/engines/draci/draci.cpp @@ -224,12 +224,6 @@ bool DraciEngine::handleEvents() { default: _mouse->handleEvent(event); } - - // TODO: I place the break here to make sure that each event is - // processed. If I don't do that and allow more than 1 event, - // then a very quick succession of mouse button down and up - // (occuring on a touchpad) cancels each other. - break; } // Show walking map overlay diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index 44a77f8f22..2593d5f763 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -157,6 +157,8 @@ void Game::init() { _shouldQuit = false; _shouldExitLoop = false; _scheduledPalette = 0; + setLoopStatus(kStatusGate); + setLoopSubstatus(kSubstatusOrdinary); _animUnderCursor = kOverlayImage; @@ -851,8 +853,7 @@ void Game::dialogueDone() { _vm->_anims->stop(_dialogueAnims[i]->getID()); } - _dialogueArchive->closeArchive(); - + delete _dialogueArchive; delete[] _dialogueBlocks; setLoopStatus(kStatusOrdinary); @@ -1286,6 +1287,10 @@ void Game::enterNewRoom() { _persons[kDragonObject]._y = 0; } + // Set the appropriate loop statu before loading the room + setLoopStatus(kStatusGate); + setLoopSubstatus(kSubstatusOrdinary); + loadRoom(_newRoom); loadOverlays(); @@ -1309,10 +1314,6 @@ void Game::enterNewRoom() { void Game::runGateProgram(int gate) { debugC(6, kDraciLogicDebugLevel, "Running program for gate %d", gate); - // Set the appropriate loop statu before executing the gate program - setLoopStatus(kStatusGate); - setLoopSubstatus(kSubstatusOrdinary); - // Mark last animation int lastAnimIndex = _vm->_anims->getLastIndex(); diff --git a/engines/draci/mouse.cpp b/engines/draci/mouse.cpp index 3629d40d0d..f5eb2bbf4d 100644 --- a/engines/draci/mouse.cpp +++ b/engines/draci/mouse.cpp @@ -47,7 +47,10 @@ void Mouse::handleEvent(Common::Event event) { case Common::EVENT_LBUTTONUP: debugC(6, kDraciGeneralDebugLevel, "Left button up (x: %u y: %u)", _x, _y); - _lButton = false; + // Don't set _lButton to false, because some touchpads generate + // down and up at such a quick succession, that they will + // cancel each other in the same call of handleEvents(). Let + // the game clear this flag by calling lButtonSet() instead. break; case Common::EVENT_RBUTTONDOWN: @@ -57,7 +60,6 @@ void Mouse::handleEvent(Common::Event event) { case Common::EVENT_RBUTTONUP: debugC(6, kDraciGeneralDebugLevel, "Right button up (x: %u y: %u)", _x, _y); - _rButton = false; break; case Common::EVENT_MOUSEMOVE: -- cgit v1.2.3