10 #include "../stdafx.h"
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"
21 #include "table/strings.h"
23 #include "../safeguards.h"
31 if (!o->
IsType(OT_GOTO_STATION))
return;
64 StationID index = st->index;
66 Town *town = st->town;
68 std::string name = st->
name;
69 Date build_date = st->build_date;
72 TileArea train_st = st->train_station;
82 wp->
string_id = train ? STR_SV_STNAME_WAYPOINT : STR_SV_STNAME_BUOY;
88 if (
IsInsideBS(string_id, STR_SV_STNAME_BUOY, 9)) wp->
town_cn = string_id - STR_SV_STNAME_BUOY;
95 SB(
_me[t].m6, 3, 3, STATION_WAYPOINT);
96 wp->
rect.BeforeAddTile(t, StationRect::ADD_FORCE);
102 wp->
rect.BeforeAddTile(xy, StationRect::ADD_FORCE);
108 void AfterLoadStations()
112 for (uint i = 0; i < st->speclist.size(); i++) {
113 if (st->speclist[i].grfid == 0)
continue;
115 st->speclist[i].spec = StationClass::GetByGrf(st->speclist[i].grfid, st->speclist[i].localidx,
nullptr);
146 static const SaveLoad _roadstop_desc[] = {
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;
159 std::list<CargoPacket *> _packets;
160 uint32 _old_num_dests;
163 FlowSaveLoad() : source(0), via(0), share(0), restricted(
false) {}
170 typedef std::pair<const StationID, std::list<CargoPacket *> > StationCargoPair;
183 if (_packets.empty()) {
184 std::map<StationID, std::list<CargoPacket *> >::iterator it(ge_packets.find(INVALID_STATION));
185 if (it == ge_packets.end()) {
188 it->second.swap(_packets);
191 assert(ge_packets[INVALID_STATION].empty());
192 ge_packets[INVALID_STATION].swap(_packets);
198 inline static const SaveLoad description[] = {
209 for (uint i = 0; i < bst->
speclist.size(); i++) {
219 for (uint i = 0; i < num_specs; i++) {
229 inline static const SaveLoad description[] = {
230 SLE_VAR(StationCargoPair, first, SLE_UINT16),
238 for (StationCargoPacketMap::ConstMapIterator it(ge->
cargo.
Packets()->begin()); it != ge->
cargo.
Packets()->end(); ++it) {
247 StationCargoPair pair;
248 for (uint j = 0; j < num_dests; ++j) {
251 assert(pair.second.empty());
255 void FixPointers(
GoodsEntry *ge)
const override
257 for (StationCargoPacketMap::ConstMapIterator it = ge->
cargo.
Packets()->begin(); it != ge->
cargo.
Packets()->end(); ++it) {
265 inline static const SaveLoad description[] = {
275 uint32 num_flows = 0;
276 for (FlowStatMap::const_iterator it(ge->
flows.begin()); it != ge->
flows.end(); ++it) {
277 num_flows += (uint32)it->second.GetShares()->size();
281 for (FlowStatMap::const_iterator outer_it(ge->
flows.begin()); outer_it != ge->
flows.end(); ++outer_it) {
282 const FlowStat::SharesMap *shares = outer_it->second.GetShares();
283 uint32 sum_shares = 0;
285 flow.source = outer_it->first;
286 for (FlowStat::SharesMap::const_iterator inner_it(shares->begin()); inner_it != shares->end(); ++inner_it) {
287 flow.via = inner_it->second;
288 flow.share = inner_it->first - sum_shares;
289 flow.restricted = inner_it->first > outer_it->second.GetUnrestricted();
290 sum_shares = inner_it->first;
291 assert(flow.share > 0);
303 StationID prev_source = INVALID_STATION;
304 for (uint32 j = 0; j < num_flows; ++j) {
306 if (fs ==
nullptr || prev_source != flow.source) {
307 fs = &(ge->
flows.insert(std::make_pair(flow.source,
FlowStat(flow.via, flow.share, flow.restricted))).first->second);
309 fs->
AppendShare(flow.via, flow.share, flow.restricted);
311 prev_source = flow.source;
318 #if defined(_MSC_VER) && (_MSC_VER == 1915 || _MSC_VER == 1916)
323 inline static const SaveLoad description[] = {{}};
328 static const SaveLoad description[] = {
352 #if defined(_MSC_VER) && (_MSC_VER == 1915 || _MSC_VER == 1916)
395 for (
CargoID i = 0; i < num_cargo; i++) {
403 if (
GB(_waiting_acceptance, 0, 12) != 0) {
414 CargoPacket *cp =
new CargoPacket(
GB(_waiting_acceptance, 0, 12), _cargo_days, source, _cargo_source_xy, _cargo_source_xy, _cargo_feeder_share);
427 for (
CargoID i = 0; i < num_cargo; i++) {
440 static const SaveLoad _old_station_desc[] = {
493 _cargo_source_xy = 0;
495 _cargo_feeder_share = 0;
501 _waiting_acceptance = 0;
525 inline static const SaveLoad description[] = {
563 inline static const SaveLoad description[] = {
621 inline static const SaveLoad description[] = {
650 static const SaveLoad _station_desc[] = {
666 SlSetArrayIndex(st->
index);
708 SlSetArrayIndex(rs->index);