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);
748 MarkCatchmentTilesDirty();
751 MarkCatchmentTilesDirty();
759 case STATION_AIRPORT:
768 default: NOT_REACHED();
798 if (ret.
Failed())
return ret;
821 cost.
AddCost(_price[PR_BUILD_FOUNDATION]);
828 }
else if (allowed_z != flat_z) {
848 if (ret.
Failed())
return ret;
852 if (ret.
Failed())
return ret;
877 uint invalid_dirs = 5 << axis;
884 if (ret.
Failed())
return ret;
890 if (ret.
Failed())
return ret;
901 if (*station == INVALID_STATION) {
903 }
else if (*station != st) {
928 affected_vehicles.push_back(v);
932 if (ret.
Failed())
return ret;
939 if (ret.
Failed())
return ret;
966 if (ret.
Failed())
return ret;
985 if (*station == INVALID_STATION) {
987 }
else if (*station != st) {
1010 if (build_over_road) {
1012 RoadType road_rt = GetRoadType(cur_tile, RTT_ROAD);
1019 if (ret.
Failed())
return ret;
1027 if (ret.
Failed())
return ret;
1031 }
else if (RoadTypeIsRoad(rt)) {
1036 RoadType tram_rt = GetRoadType(cur_tile, RTT_TRAM);
1045 if (ret.
Failed())
return ret;
1052 }
else if (RoadTypeIsTram(rt)) {
1057 if (ret.
Failed())
return ret;
1093 static inline byte *CreateSingle(
byte *layout,
int n)
1096 do *layout++ = 0;
while (--i);
1097 layout[((n - 1) >> 1) - n] = 2;
1101 static inline byte *CreateMulti(
byte *layout,
int n,
byte b)
1104 do *layout++ = b;
while (--i);
1107 layout[n - 1 - n] = 0;
1121 if (statspec !=
nullptr && statspec->
layouts.size() >= plat_len &&
1122 statspec->
layouts[plat_len - 1].size() >= numtracks &&
1123 !statspec->
layouts[plat_len - 1][numtracks - 1].empty()) {
1125 memcpy(layout, statspec->
layouts[plat_len - 1][numtracks - 1].data(),
1126 plat_len * numtracks);
1130 if (plat_len == 1) {
1131 CreateSingle(layout, numtracks);
1133 if (numtracks & 1) layout = CreateSingle(layout, plat_len);
1134 int n = numtracks >> 1;
1137 layout = CreateMulti(layout, plat_len, 4);
1138 layout = CreateMulti(layout, plat_len, 6);
1154 template <
class T, StringID error_message>
1157 assert(*st ==
nullptr);
1158 bool check_surrounding =
true;
1161 if (existing_station != INVALID_STATION) {
1162 if (adjacent && existing_station != station_to_join) {
1169 *st = T::GetIfValid(existing_station);
1170 check_surrounding = (*st ==
nullptr);
1175 if (adjacent) check_surrounding =
false;
1179 if (check_surrounding) {
1182 if (ret.
Failed())
return ret;
1186 if (*st ==
nullptr && station_to_join != INVALID_STATION) *st = T::GetIfValid(station_to_join);
1202 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_RAILWAY_STATION_FIRST>(existing_station, station_to_join, adjacent, ta, st);
1216 return FindJoiningBaseStation<Waypoint, STR_ERROR_MUST_REMOVE_RAILWAYPOINT_FIRST>(existing_waypoint, waypoint_to_join, adjacent, ta, wp);
1263 RailType rt = Extract<RailType, 0, 6>(p1);
1264 Axis axis = Extract<Axis, 6, 1>(p1);
1265 byte numtracks =
GB(p1, 8, 8);
1266 byte plat_len =
GB(p1, 16, 8);
1267 bool adjacent =
HasBit(p1, 24);
1270 byte spec_index =
GB(p2, 8, 8);
1271 StationID station_to_join =
GB(p2, 16, 16);
1275 if (ret.
Failed())
return ret;
1282 if (plat_len == 0 || numtracks == 0)
return CMD_ERROR;
1293 bool reuse = (station_to_join != NEW_STATION);
1294 if (!reuse) station_to_join = INVALID_STATION;
1295 bool distant_join = (station_to_join != INVALID_STATION);
1302 TileArea new_location(tile_org, w_org, h_org);
1305 StationID est = INVALID_STATION;
1306 std::vector<Train *> affected_vehicles;
1309 if (cost.
Failed())
return cost;
1311 cost.
AddCost((numtracks * _price[PR_BUILD_STATION_RAIL] + _price[PR_BUILD_STATION_RAIL_LENGTH]) * plat_len);
1316 if (ret.
Failed())
return ret;
1318 ret =
BuildStationPart(&st, flags, reuse, new_location, STATIONNAMING_RAIL);
1319 if (ret.
Failed())
return ret;
1323 if (ret.
Failed())
return ret;
1331 if (statspec !=
nullptr) {
1349 byte numtracks_orig;
1355 st->
rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY);
1357 if (statspec !=
nullptr) {
1366 layout_ptr =
AllocaM(
byte, numtracks * plat_len);
1369 numtracks_orig = numtracks;
1377 byte layout = *layout_ptr++;
1382 affected_vehicles.push_back(v);
1407 if (statspec !=
nullptr) {
1422 TriggerStationAnimation(st, tile,
SAT_BUILT);
1430 }
while (--numtracks);
1432 for (uint i = 0; i < affected_vehicles.size(); ++i) {
1440 update_reservation_area =
TileArea(tile_org, 1, numtracks_orig);
1442 update_reservation_area =
TileArea(tile_org, numtracks_orig, 1);
1445 for (
TileIndex tile : update_reservation_area) {
1456 platform_begin = next_tile;
1459 platform_end = next_tile;
1463 bool reservation =
false;
1464 for (
TileIndex t = platform_begin; !reservation && t <= platform_end; t += tile_offset) {
1485 if (ta.
w != 0 && ta.
h != 0) {
1535 static void MakeRailStationAreaSmaller(
BaseStation *st)
1545 static void MakeShipStationAreaSmaller(
Station *st)
1548 UpdateStationDockingTiles(st);
1580 if (ret.
Failed())
continue;
1583 T *st = T::GetByTile(tile);
1584 if (st ==
nullptr)
continue;
1589 if (ret.
Failed())
continue;
1598 total_cost.
AddCost(-_price[PR_CLEAR_RAIL]);
1617 DoClearSquare(tile);
1623 st->rect.AfterRemoveTile(st, tile);
1629 include(affected_stations, st);
1637 for (T *st : affected_stations) {
1642 MakeRailStationAreaSmaller(st);
1643 UpdateStationSignCoord(st);
1649 MarkCatchmentTilesDirty();
1655 total_cost.
AddCost(quantity * removal_cost);
1676 std::vector<Station *> affected_stations;
1679 if (ret.
Failed())
return ret;
1682 for (
Station *st : affected_stations) {
1685 st->MarkTilesDirty(
false);
1686 MarkCatchmentTilesDirty();
1687 st->RecomputeCatchment();
1711 std::vector<Waypoint *> affected_stations;
1731 if (ret.
Failed())
return ret;
1737 assert(ta.
w != 0 && ta.
h != 0);
1743 if (st->TileBelongsToRailStation(tile)) {
1744 std::vector<T*> affected_stations;
1746 if (ret.
Failed())
return ret;
1801 if (*primary_stop ==
nullptr) {
1803 return primary_stop;
1807 while (stop->
next !=
nullptr) stop = stop->
next;
1825 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_ROAD_STOP_FIRST>(existing_stop, station_to_join, adjacent, ta, st);
1846 bool type =
HasBit(p2, 0);
1847 bool is_drive_through =
HasBit(p2, 1);
1848 RoadType rt = Extract<RoadType, 5, 6>(p2);
1850 StationID station_to_join =
GB(p2, 16, 16);
1851 bool reuse = (station_to_join != NEW_STATION);
1852 if (!reuse) station_to_join = INVALID_STATION;
1853 bool distant_join = (station_to_join != INVALID_STATION);
1855 uint8 width = (uint8)
GB(p1, 0, 8);
1856 uint8 length = (uint8)
GB(p1, 8, 8);
1861 if (width == 0 || length == 0)
return CMD_ERROR;
1865 TileArea roadstop_area(tile, width, length);
1870 if (!is_drive_through && RoadTypeIsTram(rt))
return CMD_ERROR;
1874 if (is_drive_through) {
1876 axis = Extract<Axis, 3, 1>(p2);
1880 ddir = Extract<DiagDirection, 3, 2>(p2);
1885 if (ret.
Failed())
return ret;
1889 StationID est = INVALID_STATION;
1890 ret =
CheckFlatLandRoadStop(roadstop_area, flags, is_drive_through ? 5 << axis : 1 << ddir, is_drive_through, type, axis, &est, rt);
1891 if (ret.
Failed())
return ret;
1896 if (ret.
Failed())
return ret;
1901 ret =
BuildStationPart(&st, flags, reuse, roadstop_area, STATIONNAMING_ROAD);
1902 if (ret.
Failed())
return ret;
1906 for (
TileIndex cur_tile : roadstop_area) {
1920 *currstop = road_stop;
1931 st->
rect.BeforeAddTile(cur_tile, StationRect::ADD_TRY);
1934 if (is_drive_through) {
1962 if (st !=
nullptr) {
1999 if (ret.
Failed())
return ret;
2014 assert(cur_stop !=
nullptr);
2022 if (ret.
Failed())
return ret;
2026 if (*primary_stop == cur_stop) {
2028 *primary_stop = cur_stop->
next;
2030 if (*primary_stop ==
nullptr) {
2036 while (pred->
next != cur_stop) pred = pred->
next;
2041 for (RoadTramType rtt : _roadtramtypes) {
2042 RoadType rt = GetRoadType(tile, rtt);
2053 DoClearSquare(tile);
2066 st->
rect.AfterRemoveTile(st, tile);
2096 uint8 width = (uint8)
GB(p1, 0, 8);
2097 uint8 height = (uint8)
GB(p1, 8, 8);
2098 bool keep_drive_through_roads = !
HasBit(p2, 1);
2101 if (width == 0 || height == 0)
return CMD_ERROR;
2107 TileArea roadstop_area(tile, width, height);
2110 CommandCost last_error(STR_ERROR_THERE_IS_NO_STATION);
2111 bool had_success =
false;
2113 for (
TileIndex cur_tile : roadstop_area) {
2122 for (RoadTramType rtt : _roadtramtypes) {
2123 road_type[rtt] = GetRoadType(cur_tile, rtt);
2143 road_owner[RTT_ROAD], road_owner[RTT_TRAM]);
2152 return had_success ? cost : last_error;
2177 uint noise_reduction = distance / town_tolerance_distance;
2196 Town *nearest =
nullptr;
2198 uint perimeter_min_x =
TileX(it);
2199 uint perimeter_min_y =
TileY(it);
2200 uint perimeter_max_x = perimeter_min_x + as->
size_x - 1;
2201 uint perimeter_max_y = perimeter_min_y + as->
size_y - 1;
2203 mindist = UINT_MAX - 1;
2205 std::unique_ptr<TileIterator> copy(it.
Clone());
2207 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) {
2209 if (t ==
nullptr)
continue;
2212 if (dist == mindist && t->
index < nearest->
index) nearest = t;
2213 if (dist < mindist) {
2255 StationID station_to_join =
GB(p2, 16, 16);
2256 bool reuse = (station_to_join != NEW_STATION);
2257 if (!reuse) station_to_join = INVALID_STATION;
2258 bool distant_join = (station_to_join != INVALID_STATION);
2259 byte airport_type =
GB(p1, 0, 8);
2260 byte layout =
GB(p1, 8, 8);
2267 if (ret.
Failed())
return ret;
2286 if (cost.
Failed())
return cost;
2294 StringID authority_refuse_message = STR_NULL;
2295 Town *authority_refuse_town =
nullptr;
2300 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE;
2301 authority_refuse_town = nearest;
2310 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
2311 authority_refuse_town = t;
2315 if (authority_refuse_message != STR_NULL) {
2322 if (ret.
Failed())
return ret;
2328 if (ret.
Failed())
return ret;
2335 cost.
AddCost(_price[PR_BUILD_STATION_AIRPORT]);
2348 st->
rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
2360 AirportTileAnimationTrigger(st, iter,
AAT_BUILT);
2390 if (ret.
Failed())
return ret;
2398 if (!a->IsNormalAircraft())
continue;
2399 if (a->targetairport == st->
index && a->state !=
FLYING) {
2426 if (!st->TileBelongsToAirport(tile_cur))
continue;
2429 if (ret.
Failed())
return ret;
2431 cost.
AddCost(_price[PR_CLEAR_STATION_AIRPORT]);
2435 DoClearSquare(tile_cur);
2478 if (ret.
Failed())
return ret;
2496 if ((v->
owner == company) == include_company) {
2498 if ((order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT)) && order->GetDestination() == station) {
2513 static const byte _dock_w_chk[4] = { 2, 1, 2, 1 };
2514 static const byte _dock_h_chk[4] = { 1, 2, 1, 2 };
2527 StationID station_to_join =
GB(p2, 16, 16);
2528 bool reuse = (station_to_join != NEW_STATION);
2529 if (!reuse) station_to_join = INVALID_STATION;
2530 bool distant_join = (station_to_join != INVALID_STATION);
2542 if (ret.
Failed())
return ret;
2548 if (ret.
Failed())
return ret;
2563 if (ret.
Failed())
return ret;
2571 _dock_w_chk[direction], _dock_h_chk[direction]);
2576 if (ret.
Failed())
return ret;
2582 if (ret.
Failed())
return ret;
2589 st->
rect.BeforeAddRect(dock_area.
tile, dock_area.
w, dock_area.
h, StationRect::ADD_TRY);
2599 UpdateStationDockingTiles(st);
2615 if (st !=
nullptr) UpdateStationDockingTiles(st);
2618 if (neutral !=
nullptr) UpdateStationDockingTiles(neutral);
2637 if (IsPossibleDockingTile(docking_tile)) {
2690 if (ret.
Failed())
return ret;
2700 if (ret.
Failed())
return ret;
2703 DoClearSquare(tile1);
2705 MakeWaterKeepingClass(tile2, st->
owner);
2707 st->
rect.AfterRemoveTile(st, tile1);
2708 st->
rect.AfterRemoveTile(st, tile2);
2710 MakeShipStationAreaSmaller(st);
2726 if (s->current_order.GetDestination() != st->
index) {
2741 s->SetDestTile(s->GetOrderStationLocation(st->
index));
2753 return &_station_display_datas[st][gfx];
2769 case SPR_RAIL_TRACK_X:
2770 case SPR_MONO_TRACK_X:
2771 case SPR_MGLV_TRACK_X:
2772 snow_desert =
false;
2773 *overlay_offset =
RTO_X;
2776 case SPR_RAIL_TRACK_Y:
2777 case SPR_MONO_TRACK_Y:
2778 case SPR_MGLV_TRACK_Y:
2779 snow_desert =
false;
2780 *overlay_offset =
RTO_Y;
2783 case SPR_RAIL_TRACK_X_SNOW:
2784 case SPR_MONO_TRACK_X_SNOW:
2785 case SPR_MGLV_TRACK_X_SNOW:
2787 *overlay_offset =
RTO_X;
2790 case SPR_RAIL_TRACK_Y_SNOW:
2791 case SPR_MONO_TRACK_Y_SNOW:
2792 case SPR_MGLV_TRACK_Y_SNOW:
2794 *overlay_offset =
RTO_Y;
2801 if (ti !=
nullptr) {
2817 *ground = snow_desert ? SPR_FLAT_SNOW_DESERT_TILE : SPR_FLAT_GRASS_TILE;
2821 static void DrawTile_Station(
TileInfo *ti)
2828 uint32 relocation = 0;
2829 uint32 ground_relocation = 0;
2832 uint tile_layout = 0;
2843 if (statspec !=
nullptr) {
2879 case APT_RADAR_GRASS_FENCE_SW:
2882 case APT_GRASS_FENCE_NE_FLAG:
2885 case APT_RADAR_FENCE_SW:
2888 case APT_RADAR_FENCE_NE:
2891 case APT_GRASS_FENCE_NE_FLAG_2:
2901 palette = COMPANY_SPRITE_COLOUR(owner);
2904 palette = PALETTE_TO_GREY;
2907 if (layout ==
nullptr && (t ==
nullptr || t->
seq ==
nullptr)) t = GetStationTileLayout(
GetStationType(ti->
tile), gfx);
2917 if (!HasFoundationNW(ti->
tile, slope, z))
SetBit(edge_info, 0);
2918 if (!HasFoundationNE(ti->
tile, slope, z))
SetBit(edge_info, 1);
2920 if (image == 0)
goto draw_default_foundation;
2925 static const uint8 foundation_parts[] = {
2938 static const uint8 composite_foundation_parts[] = {
2940 0x00, 0xD1, 0xE4, 0xE0,
2942 0xCA, 0xC9, 0xC4, 0xC0,
2944 0xD2, 0x91, 0xE4, 0xA0,
2949 uint8 parts = composite_foundation_parts[ti->
tileh];
2960 goto draw_default_foundation;
2964 for (
int i = 0; i < 8; i++) {
2975 draw_default_foundation:
2981 DrawWaterClassGround(ti);
2983 if (sprite != 0) total_offset = sprite - SPR_IMG_BUOY;
2986 DrawWaterClassGround(ti);
2992 DrawShoreTile(ti->
tileh);
2994 DrawClearLandTile(ti, 3);
2998 if (layout !=
nullptr) {
3007 t = &tmp_rail_layout;
3009 }
else if (statspec !=
nullptr) {
3053 uint sprite_offset = axis ==
AXIS_X ? 1 : 0;
3055 DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset);
3060 if (road_rti->UsesOverlay()) {
3081 int32 total_offset = 0;
3096 DrawSprite(ground + overlay_offset, PAL_NONE, x, y);
3105 uint sprite_offset = 5 - image;
3108 if (rti->UsesOverlay()) {
3110 DrawSprite(ground + sprite_offset, PAL_NONE, x, y);
3113 if (overlay)
DrawSprite(overlay + sprite_offset, PAL_NONE, x, y);
3114 }
else if (RoadTypeIsTram(roadtype)) {
3115 DrawSprite(SPR_TRAMWAY_TRAM + sprite_offset, PAL_NONE, x, y);
3119 if (RoadTypeIsRoad(roadtype) && rti->UsesOverlay()) {
3130 static int GetSlopePixelZ_Station(
TileIndex tile, uint x, uint y)
3145 RoadType road_rt = GetRoadTypeRoad(tile);
3146 RoadType tram_rt = GetRoadTypeTram(tile);
3169 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER;
3170 td->
owner[i] = road_owner;
3174 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER;
3175 td->
owner[i] = tram_owner;
3186 if (spec !=
nullptr) {
3220 default: NOT_REACHED();
3221 case STATION_RAIL: str = STR_LAI_STATION_DESCRIPTION_RAILROAD_STATION;
break;
3222 case STATION_AIRPORT:
3223 str = (
IsHangar(tile) ? STR_LAI_STATION_DESCRIPTION_AIRCRAFT_HANGAR : STR_LAI_STATION_DESCRIPTION_AIRPORT);
3225 case STATION_TRUCK: str = STR_LAI_STATION_DESCRIPTION_TRUCK_LOADING_AREA;
break;
3226 case STATION_BUS: str = STR_LAI_STATION_DESCRIPTION_BUS_STATION;
break;
3227 case STATION_OILRIG: {
3235 case STATION_DOCK: str = STR_LAI_STATION_DESCRIPTION_SHIP_DOCK;
break;
3236 case STATION_BUOY: str = STR_LAI_STATION_DESCRIPTION_BUOY;
break;
3237 case STATION_WAYPOINT: str = STR_LAI_STATION_DESCRIPTION_WAYPOINT;
break;
3267 RoadTramType rtt = (RoadTramType)sub_mode;
3289 static void TileLoop_Station(
TileIndex tile)
3294 case STATION_AIRPORT:
3302 case STATION_OILRIG:
3312 static void AnimateTile_Station(
TileIndex tile)
3315 AnimateStationTile(tile);
3320 AnimateAirportTile(tile);
3325 static bool ClickTile_Station(
TileIndex tile)
3369 }
else if (x < stop) {
3371 uint16 spd = std::max(0, (stop - x) * 20 - 15);
3372 if (spd < v->cur_speed) v->
cur_speed = spd;
3395 CargoTypes cargoes = 0;
3401 if (cargoes == 0)
return;
3439 static inline void byte_inc_sat(
byte *p)
3456 StationCargoAmountMap waiting_per_source;
3458 for (StationCargoAmountMap::iterator i(waiting_per_source.begin()); i != waiting_per_source.end(); ++i) {
3460 if (source_station ==
nullptr)
continue;
3467 static void UpdateStationRating(
Station *st)
3469 bool waiting_changed =
false;
3471 byte_inc_sat(&st->time_since_load);
3472 byte_inc_sat(&st->time_since_unload);
3490 waiting_changed =
true;
3509 uint waiting_avg = waiting / (num_dests + 1);
3520 | (std::min<uint>(last_speed, 0xFFu) << 24);
3522 uint32 var10 = (st->last_vehicle_type ==
VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10);
3526 rating =
GB(callback, 0, 14);
3529 if (
HasBit(callback, 14)) rating -= 0x4000;
3535 if (b >= 0) rating += b >> 2;
3538 if (st->last_vehicle_type ==
VEH_SHIP) waittime >>= 2;
3539 if (waittime <= 21) rating += 25;
3540 if (waittime <= 12) rating += 25;
3541 if (waittime <= 6) rating += 45;
3542 if (waittime <= 3) rating += 35;
3555 if (age < 3) rating += 10;
3556 if (age < 2) rating += 10;
3557 if (age < 1) rating += 13;
3567 if (rating <= 64 && waiting_avg >= 100) {
3568 int dec = Random() & 0x1F;
3569 if (waiting_avg < 200) dec &= 7;
3570 waiting -= (dec + 1) * num_dests;
3571 waiting_changed =
true;
3575 if (rating <= 127 && waiting != 0) {
3576 uint32 r = Random();
3577 if (rating <= (
int)
GB(r, 0, 7)) {
3579 waiting = std::max((
int)waiting - (
int)((
GB(r, 8, 2) - 1) * num_dests), 0);
3580 waiting_changed =
true;
3587 static const uint WAITING_CARGO_THRESHOLD = 1 << 12;
3588 static const uint WAITING_CARGO_CUT_FACTOR = 1 << 6;
3589 static const uint MAX_WAITING_CARGO = 1 << 15;
3591 if (waiting > WAITING_CARGO_THRESHOLD) {
3592 uint difference = waiting - WAITING_CARGO_THRESHOLD;
3593 waiting -= (difference / WAITING_CARGO_CUT_FACTOR);
3595 waiting = std::min(waiting, MAX_WAITING_CARGO);
3596 waiting_changed =
true;
3601 if (waiting_changed && waiting < ge->cargo.AvailableCount()) {
3615 StationID index = st->
index;
3616 if (waiting_changed) {
3639 for (std::list<Vehicle *>::iterator it(st->loading_vehicles.begin()); it != st->loading_vehicles.end(); ++it) {
3640 for (
Vehicle *v = *it; v !=
nullptr; v = v->
Next()) {
3661 if (lg ==
nullptr)
continue;
3664 Edge edge = it->second;
3671 bool updated =
false;
3673 if (auto_distributed) {
3676 std::vector<Vehicle *> vehicles;
3678 bool found_from =
false;
3679 bool found_to =
false;
3680 for (
Order *order = l->GetFirstOrder(); order !=
nullptr; order = order->
next) {
3681 if (!order->IsType(OT_GOTO_STATION) && !order->IsType(OT_IMPLICIT))
continue;
3682 if (order->GetDestination() == from->
index) {
3684 if (found_to)
break;
3685 }
else if (order->GetDestination() == to->
index) {
3687 if (found_from)
break;
3690 if (!found_to || !found_from)
continue;
3691 vehicles.push_back(l->GetFirstSharedVehicle());
3694 auto iter = vehicles.begin();
3695 while (iter != vehicles.end()) {
3709 *iter = next_shared;
3712 iter = vehicles.erase(iter);
3715 if (iter == vehicles.end()) iter = vehicles.begin();
3763 Debug(misc, 0,
"Can't allocate link graph");
3772 }
else if (ge2.
link_graph == INVALID_LINK_GRAPH) {
3790 if (lg !=
nullptr) {
3791 (*lg)[ge1.
node].UpdateEdge(ge2.
node, capacity, usage, time, mode);
3803 for (
const Vehicle *v = front; v !=
nullptr; v = v->
Next()) {
3818 static void StationHandleSmallTick(
BaseStation *st)
3829 void OnTick_Station()
3831 if (_game_mode == GM_EDITOR)
return;
3834 StationHandleSmallTick(st);
3866 void ModifyStationRatingAround(
TileIndex tile,
Owner owner,
int amount, uint radius)
3870 for (CargoID i = 0; i < NUM_CARGO; i++) {
3871 GoodsEntry *ge = &st->goods[i];
3873 if (ge->status != 0) {
3874 ge->rating = Clamp(ge->rating + amount, 0, 255);
3893 if (amount == 0)
return 0;
3905 Debug(misc, 0,
"Can't allocate link graph");
3910 if (lg !=
nullptr) (*lg)[ge.
node].UpdateSupply(amount);
3926 static bool IsUniqueStationName(
const std::string &name)
3929 if (!st->
name.empty() && st->
name == name)
return false;
3950 if (ret.
Failed())
return ret;
3952 bool reset = text.empty();
3956 if (!IsUniqueStationName(text))
return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
3977 if (st->TileIsInCatchment(tile)) stations->insert(st);
3990 assert(this->
w == 1 && this->
h == 1);
3991 AddNearbyStationsByCatchment(this->tile, &this->stations, Town::GetByTile(this->tile)->stations_near);
3994 this->stations.insert(st);
4004 static bool CanMoveGoodsToStation(
const Station *st,
CargoID type)
4028 if (all_stations->empty())
return 0;
4029 if (amount == 0)
return 0;
4031 Station *first_station =
nullptr;
4032 typedef std::pair<Station *, uint> StationInfo;
4033 std::vector<StationInfo> used_stations;
4035 for (
Station *st : *all_stations) {
4037 if (!CanMoveGoodsToStation(st, type))
continue;
4041 if (first_station ==
nullptr) {
4045 if (used_stations.empty()) {
4046 used_stations.reserve(2);
4047 used_stations.emplace_back(std::make_pair(first_station, 0));
4049 used_stations.emplace_back(std::make_pair(st, 0));
4053 if (first_station ==
nullptr)
return 0;
4055 if (used_stations.empty()) {
4058 return UpdateStationWaiting(first_station, type, amount, source_type, source_id);
4063 uint best_rating = 0;
4066 for (
auto &p : used_stations) {
4067 auto owner = p.first->owner;
4068 auto rating = p.first->goods[type].rating;
4069 if (rating > company_best[owner]) {
4070 best_sum += rating - company_best[owner];
4071 company_best[owner] = rating;
4072 if (rating > best_rating) best_rating = rating;
4074 company_sum[owner] += rating;
4079 amount *= best_rating + 1;
4082 for (
auto &p : used_stations) {
4083 uint owner = p.first->owner;
4086 p.second = amount * company_best[owner] * p.first->goods[type].rating / best_sum / company_sum[owner];
4091 if (amount > moving) {
4092 std::stable_sort(used_stations.begin(), used_stations.end(), [type](
const StationInfo &a,
const StationInfo &b) {
4093 return b.first->goods[type].rating < a.first->goods[type].rating;
4096 assert(amount - moving <= used_stations.size());
4097 for (uint i = 0; i < amount - moving; i++) {
4098 used_stations[i].second++;
4103 for (
auto &p : used_stations) {
4104 moved += UpdateStationWaiting(p.first, type, p.second, source_type, source_id);
4110 void UpdateStationDockingTiles(
Station *st)
4124 int x2 = std::min<int>(x + area->
w + 1,
MapSizeX());
4125 int x1 = std::max<int>(x - 1, 0);
4127 int y2 = std::min<int>(y + area->
h + 1,
MapSizeY());
4128 int y1 = std::max<int>(y - 1, 0);
4139 Debug(misc, 0,
"Can't allocate station for oilrig at 0x{:X}, reverting to oilrig only", tile);
4147 st->
string_id = GenerateStationName(st, tile, STATIONNAMING_OILRIG);
4162 UpdateStationDockingTiles(st);
4164 st->
rect.BeforeAddTile(tile, StationRect::ADD_FORCE);
4189 for (RoadTramType rtt : _roadtramtypes) {
4192 RoadType rt = GetRoadType(tile, rtt);
4216 case STATION_WAYPOINT:
4307 case STATION_WAYPOINT:
return_cmd_error(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
4308 case STATION_AIRPORT:
return_cmd_error(STR_ERROR_MUST_DEMOLISH_AIRPORT_FIRST);
4309 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);
4310 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);
4313 case STATION_OILRIG:
4314 SetDParam(1, STR_INDUSTRY_NAME_OIL_RIG);
4333 case STATION_BUOY:
return RemoveBuoy(tile, flags);
4334 case STATION_DOCK:
return RemoveDock(tile, flags);
4349 case STATION_WAYPOINT:
4350 case STATION_RAIL: {
4357 case STATION_AIRPORT:
4385 for (SharesMap::const_iterator it = this->
shares.begin(); it != this->shares.end(); ++it) {
4386 if (it->second == st) {
4387 return it->first - prev;
4404 assert(!this->
shares.empty());
4406 assert(it != this->
shares.end() && it->first <= this->unrestricted);
4407 if (it->second != excluded && it->second != excluded2)
return it->second;
4412 uint end = it->first;
4413 uint begin = (it == this->
shares.begin() ? 0 : (--it)->first);
4414 uint interval = end - begin;
4415 if (interval >= this->
unrestricted)
return INVALID_STATION;
4418 SharesMap::const_iterator it2 = (rand < begin) ? this->
shares.upper_bound(rand) :
4419 this->
shares.upper_bound(rand + interval);
4420 assert(it2 != this->
shares.end() && it2->first <= this->unrestricted);
4421 if (it2->second != excluded && it2->second != excluded2)
return it2->second;
4426 uint end2 = it2->first;
4427 uint begin2 = (it2 == this->
shares.begin() ? 0 : (--it2)->first);
4428 uint interval2 = end2 - begin2;
4429 if (interval2 >= new_max)
return INVALID_STATION;
4430 new_max -= interval2;
4431 if (begin > begin2) {
4432 Swap(begin, begin2);
4434 Swap(interval, interval2);
4439 it3 = this->
shares.upper_bound(rand);
4440 }
else if (rand < begin2 - interval) {
4441 it3 = this->
shares.upper_bound(rand + interval);
4443 it3 = this->
shares.upper_bound(rand + interval + interval2);
4445 assert(it3 != this->
shares.end() && it3->first <= this->unrestricted);
4456 assert(!this->
shares.empty());
4457 SharesMap new_shares;
4459 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4460 new_shares[++i] = it->second;
4461 if (it->first == this->unrestricted) this->
unrestricted = i;
4463 this->
shares.swap(new_shares);
4464 assert(!this->
shares.empty() && this->unrestricted <= (--this->shares.end())->first);
4477 assert(!this->
shares.empty());
4479 uint removed_shares = 0;
4480 uint added_shares = 0;
4481 uint last_share = 0;
4482 SharesMap new_shares;
4483 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4484 if (it->second == st) {
4486 uint share = it->first - last_share;
4487 if (flow == INT_MIN || (uint)(-flow) >= share) {
4488 removed_shares += share;
4489 if (it->first <= this->unrestricted) this->
unrestricted -= share;
4490 if (flow != INT_MIN) flow += share;
4491 last_share = it->first;
4494 removed_shares += (uint)(-flow);
4496 added_shares += (uint)(flow);
4498 if (it->first <= this->unrestricted) this->
unrestricted += flow;
4504 new_shares[it->first + added_shares - removed_shares] = it->second;
4505 last_share = it->first;
4508 new_shares[last_share + (uint)flow] = st;
4515 this->
shares.swap(new_shares);
4525 assert(!this->
shares.empty());
4527 uint last_share = 0;
4528 SharesMap new_shares;
4529 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4531 if (it->first > this->unrestricted)
return;
4532 if (it->second == st) {
4533 flow = it->first - last_share;
4536 new_shares[it->first] = it->second;
4539 new_shares[it->first - flow] = it->second;
4541 last_share = it->first;
4543 if (flow == 0)
return;
4544 new_shares[last_share + flow] = st;
4545 this->
shares.swap(new_shares);
4546 assert(!this->
shares.empty());
4556 assert(!this->
shares.empty());
4558 uint next_share = 0;
4560 for (SharesMap::reverse_iterator it(this->
shares.rbegin()); it != this->shares.rend(); ++it) {
4561 if (it->first < this->unrestricted)
return;
4563 flow = next_share - it->first;
4567 if (it->first == this->unrestricted)
return;
4568 if (it->second == st) found =
true;
4570 next_share = it->first;
4572 if (flow == 0)
return;
4573 SharesMap new_shares;
4574 new_shares[flow] = st;
4575 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4576 if (it->second != st) {
4577 new_shares[flow + it->first] = it->second;
4582 this->
shares.swap(new_shares);
4583 assert(!this->
shares.empty());
4593 assert(runtime > 0);
4594 SharesMap new_shares;
4596 for (SharesMap::iterator i = this->
shares.begin(); i != this->shares.end(); ++i) {
4597 share = std::max(share + 1, i->first * 30 / runtime);
4598 new_shares[share] = i->second;
4601 this->
shares.swap(new_shares);
4612 FlowStatMap::iterator origin_it = this->find(origin);
4613 if (origin_it == this->end()) {
4614 this->insert(std::make_pair(origin,
FlowStat(via, flow)));
4616 origin_it->second.ChangeShare(via, flow);
4617 assert(!origin_it->second.GetShares()->empty());
4631 FlowStatMap::iterator prev_it = this->find(origin);
4632 if (prev_it == this->end()) {
4635 this->insert(std::make_pair(origin, fs));
4637 prev_it->second.ChangeShare(via, flow);
4638 prev_it->second.ChangeShare(INVALID_STATION, flow);
4639 assert(!prev_it->second.GetShares()->empty());
4649 for (FlowStatMap::iterator i = this->begin(); i != this->end(); ++i) {
4651 uint local = fs.
GetShare(INVALID_STATION);
4652 if (local > INT_MAX) {
4675 for (FlowStatMap::iterator f_it = this->begin(); f_it != this->end();) {
4679 ret.
Push(f_it->first);
4680 this->erase(f_it++);
4694 for (FlowStatMap::iterator it = this->begin(); it != this->end(); ++it) {
4695 it->second.RestrictShare(via);
4705 for (FlowStatMap::iterator it = this->begin(); it != this->end(); ++it) {
4706 it->second.ReleaseShare(via);
4717 for (FlowStatMap::const_iterator i = this->begin(); i != this->end(); ++i) {
4718 ret += (--(i->second.GetShares()->end()))->first;
4731 for (FlowStatMap::const_iterator i = this->begin(); i != this->end(); ++i) {
4732 ret += i->second.GetShare(via);
4744 FlowStatMap::const_iterator i = this->find(from);
4745 if (i == this->end())
return 0;
4746 return (--(i->second.GetShares()->end()))->first;
4757 FlowStatMap::const_iterator i = this->find(from);
4758 if (i == this->end())
return 0;
4759 return i->second.GetShare(via);
4764 GetSlopePixelZ_Station,
4767 GetTileDesc_Station,
4768 GetTileTrackStatus_Station,
4770 AnimateTile_Station,
4772 ChangeTileOwner_Station,
4774 VehicleEnter_Station,
4775 GetFoundation_Station,
4776 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
uint8 FindFirstBit(uint64 x)
Search the first set bit in a 64 bit variable.
DifficultySettings difficulty
settings related to the difficulty
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
uint16 tram_speed
Speed limit of tram (bridges and track)
static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, std::vector< Train * > &affected_vehicles, StationClassID spec_class, byte spec_index, byte plat_len, byte numtracks)
Checks if a rail station can be built at the given area.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
@ CBID_CARGO_STATION_RATING_CALC
Called to calculate part of a station rating.
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.
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.