20 #include "table/strings.h"
28 static const Price clear_price_table[] = {
42 if (flags &
DC_EXEC) DoClearSquare(tile);
47 void DrawClearLandTile(
const TileInfo *ti, uint8_t set)
52 void DrawHillyLandTile(
const TileInfo *ti)
61 static void DrawClearLandFence(
const TileInfo *ti)
71 SpriteID sprite = _clear_land_fence_sprites[fence_nw - 1] + _fence_mod_by_tileh_nw[ti->
tileh];
72 AddSortableSpriteToDraw(sprite, PAL_NONE, ti->
x, ti->
y - 16, 16, 32, maxz - z + 4, ti->
z + z,
false, 0, 16, -z);
78 SpriteID sprite = _clear_land_fence_sprites[fence_ne - 1] + _fence_mod_by_tileh_ne[ti->
tileh];
79 AddSortableSpriteToDraw(sprite, PAL_NONE, ti->
x - 16, ti->
y, 32, 16, maxz - z + 4, ti->
z + z,
false, 16, 0, -z);
85 if (fence_sw != 0 || fence_se != 0) {
89 SpriteID sprite = _clear_land_fence_sprites[fence_sw - 1] + _fence_mod_by_tileh_sw[ti->
tileh];
90 AddSortableSpriteToDraw(sprite, PAL_NONE, ti->
x, ti->
y, 16, 16, maxz - z + 4, ti->
z + z,
false, 0, 0, -z);
94 SpriteID sprite = _clear_land_fence_sprites[fence_se - 1] + _fence_mod_by_tileh_se[ti->
tileh];
95 AddSortableSpriteToDraw(sprite, PAL_NONE, ti->
x, ti->
y, 16, 16, maxz - z + 4, ti->
z + z,
false, 0, 0, -z);
101 static void DrawTile_Clear(
TileInfo *ti)
109 DrawHillyLandTile(ti);
118 DrawClearLandFence(ti);
130 static int GetSlopePixelZ_Clear(
TileIndex tile, uint x, uint y,
bool)
148 if (
GetFence(tile, dir) != 0)
continue;
176 uint req_density = (k < 0) ? 0u : std::min<uint>(k, 3u);
178 if (current_density == req_density) {
205 static void TileLoopClearDesert(
TileIndex tile)
217 if (current == expected)
return;
229 static void TileLoop_Clear(
TileIndex tile)
234 case LT_TROPIC: TileLoopClearDesert(tile);
break;
242 if (_game_mode != GM_EDITOR) {
258 if (_game_mode == GM_EDITOR)
return;
272 field_type = (field_type < 8) ? field_type + 1 : 0;
284 void GenerateClearTile()
303 uint32_t r = Random();
308 uint j =
GB(r, 16, 4) + 5;
315 if (--j == 0)
goto get_out;
330 static const StringID _clear_land_str[] = {
331 STR_LAI_CLEAR_DESCRIPTION_GRASS,
332 STR_LAI_CLEAR_DESCRIPTION_ROUGH_LAND,
333 STR_LAI_CLEAR_DESCRIPTION_ROCKS,
334 STR_LAI_CLEAR_DESCRIPTION_FIELDS,
335 STR_LAI_CLEAR_DESCRIPTION_SNOW_COVERED_LAND,
336 STR_LAI_CLEAR_DESCRIPTION_DESERT
342 td->
str = STR_LAI_CLEAR_DESCRIPTION_BARE_LAND;
361 GetSlopePixelZ_Clear,
365 GetTileTrackStatus_Clear,
369 ChangeTileOwner_Clear,
constexpr static debug_inline 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.
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.
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.
DoCommandFlag
List of flags for a command.
@ DC_EXEC
execute the given command
Owner
Enum for all companies/owners.
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.).
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.
Definition of base types and functions in a cross-platform compatible way.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
uint8_t 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.
Owner owner[4]
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.
bool IsValidTile(Tile tile)
Checks if a tile is valid.
TropicZone GetTropicZone(Tile tile)
Get the tropic zone.
std::tuple< Slope, int > GetTilePixelSlope(TileIndex tile)
Return the slope of a given tile.
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.