diff options
author | Strangerke | 2019-07-23 08:28:10 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:26 +0200 |
commit | 4b65e396c801e1a08c89de79ebfeaf2f20ada0a0 (patch) | |
tree | 102533b4424a370fa2b1c5c589053165d1c9bead /engines/hdb/input.cpp | |
parent | bf57f7befb5af0c7f3d95b96d6fd1f8a46c056ef (diff) | |
download | scummvm-rg350-4b65e396c801e1a08c89de79ebfeaf2f20ada0a0.tar.gz scummvm-rg350-4b65e396c801e1a08c89de79ebfeaf2f20ada0a0.tar.bz2 scummvm-rg350-4b65e396c801e1a08c89de79ebfeaf2f20ada0a0.zip |
HDB: Reduce some variable scopes, some janitorial work
Diffstat (limited to 'engines/hdb/input.cpp')
-rw-r--r-- | engines/hdb/input.cpp | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp index 91b3a97589..e345032368 100644 --- a/engines/hdb/input.cpp +++ b/engines/hdb/input.cpp @@ -121,8 +121,6 @@ uint16 Input::getButtons() { } void Input::stylusDown(int x, int y) { - int worldX, worldY; - GameState gs; static uint32 delay = 0, time; // Don't let the screen get clicked too fast @@ -134,7 +132,7 @@ void Input::stylusDown(int x, int y) { _stylusDown = true; _stylusDownX = x; _stylusDownY = y; - gs = g_hdb->getGameState(); + GameState gs = g_hdb->getGameState(); switch (gs) { case GAME_TITLE: @@ -183,9 +181,9 @@ void Input::stylusDown(int x, int y) { // Check for map dragging in debug Mode and place player there if ((GAME_PLAY == g_hdb->getGameState()) && g_hdb->getDebug() == 2) { - int mx, my; - + int mx, my; g_hdb->_map->getMapXY(&mx, &my); + mx = ((mx + _stylusDownY) / kTileWidth) * kTileWidth; my = ((my + _stylusDownY) / kTileHeight) * kTileHeight; g_hdb->_ai->setPlayerXY(mx, my); @@ -195,6 +193,7 @@ void Input::stylusDown(int x, int y) { } // Clicked in the world + int worldX, worldY; g_hdb->_map->getMapXY(&worldX, &worldY); worldX = ((worldX + x) / kTileWidth) * kTileWidth; worldY = ((worldY + y) / kTileHeight) * kTileHeight; @@ -317,6 +316,7 @@ void Input::updateMouseButtons(int l, int m, int r) { } void Input::updateKeys(Common::Event event, bool keyDown) { + static int current = 0, last = 0; if (keyDown && event.kbd.keycode == _keyQuit) { g_hdb->quitGame(); @@ -326,18 +326,15 @@ void Input::updateKeys(Common::Event event, bool keyDown) { uint16 buttons = getButtons(); // PAUSE key pressed? - { - static int current = 0, last = 0; - last = current; - if (keyDown && event.kbd.keycode == Common::KEYCODE_p && g_hdb->getGameState() == GAME_PLAY) { - current = 1; - if (!last) { - g_hdb->togglePause(); - g_hdb->_sound->playSound(SND_POP); - } - } else - current = 0; - } + last = current; + if (keyDown && event.kbd.keycode == Common::KEYCODE_p && g_hdb->getGameState() == GAME_PLAY) { + current = 1; + if (!last) { + g_hdb->togglePause(); + g_hdb->_sound->playSound(SND_POP); + } + } else + current = 0; if (!g_hdb->getPause()) { if (event.kbd.keycode == _keyUp) { |