|
OpenTTD Source
14.0-beta1
|
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,
bool)
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)
253 case LT_TROPIC: TileLoopClearDesert(tile);
break;
261 if (_game_mode != GM_EDITOR) {
277 if (_game_mode == GM_EDITOR)
return;
291 field_type = (field_type < 8) ? field_type + 1 : 0;
303 void GenerateClearTile()
322 uint32_t r = Random();
327 uint j =
GB(r, 16, 4) + 5;
334 if (--j == 0)
goto get_out;
349 static const StringID _clear_land_str[] = {
350 STR_LAI_CLEAR_DESCRIPTION_GRASS,
351 STR_LAI_CLEAR_DESCRIPTION_ROUGH_LAND,
352 STR_LAI_CLEAR_DESCRIPTION_ROCKS,
353 STR_LAI_CLEAR_DESCRIPTION_FIELDS,
354 STR_LAI_CLEAR_DESCRIPTION_SNOW_COVERED_LAND,
355 STR_LAI_CLEAR_DESCRIPTION_DESERT
361 td->
str = STR_LAI_CLEAR_DESCRIPTION_BARE_LAND;
380 GetSlopePixelZ_Clear,
384 GetTileTrackStatus_Clear,
388 ChangeTileOwner_Clear,
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
@ TROPICZONE_DESERT
Tile is desert.
bool IsClearGround(Tile t, ClearGround ct)
Set the type of clear tile.
void MakeSnow(Tile t, uint density=0)
Make a snow tile.
Tile information, used while rendering the tile.
WaterClass GetWaterClass(Tile t)
Get the water class at a tile.
byte landscape
the landscape we're currently in
Owner owner[4]
Name of the owner(s)
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
void AmbientSoundEffect(TileIndex tile)
Play an ambient sound effect for an empty tile.
Price
Enumeration of all base prices for use with Prices.
void SetClearCounter(Tile t, uint c)
Sets the counter used to advance to the next clear density/field type.
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.
@ DIAGDIR_END
Used for iterations.
void AddClearDensity(Tile t, int d)
Increment the density of a non-field clear tile.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
uint TileHash(uint x, uint y)
Calculate a hash value from a tile position.
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 GetFieldType(Tile t)
Get the field type (production stage) of the field.
int y
Y position of the tile in unit coordinates.
Owner
Enum for all companies/owners.
static uint ScaleBySize(uint n)
Scales the given value by the map size, where the given value is for a 256 by 256 map.
@ DC_EXEC
execute the given command
Tile description for the 'land area information' tool.
DoCommandFlag
List of flags for a command.
Foundation
Enumeration for Foundations.
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
GameCreationSettings game_creation
settings used during the creation of a game (map)
Slope tileh
Slope of the tile.
void MakeClear(Tile t, ClearGround g, uint density)
Make a clear tile.
Slope
Enumeration for the slope-type.
@ EXPENSES_CONSTRUCTION
Construction costs.
Common return value for all commands.
byte GetSnowLine()
Get the current snow line, either variable or static.
uint GetClearCounter(Tile t)
Get the counter used to advance to the next clear density/field type.
static constexpr int GetSlopeMaxPixelZ(Slope s)
Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
TransportType
Available types of transport.
void SetFence(Tile t, DiagDirection side, uint h)
Sets the type of fence (and whether there is one) for the given border.
ClearGround GetClearGround(Tile t)
Get the type of clear tile.
void EndSpriteCombine()
Terminates a block of sprites started by StartSpriteCombine.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ GWP_ROUGH_ROCKY
Make rough and rocky areas.
#define RandomTile()
Get a valid random tile.
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
bool HasGrfMiscBit(GrfMiscBit bit)
Check for grf miscellaneous bits.
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.
DiagDirection
Enumeration for diagonal directions.
Set of callback functions for performing tile operations of a given tile type.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
bool HasTileWaterClass(Tile t)
Checks whether the tile has an waterclass associated.
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.
bool IsValidTile(Tile tile)
Checks if a tile is valid.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Slope GetTilePixelSlope(TileIndex tile, int *h)
Return the slope of a given tile.
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
int GetSlopePixelZInCorner(Slope tileh, Corner corner)
Determine the Z height of a corner relative to TileZ.
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.
void SetFieldType(Tile t, uint f)
Set the field type (production stage) of the field.
StringID str
Description of the tile.
#define TILE_ADDXY(tile, x, y)
Adds a given offset to a tile.
void SetClearGroundDensity(Tile t, ClearGround type, uint density)
Sets ground type and density in one go, also sets the counter to 0.
uint SlopeToSpriteOffset(Slope s)
Returns the Sprite offset for a given Slope.
bool IsSnowTile(Tile t)
Test if a tile is covered with snow.
int x
X position of the tile in unit coordinates.
TileIndex tile
Tile index.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
uint GetFence(Tile t, DiagDirection side)
Is there a fence at the given border?
@ DIAGDIR_NE
Northeast, upper right on your monitor.
TropicZone GetTropicZone(Tile tile)
Get the tropic zone.
void AddClearCounter(Tile t, int c)
Increments the counter used to advance to the next clear density/field type.
IndustryID GetIndustryIndexOfField(Tile t)
Get the industry (farm) that made the field.
uint GetClearDensity(Tile t)
Get the density of a non-field clear tile.
static void TileLoopClearAlps(TileIndex tile)
Convert to or from snowy tiles.
TileIndex RandomTileSeed(uint32_t r)
Get a random tile out of a given seed.
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.
void ClearSnow(Tile t)
Clear the snow from a tile and return it to its previous type.
static bool NeighbourIsNormal(TileIndex tile)
Tests if at least one surrounding tile is non-desert.