[Scummvm-cvs-logs] scummvm master -> 2743da58542aceb21d2403bdcbd8305a3a1ab52e

wjp wjp at usecode.org
Thu May 16 08:11:50 CEST 2013


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
2743da5854 HOPKINS: Clean up loops


Commit: 2743da58542aceb21d2403bdcbd8305a3a1ab52e
    https://github.com/scummvm/scummvm/commit/2743da58542aceb21d2403bdcbd8305a3a1ab52e
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2013-05-15T23:10:14-07:00

Commit Message:
HOPKINS: Clean up loops

Changed paths:
    engines/hopkins/lines.cpp



diff --git a/engines/hopkins/lines.cpp b/engines/hopkins/lines.cpp
index 6f690a8..767b599 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;






More information about the Scummvm-git-logs mailing list