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);
456 void BaseStation::FillCachedName()
const 459 int64 args_array[] = { this->index };
462 this->cached_name.assign(buf, end);
465 void ClearAllStationCachedNames()
493 for (uint i = 0; i < num_items; i++) {
511 std::set<IndustryID> industries;
518 AddProducedCargo(tile, produced);
524 for (IndustryID industry : industries) {
550 if (always_accepted !=
nullptr) *always_accepted = 0;
558 AddAcceptedCargo(tile, acceptance, always_accepted);
572 if (always_accepted !=
nullptr) *always_accepted = 0;
576 AddAcceptedCargo(tile, acceptance, always_accepted);
594 if (!st->
rect.IsEmpty()) {
600 uint amt = acceptance[i];
618 if (old_acc == new_acc)
return;
624 static const StringID accept_msg[] = {
625 STR_NEWS_STATION_NOW_ACCEPTS_CARGO,
626 STR_NEWS_STATION_NOW_ACCEPTS_CARGO_AND_CARGO,
628 static const StringID reject_msg[] = {
629 STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO,
630 STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_OR_CARGO,
644 accepts[num_acc++] = i;
649 rejects[num_rej++] = i;
663 static void UpdateStationSignCoord(
BaseStation *st)
667 if (r->IsEmpty())
return;
671 st->MoveSign(new_xy);
696 if (*st !=
nullptr) {
701 CommandCost ret = (*st)->rect.BeforeAddRect(area.
tile, area.
w, area.
h, StationRect::ADD_TEST);
702 if (ret.
Failed())
return ret;
709 _station_kdtree.
Insert((*st)->index);
712 (*st)->string_id = GenerateStationName(*st, area.
tile, name_class);
735 UpdateStationSignCoord(st);
745 this->UpdateVirtCoord();
746 this->RecomputeCatchment();
754 case STATION_AIRPORT:
763 default: NOT_REACHED();
793 if (ret.
Failed())
return ret;
816 cost.
AddCost(_price[PR_BUILD_FOUNDATION]);
823 }
else if (allowed_z != flat_z) {
843 if (ret.
Failed())
return ret;
847 if (ret.
Failed())
return ret;
872 uint invalid_dirs = 5 << axis;
879 if (ret.
Failed())
return ret;
885 if (ret.
Failed())
return ret;
896 if (*station == INVALID_STATION) {
898 }
else if (*station != st) {
923 affected_vehicles.push_back(v);
927 if (ret.
Failed())
return ret;
934 if (ret.
Failed())
return ret;
961 if (ret.
Failed())
return ret;
980 if (*station == INVALID_STATION) {
982 }
else if (*station != st) {
1005 if (build_over_road) {
1007 RoadType road_rt = GetRoadType(cur_tile, RTT_ROAD);
1014 if (ret.
Failed())
return ret;
1022 if (ret.
Failed())
return ret;
1026 }
else if (RoadTypeIsRoad(rt)) {
1031 RoadType tram_rt = GetRoadType(cur_tile, RTT_TRAM);
1040 if (ret.
Failed())
return ret;
1047 }
else if (RoadTypeIsTram(rt)) {
1052 if (ret.
Failed())
return ret;
1088 static inline byte *CreateSingle(byte *layout,
int n)
1091 do *layout++ = 0;
while (--i);
1092 layout[((n - 1) >> 1) - n] = 2;
1096 static inline byte *CreateMulti(byte *layout,
int n, byte b)
1099 do *layout++ = b;
while (--i);
1102 layout[n - 1 - n] = 0;
1116 if (statspec !=
nullptr && statspec->lengths >= plat_len &&
1117 statspec->platforms[plat_len - 1] >= numtracks &&
1118 statspec->layouts[plat_len - 1][numtracks - 1]) {
1120 memcpy(layout, statspec->layouts[plat_len - 1][numtracks - 1],
1121 plat_len * numtracks);
1125 if (plat_len == 1) {
1126 CreateSingle(layout, numtracks);
1128 if (numtracks & 1) layout = CreateSingle(layout, plat_len);
1131 while (--numtracks >= 0) {
1132 layout = CreateMulti(layout, plat_len, 4);
1133 layout = CreateMulti(layout, plat_len, 6);
1149 template <
class T, StringID error_message>
1152 assert(*st ==
nullptr);
1153 bool check_surrounding =
true;
1156 if (existing_station != INVALID_STATION) {
1157 if (adjacent && existing_station != station_to_join) {
1164 *st = T::GetIfValid(existing_station);
1165 check_surrounding = (*st ==
nullptr);
1170 if (adjacent) check_surrounding =
false;
1174 if (check_surrounding) {
1177 if (ret.
Failed())
return ret;
1181 if (*st ==
nullptr && station_to_join != INVALID_STATION) *st = T::GetIfValid(station_to_join);
1197 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_RAILWAY_STATION_FIRST>(existing_station, station_to_join, adjacent, ta, st);
1211 return FindJoiningBaseStation<Waypoint, STR_ERROR_MUST_REMOVE_RAILWAYPOINT_FIRST>(existing_waypoint, waypoint_to_join, adjacent, ta, wp);
1258 RailType rt = Extract<RailType, 0, 6>(p1);
1259 Axis axis = Extract<Axis, 6, 1>(p1);
1260 byte numtracks =
GB(p1, 8, 8);
1261 byte plat_len =
GB(p1, 16, 8);
1262 bool adjacent =
HasBit(p1, 24);
1265 byte spec_index =
GB(p2, 8, 8);
1266 StationID station_to_join =
GB(p2, 16, 16);
1270 if (ret.
Failed())
return ret;
1277 if (plat_len == 0 || numtracks == 0)
return CMD_ERROR;
1288 bool reuse = (station_to_join != NEW_STATION);
1289 if (!reuse) station_to_join = INVALID_STATION;
1290 bool distant_join = (station_to_join != INVALID_STATION);
1297 TileArea new_location(tile_org, w_org, h_org);
1300 StationID est = INVALID_STATION;
1301 std::vector<Train *> affected_vehicles;
1304 if (cost.
Failed())
return cost;
1306 cost.
AddCost((numtracks * _price[PR_BUILD_STATION_RAIL] + _price[PR_BUILD_STATION_RAIL_LENGTH]) * plat_len);
1311 if (ret.
Failed())
return ret;
1313 ret =
BuildStationPart(&st, flags, reuse, new_location, STATIONNAMING_RAIL);
1314 if (ret.
Failed())
return ret;
1318 if (ret.
Failed())
return ret;
1326 if (statspec !=
nullptr) {
1341 if (flags & DC_EXEC) {
1344 byte numtracks_orig;
1350 st->
rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY);
1352 if (statspec !=
nullptr) {
1361 layout_ptr =
AllocaM(byte, numtracks * plat_len);
1364 numtracks_orig = numtracks;
1372 byte layout = *layout_ptr++;
1377 affected_vehicles.push_back(v);
1402 if (statspec !=
nullptr) {
1417 TriggerStationAnimation(st, tile,
SAT_BUILT);
1425 }
while (--numtracks);
1427 for (uint i = 0; i < affected_vehicles.size(); ++i) {
1435 update_reservation_area =
TileArea(tile_org, 1, numtracks_orig);
1437 update_reservation_area =
TileArea(tile_org, numtracks_orig, 1);
1451 platform_begin = next_tile;
1454 platform_end = next_tile;
1458 bool reservation =
false;
1459 for (
TileIndex t = platform_begin; !reservation && t <= platform_end; t += tile_offset) {
1480 if (ta.
w != 0 && ta.
h != 0) {
1530 static void MakeRailStationAreaSmaller(
BaseStation *st)
1540 static void MakeShipStationAreaSmaller(
Station *st)
1543 UpdateStationDockingTiles(st);
1575 if (ret.
Failed())
continue;
1578 T *st = T::GetByTile(tile);
1579 if (st ==
nullptr)
continue;
1584 if (ret.
Failed())
continue;
1593 total_cost.
AddCost(-_price[PR_CLEAR_RAIL]);
1612 DoClearSquare(tile);
1618 st->rect.AfterRemoveTile(st, tile);
1624 include(affected_stations, st);
1632 for (T *st : affected_stations) {
1637 MakeRailStationAreaSmaller(st);
1638 UpdateStationSignCoord(st);
1649 total_cost.
AddCost(quantity * removal_cost);
1670 std::vector<Station *> affected_stations;
1673 if (ret.
Failed())
return ret;
1676 for (
Station *st : affected_stations) {
1704 std::vector<Waypoint *> affected_stations;
1724 if (ret.
Failed())
return ret;
1730 assert(ta.
w != 0 && ta.
h != 0);
1736 if (st->TileBelongsToRailStation(tile)) {
1737 std::vector<T*> affected_stations;
1739 if (ret.
Failed())
return ret;
1794 if (*primary_stop ==
nullptr) {
1796 return primary_stop;
1800 while (stop->
next !=
nullptr) stop = stop->
next;
1818 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_ROAD_STOP_FIRST>(existing_stop, station_to_join, adjacent, ta, st);
1839 bool type =
HasBit(p2, 0);
1840 bool is_drive_through =
HasBit(p2, 1);
1841 RoadType rt = Extract<RoadType, 5, 6>(p2);
1843 StationID station_to_join =
GB(p2, 16, 16);
1844 bool reuse = (station_to_join != NEW_STATION);
1845 if (!reuse) station_to_join = INVALID_STATION;
1846 bool distant_join = (station_to_join != INVALID_STATION);
1848 uint8 width = (uint8)
GB(p1, 0, 8);
1849 uint8 length = (uint8)
GB(p1, 8, 8);
1854 if (width == 0 || length == 0)
return CMD_ERROR;
1858 TileArea roadstop_area(tile, width, length);
1863 if (!is_drive_through && RoadTypeIsTram(rt))
return CMD_ERROR;
1867 if (is_drive_through) {
1869 axis = Extract<Axis, 3, 1>(p2);
1873 ddir = Extract<DiagDirection, 3, 2>(p2);
1878 if (ret.
Failed())
return ret;
1882 StationID est = INVALID_STATION;
1883 ret =
CheckFlatLandRoadStop(roadstop_area, flags, is_drive_through ? 5 << axis : 1 << ddir, is_drive_through, type, axis, &est, rt);
1884 if (ret.
Failed())
return ret;
1889 if (ret.
Failed())
return ret;
1894 ret =
BuildStationPart(&st, flags, reuse, roadstop_area, STATIONNAMING_ROAD);
1895 if (ret.
Failed())
return ret;
1913 *currstop = road_stop;
1924 st->
rect.BeforeAddTile(cur_tile, StationRect::ADD_TRY);
1927 if (is_drive_through) {
1956 if (st !=
nullptr) {
1992 if (ret.
Failed())
return ret;
2007 assert(cur_stop !=
nullptr);
2015 if (ret.
Failed())
return ret;
2019 if (*primary_stop == cur_stop) {
2021 *primary_stop = cur_stop->
next;
2023 if (*primary_stop ==
nullptr) {
2029 while (pred->
next != cur_stop) pred = pred->
next;
2034 FOR_ALL_ROADTRAMTYPES(rtt) {
2035 RoadType rt = GetRoadType(tile, rtt);
2046 DoClearSquare(tile);
2059 st->
rect.AfterRemoveTile(st, tile);
2089 uint8 width = (uint8)
GB(p1, 0, 8);
2090 uint8 height = (uint8)
GB(p1, 8, 8);
2091 bool keep_drive_through_roads = !
HasBit(p2, 1);
2094 if (width == 0 || height == 0)
return CMD_ERROR;
2100 TileArea roadstop_area(tile, width, height);
2103 CommandCost last_error(STR_ERROR_THERE_IS_NO_STATION);
2104 bool had_success =
false;
2115 FOR_ALL_ROADTRAMTYPES(rtt) {
2116 road_type[rtt] = GetRoadType(cur_tile, rtt);
2117 if (road_type[rtt] == INVALID_ROADTYPE)
continue;
2134 if ((flags &
DC_EXEC) && (road_type[RTT_ROAD] != INVALID_ROADTYPE || road_type[RTT_TRAM] != INVALID_ROADTYPE)) {
2136 road_owner[RTT_ROAD], road_owner[RTT_TRAM]);
2145 return had_success ? cost : last_error;
2170 uint noise_reduction = distance / town_tolerance_distance;
2189 Town *nearest =
nullptr;
2191 uint perimeter_min_x =
TileX(it);
2192 uint perimeter_min_y =
TileY(it);
2193 uint perimeter_max_x = perimeter_min_x + as->
size_x - 1;
2194 uint perimeter_max_y = perimeter_min_y + as->
size_y - 1;
2196 mindist = UINT_MAX - 1;
2198 std::unique_ptr<TileIterator> copy(it.
Clone());
2200 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) {
2202 if (t ==
nullptr)
continue;
2205 if (dist == mindist && t->
index < nearest->
index) nearest = t;
2206 if (dist < mindist) {
2248 StationID station_to_join =
GB(p2, 16, 16);
2249 bool reuse = (station_to_join != NEW_STATION);
2250 if (!reuse) station_to_join = INVALID_STATION;
2251 bool distant_join = (station_to_join != INVALID_STATION);
2252 byte airport_type =
GB(p1, 0, 8);
2253 byte layout =
GB(p1, 8, 8);
2260 if (ret.
Failed())
return ret;
2279 if (cost.
Failed())
return cost;
2287 StringID authority_refuse_message = STR_NULL;
2288 Town *authority_refuse_town =
nullptr;
2293 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE;
2294 authority_refuse_town = nearest;
2303 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
2304 authority_refuse_town = t;
2308 if (authority_refuse_message != STR_NULL) {
2315 if (ret.
Failed())
return ret;
2321 if (ret.
Failed())
return ret;
2328 cost.
AddCost(_price[PR_BUILD_STATION_AIRPORT]);
2341 st->
rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
2353 AirportTileAnimationTrigger(st, iter,
AAT_BUILT);
2383 if (ret.
Failed())
return ret;
2391 if (!a->IsNormalAircraft())
continue;
2392 if (a->targetairport == st->
index && a->state !=
FLYING) {
2409 if (!st->TileBelongsToAirport(tile_cur))
continue;
2412 if (ret.
Failed())
return ret;
2414 cost.
AddCost(_price[PR_CLEAR_STATION_AIRPORT]);
2416 if (flags & DC_EXEC) {
2419 DoClearSquare(tile_cur);
2424 if (flags & DC_EXEC) {
2472 if (ret.
Failed())
return ret;
2490 if ((v->
owner == company) == include_company) {
2492 FOR_VEHICLE_ORDERS(v, order) {
2508 static const byte _dock_w_chk[4] = { 2, 1, 2, 1 };
2509 static const byte _dock_h_chk[4] = { 1, 2, 1, 2 };
2522 StationID station_to_join =
GB(p2, 16, 16);
2523 bool reuse = (station_to_join != NEW_STATION);
2524 if (!reuse) station_to_join = INVALID_STATION;
2525 bool distant_join = (station_to_join != INVALID_STATION);
2537 if (ret.
Failed())
return ret;
2542 if (ret.
Failed())
return ret;
2556 if (ret.
Failed())
return ret;
2564 _dock_w_chk[direction], _dock_h_chk[direction]);
2569 if (ret.
Failed())
return ret;
2575 if (ret.
Failed())
return ret;
2582 st->
rect.BeforeAddRect(dock_area.
tile, dock_area.
w, dock_area.
h, StationRect::ADD_TRY);
2592 UpdateStationDockingTiles(st);
2610 if (neutral !=
nullptr) UpdateStationDockingTiles(neutral);
2629 if (IsPossibleDockingTile(docking_tile)) {
2647 static const uint8 _valid_docking_tile[] = {
2654 assert(gfx <
lengthof(_valid_docking_tile));
2655 return HasBit(_valid_docking_tile[gfx], d);
2690 if (ret.
Failed())
return ret;
2700 if (ret.
Failed())
return ret;
2703 DoClearSquare(tile1);
2705 MakeWaterKeepingClass(tile2, st->
owner);
2707 st->
rect.AfterRemoveTile(st, tile1);
2708 st->
rect.AfterRemoveTile(st, tile2);
2710 MakeShipStationAreaSmaller(st);
2730 if (s->current_order.IsType(OT_LOADING) && s->current_order.GetDestination() == st->
index) {
2734 if (s->current_order.IsType(OT_GOTO_STATION) && s->current_order.GetDestination() == st->
index) {
2735 s->SetDestTile(s->GetOrderStationLocation(st->
index));
2748 return &_station_display_datas[st][gfx];
2764 case SPR_RAIL_TRACK_X:
2765 case SPR_MONO_TRACK_X:
2766 case SPR_MGLV_TRACK_X:
2767 snow_desert =
false;
2768 *overlay_offset =
RTO_X;
2771 case SPR_RAIL_TRACK_Y:
2772 case SPR_MONO_TRACK_Y:
2773 case SPR_MGLV_TRACK_Y:
2774 snow_desert =
false;
2775 *overlay_offset =
RTO_Y;
2778 case SPR_RAIL_TRACK_X_SNOW:
2779 case SPR_MONO_TRACK_X_SNOW:
2780 case SPR_MGLV_TRACK_X_SNOW:
2782 *overlay_offset =
RTO_X;
2785 case SPR_RAIL_TRACK_Y_SNOW:
2786 case SPR_MONO_TRACK_Y_SNOW:
2787 case SPR_MGLV_TRACK_Y_SNOW:
2789 *overlay_offset =
RTO_Y;
2796 if (ti !=
nullptr) {
2812 *ground = snow_desert ? SPR_FLAT_SNOW_DESERT_TILE : SPR_FLAT_GRASS_TILE;
2816 static void DrawTile_Station(
TileInfo *ti)
2823 uint32 relocation = 0;
2824 uint32 ground_relocation = 0;
2827 uint tile_layout = 0;
2838 if (statspec !=
nullptr) {
2874 case APT_RADAR_GRASS_FENCE_SW:
2877 case APT_GRASS_FENCE_NE_FLAG:
2880 case APT_RADAR_FENCE_SW:
2883 case APT_RADAR_FENCE_NE:
2886 case APT_GRASS_FENCE_NE_FLAG_2:
2896 palette = COMPANY_SPRITE_COLOUR(owner);
2899 palette = PALETTE_TO_GREY;
2902 if (layout ==
nullptr && (t ==
nullptr || t->
seq ==
nullptr)) t = GetStationTileLayout(
GetStationType(ti->
tile), gfx);
2912 if (!HasFoundationNW(ti->
tile, slope, z))
SetBit(edge_info, 0);
2913 if (!HasFoundationNE(ti->
tile, slope, z))
SetBit(edge_info, 1);
2915 if (image == 0)
goto draw_default_foundation;
2920 static const uint8 foundation_parts[] = {
2933 static const uint8 composite_foundation_parts[] = {
2935 0x00, 0xD1, 0xE4, 0xE0,
2937 0xCA, 0xC9, 0xC4, 0xC0,
2939 0xD2, 0x91, 0xE4, 0xA0,
2944 uint8 parts = composite_foundation_parts[ti->
tileh];
2955 goto draw_default_foundation;
2959 for (
int i = 0; i < 8; i++) {
2970 draw_default_foundation:
2976 DrawWaterClassGround(ti);
2978 if (sprite != 0) total_offset = sprite - SPR_IMG_BUOY;
2981 DrawWaterClassGround(ti);
2987 DrawShoreTile(ti->
tileh);
2989 DrawClearLandTile(ti, 3);
2993 if (layout !=
nullptr) {
3003 t = &tmp_rail_layout;
3005 }
else if (statspec !=
nullptr) {
3049 uint sprite_offset = axis ==
AXIS_X ? 1 : 0;
3051 DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset);
3056 if (road_rti->UsesOverlay()) {
3077 int32 total_offset = 0;
3092 DrawSprite(ground + overlay_offset, PAL_NONE, x, y);
3101 uint sprite_offset = 5 - image;
3104 if (rti->UsesOverlay()) {
3106 DrawSprite(ground + sprite_offset, PAL_NONE, x, y);
3109 if (overlay)
DrawSprite(overlay + sprite_offset, PAL_NONE, x, y);
3110 }
else if (RoadTypeIsTram(roadtype)) {
3111 DrawSprite(SPR_TRAMWAY_TRAM + sprite_offset, PAL_NONE, x, y);
3115 if (RoadTypeIsRoad(roadtype) && rti->UsesOverlay()) {
3126 static int GetSlopePixelZ_Station(
TileIndex tile, uint x, uint y)
3141 RoadType road_rt = GetRoadTypeRoad(tile);
3142 RoadType tram_rt = GetRoadTypeTram(tile);
3165 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER;
3166 td->
owner[i] = road_owner;
3170 td->
owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER;
3171 td->
owner[i] = tram_owner;
3182 if (spec !=
nullptr) {
3216 default: NOT_REACHED();
3217 case STATION_RAIL: str = STR_LAI_STATION_DESCRIPTION_RAILROAD_STATION;
break;
3218 case STATION_AIRPORT:
3219 str = (
IsHangar(tile) ? STR_LAI_STATION_DESCRIPTION_AIRCRAFT_HANGAR : STR_LAI_STATION_DESCRIPTION_AIRPORT);
3221 case STATION_TRUCK: str = STR_LAI_STATION_DESCRIPTION_TRUCK_LOADING_AREA;
break;
3222 case STATION_BUS: str = STR_LAI_STATION_DESCRIPTION_BUS_STATION;
break;
3223 case STATION_OILRIG: {
3231 case STATION_DOCK: str = STR_LAI_STATION_DESCRIPTION_SHIP_DOCK;
break;
3232 case STATION_BUOY: str = STR_LAI_STATION_DESCRIPTION_BUOY;
break;
3233 case STATION_WAYPOINT: str = STR_LAI_STATION_DESCRIPTION_WAYPOINT;
break;
3263 RoadTramType rtt = (RoadTramType)sub_mode;
3285 static void TileLoop_Station(
TileIndex tile)
3290 case STATION_AIRPORT:
3298 case STATION_OILRIG:
3308 static void AnimateTile_Station(
TileIndex tile)
3311 AnimateStationTile(tile);
3316 AnimateAirportTile(tile);
3321 static bool ClickTile_Station(
TileIndex tile)
3365 }
else if (x < stop) {
3367 uint16 spd =
max(0, (stop - x) * 20 - 15);
3368 if (spd < v->cur_speed) v->
cur_speed = spd;
3391 CargoTypes cargoes = 0;
3397 if (cargoes == 0)
return;
3435 static inline void byte_inc_sat(byte *p)
3452 StationCargoAmountMap waiting_per_source;
3454 for (StationCargoAmountMap::iterator i(waiting_per_source.begin()); i != waiting_per_source.end(); ++i) {
3456 if (source_station ==
nullptr)
continue;
3463 static void UpdateStationRating(
Station *st)
3465 bool waiting_changed =
false;
3467 byte_inc_sat(&st->time_since_load);
3468 byte_inc_sat(&st->time_since_unload);
3471 FOR_ALL_CARGOSPECS(cs) {
3487 waiting_changed =
true;
3506 uint waiting_avg = waiting / (num_dests + 1);
3517 uint32 var10 = (st->last_vehicle_type ==
VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10);
3521 rating =
GB(callback, 0, 14);
3524 if (
HasBit(callback, 14)) rating -= 0x4000;
3530 if (b >= 0) rating += b >> 2;
3533 if (st->last_vehicle_type ==
VEH_SHIP) waittime >>= 2;
3534 if (waittime <= 21) rating += 25;
3535 if (waittime <= 12) rating += 25;
3536 if (waittime <= 6) rating += 45;
3537 if (waittime <= 3) rating += 35;
3550 if (age < 3) rating += 10;
3551 if (age < 2) rating += 10;
3552 if (age < 1) rating += 13;
3562 if (rating <= 64 && waiting_avg >= 100) {
3563 int dec = Random() & 0x1F;
3564 if (waiting_avg < 200) dec &= 7;
3565 waiting -= (dec + 1) * num_dests;
3566 waiting_changed =
true;
3570 if (rating <= 127 && waiting != 0) {
3571 uint32 r = Random();
3572 if (rating <= (
int)
GB(r, 0, 7)) {
3574 waiting =
max((
int)waiting - (
int)((
GB(r, 8, 2) - 1) * num_dests), 0);
3575 waiting_changed =
true;
3582 static const uint WAITING_CARGO_THRESHOLD = 1 << 12;
3583 static const uint WAITING_CARGO_CUT_FACTOR = 1 << 6;
3584 static const uint MAX_WAITING_CARGO = 1 << 15;
3586 if (waiting > WAITING_CARGO_THRESHOLD) {
3587 uint difference = waiting - WAITING_CARGO_THRESHOLD;
3588 waiting -= (difference / WAITING_CARGO_CUT_FACTOR);
3590 waiting =
min(waiting, MAX_WAITING_CARGO);
3591 waiting_changed =
true;
3596 if (waiting_changed && waiting < ge->cargo.AvailableCount()) {
3610 StationID index = st->
index;
3611 if (waiting_changed) {
3634 for (std::list<Vehicle *>::iterator it(st->loading_vehicles.begin()); it != st->loading_vehicles.end(); ++it) {
3635 for (
Vehicle *v = *it; v !=
nullptr; v = v->
Next()) {
3656 if (lg ==
nullptr)
continue;
3659 Edge edge = it->second;
3666 bool updated =
false;
3668 if (auto_distributed) {
3671 std::vector<Vehicle *> vehicles;
3673 bool found_from =
false;
3674 bool found_to =
false;
3675 for (
Order *order = l->GetFirstOrder(); order !=
nullptr; order = order->
next) {
3676 if (!order->IsType(OT_GOTO_STATION) && !order->IsType(OT_IMPLICIT))
continue;
3677 if (order->GetDestination() == from->
index) {
3679 if (found_to)
break;
3680 }
else if (order->GetDestination() == to->
index) {
3682 if (found_from)
break;
3685 if (!found_to || !found_from)
continue;
3686 vehicles.push_back(l->GetFirstSharedVehicle());
3689 auto iter = vehicles.begin();
3690 while (iter != vehicles.end()) {
3701 *iter = next_shared;
3704 iter = vehicles.erase(iter);
3707 if (iter == vehicles.end()) iter = vehicles.begin();
3755 DEBUG(misc, 0,
"Can't allocate link graph");
3764 }
else if (ge2.
link_graph == INVALID_LINK_GRAPH) {
3782 if (lg !=
nullptr) {
3783 (*lg)[ge1.
node].UpdateEdge(ge2.
node, capacity, usage, mode);
3795 for (
const Vehicle *v = front; v !=
nullptr; v = v->
Next()) {
3810 static void StationHandleSmallTick(
BaseStation *st)
3821 void OnTick_Station()
3823 if (_game_mode == GM_EDITOR)
return;
3826 StationHandleSmallTick(st);
3858 void ModifyStationRatingAround(
TileIndex tile,
Owner owner,
int amount, uint radius)
3862 for (CargoID i = 0; i < NUM_CARGO; i++) {
3863 GoodsEntry *ge = &st->goods[i];
3865 if (ge->status != 0) {
3866 ge->rating = Clamp(ge->rating + amount, 0, 255);
3885 if (amount == 0)
return 0;
3897 DEBUG(misc, 0,
"Can't allocate link graph");
3902 if (lg !=
nullptr) (*lg)[ge.
node].UpdateSupply(amount);
3918 static bool IsUniqueStationName(
const char *name)
3921 if (st->
name !=
nullptr && strcmp(st->
name, name) == 0)
return false;
3942 if (ret.
Failed())
return ret;
3948 if (!IsUniqueStationName(text))
return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
3966 if (st->TileIsInCatchment(tile)) stations->insert(st);
3987 assert(location.
w == 1 && location.
h == 1);
3988 AddNearbyStationsByCatchment(location.
tile, stations, Town::GetByTile(location.
tile)->
stations_near);
3994 std::set<StationID> seen_stations;
4004 for (StationID stationid : seen_stations) {
4006 if (st ==
nullptr)
continue;
4013 if (st->TileIsInCatchment(tile)) {
4014 stations->insert(st);
4031 return &this->stations;
4034 static bool CanMoveGoodsToStation(
const Station *st,
CargoID type)
4058 if (all_stations->empty())
return 0;
4059 if (amount == 0)
return 0;
4061 Station *first_station =
nullptr;
4062 typedef std::pair<Station *, uint> StationInfo;
4063 std::vector<StationInfo> used_stations;
4065 for (
Station *st : *all_stations) {
4066 if (!CanMoveGoodsToStation(st, type))
continue;
4070 if (first_station ==
nullptr) {
4074 if (used_stations.empty()) {
4075 used_stations.reserve(2);
4076 used_stations.emplace_back(std::make_pair(first_station, 0));
4078 used_stations.emplace_back(std::make_pair(st, 0));
4082 if (first_station ==
nullptr)
return 0;
4084 if (used_stations.empty()) {
4087 return UpdateStationWaiting(first_station, type, amount, source_type, source_id);
4092 uint best_rating = 0;
4095 for (
auto &p : used_stations) {
4096 auto owner = p.first->owner;
4097 auto rating = p.first->goods[type].rating;
4098 if (rating > company_best[owner]) {
4099 best_sum += rating - company_best[owner];
4100 company_best[owner] = rating;
4101 if (rating > best_rating) best_rating = rating;
4103 company_sum[owner] += rating;
4108 amount *= best_rating + 1;
4111 for (
auto &p : used_stations) {
4112 uint owner = p.first->owner;
4115 p.second = amount * company_best[owner] * p.first->goods[type].rating / best_sum / company_sum[owner];
4120 if (amount > moving) {
4121 std::sort(used_stations.begin(), used_stations.end(), [type] (
const StationInfo &a,
const StationInfo &b) {
4122 return b.first->goods[type].rating < a.first->goods[type].rating;
4125 assert(amount - moving <= used_stations.size());
4126 for (uint i = 0; i < amount - moving; i++) {
4127 used_stations[i].second++;
4132 for (
auto &p : used_stations) {
4133 moved += UpdateStationWaiting(p.first, type, p.second, source_type, source_id);
4139 void UpdateStationDockingTiles(
Station *st)
4154 int x1 =
max(x - 1, 0);
4157 int y1 =
max(y - 1, 0);
4168 DEBUG(misc, 0,
"Can't allocate station for oilrig at 0x%X, reverting to oilrig only", tile);
4176 st->
string_id = GenerateStationName(st, tile, STATIONNAMING_OILRIG);
4191 UpdateStationDockingTiles(st);
4193 st->
rect.BeforeAddTile(tile, StationRect::ADD_FORCE);
4218 FOR_ALL_ROADTRAMTYPES(rtt) {
4221 RoadType rt = GetRoadType(tile, rtt);
4245 case STATION_WAYPOINT:
4336 case STATION_WAYPOINT:
return_cmd_error(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
4337 case STATION_AIRPORT:
return_cmd_error(STR_ERROR_MUST_DEMOLISH_AIRPORT_FIRST);
4338 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);
4339 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);
4342 case STATION_OILRIG:
4343 SetDParam(1, STR_INDUSTRY_NAME_OIL_RIG);
4362 case STATION_BUOY:
return RemoveBuoy(tile, flags);
4363 case STATION_DOCK:
return RemoveDock(tile, flags);
4378 case STATION_WAYPOINT:
4379 case STATION_RAIL: {
4386 case STATION_AIRPORT:
4414 for (SharesMap::const_iterator it = this->shares.begin(); it != this->shares.end(); ++it) {
4415 if (it->second == st) {
4416 return it->first - prev;
4432 if (this->unrestricted == 0)
return INVALID_STATION;
4433 assert(!this->shares.empty());
4434 SharesMap::const_iterator it = this->shares.upper_bound(
RandomRange(this->unrestricted));
4435 assert(it != this->shares.end() && it->first <= this->unrestricted);
4436 if (it->second != excluded && it->second != excluded2)
return it->second;
4441 uint end = it->first;
4442 uint begin = (it == this->shares.begin() ? 0 : (--it)->first);
4443 uint interval = end - begin;
4444 if (interval >= this->unrestricted)
return INVALID_STATION;
4445 uint new_max = this->unrestricted - interval;
4447 SharesMap::const_iterator it2 = (rand < begin) ? this->shares.upper_bound(rand) :
4448 this->shares.upper_bound(rand + interval);
4449 assert(it2 != this->shares.end() && it2->first <= this->unrestricted);
4450 if (it2->second != excluded && it2->second != excluded2)
return it2->second;
4455 uint end2 = it2->first;
4456 uint begin2 = (it2 == this->shares.begin() ? 0 : (--it2)->first);
4457 uint interval2 = end2 - begin2;
4458 if (interval2 >= new_max)
return INVALID_STATION;
4459 new_max -= interval2;
4460 if (begin > begin2) {
4461 Swap(begin, begin2);
4463 Swap(interval, interval2);
4466 SharesMap::const_iterator it3 = this->shares.upper_bound(this->unrestricted);
4468 it3 = this->shares.upper_bound(rand);
4469 }
else if (rand < begin2 - interval) {
4470 it3 = this->shares.upper_bound(rand + interval);
4472 it3 = this->shares.upper_bound(rand + interval + interval2);
4474 assert(it3 != this->shares.end() && it3->first <= this->unrestricted);
4485 assert(!this->shares.empty());
4486 SharesMap new_shares;
4488 for (SharesMap::iterator it(this->shares.begin()); it != this->shares.end(); ++it) {
4489 new_shares[++i] = it->second;
4490 if (it->first == this->unrestricted) this->unrestricted = i;
4492 this->shares.swap(new_shares);
4493 assert(!this->shares.empty() && this->unrestricted <= (--this->shares.end())->first);
4506 assert(!this->shares.empty());
4508 uint removed_shares = 0;
4509 uint added_shares = 0;
4510 uint last_share = 0;
4511 SharesMap new_shares;
4512 for (SharesMap::iterator it(this->shares.begin()); it != this->shares.end(); ++it) {
4513 if (it->second == st) {
4515 uint share = it->first - last_share;
4516 if (flow == INT_MIN || (uint)(-flow) >= share) {
4517 removed_shares += share;
4518 if (it->first <= this->unrestricted) this->unrestricted -= share;
4519 if (flow != INT_MIN) flow += share;
4520 last_share = it->first;
4523 removed_shares += (uint)(-flow);
4525 added_shares += (uint)(flow);
4527 if (it->first <= this->unrestricted) this->unrestricted += flow;
4533 new_shares[it->first + added_shares - removed_shares] = it->second;
4534 last_share = it->first;
4537 new_shares[last_share + (uint)flow] = st;
4538 if (this->unrestricted < last_share) {
4539 this->ReleaseShare(st);
4541 this->unrestricted += flow;
4544 this->shares.swap(new_shares);
4554 assert(!this->shares.empty());
4556 uint last_share = 0;
4557 SharesMap new_shares;
4558 for (SharesMap::iterator it(this->shares.begin()); it != this->shares.end(); ++it) {
4560 if (it->first > this->unrestricted)
return;
4561 if (it->second == st) {
4562 flow = it->first - last_share;
4563 this->unrestricted -= flow;
4565 new_shares[it->first] = it->second;
4568 new_shares[it->first - flow] = it->second;
4570 last_share = it->first;
4572 if (flow == 0)
return;
4573 new_shares[last_share + flow] = st;
4574 this->shares.swap(new_shares);
4575 assert(!this->shares.empty());
4585 assert(!this->shares.empty());
4587 uint next_share = 0;
4589 for (SharesMap::reverse_iterator it(this->shares.rbegin()); it != this->shares.rend(); ++it) {
4590 if (it->first < this->unrestricted)
return;
4592 flow = next_share - it->first;
4593 this->unrestricted += flow;
4596 if (it->first == this->unrestricted)
return;
4597 if (it->second == st) found =
true;
4599 next_share = it->first;
4601 if (flow == 0)
return;
4602 SharesMap new_shares;
4603 new_shares[flow] = st;
4604 for (SharesMap::iterator it(this->shares.begin()); it != this->shares.end(); ++it) {
4605 if (it->second != st) {
4606 new_shares[flow + it->first] = it->second;
4611 this->shares.swap(new_shares);
4612 assert(!this->shares.empty());
4622 assert(runtime > 0);
4623 SharesMap new_shares;
4625 for (SharesMap::iterator i = this->shares.begin(); i != this->shares.end(); ++i) {
4626 share =
max(share + 1, i->first * 30 / runtime);
4627 new_shares[share] = i->second;
4628 if (this->unrestricted == i->first) this->unrestricted = share;
4630 this->shares.swap(new_shares);
4641 FlowStatMap::iterator origin_it = this->find(origin);
4642 if (origin_it == this->end()) {
4643 this->insert(std::make_pair(origin,
FlowStat(via, flow)));
4645 origin_it->second.ChangeShare(via, flow);
4646 assert(!origin_it->second.GetShares()->empty());
4660 FlowStatMap::iterator prev_it = this->find(origin);
4661 if (prev_it == this->end()) {
4664 this->insert(std::make_pair(origin, fs));
4666 prev_it->second.ChangeShare(via, flow);
4667 prev_it->second.ChangeShare(INVALID_STATION, flow);
4668 assert(!prev_it->second.GetShares()->empty());
4678 for (FlowStatMap::iterator i = this->begin(); i != this->end(); ++i) {
4680 uint local = fs.
GetShare(INVALID_STATION);
4681 if (local > INT_MAX) {
4704 for (FlowStatMap::iterator f_it = this->begin(); f_it != this->end();) {
4708 ret.
Push(f_it->first);
4709 this->erase(f_it++);
4723 for (FlowStatMap::iterator it = this->begin(); it != this->end(); ++it) {
4724 it->second.RestrictShare(via);
4734 for (FlowStatMap::iterator it = this->begin(); it != this->end(); ++it) {
4735 it->second.ReleaseShare(via);
4746 for (FlowStatMap::const_iterator i = this->begin(); i != this->end(); ++i) {
4747 ret += (--(i->second.GetShares()->end()))->first;
4760 for (FlowStatMap::const_iterator i = this->begin(); i != this->end(); ++i) {
4761 ret += i->second.GetShare(via);
4773 FlowStatMap::const_iterator i = this->find(from);
4774 if (i == this->end())
return 0;
4775 return (--(i->second.GetShares()->end()))->first;
4786 FlowStatMap::const_iterator i = this->find(from);
4787 if (i == this->end())
return 0;
4788 return i->second.GetShare(via);
4793 GetSlopePixelZ_Station,
4796 GetTileDesc_Station,
4797 GetTileTrackStatus_Station,
4799 AnimateTile_Station,
4801 ChangeTileOwner_Station,
4803 VehicleEnter_Station,
4804 GetFoundation_Station,
4805 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.
#define lastof(x)
Get the last element of an fixed size array.
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.
char * GetStringWithArgs(char *buffr, StringID string, StringParameters *args, const char *last, uint case_index, bool game_script)
Get a parsed string with most special stringcodes replaced by the string parameters.
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.
static const int MAX_CHAR_LENGTH
Max. length of UTF-8 encoded unicode character.
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.
std::string cached_name
NOSAVE: Cache of the resolved name of the station, if not using a custom name.
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.