Changeset - r856:e23ff9905ff0
[Not reviewed]
master
0 15 0
tron - 20 years ago 2005-01-03 12:56:22
tron@openttd.org
(svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
While here replace one erroneous TILE_MAX_X with MapMaxY()
15 files changed with 42 insertions and 46 deletions:
0 comments (0 inline, 0 general)
ai.h
Show inline comments
 
@@ -227,7 +227,7 @@ enum {
 

	
 
#define AI_NO_CARGO 0xFF // Means that there is no cargo defined yet (used for industry)
 
#define AI_NEED_CARGO 0xFE // Used when the AI needs to find out a cargo for the route
 
#define AI_STATION_RANGE TILE_XY(TILE_X_MAX, TILE_Y_MAX)
 
#define AI_STATION_RANGE TILE_XY(MapMaxX(), MapMaxY())
 

	
 
#define AI_PATHFINDER_NO_DIRECTION (byte)-1
 

	
ai_pathfinder.c
Show inline comments
 
@@ -175,8 +175,8 @@ static void AyStar_AiPathFinder_GetNeigh
 

	
 
  	// Go through all surrounding tiles and check if they are within the limits
 
   	for (i=0;i<4;i++) {
 
   		if (GET_TILE_X(_tiles_around[i] + current->path.node.tile) > 1 && GET_TILE_X(_tiles_around[i] + current->path.node.tile) < TILE_X_MAX - 1 &&
 
       		GET_TILE_Y(_tiles_around[i] + current->path.node.tile) > 1 && GET_TILE_Y(_tiles_around[i] + current->path.node.tile) < TILE_Y_MAX - 1) {
 
   		if (GET_TILE_X(_tiles_around[i] + current->path.node.tile) > 1 && GET_TILE_X(_tiles_around[i] + current->path.node.tile) < MapMaxX() - 1 &&
 
       		GET_TILE_Y(_tiles_around[i] + current->path.node.tile) > 1 && GET_TILE_Y(_tiles_around[i] + current->path.node.tile) < MapMaxY() - 1) {
 
       		// We also directly test if the current tile can connect to this tile..
 
       		//  We do this simply by just building the tile!
 

	
clear_cmd.c
Show inline comments
 
@@ -30,7 +30,7 @@ static int TerraformAllowTileProcess(Ter
 
	TileIndex *t;
 
	int count;
 

	
 
	if ((GET_TILE_X(tile) == TILE_X_MAX) || (GET_TILE_Y(tile) == TILE_Y_MAX))
 
	if (GET_TILE_X(tile) == MapMaxX() || GET_TILE_Y(tile) == MapMaxY())
 
		return -1;
 

	
 
	t = ts->tile_table;
industry_cmd.c
Show inline comments
 
@@ -1215,7 +1215,7 @@ static bool CheckSuitableIndustryPos(uin
 
	int x = GET_TILE_X(tile);
 
	int y = GET_TILE_Y(tile);
 

	
 
	if ( x < 2 || y < 2 || x > TILE_X_MAX - 3 || y > TILE_Y_MAX - 3) {
 
	if ( x < 2 || y < 2 || x > MapMaxX() - 3 || y > MapMaxY() - 3) {
 
		_error_message = STR_0239_SITE_UNSUITABLE;
 
		return false;
 
	}
landscape.c
Show inline comments
 
@@ -45,13 +45,13 @@ uint GetTileSlope(uint tile, int *h)
 
	uint a,b,c,d,min;
 
	int r;
 

	
 
	if (GET_TILE_X(tile) == TILE_X_MAX || GET_TILE_Y(tile) == TILE_Y_MAX) {
 
	if (GET_TILE_X(tile) == MapMaxX() || GET_TILE_Y(tile) == MapMaxY()) {
 
		if (h)
 
			*h = 0;
 
		return 0;
 
	}
 

	
 
	assert(tile < TILES_X * TILES_Y && GET_TILE_X(tile) != TILE_X_MAX && GET_TILE_Y(tile) != TILE_Y_MAX);
 
	assert(tile < TILES_X * TILES_Y && GET_TILE_X(tile) != MapMaxX() && GET_TILE_Y(tile) != MapMaxY());
 

	
 
	min = a = _map_type_and_height[tile] & 0xF;
 
	b = _map_type_and_height[tile+TILE_XY(1,0)] & 0xF;
 
@@ -82,8 +82,7 @@ int GetTileZ(uint tile)
 

	
 
void FindLandscapeHeightByTile(TileInfo *ti, uint tile)
 
{
 
	if (GET_TILE_X(tile) == TILE_X_MAX ||
 
			GET_TILE_Y(tile) == TILE_Y_MAX) {
 
	if (GET_TILE_X(tile) == MapMaxX() || GET_TILE_Y(tile) == MapMaxY()) {
 
		ti->tileh = 0;
 
		ti->type = MP_STRANGE;
 
		ti->tile = 0;
 
@@ -107,7 +106,7 @@ void FindLandscapeHeight(TileInfo *ti, u
 
	ti->x = x;
 
	ti->y = y;
 

	
 
	if (x >= TILE_X_MAX*16-1 || y >= TILE_Y_MAX*16-1) {
 
	if (x >= MapMaxX() * 16 - 1 || y >= MapMaxY() * 16 - 1) {
 
		ti->tileh = 0;
 
		ti->type = MP_STRANGE;
 
		ti->tile = 0;
 
@@ -512,9 +511,9 @@ void ConvertGroundTilesIntoWaterTiles()
 
			_map_owner[tile] = OWNER_WATER;
 
		}
 
		tile++;
 
		if (GET_TILE_X(tile) == TILE_X_MAX) {
 
			tile += TILE_XY(-TILE_X_MAX, 1);
 
			if (GET_TILE_Y(tile) == TILE_Y_MAX)
 
		if (GET_TILE_X(tile) == MapMaxX()) {
 
			tile += TILE_XY(-MapMaxX(), 1);
 
			if (GET_TILE_Y(tile) == MapMaxY())
 
				break;
 
		}
 
	}
 
@@ -534,8 +533,8 @@ static void GenerateTerrain(int type, in
 
	r = Random();
 
	p = GetSpritePtr((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + 4845);
 

	
 
	x = r & TILE_X_MAX;
 
	y = (r >> TILE_X_BITS) & TILE_Y_MAX;
 
	x = r & MapMaxX();
 
	y = (r >> TILE_X_BITS) & MapMaxY();
 

	
 

	
 
	if (x < 2 || y < 2)
 
@@ -567,10 +566,10 @@ static void GenerateTerrain(int type, in
 
		}
 
	}
 

	
 
	if (x + w >= TILE_X_MAX-1)
 
	if (x + w >= MapMaxX() - 1)
 
		return;
 

	
 
	if (y + h >= TILE_Y_MAX-1)
 
	if (y + h >= MapMaxY() - 1)
 
		return;
 

	
 
	tile = &_map_type_and_height[TILE_XY(x,y)];
 
@@ -753,7 +752,7 @@ uint TileAddWrap(TileIndex tile, int add
 
	y = GET_TILE_Y(tile) + addy;
 

	
 
	// Are we about to wrap?
 
	if (x > 0 && x < TILE_X_MAX && y > 0 && y < TILE_Y_MAX)
 
	if (x > 0 && x < MapMaxX() && y > 0 && y < MapMaxY())
 
		return tile + TILE_XY(addx, addy);
 

	
 
	return TILE_WRAPPED;
 
@@ -761,5 +760,5 @@ uint TileAddWrap(TileIndex tile, int add
 

	
 
bool IsValidTile(uint tile)
 
{
 
	return (tile < TILES_X * TILE_Y_MAX && GET_TILE_X(tile) != TILE_X_MAX);
 
	return (tile < TILES_X * MapMaxY() && GET_TILE_X(tile) != MapMaxX());
 
}
map.h
Show inline comments
 
@@ -7,9 +7,6 @@
 
#define TILES_X (1 << TILE_X_BITS)
 
#define TILES_Y (1 << TILE_Y_BITS)
 

	
 
#define TILE_X_MAX (TILES_X - 1)
 
#define TILE_Y_MAX (TILES_Y - 1)
 

	
 
extern byte   _map_type_and_height[];
 
extern byte   _map5[];
 
extern byte   _map3_lo[];
misc.c
Show inline comments
 
@@ -565,8 +565,8 @@ uint GetTileDistAdv(TileIndex xy1, TileI
 

	
 
bool CheckDistanceFromEdge(TileIndex tile, uint distance)
 
{
 
	return IS_INT_INSIDE(GET_TILE_X(tile), distance, TILE_X_MAX + 1 - distance) &&
 
			IS_INT_INSIDE(GET_TILE_Y(tile), distance, TILE_Y_MAX + 1 - distance);
 
	return IS_INT_INSIDE(GET_TILE_X(tile), distance, MapSizeX() - distance) &&
 
			IS_INT_INSIDE(GET_TILE_Y(tile), distance, MapSizeY() - distance);
 
}
 

	
 
void OnNewDay_Train(Vehicle *v);
smallmap_gui.c
Show inline comments
 
@@ -356,7 +356,7 @@ static inline uint32 GetSmallMapCountour
 
static void DrawSmallMapContours(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask)
 
{
 
	do {
 
		if (xc < TILE_X_MAX && yc < TILE_Y_MAX)
 
		if (xc < MapMaxX() && yc < MapMaxY())
 
		    if (dst > _screen.dst_ptr && dst < (_screen.dst_ptr + _screen.width * _screen.height - _screen.width) )
 
		        WRITE_PIXELS_OR( dst, GetSmallMapCountoursPixels(TILE_XY(xc,yc)) & mask );
 
	} while (xc++,yc++,dst+=pitch,--reps != 0);
 
@@ -386,7 +386,7 @@ static inline uint32 GetSmallMapVehicles
 
static void DrawSmallMapVehicles(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask)
 
{
 
	do {
 
		if (xc < TILE_X_MAX && yc < TILE_Y_MAX)
 
		if (xc < MapMaxX() && yc < MapMaxY())
 
			WRITE_PIXELS_OR( dst, GetSmallMapVehiclesPixels(TILE_XY(xc,yc)) & mask );
 
	} while (xc++,yc++,dst+=pitch,--reps != 0);
 
}
 
@@ -443,7 +443,7 @@ static inline uint32 GetSmallMapIndustri
 
static void DrawSmallMapIndustries(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask)
 
{
 
	do {
 
		if (xc < TILE_X_MAX && yc < TILE_Y_MAX)
 
		if (xc < MapMaxX() && yc < MapMaxY())
 
			WRITE_PIXELS_OR(dst, GetSmallMapIndustriesPixels(TILE_XY(xc,yc)) & mask);
 
	} while (xc++,yc++,dst+=pitch,--reps != 0);
 
}
 
@@ -484,7 +484,7 @@ static inline uint32 GetSmallMapRoutesPi
 
static void DrawSmallMapRoutes(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask)
 
{
 
	do {
 
		if (xc < TILE_X_MAX && yc < TILE_Y_MAX)
 
		if (xc < MapMaxX() && yc < MapMaxY())
 
			WRITE_PIXELS_OR(dst, GetSmallMapRoutesPixels(TILE_XY(xc,yc)) & mask);
 
	} while (xc++,yc++,dst+=pitch,--reps != 0);
 
}
 
@@ -542,7 +542,7 @@ static inline uint32 GetSmallMapVegetati
 
static void DrawSmallMapVegetation(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask)
 
{
 
	do {
 
		if (xc < TILE_X_MAX && yc < TILE_Y_MAX)
 
		if (xc < MapMaxX() && yc < MapMaxY())
 
			WRITE_PIXELS_OR(dst, GetSmallMapVegetationPixels(TILE_XY(xc,yc)) & mask);
 
	} while (xc++,yc++,dst+=pitch,--reps != 0);
 
}
 
@@ -570,7 +570,7 @@ static inline uint32 GetSmallMapOwnerPix
 
static void DrawSmallMapOwners(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask)
 
{
 
	do {
 
		if (xc < TILE_X_MAX && yc < TILE_Y_MAX)
 
		if (xc < MapMaxX() && yc < MapMaxY())
 
			WRITE_PIXELS_OR(dst, GetSmallMapOwnerPixels(TILE_XY(xc,yc)) & mask);
 
	} while (xc++,yc++,dst+=pitch,--reps != 0);
 
}
station_cmd.c
Show inline comments
 
@@ -414,10 +414,10 @@ void GetProductionAroundTiles(uint *prod
 

	
 
	// expand the region by 4 tiles on each side
 
	// while making sure that we remain inside the board.
 
	x2 = min(x + w + rad, TILE_X_MAX+1);
 
	x2 = min(x + w + rad, MapSizeX());
 
	x1 = max(x-rad, 0);
 

	
 
	y2 = min(y + h + rad, TILE_Y_MAX+1);
 
	y2 = min(y + h + rad, MapSizeY());
 
	y1 = max(y-rad, 0);
 

	
 
	assert(x1 < x2);
 
@@ -462,8 +462,8 @@ void GetAcceptanceAroundTiles(uint *acce
 

	
 
	// expand the region by 4 tiles on each side
 
	// while making sure that we remain inside the board.
 
	x2 = min(x + w + rad, TILE_X_MAX+1);
 
	y2 = min(y + h + rad, TILE_Y_MAX+1);
 
	x2 = min(x + w + rad, MapSizeX());
 
	y2 = min(y + h + rad, MapSizeY());
 
	x1 = max(x-rad, 0);
 
	y1 = max(y-rad, 0);
 

	
ttd.c
Show inline comments
 
@@ -1082,7 +1082,7 @@ void GameLoop()
 
			ShowScreenshotResult(MakeScreenshot());
 
			break;
 
		case 2: // make large screenshot
 
			ShowScreenshotResult(MakeWorldScreenshot(-(TILE_X_MAX)*32, 0, TILE_X_MAX*32 + (TILE_X_MAX)*32, TILES_Y * 32, 0));
 
			ShowScreenshotResult(MakeWorldScreenshot(-MapMaxX() * 32, 0, MapMaxX() * 64, TILES_Y * 32, 0));
 
			break;
 
		}
 
	}
tunnelbridge_cmd.c
Show inline comments
 
@@ -431,7 +431,7 @@ static int32 DoBuildTunnel(int x, int y,
 
	TileInfo ti;
 
	uint z;
 

	
 
	if ( (uint) x > TILE_X_MAX * 16 - 1 ||  (uint) y > TILE_X_MAX * 16 - 1)
 
	if ((uint)x > MapMaxX() * 16 - 1 || (uint)y > MapMaxY() * 16 - 1)
 
		return CMD_ERROR;
 

	
 
	/* check if valid, and make sure that (x,y) is smaller than (x2,y2) */
unmovable_cmd.c
Show inline comments
 
@@ -285,12 +285,12 @@ void GenerateUnmovables()
 
restart:
 
		r = Random();
 
		dir = r >> 30;
 
		r = r%((dir==0 || dir== 2)?TILE_Y_MAX:TILE_X_MAX);
 
		r %= (dir == 0 || dir == 2) ? MapMaxY() : MapMaxX();
 
		tile =
 
          (dir==0)?TILE_XY(0,r):0 +             // left
 
          (dir==1)?TILE_XY(r,0):0 +             // top
 
          (dir==2)?TILE_XY(TILE_X_MAX,r):0 +    // right
 
          (dir==3)?TILE_XY(r,TILE_Y_MAX):0;     // bottom
 
			(dir == 2) ? TILE_XY(MapMaxX(), r) : 0 + // right
 
			(dir == 3) ? TILE_XY(r, MapMaxY()) : 0;  // bottom
 
		j = 20;
 
		do {
 
			if (--j == 0)
viewport.c
Show inline comments
 
@@ -295,7 +295,7 @@ Point TranslateXYToTileCoord(ViewPort *v
 
	pt.x = a+z;
 
	pt.y = b+z;
 

	
 
	if ((uint)pt.x >= TILE_X_MAX*16 || (uint)pt.y >= TILE_Y_MAX*16) {
 
	if ((uint)pt.x >= MapMaxX() * 16 || (uint)pt.y >= MapMaxY() * 16) {
 
		pt.x = pt.y = -1;
 
	}
 

	
 
@@ -1289,8 +1289,8 @@ void UpdateViewportPosition(Window *w)
 
		vx = -x + y * 2;
 
		vy =  x + y * 2;
 
		// clamp to size of map
 
		vx = clamp(vx, 0 * 4, TILE_X_MAX * 16 * 4);
 
		vy = clamp(vy, 0 * 4, TILE_Y_MAX * 16 * 4);
 
		vx = clamp(vx, 0 * 4, MapMaxX() * 16 * 4);
 
		vy = clamp(vy, 0 * 4, MapMaxY() * 16 * 4);
 
		// Convert map coordinates to viewport coordinates
 
		x = (-vx + vy) / 2;
 
		y = ( vx + vy) / 4;
water_cmd.c
Show inline comments
 
@@ -265,8 +265,8 @@ static int32 ClearTile_Water(uint tile, 
 
			return CMD_ERROR;
 

	
 
		// Make sure it's not an edge tile.
 
		if (!(IS_INT_INSIDE(GET_TILE_X(tile),1,TILE_X_MAX-1) &&
 
				IS_INT_INSIDE(GET_TILE_Y(tile),1,TILE_Y_MAX-1)))
 
		if (!(IS_INT_INSIDE(GET_TILE_X(tile), 1, MapMaxX() - 1) &&
 
				IS_INT_INSIDE(GET_TILE_Y(tile), 1, MapMaxY() - 1)))
 
			return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
 

	
 
		if (m5 == 0) {
window.c
Show inline comments
 
@@ -1042,9 +1042,9 @@ stop_capt:;
 
		hvx = hx * -4 + hy * 8;
 
		hvy = hx *  4 + hy * 8;
 
		if (x < -hvx) { x = -hvx; sub = 0; }
 
		if (x > TILE_X_MAX * 16 - hvx)  { x = TILE_X_MAX * 16 - hvx; sub = 0; }
 
		if (x > MapMaxX() * 16 - hvx) { x = MapMaxX() * 16 - hvx; sub = 0; }
 
		if (y < -hvy) { y = -hvy; sub = 0; }
 
		if (y > TILE_Y_MAX * 16 - hvy)  { y = TILE_Y_MAX * 16 - hvy; sub = 0; }
 
		if (y > MapMaxY() * 16 - hvy) { y = MapMaxY() * 16 - hvy; sub = 0; }
 

	
 
		WP(w,smallmap_d).scroll_x = x;
 
		WP(w,smallmap_d).scroll_y = y;
0 comments (0 inline, 0 general)