46#include "table/strings.h"
55std::vector<RoadType> _sorted_roadtypes;
81 if (cursors_base != 0) {
105 if (RoadTypeIsRoad(first) == RoadTypeIsRoad(second)) {
108 return RoadTypeIsTram(first) < RoadTypeIsTram(second);
118 ResolveRoadTypeGUISprites(rti);
122 _sorted_roadtypes.clear();
124 if (_roadtypes[rt].label != 0 && !
HasBit(_roadtypes_hidden_mask, rt)) {
125 _sorted_roadtypes.push_back(rt);
128 std::sort(_sorted_roadtypes.begin(), _sorted_roadtypes.end(),
CompareRoadTypes);
139 if (rti->
label == 0) {
162 if (rtt == RTT_TRAM) {
195 if (c ==
nullptr)
return;
290 if (ret.
Failed())
return ret;
307 return CommandCost(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS);
331 if (existing_rt ==
INVALID_ROADTYPE)
return CommandCost((rtt == RTT_TRAM) ? STR_ERROR_THERE_IS_NO_TRAMWAY : STR_ERROR_THERE_IS_NO_ROAD);
336 if (ret.
Failed())
return ret;
344 if (ret.
Failed())
return ret;
351 if (ret.
Failed())
return ret;
360 if (ret.
Failed())
return ret;
436 if (pieces ==
ROAD_NONE)
return CommandCost((rtt == RTT_TRAM) ? STR_ERROR_THERE_IS_NO_TRAMWAY : STR_ERROR_THERE_IS_NO_ROAD);
562 RoadBits type_bits = existing | *pieces;
575 type_bits = existing | *pieces;
623 town_id = (town !=
nullptr) ? town->
index : INVALID_TOWN;
640 RoadTramType rtt = GetRoadTramType(rt);
642 bool need_to_clear =
false;
649 other_bits =
GetRoadBits(tile, OtherRoadTramType(rtt));
656 return CommandCost(STR_ERROR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION);
658 if ((existing & pieces) == pieces) {
660 if (toggle_drd !=
DRD_NONE && rtt == RTT_ROAD) {
661 if (crossing)
return CommandCost(STR_ERROR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION);
666 if (ret.
Failed())
return ret;
678 if (ret.
Failed())
return ret;
696 if (ret.
Failed())
return ret;
704 return CommandCost(STR_ERROR_CROSSING_DISALLOWED_ROAD);
718 default: NOT_REACHED();
724 return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
729 return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
734 if (ret.
Failed())
return ret;
740 return CommandCost(STR_ERROR_CROSSING_DISALLOWED_ROAD);
744 return CommandCost(STR_ERROR_CROSSING_DISALLOWED_RAIL);
750 if (pieces &
ROAD_X)
goto do_clear;
755 if (pieces &
ROAD_Y)
goto do_clear;
759 default:
goto do_clear;
763 if (ret.
Failed())
return ret;
795 if (pieces & ~curbits)
goto do_clear;
809 if (ret.
Failed())
return ret;
815 need_to_clear =
true;
822 if (ret.
Failed())
return ret;
826 if (other_bits != pieces) {
832 return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
837 if (!need_to_clear) {
850 return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
856 if (ret.
Failed())
return ret;
862 RoadType existing_rt = GetRoadType(tile, rtt);
868 if (ret.
Failed())
return ret;
955 RoadTramType rtt = GetRoadTramType(rt);
956 RoadType existing = GetRoadType(tile, rtt);
992 if (start_tile > end_tile || (start_tile == end_tile && start_half)) {
994 start_half = !start_half;
995 end_half = !end_half;
1007 bool had_bridge =
false;
1008 bool had_tunnel =
false;
1009 bool had_success =
false;
1016 if (!is_ai && start_tile != end_tile) {
1033 if (is_ai)
return last_error;
1034 if (had_success)
break;
1056 if (tile == end_tile)
break;
1061 return had_success ? cost : last_error;
1087 if (start_tile > end_tile || (start_tile == end_tile && start_half)) {
1088 std::swap(start_tile, end_tile);
1089 std::swap(start_half, end_half);
1093 Money money_spent = 0;
1096 bool had_success =
false;
1106 RoadTramType rtt = GetRoadTramType(rt);
1111 if (money_spent > 0 && money_spent > money_available) {
1121 case STR_ERROR_OWNED_BY:
1122 case STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS:
1130 if (tile == end_tile)
break;
1135 return { had_success ? cost : last_error, 0 };
1160 cost.
AddCost(_price[PR_BUILD_FOUNDATION]);
1164 bool rotate_existing_depot =
false;
1165 if (
IsRoadDepotTile(tile) && (HasRoadTypeTram(tile) ? rt == GetRoadTypeTram(tile) : rt == GetRoadTypeRoad(tile)))
1168 if (ret.
Failed())
return ret;
1173 if (ret.
Failed())
return ret;
1175 rotate_existing_depot =
true;
1178 if (!rotate_existing_depot) {
1180 if (cost.
Failed())
return cost;
1188 if (rotate_existing_depot) {
1203 cost.
AddCost(_price[PR_BUILD_DEPOT_ROAD]);
1211 if (ret.
Failed())
return ret;
1215 if (ret.
Failed())
return ret;
1221 RoadType rt = GetRoadTypeRoad(tile);
1227 delete Depot::GetByTile(tile);
1228 DoClearSquare(tile);
1243 for (RoadTramType rtt : _roadtramtypes) {
1247 if (tmp_ret.
Failed())
return tmp_ret;
1252 return CommandCost(STR_ERROR_MUST_REMOVE_ROAD_FIRST);
1262 for (RoadTramType rtt : { RTT_TRAM, RTT_ROAD }) {
1266 if (tmp_ret.
Failed())
return tmp_ret;
1279 return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
1281 return RemoveRoadDepot(tile, flags);
1323const uint8_t _road_sloped_sprites[14] = {
1344 default: NOT_REACHED();
1347 static const uint offsets[] = {
1353 return offsets[bits];
1368 return (snow_or_desert &&
1396 RoadType rt_road = GetRoadTypeRoad(neighbour);
1397 RoadType rt_tram = GetRoadTypeTram(neighbour);
1406 if (
CountBits(rb_new) >= 2) rb = rb_new;
1413 if (front != 0 || back != 0) {
1417 back = SPR_TRAMWAY_BACK_WIRES_SLOPED + _road_sloped_sprites[ti->
tileh - 1];
1418 front = SPR_TRAMWAY_FRONT_WIRES_SLOPED + _road_sloped_sprites[ti->
tileh - 1];
1433 static const int INF = 1000;
1434 static const SubSprite west = { -INF, -INF, -12, INF };
1435 static const SubSprite north = { -12, -INF, 12, INF };
1436 static const SubSprite east = { 12, -INF, INF, INF };
1437 AddSortableSpriteToDraw(back, pal, ti->
x, ti->
y, 16, 1, z_wires, ti->
z,
IsTransparencySet(
TO_CATENARY), 15, 0,
GetSlopePixelZInCorner(ti->
tileh, CORNER_W), &west);
1438 AddSortableSpriteToDraw(back, pal, ti->
x, ti->
y, 1, 1, z_wires, ti->
z,
IsTransparencySet(
TO_CATENARY), 0, 0,
GetSlopePixelZInCorner(ti->
tileh, CORNER_N), &north);
1439 AddSortableSpriteToDraw(back, pal, ti->
x, ti->
y, 1, 16, z_wires, ti->
z,
IsTransparencySet(
TO_CATENARY), 0, 15,
GetSlopePixelZInCorner(ti->
tileh, CORNER_E), &east);
1443 AddSortableSpriteToDraw(front, pal, ti->
x, ti->
y, 16, 16, z_wires + 1, ti->
z,
IsTransparencySet(
TO_CATENARY), 0, 0, z_wires);
1482 rt = GetRoadTypeTram(ti->
tile);
1517 if (draw_underlay) {
1519 if (road_rti !=
nullptr) {
1520 if (road_rti->UsesOverlay()) {
1525 if (tram_rti->UsesOverlay()) {
1535 if (road_rti !=
nullptr) {
1536 if (road_rti->UsesOverlay()) {
1543 if (tram_rti !=
nullptr) {
1544 if (tram_rti->UsesOverlay()) {
1547 }
else if (road_rti !=
nullptr) {
1565 if (rti ==
nullptr || rti->UsesOverlay()) {
1580 SpriteID image = SPR_ROAD_Y + offset;
1588 default: image -= 19;
break;
1641 if (road_rti !=
nullptr) {
1649 oneway += SPR_ONEWAY_SLOPE_N_OFFSET;
1651 oneway += SPR_ONEWAY_SLOPE_S_OFFSET;
1678 if (height < minz)
return;
1689 bool is_transparent =
false;
1691 is_transparent =
true;
1694 is_transparent =
true;
1698 for (
const DrawRoadTileStruct *drts = _road_display_table[roadside][road | tram]; drts->image != 0; drts++) {
1699 DrawRoadDetail(drts->image, ti, drts->subcoord_x, drts->subcoord_y, 0x10, is_transparent);
1726 if (rti->UsesOverlay()) {
1727 SpriteID image = SPR_ROAD_Y + axis;
1736 default: image -= 19;
break;
1752 default: image += 4;
break;
1763 if (rti->UsesOverlay()) {
1771 uint adjacent_diagdirs = 0;
1775 SetBit(adjacent_diagdirs, dir);
1779 switch (adjacent_diagdirs) {
1804 }
else if (draw_pbs || tram_rti !=
nullptr || road_rti->UsesOverlay()) {
1831 bool default_gfx = relocation == 0;
1836 relocation = SPR_TRAMWAY_DEPOT_WITH_TRACK - SPR_ROAD_DEPOT;
1837 default_gfx =
false;
1840 relocation = SPR_TRAMWAY_DEPOT_NO_TRACK - SPR_ROAD_DEPOT;
1844 relocation -= SPR_ROAD_DEPOT;
1853 if (rti->UsesOverlay()) {
1881 bool default_gfx = relocation == 0;
1886 relocation = SPR_TRAMWAY_DEPOT_WITH_TRACK - SPR_ROAD_DEPOT;
1887 default_gfx =
false;
1890 relocation = SPR_TRAMWAY_DEPOT_NO_TRACK - SPR_ROAD_DEPOT;
1894 relocation -= SPR_ROAD_DEPOT;
1902 if (rti->UsesOverlay()) {
1904 if (ground != 0)
DrawSprite(ground + offset, PAL_NONE, x, y);
1905 }
else if (RoadTypeIsTram(rt)) {
1906 DrawSprite(SPR_TRAMWAY_OVERLAY + offset, PAL_NONE, x, y);
1924 TownID tid = INVALID_TOWN;
1927 if (town !=
nullptr) tid = town->
index;
1934static int GetSlopePixelZ_Road(
TileIndex tile, uint x, uint y,
bool)
1958static const Roadside _town_road_types[][2] = {
1966static_assert(
lengthof(_town_road_types) == HZB_END);
1968static const Roadside _town_road_types_2[][2] = {
1976static_assert(
lengthof(_town_road_types_2) == HZB_END);
1979static void TileLoop_Road(
TileIndex tile)
2004 HouseZonesBits grp = HZB_TOWN_EDGE;
2034 if (cur_rs == new_rs[0])
return;
2037 if (cur_rs == new_rs[1]) {
2057 if (old_rb != new_rb) {
2071 if (rt != GetRoadTypeRoad(tile)) {
2080static bool ClickTile_Road(
TileIndex tile)
2089static const TrackBits _road_trackbits[16] = {
2118 RoadTramType rtt = (RoadTramType)sub_mode;
2122 const uint drd_to_multiplier[
DRD_END] = { 0x101, 0x100, 0x1, 0x0 };
2140 red_signals = trackdirbits;
2172static const StringID _road_tile_strings[] = {
2173 STR_LAI_ROAD_DESCRIPTION_ROAD,
2174 STR_LAI_ROAD_DESCRIPTION_ROAD,
2175 STR_LAI_ROAD_DESCRIPTION_ROAD,
2176 STR_LAI_ROAD_DESCRIPTION_ROAD_WITH_STREETLIGHTS,
2177 STR_LAI_ROAD_DESCRIPTION_ROAD,
2178 STR_LAI_ROAD_DESCRIPTION_TREE_LINED_ROAD,
2179 STR_LAI_ROAD_DESCRIPTION_ROAD,
2180 STR_LAI_ROAD_DESCRIPTION_ROAD,
2189 RoadType road_rt = GetRoadTypeRoad(tile);
2190 RoadType tram_rt = GetRoadTypeTram(tile);
2206 td->
str = STR_LAI_ROAD_DESCRIPTION_ROAD_RAIL_LEVEL_CROSSING;
2217 td->
str = STR_LAI_ROAD_DESCRIPTION_ROAD_VEHICLE_DEPOT;
2233 bool mixed_owners = (tram_owner !=
INVALID_OWNER && tram_owner != first_owner) || (rail_owner !=
INVALID_OWNER && rail_owner != first_owner);
2238 td->
owner[0] = rail_owner;
2240 td->
owner[1] = road_owner;
2242 td->
owner[2] = tram_owner;
2245 td->
owner[0] = first_owner;
2264 if (rv->frame == RVC_DEPOT_STOP_FRAME &&
2292 RoadType rt = GetRoadTypeRoad(tile);
2298 for (RoadTramType rtt : _roadtramtypes) {
2308 for (RoadTramType rtt : _roadtramtypes) {
2311 RoadType rt = GetRoadType(tile, rtt);
2315 Company::Get(old_owner)->infrastructure.road[rt] -= num_bits;
2356 if (bits == bits_copy) {
2370 default: NOT_REACHED();
2450 RoadTramType rtt = GetRoadTramType(to_type);
2453 CommandCost error =
CommandCost((rtt == RTT_TRAM) ? STR_ERROR_NO_SUITABLE_TRAMWAY : STR_ERROR_NO_SUITABLE_ROAD);
2454 bool found_convertible_road =
false;
2456 std::unique_ptr<TileIterator> iter = std::make_unique<OrthogonalTileIterator>(area_start, area_end);
2462 RoadType from_type = GetRoadType(tile, rtt);
2473 error.
MakeError(STR_ERROR_CROSSING_DISALLOWED_ROAD);
2514 if (rtt == RTT_ROAD && owner ==
OWNER_TOWN) {
2528 found_convertible_road =
true;
2555 if (endtile < tile) {
2567 if (rtt == RTT_ROAD && owner ==
OWNER_TOWN) {
2576 found_convertible_road =
true;
2612 return found_convertible_road ? cost : error;
2619 GetSlopePixelZ_Road,
2623 GetTileTrackStatus_Road,
2627 ChangeTileOwner_Road,
Functions related to autoslope.
bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
Autoslope check for tiles with an entrance on an edge.
bool AutoslopeEnabled()
Tests if autoslope is enabled for _current_company.
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr bool HasExactlyOneBit(T value)
Test whether value has exactly 1 bit set.
#define CLRBITS(x, y)
Clears several bits in a variable.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr uint CountBits(T value)
Counts the number of set bits in a variable.
constexpr bool HasAtMostOneBit(T value)
Test whether value has at most 1 bit set.
constexpr T KillFirstBit(T value)
Clear the first bit in an integer.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
void DrawBridgeMiddle(const TileInfo *ti)
Draw the middle bits of a bridge.
TileIndex GetNorthernBridgeEnd(TileIndex t)
Finds the northern end of a bridge starting at a middle tile.
int GetBridgeHeight(TileIndex t)
Get the height ('z') of a bridge.
bool IsBridgeAbove(Tile t)
checks if a bridge is set above the ground of this tile
bool IsBridge(Tile t)
Checks if this is a bridge, instead of a tunnel.
Cheats _cheats
All the cheats.
Types related to cheating.
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?
StringID GetErrorMessage() const
Returns the error message of a command.
void MakeError(StringID message, StringID extra_message=INVALID_STRING_ID)
Makes this CommandCost behave like an error command.
This struct contains all the info that is needed to draw and construct tracks.
SpriteID single_x
single piece of rail in X direction, without ground
uint16_t max_speed
Maximum speed for vehicles travelling on this rail type.
struct RailTypeInfo::@23 base_sprites
Struct containing the main sprites.
struct RailTypeInfo::@26 strings
Strings associated with the rail type.
SpriteID crossing
level crossing, rail in X direction
SpriteID single_y
single piece of rail in Y direction, without ground
StringID name
Name of this rail type.
RoadTypeLabel label
Unique 32 bit road type identifier.
RoadTypeLabelList alternate_labels
Road type labels this type provides in addition to the main label.
RoadTypes powered_roadtypes
bitmask to the OTHER roadtypes on which a vehicle of THIS roadtype generates power
RoadTypes introduces_roadtypes
Bitmask of which other roadtypes are introduced when this roadtype is introduced.
struct RoadTypeInfo::@28 cursor
Cursors associated with the road type.
CursorID autoroad
Cursor for autorail tool.
TimerGameCalendar::Date introduction_date
Introduction date.
uint8_t sorting_order
The sorting order of this roadtype for the toolbar dropdown.
RoadTypeFlags flags
Bit mask of road type flags.
struct RoadTypeInfo::@29 strings
Strings associated with the rail type.
CursorID depot
Cursor for building a depot.
CursorID road_nwse
Cursor for building rail in Y direction.
uint16_t max_speed
Maximum speed for vehicles travelling on this road type.
StringID name
Name of this rail type.
SpriteID build_y_road
button for building single rail in Y direction
CursorID tunnel
Cursor for building a tunnel.
SpriteID auto_road
button for the autoroad construction
struct RoadTypeInfo::@27 gui_sprites
struct containing the sprites for the road GUI.
SpriteID convert_road
button for converting road types
CursorID road_swne
Cursor for building rail in X direction.
SpriteID build_x_road
button for building single rail in X direction
SpriteID build_depot
button for building depots
SpriteID build_tunnel
button for building a tunnel
static Date date
Current date in days (day counter).
static constexpr TimerGame< struct Calendar >::Date INVALID_DATE
Representation of an invalid date.
Functions related to commands.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
DoCommandFlag
List of flags for a command.
@ DC_AUTO
don't allow building on structures
@ 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.
Money GetAvailableMoneyForCommand()
This functions returns the money which can be used to execute a command.
CommandCost CheckOwnership(Owner owner, TileIndex tile)
Check whether the current owner owns something.
void SetDParamsForOwnedBy(Owner owner, TileIndex tile)
Set the right DParams for STR_ERROR_OWNED_BY.
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_DEITY
The object is owned by a superuser / goal script.
@ OWNER_NONE
The tile has no ownership.
@ OWNER_WATER
The tile/execution is done by "water".
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
@ MAX_COMPANIES
Maximum number of companies.
Some simple functions to help with accessing containers.
bool include(Container &container, typename Container::const_reference &item)
Helper function to append an item to a container if it is not already contained.
Base for all depots (except hangars)
bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
Find out if the slope of the tile is suitable to build a depot of given direction.
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.
bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
DiagDirection AxisToDiagDir(Axis a)
Converts an Axis to a DiagDirection.
Axis OtherAxis(Axis a)
Select the other axis as provided.
Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
Axis
Allow incrementing of DiagDirDiff variables.
DiagDirection
Enumeration for diagonal directions.
@ DIAGDIR_NE
Northeast, upper right on your monitor.
@ DIAGDIR_END
Used for iterations.
@ DIAGDIR_BEGIN
Used for iterations.
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
static const uint LEVELCROSSING_TRACKBIT_FACTOR
Multiplier for how many regular track bits a level crossing counts.
static const uint ROAD_STOP_TRACKBIT_FACTOR
Multiplier for how many regular track bits a bay stop counts.
static const uint ROAD_DEPOT_TRACKBIT_FACTOR
Multiplier for how many regular track bits a road depot counts.
@ EXPENSES_CONSTRUCTION
Construction costs.
static const uint TUNNELBRIDGE_TRACKBIT_FACTOR
Multiplier for how many regular track bits a tunnel/bridge counts.
EffectVehicle * CreateEffectVehicleAbove(int x, int y, int z, EffectVehicleType type)
Create an effect vehicle above a particular location.
Base class for all effect vehicles.
Functions related to effect vehicles.
@ EV_BULLDOZER
Bulldozer at roadworks.
void DrawRailCatenary(const TileInfo *ti)
Draws overhead wires and pylons for electric railways.
header file for electrified rail specific functions
bool HasRailCatenaryDrawn(RailType rt)
Test if we should draw rail catenary.
bool _generating_world
Whether we are generating the map or not.
Functions related to world/map generation.
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.
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.
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
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,...
uint ApplyFoundationToSlope(Foundation f, Slope &s)
Applies a foundation to a slope.
int GetSlopePixelZ(int x, int y, bool ground_vehicle)
Return world Z coordinate of a given point of a tile.
uint ApplyPixelFoundationToSlope(Foundation f, Slope &s)
Applies a foundation to a slope.
int GetSlopePixelZInCorner(Slope tileh, Corner corner)
Determine the Z height of a corner relative to TileZ.
Command definitions related to landscape (slopes etc.).
uint DistanceSquare(TileIndex t0, TileIndex t1)
Gets the 'Square' distance between the two given tiles.
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
TileIndex TileAddXY(TileIndex tile, int x, int y)
Adds a given offset to a tile.
TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
TileIndexDiff TileOffsByAxis(Axis axis)
Convert an Axis 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.
static debug_inline TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
GRFLoadedFeatures _loaded_newgrf_features
Indicates which are the newgrf features currently loaded ingame.
Base for the NewGRF implementation.
bool HasGrfMiscBit(GrfMiscBit bit)
Check for grf miscellaneous bits.
@ TRAMWAY_REPLACE_DEPOT_WITH_TRACK
Electrified depot graphics with tram track were loaded.
Functions/types related to NewGRF debugging.
SpriteID GetCustomRailSprite(const RailTypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
NewGRF handling of rail types.
SpriteID GetCustomRoadSprite(const RoadTypeInfo *rti, TileIndex tile, RoadTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
NewGRF handling of road types.
@ DO_FULL_DETAIL
Also draw details of track and roads.
@ RTSG_CROSSING
Level crossing overlay images.
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
bool RailNoLevelCrossings(RailType rt)
Test if a RailType disallows build of level crossings.
Command definitions for rail.
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
static debug_inline RailTileType GetRailTileType(Tile t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
TrackBits GetTrackBits(Tile tile)
Gets the track bits of the given tile.
void SetTrackReservation(Tile t, TrackBits b)
Sets the reserved track bits of the tile.
TrackBits GetRailReservationTrackBits(Tile t)
Returns the reserved track bits of the tile.
@ RAIL_TILE_NORMAL
Normal rail tile without signals.
Pseudo random number generator.
bool Chance16(const uint32_t a, const uint32_t b, const std::source_location location=std::source_location::current())
Flips a coin with given probability.
RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb)
Clean up unnecessary RoadBits of a planned tile.
bool ValParamRoadType(RoadType roadtype)
Validate functions for rail building.
bool HasPowerOnRoad(RoadType enginetype, RoadType tiletype)
Checks if an engine of the given RoadType got power on a tile with a given RoadType.
@ ROTF_HIDDEN
Bit number for hidden from construction.
@ ROTF_CATENARY
Bit number for adding catenary.
Money RoadClearCost(RoadType roadtype)
Returns the cost of clearing the specified roadtype.
@ ROTFB_NONE
All flags cleared.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
Money RoadConvertCost(RoadType from, RoadType to)
Calculates the cost of road conversion.
@ ROTSG_ONEWAY
Optional: One-way indicator images.
@ ROTSG_OVERLAY
Optional: Images for overlaying track.
@ ROTSG_GROUND
Required: Main group of ground images.
@ ROTSG_DEPOT
Optional: Depot images.
@ ROTSG_CURSORS
Optional: Cursor and toolbar icon images.
@ ROTSG_CATENARY_BACK
Optional: Catenary back.
@ ROTSG_CATENARY_FRONT
Optional: Catenary front.
bool RoadNoLevelCrossing(RoadType roadtype)
Test if road disallows level crossings.
Money RoadBuildCost(RoadType roadtype)
Returns the cost of building the specified roadtype.
void ResetRoadTypes()
Reset all road type information to its default values.
std::vector< RoadVehicle * > RoadVehicleList
Helper type for lists/vectors of road vehicles.
void InitRoadTypes()
Resolve sprites of custom road types.
RoadTypes _roadtypes_type
Bitmap of road/tram types.
CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadTramType rtt, DoCommandFlag flags, bool town_check)
Is it allowed to remove the given road bits from the given tile?
static const RoadBits _invalid_tileh_slopes_road[2][15]
Invalid RoadBits on slopes.
CommandCost CmdBuildRoadDepot(DoCommandFlag flags, TileIndex tile, RoadType rt, DiagDirection dir)
Build a road depot.
static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits pieces, RoadTramType rtt, bool town_check)
Delete a piece of road.
static Foundation GetRoadFoundation(Slope tileh, RoadBits bits)
Get the foundationtype of a RoadBits Slope combination.
static bool CanConnectToRoad(TileIndex tile, RoadType rt, DiagDirection dir)
Checks whether a road or tram connection can be found when building a new road or tram.
static CommandCost CheckRoadSlope(Slope tileh, RoadBits *pieces, RoadBits existing, RoadBits other)
Calculate the costs for roads on slopes Aside modify the RoadBits to fit on the slopes.
void DrawRoadGroundSprites(const TileInfo *ti, RoadBits road, RoadBits tram, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rti, Roadside roadside, bool snow_or_desert)
Draw road ground sprites.
CommandCost CmdBuildRoad(DoCommandFlag flags, TileIndex tile, RoadBits pieces, RoadType rt, DisallowedRoadDirections toggle_drd, TownID town_id)
Build a piece of road.
bool RoadVehiclesAreBuilt()
Verify whether a road vehicle is available.
void DrawRoadCatenary(const TileInfo *ti)
Draws the catenary for the given tile.
void UpdateNearestTownForRoadTiles(bool invalidate)
Updates cached nearest town for all road tiles.
static void DrawTile_Road(TileInfo *ti)
Tile callback function for rendering a road tile to the screen.
void DrawRoadTypeCatenary(const TileInfo *ti, RoadType rt, RoadBits rb)
Draws the catenary for the RoadType of the given tile.
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
Draw the road depot sprite.
void UpdateCompanyRoadInfrastructure(RoadType rt, Owner o, int count)
Update road infrastructure counts for a company.
static SpriteID GetRoadGroundSprite(const TileInfo *ti, Roadside roadside, const RoadTypeInfo *rti, uint offset, bool snow_or_desert, PaletteID *pal)
Get ground sprite to draw for a road tile.
std::tuple< CommandCost, Money > CmdRemoveLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, bool start_half, bool end_half)
Remove a long piece of road.
CommandCost CmdBuildLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, DisallowedRoadDirections drd, bool start_half, bool end_half, bool is_ai)
Build a long piece of road.
static bool CanConvertUnownedRoadType(Owner owner, RoadTramType rtt)
Checks the tile and returns whether the current player is allowed to convert the roadtype to another ...
static void DrawRoadBits(TileInfo *ti)
Draw ground sprite and road pieces.
static void DrawRoadDetail(SpriteID img, const TileInfo *ti, int dx, int dy, int h, bool transparent)
Draws details on/around the road.
static bool DrawRoadAsSnowDesert(bool snow_or_desert, Roadside roadside)
Should the road be drawn as a unpaved snow/desert road? By default, roads are always drawn as unpaved...
const TileTypeProcs _tile_type_road_procs
Tile callback functions for road tiles.
CommandCost CmdConvertRoad(DoCommandFlag flags, TileIndex tile, TileIndex area_start, RoadType to_type)
Convert one road subtype to another.
static const uint8_t _roadveh_enter_depot_dir[4]
Given the direction the road depot is pointing, this is the direction the vehicle should be travellin...
RoadType AllocateRoadType(RoadTypeLabel label, RoadTramType rtt)
Allocate a new road type label.
static Vehicle * UpdateRoadVehPowerProc(Vehicle *v, void *data)
Update power of road vehicle under which is the roadtype being converted.
static uint GetRoadSpriteOffset(Slope slope, RoadBits bits)
Get the sprite offset within a spritegroup.
static void ConvertRoadTypeOwner(TileIndex tile, uint num_pieces, Owner owner, RoadType from_type, RoadType to_type)
Convert the ownership of the RoadType of the tile if applicable.
static bool CompareRoadTypes(const RoadType &first, const RoadType &second)
Compare roadtypes based on their sorting order.
void DrawRoadOverlays(const TileInfo *ti, PaletteID pal, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rti, uint road_offset, uint tram_offset, bool draw_underlay)
Draw road underlay and overlay sprites.
Functions related to roads.
RoadBits AxisToRoadBits(Axis a)
Create the road-part which belongs to the given Axis.
bool IsValidRoadBits(RoadBits r)
Whether the given roadtype is valid.
bool HasRoadCatenaryDrawn(RoadType roadtype)
Test if we should draw road catenary.
void UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(TileIndex tile, Axis road_axis)
Update adjacent level crossing tiles in this multi-track crossing, due to removal of a level crossing...
bool HasRoadCatenary(RoadType roadtype)
Test if a road type has catenary.
bool IsStraightRoad(RoadBits r)
Check if we've got a straight road.
RoadBits MirrorRoadBits(RoadBits r)
Calculate the mirrored RoadBits.
void MarkDirtyAdjacentLevelCrossingTiles(TileIndex tile, Axis road_axis)
Find adjacent level crossing tiles in this multi-track crossing and mark them dirty.
RoadBits DiagDirToRoadBits(DiagDirection d)
Create the road-part which belongs to the given DiagDirection.
void UpdateLevelCrossing(TileIndex tile, bool sound=true, bool force_bar=false)
Update a level crossing to barred or open (crossing may include multiple adjacent tiles).
RoadBits ComplementRoadBits(RoadBits r)
Calculate the complement of a RoadBits value.
Functions used internally by the roads.
Sprite constructs for road depots.
RoadBits GetAnyRoadBits(Tile tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance)
Returns the RoadBits on an arbitrary tile Special behaviour:
void SetRoadOwner(Tile t, RoadTramType rtt, Owner o)
Set the owner of a specific road type.
bool HasCrossingReservation(Tile t)
Get the reservation state of the rail crossing.
bool HasTownOwnedRoad(Tile t)
Checks if given tile has town owned road.
static debug_inline bool IsNormalRoadTile(Tile t)
Return whether a tile is a normal road tile.
static debug_inline bool IsRoadDepot(Tile t)
Return whether a tile is a road depot.
#define IsOnDesert
Check if a road tile has snow/desert.
void SetRoadDepotExitDirection(Tile tile, DiagDirection dir)
Sets the exit direction of a road depot.
bool IsLevelCrossingTile(Tile t)
Return whether a tile is a level crossing tile.
bool IncreaseRoadWorksCounter(Tile t)
Increase the progress counter of road works.
RoadBits GetRoadBits(Tile t, RoadTramType rtt)
Get the present road bits for a specific road type.
RoadTileType
The different types of road tiles.
@ ROAD_TILE_NORMAL
Normal road.
@ ROAD_TILE_DEPOT
Depot (one entrance)
@ ROAD_TILE_CROSSING
Level crossing.
bool MayHaveRoad(Tile t)
Test whether a tile can have road/tram types.
bool IsValidDisallowedRoadDirections(DisallowedRoadDirections drt)
Checks if a DisallowedRoadDirections is valid.
Axis GetCrossingRoadAxis(Tile t)
Get the road axis of a level crossing.
TrackBits GetCrossingRailBits(Tile tile)
Get the rail track bits of a level crossing.
void SetDisallowedRoadDirections(Tile t, DisallowedRoadDirections drd)
Sets the disallowed directions.
Track GetCrossingRailTrack(Tile tile)
Get the rail track of a level crossing.
void StartRoadWorks(Tile t)
Start road works on a tile.
DisallowedRoadDirections GetDisallowedRoadDirections(Tile t)
Gets the disallowed directions.
bool HasTileRoadType(Tile t, RoadTramType rtt)
Check if a tile has a road or a tram road type.
DiagDirection GetRoadDepotDirection(Tile t)
Get the direction of the exit of a road depot.
#define ToggleDesert
Toggle the snow/desert state of a road tile.
static debug_inline bool IsRoadDepotTile(Tile t)
Return whether a tile is a road depot tile.
void MakeRoadCrossing(Tile t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadType road_rt, RoadType tram_rt, uint town)
Make a level crossing.
void MakeRoadNormal(Tile t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
Make a normal road tile.
Roadside GetRoadside(Tile tile)
Get the decorations of a road.
RoadBits GetAllRoadBits(Tile tile)
Get all set RoadBits on the given tile.
void ToggleSnow(Tile t)
Toggle the snow/desert state of a road tile.
bool IsOnSnow(Tile t)
Check if a road tile has snow/desert.
Axis GetCrossingRailAxis(Tile t)
Get the rail axis of a level crossing.
void TerminateRoadWorks(Tile t)
Terminate road works on a tile.
RoadBits GetCrossingRoadBits(Tile tile)
Get the road bits of a level crossing.
void SetRoadType(Tile t, RoadTramType rtt, RoadType rt)
Set the road type of a tile.
Owner GetRoadOwner(Tile t, RoadTramType rtt)
Get the owner of a specific road type.
static debug_inline RoadTileType GetRoadTileType(Tile t)
Get the type of the road tile.
bool IsCrossingBarred(Tile t)
Check if the level crossing is barred.
void SetRoadside(Tile tile, Roadside s)
Set the decorations of a road.
bool IsRoadOwner(Tile t, RoadTramType rtt, Owner o)
Check if a specific road type is owned by an owner.
void MakeRoadDepot(Tile tile, Owner owner, DepotID depot_id, DiagDirection dir, RoadType rt)
Make a road depot.
void SetCrossingReservation(Tile t, bool b)
Set the reservation state of the rail crossing.
void SetRoadBits(Tile t, RoadBits r, RoadTramType rtt)
Set the present road bits for a specific road type.
Roadside
The possible road side decorations.
@ ROADSIDE_GRASS_ROAD_WORKS
Road on grass with road works.
@ ROADSIDE_PAVED
Road with paved sidewalks.
@ ROADSIDE_STREET_LIGHTS
Road with street lights on paved sidewalks.
@ ROADSIDE_BARREN
Road on barren land.
@ ROADSIDE_GRASS
Road on grass.
@ ROADSIDE_TREES
Road with trees on paved sidewalks.
bool IsLevelCrossing(Tile t)
Return whether a tile is a level crossing.
bool HasRoadWorks(Tile t)
Check if a tile has road works.
static debug_inline bool IsNormalRoad(Tile t)
Return whether a tile is a normal road.
RoadBits
Enumeration for the road parts on a tile.
@ ROAD_SW
South-west part.
@ ROAD_ALL
Full 4-way crossing.
@ ROAD_NONE
No road-part is build.
@ ROAD_NE
North-east part.
@ ROAD_SE
South-east part.
@ ROAD_Y
Full road along the y-axis (north-west + south-east)
@ ROAD_NW
North-west part.
@ ROAD_X
Full road along the x-axis (south-west + north-east)
RoadTypes
The different roadtypes we support, but then a bitmask of them.
@ ROADTYPES_NONE
No roadtypes.
RoadType
The different roadtypes we support.
@ INVALID_ROADTYPE
flag for invalid roadtype
@ ROADTYPE_ROAD
Basic road type.
@ ROADTYPE_END
Used for iterations.
@ ROADTYPE_BEGIN
Used for iterations.
DisallowedRoadDirections
Which directions are disallowed ?
@ DRD_NORTHBOUND
All northbound traffic is disallowed.
@ DRD_BOTH
All directions are disallowed.
@ DRD_NONE
None of the directions are disallowed.
@ DRD_SOUTHBOUND
All southbound traffic is disallowed.
All the roadtype-specific information is stored here.
static const RoadTypeInfo _original_roadtypes[]
Global Roadtype definition.
@ RVSB_IN_DEPOT
The vehicle is in a depot.
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 constexpr int GetSlopeMaxZ(Slope s)
Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
bool IsSlopeWithOneCornerRaised(Slope s)
Tests if a specific slope has exactly one corner raised.
uint SlopeToSpriteOffset(Slope s)
Returns the Sprite offset for a given Slope.
Corner GetHighestSlopeCorner(Slope s)
Returns the highest corner of a slope (one corner raised or a steep slope).
static constexpr bool IsSteepSlope(Slope s)
Checks if a slope is steep.
Foundation FlatteningFoundation(Slope s)
Returns the foundation needed to flatten a slope.
Slope SlopeWithOneCornerRaised(Corner corner)
Returns the slope with a specific corner raised.
Slope
Enumeration for the slope-type.
@ SLOPE_ELEVATED
bit mask containing all 'simple' slopes
@ 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
Foundation
Enumeration for Foundations.
@ FOUNDATION_LEVELED
The tile is leveled up to a flat slope.
@ FOUNDATION_NONE
The tile has no foundation, the slope remains unchanged.
@ FOUNDATION_INCLINED_X
The tile has an along X-axis inclined foundation.
@ FOUNDATION_INCLINED_Y
The tile has an along Y-axis inclined foundation.
static const uint32_t VALID_LEVEL_CROSSING_SLOPES
Constant bitset with safe slopes for building a level crossing.
Functions related to sound.
@ SND_21_ROAD_WORKS
31 == 0x1F Road reconstruction animation
void DrawRailTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32_t total_offset, uint32_t newgrf_offset, PaletteID default_palette)
Draw tile sprite sequence in GUI with railroad specifics.
void DrawRailTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32_t total_offset, uint32_t newgrf_offset, PaletteID default_palette)
Draw tile sprite sequence on tile with railroad specifics.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
static const SpriteID SPR_TRAMWAY_BASE
Tramway sprites.
static const PaletteID PALETTE_TO_BARE_LAND
sets colour to bare land stuff for rail, road and crossings
static const SpriteID SPR_ONEWAY_BASE
One way road sprites.
bool IsBayRoadStopTile(Tile t)
Is tile t a bay (non-drive through) road stop station?
bool IsDriveThroughStopTile(Tile t)
Is tile t a drive through road stop station or waypoint?
bool IsAnyRoadStop(Tile t)
Is the station at t a road station?
Axis GetDriveThroughStopAxis(Tile t)
Gets the axis of the drive through stop.
DiagDirection GetBayRoadStopDir(Tile t)
Gets the direction the bay road stop entrance points towards.
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
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.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
VehicleType type
Type of vehicle.
bool value
tells if the bool cheat is active or not
Cheat magic_bulldozer
dynamite industries, objects
SoundSettings sound
sound effect settings
GUISettings gui
settings related to the GUI
std::array< uint32_t, ROADTYPE_END > road
Count of company owned track bits for each road type.
std::array< uint32_t, RAILTYPE_END > rail
Count of company owned track bits for each rail type.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
bool build_on_slopes
allow building on slopes
bool extra_dynamite
extra dynamite
bool crossing_with_competitor
allow building of level crossings with competitor roads or rails
TimerGameCalendar::Date build_date
Date of construction.
Ground palette sprite of a tile, together with its sprite layout.
PalSpriteID ground
Palette and sprite for the ground.
bool mod_road_rebuild
roadworks remove unnecessary RoadBits
uint8_t dist_local_authority
distance for town local authority, default 20
A special vehicle is one of the following:
TramReplacement tram
In which way tram depots were replaced.
bool show_track_reservation
highlight reserved tracks.
uint8_t landscape
the landscape we're currently in
EconomySettings economy
settings to change the economy
ConstructionSettings construction
construction of things in-game
GameCreationSettings game_creation
settings used during the creation of a game (map)
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
static debug_inline uint Size()
Get the size of the map.
Represents the covered area of e.g.
SpriteID sprite
The 'real' sprite.
Tindex index
Index of this pool item.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
static Titem * Get(size_t index)
Returns Titem with given index.
Buses, trucks and trams belong to this class.
bool ambient
Play ambient, industry and town sounds.
T * Next() const
Get next vehicle in the chain.
static Pool::IterateWrapper< T > Iterate(size_t from=0)
Returns an iterable ensemble of all valid vehicles of type T.
static T * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
T * First() const
Get the first vehicle in the chain.
Used to only draw a part of the sprite.
Tile description for the 'land area information' tool.
uint16_t rail_speed
Speed limit of rail (bridges and track)
StringID str
Description of the tile.
TimerGameCalendar::Date build_date
Date of construction of tile contents.
uint16_t tram_speed
Speed limit of tram (bridges and track)
StringID roadtype
Type of road on the tile.
StringID tramtype
Type of tram on the tile.
StringID railtype
Type of rail on the tile.
uint16_t road_speed
Speed limit of road (bridges and track)
Owner owner[4]
Name of the owner(s)
StringID owner_type[4]
Type of each owner.
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.
std::array< uint32_t, HZB_END > squared_town_zone_radius
UpdateTownRadius updates this given the house count.
TileIndex xy
town center tile
TownCache cache
Container for all cacheable data.
uint8_t road_build_months
fund road reconstruction in action?
Direction direction
facing
TileIndex tile
Current tile index.
VehicleEnterTileStatus
The returned bits of VehicleEnterTile.
@ VETSB_ENTERED_WORMHOLE
The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/...
@ VETSB_CONTINUE
Bit sets of the above specified bits.
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.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
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.
int GetTileMaxPixelZ(TileIndex tile)
Get top height of the tile.
static debug_inline TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
std::tuple< Slope, int > GetTilePixelSlope(TileIndex tile)
Return the slope of a given tile.
bool IsValidTile(Tile tile)
Checks if a tile is valid.
TropicZone GetTropicZone(Tile tile)
Get the tropic zone.
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.
@ TROPICZONE_DESERT
Tile is desert.
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in ZOOM_BASE.
static const uint TILE_SIZE
Tile size in world coordinates.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
TileType
The different types of tiles.
@ MP_ROAD
A tile with road (or tram tracks)
@ MP_STATION
A tile of a station.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
Definition of the game-calendar-timer.
HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
@ ROAD_REMOVE
Removal of a road owned by the town.
@ TUNNELBRIDGE_REMOVE
Removal of a tunnel or bridge owned by the towb.
void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
Changes town rating of the current company.
RoadType GetTownRoadType()
Get the road type that towns should build at this current moment.
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
CommandCost CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType type)
Does the town authority allow the (destructive) action of the current company?
void MakeDefaultName(T *obj)
Set the default name for a depot/waypoint.
void SetTownIndex(Tile t, TownID index)
Set the town index for a road or house tile.
static constexpr int RATING_ROAD_DOWN_STEP_EDGE
removing a roadpiece at the edge
static constexpr int RATING_ROAD_DOWN_STEP_INNER
removing a roadpiece in the middle
static constexpr int RATING_ROAD_MINIMUM
minimum rating after removing town owned road
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.
Track AxisToTrack(Axis a)
Convert an Axis to the corresponding Track AXIS_X -> TRACK_X AXIS_Y -> TRACK_Y Uses the fact that the...
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_X_NE
X-axis and direction to north-east.
@ TRACKDIR_Y_SE
Y-axis and direction to south-east.
@ TRACKDIR_X_SW
X-axis and direction to south-west.
@ TRACKDIR_Y_NW
Y-axis and direction to north-west.
TrackdirBits
Allow incrementing of Trackdir variables.
@ TRACKDIR_BIT_Y_NW
Track y-axis, direction north-west.
@ TRACKDIR_BIT_X_NE
Track x-axis, direction north-east.
@ TRACKDIR_BIT_Y_SE
Track y-axis, direction south-east.
@ TRACKDIR_BIT_NONE
No track build.
@ TRACKDIR_BIT_X_SW
Track x-axis, direction south-west.
Track
These are used to specify a single track.
Base for the train class.
bool TrainOnCrossing(TileIndex tile)
Check if a level crossing tile has a train on it.
@ TO_BUILDINGS
company buildings - depots, stations, HQ, ...
@ TO_HOUSES
town buildings
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...
uint8_t _display_opt
What do we want to draw/do?
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_RAIL
Transport by train.
@ TRANSPORT_ROAD
Transport by road vehicle.
Header file for things common for tunnels and bridges.
void SetTunnelBridgeOwner(TileIndex begin, TileIndex end, Owner owner)
Sets the ownership of the bridge/tunnel ramps.
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height)
Mark bridge tiles dirty.
uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
Calculates the length of a tunnel or a bridge (without end tiles)
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...
TileIndex GetOtherTunnelBridgeEnd(Tile t)
Determines type of the wormhole and returns its other end.
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
void VehicleEnterDepot(Vehicle *v)
Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it,...
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
CommandCost TunnelBridgeIsFree(TileIndex tile, TileIndex endtile, const Vehicle *ignore)
Finds vehicle in tunnel / bridge.
@ VS_HIDDEN
Vehicle is not visible.
Functions related to vehicles.
@ VEH_ROAD
Road 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 DrawGroundSpriteAt(SpriteID image, PaletteID pal, int32_t x, int32_t y, int z, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
Draws a ground sprite at a specific world-coordinate relative to the current 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.
Functions related to (drawing on) viewports.
static const uint BB_HEIGHT_UNDER_BRIDGE
Some values for constructing bounding boxes (BB).
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
@ WC_VEHICLE_DEPOT
Depot view; Window numbers:
@ WC_BUILD_VEHICLE
Build vehicle; Window numbers:
Entry point for OpenTTD to YAPF's cache.
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track)
Use this function to notify YAPF that track layout (or signal configuration) has change.
@ ZOOM_LVL_DETAIL
All zoom levels below or equal to this will result in details on the screen, like road-work,...