Go to the documentation of this file.
14 #include "viewport_kdtree.h"
63 #include "table/strings.h"
114 if (!T::IsValidID(t) ||
Station::Get(t)->owner != company)
continue;
115 if (closest_station == INVALID_STATION) {
117 }
else if (closest_station != t) {
122 *st = (closest_station == INVALID_STATION) ?
nullptr : T::Get(closest_station);
143 for (
int dx = -3; dx <= 3; dx++) {
144 for (
int dy = -3; dy <= 3; dy++) {
200 #define M(x) ((x) - STR_SV_STNAME)
205 STATIONNAMING_AIRPORT,
206 STATIONNAMING_OILRIG,
208 STATIONNAMING_HELIPORT,
233 if (
GetIndustrySpec(indtype)->station_name == STR_UNDEFINED)
return false;
237 sni->
free_names &= ~(1 << M(STR_SV_STNAME_OILFIELD) | 1 << M(STR_SV_STNAME_MINES));
243 static const uint32 _gen_station_name_bits[] = {
246 1U << M(STR_SV_STNAME_AIRPORT),
247 1U << M(STR_SV_STNAME_OILFIELD),
248 1U << M(STR_SV_STNAME_DOCKS),
249 1U << M(STR_SV_STNAME_HELIPORT),
253 uint32 free_names = UINT32_MAX;
256 memset(indtypes, 0,
sizeof(indtypes));
259 if (s != st && s->town == t) {
260 if (s->indtype != IT_INVALID) {
261 indtypes[s->indtype] =
true;
263 if (name != STR_UNDEFINED) {
272 uint str = M(s->string_id);
274 if (str == M(STR_SV_STNAME_FOREST)) {
275 str = M(STR_SV_STNAME_WOODS);
291 return STR_SV_STNAME_FALLBACK;
299 uint32 tmp = free_names & _gen_station_name_bits[name_class];
303 if (
HasBit(free_names, M(STR_SV_STNAME_MINES))) {
305 return STR_SV_STNAME_MINES;
311 if (
HasBit(free_names, M(STR_SV_STNAME)))
return STR_SV_STNAME;
313 if (
HasBit(free_names, M(STR_SV_STNAME_CENTRAL)))
return STR_SV_STNAME_CENTRAL;
317 if (
HasBit(free_names, M(STR_SV_STNAME_LAKESIDE)) &&
320 return STR_SV_STNAME_LAKESIDE;
324 if (
HasBit(free_names, M(STR_SV_STNAME_WOODS)) && (
335 if (
HasBit(free_names, M(STR_SV_STNAME_VALLEY)))
return STR_SV_STNAME_VALLEY;
337 if (
HasBit(free_names, M(STR_SV_STNAME_HEIGHTS)))
return STR_SV_STNAME_HEIGHTS;
341 static const int8 _direction_and_table[] = {
342 ~( (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
343 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
344 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
345 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) ),
348 free_names &= _direction_and_table[
352 tmp = free_names & ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 6) | (1 << 7) | (1 << 12) | (1 << 26) | (1 << 27) | (1 << 28) | (1 << 29) | (1 << 30));
353 return (tmp == 0) ? STR_SV_STNAME_FALLBACK : (STR_SV_STNAME +
FindFirstBit(tmp));
366 Station *best_station =
nullptr;
369 uint cur_dist = DistanceManhattan(tile, st->xy);
371 if (cur_dist < threshold) {
372 threshold = cur_dist;
374 }
else if (cur_dist == threshold && best_station !=
nullptr) {
376 if (st->
index < best_station->
index) best_station = st;
392 case STATION_AIRPORT:
409 default: NOT_REACHED();
420 pt.y -= 32 * ZOOM_LVL_BASE;
427 this->
sign.
UpdatePosition(pt.x, pt.y, STR_VIEWPORT_STATION, STR_VIEWPORT_STATION_TINY);
429 _viewport_sign_kdtree.
Insert(ViewportSignKdtreeItem::MakeStation(this->
index));
440 if (this->
xy == new_xy)
return;
444 this->BaseStation::MoveSign(new_xy);
457 void BaseStation::FillCachedName()
const
460 int64 args_array[] = { this->
index };
466 void ClearAllStationCachedNames()
494 for (uint i = 0; i < num_items; i++) {
512 std::set<IndustryID> industries;
519 AddProducedCargo(tile, produced);
525 for (IndustryID industry : industries) {
551 if (always_accepted !=
nullptr) *always_accepted = 0;
559 AddAcceptedCargo(tile, acceptance, always_accepted);
573 if (always_accepted !=
nullptr) *always_accepted = 0;
577 AddAcceptedCargo(tile, acceptance, always_accepted);
595 if (!st->
rect.IsEmpty()) {
601 uint amt = acceptance[i];
619 if (old_acc == new_acc)
return;
625 static const StringID accept_msg[] = {
626 STR_NEWS_STATION_NOW_ACCEPTS_CARGO,
627 STR_NEWS_STATION_NOW_ACCEPTS_CARGO_AND_CARGO,
629 static const StringID reject_msg[] = {
630 STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO,
631 STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_OR_CARGO,
645 accepts[num_acc++] = i;
650 rejects[num_rej++] = i;
664 static void UpdateStationSignCoord(
BaseStation *st)
668 if (r->IsEmpty())
return;
672 st->MoveSign(new_xy);
697 if (*st !=
nullptr) {
702 CommandCost ret = (*st)->rect.BeforeAddRect(area.
tile, area.
w, area.
h, StationRect::ADD_TEST);
703 if (ret.
Failed())
return ret;
710 _station_kdtree.
Insert((*st)->index);
713 (*st)->string_id = GenerateStationName(*st, area.
tile, name_class);
736 UpdateStationSignCoord(st);
751 MarkCatchmentTilesDirty();
754 MarkCatchmentTilesDirty();
761 case STATION_AIRPORT:
770 default: NOT_REACHED();
801 if (ret.
Failed())
return ret;
824 cost.
AddCost(_price[PR_BUILD_FOUNDATION]);
831 }
else if (allowed_z != flat_z) {
851 if (ret.
Failed())
return ret;
855 if (ret.
Failed())
return ret;
880 uint invalid_dirs = 5 << axis;
887 if (ret.
Failed())
return ret;
893 if (ret.
Failed())
return ret;
904 if (*station == INVALID_STATION) {
906 }
else if (*station != st) {
931 affected_vehicles.push_back(v);
935 if (ret.
Failed())
return ret;
942 if (ret.
Failed())
return ret;
969 if (ret.
Failed())
return ret;
988 if (*station == INVALID_STATION) {
990 }
else if (*station != st) {
1013 if (build_over_road) {
1015 RoadType road_rt = GetRoadType(cur_tile, RTT_ROAD);
1022 if (ret.
Failed())
return ret;
1030 if (ret.
Failed())
return ret;
1034 }
else if (RoadTypeIsRoad(rt)) {
1039 RoadType tram_rt = GetRoadType(cur_tile, RTT_TRAM);
1048 if (ret.
Failed())
return ret;
1055 }
else if (RoadTypeIsTram(rt)) {
1060 if (ret.
Failed())
return ret;
1096 static inline byte *CreateSingle(
byte *layout,
int n)
1099 do *layout++ = 0;
while (--i);
1100 layout[((n - 1) >> 1) - n] = 2;
1104 static inline byte *CreateMulti(
byte *layout,
int n,
byte b)
1107 do *layout++ = b;
while (--i);
1110 layout[n - 1 - n] = 0;
1124 if (statspec !=
nullptr && statspec->
layouts.size() >= plat_len &&
1125 statspec->
layouts[plat_len - 1].size() >= numtracks &&
1126 !statspec->
layouts[plat_len - 1][numtracks - 1].empty()) {
1128 memcpy(layout, statspec->
layouts[plat_len - 1][numtracks - 1].data(),
1129 plat_len * numtracks);
1133 if (plat_len == 1) {
1134 CreateSingle(layout, numtracks);
1136 if (numtracks & 1) layout = CreateSingle(layout, plat_len);
1137 int n = numtracks >> 1;
1140 layout = CreateMulti(layout, plat_len, 4);
1141 layout = CreateMulti(layout, plat_len, 6);
1157 template <
class T, StringID error_message>
1160 assert(*st ==
nullptr);
1161 bool check_surrounding =
true;
1164 if (existing_station != INVALID_STATION) {
1165 if (adjacent && existing_station != station_to_join) {
1172 *st = T::GetIfValid(existing_station);
1173 check_surrounding = (*st ==
nullptr);
1178 if (adjacent) check_surrounding =
false;
1182 if (check_surrounding) {
1185 if (ret.
Failed())
return ret;
1189 if (*st ==
nullptr && station_to_join != INVALID_STATION) *st = T::GetIfValid(station_to_join);
1205 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_RAILWAY_STATION_FIRST>(existing_station, station_to_join, adjacent, ta, st);
1219 return FindJoiningBaseStation<Waypoint, STR_ERROR_MUST_REMOVE_RAILWAYPOINT_FIRST>(existing_waypoint, waypoint_to_join, adjacent, ta, wp);
1264 if (ret.
Failed())
return ret;
1271 if (plat_len == 0 || numtracks == 0)
return CMD_ERROR;
1282 bool reuse = (station_to_join != NEW_STATION);
1283 if (!reuse) station_to_join = INVALID_STATION;
1284 bool distant_join = (station_to_join != INVALID_STATION);
1291 TileArea new_location(tile_org, w_org, h_org);
1294 StationID est = INVALID_STATION;
1295 std::vector<Train *> affected_vehicles;
1298 if (cost.
Failed())
return cost;
1300 cost.
AddCost((numtracks * _price[PR_BUILD_STATION_RAIL] + _price[PR_BUILD_STATION_RAIL_LENGTH]) * plat_len);
1305 if (ret.
Failed())
return ret;
1307 ret =
BuildStationPart(&st, flags, reuse, new_location, STATIONNAMING_RAIL);
1308 if (ret.
Failed())
return ret;
1312 if (ret.
Failed())
return ret;
1320 if (statspec !=
nullptr) {
1338 byte numtracks_orig;
1344 st->
rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY);
1346 if (statspec !=
nullptr) {
1355 layout_ptr =
AllocaM(
byte, numtracks * plat_len);
1358 numtracks_orig = numtracks;
1366 byte layout = *layout_ptr++;
1371 affected_vehicles.push_back(v);
1396 if (statspec !=
nullptr) {
1411 TriggerStationAnimation(st, tile,
SAT_BUILT);
1419 }
while (--numtracks);
1421 for (uint i = 0; i < affected_vehicles.size(); ++i) {
1429 update_reservation_area =
TileArea(tile_org, 1, numtracks_orig);
1431 update_reservation_area =
TileArea(tile_org, numtracks_orig, 1);
1434 for (
TileIndex tile : update_reservation_area) {
1445 platform_begin = next_tile;
1448 platform_end = next_tile;
1452 bool reservation =
false;
1453 for (
TileIndex t = platform_begin; !reservation && t <= platform_end; t += tile_offset) {
1474 if (ta.
w != 0 && ta.
h != 0) {
1524 static void MakeRailStationAreaSmaller(
BaseStation *st)
1534 static void MakeShipStationAreaSmaller(
Station *st)
1537 UpdateStationDockingTiles(st);
1569 if (ret.
Failed())
continue;
1572 T *st = T::GetByTile(tile);
1573 if (st ==
nullptr)
continue;
1578 if (ret.
Failed())
continue;
1587 total_cost.
AddCost(-_price[PR_CLEAR_RAIL]);
1606 DoClearSquare(tile);
1612 st->rect.AfterRemoveTile(st, tile);
1618 include(affected_stations, st);
1626 for (T *st : affected_stations) {
1631 MakeRailStationAreaSmaller(st);
1632 UpdateStationSignCoord(st);
1638 MarkCatchmentTilesDirty();
1644 total_cost.
AddCost(quantity * removal_cost);
1659 if (end == 0) end = start;
1663 std::vector<Station *> affected_stations;
1666 if (ret.
Failed())
return ret;
1669 for (
Station *st : affected_stations) {
1672 st->MarkTilesDirty(
false);
1673 MarkCatchmentTilesDirty();
1674 st->RecomputeCatchment();
1692 if (end == 0) end = start;
1696 std::vector<Waypoint *> affected_stations;
1716 if (ret.
Failed())
return ret;
1722 assert(ta.
w != 0 && ta.
h != 0);
1728 if (st->TileBelongsToRailStation(tile)) {
1729 std::vector<T*> affected_stations;
1731 if (ret.
Failed())
return ret;
1786 if (*primary_stop ==
nullptr) {
1788 return primary_stop;
1792 while (stop->
next !=
nullptr) stop = stop->
next;
1810 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_ROAD_STOP_FIRST>(existing_stop, station_to_join, adjacent, ta, st);
1830 bool reuse = (station_to_join != NEW_STATION);
1831 if (!reuse) station_to_join = INVALID_STATION;
1832 bool distant_join = (station_to_join != INVALID_STATION);
1837 if (width == 0 || length == 0)
return CMD_ERROR;
1841 TileArea roadstop_area(tile, width, length);
1846 if (!is_drive_through && RoadTypeIsTram(rt))
return CMD_ERROR;
1851 if (ret.
Failed())
return ret;
1857 StationID est = INVALID_STATION;
1858 ret =
CheckFlatLandRoadStop(roadstop_area, flags, is_drive_through ? 5 << axis : 1 << ddir, is_drive_through, is_truck_stop, axis, &est, rt);
1859 if (ret.
Failed())
return ret;
1864 if (ret.
Failed())
return ret;
1869 ret =
BuildStationPart(&st, flags, reuse, roadstop_area, STATIONNAMING_ROAD);
1870 if (ret.
Failed())
return ret;
1874 for (
TileIndex cur_tile : roadstop_area) {
1888 *currstop = road_stop;
1890 if (is_truck_stop) {
1899 st->
rect.BeforeAddTile(cur_tile, StationRect::ADD_TRY);
1902 if (is_drive_through) {
1927 if (st !=
nullptr) {
1964 if (ret.
Failed())
return ret;
1979 assert(cur_stop !=
nullptr);
1987 if (ret.
Failed())
return ret;
1991 if (*primary_stop == cur_stop) {
1993 *primary_stop = cur_stop->
next;
1995 if (*primary_stop ==
nullptr) {
2001 while (pred->
next != cur_stop) pred = pred->
next;
2006 for (RoadTramType rtt : _roadtramtypes) {
2007 RoadType rt = GetRoadType(tile, rtt);
2018 DoClearSquare(tile);
2031 st->
rect.AfterRemoveTile(st, tile);
2062 if (width == 0 || height == 0)
return CMD_ERROR;
2068 TileArea roadstop_area(tile, width, height);
2071 CommandCost last_error(STR_ERROR_THERE_IS_NO_STATION);
2072 bool had_success =
false;
2074 for (
TileIndex cur_tile : roadstop_area) {
2083 for (RoadTramType rtt : _roadtramtypes) {
2084 road_type[rtt] = GetRoadType(cur_tile, rtt);
2104 road_owner[RTT_ROAD], road_owner[RTT_TRAM]);
2113 return had_success ? cost : last_error;
2138 uint noise_reduction = distance / town_tolerance_distance;
2157 Town *nearest =
nullptr;
2159 uint perimeter_min_x =
TileX(it);
2160 uint perimeter_min_y =
TileY(it);
2161 uint perimeter_max_x = perimeter_min_x + as->
size_x - 1;
2162 uint perimeter_max_y = perimeter_min_y + as->
size_y - 1;
2164 mindist = UINT_MAX - 1;
2166 std::unique_ptr<TileIterator> copy(it.
Clone());
2168 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) {
2170 if (t ==
nullptr)
continue;
2173 if (dist == mindist && t->
index < nearest->
index) nearest = t;
2174 if (dist < mindist) {
2213 bool reuse = (station_to_join != NEW_STATION);
2214 if (!reuse) station_to_join = INVALID_STATION;
2215 bool distant_join = (station_to_join != INVALID_STATION);
2222 if (ret.
Failed())
return ret;
2241 if (cost.
Failed())
return cost;
2249 StringID authority_refuse_message = STR_NULL;
2250 Town *authority_refuse_town =
nullptr;
2255 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE;
2256 authority_refuse_town = nearest;
2265 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
2266 authority_refuse_town = t;
2270 if (authority_refuse_message != STR_NULL) {
2276 ret =
FindJoiningStation(INVALID_STATION, station_to_join, allow_adjacent, airport_area, &st);
2277 if (ret.
Failed())
return ret;
2283 if (ret.
Failed())
return ret;
2290 cost.
AddCost(_price[PR_BUILD_STATION_AIRPORT]);
2303 st->
rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
2315 AirportTileAnimationTrigger(st, iter,
AAT_BUILT);
2345 if (ret.
Failed())
return ret;
2353 if (!a->IsNormalAircraft())
continue;
2354 if (a->targetairport == st->
index && a->state !=
FLYING) {
2381 if (!st->TileBelongsToAirport(tile_cur))
continue;
2384 if (ret.
Failed())
return ret;
2386 cost.
AddCost(_price[PR_CLEAR_STATION_AIRPORT]);
2390 DoClearSquare(tile_cur);
2430 if (ret.
Failed())
return ret;
2448 if ((v->
owner == company) == include_company) {
2450 if ((order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT)) && order->GetDestination() == station) {
2465 static const byte _dock_w_chk[4] = { 2, 1, 2, 1 };
2466 static const byte _dock_h_chk[4] = { 1, 2, 1, 2 };
2478 bool reuse = (station_to_join != NEW_STATION);
2479 if (!reuse) station_to_join = INVALID_STATION;
2480 bool distant_join = (station_to_join != INVALID_STATION);
2492 if (ret.
Failed())
return ret;
2498 if (ret.
Failed())
return ret;
2514 if (ret.
Failed())
return ret;
2515 if (add_cost) cost.
AddCost(ret);
2523 _dock_w_chk[direction], _dock_h_chk[direction]);
2527 ret =
FindJoiningStation(INVALID_STATION, station_to_join, adjacent, dock_area, &st);
2528 if (ret.
Failed())
return ret;
2534 if (ret.
Failed())
return ret;
2542 st->
rect.BeforeAddRect(dock_area.
tile, dock_area.
w, dock_area.
h, StationRect::ADD_TRY);
2554 UpdateStationDockingTiles(st);
2570 if (st !=
nullptr) UpdateStationDockingTiles(st);
2573 if (neutral !=
nullptr) UpdateStationDockingTiles(neutral);
2592 if (IsPossibleDockingTile(docking_tile)) {
2645 if (ret.
Failed())
return ret;
2655 if (ret.
Failed())
return ret;
2658 DoClearSquare(tile1);
2660 MakeWaterKeepingClass(tile2, st->
owner);
2662 st->
rect.AfterRemoveTile(st, tile1);
2663 st->
rect.AfterRemoveTile(st, tile2);
2665 MakeShipStationAreaSmaller(st);
2681 if (s->current_order.GetDestination() != st->
index) {
2696 s->SetDestTile(s->GetOrderStationLocation(st->
index));
2708 return &_station_display_datas[st][gfx];
2724 case SPR_RAIL_TRACK_X:
2725 case SPR_MONO_TRACK_X:
2726 case SPR_MGLV_TRACK_X:
2727 snow_desert =
false;
2728 *overlay_offset =
RTO_X;
2731 case SPR_RAIL_TRACK_Y:
2732 case SPR_MONO_TRACK_Y:
2733 case SPR_MGLV_TRACK_Y:
2734 snow_desert =
false;
2735 *overlay_offset =
RTO_Y;
2738 case SPR_RAIL_TRACK_X_SNOW:
2739 case SPR_MONO_TRACK_X_SNOW:
2740 case SPR_MGLV_TRACK_X_SNOW:
2742 *overlay_offset =
RTO_X;
2745 case SPR_RAIL_TRACK_Y_SNOW:
2746 case SPR_MONO_TRACK_Y_SNOW:
2747 case SPR_MGLV_TRACK_Y_SNOW:
2749 *overlay_offset =
RTO_Y;
2756 if (ti !=
nullptr) {
2772 *ground = snow_desert ? SPR_FLAT_SNOW_DESERT_TILE : SPR_FLAT_GRASS_TILE;
2776 static void DrawTile_Station(
TileInfo *ti)
2783 uint32 relocation = 0;
2784 uint32 ground_relocation = 0;
2787 uint tile_layout = 0;
2798 if (statspec !=
nullptr) {
2834 case APT_RADAR_GRASS_FENCE_SW:
2837 case APT_GRASS_FENCE_NE_FLAG:
2840 case APT_RADAR_FENCE_SW:
2843 case APT_RADAR_FENCE_NE:
2846 case APT_GRASS_FENCE_NE_FLAG_2:
2856 palette = COMPANY_SPRITE_COLOUR(owner);
2859 palette = PALETTE_TO_GREY;
2862 if (layout ==
nullptr && (t ==
nullptr || t->
seq ==
nullptr)) t = GetStationTileLayout(
GetStationType(ti->
tile), gfx);
2872 if (!HasFoundationNW(ti->
tile, slope, z))
SetBit(edge_info, 0);
2873 if (!HasFoundationNE(ti->
tile, slope, z))
SetBit(edge_info, 1);
2875 if (image == 0)
goto draw_default_foundation;
2880 static const uint8 foundation_parts[] = {
2893 static const uint8 composite_foundation_parts[] = {
2895 0x00, 0xD1, 0xE4, 0xE0,
2897 0xCA, 0xC9, 0xC4, 0xC0,
2899 0xD2, 0x91, 0xE4, 0xA0,
2904 uint8 parts = composite_foundation_parts[ti->
tileh];
2915 goto draw_default_foundation;
2919 for (
int i = 0; i < 8; i++) {
2930 draw_default_foundation:
2936 DrawWaterClassGround(ti);
2938 if (sprite != 0) total_offset = sprite - SPR_IMG_BUOY;
2941 DrawWaterClassGround(ti);
2947 DrawShoreTile(ti->
tileh);
2949 DrawClearLandTile(ti, 3);
2953 if (layout !=
nullptr) {
2962 t = &tmp_rail_layout;
2964 }
else if (statspec !=
nullptr) {
3008 uint sprite_offset = axis ==
AXIS_X ? 1 : 0;
3010 DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset);
3015 if (road_rti->UsesOverlay()) {
3036 int32 total_offset = 0;
3051 DrawSprite(ground + overlay_offset, PAL_NONE, x, y);
3060 uint sprite_offset = 5 - image;
3063 if (rti->UsesOverlay()) {
3065 DrawSprite(ground + sprite_offset, PAL_NONE, x, y);
3068 if (overlay)
DrawSprite(overlay + sprite_offset, PAL_NONE, x, y);
3069 }
else if (RoadTypeIsTram(roadtype)) {
3070 DrawSprite(SPR_TRAMWAY_TRAM + sprite_offset, PAL_NONE, x, y);
3074 if (RoadTypeIsRoad(roadtype) && rti->UsesOverlay()) {
3085 static int GetSlopePixelZ_Station(
TileIndex tile, uint x, uint y)
3100 RoadType road_rt = GetRoadTypeRoad(tile);
3101 RoadType tram_rt = GetRoadTypeTram(tile);
3124 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER;
3125 td->
owner[i] = road_owner;
3129 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER;
3130 td->
owner[i] = tram_owner;
3141 if (spec !=
nullptr) {
3175 default: NOT_REACHED();
3176 case STATION_RAIL: str = STR_LAI_STATION_DESCRIPTION_RAILROAD_STATION;
break;
3177 case STATION_AIRPORT:
3178 str = (
IsHangar(tile) ? STR_LAI_STATION_DESCRIPTION_AIRCRAFT_HANGAR : STR_LAI_STATION_DESCRIPTION_AIRPORT);
3180 case STATION_TRUCK: str = STR_LAI_STATION_DESCRIPTION_TRUCK_LOADING_AREA;
break;
3181 case STATION_BUS: str = STR_LAI_STATION_DESCRIPTION_BUS_STATION;
break;
3182 case STATION_OILRIG: {
3190 case STATION_DOCK: str = STR_LAI_STATION_DESCRIPTION_SHIP_DOCK;
break;
3191 case STATION_BUOY: str = STR_LAI_STATION_DESCRIPTION_BUOY;
break;
3192 case STATION_WAYPOINT: str = STR_LAI_STATION_DESCRIPTION_WAYPOINT;
break;
3222 RoadTramType rtt = (RoadTramType)sub_mode;
3244 static void TileLoop_Station(
TileIndex tile)
3249 case STATION_AIRPORT:
3257 case STATION_OILRIG:
3267 static void AnimateTile_Station(
TileIndex tile)
3270 AnimateStationTile(tile);
3275 AnimateAirportTile(tile);
3280 static bool ClickTile_Station(
TileIndex tile)
3324 }
else if (x < stop) {
3326 uint16 spd = std::max(0, (stop - x) * 20 - 15);
3327 if (spd < v->cur_speed) v->
cur_speed = spd;
3350 CargoTypes cargoes = 0;
3356 if (cargoes == 0)
return;
3394 static inline void byte_inc_sat(
byte *p)
3411 StationCargoAmountMap waiting_per_source;
3413 for (StationCargoAmountMap::iterator i(waiting_per_source.begin()); i != waiting_per_source.end(); ++i) {
3415 if (source_station ==
nullptr)
continue;
3422 static void UpdateStationRating(
Station *st)
3424 bool waiting_changed =
false;
3426 byte_inc_sat(&st->time_since_load);
3427 byte_inc_sat(&st->time_since_unload);
3445 waiting_changed =
true;
3464 uint waiting_avg = waiting / (num_dests + 1);
3475 | (std::min<uint>(last_speed, 0xFFu) << 24);
3477 uint32 var10 = (st->last_vehicle_type ==
VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10);
3481 rating =
GB(callback, 0, 14);
3484 if (
HasBit(callback, 14)) rating -= 0x4000;
3490 if (b >= 0) rating += b >> 2;
3493 if (st->last_vehicle_type ==
VEH_SHIP) waittime >>= 2;
3494 if (waittime <= 21) rating += 25;
3495 if (waittime <= 12) rating += 25;
3496 if (waittime <= 6) rating += 45;
3497 if (waittime <= 3) rating += 35;
3510 if (age < 3) rating += 10;
3511 if (age < 2) rating += 10;
3512 if (age < 1) rating += 13;
3522 if (rating <= 64 && waiting_avg >= 100) {
3523 int dec = Random() & 0x1F;
3524 if (waiting_avg < 200) dec &= 7;
3525 waiting -= (dec + 1) * num_dests;
3526 waiting_changed =
true;
3530 if (rating <= 127 && waiting != 0) {
3531 uint32 r = Random();
3532 if (rating <= (
int)
GB(r, 0, 7)) {
3534 waiting = std::max((
int)waiting - (
int)((
GB(r, 8, 2) - 1) * num_dests), 0);
3535 waiting_changed =
true;
3542 static const uint WAITING_CARGO_THRESHOLD = 1 << 12;
3543 static const uint WAITING_CARGO_CUT_FACTOR = 1 << 6;
3544 static const uint MAX_WAITING_CARGO = 1 << 15;
3546 if (waiting > WAITING_CARGO_THRESHOLD) {
3547 uint difference = waiting - WAITING_CARGO_THRESHOLD;
3548 waiting -= (difference / WAITING_CARGO_CUT_FACTOR);
3550 waiting = std::min(waiting, MAX_WAITING_CARGO);
3551 waiting_changed =
true;
3556 if (waiting_changed && waiting < ge->cargo.AvailableCount()) {
3570 StationID index = st->
index;
3571 if (waiting_changed) {
3594 for (std::list<Vehicle *>::iterator it(st->loading_vehicles.begin()); it != st->loading_vehicles.end(); ++it) {
3595 for (
Vehicle *v = *it; v !=
nullptr; v = v->
Next()) {
3616 if (lg ==
nullptr)
continue;
3619 Edge edge = it->second;
3626 bool updated =
false;
3628 if (auto_distributed) {
3631 std::vector<Vehicle *> vehicles;
3633 bool found_from =
false;
3634 bool found_to =
false;
3635 for (
Order *order = l->GetFirstOrder(); order !=
nullptr; order = order->
next) {
3636 if (!order->IsType(OT_GOTO_STATION) && !order->IsType(OT_IMPLICIT))
continue;
3637 if (order->GetDestination() == from->
index) {
3639 if (found_to)
break;
3640 }
else if (order->GetDestination() == to->
index) {
3642 if (found_from)
break;
3645 if (!found_to || !found_from)
continue;
3646 vehicles.push_back(l->GetFirstSharedVehicle());
3649 auto iter = vehicles.begin();
3650 while (iter != vehicles.end()) {
3664 *iter = next_shared;
3667 iter = vehicles.erase(iter);
3670 if (iter == vehicles.end()) iter = vehicles.begin();
3718 Debug(misc, 0,
"Can't allocate link graph");
3727 }
else if (ge2.
link_graph == INVALID_LINK_GRAPH) {
3745 if (lg !=
nullptr) {
3746 (*lg)[ge1.
node].UpdateEdge(ge2.
node, capacity, usage, time, mode);
3758 for (
const Vehicle *v = front; v !=
nullptr; v = v->
Next()) {
3773 static void StationHandleSmallTick(
BaseStation *st)
3784 void OnTick_Station()
3786 if (_game_mode == GM_EDITOR)
return;
3789 StationHandleSmallTick(st);
3821 void ModifyStationRatingAround(
TileIndex tile,
Owner owner,
int amount, uint radius)
3825 for (CargoID i = 0; i < NUM_CARGO; i++) {
3826 GoodsEntry *ge = &st->goods[i];
3828 if (ge->status != 0) {
3829 ge->rating = Clamp(ge->rating + amount, 0, 255);
3848 if (amount == 0)
return 0;
3860 Debug(misc, 0,
"Can't allocate link graph");
3865 if (lg !=
nullptr) (*lg)[ge.
node].UpdateSupply(amount);
3881 static bool IsUniqueStationName(
const std::string &name)
3884 if (!st->
name.empty() && st->
name == name)
return false;
3903 if (ret.
Failed())
return ret;
3905 bool reset = text.empty();
3909 if (!IsUniqueStationName(text))
return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
3930 if (st->TileIsInCatchment(tile)) stations->insert(st);
3943 assert(this->
w == 1 && this->
h == 1);
3944 AddNearbyStationsByCatchment(this->tile, &this->stations, Town::GetByTile(this->tile)->stations_near);
3947 this->stations.insert(st);
3957 static bool CanMoveGoodsToStation(
const Station *st,
CargoID type)
3981 if (all_stations->empty())
return 0;
3982 if (amount == 0)
return 0;
3984 Station *first_station =
nullptr;
3985 typedef std::pair<Station *, uint> StationInfo;
3986 std::vector<StationInfo> used_stations;
3988 for (
Station *st : *all_stations) {
3990 if (!CanMoveGoodsToStation(st, type))
continue;
3994 if (first_station ==
nullptr) {
3998 if (used_stations.empty()) {
3999 used_stations.reserve(2);
4000 used_stations.emplace_back(std::make_pair(first_station, 0));
4002 used_stations.emplace_back(std::make_pair(st, 0));
4006 if (first_station ==
nullptr)
return 0;
4008 if (used_stations.empty()) {
4011 return UpdateStationWaiting(first_station, type, amount, source_type, source_id);
4016 uint best_rating = 0;
4019 for (
auto &p : used_stations) {
4020 auto owner = p.first->owner;
4021 auto rating = p.first->goods[type].rating;
4022 if (rating > company_best[owner]) {
4023 best_sum += rating - company_best[owner];
4024 company_best[owner] = rating;
4025 if (rating > best_rating) best_rating = rating;
4027 company_sum[owner] += rating;
4032 amount *= best_rating + 1;
4035 for (
auto &p : used_stations) {
4036 uint owner = p.first->owner;
4039 p.second = amount * company_best[owner] * p.first->goods[type].rating / best_sum / company_sum[owner];
4044 if (amount > moving) {
4045 std::stable_sort(used_stations.begin(), used_stations.end(), [type](
const StationInfo &a,
const StationInfo &b) {
4046 return b.first->goods[type].rating < a.first->goods[type].rating;
4049 assert(amount - moving <= used_stations.size());
4050 for (uint i = 0; i < amount - moving; i++) {
4051 used_stations[i].second++;
4056 for (
auto &p : used_stations) {
4057 moved += UpdateStationWaiting(p.first, type, p.second, source_type, source_id);
4063 void UpdateStationDockingTiles(
Station *st)
4077 int x2 = std::min<int>(x + area->
w + 1,
MapSizeX());
4078 int x1 = std::max<int>(x - 1, 0);
4080 int y2 = std::min<int>(y + area->
h + 1,
MapSizeY());
4081 int y1 = std::max<int>(y - 1, 0);
4092 Debug(misc, 0,
"Can't allocate station for oilrig at 0x{:X}, reverting to oilrig only", tile);
4100 st->
string_id = GenerateStationName(st, tile, STATIONNAMING_OILRIG);
4115 UpdateStationDockingTiles(st);
4117 st->
rect.BeforeAddTile(tile, StationRect::ADD_FORCE);
4142 for (RoadTramType rtt : _roadtramtypes) {
4145 RoadType rt = GetRoadType(tile, rtt);
4169 case STATION_WAYPOINT:
4260 case STATION_WAYPOINT:
return_cmd_error(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
4261 case STATION_AIRPORT:
return_cmd_error(STR_ERROR_MUST_DEMOLISH_AIRPORT_FIRST);
4262 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);
4263 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);
4266 case STATION_OILRIG:
4267 SetDParam(1, STR_INDUSTRY_NAME_OIL_RIG);
4286 case STATION_BUOY:
return RemoveBuoy(tile, flags);
4287 case STATION_DOCK:
return RemoveDock(tile, flags);
4302 case STATION_WAYPOINT:
4303 case STATION_RAIL: {
4310 case STATION_AIRPORT:
4338 for (SharesMap::const_iterator it = this->
shares.begin(); it != this->shares.end(); ++it) {
4339 if (it->second == st) {
4340 return it->first - prev;
4357 assert(!this->
shares.empty());
4359 assert(it != this->
shares.end() && it->first <= this->unrestricted);
4360 if (it->second != excluded && it->second != excluded2)
return it->second;
4365 uint end = it->first;
4366 uint begin = (it == this->
shares.begin() ? 0 : (--it)->first);
4367 uint interval = end - begin;
4368 if (interval >= this->
unrestricted)
return INVALID_STATION;
4371 SharesMap::const_iterator it2 = (rand < begin) ? this->
shares.upper_bound(rand) :
4372 this->
shares.upper_bound(rand + interval);
4373 assert(it2 != this->
shares.end() && it2->first <= this->unrestricted);
4374 if (it2->second != excluded && it2->second != excluded2)
return it2->second;
4379 uint end2 = it2->first;
4380 uint begin2 = (it2 == this->
shares.begin() ? 0 : (--it2)->first);
4381 uint interval2 = end2 - begin2;
4382 if (interval2 >= new_max)
return INVALID_STATION;
4383 new_max -= interval2;
4384 if (begin > begin2) {
4385 Swap(begin, begin2);
4387 Swap(interval, interval2);
4392 it3 = this->
shares.upper_bound(rand);
4393 }
else if (rand < begin2 - interval) {
4394 it3 = this->
shares.upper_bound(rand + interval);
4396 it3 = this->
shares.upper_bound(rand + interval + interval2);
4398 assert(it3 != this->
shares.end() && it3->first <= this->unrestricted);
4409 assert(!this->
shares.empty());
4410 SharesMap new_shares;
4412 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4413 new_shares[++i] = it->second;
4414 if (it->first == this->unrestricted) this->
unrestricted = i;
4416 this->
shares.swap(new_shares);
4417 assert(!this->
shares.empty() && this->unrestricted <= (--this->shares.end())->first);
4430 assert(!this->
shares.empty());
4432 uint removed_shares = 0;
4433 uint added_shares = 0;
4434 uint last_share = 0;
4435 SharesMap new_shares;
4436 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4437 if (it->second == st) {
4439 uint share = it->first - last_share;
4440 if (flow == INT_MIN || (uint)(-flow) >= share) {
4441 removed_shares += share;
4442 if (it->first <= this->unrestricted) this->
unrestricted -= share;
4443 if (flow != INT_MIN) flow += share;
4444 last_share = it->first;
4447 removed_shares += (uint)(-flow);
4449 added_shares += (uint)(flow);
4451 if (it->first <= this->unrestricted) this->
unrestricted += flow;
4457 new_shares[it->first + added_shares - removed_shares] = it->second;
4458 last_share = it->first;
4461 new_shares[last_share + (uint)flow] = st;
4468 this->
shares.swap(new_shares);
4478 assert(!this->
shares.empty());
4480 uint last_share = 0;
4481 SharesMap new_shares;
4482 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4484 if (it->first > this->unrestricted)
return;
4485 if (it->second == st) {
4486 flow = it->first - last_share;
4489 new_shares[it->first] = it->second;
4492 new_shares[it->first - flow] = it->second;
4494 last_share = it->first;
4496 if (flow == 0)
return;
4497 new_shares[last_share + flow] = st;
4498 this->
shares.swap(new_shares);
4499 assert(!this->
shares.empty());
4509 assert(!this->
shares.empty());
4511 uint next_share = 0;
4513 for (SharesMap::reverse_iterator it(this->
shares.rbegin()); it != this->shares.rend(); ++it) {
4514 if (it->first < this->unrestricted)
return;
4516 flow = next_share - it->first;
4520 if (it->first == this->unrestricted)
return;
4521 if (it->second == st) found =
true;
4523 next_share = it->first;
4525 if (flow == 0)
return;
4526 SharesMap new_shares;
4527 new_shares[flow] = st;
4528 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4529 if (it->second != st) {
4530 new_shares[flow + it->first] = it->second;
4535 this->
shares.swap(new_shares);
4536 assert(!this->
shares.empty());
4546 assert(runtime > 0);
4547 SharesMap new_shares;
4549 for (SharesMap::iterator i = this->
shares.begin(); i != this->shares.end(); ++i) {
4550 share = std::max(share + 1, i->first * 30 / runtime);
4551 new_shares[share] = i->second;
4554 this->
shares.swap(new_shares);
4565 FlowStatMap::iterator origin_it = this->find(origin);
4566 if (origin_it == this->end()) {
4567 this->insert(std::make_pair(origin,
FlowStat(via, flow)));
4569 origin_it->second.ChangeShare(via, flow);
4570 assert(!origin_it->second.GetShares()->empty());
4584 FlowStatMap::iterator prev_it = this->find(origin);
4585 if (prev_it == this->end()) {
4588 this->insert(std::make_pair(origin, fs));
4590 prev_it->second.ChangeShare(via, flow);
4591 prev_it->second.ChangeShare(INVALID_STATION, flow);
4592 assert(!prev_it->second.GetShares()->empty());
4602 for (FlowStatMap::iterator i = this->begin(); i != this->end(); ++i) {
4604 uint local = fs.
GetShare(INVALID_STATION);
4605 if (local > INT_MAX) {
4628 for (FlowStatMap::iterator f_it = this->begin(); f_it != this->end();) {
4632 ret.
Push(f_it->first);
4633 this->erase(f_it++);
4647 for (FlowStatMap::iterator it = this->begin(); it != this->end(); ++it) {
4648 it->second.RestrictShare(via);
4658 for (FlowStatMap::iterator it = this->begin(); it != this->end(); ++it) {
4659 it->second.ReleaseShare(via);
4670 for (FlowStatMap::const_iterator i = this->begin(); i != this->end(); ++i) {
4671 ret += (--(i->second.GetShares()->end()))->first;
4684 for (FlowStatMap::const_iterator i = this->begin(); i != this->end(); ++i) {
4685 ret += i->second.GetShare(via);
4697 FlowStatMap::const_iterator i = this->find(from);
4698 if (i == this->end())
return 0;
4699 return (--(i->second.GetShares()->end()))->first;
4710 FlowStatMap::const_iterator i = this->find(from);
4711 if (i == this->end())
return 0;
4712 return i->second.GetShare(via);
4717 GetSlopePixelZ_Station,
4720 GetTileDesc_Station,
4721 GetTileTrackStatus_Station,
4723 AnimateTile_Station,
4725 ChangeTileOwner_Station,
4727 VehicleEnter_Station,
4728 GetFoundation_Station,
4729 TerraformTile_Station,
@ VEH_AIRCRAFT
Aircraft vehicle type.
static void DrawRailTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette)
Draw tile sprite sequence in GUI with railroad specifics.
@ 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).
StringID airport_class
Name of the airport class.
@ 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).
@ 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.
@ ROTSG_GROUND
Required: Main group of ground images.
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...
SpriteID single_x
single piece of rail in X direction, without ground
Minimal stack that uses a pool to avoid pointers.
GoodsEntry goods[NUM_CARGO]
Goods at this station.
@ TRACK_BIT_NONE
No track.
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.
byte StationGfx
Copy from station_map.h.
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
static CargoArray GetAcceptanceAroundStation(const Station *st, CargoTypes *always_accepted)
Get the acceptance of cargoes around the station in.
static bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
uint unrestricted
Limit for unrestricted shares.
bool IsType(OrderType type) const
Check whether this order is of the given type.
static const uint COMPRESSION_INTERVAL
Minimum number of days between subsequent compressions of a LG.
static Titem * Get(size_t index)
Returns Titem with given index.
byte flags
Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size.
static DiagDirection GetDockDirection(TileIndex t)
Get the direction of a dock.
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
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.
static bool IsRoadStop(TileIndex t)
Is the station at t a road station?
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.
static const int STATION_RATING_TICKS
cycle duration for updating station rating
std::vector< NewGRFSpriteLayout > renderdata
Number of tile layouts.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
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.
uint Reroute(uint max_move, VehicleCargoList *dest, StationID avoid, StationID avoid2, const GoodsEntry *ge)
Routes packets with station "avoid" as next hop to a different place.
RoadStopType
Types of RoadStops.
StationGfx GetStationGfx() const
Get the StationGfx for the current tile.
@ ROADSTOP_TRUCK
A standard stop for trucks.
static bool HasTileWaterClass(TileIndex t)
Checks whether the tile has an waterclass associated.
CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailType rt, Axis axis, byte numtracks, byte plat_len, StationClassID spec_class, byte spec_index, StationID station_to_join, bool adjacent)
Build rail station.
void Push(const Titem &item)
Pushes a new item onto the stack if there is still space in the underlying pool.
uint32 PrepareLayout(uint32 orig_offset, uint32 newgrf_ground_offset, uint32 newgrf_offset, uint constr_stage, bool separate_ground) const
Prepares a sprite layout before resolving action-1-2-3 chains.
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track)
Use this function to notify YAPF that track layout (or signal configuration) has change.
uint x
X position of the tile in unit coordinates.
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.
static bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
Autoslope check for tiles with an entrance on an edge.
@ 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.
void ReleaseShare(StationID st)
Release ("unrestrict") a flow by moving it to the begin of the map and increasing the amount of unres...
byte landscape
the landscape we're currently in
StringID railtype
Type of rail on the tile.
CompanyMask statues
which companies have a statue?
SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32 var10)
Resolve sprites for drawing a station tile.
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.
Date LastRestrictedUpdate() const
Get the date of the last update to the edge's restricted capacity.
static void SetCustomStationSpecIndex(TileIndex t, byte specindex)
Set the custom station spec for this tile.
@ 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
static 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,...
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.
void RecomputeCatchment()
Recompute tiles covered in our catchment area.
@ AAT_STATION_NEW_CARGO
Triggered when new cargo arrives at the station (for all tiles at the same time).
Date LastUpdate() const
Get the date of the last update to any part of the edge's capacity.
@ PALETTE_MODIFIER_COLOUR
this bit is set when a recolouring process is in action
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.
static Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
CommandCost RemoveRailStation(T *st, DoCommandFlag flags, Money removal_cost)
Remove a rail station/waypoint.
byte town_council_tolerance
minimum required town ratings to be allowed to demolish stuff
IndustryType GetIndustryType(TileIndex tile)
Retrieve the type for this industry.
static bool IsCustomStationSpecIndex(TileIndex t)
Is there a custom rail station spec on this tile?
Iterator to iterate over all tiles belonging to a bitmaptilearea.
uint16 noise_reached
level of noise that all the airports are generating
@ 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.
uint32 water
Count of company owned track bits for canals.
static bool IsRailStation(TileIndex t)
Is this station tile a rail station?
Tindex index
Index of this pool item.
void DrawRoadCatenary(const TileInfo *ti)
Draws the catenary for the given tile.
bool IsHangar(TileIndex t)
Check whether the given tile is a hangar.
@ 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.
static Track GetRailStationTrack(TileIndex t)
Get the rail track of a rail station tile.
CommandCost CmdOpenCloseAirport(DoCommandFlag flags, StationID station_id)
Open/close an airport to incoming aircraft.
EdgeIterator Begin()
Get an iterator pointing to the start of the edges array.
CommandCost FindJoiningBaseStation(StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, T **st)
Find a nearby station that joins this station.
static TrackBits AxisToTrackBits(Axis a)
Maps an Axis to the corresponding TrackBits value.
static bool HasPowerOnRail(RailType enginetype, RailType tiletype)
Checks if an engine of the given RailType got power on a tile with a given RailType.
An iterator for non-const edges.
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.
static uint ClampU(const uint a, const uint min, const uint max)
Clamp an unsigned integer between an interval.
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.
SpriteID single_y
single piece of rail in Y direction, without ground
uint8 FindFirstBit(uint64 x)
Search the first set bit in a 64 bit variable.
DifficultySettings difficulty
settings related to the difficulty
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
uint16 tram_speed
Speed limit of tram (bridges and track)
static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, std::vector< Train * > &affected_vehicles, StationClassID spec_class, byte spec_index, byte plat_len, byte numtracks)
Checks if a rail station can be built at the given area.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
@ CBID_CARGO_STATION_RATING_CALC
Called to calculate part of a station rating.
static constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
uint32 station
Count of company owned station tiles.
void ProcessRegisters(uint8 resolved_var10, uint32 resolved_sprite, bool separate_ground) const
Evaluates the register modifiers and integrates them into the preprocessed sprite layout.
CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 height, RoadStopType stop_type, bool remove_road)
Remove bus or truck stops.
void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1=NR_NONE, uint32 ref1=UINT32_MAX, NewsReferenceType reftype2=NR_NONE, uint32 ref2=UINT32_MAX, const NewsAllocatedData *data=nullptr)
Add a new newsitem to be shown.
This struct contains all the info that is needed to draw and construct tracks.
bool include(std::vector< T > &vec, const T &item)
Helper function to append an item to a vector if it is not already contained Consider using std::set,...
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
static bool IsCompatibleTrainStationTile(TileIndex test_tile, TileIndex station_tile)
Check if a tile is a valid continuation to a railstation tile.
static RoadStopType GetRoadStopType(TileIndex t)
Get the road stop type of this tile.
@ VETSB_CONTINUE
Bit sets of the above specified bits.
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.
byte layout
Airport layout number.
static bool IsStandardRoadStopTile(TileIndex t)
Is tile t a standard (non-drive through) road stop station?
static void SetStationGfx(TileIndex t, StationGfx gfx)
Set the station graphics of this tile.
static RoadStop * GetByTile(TileIndex tile, RoadStopType type)
Find a roadstop at given tile.
static bool IsValidDiagDirection(DiagDirection d)
Checks if an integer value is a valid DiagDirection.
static void SetRoadOwner(TileIndex t, RoadTramType rtt, Owner o)
Set the owner of a specific road type.
@ EUM_INCREASE
Increase capacity.
static bool IsDriveThroughStopTile(TileIndex t)
Is tile t a drive through road stop station?
static const uint TILE_SIZE
Tile size in world coordinates.
EdgeIterator End()
Get an iterator pointing beyond the end of the edges array.
static TrackBits GetTrackBits(TileIndex tile)
Gets the track bits of the given tile.
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.
uint y
Y position of the tile in unit coordinates.
ClientSettings _settings_client
The current settings for this game.
static bool HasSignals(TileIndex t)
Checks if a rail tile has signals.
TileIndex xy
town center tile
Specification of a cargo type.
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.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
@ 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.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
@ VS_TRAIN_SLOWING
Train is slowing down.
static uint32 RandomRange(uint32 limit)
Pick a random number between 0 and limit - 1, inclusive.
NodeID Size() const
Get the current size of the component.
@ WC_STATION_VIEW
Station view; Window numbers:
StringID station_name
Default name for nearby station.
Town * AirportGetNearestTown(const AirportSpec *as, const TileIterator &it, uint &mindist)
Finds the town nearest to given airport.
bool Enter(RoadVehicle *rv)
Enter the road stop.
byte fallback_railtype
Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations.
@ VEH_ROAD
Road vehicle type.
@ CC_PASSENGERS
Passengers.
uint16 cur_speed
current speed
Defines the internal data of a functional industry.
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.
void FinalizeLocalConsumption(StationID self)
Subtract invalid flows from locally consumed flow.
Owner owner
The owner of this station.
static bool IsTruckStop(TileIndex t)
Is the station at t a truck stop?
@ MP_ROAD
A tile with road (or tram tracks)
Defines the data structure for an airport.
@ 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.
static bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
Find out if the slope of the tile is suitable to build a depot of given direction.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
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,...
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.
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
static Track RemoveFirstTrack(TrackBits *tracks)
Removes first Track from TrackBits and returns it.
Station * neutral_station
Associated neutral station.
static Foundation FlatteningFoundation(Slope s)
Returns the foundation needed to flatten a slope.
@ TRACK_BIT_UPPER
Upper track.
const AirportFTAClass * GetAirport(const byte airport_type)
Get the finite state machine of an airport type.
bool Succeeded() const
Did this command succeed?
byte amount_fract
Fractional part of the amount in the cargo list.
static TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
static uint TileX(TileIndex tile)
Get the X component of a tile.
static TrackBits GetRailReservationTrackBits(TileIndex t)
Returns the reserved track bits of the tile.
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.
virtual TileIterator * Clone() const =0
Allocate a new iterator that is a copy of this one.
@ AAT_TILELOOP
Triggered in the periodic tile loop.
static uint CountBits(T value)
Counts the number of set bits in a variable.
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...
uint8 cached_anim_triggers
NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen.
void Clear()
Clears the 'tile area', i.e.
static const int MAX_CHAR_LENGTH
Max. length of UTF-8 encoded unicode character.
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.
static const uint STALE_LINK_DEPOT_TIMEOUT
Number of days before deleting links served only by vehicles stopped in depot.
Aircraft, helicopters, rotors and their shadows belong to this class.
Slope tileh
Slope of the tile.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
static RoadBits AxisToRoadBits(Axis a)
Create the road-part which belongs to the given Axis.
@ ROAD_X
Full road along the x-axis (south-west + north-east)
@ SSF_SEPARATE_GROUND
Use different sprite set for ground sprites.
static uint MapSizeX()
Get the size of the map along the X.
static bool IsTileOnWater(TileIndex t)
Tests if the tile was built on water.
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...
char * GetStringWithArgs(char *buffr, StringID string, StringParameters *args, const char *last, uint case_index, bool game_script)
Get a parsed string with most special stringcodes replaced by the string parameters.
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner)
Change the owner of a tile.
StringID name
Name of this rail type.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
void Queue(LinkGraph *lg)
Queue a link graph for execution.
Date build_date
Date of construction of tile contents.
StationType
Station types.
PalSpriteID ground
Palette and sprite for the ground.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
bool ValParamRailtype(const RailType rail)
Validate functions for rail building.
void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, byte widget_index)
Mark a particular widget in a particular window as dirty (in need of repainting)
Defines the data structure of each individual tile of an airport.
StationClassID cls_id
The class to which this spec belongs.
static RoadBits GetAllRoadBits(TileIndex tile)
Get all set RoadBits on the given tile.
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...
static void MakeOilrig(TileIndex t, StationID sid, WaterClass wc)
Make the given tile an oilrig tile.
static TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between two tiles from a TileIndexDiffC struct.
OrderSettings order
settings related to orders
@ ROAD_Y
Full road along the y-axis (north-west + south-east)
static RoadBits GetRoadBits(TileIndex t, RoadTramType rtt)
Get the present road bits for a specific road type.
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.
uint32 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.
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
static void DrawRailTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette)
Draw tile sprite sequence on tile with railroad specifics.
static int GetSlopeMaxZ(Slope s)
Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
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.
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 byte GetAnimationFrame(TileIndex t)
Get the current animation frame.
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.
static DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
bool serve_neutral_industries
company stations can serve industries with attached neutral stations
static StationGfx GetAirportGfx(TileIndex t)
Get the station graphics of this airport tile.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
StationList stations
List of stations nearby.
static uint MapSize()
Get the size of the map.
static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCommandFlag flags)
Checks if an airport can be built at the given location and clear the area.
Date LastUnrestrictedUpdate() const
Get the date of the last update to the edge's unrestricted capacity.
@ 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.
static bool IsSteepSlope(Slope s)
Checks if a slope is steep.
void ReleaseFlows(StationID via)
Release all flows at a station for specific cargo and destination.
Common return value for all commands.
byte GetSnowLine()
Get the current snow line, either variable or static.
TileArea location
Location of the industry.
static uint GetCustomStationSpecIndex(TileIndex t)
Get the custom station spec for this tile.
@ TRACK_Y
Track along the y-axis (north-west to south-east)
static bool HasTileWaterGround(TileIndex t)
Checks whether the tile has water at the ground.
WaterClass
classes of water (for WATER_TILE_CLEAR water tile type).
static const AirportSpec * Get(byte type)
Retrieve airport spec for the given airport.
Iterable ensemble of each set bit in a value.
AirportClassID cls_id
the class to which this airport type belongs
Trackdir GetVehicleTrackdir() const override
Get the tracks of the train vehicle.
Date _date
Current date in days (day counter)
uint16 SourceID
Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
static bool HasStationRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
@ 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.
static Track AxisToTrack(Axis a)
Convert an Axis to the corresponding Track AXIS_X -> TRACK_X AXIS_Y -> TRACK_Y Uses the fact that the...
void StationMonthlyLoop()
Monthly loop for stations.
TileArea train_station
Tile area the train 'station' part covers.
RoadBits GetAnyRoadBits(TileIndex tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance)
Returns the RoadBits on an arbitrary tile Special behaviour:
static const int STATION_ACCEPTANCE_TICKS
cycle duration for updating station acceptance
static bool HasExactlyOneBit(T value)
Test whether value has exactly 1 bit set.
@ 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.
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.
static TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
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.
int32 TileIndexDiff
An offset value between two tiles.
bool HasRating() const
Does this cargo have a rating at this station?
TileIndex tile
Current tile index.
static bool FindNearIndustryName(TileIndex tile, void *user_data)
Find a station action 0 property 24 station name, or reduce the free_names if needed.
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
Converts a callback result into a boolean.
Base class for tile iterators.
static bool CMSAMine(TileIndex tile)
Check whether the tile is a mine.
uint DistanceFromEdge(TileIndex tile)
Param the minimum distance to an edge.
CommandCost CanExpandRailStation(const BaseStation *st, TileArea &new_ta, Axis axis)
Check whether we can expand the rail part of the given station.
void MarkTilesDirty(bool cargo_change) const
Marks the tiles of the station as dirty.
static DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
void Insert(const T &element)
Insert a single element in the tree.
StringID roadtype
Type of road on the tile.
@ ROADSTOP_END
End of valid types.
TransportType
Available types of transport.
byte last_speed
Maximum speed (up to 255) of the last vehicle that tried to load this cargo.
struct RailtypeInfo::@36 base_sprites
Struct containing the main sprites.
@ GES_ACCEPTED_BIGTICK
Set when cargo was delivered for final delivery during the current STATION_ACCEPTANCE_TICKS interval.
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
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.
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
static void MakeDriveThroughRoadStop(TileIndex 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.
static bool IsBuoy(TileIndex t)
Is tile t a buoy tile?
@ INVALID_OWNER
An invalid owner.
uint16 w
The width of the area.
TileArea truck_station
Tile area the truck 'station' part covers.
void UpdateAirportsNoise()
Recalculate the noise generated by the airports of each town.
CargoID produced_cargo[INDUSTRY_NUM_OUTPUTS]
16 production cargo slots
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.
static StationType GetStationType(TileIndex t)
Get the station type of this tile.
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.
static void ShowRejectOrAcceptNews(const Station *st, uint num_items, CargoID *cargo, StringID msg)
Items contains the two cargo names that are to be accepted or rejected.
void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint capacity, uint usage, uint32 time, EdgeUpdateMode mode)
Increase capacity for a link stat given by station cargo and next hop.
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.
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.
static bool CMSATree(TileIndex tile)
Check whether the tile is a tree.
bool IsFrontEngine() const
Check if the vehicle is a front engine.
@ SRT_NEW_CARGO
Trigger station on new cargo arrival.
static bool HasTileRoadType(TileIndex t, RoadTramType rtt)
Check if a tile has a road or a tram road type.
static const AirportTileSpec * GetByTile(TileIndex tile)
Retrieve airport tile spec for the given airport tile.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static const uint8 ANIM_STATUS_NO_ANIMATION
There is no animation.
static TropicZone GetTropicZone(TileIndex tile)
Get the tropic zone.
IndustryType indtype
Industry type to get the name from.
uint16 MaxTownNoise() const
Calculate the max town noise.
EconomySettings economy
settings to change the economy
static Money RailBuildCost(RailType railtype)
Returns the cost of building the specified railtype.
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.
NewGRF supplied spritelayout.
static bool HasStationTileRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
static TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, TrackdirBits red_signals)
Builds a TrackStatus.
static void SetDockingTile(TileIndex t, bool b)
Set the docking tile state of a tile.
StringID name
Name of this station.
@ ROTSG_ROADSTOP
Required: Drive-in 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(),...
'Train' is either a loco or a wagon.
@ VEH_INVALID
Non-existing type of vehicle.
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
uint64 flags
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
void FreeTrainTrackReservation(const Train *v)
Free the reserved path in front of a vehicle.
SpriteID GetCanalSprite(CanalFeature feature, TileIndex tile)
Lookup the base sprite to use for a canal.
static void SetStationTileRandomBits(TileIndex t, byte random_bits)
Set the random bits for a station tile.
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Slope GetTileSlope(TileIndex tile, int *h)
Return the slope of a given tile inside the map.
@ SPRITE_MODIFIER_CUSTOM_SPRITE
Set when a sprite originates from an Action 1.
static bool IsTileOwner(TileIndex tile, Owner owner)
Checks if a tile belongs to the given owner.
static bool HasStationReservation(TileIndex t)
Get the reservation state of the rail station.
static void MakeAirport(TileIndex t, Owner o, StationID sid, byte section, WaterClass wc)
Make the given tile an airport tile.
@ NUM_AIRPORTS
Maximal number of airports in total.
std::string name
Custom name.
static const int STATION_LINKGRAPH_TICKS
cycle duration for cleaning dead links
Ground palette sprite of a tile, together with its sprite layout.
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.
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.
TileArea bus_station
Tile area the bus 'station' part covers.
CommandCost RemoveBuoy(TileIndex tile, DoCommandFlag flags)
Remove a buoy.
static bool AutoslopeEnabled()
Tests if autoslope is enabled for _current_company.
@ RTSG_GROUND
Main group of ground images.
byte rating
Station rating for this cargo.
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 ...
static DiagDirection GetRoadStopDir(TileIndex t)
Gets the direction the road stop entrance points towards.
DiagDirection
Enumeration for diagonal directions.
static uint MapSizeY()
Get the size of the map along the Y.
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.
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 Station * From(BaseStation *st)
Converts a BaseStation to SpecializedStation with type checking.
byte station_spread
amount a station may spread
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.
static bool IsRailStationTile(TileIndex t)
Is this tile a station tile and a rail 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.
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 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.
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.
@ DRD_NONE
None of the directions are disallowed.
RoadStop * truck_stops
All the truck stops.
Defines the data structure for constructing industry.
Industry * industry
NOSAVE: Associated industry for neutral stations. (Rebuilt on load from Industry->st)
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
bool IsValidDockingDirectionForDock(TileIndex t, DiagDirection d)
Check if a dock tile can be docked from the given direction.
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.
static DiagDirection AxisToDiagDir(Axis a)
Converts an Axis to a DiagDirection.
std::set< Station *, StationCompare > StationList
List of stations.
void TileLoop_Water(TileIndex tile)
Let a water tile floods its diagonal adjoining tiles called from tunnelbridge_cmd,...
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
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.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
static bool IsAirport(TileIndex t)
Is this station tile an airport?
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.
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.
static PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
Direction direction
facing
void AddFlow(StationID origin, StationID via, uint amount)
Add some flow from "origin", going via "via".
uint16 h
The height of the area.
bool IsTileForestIndustry(TileIndex tile)
Check whether the tile is a forest.
static uint ApplyPixelFoundationToSlope(Foundation f, Slope *s)
Applies a foundation to a slope.
uint DistanceMax(TileIndex t0, TileIndex t1)
Gets the biggest distance component (x or y) between the two given tiles.
byte size_x
size of airport in x direction
@ MP_TREES
Tile got trees.
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'.
@ SSF_CUSTOM_FOUNDATIONS
Draw custom foundations.
Date LastCompression() const
Get date of last compression.
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
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
static const uint64 AIRPORT_CLOSED_block
Dummy block for indicating a closed airport.
bool IsStationTileBlocked(TileIndex tile)
Check whether a rail station tile is NOT traversable.
@ GES_CURRENT_MONTH
Set when cargo was delivered for final delivery this month.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
@ ROADSTOP_BUS
A standard stop for buses.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
static bool IsDockTile(TileIndex t)
Is tile t a dock tile?
@ TRACKDIR_BIT_NONE
No track build.
static bool IsBuoyTile(TileIndex t)
Is tile t a buoy tile?
static DisallowedRoadDirections GetDisallowedRoadDirections(TileIndex t)
Gets the disallowed directions.
static bool IsRoadStopTile(TileIndex t)
Is tile t a road stop station?
All ships have this type.
SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
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 T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
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
Vehicle * First() const
Get the first vehicle of this vehicle chain.
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
static int CountMapSquareAround(TileIndex tile, CMSAMatcher cmp)
Counts the numbers of tiles matching a specific type in the area around.
byte last_age
Age in years (up to 255) of the last vehicle that tried to load this cargo.
@ TRACK_BIT_LEFT
Left track.
static bool IsRailWaypoint(TileIndex t)
Is this station tile a rail waypoint?
NodeID AddNode(const Station *st)
Add a node to the component and create empty edges associated with it.
void RemoveEdge(NodeID to)
Remove an outgoing edge from this node.
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.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
void ClearDriveThrough()
Prepare for removal of this stop; update other neighbouring stops if needed.
static const Date INVALID_DATE
Representation of an invalid date.
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 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.
static StationGfx GetStationGfx(TileIndex t)
Get the station graphics of this tile.
static Axis GetRailStationAxis(TileIndex t)
Get the rail direction of a rail station.
static bool IsWaterTile(TileIndex t)
Is it a water tile with plain water?
FlowStatMap flows
Planned flows through this station.
RailTrackOffset
Offsets for sprites within an overlay/underlay set.
TileIndex tile
The base tile of the area.
uint32 PaletteID
The number of the palette.
static const uint MIN_TIMEOUT_DISTANCE
Minimum effective distance for timeout calculation.
static bool HasRailCatenaryDrawn(RailType rt)
Test if we should draw rail catenary.
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...
@ 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...
static IndustryID GetIndustryIndex(TileIndex t)
Get the industry ID of the given tile.
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.
@ FOUNDATION_LEVELED
The tile is leveled up to a flat slope.
uint32 rail[RAILTYPE_END]
Count of company owned track bits for each rail type.
void UpdateVirtCoord() override
Update the virtual coords needed to draw the station sign.
static void MakeRoadNormal(TileIndex t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
Make a normal road tile.
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
@ WC_VEHICLE_DEPOT
Depot view; Window numbers:
uint16 classes
Classes of this cargo type.
@ MP_STATION
A tile of a station.
GRFFileProps grf_prop
properties related to the grf file
@ NUM_CARGO
Maximal number of cargo types in a game.
@ GES_ACCEPTANCE
Set when the station accepts the cargo currently for final deliveries.
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
byte time_since_pickup
Number of rating-intervals (up to 255) since the last vehicle tried to load this cargo.
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()
StationID GetVia() const
Get a station a package can be routed to.
@ DIAGDIR_BEGIN
Used for iterations.
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
CommandCost CmdRemoveFromRailWaypoint(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail)
Remove a single tile from a waypoint.
static void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadType road_rt, RoadType tram_rt, DiagDirection d)
Make the given tile a roadstop tile.
StringID name
Name of this class.
static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags)
Remove a bus station/truck stop.
RoadType
The different roadtypes we support.
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.
StringID str
Description of the tile.
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.
static int GetTileMaxPixelZ(TileIndex tile)
Get top height of the tile.
Base class for all station-ish types.
bool HasStationInUse(StationID station, bool include_company, CompanyID company)
Tests whether the company's vehicles have this station in orders.
uint16 triggers
The triggers that trigger animation.
RoadBits
Enumeration for the road parts on a tile.
static Pool::IterateWrapper< RoadVehicle > Iterate(size_t from=0)
Returns an iterable ensemble of all valid vehicles of type T.
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...
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
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
uint GetNumHangars() const
Get the number of hangars on this airport.
TrackBits
Bitfield corresponding to Track.
static bool IsDockingTile(TileIndex t)
Checks whether the tile is marked as a dockling tile.
const DrawTileSeqStruct * seq
Array of child sprites. Terminated with a terminator entry.
bool adjacent_stations
allow stations to be built directly adjacent to other stations
CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, StationID station_to_join, bool adjacent)
Build a bus or truck stop.
#define Debug(name, level, format_string,...)
Ouptut a line of debugging information.
uint8 status
Status; 0: no looping, 1: looping, 0xFF: no animation.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
#define lengthof(x)
Return the length of an fixed size array.
uint16 rail_speed
Speed limit of rail (bridges and track)
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.
uint16 max_speed
Maximum speed for vehicles travelling on this road type.
static bool IsDock(TileIndex t)
Is tile t a dock tile?
static Station * GetIfValid(size_t index)
Returns station if the index is a valid index for this station type.
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,.
static bool IsOilRig(TileIndex t)
Is tile t part of an oilrig?
@ NF_SMALL
Small news item. (Information window with text and viewport)
byte CargoID
Cargo slots to indicate a cargo type within a game.
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 CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
static bool IsPlainRailTile(TileIndex t)
Checks whether the tile is a rail tile or rail tile with signals.
void DrawRailCatenary(const TileInfo *ti)
Draws overhead wires and pylons for electric railways.
static CargoTypes GetAcceptanceMask(const Station *st)
Get a mask of the cargo types that the station accepts.
static Money RoadBuildCost(RoadType roadtype)
Returns the cost of building the specified roadtype.
bool IsShipDestinationTile(TileIndex tile, StationID station)
Test if a tile is a docking tile for the given station.
static bool HasPowerOnRoad(RoadType enginetype, RoadType tiletype)
Checks if an engine of the given RoadType got power on a tile with a given RoadType.
static bool IsNormalRoadTile(TileIndex t)
Return whether a tile is a normal road tile.
static const uint NEW_AIRPORTTILE_OFFSET
offset of first newgrf airport tile
const DrawTileSeqStruct * GetLayout(PalSpriteID *ground) const
Returns the result spritelayout after preprocessing.
static void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
Make the given tile a rail station tile.
@ 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.
OrthogonalTileArea & Expand(int rad)
Expand a tile area by rad tiles in each direction, keeping within map bounds.
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:
static Owner GetRoadOwner(TileIndex t, RoadTramType rtt)
Get the owner of a specific road type.
StringID owner_type[4]
Type of each owner.
static Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
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.
static void SetTileOwner(TileIndex tile, Owner owner)
Sets the owner of a tile.
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.
TileIndex tile
Tile index.
static bool IsReversingRoadTrackdir(Trackdir dir)
Checks whether the trackdir means that we are reversing.
ConstructionSettings construction
construction of things in-game
SharesMap shares
Shares of flow to be sent via specified station (or consumed locally).
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
Trackdir
Enumeration for tracks and directions.
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
byte nof_depots
the number of hangar tiles in this airport
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
@ VEH_TRAIN
Train vehicle type.
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.
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
A Stop for a Road Vehicle.
VehicleType type
Type of vehicle.
uint8 GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance)
Get a possible noise reduction factor based on distance from town center.
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.
StringID tramtype
Type of tram on the tile.
static bool IsWater(TileIndex t)
Is it a plain water 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 bool CanRemoveRoadWithStop(TileIndex tile, DoCommandFlag flags)
Check if a drive-through road stop tile can be cleared.
static void Swap(T &a, T &b)
Type safe swap operation.
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.
static void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
Make the given tile a dock tile.
const AirportTileTable *const * table
list of the tiles composing the airport
@ CT_INVALID
Invalid cargo type.
uint64 _tick_counter
Ever incrementing tick counter for setting off various events.
static bool IsCargoInClass(CargoID c, CargoClass cc)
Does cargo c have cargo class cc?
static void SetAnimationFrame(TileIndex t, byte frame)
Set a new animation frame.
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.
static Point RemapCoords2(int x, int y)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap.
void GetTileArea(TileArea *ta, StationType type) const override
Get the tile area for a given station type.
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
GRFFileProps grf_prop
properties related the the grf file
void UpdateAllStationVirtCoords()
Update the virtual coords needed to draw the station sign for all stations.
@ OWNER_WATER
The tile/execution is done by "water".
@ NR_STATION
Reference station. Scroll to station when clicking on the news. Delete news when station is deleted.
uint8 exclusive_counter
months till the exclusivity expires
Date build_date
Date of construction.
#define lastof(x)
Get the last element of an fixed size array.
@ 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.
@ CBID_STATION_SPRITE_LAYOUT
Choose a sprite layout to draw, instead of the standard 0-7 range.
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.
uint Truncate(uint max_move=UINT_MAX, StationCargoAmountMap *cargo_per_source=nullptr)
Truncates where each destination loses roughly the same percentage of its cargo.
TileArea ship_station
Tile area the ship 'station' part covers.
uint GetRailtypeSpriteOffset() const
Offset between the current railtype and normal rail.
void ChangeShare(StationID st, int flow)
Change share for specified station.
VehicleEnterTileStatus
The returned bits of VehicleEnterTile.
GRFConfig * GetGRFConfig(uint32 grfid, uint32 mask)
Retrieve a NewGRF from the current config by its grfid.
@ 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.
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
uint GetFlowFromVia(StationID from, StationID via) const
Get the flow from a specific station via a specific other station.
virtual TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
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.
@ RVSB_ROAD_STOP_TRACKDIR_MASK
Only bits 0 and 3 are used to encode the trackdir for road stops.
GUISettings gui
settings related to the GUI
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 refit_cap
Capacity left over from before last refit.
static bool MayHaveRoad(TileIndex t)
Test whether a tile can have road/tram types.
static DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
Date date_of_last_service
Last date the vehicle had a service at a depot.
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.
AnimationInfo animation
Information about the animation.
struct RoadTypeInfo::@42 strings
Strings associated with the rail type.
static bool IsBridgeAbove(TileIndex t)
checks if a bridge is set above the ground of this tile
void AddAnimatedTile(TileIndex tile)
Add the given tile to the animated tile table (if it does not exist on that table yet).
@ INVALID_RAILTYPE
Flag for invalid railtype.
#define AllocaM(T, num_elements)
alloca() has to be called in the parent function, so define AllocaM() as a macro
uint16 road_speed
Speed limit of road (bridges and track)
@ INDUSTRYLIFE_EXTRACTIVE
Like mines.