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 10 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -1013,16 +1013,21 @@ static bool IsSuitableForFarmField(TileI
 
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)) {
 
			byte or_ = type;
 

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

	
 
			SetFence(tile, side, or_);
 
			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;
0 comments (0 inline, 0 general)