47#include "table/strings.h"
79 if (cursors_base != 0) {
103 if (RoadTypeIsRoad(first) == RoadTypeIsRoad(second)) {
106 return RoadTypeIsTram(first) < RoadTypeIsTram(second);
118 ResolveRoadTypeGUISprites(&rti);
189 if (c ==
nullptr)
return;
284 if (ret.
Failed())
return ret;
297 if (n.
Count() > 1 && n.
Any(remove)) {
321 assert(pieces.
Any());
330 if (ret.
Failed())
return ret;
338 if (ret.
Failed())
return ret;
345 if (ret.
Failed())
return ret;
354 if (ret.
Failed())
return ret;
378 Owner other_owner =
GetRoadOwner(tile, OtherRoadTramType(rtt));
433 present.
Flip(pieces);
454 if (present.
None()) {
463 SetTownIndex(tile, town ==
nullptr ? TownID::Invalid() : town->index);
541 pieces->
Reset(existing);
555 RoadBits type_bits = existing | *pieces;
568 type_bits = existing | *pieces;
616 town_id = (town !=
nullptr) ? town->index : TownID::Invalid();
635 bool need_to_clear =
false;
642 other_bits =
GetRoadBits(tile, OtherRoadTramType(rtt));
649 return CommandCost(STR_ERROR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION);
651 if (existing.
All(pieces)) {
657 if (ret.
Failed())
return ret;
667 if (dis_existing.
Count() <= dis_new.
Count()) {
669 if (ret.
Failed())
return ret;
687 if (ret.
Failed())
return ret;
695 return CommandCost(STR_ERROR_CROSSING_DISALLOWED_ROAD);
709 default: NOT_REACHED();
715 return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
720 return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
725 if (ret.
Failed())
return ret;
731 return CommandCost(STR_ERROR_CROSSING_DISALLOWED_ROAD);
735 return CommandCost(STR_ERROR_CROSSING_DISALLOWED_RAIL);
750 default:
goto do_clear;
754 if (ret.
Failed())
return ret;
800 if (ret.
Failed())
return ret;
806 need_to_clear =
true;
812 CommandCost ret = Command<Commands::LandscapeClear>::Do(flags, tile);
813 if (ret.
Failed())
return ret;
817 if (other_bits != pieces) {
823 return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
828 if (!need_to_clear) {
831 pieces.
Reset(existing);
841 return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
847 if (ret.
Failed())
return ret;
858 ret = Command<Commands::ConvertRoad>::Do(flags, tile, tile, rt,
false);
859 if (ret.
Failed())
return ret;
924 existing.
Set(pieces);
983 if (start_tile > end_tile || (start_tile == end_tile && start_half)) {
985 start_half = !start_half;
986 end_half = !end_half;
998 bool had_bridge =
false;
999 bool had_tunnel =
false;
1000 bool had_success =
false;
1007 if (!is_ai && start_tile != end_tile) {
1020 CommandCost ret = Command<Commands::BuildRoad>::Do(flags, tile, bits, rt, drd, TownID::Invalid());
1021 if (!is_ai && ret.
GetErrorMessage() == STR_ERROR_ALREADY_BUILT) had_success =
true;
1023 last_error = std::move(ret);
1025 if (is_ai)
return last_error;
1026 if (had_success)
break;
1048 if (tile == end_tile)
break;
1053 return had_success ? cost : last_error;
1079 if (start_tile > end_tile || (start_tile == end_tile && start_half)) {
1080 std::swap(start_tile, end_tile);
1081 std::swap(start_half, end_half);
1085 Money money_spent = 0;
1088 bool had_success =
false;
1103 if (money_spent > 0 && money_spent > money_available) {
1113 case STR_ERROR_OWNED_BY.base():
1114 case STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS.base():
1117 last_error = std::move(ret);
1122 if (tile == end_tile)
break;
1127 return { had_success ? cost : last_error, 0 };
1152 bool rotate_existing_depot =
false;
1156 if (ret.
Failed())
return ret;
1161 if (ret.
Failed())
return ret;
1163 rotate_existing_depot =
true;
1166 if (!rotate_existing_depot) {
1167 cost.
AddCost(Command<Commands::LandscapeClear>::Do(flags, tile));
1168 if (cost.
Failed())
return cost;
1179 if (rotate_existing_depot) {
1201 if (ret.
Failed())
return ret;
1205 if (ret.
Failed())
return ret;
1217 delete Depot::GetByTile(tile);
1218 DoClearSquare(tile);
1238 if (tmp_ret.
Failed())
return tmp_ret;
1243 return CommandCost(STR_ERROR_MUST_REMOVE_ROAD_FIRST);
1257 if (tmp_ret.
Failed())
return tmp_ret;
1262 Command<Commands::LandscapeClear>::Do(flags, tile);
1270 return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
1272 return RemoveRoadDepot(tile, flags);
1337 default: NOT_REACHED();
1340 static const uint offsets[] = {
1346 return offsets[bits.
base()];
1361 return (snow_or_desert &&
1381 if (rb.
Count() > 2) {
1399 if (rb_new.
Count() >= 2) rb = rb_new;
1406 if (front != 0 || back != 0) {
1426 static const int INF = 1000;
1433 AddSortableSpriteToDraw(back, pal, *ti, {{15, 0, west_z}, {1, 1, z_wires}, {-15, 0,
static_cast<int8_t
>(-west_z)}},
IsTransparencySet(
TransparencyOption::Catenary), &west);
1434 AddSortableSpriteToDraw(back, pal, *ti, {{0, 0, north_z}, {1, 1, z_wires}, {0, 0,
static_cast<int8_t
>(-north_z)}},
IsTransparencySet(
TransparencyOption::Catenary), &north);
1435 AddSortableSpriteToDraw(back, pal, *ti, {{0, 15, east_z}, {1, 1, z_wires}, {0, -15,
static_cast<int8_t
>(-east_z)}},
IsTransparencySet(
TransparencyOption::Catenary), &east);
1439 AddSortableSpriteToDraw(front, pal, *ti, {{0, 0,
static_cast<int8_t
>(z_wires)}, {
TILE_SIZE,
TILE_SIZE, 1}, {0, 0,
static_cast<int8_t
>(-z_wires)}},
IsTransparencySet(
TransparencyOption::Catenary));
1499 AddSortableSpriteToDraw(img, PAL_NONE, ti->
x, ti->
y, z, {{dx, dy, 0}, {2, 2, h}, {}}, transparent);
1514 if (draw_underlay) {
1516 if (road_rti !=
nullptr) {
1517 if (road_rti->UsesOverlay()) {
1522 if (tram_rti->UsesOverlay()) {
1532 if (road_rti !=
nullptr) {
1533 if (road_rti->UsesOverlay()) {
1540 if (tram_rti !=
nullptr) {
1541 if (tram_rti->UsesOverlay()) {
1544 }
else if (road_rti !=
nullptr) {
1563 if (rti ==
nullptr || rti->UsesOverlay()) {
1651 if (road_rti !=
nullptr) {
1688 if (height < minz)
return;
1692 if (road.
Count() <= 1)
return;
1699 bool is_transparent =
false;
1701 is_transparent =
true;
1704 is_transparent =
true;
1709 DrawRoadDetail(drts->image, ti, drts->subcoord_x, drts->subcoord_y, 0x10, is_transparent);
1745 if (rti->UsesOverlay()) {
1796 if (rti->UsesOverlay()) {
1806 adjacent_diagdirs.
Set(dir);
1810 switch (adjacent_diagdirs.
base()) {
1835 }
else if (draw_pbs || tram_rti !=
nullptr || road_rti->UsesOverlay()) {
1862 bool default_gfx = relocation == 0;
1868 default_gfx =
false;
1884 if (rti->UsesOverlay()) {
1893 blocked_pillars = BRIDGEPILLARFLAGS_ALL;
1913 bool default_gfx = relocation == 0;
1919 default_gfx =
false;
1934 if (rti->UsesOverlay()) {
1936 if (ground != 0)
DrawSprite(ground + offset, PAL_NONE, x, y);
1937 }
else if (RoadTypeIsTram(rt)) {
1959 TownID tid = TownID::Invalid();
1962 if (town !=
nullptr) tid = town->index;
1998static const Roadside _town_road_types[][2] = {
2006static_assert(
lengthof(_town_road_types) == NUM_HOUSE_ZONES);
2008static const Roadside _town_road_types_2[][2] = {
2016static_assert(
lengthof(_town_road_types_2) == NUM_HOUSE_ZONES);
2078 if (cur_rs == new_rs[0])
return;
2081 if (cur_rs == new_rs[1]) {
2101 if (old_rb != new_rb) {
2105 if (new_rb.
None()) {
2168 const uint drd_to_multiplier[] = { 0x101, 0x100, 0x1, 0x0 };
2186 red_signals = trackdirbits;
2215 return {trackdirbits, red_signals};
2218static const StringID _road_tile_strings[] = {
2219 STR_LAI_ROAD_DESCRIPTION_ROAD,
2220 STR_LAI_ROAD_DESCRIPTION_ROAD,
2221 STR_LAI_ROAD_DESCRIPTION_ROAD,
2222 STR_LAI_ROAD_DESCRIPTION_ROAD_WITH_STREETLIGHTS,
2223 STR_LAI_ROAD_DESCRIPTION_ROAD,
2224 STR_LAI_ROAD_DESCRIPTION_TREE_LINED_ROAD,
2225 STR_LAI_ROAD_DESCRIPTION_ROAD,
2226 STR_LAI_ROAD_DESCRIPTION_ROAD,
2253 td.
str = STR_LAI_ROAD_DESCRIPTION_ROAD_RAIL_LEVEL_CROSSING;
2264 td.
str = STR_LAI_ROAD_DESCRIPTION_ROAD_VEHICLE_DEPOT;
2265 td.
build_date = Depot::GetByTile(tile)->build_date;
2279 Owner first_owner = (road_owner ==
INVALID_OWNER ? tram_owner : road_owner);
2280 bool mixed_owners = (tram_owner !=
INVALID_OWNER && tram_owner != first_owner) || (rail_owner !=
INVALID_OWNER && rail_owner != first_owner);
2285 td.
owner[0] = rail_owner;
2287 td.
owner[1] = road_owner;
2289 td.
owner[2] = tram_owner;
2292 td.
owner[0] = first_owner;
2312 if (rv->frame == RVC_DEPOT_STOP_FRAME &&
2364 Company::Get(old_owner)->infrastructure.road[rt] -= num_bits;
2406 if (bits == bits_copy) {
2420 default: NOT_REACHED();
2424 return Command<Commands::LandscapeClear>::Do(flags, tile);
2452 if (owner >= MAX_COMPANIES && owner !=
OWNER_NONE)
return;
2456 switch (owner.base()) {
2494 bool found_convertible_road =
false;
2513 error.
MakeError(STR_ERROR_CROSSING_DISALLOWED_ROAD);
2528 error = std::move(ret);
2539 error = std::move(ret);
2550 error = std::move(ret);
2571 found_convertible_road =
true;
2600 if (endtile < cur_tile) {
2601 if (tilearea.Contains(endtile))
continue;
2608 error = std::move(ret);
2624 found_convertible_road =
true;
2664 return found_convertible_road ? cost : error;
@ None
Tile is not animated.
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.
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
void DrawBridgeMiddle(const TileInfo *ti, BridgePillarFlags blocked_pillars)
Draw the middle bits of a bridge.
TileIndex GetSouthernBridgeEnd(TileIndex t)
Finds the southern end of a bridge starting at a middle tile.
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.
EnumBitSet< BridgePillarFlag, uint8_t > BridgePillarFlags
Bitset of BridgePillarFlag elements.
@ EdgeNE
Northeast edge is obstructed.
@ EdgeSW
Southwest edge is obstructed.
@ EdgeNW
Northwest edge is obstructed.
@ EdgeSE
Southeast edge is obstructed.
Cheats _cheats
All the cheats.
Types related to cheating.
uint Count() const
Count the number of set bits.
constexpr bool All(const Timpl &other) const
Test if all of the values are set.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr Tstorage base() const noexcept
Retrieve the raw value behind this bit set.
constexpr bool None() const
Test if none of the values are set.
constexpr Timpl & Flip()
Flip all bits.
constexpr Timpl & Reset()
Reset all bits.
constexpr Timpl & Set()
Set all bits.
constexpr bool Any(const Timpl &other) const
Test if any of the given values are set.
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.
void MakeError(StringID message)
Makes this CommandCost behave like an error command.
Money GetCost() const
The costs as made up to this moment.
void SetEncodedMessage(EncodedString &&message)
Set the encoded message string.
bool Failed() const
Did this command fail?
StringID GetErrorMessage() const
Returns the error message of a command.
Iterate a range of enum values.
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::@157247141350136173143103254227157213063052244122 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.
struct RailTypeInfo::@332027037331076264023214171276243307073252216167 base_sprites
Struct containing the main sprites.
RoadTypeLabel label
Unique 32 bit road type identifier.
struct RoadTypeInfo::@040007041145073342004320043002073006000034160103 gui_sprites
struct containing the sprites for the road GUI.
RoadTypes powered_roadtypes
bitmask to the OTHER roadtypes on which a vehicle of THIS roadtype generates power
struct RoadTypeInfo::@262365004142063215107272155332373126354130071373 cursor
Cursors associated with the road type.
RoadTypes introduces_roadtypes
Bitmask of which other roadtypes are introduced when this roadtype is introduced.
RoadType Index() const
Get the RoadType for this RoadTypeInfo.
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.
FlatSet< RoadTypeLabel > alternate_labels
Road type labels this type provides in addition to the main label.
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.
struct RoadTypeInfo::@070000167274302256150317022075324310363002361255 strings
Strings associated with the rail 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
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 constexpr TimerGame< struct Calendar >::Date INVALID_DATE
Iterate over all vehicles on a tile.
CommandCost CommandCostWithParam(StringID str, uint64_t value)
Return an error status, with string and parameter.
Functions related to commands.
CommandCost & ExtractCommandCost(Tret &ret)
Extract the CommandCost from a command proc result.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
@ Auto
don't allow building on structures
@ NoWater
don't allow building on water
@ Execute
execute the given command
@ Bankrupt
company bankrupts, skip money check, skip vehicle on tile check in some cases
EnumBitSet< DoCommandFlag, uint16_t > DoCommandFlags
Bitset of DoCommandFlag elements.
Definition of stuff that is very close to a company, like the company struct itself.
std::array< StringParameter, 2 > GetParamsForOwnedBy(Owner owner, TileIndex tile)
Get the right StringParameters for STR_ERROR_OWNED_BY.
CommandCost CheckTileOwnership(TileIndex tile)
Check whether the current owner owns the stuff on the given tile.
PaletteID GetCompanyPalette(CompanyID company)
Get the palette for recolouring with a company colour.
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.
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.
bool IsLocalCompany()
Is the current company the local company?
void DirtyCompanyInfrastructureWindows(CompanyID company)
Redraw all windows with company infrastructure counts.
GUI Functions related to companies.
static constexpr Owner OWNER_DEITY
The object is owned by a superuser / goal script.
static constexpr Owner OWNER_TOWN
A town owns the tile, or a town is expanding.
static constexpr Owner OWNER_NONE
The tile has no ownership.
static constexpr Owner INVALID_OWNER
An invalid owner.
static constexpr Owner OWNER_WATER
The tile/execution is done by "water".
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.
static constexpr uint8_t MINIMAL_DEPOT_BRIDGE_HEIGHT
Minimal height for a bridge above any depot tile.
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.
DiagDirections AxisToDiagDirs(Axis a)
Converts an Axis to DiagDirections.
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.
EnumIndexArray< T, DiagDirection, DiagDirection::End > DiagDirectionIndexArray
Array with DiagDirection as index.
Axis
Enumeration for the two axis X and Y.
DiagDirection
Enumeration for diagonal directions.
@ Invalid
Flag for an invalid DiagDirection.
@ End
Used for iterations.
@ NE
Northeast, upper right on your monitor.
EnumBitSet< DiagDirection, uint8_t > DiagDirections
Bitset of DiagDirection elements.
Prices _price
Prices and also the fractional part.
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.
@ Construction
Construction costs.
static const uint TUNNELBRIDGE_TRACKBIT_FACTOR
Multiplier for how many regular track bits a tunnel/bridge counts.
@ ClearDepotRoad
Price for destroying road vehicle depots.
@ BuildFoundation
Price for building foundation under other constructions e.g. roads, rails, depots,...
@ BuildDepotRoad
Price for building road vehicle depots.
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.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23).
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.
HouseZone
Concentric rings of zoning around the centre of a town.
@ TownEdge
Edge of the town; roads without pavement.
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,...
const TileTypeProcs _tile_type_road_procs
TileTypeProcs definitions for TileType::Road tiles.
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.).
@ Arctic
Landscape with snow levels.
@ Toyland
Landscape with funky industries and vehicles.
@ Tropic
Landscape with distinct rainforests and deserts,.
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.
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
TileIndexDiff TileOffsByAxis(Axis axis)
Convert an Axis to a TileIndexDiff.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
static uint TileX(TileIndex tile)
Get the X component of a tile.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
@ First
The first client ID.
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.
@ WithTrack
Electrified depot graphics with tram track were loaded.
@ DesertPavedRoads
Show pavement and lights in desert towns.
SpriteID GetCustomRailSprite(const RailTypeInfo *rti, TileIndex tile, RailSpriteType 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, RoadSpriteType rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
NewGRF handling of road types.
@ All
Match if all bits are triggered.
@ FullDetail
Also draw details of track and roads.
@ Editor
In the scenario editor.
@ 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.
static const int INF
Big number compared to tilesprite size.
Command definitions for rail.
static RailTileType GetRailTileType(Tile t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
TrackBits GetTrackBits(Tile tile)
Gets the track bits of the given tile.
void MakeRailNormal(Tile t, Owner o, TrackBits b, RailType r)
Make the given tile a normal rail.
@ Normal
Normal rail tile without signals.
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.
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.
@ Catenary
Bit number for adding catenary.
@ Hidden
Bit number for hidden from construction.
RoadTypes _roadtypes_hidden_mask
Bitset of hidden roadtypes.
Money RoadClearCost(RoadType roadtype)
Returns the cost of clearing the specified roadtype.
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.
@ Ground
Required: Main group of ground images.
@ CatenaryFront
Optional: Catenary front.
@ Overlay
Optional: Images for overlaying track.
@ UI
Optional: Cursor and toolbar icon images.
@ CatenaryRear
Optional: Catenary back.
@ Depot
Optional: Depot images.
@ Oneway
Optional: One-way indicator images.
std::vector< RoadType > _sorted_roadtypes
Sorted list of road types.
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.
static VehicleEnterTileStates VehicleEnterTile_Road(Vehicle *v, TileIndex tile, int x, int y)
Tile callback function for a vehicle entering a tile.
std::vector< RoadVehicle * > RoadVehicleList
Helper type for lists/vectors of road vehicles.
void InitRoadTypes()
Resolve sprites of custom road types.
static CommandCost TerraformTile_Road(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
Tile callback function signature of the terraforming callback.
CommandCost CmdBuildRoad(DoCommandFlags flags, TileIndex tile, RoadBits pieces, RoadType rt, DisallowedRoadDirections toggle_drd, TownID town_id)
Build a piece of road.
static Foundation GetFoundation_Road(TileIndex tile, Slope tileh)
Tile callback function signature for getting the foundation of a tile.
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 bool DrawRoadAsSnowOrDesert(bool snow_or_desert, Roadside roadside)
Should the road be drawn as a unpaved snow/desert road?
bool UpdateNearestTownForRoadTiles(bool invalidate)
Updates cached nearest town for all road tiles.
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.
bool RoadVehiclesAreBuilt()
Verify whether a road vehicle is available.
void DrawRoadCatenary(const TileInfo *ti)
Draws the catenary for the given tile.
static void DrawTile_Road(TileInfo *ti)
Tile callback function signature for drawing a tile and its contents to the screen.
CommandCost CmdBuildRoadDepot(DoCommandFlags flags, TileIndex tile, RoadType rt, DiagDirection dir)
Build a road depot.
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.
static int GetSlopePixelZ_Road(TileIndex tile, uint x, uint y, bool ground_vehicle)
Tile callback function signature for obtaining the world Z coordinate of a given point of a tile.
static void ChangeTileOwner_Road(TileIndex tile, Owner old_owner, Owner new_owner)
Tile callback function signature for changing the owner of a tile.
static bool ClickTile_Road(TileIndex tile)
Tile callback function signature for clicking a tile.
CommandCost CmdBuildLongRoad(DoCommandFlags 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 const TrackBits _road_trackbits[16]
Converts RoadBits to TrackBits.
static constexpr NonSteepSlopeIndexArray< uint8_t > _road_sloped_sprites
Lookup table to convert tile's slope into corresponding road sprite offset.
static void DrawRoadDetail(SpriteID img, const TileInfo *ti, int8_t dx, int8_t dy, uint8_t h, bool transparent)
Draws details on/around the road.
RoadTypes _roadtypes_road
Bitset of road roadtypes.
std::tuple< CommandCost, Money > CmdRemoveLongRoad(DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, bool start_half, bool end_half)
Remove 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 CommandCost ClearTile_Road(TileIndex tile, DoCommandFlags flags)
Tile callback function signature for clearing a tile.
CommandCost CmdConvertRoad(DoCommandFlags flags, TileIndex tile, TileIndex area_start, RoadType to_type, bool diagonal)
Convert one road subtype to another.
static void GetTileDesc_Road(TileIndex tile, TileDesc &td)
Tile callback function signature for obtaining a tile description.
static void DrawRoadBits(TileInfo *ti)
Draw ground sprite and road pieces.
static const std::array< NonSteepSlopeIndexArray< RoadBits >, 2 > _invalid_tileh_slopes_road
Invalid RoadBits on slopes.
static CommandCost RemoveRoad(TileIndex tile, DoCommandFlags flags, RoadBits pieces, RoadTramType rtt, bool town_check)
Delete a piece of road.
static constexpr DiagDirectionIndexArray< Trackdir > _roadveh_enter_depot_dir
Given the direction the road depot is pointing, this is the direction the vehicle should be travellin...
static void TileLoop_Road(TileIndex tile)
Tile callback function signature for running periodic tile updates.
static CommandCost CheckBuildAbove_Road(TileIndex tile, DoCommandFlags flags, Axis axis, int height)
Tile callback function signature to test if a bridge can be built above a tile.
RoadType AllocateRoadType(RoadTypeLabel label, RoadTramType rtt)
Allocate a new road type label.
RoadTypes _roadtypes_tram
Bitset of tram roadtypes.
static uint GetRoadSpriteOffset(Slope slope, RoadBits bits)
Get the sprite offset within a spritegroup.
CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadTramType rtt, DoCommandFlags flags, bool town_check)
Is it allowed to remove the given road bits from the given tile?
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.
static TrackStatus GetTileTrackStatus_Road(TileIndex tile, TransportType mode, RoadTramType sub_mode, DiagDirection side)
Tile callback function signature for getting the possible tracks that can be taken on a given tile by...
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.
static const DiagDirectionIndexArray< DrawTileSpriteSpan > _road_depot
Sprite layout for a road depot for each direction.
bool MayHaveRoad(Tile t)
Test whether a tile can have road/tram types.
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.
static RoadTileType GetRoadTileType(Tile t)
Get the type of the road tile.
bool HasTownOwnedRoad(Tile t)
Checks if given tile has town owned road.
RoadType GetRoadTypeRoad(Tile t)
Get the road type for RoadTramType being RoadTramType::Road.
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.
static bool IsRoadDepotTile(Tile t)
Return whether a tile is a road depot tile.
bool IsValidDisallowedRoadDirections(DisallowedRoadDirections drt)
Checks if a DisallowedRoadDirections is valid.
Axis GetCrossingRoadAxis(Tile t)
Get the road axis 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.
bool HasRoadTypeTram(Tile t)
Check if a tile has a road type when RoadTramType is RoadTramType::Tram.
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.
static bool IsRoadDepot(Tile t)
Return whether a tile is a road depot.
RoadType GetRoadTypeTram(Tile t)
Get the road type for RoadTramType being RoadTramType::Tram.
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.
RoadTileType
The different types of road tiles.
@ Depot
Depot (one entrance).
@ Crossing
Level crossing.
void MakeRoadCrossing(Tile t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadType road_rt, RoadType tram_rt, TownID town)
Make a level crossing.
void ToggleSnowOrDesert(Tile t)
Toggle the snow/desert state of a road tile.
RoadBits GetAllRoadBits(Tile tile)
Get all set RoadBits on the given tile.
Axis GetCrossingRailAxis(Tile t)
Get the rail axis of a level crossing.
RoadType GetRoadType(Tile t, RoadTramType rtt)
Get the road type for the given RoadTramType.
static bool IsNormalRoadTile(Tile t)
Return whether a tile is a normal road tile.
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.
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.
@ Paved
Road with paved sidewalks.
@ Barren
Road on barren land.
@ GrassRoadWorks
Road on grass with road works.
@ StreetLights
Road with street lights on paved sidewalks.
@ Trees
Road with trees on paved sidewalks.
bool IsLevelCrossing(Tile t)
Return whether a tile is a level crossing.
static bool IsNormalRoad(Tile t)
Return whether a tile is a normal road.
bool IsOnSnowOrDesert(Tile t)
Check if a road tile has snow/desert.
bool HasRoadWorks(Tile t)
Check if a tile has road works.
EnumBitSet< RoadType, uint64_t > RoadTypes
Bitset of RoadType elements.
static constexpr RoadBits ROAD_X
Full road along the x-axis (south-west + north-east).
@ Northbound
All northbound traffic is disallowed.
@ Southbound
All southbound traffic is disallowed.
EnumBitSet< RoadBit, uint8_t > RoadBits
Bitset of RoadBit elements.
EnumBitSet< DisallowedRoadDirection, uint8_t > DisallowedRoadDirections
Bitset of DisallowedRoadDirection elements.
static constexpr RoadBits ROAD_ALL
Full 4-way crossing.
static constexpr RoadBits ROAD_Y
Full road along the y-axis (north-west + south-east).
static constexpr RoadTramTypes ROADTRAMTYPES_ALL
All possible RoadTramTypes.
RoadType
The different roadtypes we support.
@ INVALID_ROADTYPE
flag for invalid roadtype
@ ROADTYPE_ROAD
Basic road type.
@ ROADTYPE_END
Used for iterations.
RoadTramType
The different types of road type.
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
static constexpr uint8_t NUM_SLOPES
The total number of possible slope types.
Foundation
Enumeration for Foundations.
@ Leveled
The tile is leveled up to a flat slope.
@ None
The tile has no foundation, the slope remains unchanged.
@ InclinedY
The tile has an along Y-axis inclined foundation.
@ InclinedX
The tile has an along X-axis inclined foundation.
static const uint32_t VALID_LEVEL_CROSSING_SLOPES
Constant bitset with safe slopes for building a level crossing.
EnumClassIndexContainer< std::array< T, SLOPE_ELEVATED >, Slope > NonSteepSlopeIndexArray
Array with non steep Slope as index.
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.
static PaletteID GetColourPalette(Colours colour)
Get recolour palette for a colour.
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 SpriteID SPR_TRAMWAY_TRAM
static const SpriteID SPR_TRAMWAY_DEPOT_WITH_TRACK
static const SpriteID SPR_TRAMWAY_BACK_WIRES_SLOPED
static const uint16_t ONEWAY_SLOPE_N_OFFSET
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
static const SpriteID SPR_TRAMWAY_DEPOT_NO_TRACK
static const SpriteID SPR_ROAD_DEPOT
static const SpriteID SPR_FLAT_SNOW_DESERT_TILE
static const SpriteID SPR_TRAMWAY_OVERLAY
static const SpriteID SPR_TRAMWAY_BASE
static const SpriteID SPR_ROAD_Y
static const uint16_t ONEWAY_SLOPE_S_OFFSET
static const SpriteID SPR_FLAT_GRASS_TILE
static const PaletteID PALETTE_TO_BARE_LAND
sets colour to bare land stuff for rail, road and crossings
static const SpriteID SPR_TRAMWAY_FRONT_WIRES_SLOPED
static const SpriteID SPR_ONEWAY_BASE
@ Count
by amount of cargo
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.
EncodedString GetEncodedStringWithArgs(StringID str, std::span< const StringParameter > params)
Encode a string with its parameters into an encoded string.
Functions related to OTTD's strings.
StrongType::Typedef< uint32_t, struct StringIDTag, StrongType::Compare, StrongType::Integer > StringID
Numeric value that represents a string, independent of the selected language.
constexpr bool Empty() const
Check whether the label is empty.
VehicleType type
Type of vehicle.
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.
Ground palette sprite of a tile, together with its sprite layout.
PalSpriteID ground
Palette and sprite for the ground.
A special vehicle is one of the following:
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
static uint Size()
Get the size of the map.
SpriteID sprite
The 'real' sprite.
static Pool::IterateWrapper< Vehicle > Iterate(size_t from=0)
static T * Create(Targs &&... args)
static Company * Get(auto index)
static bool CanAllocateItem(size_t n=1)
static bool IsValidID(auto index)
static Company * GetIfValid(auto index)
Buses, trucks and trams belong to this class.
T * Next() const
Get next vehicle in the chain.
static RoadVehicle * From(Vehicle *v)
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.
std::array< Owner, 4 > owner
Name of the owner(s).
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).
std::array< StringID, 4 > owner_type
Type of each owner.
Tile information, used while rendering the tile.
Slope tileh
Slope of the tile.
TileIndex tile
Tile index.
Set of callback functions for performing tile operations of a given tile type.
std::array< uint32_t, NUM_HOUSE_ZONES > 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
VehStates vehstatus
Status.
TileIndex tile
Current tile index.
@ EnteredWormhole
The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/...
EnumBitSet< VehicleEnterTileState, uint8_t > VehicleEnterTileStates
Bitset of VehicleEnterTileState elements.
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.
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
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.
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.
Slope GetTileSlope(TileIndex tile)
Return the slope of a given tile inside the map.
static TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
static constexpr uint TILE_SIZE
Tile size in world coordinates.
static constexpr uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in ZOOM_BASE.
TileType
The different types of tiles.
@ TunnelBridge
Tunnel entry/exit and bridge heads.
@ Station
A tile of a station or airport.
@ Railway
A tile with railway.
@ Road
A tile with road and/or tram tracks.
OrthoDiagonalTileArea CreateOrthoDiagonalArea(TileIndex corner1, TileIndex corner2, bool diagonal)
Create an Orthogonal/Diagonal tile area wrapper.
Type for storing the 'area' of something uses on the map.
Definition of the game-calendar-timer.
void ChangeTownRating(Town *t, int add, int max, DoCommandFlags flags)
Changes town rating of the current company.
@ TunnelBridgeRemove
Removal of a tunnel or bridge owned by the town.
@ RoadRemove
Removal of a road owned by the town.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
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(DoCommandFlags flags, Town *t, TownRatingCheckType type)
Does the town authority allow the (destructive) action of the current company?
HouseZone GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
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.
Track AxisToTrack(Axis a)
Convert an Axis to the corresponding Track Axis::X -> Track::X Axis::Y -> Track::Y Uses the fact that...
Track DiagDirToDiagTrack(DiagDirection diagdir)
Maps a DiagDirection to the associated diagonal Track.
EnumBitSet< Trackdir, uint16_t > TrackdirBits
Bitset of Trackdir elements.
EnumBitSet< Track, uint8_t > TrackBits
Bitset of Track elements.
static constexpr TrackBits TRACK_BIT_ALL
All possible tracks.
Trackdir
Enumeration for tracks and directions.
@ X_NE
X-axis and direction to north-east.
@ X_SW
X-axis and direction to south-west.
@ Y_SE
Y-axis and direction to south-east.
@ Y_NW
Y-axis and direction to north-west.
Track
These are used to specify a single track.
@ X
Track along the x-axis (north-east to south-west).
@ Upper
Track in the upper corner of the tile (north).
@ Y
Track along the y-axis (north-west to south-east).
@ Right
Track in the right corner of the tile (east).
@ Left
Track in the left corner of the tile (west).
@ Lower
Track in the lower corner of the tile (south).
Base for the train class.
bool TrainOnCrossing(TileIndex tile)
Check if a level crossing tile has a train on it.
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...
DisplayOptions _display_opt
What do we want to draw/do?
@ Buildings
company buildings - depots, stations, HQ, ...
TransportType
Available types of transport.
@ Rail
Transport by train.
@ 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,...
CommandCost TunnelBridgeIsFree(TileIndex tile, TileIndex endtile, const Vehicle *ignore)
Finds vehicle in tunnel / bridge.
@ Hidden
Vehicle is not visible.
Functions related to vehicles.
void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int z, const SpriteBounds &bounds, bool transparent, 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 int TILE_HEIGHT_STEP
One Z unit tile height difference is displayed as 50m.
static constexpr int 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-...
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.
@ Detail
All zoom levels below or equal to this will result in details on the screen, like road-work,...