Go to the documentation of this file.
14 #include "viewport_kdtree.h"
30 #include "strings_internal.h"
70 #include "table/strings.h"
123 if (!T::IsValidID(t) ||
Station::Get(t)->owner != company)
continue;
124 if (closest_station == INVALID_STATION) {
126 }
else if (closest_station != t) {
131 *st = (closest_station == INVALID_STATION) ?
nullptr : T::Get(closest_station);
152 for (
int dx = -3; dx <= 3; dx++) {
153 for (
int dy = -3; dy <= 3; dy++) {
177 for (
const auto &p : ind->
produced) {
209 #define M(x) ((x) - STR_SV_STNAME)
214 STATIONNAMING_AIRPORT,
215 STATIONNAMING_OILRIG,
217 STATIONNAMING_HELIPORT,
242 if (
GetIndustrySpec(indtype)->station_name == STR_UNDEFINED)
return false;
246 sni->
free_names &= ~(1 <<
M(STR_SV_STNAME_OILFIELD) | 1 <<
M(STR_SV_STNAME_MINES));
252 static const uint32_t _gen_station_name_bits[] = {
255 1U <<
M(STR_SV_STNAME_AIRPORT),
256 1U <<
M(STR_SV_STNAME_OILFIELD),
257 1U <<
M(STR_SV_STNAME_DOCKS),
258 1U <<
M(STR_SV_STNAME_HELIPORT),
267 if (s != st && s->
town == t) {
268 if (s->indtype != IT_INVALID) {
269 sni.indtypes[s->indtype] =
true;
271 if (name != STR_UNDEFINED) {
280 uint str =
M(s->string_id);
282 if (str ==
M(STR_SV_STNAME_FOREST)) {
283 str =
M(STR_SV_STNAME_WOODS);
285 ClrBit(sni.free_names, str);
298 return STR_SV_STNAME_FALLBACK;
305 uint32_t tmp = sni.free_names & _gen_station_name_bits[name_class];
309 if (
HasBit(sni.free_names,
M(STR_SV_STNAME_MINES))) {
311 return STR_SV_STNAME_MINES;
317 if (
HasBit(sni.free_names,
M(STR_SV_STNAME)))
return STR_SV_STNAME;
319 if (
HasBit(sni.free_names,
M(STR_SV_STNAME_CENTRAL)))
return STR_SV_STNAME_CENTRAL;
323 if (
HasBit(sni.free_names,
M(STR_SV_STNAME_LAKESIDE)) &&
326 return STR_SV_STNAME_LAKESIDE;
330 if (
HasBit(sni.free_names,
M(STR_SV_STNAME_WOODS)) && (
341 if (
HasBit(sni.free_names,
M(STR_SV_STNAME_VALLEY)))
return STR_SV_STNAME_VALLEY;
343 if (
HasBit(sni.free_names,
M(STR_SV_STNAME_HEIGHTS)))
return STR_SV_STNAME_HEIGHTS;
347 static const int8_t _direction_and_table[] = {
348 ~( (1 <<
M(STR_SV_STNAME_WEST)) | (1 <<
M(STR_SV_STNAME_EAST)) | (1 <<
M(STR_SV_STNAME_NORTH)) ),
349 ~( (1 <<
M(STR_SV_STNAME_SOUTH)) | (1 <<
M(STR_SV_STNAME_WEST)) | (1 <<
M(STR_SV_STNAME_NORTH)) ),
350 ~( (1 <<
M(STR_SV_STNAME_SOUTH)) | (1 <<
M(STR_SV_STNAME_EAST)) | (1 <<
M(STR_SV_STNAME_NORTH)) ),
351 ~( (1 <<
M(STR_SV_STNAME_SOUTH)) | (1 <<
M(STR_SV_STNAME_WEST)) | (1 <<
M(STR_SV_STNAME_EAST)) ),
354 sni.free_names &= _direction_and_table[
359 static const uint32_t fallback_names = (
360 (1U <<
M(STR_SV_STNAME_NORTH)) |
361 (1U <<
M(STR_SV_STNAME_SOUTH)) |
362 (1U <<
M(STR_SV_STNAME_EAST)) |
363 (1U <<
M(STR_SV_STNAME_WEST)) |
364 (1U <<
M(STR_SV_STNAME_TRANSFER)) |
365 (1U <<
M(STR_SV_STNAME_HALT)) |
366 (1U <<
M(STR_SV_STNAME_EXCHANGE)) |
367 (1U <<
M(STR_SV_STNAME_ANNEXE)) |
368 (1U <<
M(STR_SV_STNAME_SIDINGS)) |
369 (1U <<
M(STR_SV_STNAME_BRANCH)) |
370 (1U <<
M(STR_SV_STNAME_UPPER)) |
371 (1U <<
M(STR_SV_STNAME_LOWER))
374 sni.free_names &= fallback_names;
375 return (sni.free_names == 0) ? STR_SV_STNAME_FALLBACK : (STR_SV_STNAME +
FindFirstBit(sni.free_names));
388 Station *best_station =
nullptr;
391 uint cur_dist = DistanceManhattan(tile, st->xy);
393 if (cur_dist < threshold) {
394 threshold = cur_dist;
396 }
else if (cur_dist == threshold && best_station !=
nullptr) {
398 if (st->
index < best_station->
index) best_station = st;
414 case STATION_AIRPORT:
431 default: NOT_REACHED();
442 pt.y -= 32 * ZOOM_LVL_BASE;
449 this->
sign.
UpdatePosition(pt.x, pt.y, STR_VIEWPORT_STATION, STR_VIEWPORT_STATION_TINY);
451 _viewport_sign_kdtree.
Insert(ViewportSignKdtreeItem::MakeStation(this->
index));
462 if (this->
xy == new_xy)
return;
466 this->BaseStation::MoveSign(new_xy);
475 st->UpdateVirtCoord();
479 void BaseStation::FillCachedName()
const
481 auto tmp_params = MakeParameters(this->
index);
485 void ClearAllStationCachedNames()
488 st->cached_name.clear();
501 for (
auto it = std::begin(st->
goods); it != std::end(st->
goods); ++it) {
516 for (
auto it = std::begin(st->
goods); it != std::end(st->
goods); ++it) {
517 if (it->cargo.TotalCount() == 0)
SetBit(mask, std::distance(std::begin(st->
goods), it));
532 StringID msg = reject ? STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_LIST : STR_NEWS_STATION_NOW_ACCEPTS_CARGO_LIST;
546 std::set<IndustryID> industries;
553 AddProducedCargo(tile, produced);
559 for (IndustryID industry : industries) {
584 if (always_accepted !=
nullptr) *always_accepted = 0;
592 AddAcceptedCargo(tile, acceptance, always_accepted);
606 if (always_accepted !=
nullptr) *always_accepted = 0;
610 AddAcceptedCargo(tile, acceptance, always_accepted);
628 if (!st->
rect.IsEmpty()) {
634 uint amt = acceptance[i];
652 if (old_acc == new_acc)
return;
657 CargoTypes accepts = new_acc & ~old_acc;
658 CargoTypes rejects = ~new_acc & old_acc;
669 static void UpdateStationSignCoord(
BaseStation *st)
673 if (r->IsEmpty())
return;
677 st->MoveSign(new_xy);
702 if (*st !=
nullptr) {
707 CommandCost ret = (*st)->rect.BeforeAddRect(area.
tile, area.
w, area.
h, StationRect::ADD_TEST);
708 if (ret.
Failed())
return ret;
715 _station_kdtree.
Insert((*st)->index);
741 UpdateStationSignCoord(st);
756 MarkCatchmentTilesDirty();
759 MarkCatchmentTilesDirty();
766 case STATION_AIRPORT:
775 default: NOT_REACHED();
806 if (ret.
Failed())
return ret;
829 cost.
AddCost(_price[PR_BUILD_FOUNDATION]);
836 }
else if (allowed_z != flat_z) {
856 if (ret.
Failed())
return ret;
860 if (ret.
Failed())
return ret;
883 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,
byte plat_len,
byte numtracks)
886 uint invalid_dirs = 5 << axis;
892 if (ret.
Failed())
return ret;
898 if (ret.
Failed())
return ret;
909 if (*station == INVALID_STATION) {
911 }
else if (*station != st) {
936 affected_vehicles.push_back(v);
940 if (ret.
Failed())
return ret;
947 if (ret.
Failed())
return ret;
972 if (ret.
Failed())
return ret;
991 if (*station == INVALID_STATION) {
993 }
else if (*station != st) {
1016 if (build_over_road) {
1018 RoadType road_rt = GetRoadType(cur_tile, RTT_ROAD);
1025 if (ret.
Failed())
return ret;
1033 if (ret.
Failed())
return ret;
1037 }
else if (RoadTypeIsRoad(rt)) {
1042 RoadType tram_rt = GetRoadType(cur_tile, RTT_TRAM);
1051 if (ret.
Failed())
return ret;
1058 }
else if (RoadTypeIsTram(rt)) {
1063 if (ret.
Failed())
return ret;
1097 static inline byte *CreateSingle(
byte *layout,
int n)
1100 do *layout++ = 0;
while (--i);
1101 layout[((n - 1) >> 1) - n] = 2;
1105 static inline byte *CreateMulti(
byte *layout,
int n,
byte b)
1108 do *layout++ = b;
while (--i);
1111 layout[n - 1 - n] = 0;
1125 if (statspec !=
nullptr && statspec->
layouts.size() >= plat_len &&
1126 statspec->
layouts[plat_len - 1].size() >= numtracks &&
1127 !statspec->
layouts[plat_len - 1][numtracks - 1].empty()) {
1129 memcpy(layout, statspec->
layouts[plat_len - 1][numtracks - 1].data(),
1130 static_cast<size_t>(plat_len) * numtracks);
1134 if (plat_len == 1) {
1135 CreateSingle(layout, numtracks);
1137 if (numtracks & 1) layout = CreateSingle(layout, plat_len);
1138 int n = numtracks >> 1;
1141 layout = CreateMulti(layout, plat_len, 4);
1142 layout = CreateMulti(layout, plat_len, 6);
1158 template <
class T, StringID error_message>
1161 assert(*st ==
nullptr);
1162 bool check_surrounding =
true;
1165 if (existing_station != INVALID_STATION) {
1166 if (adjacent && existing_station != station_to_join) {
1173 *st = T::GetIfValid(existing_station);
1174 check_surrounding = (*st ==
nullptr);
1179 if (adjacent) check_surrounding =
false;
1183 if (check_surrounding) {
1186 if (ret.
Failed())
return ret;
1190 if (*st ==
nullptr && station_to_join != INVALID_STATION) *st = T::GetIfValid(station_to_join);
1206 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_RAILWAY_STATION_FIRST>(existing_station, station_to_join, adjacent, ta, st);
1220 return FindJoiningBaseStation<Waypoint, STR_ERROR_MUST_REMOVE_RAILWAYPOINT_FIRST>(existing_waypoint, waypoint_to_join, adjacent, ta, wp);
1264 bool length_price_ready =
true;
1269 CommandCost ret =
CheckFlatLandRailStation(cur_tile, tile_area.tile, allowed_z, flags, axis, station, rt, affected_vehicles, spec_class, spec_index, plat_len, numtracks);
1270 if (ret.
Failed())
return ret;
1273 if (tracknum == numtracks) {
1274 length_price_ready =
true;
1283 cost.
AddCost(_price[PR_BUILD_STATION_RAIL]);
1286 if (length_price_ready) {
1287 cost.
AddCost(_price[PR_BUILD_STATION_RAIL_LENGTH]);
1288 length_price_ready =
false;
1314 if (ret.
Failed())
return ret;
1321 if (plat_len == 0 || numtracks == 0)
return CMD_ERROR;
1332 bool reuse = (station_to_join != NEW_STATION);
1333 if (!reuse) station_to_join = INVALID_STATION;
1334 bool distant_join = (station_to_join != INVALID_STATION);
1341 TileArea new_location(tile_org, w_org, h_org);
1344 StationID est = INVALID_STATION;
1345 std::vector<Train *> affected_vehicles;
1348 if (cost.
Failed())
return cost;
1352 if (ret.
Failed())
return ret;
1354 ret =
BuildStationPart(&st, flags, reuse, new_location, STATIONNAMING_RAIL);
1355 if (ret.
Failed())
return ret;
1359 if (ret.
Failed())
return ret;
1367 if (statspec !=
nullptr) {
1384 byte numtracks_orig;
1390 st->
rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY);
1392 if (statspec !=
nullptr) {
1401 std::vector<byte> layouts(numtracks * plat_len);
1404 numtracks_orig = numtracks;
1407 size_t layout_idx = 0;
1413 byte layout = layouts[layout_idx++];
1418 affected_vehicles.push_back(v);
1440 if (statspec !=
nullptr) {
1455 TriggerStationAnimation(st, tile,
SAT_BUILT);
1460 bool blocked = statspec !=
nullptr &&
HasBit(statspec->
blocked, gfx);
1462 bool pylons = statspec !=
nullptr ?
HasBit(statspec->
pylons, gfx) : gfx < 4;
1463 bool wires = statspec ==
nullptr || !
HasBit(statspec->
wires, gfx);
1477 }
while (--numtracks);
1479 for (uint i = 0; i < affected_vehicles.size(); ++i) {
1487 update_reservation_area =
TileArea(tile_org, 1, numtracks_orig);
1489 update_reservation_area =
TileArea(tile_org, numtracks_orig, 1);
1492 for (
TileIndex tile : update_reservation_area) {
1503 platform_begin = next_tile;
1506 platform_end = next_tile;
1510 bool reservation =
false;
1511 for (
TileIndex t = platform_begin; !reservation && t <= platform_end; t += tile_offset) {
1532 if (ta.
w != 0 && ta.
h != 0) {
1582 static void MakeRailStationAreaSmaller(
BaseStation *st)
1592 static void MakeShipStationAreaSmaller(
Station *st)
1595 UpdateStationDockingTiles(st);
1627 if (ret.
Failed())
continue;
1630 T *st = T::GetByTile(tile);
1631 if (st ==
nullptr)
continue;
1636 if (ret.
Failed())
continue;
1645 total_cost.
AddCost(-_price[PR_CLEAR_RAIL]);
1664 DoClearSquare(tile);
1670 st->rect.AfterRemoveTile(st, tile);
1676 include(affected_stations, st);
1682 if (quantity == 0)
return error.
Failed() ? error :
CommandCost(STR_ERROR_THERE_IS_NO_STATION);
1684 for (T *st : affected_stations) {
1689 MakeRailStationAreaSmaller(st);
1690 UpdateStationSignCoord(st);
1697 MarkCatchmentTilesDirty();
1703 total_cost.
AddCost(quantity * removal_cost);
1718 if (end == 0) end = start;
1722 std::vector<Station *> affected_stations;
1725 if (ret.
Failed())
return ret;
1728 for (
Station *st : affected_stations) {
1731 st->MarkTilesDirty(
false);
1732 MarkCatchmentTilesDirty();
1733 st->RecomputeCatchment();
1751 if (end == 0) end = start;
1755 std::vector<Waypoint *> affected_stations;
1775 if (ret.
Failed())
return ret;
1781 assert(ta.
w != 0 && ta.
h != 0);
1787 if (st->TileBelongsToRailStation(tile)) {
1788 std::vector<T*> affected_stations;
1790 if (ret.
Failed())
return ret;
1845 if (*primary_stop ==
nullptr) {
1847 return primary_stop;
1851 while (stop->
next !=
nullptr) stop = stop->
next;
1869 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_ROAD_STOP_FIRST>(existing_stop, station_to_join, adjacent, ta, st);
1887 uint invalid_dirs = 0;
1888 if (is_drive_through) {
1892 SetBit(invalid_dirs, ddir);
1900 if (ret.
Failed())
return ret;
1905 if (!is_preexisting_roadstop) {
1934 bool reuse = (station_to_join != NEW_STATION);
1935 if (!reuse) station_to_join = INVALID_STATION;
1936 bool distant_join = (station_to_join != INVALID_STATION);
1943 if (roadstopspec !=
nullptr) {
1952 if (width == 0 || length == 0)
return CMD_ERROR;
1956 TileArea roadstop_area(tile, width, length);
1961 if (!is_drive_through && RoadTypeIsTram(rt))
return CMD_ERROR;
1966 if (ret.
Failed())
return ret;
1972 if (roadstopspec !=
nullptr) {
1973 unit_cost = roadstopspec->
GetBuildCost(is_truck_stop ? PR_BUILD_STATION_TRUCK : PR_BUILD_STATION_BUS);
1975 unit_cost = _price[is_truck_stop ? PR_BUILD_STATION_TRUCK : PR_BUILD_STATION_BUS];
1977 StationID est = INVALID_STATION;
1979 if (cost.
Failed())
return cost;
1983 if (ret.
Failed())
return ret;
1988 ret =
BuildStationPart(&st, flags, reuse, roadstop_area, STATIONNAMING_ROAD);
1989 if (ret.
Failed())
return ret;
1992 int specindex = AllocateSpecToRoadStop(roadstopspec, st, (flags &
DC_EXEC) != 0);
1995 if (roadstopspec !=
nullptr) {
2007 for (
TileIndex cur_tile : roadstop_area) {
2018 if (roadstopspec !=
nullptr) {
2027 *currstop = road_stop;
2029 if (is_truck_stop) {
2038 st->
rect.BeforeAddTile(cur_tile, StationRect::ADD_TRY);
2041 if (is_drive_through) {
2064 if (roadstopspec !=
nullptr) {
2065 st->SetRoadStopRandomBits(cur_tile,
GB(Random(), 0, 8));
2066 TriggerRoadStopAnimation(st, cur_tile,
SAT_BUILT);
2072 if (st !=
nullptr) {
2110 if (ret.
Failed())
return ret;
2125 assert(cur_stop !=
nullptr);
2133 if (ret.
Failed())
return ret;
2139 if (*primary_stop == cur_stop) {
2141 *primary_stop = cur_stop->
next;
2143 if (*primary_stop ==
nullptr) {
2150 while (pred->
next != cur_stop) pred = pred->
next;
2155 for (RoadTramType rtt : _roadtramtypes) {
2156 RoadType rt = GetRoadType(tile, rtt);
2173 DoClearSquare(tile);
2186 st->
rect.AfterRemoveTile(st, tile);
2190 st->RemoveRoadStopTileData(tile);
2191 if ((
int)specindex != replacement_spec_index) DeallocateSpecFromRoadStop(st, specindex);
2203 Price category = is_truck ? PR_CLEAR_STATION_TRUCK : PR_CLEAR_STATION_BUS;
2221 if (width == 0 || height == 0)
return CMD_ERROR;
2227 TileArea roadstop_area(tile, width, height);
2230 CommandCost last_error(STR_ERROR_THERE_IS_NO_STATION);
2231 bool had_success =
false;
2233 for (
TileIndex cur_tile : roadstop_area) {
2242 for (RoadTramType rtt : _roadtramtypes) {
2243 road_type[rtt] = GetRoadType(cur_tile, rtt);
2263 road_owner[RTT_ROAD], road_owner[RTT_TRAM]);
2272 return had_success ? cost : last_error;
2297 uint noise_reduction = distance / town_tolerance_distance;
2318 Town *nearest =
nullptr;
2321 auto height = as->
size_y;
2322 if (rotation ==
DIR_E || rotation ==
DIR_W) std::swap(width, height);
2324 uint perimeter_min_x =
TileX(tile);
2325 uint perimeter_min_y =
TileY(tile);
2326 uint perimeter_max_x = perimeter_min_x + width - 1;
2327 uint perimeter_max_y = perimeter_min_y + height - 1;
2329 mindist = UINT_MAX - 1;
2334 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) {
2336 if (t ==
nullptr)
continue;
2339 if (dist == mindist && t->
index < nearest->
index) nearest = t;
2340 if (dist < mindist) {
2389 bool reuse = (station_to_join != NEW_STATION);
2390 if (!reuse) station_to_join = INVALID_STATION;
2391 bool distant_join = (station_to_join != INVALID_STATION);
2398 if (ret.
Failed())
return ret;
2417 if (cost.
Failed())
return cost;
2425 StringID authority_refuse_message = STR_NULL;
2426 Town *authority_refuse_town =
nullptr;
2431 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE;
2432 authority_refuse_town = nearest;
2441 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
2442 authority_refuse_town = t;
2446 if (authority_refuse_message != STR_NULL) {
2452 ret =
FindJoiningStation(INVALID_STATION, station_to_join, allow_adjacent, airport_area, &st);
2453 if (ret.
Failed())
return ret;
2459 if (ret.
Failed())
return ret;
2466 cost.
AddCost(_price[PR_BUILD_STATION_AIRPORT]);
2479 st->
rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
2492 AirportTileAnimationTrigger(st, iter,
AAT_BUILT);
2522 if (ret.
Failed())
return ret;
2530 if (!a->IsNormalAircraft())
continue;
2531 if (a->targetairport == st->
index && a->state !=
FLYING) {
2556 if (!st->TileBelongsToAirport(tile_cur))
continue;
2559 if (ret.
Failed())
return ret;
2561 cost.
AddCost(_price[PR_CLEAR_STATION_AIRPORT]);
2565 DoClearSquare(tile_cur);
2606 if (ret.
Failed())
return ret;
2624 if ((v->
owner == company) == include_company) {
2626 if ((order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT)) && order->GetDestination() == station) {
2641 static const byte _dock_w_chk[4] = { 2, 1, 2, 1 };
2642 static const byte _dock_h_chk[4] = { 1, 2, 1, 2 };
2654 bool reuse = (station_to_join != NEW_STATION);
2655 if (!reuse) station_to_join = INVALID_STATION;
2656 bool distant_join = (station_to_join != INVALID_STATION);
2668 if (ret.
Failed())
return ret;
2674 if (ret.
Failed())
return ret;
2690 if (ret.
Failed())
return ret;
2691 if (add_cost) cost.
AddCost(ret);
2699 _dock_w_chk[direction], _dock_h_chk[direction]);
2703 ret =
FindJoiningStation(INVALID_STATION, station_to_join, adjacent, dock_area, &st);
2704 if (ret.
Failed())
return ret;
2710 if (ret.
Failed())
return ret;
2718 st->
rect.BeforeAddRect(dock_area.
tile, dock_area.
w, dock_area.
h, StationRect::ADD_TRY);
2730 UpdateStationDockingTiles(st);
2746 if (st !=
nullptr) UpdateStationDockingTiles(st);
2749 if (neutral !=
nullptr) UpdateStationDockingTiles(neutral);
2768 if (IsPossibleDockingTile(docking_tile)) {
2807 if (ret.
Failed())
return ret;
2817 if (ret.
Failed())
return ret;
2820 DoClearSquare(tile1);
2822 MakeWaterKeepingClass(tile2, st->
owner);
2824 st->
rect.AfterRemoveTile(st, tile1);
2825 st->
rect.AfterRemoveTile(st, tile2);
2827 MakeShipStationAreaSmaller(st);
2844 if (s->current_order.GetDestination() != st->
index) {
2859 s->SetDestTile(s->GetOrderStationLocation(st->
index));
2871 return &_station_display_datas[st][gfx];
2887 case SPR_RAIL_TRACK_X:
2888 case SPR_MONO_TRACK_X:
2889 case SPR_MGLV_TRACK_X:
2890 snow_desert =
false;
2891 *overlay_offset =
RTO_X;
2894 case SPR_RAIL_TRACK_Y:
2895 case SPR_MONO_TRACK_Y:
2896 case SPR_MGLV_TRACK_Y:
2897 snow_desert =
false;
2898 *overlay_offset =
RTO_Y;
2901 case SPR_RAIL_TRACK_X_SNOW:
2902 case SPR_MONO_TRACK_X_SNOW:
2903 case SPR_MGLV_TRACK_X_SNOW:
2905 *overlay_offset =
RTO_X;
2908 case SPR_RAIL_TRACK_Y_SNOW:
2909 case SPR_MONO_TRACK_Y_SNOW:
2910 case SPR_MGLV_TRACK_Y_SNOW:
2912 *overlay_offset =
RTO_Y;
2919 if (ti !=
nullptr) {
2935 *ground = snow_desert ? SPR_FLAT_SNOW_DESERT_TILE : SPR_FLAT_GRASS_TILE;
2939 static void DrawTile_Station(
TileInfo *ti)
2944 int32_t total_offset;
2946 uint32_t relocation = 0;
2947 uint32_t ground_relocation = 0;
2950 uint tile_layout = 0;
2961 if (statspec !=
nullptr) {
2997 case APT_RADAR_GRASS_FENCE_SW:
3000 case APT_GRASS_FENCE_NE_FLAG:
3003 case APT_RADAR_FENCE_SW:
3006 case APT_RADAR_FENCE_NE:
3009 case APT_GRASS_FENCE_NE_FLAG_2:
3019 palette = COMPANY_SPRITE_COLOUR(owner);
3022 palette = PALETTE_TO_GREY;
3025 if (layout ==
nullptr && (t ==
nullptr || t->
seq ==
nullptr)) t = GetStationTileLayout(
GetStationType(ti->
tile), gfx);
3035 if (!HasFoundationNW(ti->
tile, slope, z))
SetBit(edge_info, 0);
3036 if (!HasFoundationNE(ti->
tile, slope, z))
SetBit(edge_info, 1);
3038 if (image == 0)
goto draw_default_foundation;
3043 static const uint8_t foundation_parts[] = {
3056 static const uint8_t composite_foundation_parts[] = {
3058 0x00, 0xD1, 0xE4, 0xE0,
3060 0xCA, 0xC9, 0xC4, 0xC0,
3062 0xD2, 0x91, 0xE4, 0xA0,
3067 uint8_t parts = composite_foundation_parts[ti->
tileh];
3078 goto draw_default_foundation;
3082 for (
int i = 0; i < 8; i++) {
3093 draw_default_foundation:
3098 bool draw_ground =
false;
3101 DrawWaterClassGround(ti);
3103 if (sprite != 0) total_offset = sprite - SPR_IMG_BUOY;
3106 DrawWaterClassGround(ti);
3112 DrawShoreTile(ti->
tileh);
3114 DrawClearLandTile(ti, 3);
3118 if (layout !=
nullptr) {
3127 t = &tmp_rail_layout;
3129 }
else if (statspec !=
nullptr) {
3179 if (stopspec !=
nullptr) {
3185 if (group !=
nullptr && group->type == SGT_TILELAYOUT) {
3202 uint sprite_offset = axis ==
AXIS_X ? 1 : 0;
3204 DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset);
3209 if ((stopspec ==
nullptr || (stopspec->draw_mode &
ROADSTOP_DRAW_MODE_ROAD) != 0) && road_rti->UsesOverlay()) {
3231 int32_t total_offset = 0;
3246 DrawSprite(ground + overlay_offset, PAL_NONE, x, y);
3255 uint sprite_offset = 5 - image;
3258 if (roadtype_info->UsesOverlay()) {
3260 DrawSprite(ground + sprite_offset, PAL_NONE, x, y);
3263 if (overlay)
DrawSprite(overlay + sprite_offset, PAL_NONE, x, y);
3264 }
else if (RoadTypeIsTram(roadtype)) {
3265 DrawSprite(SPR_TRAMWAY_TRAM + sprite_offset, PAL_NONE, x, y);
3269 if (RoadTypeIsRoad(roadtype) && roadtype_info->UsesOverlay()) {
3280 static int GetSlopePixelZ_Station(
TileIndex tile, uint, uint,
bool)
3292 RoadType road_rt = GetRoadTypeRoad(tile);
3293 RoadType tram_rt = GetRoadTypeTram(tile);
3316 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER;
3317 td->
owner[i] = road_owner;
3321 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER;
3322 td->
owner[i] = tram_owner;
3332 if (spec !=
nullptr) {
3370 if (
IsRoadStop(tile)) FillTileDescRoadStop(tile, td);
3372 if (
IsAirport(tile)) FillTileDescAirport(tile, td);
3376 default: NOT_REACHED();
3377 case STATION_RAIL: str = STR_LAI_STATION_DESCRIPTION_RAILROAD_STATION;
break;
3378 case STATION_AIRPORT:
3379 str = (
IsHangar(tile) ? STR_LAI_STATION_DESCRIPTION_AIRCRAFT_HANGAR : STR_LAI_STATION_DESCRIPTION_AIRPORT);
3381 case STATION_TRUCK: str = STR_LAI_STATION_DESCRIPTION_TRUCK_LOADING_AREA;
break;
3382 case STATION_BUS: str = STR_LAI_STATION_DESCRIPTION_BUS_STATION;
break;
3383 case STATION_OILRIG: {
3391 case STATION_DOCK: str = STR_LAI_STATION_DESCRIPTION_SHIP_DOCK;
break;
3392 case STATION_BUOY: str = STR_LAI_STATION_DESCRIPTION_BUOY;
break;
3393 case STATION_WAYPOINT: str = STR_LAI_STATION_DESCRIPTION_WAYPOINT;
break;
3423 RoadTramType rtt = (RoadTramType)sub_mode;
3445 static void TileLoop_Station(
TileIndex tile)
3450 case STATION_AIRPORT:
3458 case STATION_OILRIG:
3468 static void AnimateTile_Station(
TileIndex tile)
3471 AnimateStationTile(tile);
3476 AnimateAirportTile(tile);
3481 AnimateRoadStopTile(tile);
3487 static bool ClickTile_Station(
TileIndex tile)
3531 }
else if (x < stop) {
3533 uint16_t spd = std::max(0, (stop - x) * 20 - 15);
3534 if (spd < v->cur_speed) v->
cur_speed = spd;
3557 CargoTypes cargoes = 0;
3563 if (cargoes == 0)
return;
3601 static inline void byte_inc_sat(
byte *p)
3618 StationCargoAmountMap waiting_per_source;
3620 for (StationCargoAmountMap::iterator i(waiting_per_source.begin()); i != waiting_per_source.end(); ++i) {
3622 if (source_station ==
nullptr)
continue;
3629 static void UpdateStationRating(
Station *st)
3631 bool waiting_changed =
false;
3633 byte_inc_sat(&st->time_since_load);
3634 byte_inc_sat(&st->time_since_unload);
3652 waiting_changed =
true;
3671 uint waiting_avg = waiting / (num_dests + 1);
3674 ge->
rating = rating = MAX_STATION_RATING;
3685 | (ClampTo<uint8_t>(last_speed) << 24);
3687 uint32_t var10 = (st->last_vehicle_type ==
VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10);
3691 rating =
GB(callback, 0, 14);
3694 if (
HasBit(callback, 14)) rating -= 0x4000;
3700 if (b >= 0) rating += b >> 2;
3703 if (st->last_vehicle_type ==
VEH_SHIP) waittime >>= 2;
3704 if (waittime <= 21) rating += 25;
3705 if (waittime <= 12) rating += 25;
3706 if (waittime <= 6) rating += 45;
3707 if (waittime <= 3) rating += 35;
3720 if (age < 3) rating += 10;
3721 if (age < 2) rating += 10;
3722 if (age < 1) rating += 13;
3728 ge->
rating = rating = or_ +
Clamp(ClampTo<uint8_t>(rating) - or_, -2, 2);
3732 if (rating <= 64 && waiting_avg >= 100) {
3733 int dec = Random() & 0x1F;
3734 if (waiting_avg < 200) dec &= 7;
3735 waiting -= (dec + 1) * num_dests;
3736 waiting_changed =
true;
3740 if (rating <= 127 && waiting != 0) {
3741 uint32_t r = Random();
3742 if (rating <= (
int)
GB(r, 0, 7)) {
3744 waiting = std::max((
int)waiting - (
int)((
GB(r, 8, 2) - 1) * num_dests), 0);
3745 waiting_changed =
true;
3752 static const uint WAITING_CARGO_THRESHOLD = 1 << 12;
3753 static const uint WAITING_CARGO_CUT_FACTOR = 1 << 6;
3754 static const uint MAX_WAITING_CARGO = 1 << 15;
3756 if (waiting > WAITING_CARGO_THRESHOLD) {
3757 uint difference = waiting - WAITING_CARGO_THRESHOLD;
3758 waiting -= (difference / WAITING_CARGO_CUT_FACTOR);
3760 waiting = std::min(waiting, MAX_WAITING_CARGO);
3761 waiting_changed =
true;
3766 if (waiting_changed && waiting < ge->cargo.AvailableCount()) {
3780 StationID index = st->
index;
3781 if (waiting_changed) {
3804 for (
Vehicle *v : st->loading_vehicles) {
3805 for (
Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
3806 if (u->cargo_type != c)
continue;
3807 u->cargo.Reroute(UINT_MAX, &u->cargo, avoid, avoid2, &ge);
3826 if (lg ==
nullptr)
continue;
3827 std::vector<NodeID> to_remove{};
3828 for (
Edge &edge : (*lg)[ge.
node].edges) {
3830 assert(to->
goods[c].
node == edge.dest_node);
3834 bool updated =
false;
3836 if (auto_distributed) {
3839 std::vector<Vehicle *> vehicles;
3841 bool found_from =
false;
3842 bool found_to =
false;
3843 for (
Order *order = l->GetFirstOrder(); order !=
nullptr; order = order->
next) {
3844 if (!order->IsType(OT_GOTO_STATION) && !order->IsType(OT_IMPLICIT))
continue;
3845 if (order->GetDestination() == from->
index) {
3847 if (found_to)
break;
3848 }
else if (order->GetDestination() == to->
index) {
3850 if (found_from)
break;
3853 if (!found_to || !found_from)
continue;
3854 vehicles.push_back(l->GetFirstSharedVehicle());
3857 auto iter = vehicles.begin();
3858 while (iter != vehicles.end()) {
3871 *iter = next_shared;
3874 iter = vehicles.erase(iter);
3877 if (iter == vehicles.end()) iter = vehicles.begin();
3883 to_remove.emplace_back(to->
goods[c].
node);
3896 for (NodeID r : to_remove) (*lg)[ge.
node].RemoveEdge(r);
3928 Debug(misc, 0,
"Can't allocate link graph");
3937 }
else if (ge2.
link_graph == INVALID_LINK_GRAPH) {
3955 if (lg !=
nullptr) {
3956 (*lg)[ge1.
node].UpdateEdge(ge2.
node, capacity, usage, time, mode);
3968 for (
const Vehicle *v = front; v !=
nullptr; v = v->
Next()) {
3983 static void StationHandleSmallTick(
BaseStation *st)
3994 void OnTick_Station()
3996 if (_game_mode == GM_EDITOR)
return;
3999 StationHandleSmallTick(st);
4032 void ModifyStationRatingAround(
TileIndex tile,
Owner owner,
int amount, uint radius)
4036 for (GoodsEntry &ge : st->goods) {
4037 if (ge.status != 0) {
4038 ge.rating = ClampTo<uint8_t>(ge.rating + amount);
4057 if (amount == 0)
return 0;
4069 Debug(misc, 0,
"Can't allocate link graph");
4074 if (lg !=
nullptr) (*lg)[ge.
node].UpdateSupply(amount);
4093 static bool IsUniqueStationName(
const std::string &name)
4096 if (!st->
name.empty() && st->
name == name)
return false;
4115 if (ret.
Failed())
return ret;
4117 bool reset = text.empty();
4121 if (!IsUniqueStationName(text))
return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
4142 if (st->TileIsInCatchment(tile)) stations->insert(st);
4155 assert(this->
w == 1 && this->
h == 1);
4156 AddNearbyStationsByCatchment(this->tile, &this->stations, Town::GetByTile(this->tile)->stations_near);
4159 this->stations.insert(st);
4169 static bool CanMoveGoodsToStation(
const Station *st,
CargoID type)
4193 if (all_stations->empty())
return 0;
4194 if (amount == 0)
return 0;
4196 Station *first_station =
nullptr;
4197 typedef std::pair<Station *, uint> StationInfo;
4198 std::vector<StationInfo> used_stations;
4200 for (
Station *st : *all_stations) {
4202 if (!CanMoveGoodsToStation(st, type))
continue;
4206 if (first_station ==
nullptr) {
4210 if (used_stations.empty()) {
4211 used_stations.reserve(2);
4212 used_stations.emplace_back(std::make_pair(first_station, 0));
4214 used_stations.emplace_back(std::make_pair(st, 0));
4218 if (first_station ==
nullptr)
return 0;
4220 if (used_stations.empty()) {
4223 return UpdateStationWaiting(first_station, type, amount, source_type, source_id);
4228 uint best_rating = 0;
4231 for (
auto &p : used_stations) {
4232 auto owner = p.first->owner;
4233 auto rating = p.first->goods[type].rating;
4234 if (rating > company_best[owner]) {
4235 best_sum += rating - company_best[owner];
4236 company_best[owner] = rating;
4237 if (rating > best_rating) best_rating = rating;
4239 company_sum[owner] += rating;
4244 amount *= best_rating + 1;
4247 for (
auto &p : used_stations) {
4248 uint owner = p.first->owner;
4251 p.second = amount * company_best[owner] * p.first->goods[type].rating / best_sum / company_sum[owner];
4256 if (amount > moving) {
4257 std::stable_sort(used_stations.begin(), used_stations.end(), [type](
const StationInfo &a,
const StationInfo &b) {
4258 return b.first->goods[type].rating < a.first->goods[type].rating;
4261 assert(amount - moving <= used_stations.size());
4262 for (uint i = 0; i < amount - moving; i++) {
4263 used_stations[i].second++;
4268 for (
auto &p : used_stations) {
4269 moved += UpdateStationWaiting(p.first, type, p.second, source_type, source_id);
4275 void UpdateStationDockingTiles(
Station *st)
4289 int x2 = std::min<int>(x + area->
w + 1,
Map::SizeX());
4290 int x1 = std::max<int>(x - 1, 0);
4292 int y2 = std::min<int>(y + area->
h + 1,
Map::SizeY());
4293 int y1 = std::max<int>(y - 1, 0);
4304 Debug(misc, 0,
"Can't allocate station for oilrig at 0x{:X}, reverting to oilrig only", tile);
4327 UpdateStationDockingTiles(st);
4329 st->
rect.BeforeAddTile(tile, StationRect::ADD_FORCE);
4339 for (
Station *near : nearby) {
4340 near->RecomputeCatchment(
true);
4367 for (RoadTramType rtt : _roadtramtypes) {
4370 RoadType rt = GetRoadType(tile, rtt);
4394 case STATION_WAYPOINT:
4463 if (ret.
Failed())
return ret;
4471 if (ret.
Failed())
return ret;
4474 if (ret.
Failed())
return ret;
4493 case STATION_WAYPOINT:
return_cmd_error(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
4494 case STATION_AIRPORT:
return_cmd_error(STR_ERROR_MUST_DEMOLISH_AIRPORT_FIRST);
4495 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);
4496 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);
4499 case STATION_OILRIG:
4500 SetDParam(1, STR_INDUSTRY_NAME_OIL_RIG);
4509 case STATION_TRUCK: [[fallthrough]];
4513 if (remove_road.
Failed())
return remove_road;
4516 case STATION_BUOY:
return RemoveBuoy(tile, flags);
4517 case STATION_DOCK:
return RemoveDock(tile, flags);
4532 case STATION_WAYPOINT:
4533 case STATION_RAIL: {
4540 case STATION_AIRPORT:
4568 for (
const auto &it : this->
shares) {
4569 if (it.second == st) {
4570 return it.first - prev;
4587 assert(!this->
shares.empty());
4589 assert(it != this->
shares.end() && it->first <= this->unrestricted);
4590 if (it->second != excluded && it->second != excluded2)
return it->second;
4595 uint end = it->first;
4596 uint begin = (it == this->
shares.begin() ? 0 : (--it)->first);
4597 uint interval = end - begin;
4598 if (interval >= this->
unrestricted)
return INVALID_STATION;
4601 SharesMap::const_iterator it2 = (rand < begin) ? this->
shares.upper_bound(rand) :
4602 this->
shares.upper_bound(rand + interval);
4603 assert(it2 != this->
shares.end() && it2->first <= this->unrestricted);
4604 if (it2->second != excluded && it2->second != excluded2)
return it2->second;
4609 uint end2 = it2->first;
4610 uint begin2 = (it2 == this->
shares.begin() ? 0 : (--it2)->first);
4611 uint interval2 = end2 - begin2;
4612 if (interval2 >= new_max)
return INVALID_STATION;
4613 new_max -= interval2;
4614 if (begin > begin2) {
4615 Swap(begin, begin2);
4617 Swap(interval, interval2);
4622 it3 = this->
shares.upper_bound(rand);
4623 }
else if (rand < begin2 - interval) {
4624 it3 = this->
shares.upper_bound(rand + interval);
4626 it3 = this->
shares.upper_bound(rand + interval + interval2);
4628 assert(it3 != this->
shares.end() && it3->first <= this->unrestricted);
4639 assert(!this->
shares.empty());
4640 SharesMap new_shares;
4642 for (
const auto &it : this->
shares) {
4643 new_shares[++i] = it.second;
4644 if (it.first == this->unrestricted) this->
unrestricted = i;
4646 this->shares.swap(new_shares);
4647 assert(!this->shares.empty() && this->unrestricted <= (--this->shares.end())->first);
4660 assert(!this->
shares.empty());
4662 uint removed_shares = 0;
4663 uint added_shares = 0;
4664 uint last_share = 0;
4665 SharesMap new_shares;
4666 for (
const auto &it : this->
shares) {
4667 if (it.second == st) {
4669 uint share = it.first - last_share;
4670 if (flow == INT_MIN || (uint)(-flow) >= share) {
4671 removed_shares += share;
4672 if (it.first <= this->unrestricted) this->
unrestricted -= share;
4673 if (flow != INT_MIN) flow += share;
4674 last_share = it.first;
4677 removed_shares += (uint)(-flow);
4679 added_shares += (uint)(flow);
4681 if (it.first <= this->unrestricted) this->
unrestricted += flow;
4687 new_shares[it.first + added_shares - removed_shares] = it.second;
4688 last_share = it.first;
4691 new_shares[last_share + (uint)flow] = st;
4698 this->shares.swap(new_shares);
4708 assert(!this->
shares.empty());
4710 uint last_share = 0;
4711 SharesMap new_shares;
4712 for (
auto &it : this->
shares) {
4714 if (it.first > this->unrestricted)
return;
4715 if (it.second == st) {
4716 flow = it.first - last_share;
4719 new_shares[it.first] = it.second;
4722 new_shares[it.first - flow] = it.second;
4724 last_share = it.first;
4726 if (flow == 0)
return;
4727 new_shares[last_share + flow] = st;
4728 this->shares.swap(new_shares);
4729 assert(!this->shares.empty());
4739 assert(!this->
shares.empty());
4741 uint next_share = 0;
4743 for (SharesMap::reverse_iterator it(this->
shares.rbegin()); it != this->shares.rend(); ++it) {
4744 if (it->first < this->unrestricted)
return;
4746 flow = next_share - it->first;
4750 if (it->first == this->unrestricted)
return;
4751 if (it->second == st) found =
true;
4753 next_share = it->first;
4755 if (flow == 0)
return;
4756 SharesMap new_shares;
4757 new_shares[flow] = st;
4758 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4759 if (it->second != st) {
4760 new_shares[flow + it->first] = it->second;
4765 this->
shares.swap(new_shares);
4766 assert(!this->
shares.empty());
4776 assert(runtime > 0);
4777 SharesMap new_shares;
4779 for (
auto i : this->
shares) {
4780 share = std::max(share + 1, i.first * 30 / runtime);
4781 new_shares[share] = i.second;
4784 this->shares.swap(new_shares);
4795 FlowStatMap::iterator origin_it = this->find(origin);
4796 if (origin_it == this->end()) {
4797 this->insert(std::make_pair(origin,
FlowStat(via, flow)));
4799 origin_it->second.ChangeShare(via, flow);
4800 assert(!origin_it->second.GetShares()->empty());
4814 FlowStatMap::iterator prev_it = this->find(origin);
4815 if (prev_it == this->end()) {
4818 this->insert(std::make_pair(origin, fs));
4820 prev_it->second.ChangeShare(via, flow);
4821 prev_it->second.ChangeShare(INVALID_STATION, flow);
4822 assert(!prev_it->second.GetShares()->empty());
4832 for (
auto &i : *
this) {
4834 uint local = fs.
GetShare(INVALID_STATION);
4835 if (local > INT_MAX) {
4858 for (FlowStatMap::iterator f_it = this->begin(); f_it != this->end();) {
4862 ret.
Push(f_it->first);
4863 this->erase(f_it++);
4877 for (
auto &it : *
this) {
4878 it.second.RestrictShare(via);
4888 for (
auto &it : *
this) {
4889 it.second.ReleaseShare(via);
4900 for (
const auto &it : *
this) {
4901 ret += (--(it.second.GetShares()->end()))->first;
4914 for (
const auto &it : *
this) {
4915 ret += it.second.GetShare(via);
4927 FlowStatMap::const_iterator i = this->find(from);
4928 if (i == this->end())
return 0;
4929 return (--(i->second.GetShares()->end()))->first;
4940 FlowStatMap::const_iterator i = this->find(from);
4941 if (i == this->end())
return 0;
4942 return i->second.GetShare(via);
4947 GetSlopePixelZ_Station,
4950 GetTileDesc_Station,
4951 GetTileTrackStatus_Station,
4953 AnimateTile_Station,
4955 ChangeTileOwner_Station,
4957 VehicleEnter_Station,
4958 GetFoundation_Station,
4959 TerraformTile_Station,
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ VETS_STATION_ID_OFFSET
Shift the VehicleEnterTileStatus this many bits to the right to get the station ID when VETS_ENTERED_...
int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec)
Allocate a StationSpec to a Station.
Buses, trucks and trams belong to this class.
@ AAT_STATION_250_TICKS
Triggered every 250 ticks (for all tiles at the same time).
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
StringID airport_class
Name of the airport class.
debug_inline bool IsFrontEngine() const
Check if the vehicle is a front engine.
@ MP_HOUSE
A house by a town.
void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index)
Delete inspect window for a given feature and index.
bool IsTileFlat(TileIndex tile, int *h)
Check if a given tile is flat.
StationFacility facilities
The facilities that this station has.
const char * grf
newGRF used for the tile contents
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...
static CommandCost RemoveRailWaypoint(TileIndex tile, DoCommandFlag flags)
Remove a rail waypoint.
@ VETSB_CANNOT_ENTER
The vehicle cannot enter the tile.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
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.
@ TROPICZONE_DESERT
Tile is desert.
static const uint INVALID_AIRPORTTILE
id for an invalid airport tile
void ScaleToMonthly(uint runtime)
Scale all shares from link graph's runtime to monthly values.
std::vector< StationSpecList > speclist
List of rail station specs of this station.
TileArea docking_station
Tile area the docking tiles cover.
static const uint64_t AIRPORT_CLOSED_block
Dummy block for indicating a closed airport.
@ ROTSG_GROUND
Required: Main group of ground images.
CommandCost CanExpandRailStation(const BaseStation *st, TileArea &new_ta)
Check whether we can expand the rail part of the given station.
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-...
Owner owner
owner of the industry. Which SHOULD always be (imho) OWNER_NONE
void Invalidate()
Reduce all flows to minimum capacity so that they don't get in the way of link usage statistics too m...
PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
Minimal stack that uses a pool to avoid pointers.
uint64_t flags
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
GoodsEntry goods[NUM_CARGO]
Goods at this station.
@ TRACK_BIT_NONE
No track.
@ ROADSTOPTYPE_ALL
This RoadStop is for both types of station road stops.
static const IndustryType NUM_INDUSTRYTYPES
total number of industry types, new and old; limited to 240 because we need some special ids like INV...
StationRect - used to track station spread out rectangle - cheaper than scanning whole map.
uint8_t rating
Station rating for this cargo.
byte StationGfx
Copy from station_map.h.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
static CargoArray GetAcceptanceAroundStation(const Station *st, CargoTypes *always_accepted)
Get the acceptance of cargoes around the station in.
uint unrestricted
Limit for unrestricted shares.
bool IsType(OrderType type) const
Check whether this order is of the given type.
static Titem * Get(size_t index)
Returns Titem with given index.
DisallowedRoadDirections GetDisallowedRoadDirections(Tile t)
Gets the disallowed directions.
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.
static TickCounter counter
Monotonic counter, in ticks, since start of game.
byte flags
Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size.
Direction
Defines the 8 directions on the map.
CommandCost FindJoiningWaypoint(StationID existing_waypoint, StationID waypoint_to_join, bool adjacent, TileArea ta, Waypoint **wp)
Find a nearby waypoint that joins this waypoint.
uint GetFlowVia(StationID via) const
Get the sum of flows via a specific station from this FlowStatMap.
uint GetHangarNum(TileIndex tile) const
Get the hangar number of the hangar at a specific tile.
StationSettings station
settings related to station management
bool IsWithinMapBounds(byte table, TileIndex index) const
Check if the airport would be within the map bounds at the given tile.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
A connected component of a link graph.
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
std::vector< NewGRFSpriteLayout > renderdata
Number of tile layouts.
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.
void AfterStationTileSetChange(bool adding, StationType type)
After adding/removing tiles to station, update some station-related stuff.
uint GetFlow() const
Get the sum of all flows from this FlowStatMap.
RoadStopType
Types of RoadStops.
@ ROADSTOP_TRUCK
A standard stop for trucks.
bool ValParamRailType(const RailType rail)
Validate functions for rail building.
void Push(const Titem &item)
Pushes a new item onto the stack if there is still space in the underlying pool.
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track)
Use this function to notify YAPF that track layout (or signal configuration) has change.
constexpr void Swap(T &a, T &b)
Type safe swap operation.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
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 const CommandCost CMD_ERROR
Define a default return value for a failed command.
void UpdateAirplanesOnNewStation(const Station *st)
Updates the status of the Aircraft heading or in the station.
Foundation FlatteningFoundation(Slope s)
Returns the foundation needed to flatten a slope.
bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
Find out if the slope of the tile is suitable to build a depot of given direction.
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
uint GetRailtypeSpriteOffset() const
Offset between the current railtype and normal rail.
@ SSF_EXTENDED_FOUNDATIONS
Extended foundation block instead of simple.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
@ SAT_250_TICKS
Trigger station every 250 ticks.
@ TO_BUILDINGS
company buildings - depots, stations, HQ, ...
Tile information, used while rendering the tile.
static bool StationHandleBigTick(BaseStation *st)
This function is called for each station once every 250 ticks.
bool IsRailStation(Tile t)
Is this station tile a rail station?
void ReleaseShare(StationID st)
Release ("unrestrict") a flow by moving it to the begin of the map and increasing the amount of unres...
WaterClass GetWaterClass(Tile t)
Get the water class at a tile.
@ SPRITE_WIDTH
number of bits for the sprite number
byte landscape
the landscape we're currently in
StringID railtype
Type of rail on the tile.
CompanyMask statues
which companies have a statue?
Vehicle * Next() const
Get the next vehicle of this vehicle.
const Tcont * Packets() const
Returns a pointer to the cargo packet list (so you can iterate over it etc).
Town * town
The town this station is associated with.
void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool b)
Set the reservation for a complete station platform.
@ FACIL_TRUCK_STOP
Station with truck stops.
@ CBM_CARGO_STATION_RATING_CALC
custom station rating for this cargo type
Owner owner[4]
Name of the owner(s)
byte size_y
size of airport in y direction
Axis
Allow incrementing of DiagDirDiff variables.
@ CBID_STATION_AVAILABILITY
Determine whether a newstation should be made available to build.
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
uint GetSpecCount() const
Get the number of allocated specs within the class.
@ AAT_STATION_NEW_CARGO
Triggered when new cargo arrives at the station (for all tiles at the same time).
@ PALETTE_MODIFIER_COLOUR
this bit is set when a recolouring process is in action
DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
uint16_t triggers
The triggers that trigger animation.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Price
Enumeration of all base prices for use with Prices.
StringID name
name of this airport
static CommandCost CanRemoveRoadWithStop(TileIndex tile, DoCommandFlag flags)
Check if a drive-through road stop tile can be cleared.
static bool CMSAWater(TileIndex tile)
Check whether the tile is water.
@ SAT_NEW_CARGO
Trigger station on new cargo arrival.
StringID station_class
Class of station.
CommandCost RemoveRailStation(T *st, DoCommandFlag flags, Money removal_cost)
Remove a rail station/waypoint.
uint16_t road_speed
Speed limit of road (bridges and track)
byte town_council_tolerance
minimum required town ratings to be allowed to demolish stuff
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Iterator to iterate over all tiles belonging to a bitmaptilearea.
@ ROADSTOPTYPE_FREIGHT
This RoadStop is for freight (truck) stops.
An interval timer will fire every interval, and will continue to fire until it is deleted.
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.
@ AAT_BUILT
Triggered when the airport is built (for all tiles at the same time).
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
@ DIAGDIR_END
Used for iterations.
bool AutoslopeEnabled()
Tests if autoslope is enabled for _current_company.
Tindex index
Index of this pool item.
void DrawRoadCatenary(const TileInfo *ti)
Draws the catenary for the given tile.
@ RVSB_IN_ROAD_STOP
The vehicle is in a road stop.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
CommandCost CmdOpenCloseAirport(DoCommandFlag flags, StationID station_id)
Open/close an airport to incoming aircraft.
CommandCost FindJoiningBaseStation(StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, T **st)
Find a nearby station that joins this station.
CargoTypes GetAcceptanceMask(const Station *st)
Get a mask of the cargo types that the station accepts.
Class for storing amounts of cargo.
@ TRACK_X
Track along the x-axis (north-east to south-west)
SpriteID sprite
The 'real' sprite.
@ DT_MANUAL
Manual distribution. No link graph calculations are run.
byte noise_level
noise that this airport generates
void PassOnFlow(StationID origin, StationID via, uint amount)
Pass on some flow, remembering it as invalid, for later subtraction from locally consumed flow.
static constexpr TimerGameEconomy::Date STALE_LINK_DEPOT_TIMEOUT
Number of days before deleting links served only by vehicles stopped in depot.
DifficultySettings difficulty
settings related to the difficulty
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
@ CBID_CARGO_STATION_RATING_CALC
Called to calculate part of a station rating.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
bool IsOilRig(Tile t)
Is tile t part of an oilrig?
This struct contains all the info that is needed to draw and construct tracks.
@ VETSB_CONTINUE
Bit sets of the above specified bits.
void SetStationTileHaveWires(Tile t, bool b)
Set the catenary wires state of the rail station.
void MoveSign(TileIndex new_xy) override
Move the station main coordinate somewhere else.
Representation of a waypoint.
@ CBM_STATION_SLOPE_CHECK
Check slope of new station tiles.
void SetStationTileHavePylons(Tile t, bool b)
Set the catenary pylon state of the rail station.
byte layout
Airport layout number.
bool IsCompatibleTrainStationTile(Tile test_tile, Tile station_tile)
Check if a tile is a valid continuation to a railstation tile.
static RoadStop * GetByTile(TileIndex tile, RoadStopType type)
Find a roadstop at given tile.
uint8_t GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance)
Get a possible noise reduction factor based on distance from town center.
static constexpr bool IsSteepSlope(Slope s)
Checks if a slope is steep.
bool IsRailStationTile(Tile t)
Is this tile a station tile and a rail station?
@ EUM_INCREASE
Increase capacity.
static const uint TILE_SIZE
Tile size in world coordinates.
Wrapper class to abstract away the way the tiles are stored.
ProducedCargoArray produced
INDUSTRY_NUM_OUTPUTS production cargo slots.
static IterateWrapper Iterate(size_t from=0)
Returns an iterable ensemble of all valid CargoSpec.
static Station * Get(size_t index)
Gets station with given index.
ClientSettings _settings_client
The current settings for this game.
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.
TileIndex xy
town center tile
Specification of a cargo type.
DiagDirection GetRoadStopDir(Tile t)
Gets the direction the road stop entrance points towards.
static bool IsValidID(size_t index)
Tests whether given index is a valid index for station of this type.
@ MP_INDUSTRY
Part of an industry.
@ TRANSPORT_WATER
Transport over water.
GRFConfig * GetGRFConfig(uint32_t grfid, uint32_t mask)
Retrieve a NewGRF from the current config by its grfid.
int y
Y position of the tile in unit coordinates.
@ CC_LIQUID
Liquids (Oil, Water, Rubber)
void Add(TileIndex to_add)
Add a single tile to a tile area; enlarge if needed.
StringID airport_tile_name
Name of the airport tile.
constexpr uint ClampU(const uint a, const uint min, const uint max)
Clamp an unsigned integer between an interval.
Slope GetFoundationPixelSlope(TileIndex tile, int *z)
Get slope of a tile on top of a (possible) foundation If a tile does not have a foundation,...
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
DiagDirection GetDockDirection(Tile t)
Get the direction of a dock.
@ VS_TRAIN_SLOWING
Train is slowing down.
NodeID Size() const
Get the current size of the component.
static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags, int replacement_spec_index=-1)
Remove a bus station/truck stop.
@ WC_STATION_VIEW
Station view; Window numbers:
bool IsWaterTile(Tile t)
Is it a water tile with plain water?
StringID station_name
Default name for nearby station.
bool Enter(RoadVehicle *rv)
Enter the road stop.
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.
@ VEH_ROAD
Road vehicle type.
@ CC_PASSENGERS
Passengers.
Defines the internal data of a functional industry.
struct RailTypeInfo::@26 strings
Strings associated with the rail type.
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
Owner owner
Which company owns the vehicle?
static void RestoreTrainReservation(Train *v)
Restore platform reservation during station building/removing.
Owner
Enum for all companies/owners.
CommandCost GetStationAround(TileArea ta, StationID closest_station, CompanyID company, T **st)
Look for a station owned by the given company around the given tile area.
@ DC_EXEC
execute the given command
void DeallocateSpecFromStation(BaseStation *st, byte specindex)
Deallocate a StationSpec from a Station.
uint32_t PaletteID
The number of the palette.
void FinalizeLocalConsumption(StationID self)
Subtract invalid flows from locally consumed flow.
void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTrigger trigger, CargoID cargo_type=INVALID_CARGO)
Trigger road stop randomisation.
Owner owner
The owner of this station.
void RecomputeCatchment(bool no_clear_nearby_lists=false)
Recompute tiles covered in our catchment area.
@ MP_ROAD
A tile with road (or tram tracks)
Defines the data structure for an airport.
void MakeRailStation(Tile t, Owner o, StationID sid, Axis a, byte section, RailType rt)
Make the given tile a rail station tile.
CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailType rt, Axis axis, byte numtracks, byte plat_len, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
Build rail station.
@ WATER_CLASS_INVALID
Used for industry tiles on land (also for oilrig if newgrf says so).
Tile description for the 'land area information' tool.
uint GetShare(StationID st) const
Get flow for a station.
SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32_t var10)
Resolve sprites for drawing a station tile.
constexpr bool HasExactlyOneBit(T value)
Test whether value has exactly 1 bit set.
StringID airport_name
Name of the airport.
CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags)
Checks whether the local authority allows construction of a new station (rail, road,...
Axis GetRailStationAxis(Tile t)
Get the rail direction of a rail station.
byte status
Status of this cargo, see GoodsEntryStatus.
DoCommandFlag
List of flags for a command.
@ INVALID_ROADTYPE
flag for invalid roadtype
Foundation
Enumeration for Foundations.
EdgeUpdateMode
Special modes for updating links.
uint16_t h
The height of the area.
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
uint32_t station
Count of company owned station tiles.
uint8_t time_since_pickup
Number of rating-intervals (up to 255) since the last vehicle tried to load this cargo.
Station * neutral_station
Associated neutral station.
@ TRACK_BIT_UPPER
Upper track.
const AirportFTAClass * GetAirport(const byte airport_type)
Get the finite state machine of an airport type.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
bool Succeeded() const
Did this command succeed?
TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
static uint32_t RandomRange(uint32_t limit)
Pick a random number between 0 and limit - 1, inclusive.
void Remove(const T &element)
Remove a single element from the tree, if it exists.
virtual bool TileBelongsToRailStation(TileIndex tile) const =0
Check whether a specific tile belongs to this station.
@ AAT_TILELOOP
Triggered in the periodic tile loop.
StringID string_id
Default name (town area) of station.
GameCreationSettings game_creation
settings used during the creation of a game (map)
void MakeDriveThrough()
Join this road stop to another 'base' road stop if possible; fill all necessary data to become an act...
void Clear()
Clears the 'tile area', i.e.
void RestrictFlows(StationID via)
Restrict all flows at a station for specific cargo and destination.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
@ TRACK_BIT_RIGHT
Right track.
uint GetFlowFrom(StationID from) const
Get the sum of flows from a specific station from this FlowStatMap.
Aircraft, helicopters, rotors and their shadows belong to this class.
Slope tileh
Slope of the tile.
@ ROAD_X
Full road along the x-axis (south-west + north-east)
@ SSF_SEPARATE_GROUND
Use different sprite set for ground sprites.
@ RSF_NO_CATENARY
Do not show catenary.
bool HasPowerOnRoad(RoadType enginetype, RoadType tiletype)
Checks if an engine of the given RoadType got power on a tile with a given RoadType.
Flow statistics telling how much flow should be sent along a link.
void ClearDockingTilesCheckingNeighbours(TileIndex tile)
Clear docking tile status from tiles around a removed dock, if the tile has no neighbours which would...
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner)
Change the owner of a tile.
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.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
void Queue(LinkGraph *lg)
Queue a link graph for execution.
TimerGameEconomy::Date date_of_last_service
Last economy date the vehicle had a service at a depot.
StationType
Station types.
Money RoadBuildCost(RoadType roadtype)
Returns the cost of building the specified roadtype.
PalSpriteID ground
Palette and sprite for the ground.
bool include(Container &container, typename Container::const_reference &item)
Helper function to append an item to a container if it is not already contained.
bool IsDock(Tile t)
Is tile t a dock tile?
Defines the data structure of each individual tile of an airport.
StationClassID cls_id
The class to which this spec belongs.
TimerGameCalendar::Date build_date
Date of construction of tile contents.
bool IsTruckStop(Tile t)
Is the station at t a truck stop?
StringID name
Name of this rail type.
SpriteID GetCustomRoadSprite(const RoadTypeInfo *rti, TileIndex tile, RoadTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
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...
OrderSettings order
settings related to orders
@ ROAD_Y
Full road along the y-axis (north-west + south-east)
Slope
Enumeration for the slope-type.
IterateWrapper Orders() const
Returns an iterable ensemble of orders of a vehicle.
void GetStationLayout(byte *layout, uint numtracks, uint plat_len, const StationSpec *statspec)
Create the station layout for the given number of tracks and platform length.
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.
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
struct RoadStop * next
Next stop of the given type at this station.
@ FACIL_BUS_STOP
Station with bus stops.
Direction rotation
How this airport is rotated.
CargoArray GetProductionAroundTiles(TileIndex north_tile, int w, int h, int rad)
Get the cargo types being produced around the tile (in a rectangle).
StationIDStack DeleteFlows(StationID via)
Delete all flows at a station for specific cargo and destination.
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.
void CheckForDockingTile(TileIndex t)
Mark the supplied tile as a docking tile if it is suitable for docking.
CargoID Index() const
Determines index of this cargospec.
const Direction * rotation
the rotation of each tiletable
static constexpr TimerGameEconomy::Date COMPRESSION_INTERVAL
Minimum number of days between subsequent compressions of a LG.
void MakeAirport(Tile t, Owner o, StationID sid, byte section, WaterClass wc)
Make the given tile an airport tile.
uint8_t status
Status; 0: no looping, 1: looping, 0xFF: no animation.
bool station_noise_level
build new airports when the town noise level is still within accepted limits
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.
@ TRANSPORT_RAIL
Transport by train.
CommandCost CheckOwnership(Owner owner, TileIndex tile)
Check whether the current owner owns something.
TileIndex dest_tile
Heading for this tile.
bool serve_neutral_industries
company stations can serve industries with attached neutral stations
StationGfx GetStationGfx(Tile t)
Get the station graphics of this tile.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
StationList stations
List of stations nearby.
void SetCustomStationSpecIndex(Tile t, byte specindex)
Set the custom station spec for this tile.
TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between two tiles from a TileIndexDiffC struct.
bool IsBayRoadStopTile(Tile t)
Is tile t a bay (non-drive through) road stop station?
static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCommandFlag flags)
Checks if an airport can be built at the given location and clear the area.
@ EXPENSES_CONSTRUCTION
Construction costs.
TrackedViewportSign sign
NOSAVE: Dimensions of sign.
StationList stations_near
NOSAVE: List of nearby stations.
RailType
Enumeration for all possible railtypes.
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.
@ STAT_CLASS_WAYP
Waypoint class.
void ReleaseFlows(StationID via)
Release all flows at a station for specific cargo and destination.
#define M(x)
Helper for creating a bitset of slopes.
Common return value for all commands.
byte GetSnowLine()
Get the current snow line, either variable or static.
TileArea location
Location of the industry.
@ TRACK_Y
Track along the y-axis (north-west to south-east)
WaterClass
classes of water (for WATER_TILE_CLEAR water tile type).
Track GetRailStationTrack(Tile t)
Get the rail track of a rail station tile.
static const AirportSpec * Get(byte type)
Retrieve airport spec for the given airport.
bool IsWater(Tile t)
Is it a plain water tile?
Iterable ensemble of each set bit in a value.
Track RemoveFirstTrack(TrackBits *tracks)
Removes first Track from TrackBits and returns it.
AirportClassID cls_id
the class to which this airport type belongs
Trackdir GetVehicleTrackdir() const override
Get the tracks of the train vehicle.
@ NT_ACCEPTANCE
A type of cargo is (no longer) accepted.
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.
static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
Remove an airport.
Information about GRF, used in the game and (part of it) in savegames.
void SetStationGfx(Tile t, StationGfx gfx)
Set the station graphics of this tile.
TileArea train_station
Tile area the train 'station' part covers.
@ NF_INCOLOUR
Bit value for coloured news.
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
byte num_table
number of elements in the table
void DirtyCompanyInfrastructureWindows(CompanyID company)
Redraw all windows with company infrastructure counts.
static constexpr int GetSlopeMaxZ(Slope s)
Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
std::vector< std::vector< std::vector< byte > > > layouts
Custom platform layouts.
IndustryType type
type of industry.
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
void TriggerWatchedCargoCallbacks(Station *st)
Run the watched cargo callback for all houses in the catchment area.
bool HasRating() const
Does this cargo have a rating at this station?
TileIndex tile
Current tile index.
byte pylons
Bitmask of base tiles (0 - 7) which should contain elrail pylons.
static bool FindNearIndustryName(TileIndex tile, void *user_data)
Find a station action 0 property 24 station name, or reduce the free_names if needed.
Base class for tile iterators.
bool MayHaveRoad(Tile t)
Test whether a tile can have road/tram types.
static bool CMSAMine(TileIndex tile)
Check whether the tile is a mine.
uint DistanceFromEdge(TileIndex tile)
Param the minimum distance to an edge.
void MarkTilesDirty(bool cargo_change) const
Marks the tiles of the station as dirty.
void Insert(const T &element)
Insert a single element in the tree.
StringID roadtype
Type of road on the tile.
Money GetClearCost(Price category) const
Get the cost for clearing a road stop of this type.
@ ROADSTOP_END
End of valid types.
TransportType
Available types of transport.
TrackBits GetRailReservationTrackBits(Tile t)
Returns the reserved track bits of the tile.
static CommandCost CheckFlatLandRoadStop(TileIndex cur_tile, int &allowed_z, DoCommandFlag flags, uint invalid_dirs, bool is_drive_through, bool is_truck_stop, Axis axis, StationID *station, RoadType rt)
Checks if a road stop can be built at the given tile.
@ GES_ACCEPTED_BIGTICK
Set when cargo was delivered for final delivery during the current STATION_ACCEPTANCE_TICKS interval.
Cheats _cheats
All the cheats.
const SharesMap * GetShares() const
Get the actual shares as a const pointer so that they can be iterated over.
StationID GetVia(StationID source) const
Get the best next hop for a cargo packet from station source.
@ TRACKDIR_BIT_NONE
No track build.
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
@ INVALID_OWNER
An invalid owner.
TileArea truck_station
Tile area the truck 'station' part covers.
void UpdateAirportsNoise()
Recalculate the noise generated by the airports of each town.
DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
NodeID node
ID of node in link graph referring to this goods entry.
VehicleCargoList cargo
The cargo this vehicle is carrying.
static void FreeTrainReservation(Train *v)
Clear platform reservation during station building/removing.
bool Failed() const
Did this command fail?
static RoadStop ** FindRoadStopSpot(bool truck_station, Station *st)
Order current_order
The current order (+ status, like: loading)
TileIndex GetHangarTile(uint hangar_num) const
Get the first tile of the given hangar.
@ WATER_CLASS_CANAL
Canal.
An edge in the link graph.
Airport airport
Tile area the airport covers.
Iterator to iterate over all tiles belonging to an airport spec.
Represents the covered area of e.g.
void AddFacility(StationFacility new_facility_bit, TileIndex facil_xy)
Called when new facility is built on the station.
DiagDirection AxisToDiagDir(Axis a)
Converts an Axis to a DiagDirection.
size_t MapSize() const
Count the number of ranges with equal keys in this MultiMap.
void EndSpriteCombine()
Terminates a block of sprites started by StartSpriteCombine.
uint16_t SourceID
Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
uint16_t MaxTownNoise() const
Calculate the max town noise.
bool HasStationTileRail(Tile t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
static bool CMSATree(TileIndex tile)
Check whether the tile is a tree.
uint16_t cur_speed
current speed
CargoTypes GetEmptyMask(const Station *st)
Get a mask of the cargo types that are empty at the station.
@ SRT_NEW_CARGO
Trigger station on new cargo arrival.
Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
static const AirportTileSpec * GetByTile(TileIndex tile)
Retrieve airport tile spec for the given airport tile.
TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
GameSettings _settings_game
Game settings of a running game or the scenario editor.
IndustryType indtype
Industry type to get the name from.
bool IsTileOnWater(Tile t)
Tests if the tile was built on water.
bool IsBuoyTile(Tile t)
Is tile t a buoy tile?
static const uint8_t ANIM_STATUS_NO_ANIMATION
There is no animation.
EconomySettings economy
settings to change the economy
void MakeDriveThroughRoadStop(Tile t, Owner station, Owner road, Owner tram, StationID sid, RoadStopType rst, RoadType road_rt, RoadType tram_rt, Axis a)
Make the given tile a drivethrough roadstop tile.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags)
Remove a dock.
@ TRACK_BIT_X
X-axis track.
IndustryID GetIndustryIndex(Tile t)
Get the industry ID of the given tile.
NewGRF supplied spritelayout.
StringID name
Name of this station.
@ ROTSG_ROADSTOP
Required: Bay stop surface.
CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags)
Clear a single tile of a station.
bool NeedsPreprocessing() const
Tests whether this spritelayout needs preprocessing by PrepareLayout() and ProcessRegisters(),...
static debug_inline bool IsNormalRoadTile(Tile t)
Return whether a tile is a normal road tile.
'Train' is either a loco or a wagon.
@ VEH_INVALID
Non-existing type of vehicle.
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 FreeTrainTrackReservation(const Train *v)
Free the reserved path in front of a vehicle.
bool HasTileRoadType(Tile t, RoadTramType rtt)
Check if a tile has a road or a tram road type.
SpriteID GetCanalSprite(CanalFeature feature, TileIndex tile)
Lookup the base sprite to use for a canal.
Slope GetTileSlope(TileIndex tile, int *h)
Return the slope of a given tile inside the map.
DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
TimerGameEconomy::Date LastCompression() const
Get date of last compression.
@ SPRITE_MODIFIER_CUSTOM_SPRITE
Set when a sprite originates from an Action 1.
@ NUM_AIRPORTS
Maximal number of airports in total.
std::string name
Custom name.
Ground palette sprite of a tile, together with its sprite layout.
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
void RestrictShare(StationID st)
Restrict a flow by moving it to the end of the map and decreasing the amount of unrestricted flow.
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
void StartSpriteCombine()
Starts a block of sprites, which are "combined" into a single bounding box.
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
@ RSF_DRIVE_THROUGH_ONLY
Stop is drive-through only.
TileArea bus_station
Tile area the bus 'station' part covers.
CommandCost RemoveBuoy(TileIndex tile, DoCommandFlag flags)
Remove a buoy.
uint32_t GetPlatformInfo(Axis axis, byte 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.
@ RTSG_GROUND
Main group of ground images.
int32_t TileIndexDiff
An offset value between two tiles.
byte CargoID
Cargo slots to indicate a cargo type within a game.
Coordinates of a point in 2D.
StringID station_name
Type of station within the class.
StringID name
Name of this rail type.
bool ValParamRoadType(RoadType roadtype)
Validate functions for rail building.
LinkGraphSettings linkgraph
settings for link graph calculations
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 ...
DiagDirection
Enumeration for diagonal directions.
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, byte plat_len, byte numtracks)
Calculates cost of new rail stations within the area.
uint AvailableCount() const
Returns sum of cargo still available for loading at the sation.
static const int GFX_DOCK_BASE_WATER_PART
The offset for the water parts.
@ TRACK_BIT_ALL
All possible tracks.
@ FACIL_DOCK
Station with a dock.
void OffsetGroundSprite(int x, int y)
Called when a foundation has been drawn for the current tile.
static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming name_class)
TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, TrackdirBits red_signals)
Builds a TrackStatus.
void AppendShare(StationID st, uint flow, bool restricted=false)
Add some flow to the end of the shares map.
@ CBM_STATION_AVAIL
Availability of station in construction window.
static CommandCost CalculateRoadStopCost(TileArea tile_area, DoCommandFlag flags, bool is_drive_through, bool is_truck_stop, Axis axis, DiagDirection ddir, StationID *est, RoadType rt, Money unit_cost)
Calculates cost of new road stops within the area.
static Station * From(BaseStation *st)
Converts a BaseStation to SpecializedStation with type checking.
byte station_spread
amount a station may spread
uint GetCustomRoadStopSpecIndex(Tile t)
Get the custom road stop spec for this tile.
CargoTypes always_accepted
Bitmask of always accepted cargo types (by houses, HQs, industry tiles when industry doesn't accept c...
void ShowStationViewWindow(StationID station)
Opens StationViewWindow for given station.
void AddCost(const Money &cost)
Adds the given cost to the cost of the command.
static void TruncateCargo(const CargoSpec *cs, GoodsEntry *ge, uint amount=UINT_MAX)
Truncate the cargo by a specific amount.
@ CBID_STATION_TILE_LAYOUT
Called when building a station to customize the tile layout.
bool show_track_reservation
highlight reserved tracks.
bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
byte disallowed_platforms
Bitmask of number of platforms available for the station.
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 SetStationTileRandomBits(Tile t, byte random_bits)
Set the random bits for a station tile.
void DrawRoadOverlays(const TileInfo *ti, PaletteID pal, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rti, uint road_offset, uint tram_offset, bool draw_underlay)
Draw road underlay and overlay sprites.
Set of callback functions for performing tile operations of a given tile type.
void SetAnimationFrame(Tile t, byte frame)
Set a new animation frame.
const StationList * GetStations()
Run a tile loop to find stations around a tile, on demand.
@ SAT_BUILT
Trigger tile when built.
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.
LinkGraphID link_graph
Link graph this station belongs to.
void SetTileOwner(Tile tile, Owner owner)
Sets the owner of a tile.
@ DRD_NONE
None of the directions are disallowed.
RoadStop * truck_stops
All the truck stops.
Defines the data structure for constructing industry.
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.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
constexpr uint CountBits(T value)
Counts the number of set bits in a variable.
Industry * industry
NOSAVE: Associated industry for neutral stations. (Rebuilt on load from Industry->st)
void SetStationTileBlocked(Tile t, bool b)
Set the blocked state of the rail station.
bool value
tells if the bool cheat is active or not
static void Reset(TileIndex tile=INVALID_TILE, bool from_gui=true)
Reset the OrderBackups from GUI/game logic.
@ DC_BANKRUPT
company bankrupts, skip money check, skip vehicle on tile check in some cases
Iterator to iterate over all tiles belonging to an airport.
CommandCost CmdBuildDock(DoCommandFlag flags, TileIndex tile, StationID station_to_join, bool adjacent)
Build a dock/haven.
bool IsAvailable() const
Check whether this airport is available to build.
@ RTSG_OVERLAY
Images for overlaying track.
std::set< Station *, StationCompare > StationList
List of stations.
StationType GetStationType(Tile t)
Get the station type of this tile.
void TileLoop_Water(TileIndex tile)
Let a water tile floods its diagonal adjoining tiles called from tunnelbridge_cmd,...
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.
@ FACIL_WAYPOINT
Station is a waypoint.
bool HasTileWaterClass(Tile t)
Checks whether the tile has an waterclass associated.
static debug_inline bool IsPlainRailTile(Tile t)
Checks whether the tile is a rail tile or rail tile with signals.
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 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 FindJoiningRoadStop(StationID existing_stop, StationID station_to_join, bool adjacent, TileArea ta, Station **st)
Find a nearby station that joins this road stop.
bool IsValidTile(Tile tile)
Checks if a tile is valid.
TrackBits GetTrackBits(Tile tile)
Gets the track bits of the given tile.
Direction direction
facing
uint16_t max_speed
Maximum speed for vehicles travelling on this rail type.
void AddFlow(StationID origin, StationID via, uint amount)
Add some flow from "origin", going via "via".
bool IsTileForestIndustry(TileIndex tile)
Check whether the tile is a forest.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
static constexpr TimerGameTick::Ticks STATION_LINKGRAPH_TICKS
Cycle duration for cleaning dead links.
uint DistanceMax(TileIndex t0, TileIndex t1)
Gets the biggest distance component (x or y) between the two given tiles.
SpriteID single_x
single piece of rail in X direction, without ground
byte size_x
size of airport in x direction
@ MP_TREES
Tile got trees.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
A pair-construct of a TileIndexDiff.
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
static const uint MAX_LENGTH_STATION_NAME_CHARS
The maximum length of a station name in characters including '\0'.
static debug_inline uint SizeX()
Get the size of the map along the X.
@ SSF_CUSTOM_FOUNDATIONS
Draw custom foundations.
uint16_t tram_speed
Speed limit of tram (bridges and track)
void ForAllStationsRadius(TileIndex center, uint radius, Func func)
Call a function on all stations whose sign is within a radius of a center tile.
static const SharesMap empty_sharesmap
Static instance of FlowStat::SharesMap.
bool road_stop_on_competitor_road
allow building of drive-through road stops on roads owned by competitors
void SetCustomRoadStopSpecIndex(Tile t, byte specindex)
Set the custom road stop spec for this tile.
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.
bool enabled
entity still available (by default true).newgrf can disable it, though
RoadBits GetAnyRoadBits(Tile tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance)
Returns the RoadBits on an arbitrary tile Special behaviour:
@ GES_CURRENT_MONTH
Set when cargo was delivered for final delivery this month.
@ ROADSTOP_CLASS_WAYP
Waypoint class (unimplemented: this is reserved for future use with road waypoints).
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
@ ROADSTOP_BUS
A standard stop for buses.
Point RemapCoords2(int x, int y)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap.
bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
All ships have this type.
Stores station stats for a single cargo.
CompanyID _current_company
Company currently doing an action.
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
SourceType
Types of cargo source and destination.
static void DeleteStationIfEmpty(BaseStation *st)
This is called right after a station was deleted.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
const struct SpriteGroup * spritegroup[Tcnt]
pointer to the different sprites of the entity
bool IsBuoy(Tile t)
Is tile t a buoy tile?
Vehicle * First() const
Get the first vehicle of this vehicle chain.
static int CountMapSquareAround(TileIndex tile, CMSAMatcher cmp)
Counts the numbers of tiles matching a specific type in the area around.
@ TRACK_BIT_LEFT
Left track.
uint8_t amount_fract
Fractional part of the amount in the cargo list.
NodeID AddNode(const Station *st)
Add a node to the component and create empty edges associated with it.
static size_t GetNumItems()
Returns number of valid items in the pool.
void DeleteAnimatedTile(TileIndex tile)
Removes the given tile from the animated tile table.
bool IsDockingTile(Tile t)
Checks whether the tile is marked as a dockling tile.
void ClearDriveThrough()
Prepare for removal of this stop; update other neighbouring stops if needed.
byte fallback_railtype
Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations.
CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_tile, const StationSpec *statspec, Axis axis, byte plat_len, byte numtracks)
Check the slope of a tile of a new station.
@ FACIL_TRAIN
Station with train station.
void UpdatePosition(int center, int top, StringID str, StringID str_small=STR_NULL)
Update the position of the viewport sign.
bool IsCustomStationSpecIndex(Tile t)
Is there a custom rail station spec on this tile?
bool TryPathReserve(Train *v, bool mark_as_stuck=false, bool first_tile_okay=false)
Try to reserve a path to a safe position.
static RoadVehicle * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
Town * AirportGetNearestTown(const AirportSpec *as, Direction rotation, TileIndex tile, TileIterator &&it, uint &mindist)
Finds the town nearest to given airport.
static debug_inline uint Size()
Get the size of the map.
FlowStatMap flows
Planned flows through this station.
RailTrackOffset
Offsets for sprites within an overlay/underlay set.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
StationID GetStationIndex(Tile t)
Get StationID from a tile.
@ ROADSTOP_DRAW_MODE_ROAD
Bay stops: Draw the road itself.
TileIndex tile
The base tile of the area.
bool HasStationReservation(Tile t)
Get the reservation state of the rail station.
static const uint MIN_TIMEOUT_DISTANCE
Minimum effective distance for timeout calculation.
bool build_on_slopes
allow building on slopes
@ ROTSG_OVERLAY
Optional: Images for overlaying track.
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...
@ RSRT_NEW_CARGO
Trigger roadstop on arrival of new cargo.
bool HasStationRail(Tile t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
@ RTO_X
Piece of rail in X direction.
struct GRFFileProps grf_prop
Properties related to the grf file.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
uint8_t last_age
Age in years (up to 255) of the last vehicle that tried to load this cargo.
StationGfx GetAirportGfx(Tile t)
Get the station graphics of this airport tile.
bool HasSignals(Tile t)
Checks if a rail tile has signals.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
@ OWNER_NONE
The tile has no ownership.
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.
void SetDockingTile(Tile t, bool b)
Set the docking tile state of a tile.
@ FOUNDATION_LEVELED
The tile is leveled up to a flat slope.
void UpdateVirtCoord() override
Update the virtual coords needed to draw the station sign.
bool IsRoadStop(Tile t)
Is the station at t a road station?
bool IsHangar(Tile t)
Check whether the given tile is a hangar.
@ WC_VEHICLE_DEPOT
Depot view; Window numbers:
Owner GetRoadOwner(Tile t, RoadTramType rtt)
Get the owner of a specific road type.
@ MP_STATION
A tile of a station.
Money GetBuildCost(Price category) const
Get the cost for building a road stop of this type.
static constexpr TimerGame< struct Economy >::Date INVALID_DATE
Representation of an invalid date.
GRFFileProps grf_prop
properties related to the grf file
@ GES_ACCEPTANCE
Set when the station accepts the cargo currently for final deliveries.
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
std::string cached_name
NOSAVE: Cache of the resolved name of the station, if not using a custom name.
bool kdtree_valid
Are the sign data valid for use with the _viewport_sign_kdtree?
void ForAllStationsAroundTiles(const TileArea &ta, Func func)
Call a function on all stations that have any part of the requested area within their catchment.
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
void UpdateCompanyRoadInfrastructure(RoadType rt, Owner o, int count)
Update road infrastructure counts for a company.
@ RTO_Y
Piece of rail in Y direction.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
bool HasRailCatenaryDrawn(RailType rt)
Test if we should draw rail catenary.
StationID GetVia() const
Get a station a package can be routed to.
@ DIAGDIR_BEGIN
Used for iterations.
CommandCost CmdRemoveFromRailWaypoint(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail)
Remove a single tile from a waypoint.
StringID name
Name of this class.
RoadType
The different roadtypes we support.
RoadBits GetRoadBits(Tile t, RoadTramType rtt)
Get the present road bits for a specific road type.
BitmapTileArea catchment_tiles
NOSAVE: Set of individual tiles covered by catchment area.
void Merge(LinkGraph *other)
Merge a link graph with another one.
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, byte plat_len, byte numtracks)
Checks if a rail station can be built at the given tile.
CommandCost CmdRemoveFromRailStation(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail)
Remove a single tile from a rail station.
bool IsBridgeAbove(Tile t)
checks if a bridge is set above the ground of this tile
StringID str
Description of the tile.
static void ShowRejectOrAcceptNews(const Station *st, CargoTypes cargoes, bool reject)
Add news item for when a station changes which cargoes it accepts.
StationGfx GetTranslatedAirportTileID(StationGfx gfx)
Do airporttile gfx ID translation for NewGRFs.
@ DC_AUTO
don't allow building on structures
TileIndex xy
Base tile of the station.
void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner)
Add track to signal update buffer.
Base class for all station-ish types.
uint8_t cached_anim_triggers
NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen.
bool HasStationInUse(StationID station, bool include_company, CompanyID company)
Tests whether the company's vehicles have this station in orders.
struct RoadTypeInfo::@29 strings
Strings associated with the rail type.
void SetRoadOwner(Tile t, RoadTramType rtt, Owner o)
Set the owner of a specific road type.
RoadBits
Enumeration for the road parts on a tile.
bool IsReversingRoadTrackdir(Trackdir dir)
Checks whether the trackdir means that we are reversing.
static Pool::IterateWrapper< RoadVehicle > Iterate(size_t from=0)
Returns an iterable ensemble of all valid vehicles of type T.
Track AxisToTrack(Axis a)
Convert an Axis to the corresponding Track AXIS_X -> TRACK_X AXIS_Y -> TRACK_Y Uses the fact that the...
byte delete_ctr
Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is ...
IndustryLifeType life_type
This is also known as Industry production flag, in newgrf specs.
bool ShouldStopAtStation(const Vehicle *v, StationID station) const
Check whether the given vehicle should stop at the given station based on this order and the non-stop...
uint16_t w
The width of the area.
void ErrorUnknownCallbackResult(uint32_t grfid, uint16_t cbid, uint16_t cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRandomTrigger trigger, CargoID cargo_type)
Trigger station randomisation.
bool distant_join_stations
allow to join non-adjacent stations
uint GetNumHangars() const
Get the number of hangars on this airport.
TrackBits
Allow incrementing of Track variables.
RoadStopType GetRoadStopType(Tile t)
Get the road stop type of this tile.
virtual const SpriteGroup * Resolve([[maybe_unused]] ResolverObject &object) const
Base sprite group resolver.
const DrawTileSeqStruct * seq
Array of child sprites. Terminated with a terminator entry.
uint8_t cached_roadstop_anim_triggers
NOSAVE: Combined animation trigger bitmask for road stops, used to determine if trigger processing sh...
bool adjacent_stations
allow stations to be built directly adjacent to other stations
bool IsStationTileBlocked(Tile t)
Is tile t a blocked tile?
uint16_t max_speed
Maximum speed for vehicles travelling on this road type.
byte GetAnimationFrame(Tile t)
Get the current animation frame.
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
@ ROAD_NONE
No road-part is build.
static void Run(Vehicle *v, bool allow_merge=true, bool is_full_loading=false)
Refresh all links the given vehicle will visit.
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
Container for cargo from the same location and time.
static debug_inline TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
int GetTileMaxPixelZ(TileIndex tile)
Get top height of the tile.
static Station * GetIfValid(size_t index)
Returns station if the index is a valid index for this station type.
@ CBM_ROAD_STOP_AVAIL
Availability of road stop in construction window.
struct RailTypeInfo::@23 base_sprites
Struct containing the main sprites.
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
byte type
Type of this airport,.
@ NF_SMALL
Small news item. (Information window with text and viewport)
bool IsStoppedInDepot() const
Check whether the vehicle is in the depot and stopped.
SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint layout, uint edge_info)
Resolve the sprites for custom station foundations.
void MakeRoadNormal(Tile t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
Make a normal road tile.
void DrawRailCatenary(const TileInfo *ti)
Draws overhead wires and pylons for electric railways.
bool IsShipDestinationTile(TileIndex tile, StationID station)
Test if a tile is a docking tile for the given station.
void DrawRailTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32_t total_offset, uint32_t newgrf_offset, PaletteID default_palette)
Draw tile sprite sequence on tile with railroad specifics.
static const uint NEW_AIRPORTTILE_OFFSET
offset of first newgrf airport tile
const DrawTileSeqStruct * GetLayout(PalSpriteID *ground) const
Returns the result spritelayout after preprocessing.
@ TRANSPORT_ROAD
Transport by road vehicle.
@ VETSB_ENTERED_STATION
The vehicle entered a station.
CargoID cargo_type
type of cargo this vehicle is carrying
uint max_waiting_cargo
Max cargo from this station waiting at any station.
bool IsValidCargoID(CargoID t)
Test whether cargo type is not INVALID_CARGO.
OrthogonalTileArea & Expand(int rad)
Expand a tile area by rad tiles in each direction, keeping within map bounds.
static constexpr TimerGameTick::Ticks STATION_RATING_TICKS
Cycle duration for updating station rating.
void Append(CargoPacket *cp, StationID next)
Appends the given cargo packet to the range of packets with the same next station.
@ WC_TOWN_VIEW
Town view; Window numbers:
StringID owner_type[4]
Type of each owner.
IndustryType GetIndustryType(Tile tile)
Retrieve the type for this industry.
TrackBits AxisToTrackBits(Axis a)
Maps an Axis to the corresponding TrackBits value.
RoadStop * bus_stops
All the road stops.
@ RVS_IN_DT_ROAD_STOP
The vehicle is in a drive-through road stop.
static const uint ROAD_STOP_TRACKBIT_FACTOR
Multiplier for how many regular track bits a bay stop counts.
uint16_t noise_reached
level of noise that all the airports are generating
int x
X position of the tile in unit coordinates.
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.
void Unqueue(LinkGraph *lg)
Remove a link graph from the execution queue.
PaletteID pal
The palette (use PAL_NONE) if not needed)
bool IsInUse() const
Check whether the base station currently is in use; in use means that it is not scheduled for deletio...
@ TRACK_BIT_Y
Y-axis track.
static Date date
Current date in days (day counter).
TileIndex tile
Tile index.
ConstructionSettings construction
construction of things in-game
SharesMap shares
Shares of flow to be sent via specified station (or consumed locally).
RoadBits GetAllRoadBits(Tile tile)
Get all set RoadBits on the given tile.
Trackdir
Enumeration for tracks and directions.
Cheat station_rating
Fix station ratings at 100%.
bool IsDockTile(Tile t)
Is tile t a dock tile?
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
byte nof_depots
the number of hangar tiles in this airport
CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road)
Remove bus or truck stops.
byte callback_mask
Bitmask of station callbacks that have to be called.
bool selectgoods
only send the goods to station if a train has been there
uint16_t rail_speed
Speed limit of rail (bridges and track)
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
@ VEH_TRAIN
Train vehicle type.
bool IsRailWaypoint(Tile t)
Is this station tile a rail waypoint?
virtual TileIndex GetOrderStationLocation([[maybe_unused]] StationID station)
Determine the location for the station where the vehicle goes to next.
StringID name
Displayed name of the industry.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
byte disallowed_lengths
Bitmask of platform lengths available for the station.
A Stop for a Road Vehicle.
VehicleType type
Type of vehicle.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
virtual void UpdateVirtCoord()=0
Update the coordinated of the sign (as shown in the viewport).
const struct GRFFile * grffile
grf file that introduced this entity
@ FACIL_AIRPORT
Station with an airport.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
StringID tramtype
Type of tram on the tile.
@ CBM_STATION_SPRITE_LAYOUT
Use callback to select a sprite layout to use.
StringID name
Tile Subname string, land information on this tile will give you "AirportName (TileSubname)".
void WatchedCargoCallback(TileIndex tile, CargoTypes trigger_cargoes)
Run watched cargo accepted callback for a house.
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
bool HasPowerOnRail(RailType enginetype, RailType tiletype)
Checks if an engine of the given RailType got power on a tile with a given RailType.
PersistentStorage * psa
Persistent storage for NewGRF airports.
Track
These are used to specify a single track.
const AirportSpec * GetSpec() const
Get the AirportSpec that from the airport type of this airport.
bool IsRoadStopTile(Tile t)
Is tile t a road stop station?
const AirportTileTable *const * table
list of the tiles composing the airport
static const AirportTileSpec * Get(StationGfx gfx)
Retrieve airport tile spec for the given airport tile.
void ShowDepotWindow(TileIndex tile, VehicleType type)
Opens a depot window.
@ DIAGDIR_NE
Northeast, upper right on your monitor.
@ VEH_SHIP
Ship vehicle type.
void GetTileArea(TileArea *ta, StationType type) const override
Get the tile area for a given station type.
bool IsCargoInClass(CargoID c, CargoClass cc)
Does cargo c have cargo class cc?
bool(* CMSAMatcher)(TileIndex tile)
Function to check whether the given tile matches some criterion.
@ AIRPLANES
Can planes land on this airport type?
T * Last()
Get the last vehicle in the chain.
CompanyID exclusivity
which company has exclusivity
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
bool IsTileOwner(Tile tile, Owner owner)
Checks if a tile belongs to the given owner.
GRFFileProps grf_prop
properties related the the grf file
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, WidgetID widget_index)
Mark a particular widget in a particular window as dirty (in need of repainting)
void UpdateAllStationVirtCoords()
Update the virtual coords needed to draw the station sign for all stations.
@ OWNER_WATER
The tile/execution is done by "water".
TropicZone GetTropicZone(Tile tile)
Get the tropic zone.
@ NR_STATION
Reference station. Scroll to station when clicking on the news. Delete news when station is deleted.
@ WC_STATION_LIST
Station list; Window numbers:
Order * next
Pointer to next order. If nullptr, end of list.
void ShowWaypointWindow(const Waypoint *wp)
Show the window for the given waypoint.
DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
bool HasTileWaterGround(Tile t)
Checks whether the tile has water at the ground.
@ CBID_STATION_SPRITE_LAYOUT
Choose a sprite layout to draw, instead of the standard 0-7 range.
uint ApplyPixelFoundationToSlope(Foundation f, Slope *s)
Applies a foundation to a slope.
static Station * GetClosestDeletedStation(TileIndex tile)
Find the closest deleted station of the current company.
static CommandCost FindJoiningStation(StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, Station **st)
Find a nearby station that joins this station.
@ GES_RATING
This indicates whether a cargo has a rating at the station.
bool HasVehicleEverTriedLoading() const
Reports whether a vehicle has ever tried to load the cargo at this station.
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
static constexpr TimerGameTick::Ticks STATION_ACCEPTANCE_TICKS
Cycle duration for updating station acceptance.
uint Truncate(uint max_move=UINT_MAX, StationCargoAmountMap *cargo_per_source=nullptr)
Truncates where each destination loses roughly the same percentage of its cargo.
uint32_t water
Count of company owned track bits for canals.
uint8_t exclusive_counter
months till the exclusivity expires
TileArea ship_station
Tile area the ship 'station' part covers.
bool IsAirport(Tile t)
Is this station tile an airport?
SpriteID single_y
single piece of rail in Y direction, without ground
RoadBits AxisToRoadBits(Axis a)
Create the road-part which belongs to the given Axis.
void ChangeShare(StationID st, int flow)
Change share for specified station.
VehicleEnterTileStatus
The returned bits of VehicleEnterTile.
@ FLYING
Vehicle is flying in the air.
CommandCost CmdRenameStation(DoCommandFlag flags, StationID station_id, const std::string &text)
Rename a station.
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
byte wires
Bitmask of base tiles (0 - 7) which should contain elrail wires.
static TileIndex FindDockLandPart(TileIndex t)
Find the part of a dock that is land-based.
bool road_stop_on_town_road
allow building of drive-through road stops on town owned roads
void MakeDock(Tile t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
Make the given tile a dock tile.
bool IsDriveThroughStopTile(Tile t)
Is tile t a drive through road stop station?
uint GetFlowFromVia(StationID from, StationID via) const
Get the flow from a specific station via a specific other station.
uint8_t last_speed
Maximum speed (up to 255) of the last vehicle that tried to load this cargo.
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.
@ AT_OILRIG
Oilrig airport.
Money RailBuildCost(RailType railtype)
Returns the cost of building the specified railtype.
@ RVSB_ROAD_STOP_TRACKDIR_MASK
Only bits 0 and 3 are used to encode the trackdir for road stops.
static uint SizeY()
Get the size of the map along the Y.
@ WC_VEHICLE_ORDERS
Vehicle orders; Window numbers:
GUISettings gui
settings related to the GUI
byte blocked
Bitmask of base tiles (0 - 7) which are blocked to trains.
Train * GetTrainForReservation(TileIndex tile, Track track)
Find the train which has reserved a specific path.
CommandCost CmdBuildAirport(DoCommandFlag flags, TileIndex tile, byte airport_type, byte layout, StationID station_to_join, bool allow_adjacent)
Place an Airport.
uint16_t refit_cap
Capacity left over from before last refit.
Action 2 sprite layout for houses, industry tiles, objects and airport tiles.
void MakeOilrig(Tile t, StationID sid, WaterClass wc)
Make the given tile an oilrig tile.
uint32_t rail[RAILTYPE_END]
Count of company owned track bits for each rail type.
const char * GetName() const
Get the name of this grf.
@ GES_LAST_MONTH
Set when cargo was delivered for final delivery last month.
void UpdateStationAcceptance(Station *st, bool show_msg)
Update the acceptance for a station.
SpriteID GetCustomRailSprite(const RailTypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
AnimationInfo animation
Information about the animation.
void AddAnimatedTile(TileIndex tile)
Add the given tile to the animated tile table (if it does not exist on that table yet).
uint16_t classes
Classes of this cargo type.
@ ROADSTOPTYPE_PASSENGER
This RoadStop is for passenger (bus) stops.
@ INVALID_RAILTYPE
Flag for invalid railtype.
bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
Autoslope check for tiles with an entrance on an edge.
TimerGameCalendar::Date build_date
Date of construction.
uint GetCustomStationSpecIndex(Tile t)
Get the custom station spec for this tile.
static Date date
Current date in days (day counter).
constexpr uint8_t FindFirstBit(T x)
Search the first set bit in a value.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
@ INDUSTRYLIFE_EXTRACTIVE
Like mines.