Changeset - r28740:e9f10824f0dd
[Not reviewed]
master
0 1 0
Peter Nelson - 10 months ago 2024-02-08 18:32:44
peter1138@openttd.org
Change: Avoid adjacent fence fields.

This restores pre-r23168 behaviour of only a single fence between adjacent fields.
1 file changed with 5 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -1010,23 +1010,28 @@ static bool IsSuitableForFarmField(TileI
 
 * @param type type of fence to set
 
 * @param side the side of the tile to attempt placement
 
 */
 
static void SetupFarmFieldFence(TileIndex tile, int size, byte type, DiagDirection side)
 
{
 
	TileIndexDiff diff = (DiagDirToAxis(side) == AXIS_Y ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
 
	TileIndexDiff neighbour_diff = TileOffsByDiagDir(side);
 

	
 
	do {
 
		tile = Map::WrapToMap(tile);
 

	
 
		if (IsTileType(tile, MP_CLEAR) && IsClearGround(tile, CLEAR_FIELDS)) {
 
			TileIndex neighbour = tile + neighbour_diff;
 
			if (!IsTileType(neighbour, MP_CLEAR) || !IsClearGround(neighbour, CLEAR_FIELDS) || GetFence(neighbour, ReverseDiagDir(side)) == 0) {
 
				/* Add fence as long as neighbouring tile does not already have a fence in the same position. */
 
			byte or_ = type;
 

	
 
			if (or_ == 1 && Chance16(1, 7)) or_ = 2;
 

	
 
			SetFence(tile, side, or_);
 
		}
 
		}
 

	
 
		tile += diff;
 
	} while (--size);
 
}
 

	
 
static void PlantFarmField(TileIndex tile, IndustryID industry)
0 comments (0 inline, 0 general)