77#include "table/strings.h"
107 for (
const auto &depot : as->
depots) {
123template <
class T,
class F>
132 if (!T::IsValidID(t) || T::Get(t)->owner != company || !filter(T::Get(t)))
continue;
133 if (closest_station == StationID::Invalid()) {
135 }
else if (closest_station != t) {
136 return CommandCost(STR_ERROR_ADJOINS_MORE_THAN_ONE_EXISTING);
140 *st = (closest_station == StationID::Invalid()) ?
nullptr : T::Get(closest_station);
161 for (
int dx = -3; dx <= 3; dx++) {
162 for (
int dy = -3; dy <= 3; dy++) {
186 for (
const auto &p : ind->
produced) {
190 !
CargoSpec::Get(p.cargo)->classes.Any({CargoClass::Liquid, CargoClass::Passengers, CargoClass::Mail})) {
230 std::bitset<STR_SV_STNAME_FALLBACK - STR_SV_STNAME>
used_names;
240 assert(
IsInsideMM(str, STR_SV_STNAME, STR_SV_STNAME_FALLBACK));
241 return !this->used_names.test(str - STR_SV_STNAME);
250 assert(
IsInsideMM(str, STR_SV_STNAME, STR_SV_STNAME_FALLBACK));
251 this->used_names.set(str - STR_SV_STNAME);
270 if (s != st && s->
town == t) {
271 if (s->indtype != IT_INVALID) {
274 if (name != STR_UNDEFINED) {
283 if (
IsInsideMM(s->string_id, STR_SV_STNAME, STR_SV_STNAME_FALLBACK)) {
284 auto str = s->string_id;
285 if (str == STR_SV_STNAME_FOREST) str = STR_SV_STNAME_WOODS;
301 sni.
SetUsed(STR_SV_STNAME_OILFIELD);
302 sni.
SetUsed(STR_SV_STNAME_MINES);
303 if (sni.
indtypes[indtype])
continue;
308 return STR_SV_STNAME_FALLBACK;
315 switch (name_class) {
317 if (sni.
IsAvailable(STR_SV_STNAME_AIRPORT))
return STR_SV_STNAME_AIRPORT;
320 if (sni.
IsAvailable(STR_SV_STNAME_OILFIELD))
return STR_SV_STNAME_OILFIELD;
323 if (sni.
IsAvailable(STR_SV_STNAME_DOCKS))
return STR_SV_STNAME_DOCKS;
326 if (sni.
IsAvailable(STR_SV_STNAME_HELIPORT))
return STR_SV_STNAME_HELIPORT;
335 return STR_SV_STNAME_MINES;
341 if (sni.
IsAvailable(STR_SV_STNAME))
return STR_SV_STNAME;
342 if (sni.
IsAvailable(STR_SV_STNAME_CENTRAL))
return STR_SV_STNAME_CENTRAL;
349 return STR_SV_STNAME_LAKESIDE;
364 if (sni.
IsAvailable(STR_SV_STNAME_VALLEY))
return STR_SV_STNAME_VALLEY;
366 if (sni.
IsAvailable(STR_SV_STNAME_HEIGHTS))
return STR_SV_STNAME_HEIGHTS;
371 sni.
SetUsed(STR_SV_STNAME_SOUTH);
372 sni.
SetUsed(STR_SV_STNAME_WEST);
374 sni.
SetUsed(STR_SV_STNAME_NORTH);
375 sni.
SetUsed(STR_SV_STNAME_EAST);
378 sni.
SetUsed(STR_SV_STNAME_SOUTH);
379 sni.
SetUsed(STR_SV_STNAME_EAST);
381 sni.
SetUsed(STR_SV_STNAME_NORTH);
382 sni.
SetUsed(STR_SV_STNAME_WEST);
386 static const StringID fallback_names[] = {
391 STR_SV_STNAME_TRANSFER,
393 STR_SV_STNAME_EXCHANGE,
394 STR_SV_STNAME_ANNEXE,
395 STR_SV_STNAME_SIDINGS,
396 STR_SV_STNAME_BRANCH,
400 for (
auto str : fallback_names) {
403 return STR_SV_STNAME_FALLBACK;
415 Station *best_station =
nullptr;
420 if (cur_dist < threshold) {
421 threshold = cur_dist;
423 }
else if (cur_dist == threshold && best_station !=
nullptr) {
425 if (st->index < best_station->index) best_station = st;
443 default: NOT_REACHED();
454 pt.
y -= 32 * ZOOM_BASE;
457 if (this->
sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeStation(this->
index));
461 _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeStation(this->
index));
472 if (this->
xy == new_xy)
return;
474 _station_kdtree.Remove(this->
index);
478 _station_kdtree.Insert(this->
index);
485 st->UpdateVirtCoord();
489void BaseStation::FillCachedName()
const
495void ClearAllStationCachedNames()
498 st->cached_name.clear();
511 for (
auto it = std::begin(st->
goods); it != std::end(st->
goods); ++it) {
526 for (
auto it = std::begin(st->
goods); it != std::end(st->
goods); ++it) {
527 if (it->TotalCount() > 0) mask.
Set(
static_cast<CargoType>(std::distance(std::begin(st->
goods), it)));
540 StringID msg = reject ? STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_LIST : STR_NEWS_STATION_NOW_ACCEPTS_CARGO_LIST;
568 for (IndustryID industry : industries) {
603 return {acceptance, always_accepted};
621 return {acceptance, always_accepted};
636 if (!st->
rect.IsEmpty()) {
642 uint amt = acceptance[cargo];
646 if ((!is_passengers && !st->
facilities.
Any({StationFacility::Train, StationFacility::TruckStop, StationFacility::Airport, StationFacility::Dock})) ||
647 (is_passengers && !st->
facilities.
Any({StationFacility::Train, StationFacility::BusStop, StationFacility::Airport, StationFacility::Dock}))) {
660 if (old_acc == new_acc)
return;
681 if (r->IsEmpty())
return;
710 if (*st !=
nullptr) {
715 CommandCost ret = (*st)->rect.BeforeAddRect(area.
tile, area.
w, area.
h, StationRect::ADD_TEST);
716 if (ret.
Failed())
return ret;
723 _station_kdtree.Insert((*st)->index);
749 UpdateStationSignCoord(st);
764 MarkCatchmentTilesDirty();
767 MarkCatchmentTilesDirty();
783 default: NOT_REACHED();
810 return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
814 if (ret.
Failed())
return ret;
843 }
else if (allowed_z != flat_z) {
863 if (ret.
Failed())
return ret;
866 ret = Command<Commands::LandscapeClear>::Do(flags, tile_iter);
867 if (ret.
Failed())
return ret;
882 STR_ERROR_BRIDGE_TOO_LOW_FOR_STATION,
884 STR_ERROR_BRIDGE_TOO_LOW_FOR_ROADSTOP,
885 STR_ERROR_BRIDGE_TOO_LOW_FOR_ROADSTOP,
887 STR_ERROR_BRIDGE_TOO_LOW_FOR_DOCK,
888 STR_ERROR_BRIDGE_TOO_LOW_FOR_BUOY,
889 STR_ERROR_BRIDGE_TOO_LOW_FOR_RAIL_WAYPOINT,
890 STR_ERROR_BRIDGE_TOO_LOW_FOR_ROAD_WAYPOINT,
892 return too_low_msgs[type];
907 int height = layout < std::size(bridgeable_info) ? bridgeable_info[layout].height : 0;
915 int height_diff =
GetTileMaxZ(tile) + height - bridge_height;
927 return _station_bridgeable_info[type];
1009static CommandCost CheckFlatLandRailStation(
TileIndex tile_cur,
TileIndex north_tile,
int &allowed_z,
DoCommandFlags flags,
Axis axis, StationID *station,
RailType rt, std::vector<Train *> &affected_vehicles,
StationClassID spec_class, uint16_t spec_index, uint8_t plat_len, uint8_t numtracks)
1018 if (ret.
Failed())
return ret;
1024 if (ret.
Failed())
return ret;
1035 if (*station == StationID::Invalid()) {
1037 }
else if (*station != st) {
1038 return CommandCost(STR_ERROR_ADJOINS_MORE_THAN_ONE_EXISTING);
1056 affected_vehicles.push_back(v);
1059 ret = Command<Commands::RemoveRail>::Do(flags, tile_cur, track);
1060 if (ret.
Failed())
return ret;
1067 ret = Command<Commands::LandscapeClear>::Do(flags, tile_cur);
1068 if (ret.
Failed())
return ret;
1094 if (ret.
Failed())
return ret;
1098 if (ret.
Failed())
return ret;
1113 return CommandCost(STR_ERROR_DRIVE_THROUGH_DIRECTION);
1116 if (*station == StationID::Invalid()) {
1118 }
else if (*station != st) {
1119 return CommandCost(STR_ERROR_ADJOINS_MORE_THAN_ONE_EXISTING);
1128 switch (rb.
Count()) {
1130 return CommandCost(STR_ERROR_DRIVE_THROUGH_DIRECTION);
1134 return CommandCost(STR_ERROR_DRIVE_THROUGH_CORNER);
1137 return CommandCost(STR_ERROR_DRIVE_THROUGH_JUNCTION);
1141 if (build_over_road) {
1150 if (ret.
Failed())
return ret;
1158 if (ret.
Failed())
return ret;
1176 if (ret.
Failed())
return ret;
1189 ret = Command<Commands::LandscapeClear>::Do(flags, cur_tile);
1190 if (ret.
Failed())
return ret;
1218 return CommandCost(STR_ERROR_STATION_TOO_SPREAD_OUT);
1229 if (!
stl.layout.empty())
return this->
stl.layout[this->
position] & ~1;
1231 if (this->
stl.length == 1) {
1233 return this->
position == ((this->
stl.platforms - 1) / 2) ? 2 : 0;
1238 return this->
position == ((this->
stl.length - 1) / 2) ? 2 : 0;
1241 if (this->
stl.length > 4 && ((this->position % this->stl.length) == 0 || (this->position % this->stl.length) == this->stl.length - 1)) {
1247 return (((this->
position / this->
stl.length) % 2) == (this->stl.platforms % 2)) ? 4 : 6;
1263template <
class T, StringID error_message,
class F>
1266 assert(*st ==
nullptr);
1267 bool check_surrounding =
true;
1269 if (existing_station != StationID::Invalid()) {
1270 if (adjacent && existing_station != station_to_join) {
1277 T *candidate = T::GetIfValid(existing_station);
1278 if (candidate !=
nullptr && filter(candidate)) *st = candidate;
1279 check_surrounding = (*st ==
nullptr);
1284 if (adjacent) check_surrounding =
false;
1287 if (check_surrounding) {
1290 if (ret.
Failed())
return ret;
1294 if (*st ==
nullptr && station_to_join != StationID::Invalid()) *st = T::GetIfValid(station_to_join);
1373 bool length_price_ready =
true;
1374 uint8_t tracknum = 0;
1378 CommandCost ret =
CheckFlatLandRailStation(cur_tile, tile_area.
tile, allowed_z, flags, axis, station, rt, affected_vehicles, spec_class, spec_index, plat_len, numtracks);
1379 if (ret.
Failed())
return ret;
1382 if (tracknum == numtracks) {
1383 length_price_ready =
true;
1395 if (length_price_ready) {
1397 length_price_ready =
false;
1449 if (ret.
Failed())
return ret;
1458 if (plat_len == 0 || numtracks == 0)
return CMD_ERROR;
1472 bool reuse = (station_to_join != NEW_STATION);
1473 if (!reuse) station_to_join = StationID::Invalid();
1474 bool distant_join = (station_to_join != StationID::Invalid());
1481 TileArea new_location(tile_org, w_org, h_org);
1484 StationID est = StationID::Invalid();
1485 std::vector<Train *> affected_vehicles;
1488 if (cost.
Failed())
return cost;
1492 if (ret.
Failed())
return ret;
1495 if (ret.
Failed())
return ret;
1499 if (ret.
Failed())
return ret;
1507 for (
auto [i, it, tile_track] = std::make_tuple(0, stl.begin(), tile_org); i != numtracks; ++i, tile_track += track_delta) {
1508 for (
auto [j, tile] = std::make_tuple(0, tile_track); j != plat_len; ++j, tile += tile_delta, ++it) {
1513 if (statspec !=
nullptr) {
1514 uint32_t platinfo =
GetPlatformInfo(gfx, numtracks, plat_len, i, j,
false);
1521 if (ret.
Failed())
return ret;
1527 if (!specindex.has_value())
return CommandCost(STR_ERROR_TOO_MANY_STATION_SPECS);
1529 if (statspec !=
nullptr) {
1547 st->
rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY);
1550 if (statspec !=
nullptr) {
1558 for (
auto [i, it, tile_track] = std::make_tuple(0, stl.begin(), tile_org); i != numtracks; ++i, tile_track += track_delta) {
1559 for (
auto [j, tile] = std::make_tuple(0, tile_track); j != plat_len; ++j, tile += tile_delta, ++it) {
1564 affected_vehicles.push_back(v);
1588 if (statspec !=
nullptr) {
1594 if (callback <= UINT8_MAX) {
1614 for (uint i = 0; i < affected_vehicles.size(); ++i) {
1622 update_reservation_area =
TileArea(tile_org, 1, numtracks);
1624 update_reservation_area =
TileArea(tile_org, numtracks, 1);
1627 for (
TileIndex tile : update_reservation_area) {
1638 platform_begin = next_tile;
1641 platform_end = next_tile;
1645 bool reservation =
false;
1646 for (
TileIndex t = platform_begin; !reservation && t <= platform_end; t += tile_offset) {
1667 if (ta.
w != 0 && ta.
h != 0) {
1712static bool TileBelongsToRailStation(BaseStation *st,
TileIndex tile)
1717static void MakeRailStationAreaSmaller(BaseStation *st)
1722static bool TileBelongsToShipStation(BaseStation *st,
TileIndex tile)
1727static void MakeShipStationAreaSmaller(
Station *st)
1730 UpdateStationDockingTiles(st);
1733static bool TileBelongsToRoadWaypointStation(BaseStation *st,
TileIndex tile)
1738void MakeRoadWaypointStationAreaSmaller(BaseStation *st,
TileArea &road_waypoint_area)
1740 road_waypoint_area = MakeStationAreaSmaller(st, road_waypoint_area, TileBelongsToRoadWaypointStation);
1771 error.
AddCost(std::move(ret));
1772 if (error.
Failed())
continue;
1775 T *st = T::GetByTile(tile);
1776 if (st ==
nullptr)
continue;
1780 error.
AddCost(std::move(ret));
1781 if (error.
Failed())
continue;
1809 DoClearSquare(tile);
1815 st->tile_waiting_random_triggers.erase(tile);
1816 st->rect.AfterRemoveTile(st, tile);
1822 include(affected_stations, st);
1828 if (quantity == 0)
return error.
Failed() ? error :
CommandCost(STR_ERROR_THERE_IS_NO_STATION);
1830 for (
T *st : affected_stations) {
1835 MakeRailStationAreaSmaller(st);
1836 UpdateStationSignCoord(st);
1843 MarkCatchmentTilesDirty();
1849 total_cost.
AddCost(quantity * removal_cost);
1864 if (end == 0) end = start;
1868 std::vector<Station *> affected_stations;
1871 if (ret.
Failed())
return ret;
1874 for (
Station *st : affected_stations) {
1877 st->MarkTilesDirty(
false);
1878 MarkCatchmentTilesDirty();
1879 st->RecomputeCatchment();
1897 if (end == 0) end = start;
1901 std::vector<Waypoint *> affected_stations;
1921 if (ret.
Failed())
return ret;
1927 assert(ta.
w != 0 && ta.
h != 0);
1933 if (st->TileBelongsToRailStation(tile)) {
1934 std::vector<T*> affected_stations;
1936 if (ret.
Failed())
return ret;
1991 if (*primary_stop ==
nullptr) {
1993 return primary_stop;
1997 while (stop->
next !=
nullptr) stop = stop->
next;
2042 if (ret.
Failed())
return ret;
2047 if (!is_preexisting_roadstop) {
2076 bool reuse = (station_to_join != NEW_STATION);
2077 if (!reuse) station_to_join = StationID::Invalid();
2078 bool distant_join = (station_to_join != StationID::Invalid());
2087 if (roadstopspec !=
nullptr) {
2105 if (!is_drive_through && RoadTypeIsTram(rt))
return CMD_ERROR;
2110 if (ret.
Failed())
return ret;
2116 if (roadstopspec !=
nullptr) {
2121 StationID est = StationID::Invalid();
2123 if (cost.
Failed())
return cost;
2127 if (ret.
Failed())
return ret;
2130 if (!
RoadStop::CanAllocateItem(
static_cast<size_t>(roadstop_area.
w) * roadstop_area.
h))
return CommandCost(is_truck_stop ? STR_ERROR_TOO_MANY_TRUCK_STOPS : STR_ERROR_TOO_MANY_BUS_STOPS);
2133 if (ret.
Failed())
return ret;
2137 if (!specindex.has_value())
return CommandCost(STR_ERROR_TOO_MANY_STATION_SPECS);
2139 if (roadstopspec !=
nullptr) {
2152 for (
TileIndex cur_tile : roadstop_area) {
2163 if (roadstopspec !=
nullptr) {
2172 *currstop = road_stop;
2174 if (is_truck_stop) {
2183 st->
rect.BeforeAddTile(cur_tile, StationRect::ADD_TRY);
2186 if (is_drive_through) {
2209 if (roadstopspec !=
nullptr) {
2210 st->SetRoadStopRandomBits(cur_tile,
GB(Random(), 0, 8));
2217 if (st !=
nullptr) {
2237 if (ret.
Failed())
return ret;
2252 assert(cur_stop !=
nullptr);
2272 if (ret.
Failed())
return ret;
2278 if (*primary_stop == cur_stop) {
2280 *primary_stop = cur_stop->
next;
2282 if (*primary_stop ==
nullptr) {
2289 while (pred->
next != cur_stop) pred = pred->
next;
2311 DoClearSquare(tile);
2318 StationID station_id = st->index;
2321 [station_id](
const Order *order) {
return order->IsType(OT_GOTO_STATION) && order->GetDestination() == station_id; },
2322 [station_id, tile](
Vehicle *v) {
2329 st->
rect.AfterRemoveTile(st, tile);
2333 st->tile_waiting_random_triggers.erase(tile);
2334 st->RemoveRoadStopTileData(tile);
2364 if (ret.
Failed())
return ret;
2370 if (ret.
Failed())
return ret;
2389 DoClearSquare(tile);
2391 wp->
rect.AfterRemoveTile(wp, tile);
2393 wp->tile_waiting_random_triggers.erase(tile);
2394 wp->RemoveRoadStopTileData(tile);
2397 if (replacement_spec_index < 0) {
2400 UpdateStationSignCoord(wp);
2426 CommandCost last_error(STR_ERROR_THERE_IS_NO_STATION);
2427 bool had_success =
false;
2429 for (
TileIndex cur_tile : roadstop_area) {
2449 if (road_waypoint) {
2455 last_error = std::move(ret);
2467 int count = road_bits.
Count();
2473 return had_success ? cost : last_error;
2490 if (width == 0 || height == 0)
return CMD_ERROR;
2496 TileArea roadstop_area(tile, width, height);
2510 if (end == 0) end = start;
2513 TileArea roadstop_area(start, end);
2536 uint8_t town_tolerance_distance = 8 + (
_settings_game.difficulty.town_council_tolerance * 4);
2540 uint noise_reduction = distance / town_tolerance_distance;
2561 Town *nearest =
nullptr;
2564 auto height = as->
size_y;
2567 uint perimeter_min_x =
TileX(tile);
2568 uint perimeter_min_y =
TileY(tile);
2569 uint perimeter_max_x = perimeter_min_x + width - 1;
2570 uint perimeter_max_y = perimeter_min_y + height - 1;
2572 mindist = UINT_MAX - 1;
2577 if (
TileX(cur_tile) == perimeter_min_x ||
TileX(cur_tile) == perimeter_max_x ||
TileY(cur_tile) == perimeter_min_y ||
TileY(cur_tile) == perimeter_max_y) {
2579 if (t ==
nullptr)
continue;
2582 if (dist == mindist && t->index < nearest->index) nearest = t;
2583 if (dist < mindist) {
2632 bool reuse = (station_to_join != NEW_STATION);
2633 if (!reuse) station_to_join = StationID::Invalid();
2634 bool distant_join = (station_to_join != StationID::Invalid());
2641 if (ret.
Failed())
return ret;
2655 return CommandCost(STR_ERROR_STATION_TOO_SPREAD_OUT);
2660 if (cost.
Failed())
return cost;
2668 StringID authority_refuse_message = STR_NULL;
2669 Town *authority_refuse_town =
nullptr;
2674 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE;
2675 authority_refuse_town = nearest;
2677 }
else if (
_settings_game.difficulty.town_council_tolerance != TOWN_COUNCIL_PERMISSIVE) {
2684 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
2685 authority_refuse_town = t;
2689 if (authority_refuse_message != STR_NULL) {
2694 ret =
FindJoiningStation(StationID::Invalid(), station_to_join, allow_adjacent, airport_area, &st);
2695 if (ret.
Failed())
return ret;
2701 if (ret.
Failed())
return ret;
2704 return CommandCost(STR_ERROR_TOO_CLOSE_TO_ANOTHER_AIRPORT);
2721 st->
rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
2764 if (ret.
Failed())
return ret;
2772 if (!a->IsNormalAircraft())
continue;
2773 if (a->targetairport == st->index && a->state !=
FLYING) {
2774 return CommandCost(STR_ERROR_AIRCRAFT_IN_THE_WAY);
2798 if (!st->TileBelongsToAirport(tile_cur))
continue;
2801 if (ret.
Failed())
return ret;
2806 DoClearSquare(tile_cur);
2847 if (ret.
Failed())
return ret;
2866 const Vehicle *v = orderlist->GetFirstSharedVehicle();
2867 assert(v !=
nullptr);
2868 if ((v->
owner == company) != include_company)
continue;
2870 for (
const Order &order : orderlist->GetOrders()) {
2871 if (order.GetDestination() == station && (order.IsType(OT_GOTO_STATION) || order.IsType(OT_GOTO_WAYPOINT))) {
2901 bool reuse = (station_to_join != NEW_STATION);
2902 if (!reuse) station_to_join = StationID::Invalid();
2903 bool distant_join = (station_to_join != StationID::Invalid());
2915 if (ret.
Failed())
return ret;
2918 if (ret.
Failed())
return ret;
2921 ret = Command<Commands::LandscapeClear>::Do(flags, tile);
2922 if (ret.
Failed())
return ret;
2932 if (ret.
Failed())
return ret;
2938 ret = Command<Commands::LandscapeClear>::Do(flags, tile_cur);
2939 if (ret.
Failed())
return ret;
2952 ret =
FindJoiningStation(StationID::Invalid(), station_to_join, adjacent, dock_area, &st);
2953 if (ret.
Failed())
return ret;
2959 if (ret.
Failed())
return ret;
2967 st->
rect.BeforeAddRect(dock_area.
tile, dock_area.
w, dock_area.
h, StationRect::ADD_TRY);
2979 UpdateStationDockingTiles(st);
2995 if (st !=
nullptr) UpdateStationDockingTiles(st);
2998 if (neutral !=
nullptr) UpdateStationDockingTiles(neutral);
3056 if (ret.
Failed())
return ret;
3066 if (ret.
Failed())
return ret;
3069 DoClearSquare(tile1);
3071 MakeWaterKeepingClass(tile2, st->
owner);
3073 st->
rect.AfterRemoveTile(st, tile1);
3074 st->
rect.AfterRemoveTile(st, tile2);
3076 MakeShipStationAreaSmaller(st);
3093 if (s->current_order.GetDestination() != st->index) {
3108 s->SetDestTile(s->GetOrderStationLocation(st->index));
3124 const auto &layouts = _station_display_datas[st];
3125 if (gfx >= layouts.size()) gfx &= 1;
3126 return layouts.data() + gfx;
3145 snow_desert =
false;
3146 *overlay_offset =
RTO_X;
3152 snow_desert =
false;
3153 *overlay_offset =
RTO_Y;
3160 *overlay_offset =
RTO_X;
3167 *overlay_offset =
RTO_Y;
3174 if (ti !=
nullptr) {
3202 if (
layout < std::size(bridgeable_info))
return bridgeable_info[
layout].disallowed_pillars;
3203 return BRIDGEPILLARFLAGS_ALL;
3222 if (!HasFoundationNW(ti->
tile, slope, z))
SetBit(edge_info, 0);
3223 if (!HasFoundationNE(ti->
tile, slope, z))
SetBit(edge_info, 1);
3226 if (image == 0)
return false;
3230 static constexpr uint8_t foundation_parts[] = {
3231 UINT8_MAX, UINT8_MAX, UINT8_MAX, 0,
3236 assert(ti->
tileh < std::size(foundation_parts));
3237 if (foundation_parts[ti->
tileh] == UINT8_MAX)
return false;
3244 static constexpr uint8_t composite_foundation_parts[] = {
3245 0b0000'0000, 0b1101'0001, 0b1110'0100, 0b1110'0000,
3246 0b1100'1010, 0b1100'1001, 0b1100'0100, 0b1100'0000,
3247 0b1101'0010, 0b1001'0001, 0b1110'0100, 0b1010'0000,
3248 0b0100'1010, 0b0000'1001, 0b0100'0100,
3250 assert(ti->tileh < std::size(composite_foundation_parts));
3252 uint8_t parts = composite_foundation_parts[ti->tileh];
3259 if (parts == 0)
return false;
3262 for (uint i : SetBitIterator(parts)) {
3281 int32_t total_offset;
3283 uint32_t relocation = 0;
3284 uint32_t ground_relocation = 0;
3287 uint tile_layout = 0;
3299 if (statspec !=
nullptr) {
3310 if (!
layout->NeedsPreprocessing()) {
3336 case APT_RADAR_GRASS_FENCE_SW:
3339 case APT_GRASS_FENCE_NE_FLAG:
3342 case APT_RADAR_FENCE_SW:
3345 case APT_RADAR_FENCE_NE:
3348 case APT_GRASS_FENCE_NE_FLAG_2:
3373 bool draw_ground =
false;
3376 DrawWaterClassGround(ti);
3381 DrawWaterClassGround(ti);
3387 DrawShoreTile(ti->
tileh);
3415 }
else if (statspec !=
nullptr) {
3465 if (stopspec !=
nullptr) {
3466 stop_draw_mode = stopspec->draw_mode;
3468 std::array<int32_t, 1> regs100;
3469 auto result = GetRoadStopLayout(ti, stopspec, st, type, view, regs100);
3470 if (result.has_value()) {
3477 processor = std::move(*result);
3497 DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset);
3527 int32_t total_offset = 0;
3530 const RailTypeInfo *railtype_info =
nullptr;
3542 DrawSprite(ground + overlay_offset, PAL_NONE, x, y);
3551 uint sprite_offset = 5 - image;
3554 if (roadtype_info->UsesOverlay()) {
3556 DrawSprite(ground + sprite_offset, PAL_NONE, x, y);
3559 if (overlay)
DrawSprite(overlay + sprite_offset, PAL_NONE, x, y);
3560 }
else if (RoadTypeIsTram(roadtype)) {
3565 if (RoadTypeIsRoad(roadtype) && roadtype_info->UsesOverlay()) {
3577static void FillTileDescRoadStop(
TileIndex tile, TileDesc &td)
3603 td.
owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER;
3604 td.
owner[i] = road_owner;
3608 td.
owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER;
3609 td.
owner[i] = tram_owner;
3615void FillTileDescRailStation(
TileIndex tile, TileDesc &td)
3617 const StationSpec *spec = GetStationSpec(tile);
3619 if (spec !=
nullptr) {
3634void FillTileDescAirport(
TileIndex tile, TileDesc &td)
3660 if (
IsAirport(tile)) FillTileDescAirport(tile, td);
3664 default: NOT_REACHED();
3665 case StationType::Rail: str = STR_LAI_STATION_DESCRIPTION_RAILROAD_STATION;
break;
3667 str = (
IsHangar(tile) ? STR_LAI_STATION_DESCRIPTION_AIRCRAFT_HANGAR : STR_LAI_STATION_DESCRIPTION_AIRPORT);
3669 case StationType::Truck: str = STR_LAI_STATION_DESCRIPTION_TRUCK_LOADING_AREA;
break;
3670 case StationType::Bus: str = STR_LAI_STATION_DESCRIPTION_BUS_STATION;
break;
3793 if (new_rs != cur_rs) {
3811 AnimateStationTile(tile);
3816 AnimateAirportTile(tile);
3821 AnimateRoadStopTile(tile);
3860 if (stop + station_ahead - (
int)
TILE_SIZE >= station_length)
return {};
3874 }
else if (x < stop) {
3876 uint16_t spd = std::max(0, (stop - x) * 20 - 15);
3877 if (spd < v->cur_speed) v->
cur_speed = spd;
3907 if (cargoes.
None())
return;
3945static inline void byte_inc_sat(uint8_t *p)
3964 StationCargoAmountMap waiting_per_source;
3966 for (StationCargoAmountMap::iterator i(waiting_per_source.begin()); i != waiting_per_source.end(); ++i) {
3968 if (source_station ==
nullptr)
continue;
3981 bool waiting_changed =
false;
3983 byte_inc_sat(&st->time_since_load);
3984 byte_inc_sat(&st->time_since_unload);
4007 waiting_changed =
true;
4018 uint num_dests = ge->
HasData() ?
static_cast<uint
>(ge->
GetData().cargo.Packets()->MapSize()) : 0;
4026 uint waiting_avg = waiting / (num_dests + 1);
4028 if (
_cheats.station_rating.value) {
4029 ge->
rating = rating = MAX_STATION_RATING;
4046 rating =
GB(callback, 0, 14);
4049 if (
HasBit(callback, 14)) rating -= 0x4000;
4055 if (b >= 0) rating += b >> 2;
4059 if (waittime <= 21) rating += 25;
4060 if (waittime <= 12) rating += 25;
4061 if (waittime <= 6) rating += 45;
4062 if (waittime <= 3) rating += 35;
4075 if (age < 3) rating += 10;
4076 if (age < 2) rating += 10;
4077 if (age < 1) rating += 13;
4087 if (rating <= 64 && waiting_avg >= 100) {
4088 int dec = Random() & 0x1F;
4089 if (waiting_avg < 200) dec &= 7;
4090 waiting -= (dec + 1) * num_dests;
4091 waiting_changed =
true;
4095 if (rating <= 127 && waiting != 0) {
4096 uint32_t r = Random();
4097 if (rating <= (
int)
GB(r, 0, 7)) {
4099 waiting = std::max((
int)waiting - (
int)((
GB(r, 8, 2) + 1) * num_dests), 0);
4100 waiting_changed =
true;
4107 static const uint WAITING_CARGO_THRESHOLD = 1 << 12;
4108 static const uint WAITING_CARGO_CUT_FACTOR = 1 << 6;
4109 static const uint MAX_WAITING_CARGO = 1 << 15;
4111 if (waiting > WAITING_CARGO_THRESHOLD) {
4112 uint difference = waiting - WAITING_CARGO_THRESHOLD;
4113 waiting -= (difference / WAITING_CARGO_CUT_FACTOR);
4115 waiting = std::min(waiting, MAX_WAITING_CARGO);
4116 waiting_changed =
true;
4121 if (waiting_changed && waiting < ge->AvailableCount()) {
4134 StationID index = st->index;
4135 if (waiting_changed) {
4158 for (
Vehicle *v : st->loading_vehicles) {
4159 for (
Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
4160 if (u->cargo_type != cargo)
continue;
4161 u->cargo.Reroute(UINT_MAX, &u->cargo, avoid, avoid2, &ge);
4180 if (lg ==
nullptr)
continue;
4181 std::vector<NodeID> to_remove{};
4182 for (Edge &edge : (*lg)[ge.
node].edges) {
4184 assert(to->
goods[cargo].node == edge.dest_node);
4188 bool updated =
false;
4190 if (auto_distributed) {
4193 std::vector<Vehicle *> vehicles;
4195 bool found_from =
false;
4196 bool found_to =
false;
4197 for (
const Order &order : l->GetOrders()) {
4198 if (!order.IsType(OT_GOTO_STATION) && !order.IsType(OT_IMPLICIT))
continue;
4199 if (order.GetDestination() == from->index) {
4201 if (found_to)
break;
4202 }
else if (order.GetDestination() == to->index) {
4204 if (found_from)
break;
4207 if (!found_to || !found_from)
continue;
4208 vehicles.push_back(l->GetFirstSharedVehicle());
4211 auto iter = vehicles.begin();
4212 while (iter != vehicles.end()) {
4225 *iter = next_shared;
4228 iter = vehicles.erase(iter);
4231 if (iter == vehicles.end()) iter = vehicles.begin();
4237 to_remove.emplace_back(to->
goods[cargo].node);
4250 for (NodeID r : to_remove) (*lg)[ge.
node].RemoveEdge(r);
4275 if (ge1.
link_graph == LinkGraphID::Invalid()) {
4276 if (ge2.
link_graph == LinkGraphID::Invalid()) {
4283 Debug(misc, 0,
"Can't allocate link graph");
4292 }
else if (ge2.
link_graph == LinkGraphID::Invalid()) {
4310 if (lg !=
nullptr) {
4311 (*lg)[ge1.
node].UpdateEdge(ge2.
node, capacity, usage, time, modes);
4324 for (
const Vehicle *v = front; v !=
nullptr; v = v->
Next()) {
4325 if (v->refit_cap > 0) {
4332 IncreaseStats(st, v->cargo_type, next_station_id, v->refit_cap,
4339static void StationHandleSmallTick(BaseStation *st)
4350void OnTick_Station()
4354 for (BaseStation *st : BaseStation::Iterate()) {
4355 StationHandleSmallTick(st);
4381 for (GoodsEntry &ge : st->goods) {
4413 if (!CargoPacket::CanAllocateItem())
return 0;
4415 GoodsEntry &ge = st->
goods[cargo];
4421 if (amount == 0)
return 0;
4423 StationID next = ge.
GetVia(st->index);
4426 if (ge.
link_graph == LinkGraphID::Invalid()) {
4427 if (LinkGraph::CanAllocateItem()) {
4433 Debug(misc, 0,
"Can't allocate link graph");
4438 if (lg !=
nullptr) (*lg)[ge.
node].UpdateSupply(amount);
4457static bool IsUniqueStationName(
const std::string &name)
4460 if (!st->
name.empty() && st->
name == name)
return false;
4479 if (ret.
Failed())
return ret;
4481 bool reset = text.empty();
4485 if (!IsUniqueStationName(text))
return CommandCost(STR_ERROR_NAME_MUST_BE_UNIQUE);
4513 if (st ==
nullptr)
return {
CMD_ERROR, StationID::Invalid() };
4517 if (ret.
Failed())
return { ret, StationID::Invalid() };
4522 return {
CommandCost(STR_ERROR_SITE_UNSUITABLE), StationID::Invalid() };
4525 bool other_station =
false;
4529 if (s != st && s->
xy == tile) other_station =
true;
4532 if (other_station)
return {
CommandCost(STR_ERROR_SITE_UNSUITABLE), StationID::Invalid() };
4549 if (result.
Failed())
return;
4559 if (st->TileIsInCatchment(tile)) stations.insert(st);
4572 assert(this->
w == 1 && this->
h == 1);
4573 AddNearbyStationsByCatchment(this->tile, this->stations, Town::GetByTile(this->tile)->stations_near);
4576 this->stations.insert(st);
4582 return this->stations;
4592 if (st->
goods[cargo].rating == 0)
return false;
4595 if (
_settings_game.order.selectgoods && !st->
goods[cargo].HasVehicleEverTriedLoading())
return false;
4610 if (all_stations.empty())
return 0;
4611 if (amount == 0)
return 0;
4613 Station *first_station =
nullptr;
4614 typedef std::pair<Station *, uint> StationInfo;
4615 std::vector<StationInfo> used_stations;
4617 for (
Station *st : all_stations) {
4619 if (!CanMoveGoodsToStation(st, cargo))
continue;
4623 if (first_station ==
nullptr) {
4627 if (used_stations.empty()) {
4628 used_stations.reserve(2);
4629 used_stations.emplace_back(first_station, 0);
4631 used_stations.emplace_back(st, 0);
4635 if (first_station ==
nullptr)
return 0;
4637 if (used_stations.empty()) {
4639 amount *= first_station->
goods[cargo].rating + 1;
4640 return UpdateStationWaiting(first_station, cargo, amount, source);
4643 TypedIndexContainer<std::array<uint32_t,
OWNER_END.base()>, Owner> company_best = {};
4644 TypedIndexContainer<std::array<uint32_t,
OWNER_END.base()>, Owner> company_sum = {};
4645 uint best_rating = 0;
4648 for (
auto &p : used_stations) {
4649 auto owner = p.first->owner;
4650 auto rating = p.first->goods[cargo].rating;
4651 if (rating > company_best[owner]) {
4652 best_sum += rating - company_best[owner];
4653 company_best[owner] = rating;
4654 if (rating > best_rating) best_rating = rating;
4656 company_sum[owner] += rating;
4661 amount *= best_rating + 1;
4664 for (
auto &p : used_stations) {
4665 Owner owner = p.first->owner;
4668 p.second = amount * company_best[owner] * p.first->goods[cargo].rating / best_sum / company_sum[owner];
4673 if (amount > moving) {
4674 std::stable_sort(used_stations.begin(), used_stations.end(), [cargo](
const StationInfo &a,
const StationInfo &b) {
4675 return b.first->goods[cargo].rating < a.first->goods[cargo].rating;
4678 assert(amount - moving <= used_stations.size());
4679 for (uint i = 0; i < amount - moving; i++) {
4680 used_stations[i].second++;
4685 for (
auto &p : used_stations) {
4686 moved += UpdateStationWaiting(p.first, cargo, p.second, source);
4692void UpdateStationDockingTiles(
Station *st)
4706 int x2 = std::min<int>(x + area->
w + 1,
Map::SizeX());
4707 int x1 = std::max<int>(x - 1, 0);
4709 int y2 = std::min<int>(y + area->
h + 1,
Map::SizeY());
4710 int y1 = std::max<int>(y - 1, 0);
4720 if (!Station::CanAllocateItem()) {
4721 Debug(misc, 0,
"Can't allocate station for oilrig at 0x{:X}, reverting to oilrig only", tile);
4726 _station_kdtree.
Insert(st->index);
4745 UpdateStationDockingTiles(st);
4747 st->
rect.BeforeAddTile(tile, StationRect::ADD_FORCE);
4757 for (
Station *near : nearby) {
4758 near->RecomputeCatchment(
true);
4888 if (ret.
Failed())
return ret;
4896 if (ret.
Failed())
return ret;
4899 if (ret.
Failed())
return ret;
4933 if (remove_road.
Failed())
return remove_road;
4938 if (remove_road.
Failed())
return remove_road;
4982 return Command<Commands::LandscapeClear>::Do(flags, tile);
4993 for (
const auto &it : this->
shares) {
4994 if (it.second == st) {
4995 return it.first - prev;
5011 if (this->
unrestricted == 0)
return StationID::Invalid();
5012 assert(!this->
shares.empty());
5014 assert(it != this->
shares.end() && it->first <= this->unrestricted);
5015 if (it->second != excluded && it->second != excluded2)
return it->second;
5020 uint end = it->first;
5021 uint begin = (it == this->
shares.begin() ? 0 : (--it)->first);
5022 uint interval = end - begin;
5023 if (interval >= this->
unrestricted)
return StationID::Invalid();
5026 SharesMap::const_iterator it2 = (rand < begin) ? this->
shares.upper_bound(rand) :
5027 this->
shares.upper_bound(rand + interval);
5028 assert(it2 != this->
shares.end() && it2->first <= this->unrestricted);
5029 if (it2->second != excluded && it2->second != excluded2)
return it2->second;
5034 uint end2 = it2->first;
5035 uint begin2 = (it2 == this->
shares.begin() ? 0 : (--it2)->first);
5036 uint interval2 = end2 - begin2;
5037 if (interval2 >= new_max)
return StationID::Invalid();
5038 new_max -= interval2;
5039 if (begin > begin2) {
5040 std::swap(begin, begin2);
5041 std::swap(end, end2);
5042 std::swap(interval, interval2);
5047 it3 = this->
shares.upper_bound(rand);
5048 }
else if (rand < begin2 - interval) {
5049 it3 = this->
shares.upper_bound(rand + interval);
5051 it3 = this->
shares.upper_bound(rand + interval + interval2);
5053 assert(it3 != this->
shares.end() && it3->first <= this->unrestricted);
5064 assert(!this->
shares.empty());
5065 SharesMap new_shares;
5067 for (
const auto &it : this->
shares) {
5068 new_shares[++i] = it.second;
5069 if (it.first == this->unrestricted) this->
unrestricted = i;
5071 this->shares.swap(new_shares);
5072 assert(!this->shares.empty() && this->unrestricted <= (--this->shares.end())->first);
5085 assert(!this->
shares.empty());
5087 uint removed_shares = 0;
5088 uint added_shares = 0;
5089 uint last_share = 0;
5090 SharesMap new_shares;
5091 for (
const auto &it : this->
shares) {
5092 if (it.second == st) {
5094 uint share = it.first - last_share;
5095 if (flow == INT_MIN || (uint)(-flow) >= share) {
5096 removed_shares += share;
5097 if (it.first <= this->unrestricted) this->
unrestricted -= share;
5098 if (flow != INT_MIN) flow += share;
5099 last_share = it.first;
5102 removed_shares += (uint)(-flow);
5104 added_shares += (uint)(flow);
5106 if (it.first <= this->unrestricted) this->
unrestricted += flow;
5112 new_shares[it.first + added_shares - removed_shares] = it.second;
5113 last_share = it.first;
5116 new_shares[last_share + (uint)flow] = st;
5123 this->shares.swap(new_shares);
5133 assert(!this->
shares.empty());
5135 uint last_share = 0;
5136 SharesMap new_shares;
5137 for (
auto &it : this->
shares) {
5139 if (it.first > this->unrestricted)
return;
5140 if (it.second == st) {
5141 flow = it.first - last_share;
5144 new_shares[it.first] = it.second;
5147 new_shares[it.first - flow] = it.second;
5149 last_share = it.first;
5151 if (flow == 0)
return;
5152 new_shares[last_share + flow] = st;
5153 this->shares.swap(new_shares);
5154 assert(!this->shares.empty());
5164 assert(!this->
shares.empty());
5166 uint next_share = 0;
5168 for (SharesMap::reverse_iterator it(this->
shares.rbegin()); it != this->shares.rend(); ++it) {
5169 if (it->first < this->unrestricted)
return;
5171 flow = next_share - it->first;
5175 if (it->first == this->unrestricted)
return;
5176 if (it->second == st) found =
true;
5178 next_share = it->first;
5180 if (flow == 0)
return;
5181 SharesMap new_shares;
5182 new_shares[flow] = st;
5183 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
5184 if (it->second != st) {
5185 new_shares[flow + it->first] = it->second;
5190 this->
shares.swap(new_shares);
5191 assert(!this->
shares.empty());
5201 assert(runtime > 0);
5202 SharesMap new_shares;
5204 for (
auto i : this->
shares) {
5205 share = std::max(share + 1, i.first * 30 / runtime);
5206 new_shares[share] = i.second;
5209 this->shares.swap(new_shares);
5220 FlowStatMap::iterator origin_it = this->find(origin);
5221 if (origin_it == this->end()) {
5222 this->emplace(origin,
FlowStat(via, flow));
5224 origin_it->second.ChangeShare(via, flow);
5225 assert(!origin_it->second.GetShares()->empty());
5239 FlowStatMap::iterator prev_it = this->find(origin);
5240 if (prev_it == this->end()) {
5243 this->emplace(origin, fs);
5245 prev_it->second.ChangeShare(via, flow);
5246 prev_it->second.ChangeShare(StationID::Invalid(), flow);
5247 assert(!prev_it->second.GetShares()->empty());
5257 for (
auto &i : *
this) {
5259 uint local = fs.
GetShare(StationID::Invalid());
5260 if (local > INT_MAX) {
5266 fs.
ChangeShare(StationID::Invalid(), -(
int)local);
5282 std::vector<StationID> ret;
5283 for (FlowStatMap::iterator f_it = this->begin(); f_it != this->end();) {
5287 ret.push_back(f_it->first);
5288 this->erase(f_it++);
5302 for (
auto &it : *
this) {
5303 it.second.RestrictShare(via);
5313 for (
auto &it : *
this) {
5314 it.second.ReleaseShare(via);
5325 for (
const auto &it : *
this) {
5326 ret += (--(it.second.GetShares()->end()))->first;
5339 for (
const auto &it : *
this) {
5340 ret += it.second.GetShare(via);
5352 FlowStatMap::const_iterator i = this->find(from);
5353 if (i == this->end())
return 0;
5354 return (--(i->second.GetShares()->end()))->first;
5365 FlowStatMap::const_iterator i = this->find(from);
5366 if (i == this->end())
return 0;
5367 return i->second.GetShare(via);
void UpdateAirplanesOnNewStation(const Station *st)
Updates the status of the Aircraft heading or in the station.
const AirportFTAClass * GetAirport(const uint8_t airport_type)
Get the finite state machine of an airport type.
static const uint INVALID_AIRPORTTILE
id for an invalid airport tile
static const uint NEW_AIRPORTTILE_OFFSET
offset of first newgrf airport tile
@ AirportClosed
Dummy block for indicating a closed airport.
@ FLYING
Vehicle is flying in the air.
@ NUM_AIRPORTS
Maximal number of airports in total.
@ AT_OILRIG
Oilrig airport.
Enum of the default airport tiles.
void AddAnimatedTile(TileIndex tile, bool mark_dirty)
Add the given tile to the animated tile table (if it does not exist yet).
void DeleteAnimatedTile(TileIndex tile, bool immediate)
Stops animation on the given tile.
Functions related to autoslope.
bool AutoslopeCheckForAxis(TileIndex tile, int z_new, Slope tileh_new, Axis axis)
Autoslope check for tiles with something built along an axis.
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.
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
constexpr uint8_t FindFirstBit(T x)
Search the first set bit in a value.
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
void DrawBridgeMiddle(const TileInfo *ti, BridgePillarFlags blocked_pillars)
Draw the middle bits of a bridge.
TileIndex GetSouthernBridgeEnd(TileIndex t)
Finds the southern end of a bridge starting at a middle tile.
int GetBridgeHeight(TileIndex t)
Get the height ('z') of a bridge.
Map accessor functions for bridges.
bool IsBridgeAbove(Tile t)
checks if a bridge is set above the ground of this tile
EnumBitSet< BridgePillarFlag, uint8_t > BridgePillarFlags
Bitset of BridgePillarFlag elements.
bool IsValidCargoType(CargoType cargo)
Test whether cargo type is not INVALID_CARGO.
EnumBitSet< CargoType, uint64_t > CargoTypes
Bitset of CargoType elements.
static constexpr CargoType NUM_CARGO
Maximum number of cargo types in a game.
CargoType
Cargo slots to indicate a cargo type within a game.
bool IsCargoInClass(CargoType cargo, CargoClasses cc)
Does cargo c have cargo class cc?
Cheats _cheats
All the cheats.
Types related to cheating.
Iterator to iterate over all tiles belonging to an airport.
Iterator to iterate over all tiles belonging to an airport spec.
uint Count() const
Count the number of set bits.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr Tstorage base() const noexcept
Retrieve the raw value behind this bit set.
constexpr bool None() const
Test if none of the values are set.
constexpr Timpl & Flip()
Flip all bits.
constexpr Timpl & Reset()
Reset all bits.
constexpr Timpl & Set()
Set all bits.
constexpr bool Any(const Timpl &other) const
Test if any of the given values are set.
Iterator to iterate over all tiles belonging to a bitmaptilearea.
Common return value for all commands.
bool Succeeded() const
Did this command succeed?
void AddCost(const Money &cost)
Adds the given cost to the cost of the command.
Money GetCost() const
The costs as made up to this moment.
bool Failed() const
Did this command fail?
Iterate a range of enum values.
Flat set implementation that uses a sorted vector for storage.
std::pair< const_iterator, bool > insert(const Tkey &key)
Insert a key into the set, if it does not already exist.
uint GetFlow() const
Get the sum of all flows from this FlowStatMap.
void PassOnFlow(StationID origin, StationID via, uint amount)
Pass on some flow, remembering it as invalid, for later subtraction from locally consumed flow.
std::vector< StationID > DeleteFlows(StationID via)
Delete all flows at a station for specific cargo and destination.
void AddFlow(StationID origin, StationID via, uint amount)
Add some flow from "origin", going via "via".
uint GetFlowFrom(StationID from) const
Get the sum of flows from a specific station from this FlowStatMap.
void FinalizeLocalConsumption(StationID self)
Subtract invalid flows from locally consumed flow.
void ReleaseFlows(StationID via)
Release all flows at a station for specific cargo and destination.
uint GetFlowFromVia(StationID from, StationID via) const
Get the flow from a specific station via a specific other station.
uint GetFlowVia(StationID via) const
Get the sum of flows via a specific station from this FlowStatMap.
void RestrictFlows(StationID via)
Restrict all flows at a station for specific cargo and destination.
Flow statistics telling how much flow should be sent along a link.
static const SharesMap empty_sharesmap
Static instance of FlowStat::SharesMap.
void ScaleToMonthly(uint runtime)
Scale all shares from link graph's runtime to monthly values.
void RestrictShare(StationID st)
Restrict a flow by moving it to the end of the map and decreasing the amount of unrestricted flow.
uint GetShare(StationID st) const
Get flow for a station.
StationID GetVia() const
Get a station a package can be routed to.
const SharesMap * GetShares() const
Get the actual shares as a const pointer so that they can be iterated over.
SharesMap shares
Shares of flow to be sent via specified station (or consumed locally).
void ReleaseShare(StationID st)
Release ("unrestrict") a flow by moving it to the begin of the map and increasing the amount of unres...
void ChangeShare(StationID st, int flow)
Change share for specified station.
void AppendShare(StationID st, uint flow, bool restricted=false)
Add some flow to the end of the shares map.
void Invalidate()
Reduce all flows to minimum capacity so that they don't get in the way of link usage statistics too m...
uint unrestricted
Limit for unrestricted shares.
An interval timer will fire every interval, and will continue to fire until it is deleted.
void Insert(const T &element)
Insert a single element in the tree.
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
void Queue(LinkGraph *lg)
Queue a link graph for execution.
A connected component of a link graph.
void Merge(LinkGraph *other)
Merge a link graph with another one.
TimerGameEconomy::Date LastCompression() const
Get date of last compression.
NodeID AddNode(const Station *st)
Add a node to the component and create empty edges associated with it.
NodeID Size() const
Get the current size of the component.
static const uint MIN_TIMEOUT_DISTANCE
Minimum effective distance for timeout calculation.
static constexpr TimerGameEconomy::Date STALE_LINK_DEPOT_TIMEOUT
Number of days before deleting links served only by vehicles stopped in depot.
static constexpr TimerGameEconomy::Date COMPRESSION_INTERVAL
Minimum number of days between subsequent compressions of a LG.
static void Run(Vehicle *v, bool allow_merge=true, bool is_full_loading=false)
Refresh all links the given vehicle will visit.
const Tspec * GetSpec(uint index) const
Get a spec from the class at a given index.
uint GetSpecCount() const
Get the number of allocated specs within the class.
static NewGRFClass * Get(StationClassID class_index)
static uint GetClassCount()
StringID name
Name of this class.
const RailStationTileLayout & stl
Station tile layout being iterated.
uint position
Position within iterator.
StationGfx operator*() const
Dereference operator.
uint length
Length of platforms.
std::span< const StationGfx > layout
Predefined tile layout.
This struct contains all the info that is needed to draw and construct tracks.
SpriteID single_x
single piece of rail in X direction, without ground
uint16_t max_speed
Maximum speed for vehicles travelling on this rail type.
struct RailTypeInfo::@157247141350136173143103254227157213063052244122 strings
Strings associated with the rail type.
SpriteID single_y
single piece of rail in Y direction, without ground
StringID name
Name of this rail type.
uint8_t fallback_railtype
Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations.
uint GetRailtypeSpriteOffset() const
Offset between the current railtype and normal rail.
struct RailTypeInfo::@332027037331076264023214171276243307073252216167 base_sprites
Struct containing the main sprites.
uint16_t max_speed
Maximum speed for vehicles travelling on this road type.
struct RoadTypeInfo::@070000167274302256150317022075324310363002361255 strings
Strings associated with the rail type.
StringID name
Name of this rail type.
Generate TileIndices around a center tile or tile area, with increasing distance.
Add dynamic register values to a sprite layout.
DrawTileSpriteSpan GetLayout() const
Returns the result spritelayout after preprocessing.
uint Reroute(uint max_move, StationCargoList *dest, StationID avoid, StationID avoid2, const GoodsEntry *ge)
Routes packets with station "avoid" as next hop to a different place.
void Append(CargoPacket *cp, StationID next)
Appends the given cargo packet to the range of packets with the same next station.
uint Truncate(uint max_move=UINT_MAX, StationCargoAmountMap *cargo_per_source=nullptr)
Truncates where each destination loses roughly the same percentage of its cargo.
const StationList & GetStations()
Run a tile loop to find stations around a tile, on demand.
static constexpr TimerGameTick::Ticks STATION_LINKGRAPH_TICKS
Cycle duration for cleaning dead links.
static constexpr TimerGameTick::Ticks STATION_ACCEPTANCE_TICKS
Cycle duration for updating station acceptance.
static constexpr TimerGameTick::Ticks STATION_RATING_TICKS
Cycle duration for updating station rating.
Base class for tile iterators.
Wrapper class to abstract away the way the tiles are stored.
static Date date
Current date in days (day counter).
static constexpr TimerGame< struct Economy >::Date INVALID_DATE
static Date date
Current date in days (day counter).
static TickCounter counter
Monotonic counter, in ticks, since start of game.
StrongType::Typedef< int32_t, DateTag< struct Economy >, StrongType::Compare, StrongType::Integer > Date
Iterate over all vehicles on a tile.
void DrawClearLandTile(const TileInfo *ti, uint8_t density)
Draw a ClearGround::Grass tile.
Functions related to clear (TileType::Clear) land.
CommandCost CommandCostWithParam(StringID str, uint64_t value)
Return an error status, with string and parameter.
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
Commands
List of commands.
EnumBitSet< DoCommandFlag, uint16_t > DoCommandFlags
Bitset of DoCommandFlag elements.
Definition of stuff that is very close to a company, like the company struct itself.
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_END
Last + 1 owner.
static constexpr Owner OWNER_TOWN
A town owns the tile, or a town is expanding.
static constexpr Owner OWNER_NONE
The tile has no ownership.
static constexpr Owner INVALID_OWNER
An invalid owner.
static constexpr Owner OWNER_WATER
The tile/execution is done by "water".
Some simple functions to help with accessing containers.
bool include(Container &container, typename Container::const_reference &item)
Helper function to append an item to a container if it is not already contained.
Functions related to debugging.
#define Debug(category, level, format_string,...)
Output a line of debugging information.
bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
Find out if the slope of the tile is suitable to build a depot of given direction.
void ShowDepotWindow(TileIndex tile, VehicleType type)
Opens a depot window.
bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
DiagDirections AxisToDiagDirs(Axis a)
Converts an Axis to DiagDirections.
bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
DiagDirection AxisToDiagDir(Axis a)
Converts an Axis to a DiagDirection.
Axis OtherAxis(Axis a)
Select the other axis as provided.
Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
EnumIndexArray< T, DiagDirection, DiagDirection::End > DiagDirectionIndexArray
Array with DiagDirection as index.
Direction
Defines the 8 directions on the map.
Axis
Enumeration for the two axis X and Y.
DiagDirection
Enumeration for diagonal directions.
@ Invalid
Flag for an invalid DiagDirection.
@ End
Used for iterations.
EnumBitSet< DiagDirection, uint8_t > DiagDirections
Bitset of DiagDirection elements.
Prices _price
Prices and also the fractional part.
static const uint ROAD_STOP_TRACKBIT_FACTOR
Multiplier for how many regular track bits a bay stop counts.
@ Construction
Construction costs.
Price
Enumeration of all base prices for use with Prices.
@ BuildStationTruck
Price for building lorry stations.
@ ClearStationBus
Price for destroying bus stops.
@ BuildStationBus
Price for building bus stops.
@ ClearStationAirport
Price for destroying airports.
@ ClearStationTruck
Price for destroying lorry stations.
@ BuildStationAirport
Price for building airports.
@ ClearStationDock
Price for destroying docks.
@ ClearStationRail
Price for destroying rail stations.
@ BuildStationRailLength
Additional price for building rail stations dependent on their length.
@ BuildFoundation
Price for building foundation under other constructions e.g. roads, rails, depots,...
@ BuildStationRail
Price for building rail stations.
@ BuildStationDock
Price for building docks.
@ ClearWaypointRail
Price for destroying rail waypoints.
@ ClearRail
Price for destroying rails.
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.
#define T
Climate temperate.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23).
EnumClassIndexContainer< std::array< T, to_underlying(N)>, Index > EnumIndexArray
A typedef for EnumClassIndexContainer using std::array as the backing container type.
Flat set container implementation.
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 MarkTilesDirty(bool cargo_change) const
Marks the tiles of the station as dirty.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
static const SpriteID SPR_RAIL_TRACK_Y
static const SpriteID SPR_MONO_TRACK_X_SNOW
static const SpriteID SPR_MGLV_TRACK_Y_SNOW
static const SpriteID SPR_MONO_TRACK_Y
static const SpriteID SPR_MONO_TRACK_Y_SNOW
static const SpriteID SPR_MONO_TRACK_X
static const SpriteID SPR_RAIL_TRACK_X_SNOW
static const SpriteID SPR_MGLV_TRACK_X
static const SpriteID SPR_RAIL_TRACK_Y_SNOW
static const SpriteID SPR_MGLV_TRACK_X_SNOW
static const SpriteID SPR_MGLV_TRACK_Y
static const SpriteID SPR_RAIL_TRACK_X
HouseZone
Concentric rings of zoning around the centre of a town.
@ TownEdge
Edge of the town; roads without pavement.
bool IsTileForestIndustry(TileIndex tile)
Check whether the tile is a forest.
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
IndustryType GetIndustryType(Tile tile)
Retrieve the type for this industry.
IndustryID GetIndustryIndex(Tile t)
Get the industry ID of the given tile.
static const IndustryType NUM_INDUSTRYTYPES
total number of industry types, new and old; limited to 240 because we need some special ids like IT_...
const TileTypeProcs _tile_type_station_procs
TileTypeProcs definitions for TileType::Station tiles.
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner)
Change the owner of a tile.
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
std::tuple< Slope, int > GetFoundationPixelSlope(TileIndex tile)
Get slope of a tile on top of a (possible) foundation If a tile does not have a foundation,...
uint ApplyPixelFoundationToSlope(Foundation f, Slope &s)
Applies a foundation to a slope.
Point RemapCoords2(int x, int y)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap.
Command definitions related to landscape (slopes etc.).
@ Arctic
Landscape with snow levels.
@ Tropic
Landscape with distinct rainforests and deserts,.
Some typedefs for the main game.
EnumBitSet< EdgeUpdateMode, uint8_t > EdgeUpdateModes
Bitset of EdgeUpdateMode elements.
@ Increase
Increase capacity.
@ Manual
Manual distribution. No link graph calculations are run.
#define Point
Macro that prevents name conflicts between included headers.
uint DistanceFromEdge(TileIndex tile)
Param the minimum distance to an edge.
uint DistanceMax(TileIndex t0, TileIndex t1)
Gets the biggest distance component (x or y) between the two given tiles.
TileIndex TileAddWrap(TileIndex tile, int addx, int addy)
This function checks if we add addx/addy to tile, if we do wrap around the edges.
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between two tiles from a TileIndexDiffC struct.
TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
TileIndexDiff TileOffsByAxis(Axis axis)
Convert an Axis to a TileIndexDiff.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
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.
int32_t TileIndexDiff
An offset value between two tiles.
constexpr bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
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 Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
constexpr uint ClampU(const uint a, const uint min, const uint max)
Clamp an unsigned integer between an interval.
constexpr To ClampTo(From value)
Clamp the given value down to lie within the requested type.
@ Buoy
Buoy without underlying water.
@ RoadStops
Road stops feature.
@ Stations
Stations feature.
@ Airports
Airports feature.
@ AirportTiles
Airport tiles feature.
uint8_t StationGfx
Copy from station_map.h.
StationGfx GetTranslatedAirportTileID(StationGfx gfx)
Do airporttile gfx ID translation for NewGRFs.
NewGRF handling of airport tiles.
@ NoAnimation
There is no animation.
@ DrawTileLayout
Use callback to select a tile layout to use when drawing.
@ Avail
Availability of station in construction window.
@ SlopeCheck
Check slope of new station tiles.
@ StationRatingCalc
custom station rating for this cargo type
@ CBID_STATION_BUILD_TILE_LAYOUT
Called when building a station to customize the tile layout.
@ CBID_STATION_DRAW_TILE_LAYOUT
Choose a tile layout to draw, instead of the standard range.
@ CBID_CARGO_STATION_RATING_CALC
Called to calculate part of a station rating.
@ CBID_STATION_AVAILABILITY
Determine whether a newstation should be made available to build.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
@ Avail
Availability of road stop in construction window.
SpriteID GetCanalSprite(CanalFeature feature, TileIndex tile)
Lookup the base sprite to use for a canal.
Handling of NewGRF canals.
Cargo support for NewGRFs.
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
void ErrorUnknownCallbackResult(GrfID grfid, uint16_t cbid, uint16_t cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
GRFConfig * GetGRFConfig(GrfID grfid, uint32_t mask)
Retrieve a NewGRF from the current config by its grfid.
Functions/types related to NewGRF debugging.
void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index)
Delete inspect window for a given feature and index.
void TriggerHouseAnimation_WatchedCargoAccepted(TileIndex tile, CargoTypes trigger_cargoes)
Run watched cargo accepted callback for a house.
Functions related to NewGRF houses.
SpriteID GetCustomRailSprite(const RailTypeInfo *rti, TileIndex tile, RailSpriteType rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
NewGRF handling of rail types.
void TriggerRoadStopRandomisation(BaseStation *st, TileIndex tile, StationRandomTrigger trigger, CargoType cargo_type)
Trigger road stop randomisation.
void DeallocateSpecFromRoadStop(BaseStation *st, uint8_t specindex)
Deallocate a RoadStopSpec from a Station.
std::optional< uint8_t > AllocateSpecToRoadStop(const RoadStopSpec *spec, BaseStation *st)
Allocate a RoadStopSpec to a Station.
void AssignSpecToRoadStop(const RoadStopSpec *spec, BaseStation *st, uint8_t specindex)
Assign a previously allocated RoadStopSpec specindex to a Station.
NewGRF definitions and structures for road stops.
@ Overlay
Drive-through stops: Draw the road overlay, e.g. pavement.
@ WaypGround
Waypoints: Draw the sprite layout ground tile (on top of the road).
@ Road
Bay stops: Draw the road itself.
bool IsWaypointClass(const RoadStopClass &cls)
Test if a RoadStopClass is the waypoint class.
PoolID< uint16_t, struct RoadStopClassIDTag, UINT16_MAX, UINT16_MAX > RoadStopClassID
Class IDs for stations.
EnumBitSet< RoadStopDrawMode, uint8_t > RoadStopDrawModes
Bitset of RoadStopDrawMode elements.
@ ROADSTOPTYPE_FREIGHT
This RoadStop is for freight (truck) stops.
@ ROADSTOPTYPE_ALL
This RoadStop is for both types of station road stops.
@ ROADSTOPTYPE_PASSENGER
This RoadStop is for passenger (bus) stops.
@ NoCatenary
Do not show catenary.
@ DriveThroughOnly
Stop is drive-through only.
@ DrawModeRegister
Read draw mode from register 0x100.
SpriteID GetCustomRoadSprite(const RoadTypeInfo *rti, TileIndex tile, RoadSpriteType rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
NewGRF handling of road types.
SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32_t var10)
Resolve sprites for drawing a station tile.
SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint layout, uint edge_info)
Resolve the sprites for custom station foundations.
void AssignSpecToStation(const StationSpec *spec, BaseStation *st, uint8_t specindex)
Assign a previously allocated StationSpec specindex to a Station.
void DeallocateSpecFromStation(BaseStation *st, uint8_t specindex)
Deallocate a StationSpec from a Station.
void TriggerStationRandomisation(BaseStation *st, TileIndex trigger_tile, StationRandomTrigger trigger, CargoType cargo_type)
Trigger station randomisation.
CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_tile, const StationSpec *statspec, Axis axis, uint8_t plat_len, uint8_t numtracks)
Check the slope of a tile of a new station.
uint32_t GetPlatformInfo(StationGfx gfx, int platforms, int length, int platform, int position, bool centred)
Evaluate a tile's position within a station, and return the result in a bit-stuffed format.
std::optional< uint8_t > AllocateSpecToStation(const StationSpec *spec, BaseStation *st)
Allocate a StationSpec to a Station.
Header file for NewGRF stations.
@ CustomFoundations
Draw custom foundations.
@ SeparateGround
Use different sprite set for ground sprites.
@ ExtendedFoundations
Extended foundation block instead of simple.
NewGRFClass< StationSpec, StationClassID > StationClass
Class containing information relating to station classes.
PoolID< uint16_t, struct StationClassIDTag, UINT16_MAX, UINT16_MAX > StationClassID
Class IDs for stations.
Functions related to news.
void AddNewsItem(EncodedString &&headline, NewsType type, NewsStyle style, NewsFlags flags, NewsReference ref1={}, NewsReference ref2={}, std::unique_ptr< NewsAllocatedData > &&data=nullptr, AdviceType advice_type=AdviceType::Invalid)
Add a new newsitem to be shown.
@ Acceptance
A type of cargo is (no longer) accepted.
@ Small
Small news item. (Information window with text and viewport).
@ InColour
News item is shown in colour (otherwise it is shown in black & white).
@ LinkGraph
A game paused due to the link graph schedule lagging.
@ Editor
In the scenario editor.
Functions related to order backups.
Train * GetTrainForReservation(TileIndex tile, Track track)
Find the train which has reserved a specific path.
void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool b)
Set the reservation for a complete station platform.
bool ValParamRailType(const RailType rail)
Validate functions for rail building.
@ Ground
Main group of ground images.
@ Overlay
Images for overlaying track.
Money RailBuildCost(RailType railtype)
Returns the cost of building the specified 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.
RailTrackOffset
Offsets for sprites within an overlay/underlay set.
@ RTO_Y
Piece of rail in Y direction.
@ RTO_X
Piece of rail in X direction.
Command definitions for rail.
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
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.
void MakeRailNormal(Tile t, Owner o, TrackBits b, RailType r)
Make the given tile a normal rail.
TrackBits GetRailReservationTrackBits(Tile t)
Returns the reserved track bits of the tile.
bool HasSignals(Tile t)
Checks if a rail tile has signals.
RailType
Enumeration for all possible railtypes.
@ INVALID_RAILTYPE
Flag for invalid railtype.
Pseudo random number generator.
uint32_t RandomRange(uint32_t limit, const std::source_location location=std::source_location::current())
Pick a random number between 0 and limit - 1, inclusive.
Declaration of link refreshing utility.
bool ValParamRoadType(RoadType roadtype)
Validate functions for rail building.
bool HasPowerOnRoad(RoadType enginetype, RoadType tiletype)
Checks if an engine of the given RoadType got power on a tile with a given RoadType.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
@ Roadstop
Required: Bay stop surface.
@ Ground
Required: Main group of ground images.
@ Overlay
Optional: Images for overlaying track.
Money RoadBuildCost(RoadType roadtype)
Returns the cost of building the specified roadtype.
void DrawRoadGroundSprites(const TileInfo *ti, RoadBits road, RoadBits tram, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rti, Roadside roadside, bool snow_or_desert)
Draw road ground sprites.
void DrawRoadCatenary(const TileInfo *ti)
Draws the catenary for the given tile.
void UpdateCompanyRoadInfrastructure(RoadType rt, Owner o, int count)
Update road infrastructure counts for a company.
CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadTramType rtt, DoCommandFlags flags, bool town_check)
Is it allowed to remove the given road bits from the given tile?
void DrawRoadOverlays(const TileInfo *ti, PaletteID pal, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rti, uint road_offset, uint tram_offset, bool draw_underlay)
Draw road underlay and overlay sprites.
Functions related to roads.
RoadBits AxisToRoadBits(Axis a)
Create the road-part which belongs to the given Axis.
Functions used internally by the roads.
bool MayHaveRoad(Tile t)
Test whether a tile can have road/tram types.
RoadBits GetAnyRoadBits(Tile tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance)
Returns the RoadBits on an arbitrary tile Special behaviour:
void SetRoadOwner(Tile t, RoadTramType rtt, Owner o)
Set the owner of a specific road type.
RoadType GetRoadTypeRoad(Tile t)
Get the road type for RoadTramType being RoadTramType::Road.
RoadBits GetRoadBits(Tile t, RoadTramType rtt)
Get the present road bits for a specific road type.
DisallowedRoadDirections GetDisallowedRoadDirections(Tile t)
Gets the disallowed directions.
bool HasTileRoadType(Tile t, RoadTramType rtt)
Check if a tile has a road or a tram road type.
RoadType GetRoadTypeTram(Tile t)
Get the road type for RoadTramType being RoadTramType::Tram.
void MakeRoadNormal(Tile t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
Make a normal road tile.
RoadBits GetAllRoadBits(Tile tile)
Get all set RoadBits on the given tile.
RoadType GetRoadType(Tile t, RoadTramType rtt)
Get the road type for the given RoadTramType.
static bool IsNormalRoadTile(Tile t)
Return whether a tile is a normal road tile.
Owner GetRoadOwner(Tile t, RoadTramType rtt)
Get the owner of a specific road type.
Roadside
The possible road side decorations.
@ Paved
Road with paved sidewalks.
@ Barren
Road on barren land.
static constexpr RoadBits ROAD_X
Full road along the x-axis (south-west + north-east).
EnumBitSet< RoadBit, uint8_t > RoadBits
Bitset of RoadBit elements.
static constexpr RoadBits ROAD_Y
Full road along the y-axis (north-west + south-east).
static constexpr RoadTramTypes ROADTRAMTYPES_ALL
All possible RoadTramTypes.
RoadType
The different roadtypes we support.
@ INVALID_ROADTYPE
flag for invalid roadtype
RoadTramType
The different types of road type.
Base class for roadstops.
@ RVSB_IN_ROAD_STOP
The vehicle is in a road stop.
@ RVSB_ROAD_STOP_TRACKDIR_MASK
Only bits 0 and 3 are used to encode the trackdir for road stops.
@ RVS_IN_DT_ROAD_STOP
The vehicle is in a drive-through road stop.
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.
bool IsShipDestinationTile(TileIndex tile, StationID station)
Test if a tile is a docking tile for the given station.
void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner)
Add track to signal update buffer.
@ Enter
signal entering the block found
static constexpr int GetSlopeMaxZ(Slope s)
Returns the height of the highest corner of a slope relative to TileZ (= minimal height).
static constexpr bool IsSteepSlope(Slope s)
Checks if a slope is steep.
Foundation FlatteningFoundation(Slope s)
Returns the foundation needed to flatten a slope.
DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
Slope
Enumeration for the slope-type.
@ Leveled
The tile is leveled up to a flat slope.
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 SpriteID SPR_TRAMWAY_TRAM
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
static const SpriteID SPR_FLAT_SNOW_DESERT_TILE
static const PaletteID PALETTE_TO_GREY
static const SpriteID SPR_IMG_BUOY
static const SpriteID SPR_FLAT_GRASS_TILE
static constexpr uint8_t SPRITE_MODIFIER_CUSTOM_SPRITE
these masks change the colours of the palette for a sprite.
static constexpr uint8_t SPRITE_WIDTH
number of bits for the sprite number
static constexpr uint8_t PALETTE_MODIFIER_COLOUR
this bit is set when a recolouring process is in action
Base classes/functions for stations.
void ForAllStationsAroundTiles(const TileArea &ta, Func func)
Call a function on all stations that have any part of the requested area within their catchment.
static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlags flags, int replacement_spec_index=-1)
Remove a bus station/truck stop.
std::tuple< CommandCost, StationID > CmdMoveStationName(DoCommandFlags flags, StationID station_id, TileIndex tile)
Move a station name.
static StringID GetBridgeTooLowMessageForStationType(StationType type)
Get station-type-specific string for a bridge that is too low.
static void GetTileDesc_Station(TileIndex tile, TileDesc &td)
Tile callback function signature for obtaining a tile description.
static CommandCost BuildStationPart(Station **st, DoCommandFlags flags, bool reuse, TileArea area, StationNaming name_class)
Common part of building various station parts and possibly attaching them to an existing one.
static CommandCost RemoveRailWaypoint(TileIndex tile, DoCommandFlags flags)
Remove a rail waypoint.
void CcMoveStationName(Commands, const CommandCost &result, StationID station_id)
Callback function that is called after a name is moved.
CommandCost IsRailStationBridgeAboveOk(TileIndex tile, const StationSpec *spec, StationType type, StationGfx layout)
Test if a rail station can be built below a bridge.
uint8_t GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance)
Get a possible noise reduction factor based on distance from town center.
static constexpr DiagDirectionIndexArray< uint8_t > _dock_w_chk
X dimension of dock for each direction.
static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
Tile callback function signature of the terraforming callback.
CommandCost RemoveFromRailBaseStation(TileArea ta, std::vector< T * > &affected_stations, DoCommandFlags flags, Money removal_cost, bool keep_rail)
Remove a number of tiles from any rail station within the area.
static CommandCost CalculateRailStationCost(TileArea tile_area, DoCommandFlags flags, Axis axis, StationID *station, RailType rt, std::vector< Train * > &affected_vehicles, StationClassID spec_class, uint16_t spec_index, uint8_t plat_len, uint8_t numtracks)
Calculates cost of new rail stations within the area.
static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming name_class)
Generate a station name for the given station at the given location.
CommandCost CanExpandRailStation(const BaseStation *st, TileArea &new_ta)
Check whether we can expand the rail part of the given station.
void ClearDockingTilesCheckingNeighbours(TileIndex tile)
Clear docking tile status from tiles around a removed dock, if the tile has no neighbours which would...
bool(* CMSAMatcher)(TileIndex tile)
Function to check whether the given tile matches some criterion.
CommandCost IsRoadStationBridgeAboveOk(TileIndex tile, const RoadStopSpec *spec, StationType type, StationGfx layout)
Test if a road station can be built below a bridge.
bool IsHangar(Tile t)
Check whether the given tile is a hangar.
static Station * GetClosestDeletedStation(TileIndex tile)
Find the closest deleted station of the current company.
CommandCost CmdRenameStation(DoCommandFlags flags, StationID station_id, const std::string &text)
Rename a station.
std::pair< CargoArray, CargoTypes > GetAcceptanceAroundTiles(TileIndex center_tile, int w, int h, int rad)
Get the acceptance of cargoes around the tile in 1/8.
static CommandCost RemoveAirport(TileIndex tile, DoCommandFlags flags)
Remove an airport.
static void TileLoop_Station(TileIndex tile)
Tile callback function signature for running periodic tile updates.
static bool CMSAMine(TileIndex tile)
Check whether the tile is a mine.
void IncreaseStats(Station *st, CargoType cargo, StationID next_station_id, uint capacity, uint usage, uint32_t time, EdgeUpdateModes modes)
Increase capacity for a link stat given by station cargo and next hop.
static CommandCost CheckFlatLandRoadStop(TileIndex cur_tile, int &allowed_z, const RoadStopSpec *spec, DoCommandFlags flags, DiagDirections invalid_dirs, bool is_drive_through, StationType station_type, Axis axis, StationID *station, RoadType rt)
Checks if a road stop can be built at the given tile.
static CommandCost RemoveGenericRoadStop(DoCommandFlags flags, const TileArea &roadstop_area, bool road_waypoint, bool remove_road)
Remove a tile area of road stop or road waypoints.
static void TruncateCargo(const CargoSpec *cs, GoodsEntry *ge, uint amount=UINT_MAX)
Truncate the cargo by a specific amount.
CommandCost CmdRemoveFromRailWaypoint(DoCommandFlags flags, TileIndex start, TileIndex end, bool keep_rail)
Remove a single tile from a waypoint.
StationNaming
Station types a station could be named after.
@ Oilrig
Heliport of an oilrig.
@ Heliport
Standalone heliport.
@ Airport
Airport for fixed wing aircraft.
CommandCost FindJoiningWaypoint(StationID existing_waypoint, StationID waypoint_to_join, bool adjacent, TileArea ta, Waypoint **wp, bool is_road)
Find a nearby waypoint that joins this waypoint.
CommandCost CmdBuildDock(DoCommandFlags flags, TileIndex tile, StationID station_to_join, bool adjacent)
Build a dock/haven.
CommandCost IsBuoyBridgeAboveOk(TileIndex tile)
Test if a buoy can be built below a bridge.
static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCommandFlags flags)
Checks if an airport can be built at the given location and clear the area.
CommandCost RemoveRoadWaypointStop(TileIndex tile, DoCommandFlags flags, int replacement_spec_index=-1)
Remove a road waypoint.
CommandCost GetStationAround(TileArea ta, StationID closest_station, CompanyID company, T **st, F filter)
Look for a station owned by the given company around the given tile area.
CommandCost CmdRemoveRoadStop(DoCommandFlags flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road)
Remove bus or truck stops.
static VehicleEnterTileStates VehicleEnterTile_Station(Vehicle *v, TileIndex tile, int x, int y)
Tile callback function for a vehicle entering a tile.
static void ChangeTileOwner_Station(TileIndex tile, Owner old_owner, Owner new_owner)
Tile callback function signature for changing the owner of a tile.
bool HasStationInUse(StationID station, bool include_company, CompanyID company)
Tests whether the company's vehicles have this station in orders.
static int CountMapSquareAround(TileIndex tile, CMSAMatcher cmp)
Counts the numbers of tiles matching a specific type in the area around.
CommandCost CmdBuildRoadStop(DoCommandFlags flags, TileIndex tile, uint8_t width, uint8_t length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
Build a bus or truck stop.
static StationSpec::TileFlags GetStationTileFlags(StationGfx gfx, const StationSpec *statspec)
Get station tile flags for the given StationGfx.
static CommandCost IsDockBridgeAboveOk(TileIndex tile, StationGfx layout)
Test if a dock can be built below a bridge.
static bool DrawCustomStationFoundations(const StationSpec *statspec, BaseStation *st, TileInfo *ti, StationGfx gfx)
Draw custom station foundations for a NewGRF station if provided.
const DrawTileSprites * GetStationTileLayout(StationType st, uint8_t gfx)
Get station tile layout for a station type and its station gfx.
CommandCost CmdRemoveFromRoadWaypoint(DoCommandFlags flags, TileIndex start, TileIndex end)
Remove road waypoints.
void RerouteCargo(Station *st, CargoType cargo, StationID avoid, StationID avoid2)
Reroute cargo of type c at station st or in any vehicles unloading there.
static constexpr DiagDirectionIndexArray< TileIndexDiffC > _dock_tileoffs_chkaround
Offset of northern-most dock tile for each direction.
CommandCost ClearTile_Station(TileIndex tile, DoCommandFlags flags)
Tile callback function signature for clearing a tile.
static std::pair< CargoArray, CargoTypes > GetAcceptanceAroundStation(const Station *st)
Get the acceptance of cargoes around the station in.
static void UpdateStationRating(Station *st)
Periodic update of a station's rating.
static TrackStatus GetTileTrackStatus_Station(TileIndex tile, TransportType mode, RoadTramType sub_mode, DiagDirection side)
Tile callback function signature for getting the possible tracks that can be taken on a given tile by...
void UpdateAllStationVirtCoords()
Update the virtual coords needed to draw the station sign for all stations.
static void DrawTile_Station(TileInfo *ti)
Tile callback function signature for drawing a tile and its contents to the screen.
static bool CMSAWater(TileIndex tile)
Check whether the tile is water.
CommandCost CmdBuildAirport(DoCommandFlags flags, TileIndex tile, uint8_t airport_type, uint8_t layout, StationID station_to_join, bool allow_adjacent)
Place an Airport.
void TriggerWatchedCargoCallbacks(Station *st)
Run the watched cargo callback for all houses in the catchment area.
static CommandCost CanRemoveRoadWithStop(TileIndex tile, DoCommandFlags flags)
Check if a drive-through road stop tile can be cleared.
static RoadStop ** FindRoadStopSpot(bool truck_station, Station *st)
CargoTypes GetAcceptanceMask(const Station *st)
Get a mask of the cargo types that the station accepts.
static void RestoreTrainReservation(Train *v)
Restore platform reservation during station building/removing.
void UpdateAirportsNoise()
Recalculate the noise generated by the airports of each town.
static std::span< const BridgeableTileInfo > GetStationBridgeableTileInfo(StationType type)
Get bridgeable tile information for a station type.
static bool CMSATree(TileIndex tile)
Check whether the tile is a tree.
void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius)
Forcibly modify station ratings near a given tile.
CommandCost RemoveRailStation(T *st, DoCommandFlags flags, Money removal_cost)
Remove a rail station/waypoint.
void UpdateStationAcceptance(Station *st, bool show_msg)
Update the acceptance for a station.
static CommandCost FindJoiningRoadStop(StationID existing_stop, StationID station_to_join, bool adjacent, TileArea ta, Station **st)
Find a nearby station that joins this road stop.
CommandCost CmdOpenCloseAirport(DoCommandFlags flags, StationID station_id)
Open/close an airport to incoming aircraft.
static const IntervalTimer< TimerGameEconomy > _economy_stations_monthly({TimerGameEconomy::Trigger::Month, TimerGameEconomy::Priority::Station}, [](auto) { for(Station *st :Station::Iterate()) { for(GoodsEntry &ge :st->goods) { ge.status.Set(GoodsEntry::State::LastMonth, ge.status.Test(GoodsEntry::State::CurrentMonth));ge.status.Reset(GoodsEntry::State::CurrentMonth);} } })
Economy monthly loop for stations.
static CommandCost CheckFlatLandRailStation(TileIndex tile_cur, TileIndex north_tile, int &allowed_z, DoCommandFlags flags, Axis axis, StationID *station, RailType rt, std::vector< Train * > &affected_vehicles, StationClassID spec_class, uint16_t spec_index, uint8_t plat_len, uint8_t numtracks)
Checks if a rail station can be built at the given tile.
static TileIndex FindDockLandPart(TileIndex t)
Find the part of a dock that is land-based.
static CommandCost CheckBuildAbove_Station(TileIndex tile, DoCommandFlags flags, Axis axis, int height)
Tile callback function signature to test if a bridge can be built above a tile.
static void FreeTrainReservation(Train *v)
Clear platform reservation during station building/removing.
static bool ClickTile_Station(TileIndex tile)
Tile callback function signature for clicking a tile.
void SetRailStationTileFlags(TileIndex tile, const StationSpec *statspec)
Set rail station tile flags for the given tile.
CommandCost CalculateRoadStopCost(TileArea tile_area, DoCommandFlags flags, bool is_drive_through, StationType station_type, const RoadStopSpec *roadstopspec, Axis axis, DiagDirection ddir, StationID *station, RoadType rt, Money unit_cost)
Calculates cost of new road stops within the area.
CargoTypes GetCargoWaitingMask(const Station *st)
Get a mask of the cargo types that have cargo waiting at the station.
static CommandCost RemoveDock(TileIndex tile, DoCommandFlags flags)
Remove a dock.
static void AnimateTile_Station(TileIndex tile)
Tile callback function signature for animating a tile.
bool SplitGroundSpriteForOverlay(const TileInfo *ti, SpriteID *ground, RailTrackOffset *overlay_offset)
Check whether a sprite is a track sprite, which can be replaced by a non-track ground sprite and a ra...
CargoArray GetProductionAroundTiles(TileIndex north_tile, int w, int h, int rad)
Get the cargo types being produced around the tile (in a rectangle).
CommandCost CmdRemoveFromRailStation(DoCommandFlags flags, TileIndex start, TileIndex end, bool keep_rail)
Remove a single tile from a rail station.
static CommandCost FindJoiningStation(StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, Station **st)
Find a nearby station that joins this station.
void DeleteStaleLinks(Station *from)
Check all next hops of cargo packets in this station for existence of a a valid link they may use to ...
static BridgePillarFlags GetStationBlockedPillars(std::span< const BridgeableTileInfo > bridgeable_info, uint8_t layout)
Get blocked pillar information for a station tile.
CommandCost CheckBuildableTile(TileIndex tile, DiagDirections invalid_dirs, int &allowed_z, bool allow_steep, bool check_bridge=true)
Checks if the given tile is buildable, flat and has a certain height.
static constexpr DiagDirectionIndexArray< uint8_t > _dock_h_chk
Y dimension of dock for each direction.
CommandCost FindJoiningBaseStation(StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, T **st, F filter)
Find a nearby station that joins this station.
Town * AirportGetNearestTown(const AirportSpec *as, Direction rotation, TileIndex tile, TileIterator &&it, uint &mindist)
Finds the town nearest to given airport.
static bool StationHandleBigTick(BaseStation *st)
This function is called for each station once every 250 ticks.
static void ShowRejectOrAcceptNews(const Station *st, CargoTypes cargoes, bool reject)
Add news item for when a station changes which cargoes it accepts.
CommandCost CmdBuildRailStation(DoCommandFlags flags, TileIndex tile_org, RailType rt, Axis axis, uint8_t numtracks, uint8_t plat_len, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
Build rail station.
static void DeleteStationIfEmpty(BaseStation *st)
This is called right after a station was deleted.
static CommandCost IsStationBridgeAboveOk(TileIndex tile, std::span< const BridgeableTileInfo > bridgeable_info, StationType type, StationGfx layout, int bridge_height, StringID disallowed_msg=INVALID_STRING_ID)
Test if a bridge can be built above a station.
Command definitions related to stations.
Functions related to stations.
void ShowStationViewWindow(StationID station)
Opens StationViewWindow for given station.
@ Count
by amount of cargo
Declarations for accessing the k-d tree of stations.
void ForAllStationsRadius(TileIndex center, uint radius, Func func)
Call a function on all stations whose sign is within a radius of a center tile.
Sprites to use and how to display them for station tiles.
Functions related to station layouts.
void MakeAirport(Tile t, Owner o, StationID sid, uint8_t section, WaterClass wc)
Make the given tile an airport tile.
StationType GetStationType(Tile t)
Get the station type of this tile.
StationGfx GetStationGfx(Tile t)
Get the station graphics of this tile.
void SetStationGfx(Tile t, StationGfx gfx)
Set the station graphics of this tile.
void MakeRoadStop(Tile t, Owner o, StationID sid, RoadStopType rst, RoadType road_rt, RoadType tram_rt, DiagDirection d)
Make the given tile a roadstop tile.
void SetCustomStationSpecIndex(Tile t, uint8_t specindex)
Set the custom station spec for this tile.
void SetStationTileHaveWires(Tile t, bool b)
Set the catenary wires state of the rail station.
bool IsAirport(Tile t)
Is this station tile an airport?
bool IsBayRoadStopTile(Tile t)
Is tile t a bay (non-drive through) road stop station?
uint GetCustomRoadStopSpecIndex(Tile t)
Get the custom road stop spec for this tile.
static const int GFX_DOCK_BASE_WATER_PART
The offset for the water parts.
bool IsBuoy(Tile t)
Is tile t a buoy tile?
bool IsCompatibleTrainStationTile(Tile test_tile, Tile station_tile)
Check if a tile is a valid continuation to a railstation tile.
bool IsRoadWaypoint(Tile t)
Is the station at t a road waypoint?
void MakeDriveThroughRoadStop(Tile t, Owner station, Owner road, Owner tram, StationID sid, StationType rst, RoadType road_rt, RoadType tram_rt, Axis a)
Make the given tile a drivethrough roadstop tile.
bool IsDriveThroughStopTile(Tile t)
Is tile t a drive through road stop station or waypoint?
static Roadside GetRoadWaypointRoadside(Tile tile)
Get the decorations of a road waypoint.
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.
static void ToggleRoadWaypointOnSnowOrDesert(Tile t)
Toggle the snow/desert state of a road waypoint tile.
StationID GetStationIndex(Tile t)
Get StationID from a tile.
bool HasStationTileRail(Tile t)
Has this station tile a rail?
StationGfx GetAirportGfx(Tile t)
Get the station graphics of this airport tile.
uint GetCustomStationSpecIndex(Tile t)
Get the custom station spec for this tile.
bool IsRailWaypoint(Tile t)
Is this station tile a rail waypoint?
bool IsRailStation(Tile t)
Is this station tile a rail station?
bool IsDockTile(Tile t)
Is tile t a dock tile?
static void SetRoadWaypointRoadside(Tile tile, Roadside s)
Set the decorations of a road waypoint.
void SetStationTileRandomBits(Tile t, uint8_t random_bits)
Set the random bits for a station tile.
bool IsAnyRoadStop(Tile t)
Is the station at t a road station?
void MakeOilrig(Tile t, StationID sid, WaterClass wc)
Make the given tile an oilrig tile.
DiagDirection GetDockDirection(Tile t)
Get the direction of a dock.
Axis GetRailStationAxis(Tile t)
Get the rail direction of a rail station.
static bool IsRoadWaypointOnSnowOrDesert(Tile t)
Check if a road waypoint tile has snow/desert.
bool IsRoadWaypointTile(Tile t)
Is this tile a station tile and a road waypoint?
bool IsStationTileBlocked(Tile t)
Is tile t a blocked tile?
bool IsTruckStop(Tile t)
Is the station at t a truck stop?
bool IsStationRoadStop(Tile t)
Is the station at t a road station?
bool IsCustomStationSpecIndex(Tile t)
Is there a custom rail station spec on this tile?
bool HasStationRail(Tile t)
Has this station tile a rail?
static const int GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET
The offset for the drive through parts.
Axis GetDriveThroughStopAxis(Tile t)
Gets the axis of the drive through stop.
void SetStationTileHavePylons(Tile t, bool b)
Set the catenary pylon state of the rail station.
bool IsOilRig(Tile t)
Is tile t part of an oilrig?
bool IsBuoyTile(Tile t)
Is tile t a buoy tile?
void MakeRailStation(Tile t, Owner o, StationID sid, Axis a, uint8_t section, RailType rt)
Make the given tile a rail station tile.
bool HasStationReservation(Tile t)
Get the reservation state of the rail station.
void MakeDock(Tile t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
Make the given tile a dock tile.
DiagDirection GetBayRoadStopDir(Tile t)
Gets the direction the bay road stop entrance points towards.
bool IsDock(Tile t)
Is tile t a dock tile?
bool IsAnyRoadStopTile(Tile t)
Is tile t a road stop station?
void SetStationTileBlocked(Tile t, bool b)
Set the blocked state of the rail station.
RoadStopType GetRoadStopType(Tile t)
Get the road stop type of this tile.
void SetCustomRoadStopSpecIndex(Tile t, uint8_t specindex)
Set the custom road stop spec for this tile.
RoadStopType
Types of RoadStops.
@ Bus
A standard stop for buses.
@ Truck
A standard stop for trucks.
@ Dock
Station with a dock.
@ Waypoint
Station is a waypoint.
@ TruckStop
Station with truck stops.
@ Train
Station with train station.
@ Airport
Station with an airport.
@ BusStop
Station with bus stops.
StationType
Station types.
@ Rail
Railways/train station.
@ Bus
Road stop for busses.
@ Truck
Road stop for trucks.
@ RailWaypoint
Waypoint for trains.
@ Buoy
Waypoint for ships.
@ RoadWaypoint
Waypoint for trucks and busses.
@ Oilrig
Heliport on an oil rig.
@ Airport
Airports and heliports, excluding the ones on oil rigs.
@ NewCargo
Trigger station on new cargo arrival.
std::set< Station *, StationCompare > StationList
List of stations.
@ Built
Trigger tile when built.
@ TileLoop
Trigger in the periodic tile loop.
@ NewCargo
Trigger station on new cargo arrival.
@ AcceptanceTick
Trigger station every 250 ticks.
EnumBitSet< StationFacility, uint8_t > StationFacilities
Bitset of StationFacility elements.
static const uint MAX_LENGTH_STATION_NAME_CHARS
The maximum length of a station name in characters including '\0'.
@ Built
Triggered when the airport is built (for all tiles at the same time).
@ TileLoop
Triggered in the periodic tile loop.
@ NewCargo
Triggered when new cargo arrives at the station (for all tiles at the same time).
@ AcceptanceTick
Triggered every 250 ticks (for all tiles at the same time).
Definition of base types and functions in a cross-platform compatible way.
size_t Utf8StringLength(std::string_view str)
Get the length of an UTF-8 encoded string in number of characters and thus not the number of bytes th...
Functions related to low-level strings.
void GetStringWithArgs(StringBuilder &builder, StringID string, StringParameters &args, uint case_index, bool game_script)
Get a parsed string with most special stringcodes replaced by the string parameters.
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Functions related to OTTD's strings.
auto MakeParameters(Args &&... args)
Helper to create the StringParameters with its own buffer with the given parameter values.
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).
Aircraft, helicopters, rotors and their shadows belong to this class.
@ Airplanes
Can planes land on this airport type?
Defines the data structure for an airport.
StringID name
name of this airport
SubstituteGRFFileProps grf_prop
Properties related to the grf file.
std::vector< AirportTileLayout > layouts
List of layouts composing the airport.
bool IsWithinMapBounds(uint8_t table, TileIndex index) const
Check if the airport would be within the map bounds at the given tile.
uint8_t size_y
size of airport in y direction
uint8_t size_x
size of airport in x direction
static const AirportSpec * Get(uint8_t type)
Retrieve airport spec for the given airport.
std::span< const HangarTileTable > depots
Position of the depots on the airports.
bool IsAvailable() const
Check whether this airport is available to build.
uint8_t noise_level
noise that this airport generates
Defines the data structure of each individual tile of an airport.
static const AirportTileSpec * Get(StationGfx gfx)
Retrieve airport tile spec for the given airport tile.
SubstituteGRFFileProps grf_prop
properties related the the grf file
StringID name
Tile Subname string, land information on this tile will give you "AirportName (TileSubname)".
static const AirportTileSpec * GetByTile(TileIndex tile)
Retrieve airport tile spec for the given airport tile.
All airport-related information.
AirportBlocks blocks
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
TileIndex GetRotatedTileFromOffset(TileIndexDiffC tidc) const
Add the tileoffset to the base tile of this airport but rotate it first.
uint GetHangarNum(TileIndex tile) const
Get the hangar number of the hangar at a specific tile.
Direction rotation
How this airport is rotated.
uint8_t type
Type of this airport,.
PersistentStorage * psa
Persistent storage for NewGRF airports.
uint GetNumHangars() const
Get the number of hangars on this airport.
TileIndex GetHangarTile(uint hangar_num) const
Get the first tile of the given hangar.
const AirportSpec * GetSpec() const
Get the AirportSpec that from the airport type of this airport.
uint8_t layout
Airport layout number.
Base class for all station-ish types.
StringID string_id
Default name (town area) of station.
TileIndex xy
Base tile of the station.
virtual void MoveSign(TileIndex new_xy)
Move this station's main coordinate somewhere else.
std::vector< SpecMapping< StationSpec > > speclist
List of rail station specs of this station.
StationFacilities facilities
The facilities that this station has.
std::string cached_name
NOSAVE: Cache of the resolved name of the station, if not using a custom name.
TileArea train_station
Tile area the train 'station' part covers.
StationAnimationTriggers cached_anim_triggers
NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen.
Owner owner
The owner of this station.
virtual void UpdateVirtCoord()=0
Update the coordinated of the sign (as shown in the viewport).
uint8_t delete_ctr
Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is ...
StationAnimationTriggers cached_roadstop_anim_triggers
NOSAVE: Combined animation trigger bitmask for road stops, used to determine if trigger processing sh...
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
bool IsInUse() const
Check whether the base station currently is in use; in use means that it is not scheduled for deletio...
Town * town
The town this station is associated with.
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
virtual bool TileBelongsToRailStation(TileIndex tile) const =0
Check whether a specific tile belongs to this station.
TrackedViewportSign sign
NOSAVE: Dimensions of sign.
TimerGameCalendar::Date build_date
Date of construction.
std::string name
Custom name.
VehicleType type
Type of vehicle.
Class for storing amounts of cargo.
Specification of a cargo type.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo type.
CargoType Index() const
Determines index of this cargospec.
static IterateWrapper Iterate(size_t from=0)
Returns an iterable ensemble of all valid CargoSpec.
uint32_t station
Count of company owned station tiles.
std::array< uint32_t, RAILTYPE_END > rail
Count of company owned track bits for each rail type.
uint32_t water
Count of company owned track bits for canals.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
Ground palette sprite of a tile, together with its sprite layout.
Ground palette sprite of a tile, together with its sprite layout.
PalSpriteID ground
Palette and sprite for the ground.
std::string GetName() const
Get the name of this grf.
GrfID grfid
grfid that introduced this entity.
const struct GRFFile * grffile
grf file that introduced this entity
bool HasGrfFile() const
Test if this entity was introduced by NewGRF.
StationSettings station
settings related to station management
FlowStatMap flows
Planned flows through this station.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
Stores station stats for a single cargo.
uint max_waiting_cargo
Max cargo from this station waiting at any station.
bool HasRating() const
Does this cargo have a rating at this station?
uint8_t last_speed
Maximum speed (up to 255) of the last vehicle that tried to load this cargo.
uint8_t last_age
Age in years (up to 255) of the last vehicle that tried to load this cargo.
uint8_t time_since_pickup
Number of rating-intervals (up to 255) since the last vehicle tried to load this cargo.
States status
Status of this cargo, see State.
NodeID node
ID of node in link graph referring to this goods entry.
@ LastMonth
Set when cargo was delivered for final delivery last month.
@ Acceptance
Set when the station accepts the cargo currently for final deliveries.
@ Rating
This indicates whether a cargo has a rating at the station.
@ AcceptedBigtick
Set when cargo was delivered for final delivery during the current STATION_ACCEPTANCE_TICKS interval.
@ CurrentMonth
Set when cargo was delivered for final delivery this month.
const GoodsEntryData & GetData() const
Get optional cargo packet/flow data.
uint8_t amount_fract
Fractional part of the amount in the cargo list.
LinkGraphID link_graph
Link graph this station belongs to.
bool HasVehicleEverTriedLoading() const
Reports whether a vehicle has ever tried to load the cargo at this station.
uint8_t rating
Station rating for this cargo.
bool HasData() const
Test if this goods entry has optional cargo packet/flow data.
GoodsEntryData & GetOrCreateData()
Get optional cargo packet/flow data.
uint AvailableCount() const
Returns sum of cargo still available for loading at the station.
StationID GetVia(StationID source) const
Get the best next hop for a cargo packet from station source.
Defines the data structure for constructing industry.
SubstituteGRFFileProps grf_prop
properties related to the grf file
StringID name
Displayed name of the industry.
StringID station_name
Default name for nearby station.
bool enabled
entity still available (by default true).newgrf can disable it, though
IndustryLifeTypes life_type
This is also known as Industry production flag, in newgrf specs.
Defines the internal data of a functional industry.
IndustryType type
type of industry.
ProducedCargoes produced
produced cargo slots
Owner owner
owner of the industry. Which SHOULD always be (imho) OWNER_NONE
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
TileArea location
Location of the industry.
Station * neutral_station
Associated neutral station.
StationList stations_near
NOSAVE: List of nearby stations.
static uint SizeX()
Get the size of the map along the X.
static uint SizeY()
Get the size of the map along the Y.
static uint Size()
Get the size of the map.
Tindex class_index
Class index of this spec, invalid until class is allocated.
NewGRF supplied spritelayout.
static void Reset(TileIndex tile=INVALID_TILE, bool from_gui=true)
Reset the OrderBackups from GUI/game logic.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
If you change this, keep in mind that it is also saved in 2 other places:
bool IsType(OrderType type) const
Check whether this order is of the given type.
bool ShouldStopAtStation(const Vehicle *v, StationID station) const
Check whether the given vehicle should stop at the given station based on this order and the non-stop...
uint16_t w
The width of the area.
void Add(TileIndex to_add)
Add a single tile to a tile area; enlarge if needed.
void Clear()
Clears the 'tile area', i.e.
TileIndex tile
The base tile of the area.
uint16_t h
The height of the area.
OrthogonalTileArea & Expand(int rad)
Expand a tile area by rad tiles in each direction, keeping within map bounds.
SpriteID sprite
The 'real' sprite.
PaletteID pal
The palette (use PAL_NONE) if not needed).
static Pool::IterateWrapper< BaseStation > Iterate(size_t from=0)
static T * Create(Targs &&... args)
static Industry * Get(auto index)
static size_t GetNumItems()
static bool CanAllocateItem(size_t n=1)
static bool IsValidID(auto index)
static LinkGraph * GetIfValid(auto index)
Money GetBuildCost(Price category) const
Get the cost for building a road stop of this type.
std::array< BridgeableTileInfo, 6 > bridgeable_info
Per tile layout bridge information.
CargoGRFFileProps grf_prop
Link to NewGRF.
Money GetClearCost(Price category) const
Get the cost for clearing a road stop of this type.
A Stop for a Road Vehicle.
RoadStop * next
Next stop of the given type at this station.
static RoadStop * GetByTile(TileIndex tile, RoadStopType type)
Find a roadstop at given tile.
void MakeDriveThrough()
Join this road stop to another 'base' road stop if possible; fill all necessary data to become an act...
void ClearDriveThrough()
Prepare for removal of this stop; update other neighbouring stops if needed.
Buses, trucks and trams belong to this class.
All ships have this type.
static bool IsValidID(auto index)
static Station * Create(Targs &&... args)
static bool IsExpected(const BaseStation *st)
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
static Station * Get(auto index)
static Station * GetIfValid(auto index)
static Station * From(BaseStation *st)
static RoadVehicle * From(Vehicle *v)
T * Last()
Get the last vehicle in the chain.
bool HasSpriteGroups() const
Check whether the entity has sprite groups.
StationRect - used to track station spread out rectangle - cheaper than scanning whole map.
bool PtInExtendedRect(int x, int y, int distance=0) const
Determines whether a given point (x, y) is within a certain distance of the station rectangle.
bool serve_neutral_industries
company stations can serve industries with attached neutral stations
std::vector< BridgeableTileInfo > bridgeable_info
Per tile layout bridge information.
uint8_t disallowed_lengths
Bitmask of platform lengths available for the station.
StringID name
Name of this station.
uint8_t disallowed_platforms
Bitmask of number of platforms available for the station.
CargoGRFFileProps grf_prop
Link to NewGRF.
std::vector< TileFlags > tileflags
List of tile flags.
std::vector< NewGRFSpriteLayout > renderdata
Number of tile layouts.
EnumBitSet< TileFlag, uint8_t > TileFlags
Bitset of TileFlag elements.
StationCallbackMasks callback_mask
Bitmask of station callbacks that have to be called.
@ NoWires
Tile should NOT contain catenary wires.
@ Pylons
Tile should contain catenary pylons.
@ Blocked
Tile is blocked to vehicles.
StationSpecFlags flags
Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size.
TileArea GetTileArea(StationType type) const override
Get the tile area for a given station type.
RoadStop * bus_stops
All the road stops.
TileArea ship_station
Tile area the ship 'station' part covers.
IndustryType indtype
Industry type to get the name from.
TileArea docking_station
Tile area the docking tiles cover.
CargoTypes always_accepted
Bitmask of always accepted cargo types (by houses, HQs, industry tiles when industry doesn't accept c...
Industry * industry
NOSAVE: Associated industry for neutral stations. (Rebuilt on load from Industry->st).
void MoveSign(TileIndex new_xy) override
Move the station main coordinate somewhere else.
std::array< GoodsEntry, NUM_CARGO > goods
Goods at this station.
TileArea bus_station
Tile area the bus 'station' part covers.
BitmapTileArea catchment_tiles
NOSAVE: Set of individual tiles covered by catchment area.
void RecomputeCatchment(bool no_clear_nearby_lists=false)
Recompute tiles covered in our catchment area.
void AfterStationTileSetChange(bool adding, StationType type)
After adding/removing tiles to station, update some station-related stuff.
Airport airport
Tile area the airport covers.
void UpdateVirtCoord() override
Update the virtual coords needed to draw the station sign.
TileArea truck_station
Tile area the truck 'station' part covers.
RoadStop * truck_stops
All the truck stops.
void AddFacility(StationFacility new_facility_bit, TileIndex facil_xy)
Called when new facility is built on the station.
uint16_t subst_id
The id of the entity to replace.
Tile description for the 'land area information' tool.
uint16_t rail_speed
Speed limit of rail (bridges and track).
std::optional< std::string > grf
newGRF used for the tile contents
StringID station_name
Type of station within the class.
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 airport_class
Name of the airport class.
StringID airport_name
Name of the airport.
uint16_t tram_speed
Speed limit of tram (bridges and track).
StringID roadtype
Type of road on the tile.
StringID tramtype
Type of tram on the tile.
StringID railtype
Type of rail on the tile.
uint16_t road_speed
Speed limit of road (bridges and track).
std::array< StringID, 4 > owner_type
Type of each owner.
StringID airport_tile_name
Name of the airport tile.
StringID station_class
Class of station.
Tile information, used while rendering the tile.
Slope tileh
Slope of the tile.
TileIndex tile
Tile index.
CompanyMask statues
which companies have a statue?
TileIndex xy
town center tile
uint16_t noise_reached
level of noise that all the airports are generating
uint16_t MaxTownNoise() const
Calculate the max town noise.
CompanyID exclusivity
which company has exclusivity
uint8_t exclusive_counter
months till the exclusivity expires
'Train' is either a loco or a wagon.
Trackdir GetVehicleTrackdir() const override
Get the tracks of the train vehicle.
Direction GetMovingDirection() const
Get the moving direction of this vehicle chain.
bool IsStoppedInDepot() const
Check whether the vehicle is in the depot and stopped.
bool IsMovingFront() const
Is this vehicle the moving front of the vehicle chain?
TimerGameEconomy::Date date_of_last_service
Last economy date the vehicle had a service at a depot.
virtual void SetDestTile(TileIndex tile)
Set the destination of this vehicle.
VehStates vehstatus
Status.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
virtual TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
Order current_order
The current order (+ status, like: loading).
Vehicle * Next() const
Get the next vehicle of this vehicle.
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
uint16_t cur_speed
current speed
bool IsFrontEngine() const
Check if the vehicle is a front engine.
TileIndex tile
Current tile index.
TileIndex dest_tile
Heading for this tile.
Owner owner
Which company owns the vehicle?
Representation of a waypoint.
TileArea road_waypoint_area
Tile area the road waypoint part covers.
uint16_t waypoint_flags
Waypoint flags, see WaypointFlags.
void UpdateVirtCoord() override
Update the virtual coords needed to draw the waypoint sign.
@ Source
town/industry is source of subsidised path
@ EnteredStation
The vehicle entered a station.
@ CannotEnter
The vehicle cannot enter the tile.
void AddProducedCargo(TileIndex tile, CargoArray &produced)
Obtain the produced cargo of a tile.
EnumBitSet< VehicleEnterTileState, uint8_t > VehicleEnterTileStates
Bitset of VehicleEnterTileState elements.
void AddAcceptedCargo(TileIndex tile, CargoArray &acceptance, CargoTypes &always_accepted)
Obtain cargo acceptance of a tile.
bool IsTileFlat(TileIndex tile, int *h)
Check if a given tile is flat.
std::tuple< Slope, int > GetTileSlopeZ(TileIndex tile)
Return the slope of a given tile inside the map.
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
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.
uint8_t GetAnimationFrame(Tile t)
Get the current animation frame.
bool IsValidTile(Tile tile)
Checks if a tile is valid.
TropicZone GetTropicZone(Tile tile)
Get the tropic zone.
void SetAnimationFrame(Tile t, uint8_t frame)
Set a new animation frame.
Slope GetTileSlope(TileIndex tile)
Return the slope of a given tile inside the map.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
static constexpr uint TILE_SIZE
Tile size in world coordinates.
static constexpr uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in ZOOM_BASE.
@ Station
A tile of a station or airport.
@ Industry
Part of an industry.
@ Trees
Tile with one or more trees.
@ House
A house by a town.
@ Road
A tile with road and/or tram tracks.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Functions related to tile highlights.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition of Interval and OneShot timers.
Definition of the game-calendar-timer.
Definition of the game-economy-timer.
Definition of the tick-based game-timer.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
HouseZone GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlags flags)
Checks whether the local authority allows construction of a new station (rail, road,...
TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
bool IsReversingRoadTrackdir(Trackdir dir)
Checks whether the trackdir means that we are reversing.
Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
Track AxisToTrack(Axis a)
Convert an Axis to the corresponding Track Axis::X -> Track::X Axis::Y -> Track::Y Uses the fact that...
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 DiagDirection to the associated diagonal Track.
static constexpr TrackBits TRACK_BIT_3WAY_NE
"Arrow" to the north-east
EnumBitSet< Track, uint8_t > TrackBits
Bitset of Track elements.
static constexpr TrackBits TRACK_BIT_ALL
All possible tracks.
Trackdir
Enumeration for tracks and directions.
Track
These are used to specify a single track.
@ Upper
Track in the upper corner of the tile (north).
@ Y
Track along the y-axis (north-west to south-east).
@ Left
Track in the left corner of the tile (west).
Base for the train class.
bool TryPathReserve(Train *v, bool mark_as_stuck=false, bool first_tile_okay=false)
Try to reserve a path to a safe position.
int GetTrainStopLocation(StationID station_id, TileIndex tile, const Train *moving_front, int *station_ahead, int *station_length)
Get the stop location of (the center) of the front vehicle of a train at a platform of a station.
void FreeTrainTrackReservation(const Train *v)
Free the reserved path in front of a vehicle.
@ Buildings
company buildings - depots, stations, HQ, ...
TransportType
Available types of transport.
@ Water
Transport over water.
@ Rail
Transport by train.
@ Road
Transport by road vehicle.
Functions that have tunnels and bridges in common.
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
@ TrainSlowing
Train is slowing down.
Functions related to vehicles.
@ Invalid
Non-existing type of vehicle.
@ Aircraft
Aircraft vehicle type.
@ Train
Train vehicle type.
Functions and type for generating vehicle lists.
void FindVehiclesWithOrder(VehiclePredicate veh_pred, OrderPredicate ord_pred, VehicleFunc veh_func)
Find vehicles matching an order.
void OffsetGroundSprite(int x, int y)
Called when a foundation has been drawn for the current tile.
void SetViewportStationRect(const Station *st, bool sel)
Select or deselect station for rectangle area highlight.
void StartSpriteCombine()
Starts a block of sprites, which are "combined" into a single bounding box.
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 EndSpriteCombine()
Terminates a block of sprites started by StartSpriteCombine.
void DrawGroundSprite(SpriteID image, PaletteID pal, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
Draws a ground sprite for the current tile.
Functions related to (drawing on) viewports.
static const int TILE_HEIGHT_STEP
One Z unit tile height difference is displayed as 50m.
Declarations for accessing the k-d tree of viewports.
Functions related to water management.
void TileLoop_Water(TileIndex tile)
Tile callback function signature for running periodic tile updates.
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.
bool HasTileWaterGround(Tile t)
Checks whether the tile has water at the ground.
bool IsTileOnWater(Tile t)
Tests if the tile was built on water.
WaterClass
classes of water (for WaterTileType::Clear water tile type).
@ Invalid
Used for industry tiles on land (also for oilrig if newgrf says so).
bool HasTileWaterClass(Tile t)
Checks whether the tile has an waterclass associated.
WaterClass GetWaterClass(Tile t)
Get the water class at a 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.
bool IsWater(Tile t)
Is it a plain water tile?
bool IsWaterTile(Tile t)
Is it a water tile with plain water?
@ WPF_ROAD
This is a road waypoint.
CommandCost RemoveBuoy(TileIndex tile, DoCommandFlags flags)
Remove a buoy.
Command definitions related to waypoints.
Functions related to waypoints.
void ShowWaypointWindow(const Waypoint *wp)
Show the window for the given waypoint.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting).
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-...
void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, WidgetID widget_index)
Mark a particular widget in a particular window as dirty (in need of repainting).
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting).
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
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.
@ Station
station encountered (could be a target next time)