aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2013-05-16 08:10:14 +0200
committerWillem Jan Palenstijn2013-05-16 08:10:14 +0200
commit2743da58542aceb21d2403bdcbd8305a3a1ab52e (patch)
tree4962bc0399c36d84010b5a88074bf90caebc2493
parent9f641c3d9850a1570872f98bdecbaeb1f39b6be2 (diff)
downloadscummvm-rg350-2743da58542aceb21d2403bdcbd8305a3a1ab52e.tar.gz
scummvm-rg350-2743da58542aceb21d2403bdcbd8305a3a1ab52e.tar.bz2
scummvm-rg350-2743da58542aceb21d2403bdcbd8305a3a1ab52e.zip
HOPKINS: Clean up loops
-rw-r--r--engines/hopkins/lines.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/engines/hopkins/lines.cpp b/engines/hopkins/lines.cpp
index 6f690a8894..767b599d68 100644
--- a/engines/hopkins/lines.cpp
+++ b/engines/hopkins/lines.cpp
@@ -945,45 +945,45 @@ int LinesManager::computeRouteIdx(int lineIdx, int dataIdx, int fromX, int fromY
if (destX >= minLineX && destX <= maxLineX && destY >= minLineY && destY <= maxLineY) {
int curY = destY;
int linesIdxUp = -1;
- loopCond = false;
- for (;;) {
+ do {
--curY;
- if (loopCond = checkCollisionLine(destX, curY, &foundDataIdx, &foundLineIdx, startLineIdx, endLineIdx))
+ if (checkCollisionLine(destX, curY, &foundDataIdx, &foundLineIdx, startLineIdx, endLineIdx)) {
linesIdxUp = foundLineIdx;
- if (!curY || minLineY > curY || loopCond)
break;
- }
+ }
+ } while (curY && curY >= minLineY);
+
curY = destY;
int lineIdxDown = -1;
- loopCond = false;
- for (;;) {
+ do {
++curY;
- if (loopCond = checkCollisionLine(destX, curY, &foundDataIdx, &foundLineIdx, startLineIdx, endLineIdx))
+ if (checkCollisionLine(destX, curY, &foundDataIdx, &foundLineIdx, startLineIdx, endLineIdx)) {
lineIdxDown = foundLineIdx;
- if (_vm->_globals->_characterMaxPosY <= curY || maxLineY <= curY || loopCond)
break;
- }
+ }
+ } while (curY < _vm->_globals->_characterMaxPosY && curY < maxLineY);
+
int curX = destX;
int lineIdxRight = -1;
- loopCond = false;
- for (;;) {
+ do {
++curX;
- if (loopCond = checkCollisionLine(curX, destY, &foundDataIdx, &foundLineIdx, startLineIdx, endLineIdx))
+ if (checkCollisionLine(curX, destY, &foundDataIdx, &foundLineIdx, startLineIdx, endLineIdx)) {
lineIdxRight = foundLineIdx;
-
- if (_vm->_graphicsMan->_maxX <= curX || maxLineX <= curX || loopCond)
break;
- }
+ }
+ } while (curX < _vm->_graphicsMan->_maxX && curX < maxLineX);
+
curX = destX;
int lineIdxLeft = -1;
loopCond = false;
- for(;;) {
+ do {
--curX;
- if (loopCond = checkCollisionLine(curX, destY, &foundDataIdx, &foundLineIdx, startLineIdx, endLineIdx))
+ if (checkCollisionLine(curX, destY, &foundDataIdx, &foundLineIdx, startLineIdx, endLineIdx)) {
lineIdxLeft = foundLineIdx;
- if (curX <= 0 || minLineX >= curX || loopCond)
break;
- }
+ }
+ } while (curX > 0 && curX > minLineX);
+
if (lineIdxRight != -1 && lineIdxLeft != -1 && linesIdxUp != -1 && lineIdxDown != -1) {
route[routerIdx].invalidate();
return -1;