diff options
author | David Turner | 2011-12-18 18:29:05 -0800 |
---|---|---|
committer | David Turner | 2011-12-18 18:29:05 -0800 |
commit | 538d83408091e9077f451f45c1ac1127f302b47d (patch) | |
tree | a8b3ffaf9199665b41e8f990549fc267c6421b46 /engines/toon/path.cpp | |
parent | f0eee81d327957cddb85c5a1ffe7a308a377f636 (diff) | |
parent | f722542ceea557e906699c60b10b3ace1f41c238 (diff) | |
download | scummvm-rg350-538d83408091e9077f451f45c1ac1127f302b47d.tar.gz scummvm-rg350-538d83408091e9077f451f45c1ac1127f302b47d.tar.bz2 scummvm-rg350-538d83408091e9077f451f45c1ac1127f302b47d.zip |
Merge pull request #131 from digitall/goto_considered_harmful
Goto Considered Harmful...
The following commits should improve the ScummVM code structure by reducing the number of gotos used in various engine code.
They should implement identical functionality, but without using goto and without the result being less readable/maintainable than the version with goto.
Diffstat (limited to 'engines/toon/path.cpp')
-rw-r--r-- | engines/toon/path.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/engines/toon/path.cpp b/engines/toon/path.cpp index 60ca007930..2dd5fc45e2 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<int32>(curY + 1, _height - 1); int32 startX = MAX<int32>(curX - 1, 0); int32 startY = MAX<int32>(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 |