annotate src/saveload/station_sl.cpp @ 20729:ea20edff1862 draft default tip master

(svn r25643) -Fix (r25480): [OSX] Define version constants before they're used
author planetmaker <planetmaker@openttd.org>
date Wed, 31 Jul 2013 18:50:01 +0000
parents ba40b7d45f7e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1 /* $Id$ */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12626
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12626
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12626
diff changeset
5 * 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.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12626
diff changeset
6 * 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.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12626
diff changeset
7 * 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/>.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12626
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12626
diff changeset
9
17406
107ec08fdc9b (svn r22155) -Codechange: one comment in saveload/station_sl.cpp was wrong
smatz <smatz@openttd.org>
parents: 17317
diff changeset
10 /** @file station_sl.cpp Code handling saving and loading of stations. */
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
11
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
12 #include "../stdafx.h"
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
13 #include "../station_base.h"
12475
c133b51890f4 (svn r16912) -Codechange: split waypoint.h in waypoint_base.h and waypoint_func.h
rubidium <rubidium@openttd.org>
parents: 12472
diff changeset
14 #include "../waypoint_base.h"
12225
4f649aa97318 (svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents: 11935
diff changeset
15 #include "../roadstop_base.h"
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
16 #include "../vehicle_base.h"
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
17 #include "../newgrf_station.h"
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
18
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
19 #include "saveload.h"
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
20 #include "table/strings.h"
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
21
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
22 /**
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
23 * Update the buoy orders to be waypoint orders.
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
24 * @param o the order 'list' to check.
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
25 */
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
26 static void UpdateWaypointOrder(Order *o)
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
27 {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
28 if (!o->IsType(OT_GOTO_STATION)) return;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
29
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
30 const Station *st = Station::Get(o->GetDestination());
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
31 if ((st->had_vehicle_of_type & HVOT_WAYPOINT) == 0) return;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
32
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
33 o->MakeGoToWaypoint(o->GetDestination());
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
34 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
35
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
36 /**
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
37 * Perform all steps to upgrade from the old station buoys to the new version
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
38 * that uses waypoints. This includes some old saveload mechanics.
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
39 */
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
40 void MoveBuoysToWaypoints()
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
41 {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
42 /* Buoy orders become waypoint orders */
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
43 OrderList *ol;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
44 FOR_ALL_ORDER_LISTS(ol) {
17057
d1032dce7868 (svn r21794) -Fix (r21790): convert train orders too (Rubidium)
smatz <smatz@openttd.org>
parents: 17053
diff changeset
45 VehicleType vt = ol->GetFirstSharedVehicle()->type;
d1032dce7868 (svn r21794) -Fix (r21790): convert train orders too (Rubidium)
smatz <smatz@openttd.org>
parents: 17053
diff changeset
46 if (vt != VEH_SHIP && vt != VEH_TRAIN) continue;
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
47
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
48 for (Order *o = ol->GetFirstOrder(); o != NULL; o = o->next) UpdateWaypointOrder(o);
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
49 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
50
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
51 Vehicle *v;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
52 FOR_ALL_VEHICLES(v) {
17057
d1032dce7868 (svn r21794) -Fix (r21790): convert train orders too (Rubidium)
smatz <smatz@openttd.org>
parents: 17053
diff changeset
53 VehicleType vt = v->type;
d1032dce7868 (svn r21794) -Fix (r21790): convert train orders too (Rubidium)
smatz <smatz@openttd.org>
parents: 17053
diff changeset
54 if (vt != VEH_SHIP && vt != VEH_TRAIN) continue;
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
55
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
56 UpdateWaypointOrder(&v->current_order);
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
57 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
58
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
59 /* Now make the stations waypoints */
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
60 Station *st;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
61 FOR_ALL_STATIONS(st) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
62 if ((st->had_vehicle_of_type & HVOT_WAYPOINT) == 0) continue;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
63
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
64 StationID index = st->index;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
65 TileIndex xy = st->xy;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
66 Town *town = st->town;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
67 StringID string_id = st->string_id;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
68 char *name = st->name;
17047
79adc044e86b (svn r21784) -Fix (r16909): crash when converting savegame with custom waypoint name
smatz <smatz@openttd.org>
parents: 16556
diff changeset
69 st->name = NULL;
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
70 Date build_date = st->build_date;
17053
250cc232b8ee (svn r21790) -Fix [FS#4398]: TTDPatch savegames can have train waypoints encoded as buoys
smatz <smatz@openttd.org>
parents: 17047
diff changeset
71 /* TTDPatch could use "buoys with rail station" for rail waypoints */
250cc232b8ee (svn r21790) -Fix [FS#4398]: TTDPatch savegames can have train waypoints encoded as buoys
smatz <smatz@openttd.org>
parents: 17047
diff changeset
72 bool train = st->train_station.tile != INVALID_TILE;
17058
2bbacb524f85 (svn r21795) -Fix (r21790): when converting TTDPatch train waypoints, convert the data on the map as well
rubidium <rubidium@openttd.org>
parents: 17057
diff changeset
73 TileArea train_st = st->train_station;
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
74
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
75 /* Delete the station, so we can make it a real waypoint. */
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
76 delete st;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
77
17317
93e6a660774c (svn r22057) -Fix: waypoint conversion could (previously) silently overfill the pool and crash
rubidium <rubidium@openttd.org>
parents: 17285
diff changeset
78 /* Stations and waypoints are in the same pool, so if a station
93e6a660774c (svn r22057) -Fix: waypoint conversion could (previously) silently overfill the pool and crash
rubidium <rubidium@openttd.org>
parents: 17285
diff changeset
79 * is deleted there must be place for a Waypoint. */
93e6a660774c (svn r22057) -Fix: waypoint conversion could (previously) silently overfill the pool and crash
rubidium <rubidium@openttd.org>
parents: 17285
diff changeset
80 assert(Waypoint::CanAllocateItem());
17053
250cc232b8ee (svn r21790) -Fix [FS#4398]: TTDPatch savegames can have train waypoints encoded as buoys
smatz <smatz@openttd.org>
parents: 17047
diff changeset
81 Waypoint *wp = new (index) Waypoint(xy);
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
82 wp->town = town;
17053
250cc232b8ee (svn r21790) -Fix [FS#4398]: TTDPatch savegames can have train waypoints encoded as buoys
smatz <smatz@openttd.org>
parents: 17047
diff changeset
83 wp->string_id = train ? STR_SV_STNAME_WAYPOINT : STR_SV_STNAME_BUOY;
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
84 wp->name = name;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
85 wp->delete_ctr = 0; // Just reset delete counter for once.
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
86 wp->build_date = build_date;
17053
250cc232b8ee (svn r21790) -Fix [FS#4398]: TTDPatch savegames can have train waypoints encoded as buoys
smatz <smatz@openttd.org>
parents: 17047
diff changeset
87 wp->owner = train ? GetTileOwner(xy) : OWNER_NONE;
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
88
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
89 if (IsInsideBS(string_id, STR_SV_STNAME_BUOY, 9)) wp->town_cn = string_id - STR_SV_STNAME_BUOY;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
90
17053
250cc232b8ee (svn r21790) -Fix [FS#4398]: TTDPatch savegames can have train waypoints encoded as buoys
smatz <smatz@openttd.org>
parents: 17047
diff changeset
91 if (train) {
17058
2bbacb524f85 (svn r21795) -Fix (r21790): when converting TTDPatch train waypoints, convert the data on the map as well
rubidium <rubidium@openttd.org>
parents: 17057
diff changeset
92 /* When we make a rail waypoint of the station, convert the map as well. */
2bbacb524f85 (svn r21795) -Fix (r21790): when converting TTDPatch train waypoints, convert the data on the map as well
rubidium <rubidium@openttd.org>
parents: 17057
diff changeset
93 TILE_AREA_LOOP(t, train_st) {
2bbacb524f85 (svn r21795) -Fix (r21790): when converting TTDPatch train waypoints, convert the data on the map as well
rubidium <rubidium@openttd.org>
parents: 17057
diff changeset
94 if (!IsTileType(t, MP_STATION) || GetStationIndex(t) != index) continue;
2bbacb524f85 (svn r21795) -Fix (r21790): when converting TTDPatch train waypoints, convert the data on the map as well
rubidium <rubidium@openttd.org>
parents: 17057
diff changeset
95
2bbacb524f85 (svn r21795) -Fix (r21790): when converting TTDPatch train waypoints, convert the data on the map as well
rubidium <rubidium@openttd.org>
parents: 17057
diff changeset
96 SB(_m[t].m6, 3, 3, STATION_WAYPOINT);
2bbacb524f85 (svn r21795) -Fix (r21790): when converting TTDPatch train waypoints, convert the data on the map as well
rubidium <rubidium@openttd.org>
parents: 17057
diff changeset
97 wp->rect.BeforeAddTile(t, StationRect::ADD_FORCE);
2bbacb524f85 (svn r21795) -Fix (r21790): when converting TTDPatch train waypoints, convert the data on the map as well
rubidium <rubidium@openttd.org>
parents: 17057
diff changeset
98 }
2bbacb524f85 (svn r21795) -Fix (r21790): when converting TTDPatch train waypoints, convert the data on the map as well
rubidium <rubidium@openttd.org>
parents: 17057
diff changeset
99
2bbacb524f85 (svn r21795) -Fix (r21790): when converting TTDPatch train waypoints, convert the data on the map as well
rubidium <rubidium@openttd.org>
parents: 17057
diff changeset
100 wp->train_station = train_st;
17053
250cc232b8ee (svn r21790) -Fix [FS#4398]: TTDPatch savegames can have train waypoints encoded as buoys
smatz <smatz@openttd.org>
parents: 17047
diff changeset
101 wp->facilities |= FACIL_TRAIN;
250cc232b8ee (svn r21790) -Fix [FS#4398]: TTDPatch savegames can have train waypoints encoded as buoys
smatz <smatz@openttd.org>
parents: 17047
diff changeset
102 } else if (IsBuoyTile(xy) && GetStationIndex(xy) == index) {
17058
2bbacb524f85 (svn r21795) -Fix (r21790): when converting TTDPatch train waypoints, convert the data on the map as well
rubidium <rubidium@openttd.org>
parents: 17057
diff changeset
103 wp->rect.BeforeAddTile(xy, StationRect::ADD_FORCE);
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
104 wp->facilities |= FACIL_DOCK;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
105 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
106 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
107 }
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
108
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
109 void AfterLoadStations()
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
110 {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
111 /* Update the speclists of all stations to point to the currently loaded custom stations. */
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
112 BaseStation *st;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
113 FOR_ALL_BASE_STATIONS(st) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
114 for (uint i = 0; i < st->num_specs; i++) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
115 if (st->speclist[i].grfid == 0) continue;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
116
15739
2efb086daa1a (svn r20406) -Codechange: make StationClass use the new generic class
rubidium <rubidium@openttd.org>
parents: 15708
diff changeset
117 st->speclist[i].spec = StationClass::GetByGrf(st->speclist[i].grfid, st->speclist[i].localidx, NULL);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
118 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
119
13848
a47ef53cafb4 (svn r18377) -Codechange: add 'cache' of the tile area of truck and bus stops.
rubidium <rubidium@openttd.org>
parents: 13509
diff changeset
120 if (Station::IsExpected(st)) {
a47ef53cafb4 (svn r18377) -Codechange: add 'cache' of the tile area of truck and bus stops.
rubidium <rubidium@openttd.org>
parents: 13509
diff changeset
121 Station *sta = Station::From(st);
a47ef53cafb4 (svn r18377) -Codechange: add 'cache' of the tile area of truck and bus stops.
rubidium <rubidium@openttd.org>
parents: 13509
diff changeset
122 for (const RoadStop *rs = sta->bus_stops; rs != NULL; rs = rs->next) sta->bus_station.Add(rs->xy);
a47ef53cafb4 (svn r18377) -Codechange: add 'cache' of the tile area of truck and bus stops.
rubidium <rubidium@openttd.org>
parents: 13509
diff changeset
123 for (const RoadStop *rs = sta->truck_stops; rs != NULL; rs = rs->next) sta->truck_station.Add(rs->xy);
a47ef53cafb4 (svn r18377) -Codechange: add 'cache' of the tile area of truck and bus stops.
rubidium <rubidium@openttd.org>
parents: 13509
diff changeset
124 }
a47ef53cafb4 (svn r18377) -Codechange: add 'cache' of the tile area of truck and bus stops.
rubidium <rubidium@openttd.org>
parents: 13509
diff changeset
125
19973
f8c0e108128c (svn r24905) -Feature(ish): Implement station randomisation triggers.
peter1138 <peter1138@openttd.org>
parents: 19785
diff changeset
126 StationUpdateCachedTriggers(st);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
127 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
128 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
129
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
130 /**
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
131 * (Re)building of road stop caches after loading a savegame.
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
132 */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
133 void AfterLoadRoadStops()
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
134 {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
135 /* First construct the drive through entries */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
136 RoadStop *rs;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
137 FOR_ALL_ROADSTOPS(rs) {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
138 if (IsDriveThroughStopTile(rs->xy)) rs->MakeDriveThrough();
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
139 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
140 /* And then rebuild the data in those entries */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
141 FOR_ALL_ROADSTOPS(rs) {
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
142 if (!HasBit(rs->status, RoadStop::RSSFB_BASE_ENTRY)) continue;
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
143
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
144 rs->GetEntry(DIAGDIR_NE)->Rebuild(rs);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
145 rs->GetEntry(DIAGDIR_NW)->Rebuild(rs);
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
146 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
147 }
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13848
diff changeset
148
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
149 static const SaveLoad _roadstop_desc[] = {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
150 SLE_VAR(RoadStop, xy, SLE_UINT32),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
151 SLE_CONDNULL(1, 0, 44),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
152 SLE_VAR(RoadStop, status, SLE_UINT8),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
153 /* Index was saved in some versions, but this is not needed */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
154 SLE_CONDNULL(4, 0, 8),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
155 SLE_CONDNULL(2, 0, 44),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
156 SLE_CONDNULL(1, 0, 25),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
157
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
158 SLE_REF(RoadStop, next, REF_ROADSTOPS),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
159 SLE_CONDNULL(2, 0, 44),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
160
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
161 SLE_CONDNULL(4, 0, 24),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
162 SLE_CONDNULL(1, 25, 25),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
163
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
164 SLE_END()
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
165 };
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
166
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
167 static const SaveLoad _old_station_desc[] = {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
168 SLE_CONDVAR(Station, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
169 SLE_CONDVAR(Station, xy, SLE_UINT32, 6, SL_MAX_VERSION),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
170 SLE_CONDNULL(4, 0, 5), ///< bus/lorry tile
12510
3e976121ced2 (svn r16947) -Codechange: use TileArea instead of train_tile, trainst_w and trainst_h.
rubidium <rubidium@openttd.org>
parents: 12507
diff changeset
171 SLE_CONDVAR(Station, train_station.tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
3e976121ced2 (svn r16947) -Codechange: use TileArea instead of train_tile, trainst_w and trainst_h.
rubidium <rubidium@openttd.org>
parents: 12507
diff changeset
172 SLE_CONDVAR(Station, train_station.tile, SLE_UINT32, 6, SL_MAX_VERSION),
14621
562ed276a7d0 (svn r19198) -Codechange: store the size of stations in savegames
yexo <yexo@openttd.org>
parents: 14258
diff changeset
173 SLE_CONDVAR(Station, airport.tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
562ed276a7d0 (svn r19198) -Codechange: store the size of stations in savegames
yexo <yexo@openttd.org>
parents: 14258
diff changeset
174 SLE_CONDVAR(Station, airport.tile, SLE_UINT32, 6, SL_MAX_VERSION),
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
175 SLE_CONDVAR(Station, dock_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
176 SLE_CONDVAR(Station, dock_tile, SLE_UINT32, 6, SL_MAX_VERSION),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
177 SLE_REF(Station, town, REF_TOWN),
14803
370107d8ee97 (svn r19392) -Codechange: Increase the maximum size of a TileArea.
terkhen <terkhen@openttd.org>
parents: 14793
diff changeset
178 SLE_VAR(Station, train_station.w, SLE_FILE_U8 | SLE_VAR_U16),
370107d8ee97 (svn r19392) -Codechange: Increase the maximum size of a TileArea.
terkhen <terkhen@openttd.org>
parents: 14793
diff changeset
179 SLE_CONDVAR(Station, train_station.h, SLE_FILE_U8 | SLE_VAR_U16, 2, SL_MAX_VERSION),
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
180
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
181 SLE_CONDNULL(1, 0, 3), ///< alpha_order
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
182
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
183 SLE_VAR(Station, string_id, SLE_STRINGID),
18788
49b58c8cab22 (svn r23636) -Add: introduce ScriptText in parameters where it can be used
truebrain <truebrain@openttd.org>
parents: 18678
diff changeset
184 SLE_CONDSTR(Station, name, SLE_STR | SLF_ALLOW_CONTROL, 0, 84, SL_MAX_VERSION),
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
185 SLE_CONDVAR(Station, indtype, SLE_UINT8, 103, SL_MAX_VERSION),
12318
c6024003bac3 (svn r16735) -Codechange: had_vehicle_of_type only stored 7 bits, all less that bit 7... but it was a word wasting space etc.
rubidium <rubidium@openttd.org>
parents: 12225
diff changeset
186 SLE_CONDVAR(Station, had_vehicle_of_type, SLE_FILE_U16 | SLE_VAR_U8, 0, 121),
c6024003bac3 (svn r16735) -Codechange: had_vehicle_of_type only stored 7 bits, all less that bit 7... but it was a word wasting space etc.
rubidium <rubidium@openttd.org>
parents: 12225
diff changeset
187 SLE_CONDVAR(Station, had_vehicle_of_type, SLE_UINT8, 122, SL_MAX_VERSION),
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
188
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
189 SLE_VAR(Station, time_since_load, SLE_UINT8),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
190 SLE_VAR(Station, time_since_unload, SLE_UINT8),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
191 SLE_VAR(Station, delete_ctr, SLE_UINT8),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
192 SLE_VAR(Station, owner, SLE_UINT8),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
193 SLE_VAR(Station, facilities, SLE_UINT8),
14859
304d377a82af (svn r19455) -Codechange: split all airport information in Station to a seperate class
yexo <yexo@openttd.org>
parents: 14803
diff changeset
194 SLE_VAR(Station, airport.type, SLE_UINT8),
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
195
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
196 SLE_CONDNULL(2, 0, 5), ///< Truck/bus stop status
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
197 SLE_CONDNULL(1, 0, 4), ///< Blocked months
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
198
14859
304d377a82af (svn r19455) -Codechange: split all airport information in Station to a seperate class
yexo <yexo@openttd.org>
parents: 14803
diff changeset
199 SLE_CONDVAR(Station, airport.flags, SLE_VAR_U64 | SLE_FILE_U16, 0, 2),
304d377a82af (svn r19455) -Codechange: split all airport information in Station to a seperate class
yexo <yexo@openttd.org>
parents: 14803
diff changeset
200 SLE_CONDVAR(Station, airport.flags, SLE_VAR_U64 | SLE_FILE_U32, 3, 45),
304d377a82af (svn r19455) -Codechange: split all airport information in Station to a seperate class
yexo <yexo@openttd.org>
parents: 14803
diff changeset
201 SLE_CONDVAR(Station, airport.flags, SLE_UINT64, 46, SL_MAX_VERSION),
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
202
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
203 SLE_CONDNULL(2, 0, 25), ///< last-vehicle
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
204 SLE_CONDVAR(Station, last_vehicle_type, SLE_UINT8, 26, SL_MAX_VERSION),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
205
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
206 SLE_CONDNULL(2, 3, 25), ///< custom station class and id
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
207 SLE_CONDVAR(Station, build_date, SLE_FILE_U16 | SLE_VAR_I32, 3, 30),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
208 SLE_CONDVAR(Station, build_date, SLE_INT32, 31, SL_MAX_VERSION),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
209
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
210 SLE_CONDREF(Station, bus_stops, REF_ROADSTOPS, 6, SL_MAX_VERSION),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
211 SLE_CONDREF(Station, truck_stops, REF_ROADSTOPS, 6, SL_MAX_VERSION),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
212
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
213 /* Used by newstations for graphic variations */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
214 SLE_CONDVAR(Station, random_bits, SLE_UINT16, 27, SL_MAX_VERSION),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
215 SLE_CONDVAR(Station, waiting_triggers, SLE_UINT8, 27, SL_MAX_VERSION),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
216 SLE_CONDVAR(Station, num_specs, SLE_UINT8, 27, SL_MAX_VERSION),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
217
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
218 SLE_CONDLST(Station, loading_vehicles, REF_VEHICLE, 57, SL_MAX_VERSION),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
219
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
220 /* reserve extra space in savegame here. (currently 32 bytes) */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
221 SLE_CONDNULL(32, 2, SL_MAX_VERSION),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
222
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
223 SLE_END()
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
224 };
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
225
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
226 static uint16 _waiting_acceptance;
20402
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
227 static uint32 _num_flows;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
228 static uint16 _cargo_source;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
229 static uint32 _cargo_source_xy;
20382
c8fa9135b789 (svn r25337) -Fix: saving only 8 bits of 16 causes endianness problems
fonsinchen <fonsinchen@openttd.org>
parents: 20357
diff changeset
230 static uint8 _cargo_days;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
231 static Money _cargo_feeder_share;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
232
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
233 static const SaveLoad _station_speclist_desc[] = {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
234 SLE_CONDVAR(StationSpecList, grfid, SLE_UINT32, 27, SL_MAX_VERSION),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
235 SLE_CONDVAR(StationSpecList, localidx, SLE_UINT8, 27, SL_MAX_VERSION),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
236
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
237 SLE_END()
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
238 };
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
239
20403
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
240 std::list<CargoPacket *> _packets;
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
241 uint32 _num_dests;
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
242
20402
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
243 struct FlowSaveLoad {
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
244 FlowSaveLoad() : via(0), share(0) {}
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
245 StationID source;
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
246 StationID via;
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
247 uint32 share;
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
248 };
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
249
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
250 static const SaveLoad _flow_desc[] = {
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
251 SLE_VAR(FlowSaveLoad, source, SLE_UINT16),
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
252 SLE_VAR(FlowSaveLoad, via, SLE_UINT16),
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
253 SLE_VAR(FlowSaveLoad, share, SLE_UINT32),
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
254 SLE_END()
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
255 };
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
256
13220
d8ddc1b1e866 (svn r17727) -Codechange: some coding style and documentation fixes
rubidium <rubidium@openttd.org>
parents: 13213
diff changeset
257 /**
d8ddc1b1e866 (svn r17727) -Codechange: some coding style and documentation fixes
rubidium <rubidium@openttd.org>
parents: 13213
diff changeset
258 * Wrapper function to get the GoodsEntry's internal structure while
d8ddc1b1e866 (svn r17727) -Codechange: some coding style and documentation fixes
rubidium <rubidium@openttd.org>
parents: 13213
diff changeset
259 * some of the variables itself are private.
d8ddc1b1e866 (svn r17727) -Codechange: some coding style and documentation fixes
rubidium <rubidium@openttd.org>
parents: 13213
diff changeset
260 * @return the saveload description for GoodsEntry.
d8ddc1b1e866 (svn r17727) -Codechange: some coding style and documentation fixes
rubidium <rubidium@openttd.org>
parents: 13213
diff changeset
261 */
11935
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
262 const SaveLoad *GetGoodsDesc()
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
263 {
11935
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
264 static const SaveLoad goods_desc[] = {
20357
0ac217852174 (svn r25312) -Fix-ish: missing spaces after comma + realignment of tables; quite boring with -x -w
rubidium <rubidium@openttd.org>
parents: 20078
diff changeset
265 SLEG_CONDVAR( _waiting_acceptance, SLE_UINT16, 0, 67),
0ac217852174 (svn r25312) -Fix-ish: missing spaces after comma + realignment of tables; quite boring with -x -w
rubidium <rubidium@openttd.org>
parents: 20078
diff changeset
266 SLE_CONDVAR(GoodsEntry, acceptance_pickup, SLE_UINT8, 68, SL_MAX_VERSION),
0ac217852174 (svn r25312) -Fix-ish: missing spaces after comma + realignment of tables; quite boring with -x -w
rubidium <rubidium@openttd.org>
parents: 20078
diff changeset
267 SLE_CONDNULL(2, 51, 67),
0ac217852174 (svn r25312) -Fix-ish: missing spaces after comma + realignment of tables; quite boring with -x -w
rubidium <rubidium@openttd.org>
parents: 20078
diff changeset
268 SLE_VAR(GoodsEntry, time_since_pickup, SLE_UINT8),
0ac217852174 (svn r25312) -Fix-ish: missing spaces after comma + realignment of tables; quite boring with -x -w
rubidium <rubidium@openttd.org>
parents: 20078
diff changeset
269 SLE_VAR(GoodsEntry, rating, SLE_UINT8),
0ac217852174 (svn r25312) -Fix-ish: missing spaces after comma + realignment of tables; quite boring with -x -w
rubidium <rubidium@openttd.org>
parents: 20078
diff changeset
270 SLEG_CONDVAR( _cargo_source, SLE_FILE_U8 | SLE_VAR_U16, 0, 6),
0ac217852174 (svn r25312) -Fix-ish: missing spaces after comma + realignment of tables; quite boring with -x -w
rubidium <rubidium@openttd.org>
parents: 20078
diff changeset
271 SLEG_CONDVAR( _cargo_source, SLE_UINT16, 7, 67),
0ac217852174 (svn r25312) -Fix-ish: missing spaces after comma + realignment of tables; quite boring with -x -w
rubidium <rubidium@openttd.org>
parents: 20078
diff changeset
272 SLEG_CONDVAR( _cargo_source_xy, SLE_UINT32, 44, 67),
0ac217852174 (svn r25312) -Fix-ish: missing spaces after comma + realignment of tables; quite boring with -x -w
rubidium <rubidium@openttd.org>
parents: 20078
diff changeset
273 SLEG_CONDVAR( _cargo_days, SLE_UINT8, 0, 67),
0ac217852174 (svn r25312) -Fix-ish: missing spaces after comma + realignment of tables; quite boring with -x -w
rubidium <rubidium@openttd.org>
parents: 20078
diff changeset
274 SLE_VAR(GoodsEntry, last_speed, SLE_UINT8),
0ac217852174 (svn r25312) -Fix-ish: missing spaces after comma + realignment of tables; quite boring with -x -w
rubidium <rubidium@openttd.org>
parents: 20078
diff changeset
275 SLE_VAR(GoodsEntry, last_age, SLE_UINT8),
0ac217852174 (svn r25312) -Fix-ish: missing spaces after comma + realignment of tables; quite boring with -x -w
rubidium <rubidium@openttd.org>
parents: 20078
diff changeset
276 SLEG_CONDVAR( _cargo_feeder_share, SLE_FILE_U32 | SLE_VAR_I64, 14, 64),
0ac217852174 (svn r25312) -Fix-ish: missing spaces after comma + realignment of tables; quite boring with -x -w
rubidium <rubidium@openttd.org>
parents: 20078
diff changeset
277 SLEG_CONDVAR( _cargo_feeder_share, SLE_INT64, 65, 67),
0ac217852174 (svn r25312) -Fix-ish: missing spaces after comma + realignment of tables; quite boring with -x -w
rubidium <rubidium@openttd.org>
parents: 20078
diff changeset
278 SLE_CONDVAR(GoodsEntry, amount_fract, SLE_UINT8, 150, SL_MAX_VERSION),
20403
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
279 SLEG_CONDLST( _packets, REF_CARGO_PACKET, 68, 182),
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
280 SLEG_CONDVAR( _num_dests, SLE_UINT32, 183, SL_MAX_VERSION),
20357
0ac217852174 (svn r25312) -Fix-ish: missing spaces after comma + realignment of tables; quite boring with -x -w
rubidium <rubidium@openttd.org>
parents: 20078
diff changeset
281 SLE_CONDVAR(GoodsEntry, cargo.reserved_count, SLE_UINT, 181, SL_MAX_VERSION),
20402
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
282 SLE_CONDVAR(GoodsEntry, link_graph, SLE_UINT16, 183, SL_MAX_VERSION),
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
283 SLE_CONDVAR(GoodsEntry, node, SLE_UINT16, 183, SL_MAX_VERSION),
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
284 SLEG_CONDVAR( _num_flows, SLE_UINT32, 183, SL_MAX_VERSION),
20404
ba40b7d45f7e (svn r25362) -Feature: consider cargo waiting at other stations for rating at the origin station
fonsinchen <fonsinchen@openttd.org>
parents: 20403
diff changeset
285 SLE_CONDVAR(GoodsEntry, max_waiting_cargo, SLE_UINT32, 183, SL_MAX_VERSION),
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
286 SLE_END()
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
287 };
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
288
11935
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
289 return goods_desc;
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
290 }
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
291
20403
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
292 typedef std::pair<const StationID, std::list<CargoPacket *> > StationCargoPair;
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
293
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
294 static const SaveLoad _cargo_list_desc[] = {
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
295 SLE_VAR(StationCargoPair, first, SLE_UINT16),
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
296 SLE_LST(StationCargoPair, second, REF_CARGO_PACKET),
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
297 SLE_END()
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
298 };
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
299
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
300 /**
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
301 * Swap the temporary packets with the packets without specific destination in
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
302 * the given goods entry. Assert that at least one of those is empty.
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
303 * @param ge Goods entry to swap with.
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
304 */
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
305 static void SwapPackets(GoodsEntry *ge)
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
306 {
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
307 StationCargoPacketMap &ge_packets = const_cast<StationCargoPacketMap &>(*ge->cargo.Packets());
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
308
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
309 if (_packets.empty()) {
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
310 std::map<StationID, std::list<CargoPacket *> >::iterator it(ge_packets.find(INVALID_STATION));
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
311 if (it == ge_packets.end()) {
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
312 return;
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
313 } else {
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
314 it->second.swap(_packets);
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
315 }
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
316 } else {
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
317 assert(ge_packets[INVALID_STATION].empty());
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
318 ge_packets[INVALID_STATION].swap(_packets);
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
319 }
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
320 }
11935
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
321
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
322 static void Load_STNS()
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
323 {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
324 int index;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
325 while ((index = SlIterateArray()) != -1) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
326 Station *st = new (index) Station();
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
327
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
328 SlObject(st, _old_station_desc);
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
329
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
330 _waiting_acceptance = 0;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
331
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16161
diff changeset
332 uint num_cargo = IsSavegameVersionBefore(55) ? 12 : NUM_CARGO;
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
333 for (CargoID i = 0; i < num_cargo; i++) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
334 GoodsEntry *ge = &st->goods[i];
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
335 SlObject(ge, GetGoodsDesc());
20403
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
336 SwapPackets(ge);
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16161
diff changeset
337 if (IsSavegameVersionBefore(68)) {
17756
6e539d6e9fe0 (svn r22540) -Codechange: Rename AcceptancePickup to GoodsEntryStatus.
terkhen <terkhen@openttd.org>
parents: 17406
diff changeset
338 SB(ge->acceptance_pickup, GoodsEntry::GES_ACCEPTANCE, 1, HasBit(_waiting_acceptance, 15));
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
339 if (GB(_waiting_acceptance, 0, 12) != 0) {
13298
f590f261c90a (svn r17807) -Codechange: move all 'updates' just after the 'load' constructor of CargoPackets to the constructor call itself
rubidium <rubidium@openttd.org>
parents: 13220
diff changeset
340 /* In old versions, enroute_from used 0xFF as INVALID_STATION */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16161
diff changeset
341 StationID source = (IsSavegameVersionBefore(7) && _cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
13298
f590f261c90a (svn r17807) -Codechange: move all 'updates' just after the 'load' constructor of CargoPackets to the constructor call itself
rubidium <rubidium@openttd.org>
parents: 13220
diff changeset
342
17285
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17058
diff changeset
343 /* Make sure we can allocate the CargoPacket. This is safe
18678
5604c42fa1ce (svn r23526) -Codechange: unify cargos vs cargoes
rubidium <rubidium@openttd.org>
parents: 17782
diff changeset
344 * as there can only be ~64k stations and 32 cargoes in these
17285
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17058
diff changeset
345 * savegame versions. As the CargoPacketPool has more than
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17058
diff changeset
346 * 16 million entries; it fits by an order of magnitude. */
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17058
diff changeset
347 assert(CargoPacket::CanAllocateItem());
20403
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
348
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
349 /* Don't construct the packet with station here, because that'll fail with old savegames */
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
350 CargoPacket *cp = new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_days, source, _cargo_source_xy, _cargo_source_xy, _cargo_feeder_share);
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
351 ge->cargo.Append(cp, INVALID_STATION);
17756
6e539d6e9fe0 (svn r22540) -Codechange: Rename AcceptancePickup to GoodsEntryStatus.
terkhen <terkhen@openttd.org>
parents: 17406
diff changeset
352 SB(ge->acceptance_pickup, GoodsEntry::GES_PICKUP, 1, 1);
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
353 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
354 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
355 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
356
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
357 if (st->num_specs != 0) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
358 /* Allocate speclist memory when loading a game */
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
359 st->speclist = CallocT<StationSpecList>(st->num_specs);
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
360 for (uint i = 0; i < st->num_specs; i++) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
361 SlObject(&st->speclist[i], _station_speclist_desc);
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
362 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
363 }
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
364 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
365 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
366
13509
59959bee9f95 (svn r18028) -Codechange: unglobalise some functions
rubidium <rubidium@openttd.org>
parents: 13307
diff changeset
367 static void Ptrs_STNS()
11935
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
368 {
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
369 /* Don't run when savegame version is higher than or equal to 123. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16161
diff changeset
370 if (!IsSavegameVersionBefore(123)) return;
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
371
11935
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
372 Station *st;
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
373 FOR_ALL_STATIONS(st) {
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16161
diff changeset
374 if (!IsSavegameVersionBefore(68)) {
11935
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
375 for (CargoID i = 0; i < NUM_CARGO; i++) {
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
376 GoodsEntry *ge = &st->goods[i];
20403
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
377 SwapPackets(ge);
11935
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
378 SlObject(ge, GetGoodsDesc());
20403
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
379 SwapPackets(ge);
11935
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
380 }
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
381 }
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
382 SlObject(st, _old_station_desc);
11935
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
383 }
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
384 }
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
385
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
386
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
387 static const SaveLoad _base_station_desc[] = {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
388 SLE_VAR(BaseStation, xy, SLE_UINT32),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
389 SLE_REF(BaseStation, town, REF_TOWN),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
390 SLE_VAR(BaseStation, string_id, SLE_STRINGID),
18788
49b58c8cab22 (svn r23636) -Add: introduce ScriptText in parameters where it can be used
truebrain <truebrain@openttd.org>
parents: 18678
diff changeset
391 SLE_STR(BaseStation, name, SLE_STR | SLF_ALLOW_CONTROL, 0),
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
392 SLE_VAR(BaseStation, delete_ctr, SLE_UINT8),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
393 SLE_VAR(BaseStation, owner, SLE_UINT8),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
394 SLE_VAR(BaseStation, facilities, SLE_UINT8),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
395 SLE_VAR(BaseStation, build_date, SLE_INT32),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
396
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
397 /* Used by newstations for graphic variations */
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
398 SLE_VAR(BaseStation, random_bits, SLE_UINT16),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
399 SLE_VAR(BaseStation, waiting_triggers, SLE_UINT8),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
400 SLE_VAR(BaseStation, num_specs, SLE_UINT8),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
401
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
402 SLE_END()
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
403 };
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
404
17782
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
405 static OldPersistentStorage _old_st_persistent_storage;
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
406
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
407 static const SaveLoad _station_desc[] = {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
408 SLE_WRITEBYTE(Station, facilities, FACIL_NONE),
12507
aca05c3349fd (svn r16944) -Codechange: remove needlessly complex way of getting the offset of items within a struct that are within a struct
rubidium <rubidium@openttd.org>
parents: 12475
diff changeset
409 SLE_ST_INCLUDE(),
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
410
12510
3e976121ced2 (svn r16947) -Codechange: use TileArea instead of train_tile, trainst_w and trainst_h.
rubidium <rubidium@openttd.org>
parents: 12507
diff changeset
411 SLE_VAR(Station, train_station.tile, SLE_UINT32),
14803
370107d8ee97 (svn r19392) -Codechange: Increase the maximum size of a TileArea.
terkhen <terkhen@openttd.org>
parents: 14793
diff changeset
412 SLE_VAR(Station, train_station.w, SLE_FILE_U8 | SLE_VAR_U16),
370107d8ee97 (svn r19392) -Codechange: Increase the maximum size of a TileArea.
terkhen <terkhen@openttd.org>
parents: 14793
diff changeset
413 SLE_VAR(Station, train_station.h, SLE_FILE_U8 | SLE_VAR_U16),
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
414
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
415 SLE_REF(Station, bus_stops, REF_ROADSTOPS),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
416 SLE_REF(Station, truck_stops, REF_ROADSTOPS),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
417 SLE_VAR(Station, dock_tile, SLE_UINT32),
14621
562ed276a7d0 (svn r19198) -Codechange: store the size of stations in savegames
yexo <yexo@openttd.org>
parents: 14258
diff changeset
418 SLE_VAR(Station, airport.tile, SLE_UINT32),
14803
370107d8ee97 (svn r19392) -Codechange: Increase the maximum size of a TileArea.
terkhen <terkhen@openttd.org>
parents: 14793
diff changeset
419 SLE_CONDVAR(Station, airport.w, SLE_FILE_U8 | SLE_VAR_U16, 140, SL_MAX_VERSION),
370107d8ee97 (svn r19392) -Codechange: Increase the maximum size of a TileArea.
terkhen <terkhen@openttd.org>
parents: 14793
diff changeset
420 SLE_CONDVAR(Station, airport.h, SLE_FILE_U8 | SLE_VAR_U16, 140, SL_MAX_VERSION),
14859
304d377a82af (svn r19455) -Codechange: split all airport information in Station to a seperate class
yexo <yexo@openttd.org>
parents: 14803
diff changeset
421 SLE_VAR(Station, airport.type, SLE_UINT8),
15699
9b29a5b1ae66 (svn r20365) -Codechange: allow multiple layouts for one airport statemachine, store the layout number
yexo <yexo@openttd.org>
parents: 15332
diff changeset
422 SLE_CONDVAR(Station, airport.layout, SLE_UINT8, 145, SL_MAX_VERSION),
14859
304d377a82af (svn r19455) -Codechange: split all airport information in Station to a seperate class
yexo <yexo@openttd.org>
parents: 14803
diff changeset
423 SLE_VAR(Station, airport.flags, SLE_UINT64),
15700
de46c7775be2 (svn r20366) -Codechange: store the rotation of the airport layout in the station struct and use it to rotate hangar tiles
yexo <yexo@openttd.org>
parents: 15699
diff changeset
424 SLE_CONDVAR(Station, airport.rotation, SLE_UINT8, 145, SL_MAX_VERSION),
17782
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
425 SLEG_CONDARR(_old_st_persistent_storage.storage, SLE_UINT32, 16, 145, 160),
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
426 SLE_CONDREF(Station, airport.psa, REF_STORAGE, 161, SL_MAX_VERSION),
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
427
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
428 SLE_VAR(Station, indtype, SLE_UINT8),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
429
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
430 SLE_VAR(Station, time_since_load, SLE_UINT8),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
431 SLE_VAR(Station, time_since_unload, SLE_UINT8),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
432 SLE_VAR(Station, last_vehicle_type, SLE_UINT8),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
433 SLE_VAR(Station, had_vehicle_of_type, SLE_UINT8),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
434 SLE_LST(Station, loading_vehicles, REF_VEHICLE),
13089
559dafab3ecb (svn r17589) -Codechange: rename town_acc to always_accepted
smatz <smatz@openttd.org>
parents: 12946
diff changeset
435 SLE_CONDVAR(Station, always_accepted, SLE_UINT32, 127, SL_MAX_VERSION),
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
436
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
437 SLE_END()
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
438 };
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
439
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
440 static const SaveLoad _waypoint_desc[] = {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
441 SLE_WRITEBYTE(Waypoint, facilities, FACIL_WAYPOINT),
12507
aca05c3349fd (svn r16944) -Codechange: remove needlessly complex way of getting the offset of items within a struct that are within a struct
rubidium <rubidium@openttd.org>
parents: 12475
diff changeset
442 SLE_ST_INCLUDE(),
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
443
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
444 SLE_VAR(Waypoint, town_cn, SLE_UINT16),
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
445
12555
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12550
diff changeset
446 SLE_CONDVAR(Waypoint, train_station.tile, SLE_UINT32, 124, SL_MAX_VERSION),
14803
370107d8ee97 (svn r19392) -Codechange: Increase the maximum size of a TileArea.
terkhen <terkhen@openttd.org>
parents: 14793
diff changeset
447 SLE_CONDVAR(Waypoint, train_station.w, SLE_FILE_U8 | SLE_VAR_U16, 124, SL_MAX_VERSION),
370107d8ee97 (svn r19392) -Codechange: Increase the maximum size of a TileArea.
terkhen <terkhen@openttd.org>
parents: 14793
diff changeset
448 SLE_CONDVAR(Waypoint, train_station.h, SLE_FILE_U8 | SLE_VAR_U16, 124, SL_MAX_VERSION),
12555
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12550
diff changeset
449
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
450 SLE_END()
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
451 };
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
452
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
453 /**
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
454 * Get the base station description to be used for SL_ST_INCLUDE
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
455 * @return the base station description.
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
456 */
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
457 const SaveLoad *GetBaseStationDescription()
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
458 {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
459 return _base_station_desc;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
460 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
461
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
462 static void RealSave_STNN(BaseStation *bst)
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
463 {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
464 bool waypoint = (bst->facilities & FACIL_WAYPOINT) != 0;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
465 SlObject(bst, waypoint ? _waypoint_desc : _station_desc);
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
466
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
467 if (!waypoint) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
468 Station *st = Station::From(bst);
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
469 for (CargoID i = 0; i < NUM_CARGO; i++) {
20403
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
470 _num_dests = (uint32)st->goods[i].cargo.Packets()->MapSize();
20402
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
471 _num_flows = 0;
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
472 for (FlowStatMap::const_iterator it(st->goods[i].flows.begin()); it != st->goods[i].flows.end(); ++it) {
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
473 _num_flows += (uint32)it->second.GetShares()->size();
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
474 }
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
475 SlObject(&st->goods[i], GetGoodsDesc());
20402
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
476 for (FlowStatMap::const_iterator outer_it(st->goods[i].flows.begin()); outer_it != st->goods[i].flows.end(); ++outer_it) {
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
477 const FlowStat::SharesMap *shares = outer_it->second.GetShares();
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
478 uint32 sum_shares = 0;
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
479 FlowSaveLoad flow;
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
480 flow.source = outer_it->first;
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
481 for (FlowStat::SharesMap::const_iterator inner_it(shares->begin()); inner_it != shares->end(); ++inner_it) {
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
482 flow.via = inner_it->second;
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
483 flow.share = inner_it->first - sum_shares;
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
484 sum_shares = inner_it->first;
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
485 assert(flow.share > 0);
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
486 SlObject(&flow, _flow_desc);
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
487 }
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
488 }
20403
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
489 for (StationCargoPacketMap::ConstMapIterator it(st->goods[i].cargo.Packets()->begin()); it != st->goods[i].cargo.Packets()->end(); ++it) {
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
490 SlObject(const_cast<StationCargoPacketMap::value_type *>(&(*it)), _cargo_list_desc);
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
491 }
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
492 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
493 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
494
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
495 for (uint i = 0; i < bst->num_specs; i++) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
496 SlObject(&bst->speclist[i], _station_speclist_desc);
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
497 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
498 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
499
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
500 static void Save_STNN()
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
501 {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
502 BaseStation *st;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
503 /* Write the stations */
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
504 FOR_ALL_BASE_STATIONS(st) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
505 SlSetArrayIndex(st->index);
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
506 SlAutolength((AutolengthProc*)RealSave_STNN, st);
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
507 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
508 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
509
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
510 static void Load_STNN()
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
511 {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
512 int index;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
513
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
514 while ((index = SlIterateArray()) != -1) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
515 bool waypoint = (SlReadByte() & FACIL_WAYPOINT) != 0;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
516
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
517 BaseStation *bst = waypoint ? (BaseStation *)new (index) Waypoint() : new (index) Station();
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
518 SlObject(bst, waypoint ? _waypoint_desc : _station_desc);
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
519
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
520 if (!waypoint) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
521 Station *st = Station::From(bst);
17782
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
522
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
523 /* Before savegame version 161, persistent storages were not stored in a pool. */
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
524 if (IsSavegameVersionBefore(161) && !IsSavegameVersionBefore(145) && st->facilities & FACIL_AIRPORT) {
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
525 /* Store the old persistent storage. The GRFID will be added later. */
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
526 assert(PersistentStorage::CanAllocateItem());
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
527 st->airport.psa = new PersistentStorage(0);
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
528 memcpy(st->airport.psa->storage, _old_st_persistent_storage.storage, sizeof(st->airport.psa->storage));
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
529 }
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
530
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
531 for (CargoID i = 0; i < NUM_CARGO; i++) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
532 SlObject(&st->goods[i], GetGoodsDesc());
20402
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
533 FlowSaveLoad flow;
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
534 FlowStat *fs = NULL;
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
535 StationID prev_source = INVALID_STATION;
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
536 for (uint32 j = 0; j < _num_flows; ++j) {
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
537 SlObject(&flow, _flow_desc);
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
538 if (fs == NULL || prev_source != flow.source) {
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
539 fs = &(st->goods[i].flows.insert(std::make_pair(flow.source, FlowStat(flow.via, flow.share))).first->second);
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
540 } else {
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
541 fs->AppendShare(flow.via, flow.share);
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
542 }
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
543 prev_source = flow.source;
b0c2445b94b7 (svn r25360) -Codechange: save and load flow stats
fonsinchen <fonsinchen@openttd.org>
parents: 20382
diff changeset
544 }
20403
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
545 if (IsSavegameVersionBefore(183)) {
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
546 SwapPackets(&st->goods[i]);
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
547 } else {
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
548 StationCargoPair pair;
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
549 for (uint j = 0; j < _num_dests; ++j) {
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
550 SlObject(&pair, _cargo_list_desc);
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
551 const_cast<StationCargoPacketMap &>(*(st->goods[i].cargo.Packets()))[pair.first].swap(pair.second);
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
552 assert(pair.second.empty());
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
553 }
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
554 }
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
555 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
556 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
557
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
558 if (bst->num_specs != 0) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
559 /* Allocate speclist memory when loading a game */
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
560 bst->speclist = CallocT<StationSpecList>(bst->num_specs);
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
561 for (uint i = 0; i < bst->num_specs; i++) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
562 SlObject(&bst->speclist[i], _station_speclist_desc);
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
563 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
564 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
565 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
566 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
567
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
568 static void Ptrs_STNN()
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
569 {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
570 /* Don't run when savegame version lower than 123. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16161
diff changeset
571 if (IsSavegameVersionBefore(123)) return;
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
572
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
573 Station *st;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
574 FOR_ALL_STATIONS(st) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
575 for (CargoID i = 0; i < NUM_CARGO; i++) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
576 GoodsEntry *ge = &st->goods[i];
20403
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
577 if (IsSavegameVersionBefore(183)) {
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
578 SwapPackets(ge);
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
579 SlObject(ge, GetGoodsDesc());
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
580 SwapPackets(ge);
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
581 } else {
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
582 SlObject(ge, GetGoodsDesc());
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
583 for (StationCargoPacketMap::ConstMapIterator it = ge->cargo.Packets()->begin(); it != ge->cargo.Packets()->end(); ++it) {
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
584 SlObject(const_cast<StationCargoPair *>(&(*it)), _cargo_list_desc);
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
585 }
100fee8ec68e (svn r25361) -Feature: distribute cargo according to plan given by linkgraph
fonsinchen <fonsinchen@openttd.org>
parents: 20402
diff changeset
586 }
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
587 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
588 SlObject(st, _station_desc);
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
589 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
590
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
591 Waypoint *wp;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
592 FOR_ALL_WAYPOINTS(wp) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
593 SlObject(wp, _waypoint_desc);
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
594 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
595 }
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12318
diff changeset
596
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
597 static void Save_ROADSTOP()
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
598 {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
599 RoadStop *rs;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
600
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
601 FOR_ALL_ROADSTOPS(rs) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
602 SlSetArrayIndex(rs->index);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
603 SlObject(rs, _roadstop_desc);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
604 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
605 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
606
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
607 static void Load_ROADSTOP()
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
608 {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
609 int index;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
610
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
611 while ((index = SlIterateArray()) != -1) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
612 RoadStop *rs = new (index) RoadStop(INVALID_TILE);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
613
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
614 SlObject(rs, _roadstop_desc);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
615 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
616 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
617
11935
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
618 static void Ptrs_ROADSTOP()
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
619 {
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
620 RoadStop *rs;
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
621 FOR_ALL_ROADSTOPS(rs) {
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
622 SlObject(rs, _roadstop_desc);
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
623 }
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
624 }
afd8caa1ae0d (svn r16338) -Codechange: split loading of references to two phases
smatz <smatz@openttd.org>
parents: 11925
diff changeset
625
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
626 extern const ChunkHandler _station_chunk_handlers[] = {
15332
e2d08cace39d (svn r19973) -Codechange: Add another procedure to chunk handlers for checking savegames (empty for now).
frosch <frosch@openttd.org>
parents: 14859
diff changeset
627 { 'STNS', NULL, Load_STNS, Ptrs_STNS, NULL, CH_ARRAY },
e2d08cace39d (svn r19973) -Codechange: Add another procedure to chunk handlers for checking savegames (empty for now).
frosch <frosch@openttd.org>
parents: 14859
diff changeset
628 { 'STNN', Save_STNN, Load_STNN, Ptrs_STNN, NULL, CH_ARRAY },
e2d08cace39d (svn r19973) -Codechange: Add another procedure to chunk handlers for checking savegames (empty for now).
frosch <frosch@openttd.org>
parents: 14859
diff changeset
629 { 'ROAD', Save_ROADSTOP, Load_ROADSTOP, Ptrs_ROADSTOP, NULL, CH_ARRAY | CH_LAST},
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
630 };