tron@679: #include "stdafx.h" tron@679: #include "ttd.h" tron@679: #include "map.h" tron@679: tron@927: #define TILE_X_BITS 8 tron@927: #define TILE_Y_BITS 8 tron@927: tron@689: uint _map_log_x = TILE_X_BITS; tron@689: uint _map_log_y = TILE_Y_BITS; tron@689: tron@863: #define MAP_SIZE ((1 << TILE_X_BITS) * (1 << TILE_Y_BITS)) tron@863: tron@863: byte _map_type_and_height [MAP_SIZE]; tron@863: byte _map5 [MAP_SIZE]; tron@863: byte _map3_lo [MAP_SIZE]; tron@863: byte _map3_hi [MAP_SIZE]; tron@863: byte _map_owner [MAP_SIZE]; tron@863: uint16 _map2 [MAP_SIZE]; tron@863: byte _map_extra_bits [MAP_SIZE / 4]; tron@900: tron@955: tron@955: #ifdef _DEBUG tron@955: TileIndex TileAdd(TileIndex tile, TileIndexDiff add, tron@955: const char *exp, const char *file, int line) tron@955: { tron@955: int dx; tron@955: int dy; tron@955: uint x; tron@955: uint y; tron@955: tron@955: dx = add & MapMaxX(); darkvater@957: if (dx >= (int)MapSizeX() / 2) dx -= MapSizeX(); tron@955: dy = (add - dx) / (int)MapSizeX(); tron@955: tron@955: x = TileX(tile) + dx; tron@955: y = TileY(tile) + dy; tron@955: tron@955: if (x >= MapSizeX() || y >= MapSizeY()) { tron@955: char buf[512]; tron@955: tron@955: sprintf(buf, "TILE_ADD(%s) when adding 0x%.4X and 0x%.4X failed", tron@955: exp, tile, add); tron@955: #if !defined(_MSC_VER) tron@955: fprintf(stderr, "%s:%d %s\n", file, line, buf); tron@955: #else tron@955: _assert(buf, (char*)file, line); tron@955: #endif tron@955: } tron@955: tron@955: assert(TILE_XY(x,y) == TILE_MASK(tile + add)); tron@955: tron@955: return TILE_XY(x,y); tron@955: } tron@955: #endif tron@955: tron@955: tron@909: const TileIndexDiffC _tileoffs_by_dir[] = { tron@909: {-1, 0}, tron@909: { 0, 1}, tron@909: { 1, 0}, tron@909: { 0, -1} tron@900: };