Mercurial > hg > batmud > maputils
changeset 1808:54607b2d0c8c
Don't use strchr() for the center finding algorithm, it is not fit to our purpose.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 30 Oct 2017 00:04:54 +0200 |
parents | d419124e284a |
children | 364e5ae52398 |
files | mapsearch.c |
diffstat | 1 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mapsearch.c Mon Oct 30 00:04:00 2017 +0200 +++ b/mapsearch.c Mon Oct 30 00:04:54 2017 +0200 @@ -519,7 +519,17 @@ } -BOOL mapBlockFindCenter(const MapBlock *block, const char *symbols, int *cx, int *cy, const int tolerance) +BOOL mapStrChr(const unsigned char *symbols, const size_t nsymbols, const unsigned char ch) +{ + for (size_t n = 0; n < nsymbols; n++) + if (symbols[n] == ch) + return TRUE; + + return FALSE; +} + + +BOOL mapBlockFindCenter(const MapBlock *block, const unsigned char *symbols, const size_t nsymbols, int *cx, int *cy, const int tolerance) { const int x0 = (block->width * tolerance) / 100, @@ -535,7 +545,7 @@ { if (xc >= x0 && xc <= x1 && yc >= y0 && yc <= y1 && - strchr(symbols, dp[xc]) != NULL) + mapStrChr(symbols, nsymbols, dp[xc])) { *cx = xc; *cy = yc;