summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-06-09 23:34:48 +0000
committersmatz <smatz@openttd.org>2009-06-09 23:34:48 +0000
commit0c0943fe8394e2c7d59f37c75c10049ead6f3563 (patch)
tree3770648fdafed94507570f08ed13debfc9e9c84f /src
parentfd191dd616b85ca27f2ef838fc68b41fdae0eae0 (diff)
downloadopenttd-0c0943fe8394e2c7d59f37c75c10049ead6f3563.tar.xz
(svn r16547) -Codechange: make CircularTileSearch a tiny bit faster
Diffstat (limited to 'src')
-rw-r--r--src/map.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 8e7aeffed..cdca65e00 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -307,12 +307,17 @@ bool CircularTileSearch(TileIndex *tile, uint radius, uint w, uint h, TestTileOn
uint extent[DIAGDIR_END] = { w, h, w, h };
for (uint n = 0; n < radius; n++) {
- for (DiagDirection dir = DIAGDIR_NE; dir < DIAGDIR_END; dir++) {
+ for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
+ /* Is the tile within the map? */
for (uint j = extent[dir] + n * 2 + 1; j != 0; j--) {
- if (x <= MapMaxX() && y <= MapMaxY() && ///< Is the tile within the map?
- proc(TileXY(x, y), user_data)) { ///< Is the callback successful?
- *tile = TileXY(x, y);
- return true; ///< then stop the search
+ if (x < MapSizeX() && y < MapSizeY()) {
+ TileIndex t = TileXY(x, y);
+ /* Is the callback successful? */
+ if (proc(t, user_data)) {
+ /* Stop the search */
+ *tile = t;
+ return true;
+ }
}
/* Step to the next 'neighbour' in the circular line */