Changeset - r18842:85657a637744
[Not reviewed]
master
0 1 0
truebrain - 13 years ago 2012-01-01 16:01:51
truebrain@openttd.org
(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)
1 file changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/map.cpp
Show inline comments
 
@@ -117,12 +117,12 @@ TileIndex TileAddWrap(TileIndex tile, in
 
	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 */
0 comments (0 inline, 0 general)