|
OpenTTD Source
14.0-beta3
|
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;
885 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;
974 if (ret.
Failed())
return ret;
993 if (*station == INVALID_STATION) {
995 }
else if (*station != st) {
1018 if (build_over_road) {
1020 RoadType road_rt = GetRoadType(cur_tile, RTT_ROAD);
1027 if (ret.
Failed())
return ret;
1035 if (ret.
Failed())
return ret;
1039 }
else if (RoadTypeIsRoad(rt)) {
1044 RoadType tram_rt = GetRoadType(cur_tile, RTT_TRAM);
1053 if (ret.
Failed())
return ret;
1060 }
else if (RoadTypeIsTram(rt)) {
1065 if (ret.
Failed())
return ret;
1100 static inline byte *CreateSingle(
byte *layout,
int n)
1103 do *layout++ = 0;
while (--i);
1104 layout[((n - 1) >> 1) - n] = 2;
1108 static inline byte *CreateMulti(
byte *layout,
int n,
byte b)
1111 do *layout++ = b;
while (--i);
1114 layout[n - 1 - n] = 0;
1128 if (statspec !=
nullptr && statspec->
layouts.size() >= plat_len &&
1129 statspec->
layouts[plat_len - 1].size() >= numtracks &&
1130 !statspec->
layouts[plat_len - 1][numtracks - 1].empty()) {
1132 memcpy(layout, statspec->
layouts[plat_len - 1][numtracks - 1].data(),
1133 static_cast<size_t>(plat_len) * numtracks);
1137 if (plat_len == 1) {
1138 CreateSingle(layout, numtracks);
1140 if (numtracks & 1) layout = CreateSingle(layout, plat_len);
1141 int n = numtracks >> 1;
1144 layout = CreateMulti(layout, plat_len, 4);
1145 layout = CreateMulti(layout, plat_len, 6);
1161 template <
class T, StringID error_message>
1164 assert(*st ==
nullptr);
1165 bool check_surrounding =
true;
1168 if (existing_station != INVALID_STATION) {
1169 if (adjacent && existing_station != station_to_join) {
1176 *st = T::GetIfValid(existing_station);
1177 check_surrounding = (*st ==
nullptr);
1182 if (adjacent) check_surrounding =
false;
1186 if (check_surrounding) {
1189 if (ret.
Failed())
return ret;
1193 if (*st ==
nullptr && station_to_join != INVALID_STATION) *st = T::GetIfValid(station_to_join);
1209 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_RAILWAY_STATION_FIRST>(existing_station, station_to_join, adjacent, ta, st);
1223 return FindJoiningBaseStation<Waypoint, STR_ERROR_MUST_REMOVE_RAILWAYPOINT_FIRST>(existing_waypoint, waypoint_to_join, adjacent, ta, wp);
1267 bool length_price_ready =
true;
1271 CommandCost ret =
CheckFlatLandRailStation(
TileArea(cur_tile, 1, 1), flags, axis, station, rt, affected_vehicles, spec_class, spec_index, plat_len, numtracks);
1272 if (ret.
Failed())
return ret;
1275 if (tracknum == numtracks) {
1276 length_price_ready =
true;
1286 cost.
AddCost(_price[PR_BUILD_STATION_RAIL]);
1289 if (length_price_ready) {
1290 cost.
AddCost(_price[PR_BUILD_STATION_RAIL_LENGTH]);
1291 length_price_ready =
false;
1317 if (ret.
Failed())
return ret;
1324 if (plat_len == 0 || numtracks == 0)
return CMD_ERROR;
1335 bool reuse = (station_to_join != NEW_STATION);
1336 if (!reuse) station_to_join = INVALID_STATION;
1337 bool distant_join = (station_to_join != INVALID_STATION);
1344 TileArea new_location(tile_org, w_org, h_org);
1347 StationID est = INVALID_STATION;
1348 std::vector<Train *> affected_vehicles;
1351 if (cost.
Failed())
return cost;
1355 if (ret.
Failed())
return ret;
1357 ret =
BuildStationPart(&st, flags, reuse, new_location, STATIONNAMING_RAIL);
1358 if (ret.
Failed())
return ret;
1362 if (ret.
Failed())
return ret;
1370 if (statspec !=
nullptr) {
1387 byte numtracks_orig;
1393 st->
rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY);
1395 if (statspec !=
nullptr) {
1404 std::vector<byte> layouts(numtracks * plat_len);
1407 numtracks_orig = numtracks;
1410 size_t layout_idx = 0;
1416 byte layout = layouts[layout_idx++];
1421 affected_vehicles.push_back(v);
1443 if (statspec !=
nullptr) {
1458 TriggerStationAnimation(st, tile,
SAT_BUILT);
1463 bool blocked = statspec !=
nullptr &&
HasBit(statspec->
blocked, gfx);
1465 bool pylons = statspec !=
nullptr ?
HasBit(statspec->
pylons, gfx) : gfx < 4;
1466 bool wires = statspec ==
nullptr || !
HasBit(statspec->
wires, gfx);
1480 }
while (--numtracks);
1482 for (uint i = 0; i < affected_vehicles.size(); ++i) {
1490 update_reservation_area =
TileArea(tile_org, 1, numtracks_orig);
1492 update_reservation_area =
TileArea(tile_org, numtracks_orig, 1);
1495 for (
TileIndex tile : update_reservation_area) {
1506 platform_begin = next_tile;
1509 platform_end = next_tile;
1513 bool reservation =
false;
1514 for (
TileIndex t = platform_begin; !reservation && t <= platform_end; t += tile_offset) {
1535 if (ta.
w != 0 && ta.
h != 0) {
1585 static void MakeRailStationAreaSmaller(
BaseStation *st)
1595 static void MakeShipStationAreaSmaller(
Station *st)
1598 UpdateStationDockingTiles(st);
1630 if (ret.
Failed())
continue;
1633 T *st = T::GetByTile(tile);
1634 if (st ==
nullptr)
continue;
1639 if (ret.
Failed())
continue;
1648 total_cost.
AddCost(-_price[PR_CLEAR_RAIL]);
1667 DoClearSquare(tile);
1673 st->rect.AfterRemoveTile(st, tile);
1679 include(affected_stations, st);
1685 if (quantity == 0)
return error.
Failed() ? error :
CommandCost(STR_ERROR_THERE_IS_NO_STATION);
1687 for (T *st : affected_stations) {
1692 MakeRailStationAreaSmaller(st);
1693 UpdateStationSignCoord(st);
1699 MarkCatchmentTilesDirty();
1705 total_cost.
AddCost(quantity * removal_cost);
1720 if (end == 0) end = start;
1724 std::vector<Station *> affected_stations;
1727 if (ret.
Failed())
return ret;
1730 for (
Station *st : affected_stations) {
1733 st->MarkTilesDirty(
false);
1734 MarkCatchmentTilesDirty();
1735 st->RecomputeCatchment();
1753 if (end == 0) end = start;
1757 std::vector<Waypoint *> affected_stations;
1777 if (ret.
Failed())
return ret;
1783 assert(ta.
w != 0 && ta.
h != 0);
1789 if (st->TileBelongsToRailStation(tile)) {
1790 std::vector<T*> affected_stations;
1792 if (ret.
Failed())
return ret;
1847 if (*primary_stop ==
nullptr) {
1849 return primary_stop;
1853 while (stop->
next !=
nullptr) stop = stop->
next;
1871 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_ROAD_STOP_FIRST>(existing_stop, station_to_join, adjacent, ta, st);
1892 uint invalid_dirs = 0;
1893 if (is_drive_through) {
1897 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) {
2149 while (pred->
next != cur_stop) pred = pred->
next;
2154 for (RoadTramType rtt : _roadtramtypes) {
2155 RoadType rt = GetRoadType(tile, rtt);
2172 DoClearSquare(tile);
2185 st->
rect.AfterRemoveTile(st, tile);
2189 st->RemoveRoadStopTileData(tile);
2190 if ((
int)specindex != replacement_spec_index) DeallocateSpecFromRoadStop(st, specindex);
2202 Price category = is_truck ? PR_CLEAR_STATION_TRUCK : PR_CLEAR_STATION_BUS;
2220 if (width == 0 || height == 0)
return CMD_ERROR;
2226 TileArea roadstop_area(tile, width, height);
2229 CommandCost last_error(STR_ERROR_THERE_IS_NO_STATION);
2230 bool had_success =
false;
2232 for (
TileIndex cur_tile : roadstop_area) {
2241 for (RoadTramType rtt : _roadtramtypes) {
2242 road_type[rtt] = GetRoadType(cur_tile, rtt);
2262 road_owner[RTT_ROAD], road_owner[RTT_TRAM]);
2271 return had_success ? cost : last_error;
2296 uint noise_reduction = distance / town_tolerance_distance;
2317 Town *nearest =
nullptr;
2320 auto height = as->
size_y;
2321 if (rotation ==
DIR_E || rotation ==
DIR_W) std::swap(width, height);
2323 uint perimeter_min_x =
TileX(tile);
2324 uint perimeter_min_y =
TileY(tile);
2325 uint perimeter_max_x = perimeter_min_x + width - 1;
2326 uint perimeter_max_y = perimeter_min_y + height - 1;
2328 mindist = UINT_MAX - 1;
2333 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) {
2335 if (t ==
nullptr)
continue;
2338 if (dist == mindist && t->
index < nearest->
index) nearest = t;
2339 if (dist < mindist) {
2388 bool reuse = (station_to_join != NEW_STATION);
2389 if (!reuse) station_to_join = INVALID_STATION;
2390 bool distant_join = (station_to_join != INVALID_STATION);
2397 if (ret.
Failed())
return ret;
2416 if (cost.
Failed())
return cost;
2424 StringID authority_refuse_message = STR_NULL;
2425 Town *authority_refuse_town =
nullptr;
2430 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE;
2431 authority_refuse_town = nearest;
2440 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
2441 authority_refuse_town = t;
2445 if (authority_refuse_message != STR_NULL) {
2451 ret =
FindJoiningStation(INVALID_STATION, station_to_join, allow_adjacent, airport_area, &st);
2452 if (ret.
Failed())
return ret;
2458 if (ret.
Failed())
return ret;
2465 cost.
AddCost(_price[PR_BUILD_STATION_AIRPORT]);
2478 st->
rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
2491 AirportTileAnimationTrigger(st, iter,
AAT_BUILT);
2521 if (ret.
Failed())
return ret;
2529 if (!a->IsNormalAircraft())
continue;
2530 if (a->targetairport == st->
index && a->state !=
FLYING) {
2555 if (!st->TileBelongsToAirport(tile_cur))
continue;
2558 if (ret.
Failed())
return ret;
2560 cost.
AddCost(_price[PR_CLEAR_STATION_AIRPORT]);
2564 DoClearSquare(tile_cur);
2604 if (ret.
Failed())
return ret;
2622 if ((v->
owner == company) == include_company) {
2624 if ((order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT)) && order->GetDestination() == station) {
2639 static const byte _dock_w_chk[4] = { 2, 1, 2, 1 };
2640 static const byte _dock_h_chk[4] = { 1, 2, 1, 2 };
2652 bool reuse = (station_to_join != NEW_STATION);
2653 if (!reuse) station_to_join = INVALID_STATION;
2654 bool distant_join = (station_to_join != INVALID_STATION);
2666 if (ret.
Failed())
return ret;
2672 if (ret.
Failed())
return ret;
2688 if (ret.
Failed())
return ret;
2689 if (add_cost) cost.
AddCost(ret);
2697 _dock_w_chk[direction], _dock_h_chk[direction]);
2701 ret =
FindJoiningStation(INVALID_STATION, station_to_join, adjacent, dock_area, &st);
2702 if (ret.
Failed())
return ret;
2708 if (ret.
Failed())
return ret;
2716 st->
rect.BeforeAddRect(dock_area.
tile, dock_area.
w, dock_area.
h, StationRect::ADD_TRY);
2728 UpdateStationDockingTiles(st);
2744 if (st !=
nullptr) UpdateStationDockingTiles(st);
2747 if (neutral !=
nullptr) UpdateStationDockingTiles(neutral);
2766 if (IsPossibleDockingTile(docking_tile)) {
2805 if (ret.
Failed())
return ret;
2815 if (ret.
Failed())
return ret;
2818 DoClearSquare(tile1);
2820 MakeWaterKeepingClass(tile2, st->
owner);
2822 st->
rect.AfterRemoveTile(st, tile1);
2823 st->
rect.AfterRemoveTile(st, tile2);
2825 MakeShipStationAreaSmaller(st);
2841 if (s->current_order.GetDestination() != st->
index) {
2856 s->SetDestTile(s->GetOrderStationLocation(st->
index));
2868 return &_station_display_datas[st][gfx];
2884 case SPR_RAIL_TRACK_X:
2885 case SPR_MONO_TRACK_X:
2886 case SPR_MGLV_TRACK_X:
2887 snow_desert =
false;
2888 *overlay_offset =
RTO_X;
2891 case SPR_RAIL_TRACK_Y:
2892 case SPR_MONO_TRACK_Y:
2893 case SPR_MGLV_TRACK_Y:
2894 snow_desert =
false;
2895 *overlay_offset =
RTO_Y;
2898 case SPR_RAIL_TRACK_X_SNOW:
2899 case SPR_MONO_TRACK_X_SNOW:
2900 case SPR_MGLV_TRACK_X_SNOW:
2902 *overlay_offset =
RTO_X;
2905 case SPR_RAIL_TRACK_Y_SNOW:
2906 case SPR_MONO_TRACK_Y_SNOW:
2907 case SPR_MGLV_TRACK_Y_SNOW:
2909 *overlay_offset =
RTO_Y;
2916 if (ti !=
nullptr) {
2932 *ground = snow_desert ? SPR_FLAT_SNOW_DESERT_TILE : SPR_FLAT_GRASS_TILE;
2936 static void DrawTile_Station(
TileInfo *ti)
2941 int32_t total_offset;
2943 uint32_t relocation = 0;
2944 uint32_t ground_relocation = 0;
2947 uint tile_layout = 0;
2958 if (statspec !=
nullptr) {
2994 case APT_RADAR_GRASS_FENCE_SW:
2997 case APT_GRASS_FENCE_NE_FLAG:
3000 case APT_RADAR_FENCE_SW:
3003 case APT_RADAR_FENCE_NE:
3006 case APT_GRASS_FENCE_NE_FLAG_2:
3016 palette = COMPANY_SPRITE_COLOUR(owner);
3019 palette = PALETTE_TO_GREY;
3022 if (layout ==
nullptr && (t ==
nullptr || t->
seq ==
nullptr)) t = GetStationTileLayout(
GetStationType(ti->
tile), gfx);
3032 if (!HasFoundationNW(ti->
tile, slope, z))
SetBit(edge_info, 0);
3033 if (!HasFoundationNE(ti->
tile, slope, z))
SetBit(edge_info, 1);
3035 if (image == 0)
goto draw_default_foundation;
3040 static const uint8_t foundation_parts[] = {
3053 static const uint8_t composite_foundation_parts[] = {
3055 0x00, 0xD1, 0xE4, 0xE0,
3057 0xCA, 0xC9, 0xC4, 0xC0,
3059 0xD2, 0x91, 0xE4, 0xA0,
3064 uint8_t parts = composite_foundation_parts[ti->
tileh];
3075 goto draw_default_foundation;
3079 for (
int i = 0; i < 8; i++) {
3090 draw_default_foundation:
3095 bool draw_ground =
false;
3098 DrawWaterClassGround(ti);
3100 if (sprite != 0) total_offset = sprite - SPR_IMG_BUOY;
3103 DrawWaterClassGround(ti);
3109 DrawShoreTile(ti->
tileh);
3111 DrawClearLandTile(ti, 3);
3115 if (layout !=
nullptr) {
3124 t = &tmp_rail_layout;
3126 }
else if (statspec !=
nullptr) {
3176 if (stopspec !=
nullptr) {
3182 if (group !=
nullptr && group->type == SGT_TILELAYOUT) {
3199 uint sprite_offset = axis ==
AXIS_X ? 1 : 0;
3201 DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset);
3206 if ((stopspec ==
nullptr || (stopspec->draw_mode &
ROADSTOP_DRAW_MODE_ROAD) != 0) && road_rti->UsesOverlay()) {
3228 int32_t total_offset = 0;
3243 DrawSprite(ground + overlay_offset, PAL_NONE, x, y);
3252 uint sprite_offset = 5 - image;
3255 if (roadtype_info->UsesOverlay()) {
3257 DrawSprite(ground + sprite_offset, PAL_NONE, x, y);
3260 if (overlay)
DrawSprite(overlay + sprite_offset, PAL_NONE, x, y);
3261 }
else if (RoadTypeIsTram(roadtype)) {
3262 DrawSprite(SPR_TRAMWAY_TRAM + sprite_offset, PAL_NONE, x, y);
3266 if (RoadTypeIsRoad(roadtype) && roadtype_info->UsesOverlay()) {
3277 static int GetSlopePixelZ_Station(
TileIndex tile, uint, uint,
bool)
3289 RoadType road_rt = GetRoadTypeRoad(tile);
3290 RoadType tram_rt = GetRoadTypeTram(tile);
3313 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER;
3314 td->
owner[i] = road_owner;
3318 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER;
3319 td->
owner[i] = tram_owner;
3329 if (spec !=
nullptr) {
3367 if (
IsRoadStop(tile)) FillTileDescRoadStop(tile, td);
3369 if (
IsAirport(tile)) FillTileDescAirport(tile, td);
3373 default: NOT_REACHED();
3374 case STATION_RAIL: str = STR_LAI_STATION_DESCRIPTION_RAILROAD_STATION;
break;
3375 case STATION_AIRPORT:
3376 str = (
IsHangar(tile) ? STR_LAI_STATION_DESCRIPTION_AIRCRAFT_HANGAR : STR_LAI_STATION_DESCRIPTION_AIRPORT);
3378 case STATION_TRUCK: str = STR_LAI_STATION_DESCRIPTION_TRUCK_LOADING_AREA;
break;
3379 case STATION_BUS: str = STR_LAI_STATION_DESCRIPTION_BUS_STATION;
break;
3380 case STATION_OILRIG: {
3388 case STATION_DOCK: str = STR_LAI_STATION_DESCRIPTION_SHIP_DOCK;
break;
3389 case STATION_BUOY: str = STR_LAI_STATION_DESCRIPTION_BUOY;
break;
3390 case STATION_WAYPOINT: str = STR_LAI_STATION_DESCRIPTION_WAYPOINT;
break;
3420 RoadTramType rtt = (RoadTramType)sub_mode;
3442 static void TileLoop_Station(
TileIndex tile)
3447 case STATION_AIRPORT:
3455 case STATION_OILRIG:
3465 static void AnimateTile_Station(
TileIndex tile)
3468 AnimateStationTile(tile);
3473 AnimateAirportTile(tile);
3478 AnimateRoadStopTile(tile);
3484 static bool ClickTile_Station(
TileIndex tile)
3528 }
else if (x < stop) {
3530 uint16_t spd = std::max(0, (stop - x) * 20 - 15);
3531 if (spd < v->cur_speed) v->
cur_speed = spd;
3554 CargoTypes cargoes = 0;
3560 if (cargoes == 0)
return;
3598 static inline void byte_inc_sat(
byte *p)
3615 StationCargoAmountMap waiting_per_source;
3617 for (StationCargoAmountMap::iterator i(waiting_per_source.begin()); i != waiting_per_source.end(); ++i) {
3619 if (source_station ==
nullptr)
continue;
3626 static void UpdateStationRating(
Station *st)
3628 bool waiting_changed =
false;
3630 byte_inc_sat(&st->time_since_load);
3631 byte_inc_sat(&st->time_since_unload);
3649 waiting_changed =
true;
3668 uint waiting_avg = waiting / (num_dests + 1);
3671 ge->
rating = rating = MAX_STATION_RATING;
3682 | (ClampTo<uint8_t>(last_speed) << 24);
3684 uint32_t var10 = (st->last_vehicle_type ==
VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10);
3688 rating =
GB(callback, 0, 14);
3691 if (
HasBit(callback, 14)) rating -= 0x4000;
3697 if (b >= 0) rating += b >> 2;
3700 if (st->last_vehicle_type ==
VEH_SHIP) waittime >>= 2;
3701 if (waittime <= 21) rating += 25;
3702 if (waittime <= 12) rating += 25;
3703 if (waittime <= 6) rating += 45;
3704 if (waittime <= 3) rating += 35;
3717 if (age < 3) rating += 10;
3718 if (age < 2) rating += 10;
3719 if (age < 1) rating += 13;
3725 ge->
rating = rating = or_ +
Clamp(ClampTo<uint8_t>(rating) - or_, -2, 2);
3729 if (rating <= 64 && waiting_avg >= 100) {
3730 int dec = Random() & 0x1F;
3731 if (waiting_avg < 200) dec &= 7;
3732 waiting -= (dec + 1) * num_dests;
3733 waiting_changed =
true;
3737 if (rating <= 127 && waiting != 0) {
3738 uint32_t r = Random();
3739 if (rating <= (
int)
GB(r, 0, 7)) {
3741 waiting = std::max((
int)waiting - (
int)((
GB(r, 8, 2) - 1) * num_dests), 0);
3742 waiting_changed =
true;
3749 static const uint WAITING_CARGO_THRESHOLD = 1 << 12;
3750 static const uint WAITING_CARGO_CUT_FACTOR = 1 << 6;
3751 static const uint MAX_WAITING_CARGO = 1 << 15;
3753 if (waiting > WAITING_CARGO_THRESHOLD) {
3754 uint difference = waiting - WAITING_CARGO_THRESHOLD;
3755 waiting -= (difference / WAITING_CARGO_CUT_FACTOR);
3757 waiting = std::min(waiting, MAX_WAITING_CARGO);
3758 waiting_changed =
true;
3763 if (waiting_changed && waiting < ge->cargo.AvailableCount()) {
3777 StationID index = st->
index;
3778 if (waiting_changed) {
3801 for (
Vehicle *v : st->loading_vehicles) {
3802 for (
Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
3803 if (u->cargo_type != c)
continue;
3804 u->cargo.Reroute(UINT_MAX, &u->cargo, avoid, avoid2, &ge);
3823 if (lg ==
nullptr)
continue;
3824 std::vector<NodeID> to_remove{};
3825 for (
Edge &edge : (*lg)[ge.
node].edges) {
3827 assert(to->
goods[c].
node == edge.dest_node);
3831 bool updated =
false;
3833 if (auto_distributed) {
3836 std::vector<Vehicle *> vehicles;
3838 bool found_from =
false;
3839 bool found_to =
false;
3840 for (
Order *order = l->GetFirstOrder(); order !=
nullptr; order = order->
next) {
3841 if (!order->IsType(OT_GOTO_STATION) && !order->IsType(OT_IMPLICIT))
continue;
3842 if (order->GetDestination() == from->
index) {
3844 if (found_to)
break;
3845 }
else if (order->GetDestination() == to->
index) {
3847 if (found_from)
break;
3850 if (!found_to || !found_from)
continue;
3851 vehicles.push_back(l->GetFirstSharedVehicle());
3854 auto iter = vehicles.begin();
3855 while (iter != vehicles.end()) {
3868 *iter = next_shared;
3871 iter = vehicles.erase(iter);
3874 if (iter == vehicles.end()) iter = vehicles.begin();
3880 to_remove.emplace_back(to->
goods[c].
node);
3893 for (NodeID r : to_remove) (*lg)[ge.
node].RemoveEdge(r);
3925 Debug(misc, 0,
"Can't allocate link graph");
3934 }
else if (ge2.
link_graph == INVALID_LINK_GRAPH) {
3952 if (lg !=
nullptr) {
3953 (*lg)[ge1.
node].UpdateEdge(ge2.
node, capacity, usage, time, mode);
3965 for (
const Vehicle *v = front; v !=
nullptr; v = v->
Next()) {
3980 static void StationHandleSmallTick(
BaseStation *st)
3991 void OnTick_Station()
3993 if (_game_mode == GM_EDITOR)
return;
3996 StationHandleSmallTick(st);
4029 void ModifyStationRatingAround(
TileIndex tile,
Owner owner,
int amount, uint radius)
4033 for (GoodsEntry &ge : st->goods) {
4034 if (ge.status != 0) {
4035 ge.rating = ClampTo<uint8_t>(ge.rating + amount);
4054 if (amount == 0)
return 0;
4066 Debug(misc, 0,
"Can't allocate link graph");
4071 if (lg !=
nullptr) (*lg)[ge.
node].UpdateSupply(amount);
4090 static bool IsUniqueStationName(
const std::string &name)
4093 if (!st->
name.empty() && st->
name == name)
return false;
4112 if (ret.
Failed())
return ret;
4114 bool reset = text.empty();
4118 if (!IsUniqueStationName(text))
return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
4139 if (st->TileIsInCatchment(tile)) stations->insert(st);
4152 assert(this->
w == 1 && this->
h == 1);
4153 AddNearbyStationsByCatchment(this->tile, &this->stations, Town::GetByTile(this->tile)->stations_near);
4156 this->stations.insert(st);
4166 static bool CanMoveGoodsToStation(
const Station *st,
CargoID type)
4190 if (all_stations->empty())
return 0;
4191 if (amount == 0)
return 0;
4193 Station *first_station =
nullptr;
4194 typedef std::pair<Station *, uint> StationInfo;
4195 std::vector<StationInfo> used_stations;
4197 for (
Station *st : *all_stations) {
4199 if (!CanMoveGoodsToStation(st, type))
continue;
4203 if (first_station ==
nullptr) {
4207 if (used_stations.empty()) {
4208 used_stations.reserve(2);
4209 used_stations.emplace_back(std::make_pair(first_station, 0));
4211 used_stations.emplace_back(std::make_pair(st, 0));
4215 if (first_station ==
nullptr)
return 0;
4217 if (used_stations.empty()) {
4220 return UpdateStationWaiting(first_station, type, amount, source_type, source_id);
4225 uint best_rating = 0;
4228 for (
auto &p : used_stations) {
4229 auto owner = p.first->owner;
4230 auto rating = p.first->goods[type].rating;
4231 if (rating > company_best[owner]) {
4232 best_sum += rating - company_best[owner];
4233 company_best[owner] = rating;
4234 if (rating > best_rating) best_rating = rating;
4236 company_sum[owner] += rating;
4241 amount *= best_rating + 1;
4244 for (
auto &p : used_stations) {
4245 uint owner = p.first->owner;
4248 p.second = amount * company_best[owner] * p.first->goods[type].rating / best_sum / company_sum[owner];
4253 if (amount > moving) {
4254 std::stable_sort(used_stations.begin(), used_stations.end(), [type](
const StationInfo &a,
const StationInfo &b) {
4255 return b.first->goods[type].rating < a.first->goods[type].rating;
4258 assert(amount - moving <= used_stations.size());
4259 for (uint i = 0; i < amount - moving; i++) {
4260 used_stations[i].second++;
4265 for (
auto &p : used_stations) {
4266 moved += UpdateStationWaiting(p.first, type, p.second, source_type, source_id);
4272 void UpdateStationDockingTiles(
Station *st)
4286 int x2 = std::min<int>(x + area->
w + 1,
Map::SizeX());
4287 int x1 = std::max<int>(x - 1, 0);
4289 int y2 = std::min<int>(y + area->
h + 1,
Map::SizeY());
4290 int y1 = std::max<int>(y - 1, 0);
4301 Debug(misc, 0,
"Can't allocate station for oilrig at 0x{:X}, reverting to oilrig only", tile);
4324 UpdateStationDockingTiles(st);
4326 st->
rect.BeforeAddTile(tile, StationRect::ADD_FORCE);
4351 for (RoadTramType rtt : _roadtramtypes) {
4354 RoadType rt = GetRoadType(tile, rtt);
4378 case STATION_WAYPOINT:
4469 case STATION_WAYPOINT:
return_cmd_error(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
4470 case STATION_AIRPORT:
return_cmd_error(STR_ERROR_MUST_DEMOLISH_AIRPORT_FIRST);
4471 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);
4472 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);
4475 case STATION_OILRIG:
4476 SetDParam(1, STR_INDUSTRY_NAME_OIL_RIG);
4495 case STATION_BUOY:
return RemoveBuoy(tile, flags);
4496 case STATION_DOCK:
return RemoveDock(tile, flags);
4511 case STATION_WAYPOINT:
4512 case STATION_RAIL: {
4519 case STATION_AIRPORT:
4547 for (
const auto &it : this->
shares) {
4548 if (it.second == st) {
4549 return it.first - prev;
4566 assert(!this->
shares.empty());
4568 assert(it != this->
shares.end() && it->first <= this->unrestricted);
4569 if (it->second != excluded && it->second != excluded2)
return it->second;
4574 uint end = it->first;
4575 uint begin = (it == this->
shares.begin() ? 0 : (--it)->first);
4576 uint interval = end - begin;
4577 if (interval >= this->
unrestricted)
return INVALID_STATION;
4580 SharesMap::const_iterator it2 = (rand < begin) ? this->
shares.upper_bound(rand) :
4581 this->
shares.upper_bound(rand + interval);
4582 assert(it2 != this->
shares.end() && it2->first <= this->unrestricted);
4583 if (it2->second != excluded && it2->second != excluded2)
return it2->second;
4588 uint end2 = it2->first;
4589 uint begin2 = (it2 == this->
shares.begin() ? 0 : (--it2)->first);
4590 uint interval2 = end2 - begin2;
4591 if (interval2 >= new_max)
return INVALID_STATION;
4592 new_max -= interval2;
4593 if (begin > begin2) {
4594 Swap(begin, begin2);
4596 Swap(interval, interval2);
4601 it3 = this->
shares.upper_bound(rand);
4602 }
else if (rand < begin2 - interval) {
4603 it3 = this->
shares.upper_bound(rand + interval);
4605 it3 = this->
shares.upper_bound(rand + interval + interval2);
4607 assert(it3 != this->
shares.end() && it3->first <= this->unrestricted);
4618 assert(!this->
shares.empty());
4619 SharesMap new_shares;
4621 for (
const auto &it : this->
shares) {
4622 new_shares[++i] = it.second;
4623 if (it.first == this->unrestricted) this->
unrestricted = i;
4625 this->shares.swap(new_shares);
4626 assert(!this->shares.empty() && this->unrestricted <= (--this->shares.end())->first);
4639 assert(!this->
shares.empty());
4641 uint removed_shares = 0;
4642 uint added_shares = 0;
4643 uint last_share = 0;
4644 SharesMap new_shares;
4645 for (
const auto &it : this->
shares) {
4646 if (it.second == st) {
4648 uint share = it.first - last_share;
4649 if (flow == INT_MIN || (uint)(-flow) >= share) {
4650 removed_shares += share;
4651 if (it.first <= this->unrestricted) this->
unrestricted -= share;
4652 if (flow != INT_MIN) flow += share;
4653 last_share = it.first;
4656 removed_shares += (uint)(-flow);
4658 added_shares += (uint)(flow);
4660 if (it.first <= this->unrestricted) this->
unrestricted += flow;
4666 new_shares[it.first + added_shares - removed_shares] = it.second;
4667 last_share = it.first;
4670 new_shares[last_share + (uint)flow] = st;
4677 this->shares.swap(new_shares);
4687 assert(!this->
shares.empty());
4689 uint last_share = 0;
4690 SharesMap new_shares;
4691 for (
auto &it : this->
shares) {
4693 if (it.first > this->unrestricted)
return;
4694 if (it.second == st) {
4695 flow = it.first - last_share;
4698 new_shares[it.first] = it.second;
4701 new_shares[it.first - flow] = it.second;
4703 last_share = it.first;
4705 if (flow == 0)
return;
4706 new_shares[last_share + flow] = st;
4707 this->shares.swap(new_shares);
4708 assert(!this->shares.empty());
4718 assert(!this->
shares.empty());
4720 uint next_share = 0;
4722 for (SharesMap::reverse_iterator it(this->
shares.rbegin()); it != this->shares.rend(); ++it) {
4723 if (it->first < this->unrestricted)
return;
4725 flow = next_share - it->first;
4729 if (it->first == this->unrestricted)
return;
4730 if (it->second == st) found =
true;
4732 next_share = it->first;
4734 if (flow == 0)
return;
4735 SharesMap new_shares;
4736 new_shares[flow] = st;
4737 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4738 if (it->second != st) {
4739 new_shares[flow + it->first] = it->second;
4744 this->
shares.swap(new_shares);
4745 assert(!this->
shares.empty());
4755 assert(runtime > 0);
4756 SharesMap new_shares;
4758 for (
auto i : this->
shares) {
4759 share = std::max(share + 1, i.first * 30 / runtime);
4760 new_shares[share] = i.second;
4763 this->shares.swap(new_shares);
4774 FlowStatMap::iterator origin_it = this->find(origin);
4775 if (origin_it == this->end()) {
4776 this->insert(std::make_pair(origin,
FlowStat(via, flow)));
4778 origin_it->second.ChangeShare(via, flow);
4779 assert(!origin_it->second.GetShares()->empty());
4793 FlowStatMap::iterator prev_it = this->find(origin);
4794 if (prev_it == this->end()) {
4797 this->insert(std::make_pair(origin, fs));
4799 prev_it->second.ChangeShare(via, flow);
4800 prev_it->second.ChangeShare(INVALID_STATION, flow);
4801 assert(!prev_it->second.GetShares()->empty());
4811 for (
auto &i : *
this) {
4813 uint local = fs.
GetShare(INVALID_STATION);
4814 if (local > INT_MAX) {
4837 for (FlowStatMap::iterator f_it = this->begin(); f_it != this->end();) {
4841 ret.
Push(f_it->first);
4842 this->erase(f_it++);
4856 for (
auto &it : *
this) {
4857 it.second.RestrictShare(via);
4867 for (
auto &it : *
this) {
4868 it.second.ReleaseShare(via);
4879 for (
const auto &it : *
this) {
4880 ret += (--(it.second.GetShares()->end()))->first;
4893 for (
const auto &it : *
this) {
4894 ret += it.second.GetShare(via);
4906 FlowStatMap::const_iterator i = this->find(from);
4907 if (i == this->end())
return 0;
4908 return (--(i->second.GetShares()->end()))->first;
4919 FlowStatMap::const_iterator i = this->find(from);
4920 if (i == this->end())
return 0;
4921 return i->second.GetShare(via);
4926 GetSlopePixelZ_Station,
4929 GetTileDesc_Station,
4930 GetTileTrackStatus_Station,
4932 AnimateTile_Station,
4934 ChangeTileOwner_Station,
4936 VehicleEnter_Station,
4937 GetFoundation_Station,
4938 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 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.
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.
@ 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.
static CommandCost CheckFlatLandRoadStop(TileArea tile_area, 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.
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:
static CommandCost CheckFlatLandRailStation(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)
Checks if a rail station can be built at the given area.
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.
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.
static bool CanRemoveRoadWithStop(TileIndex tile, DoCommandFlag flags)
Check if a drive-through road stop tile can be cleared.
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 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.
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.