20#include "table/strings.h"
28 static constexpr Price clear_price_table[] = {
41 price.AddCost(_price[clear_price_table[ground]]);
43 price.AddCost(std::abs(_price[PR_CLEAR_ROUGH] - _price[PR_CLEAR_GRASS]));
45 price.AddCost(_price[clear_price_table[ground]]);
53void DrawClearLandTile(
const TileInfo *ti, uint8_t set)
58void DrawHillyLandTile(
const TileInfo *ti)
67static void DrawClearLandFence(
const TileInfo *ti)
77 SpriteID sprite = _clear_land_fence_sprites[fence_nw - 1] + _fence_mod_by_tileh_nw[ti->
tileh];
78 AddSortableSpriteToDraw(sprite, PAL_NONE, ti->
x, ti->
y - 16, 16, 32, maxz - z + 4, ti->
z + z,
false, 0, 16, -z);
84 SpriteID sprite = _clear_land_fence_sprites[fence_ne - 1] + _fence_mod_by_tileh_ne[ti->
tileh];
85 AddSortableSpriteToDraw(sprite, PAL_NONE, ti->
x - 16, ti->
y, 32, 16, maxz - z + 4, ti->
z + z,
false, 16, 0, -z);
91 if (fence_sw != 0 || fence_se != 0) {
95 SpriteID sprite = _clear_land_fence_sprites[fence_sw - 1] + _fence_mod_by_tileh_sw[ti->
tileh];
96 AddSortableSpriteToDraw(sprite, PAL_NONE, ti->
x, ti->
y, 16, 16, maxz - z + 4, ti->
z + z,
false, 0, 0, -z);
100 SpriteID sprite = _clear_land_fence_sprites[fence_se - 1] + _fence_mod_by_tileh_se[ti->
tileh];
101 AddSortableSpriteToDraw(sprite, PAL_NONE, ti->
x, ti->
y, 16, 16, maxz - z + 4, ti->
z + z,
false, 0, 0, -z);
107static void DrawTile_Clear(
TileInfo *ti)
118 DrawHillyLandTile(ti);
127 DrawClearLandFence(ti);
149static int GetSlopePixelZ_Clear(
TileIndex tile, uint x, uint y,
bool)
167 if (
GetFence(tile, dir) != 0)
continue;
196 uint req_density = (k < 0) ? 0u : std::min<uint>(k, 3u);
198 if (current_density == req_density) {
225static void TileLoopClearDesert(
TileIndex tile)
237 if (current == expected)
return;
249static void TileLoop_Clear(
TileIndex tile)
254 case LandscapeType::Tropic: TileLoopClearDesert(tile);
break;
265 if (_game_mode != GM_EDITOR) {
281 if (_game_mode == GM_EDITOR)
return;
295 field_type = (field_type < 8) ? field_type + 1 : 0;
307void GenerateClearTile()
331 uint j =
GB(r, 16, 4) + 5;
338 if (--j == 0)
goto get_out;
356 static constexpr std::pair<StringID, StringID> clear_land_str[] = {
357 {STR_LAI_CLEAR_DESCRIPTION_GRASS, STR_LAI_CLEAR_DESCRIPTION_SNOWY_GRASS},
358 {STR_LAI_CLEAR_DESCRIPTION_ROUGH_LAND, STR_LAI_CLEAR_DESCRIPTION_SNOWY_ROUGH_LAND},
359 {STR_LAI_CLEAR_DESCRIPTION_ROCKS, STR_LAI_CLEAR_DESCRIPTION_SNOWY_ROCKS},
360 {STR_LAI_CLEAR_DESCRIPTION_FIELDS, STR_EMPTY},
361 {STR_EMPTY, STR_EMPTY},
362 {STR_LAI_CLEAR_DESCRIPTION_DESERT, STR_EMPTY},
366 td.
str = STR_LAI_CLEAR_DESCRIPTION_BARE_LAND;
368 const auto &[name, snowy_name] = clear_land_str[
GetClearGround(tile)];
386 GetSlopePixelZ_Clear,
390 GetTileTrackStatus_Clear,
394 ChangeTileOwner_Clear,
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
void DrawBridgeMiddle(const TileInfo *ti)
Draw the middle bits of a bridge.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Common return value for all commands.
static bool NeighbourIsNormal(TileIndex tile)
Tests if at least one surrounding tile is non-desert.
static void TileLoopClearAlps(TileIndex tile)
Convert to or from snowy tiles.
Tables with sprites for clear land and fences.
Map accessors for 'clear' tiles.
void SetFieldType(Tile t, uint f)
Set the field type (production stage) of the field.
void AddClearCounter(Tile t, int c)
Increments the counter used to advance to the next clear density/field type.
uint GetFieldType(Tile t)
Get the field type (production stage) of the field.
void AddClearDensity(Tile t, int d)
Increment the density of a non-field clear tile.
void ClearSnow(Tile t)
Clear the snow from a tile and return it to its previous type.
bool IsClearGround(Tile t, ClearGround ct)
Set the type of clear tile.
void MakeSnow(Tile t, uint density=0)
Make a snow tile.
void SetFence(Tile t, DiagDirection side, uint h)
Sets the type of fence (and whether there is one) for the given border.
IndustryID GetIndustryIndexOfField(Tile t)
Get the industry (farm) that made the field.
@ CLEAR_SNOW
0-3 (Not stored in map.)
void MakeClear(Tile t, ClearGround g, uint density)
Make a clear tile.
ClearGround GetClearGround(Tile t)
Get the type of clear tile.
void SetClearCounter(Tile t, uint c)
Sets the counter used to advance to the next clear density/field type.
void SetClearGroundDensity(Tile t, ClearGround type, uint density)
Sets ground type and density in one go, also sets the counter to 0.
uint GetFence(Tile t, DiagDirection side)
Is there a fence at the given border?
uint GetClearCounter(Tile t)
Get the counter used to advance to the next clear density/field type.
bool IsSnowTile(Tile t)
Test if a tile is covered with snow.
uint GetClearDensity(Tile t)
Get the density of a non-field clear tile.
Functions related to commands.
@ Execute
execute the given command
DiagDirection
Enumeration for diagonal directions.
@ DIAGDIR_NE
Northeast, upper right on your monitor.
@ DIAGDIR_END
Used for iterations.
@ DIAGDIR_BEGIN
Used for iterations.
@ EXPENSES_CONSTRUCTION
Construction costs.
Price
Enumeration of all base prices for use with Prices.
Functions related to world/map generation.
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
@ GWP_ROUGH_ROCKY
Make rough and rocky areas.
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
uint8_t GetSnowLine()
Get the current snow line, either variable or static.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
uint GetPartialPixelZ(int x, int y, Slope corners)
Determines height at given coordinate of a slope.
Functions related to OTTD's landscape.
int GetSlopePixelZInCorner(Slope tileh, Corner corner)
Determine the Z height of a corner relative to TileZ.
Command definitions related to landscape (slopes etc.).
@ Random
Randomise borders.
TileIndex RandomTileSeed(uint32_t r)
Get a random tile out of a given seed.
#define RandomTile()
Get a valid random tile.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
bool HasGrfMiscBit(GrfMiscBit bit)
Check for grf miscellaneous bits.
Functions related to generic callbacks.
void AmbientSoundEffect(TileIndex tile)
Play an ambient sound effect for an empty tile.
Pseudo random number generator.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
uint SlopeToSpriteOffset(Slope s)
Returns the Sprite offset for a given Slope.
static constexpr int GetSlopeMaxPixelZ(Slope s)
Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
Slope
Enumeration for the slope-type.
Foundation
Enumeration for Foundations.
@ FOUNDATION_NONE
The tile has no foundation, the slope remains unchanged.
This file contains all sprite-related enums and defines.
static constexpr SpriteID SPR_OVERLAY_ROCKS_BASE
Overlay rocks sprites.
Definition of base types and functions in a cross-platform compatible way.
LandscapeType landscape
the landscape we're currently in
GameCreationSettings game_creation
settings used during the creation of a game (map)
static uint ScaleBySize(uint n)
Scales the given value by the map size, where the given value is for a 256 by 256 map.
Tile description for the 'land area information' tool.
StringID str
Description of the tile.
std::array< Owner, 4 > owner
Name of the owner(s)
Tile information, used while rendering the tile.
int x
X position of the tile in unit coordinates.
Slope tileh
Slope of the tile.
TileIndex tile
Tile index.
int y
Y position of the tile in unit coordinates.
Set of callback functions for performing tile operations of a given tile type.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
uint TileHash(uint x, uint y)
Calculate a hash value from a tile position.
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
std::tuple< Slope, int > GetTilePixelSlope(TileIndex tile)
Return the slope of a given tile.
bool IsValidTile(Tile tile)
Checks if a tile is valid.
TropicZone GetTropicZone(Tile tile)
Get the tropic zone.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
@ TROPICZONE_DESERT
Tile is desert.
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
TransportType
Available types of transport.
void StartSpriteCombine()
Starts a block of sprites, which are "combined" into a single bounding box.
void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w, int h, int dz, int z, bool transparent, int bb_offset_x, int bb_offset_y, int bb_offset_z, const SubSprite *sub)
Draw a (transparent) sprite at given coordinates with a given bounding box.
void EndSpriteCombine()
Terminates a block of sprites started by StartSpriteCombine.
void DrawGroundSprite(SpriteID image, PaletteID pal, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
Draws a ground sprite for the current tile.
Functions related to (drawing on) viewports.
bool HasTileWaterClass(Tile t)
Checks whether the tile has an waterclass associated.
WaterClass GetWaterClass(Tile t)
Get the water class at a tile.