diff options
author | Strangerke | 2019-08-05 23:39:36 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:32 +0200 |
commit | 161553db9bbfb9f08f936f7b38e2f2ddcf793e07 (patch) | |
tree | 92914964d339ee0d6d320c8d335362c32baba57e /engines/hdb | |
parent | 22251ec2a77445d09f9f1100cd2752339acd075f (diff) | |
download | scummvm-rg350-161553db9bbfb9f08f936f7b38e2f2ddcf793e07.tar.gz scummvm-rg350-161553db9bbfb9f08f936f7b38e2f2ddcf793e07.tar.bz2 scummvm-rg350-161553db9bbfb9f08f936f7b38e2f2ddcf793e07.zip |
HDB: Reduce some more variable scopes, simplify a couple of checks in input.cpp
Diffstat (limited to 'engines/hdb')
-rw-r--r-- | engines/hdb/gfx.cpp | 18 | ||||
-rw-r--r-- | engines/hdb/input.cpp | 34 |
2 files changed, 22 insertions, 30 deletions
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp index 36ce3d941c..8a6e3530ad 100644 --- a/engines/hdb/gfx.cpp +++ b/engines/hdb/gfx.cpp @@ -1144,14 +1144,11 @@ Graphics::Surface Picture::load(Common::SeekableReadStream *stream) { if (g_hdb->isPPC()) { _surface.create(_height, _width, g_hdb->_format); - uint16 *ptr; - for (int y = 0; y < _height; y++) { for (int x = 0; x < _width; x++) { - int u, v; - u = y; - v = _height - x - 1; - ptr = (uint16 *)_surface.getBasePtr(u, v); + int u = y; + int v = _height - x - 1; + uint16 *ptr = (uint16 *)_surface.getBasePtr(u, v); *ptr = TO_LE_16(stream->readUint16LE()); } } @@ -1212,14 +1209,11 @@ Graphics::Surface Tile::load(Common::SeekableReadStream *stream) { _surface.create(32, 32, g_hdb->_format); if (g_hdb->isPPC()) { - uint16 *ptr; - for (int y = 0; y < 32; y++) { for (int x = 0; x < 32; x++) { - int u, v; - u = y; - v = 32 - x - 1; - ptr = (uint16 *)_surface.getBasePtr(u, v); + int u = y; + int v = 32 - x - 1; + uint16 *ptr = (uint16 *)_surface.getBasePtr(u, v); *ptr = TO_LE_16(stream->readUint16LE()); } } diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp index 99506a5de9..fb7f127cdf 100644 --- a/engines/hdb/input.cpp +++ b/engines/hdb/input.cpp @@ -136,8 +136,8 @@ void Input::setButtons(uint16 b) { g_hdb->_window->setSelectedDelivery(current); } else if (_buttons & kButtonRight) { - int amount = g_hdb->_ai->getDeliveriesAmount(); - int current = g_hdb->_window->getSelectedDelivery(); + int amount = g_hdb->_ai->getDeliveriesAmount(); + int current = g_hdb->_window->getSelectedDelivery(); current++; if (current == amount) @@ -156,7 +156,6 @@ void Input::setButtons(uint16 b) { // select weapon? if (_buttons & kButtonB) { static AIType lastWeaponSelected = AI_NONE; - Tile *gfx; if (!g_hdb->getActionMode()) { g_hdb->_window->closeInv(); @@ -164,7 +163,7 @@ void Input::setButtons(uint16 b) { } AIType t = g_hdb->_ai->getInvItemType(g_hdb->_window->getInvSelect()); - gfx = g_hdb->_ai->getInvItemGfx(g_hdb->_window->getInvSelect()); + Tile *gfx = g_hdb->_ai->getInvItemGfx(g_hdb->_window->getInvSelect()); switch (t) { case ITEM_CLUB: @@ -205,8 +204,8 @@ void Input::setButtons(uint16 b) { g_hdb->_sound->playSound(SND_MENU_SLIDER); g_hdb->_window->setInvSelect(current); } else if (_buttons & kButtonRight) { - int amount = g_hdb->_ai->getInvMax(); - int current = g_hdb->_window->getInvSelect(); + int amount = g_hdb->_ai->getInvMax(); + int current = g_hdb->_window->getInvSelect(); if (!amount) return; @@ -226,10 +225,10 @@ void Input::setButtons(uint16 b) { g_hdb->_sound->playSound(SND_MENU_SLIDER); g_hdb->_window->setInvSelect(current); } else if (_buttons & kButtonUp) { - int amount = g_hdb->_ai->getInvMax(); - int current = g_hdb->_window->getInvSelect(); + int amount = g_hdb->_ai->getInvMax(); + int current = g_hdb->_window->getInvSelect(); - if (!amount || amount < 6) + if (amount < 6) return; if (current - 5 >= 0) @@ -238,10 +237,10 @@ void Input::setButtons(uint16 b) { g_hdb->_sound->playSound(SND_MENU_SLIDER); g_hdb->_window->setInvSelect(current); } else if (_buttons & kButtonDown) { - int amount = g_hdb->_ai->getInvMax(); - int current = g_hdb->_window->getInvSelect(); + int amount = g_hdb->_ai->getInvMax(); + int current = g_hdb->_window->getInvSelect(); - if (!amount || amount < 6) + if (amount < 6) return; if (current + 5 < amount) @@ -346,9 +345,10 @@ void Input::stylusDown(int x, int y) { } // Is MessageBar active? - if (g_hdb->_window->msgBarActive()) + if (g_hdb->_window->msgBarActive()) { if (g_hdb->_window->checkMsgClose(x, y)) return; + } // In a cinematic? if (g_hdb->_ai->playerLocked()) @@ -380,8 +380,8 @@ void Input::stylusDown(int x, int y) { } // Toggle Walk Speed if we clicked Player - int nx, ny; static uint32 lastRunning = g_system->getMillis(); + int nx, ny; g_hdb->_ai->getPlayerXY(&nx, &ny); if (nx == worldX && ny == worldY) { if (lastRunning > g_system->getMillis()) @@ -426,7 +426,6 @@ void Input::stylusMove(int x, int y) { } void Input::updateMouse(int newX, int newY) { - if (g_hdb->isPPC()) return; @@ -579,11 +578,10 @@ void Input::updateKeys(Common::Event event, bool keyDown) { g_hdb->_menu->setMenuKey(0); } } else if (event.kbd.keycode == _keyDebug) { - if (keyDown) { + if (keyDown) buttons |= kButtonExit; - } else { + else buttons &= ~kButtonExit; - } } setButtons(buttons); |