OpenTTD Source 20260711-master-g3fb3006dff
clear_cmd.cpp File Reference

Commands related to clear tiles. More...

#include "stdafx.h"
#include "clear_map.h"
#include "command_func.h"
#include "landscape.h"
#include "genworld.h"
#include "viewport_func.h"
#include "core/random_func.hpp"
#include "newgrf_generic.h"
#include "landscape_cmd.h"
#include "table/strings.h"
#include "table/sprites.h"
#include "table/clear_land.h"
#include "safeguards.h"

Go to the source code of this file.

Functions

static CommandCost ClearTile_Clear (TileIndex tile, DoCommandFlags flags)
 Tile callback function signature for clearing a tile.
void DrawClearLandTile (const TileInfo *ti, uint8_t density)
 Draw a ClearGround::Grass tile.
void DrawRoughLandTile (const TileInfo *ti)
 Draw a ClearGround::Rough tile.
static void DrawClearLandFence (const TileInfo *ti)
 Draw the fences atop a ClearGround::Fields tile.
static void DrawTile_Clear (TileInfo *ti)
 Tile callback function signature for drawing a tile and its contents to the screen.
static int GetSlopePixelZ_Clear (TileIndex tile, uint x, uint y, bool ground_vehicle)
 Tile callback function signature for obtaining the world Z coordinate of a given point of a tile.
static void UpdateFences (TileIndex tile)
static void TileLoopClearAlps (TileIndex tile)
 Convert to or from snowy tiles.
static bool NeighbourIsNormal (TileIndex tile)
 Tests if at least one surrounding tile is non-desert.
static void TileLoopClearDesert (TileIndex tile)
static void TileLoop_Clear (TileIndex tile)
 Tile callback function signature for running periodic tile updates.
void GenerateClearTile ()
static void GetTileDesc_Clear (TileIndex tile, TileDesc &td)
 Tile callback function signature for obtaining a tile description.

Variables

const TileTypeProcs _tile_type_clear_procs
 TileTypeProcs definitions for TileType::Clear tiles.

Detailed Description

Commands related to clear tiles.

Definition in file clear_cmd.cpp.

Function Documentation

◆ ClearTile_Clear()

CommandCost ClearTile_Clear ( TileIndex tile,
DoCommandFlags flags )
static

Tile callback function signature for clearing a tile.

Parameters
tileThe tile to clear.
flagsThe command flags.
Returns
The cost or error.
See also
ClearTile

Definition at line 27 of file clear_cmd.cpp.

References _price, CommandCost::AddCost(), ClearFields, ClearGrass, ClearRocks, ClearRough, Construction, Execute, GetClearDensity(), GetClearGround(), Grass, IsSnowTile(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

◆ DrawClearLandFence()

◆ DrawClearLandTile()

void DrawClearLandTile ( const TileInfo * ti,
uint8_t density )

Draw a ClearGround::Grass tile.

Parameters
tiThe tile to draw.
densityThe density of the dirt -> grass transition to draw.

Definition at line 61 of file clear_cmd.cpp.

References _clear_land_sprites_grass, DrawGroundSprite(), SlopeToSpriteOffset(), and TileInfo::tileh.

Referenced by DrawTile_Clear(), DrawTile_Object(), DrawTile_Station(), DrawTile_Trees(), and DrawTile_TunnelBridge().

◆ DrawRoughLandTile()

void DrawRoughLandTile ( const TileInfo * ti)

◆ DrawTile_Clear()

◆ GenerateClearTile()

void GenerateClearTile ( )

Definition at line 344 of file clear_cmd.cpp.

◆ GetSlopePixelZ_Clear()

int GetSlopePixelZ_Clear ( TileIndex tile,
uint x,
uint y,
bool ground_vehicle )
static

Tile callback function signature for obtaining the world Z coordinate of a given point of a tile.

Parameters
tileThe queries tile for the Z coordinate.
xWorld X coordinate in tile "units".
yWorld Y coordinate in tile "units".
ground_vehicleWhether to get the Z coordinate of the ground vehicle, or the ground.
Returns
World Z coordinate at tile ground (vehicle) level, including slopes and foundations.
See also
GetSlopePixelZ

Definition at line 183 of file clear_cmd.cpp.

References GetPartialPixelZ(), and GetTilePixelSlope().

◆ GetTileDesc_Clear()

void GetTileDesc_Clear ( TileIndex tile,
TileDesc & td )
static

Tile callback function signature for obtaining a tile description.

Parameters
tileTile being queried
tdStorage pointer for returned tile description
See also
GetTileDesc

Definition at line 386 of file clear_cmd.cpp.

References GetClearDensity(), GetClearGround(), GetTileOwner(), Grass, IsClearGround(), IsSnowTile(), MaxSize, TileDesc::owner, and TileDesc::str.

◆ NeighbourIsNormal()

bool NeighbourIsNormal ( TileIndex tile)
inlinestatic

Tests if at least one surrounding tile is non-desert.

Parameters
tiletile to check
Returns
does this tile have at least one non-desert tile around?

Definition at line 246 of file clear_cmd.cpp.

References Desert, End, GetTropicZone(), GetWaterClass(), HasTileWaterClass(), IsValidTile(), Sea, and TileOffsByDiagDir().

◆ TileLoop_Clear()

void TileLoop_Clear ( TileIndex tile)
static

◆ TileLoopClearAlps()

void TileLoopClearAlps ( TileIndex tile)
static

Convert to or from snowy tiles.

Parameters
tileThe tile to consider.

Definition at line 211 of file clear_cmd.cpp.

References AddClearDensity(), ClearSnow(), GetClearDensity(), GetSnowLine(), GetTileZ(), IsSnowTile(), MakeSnow(), and MarkTileDirtyByTile().

Referenced by TileLoop_Clear().

◆ TileLoopClearDesert()

void TileLoopClearDesert ( TileIndex tile)
static

Definition at line 257 of file clear_cmd.cpp.

◆ UpdateFences()

void UpdateFences ( TileIndex tile)
static

Definition at line 190 of file clear_cmd.cpp.

Variable Documentation

◆ _tile_type_clear_procs

const TileTypeProcs _tile_type_clear_procs
extern
Initial value:
= {
.draw_tile_proc = DrawTile_Clear,
.get_slope_pixel_z_proc = GetSlopePixelZ_Clear,
.clear_tile_proc = ClearTile_Clear,
.get_tile_desc_proc = GetTileDesc_Clear,
.tile_loop_proc = TileLoop_Clear,
.terraform_tile_proc = [](TileIndex tile, DoCommandFlags flags, int, Slope) { return Command<Commands::LandscapeClear>::Do(flags, tile); },
.check_build_above_proc = [](TileIndex, DoCommandFlags, Axis, int) { return CommandCost(); },
}
Common return value for all commands.
static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlags flags)
Tile callback function signature for clearing a tile.
Definition clear_cmd.cpp:27
static void GetTileDesc_Clear(TileIndex tile, TileDesc &td)
Tile callback function signature for obtaining a tile description.
static int GetSlopePixelZ_Clear(TileIndex tile, uint x, uint y, bool ground_vehicle)
Tile callback function signature for obtaining the world Z coordinate of a given point of a tile.
static void TileLoop_Clear(TileIndex tile)
Tile callback function signature for running periodic tile updates.
static void DrawTile_Clear(TileInfo *ti)
Tile callback function signature for drawing a tile and its contents to the screen.
EnumBitSet< DoCommandFlag, uint16_t > DoCommandFlags
Bitset of DoCommandFlag elements.
Axis
Enumeration for the two axis X and Y.
Slope
Enumeration for the slope-type.
Definition slope_type.h:53
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
Definition tile_type.h:92

TileTypeProcs definitions for TileType::Clear tiles.