diff options
Diffstat (limited to 'map.c')
-rw-r--r-- | map.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -18,6 +18,42 @@ byte _map_owner [MAP_SIZE]; uint16 _map2 [MAP_SIZE]; byte _map_extra_bits [MAP_SIZE / 4]; + +#ifdef _DEBUG +TileIndex TileAdd(TileIndex tile, TileIndexDiff add, + const char *exp, const char *file, int line) +{ + int dx; + int dy; + uint x; + uint y; + + dx = add & MapMaxX(); + if (dx >= MapSizeX() / 2) dx -= MapSizeX(); + dy = (add - dx) / (int)MapSizeX(); + + x = TileX(tile) + dx; + y = TileY(tile) + dy; + + if (x >= MapSizeX() || y >= MapSizeY()) { + char buf[512]; + + sprintf(buf, "TILE_ADD(%s) when adding 0x%.4X and 0x%.4X failed", + exp, tile, add); +#if !defined(_MSC_VER) + fprintf(stderr, "%s:%d %s\n", file, line, buf); +#else + _assert(buf, (char*)file, line); +#endif + } + + assert(TILE_XY(x,y) == TILE_MASK(tile + add)); + + return TILE_XY(x,y); +} +#endif + + const TileIndexDiffC _tileoffs_by_dir[] = { {-1, 0}, { 0, 1}, |