Go to the documentation of this file.
15 #include "viewport_kdtree.h"
60 #include "table/strings.h"
111 if (!T::IsValidID(t) ||
Station::Get(t)->owner != company)
continue;
112 if (closest_station == INVALID_STATION) {
114 }
else if (closest_station != t) {
119 *st = (closest_station == INVALID_STATION) ?
nullptr : T::Get(closest_station);
140 for (
int dx = -3; dx <= 3; dx++) {
141 for (
int dy = -3; dy <= 3; dy++) {
197 #define M(x) ((x) - STR_SV_STNAME)
202 STATIONNAMING_AIRPORT,
203 STATIONNAMING_OILRIG,
205 STATIONNAMING_HELIPORT,
230 if (
GetIndustrySpec(indtype)->station_name == STR_UNDEFINED)
return false;
234 sni->
free_names &= ~(1 << M(STR_SV_STNAME_OILFIELD) | 1 << M(STR_SV_STNAME_MINES));
240 static const uint32 _gen_station_name_bits[] = {
243 1U << M(STR_SV_STNAME_AIRPORT),
244 1U << M(STR_SV_STNAME_OILFIELD),
245 1U << M(STR_SV_STNAME_DOCKS),
246 1U << M(STR_SV_STNAME_HELIPORT),
250 uint32 free_names = UINT32_MAX;
253 memset(indtypes, 0,
sizeof(indtypes));
256 if (s != st && s->town == t) {
257 if (s->indtype != IT_INVALID) {
258 indtypes[s->indtype] =
true;
260 if (name != STR_UNDEFINED) {
269 uint str = M(s->string_id);
271 if (str == M(STR_SV_STNAME_FOREST)) {
272 str = M(STR_SV_STNAME_WOODS);
288 return STR_SV_STNAME_FALLBACK;
296 uint32 tmp = free_names & _gen_station_name_bits[name_class];
300 if (
HasBit(free_names, M(STR_SV_STNAME_MINES))) {
302 return STR_SV_STNAME_MINES;
308 if (
HasBit(free_names, M(STR_SV_STNAME)))
return STR_SV_STNAME;
310 if (
HasBit(free_names, M(STR_SV_STNAME_CENTRAL)))
return STR_SV_STNAME_CENTRAL;
314 if (
HasBit(free_names, M(STR_SV_STNAME_LAKESIDE)) &&
317 return STR_SV_STNAME_LAKESIDE;
321 if (
HasBit(free_names, M(STR_SV_STNAME_WOODS)) && (
332 if (
HasBit(free_names, M(STR_SV_STNAME_VALLEY)))
return STR_SV_STNAME_VALLEY;
334 if (
HasBit(free_names, M(STR_SV_STNAME_HEIGHTS)))
return STR_SV_STNAME_HEIGHTS;
338 static const int8 _direction_and_table[] = {
339 ~( (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
340 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
341 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
342 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) ),
345 free_names &= _direction_and_table[
349 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));
350 return (tmp == 0) ? STR_SV_STNAME_FALLBACK : (STR_SV_STNAME +
FindFirstBit(tmp));
363 Station *best_station =
nullptr;
366 uint cur_dist = DistanceManhattan(tile, st->xy);
368 if (cur_dist < threshold) {
369 threshold = cur_dist;
371 }
else if (cur_dist == threshold && best_station !=
nullptr) {
373 if (st->
index < best_station->
index) best_station = st;
389 case STATION_AIRPORT:
406 default: NOT_REACHED();
417 pt.y -= 32 * ZOOM_LVL_BASE;
426 _viewport_sign_kdtree.
Insert(ViewportSignKdtreeItem::MakeStation(this->
index));
437 if (this->
xy == new_xy)
return;
441 this->BaseStation::MoveSign(new_xy);
454 void BaseStation::FillCachedName()
const
457 int64 args_array[] = { this->
index };
463 void ClearAllStationCachedNames()
491 for (uint i = 0; i < num_items; i++) {
509 std::set<IndustryID> industries;
516 AddProducedCargo(tile, produced);
522 for (IndustryID industry : industries) {
548 if (always_accepted !=
nullptr) *always_accepted = 0;
556 AddAcceptedCargo(tile, acceptance, always_accepted);
570 if (always_accepted !=
nullptr) *always_accepted = 0;
574 AddAcceptedCargo(tile, acceptance, always_accepted);
592 if (!st->
rect.IsEmpty()) {
598 uint amt = acceptance[i];
616 if (old_acc == new_acc)
return;
622 static const StringID accept_msg[] = {
623 STR_NEWS_STATION_NOW_ACCEPTS_CARGO,
624 STR_NEWS_STATION_NOW_ACCEPTS_CARGO_AND_CARGO,
626 static const StringID reject_msg[] = {
627 STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO,
628 STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_OR_CARGO,
642 accepts[num_acc++] = i;
647 rejects[num_rej++] = i;
661 static void UpdateStationSignCoord(
BaseStation *st)
665 if (r->IsEmpty())
return;
669 st->MoveSign(new_xy);
694 if (*st !=
nullptr) {
699 CommandCost ret = (*st)->rect.BeforeAddRect(area.
tile, area.
w, area.
h, StationRect::ADD_TEST);
700 if (ret.
Failed())
return ret;
707 _station_kdtree.
Insert((*st)->index);
710 (*st)->string_id = GenerateStationName(*st, area.
tile, name_class);
733 UpdateStationSignCoord(st);
752 case STATION_AIRPORT:
761 default: NOT_REACHED();
791 if (ret.
Failed())
return ret;
814 cost.
AddCost(_price[PR_BUILD_FOUNDATION]);
821 }
else if (allowed_z != flat_z) {
841 if (ret.
Failed())
return ret;
845 if (ret.
Failed())
return ret;
870 uint invalid_dirs = 5 << axis;
877 if (ret.
Failed())
return ret;
883 if (ret.
Failed())
return ret;
894 if (*station == INVALID_STATION) {
896 }
else if (*station != st) {
921 affected_vehicles.push_back(v);
925 if (ret.
Failed())
return ret;
932 if (ret.
Failed())
return ret;
959 if (ret.
Failed())
return ret;
978 if (*station == INVALID_STATION) {
980 }
else if (*station != st) {
1003 if (build_over_road) {
1005 RoadType road_rt = GetRoadType(cur_tile, RTT_ROAD);
1012 if (ret.
Failed())
return ret;
1020 if (ret.
Failed())
return ret;
1024 }
else if (RoadTypeIsRoad(rt)) {
1029 RoadType tram_rt = GetRoadType(cur_tile, RTT_TRAM);
1038 if (ret.
Failed())
return ret;
1045 }
else if (RoadTypeIsTram(rt)) {
1050 if (ret.
Failed())
return ret;
1086 static inline byte *CreateSingle(
byte *layout,
int n)
1089 do *layout++ = 0;
while (--i);
1090 layout[((n - 1) >> 1) - n] = 2;
1094 static inline byte *CreateMulti(
byte *layout,
int n,
byte b)
1097 do *layout++ = b;
while (--i);
1100 layout[n - 1 - n] = 0;
1114 if (statspec !=
nullptr && statspec->
layouts.size() >= plat_len &&
1115 statspec->
layouts[plat_len - 1].size() >= numtracks &&
1116 !statspec->
layouts[plat_len - 1][numtracks - 1].empty()) {
1118 memcpy(layout, statspec->
layouts[plat_len - 1][numtracks - 1].data(),
1119 plat_len * numtracks);
1123 if (plat_len == 1) {
1124 CreateSingle(layout, numtracks);
1126 if (numtracks & 1) layout = CreateSingle(layout, plat_len);
1127 int n = numtracks >> 1;
1130 layout = CreateMulti(layout, plat_len, 4);
1131 layout = CreateMulti(layout, plat_len, 6);
1147 template <
class T, StringID error_message>
1150 assert(*st ==
nullptr);
1151 bool check_surrounding =
true;
1154 if (existing_station != INVALID_STATION) {
1155 if (adjacent && existing_station != station_to_join) {
1162 *st = T::GetIfValid(existing_station);
1163 check_surrounding = (*st ==
nullptr);
1168 if (adjacent) check_surrounding =
false;
1172 if (check_surrounding) {
1175 if (ret.
Failed())
return ret;
1179 if (*st ==
nullptr && station_to_join != INVALID_STATION) *st = T::GetIfValid(station_to_join);
1195 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_RAILWAY_STATION_FIRST>(existing_station, station_to_join, adjacent, ta, st);
1209 return FindJoiningBaseStation<Waypoint, STR_ERROR_MUST_REMOVE_RAILWAYPOINT_FIRST>(existing_waypoint, waypoint_to_join, adjacent, ta, wp);
1256 RailType rt = Extract<RailType, 0, 6>(p1);
1257 Axis axis = Extract<Axis, 6, 1>(p1);
1258 byte numtracks =
GB(p1, 8, 8);
1259 byte plat_len =
GB(p1, 16, 8);
1260 bool adjacent =
HasBit(p1, 24);
1263 byte spec_index =
GB(p2, 8, 8);
1264 StationID station_to_join =
GB(p2, 16, 16);
1268 if (ret.
Failed())
return ret;
1275 if (plat_len == 0 || numtracks == 0)
return CMD_ERROR;
1286 bool reuse = (station_to_join != NEW_STATION);
1287 if (!reuse) station_to_join = INVALID_STATION;
1288 bool distant_join = (station_to_join != INVALID_STATION);
1295 TileArea new_location(tile_org, w_org, h_org);
1298 StationID est = INVALID_STATION;
1299 std::vector<Train *> affected_vehicles;
1302 if (cost.
Failed())
return cost;
1304 cost.
AddCost((numtracks * _price[PR_BUILD_STATION_RAIL] + _price[PR_BUILD_STATION_RAIL_LENGTH]) * plat_len);
1309 if (ret.
Failed())
return ret;
1311 ret =
BuildStationPart(&st, flags, reuse, new_location, STATIONNAMING_RAIL);
1312 if (ret.
Failed())
return ret;
1316 if (ret.
Failed())
return ret;
1324 if (statspec !=
nullptr) {
1342 byte numtracks_orig;
1348 st->
rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY);
1350 if (statspec !=
nullptr) {
1359 layout_ptr =
AllocaM(
byte, numtracks * plat_len);
1362 numtracks_orig = numtracks;
1370 byte layout = *layout_ptr++;
1375 affected_vehicles.push_back(v);
1400 if (statspec !=
nullptr) {
1415 TriggerStationAnimation(st, tile,
SAT_BUILT);
1423 }
while (--numtracks);
1425 for (uint i = 0; i < affected_vehicles.size(); ++i) {
1433 update_reservation_area =
TileArea(tile_org, 1, numtracks_orig);
1435 update_reservation_area =
TileArea(tile_org, numtracks_orig, 1);
1438 for (
TileIndex tile : update_reservation_area) {
1449 platform_begin = next_tile;
1452 platform_end = next_tile;
1456 bool reservation =
false;
1457 for (
TileIndex t = platform_begin; !reservation && t <= platform_end; t += tile_offset) {
1478 if (ta.
w != 0 && ta.
h != 0) {
1528 static void MakeRailStationAreaSmaller(
BaseStation *st)
1538 static void MakeShipStationAreaSmaller(
Station *st)
1541 UpdateStationDockingTiles(st);
1573 if (ret.
Failed())
continue;
1576 T *st = T::GetByTile(tile);
1577 if (st ==
nullptr)
continue;
1582 if (ret.
Failed())
continue;
1591 total_cost.
AddCost(-_price[PR_CLEAR_RAIL]);
1610 DoClearSquare(tile);
1616 st->rect.AfterRemoveTile(st, tile);
1622 include(affected_stations, st);
1630 for (T *st : affected_stations) {
1635 MakeRailStationAreaSmaller(st);
1636 UpdateStationSignCoord(st);
1647 total_cost.
AddCost(quantity * removal_cost);
1668 std::vector<Station *> affected_stations;
1671 if (ret.
Failed())
return ret;
1674 for (
Station *st : affected_stations) {
1677 st->MarkTilesDirty(
false);
1678 st->RecomputeCatchment();
1702 std::vector<Waypoint *> affected_stations;
1722 if (ret.
Failed())
return ret;
1728 assert(ta.
w != 0 && ta.
h != 0);
1734 if (st->TileBelongsToRailStation(tile)) {
1735 std::vector<T*> affected_stations;
1737 if (ret.
Failed())
return ret;
1792 if (*primary_stop ==
nullptr) {
1794 return primary_stop;
1798 while (stop->
next !=
nullptr) stop = stop->
next;
1816 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_ROAD_STOP_FIRST>(existing_stop, station_to_join, adjacent, ta, st);
1837 bool type =
HasBit(p2, 0);
1838 bool is_drive_through =
HasBit(p2, 1);
1839 RoadType rt = Extract<RoadType, 5, 6>(p2);
1841 StationID station_to_join =
GB(p2, 16, 16);
1842 bool reuse = (station_to_join != NEW_STATION);
1843 if (!reuse) station_to_join = INVALID_STATION;
1844 bool distant_join = (station_to_join != INVALID_STATION);
1846 uint8 width = (uint8)
GB(p1, 0, 8);
1847 uint8 length = (uint8)
GB(p1, 8, 8);
1852 if (width == 0 || length == 0)
return CMD_ERROR;
1856 TileArea roadstop_area(tile, width, length);
1861 if (!is_drive_through && RoadTypeIsTram(rt))
return CMD_ERROR;
1865 if (is_drive_through) {
1867 axis = Extract<Axis, 3, 1>(p2);
1871 ddir = Extract<DiagDirection, 3, 2>(p2);
1876 if (ret.
Failed())
return ret;
1880 StationID est = INVALID_STATION;
1881 ret =
CheckFlatLandRoadStop(roadstop_area, flags, is_drive_through ? 5 << axis : 1 << ddir, is_drive_through, type, axis, &est, rt);
1882 if (ret.
Failed())
return ret;
1887 if (ret.
Failed())
return ret;
1892 ret =
BuildStationPart(&st, flags, reuse, roadstop_area, STATIONNAMING_ROAD);
1893 if (ret.
Failed())
return ret;
1897 for (
TileIndex cur_tile : roadstop_area) {
1911 *currstop = road_stop;
1922 st->
rect.BeforeAddTile(cur_tile, StationRect::ADD_TRY);
1925 if (is_drive_through) {
1954 if (st !=
nullptr) {
1990 if (ret.
Failed())
return ret;
2005 assert(cur_stop !=
nullptr);
2013 if (ret.
Failed())
return ret;
2017 if (*primary_stop == cur_stop) {
2019 *primary_stop = cur_stop->
next;
2021 if (*primary_stop ==
nullptr) {
2027 while (pred->
next != cur_stop) pred = pred->
next;
2032 for (RoadTramType rtt : _roadtramtypes) {
2033 RoadType rt = GetRoadType(tile, rtt);
2044 DoClearSquare(tile);
2057 st->
rect.AfterRemoveTile(st, tile);
2087 uint8 width = (uint8)
GB(p1, 0, 8);
2088 uint8 height = (uint8)
GB(p1, 8, 8);
2089 bool keep_drive_through_roads = !
HasBit(p2, 1);
2092 if (width == 0 || height == 0)
return CMD_ERROR;
2098 TileArea roadstop_area(tile, width, height);
2101 CommandCost last_error(STR_ERROR_THERE_IS_NO_STATION);
2102 bool had_success =
false;
2104 for (
TileIndex cur_tile : roadstop_area) {
2113 for (RoadTramType rtt : _roadtramtypes) {
2114 road_type[rtt] = GetRoadType(cur_tile, rtt);
2134 road_owner[RTT_ROAD], road_owner[RTT_TRAM]);
2143 return had_success ? cost : last_error;
2168 uint noise_reduction = distance / town_tolerance_distance;
2187 Town *nearest =
nullptr;
2189 uint perimeter_min_x =
TileX(it);
2190 uint perimeter_min_y =
TileY(it);
2191 uint perimeter_max_x = perimeter_min_x + as->
size_x - 1;
2192 uint perimeter_max_y = perimeter_min_y + as->
size_y - 1;
2194 mindist = UINT_MAX - 1;
2196 std::unique_ptr<TileIterator> copy(it.
Clone());
2198 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) {
2200 if (t ==
nullptr)
continue;
2203 if (dist == mindist && t->
index < nearest->
index) nearest = t;
2204 if (dist < mindist) {
2246 StationID station_to_join =
GB(p2, 16, 16);
2247 bool reuse = (station_to_join != NEW_STATION);
2248 if (!reuse) station_to_join = INVALID_STATION;
2249 bool distant_join = (station_to_join != INVALID_STATION);
2250 byte airport_type =
GB(p1, 0, 8);
2251 byte layout =
GB(p1, 8, 8);
2258 if (ret.
Failed())
return ret;
2277 if (cost.
Failed())
return cost;
2285 StringID authority_refuse_message = STR_NULL;
2286 Town *authority_refuse_town =
nullptr;
2291 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE;
2292 authority_refuse_town = nearest;
2301 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
2302 authority_refuse_town = t;
2306 if (authority_refuse_message != STR_NULL) {
2313 if (ret.
Failed())
return ret;
2319 if (ret.
Failed())
return ret;
2326 cost.
AddCost(_price[PR_BUILD_STATION_AIRPORT]);
2339 st->
rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
2351 AirportTileAnimationTrigger(st, iter,
AAT_BUILT);
2381 if (ret.
Failed())
return ret;
2389 if (!a->IsNormalAircraft())
continue;
2390 if (a->targetairport == st->
index && a->state !=
FLYING) {
2417 if (!st->TileBelongsToAirport(tile_cur))
continue;
2420 if (ret.
Failed())
return ret;
2422 cost.
AddCost(_price[PR_CLEAR_STATION_AIRPORT]);
2426 DoClearSquare(tile_cur);
2469 if (ret.
Failed())
return ret;
2487 if ((v->
owner == company) == include_company) {
2489 if ((order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT)) && order->GetDestination() == station) {
2504 static const byte _dock_w_chk[4] = { 2, 1, 2, 1 };
2505 static const byte _dock_h_chk[4] = { 1, 2, 1, 2 };
2518 StationID station_to_join =
GB(p2, 16, 16);
2519 bool reuse = (station_to_join != NEW_STATION);
2520 if (!reuse) station_to_join = INVALID_STATION;
2521 bool distant_join = (station_to_join != INVALID_STATION);
2533 if (ret.
Failed())
return ret;
2539 if (ret.
Failed())
return ret;
2554 if (ret.
Failed())
return ret;
2562 _dock_w_chk[direction], _dock_h_chk[direction]);
2567 if (ret.
Failed())
return ret;
2573 if (ret.
Failed())
return ret;
2580 st->
rect.BeforeAddRect(dock_area.
tile, dock_area.
w, dock_area.
h, StationRect::ADD_TRY);
2590 UpdateStationDockingTiles(st);
2606 if (st !=
nullptr) UpdateStationDockingTiles(st);
2609 if (neutral !=
nullptr) UpdateStationDockingTiles(neutral);
2628 if (IsPossibleDockingTile(docking_tile)) {
2646 static const uint8 _valid_docking_tile[] = {
2653 assert(gfx <
lengthof(_valid_docking_tile));
2654 return HasBit(_valid_docking_tile[gfx], d);
2689 if (ret.
Failed())
return ret;
2699 if (ret.
Failed())
return ret;
2702 DoClearSquare(tile1);
2704 MakeWaterKeepingClass(tile2, st->
owner);
2706 st->
rect.AfterRemoveTile(st, tile1);
2707 st->
rect.AfterRemoveTile(st, tile2);
2709 MakeShipStationAreaSmaller(st);
2725 if (s->current_order.GetDestination() != st->
index) {
2740 s->SetDestTile(s->GetOrderStationLocation(st->
index));
2752 return &_station_display_datas[st][gfx];
2768 case SPR_RAIL_TRACK_X:
2769 case SPR_MONO_TRACK_X:
2770 case SPR_MGLV_TRACK_X:
2771 snow_desert =
false;
2772 *overlay_offset =
RTO_X;
2775 case SPR_RAIL_TRACK_Y:
2776 case SPR_MONO_TRACK_Y:
2777 case SPR_MGLV_TRACK_Y:
2778 snow_desert =
false;
2779 *overlay_offset =
RTO_Y;
2782 case SPR_RAIL_TRACK_X_SNOW:
2783 case SPR_MONO_TRACK_X_SNOW:
2784 case SPR_MGLV_TRACK_X_SNOW:
2786 *overlay_offset =
RTO_X;
2789 case SPR_RAIL_TRACK_Y_SNOW:
2790 case SPR_MONO_TRACK_Y_SNOW:
2791 case SPR_MGLV_TRACK_Y_SNOW:
2793 *overlay_offset =
RTO_Y;
2800 if (ti !=
nullptr) {
2816 *ground = snow_desert ? SPR_FLAT_SNOW_DESERT_TILE : SPR_FLAT_GRASS_TILE;
2820 static void DrawTile_Station(
TileInfo *ti)
2827 uint32 relocation = 0;
2828 uint32 ground_relocation = 0;
2831 uint tile_layout = 0;
2842 if (statspec !=
nullptr) {
2878 case APT_RADAR_GRASS_FENCE_SW:
2881 case APT_GRASS_FENCE_NE_FLAG:
2884 case APT_RADAR_FENCE_SW:
2887 case APT_RADAR_FENCE_NE:
2890 case APT_GRASS_FENCE_NE_FLAG_2:
2900 palette = COMPANY_SPRITE_COLOUR(owner);
2903 palette = PALETTE_TO_GREY;
2906 if (layout ==
nullptr && (t ==
nullptr || t->
seq ==
nullptr)) t = GetStationTileLayout(
GetStationType(ti->
tile), gfx);
2916 if (!HasFoundationNW(ti->
tile, slope, z))
SetBit(edge_info, 0);
2917 if (!HasFoundationNE(ti->
tile, slope, z))
SetBit(edge_info, 1);
2919 if (image == 0)
goto draw_default_foundation;
2924 static const uint8 foundation_parts[] = {
2937 static const uint8 composite_foundation_parts[] = {
2939 0x00, 0xD1, 0xE4, 0xE0,
2941 0xCA, 0xC9, 0xC4, 0xC0,
2943 0xD2, 0x91, 0xE4, 0xA0,
2948 uint8 parts = composite_foundation_parts[ti->
tileh];
2959 goto draw_default_foundation;
2963 for (
int i = 0; i < 8; i++) {
2974 draw_default_foundation:
2980 DrawWaterClassGround(ti);
2982 if (sprite != 0) total_offset = sprite - SPR_IMG_BUOY;
2985 DrawWaterClassGround(ti);
2991 DrawShoreTile(ti->
tileh);
2993 DrawClearLandTile(ti, 3);
2997 if (layout !=
nullptr) {
3006 t = &tmp_rail_layout;
3008 }
else if (statspec !=
nullptr) {
3052 uint sprite_offset = axis ==
AXIS_X ? 1 : 0;
3054 DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset);
3059 if (road_rti->UsesOverlay()) {
3080 int32 total_offset = 0;
3095 DrawSprite(ground + overlay_offset, PAL_NONE, x, y);
3104 uint sprite_offset = 5 - image;
3107 if (rti->UsesOverlay()) {
3109 DrawSprite(ground + sprite_offset, PAL_NONE, x, y);
3112 if (overlay)
DrawSprite(overlay + sprite_offset, PAL_NONE, x, y);
3113 }
else if (RoadTypeIsTram(roadtype)) {
3114 DrawSprite(SPR_TRAMWAY_TRAM + sprite_offset, PAL_NONE, x, y);
3118 if (RoadTypeIsRoad(roadtype) && rti->UsesOverlay()) {
3129 static int GetSlopePixelZ_Station(
TileIndex tile, uint x, uint y)
3144 RoadType road_rt = GetRoadTypeRoad(tile);
3145 RoadType tram_rt = GetRoadTypeTram(tile);
3168 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER;
3169 td->
owner[i] = road_owner;
3173 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER;
3174 td->
owner[i] = tram_owner;
3185 if (spec !=
nullptr) {
3219 default: NOT_REACHED();
3220 case STATION_RAIL: str = STR_LAI_STATION_DESCRIPTION_RAILROAD_STATION;
break;
3221 case STATION_AIRPORT:
3222 str = (
IsHangar(tile) ? STR_LAI_STATION_DESCRIPTION_AIRCRAFT_HANGAR : STR_LAI_STATION_DESCRIPTION_AIRPORT);
3224 case STATION_TRUCK: str = STR_LAI_STATION_DESCRIPTION_TRUCK_LOADING_AREA;
break;
3225 case STATION_BUS: str = STR_LAI_STATION_DESCRIPTION_BUS_STATION;
break;
3226 case STATION_OILRIG: {
3234 case STATION_DOCK: str = STR_LAI_STATION_DESCRIPTION_SHIP_DOCK;
break;
3235 case STATION_BUOY: str = STR_LAI_STATION_DESCRIPTION_BUOY;
break;
3236 case STATION_WAYPOINT: str = STR_LAI_STATION_DESCRIPTION_WAYPOINT;
break;
3266 RoadTramType rtt = (RoadTramType)sub_mode;
3288 static void TileLoop_Station(
TileIndex tile)
3293 case STATION_AIRPORT:
3301 case STATION_OILRIG:
3311 static void AnimateTile_Station(
TileIndex tile)
3314 AnimateStationTile(tile);
3319 AnimateAirportTile(tile);
3324 static bool ClickTile_Station(
TileIndex tile)
3368 }
else if (x < stop) {
3370 uint16 spd = std::max(0, (stop - x) * 20 - 15);
3371 if (spd < v->cur_speed) v->
cur_speed = spd;
3394 CargoTypes cargoes = 0;
3400 if (cargoes == 0)
return;
3438 static inline void byte_inc_sat(
byte *p)
3455 StationCargoAmountMap waiting_per_source;
3457 for (StationCargoAmountMap::iterator i(waiting_per_source.begin()); i != waiting_per_source.end(); ++i) {
3459 if (source_station ==
nullptr)
continue;
3466 static void UpdateStationRating(
Station *st)
3468 bool waiting_changed =
false;
3470 byte_inc_sat(&st->time_since_load);
3471 byte_inc_sat(&st->time_since_unload);
3489 waiting_changed =
true;
3508 uint waiting_avg = waiting / (num_dests + 1);
3519 | (std::min<uint>(last_speed, 0xFFu) << 24);
3521 uint32 var10 = (st->last_vehicle_type ==
VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10);
3525 rating =
GB(callback, 0, 14);
3528 if (
HasBit(callback, 14)) rating -= 0x4000;
3534 if (b >= 0) rating += b >> 2;
3537 if (st->last_vehicle_type ==
VEH_SHIP) waittime >>= 2;
3538 if (waittime <= 21) rating += 25;
3539 if (waittime <= 12) rating += 25;
3540 if (waittime <= 6) rating += 45;
3541 if (waittime <= 3) rating += 35;
3554 if (age < 3) rating += 10;
3555 if (age < 2) rating += 10;
3556 if (age < 1) rating += 13;
3566 if (rating <= 64 && waiting_avg >= 100) {
3567 int dec = Random() & 0x1F;
3568 if (waiting_avg < 200) dec &= 7;
3569 waiting -= (dec + 1) * num_dests;
3570 waiting_changed =
true;
3574 if (rating <= 127 && waiting != 0) {
3575 uint32 r = Random();
3576 if (rating <= (
int)
GB(r, 0, 7)) {
3578 waiting = std::max((
int)waiting - (
int)((
GB(r, 8, 2) - 1) * num_dests), 0);
3579 waiting_changed =
true;
3586 static const uint WAITING_CARGO_THRESHOLD = 1 << 12;
3587 static const uint WAITING_CARGO_CUT_FACTOR = 1 << 6;
3588 static const uint MAX_WAITING_CARGO = 1 << 15;
3590 if (waiting > WAITING_CARGO_THRESHOLD) {
3591 uint difference = waiting - WAITING_CARGO_THRESHOLD;
3592 waiting -= (difference / WAITING_CARGO_CUT_FACTOR);
3594 waiting = std::min(waiting, MAX_WAITING_CARGO);
3595 waiting_changed =
true;
3600 if (waiting_changed && waiting < ge->cargo.AvailableCount()) {
3614 StationID index = st->
index;
3615 if (waiting_changed) {
3638 for (std::list<Vehicle *>::iterator it(st->loading_vehicles.begin()); it != st->loading_vehicles.end(); ++it) {
3639 for (
Vehicle *v = *it; v !=
nullptr; v = v->
Next()) {
3660 if (lg ==
nullptr)
continue;
3663 Edge edge = it->second;
3670 bool updated =
false;
3672 if (auto_distributed) {
3675 std::vector<Vehicle *> vehicles;
3677 bool found_from =
false;
3678 bool found_to =
false;
3679 for (
Order *order = l->GetFirstOrder(); order !=
nullptr; order = order->
next) {
3680 if (!order->IsType(OT_GOTO_STATION) && !order->IsType(OT_IMPLICIT))
continue;
3681 if (order->GetDestination() == from->
index) {
3683 if (found_to)
break;
3684 }
else if (order->GetDestination() == to->
index) {
3686 if (found_from)
break;
3689 if (!found_to || !found_from)
continue;
3690 vehicles.push_back(l->GetFirstSharedVehicle());
3693 auto iter = vehicles.begin();
3694 while (iter != vehicles.end()) {
3708 *iter = next_shared;
3711 iter = vehicles.erase(iter);
3714 if (iter == vehicles.end()) iter = vehicles.begin();
3762 Debug(misc, 0,
"Can't allocate link graph");
3771 }
else if (ge2.
link_graph == INVALID_LINK_GRAPH) {
3789 if (lg !=
nullptr) {
3790 (*lg)[ge1.
node].UpdateEdge(ge2.
node, capacity, usage, time, mode);
3802 for (
const Vehicle *v = front; v !=
nullptr; v = v->
Next()) {
3817 static void StationHandleSmallTick(
BaseStation *st)
3828 void OnTick_Station()
3830 if (_game_mode == GM_EDITOR)
return;
3833 StationHandleSmallTick(st);
3865 void ModifyStationRatingAround(
TileIndex tile,
Owner owner,
int amount, uint radius)
3869 for (CargoID i = 0; i < NUM_CARGO; i++) {
3870 GoodsEntry *ge = &st->goods[i];
3872 if (ge->status != 0) {
3873 ge->rating = Clamp(ge->rating + amount, 0, 255);
3892 if (amount == 0)
return 0;
3904 Debug(misc, 0,
"Can't allocate link graph");
3909 if (lg !=
nullptr) (*lg)[ge.
node].UpdateSupply(amount);
3925 static bool IsUniqueStationName(
const std::string &name)
3928 if (!st->
name.empty() && st->
name == name)
return false;
3949 if (ret.
Failed())
return ret;
3951 bool reset = text.empty();
3955 if (!IsUniqueStationName(text))
return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
3976 if (st->TileIsInCatchment(tile)) stations->insert(st);
3989 assert(this->
w == 1 && this->
h == 1);
3990 AddNearbyStationsByCatchment(this->tile, &this->stations, Town::GetByTile(this->tile)->stations_near);
3993 this->stations.insert(st);
4003 static bool CanMoveGoodsToStation(
const Station *st,
CargoID type)
4027 if (all_stations->empty())
return 0;
4028 if (amount == 0)
return 0;
4030 Station *first_station =
nullptr;
4031 typedef std::pair<Station *, uint> StationInfo;
4032 std::vector<StationInfo> used_stations;
4034 for (
Station *st : *all_stations) {
4036 if (!CanMoveGoodsToStation(st, type))
continue;
4040 if (first_station ==
nullptr) {
4044 if (used_stations.empty()) {
4045 used_stations.reserve(2);
4046 used_stations.emplace_back(std::make_pair(first_station, 0));
4048 used_stations.emplace_back(std::make_pair(st, 0));
4052 if (first_station ==
nullptr)
return 0;
4054 if (used_stations.empty()) {
4057 return UpdateStationWaiting(first_station, type, amount, source_type, source_id);
4062 uint best_rating = 0;
4065 for (
auto &p : used_stations) {
4066 auto owner = p.first->owner;
4067 auto rating = p.first->goods[type].rating;
4068 if (rating > company_best[owner]) {
4069 best_sum += rating - company_best[owner];
4070 company_best[owner] = rating;
4071 if (rating > best_rating) best_rating = rating;
4073 company_sum[owner] += rating;
4078 amount *= best_rating + 1;
4081 for (
auto &p : used_stations) {
4082 uint owner = p.first->owner;
4085 p.second = amount * company_best[owner] * p.first->goods[type].rating / best_sum / company_sum[owner];
4090 if (amount > moving) {
4091 std::stable_sort(used_stations.begin(), used_stations.end(), [type](
const StationInfo &a,
const StationInfo &b) {
4092 return b.first->goods[type].rating < a.first->goods[type].rating;
4095 assert(amount - moving <= used_stations.size());
4096 for (uint i = 0; i < amount - moving; i++) {
4097 used_stations[i].second++;
4102 for (
auto &p : used_stations) {
4103 moved += UpdateStationWaiting(p.first, type, p.second, source_type, source_id);
4109 void UpdateStationDockingTiles(
Station *st)
4123 int x2 = std::min<int>(x + area->
w + 1,
MapSizeX());
4124 int x1 = std::max<int>(x - 1, 0);
4126 int y2 = std::min<int>(y + area->
h + 1,
MapSizeY());
4127 int y1 = std::max<int>(y - 1, 0);
4138 Debug(misc, 0,
"Can't allocate station for oilrig at 0x{:X}, reverting to oilrig only", tile);
4146 st->
string_id = GenerateStationName(st, tile, STATIONNAMING_OILRIG);
4161 UpdateStationDockingTiles(st);
4163 st->
rect.BeforeAddTile(tile, StationRect::ADD_FORCE);
4188 for (RoadTramType rtt : _roadtramtypes) {
4191 RoadType rt = GetRoadType(tile, rtt);
4215 case STATION_WAYPOINT:
4306 case STATION_WAYPOINT:
return_cmd_error(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
4307 case STATION_AIRPORT:
return_cmd_error(STR_ERROR_MUST_DEMOLISH_AIRPORT_FIRST);
4308 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);
4309 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);
4312 case STATION_OILRIG:
4313 SetDParam(1, STR_INDUSTRY_NAME_OIL_RIG);
4332 case STATION_BUOY:
return RemoveBuoy(tile, flags);
4333 case STATION_DOCK:
return RemoveDock(tile, flags);
4348 case STATION_WAYPOINT:
4349 case STATION_RAIL: {
4356 case STATION_AIRPORT:
4384 for (SharesMap::const_iterator it = this->
shares.begin(); it != this->shares.end(); ++it) {
4385 if (it->second == st) {
4386 return it->first - prev;
4403 assert(!this->
shares.empty());
4405 assert(it != this->
shares.end() && it->first <= this->unrestricted);
4406 if (it->second != excluded && it->second != excluded2)
return it->second;
4411 uint end = it->first;
4412 uint begin = (it == this->
shares.begin() ? 0 : (--it)->first);
4413 uint interval = end - begin;
4414 if (interval >= this->
unrestricted)
return INVALID_STATION;
4417 SharesMap::const_iterator it2 = (rand < begin) ? this->
shares.upper_bound(rand) :
4418 this->
shares.upper_bound(rand + interval);
4419 assert(it2 != this->
shares.end() && it2->first <= this->unrestricted);
4420 if (it2->second != excluded && it2->second != excluded2)
return it2->second;
4425 uint end2 = it2->first;
4426 uint begin2 = (it2 == this->
shares.begin() ? 0 : (--it2)->first);
4427 uint interval2 = end2 - begin2;
4428 if (interval2 >= new_max)
return INVALID_STATION;
4429 new_max -= interval2;
4430 if (begin > begin2) {
4431 Swap(begin, begin2);
4433 Swap(interval, interval2);
4438 it3 = this->
shares.upper_bound(rand);
4439 }
else if (rand < begin2 - interval) {
4440 it3 = this->
shares.upper_bound(rand + interval);
4442 it3 = this->
shares.upper_bound(rand + interval + interval2);
4444 assert(it3 != this->
shares.end() && it3->first <= this->unrestricted);
4455 assert(!this->
shares.empty());
4456 SharesMap new_shares;
4458 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4459 new_shares[++i] = it->second;
4460 if (it->first == this->unrestricted) this->
unrestricted = i;
4462 this->
shares.swap(new_shares);
4463 assert(!this->
shares.empty() && this->unrestricted <= (--this->shares.end())->first);
4476 assert(!this->
shares.empty());
4478 uint removed_shares = 0;
4479 uint added_shares = 0;
4480 uint last_share = 0;
4481 SharesMap new_shares;
4482 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4483 if (it->second == st) {
4485 uint share = it->first - last_share;
4486 if (flow == INT_MIN || (uint)(-flow) >= share) {
4487 removed_shares += share;
4488 if (it->first <= this->unrestricted) this->
unrestricted -= share;
4489 if (flow != INT_MIN) flow += share;
4490 last_share = it->first;
4493 removed_shares += (uint)(-flow);
4495 added_shares += (uint)(flow);
4497 if (it->first <= this->unrestricted) this->
unrestricted += flow;
4503 new_shares[it->first + added_shares - removed_shares] = it->second;
4504 last_share = it->first;
4507 new_shares[last_share + (uint)flow] = st;
4514 this->
shares.swap(new_shares);
4524 assert(!this->
shares.empty());
4526 uint last_share = 0;
4527 SharesMap new_shares;
4528 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4530 if (it->first > this->unrestricted)
return;
4531 if (it->second == st) {
4532 flow = it->first - last_share;
4535 new_shares[it->first] = it->second;
4538 new_shares[it->first - flow] = it->second;
4540 last_share = it->first;
4542 if (flow == 0)
return;
4543 new_shares[last_share + flow] = st;
4544 this->
shares.swap(new_shares);
4545 assert(!this->
shares.empty());
4555 assert(!this->
shares.empty());
4557 uint next_share = 0;
4559 for (SharesMap::reverse_iterator it(this->
shares.rbegin()); it != this->shares.rend(); ++it) {
4560 if (it->first < this->unrestricted)
return;
4562 flow = next_share - it->first;
4566 if (it->first == this->unrestricted)
return;
4567 if (it->second == st) found =
true;
4569 next_share = it->first;
4571 if (flow == 0)
return;
4572 SharesMap new_shares;
4573 new_shares[flow] = st;
4574 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4575 if (it->second != st) {
4576 new_shares[flow + it->first] = it->second;
4581 this->
shares.swap(new_shares);
4582 assert(!this->
shares.empty());
4592 assert(runtime > 0);
4593 SharesMap new_shares;
4595 for (SharesMap::iterator i = this->
shares.begin(); i != this->shares.end(); ++i) {
4596 share = std::max(share + 1, i->first * 30 / runtime);
4597 new_shares[share] = i->second;
4600 this->
shares.swap(new_shares);
4611 FlowStatMap::iterator origin_it = this->find(origin);
4612 if (origin_it == this->end()) {
4613 this->insert(std::make_pair(origin,
FlowStat(via, flow)));
4615 origin_it->second.ChangeShare(via, flow);
4616 assert(!origin_it->second.GetShares()->empty());
4630 FlowStatMap::iterator prev_it = this->find(origin);
4631 if (prev_it == this->end()) {
4634 this->insert(std::make_pair(origin, fs));
4636 prev_it->second.ChangeShare(via, flow);
4637 prev_it->second.ChangeShare(INVALID_STATION, flow);
4638 assert(!prev_it->second.GetShares()->empty());
4648 for (FlowStatMap::iterator i = this->begin(); i != this->end(); ++i) {
4650 uint local = fs.
GetShare(INVALID_STATION);
4651 if (local > INT_MAX) {
4674 for (FlowStatMap::iterator f_it = this->begin(); f_it != this->end();) {
4678 ret.
Push(f_it->first);
4679 this->erase(f_it++);
4693 for (FlowStatMap::iterator it = this->begin(); it != this->end(); ++it) {
4694 it->second.RestrictShare(via);
4704 for (FlowStatMap::iterator it = this->begin(); it != this->end(); ++it) {
4705 it->second.ReleaseShare(via);
4716 for (FlowStatMap::const_iterator i = this->begin(); i != this->end(); ++i) {
4717 ret += (--(i->second.GetShares()->end()))->first;
4730 for (FlowStatMap::const_iterator i = this->begin(); i != this->end(); ++i) {
4731 ret += i->second.GetShare(via);
4743 FlowStatMap::const_iterator i = this->find(from);
4744 if (i == this->end())
return 0;
4745 return (--(i->second.GetShares()->end()))->first;
4756 FlowStatMap::const_iterator i = this->find(from);
4757 if (i == this->end())
return 0;
4758 return i->second.GetShare(via);
4763 GetSlopePixelZ_Station,
4766 GetTileDesc_Station,
4767 GetTileTrackStatus_Station,
4769 AnimateTile_Station,
4771 ChangeTileOwner_Station,
4773 VehicleEnter_Station,
4774 GetFoundation_Station,
4775 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.
uint32 TileIndex
The index/ID of a 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.
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.
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
static CargoArray GetAcceptanceAroundStation(const Station *st, CargoTypes *always_accepted)
Get the acceptance of cargoes around the station in.
uint unrestricted
Limit for unrestricted shares.
bool IsType(OrderType type) const
Check whether this order is of the given type.
static 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.
void DrawRoadOverlays(const TileInfo *ti, PaletteID pal, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rti, uint road_offset, uint tram_offset)
Draw road underlay and overlay sprites.
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.
StationGfx GetStationGfx() const
Get the StationGfx for the current tile.
static bool HasTileWaterClass(TileIndex t)
Checks whether the tile has an waterclass associated.
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.
@ TRANSPORT_RAIL
Transport by train.
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,...
@ 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
@ NR_STATION
Reference station. Scroll to station when clicking on the news. Delete news when station is deleted.
StringID name
name of this airport
@ INVALID_ROADTYPE
flag for invalid roadtype
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.
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
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.
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.
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.
@ ROAD_X
Full road along the x-axis (south-west + north-east)
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.
WaterClass
classes of water (for WATER_TILE_CLEAR water tile type).
static RoadStop * GetByTile(TileIndex tile, RoadStopType type)
Find a roadstop at given tile.
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.
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.
@ CMD_REMOVE_FROM_RAIL_WAYPOINT
remove a (rectangle of) tiles from a rail waypoint
@ 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.
TransportType
Available types of transport.
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.
Trackdir GetVehicleTrackdir() const
Get the tracks of the train vehicle.
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.
CommandCost CmdRemoveFromRailWaypoint(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove a single tile from a waypoint.
@ 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.
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.
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.
CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove bus or truck stops.
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.
@ ROADSTOP_BUS
A standard stop for buses.
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.
@ 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.
@ TRANSPORT_ROAD
Transport by road vehicle.
RoadBits
Enumeration for the road parts on a tile.
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.
@ ROAD_NONE
No road-part is build.
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 to tiles from a TileIndexDiffC struct.
OrderSettings order
settings related to orders
static RoadBits GetRoadBits(TileIndex t, RoadTramType rtt)
Get the present road bits for a specific road 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.
@ WATER_CLASS_INVALID
Used for industry tiles on land (also for oilrig if newgrf says so).
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
CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Place an Airport.
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.
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.
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
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?
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.
@ DRD_NONE
None of the directions are disallowed.
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 to 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.
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.
CommandCost CmdOpenCloseAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Open/close an airport to incoming aircraft.
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.
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.
uint16 _tick_counter
Ever incrementing (and sometimes wrapping) tick counter for setting off various events.
NewGRF supplied spritelayout.
CommandCost CmdRemoveFromRailStation(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Remove a single tile from a rail station.
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.
@ ROADSTOP_TRUCK
A standard stop for trucks.
@ 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.
@ CMD_REMOVE_SINGLE_RAIL
remove a single rail track
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.
Slope
Enumeration for the slope-type.
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.
@ WATER_CLASS_CANAL
Canal.
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?
CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build rail station.
RoadType
The different roadtypes we support.
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.
RoadStop * truck_stops
All the truck stops.
@ CMD_REMOVE_FROM_RAIL_STATION
remove a (rectangle of) tiles from a rail station
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.
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.
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.
RoadStopType
Types of RoadStops.
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.
@ CMD_REMOVE_ROAD_STOP
remove a road stop
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
@ TRANSPORT_WATER
Transport over water.
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?
@ ROAD_Y
Full road along the y-axis (north-west + south-east)
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.
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.
BitmapTileArea catchment_tiles
NOSAVE: Set of individual tiles covered by catchment area.
void Merge(LinkGraph *other)
Merge a link graph with another one.
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.
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.
StationSpecList * speclist
List of station specs of this station.
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
#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.
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.
@ NT_ACCEPTANCE
A type of cargo is (no longer) accepted.
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 const TileIndex INVALID_TILE
The very nice invalid tile marker.
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
Axis
Allow incrementing of DiagDirDiff variables.
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.
@ 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.
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".
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.
CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build a bus or truck stop.
void ChangeShare(StationID st, int flow)
Change share for specified station.
VehicleEnterTileStatus
The returned bits of VehicleEnterTile.
@ CMD_LANDSCAPE_CLEAR
demolish a tile
GRFConfig * GetGRFConfig(uint32 grfid, uint32 mask)
Retrieve a NewGRF from the current config by its grfid.
@ FLYING
Vehicle is flying in the air.
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
uint8 FindFirstBit(uint32 x)
Search the first set bit in a 32 bit variable.
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
CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Rename a station.
Train * GetTrainForReservation(TileIndex tile, Track track)
Find the train which has reserved a specific path.
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.
CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
Build a dock/haven.
#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.