OpenTTD Source 20260311-master-g511d3794ce
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 set)
void DrawHillyLandTile (const TileInfo *ti)
static void DrawClearLandFence (const TileInfo *ti)
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, Execute, EXPENSES_CONSTRUCTION, GetClearDensity(), GetClearGround(), Grass, IsSnowTile(), MaxSize, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and to_underlying().

◆ DrawClearLandFence()

void DrawClearLandFence ( const TileInfo * ti)
static

Definition at line 70 of file clear_cmd.cpp.

◆ DrawClearLandTile()

void DrawClearLandTile ( const TileInfo * ti,
uint8_t set )

Definition at line 56 of file clear_cmd.cpp.

◆ DrawHillyLandTile()

void DrawHillyLandTile ( const TileInfo * ti)

Definition at line 61 of file clear_cmd.cpp.

◆ DrawTile_Clear()

void DrawTile_Clear ( TileInfo * ti)
static

Tile callback function signature for drawing a tile and its contents to the screen.

Parameters
tiInformation about the tile to draw

Definition at line 120 of file clear_cmd.cpp.

References Desert, DrawBridgeMiddle(), DrawGroundSprite(), Fields, GetClearDensity(), GetClearGround(), GetFieldType(), GetTropicZone(), Grass, HasGrfMiscBit(), IsSnowTile(), Rocks, Rough, SecondRockyTileSet, SlopeToSpriteOffset(), SPR_OVERLAY_ROCKS_BASE, TileInfo::tile, TileInfo::tileh, TileHash(), TROPICZONE_DESERT, Coord3D< T >::x, and Coord3D< T >::y.

◆ GenerateClearTile()

void GenerateClearTile ( )

Definition at line 331 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 170 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 373 of file clear_cmd.cpp.

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

◆ 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 233 of file clear_cmd.cpp.

References DIAGDIR_BEGIN, DIAGDIR_END, GetTropicZone(), GetWaterClass(), HasTileWaterClass(), IsValidTile(), Sea, TileOffsByDiagDir(), and TROPICZONE_DESERT.

◆ 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 198 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 244 of file clear_cmd.cpp.

◆ UpdateFences()

void UpdateFences ( TileIndex tile)
static

Definition at line 177 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.
Axis
Allow incrementing of DiagDirDiff variables.
Slope
Enumeration for the slope-type.
Definition slope_type.h:47
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.