OpenTTD Source: src/terraform_cmd.cpp File Reference

OpenTTD Source 12.2

Data Structures | Typedefs | Functions | Variables
terraform_cmd.cpp File Reference
`#include "stdafx.h"`
`#include "command_func.h"`
`#include "tunnel_map.h"`
`#include "bridge_map.h"`
`#include "viewport_func.h"`
`#include "genworld.h"`
`#include "object_base.h"`
`#include "company_base.h"`
`#include "company_func.h"`
`#include "core/backup_type.hpp"`
`#include "table/strings.h"`
`#include <map>`
`#include <set>`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | TerraformerState
| State of the terraforming. More...

## Typedefs
typedef std::set< TileIndex > | TileIndexSet
| Set of tiles.
typedef std::map< TileIndex, int > | TileIndexToHeightMap
| Mapping of tiles to their height.

## Functions
static int | TerraformGetHeightOfTile (const TerraformerState *ts, TileIndex tile)
| Gets the TileHeight (height of north corner) of a tile as of current terraforming progress. More...
static void | TerraformSetHeightOfTile (TerraformerState *ts, TileIndex tile, int height)
| Stores the TileHeight (height of north corner) of a tile in a TerraformerState. More...
static void | TerraformAddDirtyTile (TerraformerState *ts, TileIndex tile)
| Adds a tile to the "tile_table" in a TerraformerState. More...
static void | TerraformAddDirtyTileAround (TerraformerState *ts, TileIndex tile)
| Adds all tiles that incident with the north corner of a specific tile to the "tile_table" in a TerraformerState. More...
static CommandCost | TerraformTileHeight (TerraformerState *ts, TileIndex tile, int height)
| Terraform the north corner of a tile to a specific height. More...
CommandCost | CmdTerraformLand (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
| Terraform land. More...
CommandCost | CmdLevelLand (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
| Levels a selected (rectangle) area of land. More...

## Variables
TileIndex | _terraform_err_tile
| first tile we couldn't terraform

## Detailed Description

Commands related to terraforming.

Definition in file terraform_cmd.cpp.

## Function Documentation

## ◆ CmdLevelLand()

CommandCost CmdLevelLand | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const std::string & | text
| ) |  |

Levels a selected (rectangle) area of land.

Parameters

  tile | end tile of area-drag
  flags | for this command type
  p1 | start tile of area drag
  p2 | various bitstuffed data. bit 0: Whether to use the Orthogonal (0) or Diagonal (1) iterator. bits 1 - 2: Mode of leveling `LevelMode`.
  text | unused

Returns
  the cost of this operation or an error

Definition at line 345 of file terraform_cmd.cpp.

References _current_company, _settings_game, _terraform_err_tile, CMD_ERROR, GameSettings::construction, EXPENSES_CONSTRUCTION, GB(), GetAvailableMoneyForCommand(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), INVALID_STRING_ID, INVALID_TILE, LM_LEVEL, LM_LOWER, LM_RAISE, ConstructionSettings::map_height_limit, MapSize(), return_cmd_error, and TileHeight().

## ◆ CmdTerraformLand()

CommandCost CmdTerraformLand | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const std::string & | text
| ) |  |

Terraform land.

Parameters

  tile | tile to terraform
  flags | for this command type
  p1 | corners to terraform (SLOPE_xxx)
  p2 | direction; eg up (non-zero) or down (zero)
  text | unused

Returns
  the cost of this operation or an error

Definition at line 188 of file terraform_cmd.cpp.

References _generating_world, _settings_game, _terraform_err_tile, CommandCost::AddCost(), GameSettings::construction, TerraformerState::dirty_tiles, EXPENSES_CONSTRUCTION, CommandCost::Failed(), FindClearedObject(), ClearedObjectArea::first_tile, GetBridgeHeight(), GetSouthernBridgeEnd(), INVALID_TILE, IsBridgeAbove(), IsTileType(), IsTunnelInWay(), MapSize(), ConstructionSettings::max_bridge_height, MP_VOID, return_cmd_error, SLOPE_E, SLOPE_FLAT, SLOPE_N, SLOPE_S, SLOPE_STEEP, SLOPE_W, TerraformGetHeightOfTile(), TerraformTileHeight(), TileDiffXY(), and TileHeight().

## ◆ TerraformGetHeightOfTile()

static int TerraformGetHeightOfTile | ( | const TerraformerState * | ts,
|  | TileIndex | tile
| ) |  |
| static

Gets the TileHeight (height of north corner) of a tile as of current terraforming progress.

Parameters

  ts | TerraformerState.
  tile | Tile.

Returns
  TileHeight.

Definition at line 48 of file terraform_cmd.cpp.

References TerraformerState::tile_to_new_height, and TileHeight().

Referenced by CmdTerraformLand(), and TerraformTileHeight().

## ◆ TerraformSetHeightOfTile()

static void TerraformSetHeightOfTile | ( | TerraformerState * | ts,
|  | TileIndex | tile,
|  | int | height
| ) |  |
| static

Stores the TileHeight (height of north corner) of a tile in a TerraformerState.

Parameters

  ts | TerraformerState.
  tile | Tile.
  height | New TileHeight.

Definition at line 61 of file terraform_cmd.cpp.

References TerraformerState::tile_to_new_height.

## ◆ TerraformTileHeight()

static CommandCost TerraformTileHeight | ( | TerraformerState * | ts,
|  | TileIndex | tile,
|  | int | height
| ) |  |
| static

Terraform the north corner of a tile to a specific height.

Parameters

  ts | TerraformerState.
  tile | Tile.
  height | Aimed height.

Returns
  Error code or cost.

Definition at line 102 of file terraform_cmd.cpp.

References _settings_game, CMD_ERROR, GameSettings::construction, ConstructionSettings::map_height_limit, MapSize(), return_cmd_error, and TerraformGetHeightOfTile().

Referenced by CmdTerraformLand().