37#include "table/strings.h"
72 _railtypes_hidden_mask = {};
78 if (cursors_base != 0) {
98 const SpriteID _signal_lookup[2][SIGTYPE_END] = {
99 {SPR_IMG_SIGNAL_ELECTRIC_NORM, SPR_IMG_SIGNAL_ELECTRIC_ENTRY, SPR_IMG_SIGNAL_ELECTRIC_EXIT,
100 SPR_IMG_SIGNAL_ELECTRIC_COMBO, SPR_IMG_SIGNAL_ELECTRIC_PBS, SPR_IMG_SIGNAL_ELECTRIC_PBS_OWAY},
102 {SPR_IMG_SIGNAL_SEMAPHORE_NORM, SPR_IMG_SIGNAL_SEMAPHORE_ENTRY, SPR_IMG_SIGNAL_SEMAPHORE_EXIT,
103 SPR_IMG_SIGNAL_SEMAPHORE_COMBO, SPR_IMG_SIGNAL_SEMAPHORE_PBS, SPR_IMG_SIGNAL_SEMAPHORE_PBS_OWAY},
110 rti->
gui_sprites.
signals[type][var][0] = (red != 0) ? red + SIGNAL_TO_SOUTH : _signal_lookup[var][type];
111 rti->
gui_sprites.
signals[type][var][1] = (green != 0) ? green + SIGNAL_TO_SOUTH : _signal_lookup[var][type] + 1;
136 ResolveRailTypeGUISprites(&rti);
139 if (rti.
label == 0)
continue;
181static const uint8_t _track_sloped_sprites[14] = {
250 if (current == future) {
403 return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
411static inline bool ValParamTrackOrientation(
Track track)
437 if (ret.
Failed())
return ret;
439 if (!
IsPlainRail(tile))
return Command<Commands::LandscapeClear>::Do(flags, tile);
445 if (ret.
Failed())
return ret;
448 if (ret.
Failed())
return ret;
453 if (!auto_remove_signals)
return CommandCost(STR_ERROR_MUST_REMOVE_SIGNALS_FIRST);
457 CommandCost ret_remove_signals = Command<Commands::RemoveSignal>::Do(flags, tile, track_it);
458 if (ret_remove_signals.
Failed())
return ret_remove_signals;
469 ret = Command<Commands::ConvertRail>::Do(flags, tile, tile, railtype,
false);
470 if (ret.
Failed())
return ret;
500 if (ret.
Failed())
return ret;
504 if (ret.
Failed())
return ret;
529 if (ret.
Failed())
return ret;
533 if (num_new_road_pieces > 0) {
538 if (num_new_tram_pieces > 0) {
549 Company::Get(road_owner)->infrastructure.road[roadtype_road] += num_new_road_pieces;
553 Company::Get(tram_owner)->infrastructure.road[roadtype_tram] += num_new_tram_pieces;
572 if (ret.
Failed())
return ret;
575 ret = Command<Commands::LandscapeClear>::Do(flags, tile);
576 if (ret.
Failed())
return ret;
617 bool crossing =
false;
619 if (!ValParamTrackOrientation(track))
return CMD_ERROR;
636 if (ret.
Failed())
return ret;
641 if (ret.
Failed())
return ret;
670 if (ret.
Failed())
return ret;
674 if (ret.
Failed())
return ret;
677 if ((present & trackbit) == 0)
return CommandCost(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
684 cost.
AddCost(Command<Commands::RemoveSignal>::Do(flags, tile, track));
725 default:
return CommandCost(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
765 bool flooded =
false;
774 TrackBits to_remove = lower_track & rail_bits;
779 if (!flooded)
return flooded;
780 rail_bits = rail_bits & ~to_remove;
807 { -1, 0 }, { 0, 1 }, { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, 1 },
810 { 1, 0 }, { 0, -1 }, { 0, -1 }, { 1, 0 }, { 0, -1 }, { -1, 0 },
818 int x =
TileX(start);
819 int y =
TileY(start);
830 int trdx = _trackdelta[*trackdir].x;
831 int trdy = _trackdelta[*trackdir].y;
834 trdx += _trackdelta[*trackdir ^ 1].x;
835 trdy += _trackdelta[*trackdir ^ 1].y;
839 while ((trdx <= 0 && dx > 0) ||
840 (trdx >= 0 && dx < 0) ||
841 (trdy <= 0 && dy > 0) ||
842 (trdy >= 0 && dy < 0)) {
843 if (!
HasBit(*trackdir, 3)) {
855 trdx = _trackdelta[*trackdir].x;
856 trdy = _trackdelta[*trackdir].y;
884 CommandCost ret = ValidateAutoDrag(&trackdir, tile, end_tile);
885 if (ret.
Failed())
return ret;
887 bool had_success =
false;
890 ret = remove ? Command<Commands::RemoveRail>::Do(flags, tile,
TrackdirToTrack(trackdir)) : Command<Commands::BuildRail>::Do(flags, tile, railtype,
TrackdirToTrack(trackdir), auto_remove_signals);
891 if (!remove && !fail_on_obstacle && last_error.
GetErrorMessage() == STR_ERROR_ALREADY_BUILT) had_success =
true;
894 last_error = std::move(ret);
895 if (last_error.
GetErrorMessage() != STR_ERROR_ALREADY_BUILT && !remove) {
896 if (fail_on_obstacle)
return last_error;
897 if (had_success)
break;
901 if (last_error.
GetErrorMessage() == STR_ERROR_OWNED_BY && remove)
break;
907 if (tile == end_tile)
break;
915 if (had_success)
return total_cost;
934 return CmdRailTrackHelper(flags, start_tile, end_tile, railtype, track,
false, auto_remove_signals, fail_on_obstacle);
983 bool rotate_existing_depot =
false;
986 if (ret.
Failed())
return ret;
991 if (ret.
Failed())
return ret;
993 rotate_existing_depot =
true;
996 if (!rotate_existing_depot) {
997 cost.
AddCost(Command<Commands::LandscapeClear>::Do(flags, tile));
998 if (cost.
Failed())
return cost;
1006 if (rotate_existing_depot) {
1046CommandCost CmdBuildSingleSignal(DoCommandFlags flags,
TileIndex tile,
Track track,
SignalType sigtype,
SignalVariant sigvar,
bool convert_signal,
bool skip_existing_signals,
bool ctrl_pressed,
SignalType cycle_start,
SignalType cycle_stop, uint8_t num_dir_cycle, uint8_t signals_copy)
1049 if (cycle_start > cycle_stop || cycle_stop > SIGTYPE_LAST)
return CMD_ERROR;
1056 return CommandCost(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
1062 if (ret.
Failed())
return ret;
1082 }
else if (convert_signal) {
1120 if (signals_copy == 0) {
1128 if (convert_signal) {
1144 }
else if (ctrl_pressed) {
1148 if (sigtype < cycle_start || sigtype > cycle_stop) sigtype = cycle_start;
1193static bool AdvanceSignalAutoFill(
TileIndex &tile,
Trackdir &trackdir,
bool remove)
1232 default:
return false;
1252static CommandCost CmdSignalTrackHelper(DoCommandFlags flags,
TileIndex tile,
TileIndex end_tile,
Track track,
SignalType sigtype,
SignalVariant sigvar,
bool mode,
bool remove,
bool autofill,
bool minimise_gaps,
int signal_density)
1257 if (signal_density == 0 || signal_density > 20)
return CMD_ERROR;
1267 CommandCost ret = ValidateAutoDrag(&trackdir, tile, end_tile);
1268 if (ret.
Failed())
return ret;
1271 Trackdir start_trackdir = trackdir;
1280 assert(signals != 0);
1292 uint8_t signal_dir = 0;
1309 int last_used_ctr = -signal_density;
1310 int last_suitable_ctr = 0;
1314 bool had_success =
false;
1317 uint8_t signals = 0;
1322 CommandCost ret = remove ? Command<Commands::RemoveSignal>::Do(do_flags, tile,
TrackdirToTrack(trackdir)) : Command<Commands::BuildSignal>::Do(do_flags, tile,
TrackdirToTrack(trackdir), sigtype, sigvar,
false, signal_ctr == 0, mode,
SIGTYPE_BLOCK,
SIGTYPE_BLOCK, 0, signals);
1342 build_signal(tile, trackdir,
false);
1343 }
else if (minimise_gaps) {
1347 if (signal_ctr > last_used_ctr + signal_density && last_suitable_tile !=
INVALID_TILE) {
1349 if (build_signal(last_suitable_tile, last_suitable_trackdir,
false)) {
1351 last_used_ctr = last_suitable_ctr;
1355 if (signal_ctr == last_used_ctr + signal_density) {
1357 if (build_signal(tile, trackdir,
false)) {
1358 last_used_ctr = signal_ctr;
1363 if (build_signal(tile, trackdir,
true)) {
1364 last_suitable_tile = tile;
1365 last_suitable_ctr = signal_ctr;
1366 last_suitable_trackdir = trackdir;
1369 }
else if (signal_ctr >= last_used_ctr + signal_density) {
1371 build_signal(tile, trackdir,
false);
1372 last_used_ctr = signal_ctr;
1387 if (remove || minimise_gaps) {
1394 if (signal_ctr >= last_used_ctr + signal_density) last_used_ctr = signal_ctr;
1404 if (!AdvanceSignalAutoFill(tile, trackdir, remove))
break;
1407 if (tile == start_tile && trackdir == start_trackdir)
break;
1409 if (tile == end_tile)
break;
1420 if (!remove && minimise_gaps && signal_ctr > last_used_ctr + signal_density && last_suitable_tile !=
INVALID_TILE) {
1421 build_signal(last_suitable_tile, last_suitable_trackdir,
false);
1424 return had_success ? total_cost : last_error;
1445 return CmdSignalTrackHelper(flags, tile, end_tile, track, sigtype, sigvar, mode,
false, autofill, minimise_gaps, signal_density);
1458 return CommandCost(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
1461 return CommandCost(STR_ERROR_THERE_ARE_NO_SIGNALS);
1467 if (ret.
Failed())
return ret;
1478 for (
int i = 0; v ==
nullptr && i < 2; i++, td =
ReverseTrackdir(td)) {
1523 return CmdSignalTrackHelper(flags, tile, end_tile, track,
SIGTYPE_BLOCK,
SIG_ELECTRIC,
false,
true, autofill,
false, 1);
1547 bool found_convertible_track =
false;
1563 error.
MakeError(STR_ERROR_CROSSING_DISALLOWED_RAIL);
1582 error = std::move(ret);
1586 std::vector<Train *> vehicles_affected;
1594 error = std::move(ret);
1606 vehicles_affected.push_back(v);
1634 default: NOT_REACHED();
1646 found_convertible_track =
true;
1658 found_convertible_track =
true;
1669 if (endtile < tile) {
1681 error = std::move(ret);
1693 vehicles_affected.push_back(v);
1725 found_convertible_track =
true;
1737 found_convertible_track =
true;
1742 for (uint i = 0; i < vehicles_affected.size(); ++i) {
1749 for (
Train *v : affected_trains) {
1754 return found_convertible_track ? cost : error;
1761 if (ret.
Failed())
return ret;
1765 if (ret.
Failed())
return ret;
1781 delete Depot::GetByTile(tile);
1782 DoClearSquare(tile);
1798 return CommandCost(STR_ERROR_AREA_IS_OWNED_BY_ANOTHER);
1802 return CommandCost(STR_ERROR_MUST_REMOVE_RAILROAD_TRACK);
1804 return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
1818 CommandCost ret = Command<Commands::RemoveRail>::Do(flags, tile, track);
1819 if (ret.
Failed())
return ret;
1827 if (ret.
Failed())
return ret;
1831 DoClearSquare(tile);
1840 return RemoveTrainDepot(tile, flags);
1871 case 0: side =
false;
break;
1872 case 2: side =
true;
break;
1875 static const Point SignalPositions[2][12] = {
1878 { 8, 5}, {14, 1}, { 1, 14}, { 9, 11}, { 1, 0}, { 3, 10},
1880 {11, 4}, {14, 14}, {11, 3}, { 4, 13}, { 3, 4}, {11, 13}
1883 {14, 1}, {12, 10}, { 4, 6}, { 1, 14}, {10, 4}, { 0, 1},
1885 {14, 14}, { 5, 12}, {11, 13}, { 4, 3}, {13, 4}, { 3, 11}
1901 sprite += type * 16 + variant * 64 + image * 2 + condition + (type > SIGTYPE_LAST_NOPBS ? 64 : 0);
1904 AddSortableSpriteToDraw(sprite, PAL_NONE, x, y,
GetSafeSlopeZ(x, y, track), {{}, {1, 1,
BB_HEIGHT_UNDER_BRIDGE}, {}});
1908struct FenceOffset : SpriteBounds {
1911 constexpr FenceOffset(
Corner height_ref, int8_t origin_x, int8_t origin_y, uint8_t extent_x, uint8_t extent_y) :
1917 { CORNER_INVALID, 0, 1, 16, 1 },
1918 { CORNER_INVALID, 1, 0, 1, 16 },
1919 { CORNER_W, 8, 8, 1, 1 },
1920 { CORNER_N, 8, 8, 1, 1 },
1921 { CORNER_INVALID, 0, 1, 16, 1 },
1922 { CORNER_INVALID, 1, 0, 1, 16 },
1923 { CORNER_INVALID, 0, 1, 16, 1 },
1924 { CORNER_INVALID, 1, 0, 1, 16 },
1925 { CORNER_INVALID, 0, 15, 16, 1 },
1926 { CORNER_INVALID, 15, 0, 1, 16 },
1927 { CORNER_E, 8, 8, 1, 1 },
1928 { CORNER_S, 8, 8, 1, 1 },
1929 { CORNER_INVALID, 0, 15, 16, 1 },
1930 { CORNER_INVALID, 15, 0, 1, 16 },
1931 { CORNER_INVALID, 0, 15, 16, 1 },
1932 { CORNER_INVALID, 15, 0, 1, 16 },
2013 uint num_sprites = 0;
2019 psid.
sprite = SPR_TRACK_FENCE_FLAT_X;
2023 assert(num_sprites > 0);
2047 switch (track_corner) {
2052 default: NOT_REACHED();
2062static const SubSprite _halftile_sub_sprite[4] = {
2078 Corner halftile_corner = CORNER_INVALID;
2095 DrawShoreTile(ti->
tileh);
2106 default: image = SPR_FLAT_GRASS_TILE;
break;
2121 }
else if (no_combine) {
2157 DrawTrackSprite(ground +
RTO_S, PAL_NONE, ti,
SLOPE_S);
break;
2159 DrawTrackSprite(ground +
RTO_W, PAL_NONE, ti,
SLOPE_W);
break;
2209 default: image = SPR_FLAT_GRASS_TILE;
break;
2214 DrawGroundSprite(image, PAL_NONE, &(_halftile_sub_sprite[halftile_corner]));
2220 default: NOT_REACHED();
2227 DrawTrackSprite(ground + offset, PAL_NONE, ti, fake_slope);
2229 DrawTrackSprite(overlay + offset,
PALETTE_CRASH, ti, fake_slope);
2262 if (rti->UsesOverlay()) {
2263 DrawTrackBitsOverlay(ti, track, rti);
2269 Corner halftile_corner = CORNER_INVALID;
2285 bool junction =
false;
2292 DrawShoreTile(ti->
tileh);
2295 image = SPR_FLAT_WATER_TILE;
2301 default: image = SPR_FLAT_GRASS_TILE;
break;
2338 DrawShoreTile(ti->
tileh);
2340 sub = &(_halftile_sub_sprite[track_corner]);
2360 if (_game_mode != GM_MENU &&
_settings_client.gui.show_track_reservation) {
2399 static const uint8_t _corner_to_track_sprite[] = {3, 1, 2, 0};
2407 auto MAYBE_DRAW_SIGNAL = [&](uint8_t signalbit,
SignalOffsets image, uint pos,
Track track) {
2414 MAYBE_DRAW_SIGNAL(2, SIGNAL_TO_NORTH, 0,
TRACK_LEFT);
2415 MAYBE_DRAW_SIGNAL(3, SIGNAL_TO_SOUTH, 1,
TRACK_LEFT);
2418 MAYBE_DRAW_SIGNAL(0, SIGNAL_TO_NORTH, 2,
TRACK_RIGHT);
2419 MAYBE_DRAW_SIGNAL(1, SIGNAL_TO_SOUTH, 3,
TRACK_RIGHT);
2422 MAYBE_DRAW_SIGNAL(3, SIGNAL_TO_WEST, 4,
TRACK_UPPER);
2423 MAYBE_DRAW_SIGNAL(2, SIGNAL_TO_EAST, 5,
TRACK_UPPER);
2426 MAYBE_DRAW_SIGNAL(1, SIGNAL_TO_WEST, 6,
TRACK_LOWER);
2427 MAYBE_DRAW_SIGNAL(0, SIGNAL_TO_EAST, 7,
TRACK_LOWER);
2430 MAYBE_DRAW_SIGNAL(3, SIGNAL_TO_SOUTHWEST, 8,
TRACK_X);
2431 MAYBE_DRAW_SIGNAL(2, SIGNAL_TO_NORTHEAST, 9,
TRACK_X);
2434 MAYBE_DRAW_SIGNAL(3, SIGNAL_TO_SOUTHEAST, 10,
TRACK_Y);
2435 MAYBE_DRAW_SIGNAL(2, SIGNAL_TO_NORTHWEST, 11,
TRACK_Y);
2443 BridgePillarFlags blocked_pillars{};
2472 dts = &_depot_invisible_gfx_table[dir];
2474 dts = &_depot_gfx_table[dir];
2478 if (rti->UsesOverlay()) {
2479 image = SPR_FLAT_GRASS_TILE;
2487 if (image != SPR_FLAT_GRASS_TILE) {
2490 image = SPR_FLAT_SNOW_DESERT_TILE;
2496 if (rti->UsesOverlay()) {
2568void DrawTrainDepotSprite(
int x,
int y,
int dir,
RailType railtype)
2575 if (image != SPR_FLAT_GRASS_TILE) image += offset;
2580 if (rti->UsesOverlay()) {
2590 if (depot_sprite != 0) offset = depot_sprite - SPR_RAIL_DEPOT_SE_1;
2701 DiagDirections fences{};
2718 switch (fences.
base()) {
2719 case DiagDirections{}.base():
break;
2730 default: NOT_REACHED();
2735 if (old_ground != new_ground) {
2749 default: NOT_REACHED();
2764 default: NOT_REACHED();
2823 td.
str = STR_LAI_RAIL_DESCRIPTION_TRACK;
2827 static const StringID signal_type[6][6] = {
2829 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_SIGNALS,
2830 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_PRESIGNALS,
2831 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_EXITSIGNALS,
2832 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_COMBOSIGNALS,
2833 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_PBSSIGNALS,
2834 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_NOENTRYSIGNALS
2837 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_PRESIGNALS,
2838 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRESIGNALS,
2839 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_EXITSIGNALS,
2840 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_COMBOSIGNALS,
2841 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_PBSSIGNALS,
2842 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_NOENTRYSIGNALS
2845 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_EXITSIGNALS,
2846 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_EXITSIGNALS,
2847 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_EXITSIGNALS,
2848 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_EXIT_COMBOSIGNALS,
2849 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_EXIT_PBSSIGNALS,
2850 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_EXIT_NOENTRYSIGNALS
2853 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_COMBOSIGNALS,
2854 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_COMBOSIGNALS,
2855 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_EXIT_COMBOSIGNALS,
2856 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_COMBOSIGNALS,
2857 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_COMBO_PBSSIGNALS,
2858 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_COMBO_NOENTRYSIGNALS
2861 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_PBSSIGNALS,
2862 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_PBSSIGNALS,
2863 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_EXIT_PBSSIGNALS,
2864 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_COMBO_PBSSIGNALS,
2865 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PBSSIGNALS,
2866 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PBS_NOENTRYSIGNALS
2869 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_NOENTRYSIGNALS,
2870 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_NOENTRYSIGNALS,
2871 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_EXIT_NOENTRYSIGNALS,
2872 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_COMBO_NOENTRYSIGNALS,
2873 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PBS_NOENTRYSIGNALS,
2874 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NOENTRYSIGNALS
2887 td.
str = signal_type[secondary_signal][primary_signal];
2892 td.
str = STR_LAI_RAIL_DESCRIPTION_TRAIN_DEPOT;
2893 if (
_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL) {
2900 td.
build_date = Depot::GetByTile(tile)->build_date;
2915 uint num_pieces = 1;
2922 Company::Get(old_owner)->infrastructure.rail[rt] -= num_pieces;
2923 Company::Get(new_owner)->infrastructure.rail[rt] += num_pieces;
2927 Company::Get(old_owner)->infrastructure.signal -= num_sigs;
2928 Company::Get(new_owner)->infrastructure.signal += num_sigs;
2937static const uint8_t _fractcoords_behind[4] = { 0x8F, 0x8, 0x80, 0xF8 };
2938static const uint8_t _fractcoords_enter[4] = { 0x8A, 0x48, 0x84, 0xA8 };
2939static const int8_t _deltacoord_leaveoffset[8] = {
2957 case DIAGDIR_NE:
return ((
int)(v->
x_pos & 0x0F) - ((_fractcoords_enter[dir] & 0x0F) - (length + 1)));
2958 case DIAGDIR_SE:
return -((int)(v->
y_pos & 0x0F) - ((_fractcoords_enter[dir] >> 4) + (length + 1)));
2959 case DIAGDIR_SW:
return -((int)(v->
x_pos & 0x0F) - ((_fractcoords_enter[dir] & 0x0F) + (length + 1)));
2960 case DIAGDIR_NW:
return ((
int)(v->
y_pos & 0x0F) - ((_fractcoords_enter[dir] >> 4) - (length + 1)));
2961 default: NOT_REACHED();
2974 uint8_t fract_coord = (x & 0xF) + ((y & 0xF) << 4);
2984 uint8_t fract_coord_leave =
2985 ((_fractcoords_enter[dir] & 0x0F) +
2986 (length + 1) * _deltacoord_leaveoffset[dir]) +
2987 (((_fractcoords_enter[dir] >> 4) +
2988 ((length + 1) * _deltacoord_leaveoffset[dir + 4])) << 4);
2990 if (fract_coord_leave == fract_coord) {
2992 if ((v = v->
Next()) !=
nullptr) {
2997 }
else if (_fractcoords_enter[dir] == fract_coord) {
3037 switch (rail_bits) {
3045 if (z_old != z_new || tileh_old != tileh_new)
return CommandCost(STR_ERROR_MUST_REMOVE_RAILROAD_TRACK);
3052 if (z_old != z_new)
return CommandCost(STR_ERROR_MUST_REMOVE_RAILROAD_TRACK);
3056 if (tileh_old != tileh_new) {
3076 }))
return CommandCost(STR_ERROR_SHIP_IN_THE_WAY);
3083 switch (rail_bits) {
3088 default:
return autoslope_result;
3097 for (
Corner corner = (
Corner)0; corner < CORNER_END; corner = (
Corner)(corner + 1)) {
3098 if (allowed_corner == corner)
continue;
3111 return Command<Commands::LandscapeClear>::Do(flags, tile);
3118 return Command<Commands::LandscapeClear>::Do(flags, tile);
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.
Class for backupping variables and making sure they are restored later.
constexpr bool HasExactlyOneBit(T value)
Test whether value has exactly 1 bit set.
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 HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T ToggleBit(T &x, const uint8_t y)
Toggles a bit in a variable.
constexpr T KillFirstBit(T value)
Clear the first bit in an integer.
void DrawBridgeMiddle(const TileInfo *ti, BridgePillarFlags blocked_pillars)
Draw the middle bits 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.
@ EdgeNE
Northeast edge is obstructed.
@ EdgeSW
Southwest edge is obstructed.
@ EdgeNW
Northwest edge is obstructed.
@ EdgeSE
Southeast edge is obstructed.
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 Timpl & Reset()
Reset all bits.
constexpr Timpl & Set()
Set all bits.
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.
bool Failed() const
Did this command fail?
StringID GetErrorMessage() const
Returns the error message of a command.
This struct contains all the info that is needed to draw and construct tracks.
RailType Index() const
Get the RailType for this RailTypeInfo.
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.
SpriteID build_tunnel
button for building a tunnel
CursorID rail_swne
Cursor for building rail in X direction.
SpriteID convert_rail
button for converting rail
struct RailTypeInfo::@157247141350136173143103254227157213063052244122 strings
Strings associated with the rail type.
CursorID convert
Cursor for converting track.
CursorID depot
Cursor for building a depot.
RailTypes powered_railtypes
bitmask to the OTHER railtypes on which an engine of THIS railtype generates power
RailTypes introduces_railtypes
Bitmask of which other railtypes are introduced when this railtype is introduced.
SpriteID ground
ground sprite for a 3-way switch
CursorID rail_nwse
Cursor for building rail in Y direction.
SpriteID build_x_rail
button for building single rail in X direction
uint8_t sorting_order
The sorting order of this railtype for the toolbar dropdown.
RailTypeLabel label
Unique 32 bit rail type identifier.
SpriteID single_n
single piece of rail in the northern corner
CursorID rail_ew
Cursor for building rail in E-W direction.
SpriteID auto_rail
button for the autorail construction
CursorID autorail
Cursor for autorail tool.
SpriteID single_y
single piece of rail in Y direction, without ground
StringID name
Name of this rail type.
RailTypes compatible_railtypes
bitmask to the OTHER railtypes on which an engine of THIS railtype can physically travel
uint GetRailtypeSpriteOffset() const
Offset between the current railtype and normal rail.
struct RailTypeInfo::@047376261311064105134233254254216006075341230376 gui_sprites
struct containing the sprites for the rail GUI.
SpriteID single_s
single piece of rail in the southern corner
RailTypeFlags flags
Bit mask of rail type flags.
SpriteID signals[SIGTYPE_END][2][2]
signal GUI sprites (type, variant, state)
SpriteID build_ew_rail
button for building single rail in E-W direction
SpriteID build_y_rail
button for building single rail in Y direction
FlatSet< RailTypeLabel > alternate_labels
Rail type labels this type provides in addition to the main label.
SpriteID track_ns
two pieces of rail in North and South corner (East-West direction)
struct RailTypeInfo::@332027037331076264023214171276243307073252216167 base_sprites
Struct containing the main sprites.
SpriteID snow_offset
sprite number difference between a piece of track on a snowy ground and the corresponding one on norm...
SpriteID track_y
single piece of rail in Y direction, with ground
SpriteID build_depot
button for building depots
SpriteID single_w
single piece of rail in the western corner
SpriteID single_e
single piece of rail in the eastern corner
SpriteID build_ns_rail
button for building single rail in N-S direction
CursorID rail_ns
Cursor for building rail in N-S direction.
SpriteID tunnel
tunnel sprites base
SpriteID single_sloped
single piece of rail for slopes
struct RailTypeInfo::@057010233226120022371265166156055202241326366156 cursor
Cursors associated with the rail type.
static std::unique_ptr< TileIterator > Create(TileIndex corner1, TileIndex corner2, bool diagonal)
Create either an OrthogonalTileIterator or DiagonalTileIterator given the diagonal parameter.
Iterate over all vehicles on a tile.
Functions related to commands.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
@ Auto
don't allow building on structures
@ Execute
execute the given command
@ Bankrupt
company bankrupts, skip money check, skip vehicle on tile check in some cases
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.
PaletteID GetCompanyPalette(CompanyID company)
Get the palette for recolouring with a company colour.
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.
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 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.
Direction DiagDirToDir(DiagDirection dir)
Convert a DiagDirection to a Direction.
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.
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.
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.
@ EXPENSES_CONSTRUCTION
Construction costs.
static const uint TUNNELBRIDGE_TRACKBIT_FACTOR
Multiplier for how many regular track bits a tunnel/bridge counts.
@ ClearRough
Price for destroying rough land.
@ BuildSignals
Price for building rail signals.
@ BuildFoundation
Price for building foundation under other constructions e.g. roads, rails, depots,...
@ ClearWater
Price for destroying water e.g. see, rives.
@ ClearSignals
Price for destroying rail signals.
@ ClearDepotTrain
Price for destroying train depots.
@ BuildDepotTrain
Price for building train depots.
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.
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.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
int GetSlopeZInCorner(Slope tileh, Corner corner)
Determine the Z height of a corner relative to TileZ.
const TileTypeProcs _tile_type_rail_procs
TileTypeProcs definitions for TileType::Rail 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.
@ Tropic
Landscape with distinct rainforests and deserts,.
#define Point
Macro that prevents name conflicts between included headers.
TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC diff)
Add a TileIndexDiffC to a TileIndex and returns the new one.
TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between two tiles from a TileIndexDiffC struct.
TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
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.
constexpr bool IsInsideMM(const size_t x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
constexpr T abs(const T a)
Returns the absolute value of (scalar) variable.
@ TCX_UPPER_HALFTILE
Querying information about the upper part of a tile with halftile foundation.
@ TCX_NORMAL
Nothing special.
Functions/types related to NewGRF debugging.
void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index)
Delete inspect window for a given feature and index.
SpriteID GetCustomSignalSprite(const RailTypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, SignalState state, bool gui)
Get the sprite to draw for a given signal.
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.
Map accessors for object tiles.
bool IsObjectType(Tile t, ObjectType type)
Check whether the object on a tile is of a specific type.
static const ObjectType OBJECT_OWNED_LAND
Owned land 'flag'.
@ DO_FULL_DETAIL
Also draw details of track and roads.
Train * GetTrainForReservation(TileIndex tile, Track track)
Find the train which has reserved a specific path.
TrackBits GetReservedTrackbits(TileIndex t)
Get the reserved trackbits for any tile, regardless of type.
bool IsSafeWaitingPosition(const Train *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg)
Determine whether a certain track on a tile is a safe position to end a path.
bool HasReservedTracks(TileIndex tile, TrackBits tracks)
Check whether some of tracks is reserved on a tile.
bool ValParamRailType(const RailType rail)
Validate functions for rail building.
Money RailConvertCost(RailType from, RailType to)
Calculates the cost of rail conversion.
Money RailClearCost(RailType railtype)
Returns the 'cost' of clearing the specified railtype.
Money RailBuildCost(RailType railtype)
Returns the cost of building the specified railtype.
std::vector< RailType > _sorted_railtypes
Sorted list of rail types.
RailFenceOffset
Offsets from base sprite for fence sprites.
@ RFO_FLAT_RIGHT
Slope FLAT, Track RIGHT, Fence W.
@ RFO_FLAT_Y_NE
Slope FLAT, Track Y, Fence NE.
@ RFO_SLOPE_NW_SW
Slope NW, Track Y, Fence SW.
@ RFO_FLAT_X_SE
Slope FLAT, Track X, Fence SE.
@ RFO_SLOPE_NW_NE
Slope NW, Track Y, Fence NE.
@ RFO_SLOPE_SE_SW
Slope SE, Track Y, Fence SW.
@ RFO_SLOPE_NE_SE
Slope NE, Track X, Fence SE.
@ RFO_FLAT_LOWER
Slope FLAT, Track LOWER, Fence N.
@ RFO_SLOPE_SW_SE
Slope SW, Track X, Fence SE.
@ RFO_FLAT_UPPER
Slope FLAT, Track UPPER, Fence S.
@ RFO_SLOPE_SE_NE
Slope SE, Track Y, Fence NE.
@ RFO_FLAT_Y_SW
Slope FLAT, Track Y, Fence SW.
@ RFO_FLAT_LEFT
Slope FLAT, Track LEFT, Fence E.
@ RFO_SLOPE_NE_NW
Slope NE, Track X, Fence NW.
@ RFO_FLAT_X_NW
Slope FLAT, Track X, Fence NW.
@ RFO_SLOPE_SW_NW
Slope SW, Track X, Fence NW.
bool IsCompatibleRail(RailType enginetype, RailType tiletype)
Checks if an engine of the given RailType can drive on a tile with a given RailType.
bool HasPowerOnRail(RailType enginetype, RailType tiletype)
Checks if an engine of the given RailType got power on a tile with a given RailType.
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
@ Hidden
Bit number for hiding from selection.
@ NoSpriteCombine
Bit number for using non-combined junctions.
@ RTSG_GROUND
Main group of ground images.
@ RTSG_CURSORS
Cursor and toolbar icon images.
@ RTSG_GROUND_COMPLETE
Complete ground images.
@ RTSG_OVERLAY
Images for overlaying track.
@ RTSG_DEPOT
Depot images.
@ RTSG_FENCES
Fence images.
@ RTO_Y
Piece of rail in Y direction.
@ RTO_S
Piece of rail in southern corner.
@ RTO_JUNCTION_NE
Ballast for junction 'pointing' NE.
@ RTO_JUNCTION_NSEW
Ballast for full junction.
@ RTO_JUNCTION_SW
Ballast for junction 'pointing' SW.
@ RTO_SLOPE_SE
Piece of rail on slope with south-east raised.
@ RTO_E
Piece of rail in eastern corner.
@ RTO_W
Piece of rail in western corner.
@ RTO_CROSSING_XY
Crossing of X and Y rail, with ballast.
@ RTO_SLOPE_SW
Piece of rail on slope with south-west raised.
@ RTO_SLOPE_NW
Piece of rail on slope with north-west raised.
@ RTO_JUNCTION_NW
Ballast for junction 'pointing' NW.
@ RTO_JUNCTION_SE
Ballast for junction 'pointing' SE.
@ RTO_SLOPE_NE
Piece of rail on slope with north-east raised.
@ RTO_X
Piece of rail in X direction.
@ RTO_N
Piece of rail in northern corner.
bool RailNoLevelCrossings(RailType rt)
Test if a RailType disallows build of level crossings.
CommandCost CmdRemoveSignalTrack(DoCommandFlags flags, TileIndex tile, TileIndex end_tile, Track track, bool autofill)
Remove signals on a stretch of track.
int TicksToLeaveDepot(const Train *v)
Compute number of ticks when next wagon will leave a depot.
static CommandCost CheckTrackCombination(TileIndex tile, TrackBits to_build)
Check that the new track bits may be built.
static CommandCost CmdRailTrackHelper(DoCommandFlags flags, TileIndex tile, TileIndex end_tile, RailType railtype, Track track, bool remove, bool auto_remove_signals, bool fail_on_obstacle)
Build or remove a stretch of railroad tracks.
static const int INF
Big number compared to tilesprite size.
CommandCost CmdBuildTrainDepot(DoCommandFlags flags, TileIndex tile, RailType railtype, DiagDirection dir)
Build a train depot.
static void DrawTile_Rail(TileInfo *ti)
Tile callback function signature for drawing a tile and its contents to the screen.
CommandCost CmdBuildSingleSignal(DoCommandFlags flags, TileIndex tile, Track track, SignalType sigtype, SignalVariant sigvar, bool convert_signal, bool skip_existing_signals, bool ctrl_pressed, SignalType cycle_start, SignalType cycle_stop, uint8_t num_dir_cycle, uint8_t signals_copy)
Build signals, alternate between double/single, signal/semaphore, pre/exit/combo-signals,...
CommandCost CmdBuildRailroadTrack(DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, RailType railtype, Track track, bool auto_remove_signals, bool fail_on_obstacle)
Build rail on a stretch of track.
CommandCost CmdBuildSignalTrack(DoCommandFlags flags, TileIndex tile, TileIndex end_tile, Track track, SignalType sigtype, SignalVariant sigvar, bool mode, bool autofill, bool minimise_gaps, uint8_t signal_density)
Build signals on a stretch of track.
static CommandCost ClearTile_Rail(TileIndex tile, DoCommandFlags flags)
Tile callback function signature for clearing a tile.
bool FloodHalftile(TileIndex t)
Called from water_cmd if a non-flat rail-tile gets flooded and should be converted to shore.
RailType AllocateRailType(RailTypeLabel label)
Allocate a new rail type label.
static CommandCost CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits existing, TileIndex tile)
Tests if a track can be build on a tile.
CommandCost CmdRemoveSingleRail(DoCommandFlags flags, TileIndex tile, Track track)
Remove a single piece of track.
CommandCost CmdRemoveSingleSignal(DoCommandFlags flags, TileIndex tile, Track track)
Remove signals.
static uint GetSafeSlopeZ(uint x, uint y, Track track)
Get surface height in point (x,y) On tiles with halftile foundations move (x,y) to a safe point wrt.
static const TrackBits _valid_tracks_without_foundation[15]
Valid TrackBits on a specific (non-steep)-slope without foundation.
static const TrackBits _valid_tracks_on_leveled_foundation[15]
Valid TrackBits on a specific (non-steep)-slope with leveled foundation.
static CommandCost EnsureNoTrainOnTrack(TileIndex tile, Track track)
Tests if a vehicle interacts with the specified track.
static CommandCost CmdSignalTrackHelper(DoCommandFlags flags, TileIndex tile, TileIndex end_tile, Track track, SignalType sigtype, SignalVariant sigvar, bool mode, bool remove, bool autofill, bool minimise_gaps, int signal_density)
Build many signals by dragging; AutoSignals.
static int GetSlopePixelZ_Rail(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 DrawTrackBits(TileInfo *ti, TrackBits track)
Draw ground sprite and track bits.
static void DrawTrackDetails(const TileInfo *ti, const RailTypeInfo *rti, PaletteID pal)
Draw track fences.
SignalOffsets
Enum holding the signal offset in the sprite sheet according to the side it is representing.
CommandCost CmdRemoveRailroadTrack(DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, Track track)
Build rail on a stretch of track.
static VehicleEnterTileStates VehicleEnterTile_Rail(Vehicle *v, TileIndex tile, int x, int y)
Tile callback function for a vehicle entering a tile.
CommandCost CmdBuildSingleRail(DoCommandFlags flags, TileIndex tile, RailType railtype, Track track, bool auto_remove_signals)
Build a single piece of rail.
CommandCost CmdConvertRail(DoCommandFlags flags, TileIndex tile, TileIndex area_start, RailType totype, bool diagonal)
Convert one rail type to the other.
void InitRailTypes()
Resolve sprites of custom rail types.
static void ChangeTileOwner_Rail(TileIndex tile, Owner old_owner, Owner new_owner)
Tile callback function signature for changing the owner of a tile.
static void DrawTrackFence_SW(const TileInfo *ti, const PalSpriteID &psid, uint num_sprites)
Draw fence at SW border matching the tile slope.
static bool ClickTile_Rail(TileIndex tile)
Tile callback function signature for clicking a tile.
static void GetTileDesc_Rail(TileIndex tile, TileDesc &td)
Tile callback function signature for obtaining a tile description.
void ResetRailTypes()
Reset all rail type information to its default values.
static CommandCost TestAutoslopeOnRailTile(TileIndex tile, DoCommandFlags flags, int z_old, Slope tileh_old, int z_new, Slope tileh_new, TrackBits rail_bits)
Tests if autoslope is allowed.
static const FenceOffset _fence_offsets[]
Offsets for drawing fences.
static TrackStatus GetTileTrackStatus_Rail(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Tile callback function signature for getting the possible tracks that can be taken on a given tile by...
static int GetJunctionGroundSpriteOffset(TrackBits track)
Returns which of the 5 junction-'Rail underlays' to use for the given track bits.
static bool CompareRailTypes(const RailType &first, const RailType &second)
Compare railtypes based on their sorting order.
static Foundation GetFoundation_Rail(TileIndex tile, Slope tileh)
Tile callback function signature for getting the foundation of a tile.
static void DrawTrackFence_NW(const TileInfo *ti, const PalSpriteID &psid, uint num_sprites)
Draw fence at NW border matching the tile slope.
Foundation GetRailFoundation(Slope tileh, TrackBits bits)
Checks if a track combination is valid on a specific slope and returns the needed foundation.
static void DrawTrackFence_NE(const TileInfo *ti, const PalSpriteID &psid, uint num_sprites)
Draw fence at NE border matching the tile slope.
static void DrawTrackFence_SE(const TileInfo *ti, const PalSpriteID &psid, uint num_sprites)
Draw fence at SE border matching the tile slope.
static CommandCost CheckBuildAbove_Rail(TileIndex tile, DoCommandFlags flags, Axis axis, int height)
Tile callback function signature to test if a bridge can be built above a tile.
std::vector< Train * > TrainList
Helper type for lists/vectors of trains.
static void TileLoop_Rail(TileIndex tile)
Tile callback function signature for running periodic tile updates.
static CommandCost TerraformTile_Rail(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
Tile callback function signature of the terraforming callback.
static void DrawTrackFence(const TileInfo *ti, const PalSpriteID &psid, uint num_sprites, RailFenceOffset rfo)
Draw a track fence.
Command definitions for rail.
static RailTileType GetRailTileType(Tile t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
static bool IsPlainRail(Tile t)
Returns whether this is plain rails, with or without signals.
uint GetSignalStates(Tile tile)
Set the states of the signals (Along/AgainstTrackDir).
void MakeRailDepot(Tile tile, Owner owner, DepotID depot_id, DiagDirection dir, RailType rail_type)
Make a rail depot.
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
bool HasSignalOnTrackdir(Tile tile, Trackdir trackdir)
Checks for the presence of signals along the given trackdir on the given rail tile.
static bool IsRailDepot(Tile t)
Is this rail tile a rail depot?
SignalVariant GetSignalVariant(Tile t, Track track)
Get the signal variant for a track on a tile.
RailGroundType GetRailGroundType(Tile t)
Get the ground type for rail tiles.
TrackBits GetTrackBits(Tile tile)
Gets the track bits of the given tile.
static bool IsPlainRailTile(Tile t)
Checks whether the tile is a rail tile or rail tile with signals.
bool IsPbsSignal(SignalType s)
Checks whether the given signal is a path based signal.
void CycleSignalSide(Tile t, Track track)
Cycle to the next signal side at the given track on a tile.
void MakeRailNormal(Tile t, Owner o, TrackBits b, RailType r)
Make the given tile a normal rail.
@ Normal
Normal rail tile without signals.
@ Depot
Depot (one entrance).
@ Signals
Normal rail tile with signals.
Track GetRailDepotTrack(Tile t)
Returns the track of a depot, ignoring direction.
void SetTrackReservation(Tile t, TrackBits b)
Sets the reserved track bits of the tile.
bool IsSignalPresent(Tile t, uint8_t signalbit)
Checks whether the given signals is present.
DiagDirection GetRailDepotDirection(Tile t)
Returns the direction the depot is facing to.
void SetTrackBits(Tile t, TrackBits b)
Sets the track bits of the given tile.
RailGroundType
The ground 'under' the rail.
@ FenceSENW
Grass with a fence at the NW and SE edges.
@ FenceVert2
Grass with a fence at the western side.
@ HalfTileSnow
Snow only on higher part of slope (steep or one corner raised).
@ FenceNESW
Grass with a fence at the NE and SW edges.
@ FenceHoriz2
Grass with a fence at the northern side.
@ SnowOrDesert
Icy or sandy.
@ HalfTileWater
Grass with a fence and shore or water on the free halftile.
@ FenceVert1
Grass with a fence at the eastern side.
@ FenceNW
Grass with a fence at the NW edge.
@ FenceSE
Grass with a fence at the SE edge.
@ FenceNE
Grass with a fence at the NE edge.
@ FenceSW
Grass with a fence at the SW edge.
@ FenceHoriz1
Grass with a fence at the southern side.
uint GetPresentSignals(Tile tile)
Get whether the given signals are present (Along/AgainstTrackDir).
bool HasSignalOnTrack(Tile tile, Track track)
Checks for the presence of signals (either way) on the given track on the given rail tile.
bool IsOnewaySignal(Tile t, Track track)
Is the signal at the given track on a tile a one way signal?
void SetPresentSignals(Tile tile, uint signals)
Set whether the given signals are present (Along/AgainstTrackDir).
void SetRailGroundType(Tile t, RailGroundType rgt)
Set the ground type for rail tiles.
void SetRailDepotExitDirection(Tile tile, DiagDirection dir)
Sets the exit direction of a rail depot.
SignalType GetSignalType(Tile t, Track track)
Get the signal type for a track on a tile.
TrackBits GetRailReservationTrackBits(Tile t)
Returns the reserved track bits of the tile.
void SetSignalType(Tile t, Track track, SignalType s)
Set the signal type for a track on a tile.
bool HasDepotReservation(Tile t)
Get the reservation state of the depot.
void SetHasSignals(Tile tile, bool signals)
Add/remove the 'has signal' bit from the RailTileType.
bool IsSnowOrDesertRailGround(Tile t)
Is the given rail tile snowy or deserty.
bool HasSignals(Tile t)
Checks if a rail tile has signals.
void SetSignalVariant(Tile t, Track track, SignalVariant v)
Set the signal variant for a track on a tile.
static bool IsRailDepotTile(Tile t)
Is this tile rail tile and a rail depot?
bool HasTrack(Tile tile, Track track)
Returns whether the given track is present on the given tile.
SignalState GetSingleSignalState(Tile t, uint8_t signalbit)
Get the state of a single signal.
void SetSignalStates(Tile tile, uint state)
Set the states of the signals (Along/AgainstTrackDir).
void SetRailType(Tile t, RailType r)
Sets the rail type of the given tile.
EnumBitSet< RailType, uint64_t > RailTypes
Allow incrementing of Track variables.
RailType
Enumeration for all possible railtypes.
@ RAILTYPE_END
Used for iterations.
@ INVALID_RAILTYPE
Flag for invalid railtype.
@ RAILTYPE_ELECTRIC
Electric rails.
@ RAILTYPE_RAIL
Standard non-electric rails.
All the railtype-specific information is stored here.
static const RailTypeInfo _original_railtypes[]
Global Railtype definition.
bool RoadNoLevelCrossing(RoadType roadtype)
Test if road disallows level crossings.
Money RoadBuildCost(RoadType roadtype)
Returns the cost of building the specified roadtype.
void UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(TileIndex tile, Axis road_axis)
Update adjacent level crossing tiles in this multi-track crossing, due to removal of a level crossing...
void MarkDirtyAdjacentLevelCrossingTiles(TileIndex tile, Axis road_axis)
Find adjacent level crossing tiles in this multi-track crossing and mark them dirty.
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).
RoadType GetRoadTypeRoad(Tile t)
Get the road type for RoadTramType being RTT_ROAD.
bool IsLevelCrossingTile(Tile t)
Return whether a tile is a level crossing tile.
RoadBits GetRoadBits(Tile t, RoadTramType rtt)
Get the present road bits for a specific road type.
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.
Track GetCrossingRailTrack(Tile tile)
Get the rail track of a level crossing.
DisallowedRoadDirections GetDisallowedRoadDirections(Tile t)
Gets the disallowed directions.
RoadType GetRoadTypeTram(Tile t)
Get the road type for RoadTramType being RTT_TRAM.
void MakeRoadNormal(Tile t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
Make a normal road tile.
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.
RoadBits GetCrossingRoadBits(Tile tile)
Get the road bits of a level crossing.
Owner GetRoadOwner(Tile t, RoadTramType rtt)
Get the owner of a specific road type.
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 HasRoadWorks(Tile t)
Check if a tile has road works.
RoadBits
Enumeration for the road parts on a tile.
@ ROAD_NONE
No road-part is build.
@ ROAD_Y
Full road along the y-axis (north-west + south-east).
@ ROAD_X
Full road along the x-axis (south-west + north-east).
@ RTT_ROAD
Road road type.
@ RTT_TRAM
Tram road type.
RoadType
The different roadtypes we support.
@ INVALID_ROADTYPE
flag for invalid roadtype
@ DRD_NONE
None of the directions are disallowed.
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.
void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner)
Add track to signal update buffer.
void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner)
Add side of tile to signal update buffer.
uint8_t SignalAgainstTrackdir(Trackdir trackdir)
Maps a trackdir to the bit that stores its status in the map arrays, in the direction against the tra...
uint8_t SignalAlongTrackdir(Trackdir trackdir)
Maps a trackdir to the bit that stores its status in the map arrays, in the direction along with the ...
uint8_t SignalOnTrack(Track track)
Maps a Track to the bits that store the status of the two signals that can be present on the given tr...
SignalType
Type of signal, i.e.
@ SIGTYPE_ENTRY
presignal block entry
@ SIGTYPE_EXIT
presignal block exit
@ SIGTYPE_BLOCK
block signal
SignalState
These are states in which a signal can be.
@ SIGNAL_STATE_RED
The signal is red.
@ SIGNAL_STATE_GREEN
The signal is green.
SignalVariant
Variant of the signal, i.e.
@ SIG_SEMAPHORE
Old-fashioned semaphore signal.
@ SIG_ELECTRIC
Light signal.
bool IsSpecialRailFoundation(Foundation f)
Tests if a foundation is a special rail foundation for single horizontal/vertical track.
Slope SlopeWithThreeCornersRaised(Corner corner)
Returns the slope with all except one corner raised.
Corner OppositeCorner(Corner corner)
Returns the opposite corner.
static constexpr Corner GetHalftileSlopeCorner(Slope s)
Returns the leveled halftile of a halftile slope.
static constexpr Slope RemoveHalftileSlope(Slope s)
Removes a halftile slope from a slope.
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.
bool IsNonContinuousFoundation(Foundation f)
Tests if a foundation is a non-continuous foundation, i.e.
Corner GetHighestSlopeCorner(Slope s)
Returns the highest corner of a slope (one corner raised or a steep slope).
Corner GetHalftileFoundationCorner(Foundation f)
Returns the halftile corner of a halftile-foundation.
static constexpr bool IsValidCorner(Corner corner)
Rangecheck for Corner enumeration.
static constexpr bool IsSteepSlope(Slope s)
Checks if a slope is steep.
bool IsSlopeWithThreeCornersRaised(Slope s)
Tests if a specific slope has exactly three corners raised.
Foundation FlatteningFoundation(Slope s)
Returns the foundation needed to flatten a slope.
static constexpr bool IsHalftileSlope(Slope s)
Checks for non-continuous slope on halftile foundations.
Foundation HalftileFoundation(Corner corner)
Returns the halftile foundation for single horizontal/vertical track.
Foundation SpecialRailFoundation(Corner corner)
Returns the special rail foundation for single horizontal/vertical track.
Slope ComplementSlope(Slope s)
Return the complement of a slope.
Slope SlopeWithOneCornerRaised(Corner corner)
Returns the slope with a specific corner raised.
Corner
Enumeration of tile corners.
Slope
Enumeration for the slope-type.
@ SLOPE_W
the west corner of the tile is raised
@ SLOPE_ELEVATED
bit mask containing all 'simple' slopes
@ SLOPE_NS
north and south corner are raised
@ SLOPE_E
the east corner of the tile is raised
@ SLOPE_S
the south corner of the tile is raised
@ SLOPE_N
the north corner of the tile is raised
@ SLOPE_SW
south and west corner are raised
@ SLOPE_NE
north and east corner are raised
@ SLOPE_SE
south and east corner are raised
@ SLOPE_NW
north and west corner are raised
@ SLOPE_EW
east and west corner are raised
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_STEEP_BOTH
The tile has a steep slope. The lowest corner is raised by a foundation and the upper halftile is lev...
@ FOUNDATION_INCLINED_Y
The tile has an along Y-axis inclined foundation.
@ FOUNDATION_STEEP_LOWER
The tile has a steep slope. The lowest corner is raised by a foundation to allow building railroad on...
@ FOUNDATION_HALFTILE_N
Level north halftile non-continuously.
@ FOUNDATION_INVALID
Used inside "rail_cmd.cpp" to indicate invalid slope/track combination.
static const uint32_t VALID_LEVEL_CROSSING_SLOPES
Constant bitset with safe slopes for building a level crossing.
Functions related to sound.
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.
PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
static const PaletteID PALETTE_TO_BARE_LAND
sets colour to bare land stuff for rail, road and crossings
bool IsRailStationTile(Tile t)
Is this tile a station tile and a rail station?
Track GetRailStationTrack(Tile t)
Get the rail track of a rail station tile.
bool IsStationTileBlocked(Tile t)
Is tile t a blocked tile?
bool HasStationRail(Tile t)
Has this station tile a rail?
Definition of base types and functions in a cross-platform compatible way.
Functions related to OTTD's strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames).
Class to backup a specific variable and restore it later.
void Restore()
Restore the variable.
VehicleType type
Type of vehicle.
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.
Represents a diagonal tile area.
Ground palette sprite of a tile, together with its sprite layout.
PalSpriteID ground
Palette and sprite for the ground.
Offsets for drawing fences.
Corner height_ref
Corner to use height offset from.
static uint Size()
Get the size of the map.
bool IsType(OrderType type) const
Check whether this order is of the given type.
Represents the covered area of e.g.
Combination of a palette sprite and a 'real' sprite.
SpriteID sprite
The 'real' sprite.
PaletteID pal
The palette (use PAL_NONE) if not needed).
static Company * Get(auto index)
static bool CanAllocateItem(size_t n=1)
static bool IsValidID(auto index)
static T * Create(Targs &&... args)
static Train * From(Vehicle *v)
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).
StringID railtype
Type of rail on the tile.
A pair-construct of a TileIndexDiff.
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.
'Train' is either a loco or a wagon.
Trackdir GetVehicleTrackdir() const override
Get the tracks of the train vehicle.
RailTypes railtypes
On which rail types the train can run.
TrackBits track
On which track the train currently is.
int CalcNextVehicleOffset() const
Calculate the offset from this vehicle's center to the following center taking the vehicle lengths in...
Direction direction
facing
VehStates vehstatus
Status.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
Order current_order
The current order (+ status, like: loading).
Vehicle * Next() const
Get the next vehicle of this vehicle.
int32_t y_pos
y coordinate.
int32_t x_pos
x coordinate.
uint16_t cur_speed
current speed
TileIndex tile
Current tile index.
@ CannotEnter
The vehicle cannot enter the tile.
@ EnteredWormhole
The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/...
std::tuple< Slope, int > GetTileSlopeZ(TileIndex tile)
Return the slope of a given 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.
@ TROPICZONE_DESERT
Tile is desert.
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.
@ Object
Contains objects such as transmitters and owned land.
@ Industry
Part of an industry.
@ Railway
A tile with railway.
@ House
A house by a town.
@ Road
A tile with road and/or tram tracks.
Definition of the game-calendar-timer.
void MakeDefaultName(T *obj)
Set the default name for a depot/waypoint.
TownID GetTownIndex(Tile t)
Get the index of which town this house/street is attached to.
Trackdir TrackToTrackdir(Track track)
Returns a Trackdir for the given Track.
Trackdir RemoveFirstTrackdir(TrackdirBits *trackdirs)
Removes first Trackdir from TrackdirBits and returns it.
Track TrackdirToTrack(Trackdir trackdir)
Returns the Track that a given Trackdir represents.
TrackBits CornerToTrackBits(Corner corner)
Returns a single horizontal/vertical trackbit that is in a specific tile corner.
TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
TrackdirBits TrackStatusToTrackdirBits(TrackStatus ts)
Returns the present-trackdir-information of a TrackStatus.
Track TrackBitsToTrack(TrackBits tracks)
Converts TrackBits to Track.
Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, TrackdirBits red_signals)
Builds a TrackStatus.
bool TracksOverlap(TrackBits bits)
Checks if the given tracks overlap, ie form a crossing.
TrackdirBits TrackdirReachesTrackdirs(Trackdir trackdir)
Maps a trackdir to the trackdirs that can be reached from it (ie, when entering the next tile.
bool IsValidTrack(Track track)
Checks if a Track is valid.
Track FindFirstTrack(TrackBits tracks)
Returns first Track from TrackBits or INVALID_TRACK.
bool IsDiagonalTrackdir(Trackdir trackdir)
Checks if a given Trackdir is diagonal.
TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir.
Track RemoveFirstTrack(TrackBits *tracks)
Removes first Track from TrackBits and returns it.
DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
Track DiagDirToDiagTrack(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track incidating with that diagdir.
TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
Discards all directional information from a TrackdirBits value.
Sprites to use and how to display them for train depot tiles.
TrackBits
Allow incrementing of Track variables.
@ TRACK_BIT_UPPER
Upper track.
@ TRACK_BIT_DEPOT
Bitflag for a depot.
@ TRACK_BIT_LEFT
Left track.
@ TRACK_BIT_Y
Y-axis track.
@ TRACK_BIT_CROSS
X-Y-axis cross.
@ TRACK_BIT_HORZ
Upper and lower track.
@ TRACK_BIT_NONE
No track.
@ TRACK_BIT_3WAY_NW
"Arrow" to the north-west
@ TRACK_BIT_X
X-axis track.
@ TRACK_BIT_LOWER
Lower track.
@ TRACK_BIT_ALL
All possible tracks.
@ TRACK_BIT_3WAY_NE
"Arrow" to the north-east
@ TRACK_BIT_RIGHT
Right track.
@ TRACK_BIT_3WAY_SW
"Arrow" to the south-west
@ TRACK_BIT_VERT
Left and right track.
@ TRACK_BIT_3WAY_SE
"Arrow" to the south-east
Trackdir
Enumeration for tracks and directions.
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
TrackdirBits
Allow incrementing of Trackdir variables.
@ TRACKDIR_BIT_LEFT_S
Track left, direction south.
@ TRACKDIR_BIT_Y_NW
Track y-axis, direction north-west.
@ TRACKDIR_BIT_UPPER_E
Track upper, direction east.
@ TRACKDIR_BIT_X_NE
Track x-axis, direction north-east.
@ TRACKDIR_BIT_LOWER_E
Track lower, direction east.
@ TRACKDIR_BIT_LEFT_N
Track left, direction north.
@ TRACKDIR_BIT_RIGHT_S
Track right, direction south.
@ TRACKDIR_BIT_Y_SE
Track y-axis, direction south-east.
@ TRACKDIR_BIT_NONE
No track build.
@ TRACKDIR_BIT_RIGHT_N
Track right, direction north.
@ TRACKDIR_BIT_UPPER_W
Track upper, direction west.
@ TRACKDIR_BIT_LOWER_W
Track lower, direction west.
@ TRACKDIR_BIT_X_SW
Track x-axis, direction south-west.
Track
These are used to specify a single track.
@ INVALID_TRACK
Flag for an invalid track.
@ TRACK_Y
Track along the y-axis (north-west to south-east).
@ TRACK_LOWER
Track in the lower corner of the tile (south).
@ TRACK_END
Used for iterations.
@ TRACK_LEFT
Track in the left corner of the tile (west).
@ TRACK_RIGHT
Track in the right corner of the tile (east).
@ TRACK_BEGIN
Used for iterations.
@ TRACK_X
Track along the x-axis (north-east to south-west).
@ TRACK_UPPER
Track in the upper corner of the tile (north).
Base for the train class.
static constexpr ConsistChangeFlags CCF_TRACK
Valid changes while vehicle is driving, and possibly changing tracks.
bool TryPathReserve(Train *v, bool mark_as_stuck=false, bool first_tile_okay=false)
Try to reserve a path to a safe position.
void FreeTrainTrackReservation(const Train *v)
Free the reserved path in front of a vehicle.
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...
@ TO_BUILDINGS
company buildings - depots, stations, HQ, ...
TransportType
Available types of transport.
@ TRANSPORT_RAIL
Transport by train.
@ TRANSPORT_WATER
Transport over water.
Header file for things common for tunnels and bridges.
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.
bool HasTunnelBridgeReservation(Tile t)
Get the reservation state of the rail tunnel/bridge.
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 EnsureNoTrainOnTrackBits(TileIndex tile, TrackBits track_bits)
Tests if a vehicle interacts with the specified track bits.
CommandCost TunnelBridgeIsFree(TileIndex tile, TileIndex endtile, const Vehicle *ignore)
Finds vehicle in tunnel / bridge.
const uint TILE_AXIAL_DISTANCE
Logical length of the tile in any DiagDirection used in vehicle movement.
const uint TILE_CORNER_DISTANCE
Logical length of the tile corner crossing in any non-diagonal direction used in vehicle movement.
@ Hidden
Vehicle is not visible.
@ Stopped
Vehicle is stopped by the player.
Functions related to vehicles.
bool HasVehicleOnTile(TileIndex tile, UnaryPred &&predicate)
Loop over vehicles on a tile, and check whether a predicate is true for any of them.
@ VEH_SHIP
Ship vehicle type.
@ VEH_TRAIN
Train vehicle type.
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 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 constexpr int BB_HEIGHT_UNDER_BRIDGE
Some values for constructing bounding boxes (BB).
Functions related to water management.
void TileLoop_Water(TileIndex tile)
Tile callback function signature for running periodic tile updates.
@ FLOOD_NONE
The tile does not flood neighboured tiles.
FloodingBehaviour GetFloodingBehaviour(TileIndex tile)
Returns the behaviour of a tile during flooding.
void CheckForDockingTile(TileIndex t)
Mark the supplied tile as a docking tile if it is suitable for docking.
bool IsPossibleDockingTile(Tile t)
Check whether it is feasible that the given tile could be a docking tile.
void MakeShore(Tile t)
Helper function to make a coast tile.
bool IsDockingTile(Tile t)
Checks whether the tile is marked as a dockling tile.
void SetDockingTile(Tile t, bool b)
Set the docking tile state of a tile.
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.