diff options
author | Filippos Karapetis | 2015-12-19 02:07:33 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:34:10 +0100 |
commit | eb70efc900cd224c4ca301ddf49785ab21ab6132 (patch) | |
tree | ceff0be4f4a1175eb9de34e0e7cd4260cd1c6458 | |
parent | f1bb844e90cd9722170c1a02dd23a7a4cded1943 (diff) | |
download | scummvm-rg350-eb70efc900cd224c4ca301ddf49785ab21ab6132.tar.gz scummvm-rg350-eb70efc900cd224c4ca301ddf49785ab21ab6132.tar.bz2 scummvm-rg350-eb70efc900cd224c4ca301ddf49785ab21ab6132.zip |
LAB: Simplify decIncInv()
-rw-r--r-- | engines/lab/engine.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp index 5eed831d11..a34926f48d 100644 --- a/engines/lab/engine.cpp +++ b/engines/lab/engine.cpp @@ -390,30 +390,30 @@ bool LabEngine::doUse(uint16 curInv) { */ void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) { int8 step = (decreaseFl) ? -1 : 1; + uint newInv = *curInv + step; + + // Handle wrapping + if (newInv < 1) + newInv = _numInv; + if (newInv > _numInv) + newInv = 1; + interfaceOff(); - (*curInv) += step; - - while (*curInv && (*curInv <= _numInv)) { - if (_conditions->in(*curInv) && _inventory[*curInv]._bitmapName) { - _nextFileName = getInvName(*curInv); + while (newInv && (newInv <= _numInv)) { + if (_conditions->in(newInv) && _inventory[newInv]._bitmapName) { + _nextFileName = getInvName(newInv); + *curInv = newInv; break; } - (*curInv) += step; - } - - if ((*curInv == 0) || (*curInv > _numInv)) { - (*curInv) += step; + newInv += step; - while (*curInv && (*curInv <= _numInv)) { - if (_conditions->in(*curInv) && _inventory[*curInv]._bitmapName) { - _nextFileName = getInvName(*curInv); - break; - } - - (*curInv) += step; - } + // Handle wrapping + if (newInv < 1) + newInv = _numInv; + if (newInv > _numInv) + newInv = 1; } } |