15 #include "viewport_kdtree.h" 59 #include "table/strings.h" 110 if (!T::IsValidID(t) ||
Station::Get(t)->owner != company)
continue;
111 if (closest_station == INVALID_STATION) {
113 }
else if (closest_station != t) {
118 *st = (closest_station == INVALID_STATION) ?
nullptr : T::Get(closest_station);
139 for (
int dx = -3; dx <= 3; dx++) {
140 for (
int dy = -3; dy <= 3; dy++) {
196 #define M(x) ((x) - STR_SV_STNAME) 201 STATIONNAMING_AIRPORT,
202 STATIONNAMING_OILRIG,
204 STATIONNAMING_HELIPORT,
229 if (
GetIndustrySpec(indtype)->station_name == STR_UNDEFINED)
return false;
233 sni->
free_names &= ~(1 << M(STR_SV_STNAME_OILFIELD) | 1 << M(STR_SV_STNAME_MINES));
239 static const uint32 _gen_station_name_bits[] = {
242 1U << M(STR_SV_STNAME_AIRPORT),
243 1U << M(STR_SV_STNAME_OILFIELD),
244 1U << M(STR_SV_STNAME_DOCKS),
245 1U << M(STR_SV_STNAME_HELIPORT),
252 memset(indtypes, 0,
sizeof(indtypes));
255 if (s != st && s->
town == t) {
256 if (s->indtype != IT_INVALID) {
257 indtypes[s->indtype] =
true;
259 if (name != STR_UNDEFINED) {
268 uint str = M(s->string_id);
270 if (str == M(STR_SV_STNAME_FOREST)) {
271 str = M(STR_SV_STNAME_WOODS);
287 return STR_SV_STNAME_FALLBACK;
295 uint32 tmp = free_names & _gen_station_name_bits[name_class];
299 if (
HasBit(free_names, M(STR_SV_STNAME_MINES))) {
301 return STR_SV_STNAME_MINES;
307 if (
HasBit(free_names, M(STR_SV_STNAME)))
return STR_SV_STNAME;
309 if (
HasBit(free_names, M(STR_SV_STNAME_CENTRAL)))
return STR_SV_STNAME_CENTRAL;
313 if (
HasBit(free_names, M(STR_SV_STNAME_LAKESIDE)) &&
316 return STR_SV_STNAME_LAKESIDE;
320 if (
HasBit(free_names, M(STR_SV_STNAME_WOODS)) && (
331 if (
HasBit(free_names, M(STR_SV_STNAME_VALLEY)))
return STR_SV_STNAME_VALLEY;
333 if (
HasBit(free_names, M(STR_SV_STNAME_HEIGHTS)))
return STR_SV_STNAME_HEIGHTS;
337 static const int8 _direction_and_table[] = {
338 ~( (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
339 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
340 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
341 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) ),
344 free_names &= _direction_and_table[
348 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));
349 return (tmp == 0) ? STR_SV_STNAME_FALLBACK : (STR_SV_STNAME +
FindFirstBit(tmp));
362 Station *best_station =
nullptr;
367 if (cur_dist < threshold) {
368 threshold = cur_dist;
370 }
else if (cur_dist == threshold && best_station !=
nullptr) {
372 if (st->
index < best_station->
index) best_station = st;
385 *ta = this->train_station;
388 case STATION_AIRPORT:
393 *ta = this->truck_station;
397 *ta = this->bus_station;
402 *ta = this->docking_station;
405 default: NOT_REACHED();
419 pt.y -= 32 * ZOOM_LVL_BASE;
422 if (this->sign.kdtree_valid) _viewport_sign_kdtree.
Remove(ViewportSignKdtreeItem::MakeStation(this->index));
426 this->sign.UpdatePosition(pt.x, pt.y, STR_VIEWPORT_STATION);
428 _viewport_sign_kdtree.
Insert(ViewportSignKdtreeItem::MakeStation(this->index));
439 if (this->xy == new_xy)
return;
441 _station_kdtree.
Remove(this->index);
443 this->BaseStation::MoveSign(new_xy);
445 _station_kdtree.
Insert(this->index);
477 for (uint i = 0; i < num_items; i++) {
495 std::set<IndustryID> industries;
502 AddProducedCargo(tile, produced);
508 for (IndustryID industry : industries) {
534 if (always_accepted !=
nullptr) *always_accepted = 0;
542 AddAcceptedCargo(tile, acceptance, always_accepted);
556 if (always_accepted !=
nullptr) *always_accepted = 0;
560 AddAcceptedCargo(tile, acceptance, always_accepted);
578 if (!st->
rect.IsEmpty()) {
584 uint amt = acceptance[i];
602 if (old_acc == new_acc)
return;
608 static const StringID accept_msg[] = {
609 STR_NEWS_STATION_NOW_ACCEPTS_CARGO,
610 STR_NEWS_STATION_NOW_ACCEPTS_CARGO_AND_CARGO,
612 static const StringID reject_msg[] = {
613 STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO,
614 STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_OR_CARGO,
628 accepts[num_acc++] = i;
633 rejects[num_rej++] = i;
647 static void UpdateStationSignCoord(
BaseStation *st)
651 if (r->IsEmpty())
return;
655 st->MoveSign(new_xy);
680 if (*st !=
nullptr) {
685 CommandCost ret = (*st)->rect.BeforeAddRect(area.
tile, area.
w, area.
h, StationRect::ADD_TEST);
686 if (ret.
Failed())
return ret;
693 _station_kdtree.
Insert((*st)->index);
696 (*st)->string_id = GenerateStationName(*st, area.
tile, name_class);
719 UpdateStationSignCoord(st);
729 this->UpdateVirtCoord();
730 this->RecomputeCatchment();
738 case STATION_AIRPORT:
747 default: NOT_REACHED();
777 if (ret.
Failed())
return ret;
800 cost.
AddCost(_price[PR_BUILD_FOUNDATION]);
807 }
else if (allowed_z != flat_z) {
827 if (ret.
Failed())
return ret;
831 if (ret.
Failed())
return ret;
856 uint invalid_dirs = 5 << axis;
863 if (ret.
Failed())
return ret;
869 if (ret.
Failed())
return ret;
880 if (*station == INVALID_STATION) {
882 }
else if (*station != st) {
907 affected_vehicles.push_back(v);
911 if (ret.
Failed())
return ret;
918 if (ret.
Failed())
return ret;
945 if (ret.
Failed())
return ret;
964 if (*station == INVALID_STATION) {
966 }
else if (*station != st) {
989 if (build_over_road) {
991 RoadType road_rt = GetRoadType(cur_tile, RTT_ROAD);
998 if (ret.
Failed())
return ret;
1006 if (ret.
Failed())
return ret;
1010 }
else if (RoadTypeIsRoad(rt)) {
1015 RoadType tram_rt = GetRoadType(cur_tile, RTT_TRAM);
1024 if (ret.
Failed())
return ret;
1031 }
else if (RoadTypeIsTram(rt)) {
1036 if (ret.
Failed())
return ret;
1072 static inline byte *CreateSingle(byte *layout,
int n)
1075 do *layout++ = 0;
while (--i);
1076 layout[((n - 1) >> 1) - n] = 2;
1080 static inline byte *CreateMulti(byte *layout,
int n, byte b)
1083 do *layout++ = b;
while (--i);
1086 layout[n - 1 - n] = 0;
1100 if (statspec !=
nullptr && statspec->lengths >= plat_len &&
1101 statspec->platforms[plat_len - 1] >= numtracks &&
1102 statspec->layouts[plat_len - 1][numtracks - 1]) {
1104 memcpy(layout, statspec->layouts[plat_len - 1][numtracks - 1],
1105 plat_len * numtracks);
1109 if (plat_len == 1) {
1110 CreateSingle(layout, numtracks);
1112 if (numtracks & 1) layout = CreateSingle(layout, plat_len);
1115 while (--numtracks >= 0) {
1116 layout = CreateMulti(layout, plat_len, 4);
1117 layout = CreateMulti(layout, plat_len, 6);
1133 template <
class T, StringID error_message>
1136 assert(*st ==
nullptr);
1137 bool check_surrounding =
true;
1140 if (existing_station != INVALID_STATION) {
1141 if (adjacent && existing_station != station_to_join) {
1148 *st = T::GetIfValid(existing_station);
1149 check_surrounding = (*st ==
nullptr);
1154 if (adjacent) check_surrounding =
false;
1158 if (check_surrounding) {
1161 if (ret.
Failed())
return ret;
1165 if (*st ==
nullptr && station_to_join != INVALID_STATION) *st = T::GetIfValid(station_to_join);
1181 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_RAILWAY_STATION_FIRST>(existing_station, station_to_join, adjacent, ta, st);
1195 return FindJoiningBaseStation<Waypoint, STR_ERROR_MUST_REMOVE_RAILWAYPOINT_FIRST>(existing_waypoint, waypoint_to_join, adjacent, ta, wp);
1242 RailType rt = Extract<RailType, 0, 6>(p1);
1243 Axis axis = Extract<Axis, 6, 1>(p1);
1244 byte numtracks =
GB(p1, 8, 8);
1245 byte plat_len =
GB(p1, 16, 8);
1246 bool adjacent =
HasBit(p1, 24);
1249 byte spec_index =
GB(p2, 8, 8);
1250 StationID station_to_join =
GB(p2, 16, 16);
1254 if (ret.
Failed())
return ret;
1261 if (plat_len == 0 || numtracks == 0)
return CMD_ERROR;
1272 bool reuse = (station_to_join != NEW_STATION);
1273 if (!reuse) station_to_join = INVALID_STATION;
1274 bool distant_join = (station_to_join != INVALID_STATION);
1281 TileArea new_location(tile_org, w_org, h_org);
1284 StationID est = INVALID_STATION;
1285 std::vector<Train *> affected_vehicles;
1288 if (cost.
Failed())
return cost;
1290 cost.
AddCost((numtracks * _price[PR_BUILD_STATION_RAIL] + _price[PR_BUILD_STATION_RAIL_LENGTH]) * plat_len);
1295 if (ret.
Failed())
return ret;
1297 ret =
BuildStationPart(&st, flags, reuse, new_location, STATIONNAMING_RAIL);
1298 if (ret.
Failed())
return ret;
1302 if (ret.
Failed())
return ret;
1310 if (statspec !=
nullptr) {
1325 if (flags & DC_EXEC) {
1328 byte numtracks_orig;
1334 st->
rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY);
1336 if (statspec !=
nullptr) {
1345 layout_ptr =
AllocaM(byte, numtracks * plat_len);
1348 numtracks_orig = numtracks;
1356 byte layout = *layout_ptr++;
1361 affected_vehicles.push_back(v);
1386 if (statspec !=
nullptr) {
1401 TriggerStationAnimation(st, tile,
SAT_BUILT);
1409 }
while (--numtracks);
1411 for (uint i = 0; i < affected_vehicles.size(); ++i) {
1419 update_reservation_area =
TileArea(tile_org, 1, numtracks_orig);
1421 update_reservation_area =
TileArea(tile_org, numtracks_orig, 1);
1435 platform_begin = next_tile;
1438 platform_end = next_tile;
1442 bool reservation =
false;
1443 for (
TileIndex t = platform_begin; !reservation && t <= platform_end; t += tile_offset) {
1464 if (ta.
w != 0 && ta.
h != 0) {
1514 static void MakeRailStationAreaSmaller(
BaseStation *st)
1524 static void MakeShipStationAreaSmaller(
Station *st)
1527 UpdateStationDockingTiles(st);
1559 if (ret.
Failed())
continue;
1562 T *st = T::GetByTile(tile);
1563 if (st ==
nullptr)
continue;
1568 if (ret.
Failed())
continue;
1577 total_cost.
AddCost(-_price[PR_CLEAR_RAIL]);
1596 DoClearSquare(tile);
1602 st->rect.AfterRemoveTile(st, tile);
1608 include(affected_stations, st);
1616 for (T *st : affected_stations) {
1621 MakeRailStationAreaSmaller(st);
1622 UpdateStationSignCoord(st);
1633 total_cost.
AddCost(quantity * removal_cost);
1654 std::vector<Station *> affected_stations;
1657 if (ret.
Failed())
return ret;
1660 for (
Station *st : affected_stations) {
1688 std::vector<Waypoint *> affected_stations;
1708 if (ret.
Failed())
return ret;
1714 assert(ta.
w != 0 && ta.
h != 0);
1720 if (st->TileBelongsToRailStation(tile)) {
1721 std::vector<T*> affected_stations;
1723 if (ret.
Failed())
return ret;
1778 if (*primary_stop ==
nullptr) {
1780 return primary_stop;
1784 while (stop->
next !=
nullptr) stop = stop->
next;
1802 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_ROAD_STOP_FIRST>(existing_stop, station_to_join, adjacent, ta, st);
1823 bool type =
HasBit(p2, 0);
1824 bool is_drive_through =
HasBit(p2, 1);
1825 RoadType rt = Extract<RoadType, 5, 6>(p2);
1827 StationID station_to_join =
GB(p2, 16, 16);
1828 bool reuse = (station_to_join != NEW_STATION);
1829 if (!reuse) station_to_join = INVALID_STATION;
1830 bool distant_join = (station_to_join != INVALID_STATION);
1832 uint8 width = (uint8)
GB(p1, 0, 8);
1833 uint8 length = (uint8)
GB(p1, 8, 8);
1838 if (width == 0 || length == 0)
return CMD_ERROR;
1842 TileArea roadstop_area(tile, width, length);
1847 if (!is_drive_through && RoadTypeIsTram(rt))
return CMD_ERROR;
1851 if (is_drive_through) {
1853 axis = Extract<Axis, 3, 1>(p2);
1857 ddir = Extract<DiagDirection, 3, 2>(p2);
1862 if (ret.
Failed())
return ret;
1866 StationID est = INVALID_STATION;
1867 ret =
CheckFlatLandRoadStop(roadstop_area, flags, is_drive_through ? 5 << axis : 1 << ddir, is_drive_through, type, axis, &est, rt);
1868 if (ret.
Failed())
return ret;
1873 if (ret.
Failed())
return ret;
1878 ret =
BuildStationPart(&st, flags, reuse, roadstop_area, STATIONNAMING_ROAD);
1879 if (ret.
Failed())
return ret;
1897 *currstop = road_stop;
1908 st->
rect.BeforeAddTile(cur_tile, StationRect::ADD_TRY);
1911 if (is_drive_through) {
1940 if (st !=
nullptr) {
1976 if (ret.
Failed())
return ret;
1991 assert(cur_stop !=
nullptr);
1999 if (ret.
Failed())
return ret;
2003 if (*primary_stop == cur_stop) {
2005 *primary_stop = cur_stop->
next;
2007 if (*primary_stop ==
nullptr) {
2013 while (pred->
next != cur_stop) pred = pred->
next;
2018 FOR_ALL_ROADTRAMTYPES(rtt) {
2019 RoadType rt = GetRoadType(tile, rtt);
2030 DoClearSquare(tile);
2043 st->
rect.AfterRemoveTile(st, tile);
2073 uint8 width = (uint8)
GB(p1, 0, 8);
2074 uint8 height = (uint8)
GB(p1, 8, 8);
2075 bool keep_drive_through_roads = !
HasBit(p2, 1);
2078 if (width == 0 || height == 0)
return CMD_ERROR;
2084 TileArea roadstop_area(tile, width, height);
2087 CommandCost last_error(STR_ERROR_THERE_IS_NO_STATION);
2088 bool had_success =
false;
2099 FOR_ALL_ROADTRAMTYPES(rtt) {
2100 road_type[rtt] = GetRoadType(cur_tile, rtt);
2101 if (road_type[rtt] == INVALID_ROADTYPE)
continue;
2118 if ((flags &
DC_EXEC) && (road_type[RTT_ROAD] != INVALID_ROADTYPE || road_type[RTT_TRAM] != INVALID_ROADTYPE)) {
2120 road_owner[RTT_ROAD], road_owner[RTT_TRAM]);
2129 return had_success ? cost : last_error;
2154 uint noise_reduction = distance / town_tolerance_distance;
2173 Town *nearest =
nullptr;
2175 uint perimeter_min_x =
TileX(it);
2176 uint perimeter_min_y =
TileY(it);
2177 uint perimeter_max_x = perimeter_min_x + as->
size_x - 1;
2178 uint perimeter_max_y = perimeter_min_y + as->
size_y - 1;
2180 mindist = UINT_MAX - 1;
2182 std::unique_ptr<TileIterator> copy(it.
Clone());
2184 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) {
2186 if (t ==
nullptr)
continue;
2189 if (dist == mindist && t->
index < nearest->
index) nearest = t;
2190 if (dist < mindist) {
2232 StationID station_to_join =
GB(p2, 16, 16);
2233 bool reuse = (station_to_join != NEW_STATION);
2234 if (!reuse) station_to_join = INVALID_STATION;
2235 bool distant_join = (station_to_join != INVALID_STATION);
2236 byte airport_type =
GB(p1, 0, 8);
2237 byte layout =
GB(p1, 8, 8);
2244 if (ret.
Failed())
return ret;
2263 if (cost.
Failed())
return cost;
2271 StringID authority_refuse_message = STR_NULL;
2272 Town *authority_refuse_town =
nullptr;
2277 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE;
2278 authority_refuse_town = nearest;
2287 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
2288 authority_refuse_town = t;
2292 if (authority_refuse_message != STR_NULL) {
2299 if (ret.
Failed())
return ret;
2305 if (ret.
Failed())
return ret;
2312 cost.
AddCost(_price[PR_BUILD_STATION_AIRPORT]);
2325 st->
rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
2337 AirportTileAnimationTrigger(st, iter,
AAT_BUILT);
2367 if (ret.
Failed())
return ret;
2375 if (!a->IsNormalAircraft())
continue;
2376 if (a->targetairport == st->
index && a->state !=
FLYING) {
2393 if (!st->TileBelongsToAirport(tile_cur))
continue;
2396 if (ret.
Failed())
return ret;
2398 cost.
AddCost(_price[PR_CLEAR_STATION_AIRPORT]);
2400 if (flags & DC_EXEC) {
2403 DoClearSquare(tile_cur);
2408 if (flags & DC_EXEC) {
2456 if (ret.
Failed())
return ret;
2474 if ((v->
owner == company) == include_company) {
2476 FOR_VEHICLE_ORDERS(v, order) {
2492 static const byte _dock_w_chk[4] = { 2, 1, 2, 1 };
2493 static const byte _dock_h_chk[4] = { 1, 2, 1, 2 };
2506 StationID station_to_join =
GB(p2, 16, 16);
2507 bool reuse = (station_to_join != NEW_STATION);
2508 if (!reuse) station_to_join = INVALID_STATION;
2509 bool distant_join = (station_to_join != INVALID_STATION);
2521 if (ret.
Failed())
return ret;
2526 if (ret.
Failed())
return ret;
2540 if (ret.
Failed())
return ret;
2548 _dock_w_chk[direction], _dock_h_chk[direction]);
2553 if (ret.
Failed())
return ret;
2559 if (ret.
Failed())
return ret;
2566 st->
rect.BeforeAddRect(dock_area.
tile, dock_area.
w, dock_area.
h, StationRect::ADD_TRY);
2576 UpdateStationDockingTiles(st);
2594 if (neutral !=
nullptr) UpdateStationDockingTiles(neutral);
2613 if (IsPossibleDockingTile(docking_tile)) {
2631 static const uint8 _valid_docking_tile[] = {
2638 assert(gfx <
lengthof(_valid_docking_tile));
2639 return HasBit(_valid_docking_tile[gfx], d);
2674 if (ret.
Failed())
return ret;
2684 if (ret.
Failed())
return ret;
2687 DoClearSquare(tile1);
2689 MakeWaterKeepingClass(tile2, st->
owner);
2691 st->
rect.AfterRemoveTile(st, tile1);
2692 st->
rect.AfterRemoveTile(st, tile2);
2694 MakeShipStationAreaSmaller(st);
2714 if (s->current_order.IsType(OT_LOADING) && s->current_order.GetDestination() == st->
index) {
2718 if (s->current_order.IsType(OT_GOTO_STATION) && s->current_order.GetDestination() == st->
index) {
2719 s->SetDestTile(s->GetOrderStationLocation(st->
index));
2732 return &_station_display_datas[st][gfx];
2748 case SPR_RAIL_TRACK_X:
2749 case SPR_MONO_TRACK_X:
2750 case SPR_MGLV_TRACK_X:
2751 snow_desert =
false;
2752 *overlay_offset =
RTO_X;
2755 case SPR_RAIL_TRACK_Y:
2756 case SPR_MONO_TRACK_Y:
2757 case SPR_MGLV_TRACK_Y:
2758 snow_desert =
false;
2759 *overlay_offset =
RTO_Y;
2762 case SPR_RAIL_TRACK_X_SNOW:
2763 case SPR_MONO_TRACK_X_SNOW:
2764 case SPR_MGLV_TRACK_X_SNOW:
2766 *overlay_offset =
RTO_X;
2769 case SPR_RAIL_TRACK_Y_SNOW:
2770 case SPR_MONO_TRACK_Y_SNOW:
2771 case SPR_MGLV_TRACK_Y_SNOW:
2773 *overlay_offset =
RTO_Y;
2780 if (ti !=
nullptr) {
2796 *ground = snow_desert ? SPR_FLAT_SNOW_DESERT_TILE : SPR_FLAT_GRASS_TILE;
2800 static void DrawTile_Station(
TileInfo *ti)
2807 uint32 relocation = 0;
2808 uint32 ground_relocation = 0;
2811 uint tile_layout = 0;
2822 if (statspec !=
nullptr) {
2858 case APT_RADAR_GRASS_FENCE_SW:
2861 case APT_GRASS_FENCE_NE_FLAG:
2864 case APT_RADAR_FENCE_SW:
2867 case APT_RADAR_FENCE_NE:
2870 case APT_GRASS_FENCE_NE_FLAG_2:
2880 palette = COMPANY_SPRITE_COLOUR(owner);
2883 palette = PALETTE_TO_GREY;
2886 if (layout ==
nullptr && (t ==
nullptr || t->
seq ==
nullptr)) t = GetStationTileLayout(
GetStationType(ti->
tile), gfx);
2896 if (!HasFoundationNW(ti->
tile, slope, z))
SetBit(edge_info, 0);
2897 if (!HasFoundationNE(ti->
tile, slope, z))
SetBit(edge_info, 1);
2899 if (image == 0)
goto draw_default_foundation;
2904 static const uint8 foundation_parts[] = {
2917 static const uint8 composite_foundation_parts[] = {
2919 0x00, 0xD1, 0xE4, 0xE0,
2921 0xCA, 0xC9, 0xC4, 0xC0,
2923 0xD2, 0x91, 0xE4, 0xA0,
2928 uint8 parts = composite_foundation_parts[ti->
tileh];
2939 goto draw_default_foundation;
2943 for (
int i = 0; i < 8; i++) {
2954 draw_default_foundation:
2960 DrawWaterClassGround(ti);
2962 if (sprite != 0) total_offset = sprite - SPR_IMG_BUOY;
2965 DrawWaterClassGround(ti);
2971 DrawShoreTile(ti->
tileh);
2973 DrawClearLandTile(ti, 3);
2977 if (layout !=
nullptr) {
2987 t = &tmp_rail_layout;
2989 }
else if (statspec !=
nullptr) {
3033 uint sprite_offset = axis ==
AXIS_X ? 1 : 0;
3035 DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset);
3040 if (road_rti->UsesOverlay()) {
3061 int32 total_offset = 0;
3076 DrawSprite(ground + overlay_offset, PAL_NONE, x, y);
3085 uint sprite_offset = 5 - image;
3088 if (rti->UsesOverlay()) {
3090 DrawSprite(ground + sprite_offset, PAL_NONE, x, y);
3093 if (overlay)
DrawSprite(overlay + sprite_offset, PAL_NONE, x, y);
3094 }
else if (RoadTypeIsTram(roadtype)) {
3095 DrawSprite(SPR_TRAMWAY_TRAM + sprite_offset, PAL_NONE, x, y);
3099 if (RoadTypeIsRoad(roadtype) && rti->UsesOverlay()) {
3110 static int GetSlopePixelZ_Station(
TileIndex tile, uint x, uint y)
3125 RoadType road_rt = GetRoadTypeRoad(tile);
3126 RoadType tram_rt = GetRoadTypeTram(tile);
3149 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER;
3150 td->
owner[i] = road_owner;
3154 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER;
3155 td->
owner[i] = tram_owner;
3166 if (spec !=
nullptr) {
3200 default: NOT_REACHED();
3201 case STATION_RAIL: str = STR_LAI_STATION_DESCRIPTION_RAILROAD_STATION;
break;
3202 case STATION_AIRPORT:
3203 str = (
IsHangar(tile) ? STR_LAI_STATION_DESCRIPTION_AIRCRAFT_HANGAR : STR_LAI_STATION_DESCRIPTION_AIRPORT);
3205 case STATION_TRUCK: str = STR_LAI_STATION_DESCRIPTION_TRUCK_LOADING_AREA;
break;
3206 case STATION_BUS: str = STR_LAI_STATION_DESCRIPTION_BUS_STATION;
break;
3207 case STATION_OILRIG: {
3215 case STATION_DOCK: str = STR_LAI_STATION_DESCRIPTION_SHIP_DOCK;
break;
3216 case STATION_BUOY: str = STR_LAI_STATION_DESCRIPTION_BUOY;
break;
3217 case STATION_WAYPOINT: str = STR_LAI_STATION_DESCRIPTION_WAYPOINT;
break;
3247 RoadTramType rtt = (RoadTramType)sub_mode;
3269 static void TileLoop_Station(
TileIndex tile)
3274 case STATION_AIRPORT:
3282 case STATION_OILRIG:
3292 static void AnimateTile_Station(
TileIndex tile)
3295 AnimateStationTile(tile);
3300 AnimateAirportTile(tile);
3305 static bool ClickTile_Station(
TileIndex tile)
3349 }
else if (x < stop) {
3351 uint16 spd =
max(0, (stop - x) * 20 - 15);
3352 if (spd < v->cur_speed) v->
cur_speed = spd;
3375 CargoTypes cargoes = 0;
3381 if (cargoes == 0)
return;
3419 static inline void byte_inc_sat(byte *p)
3436 StationCargoAmountMap waiting_per_source;
3438 for (StationCargoAmountMap::iterator i(waiting_per_source.begin()); i != waiting_per_source.end(); ++i) {
3440 if (source_station ==
nullptr)
continue;
3447 static void UpdateStationRating(
Station *st)
3449 bool waiting_changed =
false;
3451 byte_inc_sat(&st->time_since_load);
3452 byte_inc_sat(&st->time_since_unload);
3455 FOR_ALL_CARGOSPECS(cs) {
3471 waiting_changed =
true;
3490 uint waiting_avg = waiting / (num_dests + 1);
3501 uint32 var10 = (st->last_vehicle_type ==
VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10);
3505 rating =
GB(callback, 0, 14);
3508 if (
HasBit(callback, 14)) rating -= 0x4000;
3514 if (b >= 0) rating += b >> 2;
3517 if (st->last_vehicle_type ==
VEH_SHIP) waittime >>= 2;
3518 if (waittime <= 21) rating += 25;
3519 if (waittime <= 12) rating += 25;
3520 if (waittime <= 6) rating += 45;
3521 if (waittime <= 3) rating += 35;
3534 if (age < 3) rating += 10;
3535 if (age < 2) rating += 10;
3536 if (age < 1) rating += 13;
3546 if (rating <= 64 && waiting_avg >= 100) {
3547 int dec = Random() & 0x1F;
3548 if (waiting_avg < 200) dec &= 7;
3549 waiting -= (dec + 1) * num_dests;
3550 waiting_changed =
true;
3554 if (rating <= 127 && waiting != 0) {
3555 uint32 r = Random();
3556 if (rating <= (
int)
GB(r, 0, 7)) {
3558 waiting =
max((
int)waiting - (
int)((
GB(r, 8, 2) - 1) * num_dests), 0);
3559 waiting_changed =
true;
3566 static const uint WAITING_CARGO_THRESHOLD = 1 << 12;
3567 static const uint WAITING_CARGO_CUT_FACTOR = 1 << 6;
3568 static const uint MAX_WAITING_CARGO = 1 << 15;
3570 if (waiting > WAITING_CARGO_THRESHOLD) {
3571 uint difference = waiting - WAITING_CARGO_THRESHOLD;
3572 waiting -= (difference / WAITING_CARGO_CUT_FACTOR);
3574 waiting =
min(waiting, MAX_WAITING_CARGO);
3575 waiting_changed =
true;
3580 if (waiting_changed && waiting < ge->cargo.AvailableCount()) {
3594 StationID index = st->
index;
3595 if (waiting_changed) {
3618 for (std::list<Vehicle *>::iterator it(st->loading_vehicles.begin()); it != st->loading_vehicles.end(); ++it) {
3619 for (
Vehicle *v = *it; v !=
nullptr; v = v->
Next()) {
3640 if (lg ==
nullptr)
continue;
3643 Edge edge = it->second;
3650 bool updated =
false;
3652 if (auto_distributed) {
3655 std::vector<Vehicle *> vehicles;
3657 bool found_from =
false;
3658 bool found_to =
false;
3659 for (
Order *order = l->GetFirstOrder(); order !=
nullptr; order = order->
next) {
3660 if (!order->IsType(OT_GOTO_STATION) && !order->IsType(OT_IMPLICIT))
continue;
3661 if (order->GetDestination() == from->
index) {
3663 if (found_to)
break;
3664 }
else if (order->GetDestination() == to->
index) {
3666 if (found_from)
break;
3669 if (!found_to || !found_from)
continue;
3670 vehicles.push_back(l->GetFirstSharedVehicle());
3673 auto iter = vehicles.begin();
3674 while (iter != vehicles.end()) {
3685 *iter = next_shared;
3688 iter = vehicles.erase(iter);
3691 if (iter == vehicles.end()) iter = vehicles.begin();
3739 DEBUG(misc, 0,
"Can't allocate link graph");
3748 }
else if (ge2.
link_graph == INVALID_LINK_GRAPH) {
3766 if (lg !=
nullptr) {
3767 (*lg)[ge1.
node].UpdateEdge(ge2.
node, capacity, usage, mode);
3779 for (
const Vehicle *v = front; v !=
nullptr; v = v->
Next()) {
3794 static void StationHandleSmallTick(
BaseStation *st)
3805 void OnTick_Station()
3807 if (_game_mode == GM_EDITOR)
return;
3810 StationHandleSmallTick(st);
3842 void ModifyStationRatingAround(
TileIndex tile,
Owner owner,
int amount, uint radius)
3845 if (st->
owner == owner) {
3846 for (CargoID i = 0; i < NUM_CARGO; i++) {
3847 GoodsEntry *ge = &st->goods[i];
3849 if (ge->status != 0) {
3850 ge->rating = Clamp(ge->rating + amount, 0, 255);
3869 if (amount == 0)
return 0;
3881 DEBUG(misc, 0,
"Can't allocate link graph");
3886 if (lg !=
nullptr) (*lg)[ge.
node].UpdateSupply(amount);
3902 static bool IsUniqueStationName(
const char *name)
3905 if (st->
name !=
nullptr && strcmp(st->
name, name) == 0)
return false;
3926 if (ret.
Failed())
return ret;
3932 if (!IsUniqueStationName(text))
return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
3949 if (st->TileIsInCatchment(tile)) stations->insert(st);
3970 assert(location.
w == 1 && location.
h == 1);
3971 AddNearbyStationsByCatchment(location.
tile, stations, Town::GetByTile(location.
tile)->
stations_near);
3977 std::set<StationID> seen_stations;
3987 for (StationID stationid : seen_stations) {
3989 if (st ==
nullptr)
continue;
3996 if (st->TileIsInCatchment(tile)) {
3997 stations->insert(st);
4014 return &this->stations;
4020 if (amount == 0)
return 0;
4024 uint best_rating1 = 0;
4025 uint best_rating2 = 0;
4027 for (
Station *st : *all_stations) {
4042 if (st1 ==
nullptr || st->
goods[type].
rating >= best_rating1) {
4043 st2 = st1; best_rating2 = best_rating1; st1 = st; best_rating1 = st->
goods[type].
rating;
4044 }
else if (st2 ==
nullptr || st->
goods[type].
rating >= best_rating2) {
4050 if (st1 ==
nullptr)
return 0;
4054 amount *= best_rating1 + 1;
4056 if (st2 ==
nullptr) {
4058 return UpdateStationWaiting(st1, type, amount, source_type, source_id);
4062 assert(st1 !=
nullptr);
4063 assert(st2 !=
nullptr);
4064 assert(best_rating1 != 0 || best_rating2 != 0);
4071 uint worst_cargo = amount * best_rating2 / (best_rating1 + best_rating2);
4072 assert(worst_cargo <= (amount - worst_cargo));
4075 uint moved = UpdateStationWaiting(st1, type, amount - worst_cargo, source_type, source_id);
4078 return moved + UpdateStationWaiting(st2, type, worst_cargo, source_type, source_id);
4081 void UpdateStationDockingTiles(
Station *st)
4096 int x1 =
max(x - 1, 0);
4099 int y1 =
max(y - 1, 0);
4110 DEBUG(misc, 0,
"Can't allocate station for oilrig at 0x%X, reverting to oilrig only", tile);
4118 st->
string_id = GenerateStationName(st, tile, STATIONNAMING_OILRIG);
4133 UpdateStationDockingTiles(st);
4135 st->
rect.BeforeAddTile(tile, StationRect::ADD_FORCE);
4160 FOR_ALL_ROADTRAMTYPES(rtt) {
4163 RoadType rt = GetRoadType(tile, rtt);
4187 case STATION_WAYPOINT:
4278 case STATION_WAYPOINT:
return_cmd_error(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
4279 case STATION_AIRPORT:
return_cmd_error(STR_ERROR_MUST_DEMOLISH_AIRPORT_FIRST);
4280 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);
4281 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);
4284 case STATION_OILRIG:
4285 SetDParam(1, STR_INDUSTRY_NAME_OIL_RIG);
4304 case STATION_BUOY:
return RemoveBuoy(tile, flags);
4305 case STATION_DOCK:
return RemoveDock(tile, flags);
4320 case STATION_WAYPOINT:
4321 case STATION_RAIL: {
4328 case STATION_AIRPORT:
4356 for (SharesMap::const_iterator it = this->shares.begin(); it != this->shares.end(); ++it) {
4357 if (it->second == st) {
4358 return it->first - prev;
4374 if (this->unrestricted == 0)
return INVALID_STATION;
4375 assert(!this->shares.empty());
4376 SharesMap::const_iterator it = this->shares.upper_bound(
RandomRange(this->unrestricted));
4377 assert(it != this->shares.end() && it->first <= this->unrestricted);
4378 if (it->second != excluded && it->second != excluded2)
return it->second;
4383 uint end = it->first;
4384 uint begin = (it == this->shares.begin() ? 0 : (--it)->first);
4385 uint interval = end - begin;
4386 if (interval >= this->unrestricted)
return INVALID_STATION;
4387 uint new_max = this->unrestricted - interval;
4389 SharesMap::const_iterator it2 = (rand < begin) ? this->shares.upper_bound(rand) :
4390 this->shares.upper_bound(rand + interval);
4391 assert(it2 != this->shares.end() && it2->first <= this->unrestricted);
4392 if (it2->second != excluded && it2->second != excluded2)
return it2->second;
4397 uint end2 = it2->first;
4398 uint begin2 = (it2 == this->shares.begin() ? 0 : (--it2)->first);
4399 uint interval2 = end2 - begin2;
4400 if (interval2 >= new_max)
return INVALID_STATION;
4401 new_max -= interval2;
4402 if (begin > begin2) {
4403 Swap(begin, begin2);
4405 Swap(interval, interval2);
4408 SharesMap::const_iterator it3 = this->shares.upper_bound(this->unrestricted);
4410 it3 = this->shares.upper_bound(rand);
4411 }
else if (rand < begin2 - interval) {
4412 it3 = this->shares.upper_bound(rand + interval);
4414 it3 = this->shares.upper_bound(rand + interval + interval2);
4416 assert(it3 != this->shares.end() && it3->first <= this->unrestricted);
4427 assert(!this->shares.empty());
4428 SharesMap new_shares;
4430 for (SharesMap::iterator it(this->shares.begin()); it != this->shares.end(); ++it) {
4431 new_shares[++i] = it->second;
4432 if (it->first == this->unrestricted) this->unrestricted = i;
4434 this->shares.swap(new_shares);
4435 assert(!this->shares.empty() && this->unrestricted <= (--this->shares.end())->first);
4448 assert(!this->shares.empty());
4450 uint removed_shares = 0;
4451 uint added_shares = 0;
4452 uint last_share = 0;
4453 SharesMap new_shares;
4454 for (SharesMap::iterator it(this->shares.begin()); it != this->shares.end(); ++it) {
4455 if (it->second == st) {
4457 uint share = it->first - last_share;
4458 if (flow == INT_MIN || (uint)(-flow) >= share) {
4459 removed_shares += share;
4460 if (it->first <= this->unrestricted) this->unrestricted -= share;
4461 if (flow != INT_MIN) flow += share;
4462 last_share = it->first;
4465 removed_shares += (uint)(-flow);
4467 added_shares += (uint)(flow);
4469 if (it->first <= this->unrestricted) this->unrestricted += flow;
4475 new_shares[it->first + added_shares - removed_shares] = it->second;
4476 last_share = it->first;
4479 new_shares[last_share + (uint)flow] = st;
4480 if (this->unrestricted < last_share) {
4481 this->ReleaseShare(st);
4483 this->unrestricted += flow;
4486 this->shares.swap(new_shares);
4496 assert(!this->shares.empty());
4498 uint last_share = 0;
4499 SharesMap new_shares;
4500 for (SharesMap::iterator it(this->shares.begin()); it != this->shares.end(); ++it) {
4502 if (it->first > this->unrestricted)
return;
4503 if (it->second == st) {
4504 flow = it->first - last_share;
4505 this->unrestricted -= flow;
4507 new_shares[it->first] = it->second;
4510 new_shares[it->first - flow] = it->second;
4512 last_share = it->first;
4514 if (flow == 0)
return;
4515 new_shares[last_share + flow] = st;
4516 this->shares.swap(new_shares);
4517 assert(!this->shares.empty());
4527 assert(!this->shares.empty());
4529 uint next_share = 0;
4531 for (SharesMap::reverse_iterator it(this->shares.rbegin()); it != this->shares.rend(); ++it) {
4532 if (it->first < this->unrestricted)
return;
4534 flow = next_share - it->first;
4535 this->unrestricted += flow;
4538 if (it->first == this->unrestricted)
return;
4539 if (it->second == st) found =
true;
4541 next_share = it->first;
4543 if (flow == 0)
return;
4544 SharesMap new_shares;
4545 new_shares[flow] = st;
4546 for (SharesMap::iterator it(this->shares.begin()); it != this->shares.end(); ++it) {
4547 if (it->second != st) {
4548 new_shares[flow + it->first] = it->second;
4553 this->shares.swap(new_shares);
4554 assert(!this->shares.empty());
4564 assert(runtime > 0);
4565 SharesMap new_shares;
4567 for (SharesMap::iterator i = this->shares.begin(); i != this->shares.end(); ++i) {
4568 share =
max(share + 1, i->first * 30 / runtime);
4569 new_shares[share] = i->second;
4570 if (this->unrestricted == i->first) this->unrestricted = share;
4572 this->shares.swap(new_shares);
4583 FlowStatMap::iterator origin_it = this->find(origin);
4584 if (origin_it == this->end()) {
4585 this->insert(std::make_pair(origin,
FlowStat(via, flow)));
4587 origin_it->second.ChangeShare(via, flow);
4588 assert(!origin_it->second.GetShares()->empty());
4602 FlowStatMap::iterator prev_it = this->find(origin);
4603 if (prev_it == this->end()) {
4606 this->insert(std::make_pair(origin, fs));
4608 prev_it->second.ChangeShare(via, flow);
4609 prev_it->second.ChangeShare(INVALID_STATION, flow);
4610 assert(!prev_it->second.GetShares()->empty());
4620 for (FlowStatMap::iterator i = this->begin(); i != this->end(); ++i) {
4622 uint local = fs.
GetShare(INVALID_STATION);
4623 if (local > INT_MAX) {
4646 for (FlowStatMap::iterator f_it = this->begin(); f_it != this->end();) {
4650 ret.
Push(f_it->first);
4651 this->erase(f_it++);
4665 for (FlowStatMap::iterator it = this->begin(); it != this->end(); ++it) {
4666 it->second.RestrictShare(via);
4676 for (FlowStatMap::iterator it = this->begin(); it != this->end(); ++it) {
4677 it->second.ReleaseShare(via);
4688 for (FlowStatMap::const_iterator i = this->begin(); i != this->end(); ++i) {
4689 ret += (--(i->second.GetShares()->end()))->first;
4702 for (FlowStatMap::const_iterator i = this->begin(); i != this->end(); ++i) {
4703 ret += i->second.GetShare(via);
4715 FlowStatMap::const_iterator i = this->find(from);
4716 if (i == this->end())
return 0;
4717 return (--(i->second.GetShares()->end()))->first;
4728 FlowStatMap::const_iterator i = this->find(from);
4729 if (i == this->end())
return 0;
4730 return i->second.GetShare(via);
4735 GetSlopePixelZ_Station,
4738 GetTileDesc_Station,
4739 GetTileTrackStatus_Station,
4741 AnimateTile_Station,
4743 ChangeTileOwner_Station,
4745 VehicleEnter_Station,
4746 GetFoundation_Station,
4747 TerraformTile_Station,
Town * AirportGetNearestTown(const AirportSpec *as, const TileIterator &it, uint &mindist)
Finds the town nearest to given airport.
Functions related to OTTD's strings.
void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigger trigger, CargoID cargo_type)
Trigger station randomisation.
SourceType
Types of cargo source and destination.
Owner
Enum for all companies/owners.
don't allow building on structures
Iterator to iterate over all tiles belonging to a bitmaptilearea.
static void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
Make the given tile a rail station tile.
EdgeIterator Begin()
Get an iterator pointing to the start of the edges array.
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner)
Change the owner of a tile.
static bool HasPowerOnRail(RailType enginetype, RailType tiletype)
Checks if an engine of the given RailType got power on a tile with a given RailType.
Functions/types related to NewGRF debugging.
static void Swap(T &a, T &b)
Type safe swap operation.
byte type
Type of this airport,.
uint32 PaletteID
The number of the palette.
StationFacility facilities
The facilities that this station has.
static void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
Make the given tile a dock tile.
void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner)
Add track to signal update buffer.
struct RailtypeInfo::@36 base_sprites
Struct containing the main sprites.
VehicleCargoList cargo
The cargo this vehicle is carrying.
static uint MapSizeX()
Get the size of the map along the X.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition of stuff that is very close to a company, like the company struct itself.
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.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
NodeID AddNode(const Station *st)
Add a node to the component and create empty edges associated with it.
void ShowWaypointWindow(const Waypoint *wp)
Show the window for the given waypoint.
Use callback to select a sprite layout to use.
static void SetCustomStationSpecIndex(TileIndex t, byte specindex)
Set the custom station spec for this tile.
bool enabled
entity still available (by default true).newgrf can disable it, though
bool IsAvailable() const
Check whether this airport is available to build.
static bool FindNearIndustryName(TileIndex tile, void *user_data)
Find a station action 0 property 24 station name, or reduce the free_names if needed.
NewGRF handling of rail types.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
static TropicZone GetTropicZone(TileIndex tile)
Get the tropic zone.
Select station (when joining stations); Window numbers:
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
static void SetAnimationFrame(TileIndex t, byte frame)
Set a new animation frame.
A standard stop for trucks.
static const uint COMPRESSION_INTERVAL
Minimum number of days between subsequent compressions of a LG.
static uint MapSizeY()
Get the size of the map along the Y.
static bool IsCustomStationSpecIndex(TileIndex t)
Is there a custom rail station spec on this tile?
void ClearDockingTilesCheckingNeighbours(TileIndex tile)
Clear docking tile status from tiles around a removed dock, if the tile has no neighbours which would...
Direction direction
facing
Non-existing type of vehicle.
const AirportSpec * GetSpec() const
Get the AirportSpec that from the airport type of this airport.
static void SetTileOwner(TileIndex tile, Owner owner)
Sets the owner of a tile.
Tile information, used while rendering the tile.
TileArea bus_station
Tile area the bus 'station' part covers.
CompanyMask statues
which companies have a statue?
Definition of link refreshing utility.
Direction rotation
How this airport is rotated.
Minimal stack that uses a pool to avoid pointers.
void DeallocateSpecFromStation(BaseStation *st, byte specindex)
Deallocate a StationSpec from a Station.
Some typedefs for the main game.
const AirportFTAClass * GetAirport(const byte airport_type)
Get the finite state machine of an airport type.
void TileLoop_Water(TileIndex tile)
Let a water tile floods its diagonal adjoining tiles called from tunnelbridge_cmd, and by TileLoop_Industry() and TileLoop_Track()
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
TileArea ship_station
Tile area the ship 'station' part covers.
static DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
byte landscape
the landscape we're currently in
Reference station. Scroll to station when clicking on the news. Delete news when station is deleted...
void AddAnimatedTile(TileIndex tile)
Add the given tile to the animated tile table (if it does not exist on that table yet)...
byte size_y
size of airport in y direction
Iterator to iterate over all tiles belonging to an airport.
company buildings - depots, stations, HQ, ...
Base class for roadstops.
static bool IsReversingRoadTrackdir(Trackdir dir)
Checks whether the trackdir means that we are reversing.
Track along the x-axis (north-east to south-west)
void Queue(LinkGraph *lg)
Queue a link graph for execution.
Date LastUnrestrictedUpdate() const
Get the date of the last update to the edge's unrestricted capacity.
bool HasVehicleEverTriedLoading() const
Reports whether a vehicle has ever tried to load the cargo at this station.
uint16 triggers
The triggers that trigger animation.
uint GetNumHangars() const
Get the number of hangars on this airport.
static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCommandFlag flags)
Checks if an airport can be built at the given location and clear the area.
static bool IsRailStation(TileIndex t)
Is this station tile a rail station?
RoadBits GetAnyRoadBits(TileIndex tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance)
Returns the RoadBits on an arbitrary tile Special behaviour:
EconomySettings economy
settings to change the economy
static RoadBits GetAllRoadBits(TileIndex tile)
Get all set RoadBits on the given tile.
static RoadStopType GetRoadStopType(TileIndex t)
Get the road stop type of this tile.
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
int32 TileIndexDiff
An offset value between to tiles.
static bool IsWater(TileIndex t)
Is it a plain water tile?
virtual TileIterator * Clone() const =0
Allocate a new iterator that is a copy of this one.
static Titem * Get(size_t index)
Returns Titem with given index.
static Station * GetClosestDeletedStation(TileIndex tile)
Find the closest deleted station of the current company.
static RoadStop ** FindRoadStopSpot(bool truck_station, Station *st)
void Unqueue(LinkGraph *lg)
Remove a link graph from the execution queue.
Functions related to dates.
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
const char * grf
newGRF used for the tile contents
uint GetSpecCount() const
Get the number of allocated specs within the class.
static const AirportTileSpec * GetByTile(TileIndex tile)
Retrieve airport tile spec for the given airport tile.
static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
Remove an airport.
Base for the train class.
The vehicle is in a drive-through road stop.
CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, CargoTypes *always_accepted)
Get the acceptance of cargoes around the tile in 1/8.
static byte GetAnimationFrame(TileIndex t)
Get the current animation frame.
static bool HasTileRoadType(TileIndex t, RoadTramType rtt)
Check if a tile has a road or a tram road type.
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.
Functions related to debugging.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Trackdir
Enumeration for tracks and directions.
void DrawRoadCatenary(const TileInfo *ti)
Draws the catenary for the given tile.
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...
Can planes land on this airport type?
uint16 cur_speed
current speed
A tile with road (or tram tracks)
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
bool distant_join_stations
allow to join non-adjacent stations
static TrackBits AxisToTrackBits(Axis a)
Maps an Axis to the corresponding TrackBits value.
Depot view; Window numbers:
Slope tileh
Slope of the tile.
Maximal number of cargo types in a game.
Full road along the x-axis (south-west + north-east)
Set when cargo was delivered for final delivery during the current STATION_ACCEPTANCE_TICKS interval...
Functions used internally by the roads.
A town owns the tile, or a town is expanding.
Flag for invalid railtype.
Specification of a cargo type.
SpriteID GetCanalSprite(CanalFeature feature, TileIndex tile)
Lookup the base sprite to use for a canal.
bool IsInUse() const
Check whether the base station currently is in use; in use means that it is not scheduled for deletio...
IndustryLifeType life_type
This is also known as Industry production flag, in newgrf specs.
TileIndex dest_tile
Heading for this tile.
bool ValParamRailtype(const RailType rail)
Validate functions for rail building.
void MakeDriveThrough()
Join this road stop to another 'base' road stop if possible; fill all necessary data to become an act...
static bool IsRoadStop(TileIndex t)
Is the station at t a road station?
StringID tramtype
Type of tram on the tile.
OrthogonalTileArea & Expand(int rad)
Expand a tile area by rad tiles in each direction, keeping within map bounds.
Functions related to vehicles.
Aircraft, helicopters, rotors and their shadows belong to this class.
Set when cargo was delivered for final delivery this month.
static const uint INVALID_AIRPORTTILE
id for an invalid airport tile
static bool HasTileWaterGround(TileIndex t)
Checks whether the tile has water at the ground.
static DiagDirection GetDockDirection(TileIndex t)
Get the direction of a dock.
static uint TileX(TileIndex tile)
Get the X component of a tile.
A standard stop for buses.
TileArea train_station
Tile area the train 'station' part covers.
static bool CMSATree(TileIndex tile)
Check whether the tile is a tree.
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
static void MakeOilrig(TileIndex t, StationID sid, WaterClass wc)
Make the given tile an oilrig tile.
byte station_spread
amount a station may spread
static int GetSlopeMaxZ(Slope s)
Returns the height of the highest corner of a slope relative to TileZ (= minimal height) ...
StationIDStack DeleteFlows(StationID via)
Delete all flows at a station for specific cargo and destination.
uint8 GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance)
Get a possible noise reduction factor based on distance from town center.
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
Iterator to iterate over all tiles belonging to an airport spec.
uint GetFlowVia(StationID via) const
Get the sum of flows via a specific station from this FlowStatMap.
Defines the internal data of a functional industry.
Tile description for the 'land area information' tool.
DifficultySettings difficulty
settings related to the difficulty
Stores station stats for a single cargo.
Tindex index
Index of this pool item.
Vehicle is flying in the air.
flag for invalid roadtype
static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags)
Remove a dock.
static StationGfx GetAirportGfx(TileIndex t)
Get the station graphics of this airport tile.
Manual distribution. No link graph calculations are run.
void ReleaseFlows(StationID via)
Release all flows at a station for specific cargo and destination.
static bool IsSteepSlope(Slope s)
Checks if a slope is steep.
Declarations for accessing the k-d tree of stations.
static void FreeTrainReservation(Train *v)
Clear platform reservation during station building/removing.
void RecomputeCatchment()
Recompute tiles covered in our catchment area.
Helper functions to extract data from command parameters.
void PassOnFlow(StationID origin, StationID via, uint amount)
Pass on some flow, remembering it as invalid, for later subtraction from locally consumed flow...
const DrawTileSeqStruct * GetLayout(PalSpriteID *ground) const
Returns the result spritelayout after preprocessing.
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.
void FinalizeLocalConsumption(StationID self)
Subtract invalid flows from locally consumed flow.
Representation of a waypoint.
void MoveSign(TileIndex new_xy) override
Move the station main coordinate somewhere else.
Required: Drive-in stop surface.
void MarkTilesDirty(bool cargo_change) const
Marks the tiles of the station as dirty.
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...
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
static Track GetRailStationTrack(TileIndex t)
Get the rail track of a rail station tile.
CommandCost FindJoiningBaseStation(StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, T **st)
Find a nearby station that joins this station.
uint32 station
Count of company owned station tiles.
#define FOR_EACH_SET_BIT(bitpos_var, bitset_value)
Do an operation for each set set bit in a value.
Flag for an invalid DiagDirection.
#define AllocaM(T, num_elements)
alloca() has to be called in the parent function, so define AllocaM() as a macro
Common return value for all commands.
static bool IsStandardRoadStopTile(TileIndex t)
Is tile t a standard (non-drive through) road stop station?
static bool HasExactlyOneBit(T value)
Test whether value has exactly 1 bit set.
void StartSpriteCombine()
Starts a block of sprites, which are "combined" into a single bounding box.
RoadType
The different roadtypes we support.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
static T max(const T a, const T b)
Returns the maximum of two values.
uint16 classes
Classes of this cargo type.
static bool IsDriveThroughStopTile(TileIndex t)
Is tile t a drive through road stop station?
Town * town
The town this station is associated with.
void ForAllStationsRadius(TileIndex center, uint radius, Func func)
Call a function on all stations whose sign is within a radius of a center tile.
bool HasRating() const
Does this cargo have a rating at this station?
uint8 status
Status; 0: no looping, 1: looping, 0xFF: no animation.
static DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
uint GetFlowFrom(StationID from) const
Get the sum of flows from a specific station from this FlowStatMap.
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
uint tiles
Number of tile layouts.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
uint16 w
The width of the area.
static RoadVehicle * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
bool IsTileFlat(TileIndex tile, int *h)
Check if a given tile is flat.
void Clear()
Clears the 'tile area', i.e.
Determine whether a newstation should be made available to build.
The vehicle entered a station.
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, the function returns the same as GetTilePixelSlope.
std::set< Station *, StationCompare > StationList
List of stations.
uint16 noise_reached
level of noise that all the airports are generating
uint16 rail_speed
Speed limit of rail (bridges and track)
byte nof_depots
the number of hangar tiles in this airport
static StationType GetStationType(TileIndex t)
Get the station type of this tile.
StationSettings station
settings related to station management
GoodsEntry goods[NUM_CARGO]
Goods at this station.
static const uint TILE_SIZE
Tile size in world coordinates.
static CommandCost RemoveRailWaypoint(TileIndex tile, DoCommandFlag flags)
Remove a rail waypoint.
static uint32 RandomRange(uint32 limit)
Pick a random number between 0 and limit - 1, inclusive.
RoadStopType
Types of RoadStops.
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
void AddCost(const Money &cost)
Adds the given cost to the cost of the command.
Owner owner[4]
Name of the owner(s)
StringID name
Displayed name of the industry.
void UpdateStationAcceptance(Station *st, bool show_msg)
Update the acceptance for a station.
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.
static uint GetCustomStationSpecIndex(TileIndex t)
Get the custom station spec for this tile.
StationList stations_near
NOSAVE: List of nearby stations.
const DrawTileSeqStruct * seq
Array of child sprites. Terminated with a terminator entry.
const AirportTileTable *const * table
list of the tiles composing the airport
CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Build a bus or truck stop.
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track)
Use this function to notify YAPF that track layout (or signal configuration) has change.
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.
static Station * From(BaseStation *st)
Converts a BaseStation to SpecializedStation with type checking.
static uint ClampU(const uint a, const uint min, const uint max)
Clamp an unsigned integer between an interval.
This struct contains all the info that is needed to draw and construct tracks.
CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags)
Clear a single tile of a station.
static CargoArray GetAcceptanceAroundStation(const Station *st, CargoTypes *always_accepted)
Get the acceptance of cargoes around the station in.
byte delete_ctr
Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is ...
Order * next
Pointer to next order. If nullptr, end of list.
bool selectgoods
only send the goods to station if a train has been there
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
company bankrupts, skip money check, skip vehicle on tile check in some cases
Functions related to (drawing on) viewports.
Pseudo random number generator.
void TriggerWatchedCargoCallbacks(Station *st)
Run the watched cargo callback for all houses in the catchment area.
A connected component of a link graph.
static bool HasStationRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint...
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...
CommandCost CanExpandRailStation(const BaseStation *st, TileArea &new_ta, Axis axis)
Check whether we can expand the rail part of the given station.
Set when cargo was delivered for final delivery last month.
Slope GetTileSlope(TileIndex tile, int *h)
Return the slope of a given tile inside the map.
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
SpriteID single_y
single piece of rail in Y direction, without ground
void EndSpriteCombine()
Terminates a block of sprites started by StartSpriteCombine.
void ScaleToMonthly(uint runtime)
Scale all shares from link graph's runtime to monthly values.
Triggered in the periodic tile loop.
static bool IsBridgeAbove(TileIndex t)
checks if a bridge is set above the ground of this tile
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...
static bool IsCompatibleTrainStationTile(TileIndex test_tile, TileIndex station_tile)
Check if a tile is a valid continuation to a railstation tile.
TileArea docking_station
Tile area the docking tiles cover.
Buses, trucks and trams belong to this class.
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...
static bool IsTileOwner(TileIndex tile, Owner owner)
Checks if a tile belongs to the given owner.
void UpdateAirportsNoise()
Recalculate the noise generated by the airports of each town.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold...
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.
void FindStationsAroundTiles(const TileArea &location, StationList *const stations, bool use_nearby)
Find all stations around a rectangular producer (industry, house, headquarter, ...)
Maximal number of airports in total.
StringID name
Name of this rail type.
byte noise_level
noise that this airport generates
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
uint GetShare(StationID st) const
Get flow for a station.
static bool CanRemoveRoadWithStop(TileIndex tile, DoCommandFlag flags)
Check if a drive-through road stop tile can be cleared.
void RestrictFlows(StationID via)
Restrict all flows at a station for specific cargo and destination.
Functions related to low-level strings.
byte amount_fract
Fractional part of the amount in the cargo list.
SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
uint x
X position of the tile in unit coordinates.
SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32 var10)
Resolve sprites for drawing a station tile.
uint Size() const
Get the current size of the component.
None of the directions are disallowed.
byte rating
Station rating for this cargo.
The tile has no ownership.
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
bool ValParamRoadType(RoadType roadtype)
Validate functions for rail building.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
EdgeIterator End()
Get an iterator pointing beyond the end of the edges array.
Foundation
Enumeration for Foundations.
TileIndex xy
town center tile
static void SetStationTileRandomBits(TileIndex t, byte random_bits)
Set the random bits for a station tile.
static bool IsBuoy(TileIndex t)
Is tile t a buoy tile?
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
Triggered when the airport is built (for all tiles at the same time).
static void MakeAirport(TileIndex t, Owner o, StationID sid, byte section, WaterClass wc)
Make the given tile an airport tile.
TileIndex tile
Tile index.
AirportClassID cls_id
the class to which this airport type belongs
static uint ApplyPixelFoundationToSlope(Foundation f, Slope *s)
Applies a foundation to a slope.
static const int GFX_DOCK_BASE_WATER_PART
The offset for the water parts.
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
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.
RoadStop * truck_stops
All the truck stops.
This indicates whether a cargo has a rating at the station.
StationID GetVia(StationID source) const
Get the best next hop for a cargo packet from station source.
void Add(TileIndex to_add)
Add a single tile to a tile area; enlarge if needed.
static int CountMapSquareAround(TileIndex tile, CMSAMatcher cmp)
Counts the numbers of tiles matching a specific type in the area around.
bool serve_neutral_industries
company stations can serve industries with attached neutral stations
StringID owner_type[4]
Type of each owner.
static RoadBits GetRoadBits(TileIndex t, RoadTramType rtt)
Get the present road bits for a specific road type.
void ClearDriveThrough()
Prepare for removal of this stop; update other neighbouring stops if needed.
The tile is leveled up to a flat slope.
LinkGraphID link_graph
Link graph this station belongs to.
Information about GRF, used in the game and (part of it) in savegames.
static bool HasStationReservation(TileIndex t)
Get the reservation state of the rail station.
static bool IsRailStationTile(TileIndex t)
Is this tile a station tile and a rail station?
Ground palette sprite of a tile, together with its sprite layout.
bool road_stop_on_competitor_road
allow building of drive-through road stops on roads owned by competitors
static void SetStationGfx(TileIndex t, StationGfx gfx)
Set the station graphics of this tile.
bool IsTileForestIndustry(TileIndex tile)
Check whether the tile is a forest.
void DirtyCompanyInfrastructureWindows(CompanyID company)
Redraw all windows with company infrastructure counts.
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Remove bus or truck stops.
WaterClass
classes of water (for WATER_TILE_CLEAR water tile type).
Images for overlaying track.
static bool StationHandleBigTick(BaseStation *st)
This function is called for each station once every 250 ticks.
static bool IsTruckStop(TileIndex t)
Is the station at t a truck stop?
const Direction * rotation
the rotation of each tiletable
static void TruncateCargo(const CargoSpec *cs, GoodsEntry *ge, uint amount=UINT_MAX)
Truncate the cargo by a specific amount.
uint DistanceMax(TileIndex t0, TileIndex t1)
Gets the biggest distance component (x or y) between the two given tiles.
StationID GetVia() const
Get a station a package can be routed to.
static DiagDirection GetRoadStopDir(TileIndex t)
Gets the direction the road stop entrance points towards.
Entry point for OpenTTD to YAPF's cache.
bool IsType(OrderType type) const
Check whether this order is of the given type.
TileArea truck_station
Tile area the truck 'station' part covers.
const StationList * GetStations()
Run a tile loop to find stations around a tile, on demand.
Functions related to NewGRF houses.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
DoCommandFlag
List of flags for a command.
uint16 tram_speed
Speed limit of tram (bridges and track)
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
ClientSettings _settings_client
The current settings for this game.
byte status
Status of this cargo, see GoodsEntryStatus.
Piece of rail in X direction.
bool Succeeded() const
Did this command succeed?
Container for cargo from the same location and time.
static bool HasStationTileRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint...
void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint capacity, uint usage, EdgeUpdateMode mode)
Increase capacity for a link stat given by station cargo and next hop.
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
byte layout
Airport layout number.
void DeleteAnimatedTile(TileIndex tile)
Removes the given tile from the animated tile table.
SpriteID GetCustomRoadSprite(const RoadTypeInfo *rti, TileIndex tile, RoadTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec)
Allocate a StationSpec to a Station.
#define TILE_AREA_LOOP(var, ta)
A loop which iterates over the tiles of a TileArea.
Definition of base types and functions in a cross-platform compatible way.
static const Date INVALID_DATE
Representation of an invalid date.
Shift the VehicleEnterTileStatus this many bits to the right to get the station ID when VETS_ENTERED_...
static TrackBits GetRailReservationTrackBits(TileIndex t)
Returns the reserved track bits of the tile.
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.
A number of safeguards to prevent using unsafe methods.
StationList stations_near
NOSAVE: List of nearby stations.
static void Run(Vehicle *v, bool allow_merge=true, bool is_full_loading=false)
Refresh all links the given vehicle will visit.
Trigger station every 250 ticks.
void WatchedCargoCallback(TileIndex tile, CargoTypes trigger_cargoes)
Run watched cargo accepted callback for a house.
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.
IndustryType GetIndustryType(TileIndex tile)
Retrieve the type for this industry.
static const uint64 AIRPORT_CLOSED_block
Dummy block for indicating a closed airport.
Direction
Defines the 8 directions on the map.
IndustryType type
type of industry.
static PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
static bool IsDockTile(TileIndex t)
Is tile t a dock tile?
static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags)
Remove a bus station/truck stop.
The vehicle cannot enter the tile.
static Axis GetRailStationAxis(TileIndex t)
Get the rail direction of a rail station.
uint y
Y position of the tile in unit coordinates.
struct RoadStop * next
Next stop of the given type at this station.
bool HasStationInUse(StationID station, bool include_company, CompanyID company)
Tests whether the company's vehicles have this station in orders.
Liquids (Oil, Water, Rubber)
RoadBits
Enumeration for the road parts on a tile.
uint8 callback_mask
Bitmask of cargo callbacks that have to be called.
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 ShowDepotWindow(TileIndex tile, VehicleType type)
Opens a depot window.
void GetTileArea(TileArea *ta, StationType type) const override
Get the tile area for a given station type.
static const uint MIN_TIMEOUT_DISTANCE
Minimum effective distance for timeout calculation.
TileArea location
Location of the industry.
byte num_table
number of elements in the table
NodeID node
ID of node in link graph referring to this goods entry.
void GetStationLayout(byte *layout, int numtracks, int plat_len, const StationSpec *statspec)
Create the station layout for the given number of tracks and platform length.
static bool CMSAMine(TileIndex tile)
Check whether the tile is a mine.
bool IsHangar(TileIndex t)
Check whether the given tile is a hangar.
CargoID cargo_type
type of cargo this vehicle is carrying
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
Train * GetTrainForReservation(TileIndex tile, Track track)
Find the train which has reserved a specific path.
static bool IsBuoyTile(TileIndex t)
Is tile t a buoy tile?
NewGRF handling of road types.
Represents the covered area of e.g.
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
GUI Functions related to companies.
CargoID produced_cargo[INDUSTRY_NUM_OUTPUTS]
16 production cargo slots
static bool IsAirport(TileIndex t)
Is this station tile an airport?
TrackBits
Bitfield corresponding to Track.
CommandCost RemoveRailStation(T *st, DoCommandFlag flags, Money removal_cost)
Remove a rail station/waypoint.
StringID name
Tile Subname string, land information on this tile will give you "AirportName (TileSubname)".
Functions related to order backups.
bool IsFrontEngine() const
Check if the vehicle is a front engine.
bool road_stop_on_town_road
allow building of drive-through road stops on town owned roads
Trigger station on new cargo arrival.
void UpdateVirtCoord() override
Update the virtual coords needed to draw the station sign.
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
Map accessor functions for bridges.
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
Set when a sprite originates from an Action 1.
TileIndex tile
Current tile index.
uint16 max_speed
Maximum speed for vehicles travelling on this road type.
Owner owner
owner of the industry. Which SHOULD always be (imho) OWNER_NONE
Defines the data structure for constructing industry.
StationSpecList * speclist
List of station specs of this station.
CommandCost CheckOwnership(Owner owner, TileIndex tile)
Check whether the current owner owns something.
static Money RoadBuildCost(RoadType roadtype)
Returns the cost of building the specified roadtype.
void Push(const Titem &item)
Pushes a new item onto the stack if there is still space in the underlying pool.
Base class for tile iterators.
void UpdateCompanyRoadInfrastructure(RoadType rt, Owner o, int count)
Update road infrastructure counts for a company.
static const int STATION_RATING_TICKS
cycle duration for updating station rating
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
static const AirportSpec * Get(byte type)
Retrieve airport spec for the given airport.
PersistentStorage * psa
Persistent storage for NewGRF airports.
static const AirportTileSpec * Get(StationGfx gfx)
Retrieve airport tile spec for the given airport tile.
Station view; Window numbers:
CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Build a dock/haven.
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.
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?
Date LastRestrictedUpdate() const
Get the date of the last update to the edge's restricted capacity.
StationRect - used to track station spread out rectangle - cheaper than scanning whole map...
Bit value for coloured news.
SpriteID single_x
single piece of rail in X direction, without ground
struct RoadTypeInfo::@42 strings
Strings associated with the rail type.
Called when building a station to customize the tile layout.
virtual TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
static const uint8 ANIM_STATUS_NO_ANIMATION
There is no animation.
void RestrictShare(StationID st)
Restrict a flow by moving it to the end of the map and decreasing the amount of unrestricted flow...
void AddFlow(StationID origin, StationID via, uint amount)
Add some flow from "origin", going via "via".
Owner owner
Which company owns the vehicle?
uint64 flags
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Rename a station.
static const SharesMap empty_sharesmap
Static instance of FlowStat::SharesMap.
Catchment for all stations with "modified catchment" disabled.
#define lengthof(x)
Return the length of an fixed size array.
byte last_speed
Maximum speed (up to 255) of the last vehicle that tried to load this cargo.
uint8 cached_anim_triggers
NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen...
GRFFileProps grf_prop
properties related to the grf file
static T min(const T a, const T b)
Returns the minimum of two values.
static Foundation FlatteningFoundation(Slope s)
Returns the foundation needed to flatten a slope.
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.
StringID railtype
Type of rail on the tile.
static bool MayHaveRoad(TileIndex t)
Test whether a tile can have road/tram types.
StringID airport_tile_name
Name of the airport tile.
static bool IsCargoInClass(CargoID c, CargoClass cc)
Does cargo c have cargo class cc?
Piece of rail in Y direction.
uint16 refit_cap
Capacity left over from before last refit.
static DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
Functions related to autoslope.
NewGRF supplied spritelayout.
static bool IsPlainRailTile(TileIndex t)
Checks whether the tile is a rail tile or rail tile with signals.
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
Converts a callback result into a boolean.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
static bool AutoslopeEnabled()
Tests if autoslope is enabled for _current_company.
uint DistanceFromEdge(TileIndex tile)
Param the minimum distance to an edge.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
static TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, TrackdirBits red_signals)
Builds a TrackStatus.
bool build_on_slopes
allow building on slopes
Date LastCompression() const
Get date of last compression.
bool Failed() const
Did this command fail?
StringID station_name
Type of station within the class.
byte last_age
Age in years (up to 255) of the last vehicle that tried to load this cargo.
const struct SpriteGroup * spritegroup[Tcnt]
pointer to the different sprites of the entity
TileIndex GetHangarTile(uint hangar_num) const
Get the first tile of the given hangar.
static StationGfx GetStationGfx(TileIndex t)
Get the station graphics of this tile.
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.
All ships have this type.
Date LastUpdate() const
Get the date of the last update to any part of the edge's capacity.
RoadStop * bus_stops
All the road stops.
uint16 MaxTownNoise() const
Calculate the max town noise.
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 Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
NewGRF handling of airport tiles.
void ShowStationViewWindow(StationID station)
Opens StationViewWindow for given station.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
static void SetRoadOwner(TileIndex t, RoadTramType rtt, Owner o)
Set the owner of a specific road type.
Station list; Window numbers:
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static bool HasSignals(TileIndex t)
Checks if a rail tile has signals.
FlowStatMap flows
Planned flows through this station.
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. ...
CommandCost FindJoiningWaypoint(StationID existing_waypoint, StationID waypoint_to_join, bool adjacent, TileArea ta, Waypoint **wp)
Find a nearby waypoint that joins this waypoint.
uint Truncate(uint max_move=UINT_MAX, StationCargoAmountMap *cargo_per_source=nullptr)
Truncates where each destination loses roughly the same percentage of its cargo.
bool Enter(RoadVehicle *rv)
Enter the road stop.
static void Reset(TileIndex tile=INVALID_TILE, bool from_gui=true)
Reset the OrderBackups from GUI/game logic.
#define DEBUG(name, level,...)
Output a line of debugging information.
'Train' is either a loco or a wagon.
uint8 FindFirstBit(uint32 x)
Search the first set bit in a 32 bit variable.
void ChangeShare(StationID st, int flow)
Change share for specified station.
Functions related to clear (MP_CLEAR) land.
EdgeUpdateMode
Special modes for updating links.
TileIndex tile
The base tile of the area.
byte flags
Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size...
uint16 _tick_counter
Ever incrementing (and sometimes wrapping) tick counter for setting off various events.
StationGfx GetStationGfx() const
Get the StationGfx for the current tile.
SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint layout, uint edge_info)
Resolve the sprites for custom station foundations.
A pair-construct of a TileIndexDiff.
static TrackBits GetTrackBits(TileIndex tile)
Gets the track bits of the given tile.
bool(* CMSAMatcher)(TileIndex tile)
Function to check whether the given tile matches some criterion.
void UpdateAllStationVirtCoords()
Update the virtual coords needed to draw the station sign for all stations.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
uint32 rail[RAILTYPE_END]
Count of company owned track bits for each rail type.
bool IsValidDockingDirectionForDock(TileIndex t, DiagDirection d)
Check if a dock tile can be docked from the given direction.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
void ReleaseShare(StationID st)
Release ("unrestrict") a flow by moving it to the begin of the map and increasing the amount of unres...
static Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
static TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between to tiles from a TileIndexDiffC struct.
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
Handling of NewGRF canals.
byte StationGfx
Copy from station_map.h.
CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad)
Get the cargo types being produced around the tile (in a rectangle).
execute the given command
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
static TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
The tile/execution is done by "water".
uint GetHangarNum(TileIndex tile) const
Get the hangar number of the hangar at a specific tile.
static bool HasPowerOnRoad(RoadType enginetype, RoadType tiletype)
Checks if an engine of the given RoadType got power on a tile with a given RoadType.
CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags)
Checks whether the local authority allows construction of a new station (rail, road, airport, dock) on the given tile.
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
PalSpriteID ground
Palette and sprite for the ground.
GRFConfig * GetGRFConfig(uint32 grfid, uint32 mask)
Retrieve a NewGRF from the current config by its grfid.
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...
static uint MapSize()
Get the size of the map.
StationType
Station types.
this bit is set when a recolouring process is in action
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
Class for storing amounts of cargo.
static Owner GetRoadOwner(TileIndex t, RoadTramType rtt)
Get the owner of a specific road type.
static bool IsNormalRoadTile(TileIndex t)
Return whether a tile is a normal road tile.
static bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
Find out if the slope of the tile is suitable to build a depot of given direction.
Header file for NewGRF stations.
Track along the y-axis (north-west to south-east)
RailType
Enumeration for all possible railtypes.
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
CommandCost CmdOpenCloseAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Open/close an airport to incoming aircraft.
Trackdir GetVehicleTrackdir() const
Get the tracks of the train vehicle.
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.
bool IsStationTileBlocked(TileIndex tile)
Check whether a rail station tile is NOT traversable.
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.
GUISettings gui
settings related to the GUI
DestinationID GetDestination() const
Gets the destination of this order.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Only bits 0 and 3 are used to encode the trackdir for road stops.
static Track RemoveFirstTrack(TrackBits *tracks)
Removes first Track from TrackBits and returns it.
static TileIndex FindDockLandPart(TileIndex t)
Find the part of a dock that is land-based.
void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, byte widget_index)
Mark a particular widget in a particular window as dirty (in need of repainting)
bool station_noise_level
build new airports when the town noise level is still within accepted limits
uint max_waiting_cargo
Max cargo from this station waiting at any station.
bool NeedsPreprocessing() const
Tests whether this spritelayout needs preprocessing by PrepareLayout() and ProcessRegisters(), or whether it can be used directly.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
void StationMonthlyLoop()
Monthly loop for stations.
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
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 CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
uint16 road_speed
Speed limit of road (bridges and track)
Set of callback functions for performing tile operations of a given tile type.
T * Last()
Get the last vehicle in the chain.
size_t MapSize() const
Count the number of ranges with equal keys in this MultiMap.
uint32 TileIndex
The index/ID of a Tile.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
Use different sprite set for ground sprites.
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...
virtual bool TileBelongsToRailStation(TileIndex tile) const =0
Check whether a specific tile belongs to this station.
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
Cargo support for NewGRFs.
void RerouteCargo(Station *st, CargoID c, StationID avoid, StationID avoid2)
Reroute cargo of type c at station st or in any vehicles unloading there.
void Invalidate()
Reduce all flows to minimum capacity so that they don't get in the way of link usage statistics too m...
static size_t GetNumItems()
Returns number of valid items in the pool.
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.
Vehicle * Next() const
Get the next vehicle of this vehicle.
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...
StringID name
name of this airport
Extended foundation block instead of simple.
bool modified_catchment
different-size catchment areas
Trigger station on new cargo arrival.
byte fallback_railtype
Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations...
static Money RailBuildCost(RailType railtype)
Returns the cost of building the specified railtype.
void Remove(const T &element)
Remove a single element from the tree, if it exists.
OrderSettings order
settings related to orders
static const IndustryType NUM_INDUSTRYTYPES
total number of industry types, new and old; limited to 240 because we need some special ids like INV...
static IndustryID GetIndustryIndex(TileIndex t)
Get the industry ID of the given tile.
AnimationInfo animation
Information about the animation.
Track
These are used to specify a single track.
uint16 SourceID
Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
const SharesMap * GetShares() const
Get the actual shares as a const pointer so that they can be iterated over.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Sprites to use and how to display them for station tiles.
Bit sets of the above specified bits.
byte town_council_tolerance
minimum required town ratings to be allowed to demolish stuff
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
bool IsWithinMapBounds(byte table, TileIndex index) const
Check if the airport would be within the map bounds at the given tile.
Availability of station in construction window.
byte size_x
size of airport in x direction
void FreeTrainTrackReservation(const Train *v)
Free the reserved path in front of a vehicle.
TileIndex xy
Base tile of the station.
TransportType
Available types of transport.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
void AppendShare(StationID st, uint flow, bool restricted=false)
Add some flow to the end of the shares map.
StringID airport_name
Name of the airport.
A type of cargo is (no longer) accepted.
static bool IsOilRig(TileIndex t)
Is tile t part of an oilrig?
Slope
Enumeration for the slope-type.
VehicleType type
Type of vehicle.
Town view; Window numbers:
void DrawRailCatenary(const TileInfo *ti)
Draws overhead wires and pylons for electric railways.
BitmapTileArea catchment_tiles
NOSAVE: Set of individual tiles covered by catchment area.
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
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.
bool show_track_reservation
highlight reserved tracks.
void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool b)
Set the reservation for a complete station platform.
Main group of ground images.
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
uint8 exclusive_counter
months till the exclusivity expires
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() ...
Transport by road vehicle.
Flow statistics telling how much flow should be sent along a link.
static const int STATION_LINKGRAPH_TICKS
cycle duration for cleaning dead links
uint GetRailtypeSpriteOffset() const
Offset between the current railtype and normal rail.
The vehicle is in a road stop.
static bool IsRailWaypoint(TileIndex t)
Is this station tile a rail waypoint?
Station * neutral_station
Associated neutral station.
void OffsetGroundSprite(int x, int y)
Called when a foundation has been drawn for the current tile.
static uint CountBits(T value)
Counts the number of set bits in a variable.
Defines the data structure of each individual tile of an airport.
Functions related to commands.
static bool IsValidID(size_t index)
Tests whether given index is a valid index for station of this type.
CommandCost CmdRemoveFromRailStation(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Remove a single tile from a rail station.
Coordinates of a point in 2D.
remove a single rail track
A Stop for a Road Vehicle.
CompanyID _current_company
Company currently doing an action.
void AddFacility(StationFacility new_facility_bit, TileIndex facil_xy)
Called when new facility is built on the station.
CargoID Index() const
Determines index of this cargospec.
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.
Owner owner
The owner of this station.
byte GetSnowLine()
Get the current snow line, either variable or static.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static bool HasRailCatenaryDrawn(RailType rt)
Test if we should draw rail catenary.
Date build_date
Date of construction of tile contents.
static bool IsRoadStopTile(TileIndex t)
Is tile t a road stop station?
uint GetFlowFromVia(StationID from, StationID via) const
Get the flow from a specific station via a specific other station.
header file for electrified rail specific functions
Triggered every 250 ticks (for all tiles at the same time).
static void DeleteStationIfEmpty(BaseStation *st)
This is called right after a station was deleted.
bool adjacent_stations
allow stations to be built directly adjacent to other stations
ConstructionSettings construction
construction of things in-game
Functions that have tunnels and bridges in common.
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
static DisallowedRoadDirections GetDisallowedRoadDirections(TileIndex t)
Gets the disallowed directions.
const char * GetName() const
Get the name of this grf.
static Pool::IterateWrapper< RoadVehicle > Iterate(size_t from=0)
Returns an iterable ensemble of all valid vehicles of type T.
Functions related to waypoints.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Airport airport
Tile area the airport covers.
static bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
Autoslope check for tiles with an entrance on an edge.
StringID name
Name of this rail type.
CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Place an Airport.
RailTrackOffset
Offsets for sprites within an overlay/underlay set.
CommandCost RemoveBuoy(TileIndex tile, DoCommandFlag flags)
Remove a buoy.
const struct GRFFile * grffile
grf file that introduced this entity
static const uint MAX_LENGTH_STATION_NAME_CHARS
The maximum length of a station name in characters including '\0'.
StringID str
Description of the tile.
StringID station_name
Default name for nearby station.
static bool IsHangarTile(TileIndex t)
Is tile t an hangar tile?
const Tcont * Packets() const
Returns a pointer to the cargo packet list (so you can iterate over it etc).
remove a (rectangle of) tiles from a rail station
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 bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
static bool HasTileWaterClass(TileIndex t)
Checks whether the tile has an waterclass associated.
DiagDirection
Enumeration for diagonal directions.
static TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
StringID station_class
Class of station.
void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1=NR_NONE, uint32 ref1=UINT32_MAX, NewsReferenceType reftype2=NR_NONE, uint32 ref2=UINT32_MAX, void *free_data=nullptr)
Add a new newsitem to be shown.
byte callback_mask
Bitmask of station callbacks that have to be called.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
byte disallowed_lengths
Bitmask of platform lengths available for the station.
StringID roadtype
Type of road on the tile.
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.
Station with truck stops.
Northeast, upper right on your monitor.
Required: Main group of ground images.
CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Build rail station.
Choose a sprite layout to draw, instead of the standard 0-7 range.
GameCreationSettings game_creation
settings used during the creation of a game (map)
static const uint NEW_AIRPORTTILE_OFFSET
offset of first newgrf airport tile
uint AvailableCount() const
Returns sum of cargo still available for loading at the sation.
void UpdateAirplanesOnNewStation(const Station *st)
Updates the status of the Aircraft heading or in the station.
Full road along the y-axis (north-west + south-east)
byte CargoID
Cargo slots to indicate a cargo type within a game.
IndustryType indtype
Industry type to get the name from.
Enum of the default airport tiles.
Check slope of new station tiles.
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
NewGRFSpriteLayout * renderdata
Array of tile layouts.
Small news item. (Information window with text and viewport)
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
void AfterStationTileSetChange(bool adding, StationType type)
After adding/removing tiles to station, update some station-related stuff.
Station with train station.
byte time_since_pickup
Number of rating-intervals (up to 255) since the last vehicle tried to load this cargo.
static CargoTypes GetAcceptanceMask(const Station *st)
Get a mask of the cargo types that the station accepts.
StringID name
Name of this station.
Maximum catchment for airports with "modified catchment" enabled.
Defines the data structure for an airport.
Functions related to water (management)
static DiagDirection AxisToDiagDir(Axis a)
Converts an Axis to a DiagDirection.
static bool CMSAWater(TileIndex tile)
Check whether the tile is water.
An iterator for non-const edges.
static bool IsTileOnWater(TileIndex t)
Tests if the tile was built on water.
VehicleEnterTileStatus
The returned bits of VehicleEnterTile.
StationGfx GetTranslatedAirportTileID(StationGfx gfx)
Do airporttile gfx ID translation for NewGRFs.
SpriteID sprite
The 'real' sprite.
CommandCost CmdRemoveFromRailWaypoint(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Remove a single tile from a waypoint.
byte disallowed_platforms
Bitmask of number of platforms available for the station.
StringID airport_class
Name of the airport class.
Functions related to news.
static void MakeRoadNormal(TileIndex t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
Make a normal road tile.
uint GetFlow() const
Get the sum of all flows from this FlowStatMap.
StationClassID cls_id
The class to which this spec belongs.
Base classes/functions for stations.
void RemoveEdge(NodeID to)
Remove an outgoing edge from this node.
static bool IsDock(TileIndex t)
Is tile t a dock tile?
static Station * Get(size_t index)
Gets station with given index.
Date _date
Current date in days (day counter)
bool TryPathReserve(Train *v, bool mark_as_stuck=false, bool first_tile_okay=false)
Try to reserve a path to a safe position.
uint16 h
The height of the area.
void Insert(const T &element)
Insert a single element in the tree.
static void SetDockingTile(TileIndex t, bool b)
Set the docking tile state of a tile.
Triggered when new cargo arrives at the station (for all tiles at the same time). ...
Industry * industry
NOSAVE: Associated industry for neutral stations. (Rebuilt on load from Industry->st) ...
GRFFileProps grf_prop
properties related the the grf file
static Point RemapCoords2(int x, int y)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap...
CompanyID exclusivity
which company has exclusivity
StringID string_id
Default name (town area) of station.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
remove a (rectangle of) tiles from a rail waypoint
void CheckForDockingTile(TileIndex t)
Mark the supplied tile as a docking tile if it is suitable for docking.
void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index)
Delete inspect window for a given feature and index.
void Append(CargoPacket *cp, StationID next)
Appends the given cargo packet to the range of packets with the same next station.
void Merge(LinkGraph *other)
Merge a link graph with another one.
Optional: Images for overlaying track.
Base class for all station-ish types.
static const int STATION_ACCEPTANCE_TICKS
cycle duration for updating station acceptance
Axis
Allow incrementing of DiagDirDiff variables.
static CommandCost FindJoiningStation(StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, Station **st)
Find a nearby station that joins this station.
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.
struct GRFFileProps grf_prop
Properties related to the grf file.
custom station rating for this cargo type
LinkGraphSettings linkgraph
settings for link graph calculations
Used for industry tiles on land (also for oilrig if newgrf says so).
Set when the station accepts the cargo currently for final deliveries.
static RoadBits AxisToRoadBits(Axis a)
Create the road-part which belongs to the given Axis.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
Order current_order
The current order (+ status, like: loading)
static RoadStop * GetByTile(TileIndex tile, RoadStopType type)
Find a roadstop at given tile.
Date build_date
Date of construction.
Called to calculate part of a station rating.
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-...
static void RestoreTrainReservation(Train *v)
Restore platform reservation during station building/removing.
static int GetTileMaxPixelZ(TileIndex tile)
Get top height of the tile.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
CargoTypes always_accepted
Bitmask of always accepted cargo types (by houses, HQs, industry tiles when industry doesn't accept c...
PaletteID pal
The palette (use PAL_NONE) if not needed)
uint32 water
Count of company owned track bits for canals.
StringID name
Name of this class.
static Station * GetIfValid(size_t index)
Returns station if the index is a valid index for this station type.