22 #include "table/strings.h" 30 static const Price clear_price_table[] = {
44 if (flags &
DC_EXEC) DoClearSquare(tile);
49 void DrawClearLandTile(
const TileInfo *ti, byte
set)
54 void DrawHillyLandTile(
const TileInfo *ti)
63 static void DrawClearLandFence(
const TileInfo *ti)
73 SpriteID sprite = _clear_land_fence_sprites[fence_nw - 1] + _fence_mod_by_tileh_nw[ti->
tileh];
74 AddSortableSpriteToDraw(sprite, PAL_NONE, ti->
x, ti->
y - 15, 16, 31, maxz - z + 4, ti->
z + z,
false, 0, 15, -z);
80 SpriteID sprite = _clear_land_fence_sprites[fence_ne - 1] + _fence_mod_by_tileh_ne[ti->
tileh];
81 AddSortableSpriteToDraw(sprite, PAL_NONE, ti->
x - 15, ti->
y, 31, 16, maxz - z + 4, ti->
z + z,
false, 15, 0, -z);
87 if (fence_sw != 0 || fence_se != 0) {
91 SpriteID sprite = _clear_land_fence_sprites[fence_sw - 1] + _fence_mod_by_tileh_sw[ti->
tileh];
92 AddSortableSpriteToDraw(sprite, PAL_NONE, ti->
x, ti->
y, 16, 16, maxz - z + 4, ti->
z + z,
false, 0, 0, -z);
96 SpriteID sprite = _clear_land_fence_sprites[fence_se - 1] + _fence_mod_by_tileh_se[ti->
tileh];
97 AddSortableSpriteToDraw(sprite, PAL_NONE, ti->
x, ti->
y, 16, 16, maxz - z + 4, ti->
z + z,
false, 0, 0, -z);
103 static void DrawTile_Clear(
TileInfo *ti)
111 DrawHillyLandTile(ti);
120 DrawClearLandFence(ti);
132 static int GetSlopePixelZ_Clear(
TileIndex tile, uint x, uint y)
196 uint req_density = (k < 0) ? 0u :
min((uint)k, 3);
198 if (current_density < req_density) {
200 }
else if (current_density > req_density) {
223 static void TileLoopClearDesert(
TileIndex tile)
237 if (current == expected)
return;
249 static void TileLoop_Clear(
TileIndex tile)
263 case LT_TROPIC: TileLoopClearDesert(tile);
break;
271 if (_game_mode != GM_EDITOR) {
287 if (_game_mode == GM_EDITOR)
return;
301 field_type = (field_type < 8) ? field_type + 1 : 0;
313 void GenerateClearTile()
337 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,
#define RandomTile()
Get a valid random tile.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static TropicZone GetTropicZone(TileIndex tile)
Get the tropic zone.
Tile information, used while rendering the tile.
byte landscape
the landscape we're currently in
static bool IsSnowTile(TileIndex t)
Test if a tile is covered with snow.
uint GetPartialPixelZ(int x, int y, Slope corners)
Determines height at given coordinate of a slope.
Slope tileh
Slope of the 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...
Price
Enumeration of all base prices for use with Prices.
Tile description for the 'land area information' tool.
Northeast, upper right on your monitor.
Functions related to world/map generation.
Common return value for all commands.
void StartSpriteCombine()
Starts a block of sprites, which are "combined" into a single bounding box.
static bool IsClearGround(TileIndex t, ClearGround ct)
Set the type of clear tile.
static void AmbientSoundEffect(TileIndex tile)
Play an ambient sound effect for an empty tile.
bool IsTileFlat(TileIndex tile, int *h)
Check if a given tile is flat.
static IndustryID GetIndustryIndexOfField(TileIndex t)
Get the industry (farm) that made the field.
Owner owner[4]
Name of the owner(s)
static uint GetFence(TileIndex t, DiagDirection side)
Is there a fence at the given border?
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
Functions related to (drawing on) viewports.
Pseudo random number generator.
bool freeform_edges
allow terraforming the tiles at the map edges
void EndSpriteCombine()
Terminates a block of sprites started by StartSpriteCombine.
uint x
X position of the tile in unit coordinates.
static uint GetFieldType(TileIndex t)
Get the field type (production stage) of the field.
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Foundation
Enumeration for Foundations.
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a give tiletype.
TileIndex tile
Tile index.
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
DoCommandFlag
List of flags for a command.
Definition of base types and functions in a cross-platform compatible way.
#define TILE_ADDXY(tile, x, y)
Adds a given offset to a tile.
A number of safeguards to prevent using unsafe methods.
uint y
Y position of the tile in unit coordinates.
static void SetClearGroundDensity(TileIndex t, ClearGround type, uint density)
Sets ground type and density in one go, also sets the counter to 0.
static Slope GetTilePixelSlope(TileIndex tile, int *h)
Return the slope of a given tile.
static void SetFieldType(TileIndex t, uint f)
Set the field type (production stage) of the field.
Tables with sprites for clear land and fences.
DiagDirection
Enumeration for diagonal directions.
static uint TileHash(uint x, uint y)
Calculate a hash value from a tile position.
static T min(const T a, const T b)
Returns the minimum of two values.
static ClearGround GetClearGround(TileIndex t)
Get the type of clear tile.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
uint DistanceFromEdge(TileIndex tile)
Param the minimum distance to an edge.
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.
static void AddClearDensity(TileIndex t, int d)
Increment the density of a non-field clear tile.
static uint GetClearDensity(TileIndex t)
Get the density of a non-field clear tile.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset)
Mark a tile given by its index dirty for repaint.
static TileIndex RandomTileSeed(uint32 r)
Get a random tile out of a given seed.
execute the given command
static int GetSlopeMaxPixelZ(Slope s)
Returns the height of the highest corner of a slope relative to TileZ (= minimal height) ...
static int GetSlopePixelZInCorner(Slope tileh, Corner corner)
Determine the Z height of a corner relative to TileZ.
Functions related to generic callbacks.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
static uint GetClearCounter(TileIndex t)
Get the counter used to advance to the next clear density/field type.
Set of callback functions for performing tile operations of a given tile type.
uint32 TileIndex
The index/ID of a Tile.
Map accessors for 'clear' tiles.
static void MakeSnow(TileIndex t, uint density=0)
Make a snow tile.
static void MakeClear(TileIndex t, ClearGround g, uint density)
Make a clear tile.
The tile has no foundation, the slope remains unchanged.
TransportType
Available types of transport.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Slope
Enumeration for the slope-type.
static void AddClearCounter(TileIndex t, int c)
Increments the counter used to advance to the next clear density/field type.
Functions related to OTTD's landscape.
Functions related to commands.
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.
byte GetSnowLine()
Get the current snow line, either variable or static.
Make rough and rocky areas.
static uint SlopeToSpriteOffset(Slope s)
Returns the Sprite offset for a given Slope.
ConstructionSettings construction
construction of things in-game
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
StringID str
Description of the tile.
static void SetClearCounter(TileIndex t, uint c)
Sets the counter used to advance to the next clear density/field type.
static void SetFence(TileIndex t, DiagDirection side, uint h)
Sets the type of fence (and whether there is one) for the given border.
GameCreationSettings game_creation
settings used during the creation of a game (map)
A tile without any structures, i.e. grass, rocks, farm fields etc.
Owner
Enum for all companies/owners.
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
Functions related to water (management)
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
static bool HasGrfMiscBit(GrfMiscBit bit)
Check for grf miscellaneous bits.
static void ClearSnow(TileIndex t)
Clear the snow from a tile and return it to its previous type.
static bool NeighbourIsDesert(TileIndex tile)
Tests if at least one surrounding tile is desert.
void DrawBridgeMiddle(const TileInfo *ti)
Draw the middle bits of a bridge.
This file contains all sprite-related enums and defines.
void DoFloodTile(TileIndex target)
Floods a tile.
static void TileLoopClearAlps(TileIndex tile)
Convert to or from snowy tiles.