summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2012-01-01 16:01:51 +0000
committertruebrain <truebrain@openttd.org>2012-01-01 16:01:51 +0000
commit6f6035ce0ba88efe5a67da14f71cba54978ab471 (patch)
treeee8184c7107fcc89fba4f40cfcdf2e06eaafeacc /src
parent39f2d75e0315d42472ba645fbfdd40a350e69e54 (diff)
downloadopenttd-6f6035ce0ba88efe5a67da14f71cba54978ab471.tar.xz
(svn r23701) -Codechange: give TileAddWrap() a 27% speed-up, by swapping entries in an if() statement, and reusing already calculated values (tnx to SmatZ for the ideas)
Diffstat (limited to 'src')
-rw-r--r--src/map.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 2de65ed84..823ff6d2d 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -117,12 +117,12 @@ TileIndex TileAddWrap(TileIndex tile, int addx, int addy)
uint y = TileY(tile) + addy;
/* Disallow void tiles at the north border. */
- if (_settings_game.construction.freeform_edges && (x == 0 || y == 0)) return INVALID_TILE;
+ if ((x == 0 || y == 0) && _settings_game.construction.freeform_edges) return INVALID_TILE;
/* Are we about to wrap? */
- if (x < MapMaxX() && y < MapMaxY()) return tile + TileDiffXY(addx, addy);
+ if (x >= MapMaxX() || y >= MapMaxY()) return INVALID_TILE;
- return INVALID_TILE;
+ return TileXY(x, y);
}
/** 'Lookup table' for tile offsets given a DiagDirection */