OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
37 #include "table/strings.h"
47 std::vector<RailType> _sorted_railtypes;
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;
134 ResolveRailTypeGUISprites(rti);
138 _sorted_railtypes.clear();
140 if (_railtypes[rt].label != 0 && !
HasBit(_railtypes_hidden_mask, rt)) {
141 _sorted_railtypes.push_back(rt);
144 std::sort(_sorted_railtypes.begin(), _sorted_railtypes.end(),
CompareRailTypes);
155 if (rti->
label == 0) {
182 static const uint8_t _track_sloped_sprites[14] = {
251 if (current == future) {
412 static inline bool ValParamTrackOrientation(
Track track)
438 if (ret.
Failed())
return ret;
446 if (ret.
Failed())
return ret;
449 if (ret.
Failed())
return ret;
454 if (!auto_remove_signals)
return_cmd_error(STR_ERROR_MUST_REMOVE_SIGNALS_FIRST);
459 if (ret_remove_signals.
Failed())
return ret_remove_signals;
460 cost.
AddCost(ret_remove_signals);
471 if (ret.
Failed())
return ret;
501 if (ret.
Failed())
return ret;
505 if (ret.
Failed())
return ret;
514 RoadType roadtype_road = GetRoadTypeRoad(tile);
515 RoadType roadtype_tram = GetRoadTypeTram(tile);
530 if (ret.
Failed())
return ret;
534 if (num_new_road_pieces > 0) {
539 if (num_new_tram_pieces > 0) {
550 Company::Get(road_owner)->infrastructure.road[roadtype_road] += num_new_road_pieces;
554 Company::Get(tram_owner)->infrastructure.road[roadtype_tram] += num_new_tram_pieces;
573 if (ret.
Failed())
return ret;
577 if (ret.
Failed())
return ret;
581 cost.
AddCost(-_price[PR_CLEAR_WATER]);
582 cost.
AddCost(_price[PR_CLEAR_ROUGH]);
618 bool crossing =
false;
620 if (!ValParamTrackOrientation(track))
return CMD_ERROR;
637 if (ret.
Failed())
return ret;
642 if (ret.
Failed())
return ret;
671 if (ret.
Failed())
return ret;
675 if (ret.
Failed())
return ret;
678 if ((present & trackbit) == 0)
return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
766 bool flooded =
false;
775 TrackBits to_remove = lower_track & rail_bits;
776 if (to_remove != 0) {
780 if (!flooded)
return flooded;
781 rail_bits = rail_bits & ~to_remove;
782 if (rail_bits == 0) {
808 { -1, 0 }, { 0, 1 }, { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, 1 },
811 { 1, 0 }, { 0, -1 }, { 0, -1 }, { 1, 0 }, { 0, -1 }, { -1, 0 },
819 int x =
TileX(start);
820 int y =
TileY(start);
831 int trdx = _trackdelta[*trackdir].
x;
832 int trdy = _trackdelta[*trackdir].
y;
835 trdx += _trackdelta[*trackdir ^ 1].
x;
836 trdy += _trackdelta[*trackdir ^ 1].
y;
840 while ((trdx <= 0 && dx > 0) ||
841 (trdx >= 0 && dx < 0) ||
842 (trdy <= 0 && dy > 0) ||
843 (trdy >= 0 && dy < 0)) {
844 if (!
HasBit(*trackdir, 3)) {
856 trdx = _trackdelta[*trackdir].
x;
857 trdy = _trackdelta[*trackdir].
y;
885 CommandCost ret = ValidateAutoDrag(&trackdir, tile, end_tile);
886 if (ret.
Failed())
return ret;
888 bool had_success =
false;
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 cost.
AddCost(_price[PR_BUILD_FOUNDATION]);
987 bool rotate_existing_depot =
false;
990 if (ret.
Failed())
return ret;
995 if (ret.
Failed())
return ret;
997 rotate_existing_depot =
true;
1000 if (!rotate_existing_depot) {
1002 if (cost.
Failed())
return cost;
1010 if (rotate_existing_depot) {
1028 cost.
AddCost(_price[PR_BUILD_DEPOT_TRAIN]);
1052 CommandCost CmdBuildSingleSignal(
DoCommandFlag 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)
1055 if (cycle_start > cycle_stop || cycle_stop > SIGTYPE_LAST)
return CMD_ERROR;
1068 if (ret.
Failed())
return ret;
1084 if (signals_copy != 0 && sigvar != GetSignalVariant(tile, track)) {
1088 }
else if (convert_signal) {
1090 if (ctrl_pressed || GetSignalVariant(tile, track) != sigvar) {
1119 SetSignalType(tile, track, sigtype);
1120 SetSignalVariant(tile, track, sigvar);
1126 if (signals_copy == 0) {
1130 SetSignalType(tile, track, sigtype);
1131 SetSignalVariant(tile, track, sigvar);
1132 while (num_dir_cycle-- > 0) CycleSignalSide(tile, track);
1134 if (convert_signal) {
1140 sigtype = GetSignalType(tile, track);
1143 SetSignalType(tile, track, sigtype);
1144 SetSignalVariant(tile, track, sigvar);
1150 }
else if (ctrl_pressed) {
1152 sigtype = (
SignalType)(GetSignalType(tile, track) + 1);
1154 if (sigtype < cycle_start || sigtype > cycle_stop) sigtype = cycle_start;
1156 SetSignalType(tile, track, sigtype);
1162 CycleSignalSide(tile, track);
1164 sigtype = GetSignalType(tile, track);
1171 SetSignalVariant(tile, track, sigvar);
1172 SetSignalType(tile, track, sigtype);
1179 if (IsPbsSignal(sigtype)) {
1199 static bool AdvanceSignalAutoFill(
TileIndex &tile,
Trackdir &trackdir,
bool remove)
1238 default:
return false;
1258 static CommandCost CmdSignalTrackHelper(
DoCommandFlag flags,
TileIndex tile,
TileIndex end_tile,
Track track,
SignalType sigtype,
SignalVariant sigvar,
bool mode,
bool remove,
bool autofill,
bool minimise_gaps,
int signal_density)
1263 if (signal_density == 0 || signal_density > 20)
return CMD_ERROR;
1270 signal_density *= TILE_AXIAL_DISTANCE;
1273 CommandCost ret = ValidateAutoDrag(&trackdir, tile, end_tile);
1274 if (ret.
Failed())
return ret;
1277 Trackdir start_trackdir = trackdir;
1286 assert(signals != 0);
1289 sigvar = GetSignalVariant(tile, track);
1291 sigtype = GetSignalType(tile, track);
1298 uint8_t signal_dir = 0;
1315 int last_used_ctr = -signal_density;
1316 int last_suitable_ctr = 0;
1320 bool had_success =
false;
1323 uint8_t signals = 0;
1328 CommandCost ret = remove ?
Command<CMD_REMOVE_SINGLE_SIGNAL>::Do(do_flags, tile,
TrackdirToTrack(trackdir)) :
Command<CMD_BUILD_SINGLE_SIGNAL>::Do(do_flags, tile,
TrackdirToTrack(trackdir), sigtype, sigvar,
false, signal_ctr == 0, mode,
SIGTYPE_BLOCK,
SIGTYPE_BLOCK, 0, signals);
1348 build_signal(tile, trackdir,
false);
1349 }
else if (minimise_gaps) {
1353 if (signal_ctr > last_used_ctr + signal_density && last_suitable_tile !=
INVALID_TILE) {
1355 if (build_signal(last_suitable_tile, last_suitable_trackdir,
false)) {
1357 last_used_ctr = last_suitable_ctr;
1361 if (signal_ctr == last_used_ctr + signal_density) {
1363 if (build_signal(tile, trackdir,
false)) {
1364 last_used_ctr = signal_ctr;
1369 if (build_signal(tile, trackdir,
true)) {
1370 last_suitable_tile = tile;
1371 last_suitable_ctr = signal_ctr;
1372 last_suitable_trackdir = trackdir;
1375 }
else if (signal_ctr >= last_used_ctr + signal_density) {
1377 build_signal(tile, trackdir,
false);
1378 last_used_ctr = signal_ctr;
1384 signal_ctr += (
IsDiagonalTrackdir(trackdir) ? TILE_AXIAL_DISTANCE : TILE_CORNER_DISTANCE);
1388 signal_ctr += TILE_AXIAL_DISTANCE;
1393 if (remove || minimise_gaps) {
1398 signal_ctr += TILE_AXIAL_DISTANCE;
1399 for (uint i = TILE_AXIAL_DISTANCE; i < len; i += TILE_AXIAL_DISTANCE) {
1400 if (signal_ctr >= last_used_ctr + signal_density) last_used_ctr = signal_ctr;
1401 signal_ctr += TILE_AXIAL_DISTANCE;
1410 if (!AdvanceSignalAutoFill(tile, trackdir, remove))
break;
1413 if (tile == start_tile && trackdir == start_trackdir)
break;
1415 if (tile == end_tile)
break;
1417 signal_ctr += (
IsDiagonalTrackdir(trackdir) ? TILE_AXIAL_DISTANCE : TILE_CORNER_DISTANCE);
1426 if (!remove && minimise_gaps && signal_ctr > last_used_ctr + signal_density && last_suitable_tile !=
INVALID_TILE) {
1427 build_signal(last_suitable_tile, last_suitable_trackdir,
false);
1430 return had_success ? total_cost : last_error;
1451 return CmdSignalTrackHelper(flags, tile, end_tile, track, sigtype, sigvar, mode,
false, autofill, minimise_gaps, signal_density);
1473 if (ret.
Failed())
return ret;
1481 }
else if (IsPbsSignal(GetSignalType(tile, track))) {
1484 for (
int i = 0; v ==
nullptr && i < 2; i++, td =
ReverseTrackdir(td)) {
1529 return CmdSignalTrackHelper(flags, tile, end_tile, track,
SIGTYPE_BLOCK,
SIG_ELECTRIC,
false,
true, autofill,
false, 1);
1564 bool found_convertible_track =
false;
1580 error.
MakeError(STR_ERROR_CROSSING_DISALLOWED_RAIL);
1603 std::vector<Train *> vehicles_affected;
1623 vehicles_affected.push_back(v);
1660 found_convertible_track =
true;
1672 found_convertible_track =
true;
1683 if (endtile < tile) {
1707 vehicles_affected.push_back(v);
1735 found_convertible_track =
true;
1746 found_convertible_track =
true;
1751 for (uint i = 0; i < vehicles_affected.size(); ++i) {
1758 for (
Train *v : affected_trains) {
1763 return found_convertible_track ? cost : error;
1770 if (ret.
Failed())
return ret;
1774 if (ret.
Failed())
return ret;
1790 delete Depot::GetByTile(tile);
1791 DoClearSquare(tile);
1827 if (ret.
Failed())
return ret;
1835 if (ret.
Failed())
return ret;
1839 DoClearSquare(tile);
1841 cost.AddCost(_price[PR_CLEAR_WATER]);
1848 return RemoveTrainDepot(tile, flags);
1875 case 0: side =
false;
break;
1876 case 2: side =
true;
break;
1879 static const Point SignalPositions[2][12] = {
1882 { 8, 5}, {14, 1}, { 1, 14}, { 9, 11}, { 1, 0}, { 3, 10},
1884 {11, 4}, {14, 14}, {11, 3}, { 4, 13}, { 3, 4}, {11, 13}
1887 {14, 1}, {12, 10}, { 4, 6}, { 1, 14}, {10, 4}, { 0, 1},
1889 {14, 14}, { 5, 12}, {11, 13}, { 4, 3}, {13, 4}, { 3, 11}
1896 SignalType type = GetSignalType(tile, track);
1905 sprite += type * 16 + variant * 64 + image * 2 + condition + (type > SIGTYPE_LAST_NOPBS ? 64 : 0);
1911 static uint32_t _drawtile_track_palette;
1926 { CORNER_INVALID, 0, 1, 16, 1 },
1927 { CORNER_INVALID, 1, 0, 1, 16 },
1928 { CORNER_W, 8, 8, 1, 1 },
1929 { CORNER_N, 8, 8, 1, 1 },
1930 { CORNER_INVALID, 0, 1, 16, 1 },
1931 { CORNER_INVALID, 1, 0, 1, 16 },
1932 { CORNER_INVALID, 0, 1, 16, 1 },
1933 { CORNER_INVALID, 1, 0, 1, 16 },
1934 { CORNER_INVALID, 0, 15, 16, 1 },
1935 { CORNER_INVALID, 15, 0, 1, 16 },
1936 { CORNER_E, 8, 8, 1, 1 },
1937 { CORNER_S, 8, 8, 1, 1 },
1938 { CORNER_INVALID, 0, 15, 16, 1 },
1939 { CORNER_INVALID, 15, 0, 1, 16 },
1940 { CORNER_INVALID, 0, 15, 16, 1 },
1941 { CORNER_INVALID, 15, 0, 1, 16 },
2014 uint num_sprites = 0;
2016 if (base_image == 0) {
2017 base_image = SPR_TRACK_FENCE_FLAT_X;
2021 assert(num_sprites > 0);
2023 switch (GetRailGroundType(ti->
tile)) {
2045 switch (track_corner) {
2050 default: NOT_REACHED();
2059 static const int INF = 1000;
2060 static const SubSprite _halftile_sub_sprite[4] = {
2061 { -INF , -INF , 32 - 33, INF },
2062 { -INF , 0 + 7, INF , INF },
2063 { -31 + 33, -INF , INF , INF },
2064 { -INF , -INF , INF , 30 - 23 }
2076 Corner halftile_corner = CORNER_INVALID;
2093 DrawShoreTile(ti->
tileh);
2104 default: image = SPR_FLAT_GRASS_TILE;
break;
2119 }
else if (no_combine) {
2155 DrawTrackSprite(ground +
RTO_S, PAL_NONE, ti,
SLOPE_S);
break;
2157 DrawTrackSprite(ground +
RTO_W, PAL_NONE, ti,
SLOPE_W);
break;
2207 default: image = SPR_FLAT_GRASS_TILE;
break;
2212 DrawGroundSprite(image, PAL_NONE, &(_halftile_sub_sprite[halftile_corner]));
2218 default: NOT_REACHED();
2225 DrawTrackSprite(ground + offset, PAL_NONE, ti, fake_slope);
2227 DrawTrackSprite(overlay + offset,
PALETTE_CRASH, ti, fake_slope);
2241 if (rti->UsesOverlay()) {
2242 DrawTrackBitsOverlay(ti, track, rti);
2248 Corner halftile_corner = CORNER_INVALID;
2264 bool junction =
false;
2271 DrawShoreTile(ti->
tileh);
2274 image = SPR_FLAT_WATER_TILE;
2280 default: image = SPR_FLAT_GRASS_TILE;
break;
2321 DrawShoreTile(ti->
tileh);
2323 sub = &(_halftile_sub_sprite[track_corner]);
2382 static const uint8_t _corner_to_track_sprite[] = {3, 1, 2, 0};
2390 auto MAYBE_DRAW_SIGNAL = [&](uint8_t signalbit,
SignalOffsets image, uint pos,
Track track) {
2397 MAYBE_DRAW_SIGNAL(2, SIGNAL_TO_NORTH, 0,
TRACK_LEFT);
2398 MAYBE_DRAW_SIGNAL(3, SIGNAL_TO_SOUTH, 1,
TRACK_LEFT);
2401 MAYBE_DRAW_SIGNAL(0, SIGNAL_TO_NORTH, 2,
TRACK_RIGHT);
2402 MAYBE_DRAW_SIGNAL(1, SIGNAL_TO_SOUTH, 3,
TRACK_RIGHT);
2405 MAYBE_DRAW_SIGNAL(3, SIGNAL_TO_WEST, 4,
TRACK_UPPER);
2406 MAYBE_DRAW_SIGNAL(2, SIGNAL_TO_EAST, 5,
TRACK_UPPER);
2409 MAYBE_DRAW_SIGNAL(1, SIGNAL_TO_WEST, 6,
TRACK_LOWER);
2410 MAYBE_DRAW_SIGNAL(0, SIGNAL_TO_EAST, 7,
TRACK_LOWER);
2413 MAYBE_DRAW_SIGNAL(3, SIGNAL_TO_SOUTHWEST, 8,
TRACK_X);
2414 MAYBE_DRAW_SIGNAL(2, SIGNAL_TO_NORTHEAST, 9,
TRACK_X);
2417 MAYBE_DRAW_SIGNAL(3, SIGNAL_TO_SOUTHEAST, 10,
TRACK_Y);
2418 MAYBE_DRAW_SIGNAL(2, SIGNAL_TO_NORTHWEST, 11,
TRACK_Y);
2422 static void DrawTile_Track(
TileInfo *ti)
2454 if (rti->UsesOverlay()) {
2455 image = SPR_FLAT_GRASS_TILE;
2462 if (IsSnowRailGround(ti->
tile)) {
2463 if (image != SPR_FLAT_GRASS_TILE) {
2466 image = SPR_FLAT_SNOW_DESERT_TILE;
2472 if (rti->UsesOverlay()) {
2543 void DrawTrainDepotSprite(
int x,
int y,
int dir,
RailType railtype)
2550 if (image != SPR_FLAT_GRASS_TILE) image += offset;
2555 if (rti->UsesOverlay()) {
2565 if (depot_sprite != 0) offset = depot_sprite - SPR_RAIL_DEPOT_SE_1;
2570 static int GetSlopePixelZ_Track(
TileIndex tile, uint x, uint y,
bool)
2588 static void TileLoop_Track(
TileIndex tile)
2699 default: NOT_REACHED();
2704 if (old_ground != new_ground) {
2705 SetRailGroundType(tile, new_ground);
2717 default: NOT_REACHED();
2732 default: NOT_REACHED();
2773 static bool ClickTile_Track(
TileIndex tile)
2789 td->
str = STR_LAI_RAIL_DESCRIPTION_TRACK;
2793 static const StringID signal_type[6][6] = {
2795 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_SIGNALS,
2796 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_PRESIGNALS,
2797 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_EXITSIGNALS,
2798 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_COMBOSIGNALS,
2799 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_PBSSIGNALS,
2800 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_NOENTRYSIGNALS
2803 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_PRESIGNALS,
2804 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRESIGNALS,
2805 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_EXITSIGNALS,
2806 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_COMBOSIGNALS,
2807 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_PBSSIGNALS,
2808 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_NOENTRYSIGNALS
2811 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_EXITSIGNALS,
2812 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_EXITSIGNALS,
2813 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_EXITSIGNALS,
2814 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_EXIT_COMBOSIGNALS,
2815 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_EXIT_PBSSIGNALS,
2816 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_EXIT_NOENTRYSIGNALS
2819 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_COMBOSIGNALS,
2820 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_COMBOSIGNALS,
2821 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_EXIT_COMBOSIGNALS,
2822 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_COMBOSIGNALS,
2823 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_COMBO_PBSSIGNALS,
2824 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_COMBO_NOENTRYSIGNALS
2827 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_PBSSIGNALS,
2828 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_PBSSIGNALS,
2829 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_EXIT_PBSSIGNALS,
2830 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_COMBO_PBSSIGNALS,
2831 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PBSSIGNALS,
2832 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PBS_NOENTRYSIGNALS
2835 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_NOENTRYSIGNALS,
2836 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PRE_NOENTRYSIGNALS,
2837 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_EXIT_NOENTRYSIGNALS,
2838 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_COMBO_NOENTRYSIGNALS,
2839 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_PBS_NOENTRYSIGNALS,
2840 STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NOENTRYSIGNALS
2847 primary_signal = GetSignalType(tile,
TRACK_UPPER);
2850 secondary_signal = primary_signal = GetSignalType(tile,
TRACK_LOWER);
2853 td->
str = signal_type[secondary_signal][primary_signal];
2858 td->
str = STR_LAI_RAIL_DESCRIPTION_TRAIN_DEPOT;
2880 uint num_pieces = 1;
2887 Company::Get(old_owner)->infrastructure.rail[rt] -= num_pieces;
2888 Company::Get(new_owner)->infrastructure.rail[rt] += num_pieces;
2892 Company::Get(old_owner)->infrastructure.signal -= num_sigs;
2893 Company::Get(new_owner)->infrastructure.signal += num_sigs;
2902 static const uint8_t _fractcoords_behind[4] = { 0x8F, 0x8, 0x80, 0xF8 };
2903 static const uint8_t _fractcoords_enter[4] = { 0x8A, 0x48, 0x84, 0xA8 };
2904 static const int8_t _deltacoord_leaveoffset[8] = {
2922 case DIAGDIR_NE:
return ((
int)(v->
x_pos & 0x0F) - ((_fractcoords_enter[dir] & 0x0F) - (length + 1)));
2923 case DIAGDIR_SE:
return -((int)(v->
y_pos & 0x0F) - ((_fractcoords_enter[dir] >> 4) + (length + 1)));
2924 case DIAGDIR_SW:
return -((int)(v->
x_pos & 0x0F) - ((_fractcoords_enter[dir] & 0x0F) + (length + 1)));
2925 case DIAGDIR_NW:
return ((
int)(v->
y_pos & 0x0F) - ((_fractcoords_enter[dir] >> 4) - (length + 1)));
2926 default: NOT_REACHED();
2942 uint8_t fract_coord = (x & 0xF) + ((y & 0xF) << 4);
2954 uint8_t fract_coord_leave =
2955 ((_fractcoords_enter[dir] & 0x0F) +
2956 (length + 1) * _deltacoord_leaveoffset[dir]) +
2957 (((_fractcoords_enter[dir] >> 4) +
2958 ((length + 1) * _deltacoord_leaveoffset[dir + 4])) << 4);
2960 if (fract_coord_leave == fract_coord) {
2962 if ((v = v->
Next()) !=
nullptr) {
2967 }
else if (_fractcoords_enter[dir] == fract_coord) {
3006 switch (rail_bits) {
3014 if (z_old != z_new || tileh_old != tileh_new)
return_cmd_error(STR_ERROR_MUST_REMOVE_RAILROAD_TRACK);
3021 if (z_old != z_new)
return_cmd_error(STR_ERROR_MUST_REMOVE_RAILROAD_TRACK);
3025 if (tileh_old != tileh_new) {
3057 switch (rail_bits) {
3062 default:
return autoslope_result;
3071 for (
Corner corner = (
Corner)0; corner < CORNER_END; corner = (
Corner)(corner + 1)) {
3072 if (allowed_corner == corner)
continue;
3091 GetSlopePixelZ_Track,
3095 GetTileTrackStatus_Track,
3099 ChangeTileOwner_Track,
3102 GetFoundation_Track,
3103 TerraformTile_Track,
CursorID convert
Cursor for converting track.
@ INVALID_RAILTYPE
Flag for invalid railtype.
@ SLOPE_E
the east corner of the tile is raised
SpriteID track_y
single piece of rail in Y direction, with ground
@ SLOPE_SE
south and east corner are raised
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
@ MP_HOUSE
A house by a town.
uint8_t _display_opt
What do we want to draw/do?
void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index)
Delete inspect window for a given feature and index.
static CommandCost CmdSignalTrackHelper(DoCommandFlag 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.
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...
@ OWNER_DEITY
The object is owned by a superuser / goal script.
@ VETSB_CANNOT_ENTER
The vehicle cannot enter the tile.
@ TCX_UPPER_HALFTILE
Querying information about the upper part of a tile with halftile foundation.
CommandCost CmdRemoveSingleRail(DoCommandFlag flags, TileIndex tile, Track track)
Remove a single piece of track.
@ RTO_JUNCTION_SE
Ballast for junction 'pointing' SE.
@ TROPICZONE_DESERT
Tile is desert.
SpriteID build_ew_rail
button for building single rail in E-W direction
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Direction ReverseDir(Direction d)
Return the reverse of a direction.
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-...
PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
@ RTO_W
Piece of rail in western corner.
@ FOUNDATION_HALFTILE_N
Level north halftile non-continuously.
static const RailTypeInfo _original_railtypes[]
Global Railtype definition.
Track FindFirstTrack(TrackBits tracks)
Returns first Track from TrackBits or INVALID_TRACK.
static Vehicle * EnsureNoShipProc(Vehicle *v, void *)
Test-procedure for HasVehicleOnPos to check for a ship.
uint8_t road_side
the side of the road vehicles drive on
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
@ SIG_SEMAPHORE
Old-fashioned semaphore signal.
bool IsType(OrderType type) const
Check whether this order is of the given type.
static Titem * Get(size_t index)
Returns Titem with given index.
DisallowedRoadDirections GetDisallowedRoadDirections(Tile t)
Gets the disallowed directions.
@ SIGTYPE_EXIT
presignal block exit
Track GetCrossingRailTrack(Tile tile)
Get the rail track of a level crossing.
static constexpr bool IsHalftileSlope(Slope s)
Checks for non-continuous slope on halftile foundations.
CommandCost CmdRemoveRailroadTrack(DoCommandFlag flags, TileIndex end_tile, TileIndex start_tile, Track track)
Build rail on a stretch of track.
@ RFO_SLOPE_NW_SW
Slope NW, Track Y, Fence SW.
@ RAIL_GROUND_HALF_SNOW
Snow only on higher part of slope (steep or one corner raised)
@ RFO_SLOPE_SW_SE
Slope SW, Track X, Fence SE.
@ SIGTYPE_BLOCK
block signal
RoadBits
Enumeration for the road parts on a tile.
bool ValParamRailType(const RailType rail)
Validate functions for rail building.
RailFenceOffset
Offsets from base sprite for fence sprites.
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
static FenceOffset _fence_offsets[]
Offsets for drawing fences.
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track)
Use this function to notify YAPF that track layout (or signal configuration) has change.
uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
Calculates the length of a tunnel or a bridge (without end tiles)
bool forbid_90_deg
forbid trains to make 90 deg turns
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
SpriteID build_y_rail
button for building single rail in Y direction
TrackdirBits TrackStatusToTrackdirBits(TrackStatus ts)
Returns the present-trackdir-information of a TrackStatus.
@ TRACK_BIT_X
X-axis track.
TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC diff)
Add a TileIndexDiffC to a TileIndex and returns the new one.
Foundation FlatteningFoundation(Slope s)
Returns the foundation needed to flatten a slope.
@ ROAD_Y
Full road along the y-axis (north-west + south-east)
bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
Find out if the slope of the tile is suitable to build a depot of given direction.
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
uint GetRailtypeSpriteOffset() const
Offset between the current railtype and normal rail.
int TicksToLeaveDepot(const Train *v)
Compute number of ticks when next wagon will leave a depot.
@ TO_BUILDINGS
company buildings - depots, stations, HQ, ...
Tile information, used while rendering the tile.
bool HasVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Checks whether a vehicle is on a specific location.
Class to backup a specific variable and restore it later.
StringID railtype
Type of rail on the tile.
@ RTF_NO_SPRITE_COMBINE
Bit number for using non-combined junctions.
@ RAILTYPE_RAIL
Standard non-electric rails.
SpriteID tunnel
tunnel sprites base
@ RAIL_GROUND_FENCE_SE
Grass with a fence at the SE edge.
@ RAILTYPE_ELECTRIC
Electric rails.
T * Next() const
Get next vehicle in the chain.
Money RailClearCost(RailType railtype)
Returns the 'cost' of clearing the specified railtype.
bool IsOnewaySignal(Tile t, Track track)
One-way signals can't be passed the 'wrong' way.
TrackBits GetReservedTrackbits(TileIndex t)
Get the reserved trackbits for any tile, regardless of type.
Owner owner[4]
Name of the owner(s)
static CommandCost CmdRailTrackHelper(DoCommandFlag 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.
@ SLOPE_NE
north and east corner are raised
@ TRANSPORT_WATER
Transport over water.
Track TrackdirToTrack(Trackdir trackdir)
Returns the Track that a given Trackdir represents.
Slope GetTileSlope(TileIndex tile)
Return the slope of a given tile inside the map.
DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
static constexpr Slope RemoveHalftileSlope(Slope s)
Removes a halftile slope from a slope.
static const uint LEVELCROSSING_TRACKBIT_FACTOR
Multiplier for how many regular track bits a level crossing counts.
static debug_inline bool IsPlainRail(Tile t)
Returns whether this is plain rails, with or without signals.
@ INVALID_OWNER
An invalid owner.
static VehicleEnterTileStatus VehicleEnter_Track(Vehicle *u, TileIndex tile, int x, int y)
Tile callback routine when vehicle enters tile.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
@ RAIL_TILE_SIGNALS
Normal rail tile with signals.
void MarkDirtyAdjacentLevelCrossingTiles(TileIndex tile, Axis road_axis)
Find adjacent level crossing tiles in this multi-track crossing and mark them dirty.
int GetSlopeZInCorner(Slope tileh, Corner corner)
Determine the Z height of a corner relative to TileZ.
TrackBits GetCrossingRailBits(Tile tile)
Get the rail track bits of a level crossing.
static Vehicle * UpdateTrainPowerProc(Vehicle *v, void *data)
Update power of train under which is the railtype being converted.
@ SIG_ELECTRIC
Light signal.
bool AutoslopeEnabled()
Tests if autoslope is enabled for _current_company.
Owner
Enum for all companies/owners.
RailType
Enumeration for all possible railtypes.
@ TRACK_BIT_HORZ
Upper and lower track.
Tindex index
Index of this pool item.
Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
Foundation HalftileFoundation(Corner corner)
Returns the halftile foundation for single horizontal/vertical track.
@ VEH_TRAIN
Train vehicle type.
bool HasDepotReservation(Tile t)
Get the reservation state of the depot.
void SetPresentSignals(Tile tile, uint signals)
Set whether the given signals are present (Along/AgainstTrackDir)
SpriteID signals[SIGTYPE_END][2][2]
signal GUI sprites (type, variant, state)
@ RAIL_GROUND_FENCE_NW
Grass with a fence at the NW edge.
bool FloodHalftile(TileIndex t)
Called from water_cmd if a non-flat rail-tile gets flooded and should be converted to shore.
SpriteID sprite
The 'real' sprite.
bool HasTunnelBridgeReservation(Tile t)
Get the reservation state of the rail tunnel/bridge.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
@ RTO_SLOPE_SW
Piece of rail on slope with south-west raised.
@ SIGNAL_STATE_GREEN
The signal is green.
@ RAIL_GROUND_FENCE_VERT1
Grass with a fence at the eastern side.
static std::unique_ptr< TileIterator > Create(TileIndex corner1, TileIndex corner2, bool diagonal)
Create either an OrthogonalTileIterator or DiagonalTileIterator given the diagonal parameter.
This struct contains all the info that is needed to draw and construct tracks.
@ VETSB_CONTINUE
Bit sets of the above specified bits.
CursorID autorail
Cursor for autorail tool.
@ TRACKDIR_BIT_LEFT_N
Track left, direction north.
RailTypeLabelList alternate_labels
Rail type labels this type provides in addition to the main label.
static const uint BB_HEIGHT_UNDER_BRIDGE
Some values for constructing bounding boxes (BB).
static constexpr bool IsSteepSlope(Slope s)
Checks if a slope is steep.
bool IsRailStationTile(Tile t)
Is this tile a station tile and a rail station?
@ TRACK_BIT_VERT
Left and right track.
uint GetPartialPixelZ(int x, int y, Slope corners)
Determines height at given coordinate of a slope.
static const uint TILE_SIZE
Tile size in world coordinates.
@ RAIL_GROUND_BARREN
Nothing (dirt)
DiagDirection
Enumeration for diagonal directions.
void DrawBridgeMiddle(const TileInfo *ti)
Draw the middle bits of a bridge.
SignalState
These are states in which a signal can be.
static debug_inline bool IsNormalRoad(Tile t)
Return whether a tile is a normal road.
bool IsLevelCrossingTile(Tile t)
Return whether a tile is a level crossing tile.
SpriteID single_n
single piece of rail in the northern corner
@ RAIL_GROUND_FENCE_SENW
Grass with a fence at the NW and SE edges.
@ SLOPE_NW
north and west corner are raised
bool IsLevelCrossing(Tile t)
Return whether a tile is a level crossing.
@ RAILTYPE_END
Used for iterations.
ClientSettings _settings_client
The current settings for this game.
CursorID rail_swne
Cursor for building rail in X direction.
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 VehicleEnterDepot(Vehicle *v)
Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it,...
@ RAIL_GROUND_FENCE_VERT2
Grass with a fence at the western side.
bool IsValidTrack(Track track)
Checks if a Track is valid.
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...
@ MP_INDUSTRY
Part of an industry.
int y
Y position of the tile in unit coordinates.
void InitRailTypes()
Resolve sprites of custom rail types.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
@ RFO_SLOPE_SW_NW
Slope SW, Track X, Fence NW.
@ SLOPE_W
the west corner of the tile is raised
static CommandCost CheckTrackCombination(TileIndex tile, TrackBits to_build)
Check that the new track bits may be built.
static constexpr Corner GetHalftileSlopeCorner(Slope s)
Returns the leveled halftile of a halftile slope.
@ TRACK_BIT_3WAY_SW
"Arrow" to the south-west
CommandCost CmdBuildRailroadTrack(DoCommandFlag 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.
void SetHasSignals(Tile tile, bool signals)
Add/remove the 'has signal' bit from the RailTileType.
@ SLOPE_EW
east and west corner are raised
@ TRACKDIR_BIT_Y_NW
Track y-axis, direction north-west.
struct RailTypeInfo::@26 strings
Strings associated with the rail type.
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
SignalState GetSingleSignalState(Tile t, uint8_t signalbit)
Get the state of a single signal.
Represents a diagonal tile area.
@ DC_EXEC
execute the given command
int GetSlopePixelZ(int x, int y, bool ground_vehicle)
Return world Z coordinate of a given point of a tile.
Used to only draw a part of the sprite.
uint32_t PaletteID
The number of the palette.
uint8_t landscape
the landscape we're currently in
RailTypes
Allow incrementing of Track variables.
@ RFO_SLOPE_SE_SW
Slope SE, Track Y, Fence SW.
@ MP_ROAD
A tile with road (or tram tracks)
StringID GetErrorMessage() const
Returns the error message of a command.
Tile description for the 'land area information' tool.
constexpr bool HasExactlyOneBit(T value)
Test whether value has exactly 1 bit set.
void SetSignalStates(Tile tile, uint state)
Set the states of the signals (Along/AgainstTrackDir)
DoCommandFlag
List of flags for a command.
@ SLOPE_S
the south corner of the tile is raised
Foundation
Enumeration for Foundations.
constexpr T KillFirstBit(T value)
Clear the first bit in an integer.
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
uint GetSignalStates(Tile tile)
Set the states of the signals (Along/AgainstTrackDir)
RailType AllocateRailType(RailTypeLabel label)
Allocate a new rail type label.
@ TRACK_END
Used for iterations.
RoadBits GetCrossingRoadBits(Tile tile)
Get the road bits of a level crossing.
bool Succeeded() const
Did this command succeed?
@ RTO_JUNCTION_NE
Ballast for junction 'pointing' NE.
TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
bool TracksOverlap(TrackBits bits)
Checks if the given tracks overlap, ie form a crossing.
int32_t x_pos
x coordinate.
GameCreationSettings game_creation
settings used during the creation of a game (map)
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
SpriteID ground
ground sprite for a 3-way switch
Slope SlopeWithThreeCornersRaised(Corner corner)
Returns the slope with all except one corner raised.
TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir.
SpriteID build_depot
button for building depots
Slope ComplementSlope(Slope s)
Return the complement of a slope.
Slope tileh
Slope of the tile.
static void DrawTrackFence_SE(const TileInfo *ti, SpriteID base_image, uint num_sprites)
Draw fence at SE border matching the tile slope.
static debug_inline TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
@ RTO_SLOPE_NE
Piece of rail on slope with north-east raised.
static void DrawTrackBits(TileInfo *ti, TrackBits track)
Draw ground sprite and track bits.
@ TRACK_BIT_NONE
No track.
RailTypes compatible_railtypes
bitmask to the OTHER railtypes on which an engine of THIS railtype can physically travel
DiagDirection GetRailDepotDirection(Tile t)
Returns the direction the depot is facing to.
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...
Money RoadBuildCost(RoadType roadtype)
Returns the cost of building the specified roadtype.
PalSpriteID ground
Palette and sprite for the ground.
bool include(Container &container, typename Container::const_reference &item)
Helper function to append an item to a container if it is not already contained.
SignalVariant
Variant of the signal, i.e.
uint8_t train_acceleration_model
realistic acceleration for trains
int x_offs
Bounding box X offset.
TimerGameCalendar::Date build_date
Date of construction of tile contents.
StringID name
Name of this rail type.
bool IsObjectType(Tile t, ObjectType type)
Check whether the object on a tile is of a specific type.
TransportType
Available types of transport.
Trackdir TrackToTrackdir(Track track)
Returns a Trackdir for the given Track.
CommandCost CmdBuildSingleSignal(DoCommandFlag 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,...
PathfinderSettings pf
settings for all pathfinders
void CheckForDockingTile(TileIndex t)
Mark the supplied tile as a docking tile if it is suitable for docking.
@ VS_HIDDEN
Vehicle is not visible.
uint8_t train_signal_side
show signals on left / driving / right side
std::vector< Train * > TrainList
Helper type for lists/vectors of trains.
static debug_inline bool IsRailDepot(Tile t)
Is this rail tile a rail depot?
@ TRACK_BIT_3WAY_NE
"Arrow" to the north-east
@ RAIL_GROUND_GRASS
Grassy.
CommandCost CheckOwnership(Owner owner, TileIndex tile)
Check whether the current owner owns something.
@ FOUNDATION_INCLINED_Y
The tile has an along Y-axis inclined foundation.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between two tiles from a TileIndexDiffC struct.
@ RTO_N
Piece of rail in northern corner.
Common return value for all commands.
bool IsBridge(Tile t)
Checks if this is a bridge, instead of a tunnel.
static const TrackBits _valid_tracks_on_leveled_foundation[15]
Valid TrackBits on a specific (non-steep)-slope with leveled foundation.
uint ApplyPixelFoundationToSlope(Foundation f, Slope &s)
Applies a foundation to a slope.
Track GetRailStationTrack(Tile t)
Get the rail track of a rail station tile.
Track RemoveFirstTrack(TrackBits *tracks)
Removes first Track from TrackBits and returns it.
Track GetRailDepotTrack(Tile t)
Returns the track of a depot, ignoring direction.
Trackdir GetVehicleTrackdir() const override
Get the tracks of the train vehicle.
CursorID rail_ns
Cursor for building rail in N-S direction.
@ SLOPE_NS
north and south corner are raised
@ RTSG_GROUND_COMPLETE
Complete ground images.
@ FOUNDATION_STEEP_BOTH
The tile has a steep slope. The lowest corner is raised by a foundation and the upper halftile is lev...
int y_offs
Bounding box Y offset.
Track TrackBitsToTrack(TrackBits tracks)
Converts TrackBits to Track.
TrackBits
Allow incrementing of Track variables.
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
void DirtyCompanyInfrastructureWindows(CompanyID company)
Redraw all windows with company infrastructure counts.
static const uint32_t VALID_LEVEL_CROSSING_SLOPES
Constant bitset with safe slopes for building a level crossing.
@ RTO_CROSSING_XY
Crossing of X and Y rail, with ballast.
Corner height_ref
Corner to use height offset from.
@ RAILTYPE_BEGIN
Used for iterations.
bool RoadNoLevelCrossing(RoadType roadtype)
Test if road disallows level crossings.
std::tuple< Slope, int > GetTilePixelSlope(TileIndex tile)
Return the slope of a given tile.
@ DRD_NONE
None of the directions are disallowed.
SpriteID auto_rail
button for the autorail construction
TileIndex tile
Current tile index.
@ SIGNAL_STATE_RED
The signal is red.
bool HasReservedTracks(TileIndex tile, TrackBits tracks)
Check whether some of tracks is reserved on a tile.
@ DIAGDIR_BEGIN
Used for iterations.
CommandCost CmdRemoveSingleSignal(DoCommandFlag flags, TileIndex tile, Track track)
Remove signals.
@ MP_OBJECT
Contains objects such as transmitters and owned land.
TrackBits GetRailReservationTrackBits(Tile t)
Returns the reserved track bits of the tile.
CommandCost CmdBuildSignalTrack(DoCommandFlag 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.
bool HasTrack(Tile tile, Track track)
Returns whether the given track is present on the given tile.
void MakeError(StringID message, StringID extra_message=INVALID_STRING_ID)
Makes this CommandCost behave like an error command.
@ TRACKDIR_BIT_NONE
No track build.
DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
@ FOUNDATION_INCLINED_X
The tile has an along X-axis inclined foundation.
bool HasSignalOnTrack(Tile tile, Track track)
Checks for the presence of signals (either way) on the given track on the given rail tile.
bool Failed() const
Did this command fail?
@ RTO_SLOPE_SE
Piece of rail on slope with south-east raised.
static constexpr bool IsValidCorner(Corner corner)
Rangecheck for Corner enumeration.
Corner
Enumeration of tile corners.
bool IsNonContinuousFoundation(Foundation f)
Tests if a foundation is a non-continuous foundation, i.e.
@ RTSG_FENCES
Fence images.
Order current_order
The current order (+ status, like: loading)
@ VEH_SHIP
Ship vehicle type.
SpriteID build_ns_rail
button for building single rail in N-S direction
Direction DiagDirToDir(DiagDirection dir)
Convert a DiagDirection to a Direction.
@ TRACK_BIT_LEFT
Left track.
@ TRACKDIR_BIT_LOWER_W
Track lower, direction west.
Represents the covered area of e.g.
TrackdirBits TrackdirReachesTrackdirs(Trackdir trackdir)
Maps a trackdir to the trackdirs that can be reached from it (ie, when entering the next tile.
static const uint TUNNELBRIDGE_TRACKBIT_FACTOR
Multiplier for how many regular track bits a tunnel/bridge counts.
uint16_t cur_speed
current speed
Offsets for drawing fences.
Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
uint ApplyFoundationToSlope(Foundation f, Slope &s)
Applies a foundation to a slope.
@ TRACKDIR_BIT_UPPER_E
Track upper, direction east.
RailTypeLabel label
Unique 32 bit rail type identifier.
@ RFO_SLOPE_NE_NW
Slope NE, Track X, Fence NW.
RoadType
The different roadtypes we support.
TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
Discards all directional information from a TrackdirBits value.
@ VS_STOPPED
Vehicle is stopped by the player.
Foundation GetRailFoundation(Slope tileh, TrackBits bits)
Checks if a track combination is valid on a specific slope and returns the needed foundation.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
@ TRACKDIR_BIT_LEFT_S
Track left, direction south.
@ RTSG_CURSORS
Cursor and toolbar icon images.
#define lengthof(array)
Return the length of an fixed size array.
'Train' is either a loco or a wagon.
@ TRACKDIR_BIT_RIGHT_S
Track right, direction south.
@ FOUNDATION_INVALID
Used inside "rail_cmd.cpp" to indicate invalid slope/track combination.
void FreeTrainTrackReservation(const Train *v)
Free the reserved path in front of a vehicle.
Trackdir RemoveFirstTrackdir(TrackdirBits *trackdirs)
Removes first Trackdir from TrackdirBits and returns it.
bool IsCompatibleRail(RailType enginetype, RailType tiletype)
Checks if an engine of the given RailType can drive on a tile with a given RailType.
void SetTrackReservation(Tile t, TrackBits b)
Sets the reserved track bits of the tile.
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.
Ground palette sprite of a tile, together with its sprite layout.
@ TCX_NORMAL
Nothing special.
TimerGameCalendar::Date build_date
Date of construction.
@ RFO_FLAT_LEFT
Slope FLAT, Track LEFT, Fence E.
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
void UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(TileIndex tile, Axis road_axis)
Update adjacent level crossing tiles in this multi-track crossing, due to removal of a level crossing...
@ RTF_HIDDEN
Bit number for hiding from selection.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
SpriteID single_e
single piece of rail in the eastern corner
@ INVALID_ROADTYPE
flag for invalid roadtype
@ RTSG_GROUND
Main group of ground images.
Coordinates of a point in 2D.
bool HasRoadWorks(Tile t)
Check if a tile has road works.
@ FOUNDATION_NONE
The tile has no foundation, the slope remains unchanged.
@ TRACK_BIT_CROSS
X-Y-axis cross.
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height)
Mark bridge tiles dirty.
Corner GetHalftileFoundationCorner(Foundation f)
Returns the halftile corner of a halftile-foundation.
static void DrawTrackFence_SW(const TileInfo *ti, SpriteID base_image, uint num_sprites)
Draw fence at SW border matching the tile slope.
static debug_inline RailTileType GetRailTileType(Tile t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
struct RailTypeInfo::@25 cursor
Cursors associated with the rail type.
TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, TrackdirBits red_signals)
Builds a TrackStatus.
uint GetPresentSignals(Tile tile)
Get whether the given signals are present (Along/AgainstTrackDir)
struct RailTypeInfo::@24 gui_sprites
struct containing the sprites for the rail GUI.
@ SLOPE_N
the north corner of the tile is raised
void AddCost(const Money &cost)
Adds the given cost to the cost of the command.
bool show_track_reservation
highlight reserved tracks.
CursorID rail_ew
Cursor for building rail in E-W direction.
@ DO_FULL_DETAIL
Also draw details of track and roads.
Set of callback functions for performing tile operations of a given tile type.
void SetTileOwner(Tile tile, Owner owner)
Sets the owner of a tile.
@ SIGTYPE_ENTRY
presignal block entry
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
constexpr uint CountBits(T value)
Counts the number of set bits in a variable.
@ DC_BANKRUPT
company bankrupts, skip money check, skip vehicle on tile check in some cases
static CommandCost CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits existing, TileIndex tile)
Tests if a track can be build on a tile.
static void DrawTrackFence_NE(const TileInfo *ti, SpriteID base_image, uint num_sprites)
Draw fence at NE border matching the tile slope.
std::array< uint32_t, RAILTYPE_END > rail
Count of company owned track bits for each rail type.
@ RTSG_OVERLAY
Images for overlaying track.
void TileLoop_Water(TileIndex tile)
Let a water tile floods its diagonal adjoining tiles called from tunnelbridge_cmd,...
static uint GetSaveSlopeZ(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.
RailGroundType
The ground 'under' the rail.
static debug_inline bool IsPlainRailTile(Tile t)
Checks whether the tile is a rail tile or rail tile with signals.
@ TRACK_BIT_ALL
All possible tracks.
void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w, int h, int dz, int z, bool transparent, int bb_offset_x, int bb_offset_y, int bb_offset_z, const SubSprite *sub)
Draw a (transparent) sprite at given coordinates with a given bounding box.
SpriteID single_sloped
single piece of rail for slopes
SpriteID snow_offset
sprite number difference between a piece of track on a snowy ground and the corresponding one on norm...
bool IsValidTile(Tile tile)
Checks if a tile is valid.
TrackBits GetTrackBits(Tile tile)
Gets the track bits of the given tile.
@ RAIL_GROUND_WATER
Grass with a fence and shore or water on the free halftile.
Direction direction
facing
uint16_t max_speed
Maximum speed for vehicles travelling on this rail type.
@ TRACK_BEGIN
Used for iterations.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
@ FOUNDATION_STEEP_LOWER
The tile has a steep slope. The lowest corner is raised by a foundation to allow building railroad on...
RailTypes powered_railtypes
bitmask to the OTHER railtypes on which an engine of THIS railtype generates power
SpriteID single_x
single piece of rail in X direction, without ground
A pair-construct of a TileIndexDiff.
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
@ TRACK_BIT_UPPER
Upper track.
static const ObjectType OBJECT_OWNED_LAND
Owned land 'flag'.
void MakeRailDepot(Tile tile, Owner owner, DepotID depot_id, DiagDirection dir, RailType rail_type)
Make a rail depot.
@ TRACKDIR_BIT_X_NE
Track x-axis, direction north-east.
FloodingBehaviour GetFloodingBehaviour(TileIndex tile)
Returns the behaviour of a tile during flooding.
void MakeDefaultName(T *obj)
Set the default name for a depot/waypoint.
@ RFO_FLAT_X_NW
Slope FLAT, Track X, Fence NW.
@ RFO_SLOPE_SE_NE
Slope SE, Track Y, Fence NE.
bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
CompanyID _current_company
Company currently doing an action.
Track
These are used to specify a single track.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
SpriteID GetCustomSignalSprite(const RailTypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, SignalState state, bool gui)
Get the sprite to draw for a given signal.
void MakeRoadCrossing(Tile t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadType road_rt, RoadType tram_rt, uint town)
Make a level crossing.
static const PaletteID PALETTE_TO_BARE_LAND
sets colour to bare land stuff for rail, road and crossings
@ RAIL_GROUND_FENCE_HORIZ1
Grass with a fence at the southern side.
CommandCost EnsureNoTrainOnTrackBits(TileIndex tile, TrackBits track_bits)
Tests if a vehicle interacts with the specified track bits.
@ TRACK_BIT_RIGHT
Right track.
CursorID depot
Cursor for building a depot.
CommandCost CmdBuildTrainDepot(DoCommandFlag flags, TileIndex tile, RailType railtype, DiagDirection dir)
Build a train depot.
Trackdir
Enumeration for tracks and directions.
Axis GetCrossingRoadAxis(Tile t)
Get the road axis of a level crossing.
static void DrawTrackFence_NW(const TileInfo *ti, SpriteID base_image, uint num_sprites)
Draw fence at NW border matching the tile slope.
bool IsDockingTile(Tile t)
Checks whether the tile is marked as a dockling tile.
@ WC_BUILD_VEHICLE
Build vehicle; Window numbers:
static debug_inline bool IsRailDepotTile(Tile t)
Is this tile rail tile and a rail depot?
void Restore()
Restore the variable.
Slope
Enumeration for the slope-type.
bool TryPathReserve(Train *v, bool mark_as_stuck=false, bool first_tile_okay=false)
Try to reserve a path to a safe position.
static CommandCost EnsureNoTrainOnTrack(TileIndex tile, Track track)
Tests if a vehicle interacts with the specified track.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
bool IsSlopeWithThreeCornersRaised(Slope s)
Tests if a specific slope has exactly three corners raised.
constexpr T abs(const T a)
Returns the absolute value of (scalar) variable.
Money RailConvertCost(RailType from, RailType to)
Calculates the cost of rail conversion.
@ TRANSPORT_RAIL
Transport by train.
TileType
The different types of tiles.
Corner GetHighestSlopeCorner(Slope s)
Returns the highest corner of a slope (one corner raised or a steep slope).
static debug_inline uint Size()
Get the size of the map.
void MakeShore(Tile t)
Helper function to make a coast tile.
@ TRACKDIR_BIT_LOWER_E
Track lower, direction east.
@ RFO_FLAT_UPPER
Slope FLAT, Track UPPER, Fence S.
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 ...
SpriteID build_tunnel
button for building a tunnel
bool build_on_slopes
allow building on slopes
@ RFO_SLOPE_NE_SE
Slope NE, Track X, Fence SE.
static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, int z_old, Slope tileh_old, int z_new, Slope tileh_new, TrackBits rail_bits)
Tests if autoslope is allowed.
@ RTO_X
Piece of rail in X direction.
bool HasStationRail(Tile t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
@ OWNER_WATER
The tile/execution is done by "water".
bool IsSignalPresent(Tile t, uint8_t signalbit)
Checks whether the given signals is present.
static void DrawTrackDetails(const TileInfo *ti, const RailTypeInfo *rti)
Draw track fences.
@ SLOPE_SW
south and west corner are raised
SpriteID single_s
single piece of rail in the southern corner
bool HasSignals(Tile t)
Checks if a rail tile has signals.
int GetSlopePixelZInCorner(Slope tileh, Corner corner)
Determine the Z height of a corner relative to TileZ.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner)
Add side of tile to signal update buffer.
SpriteID build_x_rail
button for building single rail in X direction
void SetDockingTile(Tile t, bool b)
Set the docking tile state of a tile.
void SetRailType(Tile t, RailType r)
Sets the rail type of the given tile.
@ FOUNDATION_LEVELED
The tile is leveled up to a flat slope.
@ TRACK_LEFT
Track in the left corner of the tile (west)
@ RTSG_DEPOT
Depot images.
@ WC_VEHICLE_DEPOT
Depot view; Window numbers:
@ MP_STATION
A tile of a station.
Owner GetRoadOwner(Tile t, RoadTramType rtt)
Get the owner of a specific road type.
@ RTO_JUNCTION_NSEW
Ballast for full junction.
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
@ FLOOD_NONE
The tile does not flood neighboured tiles.
@ RTO_Y
Piece of rail in Y direction.
@ RAIL_TILE_NORMAL
Normal rail tile without signals.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
bool HasRailCatenaryDrawn(RailType rt)
Test if we should draw rail catenary.
TransportType GetTunnelBridgeTransportType(Tile t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
bool disable_elrails
when true, the elrails are disabled
@ DIAGDIR_END
Used for iterations.
@ TRACK_UPPER
Track in the upper corner of the tile (north)
@ SLOPE_ELEVATED
bit mask containing all 'simple' slopes
void SetRailDepotExitDirection(Tile tile, DiagDirection dir)
Sets the exit direction of a rail depot.
RoadBits GetRoadBits(Tile t, RoadTramType rtt)
Get the present road bits for a specific road type.
@ RAIL_GROUND_FENCE_NE
Grass with a fence at the NE edge.
bool IsBridgeAbove(Tile t)
checks if a bridge is set above the ground of this tile
StringID str
Description of the tile.
@ TRACK_BIT_Y
Y-axis track.
@ RTO_SLOPE_NW
Piece of rail on slope with north-west raised.
@ DC_AUTO
don't allow building on structures
void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner)
Add track to signal update buffer.
Track DiagDirToDiagTrack(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track incidating with that diagdir.
@ RTO_E
Piece of rail in eastern corner.
Foundation SpecialRailFoundation(Corner corner)
Returns the special rail foundation for single horizontal/vertical track.
bool IsSpecialRailFoundation(Foundation f)
Tests if a foundation is a special rail foundation for single horizontal/vertical track.
@ TRACK_LOWER
Track in the lower corner of the tile (south)
@ ROAD_NONE
No road-part is build.
bool IsDiagonalTrackdir(Trackdir trackdir)
Checks if a given Trackdir is diagonal.
TileIndex GetOtherTunnelBridgeEnd(Tile t)
Determines type of the wormhole and returns its other end.
int32_t y_pos
y coordinate.
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).
CursorID rail_nwse
Cursor for building rail in Y direction.
int16_t y
The y value of the coordinate.
RailTypes introduces_railtypes
Bitmask of which other railtypes are introduced when this railtype is introduced.
CommandCost CheckTileOwnership(TileIndex tile)
Check whether the current owner owns the stuff on the given tile.
@ TRACKDIR_BIT_Y_SE
Track y-axis, direction south-east.
@ TRACKDIR_BIT_RIGHT_N
Track right, direction north.
@ RFO_SLOPE_NW_NE
Slope NW, Track Y, Fence NE.
bool IsStationTileBlocked(Tile t)
Is tile t a blocked tile?
SpriteID track_ns
two pieces of rail in North and South corner (East-West direction)
uint SlopeToSpriteOffset(Slope s)
Returns the Sprite offset for a given Slope.
int GetTileMaxPixelZ(TileIndex tile)
Get top height of the tile.
struct RailTypeInfo::@23 base_sprites
Struct containing the main sprites.
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_BASE.
SignalOffsets
Enum holding the signal offset in the sprite sheet according to the side it is representing.
bool crossing_with_competitor
allow building of level crossings with competitor roads or rails
void MakeRoadNormal(Tile t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
Make a normal road tile.
void DrawRailCatenary(const TileInfo *ti)
Draws overhead wires and pylons for electric railways.
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.
@ RFO_FLAT_Y_SW
Slope FLAT, Track Y, Fence SW.
RailTypeFlags flags
Bit mask of rail type flags.
static void DrawTrackFence(const TileInfo *ti, SpriteID base_image, uint num_sprites, RailFenceOffset rfo)
Draw a track fence.
@ TRACK_BIT_LOWER
Lower track.
bool RailNoLevelCrossings(RailType rt)
Test if a RailType disallows build of level crossings.
@ TRACK_BIT_3WAY_NW
"Arrow" to the north-west
CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_start, RailType totype, bool diagonal)
Convert one rail type to the other.
CommandCost CmdBuildSingleRail(DoCommandFlag flags, TileIndex tile, RailType railtype, Track track, bool auto_remove_signals)
Build a single piece of rail.
int x
X position of the tile in unit coordinates.
@ RAIL_GROUND_FENCE_HORIZ2
Grass with a fence at the northern side.
static Date date
Current date in days (day counter).
TileIndex tile
Tile index.
int CalcNextVehicleOffset() const
Calculate the offset from this vehicle's center to the following center taking the vehicle lengths in...
ConstructionSettings construction
construction of things in-game
@ CCF_TRACK
Valid changes while vehicle is driving, and possibly changing tracks.
VehicleSettings vehicle
options for vehicles
@ RFO_FLAT_X_SE
Slope FLAT, Track X, Fence SE.
static const TrackBits _valid_tracks_without_foundation[15]
Valid TrackBits on a specific (non-steep)-slope without foundation.
@ RTO_S
Piece of rail in southern corner.
Slope SlopeWithOneCornerRaised(Corner corner)
Returns the slope with a specific corner raised.
@ RFO_FLAT_RIGHT
Slope FLAT, Track RIGHT, Fence W.
uint16_t rail_speed
Speed limit of rail (bridges and track)
SignalType
Type of signal, i.e.
uint8_t GetSnowLine()
Get the current snow line, either variable or static.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
VehicleType type
Type of vehicle.
@ RAIL_TILE_DEPOT
Depot (one entrance)
TrackdirBits
Allow incrementing of Trackdir variables.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
T * First() const
Get the first vehicle in the chain.
@ TRACK_BIT_3WAY_SE
"Arrow" to the south-east
void ResetRailTypes()
Reset all rail type information to its default values.
@ TRACK_Y
Track along the y-axis (north-west to south-east)
bool HasPowerOnRail(RailType enginetype, RailType tiletype)
Checks if an engine of the given RailType got power on a tile with a given RailType.
void SetTrackBits(Tile t, TrackBits b)
Sets the track bits of the given tile.
static bool CompareRailTypes(const RailType &first, const RailType &second)
Compare railtypes based on their sorting order.
CommandCost CmdRemoveSignalTrack(DoCommandFlag flags, TileIndex tile, TileIndex end_tile, Track track, bool autofill)
Remove signals on a stretch of track.
int x_size
Bounding box X size.
void ShowDepotWindow(TileIndex tile, VehicleType type)
Opens a depot window.
bool IsSlopeWithOneCornerRaised(Slope s)
Tests if a specific slope has exactly one corner raised.
bool IsTileOwner(Tile tile, Owner owner)
Checks if a tile belongs to the given owner.
@ INVALID_TRACK
Flag for an invalid track.
@ TRACK_BIT_DEPOT
Bitflag for a depot.
TropicZone GetTropicZone(Tile tile)
Get the tropic zone.
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
uint8_t sorting_order
The sorting order of this railtype for the toolbar dropdown.
@ RTO_JUNCTION_SW
Ballast for junction 'pointing' SW.
TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
@ RFO_FLAT_Y_NE
Slope FLAT, Track Y, Fence NE.
@ TRACKDIR_BIT_UPPER_W
Track upper, direction west.
@ TRACK_X
Track along the x-axis (north-east to south-west)
int16_t x
The x value of the coordinate.
TrackBits CornerToTrackBits(Corner corner)
Returns a single horizontal/vertical trackbit that is in a specific tile corner.
SpriteID convert_rail
button for converting rail
int y_size
Bounding box Y size.
std::tuple< Slope, int > GetTileSlopeZ(TileIndex tile)
Return the slope of a given tile inside the map.
@ RAIL_GROUND_ICE_DESERT
Icy or sandy.
@ ROAD_X
Full road along the x-axis (south-west + north-east)
SpriteID single_y
single piece of rail in Y direction, without ground
constexpr T ToggleBit(T &x, const uint8_t y)
Toggles a bit in a variable.
VehicleEnterTileStatus
The returned bits of VehicleEnterTile.
CommandCost TunnelBridgeIsFree(TileIndex tile, TileIndex endtile, const Vehicle *ignore)
Finds vehicle in tunnel / bridge.
@ RAIL_GROUND_FENCE_SW
Grass with a fence at the SW edge.
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.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Money RailBuildCost(RailType railtype)
Returns the cost of building the specified railtype.
GUISettings gui
settings related to the GUI
@ RFO_FLAT_LOWER
Slope FLAT, Track LOWER, Fence N.
Train * GetTrainForReservation(TileIndex tile, Track track)
Find the train which has reserved a specific path.
SpriteID single_w
single piece of rail in the western corner
SpriteID GetCustomRailSprite(const RailTypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
@ TRACKDIR_BIT_X_SW
Track x-axis, direction south-west.
bool HasSignalOnTrackdir(Tile tile, Trackdir trackdir)
Checks for the presence of signals along the given trackdir on the given rail tile.
@ VETSB_ENTERED_WORMHOLE
The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/...
DiagDirection GetTunnelBridgeDirection(Tile t)
Get the direction pointing to the other end.
Corner OppositeCorner(Corner corner)
Returns the opposite corner.
bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
Autoslope check for tiles with an entrance on an edge.
TownID GetTownIndex(Tile t)
Get the index of which town this house/street is attached to.
@ EXPENSES_CONSTRUCTION
Construction costs.
@ TRACK_RIGHT
Track in the right corner of the tile (east)
@ RTO_JUNCTION_NW
Ballast for junction 'pointing' NW.
@ RAIL_GROUND_FENCE_NESW
Grass with a fence at the NE and SW edges.
@ RAILTYPES_NONE
No rail types.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.