From c619b8d981393bed9958179ea5d2f0a557d41087 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Thu, 8 Dec 2011 03:10:17 +0000 Subject: [PATCH] TOON: Replace usage of 'goto'. --- engines/toon/path.cpp | 9 ++++----- engines/toon/toon.cpp | 12 +++--------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/engines/toon/path.cpp b/engines/toon/path.cpp index 60ca007930e..2dd5fc45e28 100644 --- a/engines/toon/path.cpp +++ b/engines/toon/path.cpp @@ -322,9 +322,10 @@ int32 PathFinding::findPath(int32 x, int32 y, int32 destx, int32 desty) { int32 endY = MIN(curY + 1, _height - 1); int32 startX = MAX(curX - 1, 0); int32 startY = MAX(curY - 1, 0); + bool next = false; - for (int32 px = startX; px <= endX; px++) { - for (int py = startY; py <= endY; py++) { + for (int32 px = startX; px <= endX && !next; px++) { + for (int py = startY; py <= endY && !next; py++) { if (px != curX || py != curY) { wei = ((abs(px - curX) + abs(py - curY))); @@ -336,7 +337,7 @@ int32 PathFinding::findPath(int32 x, int32 y, int32 destx, int32 desty) { sq[curPNode] = sum; _heap->push(px, py, sq[curPNode] + newWeight); if (!newWeight) - goto next; // we found it ! + next = true; // we found it ! } } } @@ -344,8 +345,6 @@ int32 PathFinding::findPath(int32 x, int32 y, int32 destx, int32 desty) { } } -next: - // let's see if we found a result ! if (!_gridTemp[destx + desty * _width]) { // didn't find anything diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp index 13f702e3dd0..99932362afe 100644 --- a/engines/toon/toon.cpp +++ b/engines/toon/toon.cpp @@ -2297,8 +2297,7 @@ void ToonEngine::processConversationClick(Conversation *conv, int32 status) { if (v8 == -1) { _gameState->_mouseHidden = false; } else { -retry: - while (1) { + while (v8 != -1) { v7 += 1; int16 *v14 = (int16 *)((char *)_conversationData + v8); @@ -2315,15 +2314,10 @@ retry: v8 = READ_LE_INT16(v7); if (v8 == -1) return; - - goto retry; + else + break; // restarts while loop; } } - - if (v8 != -1) - continue; - - break; } } }