(svn r7198) -Codechange: Implement a circular tile search function.

Just provide the number of tiles per side, a pointer to a test function, the tile to start searching and voila.
Fixes [FS#364] by removing a lengthy and suboptimal random search pattern.
Thanks Rubidium.
This commit is contained in:
belugas
2006-11-17 23:01:58 +00:00
parent 9a8c149321
commit 392fc3a45b
5 changed files with 136 additions and 89 deletions

3
map.h
View File

@@ -176,6 +176,9 @@ static inline TileIndexDiff TileOffsByDir(uint dir)
return ToTileIndexDiff(_tileoffs_by_dir[dir]);
}
typedef bool TestTileOnSearchProc(TileIndex tile, uint32 data);
bool CircularTileSearch(TileIndex tile, uint size, TestTileOnSearchProc proc, uint32 data);
/* Approximation of the length of a straight track, relative to a diagonal
* track (ie the size of a tile side). #defined instead of const so it can
* stay integer. (no runtime float operations) Is this needed?