15 #include "viewport_kdtree.h"
31 #include "strings_internal.h"
73 #include "table/strings.h"
102 for (
const auto &depot : as->
depots) {
118 template <
class T,
class F>
127 if (!T::IsValidID(t) || T::Get(t)->owner != company || !filter(T::Get(t)))
continue;
128 if (closest_station == INVALID_STATION) {
130 }
else if (closest_station != t) {
135 *st = (closest_station == INVALID_STATION) ?
nullptr : T::Get(closest_station);
156 for (
int dx = -3; dx <= 3; dx++) {
157 for (
int dy = -3; dy <= 3; dy++) {
181 for (
const auto &p : ind->
produced) {
213 #define M(x) ((x) - STR_SV_STNAME)
218 STATIONNAMING_AIRPORT,
219 STATIONNAMING_OILRIG,
221 STATIONNAMING_HELIPORT,
246 if (
GetIndustrySpec(indtype)->station_name == STR_UNDEFINED)
return false;
250 sni->
free_names &= ~(1 <<
M(STR_SV_STNAME_OILFIELD) | 1 <<
M(STR_SV_STNAME_MINES));
256 static const uint32_t _gen_station_name_bits[] = {
259 1U <<
M(STR_SV_STNAME_AIRPORT),
260 1U <<
M(STR_SV_STNAME_OILFIELD),
261 1U <<
M(STR_SV_STNAME_DOCKS),
262 1U <<
M(STR_SV_STNAME_HELIPORT),
271 if (s != st && s->
town == t) {
272 if (s->indtype != IT_INVALID) {
273 sni.indtypes[s->indtype] =
true;
275 if (name != STR_UNDEFINED) {
284 uint str =
M(s->string_id);
286 if (str ==
M(STR_SV_STNAME_FOREST)) {
287 str =
M(STR_SV_STNAME_WOODS);
289 ClrBit(sni.free_names, str);
302 return STR_SV_STNAME_FALLBACK;
309 uint32_t tmp = sni.free_names & _gen_station_name_bits[name_class];
313 if (
HasBit(sni.free_names,
M(STR_SV_STNAME_MINES))) {
315 return STR_SV_STNAME_MINES;
321 if (
HasBit(sni.free_names,
M(STR_SV_STNAME)))
return STR_SV_STNAME;
323 if (
HasBit(sni.free_names,
M(STR_SV_STNAME_CENTRAL)))
return STR_SV_STNAME_CENTRAL;
327 if (
HasBit(sni.free_names,
M(STR_SV_STNAME_LAKESIDE)) &&
330 return STR_SV_STNAME_LAKESIDE;
334 if (
HasBit(sni.free_names,
M(STR_SV_STNAME_WOODS)) && (
345 if (
HasBit(sni.free_names,
M(STR_SV_STNAME_VALLEY)))
return STR_SV_STNAME_VALLEY;
347 if (
HasBit(sni.free_names,
M(STR_SV_STNAME_HEIGHTS)))
return STR_SV_STNAME_HEIGHTS;
351 static const int8_t _direction_and_table[] = {
352 ~( (1 <<
M(STR_SV_STNAME_WEST)) | (1 <<
M(STR_SV_STNAME_EAST)) | (1 <<
M(STR_SV_STNAME_NORTH)) ),
353 ~( (1 <<
M(STR_SV_STNAME_SOUTH)) | (1 <<
M(STR_SV_STNAME_WEST)) | (1 <<
M(STR_SV_STNAME_NORTH)) ),
354 ~( (1 <<
M(STR_SV_STNAME_SOUTH)) | (1 <<
M(STR_SV_STNAME_EAST)) | (1 <<
M(STR_SV_STNAME_NORTH)) ),
355 ~( (1 <<
M(STR_SV_STNAME_SOUTH)) | (1 <<
M(STR_SV_STNAME_WEST)) | (1 <<
M(STR_SV_STNAME_EAST)) ),
358 sni.free_names &= _direction_and_table[
363 static const uint32_t fallback_names = (
364 (1U <<
M(STR_SV_STNAME_NORTH)) |
365 (1U <<
M(STR_SV_STNAME_SOUTH)) |
366 (1U <<
M(STR_SV_STNAME_EAST)) |
367 (1U <<
M(STR_SV_STNAME_WEST)) |
368 (1U <<
M(STR_SV_STNAME_TRANSFER)) |
369 (1U <<
M(STR_SV_STNAME_HALT)) |
370 (1U <<
M(STR_SV_STNAME_EXCHANGE)) |
371 (1U <<
M(STR_SV_STNAME_ANNEXE)) |
372 (1U <<
M(STR_SV_STNAME_SIDINGS)) |
373 (1U <<
M(STR_SV_STNAME_BRANCH)) |
374 (1U <<
M(STR_SV_STNAME_UPPER)) |
375 (1U <<
M(STR_SV_STNAME_LOWER))
378 sni.free_names &= fallback_names;
379 return (sni.free_names == 0) ? STR_SV_STNAME_FALLBACK : (STR_SV_STNAME +
FindFirstBit(sni.free_names));
392 Station *best_station =
nullptr;
395 uint cur_dist = DistanceManhattan(tile, st->xy);
397 if (cur_dist < threshold) {
398 threshold = cur_dist;
400 }
else if (cur_dist == threshold && best_station !=
nullptr) {
402 if (st->
index < best_station->
index) best_station = st;
418 case STATION_AIRPORT:
435 default: NOT_REACHED();
446 pt.y -= 32 * ZOOM_BASE;
453 this->
sign.
UpdatePosition(pt.x, pt.y, STR_VIEWPORT_STATION, STR_VIEWPORT_STATION_TINY);
455 _viewport_sign_kdtree.
Insert(ViewportSignKdtreeItem::MakeStation(this->
index));
466 if (this->
xy == new_xy)
return;
470 this->BaseStation::MoveSign(new_xy);
479 st->UpdateVirtCoord();
483 void BaseStation::FillCachedName()
const
485 auto tmp_params = MakeParameters(this->
index);
489 void ClearAllStationCachedNames()
492 st->cached_name.clear();
505 for (
auto it = std::begin(st->
goods); it != std::end(st->
goods); ++it) {
520 for (
auto it = std::begin(st->
goods); it != std::end(st->
goods); ++it) {
521 if (it->cargo.TotalCount() == 0)
SetBit(mask, std::distance(std::begin(st->
goods), it));
536 StringID msg = reject ? STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_LIST : STR_NEWS_STATION_NOW_ACCEPTS_CARGO_LIST;
550 std::set<IndustryID> industries;
557 AddProducedCargo(tile, produced);
563 for (IndustryID industry : industries) {
588 if (always_accepted !=
nullptr) *always_accepted = 0;
596 AddAcceptedCargo(tile, acceptance, always_accepted);
610 if (always_accepted !=
nullptr) *always_accepted = 0;
614 AddAcceptedCargo(tile, acceptance, always_accepted);
632 if (!st->
rect.IsEmpty()) {
638 uint amt = acceptance[i];
656 if (old_acc == new_acc)
return;
661 CargoTypes accepts = new_acc & ~old_acc;
662 CargoTypes rejects = ~new_acc & old_acc;
673 static void UpdateStationSignCoord(
BaseStation *st)
677 if (r->IsEmpty())
return;
681 st->MoveSign(new_xy);
706 if (*st !=
nullptr) {
711 CommandCost ret = (*st)->rect.BeforeAddRect(area.
tile, area.
w, area.
h, StationRect::ADD_TEST);
712 if (ret.
Failed())
return ret;
719 _station_kdtree.
Insert((*st)->index);
745 UpdateStationSignCoord(st);
760 MarkCatchmentTilesDirty();
763 MarkCatchmentTilesDirty();
770 case STATION_AIRPORT:
779 default: NOT_REACHED();
810 if (ret.
Failed())
return ret;
832 cost.
AddCost(_price[PR_BUILD_FOUNDATION]);
839 }
else if (allowed_z != flat_z) {
859 if (ret.
Failed())
return ret;
863 if (ret.
Failed())
return ret;
886 static CommandCost CheckFlatLandRailStation(
TileIndex tile_cur,
TileIndex north_tile,
int &allowed_z,
DoCommandFlag 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)
889 uint invalid_dirs = 5 << axis;
895 if (ret.
Failed())
return ret;
901 if (ret.
Failed())
return ret;
912 if (*station == INVALID_STATION) {
914 }
else if (*station != st) {
936 affected_vehicles.push_back(v);
940 if (ret.
Failed())
return ret;
948 if (ret.
Failed())
return ret;
973 if (ret.
Failed())
return ret;
992 if (*station == INVALID_STATION) {
994 }
else if (*station != st) {
1017 if (build_over_road) {
1019 RoadType road_rt = GetRoadType(cur_tile, RTT_ROAD);
1026 if (ret.
Failed())
return ret;
1034 if (ret.
Failed())
return ret;
1043 RoadType tram_rt = GetRoadType(cur_tile, RTT_TRAM);
1052 if (ret.
Failed())
return ret;
1066 if (ret.
Failed())
return ret;
1100 static inline uint8_t *CreateSingle(uint8_t *layout,
int n)
1103 do *layout++ = 0;
while (--i);
1104 layout[((n - 1) >> 1) - n] = 2;
1108 static inline uint8_t *CreateMulti(uint8_t *layout,
int n, uint8_t b)
1111 do *layout++ = b;
while (--i);
1114 layout[n - 1 - n] = 0;
1128 if (statspec !=
nullptr) {
1130 if (found != std::end(statspec->
layouts)) {
1132 std::copy(std::begin(found->second), std::end(found->second), layout);
1137 if (plat_len == 1) {
1138 CreateSingle(layout, numtracks);
1140 if (numtracks & 1) layout = CreateSingle(layout, plat_len);
1141 int n = numtracks >> 1;
1144 layout = CreateMulti(layout, plat_len, 4);
1145 layout = CreateMulti(layout, plat_len, 6);
1162 template <
class T, StringID error_message,
class F>
1165 assert(*st ==
nullptr);
1166 bool check_surrounding =
true;
1168 if (existing_station != INVALID_STATION) {
1169 if (adjacent && existing_station != station_to_join) {
1176 T *candidate = T::GetIfValid(existing_station);
1177 if (candidate !=
nullptr && filter(candidate)) *st = candidate;
1178 check_surrounding = (*st ==
nullptr);
1183 if (adjacent) check_surrounding =
false;
1186 if (check_surrounding) {
1189 if (ret.
Failed())
return ret;
1193 if (*st ==
nullptr && station_to_join != INVALID_STATION) *st = T::GetIfValid(station_to_join);
1209 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_RAILWAY_STATION_FIRST>(existing_station, station_to_join, adjacent, ta, st, [](
const Station *) ->
bool {
return true; });
1225 return FindJoiningBaseStation<Waypoint, STR_ERROR_MUST_REMOVE_ROADWAYPOINT_FIRST>(existing_waypoint, waypoint_to_join, adjacent, ta, wp, [](
const Waypoint *wp) ->
bool {
return HasBit(wp->
waypoint_flags,
WPF_ROAD); });
1227 return FindJoiningBaseStation<Waypoint, STR_ERROR_MUST_REMOVE_RAILWAYPOINT_FIRST>(existing_waypoint, waypoint_to_join, adjacent, ta, wp, [](
const Waypoint *wp) ->
bool {
return !
HasBit(wp->
waypoint_flags,
WPF_ROAD); });
1272 bool length_price_ready =
true;
1273 uint8_t tracknum = 0;
1277 CommandCost ret =
CheckFlatLandRailStation(cur_tile, tile_area.
tile, allowed_z, flags, axis, station, rt, affected_vehicles, spec_class, spec_index, plat_len, numtracks);
1278 if (ret.
Failed())
return ret;
1281 if (tracknum == numtracks) {
1282 length_price_ready =
true;
1291 cost.
AddCost(_price[PR_BUILD_STATION_RAIL]);
1294 if (length_price_ready) {
1295 cost.
AddCost(_price[PR_BUILD_STATION_RAIL_LENGTH]);
1296 length_price_ready =
false;
1348 if (ret.
Failed())
return ret;
1357 if (plat_len == 0 || numtracks == 0)
return CMD_ERROR;
1368 bool reuse = (station_to_join != NEW_STATION);
1369 if (!reuse) station_to_join = INVALID_STATION;
1370 bool distant_join = (station_to_join != INVALID_STATION);
1377 TileArea new_location(tile_org, w_org, h_org);
1380 StationID est = INVALID_STATION;
1381 std::vector<Train *> affected_vehicles;
1384 if (cost.
Failed())
return cost;
1388 if (ret.
Failed())
return ret;
1390 ret =
BuildStationPart(&st, flags, reuse, new_location, STATIONNAMING_RAIL);
1391 if (ret.
Failed())
return ret;
1395 if (ret.
Failed())
return ret;
1403 if (statspec !=
nullptr) {
1421 st->
rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY);
1423 if (statspec !=
nullptr) {
1433 std::vector<uint8_t> layouts(numtracks * plat_len);
1436 uint8_t numtracks_orig = numtracks;
1439 size_t layout_idx = 0;
1445 uint8_t layout = layouts[layout_idx++];
1450 affected_vehicles.push_back(v);
1472 if (statspec !=
nullptr) {
1479 if (callback <= UINT8_MAX) {
1487 TriggerStationAnimation(st, tile,
SAT_BUILT);
1499 tile_track += track_delta;
1500 }
while (--numtracks);
1502 for (uint i = 0; i < affected_vehicles.size(); ++i) {
1510 update_reservation_area =
TileArea(tile_org, 1, numtracks_orig);
1512 update_reservation_area =
TileArea(tile_org, numtracks_orig, 1);
1515 for (
TileIndex tile : update_reservation_area) {
1526 platform_begin = next_tile;
1529 platform_end = next_tile;
1533 bool reservation =
false;
1534 for (
TileIndex t = platform_begin; !reservation && t <= platform_end; t += tile_offset) {
1555 if (ta.
w != 0 && ta.
h != 0) {
1605 static void MakeRailStationAreaSmaller(
BaseStation *st)
1615 static void MakeShipStationAreaSmaller(
Station *st)
1618 UpdateStationDockingTiles(st);
1628 road_waypoint_area = MakeStationAreaSmaller(st, road_waypoint_area, TileBelongsToRoadWaypointStation);
1660 if (ret.
Failed())
continue;
1663 T *st = T::GetByTile(tile);
1664 if (st ==
nullptr)
continue;
1669 if (ret.
Failed())
continue;
1678 total_cost.
AddCost(-_price[PR_CLEAR_RAIL]);
1697 DoClearSquare(tile);
1703 st->rect.AfterRemoveTile(st, tile);
1709 include(affected_stations, st);
1715 if (quantity == 0)
return error.
Failed() ? error :
CommandCost(STR_ERROR_THERE_IS_NO_STATION);
1717 for (T *st : affected_stations) {
1722 MakeRailStationAreaSmaller(st);
1723 UpdateStationSignCoord(st);
1730 MarkCatchmentTilesDirty();
1736 total_cost.
AddCost(quantity * removal_cost);
1751 if (end == 0) end = start;
1755 std::vector<Station *> affected_stations;
1758 if (ret.
Failed())
return ret;
1761 for (
Station *st : affected_stations) {
1764 st->MarkTilesDirty(
false);
1765 MarkCatchmentTilesDirty();
1766 st->RecomputeCatchment();
1784 if (end == 0) end = start;
1788 std::vector<Waypoint *> affected_stations;
1808 if (ret.
Failed())
return ret;
1814 assert(ta.
w != 0 && ta.
h != 0);
1820 if (st->TileBelongsToRailStation(tile)) {
1821 std::vector<T*> affected_stations;
1823 if (ret.
Failed())
return ret;
1878 if (*primary_stop ==
nullptr) {
1880 return primary_stop;
1884 while (stop->
next !=
nullptr) stop = stop->
next;
1903 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_ROAD_STOP_FIRST>(existing_stop, station_to_join, adjacent, ta, st, [](
const Station *) ->
bool {
return true; });
1921 uint invalid_dirs = 0;
1922 if (is_drive_through) {
1926 SetBit(invalid_dirs, ddir);
1934 if (ret.
Failed())
return ret;
1939 if (!is_preexisting_roadstop) {
1968 bool reuse = (station_to_join != NEW_STATION);
1969 if (!reuse) station_to_join = INVALID_STATION;
1970 bool distant_join = (station_to_join != INVALID_STATION);
1979 if (roadstopspec !=
nullptr) {
1988 if (width == 0 || length == 0)
return CMD_ERROR;
1992 TileArea roadstop_area(tile, width, length);
1997 if (!is_drive_through && RoadTypeIsTram(rt))
return CMD_ERROR;
2002 if (ret.
Failed())
return ret;
2008 if (roadstopspec !=
nullptr) {
2009 unit_cost = roadstopspec->
GetBuildCost(is_truck_stop ? PR_BUILD_STATION_TRUCK : PR_BUILD_STATION_BUS);
2011 unit_cost = _price[is_truck_stop ? PR_BUILD_STATION_TRUCK : PR_BUILD_STATION_BUS];
2013 StationID est = INVALID_STATION;
2014 CommandCost cost =
CalculateRoadStopCost(roadstop_area, flags, is_drive_through, is_truck_stop ? STATION_TRUCK : STATION_BUS, axis, ddir, &est, rt, unit_cost);
2015 if (cost.
Failed())
return cost;
2019 if (ret.
Failed())
return ret;
2024 ret =
BuildStationPart(&st, flags, reuse, roadstop_area, STATIONNAMING_ROAD);
2025 if (ret.
Failed())
return ret;
2028 int specindex = AllocateSpecToRoadStop(roadstopspec, st, (flags &
DC_EXEC) != 0);
2031 if (roadstopspec !=
nullptr) {
2043 for (
TileIndex cur_tile : roadstop_area) {
2054 if (roadstopspec !=
nullptr) {
2063 *currstop = road_stop;
2065 if (is_truck_stop) {
2074 st->
rect.BeforeAddTile(cur_tile, StationRect::ADD_TRY);
2077 if (is_drive_through) {
2100 if (roadstopspec !=
nullptr) {
2101 st->SetRoadStopRandomBits(cur_tile,
GB(Random(), 0, 8));
2102 TriggerRoadStopAnimation(st, cur_tile,
SAT_BUILT);
2108 if (st !=
nullptr) {
2146 if (ret.
Failed())
return ret;
2161 assert(cur_stop !=
nullptr);
2169 if (ret.
Failed())
return ret;
2175 if (*primary_stop == cur_stop) {
2177 *primary_stop = cur_stop->
next;
2179 if (*primary_stop ==
nullptr) {
2186 while (pred->
next != cur_stop) pred = pred->
next;
2191 for (RoadTramType rtt : _roadtramtypes) {
2192 RoadType rt = GetRoadType(tile, rtt);
2209 DoClearSquare(tile);
2216 StationID station_id = st->
index;
2219 [station_id](
const Order *order) {
return order->IsType(OT_GOTO_STATION) && order->GetDestination() == station_id; },
2220 [station_id, tile](
Vehicle *v) {
2227 st->
rect.AfterRemoveTile(st, tile);
2231 st->RemoveRoadStopTileData(tile);
2232 if ((
int)specindex != replacement_spec_index) DeallocateSpecFromRoadStop(st, specindex);
2244 Price category = is_truck ? PR_CLEAR_STATION_TRUCK : PR_CLEAR_STATION_BUS;
2261 if (ret.
Failed())
return ret;
2267 if (ret.
Failed())
return ret;
2274 for (RoadTramType rtt : _roadtramtypes) {
2275 RoadType rt = GetRoadType(tile, rtt);
2288 DoClearSquare(tile);
2290 wp->
rect.AfterRemoveTile(wp, tile);
2292 wp->RemoveRoadStopTileData(tile);
2293 if ((
int)specindex != replacement_spec_index) DeallocateSpecFromRoadStop(wp, specindex);
2295 if (replacement_spec_index < 0) {
2298 UpdateStationSignCoord(wp);
2324 CommandCost last_error(STR_ERROR_THERE_IS_NO_STATION);
2325 bool had_success =
false;
2327 for (
TileIndex cur_tile : roadstop_area) {
2336 for (RoadTramType rtt : _roadtramtypes) {
2337 road_type[rtt] = GetRoadType(cur_tile, rtt);
2347 if (station_type == STATION_ROADWAYPOINT) {
2362 road_owner[RTT_ROAD], road_owner[RTT_TRAM]);
2371 return had_success ? cost : last_error;
2388 if (width == 0 || height == 0)
return CMD_ERROR;
2394 TileArea roadstop_area(tile, width, height);
2408 if (end == 0) end = start;
2411 TileArea roadstop_area(start, end);
2438 uint noise_reduction = distance / town_tolerance_distance;
2459 Town *nearest =
nullptr;
2462 auto height = as->
size_y;
2463 if (rotation ==
DIR_E || rotation ==
DIR_W) std::swap(width, height);
2465 uint perimeter_min_x =
TileX(tile);
2466 uint perimeter_min_y =
TileY(tile);
2467 uint perimeter_max_x = perimeter_min_x + width - 1;
2468 uint perimeter_max_y = perimeter_min_y + height - 1;
2470 mindist = UINT_MAX - 1;
2475 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) {
2477 if (t ==
nullptr)
continue;
2480 if (dist == mindist && t->
index < nearest->
index) nearest = t;
2481 if (dist < mindist) {
2530 bool reuse = (station_to_join != NEW_STATION);
2531 if (!reuse) station_to_join = INVALID_STATION;
2532 bool distant_join = (station_to_join != INVALID_STATION);
2539 if (ret.
Failed())
return ret;
2558 if (cost.
Failed())
return cost;
2566 StringID authority_refuse_message = STR_NULL;
2567 Town *authority_refuse_town =
nullptr;
2572 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE;
2573 authority_refuse_town = nearest;
2582 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
2583 authority_refuse_town = t;
2587 if (authority_refuse_message != STR_NULL) {
2593 ret =
FindJoiningStation(INVALID_STATION, station_to_join, allow_adjacent, airport_area, &st);
2594 if (ret.
Failed())
return ret;
2600 if (ret.
Failed())
return ret;
2607 cost.
AddCost(_price[PR_BUILD_STATION_AIRPORT]);
2620 st->
rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
2633 AirportTileAnimationTrigger(st, iter,
AAT_BUILT);
2663 if (ret.
Failed())
return ret;
2671 if (!a->IsNormalAircraft())
continue;
2672 if (a->targetairport == st->
index && a->state !=
FLYING) {
2697 if (!st->TileBelongsToAirport(tile_cur))
continue;
2700 if (ret.
Failed())
return ret;
2702 cost.
AddCost(_price[PR_CLEAR_STATION_AIRPORT]);
2706 DoClearSquare(tile_cur);
2747 if (ret.
Failed())
return ret;
2765 const Vehicle *v = orderlist->GetFirstSharedVehicle();
2766 assert(v !=
nullptr);
2767 if ((v->
owner == company) != include_company)
continue;
2769 for (
const Order *order = orderlist->GetFirstOrder(); order !=
nullptr; order = order->
next) {
2770 if (order->GetDestination() == station && (order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT))) {
2784 static const uint8_t _dock_w_chk[4] = { 2, 1, 2, 1 };
2785 static const uint8_t _dock_h_chk[4] = { 1, 2, 1, 2 };
2797 bool reuse = (station_to_join != NEW_STATION);
2798 if (!reuse) station_to_join = INVALID_STATION;
2799 bool distant_join = (station_to_join != INVALID_STATION);
2811 if (ret.
Failed())
return ret;
2817 if (ret.
Failed())
return ret;
2833 if (ret.
Failed())
return ret;
2834 if (add_cost) cost.
AddCost(ret);
2842 _dock_w_chk[direction], _dock_h_chk[direction]);
2846 ret =
FindJoiningStation(INVALID_STATION, station_to_join, adjacent, dock_area, &st);
2847 if (ret.
Failed())
return ret;
2853 if (ret.
Failed())
return ret;
2861 st->
rect.BeforeAddRect(dock_area.
tile, dock_area.
w, dock_area.
h, StationRect::ADD_TRY);
2873 UpdateStationDockingTiles(st);
2889 if (st !=
nullptr) UpdateStationDockingTiles(st);
2892 if (neutral !=
nullptr) UpdateStationDockingTiles(neutral);
2911 if (IsPossibleDockingTile(docking_tile)) {
2950 if (ret.
Failed())
return ret;
2960 if (ret.
Failed())
return ret;
2963 DoClearSquare(tile1);
2965 MakeWaterKeepingClass(tile2, st->
owner);
2967 st->
rect.AfterRemoveTile(st, tile1);
2968 st->
rect.AfterRemoveTile(st, tile2);
2970 MakeShipStationAreaSmaller(st);
2987 if (s->current_order.GetDestination() != st->
index) {
3002 s->SetDestTile(s->GetOrderStationLocation(st->
index));
3020 const auto &layouts = _station_display_datas[st];
3021 if (gfx >= layouts.size()) gfx &= 1;
3022 return layouts.data() + gfx;
3038 case SPR_RAIL_TRACK_X:
3039 case SPR_MONO_TRACK_X:
3040 case SPR_MGLV_TRACK_X:
3041 snow_desert =
false;
3042 *overlay_offset =
RTO_X;
3045 case SPR_RAIL_TRACK_Y:
3046 case SPR_MONO_TRACK_Y:
3047 case SPR_MGLV_TRACK_Y:
3048 snow_desert =
false;
3049 *overlay_offset =
RTO_Y;
3052 case SPR_RAIL_TRACK_X_SNOW:
3053 case SPR_MONO_TRACK_X_SNOW:
3054 case SPR_MGLV_TRACK_X_SNOW:
3056 *overlay_offset =
RTO_X;
3059 case SPR_RAIL_TRACK_Y_SNOW:
3060 case SPR_MONO_TRACK_Y_SNOW:
3061 case SPR_MGLV_TRACK_Y_SNOW:
3063 *overlay_offset =
RTO_Y;
3070 if (ti !=
nullptr) {
3086 *ground = snow_desert ? SPR_FLAT_SNOW_DESERT_TILE : SPR_FLAT_GRASS_TILE;
3090 static void DrawTile_Station(
TileInfo *ti)
3095 int32_t total_offset;
3097 uint32_t relocation = 0;
3098 uint32_t ground_relocation = 0;
3101 uint tile_layout = 0;
3112 if (statspec !=
nullptr) {
3148 case APT_RADAR_GRASS_FENCE_SW:
3151 case APT_GRASS_FENCE_NE_FLAG:
3154 case APT_RADAR_FENCE_SW:
3157 case APT_RADAR_FENCE_NE:
3160 case APT_GRASS_FENCE_NE_FLAG_2:
3170 palette = COMPANY_SPRITE_COLOUR(owner);
3173 palette = PALETTE_TO_GREY;
3185 if (!HasFoundationNW(ti->
tile, slope, z))
SetBit(edge_info, 0);
3186 if (!HasFoundationNE(ti->
tile, slope, z))
SetBit(edge_info, 1);
3188 if (image == 0)
goto draw_default_foundation;
3193 static const uint8_t foundation_parts[] = {
3206 static const uint8_t composite_foundation_parts[] = {
3208 0x00, 0xD1, 0xE4, 0xE0,
3210 0xCA, 0xC9, 0xC4, 0xC0,
3212 0xD2, 0x91, 0xE4, 0xA0,
3217 uint8_t parts = composite_foundation_parts[ti->
tileh];
3228 goto draw_default_foundation;
3232 for (
int i = 0; i < 8; i++) {
3243 draw_default_foundation:
3248 bool draw_ground =
false;
3251 DrawWaterClassGround(ti);
3253 if (sprite != 0) total_offset = sprite - SPR_IMG_BUOY;
3256 DrawWaterClassGround(ti);
3262 DrawShoreTile(ti->
tileh);
3264 DrawClearLandTile(ti, 3);
3282 if (layout !=
nullptr) {
3291 t = &tmp_rail_layout;
3293 }
else if (statspec !=
nullptr) {
3343 if (stopspec !=
nullptr) {
3344 stop_draw_mode = stopspec->draw_mode;
3348 if (group !=
nullptr && group->type == SGT_TILELAYOUT) {
3373 DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset);
3401 int32_t total_offset = 0;
3416 DrawSprite(ground + overlay_offset, PAL_NONE, x, y);
3425 uint sprite_offset = 5 - image;
3428 if (roadtype_info->UsesOverlay()) {
3430 DrawSprite(ground + sprite_offset, PAL_NONE, x, y);
3433 if (overlay)
DrawSprite(overlay + sprite_offset, PAL_NONE, x, y);
3434 }
else if (RoadTypeIsTram(roadtype)) {
3435 DrawSprite(SPR_TRAMWAY_TRAM + sprite_offset, PAL_NONE, x, y);
3439 if (RoadTypeIsRoad(roadtype) && roadtype_info->UsesOverlay()) {
3447 DrawRailTileSeqInGUI(x, y, t, (st == STATION_WAYPOINT || st == STATION_ROADWAYPOINT) ? 0 : total_offset, 0, pal);
3450 static int GetSlopePixelZ_Station(
TileIndex tile, uint, uint,
bool)
3462 RoadType road_rt = GetRoadTypeRoad(tile);
3463 RoadType tram_rt = GetRoadTypeTram(tile);
3486 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER;
3487 td->
owner[i] = road_owner;
3491 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER;
3492 td->
owner[i] = tram_owner;
3502 if (spec !=
nullptr) {
3542 if (
IsAirport(tile)) FillTileDescAirport(tile, td);
3546 default: NOT_REACHED();
3547 case STATION_RAIL: str = STR_LAI_STATION_DESCRIPTION_RAILROAD_STATION;
break;
3548 case STATION_AIRPORT:
3549 str = (
IsHangar(tile) ? STR_LAI_STATION_DESCRIPTION_AIRCRAFT_HANGAR : STR_LAI_STATION_DESCRIPTION_AIRPORT);
3551 case STATION_TRUCK: str = STR_LAI_STATION_DESCRIPTION_TRUCK_LOADING_AREA;
break;
3552 case STATION_BUS: str = STR_LAI_STATION_DESCRIPTION_BUS_STATION;
break;
3553 case STATION_OILRIG: {
3561 case STATION_DOCK: str = STR_LAI_STATION_DESCRIPTION_SHIP_DOCK;
break;
3562 case STATION_BUOY: str = STR_LAI_STATION_DESCRIPTION_BUOY;
break;
3563 case STATION_WAYPOINT: str = STR_LAI_STATION_DESCRIPTION_WAYPOINT;
break;
3564 case STATION_ROADWAYPOINT: str = STR_LAI_STATION_DESCRIPTION_WAYPOINT;
break;
3594 RoadTramType rtt = (RoadTramType)sub_mode;
3617 static void TileLoop_Station(
TileIndex tile)
3622 case STATION_AIRPORT:
3630 case STATION_OILRIG:
3635 case STATION_ROADWAYPOINT: {
3654 HouseZonesBits new_zone = HZB_TOWN_EDGE;
3664 if (new_rs != cur_rs) {
3676 static void AnimateTile_Station(
TileIndex tile)
3679 AnimateStationTile(tile);
3684 AnimateAirportTile(tile);
3689 AnimateRoadStopTile(tile);
3695 static bool ClickTile_Station(
TileIndex tile)
3739 }
else if (x < stop) {
3741 uint16_t spd = std::max(0, (stop - x) * 20 - 15);
3742 if (spd < v->cur_speed) v->
cur_speed = spd;
3765 CargoTypes cargoes = 0;
3771 if (cargoes == 0)
return;
3809 static inline void byte_inc_sat(uint8_t *p)
3826 StationCargoAmountMap waiting_per_source;
3828 for (StationCargoAmountMap::iterator i(waiting_per_source.begin()); i != waiting_per_source.end(); ++i) {
3830 if (source_station ==
nullptr)
continue;
3837 static void UpdateStationRating(
Station *st)
3839 bool waiting_changed =
false;
3841 byte_inc_sat(&st->time_since_load);
3842 byte_inc_sat(&st->time_since_unload);
3860 waiting_changed =
true;
3879 uint waiting_avg = waiting / (num_dests + 1);
3882 ge->
rating = rating = MAX_STATION_RATING;
3893 | (ClampTo<uint8_t>(last_speed) << 24);
3895 uint32_t var10 = (st->last_vehicle_type ==
VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10);
3899 rating =
GB(callback, 0, 14);
3902 if (
HasBit(callback, 14)) rating -= 0x4000;
3908 if (b >= 0) rating += b >> 2;
3911 if (st->last_vehicle_type ==
VEH_SHIP) waittime >>= 2;
3912 if (waittime <= 21) rating += 25;
3913 if (waittime <= 12) rating += 25;
3914 if (waittime <= 6) rating += 45;
3915 if (waittime <= 3) rating += 35;
3928 if (age < 3) rating += 10;
3929 if (age < 2) rating += 10;
3930 if (age < 1) rating += 13;
3936 ge->
rating = rating = or_ +
Clamp(ClampTo<uint8_t>(rating) - or_, -2, 2);
3940 if (rating <= 64 && waiting_avg >= 100) {
3941 int dec = Random() & 0x1F;
3942 if (waiting_avg < 200) dec &= 7;
3943 waiting -= (dec + 1) * num_dests;
3944 waiting_changed =
true;
3948 if (rating <= 127 && waiting != 0) {
3949 uint32_t r = Random();
3950 if (rating <= (
int)
GB(r, 0, 7)) {
3952 waiting = std::max((
int)waiting - (
int)((
GB(r, 8, 2) - 1) * num_dests), 0);
3953 waiting_changed =
true;
3960 static const uint WAITING_CARGO_THRESHOLD = 1 << 12;
3961 static const uint WAITING_CARGO_CUT_FACTOR = 1 << 6;
3962 static const uint MAX_WAITING_CARGO = 1 << 15;
3964 if (waiting > WAITING_CARGO_THRESHOLD) {
3965 uint difference = waiting - WAITING_CARGO_THRESHOLD;
3966 waiting -= (difference / WAITING_CARGO_CUT_FACTOR);
3968 waiting = std::min(waiting, MAX_WAITING_CARGO);
3969 waiting_changed =
true;
3974 if (waiting_changed && waiting < ge->cargo.AvailableCount()) {
3988 StationID index = st->
index;
3989 if (waiting_changed) {
4012 for (
Vehicle *v : st->loading_vehicles) {
4013 for (
Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
4014 if (u->cargo_type != c)
continue;
4015 u->cargo.Reroute(UINT_MAX, &u->cargo, avoid, avoid2, &ge);
4034 if (lg ==
nullptr)
continue;
4035 std::vector<NodeID> to_remove{};
4036 for (
Edge &edge : (*lg)[ge.
node].edges) {
4038 assert(to->
goods[c].
node == edge.dest_node);
4042 bool updated =
false;
4044 if (auto_distributed) {
4047 std::vector<Vehicle *> vehicles;
4049 bool found_from =
false;
4050 bool found_to =
false;
4051 for (
Order *order = l->GetFirstOrder(); order !=
nullptr; order = order->
next) {
4052 if (!order->IsType(OT_GOTO_STATION) && !order->IsType(OT_IMPLICIT))
continue;
4053 if (order->GetDestination() == from->
index) {
4055 if (found_to)
break;
4056 }
else if (order->GetDestination() == to->
index) {
4058 if (found_from)
break;
4061 if (!found_to || !found_from)
continue;
4062 vehicles.push_back(l->GetFirstSharedVehicle());
4065 auto iter = vehicles.begin();
4066 while (iter != vehicles.end()) {
4079 *iter = next_shared;
4082 iter = vehicles.erase(iter);
4085 if (iter == vehicles.end()) iter = vehicles.begin();
4091 to_remove.emplace_back(to->
goods[c].
node);
4104 for (NodeID r : to_remove) (*lg)[ge.
node].RemoveEdge(r);
4136 Debug(misc, 0,
"Can't allocate link graph");
4145 }
else if (ge2.
link_graph == INVALID_LINK_GRAPH) {
4163 if (lg !=
nullptr) {
4164 (*lg)[ge1.
node].UpdateEdge(ge2.
node, capacity, usage, time, mode);
4176 for (
const Vehicle *v = front; v !=
nullptr; v = v->
Next()) {
4191 static void StationHandleSmallTick(
BaseStation *st)
4202 void OnTick_Station()
4204 if (_game_mode == GM_EDITOR)
return;
4207 StationHandleSmallTick(st);
4240 void ModifyStationRatingAround(
TileIndex tile,
Owner owner,
int amount, uint radius)
4244 for (GoodsEntry &ge : st->goods) {
4245 if (ge.status != 0) {
4246 ge.rating = ClampTo<uint8_t>(ge.rating + amount);
4265 if (amount == 0)
return 0;
4277 Debug(misc, 0,
"Can't allocate link graph");
4282 if (lg !=
nullptr) (*lg)[ge.
node].UpdateSupply(amount);
4301 static bool IsUniqueStationName(
const std::string &name)
4304 if (!st->
name.empty() && st->
name == name)
return false;
4323 if (ret.
Failed())
return ret;
4325 bool reset = text.empty();
4329 if (!IsUniqueStationName(text))
return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
4350 if (st->TileIsInCatchment(tile)) stations->insert(st);
4363 assert(this->
w == 1 && this->
h == 1);
4364 AddNearbyStationsByCatchment(this->tile, &this->stations, Town::GetByTile(this->tile)->stations_near);
4367 this->stations.insert(st);
4377 static bool CanMoveGoodsToStation(
const Station *st,
CargoID type)
4401 if (all_stations->empty())
return 0;
4402 if (amount == 0)
return 0;
4404 Station *first_station =
nullptr;
4405 typedef std::pair<Station *, uint> StationInfo;
4406 std::vector<StationInfo> used_stations;
4408 for (
Station *st : *all_stations) {
4410 if (!CanMoveGoodsToStation(st, type))
continue;
4414 if (first_station ==
nullptr) {
4418 if (used_stations.empty()) {
4419 used_stations.reserve(2);
4420 used_stations.emplace_back(first_station, 0);
4422 used_stations.emplace_back(st, 0);
4426 if (first_station ==
nullptr)
return 0;
4428 if (used_stations.empty()) {
4431 return UpdateStationWaiting(first_station, type, amount, source_type, source_id);
4436 uint best_rating = 0;
4439 for (
auto &p : used_stations) {
4440 auto owner = p.first->owner;
4441 auto rating = p.first->goods[type].rating;
4442 if (rating > company_best[owner]) {
4443 best_sum += rating - company_best[owner];
4444 company_best[owner] = rating;
4445 if (rating > best_rating) best_rating = rating;
4447 company_sum[owner] += rating;
4452 amount *= best_rating + 1;
4455 for (
auto &p : used_stations) {
4456 uint owner = p.first->owner;
4459 p.second = amount * company_best[owner] * p.first->goods[type].rating / best_sum / company_sum[owner];
4464 if (amount > moving) {
4465 std::stable_sort(used_stations.begin(), used_stations.end(), [type](
const StationInfo &a,
const StationInfo &b) {
4466 return b.first->goods[type].rating < a.first->goods[type].rating;
4469 assert(amount - moving <= used_stations.size());
4470 for (uint i = 0; i < amount - moving; i++) {
4471 used_stations[i].second++;
4476 for (
auto &p : used_stations) {
4477 moved += UpdateStationWaiting(p.first, type, p.second, source_type, source_id);
4483 void UpdateStationDockingTiles(
Station *st)
4497 int x2 = std::min<int>(x + area->
w + 1,
Map::SizeX());
4498 int x1 = std::max<int>(x - 1, 0);
4500 int y2 = std::min<int>(y + area->
h + 1,
Map::SizeY());
4501 int y1 = std::max<int>(y - 1, 0);
4512 Debug(misc, 0,
"Can't allocate station for oilrig at 0x{:X}, reverting to oilrig only", tile);
4535 UpdateStationDockingTiles(st);
4537 st->
rect.BeforeAddTile(tile, StationRect::ADD_FORCE);
4547 for (
Station *near : nearby) {
4548 near->RecomputeCatchment(
true);
4575 for (RoadTramType rtt : _roadtramtypes) {
4578 RoadType rt = GetRoadType(tile, rtt);
4602 case STATION_WAYPOINT:
4611 case STATION_ROADWAYPOINT:
4676 if (ret.
Failed())
return ret;
4684 if (ret.
Failed())
return ret;
4687 if (ret.
Failed())
return ret;
4706 case STATION_WAYPOINT:
return_cmd_error(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
4707 case STATION_AIRPORT:
return_cmd_error(STR_ERROR_MUST_DEMOLISH_AIRPORT_FIRST);
4708 case STATION_TRUCK:
return_cmd_error(
HasTileRoadType(tile, RTT_TRAM) ? STR_ERROR_MUST_DEMOLISH_CARGO_TRAM_STATION_FIRST : STR_ERROR_MUST_DEMOLISH_TRUCK_STATION_FIRST);
4709 case STATION_BUS:
return_cmd_error(
HasTileRoadType(tile, RTT_TRAM) ? STR_ERROR_MUST_DEMOLISH_PASSENGER_TRAM_STATION_FIRST : STR_ERROR_MUST_DEMOLISH_BUS_STATION_FIRST);
4710 case STATION_ROADWAYPOINT:
return_cmd_error(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
4713 case STATION_OILRIG:
4714 SetDParam(1, STR_INDUSTRY_NAME_OIL_RIG);
4723 case STATION_TRUCK: [[fallthrough]];
4727 if (remove_road.
Failed())
return remove_road;
4730 case STATION_ROADWAYPOINT: {
4732 if (remove_road.
Failed())
return remove_road;
4735 case STATION_BUOY:
return RemoveBuoy(tile, flags);
4736 case STATION_DOCK:
return RemoveDock(tile, flags);
4751 case STATION_WAYPOINT:
4752 case STATION_RAIL: {
4757 case STATION_AIRPORT:
4762 case STATION_ROADWAYPOINT: {
4786 for (
const auto &it : this->
shares) {
4787 if (it.second == st) {
4788 return it.first - prev;
4805 assert(!this->
shares.empty());
4807 assert(it != this->
shares.end() && it->first <= this->unrestricted);
4808 if (it->second != excluded && it->second != excluded2)
return it->second;
4813 uint end = it->first;
4814 uint begin = (it == this->
shares.begin() ? 0 : (--it)->first);
4815 uint interval = end - begin;
4816 if (interval >= this->
unrestricted)
return INVALID_STATION;
4819 SharesMap::const_iterator it2 = (rand < begin) ? this->
shares.upper_bound(rand) :
4820 this->
shares.upper_bound(rand + interval);
4821 assert(it2 != this->
shares.end() && it2->first <= this->unrestricted);
4822 if (it2->second != excluded && it2->second != excluded2)
return it2->second;
4827 uint end2 = it2->first;
4828 uint begin2 = (it2 == this->
shares.begin() ? 0 : (--it2)->first);
4829 uint interval2 = end2 - begin2;
4830 if (interval2 >= new_max)
return INVALID_STATION;
4831 new_max -= interval2;
4832 if (begin > begin2) {
4833 Swap(begin, begin2);
4835 Swap(interval, interval2);
4840 it3 = this->
shares.upper_bound(rand);
4841 }
else if (rand < begin2 - interval) {
4842 it3 = this->
shares.upper_bound(rand + interval);
4844 it3 = this->
shares.upper_bound(rand + interval + interval2);
4846 assert(it3 != this->
shares.end() && it3->first <= this->unrestricted);
4857 assert(!this->
shares.empty());
4858 SharesMap new_shares;
4860 for (
const auto &it : this->
shares) {
4861 new_shares[++i] = it.second;
4862 if (it.first == this->unrestricted) this->
unrestricted = i;
4864 this->shares.swap(new_shares);
4865 assert(!this->shares.empty() && this->unrestricted <= (--this->shares.end())->first);
4878 assert(!this->
shares.empty());
4880 uint removed_shares = 0;
4881 uint added_shares = 0;
4882 uint last_share = 0;
4883 SharesMap new_shares;
4884 for (
const auto &it : this->
shares) {
4885 if (it.second == st) {
4887 uint share = it.first - last_share;
4888 if (flow == INT_MIN || (uint)(-flow) >= share) {
4889 removed_shares += share;
4890 if (it.first <= this->unrestricted) this->
unrestricted -= share;
4891 if (flow != INT_MIN) flow += share;
4892 last_share = it.first;
4895 removed_shares += (uint)(-flow);
4897 added_shares += (uint)(flow);
4899 if (it.first <= this->unrestricted) this->
unrestricted += flow;
4905 new_shares[it.first + added_shares - removed_shares] = it.second;
4906 last_share = it.first;
4909 new_shares[last_share + (uint)flow] = st;
4916 this->shares.swap(new_shares);
4926 assert(!this->
shares.empty());
4928 uint last_share = 0;
4929 SharesMap new_shares;
4930 for (
auto &it : this->
shares) {
4932 if (it.first > this->unrestricted)
return;
4933 if (it.second == st) {
4934 flow = it.first - last_share;
4937 new_shares[it.first] = it.second;
4940 new_shares[it.first - flow] = it.second;
4942 last_share = it.first;
4944 if (flow == 0)
return;
4945 new_shares[last_share + flow] = st;
4946 this->shares.swap(new_shares);
4947 assert(!this->shares.empty());
4957 assert(!this->
shares.empty());
4959 uint next_share = 0;
4961 for (SharesMap::reverse_iterator it(this->
shares.rbegin()); it != this->shares.rend(); ++it) {
4962 if (it->first < this->unrestricted)
return;
4964 flow = next_share - it->first;
4968 if (it->first == this->unrestricted)
return;
4969 if (it->second == st) found =
true;
4971 next_share = it->first;
4973 if (flow == 0)
return;
4974 SharesMap new_shares;
4975 new_shares[flow] = st;
4976 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4977 if (it->second != st) {
4978 new_shares[flow + it->first] = it->second;
4983 this->
shares.swap(new_shares);
4984 assert(!this->
shares.empty());
4994 assert(runtime > 0);
4995 SharesMap new_shares;
4997 for (
auto i : this->
shares) {
4998 share = std::max(share + 1, i.first * 30 / runtime);
4999 new_shares[share] = i.second;
5002 this->shares.swap(new_shares);
5013 FlowStatMap::iterator origin_it = this->find(origin);
5014 if (origin_it == this->end()) {
5015 this->emplace(origin,
FlowStat(via, flow));
5017 origin_it->second.ChangeShare(via, flow);
5018 assert(!origin_it->second.GetShares()->empty());
5032 FlowStatMap::iterator prev_it = this->find(origin);
5033 if (prev_it == this->end()) {
5036 this->emplace(origin, fs);
5038 prev_it->second.ChangeShare(via, flow);
5039 prev_it->second.ChangeShare(INVALID_STATION, flow);
5040 assert(!prev_it->second.GetShares()->empty());
5050 for (
auto &i : *
this) {
5052 uint local = fs.
GetShare(INVALID_STATION);
5053 if (local > INT_MAX) {
5076 for (FlowStatMap::iterator f_it = this->begin(); f_it != this->end();) {
5080 ret.
Push(f_it->first);
5081 this->erase(f_it++);
5095 for (
auto &it : *
this) {
5096 it.second.RestrictShare(via);
5106 for (
auto &it : *
this) {
5107 it.second.ReleaseShare(via);
5118 for (
const auto &it : *
this) {
5119 ret += (--(it.second.GetShares()->end()))->first;
5132 for (
const auto &it : *
this) {
5133 ret += it.second.GetShare(via);
5145 FlowStatMap::const_iterator i = this->find(from);
5146 if (i == this->end())
return 0;
5147 return (--(i->second.GetShares()->end()))->first;
5158 FlowStatMap::const_iterator i = this->find(from);
5159 if (i == this->end())
return 0;
5160 return i->second.GetShare(via);
5165 GetSlopePixelZ_Station,
5168 GetTileDesc_Station,
5169 GetTileTrackStatus_Station,
5171 AnimateTile_Station,
5173 ChangeTileOwner_Station,
5175 VehicleEnter_Station,
5176 GetFoundation_Station,
5177 TerraformTile_Station,
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
@ NUM_AIRPORTS
Maximal number of airports in total.
@ AT_OILRIG
Oilrig airport.
static const uint64_t AIRPORT_CLOSED_block
Dummy block for indicating a closed airport.
@ FLYING
Vehicle is flying in the air.
Enum of the default airport tiles.
void DeleteAnimatedTile(TileIndex tile)
Removes the given tile from the animated tile table.
void AddAnimatedTile(TileIndex tile, bool mark_dirty)
Add the given tile to the animated tile table (if it does not exist yet).
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.
constexpr bool HasExactlyOneBit(T value)
Test whether value has exactly 1 bit set.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
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 uint CountBits(T value)
Counts the number of set bits in a variable.
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
Map accessor functions for bridges.
bool IsBridgeAbove(Tile t)
checks if a bridge is set above the ground of this tile
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
bool IsValidCargoID(CargoID t)
Test whether cargo type is not INVALID_CARGO.
uint16_t SourceID
Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
SourceType
Types of cargo source and destination.
bool IsCargoInClass(CargoID c, CargoClass cc)
Does cargo c have cargo class cc?
@ CC_LIQUID
Liquids (Oil, Water, Rubber)
@ CC_PASSENGERS
Passengers.
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.
Iterator to iterate over all tiles belonging to a bitmaptilearea.
const Tcont * Packets() const
Returns a pointer to the cargo packet list (so you can iterate over it etc).
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.
bool Failed() const
Did this command fail?
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.
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.
StationIDStack DeleteFlows(StationID via)
Delete 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.
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.
const SharesMap * GetShares() const
Get the actual shares as a const pointer so that they can be iterated over.
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.
void Remove(const T &element)
Remove a single element from the tree, if it exists.
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
void Unqueue(LinkGraph *lg)
Remove a link graph from the execution queue.
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.
size_t MapSize() const
Count the number of ranges with equal keys in this MultiMap.
Struct containing information relating to NewGRF classes for stations and airports.
StringID name
Name of this class.
static NewGRFClass * Get(Tindex class_index)
Get a particular class.
uint GetSpecCount() const
Get the number of allocated specs within the class.
static uint GetClassCount()
Get the number of allocated classes.
const Tspec * GetSpec(uint index) const
Get a spec from the class at a given index.
This struct contains all the info that is needed to draw and construct tracks.
SpriteID single_x
single piece of rail in X direction, without ground
uint16_t max_speed
Maximum speed for vehicles travelling on this rail type.
struct RailTypeInfo::@23 base_sprites
Struct containing the main sprites.
struct RailTypeInfo::@26 strings
Strings associated with the rail type.
SpriteID 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 RoadTypeInfo::@29 strings
Strings associated with the rail type.
uint16_t max_speed
Maximum speed for vehicles travelling on this road type.
StringID name
Name of this rail type.
Minimal stack that uses a pool to avoid pointers.
void Push(const Titem &item)
Pushes a new item onto the stack if there is still space in the underlying pool.
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.
uint AvailableCount() const
Returns sum of cargo still available for loading at the sation.
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.
StationList stations
List of stations nearby.
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
Representation of an invalid date.
static Date date
Current date in days (day counter).
static TickCounter counter
Monotonic counter, in ticks, since start of game.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
Functions related to clear (MP_CLEAR) land.
Functions related to commands.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
DoCommandFlag
List of flags for a command.
@ DC_AUTO
don't allow building on structures
@ DC_BANKRUPT
company bankrupts, skip money check, skip vehicle on tile check in some cases
@ DC_EXEC
execute the given command
Definition of stuff that is very close to a company, like the company struct itself.
CommandCost 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.
Owner
Enum for all companies/owners.
@ INVALID_OWNER
An invalid owner.
@ OWNER_NONE
The tile has no ownership.
@ OWNER_WATER
The tile/execution is done by "water".
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
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,...)
Ouptut 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.
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.
Direction
Defines the 8 directions on the map.
Axis
Allow incrementing of DiagDirDiff variables.
DiagDirection
Enumeration for diagonal directions.
@ DIAGDIR_NE
Northeast, upper right on your monitor.
@ DIAGDIR_END
Used for iterations.
@ DIAGDIR_BEGIN
Used for iterations.
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
static const uint ROAD_STOP_TRACKBIT_FACTOR
Multiplier for how many regular track bits a bay stop counts.
@ EXPENSES_CONSTRUCTION
Construction costs.
Price
Enumeration of all base prices for use with Prices.
void DrawRailCatenary(const TileInfo *ti)
Draws overhead wires and pylons for electric railways.
header file for electrified rail specific functions
bool HasRailCatenaryDrawn(RailType rt)
Test if we should draw rail catenary.
constexpr debug_inline bool HasFlag(const T x, const T y)
Checks if a value in a bitset enum is set.
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.
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 INV...
@ INDUSTRYLIFE_EXTRACTIVE
Like mines.
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.).
Some typedefs for the main game.
@ DT_MANUAL
Manual distribution. No link graph calculations are run.
EdgeUpdateMode
Special modes for updating links.
@ EUM_INCREASE
Increase capacity.
bool CircularTileSearch(TileIndex *tile, uint size, TestTileOnSearchProc proc, void *user_data)
Function performing a search around a center tile and going outward, thus in circle.
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.
static debug_inline TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
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 debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
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 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 void Swap(T &a, T &b)
Type safe swap operation.
uint8_t StationGfx
Copy from station_map.h.
StationGfx GetTranslatedAirportTileID(StationGfx gfx)
Do airporttile gfx ID translation for NewGRFs.
NewGRF handling of airport tiles.
@ AAT_BUILT
Triggered when the airport is built (for all tiles at the same time).
@ AAT_STATION_NEW_CARGO
Triggered when new cargo arrives at the station (for all tiles at the same time).
@ AAT_TILELOOP
Triggered in the periodic tile loop.
@ AAT_STATION_250_TICKS
Triggered every 250 ticks (for all tiles at the same time).
static const uint8_t ANIM_STATUS_NO_ANIMATION
There is no animation.
@ SAT_NEW_CARGO
Trigger station on new cargo arrival.
@ SAT_BUILT
Trigger tile when built.
@ SAT_250_TICKS
Trigger station every 250 ticks.
@ CBM_STATION_DRAW_TILE_LAYOUT
Use callback to select a tile layout to use when drawing.
@ CBM_STATION_SLOPE_CHECK
Check slope of new station tiles.
@ CBM_STATION_AVAIL
Availability of station in construction window.
@ 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.
@ CBM_ROAD_STOP_AVAIL
Availability of road stop in construction window.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
@ CBM_CARGO_STATION_RATING_CALC
custom station rating for this cargo type
SpriteID GetCanalSprite(CanalFeature feature, TileIndex tile)
Lookup the base sprite to use for a canal.
Handling of NewGRF canals.
Cargo support for NewGRFs.
void ErrorUnknownCallbackResult(uint32_t grfid, uint16_t cbid, uint16_t cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
GRFConfig * GetGRFConfig(uint32_t 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 WatchedCargoCallback(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, RailTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
NewGRF handling of rail types.
NewGRF definitions and structures for road stops.
RoadStopDrawMode
Different draw modes to disallow rendering of some parts of the stop or road.
@ ROADSTOP_DRAW_MODE_ROAD
Bay stops: Draw the road itself.
@ ROADSTOP_DRAW_MODE_OVERLAY
Drive-through stops: Draw the road overlay, e.g. pavement.
@ ROADSTOP_DRAW_MODE_WAYP_GROUND
Waypoints: Draw the sprite layout ground tile (on top of the road)
@ RSRT_NEW_CARGO
Trigger roadstop on arrival of new cargo.
bool IsWaypointClass(const RoadStopClass &cls)
Test if a RoadStopClass is the waypoint class.
@ 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.
@ RSF_NO_CATENARY
Do not show catenary.
@ RSF_DRAW_MODE_REGISTER
Read draw mode from register 0x100.
@ RSF_DRIVE_THROUGH_ONLY
Stop is drive-through only.
void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTrigger trigger, CargoID cargo_type=INVALID_CARGO)
Trigger road stop randomisation.
SpriteID GetCustomRoadSprite(const RoadTypeInfo *rti, TileIndex tile, RoadTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
NewGRF handling of road types.
uint32_t GetRegister(uint i)
Gets the value of a so-called newgrf "register".
int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec)
Allocate a StationSpec to a Station.
uint32_t GetPlatformInfo(Axis axis, uint8_t tile, int platforms, int length, int x, int y, bool centred)
Evaluate a tile's position within a station, and return the result in a bit-stuffed format.
SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32_t var10)
Resolve sprites for drawing a station tile.
void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRandomTrigger trigger, CargoID cargo_type)
Trigger station randomisation.
SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint layout, uint edge_info)
Resolve the sprites for custom station foundations.
void DeallocateSpecFromStation(BaseStation *st, uint8_t specindex)
Deallocate a StationSpec from a Station.
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.
Header file for NewGRF stations.
@ SSF_SEPARATE_GROUND
Use different sprite set for ground sprites.
@ SSF_CUSTOM_FOUNDATIONS
Draw custom foundations.
@ SSF_EXTENDED_FOUNDATIONS
Extended foundation block instead of simple.
uint16_t GetStationLayoutKey(uint8_t platforms, uint8_t length)
Get the station layout key for a given station layout size.
@ SRT_NEW_CARGO
Trigger station on new cargo arrival.
Functions related to news.
void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1=NR_NONE, uint32_t ref1=UINT32_MAX, NewsReferenceType reftype2=NR_NONE, uint32_t ref2=UINT32_MAX, const NewsAllocatedData *data=nullptr)
Add a new newsitem to be shown.
@ NT_ACCEPTANCE
A type of cargo is (no longer) accepted.
@ NR_STATION
Reference station. Scroll to station when clicking on the news. Delete news when station is deleted.
@ NF_INCOLOUR
Bit value for coloured news.
@ NF_SMALL
Small news item. (Information window with text and viewport)
Functions related to order backups.
void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool b)
Set the reservation for a complete station platform.
Train * GetTrainForReservation(TileIndex tile, Track track)
Find the train which has reserved a specific path.
bool ValParamRailType(const RailType rail)
Validate functions for rail building.
@ RTSG_GROUND
Main group of ground images.
@ RTSG_OVERLAY
Images for overlaying track.
Money RailBuildCost(RailType railtype)
Returns the cost of building the specified railtype.
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
bool HasPowerOnRail(RailType enginetype, RailType tiletype)
Checks if an engine of the given RailType got power on a tile with a given RailType.
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.
TrackBits GetRailReservationTrackBits(Tile t)
Returns the reserved track bits of the tile.
bool HasSignals(Tile t)
Checks if a rail tile has signals.
static debug_inline bool IsPlainRailTile(Tile t)
Checks whether the tile is a rail tile or rail tile with 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.
Definition of link refreshing utility.
bool ValParamRoadType(RoadType roadtype)
Validate functions for rail building.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
bool HasPowerOnRoad(RoadType enginetype, RoadType tiletype)
Checks if an engine of the given RoadType got power on a tile with a given RoadType.
@ ROTSG_OVERLAY
Optional: Images for overlaying track.
@ ROTSG_ROADSTOP
Required: Bay stop surface.
@ ROTSG_GROUND
Required: Main group of ground images.
Money RoadBuildCost(RoadType roadtype)
Returns the cost of building the specified roadtype.
CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadTramType rtt, DoCommandFlag flags, bool town_check)
Is it allowed to remove the given road bits from the given tile?
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.
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.
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.
static debug_inline bool IsNormalRoadTile(Tile t)
Return whether a tile is a normal road tile.
RoadBits GetRoadBits(Tile t, RoadTramType rtt)
Get the present road bits for a specific road type.
bool MayHaveRoad(Tile t)
Test whether a tile can have road/tram types.
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.
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.
Owner GetRoadOwner(Tile t, RoadTramType rtt)
Get the owner of a specific road type.
Roadside
The possible road side decorations.
@ ROADSIDE_PAVED
Road with paved sidewalks.
@ ROADSIDE_BARREN
Road on barren land.
@ ROADSIDE_GRASS
Road on grass.
RoadBits
Enumeration for the road parts on a tile.
@ ROAD_NONE
No road-part is build.
@ ROAD_Y
Full road along the y-axis (north-west + south-east)
@ ROAD_X
Full road along the x-axis (south-west + north-east)
RoadType
The different roadtypes we support.
@ INVALID_ROADTYPE
flag for invalid roadtype
@ DRD_NONE
None of the directions are disallowed.
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.
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.
Foundation
Enumeration for Foundations.
@ FOUNDATION_LEVELED
The tile is leveled up to a flat slope.
#define M(x)
Helper for creating a bitset of slopes.
void DrawRailTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32_t total_offset, uint32_t newgrf_offset, PaletteID default_palette)
Draw tile sprite sequence in GUI with railroad specifics.
void DrawRailTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32_t total_offset, uint32_t newgrf_offset, PaletteID default_palette)
Draw tile sprite sequence on tile with railroad specifics.
PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
static 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.
CommandCost RemoveFromRailBaseStation(TileArea ta, std::vector< T * > &affected_stations, DoCommandFlag flags, Money removal_cost, bool keep_rail)
Remove a number of tiles from any rail station within the area.
CommandCost CmdOpenCloseAirport(DoCommandFlag flags, StationID station_id)
Open/close an airport to incoming aircraft.
CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags)
Clear a single tile of a station.
CargoTypes GetEmptyMask(const Station *st)
Get a mask of the cargo types that are empty at the station.
static CommandCost BuildStationPart(Station **st, DoCommandFlag flags, bool reuse, TileArea area, StationNaming name_class)
Common part of building various station parts and possibly attaching them to an existing one.
uint8_t GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance)
Get a possible noise reduction factor based on distance from town center.
CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road)
Remove bus or truck stops.
CargoArray GetAcceptanceAroundTiles(TileIndex center_tile, int w, int h, int rad, CargoTypes *always_accepted)
Get the acceptance of cargoes around the tile in 1/8.
static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming name_class)
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...
static RoadStop ** FindRoadStopSpot(bool truck_station, Station *st)
bool(* CMSAMatcher)(TileIndex tile)
Function to check whether the given tile matches some criterion.
bool IsHangar(Tile t)
Check whether the given tile is a hangar.
CommandCost CmdRemoveFromRoadWaypoint(DoCommandFlag flags, TileIndex start, TileIndex end)
Remove road waypoints.
void RerouteCargo(Station *st, CargoID c, StationID avoid, StationID avoid2)
Reroute cargo of type c at station st or in any vehicles unloading there.
static CommandCost CheckFlatLandRailStation(TileIndex tile_cur, TileIndex north_tile, int &allowed_z, DoCommandFlag 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 bool CMSAMine(TileIndex tile)
Check whether the tile is a mine.
CommandCost CmdRemoveFromRailStation(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail)
Remove a single tile from a rail station.
static void TruncateCargo(const CargoSpec *cs, GoodsEntry *ge, uint amount=UINT_MAX)
Truncate the cargo by a specific amount.
Town * AirportGetNearestTown(const AirportSpec *as, Direction rotation, TileIndex tile, TileIterator &&it, uint &mindist)
Finds the town nearest to given airport.
static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCommandFlag flags)
Checks if an airport can be built at the given location and clear the area.
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.
static Station * GetClosestDeletedStation(TileIndex tile)
Find the closest deleted station of the current company.
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.
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.
static StationSpec::TileFlags GetStationTileFlags(StationGfx gfx, const StationSpec *statspec)
Get station tile flags for the given StationGfx.
CommandCost CmdBuildDock(DoCommandFlag flags, TileIndex tile, StationID station_to_join, bool adjacent)
Build a dock/haven.
void GetStationLayout(uint8_t *layout, uint numtracks, uint plat_len, const StationSpec *statspec)
Create the station layout for the given number of tracks and platform length.
static bool FindNearIndustryName(TileIndex tile, void *user_data)
Find a station action 0 property 24 station name, or reduce the free_names if needed.
static CommandCost RemoveRailWaypoint(TileIndex tile, DoCommandFlag flags)
Remove a rail waypoint.
void UpdateAllStationVirtCoords()
Update the virtual coords needed to draw the station sign for all stations.
static bool CMSAWater(TileIndex tile)
Check whether the tile is water.
static CommandCost CalculateRailStationCost(TileArea tile_area, DoCommandFlag 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.
void TriggerWatchedCargoCallbacks(Station *st)
Run the watched cargo callback for all houses in the catchment area.
CommandCost CmdBuildAirport(DoCommandFlag flags, TileIndex tile, uint8_t airport_type, uint8_t layout, StationID station_to_join, bool allow_adjacent)
Place an Airport.
CommandCost CmdBuildRoadStop(DoCommandFlag 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.
CommandCost CheckFlatLandRoadStop(TileIndex cur_tile, int &allowed_z, DoCommandFlag flags, uint 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.
CommandCost CmdRemoveFromRailWaypoint(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail)
Remove a single tile from a waypoint.
static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
Remove an airport.
static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags)
Remove a dock.
CargoTypes GetAcceptanceMask(const Station *st)
Get a mask of the cargo types that the station accepts.
CommandCost CheckBuildableTile(TileIndex tile, uint 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 void RestoreTrainReservation(Train *v)
Restore platform reservation during station building/removing.
void UpdateAirportsNoise()
Recalculate the noise generated by the airports of each town.
static bool CMSATree(TileIndex tile)
Check whether the tile is a tree.
void UpdateStationAcceptance(Station *st, bool show_msg)
Update the acceptance for a station.
CommandCost CmdBuildRailStation(DoCommandFlag 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 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 CmdRenameStation(DoCommandFlag flags, StationID station_id, const std::string &text)
Rename a station.
static TileIndex FindDockLandPart(TileIndex t)
Find the part of a dock that is land-based.
static CommandCost RemoveGenericRoadStop(DoCommandFlag flags, const TileArea &roadstop_area, StationType station_type, bool remove_road)
Remove a tile area of road stop or road waypoints.
static void FreeTrainReservation(Train *v)
Clear platform reservation during station building/removing.
void SetRailStationTileFlags(TileIndex tile, const StationSpec *statspec)
Set rail station tile flags for the given tile.
static CommandCost CanRemoveRoadWithStop(TileIndex tile, DoCommandFlag flags)
Check if a drive-through road stop tile can be cleared.
static CargoArray GetAcceptanceAroundStation(const Station *st, CargoTypes *always_accepted)
Get the acceptance of cargoes around the station in.
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).
void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint capacity, uint usage, uint32_t time, EdgeUpdateMode mode)
Increase capacity for a link stat given by station cargo and next hop.
static CommandCost FindJoiningStation(StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, Station **st)
Find a nearby station that joins this station.
static IntervalTimer< TimerGameEconomy > _economy_stations_monthly({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::STATION}, [](auto) { for(Station *st :Station::Iterate()) { for(GoodsEntry &ge :st->goods) { SB(ge.status, GoodsEntry::GES_LAST_MONTH, 1, GB(ge.status, GoodsEntry::GES_CURRENT_MONTH, 1));ClrBit(ge.status, GoodsEntry::GES_CURRENT_MONTH);} } })
Economy monthly loop for stations.
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 ...
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.
const DrawTileSprites * GetStationTileLayout(StationType st, uint8_t gfx)
Get station tile layout for a station type and its station gfx.
static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags, int replacement_spec_index=-1)
Remove a bus station/truck stop.
CommandCost CalculateRoadStopCost(TileArea tile_area, DoCommandFlag flags, bool is_drive_through, StationType station_type, Axis axis, DiagDirection ddir, StationID *est, RoadType rt, Money unit_cost)
Calculates cost of new road stops within the area.
static bool StationHandleBigTick(BaseStation *st)
This function is called for each station once every 250 ticks.
CommandCost RemoveRoadWaypointStop(TileIndex tile, DoCommandFlag flags, int replacement_spec_index=-1)
Remove a road waypoint.
static void ShowRejectOrAcceptNews(const Station *st, CargoTypes cargoes, bool reject)
Add news item for when a station changes which cargoes it accepts.
CommandCost RemoveRailStation(T *st, DoCommandFlag flags, Money removal_cost)
Remove a rail station/waypoint.
static void DeleteStationIfEmpty(BaseStation *st)
This is called right after a station was deleted.
Command definitions related to stations.
Functions related to stations.
void ShowStationViewWindow(StationID station)
Opens StationViewWindow for given station.
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.
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? In other words, is this station tile a rail station or rail waypoint?
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? In other words, is this station tile a rail station or rail waypoint?
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.
@ ROADSTOP_BUS
A standard stop for buses.
@ ROADSTOP_TRUCK
A standard stop for trucks.
@ ROADSTOP_END
End of valid types.
@ FACIL_DOCK
Station with a dock.
@ FACIL_BUS_STOP
Station with bus stops.
@ FACIL_AIRPORT
Station with an airport.
@ FACIL_WAYPOINT
Station is a waypoint.
@ FACIL_TRUCK_STOP
Station with truck stops.
@ FACIL_TRAIN
Station with train station.
StationType
Station types.
std::set< Station *, StationCompare > StationList
List of stations.
static const uint MAX_LENGTH_STATION_NAME_CHARS
The maximum length of a station name in characters including '\0'.
Definition of base types and functions in a cross-platform compatible way.
size_t Utf8StringLength(const char *s)
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.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
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
std::vector< AirportTileLayout > layouts
List of layouts composing the airport.
struct GRFFileProps grf_prop
Properties related to the grf file.
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.
StringID name
Tile Subname string, land information on this tile will give you "AirportName (TileSubname)".
AnimationInfo animation
Information about the animation.
static const AirportTileSpec * GetByTile(TileIndex tile)
Retrieve airport tile spec for the given airport tile.
GRFFileProps grf_prop
properties related the the grf file
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.
uint64_t flags
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
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.
uint16_t triggers
The triggers that trigger animation.
uint8_t status
Status; 0: no looping, 1: looping, 0xFF: no animation.
Base class for all station-ish types.
StationFacility facilities
The facilities that this station has.
StringID string_id
Default name (town area) of station.
TileIndex xy
Base tile of the station.
std::vector< SpecMapping< StationSpec > > speclist
List of rail station specs of this station.
uint8_t cached_anim_triggers
NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen.
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.
uint8_t cached_roadstop_anim_triggers
NOSAVE: Combined animation trigger bitmask for road stops, used to determine if trigger processing sh...
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 ...
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.
virtual bool TileBelongsToRailStation(TileIndex tile) const =0
Check whether a specific tile belongs to this station.
TrackedViewportSign sign
NOSAVE: Dimensions of sign.
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
TimerGameCalendar::Date build_date
Date of construction.
std::string name
Custom name.
VehicleType type
Type of vehicle.
Class for storing amounts of cargo.
Container for cargo from the same location and time.
Specification of a cargo type.
CargoClasses classes
Classes of this cargo type.
CargoID Index() const
Determines index of this cargospec.
static IterateWrapper Iterate(size_t from=0)
Returns an iterable ensemble of all valid CargoSpec.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
bool value
tells if the bool cheat is active or not
Cheat station_rating
Fix station ratings at 100%.
GUISettings gui
settings related to the GUI
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.
bool build_on_slopes
allow building on slopes
bool road_stop_on_town_road
allow building of drive-through road stops on town owned roads
bool road_stop_on_competitor_road
allow building of drive-through road stops on roads owned by competitors
uint8_t town_council_tolerance
minimum required town ratings to be allowed to demolish stuff
Ground palette sprite of a tile, together with its sprite layout.
const DrawTileSeqStruct * seq
Array of child sprites. Terminated with a terminator entry.
PalSpriteID ground
Palette and sprite for the ground.
bool station_noise_level
build new airports when the town noise level is still within accepted limits
Information about GRF, used in the game and (part of it) in savegames.
const char * GetName() const
Get the name of this grf.
const struct GRFFile * grffile
grf file that introduced this entity
std::array< const struct SpriteGroup *, Tcnt > spritegroup
pointers to the different sprites of the entity
bool show_track_reservation
highlight reserved tracks.
uint8_t landscape
the landscape we're currently in
EconomySettings economy
settings to change the economy
ConstructionSettings construction
construction of things in-game
DifficultySettings difficulty
settings related to the difficulty
GameCreationSettings game_creation
settings used during the creation of a game (map)
StationSettings station
settings related to station management
LinkGraphSettings linkgraph
settings for link graph calculations
OrderSettings order
settings related to orders
Stores station stats for a single cargo.
FlowStatMap flows
Planned flows through this station.
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?
@ GES_ACCEPTANCE
Set when the station accepts the cargo currently for final deliveries.
@ GES_LAST_MONTH
Set when cargo was delivered for final delivery last month.
@ GES_RATING
This indicates whether a cargo has a rating at the station.
@ GES_CURRENT_MONTH
Set when cargo was delivered for final delivery this month.
@ GES_ACCEPTED_BIGTICK
Set when cargo was delivered for final delivery during the current STATION_ACCEPTANCE_TICKS interval.
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.
NodeID node
ID of node in link graph referring to this goods entry.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
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.
uint8_t status
Status of this cargo, see GoodsEntryStatus.
StationID GetVia(StationID source) const
Get the best next hop for a cargo packet from station source.
Defines the data structure for constructing industry.
StringID name
Displayed name of the industry.
GRFFileProps grf_prop
properties related to the grf file
StringID station_name
Default name for nearby station.
IndustryLifeType life_type
This is also known as Industry production flag, in newgrf specs.
bool enabled
entity still available (by default true).newgrf can disable it, though
Defines the internal data of a functional industry.
IndustryType type
type of industry.
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
ProducedCargoes produced
produced cargo slots
Owner owner
owner of the industry. Which SHOULD always be (imho) OWNER_NONE
TileArea location
Location of the industry.
Station * neutral_station
Associated neutral station.
StationList stations_near
NOSAVE: List of nearby stations.
An edge in the link graph.
static uint SizeY()
Get the size of the map along the Y.
static debug_inline uint SizeX()
Get the size of the map along the X.
static debug_inline uint Size()
Get the size of the map.
Tindex class_index
Class index of this spec, invalid until class is allocated.
NewGRF supplied spritelayout.
uint32_t PrepareLayout(uint32_t orig_offset, uint32_t newgrf_ground_offset, uint32_t newgrf_offset, uint constr_stage, bool separate_ground) const
Prepares a sprite layout before resolving action-1-2-3 chains.
void ProcessRegisters(uint8_t resolved_var10, uint32_t resolved_sprite, bool separate_ground) const
Evaluates the register modifiers and integrates them into the preprocessed sprite layout.
bool NeedsPreprocessing() const
Tests whether this spritelayout needs preprocessing by PrepareLayout() and ProcessRegisters(),...
const DrawTileSeqStruct * GetLayout(PalSpriteID *ground) const
Returns the result spritelayout after preprocessing.
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...
bool selectgoods
only send the goods to station if a train has been there
bool IsType(OrderType type) const
Check whether this order is of the given type.
Order * next
Pointer to next order. If nullptr, end of list.
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...
Represents the covered area of e.g.
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)
Coordinates of a point in 2D.
Tindex index
Index of this pool item.
static Titem * Get(size_t index)
Returns Titem with given index.
static size_t GetNumItems()
Returns number of valid items in the pool.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Money GetBuildCost(Price category) const
Get the cost for building a road stop of this type.
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
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.
bool Enter(RoadVehicle *rv)
Enter the road stop.
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.
Iterable ensemble of each set bit in a value.
All ships have this type.
static Station * GetIfValid(size_t index)
Returns station if the index is a valid index for this station type.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
static Station * Get(size_t index)
Gets station with given index.
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
static bool IsValidID(size_t index)
Tests whether given index is a valid index for station of this type.
static Station * From(BaseStation *st)
Converts a BaseStation to SpecializedStation with type checking.
T * Last()
Get the last vehicle in the chain.
static T * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
static Pool::IterateWrapper< Aircraft > Iterate(size_t from=0)
Returns an iterable ensemble of all valid vehicles of type T.
virtual const SpriteGroup * Resolve([[maybe_unused]] ResolverObject &object) const
Base sprite group resolver.
StationRect - used to track station spread out rectangle - cheaper than scanning whole map.
uint8_t station_spread
amount a station may spread
bool serve_neutral_industries
company stations can serve industries with attached neutral stations
bool distant_join_stations
allow to join non-adjacent stations
uint8_t callback_mask
Bitmask of station callbacks that have to be called.
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.
uint8_t flags
Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size.
std::unordered_map< uint16_t, std::vector< uint8_t > > layouts
Custom platform layouts, keyed by platform and length combined.
@ NoWires
Tile should NOT contain catenary wires.
@ Pylons
Tile should contain catenary pylons.
@ Blocked
Tile is blocked to vehicles.
std::vector< TileFlags > tileflags
List of tile flags.
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
std::vector< NewGRFSpriteLayout > renderdata
Number of tile layouts.
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...
GoodsEntry goods[NUM_CARGO]
Goods at this station.
void GetTileArea(TileArea *ta, StationType type) const override
Get the tile area for a given station type.
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.
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.
Tile description for the 'land area information' tool.
uint16_t rail_speed
Speed limit of rail (bridges and track)
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.
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)
const char * grf
newGRF used for the tile contents
StringID airport_tile_name
Name of the airport tile.
Owner owner[4]
Name of the owner(s)
StringID owner_type[4]
Type of each owner.
StringID station_class
Class of station.
A pair-construct of a TileIndexDiff.
Tile information, used while rendering the tile.
int x
X position of the tile in unit coordinates.
Slope tileh
Slope of the tile.
TileIndex tile
Tile index.
int y
Y position of the tile in unit coordinates.
Action 2 sprite layout for houses, industry tiles, objects and airport tiles.
Set of callback functions for performing tile operations of a given tile type.
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
void UpdatePosition(int center, int top, StringID str, StringID str_small=STR_NULL)
Update the position of the viewport sign.
bool kdtree_valid
Are the sign data valid for use with the _viewport_sign_kdtree?
'Train' is either a loco or a wagon.
Trackdir GetVehicleTrackdir() const override
Get the tracks of the train vehicle.
Direction direction
facing
bool IsStoppedInDepot() const
Check whether the vehicle is in the depot and stopped.
VehicleCargoList cargo
The cargo this vehicle is carrying.
TimerGameEconomy::Date date_of_last_service
Last economy date the vehicle had a service at a depot.
virtual TileIndex GetOrderStationLocation([[maybe_unused]] StationID station)
Determine the location for the station where the vehicle goes to next.
Vehicle * Next() const
Get the next vehicle of this vehicle.
debug_inline bool IsFrontEngine() const
Check if the vehicle is a front engine.
Order current_order
The current order (+ status, like: loading)
CargoID cargo_type
type of cargo this vehicle is carrying
uint16_t refit_cap
Capacity left over from before last refit.
uint16_t cur_speed
current speed
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
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.
VehicleEnterTileStatus
The returned bits of VehicleEnterTile.
@ VETSB_CANNOT_ENTER
The vehicle cannot enter the tile.
@ VETS_STATION_ID_OFFSET
Shift the VehicleEnterTileStatus this many bits to the right to get the station ID when VETS_ENTERED_...
@ VETSB_ENTERED_STATION
The vehicle entered a station.
@ VETSB_CONTINUE
Bit sets of the above specified bits.
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.
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.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Slope GetTileSlope(TileIndex tile)
Return the slope of a given tile inside the map.
@ TROPICZONE_DESERT
Tile is desert.
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_BASE.
static const uint TILE_SIZE
Tile size in world coordinates.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
@ MP_TREES
Tile got trees.
@ MP_ROAD
A tile with road (or tram tracks)
@ MP_STATION
A tile of a station.
@ MP_HOUSE
A house by a town.
@ MP_INDUSTRY
Part of an industry.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
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.
HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags)
Checks whether the local authority allows construction of a new station (rail, road,...
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
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.
TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, TrackdirBits red_signals)
Builds a TrackStatus.
TrackBits AxisToTrackBits(Axis a)
Maps an Axis to the corresponding TrackBits value.
TrackBits DiagDirToDiagTrackBits(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal track bits incidating with that diagdir.
Track AxisToTrack(Axis a)
Convert an Axis to the corresponding Track AXIS_X -> TRACK_X AXIS_Y -> TRACK_Y Uses the fact that the...
Track RemoveFirstTrack(TrackBits *tracks)
Removes first Track from TrackBits and returns it.
DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
TrackBits
Allow incrementing of Track variables.
@ TRACK_BIT_UPPER
Upper track.
@ TRACK_BIT_LEFT
Left track.
@ TRACK_BIT_Y
Y-axis track.
@ TRACK_BIT_NONE
No track.
@ TRACK_BIT_X
X-axis track.
@ TRACK_BIT_ALL
All possible tracks.
@ TRACK_BIT_RIGHT
Right track.
Trackdir
Enumeration for tracks and directions.
@ TRACKDIR_BIT_NONE
No track build.
Track
These are used to specify a single track.
@ TRACK_Y
Track along the y-axis (north-west to south-east)
@ TRACK_X
Track along the x-axis (north-east to south-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.
void FreeTrainTrackReservation(const Train *v)
Free the reserved path in front of a vehicle.
int GetTrainStopLocation(StationID station_id, TileIndex tile, const Train *v, 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.
@ TO_BUILDINGS
company buildings - depots, stations, HQ, ...
TransportType
Available types of transport.
@ TRANSPORT_RAIL
Transport by train.
@ TRANSPORT_ROAD
Transport by road vehicle.
@ TRANSPORT_WATER
Transport over water.
Functions that have tunnels and bridges in common.
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
@ VS_TRAIN_SLOWING
Train is slowing down.
Functions related to vehicles.
@ VEH_INVALID
Non-existing type of vehicle.
@ VEH_ROAD
Road vehicle type.
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ VEH_SHIP
Ship vehicle type.
@ VEH_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 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 w, int h, int dz, int z, bool transparent, int bb_offset_x, int bb_offset_y, int bb_offset_z, const SubSprite *sub)
Draw a (transparent) sprite at given coordinates with a given bounding box.
void 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.
Functions related to water (management)
void TileLoop_Water(TileIndex tile)
Let a water tile floods its diagonal adjoining tiles called from tunnelbridge_cmd,...
void CheckForDockingTile(TileIndex t)
Mark the supplied tile as a docking tile if it is suitable for docking.
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 WATER_TILE_CLEAR water tile type).
@ WATER_CLASS_CANAL
Canal.
@ WATER_CLASS_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, DoCommandFlag 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...
@ WC_STATION_LIST
Station list; Window numbers:
@ WC_VEHICLE_ORDERS
Vehicle orders; Window numbers:
@ WC_VEHICLE_DEPOT
Depot view; Window numbers:
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
@ WC_STATION_VIEW
Station view; Window numbers:
@ WC_TOWN_VIEW
Town view; Window numbers:
Entry point for OpenTTD to YAPF's cache.
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track)
Use this function to notify YAPF that track layout (or signal configuration) has change.