(svn r3791) Replace home grown direction handling for placing lighthouses by standard DiagDir
This commit is contained in:
		@@ -308,12 +308,6 @@ static void ClickTile_Unmovable(TileIndex tile)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const TileIndexDiffC _tile_add[] = {
 | 
					 | 
				
			||||||
	{ 1,  0},
 | 
					 | 
				
			||||||
	{ 0,  1},
 | 
					 | 
				
			||||||
	{-1,  0},
 | 
					 | 
				
			||||||
	{ 0, -1}
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* checks, if a radio tower is within a 9x9 tile square around tile */
 | 
					/* checks, if a radio tower is within a 9x9 tile square around tile */
 | 
				
			||||||
static bool checkRadioTowerNearby(TileIndex tile)
 | 
					static bool checkRadioTowerNearby(TileIndex tile)
 | 
				
			||||||
@@ -332,9 +326,9 @@ void GenerateUnmovables(void)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	int i,j;
 | 
						int i,j;
 | 
				
			||||||
	TileIndex tile;
 | 
						TileIndex tile;
 | 
				
			||||||
	uint32 r;
 | 
					 | 
				
			||||||
	int dir;
 | 
					 | 
				
			||||||
	uint h;
 | 
						uint h;
 | 
				
			||||||
 | 
						uint maxx;
 | 
				
			||||||
 | 
						uint maxy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (_opt.landscape == LT_CANDY) return;
 | 
						if (_opt.landscape == LT_CANDY) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -356,20 +350,26 @@ void GenerateUnmovables(void)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	/* add lighthouses */
 | 
						/* add lighthouses */
 | 
				
			||||||
	i = ScaleByMapSize1D((Random() & 3) + 7);
 | 
						i = ScaleByMapSize1D((Random() & 3) + 7);
 | 
				
			||||||
 | 
						maxx = MapMaxX();
 | 
				
			||||||
 | 
						maxy = MapMaxY();
 | 
				
			||||||
	do {
 | 
						do {
 | 
				
			||||||
 | 
							uint32 r;
 | 
				
			||||||
 | 
							DiagDirection dir;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
restart:
 | 
					restart:
 | 
				
			||||||
		r = Random();
 | 
							r = Random();
 | 
				
			||||||
		dir = r >> 30;
 | 
							dir = GB(r, 30, 2);
 | 
				
			||||||
		r %= (dir == 0 || dir == 2) ? MapMaxY() : MapMaxX();
 | 
							switch (dir) {
 | 
				
			||||||
		tile =
 | 
								default:
 | 
				
			||||||
			(dir == 0) ? TileXY(0, r)         : 0 + // left
 | 
								case DIAGDIR_NE: tile = TileXY(maxx,     r % maxy); break;
 | 
				
			||||||
			(dir == 1) ? TileXY(r, 0)         : 0 + // top
 | 
								case DIAGDIR_SE: tile = TileXY(r % maxx, 0);        break;
 | 
				
			||||||
			(dir == 2) ? TileXY(MapMaxX(), r) : 0 + // right
 | 
								case DIAGDIR_SW: tile = TileXY(0,        r % maxy); break;
 | 
				
			||||||
			(dir == 3) ? TileXY(r, MapMaxY()) : 0;  // bottom
 | 
								case DIAGDIR_NW: tile = TileXY(r % maxx, maxy);     break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		j = 20;
 | 
							j = 20;
 | 
				
			||||||
		do {
 | 
							do {
 | 
				
			||||||
			if (--j == 0) goto restart;
 | 
								if (--j == 0) goto restart;
 | 
				
			||||||
			tile = TILE_MASK(tile + ToTileIndexDiff(_tile_add[dir]));
 | 
								tile = TILE_MASK(tile + TileOffsByDir(dir));
 | 
				
			||||||
		} while (!(IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= 16));
 | 
							} while (!(IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= 16));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		assert(tile == TILE_MASK(tile));
 | 
							assert(tile == TILE_MASK(tile));
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user