OpenTTD Source: src/clear_map.h File Reference

OpenTTD Source 13.1

Enumerations | Functions
clear_map.h File Reference
`#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 bool | IsSnowTile (TileIndex t)
| Test if a tile is covered with snow. More...
static ClearGround | GetRawClearGround (TileIndex t)
| Get the type of clear tile but never return CLEAR_SNOW. More...
static ClearGround | GetClearGround (TileIndex t)
| Get the type of clear tile. More...
static bool | IsClearGround (TileIndex t, ClearGround ct)
| Set the type of clear tile. More...
static uint | GetClearDensity (TileIndex t)
| Get the density of a non-field clear tile. More...
static void | AddClearDensity (TileIndex t, int d)
| Increment the density of a non-field clear tile. More...
static void | SetClearDensity (TileIndex t, uint d)
| Set the density of a non-field clear tile. More...
static uint | GetClearCounter (TileIndex t)
| Get the counter used to advance to the next clear density/field type. More...
static void | AddClearCounter (TileIndex t, int c)
| Increments the counter used to advance to the next clear density/field type. More...
static void | SetClearCounter (TileIndex t, uint c)
| Sets the counter used to advance to the next clear density/field type. More...
static void | SetClearGroundDensity (TileIndex t, ClearGround type, uint density)
| Sets ground type and density in one go, also sets the counter to 0. More...
static uint | GetFieldType (TileIndex t)
| Get the field type (production stage) of the field. More...
static void | SetFieldType (TileIndex t, uint f)
| Set the field type (production stage) of the field. More...
static IndustryID | GetIndustryIndexOfField (TileIndex t)
| Get the industry (farm) that made the field. More...
static void | SetIndustryIndexOfField (TileIndex t, IndustryID i)
| Set the industry (farm) that made the field. More...
static uint | GetFence (TileIndex t, DiagDirection side)
| Is there a fence at the given border? More...
static void | SetFence (TileIndex t, DiagDirection side, uint h)
| Sets the type of fence (and whether there is one) for the given border. More...
static void | MakeClear (TileIndex t, ClearGround g, uint density)
| Make a clear tile. More...
static void | MakeField (TileIndex t, uint field_type, IndustryID industry)
| Make a (farm) field tile. More...
static void | MakeSnow (TileIndex t, uint density=0)
| Make a snow tile. More...
static void | ClearSnow (TileIndex t)
| Clear the snow from a tile and return it to its previous type. More...

## Detailed Description

Map accessors for 'clear' tiles

Definition in file clear_map.h.

## Enumeration Type Documentation

## ◆ ClearGround

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 19 of file clear_map.h.

## Function Documentation

## ◆ AddClearCounter()

static void AddClearCounter | ( | TileIndex | t,
|  | int | c
| ) |  |
| inlinestatic

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 132 of file clear_map.h.

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

## ◆ AddClearDensity()

static void AddClearDensity | ( | TileIndex | t,
|  | int | d
| ) |  |
| inlinestatic

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 95 of file clear_map.h.

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

Referenced by TileLoopClearAlps().

## ◆ ClearSnow()

static void ClearSnow | ( | TileIndex | t | ) |
| inlinestatic

Clear the snow from a tile and return it to its previous type.

Parameters

  t | the tile to clear of snow

Precondition
  GetClearGround(t) == CLEAR_SNOW

Definition at line 316 of file clear_map.h.

References _m, CLEAR_SNOW, ClrBit(), GetClearGround(), and SetClearDensity().

Referenced by TileLoopClearAlps().

## ◆ GetClearCounter()

static uint GetClearCounter | ( | TileIndex | t | ) |
| inlinestatic

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 120 of file clear_map.h.

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

## ◆ GetClearDensity()

static uint GetClearDensity | ( | TileIndex | t | ) |
| inlinestatic

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 83 of file clear_map.h.

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

Referenced by GetSmallMapVegetationPixels(), PlantTreesOnTile(), and TileLoopClearAlps().

## ◆ GetClearGround()

static ClearGround GetClearGround | ( | TileIndex | t | ) |
| inlinestatic

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 59 of file clear_map.h.

References CLEAR_SNOW, GetRawClearGround(), and IsSnowTile().

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

## ◆ GetFence()

static uint GetFence | ( | TileIndex | t,
|  | DiagDirection | side
| ) |  |
| inlinestatic

Is there a fence at the given border?

Parameters

  t | the tile to check for fences
  side | the border to check

Precondition
  IsClearGround(t, CLEAR_FIELDS)

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

Definition at line 221 of file clear_map.h.

References CLEAR_FIELDS, and IsClearGround().

## ◆ GetFieldType()

static uint GetFieldType | ( | TileIndex | t | ) |
| inlinestatic

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 171 of file clear_map.h.

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

## ◆ GetIndustryIndexOfField()

static IndustryID GetIndustryIndexOfField | ( | TileIndex | t | ) |
| inlinestatic

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 195 of file clear_map.h.

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

## ◆ GetRawClearGround()

static ClearGround GetRawClearGround | ( | TileIndex | t | ) |
| inlinestatic

Get the type of clear tile but never return CLEAR_SNOW.

Parameters

  t | the tile to get the clear ground type of

Precondition
  IsTileType(t, MP_CLEAR)

Returns
  the ground type

Definition at line 47 of file clear_map.h.

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

Referenced by CanPlantTreesOnTile(), GetClearGround(), MakeSnow(), and PlantTreesOnTile().

## ◆ IsClearGround()

static bool IsClearGround | ( | TileIndex | t,
|  | ClearGround | ct
| ) |  |
| inlinestatic

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 71 of file clear_map.h.

References GetClearGround().

Referenced by CanPlantTreesOnTile(), GetFence(), GetSmallMapVegetationPixels(), IsSuitableForFarmField(), SetFence(), and SetupFarmFieldFence().

## ◆ IsSnowTile()

static bool IsSnowTile | ( | TileIndex | t | ) |
| inlinestatic

Test if a tile is covered with snow.

Parameters

  t | the tile to check

Precondition
  IsTileType(t, MP_CLEAR)

Returns
  whether the tile is covered with snow.

Definition at line 35 of file clear_map.h.

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

Referenced by GetClearGround(), and TileLoopClearAlps().

## ◆ MakeClear()

static void MakeClear | ( | TileIndex | t,
|  | ClearGround | g,
|  | uint | density
| ) |  |
| inlinestatic

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 259 of file clear_map.h.

References _m, _me, Tile::m1, Tile::m2, Tile::m3, Tile::m4, TileExtended::m6, TileExtended::m7, TileExtended::m8, MP_CLEAR, OWNER_NONE, SetClearGroundDensity(), SetTileOwner(), and SetTileType().

Referenced by TgenSetTileHeight().

## ◆ MakeField()

static void MakeField | ( | TileIndex | t,
|  | uint | field_type,
|  | IndustryID | industry
| ) |  |
| inlinestatic

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 280 of file clear_map.h.

References _m, _me, CLEAR_FIELDS, Tile::m1, Tile::m2, Tile::m3, Tile::m4, TileExtended::m7, TileExtended::m8, MP_CLEAR, OWNER_NONE, SB(), SetClearGroundDensity(), SetTileOwner(), and SetTileType().

## ◆ MakeSnow()

static void MakeSnow | ( | TileIndex | t,
|  | uint | density = `0`
| ) |  |
| inlinestatic

Make a snow tile.

Parameters

  t | the tile to make snowy
  density | The density of snowiness.

Precondition
  GetClearGround(t) != CLEAR_SNOW

Definition at line 300 of file clear_map.h.

References _m, CLEAR_FIELDS, CLEAR_GRASS, CLEAR_SNOW, GetClearGround(), GetRawClearGround(), SetBit(), SetClearDensity(), and SetClearGroundDensity().

Referenced by TileLoopClearAlps().

## ◆ SetClearCounter()

static void SetClearCounter | ( | TileIndex | t,
|  | uint | c
| ) |  |
| inlinestatic

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 144 of file clear_map.h.

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

## ◆ SetClearDensity()

static void SetClearDensity | ( | TileIndex | t,
|  | uint | d
| ) |  |
| inlinestatic

Set the density of a non-field clear tile.

Parameters

  t | the tile to set the density of
  d | the new density

Precondition
  IsTileType(t, MP_CLEAR)

Definition at line 107 of file clear_map.h.

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

Referenced by ClearSnow(), and MakeSnow().

## ◆ SetClearGroundDensity()

static void SetClearGroundDensity | ( | TileIndex | t,
|  | ClearGround | type,
|  | uint | density
| ) |  |
| inlinestatic

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 158 of file clear_map.h.

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

Referenced by MakeClear(), MakeField(), and MakeSnow().

## ◆ SetFence()

static void SetFence | ( | TileIndex | t,
|  | DiagDirection | side,
|  | uint | h
| ) |  |
| inlinestatic

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

Parameters

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

Precondition
  IsClearGround(t, CLEAR_FIELDS)

Definition at line 240 of file clear_map.h.

References CLEAR_FIELDS, and IsClearGround().

Referenced by SetupFarmFieldFence().

## ◆ SetFieldType()

static void SetFieldType | ( | TileIndex | t,
|  | uint | f
| ) |  |
| inlinestatic

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 183 of file clear_map.h.

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

## ◆ SetIndustryIndexOfField()

static void SetIndustryIndexOfField | ( | TileIndex | t,
|  | IndustryID | i
| ) |  |
| inlinestatic

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 207 of file clear_map.h.

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