OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
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,
byte 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 - 15, 16, 31, maxz - z + 4, ti->
z + z,
false, 0, 15, -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 - 15, ti->
y, 31, 16, maxz - z + 4, ti->
z + z,
false, 15, 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)
194 uint req_density = (k < 0) ? 0u : std::min<uint>(k, 3u);
196 if (current_density < req_density) {
198 }
else if (current_density > req_density) {
224 static void TileLoopClearDesert(
TileIndex tile)
236 if (current == expected)
return;
248 static void TileLoop_Clear(
TileIndex tile)
262 case LT_TROPIC: TileLoopClearDesert(tile);
break;
270 if (_game_mode != GM_EDITOR) {
286 if (_game_mode == GM_EDITOR)
return;
300 field_type = (field_type < 8) ? field_type + 1 : 0;
312 void GenerateClearTile()
336 uint j =
GB(r, 16, 4) + 5;
343 if (--j == 0)
goto get_out;
358 static const StringID _clear_land_str[] = {
359 STR_LAI_CLEAR_DESCRIPTION_GRASS,
360 STR_LAI_CLEAR_DESCRIPTION_ROUGH_LAND,
361 STR_LAI_CLEAR_DESCRIPTION_ROCKS,
362 STR_LAI_CLEAR_DESCRIPTION_FIELDS,
363 STR_LAI_CLEAR_DESCRIPTION_SNOW_COVERED_LAND,
364 STR_LAI_CLEAR_DESCRIPTION_DESERT
370 td->
str = STR_LAI_CLEAR_DESCRIPTION_BARE_LAND;
389 GetSlopePixelZ_Clear,
393 GetTileTrackStatus_Clear,
397 ChangeTileOwner_Clear,
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
bool IsTileFlat(TileIndex tile, int *h)
Check if a given tile is flat.
uint32 TileIndex
The index/ID of a Tile.
@ TROPICZONE_DESERT
Tile is desert.
static void AddClearDensity(TileIndex t, int d)
Increment the density of a non-field clear tile.
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
static uint GetClearCounter(TileIndex t)
Get the counter used to advance to the next clear density/field type.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
static bool HasTileWaterClass(TileIndex t)
Checks whether the tile has an waterclass associated.
uint x
X position of the tile in unit coordinates.
Tile information, used while rendering the tile.
static void SetFieldType(TileIndex t, uint f)
Set the field type (production stage) of the field.
byte landscape
the landscape we're currently in
Owner owner[4]
Name of the owner(s)
static void AmbientSoundEffect(TileIndex tile)
Play an ambient sound effect for an empty tile.
Price
Enumeration of all base prices for use with Prices.
static void ClearSnow(TileIndex t)
Clear the snow from a tile and return it to its previous type.
@ DIAGDIR_END
Used for iterations.
static void MakeClear(TileIndex t, ClearGround g, uint density)
Make a clear tile.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
static bool IsClearGround(TileIndex t, ClearGround ct)
Set the type of clear tile.
uint GetPartialPixelZ(int x, int y, Slope corners)
Determines height at given coordinate of a slope.
void DrawBridgeMiddle(const TileInfo *ti)
Draw the middle bits of a bridge.
uint y
Y position of the tile in unit coordinates.
static uint GetFieldType(TileIndex t)
Get the field type (production stage) of the field.
static int GetSlopePixelZInCorner(Slope tileh, Corner corner)
Determine the Z height of a corner relative to TileZ.
TransportType
Available types of transport.
Owner
Enum for all companies/owners.
@ DC_EXEC
execute the given command
Tile description for the 'land area information' tool.
DoCommandFlag
List of flags for a command.
static void SetFence(TileIndex t, DiagDirection side, uint h)
Sets the type of fence (and whether there is one) for the given border.
Foundation
Enumeration for Foundations.
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
static ClearGround GetClearGround(TileIndex t)
Get the type of clear tile.
static uint SlopeToSpriteOffset(Slope s)
Returns the Sprite offset for a given Slope.
GameCreationSettings game_creation
settings used during the creation of a game (map)
Slope tileh
Slope of the tile.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
static uint GetClearDensity(TileIndex t)
Get the density of a non-field clear tile.
@ EXPENSES_CONSTRUCTION
Construction costs.
Common return value for all commands.
byte GetSnowLine()
Get the current snow line, either variable or static.
static void SetClearCounter(TileIndex t, uint c)
Sets the counter used to advance to the next clear density/field type.
static bool HasGrfMiscBit(GrfMiscBit bit)
Check for grf miscellaneous bits.
static uint GetFence(TileIndex t, DiagDirection side)
Is there a fence at the given border?
uint DistanceFromEdge(TileIndex tile)
Param the minimum distance to an edge.
void EndSpriteCombine()
Terminates a block of sprites started by StartSpriteCombine.
void DoFloodTile(TileIndex target)
Floods a tile.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static TropicZone GetTropicZone(TileIndex tile)
Get the tropic zone.
static void AddClearCounter(TileIndex t, int c)
Increments the counter used to advance to the next clear density/field type.
@ GWP_ROUGH_ROCKY
Make rough and rocky areas.
static bool IsSnowTile(TileIndex t)
Test if a tile is covered with snow.
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
bool freeform_edges
allow terraforming the tiles at the map edges
#define RandomTile()
Get a valid random tile.
static uint TileHash(uint x, uint y)
Calculate a hash value from a tile position.
void StartSpriteCombine()
Starts a block of sprites, which are "combined" into a single bounding box.
@ FOUNDATION_NONE
The tile has no foundation, the slope remains unchanged.
Slope
Enumeration for the slope-type.
DiagDirection
Enumeration for diagonal directions.
static IndustryID GetIndustryIndexOfField(TileIndex t)
Get the industry (farm) that made the field.
Set of callback functions for performing tile operations of a given tile type.
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
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.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
static void MakeSnow(TileIndex t, uint density=0)
Make a snow tile.
static uint ScaleByMapSize(uint n)
Scales the given value by the map size, where the given value is for a 256 by 256 map.
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
static int GetSlopeMaxPixelZ(Slope s)
Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
@ DIAGDIR_BEGIN
Used for iterations.
StringID str
Description of the tile.
#define TILE_ADDXY(tile, x, y)
Adds a given offset to a tile.
TileIndex tile
Tile index.
ConstructionSettings construction
construction of things in-game
static Slope GetTilePixelSlope(TileIndex tile, int *h)
Return the slope of a given tile.
@ DIAGDIR_NE
Northeast, upper right on your monitor.
static void TileLoopClearAlps(TileIndex tile)
Convert to or from snowy tiles.
@ CMD_LANDSCAPE_CLEAR
demolish a tile
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.
static TileIndex RandomTileSeed(uint32 r)
Get a random tile out of a given seed.
static bool NeighbourIsNormal(TileIndex tile)
Tests if at least one surrounding tile is non-desert.
static void SetClearGroundDensity(TileIndex t, ClearGround type, uint density)
Sets ground type and density in one go, also sets the counter to 0.