44 #include "table/strings.h"
136 if (ret.
Failed())
return ret;
142 if (ret.
Failed())
return ret;
173 bool IsPossibleDockingTile(
Tile t)
275 if (ret.
Failed())
return ret;
283 if (ret.
Failed())
return ret;
289 delete Depot::GetByTile(tile);
298 if (!do_clear) MakeWaterKeepingClass(tile,
GetTileOwner(tile));
320 if (ret.
Failed())
return ret;
325 if (ret.
Failed())
return ret;
331 if (ret.
Failed())
return ret;
333 cost.
AddCost(_price[PR_BUILD_CANAL]);
343 if (ret.
Failed())
return ret;
345 cost.
AddCost(_price[PR_BUILD_CANAL]);
379 cost.
AddCost(_price[PR_BUILD_LOCK]);
394 if (ret.
Failed())
return ret;
403 if (ret.
Failed())
return ret;
419 MakeWaterKeepingClass(tile + delta,
GetTileOwner(tile + delta));
420 MakeWaterKeepingClass(tile - delta,
GetTileOwner(tile - delta));
497 if (ret.
Failed())
return ret;
513 if (_game_mode == GM_EDITOR) {
539 cost.
AddCost(_price[PR_BUILD_CANAL]);
556 Money base_cost =
IsCanal(tile) ? _price[PR_CLEAR_CANAL] : _price[PR_CLEAR_WATER];
565 if (ret.
Failed())
return ret;
570 if (ret.
Failed())
return ret;
591 if (ret.
Failed())
return ret;
608 { { 0, 0}, {0, 0}, { 0, 0}, {0, 0} },
609 { {-1, 0}, {0, 1}, { 1, 0}, {0, -1} },
610 { { 1, 0}, {0, -1}, {-1, 0}, {0, 1} },
621 return RemoveShipDepot(tile, flags);
641 default: NOT_REACHED();
651 default:
return false;
663 default:
return false;
696 default:
return false;
709 if (base != SPR_FLAT_WATER_TILE) {
729 if (base == 0) base = SPR_CANAL_DIKES_BASE;
731 feature = CF_RIVER_EDGE;
733 if (base == 0)
return;
783 SpriteID image = SPR_FLAT_WATER_TILE;
787 if (image == 0) image = SPR_FLAT_WATER_TILE;
811 uint tile_offs = offset + dtss->image.
sprite;
814 ti->
x + dtss->
delta_x, ti->
y + dtss->delta_y,
815 dtss->size_x, dtss->size_y,
816 dtss->size_z, ti->
z + dtss->
delta_z,
831 if (water_base == 0) {
833 water_base = SPR_CANALS_BASE;
836 if (image == SPR_FLAT_WATER_TILE) {
843 if (image < 5) image += water_base;
852 base = SPR_LOCK_BASE;
854 zoffs = ti->
z > z_threshold ? 24 : 0;
863 DrawWaterClassGround(ti);
867 static void DrawRiverWater(
const TileInfo *ti)
869 SpriteID image = SPR_FLAT_WATER_TILE;
871 uint edges_offset = 0;
877 case SLOPE_NW: image = SPR_WATER_SLOPE_Y_DOWN;
break;
878 case SLOPE_SW: image = SPR_WATER_SLOPE_X_UP;
break;
879 case SLOPE_SE: image = SPR_WATER_SLOPE_Y_UP;
break;
880 case SLOPE_NE: image = SPR_WATER_SLOPE_X_DOWN;
break;
881 default: image = SPR_FLAT_WATER_TILE;
break;
888 case SLOPE_SE: edges_offset += 12;
break;
889 case SLOPE_NE: offset += 1; edges_offset += 24;
break;
890 case SLOPE_SW: offset += 2; edges_offset += 36;
break;
891 case SLOPE_NW: offset += 3; edges_offset += 48;
break;
892 default: offset = 0;
break;
905 void DrawShoreTile(
Slope tileh)
909 static const uint8_t tileh_to_shoresprite[32] = {
910 0, 1, 2, 3, 4, 16, 6, 7, 8, 9, 17, 11, 12, 13, 14, 0,
911 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 10, 15, 0,
922 void DrawWaterClassGround(
const TileInfo *ti)
928 default: NOT_REACHED();
932 static void DrawTile_Water(
TileInfo *ti)
936 DrawWaterClassGround(ti);
941 DrawShoreTile(ti->
tileh);
956 void DrawShipDepotSprite(
int x,
int y,
Axis axis,
DepotPart part)
965 static int GetSlopePixelZ_Water(
TileIndex tile, uint x, uint y,
bool)
985 default: NOT_REACHED();
991 td->
str = STR_LAI_WATER_DESCRIPTION_SHIP_DEPOT;
994 default: NOT_REACHED();
1007 uint victims = v->
Crash(
true);
1010 Game::NewEvent(
new ScriptEventVehicleCrashed(v->
index, v->
tile, ScriptEventVehicleCrashed::CRASH_FLOODED, victims));
1012 AddTileNewsItem(STR_NEWS_DISASTER_FLOOD_VEHICLE,
NT_ACCIDENT, v->
tile);
1046 int z = *(
int*)data;
1047 if (v->
z_pos > z)
break;
1135 bool flooded =
false;
1213 default: NOT_REACHED();
1215 SetRailGroundType(tile, new_ground);
1233 default: NOT_REACHED();
1254 bool continue_flooding =
false;
1266 continue_flooding =
true;
1272 if (z_dest > 0)
continue;
1300 void ConvertGroundTilesIntoWaterTiles()
1351 if (
TileX(tile) == 0) {
1355 if (
TileY(tile) == 0) {
1362 static bool ClickTile_Water(
TileIndex tile)
1423 GetSlopePixelZ_Water,
1427 GetTileTrackStatus_Water,
1431 ChangeTileOwner_Water,
1434 GetFoundation_Water,
1435 TerraformTile_Water,
Base functions for all AIs.
@ AIR_SHADOW
shadow of the aircraft
Class for backupping variables and making sure they are restored later.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
void DrawBridgeMiddle(const TileInfo *ti)
Draw the middle bits of a bridge.
TileIndex GetOtherBridgeEnd(TileIndex tile)
Starting at one bridge end finds the other bridge end.
bool IsBridgeTile(Tile t)
checks if there is a bridge on this tile
int GetBridgePixelHeight(TileIndex tile)
Get the height ('z') of a bridge in pixels.
bool IsBridgeAbove(Tile t)
checks if a bridge is set above the ground of this tile
static void NewEvent(CompanyID company, ScriptEvent *event)
Queue a new event for an AI.
Common return value for all commands.
bool Succeeded() const
Did this command succeed?
void AddCost(const Money &cost)
Adds the given cost to the cost of the command.
Money GetCost() const
The costs as made up to this moment.
bool Failed() const
Did this command fail?
static void NewEvent(class ScriptEvent *event)
Queue a new event for a Game Script.
static std::unique_ptr< TileIterator > Create(TileIndex corner1, TileIndex corner2, bool diagonal)
Create either an OrthogonalTileIterator or DiagonalTileIterator given the diagonal parameter.
Wrapper class to abstract away the way the tiles are stored.
static Date date
Current date in days (day counter).
Map accessors for 'clear' tiles.
void MakeClear(Tile t, ClearGround g, uint density)
Make a clear tile.
Functions related to commands.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
DoCommandFlag
List of flags for a command.
@ DC_AUTO
don't allow building on structures
@ DC_FORCE_CLEAR_TILE
do not only remove the object on the tile, but also clear any water left on it
@ DC_NO_WATER
don't allow building on water
@ DC_BANKRUPT
company bankrupts, skip money check, skip vehicle on tile check in some cases
@ DC_EXEC
execute the given command
Definition of stuff that is very close to a company, like the company struct itself.
CommandCost CheckTileOwnership(TileIndex tile)
Check whether the current owner owns the stuff on the given tile.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
CompanyID _current_company
Company currently doing an action.
Functions related to companies.
void DirtyCompanyInfrastructureWindows(CompanyID company)
Redraw all windows with company infrastructure counts.
GUI Functions related to companies.
Owner
Enum for all companies/owners.
@ INVALID_OWNER
An invalid owner.
@ OWNER_NONE
The tile has no ownership.
@ OWNER_WATER
The tile/execution is done by "water".
Base for all depots (except hangars)
Functions related to depots.
void ShowDepotWindow(TileIndex tile, VehicleType type)
Opens a depot window.
bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Direction ReverseDir(Direction d)
Return the reverse of a direction.
Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
Direction
Defines the 8 directions on the map.
@ DIR_BEGIN
Used to iterate.
@ DIR_END
Used to iterate.
Axis
Allow incrementing of DiagDirDiff variables.
DiagDirection
Enumeration for diagonal directions.
@ DIAGDIR_END
Used for iterations.
@ DIAGDIR_BEGIN
Used for iterations.
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
static const uint LOCK_DEPOT_TILE_FACTOR
Multiplier for how many regular tiles a lock counts.
@ EXPENSES_CONSTRUCTION
Construction costs.
EffectVehicle * CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicleType type)
Create an effect vehicle above a particular vehicle.
Functions related to effect vehicles.
@ EV_EXPLOSION_LARGE
Various explosions.
Base functions for all Games.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
uint32_t PaletteID
The number of the palette.
static void MarkCanalsAndRiversAroundDirty(TileIndex tile)
Marks the tiles around a tile as dirty, if they are canals or rivers.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
Accessors for industries.
IndustryID GetIndustryIndex(Tile t)
Get the industry ID of the given tile.
uint GetPartialPixelZ(int x, int y, Slope corners)
Determines height at given coordinate of a slope.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
std::tuple< Slope, int > GetFoundationSlope(TileIndex tile)
Get slope of a tile on top of a (possible) foundation If a tile does not have a foundation,...
Functions related to OTTD's landscape.
Command definitions related to landscape (slopes etc.).
bool CircularTileSearch(TileIndex *tile, uint size, TestTileOnSearchProc proc, void *user_data)
Function performing a search around a center tile and going outward, thus in circle.
TileIndex TileAddXY(TileIndex tile, int x, int y)
Adds a given offset to a tile.
TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC diff)
Add a TileIndexDiffC to a TileIndex and returns the new one.
TileIndex TileAddByDir(TileIndex tile, Direction dir)
Adds a Direction to a tile.
TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between two tiles from a TileIndexDiffC struct.
TileIndexDiff TileOffsByAxis(Axis axis)
Convert an Axis to a TileIndexDiff.
TileIndexDiffC TileIndexDiffCByDir(Direction dir)
Returns the TileIndexDiffC offset from a Direction.
TileIndexDiff TileOffsByDir(Direction dir)
Convert a Direction to a TileIndexDiff.
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
int32_t TileIndexDiff
An offset value between two tiles.
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
CanalFeature
List of different canal 'features'.
uint GetCanalSpriteOffset(CanalFeature feature, TileIndex tile, uint cur_offset)
Get the new sprite offset for a water tile.
WaterFeature _water_feature[CF_END]
Table of canal 'feature' sprite groups.
SpriteID GetCanalSprite(CanalFeature feature, TileIndex tile)
Lookup the base sprite to use for a canal.
Handling of NewGRF canals.
@ CFF_HAS_FLAT_SPRITE
Additional flat ground sprite in the beginning.
Functions related to generic callbacks.
void AmbientSoundEffect(TileIndex tile)
Play an ambient sound effect for an empty tile.
Functions related to news.
@ NT_ACCIDENT
An accident or disaster has occurred.
bool FloodHalftile(TileIndex t)
Called from water_cmd if a non-flat rail-tile gets flooded and should be converted to shore.
TrackBits GetTrackBits(Tile tile)
Gets the track bits of the given tile.
RailGroundType
The ground 'under' the rail.
@ RAIL_GROUND_FENCE_HORIZ1
Grass with a fence at the southern side.
@ RAIL_GROUND_FENCE_VERT1
Grass with a fence at the eastern side.
@ RAIL_GROUND_FENCE_HORIZ2
Grass with a fence at the northern side.
@ RAIL_GROUND_WATER
Grass with a fence and shore or water on the free halftile.
@ RAIL_GROUND_FENCE_VERT2
Grass with a fence at the western side.
static debug_inline bool IsPlainRail(Tile t)
Returns whether this is plain rails, with or without signals.
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.
ClientSettings _settings_client
The current settings for this game.
static SigSegState UpdateSignalsInBuffer(Owner owner)
Updates blocks in _globset buffer.
bool IsSlopeWithOneCornerRaised(Slope s)
Tests if a specific slope has exactly one corner raised.
bool IsInclinedSlope(Slope s)
Tests if a specific slope is an inclined slope.
static constexpr bool IsHalftileSlope(Slope s)
Checks for non-continuous slope on halftile foundations.
DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
Slope
Enumeration for the slope-type.
@ SLOPE_W
the west corner of the tile is raised
@ SLOPE_HALFTILE_MASK
three bits used for halftile slopes
@ SLOPE_NS
north and south corner are raised
@ SLOPE_E
the east corner of the tile is raised
@ SLOPE_S
the south corner of the tile is raised
@ SLOPE_N
the north corner of the tile is raised
@ SLOPE_SW
south and west corner are raised
@ SLOPE_NE
north and east corner are raised
@ SLOPE_SE
south and east corner are raised
@ SLOPE_NW
north and west corner are raised
@ SLOPE_EW
east and west corner are raised
@ SLOPE_STEEP
indicates the slope is steep
Foundation
Enumeration for Foundations.
@ FOUNDATION_NONE
The tile has no foundation, the slope remains unchanged.
Functions related to sound.
@ SND_12_EXPLOSION
16 == 0x10 Destruction, crashes, disasters, ...
void DrawOrigTileSeqInGUI(int x, int y, const DrawTileSprites *dts, PaletteID default_palette)
Draw TTD sprite sequence in GUI.
static const SpriteID SPR_SHORE_BASE
shore tiles - action 05-0D
Base classes/functions for stations.
bool IsAirportTile(Tile t)
Is this tile a station tile and an airport tile?
bool IsBuoy(Tile t)
Is tile t a buoy tile?
bool IsDockTile(Tile t)
Is tile t a dock tile?
bool IsOilRig(Tile t)
Is tile t part of an oilrig?
bool IsDockWaterPart(Tile t)
Check whether a dock tile is the tile on water.
bool IsDock(Tile t)
Is tile t a dock tile?
Definition of base types and functions in a cross-platform compatible way.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Functions related to OTTD's strings.
Finite sTate mAchine (FTA) of an airport.
uint8_t delta_z
Z adjustment for helicopter pads.
const AirportFTAClass * GetFTA() const
Get the finite-state machine for this airport or the finite-state machine for the dummy airport in ca...
Class to backup a specific variable and restore it later.
void Restore()
Restore the variable.
VehicleType type
Type of vehicle.
SoundSettings sound
sound effect settings
uint32_t water
Count of company owned track bits for canals.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
bool freeform_edges
allow terraforming the tiles at the map edges
TimerGameCalendar::Date build_date
Date of construction.
A tile child sprite and palette to draw for stations etc, with 3D bounding box.
int8_t delta_z
0x80 identifies child sprites
bool IsTerminator() const
Check whether this is a sequence terminator.
int8_t delta_x
0x80 is sequence terminator
Ground palette sprite of a tile, together with its sprite layout.
const DrawTileSeqStruct * seq
Array of child sprites. Terminated with a terminator entry.
PalSpriteID ground
Palette and sprite for the ground.
ConstructionSettings construction
construction of things in-game
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
Station * neutral_station
Associated neutral station.
static uint MaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
static debug_inline uint Size()
Get the size of the map.
static debug_inline uint MaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
void Add(TileIndex to_add)
Add a single tile to a tile area; enlarge if needed.
SpriteID sprite
The 'real' sprite.
PaletteID pal
The palette (use PAL_NONE) if not needed)
Tindex index
Index of this pool item.
static Titem * Get(size_t index)
Returns Titem with given index.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Iterable ensemble of each set bit in a value.
bool disaster
Play disaster and accident sounds.
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
TileArea docking_station
Tile area the docking tiles cover.
Airport airport
Tile area the airport covers.
Tile description for the 'land area information' tool.
StringID str
Description of the tile.
TimerGameCalendar::Date build_date
Date of construction of tile contents.
Owner owner[4]
Name of the owner(s)
A pair-construct of a TileIndexDiff.
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.
int32_t z_pos
z coordinate.
virtual uint Crash(bool flooded=false)
Crash the (whole) vehicle chain.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
uint8_t subtype
subtype (Filled with values from AircraftSubType/DisasterSubType/EffectVehicleType/GroundVehicleSubty...
TileIndex tile
Current tile index.
Owner owner
Which company owns the vehicle?
VehicleEnterTileStatus
The returned bits of VehicleEnterTile.
@ VETSB_CONTINUE
Bit sets of the above specified bits.
bool IsTileFlat(TileIndex tile, int *h)
Check if a given tile is flat.
std::tuple< Slope, int > GetTileSlopeZ(TileIndex tile)
Return the slope of a given tile inside the map.
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
bool IsTileOwner(Tile tile, Owner owner)
Checks if a tile belongs to the given owner.
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
void SetTileOwner(Tile tile, Owner owner)
Sets the owner of a tile.
static debug_inline TileType GetTileType(Tile tile)
Get the tiletype of a given 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.
Slope GetTileSlope(TileIndex tile)
Return the slope of a given tile inside the map.
void SetTropicZone(Tile tile, TropicZone type)
Set the tropic zone.
static debug_inline uint TileHeight(Tile tile)
Returns the height of a tile.
@ TROPICZONE_DESERT
Tile is desert.
@ TROPICZONE_NORMAL
Normal tropiczone.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
@ MP_TREES
Tile got trees.
@ MP_STATION
A tile of a station.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
@ MP_INDUSTRY
Part of an industry.
@ MP_VOID
Invisible tiles at the SW and SE border.
@ MP_OBJECT
Contains objects such as transmitters and owned land.
Definition of the game-calendar-timer.
void MakeDefaultName(T *obj)
Set the default name for a depot/waypoint.
TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, TrackdirBits red_signals)
Builds a TrackStatus.
TrackBits AxisToTrackBits(Axis a)
Maps an Axis to the corresponding TrackBits value.
TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir.
TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
TrackBits
Allow incrementing of Track variables.
@ TRACK_BIT_UPPER
Upper track.
@ TRACK_BIT_LEFT
Left track.
@ TRACK_BIT_Y
Y-axis track.
@ TRACK_BIT_NONE
No track.
@ TRACK_BIT_X
X-axis track.
@ TRACK_BIT_LOWER
Lower track.
@ TRACK_BIT_ALL
All possible tracks.
@ TRACK_BIT_RIGHT
Right track.
@ TRACKDIR_BIT_NONE
No track build.
@ TO_BUILDINGS
company buildings - depots, stations, HQ, ...
bool IsTransparencySet(TransparencyOption to)
Check if the transparency option bit is set and if we aren't in the game menu (there's never transpar...
bool IsInvisibilitySet(TransparencyOption to)
Check if the invisibility option bit is set and if we aren't in the game menu (there's never transpar...
TransportType
Available types of transport.
@ TRANSPORT_WATER
Transport over water.
Map accessors for tree tiles.
TreeGround GetTreeGround(Tile t)
Returns the groundtype for tree tiles.
@ TREE_GROUND_GRASS
normal grass
void SetTreeGroundDensity(Tile t, TreeGround g, uint d)
Set the density and ground type of a tile with trees.
Functions that have tunnels and bridges in common.
DiagDirection GetTunnelBridgeDirection(Tile t)
Get the direction pointing to the other end.
TransportType GetTunnelBridgeTransportType(Tile t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
@ VS_CRASHED
Vehicle is crashed.
Functions related to vehicles.
@ VEH_ROAD
Road vehicle type.
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ VEH_SHIP
Ship vehicle type.
@ VEH_TRAIN
Train vehicle type.
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 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.
Functions related to water (management)
static const uint RIVER_OFFSET_DESERT_DISTANCE
Circular tile search radius to create non-desert around a river tile.
FloodingBehaviour
Describes the behaviour of a tile during flooding.
@ FLOOD_NONE
The tile does not flood neighboured tiles.
@ FLOOD_ACTIVE
The tile floods neighboured tiles.
@ FLOOD_DRYUP
The tile drys up if it is not constantly flooded from neighboured tiles.
@ FLOOD_PASSIVE
The tile does not actively flood neighboured tiles, but it prevents them from drying up.
void TileLoop_Water(TileIndex tile)
Let a water tile floods its diagonal adjoining tiles called from tunnelbridge_cmd,...
static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlag flags)
Builds a lock.
static void DrawWaterDepot(const TileInfo *ti)
Draw a ship depot tile.
static CommandCost RemoveLock(TileIndex tile, DoCommandFlag flags)
Remove a lock.
static void DrawWaterSprite(SpriteID base, uint offset, CanalFeature feature, TileIndex tile)
Draw a water sprite, potentially with a NewGRF-modified sprite offset.
static void DrawWaterLock(const TileInfo *ti)
Draw a lock tile.
static bool RiverModifyDesertZone(TileIndex tile, void *)
Callback to create non-desert around a river tile.
static void FloodVehicle(Vehicle *v)
Handle the flooding of a vehicle.
static void FloodVehicles(TileIndex tile)
Finds a vehicle to flood.
static void DrawWaterEdges(bool canal, uint offset, TileIndex tile)
Draw canal or river edges.
void ClearNeighbourNonFloodingStates(TileIndex tile)
Clear non-flooding state of the tiles around a tile.
static void DoDryUp(TileIndex tile)
Drys a tile up.
static Vehicle * FloodVehicleProc(Vehicle *v, void *data)
Flood a vehicle if we are allowed to flood it, i.e.
CommandCost CmdBuildLock(DoCommandFlag flags, TileIndex tile)
Builds a lock.
static void MarkTileDirtyIfCanalOrRiver(TileIndex tile)
Marks tile dirty if it is a canal or river tile.
FloodingBehaviour GetFloodingBehaviour(TileIndex tile)
Returns the behaviour of a tile during flooding.
void CheckForDockingTile(TileIndex t)
Mark the supplied tile as a docking tile if it is suitable for docking.
static void DrawSeaWater(TileIndex)
Draw a plain sea water tile with no edges.
static void DrawWaterTileStruct(const TileInfo *ti, const DrawTileSeqStruct *dtss, SpriteID base, uint offset, PaletteID palette, CanalFeature feature)
Draw a build sprite sequence for water tiles.
static const uint8_t _flood_from_dirs[]
Describes from which directions a specific slope can be flooded (if the tile is floodable at all).
static void DrawCanalWater(TileIndex tile)
draw a canal styled water tile with dikes around
CommandCost CmdBuildShipDepot(DoCommandFlag flags, TileIndex tile, Axis axis)
Build a ship depot.
void MakeRiverAndModifyDesertZoneAround(TileIndex tile)
Make a river tile and remove desert directly around it.
static void DoFloodTile(TileIndex target)
Floods a tile.
bool IsWateredTile(TileIndex tile, Direction from)
return true if a tile is a water tile wrt.
CommandCost CmdBuildCanal(DoCommandFlag flags, TileIndex tile, TileIndex start_tile, WaterClass wc, bool diagonal)
Build a piece of canal.
Command definitions related to water tiles.
Sprites to use and how to display them for water tiles (depots/locks).
void MakeShore(Tile t)
Helper function to make a coast tile.
bool HasTileWaterGround(Tile t)
Checks whether the tile has water at the ground.
TileIndex GetShipDepotNorthTile(Tile t)
Get the most northern tile of a ship depot.
void MakeLock(Tile t, Owner o, DiagDirection d, WaterClass wc_lower, WaterClass wc_upper, WaterClass wc_middle)
Make a water lock.
DepotPart GetShipDepotPart(Tile t)
Get the part of a ship depot.
bool IsTileOnWater(Tile t)
Tests if the tile was built on water.
DepotPart
Sections of the water depot.
@ DEPOT_PART_NORTH
Northern part of a depot.
@ DEPOT_PART_SOUTH
Southern part of a depot.
bool IsShipDepot(Tile t)
Is it a water tile with a ship depot on it?
bool IsValidWaterClass(WaterClass wc)
Checks if a water class is valid.
bool IsRiver(Tile t)
Is it a river water tile?
DiagDirection GetLockDirection(Tile t)
Get the direction of the water lock.
WaterClass
classes of water (for WATER_TILE_CLEAR water tile type).
@ WATER_CLASS_CANAL
Canal.
@ WATER_CLASS_INVALID
Used for industry tiles on land (also for oilrig if newgrf says so).
@ WATER_CLASS_RIVER
River.
bool HasTileWaterClass(Tile t)
Checks whether the tile has an waterclass associated.
bool IsCanal(Tile t)
Is it a canal tile?
bool IsCoast(Tile t)
Is it a coast tile?
void MakeRiver(Tile t, uint8_t random_bits)
Make a river tile.
WaterTileType GetWaterTileType(Tile t)
Get the water tile type of a tile.
void SetNonFloodingWaterTile(Tile t, bool b)
Set the non-flooding water tile state of a tile.
@ WATER_TILE_LOCK
Water lock.
@ WATER_TILE_DEPOT
Water Depot.
@ WATER_TILE_CLEAR
Plain water.
WaterClass GetWaterClass(Tile t)
Get the water class at a tile.
void MakeCanal(Tile t, Owner o, uint8_t random_bits)
Make a canal tile.
uint8_t GetLockPart(Tile t)
Get the part of a lock.
TileIndex GetOtherShipDepotTile(Tile t)
Get the other tile of the ship depot.
bool IsNonFloodingWaterTile(Tile t)
Checks whether the tile is marked as a non-flooding water tile.
void SetDockingTile(Tile t, bool b)
Set the docking tile state of a tile.
bool IsWaterTile(Tile t)
Is it a water tile with plain water?
bool IsLock(Tile t)
Is there a lock on a given water tile?
void MakeShipDepot(Tile t, Owner o, DepotID did, DepotPart part, Axis a, WaterClass original_water_class)
Make a ship depot section.
void MakeSea(Tile t)
Make a sea tile.
@ LOCK_PART_UPPER
Upper part of a lock.
@ LOCK_PART_MIDDLE
Middle part of a lock.
Axis GetShipDepotAxis(Tile t)
Get the axis of the ship depot.
void InvalidateWaterRegion(TileIndex tile)
Marks the water region that tile is part of as invalid.
Handles dividing the water in the map into regions to assist pathfinding.