OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
15 #include "viewport_kdtree.h"
60 #include "table/strings.h"
111 if (!T::IsValidID(t) ||
Station::Get(t)->owner != company)
continue;
112 if (closest_station == INVALID_STATION) {
114 }
else if (closest_station != t) {
119 *st = (closest_station == INVALID_STATION) ?
nullptr : T::Get(closest_station);
140 for (
int dx = -3; dx <= 3; dx++) {
141 for (
int dy = -3; dy <= 3; dy++) {
197 #define M(x) ((x) - STR_SV_STNAME)
202 STATIONNAMING_AIRPORT,
203 STATIONNAMING_OILRIG,
205 STATIONNAMING_HELIPORT,
230 if (
GetIndustrySpec(indtype)->station_name == STR_UNDEFINED)
return false;
234 sni->
free_names &= ~(1 << M(STR_SV_STNAME_OILFIELD) | 1 << M(STR_SV_STNAME_MINES));
240 static const uint32 _gen_station_name_bits[] = {
243 1U << M(STR_SV_STNAME_AIRPORT),
244 1U << M(STR_SV_STNAME_OILFIELD),
245 1U << M(STR_SV_STNAME_DOCKS),
246 1U << M(STR_SV_STNAME_HELIPORT),
250 uint32 free_names = UINT32_MAX;
253 memset(indtypes, 0,
sizeof(indtypes));
256 if (s != st && s->town == t) {
257 if (s->indtype != IT_INVALID) {
258 indtypes[s->indtype] =
true;
260 if (name != STR_UNDEFINED) {
269 uint str = M(s->string_id);
271 if (str == M(STR_SV_STNAME_FOREST)) {
272 str = M(STR_SV_STNAME_WOODS);
288 return STR_SV_STNAME_FALLBACK;
296 uint32 tmp = free_names & _gen_station_name_bits[name_class];
300 if (
HasBit(free_names, M(STR_SV_STNAME_MINES))) {
302 return STR_SV_STNAME_MINES;
308 if (
HasBit(free_names, M(STR_SV_STNAME)))
return STR_SV_STNAME;
310 if (
HasBit(free_names, M(STR_SV_STNAME_CENTRAL)))
return STR_SV_STNAME_CENTRAL;
314 if (
HasBit(free_names, M(STR_SV_STNAME_LAKESIDE)) &&
317 return STR_SV_STNAME_LAKESIDE;
321 if (
HasBit(free_names, M(STR_SV_STNAME_WOODS)) && (
332 if (
HasBit(free_names, M(STR_SV_STNAME_VALLEY)))
return STR_SV_STNAME_VALLEY;
334 if (
HasBit(free_names, M(STR_SV_STNAME_HEIGHTS)))
return STR_SV_STNAME_HEIGHTS;
338 static const int8 _direction_and_table[] = {
339 ~( (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
340 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
341 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ),
342 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) ),
345 free_names &= _direction_and_table[
349 tmp = free_names & ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 6) | (1 << 7) | (1 << 12) | (1 << 26) | (1 << 27) | (1 << 28) | (1 << 29) | (1 << 30));
350 return (tmp == 0) ? STR_SV_STNAME_FALLBACK : (STR_SV_STNAME +
FindFirstBit(tmp));
363 Station *best_station =
nullptr;
366 uint cur_dist = DistanceManhattan(tile, st->xy);
368 if (cur_dist < threshold) {
369 threshold = cur_dist;
371 }
else if (cur_dist == threshold && best_station !=
nullptr) {
373 if (st->
index < best_station->
index) best_station = st;
389 case STATION_AIRPORT:
406 default: NOT_REACHED();
417 pt.y -= 32 * ZOOM_LVL_BASE;
426 _viewport_sign_kdtree.
Insert(ViewportSignKdtreeItem::MakeStation(this->
index));
437 if (this->
xy == new_xy)
return;
441 this->BaseStation::MoveSign(new_xy);
454 void BaseStation::FillCachedName()
const
457 int64 args_array[] = { this->
index };
463 void ClearAllStationCachedNames()
491 for (uint i = 0; i < num_items; i++) {
509 std::set<IndustryID> industries;
516 AddProducedCargo(tile, produced);
522 for (IndustryID industry : industries) {
548 if (always_accepted !=
nullptr) *always_accepted = 0;
556 AddAcceptedCargo(tile, acceptance, always_accepted);
570 if (always_accepted !=
nullptr) *always_accepted = 0;
574 AddAcceptedCargo(tile, acceptance, always_accepted);
592 if (!st->
rect.IsEmpty()) {
598 uint amt = acceptance[i];
616 if (old_acc == new_acc)
return;
622 static const StringID accept_msg[] = {
623 STR_NEWS_STATION_NOW_ACCEPTS_CARGO,
624 STR_NEWS_STATION_NOW_ACCEPTS_CARGO_AND_CARGO,
626 static const StringID reject_msg[] = {
627 STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO,
628 STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_OR_CARGO,
642 accepts[num_acc++] = i;
647 rejects[num_rej++] = i;
661 static void UpdateStationSignCoord(
BaseStation *st)
665 if (r->IsEmpty())
return;
669 st->MoveSign(new_xy);
694 if (*st !=
nullptr) {
699 CommandCost ret = (*st)->rect.BeforeAddRect(area.
tile, area.
w, area.
h, StationRect::ADD_TEST);
700 if (ret.
Failed())
return ret;
707 _station_kdtree.
Insert((*st)->index);
710 (*st)->string_id = GenerateStationName(*st, area.
tile, name_class);
733 UpdateStationSignCoord(st);
752 case STATION_AIRPORT:
761 default: NOT_REACHED();
791 if (ret.
Failed())
return ret;
814 cost.
AddCost(_price[PR_BUILD_FOUNDATION]);
821 }
else if (allowed_z != flat_z) {
841 if (ret.
Failed())
return ret;
845 if (ret.
Failed())
return ret;
870 uint invalid_dirs = 5 << axis;
877 if (ret.
Failed())
return ret;
883 if (ret.
Failed())
return ret;
894 if (*station == INVALID_STATION) {
896 }
else if (*station != st) {
921 affected_vehicles.push_back(v);
925 if (ret.
Failed())
return ret;
932 if (ret.
Failed())
return ret;
959 if (ret.
Failed())
return ret;
978 if (*station == INVALID_STATION) {
980 }
else if (*station != st) {
1003 if (build_over_road) {
1005 RoadType road_rt = GetRoadType(cur_tile, RTT_ROAD);
1012 if (ret.
Failed())
return ret;
1020 if (ret.
Failed())
return ret;
1024 }
else if (RoadTypeIsRoad(rt)) {
1029 RoadType tram_rt = GetRoadType(cur_tile, RTT_TRAM);
1038 if (ret.
Failed())
return ret;
1045 }
else if (RoadTypeIsTram(rt)) {
1050 if (ret.
Failed())
return ret;
1086 static inline byte *CreateSingle(
byte *layout,
int n)
1089 do *layout++ = 0;
while (--i);
1090 layout[((n - 1) >> 1) - n] = 2;
1094 static inline byte *CreateMulti(
byte *layout,
int n,
byte b)
1097 do *layout++ = b;
while (--i);
1100 layout[n - 1 - n] = 0;
1114 if (statspec !=
nullptr && statspec->lengths >= plat_len &&
1115 statspec->platforms[plat_len - 1] >= numtracks &&
1116 statspec->layouts[plat_len - 1][numtracks - 1]) {
1118 memcpy(layout, statspec->layouts[plat_len - 1][numtracks - 1],
1119 plat_len * numtracks);
1123 if (plat_len == 1) {
1124 CreateSingle(layout, numtracks);
1126 if (numtracks & 1) layout = CreateSingle(layout, plat_len);
1129 while (--numtracks >= 0) {
1130 layout = CreateMulti(layout, plat_len, 4);
1131 layout = CreateMulti(layout, plat_len, 6);
1147 template <
class T, StringID error_message>
1150 assert(*st ==
nullptr);
1151 bool check_surrounding =
true;
1154 if (existing_station != INVALID_STATION) {
1155 if (adjacent && existing_station != station_to_join) {
1162 *st = T::GetIfValid(existing_station);
1163 check_surrounding = (*st ==
nullptr);
1168 if (adjacent) check_surrounding =
false;
1172 if (check_surrounding) {
1175 if (ret.
Failed())
return ret;
1179 if (*st ==
nullptr && station_to_join != INVALID_STATION) *st = T::GetIfValid(station_to_join);
1195 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_RAILWAY_STATION_FIRST>(existing_station, station_to_join, adjacent, ta, st);
1209 return FindJoiningBaseStation<Waypoint, STR_ERROR_MUST_REMOVE_RAILWAYPOINT_FIRST>(existing_waypoint, waypoint_to_join, adjacent, ta, wp);
1256 RailType rt = Extract<RailType, 0, 6>(p1);
1257 Axis axis = Extract<Axis, 6, 1>(p1);
1258 byte numtracks =
GB(p1, 8, 8);
1259 byte plat_len =
GB(p1, 16, 8);
1260 bool adjacent =
HasBit(p1, 24);
1263 byte spec_index =
GB(p2, 8, 8);
1264 StationID station_to_join =
GB(p2, 16, 16);
1268 if (ret.
Failed())
return ret;
1275 if (plat_len == 0 || numtracks == 0)
return CMD_ERROR;
1286 bool reuse = (station_to_join != NEW_STATION);
1287 if (!reuse) station_to_join = INVALID_STATION;
1288 bool distant_join = (station_to_join != INVALID_STATION);
1295 TileArea new_location(tile_org, w_org, h_org);
1298 StationID est = INVALID_STATION;
1299 std::vector<Train *> affected_vehicles;
1302 if (cost.
Failed())
return cost;
1304 cost.
AddCost((numtracks * _price[PR_BUILD_STATION_RAIL] + _price[PR_BUILD_STATION_RAIL_LENGTH]) * plat_len);
1309 if (ret.
Failed())
return ret;
1311 ret =
BuildStationPart(&st, flags, reuse, new_location, STATIONNAMING_RAIL);
1312 if (ret.
Failed())
return ret;
1316 if (ret.
Failed())
return ret;
1324 if (statspec !=
nullptr) {
1342 byte numtracks_orig;
1348 st->
rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY);
1350 if (statspec !=
nullptr) {
1359 layout_ptr =
AllocaM(
byte, numtracks * plat_len);
1362 numtracks_orig = numtracks;
1370 byte layout = *layout_ptr++;
1375 affected_vehicles.push_back(v);
1400 if (statspec !=
nullptr) {
1415 TriggerStationAnimation(st, tile,
SAT_BUILT);
1423 }
while (--numtracks);
1425 for (uint i = 0; i < affected_vehicles.size(); ++i) {
1433 update_reservation_area =
TileArea(tile_org, 1, numtracks_orig);
1435 update_reservation_area =
TileArea(tile_org, numtracks_orig, 1);
1449 platform_begin = next_tile;
1452 platform_end = next_tile;
1456 bool reservation =
false;
1457 for (
TileIndex t = platform_begin; !reservation && t <= platform_end; t += tile_offset) {
1478 if (ta.
w != 0 && ta.
h != 0) {
1528 static void MakeRailStationAreaSmaller(
BaseStation *st)
1538 static void MakeShipStationAreaSmaller(
Station *st)
1541 UpdateStationDockingTiles(st);
1573 if (ret.
Failed())
continue;
1576 T *st = T::GetByTile(tile);
1577 if (st ==
nullptr)
continue;
1582 if (ret.
Failed())
continue;
1591 total_cost.
AddCost(-_price[PR_CLEAR_RAIL]);
1610 DoClearSquare(tile);
1616 st->rect.AfterRemoveTile(st, tile);
1622 include(affected_stations, st);
1630 for (T *st : affected_stations) {
1635 MakeRailStationAreaSmaller(st);
1636 UpdateStationSignCoord(st);
1647 total_cost.
AddCost(quantity * removal_cost);
1668 std::vector<Station *> affected_stations;
1671 if (ret.
Failed())
return ret;
1674 for (
Station *st : affected_stations) {
1677 st->MarkTilesDirty(
false);
1678 st->RecomputeCatchment();
1702 std::vector<Waypoint *> affected_stations;
1722 if (ret.
Failed())
return ret;
1728 assert(ta.
w != 0 && ta.
h != 0);
1734 if (st->TileBelongsToRailStation(tile)) {
1735 std::vector<T*> affected_stations;
1737 if (ret.
Failed())
return ret;
1792 if (*primary_stop ==
nullptr) {
1794 return primary_stop;
1798 while (stop->
next !=
nullptr) stop = stop->
next;
1816 return FindJoiningBaseStation<Station, STR_ERROR_MUST_REMOVE_ROAD_STOP_FIRST>(existing_stop, station_to_join, adjacent, ta, st);
1837 bool type =
HasBit(p2, 0);
1838 bool is_drive_through =
HasBit(p2, 1);
1839 RoadType rt = Extract<RoadType, 5, 6>(p2);
1841 StationID station_to_join =
GB(p2, 16, 16);
1842 bool reuse = (station_to_join != NEW_STATION);
1843 if (!reuse) station_to_join = INVALID_STATION;
1844 bool distant_join = (station_to_join != INVALID_STATION);
1846 uint8 width = (uint8)
GB(p1, 0, 8);
1847 uint8 length = (uint8)
GB(p1, 8, 8);
1852 if (width == 0 || length == 0)
return CMD_ERROR;
1856 TileArea roadstop_area(tile, width, length);
1861 if (!is_drive_through && RoadTypeIsTram(rt))
return CMD_ERROR;
1865 if (is_drive_through) {
1867 axis = Extract<Axis, 3, 1>(p2);
1871 ddir = Extract<DiagDirection, 3, 2>(p2);
1876 if (ret.
Failed())
return ret;
1880 StationID est = INVALID_STATION;
1881 ret =
CheckFlatLandRoadStop(roadstop_area, flags, is_drive_through ? 5 << axis : 1 << ddir, is_drive_through, type, axis, &est, rt);
1882 if (ret.
Failed())
return ret;
1887 if (ret.
Failed())
return ret;
1892 ret =
BuildStationPart(&st, flags, reuse, roadstop_area, STATIONNAMING_ROAD);
1893 if (ret.
Failed())
return ret;
1911 *currstop = road_stop;
1922 st->
rect.BeforeAddTile(cur_tile, StationRect::ADD_TRY);
1925 if (is_drive_through) {
1954 if (st !=
nullptr) {
1990 if (ret.
Failed())
return ret;
2005 assert(cur_stop !=
nullptr);
2013 if (ret.
Failed())
return ret;
2017 if (*primary_stop == cur_stop) {
2019 *primary_stop = cur_stop->
next;
2021 if (*primary_stop ==
nullptr) {
2027 while (pred->
next != cur_stop) pred = pred->
next;
2032 FOR_ALL_ROADTRAMTYPES(rtt) {
2033 RoadType rt = GetRoadType(tile, rtt);
2044 DoClearSquare(tile);
2057 st->
rect.AfterRemoveTile(st, tile);
2087 uint8 width = (uint8)
GB(p1, 0, 8);
2088 uint8 height = (uint8)
GB(p1, 8, 8);
2089 bool keep_drive_through_roads = !
HasBit(p2, 1);
2092 if (width == 0 || height == 0)
return CMD_ERROR;
2098 TileArea roadstop_area(tile, width, height);
2101 CommandCost last_error(STR_ERROR_THERE_IS_NO_STATION);
2102 bool had_success =
false;
2113 FOR_ALL_ROADTRAMTYPES(rtt) {
2114 road_type[rtt] = GetRoadType(cur_tile, rtt);
2134 road_owner[RTT_ROAD], road_owner[RTT_TRAM]);
2143 return had_success ? cost : last_error;
2168 uint noise_reduction = distance / town_tolerance_distance;
2187 Town *nearest =
nullptr;
2189 uint perimeter_min_x =
TileX(it);
2190 uint perimeter_min_y =
TileY(it);
2191 uint perimeter_max_x = perimeter_min_x + as->
size_x - 1;
2192 uint perimeter_max_y = perimeter_min_y + as->
size_y - 1;
2194 mindist = UINT_MAX - 1;
2196 std::unique_ptr<TileIterator> copy(it.
Clone());
2198 if (
TileX(cur_tile) == perimeter_min_x ||
TileX(cur_tile) == perimeter_max_x ||
TileY(cur_tile) == perimeter_min_y ||
TileY(cur_tile) == perimeter_max_y) {
2200 if (t ==
nullptr)
continue;
2203 if (dist == mindist && t->
index < nearest->
index) nearest = t;
2204 if (dist < mindist) {
2246 StationID station_to_join =
GB(p2, 16, 16);
2247 bool reuse = (station_to_join != NEW_STATION);
2248 if (!reuse) station_to_join = INVALID_STATION;
2249 bool distant_join = (station_to_join != INVALID_STATION);
2250 byte airport_type =
GB(p1, 0, 8);
2251 byte layout =
GB(p1, 8, 8);
2258 if (ret.
Failed())
return ret;
2277 if (cost.
Failed())
return cost;
2285 StringID authority_refuse_message = STR_NULL;
2286 Town *authority_refuse_town =
nullptr;
2291 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_NOISE;
2292 authority_refuse_town = nearest;
2301 authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
2302 authority_refuse_town = t;
2306 if (authority_refuse_message != STR_NULL) {
2313 if (ret.
Failed())
return ret;
2319 if (ret.
Failed())
return ret;
2326 cost.
AddCost(_price[PR_BUILD_STATION_AIRPORT]);
2339 st->
rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
2351 AirportTileAnimationTrigger(st, iter,
AAT_BUILT);
2381 if (ret.
Failed())
return ret;
2389 if (!a->IsNormalAircraft())
continue;
2390 if (a->targetairport == st->
index && a->state !=
FLYING) {
2407 if (!st->TileBelongsToAirport(tile_cur))
continue;
2410 if (ret.
Failed())
return ret;
2412 cost.
AddCost(_price[PR_CLEAR_STATION_AIRPORT]);
2417 DoClearSquare(tile_cur);
2470 if (ret.
Failed())
return ret;
2488 if ((v->
owner == company) == include_company) {
2490 if ((order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT)) && order->GetDestination() == station) {
2505 static const byte _dock_w_chk[4] = { 2, 1, 2, 1 };
2506 static const byte _dock_h_chk[4] = { 1, 2, 1, 2 };
2519 StationID station_to_join =
GB(p2, 16, 16);
2520 bool reuse = (station_to_join != NEW_STATION);
2521 if (!reuse) station_to_join = INVALID_STATION;
2522 bool distant_join = (station_to_join != INVALID_STATION);
2534 if (ret.
Failed())
return ret;
2540 if (ret.
Failed())
return ret;
2555 if (ret.
Failed())
return ret;
2563 _dock_w_chk[direction], _dock_h_chk[direction]);
2568 if (ret.
Failed())
return ret;
2574 if (ret.
Failed())
return ret;
2581 st->
rect.BeforeAddRect(dock_area.
tile, dock_area.
w, dock_area.
h, StationRect::ADD_TRY);
2591 UpdateStationDockingTiles(st);
2607 if (st !=
nullptr) 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 = std::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 | (std::min<uint>(last_speed, 0xFFu) << 24);
3519 uint32 var10 = (st->last_vehicle_type ==
VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10);
3523 rating =
GB(callback, 0, 14);
3526 if (
HasBit(callback, 14)) rating -= 0x4000;
3532 if (b >= 0) rating += b >> 2;
3535 if (st->last_vehicle_type ==
VEH_SHIP) waittime >>= 2;
3536 if (waittime <= 21) rating += 25;
3537 if (waittime <= 12) rating += 25;
3538 if (waittime <= 6) rating += 45;
3539 if (waittime <= 3) rating += 35;
3552 if (age < 3) rating += 10;
3553 if (age < 2) rating += 10;
3554 if (age < 1) rating += 13;
3564 if (rating <= 64 && waiting_avg >= 100) {
3565 int dec = Random() & 0x1F;
3566 if (waiting_avg < 200) dec &= 7;
3567 waiting -= (dec + 1) * num_dests;
3568 waiting_changed =
true;
3572 if (rating <= 127 && waiting != 0) {
3573 uint32 r = Random();
3574 if (rating <= (
int)
GB(r, 0, 7)) {
3576 waiting = std::max((
int)waiting - (
int)((
GB(r, 8, 2) - 1) * num_dests), 0);
3577 waiting_changed =
true;
3584 static const uint WAITING_CARGO_THRESHOLD = 1 << 12;
3585 static const uint WAITING_CARGO_CUT_FACTOR = 1 << 6;
3586 static const uint MAX_WAITING_CARGO = 1 << 15;
3588 if (waiting > WAITING_CARGO_THRESHOLD) {
3589 uint difference = waiting - WAITING_CARGO_THRESHOLD;
3590 waiting -= (difference / WAITING_CARGO_CUT_FACTOR);
3592 waiting = std::min(waiting, MAX_WAITING_CARGO);
3593 waiting_changed =
true;
3598 if (waiting_changed && waiting < ge->cargo.AvailableCount()) {
3612 StationID index = st->
index;
3613 if (waiting_changed) {
3636 for (std::list<Vehicle *>::iterator it(st->loading_vehicles.begin()); it != st->loading_vehicles.end(); ++it) {
3637 for (
Vehicle *v = *it; v !=
nullptr; v = v->
Next()) {
3658 if (lg ==
nullptr)
continue;
3661 Edge edge = it->second;
3668 bool updated =
false;
3670 if (auto_distributed) {
3673 std::vector<Vehicle *> vehicles;
3675 bool found_from =
false;
3676 bool found_to =
false;
3677 for (
Order *order = l->GetFirstOrder(); order !=
nullptr; order = order->
next) {
3678 if (!order->IsType(OT_GOTO_STATION) && !order->IsType(OT_IMPLICIT))
continue;
3679 if (order->GetDestination() == from->
index) {
3681 if (found_to)
break;
3682 }
else if (order->GetDestination() == to->
index) {
3684 if (found_from)
break;
3687 if (!found_to || !found_from)
continue;
3688 vehicles.push_back(l->GetFirstSharedVehicle());
3691 auto iter = vehicles.begin();
3692 while (iter != vehicles.end()) {
3703 *iter = next_shared;
3706 iter = vehicles.erase(iter);
3709 if (iter == vehicles.end()) iter = vehicles.begin();
3757 DEBUG(misc, 0,
"Can't allocate link graph");
3766 }
else if (ge2.
link_graph == INVALID_LINK_GRAPH) {
3784 if (lg !=
nullptr) {
3785 (*lg)[ge1.
node].UpdateEdge(ge2.
node, capacity, usage, mode);
3797 for (
const Vehicle *v = front; v !=
nullptr; v = v->
Next()) {
3812 static void StationHandleSmallTick(
BaseStation *st)
3823 void OnTick_Station()
3825 if (_game_mode == GM_EDITOR)
return;
3828 StationHandleSmallTick(st);
3860 void ModifyStationRatingAround(
TileIndex tile,
Owner owner,
int amount, uint radius)
3864 for (CargoID i = 0; i < NUM_CARGO; i++) {
3865 GoodsEntry *ge = &st->goods[i];
3867 if (ge->status != 0) {
3868 ge->rating = Clamp(ge->rating + amount, 0, 255);
3887 if (amount == 0)
return 0;
3899 DEBUG(misc, 0,
"Can't allocate link graph");
3904 if (lg !=
nullptr) (*lg)[ge.
node].UpdateSupply(amount);
3920 static bool IsUniqueStationName(
const char *name)
3923 if (!st->
name.empty() && st->
name == name)
return false;
3944 if (ret.
Failed())
return ret;
3950 if (!IsUniqueStationName(text))
return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
3971 if (st->TileIsInCatchment(tile)) stations->insert(st);
3984 assert(this->
w == 1 && this->
h == 1);
3985 AddNearbyStationsByCatchment(this->tile, &this->stations, Town::GetByTile(this->tile)->stations_near);
3988 this->stations.insert(st);
3998 static bool CanMoveGoodsToStation(
const Station *st,
CargoID type)
4022 if (all_stations->empty())
return 0;
4023 if (amount == 0)
return 0;
4025 Station *first_station =
nullptr;
4026 typedef std::pair<Station *, uint> StationInfo;
4027 std::vector<StationInfo> used_stations;
4029 for (
Station *st : *all_stations) {
4031 if (!CanMoveGoodsToStation(st, type))
continue;
4035 if (first_station ==
nullptr) {
4039 if (used_stations.empty()) {
4040 used_stations.reserve(2);
4041 used_stations.emplace_back(std::make_pair(first_station, 0));
4043 used_stations.emplace_back(std::make_pair(st, 0));
4047 if (first_station ==
nullptr)
return 0;
4049 if (used_stations.empty()) {
4052 return UpdateStationWaiting(first_station, type, amount, source_type, source_id);
4057 uint best_rating = 0;
4060 for (
auto &p : used_stations) {
4061 auto owner = p.first->owner;
4062 auto rating = p.first->goods[type].rating;
4063 if (rating > company_best[owner]) {
4064 best_sum += rating - company_best[owner];
4065 company_best[owner] = rating;
4066 if (rating > best_rating) best_rating = rating;
4068 company_sum[owner] += rating;
4073 amount *= best_rating + 1;
4076 for (
auto &p : used_stations) {
4077 uint owner = p.first->owner;
4080 p.second = amount * company_best[owner] * p.first->goods[type].rating / best_sum / company_sum[owner];
4085 if (amount > moving) {
4086 std::sort(used_stations.begin(), used_stations.end(), [type](
const StationInfo &a,
const StationInfo &b) {
4087 return b.first->goods[type].rating < a.first->goods[type].rating;
4090 assert(amount - moving <= used_stations.size());
4091 for (uint i = 0; i < amount - moving; i++) {
4092 used_stations[i].second++;
4097 for (
auto &p : used_stations) {
4098 moved += UpdateStationWaiting(p.first, type, p.second, source_type, source_id);
4104 void UpdateStationDockingTiles(
Station *st)
4118 int x2 = std::min<int>(x + area->
w + 1,
MapSizeX());
4119 int x1 = std::max<int>(x - 1, 0);
4121 int y2 = std::min<int>(y + area->
h + 1,
MapSizeY());
4122 int y1 = std::max<int>(y - 1, 0);
4133 DEBUG(misc, 0,
"Can't allocate station for oilrig at 0x%X, reverting to oilrig only", tile);
4141 st->
string_id = GenerateStationName(st, tile, STATIONNAMING_OILRIG);
4156 UpdateStationDockingTiles(st);
4158 st->
rect.BeforeAddTile(tile, StationRect::ADD_FORCE);
4183 FOR_ALL_ROADTRAMTYPES(rtt) {
4186 RoadType rt = GetRoadType(tile, rtt);
4210 case STATION_WAYPOINT:
4301 case STATION_WAYPOINT:
return_cmd_error(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
4302 case STATION_AIRPORT:
return_cmd_error(STR_ERROR_MUST_DEMOLISH_AIRPORT_FIRST);
4303 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);
4304 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);
4307 case STATION_OILRIG:
4308 SetDParam(1, STR_INDUSTRY_NAME_OIL_RIG);
4327 case STATION_BUOY:
return RemoveBuoy(tile, flags);
4328 case STATION_DOCK:
return RemoveDock(tile, flags);
4343 case STATION_WAYPOINT:
4344 case STATION_RAIL: {
4351 case STATION_AIRPORT:
4379 for (SharesMap::const_iterator it = this->
shares.begin(); it != this->shares.end(); ++it) {
4380 if (it->second == st) {
4381 return it->first - prev;
4398 assert(!this->
shares.empty());
4400 assert(it != this->
shares.end() && it->first <= this->unrestricted);
4401 if (it->second != excluded && it->second != excluded2)
return it->second;
4406 uint end = it->first;
4407 uint begin = (it == this->
shares.begin() ? 0 : (--it)->first);
4408 uint interval = end - begin;
4409 if (interval >= this->
unrestricted)
return INVALID_STATION;
4412 SharesMap::const_iterator it2 = (rand < begin) ? this->
shares.upper_bound(rand) :
4413 this->
shares.upper_bound(rand + interval);
4414 assert(it2 != this->
shares.end() && it2->first <= this->unrestricted);
4415 if (it2->second != excluded && it2->second != excluded2)
return it2->second;
4420 uint end2 = it2->first;
4421 uint begin2 = (it2 == this->
shares.begin() ? 0 : (--it2)->first);
4422 uint interval2 = end2 - begin2;
4423 if (interval2 >= new_max)
return INVALID_STATION;
4424 new_max -= interval2;
4425 if (begin > begin2) {
4426 Swap(begin, begin2);
4428 Swap(interval, interval2);
4433 it3 = this->
shares.upper_bound(rand);
4434 }
else if (rand < begin2 - interval) {
4435 it3 = this->
shares.upper_bound(rand + interval);
4437 it3 = this->
shares.upper_bound(rand + interval + interval2);
4439 assert(it3 != this->
shares.end() && it3->first <= this->unrestricted);
4450 assert(!this->
shares.empty());
4451 SharesMap new_shares;
4453 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4454 new_shares[++i] = it->second;
4455 if (it->first == this->unrestricted) this->
unrestricted = i;
4457 this->
shares.swap(new_shares);
4458 assert(!this->
shares.empty() && this->unrestricted <= (--this->shares.end())->first);
4471 assert(!this->
shares.empty());
4473 uint removed_shares = 0;
4474 uint added_shares = 0;
4475 uint last_share = 0;
4476 SharesMap new_shares;
4477 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4478 if (it->second == st) {
4480 uint share = it->first - last_share;
4481 if (flow == INT_MIN || (uint)(-flow) >= share) {
4482 removed_shares += share;
4483 if (it->first <= this->unrestricted) this->
unrestricted -= share;
4484 if (flow != INT_MIN) flow += share;
4485 last_share = it->first;
4488 removed_shares += (uint)(-flow);
4490 added_shares += (uint)(flow);
4492 if (it->first <= this->unrestricted) this->
unrestricted += flow;
4498 new_shares[it->first + added_shares - removed_shares] = it->second;
4499 last_share = it->first;
4502 new_shares[last_share + (uint)flow] = st;
4509 this->
shares.swap(new_shares);
4519 assert(!this->
shares.empty());
4521 uint last_share = 0;
4522 SharesMap new_shares;
4523 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4525 if (it->first > this->unrestricted)
return;
4526 if (it->second == st) {
4527 flow = it->first - last_share;
4530 new_shares[it->first] = it->second;
4533 new_shares[it->first - flow] = it->second;
4535 last_share = it->first;
4537 if (flow == 0)
return;
4538 new_shares[last_share + flow] = st;
4539 this->
shares.swap(new_shares);
4540 assert(!this->
shares.empty());
4550 assert(!this->
shares.empty());
4552 uint next_share = 0;
4554 for (SharesMap::reverse_iterator it(this->
shares.rbegin()); it != this->shares.rend(); ++it) {
4555 if (it->first < this->unrestricted)
return;
4557 flow = next_share - it->first;
4561 if (it->first == this->unrestricted)
return;
4562 if (it->second == st) found =
true;
4564 next_share = it->first;
4566 if (flow == 0)
return;
4567 SharesMap new_shares;
4568 new_shares[flow] = st;
4569 for (SharesMap::iterator it(this->
shares.begin()); it != this->shares.end(); ++it) {
4570 if (it->second != st) {
4571 new_shares[flow + it->first] = it->second;
4576 this->
shares.swap(new_shares);
4577 assert(!this->
shares.empty());
4587 assert(runtime > 0);
4588 SharesMap new_shares;
4590 for (SharesMap::iterator i = this->
shares.begin(); i != this->shares.end(); ++i) {
4591 share = std::max(share + 1, i->first * 30 / runtime);
4592 new_shares[share] = i->second;
4595 this->
shares.swap(new_shares);
4606 FlowStatMap::iterator origin_it = this->find(origin);
4607 if (origin_it == this->end()) {
4608 this->insert(std::make_pair(origin,
FlowStat(via, flow)));
4610 origin_it->second.ChangeShare(via, flow);
4611 assert(!origin_it->second.GetShares()->empty());
4625 FlowStatMap::iterator prev_it = this->find(origin);
4626 if (prev_it == this->end()) {
4629 this->insert(std::make_pair(origin, fs));
4631 prev_it->second.ChangeShare(via, flow);
4632 prev_it->second.ChangeShare(INVALID_STATION, flow);
4633 assert(!prev_it->second.GetShares()->empty());
4643 for (FlowStatMap::iterator i = this->begin(); i != this->end(); ++i) {
4645 uint local = fs.
GetShare(INVALID_STATION);
4646 if (local > INT_MAX) {
4669 for (FlowStatMap::iterator f_it = this->begin(); f_it != this->end();) {
4673 ret.
Push(f_it->first);
4674 this->erase(f_it++);
4688 for (FlowStatMap::iterator it = this->begin(); it != this->end(); ++it) {
4689 it->second.RestrictShare(via);
4699 for (FlowStatMap::iterator it = this->begin(); it != this->end(); ++it) {
4700 it->second.ReleaseShare(via);
4711 for (FlowStatMap::const_iterator i = this->begin(); i != this->end(); ++i) {
4712 ret += (--(i->second.GetShares()->end()))->first;
4725 for (FlowStatMap::const_iterator i = this->begin(); i != this->end(); ++i) {
4726 ret += i->second.GetShare(via);
4738 FlowStatMap::const_iterator i = this->find(from);
4739 if (i == this->end())
return 0;
4740 return (--(i->second.GetShares()->end()))->first;
4751 FlowStatMap::const_iterator i = this->find(from);
4752 if (i == this->end())
return 0;
4753 return i->second.GetShare(via);
4758 GetSlopePixelZ_Station,
4761 GetTileDesc_Station,
4762 GetTileTrackStatus_Station,
4764 AnimateTile_Station,
4766 ChangeTileOwner_Station,
4768 VehicleEnter_Station,
4769 GetFoundation_Station,
4770 TerraformTile_Station,
@ VEH_AIRCRAFT
Aircraft vehicle type.
static void DrawRailTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette)
Draw tile sprite sequence in GUI with railroad specifics.
@ VETS_STATION_ID_OFFSET
Shift the VehicleEnterTileStatus this many bits to the right to get the station ID when VETS_ENTERED_...
int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec)
Allocate a StationSpec to a Station.
Buses, trucks and trams belong to this class.
@ AAT_STATION_250_TICKS
Triggered every 250 ticks (for all tiles at the same time).
StringID airport_class
Name of the airport class.
@ MP_HOUSE
A house by a town.
void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index)
Delete inspect window for a given feature and index.
bool IsTileFlat(TileIndex tile, int *h)
Check if a given tile is flat.
StationFacility facilities
The facilities that this station has.
const char * grf
newGRF used for the tile contents
bool SplitGroundSpriteForOverlay(const TileInfo *ti, SpriteID *ground, RailTrackOffset *overlay_offset)
Check whether a sprite is a track sprite, which can be replaced by a non-track ground sprite and a ra...
static CommandCost RemoveRailWaypoint(TileIndex tile, DoCommandFlag flags)
Remove a rail waypoint.
@ VETSB_CANNOT_ENTER
The vehicle cannot enter the tile.
uint32 TileIndex
The index/ID of a Tile.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
@ TROPICZONE_DESERT
Tile is desert.
static const uint INVALID_AIRPORTTILE
id for an invalid airport tile
void ScaleToMonthly(uint runtime)
Scale all shares from link graph's runtime to monthly values.
TileArea docking_station
Tile area the docking tiles cover.
CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Place an Airport.
@ ROTSG_GROUND
Required: Main group of ground images.
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
Owner owner
owner of the industry. Which SHOULD always be (imho) OWNER_NONE
void Invalidate()
Reduce all flows to minimum capacity so that they don't get in the way of link usage statistics too m...
SpriteID single_x
single piece of rail in X direction, without ground
Minimal stack that uses a pool to avoid pointers.
uint8 callback_mask
Bitmask of cargo callbacks that have to be called.
GoodsEntry goods[NUM_CARGO]
Goods at this station.
@ TRACK_BIT_NONE
No track.
static const IndustryType NUM_INDUSTRYTYPES
total number of industry types, new and old; limited to 240 because we need some special ids like INV...
StationRect - used to track station spread out rectangle - cheaper than scanning whole map.
byte StationGfx
Copy from station_map.h.
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
static CargoArray GetAcceptanceAroundStation(const Station *st, CargoTypes *always_accepted)
Get the acceptance of cargoes around the station in.
uint unrestricted
Limit for unrestricted shares.
bool IsType(OrderType type) const
Check whether this order is of the given type.
static const uint COMPRESSION_INTERVAL
Minimum number of days between subsequent compressions of a LG.
static Titem * Get(size_t index)
Returns Titem with given index.
byte flags
Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size.
static DiagDirection GetDockDirection(TileIndex t)
Get the direction of a dock.
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Direction
Defines the 8 directions on the map.
CommandCost FindJoiningWaypoint(StationID existing_waypoint, StationID waypoint_to_join, bool adjacent, TileArea ta, Waypoint **wp)
Find a nearby waypoint that joins this waypoint.
uint GetFlowVia(StationID via) const
Get the sum of flows via a specific station from this FlowStatMap.
uint GetHangarNum(TileIndex tile) const
Get the hangar number of the hangar at a specific tile.
StationSettings station
settings related to station management
bool IsWithinMapBounds(byte table, TileIndex index) const
Check if the airport would be within the map bounds at the given tile.
static bool IsRoadStop(TileIndex t)
Is the station at t a road station?
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
A connected component of a link graph.
int GetTileMaxZ(TileIndex t)
Get top height of the tile inside the map.
static const int STATION_RATING_TICKS
cycle duration for updating station rating
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
void AfterStationTileSetChange(bool adding, StationType type)
After adding/removing tiles to station, update some station-related stuff.
void DrawRoadOverlays(const TileInfo *ti, PaletteID pal, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rti, uint road_offset, uint tram_offset)
Draw road underlay and overlay sprites.
uint GetFlow() const
Get the sum of all flows from this FlowStatMap.
uint Reroute(uint max_move, VehicleCargoList *dest, StationID avoid, StationID avoid2, const GoodsEntry *ge)
Routes packets with station "avoid" as next hop to a different place.
StationGfx GetStationGfx() const
Get the StationGfx for the current tile.
static bool HasTileWaterClass(TileIndex t)
Checks whether the tile has an waterclass associated.
void Push(const Titem &item)
Pushes a new item onto the stack if there is still space in the underlying pool.
uint32 PrepareLayout(uint32 orig_offset, uint32 newgrf_ground_offset, uint32 newgrf_offset, uint constr_stage, bool separate_ground) const
Prepares a sprite layout before resolving action-1-2-3 chains.
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track)
Use this function to notify YAPF that track layout (or signal configuration) has change.
uint x
X position of the tile in unit coordinates.
struct RoadTypeInfo::@44 strings
Strings associated with the rail type.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
void RerouteCargo(Station *st, CargoID c, StationID avoid, StationID avoid2)
Reroute cargo of type c at station st or in any vehicles unloading there.
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
void 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.
void UpdateAirplanesOnNewStation(const Station *st)
Updates the status of the Aircraft heading or in the station.
static bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
Autoslope check for tiles with an entrance on an edge.
@ SSF_EXTENDED_FOUNDATIONS
Extended foundation block instead of simple.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
@ SAT_250_TICKS
Trigger station every 250 ticks.
@ TO_BUILDINGS
company buildings - depots, stations, HQ, ...
Tile information, used while rendering the tile.
static bool StationHandleBigTick(BaseStation *st)
This function is called for each station once every 250 ticks.
void ReleaseShare(StationID st)
Release ("unrestrict") a flow by moving it to the begin of the map and increasing the amount of unres...
byte landscape
the landscape we're currently in
StringID railtype
Type of rail on the tile.
CompanyMask statues
which companies have a statue?
SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32 var10)
Resolve sprites for drawing a station tile.
Vehicle * Next() const
Get the next vehicle of this vehicle.
@ TRANSPORT_RAIL
Transport by train.
const Tcont * Packets() const
Returns a pointer to the cargo packet list (so you can iterate over it etc).
Town * town
The town this station is associated with.
void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool b)
Set the reservation for a complete station platform.
Date LastRestrictedUpdate() const
Get the date of the last update to the edge's restricted capacity.
static void SetCustomStationSpecIndex(TileIndex t, byte specindex)
Set the custom station spec for this tile.
@ FACIL_TRUCK_STOP
Station with truck stops.
@ CBM_CARGO_STATION_RATING_CALC
custom station rating for this cargo type
Owner owner[4]
Name of the owner(s)
byte size_y
size of airport in y direction
static Slope GetFoundationPixelSlope(TileIndex tile, int *z)
Get slope of a tile on top of a (possible) foundation If a tile does not have a foundation,...
@ CBID_STATION_AVAILABILITY
Determine whether a newstation should be made available to build.
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
void RecomputeCatchment()
Recompute tiles covered in our catchment area.
@ AAT_STATION_NEW_CARGO
Triggered when new cargo arrives at the station (for all tiles at the same time).
Date LastUpdate() const
Get the date of the last update to any part of the edge's capacity.
@ PALETTE_MODIFIER_COLOUR
this bit is set when a recolouring process is in action
CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Rename a station.
@ NR_STATION
Reference station. Scroll to station when clicking on the news. Delete news when station is deleted.
StringID name
name of this airport
@ INVALID_ROADTYPE
flag for invalid roadtype
static bool CMSAWater(TileIndex tile)
Check whether the tile is water.
@ SAT_NEW_CARGO
Trigger station on new cargo arrival.
StringID station_class
Class of station.
static Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
CommandCost RemoveRailStation(T *st, DoCommandFlag flags, Money removal_cost)
Remove a rail station/waypoint.
byte town_council_tolerance
minimum required town ratings to be allowed to demolish stuff
IndustryType GetIndustryType(TileIndex tile)
Retrieve the type for this industry.
static bool IsCustomStationSpecIndex(TileIndex t)
Is there a custom rail station spec on this tile?
Iterator to iterate over all tiles belonging to a bitmaptilearea.
uint16 noise_reached
level of noise that all the airports are generating
@ AAT_BUILT
Triggered when the airport is built (for all tiles at the same time).
static LinkGraphSchedule instance
Static instance of LinkGraphSchedule.
@ DIAGDIR_END
Used for iterations.
uint32 water
Count of company owned track bits for canals.
static bool IsRailStation(TileIndex t)
Is this station tile a rail station?
Tindex index
Index of this pool item.
void DrawRoadCatenary(const TileInfo *ti)
Draws the catenary for the given tile.
bool IsHangar(TileIndex t)
Check whether the given tile is a hangar.
@ RVSB_IN_ROAD_STOP
The vehicle is in a road stop.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
static Track GetRailStationTrack(TileIndex t)
Get the rail track of a rail station tile.
EdgeIterator Begin()
Get an iterator pointing to the start of the edges array.
CommandCost FindJoiningBaseStation(StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, T **st)
Find a nearby station that joins this station.
static TrackBits AxisToTrackBits(Axis a)
Maps an Axis to the corresponding TrackBits value.
static bool HasPowerOnRail(RailType enginetype, RailType tiletype)
Checks if an engine of the given RailType got power on a tile with a given RailType.
An iterator for non-const edges.
Class for storing amounts of cargo.
@ TRACK_X
Track along the x-axis (north-east to south-west)
SpriteID sprite
The 'real' sprite.
@ DT_MANUAL
Manual distribution. No link graph calculations are run.
static uint ClampU(const uint a, const uint min, const uint max)
Clamp an unsigned integer between an interval.
byte noise_level
noise that this airport generates
void PassOnFlow(StationID origin, StationID via, uint amount)
Pass on some flow, remembering it as invalid, for later subtraction from locally consumed flow.
SpriteID single_y
single piece of rail in Y direction, without ground
DifficultySettings difficulty
settings related to the difficulty
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
uint16 tram_speed
Speed limit of tram (bridges and track)
static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, std::vector< Train * > &affected_vehicles, StationClassID spec_class, byte spec_index, byte plat_len, byte numtracks)
Checks if a rail station can be built at the given area.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
@ CBID_CARGO_STATION_RATING_CALC
Called to calculate part of a station rating.
uint32 station
Count of company owned station tiles.
void ProcessRegisters(uint8 resolved_var10, uint32 resolved_sprite, bool separate_ground) const
Evaluates the register modifiers and integrates them into the preprocessed sprite layout.
This struct contains all the info that is needed to draw and construct tracks.
@ ROAD_X
Full road along the x-axis (south-west + north-east)
bool include(std::vector< T > &vec, const T &item)
Helper function to append an item to a vector if it is not already contained Consider using std::set,...
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
static bool IsCompatibleTrainStationTile(TileIndex test_tile, TileIndex station_tile)
Check if a tile is a valid continuation to a railstation tile.
static RoadStopType GetRoadStopType(TileIndex t)
Get the road stop type of this tile.
@ VETSB_CONTINUE
Bit sets of the above specified bits.
void MoveSign(TileIndex new_xy) override
Move the station main coordinate somewhere else.
Representation of a waypoint.
@ CBM_STATION_SLOPE_CHECK
Check slope of new station tiles.
byte layout
Airport layout number.
static bool IsStandardRoadStopTile(TileIndex t)
Is tile t a standard (non-drive through) road stop station?
static void SetStationGfx(TileIndex t, StationGfx gfx)
Set the station graphics of this tile.
WaterClass
classes of water (for WATER_TILE_CLEAR water tile type).
static RoadStop * GetByTile(TileIndex tile, RoadStopType type)
Find a roadstop at given tile.
static void SetRoadOwner(TileIndex t, RoadTramType rtt, Owner o)
Set the owner of a specific road type.
@ EUM_INCREASE
Increase capacity.
static bool IsDriveThroughStopTile(TileIndex t)
Is tile t a drive through road stop station?
static const uint TILE_SIZE
Tile size in world coordinates.
EdgeIterator End()
Get an iterator pointing beyond the end of the edges array.
static TrackBits GetTrackBits(TileIndex tile)
Gets the track bits of the given tile.
static Station * Get(size_t index)
Gets station with given index.
uint y
Y position of the tile in unit coordinates.
ClientSettings _settings_client
The current settings for this game.
static bool HasSignals(TileIndex t)
Checks if a rail tile has signals.
TileIndex xy
town center tile
Specification of a cargo type.
static bool IsValidID(size_t index)
Tests whether given index is a valid index for station of this type.
@ MP_INDUSTRY
Part of an industry.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
@ CC_LIQUID
Liquids (Oil, Water, Rubber)
void Add(TileIndex to_add)
Add a single tile to a tile area; enlarge if needed.
StringID airport_tile_name
Name of the airport tile.
CompanyInfrastructure infrastructure
NOSAVE: Counts of company owned infrastructure.
@ VS_TRAIN_SLOWING
Train is slowing down.
static uint32 RandomRange(uint32 limit)
Pick a random number between 0 and limit - 1, inclusive.
@ CMD_REMOVE_FROM_RAIL_WAYPOINT
remove a (rectangle of) tiles from a rail waypoint
@ WC_STATION_VIEW
Station view; Window numbers:
StringID station_name
Default name for nearby station.
Town * AirportGetNearestTown(const AirportSpec *as, const TileIterator &it, uint &mindist)
Finds the town nearest to given airport.
bool Enter(RoadVehicle *rv)
Enter the road stop.
CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Build rail station.
TransportType
Available types of transport.
byte fallback_railtype
Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations.
@ VEH_ROAD
Road vehicle type.
@ CC_PASSENGERS
Passengers.
uint16 cur_speed
current speed
Defines the internal data of a functional industry.
Owner owner
Which company owns the vehicle?
static void RestoreTrainReservation(Train *v)
Restore platform reservation during station building/removing.
Trackdir GetVehicleTrackdir() const
Get the tracks of the train vehicle.
Owner
Enum for all companies/owners.
CommandCost GetStationAround(TileArea ta, StationID closest_station, CompanyID company, T **st)
Look for a station owned by the given company around the given tile area.
@ DC_EXEC
execute the given command
void DeallocateSpecFromStation(BaseStation *st, byte specindex)
Deallocate a StationSpec from a Station.
void FinalizeLocalConsumption(StationID self)
Subtract invalid flows from locally consumed flow.
Owner owner
The owner of this station.
static bool IsTruckStop(TileIndex t)
Is the station at t a truck stop?
@ MP_ROAD
A tile with road (or tram tracks)
Defines the data structure for an airport.
Tile description for the 'land area information' tool.
uint GetShare(StationID st) const
Get flow for a station.
static bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
Find out if the slope of the tile is suitable to build a depot of given direction.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
StringID airport_name
Name of the airport.
CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags)
Checks whether the local authority allows construction of a new station (rail, road,...
byte status
Status of this cargo, see GoodsEntryStatus.
DoCommandFlag
List of flags for a command.
Foundation
Enumeration for Foundations.
EdgeUpdateMode
Special modes for updating links.
CommandCost EnsureNoVehicleOnGround(TileIndex tile)
Ensure there is no vehicle at the ground at the given position.
static Track RemoveFirstTrack(TrackBits *tracks)
Removes first Track from TrackBits and returns it.
Station * neutral_station
Associated neutral station.
static Foundation FlatteningFoundation(Slope s)
Returns the foundation needed to flatten a slope.
@ TRACK_BIT_UPPER
Upper track.
const AirportFTAClass * GetAirport(const byte airport_type)
Get the finite state machine of an airport type.
bool Succeeded() const
Did this command succeed?
byte amount_fract
Fractional part of the amount in the cargo list.
static TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
static uint TileX(TileIndex tile)
Get the X component of a tile.
static TrackBits GetRailReservationTrackBits(TileIndex t)
Returns the reserved track bits of the tile.
NewGRFSpriteLayout * renderdata
Array of tile layouts.
void Remove(const T &element)
Remove a single element from the tree, if it exists.
virtual bool TileBelongsToRailStation(TileIndex tile) const =0
Check whether a specific tile belongs to this station.
virtual TileIterator * Clone() const =0
Allocate a new iterator that is a copy of this one.
@ AAT_TILELOOP
Triggered in the periodic tile loop.
static uint CountBits(T value)
Counts the number of set bits in a variable.
StringID string_id
Default name (town area) of station.
GameCreationSettings game_creation
settings used during the creation of a game (map)
void MakeDriveThrough()
Join this road stop to another 'base' road stop if possible; fill all necessary data to become an act...
uint8 cached_anim_triggers
NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen.
void Clear()
Clears the 'tile area', i.e.
static const int MAX_CHAR_LENGTH
Max. length of UTF-8 encoded unicode character.
void RestrictFlows(StationID via)
Restrict all flows at a station for specific cargo and destination.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
@ TRACK_BIT_RIGHT
Right track.
@ ROADSTOP_BUS
A standard stop for buses.
uint GetFlowFrom(StationID from) const
Get the sum of flows from a specific station from this FlowStatMap.
Aircraft, helicopters, rotors and their shadows belong to this class.
Slope tileh
Slope of the tile.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
static RoadBits AxisToRoadBits(Axis a)
Create the road-part which belongs to the given Axis.
@ SSF_SEPARATE_GROUND
Use different sprite set for ground sprites.
static uint MapSizeX()
Get the size of the map along the X.
static bool IsTileOnWater(TileIndex t)
Tests if the tile was built on water.
uint tiles
Number of tile layouts.
Flow statistics telling how much flow should be sent along a link.
void ClearDockingTilesCheckingNeighbours(TileIndex tile)
Clear docking tile status from tiles around a removed dock, if the tile has no neighbours which would...
char * GetStringWithArgs(char *buffr, StringID string, StringParameters *args, const char *last, uint case_index, bool game_script)
Get a parsed string with most special stringcodes replaced by the string parameters.
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner)
Change the owner of a tile.
StringID name
Name of this rail type.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
void Queue(LinkGraph *lg)
Queue a link graph for execution.
Date build_date
Date of construction of tile contents.
StationType
Station types.
@ TRANSPORT_ROAD
Transport by road vehicle.
RoadBits
Enumeration for the road parts on a tile.
PalSpriteID ground
Palette and sprite for the ground.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
bool ValParamRailtype(const RailType rail)
Validate functions for rail building.
@ ROAD_NONE
No road-part is build.
void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, byte widget_index)
Mark a particular widget in a particular window as dirty (in need of repainting)
Defines the data structure of each individual tile of an airport.
StationClassID cls_id
The class to which this spec belongs.
static RoadBits GetAllRoadBits(TileIndex tile)
Get all set RoadBits on the given tile.
SpriteID GetCustomRoadSprite(const RoadTypeInfo *rti, TileIndex tile, RoadTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
size_t Utf8StringLength(const char *s)
Get the length of an UTF-8 encoded string in number of characters and thus not the number of bytes th...
static void MakeOilrig(TileIndex t, StationID sid, WaterClass wc)
Make the given tile an oilrig tile.
static TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between to tiles from a TileIndexDiffC struct.
OrderSettings order
settings related to orders
static RoadBits GetRoadBits(TileIndex t, RoadTramType rtt)
Get the present road bits for a specific road type.
IterateWrapper Orders() const
Returns an iterable ensemble of orders of a vehicle.
CommandCost CheckBuildableTile(TileIndex tile, uint invalid_dirs, int &allowed_z, bool allow_steep, bool check_bridge=true)
Checks if the given tile is buildable, flat and has a certain height.
@ WATER_CLASS_INVALID
Used for industry tiles on land (also for oilrig if newgrf says so).
uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred)
Evaluate a tile's position within a station, and return the result in a bit-stuffed format.
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
static void DrawRailTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette)
Draw tile sprite sequence on tile with railroad specifics.
static int GetSlopeMaxZ(Slope s)
Returns the height of the highest corner of a slope relative to TileZ (= minimal height)
struct RoadStop * next
Next stop of the given type at this station.
@ FACIL_BUS_STOP
Station with bus stops.
Direction rotation
How this airport is rotated.
StationIDStack DeleteFlows(StationID via)
Delete all flows at a station for specific cargo and destination.
void CheckForDockingTile(TileIndex t)
Mark the supplied tile as a docking tile if it is suitable for docking.
CargoID Index() const
Determines index of this cargospec.
const Direction * rotation
the rotation of each tiletable
static byte GetAnimationFrame(TileIndex t)
Get the current animation frame.
bool station_noise_level
build new airports when the town noise level is still within accepted limits
uint Reroute(uint max_move, StationCargoList *dest, StationID avoid, StationID avoid2, const GoodsEntry *ge)
Routes packets with station "avoid" as next hop to a different place.
CommandCost CheckOwnership(Owner owner, TileIndex tile)
Check whether the current owner owns something.
TileIndex dest_tile
Heading for this tile.
static DiagDirection DirToDiagDir(Direction dir)
Convert a Direction to a DiagDirection.
bool serve_neutral_industries
company stations can serve industries with attached neutral stations
static StationGfx GetAirportGfx(TileIndex t)
Get the station graphics of this airport tile.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
StationList stations
List of stations nearby.
void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigger trigger, CargoID cargo_type)
Trigger station randomisation.
static uint MapSize()
Get the size of the map.
static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCommandFlag flags)
Checks if an airport can be built at the given location and clear the area.
Date LastUnrestrictedUpdate() const
Get the date of the last update to the edge's unrestricted capacity.
@ EXPENSES_CONSTRUCTION
Construction costs.
TrackedViewportSign sign
NOSAVE: Dimensions of sign.
RailType
Enumeration for all possible railtypes.
TileIndex TileAddWrap(TileIndex tile, int addx, int addy)
This function checks if we add addx/addy to tile, if we do wrap around the edges.
@ STAT_CLASS_WAYP
Waypoint class.
static bool IsSteepSlope(Slope s)
Checks if a slope is steep.
void ReleaseFlows(StationID via)
Release all flows at a station for specific cargo and destination.
Common return value for all commands.
byte GetSnowLine()
Get the current snow line, either variable or static.
TileArea location
Location of the industry.
static uint GetCustomStationSpecIndex(TileIndex t)
Get the custom station spec for this tile.
@ TRACK_Y
Track along the y-axis (north-west to south-east)
static bool HasTileWaterGround(TileIndex t)
Checks whether the tile has water at the ground.
static const AirportSpec * Get(byte type)
Retrieve airport spec for the given airport.
AirportClassID cls_id
the class to which this airport type belongs
Date _date
Current date in days (day counter)
uint16 SourceID
Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
static bool HasStationRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
#define TILE_AREA_LOOP(var, ta)
A loop which iterates over the tiles of a TileArea.
bool CircularTileSearch(TileIndex *tile, uint size, TestTileOnSearchProc proc, void *user_data)
Function performing a search around a center tile and going outward, thus in circle.
static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
Remove an airport.
Information about GRF, used in the game and (part of it) in savegames.
static Track AxisToTrack(Axis a)
Convert an Axis to the corresponding Track AXIS_X -> TRACK_X AXIS_Y -> TRACK_Y Uses the fact that the...
void StationMonthlyLoop()
Monthly loop for stations.
TileArea train_station
Tile area the train 'station' part covers.
RoadBits GetAnyRoadBits(TileIndex tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance)
Returns the RoadBits on an arbitrary tile Special behaviour:
static const int STATION_ACCEPTANCE_TICKS
cycle duration for updating station acceptance
static bool HasExactlyOneBit(T value)
Test whether value has exactly 1 bit set.
@ NF_INCOLOUR
Bit value for coloured news.
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
byte num_table
number of elements in the table
void DirtyCompanyInfrastructureWindows(CompanyID company)
Redraw all windows with company infrastructure counts.
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
IndustryType type
type of industry.
@ DRD_NONE
None of the directions are disallowed.
static TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
void TriggerWatchedCargoCallbacks(Station *st)
Run the watched cargo callback for all houses in the catchment area.
int32 TileIndexDiff
An offset value between to tiles.
bool HasRating() const
Does this cargo have a rating at this station?
TileIndex tile
Current tile index.
#define DEBUG(name, level,...)
Output a line of debugging information.
static bool FindNearIndustryName(TileIndex tile, void *user_data)
Find a station action 0 property 24 station name, or reduce the free_names if needed.
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
Converts a callback result into a boolean.
Base class for tile iterators.
static bool CMSAMine(TileIndex tile)
Check whether the tile is a mine.
uint DistanceFromEdge(TileIndex tile)
Param the minimum distance to an edge.
CommandCost CanExpandRailStation(const BaseStation *st, TileArea &new_ta, Axis axis)
Check whether we can expand the rail part of the given station.
void MarkTilesDirty(bool cargo_change) const
Marks the tiles of the station as dirty.
static DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
void Insert(const T &element)
Insert a single element in the tree.
StringID roadtype
Type of road on the tile.
CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad)
Get the cargo types being produced around the tile (in a rectangle).
byte last_speed
Maximum speed (up to 255) of the last vehicle that tried to load this cargo.
@ GES_ACCEPTED_BIGTICK
Set when cargo was delivered for final delivery during the current STATION_ACCEPTANCE_TICKS interval.
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
const SharesMap * GetShares() const
Get the actual shares as a const pointer so that they can be iterated over.
StationID GetVia(StationID source) const
Get the best next hop for a cargo packet from station source.
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
static void MakeDriveThroughRoadStop(TileIndex t, Owner station, Owner road, Owner tram, StationID sid, RoadStopType rst, RoadType road_rt, RoadType tram_rt, Axis a)
Make the given tile a drivethrough roadstop tile.
static bool IsBuoy(TileIndex t)
Is tile t a buoy tile?
@ INVALID_OWNER
An invalid owner.
uint16 w
The width of the area.
TileArea truck_station
Tile area the truck 'station' part covers.
void UpdateAirportsNoise()
Recalculate the noise generated by the airports of each town.
CargoID produced_cargo[INDUSTRY_NUM_OUTPUTS]
16 production cargo slots
NodeID node
ID of node in link graph referring to this goods entry.
VehicleCargoList cargo
The cargo this vehicle is carrying.
static void FreeTrainReservation(Train *v)
Clear platform reservation during station building/removing.
static StationType GetStationType(TileIndex t)
Get the station type of this tile.
bool Failed() const
Did this command fail?
static RoadStop ** FindRoadStopSpot(bool truck_station, Station *st)
CommandCost CmdRemoveFromRailWaypoint(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Remove a single tile from a waypoint.
Order current_order
The current order (+ status, like: loading)
TileIndex GetHangarTile(uint hangar_num) const
Get the first tile of the given hangar.
static void ShowRejectOrAcceptNews(const Station *st, uint num_items, CargoID *cargo, StringID msg)
Items contains the two cargo names that are to be accepted or rejected.
Airport airport
Tile area the airport covers.
Iterator to iterate over all tiles belonging to an airport spec.
uint Size() const
Get the current size of the component.
Represents the covered area of e.g.
void AddFacility(StationFacility new_facility_bit, TileIndex facil_xy)
Called when new facility is built on the station.
size_t MapSize() const
Count the number of ranges with equal keys in this MultiMap.
void EndSpriteCombine()
Terminates a block of sprites started by StartSpriteCombine.
static bool CMSATree(TileIndex tile)
Check whether the tile is a tree.
bool IsFrontEngine() const
Check if the vehicle is a front engine.
@ SRT_NEW_CARGO
Trigger station on new cargo arrival.
static bool HasTileRoadType(TileIndex t, RoadTramType rtt)
Check if a tile has a road or a tram road type.
static const AirportTileSpec * GetByTile(TileIndex tile)
Retrieve airport tile spec for the given airport tile.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static const uint8 ANIM_STATUS_NO_ANIMATION
There is no animation.
static TropicZone GetTropicZone(TileIndex tile)
Get the tropic zone.
IndustryType indtype
Industry type to get the name from.
uint16 MaxTownNoise() const
Calculate the max town noise.
EconomySettings economy
settings to change the economy
static Money RailBuildCost(RailType railtype)
Returns the cost of building the specified railtype.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags)
Remove a dock.
@ TRACK_BIT_X
X-axis track.
uint16 _tick_counter
Ever incrementing (and sometimes wrapping) tick counter for setting off various events.
NewGRF supplied spritelayout.
static bool HasStationTileRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
static TrackStatus CombineTrackStatus(TrackdirBits trackdirbits, TrackdirBits red_signals)
Builds a TrackStatus.
static void SetDockingTile(TileIndex t, bool b)
Set the docking tile state of a tile.
StringID name
Name of this station.
@ ROTSG_ROADSTOP
Required: Drive-in stop surface.
CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags)
Clear a single tile of a station.
bool NeedsPreprocessing() const
Tests whether this spritelayout needs preprocessing by PrepareLayout() and ProcessRegisters(),...
'Train' is either a loco or a wagon.
@ VEH_INVALID
Non-existing type of vehicle.
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
uint64 flags
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
void FreeTrainTrackReservation(const Train *v)
Free the reserved path in front of a vehicle.
SpriteID GetCanalSprite(CanalFeature feature, TileIndex tile)
Lookup the base sprite to use for a canal.
static void SetStationTileRandomBits(TileIndex t, byte random_bits)
Set the random bits for a station tile.
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Slope GetTileSlope(TileIndex tile, int *h)
Return the slope of a given tile inside the map.
@ ROADSTOP_TRUCK
A standard stop for trucks.
@ SPRITE_MODIFIER_CUSTOM_SPRITE
Set when a sprite originates from an Action 1.
static bool IsTileOwner(TileIndex tile, Owner owner)
Checks if a tile belongs to the given owner.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
static bool HasStationReservation(TileIndex t)
Get the reservation state of the rail station.
static void MakeAirport(TileIndex t, Owner o, StationID sid, byte section, WaterClass wc)
Make the given tile an airport tile.
@ NUM_AIRPORTS
Maximal number of airports in total.
@ CMD_REMOVE_SINGLE_RAIL
remove a single rail track
std::string name
Custom name.
static const int STATION_LINKGRAPH_TICKS
cycle duration for cleaning dead links
Ground palette sprite of a tile, together with its sprite layout.
static CommandCost CheckFlatLandRoadStop(TileArea tile_area, DoCommandFlag flags, uint invalid_dirs, bool is_drive_through, bool is_truck_stop, Axis axis, StationID *station, RoadType rt)
Checks if a road stop can be built at the given tile.
void RestrictShare(StationID st)
Restrict a flow by moving it to the end of the map and decreasing the amount of unrestricted flow.
void StartSpriteCombine()
Starts a block of sprites, which are "combined" into a single bounding box.
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
TileArea bus_station
Tile area the bus 'station' part covers.
CommandCost RemoveBuoy(TileIndex tile, DoCommandFlag flags)
Remove a buoy.
static bool AutoslopeEnabled()
Tests if autoslope is enabled for _current_company.
@ RTSG_GROUND
Main group of ground images.
byte rating
Station rating for this cargo.
Coordinates of a point in 2D.
StringID station_name
Type of station within the class.
StringID name
Name of this rail type.
bool ValParamRoadType(RoadType roadtype)
Validate functions for rail building.
LinkGraphSettings linkgraph
settings for link graph calculations
void DeleteStaleLinks(Station *from)
Check all next hops of cargo packets in this station for existence of a a valid link they may use to ...
static DiagDirection GetRoadStopDir(TileIndex t)
Gets the direction the road stop entrance points towards.
Slope
Enumeration for the slope-type.
DiagDirection
Enumeration for diagonal directions.
static uint MapSizeY()
Get the size of the map along the Y.
uint AvailableCount() const
Returns sum of cargo still available for loading at the sation.
static const int GFX_DOCK_BASE_WATER_PART
The offset for the water parts.
@ TRACK_BIT_ALL
All possible tracks.
@ FACIL_DOCK
Station with a dock.
void OffsetGroundSprite(int x, int y)
Called when a foundation has been drawn for the current tile.
void AppendShare(StationID st, uint flow, bool restricted=false)
Add some flow to the end of the shares map.
struct RailtypeInfo::@38 base_sprites
Struct containing the main sprites.
@ CBM_STATION_AVAIL
Availability of station in construction window.
static Station * From(BaseStation *st)
Converts a BaseStation to SpecializedStation with type checking.
byte station_spread
amount a station may spread
CargoTypes always_accepted
Bitmask of always accepted cargo types (by houses, HQs, industry tiles when industry doesn't accept c...
void ShowStationViewWindow(StationID station)
Opens StationViewWindow for given station.
static bool IsRailStationTile(TileIndex t)
Is this tile a station tile and a rail station?
void AddCost(const Money &cost)
Adds the given cost to the cost of the command.
static void TruncateCargo(const CargoSpec *cs, GoodsEntry *ge, uint amount=UINT_MAX)
Truncate the cargo by a specific amount.
@ CBID_STATION_TILE_LAYOUT
Called when building a station to customize the tile layout.
bool show_track_reservation
highlight reserved tracks.
@ WATER_CLASS_CANAL
Canal.
byte disallowed_platforms
Bitmask of number of platforms available for the station.
CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadTramType rtt, DoCommandFlag flags, bool town_check)
Is it allowed to remove the given road bits from the given tile?
RoadType
The different roadtypes we support.
Set of callback functions for performing tile operations of a given tile type.
const StationList * GetStations()
Run a tile loop to find stations around a tile, on demand.
@ SAT_BUILT
Trigger tile when built.
static CommandCost BuildStationPart(Station **st, DoCommandFlag flags, bool reuse, TileArea area, StationNaming name_class)
Common part of building various station parts and possibly attaching them to an existing one.
LinkGraphID link_graph
Link graph this station belongs to.
RoadStop * truck_stops
All the truck stops.
@ CMD_REMOVE_FROM_RAIL_STATION
remove a (rectangle of) tiles from a rail station
Defines the data structure for constructing industry.
Industry * industry
NOSAVE: Associated industry for neutral stations. (Rebuilt on load from Industry->st)
static void Reset(TileIndex tile=INVALID_TILE, bool from_gui=true)
Reset the OrderBackups from GUI/game logic.
@ DC_BANKRUPT
company bankrupts, skip money check, skip vehicle on tile check in some cases
bool IsValidDockingDirectionForDock(TileIndex t, DiagDirection d)
Check if a dock tile can be docked from the given direction.
Iterator to iterate over all tiles belonging to an airport.
bool IsAvailable() const
Check whether this airport is available to build.
@ RTSG_OVERLAY
Images for overlaying track.
static DiagDirection AxisToDiagDir(Axis a)
Converts an Axis to a DiagDirection.
std::set< Station *, StationCompare > StationList
List of stations.
void TileLoop_Water(TileIndex tile)
Let a water tile floods its diagonal adjoining tiles called from tunnelbridge_cmd,...
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
int GetTrainStopLocation(StationID station_id, TileIndex tile, const Train *v, int *station_ahead, int *station_length)
Get the stop location of (the center) of the front vehicle of a train at a platform of a station.
@ FACIL_WAYPOINT
Station is a waypoint.
CommandCost CmdRemoveFromRailStation(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Remove a single tile from a rail station.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
static bool IsAirport(TileIndex t)
Is this station tile an airport?
void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w, int h, int dz, int z, bool transparent, int bb_offset_x, int bb_offset_y, int bb_offset_z, const SubSprite *sub)
Draw a (transparent) sprite at given coordinates with a given bounding box.
static CommandCost FindJoiningRoadStop(StationID existing_stop, StationID station_to_join, bool adjacent, TileArea ta, Station **st)
Find a nearby station that joins this road stop.
static PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
Direction direction
facing
void AddFlow(StationID origin, StationID via, uint amount)
Add some flow from "origin", going via "via".
uint16 h
The height of the area.
bool IsTileForestIndustry(TileIndex tile)
Check whether the tile is a forest.
static uint ApplyPixelFoundationToSlope(Foundation f, Slope *s)
Applies a foundation to a slope.
uint DistanceMax(TileIndex t0, TileIndex t1)
Gets the biggest distance component (x or y) between the two given tiles.
byte size_x
size of airport in x direction
@ MP_TREES
Tile got trees.
A pair-construct of a TileIndexDiff.
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
static const uint MAX_LENGTH_STATION_NAME_CHARS
The maximum length of a station name in characters including '\0'.
@ SSF_CUSTOM_FOUNDATIONS
Draw custom foundations.
Date LastCompression() const
Get date of last compression.
void ForAllStationsRadius(TileIndex center, uint radius, Func func)
Call a function on all stations whose sign is within a radius of a center tile.
static const SharesMap empty_sharesmap
Static instance of FlowStat::SharesMap.
bool road_stop_on_competitor_road
allow building of drive-through road stops on roads owned by competitors
CommandCost RemoveFromRailBaseStation(TileArea ta, std::vector< T * > &affected_stations, DoCommandFlag flags, Money removal_cost, bool keep_rail)
Remove a number of tiles from any rail station within the area.
bool enabled
entity still available (by default true).newgrf can disable it, though
static const uint64 AIRPORT_CLOSED_block
Dummy block for indicating a closed airport.
bool IsStationTileBlocked(TileIndex tile)
Check whether a rail station tile is NOT traversable.
@ GES_CURRENT_MONTH
Set when cargo was delivered for final delivery this month.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
static bool IsDockTile(TileIndex t)
Is tile t a dock tile?
@ TRACKDIR_BIT_NONE
No track build.
static bool IsBuoyTile(TileIndex t)
Is tile t a buoy tile?
static DisallowedRoadDirections GetDisallowedRoadDirections(TileIndex t)
Gets the disallowed directions.
static bool IsRoadStopTile(TileIndex t)
Is tile t a road stop station?
All ships have this type.
SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
Stores station stats for a single cargo.
CompanyID _current_company
Company currently doing an action.
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
SourceType
Types of cargo source and destination.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static void DeleteStationIfEmpty(BaseStation *st)
This is called right after a station was deleted.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
const struct SpriteGroup * spritegroup[Tcnt]
pointer to the different sprites of the entity
Vehicle * First() const
Get the first vehicle of this vehicle chain.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
static WaterClass GetWaterClass(TileIndex t)
Get the water class at a tile.
static int CountMapSquareAround(TileIndex tile, CMSAMatcher cmp)
Counts the numbers of tiles matching a specific type in the area around.
byte last_age
Age in years (up to 255) of the last vehicle that tried to load this cargo.
@ TRACK_BIT_LEFT
Left track.
static bool IsRailWaypoint(TileIndex t)
Is this station tile a rail waypoint?
NodeID AddNode(const Station *st)
Add a node to the component and create empty edges associated with it.
void RemoveEdge(NodeID to)
Remove an outgoing edge from this node.
static size_t GetNumItems()
Returns number of valid items in the pool.
void DeleteAnimatedTile(TileIndex tile)
Removes the given tile from the animated tile table.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
void ClearDriveThrough()
Prepare for removal of this stop; update other neighbouring stops if needed.
static const Date INVALID_DATE
Representation of an invalid date.
CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_tile, const StationSpec *statspec, Axis axis, byte plat_len, byte numtracks)
Check the slope of a tile of a new station.
@ FACIL_TRAIN
Station with train station.
void UpdatePosition(int center, int top, StringID str, StringID str_small=STR_NULL)
Update the position of the viewport sign.
bool TryPathReserve(Train *v, bool mark_as_stuck=false, bool first_tile_okay=false)
Try to reserve a path to a safe position.
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 RoadVehicle * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
static StationGfx GetStationGfx(TileIndex t)
Get the station graphics of this tile.
CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Remove bus or truck stops.
static Axis GetRailStationAxis(TileIndex t)
Get the rail direction of a rail station.
RoadStopType
Types of RoadStops.
FlowStatMap flows
Planned flows through this station.
RailTrackOffset
Offsets for sprites within an overlay/underlay set.
TileIndex tile
The base tile of the area.
uint32 PaletteID
The number of the palette.
static const uint MIN_TIMEOUT_DISTANCE
Minimum effective distance for timeout calculation.
static bool HasRailCatenaryDrawn(RailType rt)
Test if we should draw rail catenary.
bool build_on_slopes
allow building on slopes
@ ROTSG_OVERLAY
Optional: Images for overlaying track.
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
@ RTO_X
Piece of rail in X direction.
struct GRFFileProps grf_prop
Properties related to the grf file.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
static IndustryID GetIndustryIndex(TileIndex t)
Get the industry ID of the given tile.
@ CMD_REMOVE_ROAD_STOP
remove a road stop
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
@ TRANSPORT_WATER
Transport over water.
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
@ OWNER_NONE
The tile has no ownership.
@ FOUNDATION_LEVELED
The tile is leveled up to a flat slope.
uint32 rail[RAILTYPE_END]
Count of company owned track bits for each rail type.
void UpdateVirtCoord() override
Update the virtual coords needed to draw the station sign.
static void MakeRoadNormal(TileIndex t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
Make a normal road tile.
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
@ WC_VEHICLE_DEPOT
Depot view; Window numbers:
uint16 classes
Classes of this cargo type.
@ MP_STATION
A tile of a station.
GRFFileProps grf_prop
properties related to the grf file
@ NUM_CARGO
Maximal number of cargo types in a game.
@ GES_ACCEPTANCE
Set when the station accepts the cargo currently for final deliveries.
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
byte time_since_pickup
Number of rating-intervals (up to 255) since the last vehicle tried to load this cargo.
std::string cached_name
NOSAVE: Cache of the resolved name of the station, if not using a custom name.
bool kdtree_valid
Are the sign data valid for use with the _viewport_sign_kdtree?
@ ROAD_Y
Full road along the y-axis (north-west + south-east)
void ForAllStationsAroundTiles(const TileArea &ta, Func func)
Call a function on all stations that have any part of the requested area within their catchment.
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
void UpdateCompanyRoadInfrastructure(RoadType rt, Owner o, int count)
Update road infrastructure counts for a company.
@ RTO_Y
Piece of rail in Y direction.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
StationID GetVia() const
Get a station a package can be routed to.
@ DIAGDIR_BEGIN
Used for iterations.
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
static void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadType road_rt, RoadType tram_rt, DiagDirection d)
Make the given tile a roadstop tile.
StringID name
Name of this class.
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 CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags)
Remove a bus station/truck stop.
BitmapTileArea catchment_tiles
NOSAVE: Set of individual tiles covered by catchment area.
void Merge(LinkGraph *other)
Merge a link graph with another one.
StringID str
Description of the tile.
StationGfx GetTranslatedAirportTileID(StationGfx gfx)
Do airporttile gfx ID translation for NewGRFs.
@ DC_AUTO
don't allow building on structures
TileIndex xy
Base tile of the station.
void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner)
Add track to signal update buffer.
static int GetTileMaxPixelZ(TileIndex tile)
Get top height of the tile.
struct RailtypeInfo::@41 strings
Strings associated with the rail type.
Base class for all station-ish types.
bool HasStationInUse(StationID station, bool include_company, CompanyID company)
Tests whether the company's vehicles have this station in orders.
uint16 triggers
The triggers that trigger animation.
static Pool::IterateWrapper< RoadVehicle > Iterate(size_t from=0)
Returns an iterable ensemble of all valid vehicles of type T.
byte delete_ctr
Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is ...
IndustryLifeType life_type
This is also known as Industry production flag, in newgrf specs.
bool ShouldStopAtStation(const Vehicle *v, StationID station) const
Check whether the given vehicle should stop at the given station based on this order and the non-stop...
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
bool distant_join_stations
allow to join non-adjacent stations
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Build a dock/haven.
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.
StationSpecList * speclist
List of station specs of this station.
uint GetNumHangars() const
Get the number of hangars on this airport.
TrackBits
Bitfield corresponding to Track.
const DrawTileSeqStruct * seq
Array of child sprites. Terminated with a terminator entry.
bool adjacent_stations
allow stations to be built directly adjacent to other stations
uint8 status
Status; 0: no looping, 1: looping, 0xFF: no animation.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
#define lengthof(x)
Return the length of an fixed size array.
uint16 rail_speed
Speed limit of rail (bridges and track)
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
static void Run(Vehicle *v, bool allow_merge=true, bool is_full_loading=false)
Refresh all links the given vehicle will visit.
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
Container for cargo from the same location and time.
uint16 max_speed
Maximum speed for vehicles travelling on this road type.
static bool IsDock(TileIndex t)
Is tile t a dock tile?
static Station * GetIfValid(size_t index)
Returns station if the index is a valid index for this station type.
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
byte type
Type of this airport,.
static bool IsOilRig(TileIndex t)
Is tile t part of an oilrig?
@ NF_SMALL
Small news item. (Information window with text and viewport)
byte CargoID
Cargo slots to indicate a cargo type within a game.
SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint layout, uint edge_info)
Resolve the sprites for custom station foundations.
static bool IsPlainRailTile(TileIndex t)
Checks whether the tile is a rail tile or rail tile with signals.
void DrawRailCatenary(const TileInfo *ti)
Draws overhead wires and pylons for electric railways.
static CargoTypes GetAcceptanceMask(const Station *st)
Get a mask of the cargo types that the station accepts.
static Money RoadBuildCost(RoadType roadtype)
Returns the cost of building the specified roadtype.
@ NT_ACCEPTANCE
A type of cargo is (no longer) accepted.
static bool HasPowerOnRoad(RoadType enginetype, RoadType tiletype)
Checks if an engine of the given RoadType got power on a tile with a given RoadType.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
static bool IsNormalRoadTile(TileIndex t)
Return whether a tile is a normal road tile.
static const uint NEW_AIRPORTTILE_OFFSET
offset of first newgrf airport tile
Axis
Allow incrementing of DiagDirDiff variables.
const DrawTileSeqStruct * GetLayout(PalSpriteID *ground) const
Returns the result spritelayout after preprocessing.
static void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
Make the given tile a rail station tile.
@ VETSB_ENTERED_STATION
The vehicle entered a station.
CargoID cargo_type
type of cargo this vehicle is carrying
uint max_waiting_cargo
Max cargo from this station waiting at any station.
OrthogonalTileArea & Expand(int rad)
Expand a tile area by rad tiles in each direction, keeping within map bounds.
void Append(CargoPacket *cp, StationID next)
Appends the given cargo packet to the range of packets with the same next station.
@ WC_TOWN_VIEW
Town view; Window numbers:
static Owner GetRoadOwner(TileIndex t, RoadTramType rtt)
Get the owner of a specific road type.
StringID owner_type[4]
Type of each owner.
static Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
RoadStop * bus_stops
All the road stops.
@ RVS_IN_DT_ROAD_STOP
The vehicle is in a drive-through road stop.
static const uint ROAD_STOP_TRACKBIT_FACTOR
Multiplier for how many regular track bits a bay stop counts.
static void SetTileOwner(TileIndex tile, Owner owner)
Sets the owner of a tile.
void Unqueue(LinkGraph *lg)
Remove a link graph from the execution queue.
PaletteID pal
The palette (use PAL_NONE) if not needed)
bool IsInUse() const
Check whether the base station currently is in use; in use means that it is not scheduled for deletio...
@ TRACK_BIT_Y
Y-axis track.
TileIndex tile
Tile index.
static bool IsReversingRoadTrackdir(Trackdir dir)
Checks whether the trackdir means that we are reversing.
ConstructionSettings construction
construction of things in-game
SharesMap shares
Shares of flow to be sent via specified station (or consumed locally).
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
Trackdir
Enumeration for tracks and directions.
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
byte nof_depots
the number of hangar tiles in this airport
byte callback_mask
Bitmask of station callbacks that have to be called.
bool selectgoods
only send the goods to station if a train has been there
CommandCost CmdOpenCloseAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Open/close an airport to incoming aircraft.
@ VEH_TRAIN
Train vehicle type.
StringID name
Displayed name of the industry.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
byte disallowed_lengths
Bitmask of platform lengths available for the station.
A Stop for a Road Vehicle.
VehicleType type
Type of vehicle.
uint8 GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance)
Get a possible noise reduction factor based on distance from town center.
virtual void UpdateVirtCoord()=0
Update the coordinated of the sign (as shown in the viewport).
const struct GRFFile * grffile
grf file that introduced this entity
@ FACIL_AIRPORT
Station with an airport.
StringID tramtype
Type of tram on the tile.
static bool IsWater(TileIndex t)
Is it a plain water tile?
@ CBM_STATION_SPRITE_LAYOUT
Use callback to select a sprite layout to use.
StringID name
Tile Subname string, land information on this tile will give you "AirportName (TileSubname)".
void WatchedCargoCallback(TileIndex tile, CargoTypes trigger_cargoes)
Run watched cargo accepted callback for a house.
static bool CanRemoveRoadWithStop(TileIndex tile, DoCommandFlag flags)
Check if a drive-through road stop tile can be cleared.
static void Swap(T &a, T &b)
Type safe swap operation.
PersistentStorage * psa
Persistent storage for NewGRF airports.
Track
These are used to specify a single track.
const AirportSpec * GetSpec() const
Get the AirportSpec that from the airport type of this airport.
static void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
Make the given tile a dock tile.
const AirportTileTable *const * table
list of the tiles composing the airport
@ CT_INVALID
Invalid cargo type.
static bool IsCargoInClass(CargoID c, CargoClass cc)
Does cargo c have cargo class cc?
static void SetAnimationFrame(TileIndex t, byte frame)
Set a new animation frame.
static const AirportTileSpec * Get(StationGfx gfx)
Retrieve airport tile spec for the given airport tile.
void ShowDepotWindow(TileIndex tile, VehicleType type)
Opens a depot window.
@ DIAGDIR_NE
Northeast, upper right on your monitor.
@ VEH_SHIP
Ship vehicle type.
static Point RemapCoords2(int x, int y)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap.
void GetTileArea(TileArea *ta, StationType type) const override
Get the tile area for a given station type.
bool(* CMSAMatcher)(TileIndex tile)
Function to check whether the given tile matches some criterion.
@ AIRPLANES
Can planes land on this airport type?
T * Last()
Get the last vehicle in the chain.
CompanyID exclusivity
which company has exclusivity
GRFFileProps grf_prop
properties related the the grf file
void UpdateAllStationVirtCoords()
Update the virtual coords needed to draw the station sign for all stations.
@ OWNER_WATER
The tile/execution is done by "water".
uint8 exclusive_counter
months till the exclusivity expires
Date build_date
Date of construction.
#define lastof(x)
Get the last element of an fixed size array.
@ WC_STATION_LIST
Station list; Window numbers:
Order * next
Pointer to next order. If nullptr, end of list.
void ShowWaypointWindow(const Waypoint *wp)
Show the window for the given waypoint.
@ CBID_STATION_SPRITE_LAYOUT
Choose a sprite layout to draw, instead of the standard 0-7 range.
static Station * GetClosestDeletedStation(TileIndex tile)
Find the closest deleted station of the current company.
static CommandCost FindJoiningStation(StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, Station **st)
Find a nearby station that joins this station.
@ GES_RATING
This indicates whether a cargo has a rating at the station.
bool HasVehicleEverTriedLoading() const
Reports whether a vehicle has ever tried to load the cargo at this station.
uint Truncate(uint max_move=UINT_MAX, StationCargoAmountMap *cargo_per_source=nullptr)
Truncates where each destination loses roughly the same percentage of its cargo.
#define FOR_EACH_SET_BIT(bitpos_var, bitset_value)
Do an operation for each set set bit in a value.
TileArea ship_station
Tile area the ship 'station' part covers.
uint GetRailtypeSpriteOffset() const
Offset between the current railtype and normal rail.
void ChangeShare(StationID st, int flow)
Change share for specified station.
VehicleEnterTileStatus
The returned bits of VehicleEnterTile.
@ CMD_LANDSCAPE_CLEAR
demolish a tile
GRFConfig * GetGRFConfig(uint32 grfid, uint32 mask)
Retrieve a NewGRF from the current config by its grfid.
@ FLYING
Vehicle is flying in the air.
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
uint8 FindFirstBit(uint32 x)
Search the first set bit in a 32 bit variable.
static TileIndex FindDockLandPart(TileIndex t)
Find the part of a dock that is land-based.
bool road_stop_on_town_road
allow building of drive-through road stops on town owned roads
uint GetFlowFromVia(StationID from, StationID via) const
Get the flow from a specific station via a specific other station.
virtual TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
void DrawGroundSprite(SpriteID image, PaletteID pal, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
Draws a ground sprite for the current tile.
@ AT_OILRIG
Oilrig airport.
@ RVSB_ROAD_STOP_TRACKDIR_MASK
Only bits 0 and 3 are used to encode the trackdir for road stops.
GUISettings gui
settings related to the GUI
Train * GetTrainForReservation(TileIndex tile, Track track)
Find the train which has reserved a specific path.
uint16 refit_cap
Capacity left over from before last refit.
static bool MayHaveRoad(TileIndex t)
Test whether a tile can have road/tram types.
static DiagDirection GetInclinedSlopeDirection(Slope s)
Returns the direction of an inclined slope.
const char * GetName() const
Get the name of this grf.
@ GES_LAST_MONTH
Set when cargo was delivered for final delivery last month.
void UpdateStationAcceptance(Station *st, bool show_msg)
Update the acceptance for a station.
static bool IsHangarTile(TileIndex t)
Is tile t an hangar tile?
AnimationInfo animation
Information about the animation.
CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Build a bus or truck stop.
static bool IsBridgeAbove(TileIndex t)
checks if a bridge is set above the ground of this tile
void AddAnimatedTile(TileIndex tile)
Add the given tile to the animated tile table (if it does not exist on that table yet).
@ INVALID_RAILTYPE
Flag for invalid railtype.
#define AllocaM(T, num_elements)
alloca() has to be called in the parent function, so define AllocaM() as a macro
uint16 road_speed
Speed limit of road (bridges and track)
@ INDUSTRYLIFE_EXTRACTIVE
Like mines.