# clear_map.h File Reference

Map accessors for 'clear' tiles. More...

`#include "bridge_map.h"`
`#include "industry_type.h"`

Go to the source code of this file.

## Enumerations
enum | ClearGround { CLEAR_GRASS = 0, CLEAR_ROUGH = 1, CLEAR_ROCKS = 2, CLEAR_FIELDS = 3, CLEAR_SNOW = 4, CLEAR_DESERT = 5 }
| Ground types. More...
## Functions
static ClearGround | GetClearGround (TileIndex t)
| Get the type of clear tile.
static bool | IsClearGround (TileIndex t, ClearGround ct)
| Set the type of clear tile.
static uint | GetClearDensity (TileIndex t)
| Get the density of a non-field clear tile.
static void | AddClearDensity (TileIndex t, int d)
| Increment the density of a non-field clear tile.
static uint | GetClearCounter (TileIndex t)
| Get the counter used to advance to the next clear density/field type.
static void | AddClearCounter (TileIndex t, int c)
| Increments the counter used to advance to the next clear density/field type.
static void | SetClearCounter (TileIndex t, uint c)
| Sets the counter used to advance to the next clear density/field type.
static void | SetClearGroundDensity (TileIndex t, ClearGround type, uint density)
| Sets ground type and density in one go, also sets the counter to 0.
static uint | GetFieldType (TileIndex t)
| Get the field type (production stage) of the field.
static void | SetFieldType (TileIndex t, uint f)
| Set the field type (production stage) of the field.
static IndustryID | GetIndustryIndexOfField (TileIndex t)
| Get the industry (farm) that made the field.
static void | SetIndustryIndexOfField (TileIndex t, IndustryID i)
| Set the industry (farm) that made the field.
static uint | GetFenceSE (TileIndex t)
| Is there a fence at the south eastern border?
static void | SetFenceSE (TileIndex t, uint h)
| Sets the type of fence (and whether there is one) for the south eastern border.
static uint | GetFenceSW (TileIndex t)
| Is there a fence at the south western border?
static void | SetFenceSW (TileIndex t, uint h)
| Sets the type of fence (and whether there is one) for the south western border.
static void | MakeClear (TileIndex t, ClearGround g, uint density)
| Make a clear tile.
static void | MakeField (TileIndex t, uint field_type, IndustryID industry)
| Make a (farm) field tile.

## Detailed Description

Map accessors for 'clear' tiles.

Definition in file clear_map.h.

## Enumeration Type Documentation

enum ClearGround

Ground types.

Valid densities in comments after the enum.

Enumerator:

  CLEAR_GRASS | 0-3
  CLEAR_ROUGH | 3
  CLEAR_ROCKS | 3
  CLEAR_FIELDS | 3
  CLEAR_SNOW | 0-3
  CLEAR_DESERT | 1,3

Definition at line 14 of file clear_map.h.

## Function Documentation

static void AddClearCounter | ( | TileIndex | t,
|  | int | c |
| ) |  |  | `[inline, static]`

Increments the counter used to advance to the next clear density/field type.

Parameters:

  | t | the tile to increment the counter of
  | c | the amount to increment the counter with

Precondition:
  IsTileType(t, MP_CLEAR)

Definition at line 91 of file clear_map.h.

References _m, IsTileType(), Tile::m5, and MP_CLEAR.

static void AddClearDensity | ( | TileIndex | t,
|  | int | d |
| ) |  |  | `[inline, static]`

Increment the density of a non-field clear tile.

Parameters:

  | t | the tile to increment the density of
  | d | the amount to increment the density with

Precondition:
  IsTileType(t, MP_CLEAR)

Definition at line 66 of file clear_map.h.

References _m, IsTileType(), Tile::m5, and MP_CLEAR.

static uint GetClearCounter | ( | TileIndex | t | ) | `[inline, static]`

Get the counter used to advance to the next clear density/field type.

Parameters:

  | t | the tile to get the counter of

Precondition:
  IsTileType(t, MP_CLEAR)

Returns:
  the value of the counter

Definition at line 79 of file clear_map.h.

References _m, GB(), IsTileType(), and MP_CLEAR.

static uint GetClearDensity | ( | TileIndex | t | ) | `[inline, static]`

Get the density of a non-field clear tile.

Parameters:

  | t | the tile to get the density of

Precondition:
  IsTileType(t, MP_CLEAR)

Returns:
  the density

Definition at line 54 of file clear_map.h.

References _m, GB(), IsTileType(), and MP_CLEAR.

Referenced by PlantTreesOnTile().

static ClearGround GetClearGround | ( | TileIndex | t | ) | `[inline, static]`

Get the type of clear tile.

Parameters:

  | t | the tile to get the clear ground type of

Precondition:
  IsTileType(t, MP_CLEAR)

Returns:
  the ground type

Definition at line 30 of file clear_map.h.

References _m, GB(), IsTileType(), and MP_CLEAR.

Referenced by CmdPlantTree(), GetFieldType(), GetIndustryIndexOfField(), IsClearGround(), PlantTreesOnTile(), SetFieldType(), and SetIndustryIndexOfField().

static uint GetFenceSE | ( | TileIndex | t | ) | `[inline, static]`

Is there a fence at the south eastern border?

Parameters:

  | t | the tile to check for fences

Precondition:
  IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)

Returns:
  0 if there is no fence, otherwise the fence type

Definition at line 179 of file clear_map.h.

References _m, GB(), IsTileType(), MP_CLEAR, and MP_TREES.

static uint GetFenceSW | ( | TileIndex | t | ) | `[inline, static]`

Is there a fence at the south western border?

Parameters:

  | t | the tile to check for fences

Precondition:
  IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)

Returns:
  0 if there is no fence, otherwise the fence type

Definition at line 204 of file clear_map.h.

References _m, GB(), IsTileType(), MP_CLEAR, and MP_TREES.

static uint GetFieldType | ( | TileIndex | t | ) | `[inline, static]`

Get the field type (production stage) of the field.

Parameters:

  | t | the field to get the type of

Precondition:
  GetClearGround(t) == CLEAR_FIELDS

Returns:
  the field type

Definition at line 130 of file clear_map.h.

References _m, CLEAR_FIELDS, GB(), and GetClearGround().

static IndustryID GetIndustryIndexOfField | ( | TileIndex | t | ) | `[inline, static]`

Get the industry (farm) that made the field.

Parameters:

  | t | the field to get creating industry of

Precondition:
  GetClearGround(t) == CLEAR_FIELDS

Returns:
  the industry that made the field

Definition at line 154 of file clear_map.h.

References _m, CLEAR_FIELDS, GetClearGround(), and Tile::m2.

static bool IsClearGround | ( | TileIndex | t,
|  | ClearGround | ct |
| ) |  |  | `[inline, static]`

Set the type of clear tile.

Parameters:

  | t | the tile to set the clear ground type of
  | ct | the ground type

Precondition:
  IsTileType(t, MP_CLEAR)

Definition at line 42 of file clear_map.h.

References GetClearGround().

Referenced by CanPlantTreesOnTile().

static void MakeClear | ( | TileIndex | t,
|  | ClearGround | g,
|  | uint | density |
| ) |  |  | `[inline, static]`

Make a clear tile.

Parameters:

  | t | the tile to make a clear tile
  | g | the type of ground
  | density | the density of the grass/snow/desert etc

Definition at line 230 of file clear_map.h.

References _m, Tile::m2, Tile::m3, Tile::m4, MayHaveBridgeAbove(), MP_CLEAR, OWNER_NONE, SB(), SetClearGroundDensity(), SetTileOwner(), and SetTileType().

Referenced by DoDryUp(), GenerateRockyArea(), GrayscaleToMapHeights(), and TgenSetTileHeight().

static void MakeField | ( | TileIndex | t,
|  | uint | field_type,
|  | IndustryID | industry |
| ) |  |  | `[inline, static]`

Make a (farm) field tile.

Parameters:

  | t | the tile to make a farm field
  | field_type | the 'growth' level of the field
  | industry | the industry this tile belongs to

Definition at line 252 of file clear_map.h.

References _m, CLEAR_FIELDS, Tile::m2, Tile::m3, Tile::m4, MP_CLEAR, OWNER_NONE, SetClearGroundDensity(), SetTileOwner(), and SetTileType().

static void SetClearCounter | ( | TileIndex | t,
|  | uint | c |
| ) |  |  | `[inline, static]`

Sets the counter used to advance to the next clear density/field type.

Parameters:

  | t | the tile to set the counter of
  | c | the amount to set the counter to

Precondition:
  IsTileType(t, MP_CLEAR)

Definition at line 103 of file clear_map.h.

References _m, IsTileType(), MP_CLEAR, and SB().

static void SetClearGroundDensity | ( | TileIndex | t,
|  | ClearGround | type,
|  | uint | density |
| ) |  |  | `[inline, static]`

Sets ground type and density in one go, also sets the counter to 0.

Parameters:

  | t | the tile to set the ground type and density for
  | type | the new ground type of the tile
  | density | the density of the ground tile

Precondition:
  IsTileType(t, MP_CLEAR)

Definition at line 117 of file clear_map.h.

References _m, IsTileType(), Tile::m5, and MP_CLEAR.

Referenced by MakeClear(), and MakeField().

static void SetFenceSE | ( | TileIndex | t,
|  | uint | h |
| ) |  |  | `[inline, static]`

Sets the type of fence (and whether there is one) for the south eastern border.

Parameters:

  | t | the tile to check for fences
  | h | 0 if there is no fence, otherwise the fence type

Precondition:
  IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)

Definition at line 192 of file clear_map.h.

References _m, IsTileType(), MP_CLEAR, MP_TREES, and SB().

static void SetFenceSW | ( | TileIndex | t,
|  | uint | h |
| ) |  |  | `[inline, static]`

Sets the type of fence (and whether there is one) for the south western border.

Parameters:

  | t | the tile to check for fences
  | h | 0 if there is no fence, otherwise the fence type

Precondition:
  IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)

Definition at line 217 of file clear_map.h.

References _m, IsTileType(), MP_CLEAR, MP_TREES, and SB().

static void SetFieldType | ( | TileIndex | t,
|  | uint | f |
| ) |  |  | `[inline, static]`

Set the field type (production stage) of the field.

Parameters:

  | t | the field to get the type of
  | f | the field type

Precondition:
  GetClearGround(t) == CLEAR_FIELDS

Definition at line 142 of file clear_map.h.

References _m, CLEAR_FIELDS, GetClearGround(), and SB().

static void SetIndustryIndexOfField | ( | TileIndex | t,
|  | IndustryID | i |
| ) |  |  | `[inline, static]`

Set the industry (farm) that made the field.

Parameters:

  | t | the field to get creating industry of
  | i | the industry that made the field

Precondition:
  GetClearGround(t) == CLEAR_FIELDS

Definition at line 166 of file clear_map.h.

References _m, CLEAR_FIELDS, GetClearGround(), and Tile::m2.