Mercurial > hg > openttd
changeset 18852:63b2d7ad4248 draft
(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)
author | truebrain <truebrain@openttd.org> |
---|---|
date | Sun, 01 Jan 2012 16:01:51 +0000 |
parents | 529df770c92d |
children | c395d39368f3 |
files | src/map.cpp |
diffstat | 1 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/map.cpp +++ b/src/map.cpp @@ -117,12 +117,12 @@ 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 */