OpenTTD Source  12.0-beta2
station_sl.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "../stdafx.h"
11 
12 #include "saveload.h"
14 
15 #include "../station_base.h"
16 #include "../waypoint_base.h"
17 #include "../roadstop_base.h"
18 #include "../vehicle_base.h"
19 #include "../newgrf_station.h"
20 
21 #include "table/strings.h"
22 
23 #include "../safeguards.h"
24 
29 static void UpdateWaypointOrder(Order *o)
30 {
31  if (!o->IsType(OT_GOTO_STATION)) return;
32 
33  const Station *st = Station::Get(o->GetDestination());
34  if ((st->had_vehicle_of_type & HVOT_WAYPOINT) == 0) return;
35 
37 }
38 
44 {
45  /* Buoy orders become waypoint orders */
46  for (OrderList *ol : OrderList::Iterate()) {
47  VehicleType vt = ol->GetFirstSharedVehicle()->type;
48  if (vt != VEH_SHIP && vt != VEH_TRAIN) continue;
49 
50  for (Order *o = ol->GetFirstOrder(); o != nullptr; o = o->next) UpdateWaypointOrder(o);
51  }
52 
53  for (Vehicle *v : Vehicle::Iterate()) {
54  VehicleType vt = v->type;
55  if (vt != VEH_SHIP && vt != VEH_TRAIN) continue;
56 
57  UpdateWaypointOrder(&v->current_order);
58  }
59 
60  /* Now make the stations waypoints */
61  for (Station *st : Station::Iterate()) {
62  if ((st->had_vehicle_of_type & HVOT_WAYPOINT) == 0) continue;
63 
64  StationID index = st->index;
65  TileIndex xy = st->xy;
66  Town *town = st->town;
67  StringID string_id = st->string_id;
68  std::string name = st->name;
69  Date build_date = st->build_date;
70  /* TTDPatch could use "buoys with rail station" for rail waypoints */
71  bool train = st->train_station.tile != INVALID_TILE;
72  TileArea train_st = st->train_station;
73 
74  /* Delete the station, so we can make it a real waypoint. */
75  delete st;
76 
77  /* Stations and waypoints are in the same pool, so if a station
78  * is deleted there must be place for a Waypoint. */
79  assert(Waypoint::CanAllocateItem());
80  Waypoint *wp = new (index) Waypoint(xy);
81  wp->town = town;
82  wp->string_id = train ? STR_SV_STNAME_WAYPOINT : STR_SV_STNAME_BUOY;
83  wp->name = name;
84  wp->delete_ctr = 0; // Just reset delete counter for once.
85  wp->build_date = build_date;
86  wp->owner = train ? GetTileOwner(xy) : OWNER_NONE;
87 
88  if (IsInsideBS(string_id, STR_SV_STNAME_BUOY, 9)) wp->town_cn = string_id - STR_SV_STNAME_BUOY;
89 
90  if (train) {
91  /* When we make a rail waypoint of the station, convert the map as well. */
92  for (TileIndex t : train_st) {
93  if (!IsTileType(t, MP_STATION) || GetStationIndex(t) != index) continue;
94 
95  SB(_me[t].m6, 3, 3, STATION_WAYPOINT);
96  wp->rect.BeforeAddTile(t, StationRect::ADD_FORCE);
97  }
98 
99  wp->train_station = train_st;
100  wp->facilities |= FACIL_TRAIN;
101  } else if (IsBuoyTile(xy) && GetStationIndex(xy) == index) {
102  wp->rect.BeforeAddTile(xy, StationRect::ADD_FORCE);
103  wp->facilities |= FACIL_DOCK;
104  }
105  }
106 }
107 
108 void AfterLoadStations()
109 {
110  /* Update the speclists of all stations to point to the currently loaded custom stations. */
111  for (BaseStation *st : BaseStation::Iterate()) {
112  for (uint i = 0; i < st->num_specs; i++) {
113  if (st->speclist[i].grfid == 0) continue;
114 
115  st->speclist[i].spec = StationClass::GetByGrf(st->speclist[i].grfid, st->speclist[i].localidx, nullptr);
116  }
117 
118  if (Station::IsExpected(st)) {
119  Station *sta = Station::From(st);
120  for (const RoadStop *rs = sta->bus_stops; rs != nullptr; rs = rs->next) sta->bus_station.Add(rs->xy);
121  for (const RoadStop *rs = sta->truck_stops; rs != nullptr; rs = rs->next) sta->truck_station.Add(rs->xy);
122  }
123 
125  }
126 }
127 
132 {
133  /* First construct the drive through entries */
134  for (RoadStop *rs : RoadStop::Iterate()) {
135  if (IsDriveThroughStopTile(rs->xy)) rs->MakeDriveThrough();
136  }
137  /* And then rebuild the data in those entries */
138  for (RoadStop *rs : RoadStop::Iterate()) {
139  if (!HasBit(rs->status, RoadStop::RSSFB_BASE_ENTRY)) continue;
140 
141  rs->GetEntry(DIAGDIR_NE)->Rebuild(rs);
142  rs->GetEntry(DIAGDIR_NW)->Rebuild(rs);
143  }
144 }
145 
146 static const SaveLoad _roadstop_desc[] = {
147  SLE_VAR(RoadStop, xy, SLE_UINT32),
148  SLE_VAR(RoadStop, status, SLE_UINT8),
150 };
151 
152 static uint16 _waiting_acceptance;
153 static uint32 _old_num_flows;
154 static uint16 _cargo_source;
155 static uint32 _cargo_source_xy;
156 static uint8 _cargo_days;
157 static Money _cargo_feeder_share;
158 
159 std::list<CargoPacket *> _packets;
160 uint32 _old_num_dests;
161 
162 struct FlowSaveLoad {
163  FlowSaveLoad() : source(0), via(0), share(0), restricted(false) {}
164  StationID source;
165  StationID via;
166  uint32 share;
167  bool restricted;
168 };
169 
170 typedef std::pair<const StationID, std::list<CargoPacket *> > StationCargoPair;
171 
172 static OldPersistentStorage _old_st_persistent_storage;
173 
179 static void SwapPackets(GoodsEntry *ge)
180 {
181  StationCargoPacketMap &ge_packets = const_cast<StationCargoPacketMap &>(*ge->cargo.Packets());
182 
183  if (_packets.empty()) {
184  std::map<StationID, std::list<CargoPacket *> >::iterator it(ge_packets.find(INVALID_STATION));
185  if (it == ge_packets.end()) {
186  return;
187  } else {
188  it->second.swap(_packets);
189  }
190  } else {
191  assert(ge_packets[INVALID_STATION].empty());
192  ge_packets[INVALID_STATION].swap(_packets);
193  }
194 }
195 
196 class SlStationSpecList : public DefaultSaveLoadHandler<SlStationSpecList, BaseStation> {
197 public:
198  inline static const SaveLoad description[] = {
199  SLE_CONDVAR(StationSpecList, grfid, SLE_UINT32, SLV_27, SL_MAX_VERSION),
200  SLE_CONDVAR(StationSpecList, localidx, SLE_UINT8, SLV_27, SL_MAX_VERSION),
201  };
202  inline const static SaveLoadCompatTable compat_description = _station_spec_list_sl_compat;
203 
204  void Save(BaseStation *bst) const override
205  {
207  for (uint i = 0; i < bst->num_specs; i++) {
208  SlObject(&bst->speclist[i], this->GetDescription());
209  }
210  }
211 
212  void Load(BaseStation *bst) const override
213  {
215  bst->num_specs = (uint8)SlGetStructListLength(UINT8_MAX);
216  }
217 
218  if (bst->num_specs != 0) {
219  /* Allocate speclist memory when loading a game */
220  bst->speclist = CallocT<StationSpecList>(bst->num_specs);
221  for (uint i = 0; i < bst->num_specs; i++) {
222  SlObject(&bst->speclist[i], this->GetLoadDescription());
223  }
224  }
225  }
226 };
227 
228 class SlStationCargo : public DefaultSaveLoadHandler<SlStationCargo, GoodsEntry> {
229 public:
230  inline static const SaveLoad description[] = {
231  SLE_VAR(StationCargoPair, first, SLE_UINT16),
232  SLE_REFLIST(StationCargoPair, second, REF_CARGO_PACKET),
233  };
234  inline const static SaveLoadCompatTable compat_description = _station_cargo_sl_compat;
235 
236  void Save(GoodsEntry *ge) const override
237  {
239  for (StationCargoPacketMap::ConstMapIterator it(ge->cargo.Packets()->begin()); it != ge->cargo.Packets()->end(); ++it) {
240  SlObject(const_cast<StationCargoPacketMap::value_type *>(&(*it)), this->GetDescription());
241  }
242  }
243 
244  void Load(GoodsEntry *ge) const override
245  {
246  size_t num_dests = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? _old_num_dests : SlGetStructListLength(UINT32_MAX);
247 
248  StationCargoPair pair;
249  for (uint j = 0; j < num_dests; ++j) {
250  SlObject(&pair, this->GetLoadDescription());
251  const_cast<StationCargoPacketMap &>(*(ge->cargo.Packets()))[pair.first].swap(pair.second);
252  assert(pair.second.empty());
253  }
254  }
255 
256  void FixPointers(GoodsEntry *ge) const override
257  {
258  for (StationCargoPacketMap::ConstMapIterator it = ge->cargo.Packets()->begin(); it != ge->cargo.Packets()->end(); ++it) {
259  SlObject(const_cast<StationCargoPair *>(&(*it)), this->GetDescription());
260  }
261  }
262 };
263 
264 class SlStationFlow : public DefaultSaveLoadHandler<SlStationFlow, GoodsEntry> {
265 public:
266  inline static const SaveLoad description[] = {
267  SLE_VAR(FlowSaveLoad, source, SLE_UINT16),
268  SLE_VAR(FlowSaveLoad, via, SLE_UINT16),
269  SLE_VAR(FlowSaveLoad, share, SLE_UINT32),
270  SLE_CONDVAR(FlowSaveLoad, restricted, SLE_BOOL, SLV_187, SL_MAX_VERSION),
271  };
272  inline const static SaveLoadCompatTable compat_description = _station_flow_sl_compat;
273 
274  void Save(GoodsEntry *ge) const override
275  {
276  uint32 num_flows = 0;
277  for (FlowStatMap::const_iterator it(ge->flows.begin()); it != ge->flows.end(); ++it) {
278  num_flows += (uint32)it->second.GetShares()->size();
279  }
280  SlSetStructListLength(num_flows);
281 
282  for (FlowStatMap::const_iterator outer_it(ge->flows.begin()); outer_it != ge->flows.end(); ++outer_it) {
283  const FlowStat::SharesMap *shares = outer_it->second.GetShares();
284  uint32 sum_shares = 0;
285  FlowSaveLoad flow;
286  flow.source = outer_it->first;
287  for (FlowStat::SharesMap::const_iterator inner_it(shares->begin()); inner_it != shares->end(); ++inner_it) {
288  flow.via = inner_it->second;
289  flow.share = inner_it->first - sum_shares;
290  flow.restricted = inner_it->first > outer_it->second.GetUnrestricted();
291  sum_shares = inner_it->first;
292  assert(flow.share > 0);
293  SlObject(&flow, this->GetDescription());
294  }
295  }
296  }
297 
298  void Load(GoodsEntry *ge) const override
299  {
300  size_t num_flows = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? _old_num_flows : SlGetStructListLength(UINT32_MAX);
301 
302  FlowSaveLoad flow;
303  FlowStat *fs = nullptr;
304  StationID prev_source = INVALID_STATION;
305  for (uint32 j = 0; j < num_flows; ++j) {
306  SlObject(&flow, this->GetLoadDescription());
307  if (fs == nullptr || prev_source != flow.source) {
308  fs = &(ge->flows.insert(std::make_pair(flow.source, FlowStat(flow.via, flow.share, flow.restricted))).first->second);
309  } else {
310  fs->AppendShare(flow.via, flow.share, flow.restricted);
311  }
312  prev_source = flow.source;
313  }
314  }
315 };
316 
317 class SlStationGoods : public DefaultSaveLoadHandler<SlStationGoods, BaseStation> {
318 public:
319 #if defined(_MSC_VER) && (_MSC_VER == 1915 || _MSC_VER == 1916)
320  /* This table access private members of other classes; they have this
321  * class as friend. For MSVC CL 19.15 and 19.16 this doesn't work for
322  * "inline static const", so we are forced to wrap the table in a
323  * function. CL 19.16 is the latest for VS2017. */
324  inline static const SaveLoad description[] = {{}};
325  SaveLoadTable GetDescription() const override {
326 #else
327  inline
328 #endif
329  static const SaveLoad description[] = {
330  SLEG_CONDVAR("waiting_acceptance", _waiting_acceptance, SLE_UINT16, SL_MIN_VERSION, SLV_68),
331  SLE_CONDVAR(GoodsEntry, status, SLE_UINT8, SLV_68, SL_MAX_VERSION),
332  SLE_VAR(GoodsEntry, time_since_pickup, SLE_UINT8),
333  SLE_VAR(GoodsEntry, rating, SLE_UINT8),
334  SLEG_CONDVAR("cargo_source", _cargo_source, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_7),
335  SLEG_CONDVAR("cargo_source", _cargo_source, SLE_UINT16, SLV_7, SLV_68),
336  SLEG_CONDVAR("cargo_source_xy", _cargo_source_xy, SLE_UINT32, SLV_44, SLV_68),
337  SLEG_CONDVAR("cargo_days", _cargo_days, SLE_UINT8, SL_MIN_VERSION, SLV_68),
338  SLE_VAR(GoodsEntry, last_speed, SLE_UINT8),
339  SLE_VAR(GoodsEntry, last_age, SLE_UINT8),
340  SLEG_CONDVAR("cargo_feeder_share", _cargo_feeder_share, SLE_FILE_U32 | SLE_VAR_I64, SLV_14, SLV_65),
341  SLEG_CONDVAR("cargo_feeder_share", _cargo_feeder_share, SLE_INT64, SLV_65, SLV_68),
342  SLE_CONDVAR(GoodsEntry, amount_fract, SLE_UINT8, SLV_150, SL_MAX_VERSION),
343  SLEG_CONDREFLIST("packets", _packets, REF_CARGO_PACKET, SLV_68, SLV_183),
344  SLEG_CONDVAR("old_num_dests", _old_num_dests, SLE_UINT32, SLV_183, SLV_SAVELOAD_LIST_LENGTH),
345  SLE_CONDVAR(GoodsEntry, cargo.reserved_count, SLE_UINT, SLV_181, SL_MAX_VERSION),
346  SLE_CONDVAR(GoodsEntry, link_graph, SLE_UINT16, SLV_183, SL_MAX_VERSION),
347  SLE_CONDVAR(GoodsEntry, node, SLE_UINT16, SLV_183, SL_MAX_VERSION),
348  SLEG_CONDVAR("old_num_flows", _old_num_flows, SLE_UINT32, SLV_183, SLV_SAVELOAD_LIST_LENGTH),
349  SLE_CONDVAR(GoodsEntry, max_waiting_cargo, SLE_UINT32, SLV_183, SL_MAX_VERSION),
352  };
353 #if defined(_MSC_VER) && (_MSC_VER == 1915 || _MSC_VER == 1916)
354  return description;
355  }
356 #endif
357  inline const static SaveLoadCompatTable compat_description = _station_goods_sl_compat;
358 
363  size_t GetNumCargo() const
364  {
365  if (IsSavegameVersionBefore(SLV_55)) return 12;
368  /* Read from the savegame how long the list is. */
370  }
371 
372  void Save(BaseStation *bst) const override
373  {
374  Station *st = Station::From(bst);
375 
377 
378  for (CargoID i = 0; i < NUM_CARGO; i++) {
379  SlObject(&st->goods[i], this->GetDescription());
380  }
381  }
382 
383  void Load(BaseStation *bst) const override
384  {
385  Station *st = Station::From(bst);
386 
387  /* Before savegame version 161, persistent storages were not stored in a pool. */
389  /* Store the old persistent storage. The GRFID will be added later. */
391  st->airport.psa = new PersistentStorage(0, 0, 0);
392  memcpy(st->airport.psa->storage, _old_st_persistent_storage.storage, sizeof(_old_st_persistent_storage.storage));
393  }
394 
395  size_t num_cargo = this->GetNumCargo();
396  for (CargoID i = 0; i < num_cargo; i++) {
397  GoodsEntry *ge = &st->goods[i];
398  SlObject(ge, this->GetLoadDescription());
400  SwapPackets(ge);
401  }
403  SB(ge->status, GoodsEntry::GES_ACCEPTANCE, 1, HasBit(_waiting_acceptance, 15));
404  if (GB(_waiting_acceptance, 0, 12) != 0) {
405  /* In old versions, enroute_from used 0xFF as INVALID_STATION */
406  StationID source = (IsSavegameVersionBefore(SLV_7) && _cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
407 
408  /* Make sure we can allocate the CargoPacket. This is safe
409  * as there can only be ~64k stations and 32 cargoes in these
410  * savegame versions. As the CargoPacketPool has more than
411  * 16 million entries; it fits by an order of magnitude. */
413 
414  /* Don't construct the packet with station here, because that'll fail with old savegames */
415  CargoPacket *cp = new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_days, source, _cargo_source_xy, _cargo_source_xy, _cargo_feeder_share);
416  ge->cargo.Append(cp, INVALID_STATION);
417  SB(ge->status, GoodsEntry::GES_RATING, 1, 1);
418  }
419  }
420  }
421  }
422 
423  void FixPointers(BaseStation *bst) const override
424  {
425  Station *st = Station::From(bst);
426 
428  for (CargoID i = 0; i < num_cargo; i++) {
429  GoodsEntry *ge = &st->goods[i];
431  SwapPackets(ge); // We have to swap back again to be in the format pre-183 expects.
432  SlObject(ge, this->GetDescription());
433  SwapPackets(ge);
434  } else {
435  SlObject(ge, this->GetDescription());
436  }
437  }
438  }
439 };
440 
441 static const SaveLoad _old_station_desc[] = {
442  SLE_CONDVAR(Station, xy, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6),
443  SLE_CONDVAR(Station, xy, SLE_UINT32, SLV_6, SL_MAX_VERSION),
444  SLE_CONDVAR(Station, train_station.tile, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6),
445  SLE_CONDVAR(Station, train_station.tile, SLE_UINT32, SLV_6, SL_MAX_VERSION),
446  SLE_CONDVAR(Station, airport.tile, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6),
447  SLE_CONDVAR(Station, airport.tile, SLE_UINT32, SLV_6, SL_MAX_VERSION),
448  SLE_REF(Station, town, REF_TOWN),
449  SLE_VAR(Station, train_station.w, SLE_FILE_U8 | SLE_VAR_U16),
450  SLE_CONDVAR(Station, train_station.h, SLE_FILE_U8 | SLE_VAR_U16, SLV_2, SL_MAX_VERSION),
451 
452  SLE_VAR(Station, string_id, SLE_STRINGID),
454  SLE_CONDVAR(Station, indtype, SLE_UINT8, SLV_103, SL_MAX_VERSION),
455  SLE_CONDVAR(Station, had_vehicle_of_type, SLE_FILE_U16 | SLE_VAR_U8, SL_MIN_VERSION, SLV_122),
456  SLE_CONDVAR(Station, had_vehicle_of_type, SLE_UINT8, SLV_122, SL_MAX_VERSION),
457 
458  SLE_VAR(Station, time_since_load, SLE_UINT8),
459  SLE_VAR(Station, time_since_unload, SLE_UINT8),
460  SLE_VAR(Station, delete_ctr, SLE_UINT8),
461  SLE_VAR(Station, owner, SLE_UINT8),
462  SLE_VAR(Station, facilities, SLE_UINT8),
463  SLE_VAR(Station, airport.type, SLE_UINT8),
464  SLE_CONDVAR(Station, airport.flags, SLE_VAR_U64 | SLE_FILE_U16, SL_MIN_VERSION, SLV_3),
465  SLE_CONDVAR(Station, airport.flags, SLE_VAR_U64 | SLE_FILE_U32, SLV_3, SLV_46),
466  SLE_CONDVAR(Station, airport.flags, SLE_UINT64, SLV_46, SL_MAX_VERSION),
467 
468  SLE_CONDVAR(Station, last_vehicle_type, SLE_UINT8, SLV_26, SL_MAX_VERSION),
469 
470  SLE_CONDVAR(Station, build_date, SLE_FILE_U16 | SLE_VAR_I32, SLV_3, SLV_31),
471  SLE_CONDVAR(Station, build_date, SLE_INT32, SLV_31, SL_MAX_VERSION),
472 
475 
476  /* Used by newstations for graphic variations */
477  SLE_CONDVAR(Station, random_bits, SLE_UINT16, SLV_27, SL_MAX_VERSION),
478  SLE_CONDVAR(Station, waiting_triggers, SLE_UINT8, SLV_27, SL_MAX_VERSION),
479  SLE_CONDVAR(Station, num_specs, SLE_UINT8, SLV_27, SL_MAX_VERSION),
480 
482 
485 };
486 
489 
490  void Load() const override
491  {
492  const std::vector<SaveLoad> slt = SlCompatTableHeader(_old_station_desc, _old_station_sl_compat);
493 
494  _cargo_source_xy = 0;
495  _cargo_days = 0;
496  _cargo_feeder_share = 0;
497 
498  int index;
499  while ((index = SlIterateArray()) != -1) {
500  Station *st = new (index) Station();
501 
502  _waiting_acceptance = 0;
503  SlObject(st, slt);
504  }
505  }
506 
507  void FixPointers() const override
508  {
509  /* From SLV_123 we store stations in STNN; before that in STNS. So do not
510  * fix pointers when the version is SLV_123 or up, as that would fix
511  * pointers twice: once in STNN chunk and once here. */
512  if (!IsSavegameVersionBefore(SLV_123)) return;
513 
514  for (Station *st : Station::Iterate()) {
515  SlObject(st, _old_station_desc);
516  }
517  }
518 };
519 
524 class SlStationBase : public DefaultSaveLoadHandler<SlStationBase, BaseStation> {
525 public:
526  inline static const SaveLoad description[] = {
527  SLE_VAR(BaseStation, xy, SLE_UINT32),
528  SLE_REF(BaseStation, town, REF_TOWN),
529  SLE_VAR(BaseStation, string_id, SLE_STRINGID),
531  SLE_VAR(BaseStation, delete_ctr, SLE_UINT8),
532  SLE_VAR(BaseStation, owner, SLE_UINT8),
533  SLE_VAR(BaseStation, facilities, SLE_UINT8),
534  SLE_VAR(BaseStation, build_date, SLE_INT32),
535 
536  /* Used by newstations for graphic variations */
537  SLE_VAR(BaseStation, random_bits, SLE_UINT16),
538  SLE_VAR(BaseStation, waiting_triggers, SLE_UINT8),
540  };
541  inline const static SaveLoadCompatTable compat_description = _station_base_sl_compat;
542 
543  void Save(BaseStation *bst) const override
544  {
545  SlObject(bst, this->GetDescription());
546  }
547 
548  void Load(BaseStation *bst) const override
549  {
550  SlObject(bst, this->GetLoadDescription());
551  }
552 
553  void FixPointers(BaseStation *bst) const override
554  {
555  SlObject(bst, this->GetDescription());
556  }
557 };
558 
562 class SlStationNormal : public DefaultSaveLoadHandler<SlStationNormal, BaseStation> {
563 public:
564  inline static const SaveLoad description[] = {
565  SLEG_STRUCT("base", SlStationBase),
566  SLE_VAR(Station, train_station.tile, SLE_UINT32),
567  SLE_VAR(Station, train_station.w, SLE_FILE_U8 | SLE_VAR_U16),
568  SLE_VAR(Station, train_station.h, SLE_FILE_U8 | SLE_VAR_U16),
569 
570  SLE_REF(Station, bus_stops, REF_ROADSTOPS),
571  SLE_REF(Station, truck_stops, REF_ROADSTOPS),
572  SLE_CONDVAR(Station, ship_station.tile, SLE_UINT32, SLV_MULTITILE_DOCKS, SL_MAX_VERSION),
573  SLE_CONDVAR(Station, ship_station.w, SLE_FILE_U8 | SLE_VAR_U16, SLV_MULTITILE_DOCKS, SL_MAX_VERSION),
574  SLE_CONDVAR(Station, ship_station.h, SLE_FILE_U8 | SLE_VAR_U16, SLV_MULTITILE_DOCKS, SL_MAX_VERSION),
575  SLE_CONDVAR(Station, docking_station.tile, SLE_UINT32, SLV_MULTITILE_DOCKS, SL_MAX_VERSION),
576  SLE_CONDVAR(Station, docking_station.w, SLE_FILE_U8 | SLE_VAR_U16, SLV_MULTITILE_DOCKS, SL_MAX_VERSION),
577  SLE_CONDVAR(Station, docking_station.h, SLE_FILE_U8 | SLE_VAR_U16, SLV_MULTITILE_DOCKS, SL_MAX_VERSION),
578  SLE_VAR(Station, airport.tile, SLE_UINT32),
579  SLE_CONDVAR(Station, airport.w, SLE_FILE_U8 | SLE_VAR_U16, SLV_140, SL_MAX_VERSION),
580  SLE_CONDVAR(Station, airport.h, SLE_FILE_U8 | SLE_VAR_U16, SLV_140, SL_MAX_VERSION),
581  SLE_VAR(Station, airport.type, SLE_UINT8),
582  SLE_CONDVAR(Station, airport.layout, SLE_UINT8, SLV_145, SL_MAX_VERSION),
583  SLE_VAR(Station, airport.flags, SLE_UINT64),
584  SLE_CONDVAR(Station, airport.rotation, SLE_UINT8, SLV_145, SL_MAX_VERSION),
585  SLEG_CONDARR("storage", _old_st_persistent_storage.storage, SLE_UINT32, 16, SLV_145, SLV_161),
587 
588  SLE_VAR(Station, indtype, SLE_UINT8),
589 
590  SLE_VAR(Station, time_since_load, SLE_UINT8),
591  SLE_VAR(Station, time_since_unload, SLE_UINT8),
592  SLE_VAR(Station, last_vehicle_type, SLE_UINT8),
593  SLE_VAR(Station, had_vehicle_of_type, SLE_UINT8),
594  SLE_REFLIST(Station, loading_vehicles, REF_VEHICLE),
595  SLE_CONDVAR(Station, always_accepted, SLE_FILE_U32 | SLE_VAR_U64, SLV_127, SLV_EXTEND_CARGOTYPES),
596  SLE_CONDVAR(Station, always_accepted, SLE_UINT64, SLV_EXTEND_CARGOTYPES, SL_MAX_VERSION),
598  };
599  inline const static SaveLoadCompatTable compat_description = _station_normal_sl_compat;
600 
601  void Save(BaseStation *bst) const
602  {
603  if ((bst->facilities & FACIL_WAYPOINT) != 0) return;
604  SlObject(bst, this->GetDescription());
605  }
606 
607  void Load(BaseStation *bst) const
608  {
609  if ((bst->facilities & FACIL_WAYPOINT) != 0) return;
610  SlObject(bst, this->GetLoadDescription());
611  }
612 
613  void FixPointers(BaseStation *bst) const
614  {
615  if ((bst->facilities & FACIL_WAYPOINT) != 0) return;
616  SlObject(bst, this->GetDescription());
617  }
618 };
619 
620 class SlStationWaypoint : public DefaultSaveLoadHandler<SlStationWaypoint, BaseStation> {
621 public:
622  inline static const SaveLoad description[] = {
623  SLEG_STRUCT("base", SlStationBase),
624  SLE_VAR(Waypoint, town_cn, SLE_UINT16),
625 
626  SLE_CONDVAR(Waypoint, train_station.tile, SLE_UINT32, SLV_124, SL_MAX_VERSION),
627  SLE_CONDVAR(Waypoint, train_station.w, SLE_FILE_U8 | SLE_VAR_U16, SLV_124, SL_MAX_VERSION),
628  SLE_CONDVAR(Waypoint, train_station.h, SLE_FILE_U8 | SLE_VAR_U16, SLV_124, SL_MAX_VERSION),
629  };
630  inline const static SaveLoadCompatTable compat_description = _station_waypoint_sl_compat;
631 
632  void Save(BaseStation *bst) const
633  {
634  if ((bst->facilities & FACIL_WAYPOINT) == 0) return;
635  SlObject(bst, this->GetDescription());
636  }
637 
638  void Load(BaseStation *bst) const
639  {
640  if ((bst->facilities & FACIL_WAYPOINT) == 0) return;
641  SlObject(bst, this->GetLoadDescription());
642  }
643 
644  void FixPointers(BaseStation *bst) const
645  {
646  if ((bst->facilities & FACIL_WAYPOINT) == 0) return;
647  SlObject(bst, this->GetDescription());
648  }
649 };
650 
651 static const SaveLoad _station_desc[] = {
652  SLE_SAVEBYTE(BaseStation, facilities),
653  SLEG_STRUCT("normal", SlStationNormal),
654  SLEG_STRUCT("waypoint", SlStationWaypoint),
656 };
657 
659  STNNChunkHandler() : ChunkHandler('STNN', CH_TABLE) {}
660 
661  void Save() const override
662  {
663  SlTableHeader(_station_desc);
664 
665  /* Write the stations */
666  for (BaseStation *st : BaseStation::Iterate()) {
667  SlSetArrayIndex(st->index);
668  SlObject(st, _station_desc);
669  }
670  }
671 
672 
673  void Load() const override
674  {
675  const std::vector<SaveLoad> slt = SlCompatTableHeader(_station_desc, _station_sl_compat);
676 
677  _old_num_flows = 0;
678 
679  int index;
680  while ((index = SlIterateArray()) != -1) {
681  bool waypoint = (SlReadByte() & FACIL_WAYPOINT) != 0;
682 
683  BaseStation *bst = waypoint ? (BaseStation *)new (index) Waypoint() : new (index) Station();
684  SlObject(bst, slt);
685  }
686  }
687 
688  void FixPointers() const override
689  {
690  /* From SLV_123 we store stations in STNN; before that in STNS. So do not
691  * fix pointers when the version is below SLV_123, as that would fix
692  * pointers twice: once in STNS chunk and once here. */
693  if (IsSavegameVersionBefore(SLV_123)) return;
694 
695  for (BaseStation *bst : BaseStation::Iterate()) {
696  SlObject(bst, _station_desc);
697  }
698  }
699 };
700 
702  ROADChunkHandler() : ChunkHandler('ROAD', CH_TABLE) {}
703 
704  void Save() const override
705  {
706  SlTableHeader(_roadstop_desc);
707 
708  for (RoadStop *rs : RoadStop::Iterate()) {
709  SlSetArrayIndex(rs->index);
710  SlObject(rs, _roadstop_desc);
711  }
712  }
713 
714  void Load() const override
715  {
716  const std::vector<SaveLoad> slt = SlCompatTableHeader(_roadstop_desc, _roadstop_sl_compat);
717 
718  int index;
719 
720  while ((index = SlIterateArray()) != -1) {
721  RoadStop *rs = new (index) RoadStop(INVALID_TILE);
722 
723  SlObject(rs, slt);
724  }
725  }
726 
727  void FixPointers() const override
728  {
729  for (RoadStop *rs : RoadStop::Iterate()) {
730  SlObject(rs, _roadstop_desc);
731  }
732  }
733 };
734 
735 static const STNSChunkHandler STNS;
736 static const STNNChunkHandler STNN;
737 static const ROADChunkHandler ROAD;
738 static const ChunkHandlerRef station_chunk_handlers[] = {
739  STNS,
740  STNN,
741  ROAD,
742 };
743 
744 extern const ChunkHandlerTable _station_chunk_handlers(station_chunk_handlers);
SLV_187
@ SLV_187
187 25899 Linkgraph - restricted flows
Definition: saveload.h:271
SLEG_CONDSTRUCTLIST
#define SLEG_CONDSTRUCTLIST(name, handler, from, to)
Storage of a list of structs in some savegame versions.
Definition: saveload.h:929
BaseStation::facilities
StationFacility facilities
The facilities that this station has.
Definition: base_station_base.h:63
SLV_65
@ SLV_65
65 10210
Definition: saveload.h:125
_station_base_sl_compat
const SaveLoadCompat _station_base_sl_compat[]
Original field order for SlStationBase.
Definition: station_sl_compat.h:75
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
Station::goods
GoodsEntry goods[NUM_CARGO]
Goods at this station.
Definition: station_base.h:476
DefaultSaveLoadHandler
Default handler for saving/loading an object to/from disk.
Definition: saveload.h:515
Order::IsType
bool IsType(OrderType type) const
Check whether this order is of the given type.
Definition: order_base.h:64
SLE_REFLIST
#define SLE_REFLIST(base, variable, type)
Storage of a list of SL_REF elements in every savegame version.
Definition: saveload.h:814
SlStationGoods::GetNumCargo
size_t GetNumCargo() const
Get the number of cargoes used by this savegame version.
Definition: station_sl.cpp:363
GB
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
UpdateWaypointOrder
static void UpdateWaypointOrder(Order *o)
Update the buoy orders to be waypoint orders.
Definition: station_sl.cpp:29
SL_MIN_VERSION
@ SL_MIN_VERSION
First savegame version.
Definition: saveload.h:35
REF_TOWN
@ REF_TOWN
Load/save a reference to a town.
Definition: saveload.h:538
REF_ROADSTOPS
@ REF_ROADSTOPS
Load/save a reference to a bus/truck stop.
Definition: saveload.h:540
CargoList::Packets
const Tcont * Packets() const
Returns a pointer to the cargo packet list (so you can iterate over it etc).
Definition: cargopacket.h:247
SLE_CONDSSTR
#define SLE_CONDSSTR(base, variable, type, from, to)
Storage of a std::string in some savegame versions.
Definition: saveload.h:744
SlStationBase
SaveLoad handler for the BaseStation, which all other stations / waypoints make use of.
Definition: station_sl.cpp:524
BaseStation::town
Town * town
The town this station is associated with.
Definition: base_station_base.h:61
Station
Station data structure.
Definition: station_base.h:447
Order::GetDestination
DestinationID GetDestination() const
Gets the destination of this order.
Definition: order_base.h:97
SLV_124
@ SLV_124
124 16993
Definition: saveload.h:195
ChunkHandlerRef
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
Definition: saveload.h:443
StationSpecList
Definition: base_station_base.h:21
ROADChunkHandler::Load
void Load() const override
Load the chunk.
Definition: station_sl.cpp:714
Waypoint::town_cn
uint16 town_cn
The N-1th waypoint for this town (consecutive number)
Definition: waypoint_base.h:17
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:235
SLE_CONDVAR
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
Definition: saveload.h:702
SLV_84
@ SLV_84
84 11822
Definition: saveload.h:147
SLE_STR
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
Definition: saveload.h:798
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
_me
TileExtended * _me
Extended Tiles of the map.
Definition: map.cpp:31
Waypoint
Representation of a waypoint.
Definition: waypoint_base.h:16
IsDriveThroughStopTile
static bool IsDriveThroughStopTile(TileIndex t)
Is tile t a drive through road stop station?
Definition: station_map.h:233
SaveLoadHandler::GetLoadDescription
SaveLoadTable GetLoadDescription() const
Get the description for how to load the chunk.
Definition: saveload.cpp:3436
saveload.h
SpecializedStation< Station, false >::Get
static Station * Get(size_t index)
Gets station with given index.
Definition: base_station_base.h:219
STNNChunkHandler::Save
void Save() const override
Save the chunk.
Definition: station_sl.cpp:661
STNSChunkHandler::FixPointers
void FixPointers() const override
Fix the pointers.
Definition: station_sl.cpp:507
OrthogonalTileArea::Add
void Add(TileIndex to_add)
Add a single tile to a tile area; enlarge if needed.
Definition: tilearea.cpp:43
DIAGDIR_NW
@ DIAGDIR_NW
Northwest.
Definition: direction_type.h:82
ChunkHandler
Handlers and description of chunk.
Definition: saveload.h:406
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:221
MoveBuoysToWaypoints
void MoveBuoysToWaypoints()
Perform all steps to upgrade from the old station buoys to the new version that uses waypoints.
Definition: station_sl.cpp:43
SLEG_CONDREFLIST
#define SLEG_CONDREFLIST(name, variable, type, from, to)
Storage of a global reference list in some savegame versions.
Definition: saveload.h:910
SLV_181
@ SLV_181
181 25012
Definition: saveload.h:264
BaseStation::owner
Owner owner
The owner of this station.
Definition: base_station_base.h:62
GoodsEntry::status
byte status
Status of this cargo, see GoodsEntryStatus.
Definition: station_base.h:223
_old_station_sl_compat
const SaveLoadCompat _old_station_sl_compat[]
Original field order for _old_station_desc.
Definition: station_sl_compat.h:141
SlStationWaypoint
Definition: station_sl.cpp:620
STNSChunkHandler
Definition: station_sl.cpp:487
BaseStation::num_specs
uint8 num_specs
Number of specs in the speclist.
Definition: base_station_base.h:65
BaseStation::string_id
StringID string_id
Default name (town area) of station.
Definition: base_station_base.h:58
SLE_REF
#define SLE_REF(base, variable, type)
Storage of a reference in every version of a savegame.
Definition: saveload.h:780
SLV_14
@ SLV_14
14.0 2441
Definition: saveload.h:61
RoadStop::RSSFB_BASE_ENTRY
@ RSSFB_BASE_ENTRY
Non-zero when the entries on this road stop are the primary, i.e. the ones to delete.
Definition: roadstop_base.h:27
SpecializedStation< Station, false >::Iterate
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
Definition: base_station_base.h:270
FlowStat
Flow statistics telling how much flow should be sent along a link.
Definition: station_base.h:33
GoodsEntry::cargo
StationCargoList cargo
The cargo packets of cargo waiting in this station.
Definition: station_base.h:252
ROADChunkHandler
Definition: station_sl.cpp:701
RoadStop::next
struct RoadStop * next
Next stop of the given type at this station.
Definition: roadstop_base.h:69
SLV_161
@ SLV_161
161 22567
Definition: saveload.h:240
SLF_ALLOW_CONTROL
@ SLF_ALLOW_CONTROL
Allow control codes in the strings.
Definition: saveload.h:625
_station_cargo_sl_compat
const SaveLoadCompat _station_cargo_sl_compat[]
Original field order for SlStationCargo.
Definition: station_sl_compat.h:36
SlStationNormal
SaveLoad handler for a normal station (read: not a waypoint).
Definition: station_sl.cpp:562
SLV_123
@ SLV_123
123 16909
Definition: saveload.h:194
SLV_150
@ SLV_150
150 20857
Definition: saveload.h:227
AfterLoadRoadStops
void AfterLoadRoadStops()
(Re)building of road stop caches after loading a savegame.
Definition: station_sl.cpp:131
BaseStation::train_station
TileArea train_station
Tile area the train 'station' part covers.
Definition: base_station_base.h:75
SLV_55
@ SLV_55
55 9638
Definition: saveload.h:113
span
A trimmed down version of what std::span will be in C++20.
Definition: span_type.hpp:60
CH_READONLY
@ CH_READONLY
Chunk is never saved.
Definition: saveload.h:402
SLV_31
@ SLV_31
31 5999
Definition: saveload.h:84
_station_spec_list_sl_compat
const SaveLoadCompat _station_spec_list_sl_compat[]
Original field order for SlStationSpecList.
Definition: station_sl_compat.h:30
BaseStation::rect
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
Definition: base_station_base.h:76
SLV_MULTITILE_DOCKS
@ SLV_MULTITILE_DOCKS
216 PR#7380 Multiple docks per station.
Definition: saveload.h:307
Order::MakeGoToWaypoint
void MakeGoToWaypoint(StationID destination)
Makes this order a Go To Waypoint order.
Definition: order_cmd.cpp:103
HVOT_WAYPOINT
@ HVOT_WAYPOINT
Station is a waypoint (NewGRF only!)
Definition: station_type.h:70
SLE_SAVEBYTE
#define SLE_SAVEBYTE(base, variable)
Only write byte during saving; never read it during loading.
Definition: saveload.h:826
STNNChunkHandler::FixPointers
void FixPointers() const override
Fix the pointers.
Definition: station_sl.cpp:688
SB
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.
Definition: bitmath_func.hpp:58
IsInsideBS
static bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
Definition: math_func.hpp:188
PersistentStorage
Class for pooled persistent storage of data.
Definition: newgrf_storage.h:221
SpecializedStation< Station, false >::IsExpected
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
Definition: base_station_base.h:200
Station::truck_station
TileArea truck_station
Tile area the truck 'station' part covers.
Definition: station_base.h:459
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:14
Station::airport
Airport airport
Tile area the airport covers.
Definition: station_base.h:461
SLV_27
@ SLV_27
27 4757
Definition: saveload.h:79
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:18
MultiMap::MapSize
size_t MapSize() const
Count the number of ranges with equal keys in this MultiMap.
Definition: multimap.hpp:350
SlStationCargo
Definition: station_sl.cpp:228
SLV_46
@ SLV_46
46 8705
Definition: saveload.h:102
_station_normal_sl_compat
const SaveLoadCompat _station_normal_sl_compat[]
Original field order for SlStationNormal.
Definition: station_sl_compat.h:90
SwapPackets
static void SwapPackets(GoodsEntry *ge)
Swap the temporary packets with the packets without specific destination in the given goods entry.
Definition: station_sl.cpp:179
SLV_EXTEND_CARGOTYPES
@ SLV_EXTEND_CARGOTYPES
199 PR#6802 Extend cargotypes to 64
Definition: saveload.h:286
REF_STORAGE
@ REF_STORAGE
Load/save a reference to a persistent storage.
Definition: saveload.h:544
SLE_CONDREF
#define SLE_CONDREF(base, variable, type, from, to)
Storage of a reference in some savegame versions.
Definition: saveload.h:712
SLV_183
@ SLV_183
183 25363 Cargodist
Definition: saveload.h:266
IsSavegameVersionBefore
static bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor=0)
Checks whether the savegame is below major.
Definition: saveload.h:1024
BaseStation::name
std::string name
Custom name.
Definition: base_station_base.h:57
Station::bus_station
TileArea bus_station
Tile area the bus 'station' part covers.
Definition: station_base.h:457
_station_goods_sl_compat
const SaveLoadCompat _station_goods_sl_compat[]
Original field order for SlStationGoods.
Definition: station_sl_compat.h:50
PersistentStorageArray::storage
TYPE storage[SIZE]
Memory to for the storage array.
Definition: newgrf_storage.h:67
SLV_7
@ SLV_7
7.0 1770
Definition: saveload.h:52
ROADChunkHandler::FixPointers
void FixPointers() const override
Fix the pointers.
Definition: station_sl.cpp:727
REF_VEHICLE
@ REF_VEHICLE
Load/save a reference to a vehicle.
Definition: saveload.h:536
FACIL_DOCK
@ FACIL_DOCK
Station with a dock.
Definition: station_type.h:56
REF_CARGO_PACKET
@ REF_CARGO_PACKET
Load/save a reference to a cargo packet.
Definition: saveload.h:542
FlowStat::AppendShare
void AppendShare(StationID st, uint flow, bool restricted=false)
Add some flow to the end of the shares map.
Definition: station_base.h:67
SpecializedStation< Station, false >::From
static Station * From(BaseStation *st)
Converts a BaseStation to SpecializedStation with type checking.
Definition: base_station_base.h:248
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
Station::truck_stops
RoadStop * truck_stops
All the truck stops.
Definition: station_base.h:458
SLV_145
@ SLV_145
145 20376
Definition: saveload.h:221
IsTileType
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
Definition: tile_map.h:150
SlGetStructListLength
size_t SlGetStructListLength(size_t limit)
Get the length of this list; if it exceeds the limit, error out.
Definition: saveload.cpp:1825
FACIL_WAYPOINT
@ FACIL_WAYPOINT
Station is a waypoint.
Definition: station_type.h:57
SLV_2
@ SLV_2
2.0 0.3.0 2.1 0.3.1, 0.3.2
Definition: saveload.h:38
ROADChunkHandler::Save
void Save() const override
Save the chunk.
Definition: station_sl.cpp:704
GetTileOwner
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
Definition: tile_map.h:178
station_sl_compat.h
_station_waypoint_sl_compat
const SaveLoadCompat _station_waypoint_sl_compat[]
Original field order for SlStationWaypoint.
Definition: station_sl_compat.h:124
SL_MAX_VERSION
@ SL_MAX_VERSION
Highest possible saveload version.
Definition: saveload.h:342
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
IsBuoyTile
static bool IsBuoyTile(TileIndex t)
Is tile t a buoy tile?
Definition: station_map.h:316
GoodsEntry
Stores station stats for a single cargo.
Definition: station_base.h:167
SLE_VAR
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
Definition: saveload.h:772
Pool::PoolItem<&_orderlist_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:386
STNSChunkHandler::Load
void Load() const override
Load the chunk.
Definition: station_sl.cpp:490
STNNChunkHandler
Definition: station_sl.cpp:658
SLV_127
@ SLV_127
127 17439
Definition: saveload.h:199
SLEG_CONDVAR
#define SLEG_CONDVAR(name, variable, type, from, to)
Storage of a global variable in some savegame versions.
Definition: saveload.h:849
SlStationGoods
Definition: station_sl.cpp:317
SLV_6
@ SLV_6
6.0 1721 6.1 1768
Definition: saveload.h:50
FACIL_TRAIN
@ FACIL_TRAIN
Station with train station.
Definition: station_type.h:52
GoodsEntry::flows
FlowStatMap flows
Planned flows through this station.
Definition: station_base.h:256
SLV_44
@ SLV_44
44 8144
Definition: saveload.h:99
SLEG_CONDARR
#define SLEG_CONDARR(name, variable, type, length, from, to)
Storage of a global fixed-size array of SL_VAR elements in some savegame versions.
Definition: saveload.h:870
DefaultSaveLoadHandler< SlStationCargo, GoodsEntry >::GetDescription
SaveLoadTable GetDescription() const override
Definition: saveload.h:517
OrderList
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
Definition: order_base.h:253
_roadstop_sl_compat
const SaveLoadCompat _roadstop_sl_compat[]
Original field order for _roadstop_desc.
Definition: station_sl_compat.h:16
OWNER_NONE
@ OWNER_NONE
The tile has no ownership.
Definition: company_type.h:25
SlReadByte
byte SlReadByte()
Wrapper for reading a byte from the buffer.
Definition: saveload.cpp:424
MP_STATION
@ MP_STATION
A tile of a station.
Definition: tile_type.h:51
NUM_CARGO
@ NUM_CARGO
Maximal number of cargo types in a game.
Definition: cargo_type.h:65
GoodsEntry::GES_ACCEPTANCE
@ GES_ACCEPTANCE
Set when the station accepts the cargo currently for final deliveries.
Definition: station_base.h:174
GetStationIndex
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
Definition: station_map.h:28
SLV_122
@ SLV_122
122 16855
Definition: saveload.h:193
STNNChunkHandler::Load
void Load() const override
Load the chunk.
Definition: station_sl.cpp:673
Pool::PoolItem<&_station_pool >::CanAllocateItem
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
Definition: pool_type.hpp:307
BaseStation
Base class for all station-ish types.
Definition: base_station_base.h:52
SLV_3
@ SLV_3
3.x lost
Definition: saveload.h:40
SLE_CONDREFLIST
#define SLE_CONDREFLIST(base, variable, type, from, to)
Storage of a list of SL_REF elements in some savegame versions.
Definition: saveload.h:754
SlStationFlow
Definition: station_sl.cpp:264
BaseStation::delete_ctr
byte delete_ctr
Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is ...
Definition: base_station_base.h:55
SLE_SSTR
#define SLE_SSTR(base, variable, type)
Storage of a std::string in every savegame version.
Definition: saveload.h:806
BaseStation::speclist
StationSpecList * speclist
List of station specs of this station.
Definition: base_station_base.h:66
SLV_68
@ SLV_68
68 10266
Definition: saveload.h:128
Town
Town data structure.
Definition: town.h:50
CargoPacket
Container for cargo from the same location and time.
Definition: cargopacket.h:43
OverflowSafeInt< int64 >
SLV_103
@ SLV_103
103 14598
Definition: saveload.h:170
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:20
SLV_SAVELOAD_LIST_LENGTH
@ SLV_SAVELOAD_LIST_LENGTH
293 PR#9374 Consistency in list length with SL_STRUCT / SL_STRUCTLIST / SL_DEQUE / SL_REFLIST.
Definition: saveload.h:335
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:88
SlCompatTableHeader
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
Definition: saveload.cpp:2029
StationCargoList::Append
void Append(CargoPacket *cp, StationID next)
Appends the given cargo packet to the range of packets with the same next station.
Definition: cargopacket.cpp:690
Station::bus_stops
RoadStop * bus_stops
All the road stops.
Definition: station_base.h:456
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
RoadStop
A Stop for a Road Vehicle.
Definition: roadstop_base.h:22
FACIL_AIRPORT
@ FACIL_AIRPORT
Station with an airport.
Definition: station_type.h:55
SlObject
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
Definition: saveload.cpp:1838
SlTableHeader
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
Definition: saveload.cpp:1891
Airport::psa
PersistentStorage * psa
Persistent storage for NewGRF airports.
Definition: station_base.h:310
SlSetStructListLength
void SlSetStructListLength(size_t length)
Set the length of this list.
Definition: saveload.cpp:1809
SaveLoad
SaveLoad type struct.
Definition: saveload.h:653
MultiMap
Hand-rolled multimap as map of lists.
Definition: multimap.hpp:17
DIAGDIR_NE
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Definition: direction_type.h:79
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
Town::name
std::string name
Custom town name. If empty, the town was not renamed and uses the generated name.
Definition: town.h:59
SLV_140
@ SLV_140
140 19382
Definition: saveload.h:215
SLV_26
@ SLV_26
26 4466
Definition: saveload.h:78
StationUpdateCachedTriggers
void StationUpdateCachedTriggers(BaseStation *st)
Update the cached animation trigger bitmask for a station.
Definition: newgrf_station.cpp:1046
BaseStation::build_date
Date build_date
Date of construction.
Definition: base_station_base.h:68
Order::next
Order * next
Pointer to next order. If nullptr, end of list.
Definition: order_base.h:52
Order
Definition: order_base.h:33
GoodsEntry::GES_RATING
@ GES_RATING
This indicates whether a cargo has a rating at the station.
Definition: station_base.h:184
SLV_57
@ SLV_57
57 9691
Definition: saveload.h:115
SlIterateArray
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
Definition: saveload.cpp:670
_station_sl_compat
const SaveLoadCompat _station_sl_compat[]
Original field order for _station_desc.
Definition: station_sl_compat.h:133
_station_flow_sl_compat
const SaveLoadCompat _station_flow_sl_compat[]
Original field order for SlStationFlow.
Definition: station_sl_compat.h:42
SlStationSpecList
Definition: station_sl.cpp:196
FlowSaveLoad
Definition: station_sl.cpp:162
PersistentStorageArray
Class for persistent storage of data.
Definition: newgrf_storage.h:66
SLEG_STRUCTLIST
#define SLEG_STRUCTLIST(name, handler)
Storage of a list of structs in every savegame version.
Definition: saveload.h:999
SLEG_STRUCT
#define SLEG_STRUCT(name, handler)
Storage of a structs in every savegame version.
Definition: saveload.h:976