Mercurial > hg > openttd
annotate src/saveload/afterload.cpp @ 12228:240adc64d01a draft
(svn r16643) -Codechange: replace GetStationByTile() by Station::GetByTile()
author | smatz <smatz@openttd.org> |
---|---|
date | Wed, 24 Jun 2009 17:39:54 +0000 |
parents | 4f649aa97318 |
children | b1d30d9d4025 |
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 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
3 /** @file afterload.cpp Code updating data after game load */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
4 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
5 #include "../stdafx.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
6 #include "../void_map.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
7 #include "../signs_base.h" |
12225
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
12156
diff
changeset
|
8 #include "../roadstop_base.h" |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
9 #include "../window_func.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
10 #include "../fios.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
11 #include "../train.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
12 #include "../string_func.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
13 #include "../gamelog.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
14 #include "../network/network.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
15 #include "../gfxinit.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
16 #include "../functions.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
17 #include "../industry_map.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
18 #include "../town_map.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
19 #include "../clear_map.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
20 #include "../vehicle_func.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
21 #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
|
22 #include "../yapf/yapf.hpp" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
23 #include "../elrail_func.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
24 #include "../signs_func.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
25 #include "../aircraft.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
26 #include "../unmovable_map.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
27 #include "../tree_map.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
28 #include "../company_func.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
29 #include "../road_cmd.h" |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10647
diff
changeset
|
30 #include "../ai/ai.hpp" |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
31 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
32 #include "table/strings.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
33 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
34 #include "saveload_internal.h" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
35 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
36 #include <signal.h> |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
37 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
38 extern StringID _switch_mode_errorstr; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
39 extern Company *DoStartupNewCompany(bool is_ai); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
40 extern void InitializeRailGUI(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
41 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
42 /** |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
43 * Makes a tile canal or water depending on the surroundings. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
44 * |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
45 * Must only be used for converting old savegames. Use WaterClass now. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
46 * |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
47 * This as for example docks and shipdepots do not store |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
48 * whether the tile used to be canal or 'normal' water. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
49 * @param t the tile to change. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
50 * @param o the owner of the new tile. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
51 * @param include_invalid_water_class Also consider WATER_CLASS_INVALID, i.e. industry tiles on land |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
52 */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
53 void SetWaterClassDependingOnSurroundings(TileIndex t, bool include_invalid_water_class) |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
54 { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
55 /* If the slope is not flat, we always assume 'land' (if allowed). Also for one-corner-raised-shores. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
56 * Note: Wrt. autosloping under industry tiles this is the most fool-proof behaviour. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
57 if (GetTileSlope(t, NULL) != SLOPE_FLAT) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
58 if (include_invalid_water_class) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
59 SetWaterClass(t, WATER_CLASS_INVALID); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
60 return; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
61 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
62 NOT_REACHED(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
63 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
64 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
65 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
66 /* Mark tile dirty in all cases */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
67 MarkTileDirtyByTile(t); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
68 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
69 if (TileX(t) == 0 || TileY(t) == 0 || TileX(t) == MapMaxX() - 1 || TileY(t) == MapMaxY() - 1) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
70 /* tiles at map borders are always WATER_CLASS_SEA */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
71 SetWaterClass(t, WATER_CLASS_SEA); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
72 return; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
73 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
74 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
75 bool has_water = false; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
76 bool has_canal = false; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
77 bool has_river = false; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
78 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
79 for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
80 TileIndex neighbour = TileAddByDiagDir(t, dir); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
81 switch (GetTileType(neighbour)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
82 case MP_WATER: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
83 /* clear water and shipdepots have already a WaterClass associated */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
84 if (IsCoast(neighbour)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
85 has_water = true; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
86 } else if (!IsLock(neighbour)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
87 switch (GetWaterClass(neighbour)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
88 case WATER_CLASS_SEA: has_water = true; break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
89 case WATER_CLASS_CANAL: has_canal = true; break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
90 case WATER_CLASS_RIVER: has_river = true; break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
91 default: NOT_REACHED(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
92 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
93 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
94 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
95 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
96 case MP_RAILWAY: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
97 /* Shore or flooded halftile */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
98 has_water |= (GetRailGroundType(neighbour) == RAIL_GROUND_WATER); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
99 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
100 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
101 case MP_TREES: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
102 /* trees on shore */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
103 has_water |= (GetTreeGround(neighbour) == TREE_GROUND_SHORE); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
104 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
105 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
106 default: break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
107 } |
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 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
110 if (!has_water && !has_canal && !has_river && include_invalid_water_class) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
111 SetWaterClass(t, WATER_CLASS_INVALID); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
112 return; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
113 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
114 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
115 if (has_river && !has_canal) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
116 SetWaterClass(t, WATER_CLASS_RIVER); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
117 } else if (has_canal || !has_water) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
118 SetWaterClass(t, WATER_CLASS_CANAL); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
119 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
120 SetWaterClass(t, WATER_CLASS_SEA); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
121 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
122 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
123 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
124 static void ConvertTownOwner() |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
125 { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
126 for (TileIndex tile = 0; tile != MapSize(); tile++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
127 switch (GetTileType(tile)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
128 case MP_ROAD: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
129 if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HasBit(_m[tile].m3, 7)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
130 _m[tile].m3 = OWNER_TOWN; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
131 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
132 /* FALLTHROUGH */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
133 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
134 case MP_TUNNELBRIDGE: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
135 if (GetTileOwner(tile) & 0x80) SetTileOwner(tile, OWNER_TOWN); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
136 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
137 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
138 default: break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
139 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
140 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
141 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
142 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
143 /* since savegame version 4.1, exclusive transport rights are stored at towns */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
144 static void UpdateExclusiveRights() |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
145 { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
146 Town *t; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
147 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
148 FOR_ALL_TOWNS(t) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
149 t->exclusivity = INVALID_COMPANY; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
150 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
151 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
152 /* FIXME old exclusive rights status is not being imported (stored in s->blocked_months_obsolete) |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
153 * could be implemented this way: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
154 * 1.) Go through all stations |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
155 * Build an array town_blocked[ town_id ][ company_id ] |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
156 * that stores if at least one station in that town is blocked for a company |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
157 * 2.) Go through that array, if you find a town that is not blocked for |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
158 * one company, but for all others, then give him exclusivity. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
159 */ |
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 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
162 static const byte convert_currency[] = { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
163 0, 1, 12, 8, 3, |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
164 10, 14, 19, 4, 5, |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
165 9, 11, 13, 6, 17, |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
166 16, 22, 21, 7, 15, |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
167 18, 2, 20, |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
168 }; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
169 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
170 /* since savegame version 4.2 the currencies are arranged differently */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
171 static void UpdateCurrencies() |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
172 { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
173 _settings_game.locale.currency = convert_currency[_settings_game.locale.currency]; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
174 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
175 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
176 /* Up to revision 1413 the invisible tiles at the southern border have not been |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
177 * MP_VOID, even though they should have. This is fixed by this function |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
178 */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
179 static void UpdateVoidTiles() |
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 uint i; |
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 for (i = 0; i < MapMaxY(); ++i) MakeVoid(i * MapSizeX() + MapMaxX()); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
184 for (i = 0; i < MapSizeX(); ++i) MakeVoid(MapSizeX() * MapMaxY() + i); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
185 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
186 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
187 static inline RailType UpdateRailType(RailType rt, RailType min) |
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 return rt >= min ? (RailType)(rt + 1): rt; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
190 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
191 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
192 /** |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
193 * Initialization of the windows and several kinds of caches. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
194 * This is not done directly in AfterLoadGame because these |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
195 * functions require that all saveload conversions have been |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
196 * done. As people tend to add savegame conversion stuff after |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
197 * the intialization of the windows and caches quite some bugs |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
198 * had been made. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
199 * Moving this out of there is both cleaner and less bug-prone. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
200 * |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
201 * @return true if everything went according to plan, otherwise false. |
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 static bool InitializeWindowsAndCaches() |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
204 { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
205 /* Initialize windows */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
206 ResetWindowSystem(); |
11085
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
11069
diff
changeset
|
207 SetupColoursAndInitialWindow(); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
208 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
209 ResetViewportAfterLoadGame(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
210 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
211 /* Update coordinates of the signs. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
212 UpdateAllStationVirtCoord(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
213 UpdateAllSignVirtCoords(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
214 UpdateAllTownVirtCoords(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
215 UpdateAllWaypointSigns(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
216 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
217 Company *c; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
218 FOR_ALL_COMPANIES(c) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
219 /* For each company, verify (while loading a scenario) that the inauguration date is the current year and set it |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
220 * accordingly if it is not the case. No need to set it on companies that are not been used already, |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
221 * thus the MIN_YEAR (which is really nothing more than Zero, initialized value) test */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
222 if (_file_to_saveload.filetype == FT_SCENARIO && c->inaugurated_year != MIN_YEAR) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
223 c->inaugurated_year = _cur_year; |
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 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
227 SetCachedEngineCounts(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
228 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
229 /* Towns have a noise controlled number of airports system |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
230 * So each airport's noise value must be added to the town->noise_reached value |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
231 * Reset each town's noise_reached value to '0' before. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
232 UpdateAirportsNoise(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
233 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
234 CheckTrainsLengths(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
235 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
236 return true; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
237 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
238 |
11948
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
239 typedef void (CDECL *SignalHandlerPointer)(int); |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
240 static SignalHandlerPointer _prev_segfault = NULL; |
12156
292dc6ec679f
(svn r16572) -Codechange: also catch FPEs in saveload and the warning about missing NewGRFs; only happens when assertions are disabled and NewGRFs are missing.
rubidium <rubidium@openttd.org>
parents:
12137
diff
changeset
|
241 static SignalHandlerPointer _prev_abort = NULL; |
292dc6ec679f
(svn r16572) -Codechange: also catch FPEs in saveload and the warning about missing NewGRFs; only happens when assertions are disabled and NewGRFs are missing.
rubidium <rubidium@openttd.org>
parents:
12137
diff
changeset
|
242 static SignalHandlerPointer _prev_fpe = NULL; |
11948
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
243 |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
244 static void CDECL HandleSavegameLoadCrash(int signum); |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
245 |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
246 /** |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
247 * Replaces signal handlers of SIGSEGV and SIGABRT |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
248 * and stores pointers to original handlers in memory. |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
249 */ |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
250 static void SetSignalHandlers() |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
251 { |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
252 _prev_segfault = signal(SIGSEGV, HandleSavegameLoadCrash); |
12156
292dc6ec679f
(svn r16572) -Codechange: also catch FPEs in saveload and the warning about missing NewGRFs; only happens when assertions are disabled and NewGRFs are missing.
rubidium <rubidium@openttd.org>
parents:
12137
diff
changeset
|
253 _prev_abort = signal(SIGABRT, HandleSavegameLoadCrash); |
292dc6ec679f
(svn r16572) -Codechange: also catch FPEs in saveload and the warning about missing NewGRFs; only happens when assertions are disabled and NewGRFs are missing.
rubidium <rubidium@openttd.org>
parents:
12137
diff
changeset
|
254 _prev_fpe = signal(SIGFPE, HandleSavegameLoadCrash); |
11948
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
255 } |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
256 |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
257 /** |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
258 * Resets signal handlers back to original handlers. |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
259 */ |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
260 static void ResetSignalHandlers() |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
261 { |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
262 signal(SIGSEGV, _prev_segfault); |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
263 signal(SIGABRT, _prev_abort); |
12156
292dc6ec679f
(svn r16572) -Codechange: also catch FPEs in saveload and the warning about missing NewGRFs; only happens when assertions are disabled and NewGRFs are missing.
rubidium <rubidium@openttd.org>
parents:
12137
diff
changeset
|
264 signal(SIGFPE, _prev_fpe); |
11948
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
265 } |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
266 |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
267 /** |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
268 * Signal handler used to give a user a more useful report for crashes during |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
269 * the savegame loading process; especially when there's problems with the |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
270 * NewGRFs that are required by the savegame. |
11948
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
271 * @param signum received signal |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
272 */ |
11948
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
273 static void CDECL HandleSavegameLoadCrash(int signum) |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
274 { |
11948
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
275 ResetSignalHandlers(); |
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
276 |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
277 char buffer[8192]; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
278 char *p = buffer; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
279 p += seprintf(p, lastof(buffer), |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
280 "Loading your savegame caused OpenTTD to crash.\n" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
281 "This is most likely caused by a missing NewGRF or a NewGRF that has been\n" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
282 "loaded as replacement for a missing NewGRF. OpenTTD cannot easily\n" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
283 "determine whether a replacement NewGRF is of a newer or older version.\n" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
284 "It will load a NewGRF with the same GRF ID as the missing NewGRF. This\n" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
285 "means that if the author makes incompatible NewGRFs with the same GRF ID\n" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
286 "OpenTTD cannot magically do the right thing. In most cases OpenTTD will\n" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
287 "load the savegame and not crash, but this is an exception.\n" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
288 "Please load the savegame with the appropriate NewGRFs. When loading a\n" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
289 "savegame still crashes when all NewGRFs are found you should file a\n" |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
290 "bug report. The missing NewGRFs are:\n"); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
291 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
292 for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
293 if (HasBit(c->flags, GCF_COMPATIBLE)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
294 char buf[40]; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
295 md5sumToString(buf, lastof(buf), c->md5sum); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
296 p += seprintf(p, lastof(buffer), "NewGRF %08X (%s) not found; checksum %s. Tried another NewGRF with same GRF ID\n", BSWAP32(c->grfid), c->filename, buf); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
297 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
298 if (c->status == GCS_NOT_FOUND) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
299 char buf[40]; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
300 md5sumToString(buf, lastof(buf), c->md5sum); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
301 p += seprintf(p, lastof(buffer), "NewGRF %08X (%s) not found; checksum %s\n", BSWAP32(c->grfid), c->filename, buf); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
302 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
303 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
304 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
305 ShowInfo(buffer); |
11948
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
306 |
12156
292dc6ec679f
(svn r16572) -Codechange: also catch FPEs in saveload and the warning about missing NewGRFs; only happens when assertions are disabled and NewGRFs are missing.
rubidium <rubidium@openttd.org>
parents:
12137
diff
changeset
|
307 SignalHandlerPointer call = NULL; |
292dc6ec679f
(svn r16572) -Codechange: also catch FPEs in saveload and the warning about missing NewGRFs; only happens when assertions are disabled and NewGRFs are missing.
rubidium <rubidium@openttd.org>
parents:
12137
diff
changeset
|
308 switch (signum) { |
292dc6ec679f
(svn r16572) -Codechange: also catch FPEs in saveload and the warning about missing NewGRFs; only happens when assertions are disabled and NewGRFs are missing.
rubidium <rubidium@openttd.org>
parents:
12137
diff
changeset
|
309 case SIGSEGV: call = _prev_segfault; break; |
292dc6ec679f
(svn r16572) -Codechange: also catch FPEs in saveload and the warning about missing NewGRFs; only happens when assertions are disabled and NewGRFs are missing.
rubidium <rubidium@openttd.org>
parents:
12137
diff
changeset
|
310 case SIGABRT: call = _prev_abort; break; |
292dc6ec679f
(svn r16572) -Codechange: also catch FPEs in saveload and the warning about missing NewGRFs; only happens when assertions are disabled and NewGRFs are missing.
rubidium <rubidium@openttd.org>
parents:
12137
diff
changeset
|
311 case SIGFPE: call = _prev_fpe; break; |
292dc6ec679f
(svn r16572) -Codechange: also catch FPEs in saveload and the warning about missing NewGRFs; only happens when assertions are disabled and NewGRFs are missing.
rubidium <rubidium@openttd.org>
parents:
12137
diff
changeset
|
312 default: NOT_REACHED(); |
292dc6ec679f
(svn r16572) -Codechange: also catch FPEs in saveload and the warning about missing NewGRFs; only happens when assertions are disabled and NewGRFs are missing.
rubidium <rubidium@openttd.org>
parents:
12137
diff
changeset
|
313 } |
11948
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
314 if (call != NULL) call(signum); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
315 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
316 |
10848
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
317 /** |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
318 * Tries to change owner of this rail tile to a valid owner. In very old versions it could happen that |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
319 * a rail track had an invalid owner. When conversion isn't possible, track is removed. |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
320 * @param t tile to update |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
321 */ |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
322 static void FixOwnerOfRailTrack(TileIndex t) |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
323 { |
11924
fccc9cea27a7
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents:
11922
diff
changeset
|
324 assert(!Company::IsValidID(GetTileOwner(t)) && (IsLevelCrossingTile(t) || IsPlainRailTile(t))); |
10848
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
325 |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
326 /* remove leftover rail piece from crossing (from very old savegames) */ |
12035
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
327 Train *v = NULL, *w; |
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
328 FOR_ALL_TRAINS(w) { |
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
329 if (w->tile == t) { |
10848
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
330 v = w; |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
331 break; |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
332 } |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
333 } |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
334 |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
335 if (v != NULL) { |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
336 /* when there is a train on crossing (it could happen in TTD), set owner of crossing to train owner */ |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
337 SetTileOwner(t, v->owner); |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
338 return; |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
339 } |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
340 |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
341 /* try to find any connected rail */ |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
342 for (DiagDirection dd = DIAGDIR_BEGIN; dd < DIAGDIR_END; dd++) { |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
343 TileIndex tt = t + TileOffsByDiagDir(dd); |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
344 if (GetTileTrackStatus(t, TRANSPORT_RAIL, 0, dd) != 0 && |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
345 GetTileTrackStatus(tt, TRANSPORT_RAIL, 0, ReverseDiagDir(dd)) != 0 && |
11924
fccc9cea27a7
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents:
11922
diff
changeset
|
346 Company::IsValidID(GetTileOwner(tt))) { |
10848
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
347 SetTileOwner(t, GetTileOwner(tt)); |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
348 return; |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
349 } |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
350 } |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
351 |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
352 if (IsLevelCrossingTile(t)) { |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
353 /* else change the crossing to normal road (road vehicles won't care) */ |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
354 MakeRoadNormal(t, GetCrossingRoadBits(t), GetRoadTypes(t), GetTownIndex(t), |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
355 GetRoadOwner(t, ROADTYPE_ROAD), GetRoadOwner(t, ROADTYPE_TRAM)); |
10848
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
356 return; |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
357 } |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
358 |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
359 /* if it's not a crossing, make it clean land */ |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
360 MakeClear(t, CLEAR_GRASS, 0); |
51cf93516bd6
(svn r15183) -Fix: stand-alone rail tiles with invalid owner were not removed. Also, make the whole check a bit more intelligent.
smatz <smatz@openttd.org>
parents:
10846
diff
changeset
|
361 } |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
362 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
363 bool AfterLoadGame() |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
364 { |
11948
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
365 SetSignalHandlers(); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
366 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
367 TileIndex map_size = MapSize(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
368 Company *c; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
369 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
370 if (CheckSavegameVersion(98)) GamelogOldver(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
371 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
372 GamelogTestRevision(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
373 GamelogTestMode(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
374 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
375 if (CheckSavegameVersion(98)) GamelogGRFAddList(_grfconfig); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
376 |
11852
862dd1024fe7
(svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents:
11657
diff
changeset
|
377 if (CheckSavegameVersion(119)) { |
862dd1024fe7
(svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents:
11657
diff
changeset
|
378 _pause_mode = (_pause_mode == 2) ? PM_PAUSED_NORMAL : PM_UNPAUSED; |
862dd1024fe7
(svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents:
11657
diff
changeset
|
379 } |
862dd1024fe7
(svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents:
11657
diff
changeset
|
380 |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
381 /* in very old versions, size of train stations was stored differently */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
382 if (CheckSavegameVersion(2)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
383 Station *st; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
384 FOR_ALL_STATIONS(st) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
385 if (st->train_tile != 0 && st->trainst_h == 0) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
386 uint n = _savegame_type == SGT_OTTD ? 4 : 3; // OTTD uses 4 bits per dimensions, TTD 3 bits |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
387 uint w = GB(st->trainst_w, n, n); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
388 uint h = GB(st->trainst_w, 0, n); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
389 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
390 if (GetRailStationAxis(st->train_tile) != AXIS_X) Swap(w, h); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
391 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
392 st->trainst_w = w; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
393 st->trainst_h = h; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
394 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
395 assert(GetStationIndex(st->train_tile + TileDiffXY(w - 1, h - 1)) == st->index); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
396 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
397 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
398 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
399 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
400 /* in version 2.1 of the savegame, town owner was unified. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
401 if (CheckSavegameVersionOldStyle(2, 1)) ConvertTownOwner(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
402 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
403 /* from version 4.1 of the savegame, exclusive rights are stored at towns */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
404 if (CheckSavegameVersionOldStyle(4, 1)) UpdateExclusiveRights(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
405 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
406 /* from version 4.2 of the savegame, currencies are in a different order */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
407 if (CheckSavegameVersionOldStyle(4, 2)) UpdateCurrencies(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
408 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
409 /* In old version there seems to be a problem that water is owned by |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
410 * OWNER_NONE, not OWNER_WATER.. I can't replicate it for the current |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
411 * (4.3) version, so I just check when versions are older, and then |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
412 * walk through the whole map.. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
413 if (CheckSavegameVersionOldStyle(4, 3)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
414 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
415 if (IsTileType(t, MP_WATER) && GetTileOwner(t) >= MAX_COMPANIES) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
416 SetTileOwner(t, OWNER_WATER); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
417 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
418 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
419 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
420 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
421 if (CheckSavegameVersion(84)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
422 FOR_ALL_COMPANIES(c) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
423 c->name = CopyFromOldName(c->name_1); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
424 if (c->name != NULL) c->name_1 = STR_SV_UNNAMED; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
425 c->president_name = CopyFromOldName(c->president_name_1); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
426 if (c->president_name != NULL) c->president_name_1 = SPECSTR_PRESIDENT_NAME; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
427 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
428 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
429 Station *st; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
430 FOR_ALL_STATIONS(st) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
431 st->name = CopyFromOldName(st->string_id); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
432 /* generating new name would be too much work for little effect, use the station name fallback */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
433 if (st->name != NULL) st->string_id = STR_SV_STNAME_FALLBACK; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
434 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
435 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
436 Town *t; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
437 FOR_ALL_TOWNS(t) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
438 t->name = CopyFromOldName(t->townnametype); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
439 if (t->name != NULL) t->townnametype = SPECSTR_TOWNNAME_START + _settings_game.game_creation.town_name; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
440 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
441 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
442 Waypoint *wp; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
443 FOR_ALL_WAYPOINTS(wp) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
444 wp->name = CopyFromOldName(wp->string); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
445 wp->string = STR_EMPTY; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
446 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
447 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
448 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
449 /* From this point the old names array is cleared. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
450 ResetOldNames(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
451 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
452 if (CheckSavegameVersion(106)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
453 /* no station is determined by 'tile == INVALID_TILE' now (instead of '0') */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
454 Station *st; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
455 FOR_ALL_STATIONS(st) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
456 if (st->airport_tile == 0) st->airport_tile = INVALID_TILE; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
457 if (st->dock_tile == 0) st->dock_tile = INVALID_TILE; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
458 if (st->train_tile == 0) st->train_tile = INVALID_TILE; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
459 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
460 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
461 /* the same applies to Company::location_of_HQ */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
462 Company *c; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
463 FOR_ALL_COMPANIES(c) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
464 if (c->location_of_HQ == 0 || (CheckSavegameVersion(4) && c->location_of_HQ == 0xFFFF)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
465 c->location_of_HQ = INVALID_TILE; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
466 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
467 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
468 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
469 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
470 /* convert road side to my format. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
471 if (_settings_game.vehicle.road_side) _settings_game.vehicle.road_side = 1; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
472 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
473 /* Check if all NewGRFs are present, we are very strict in MP mode */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
474 GRFListCompatibility gcf_res = IsGoodGRFConfigList(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
475 if (_networking && gcf_res != GLC_ALL_GOOD) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
476 SetSaveLoadError(STR_NETWORK_ERR_CLIENT_NEWGRF_MISMATCH); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
477 /* Restore the signals */ |
11948
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
478 ResetSignalHandlers(); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
479 return false; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
480 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
481 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
482 switch (gcf_res) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
483 case GLC_COMPATIBLE: _switch_mode_errorstr = STR_NEWGRF_COMPATIBLE_LOAD_WARNING; break; |
11852
862dd1024fe7
(svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents:
11657
diff
changeset
|
484 case GLC_NOT_FOUND: _switch_mode_errorstr = STR_NEWGRF_DISABLED_WARNING; _pause_mode = PM_PAUSED_ERROR; break; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
485 default: break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
486 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
487 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
488 /* Update current year |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
489 * must be done before loading sprites as some newgrfs check it */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
490 SetDate(_date); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
491 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
492 /* Force dynamic engines off when loading older savegames */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
493 if (CheckSavegameVersion(95)) _settings_game.vehicle.dynamic_engines = 0; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
494 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
495 /* Load the sprites */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
496 GfxLoadSprites(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
497 LoadStringWidthTable(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
498 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
499 /* Copy temporary data to Engine pool */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
500 CopyTempEngineData(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
501 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
502 /* Connect front and rear engines of multiheaded trains and converts |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
503 * subtype to the new format */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
504 if (CheckSavegameVersionOldStyle(17, 1)) ConvertOldMultiheadToNew(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
505 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
506 /* Connect front and rear engines of multiheaded trains */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
507 ConnectMultiheadedTrains(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
508 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
509 /* reinit the landscape variables (landscape might have changed) */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
510 InitializeLandscapeVariables(true); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
511 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
512 /* Update all vehicles */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
513 AfterLoadVehicles(true); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
514 |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10647
diff
changeset
|
515 /* Make sure there is an AI attached to an AI company */ |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10647
diff
changeset
|
516 { |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10647
diff
changeset
|
517 Company *c; |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10647
diff
changeset
|
518 FOR_ALL_COMPANIES(c) { |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10647
diff
changeset
|
519 if (c->is_ai && c->ai_instance == NULL) AI::StartNew(c->index); |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10647
diff
changeset
|
520 } |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10647
diff
changeset
|
521 } |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10647
diff
changeset
|
522 |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
523 /* Update all waypoints */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
524 if (CheckSavegameVersion(12)) FixOldWaypoints(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
525 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
526 /* make sure there is a town in the game */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
527 if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, UINT_MAX)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
528 SetSaveLoadError(STR_NO_TOWN_IN_SCENARIO); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
529 /* Restore the signals */ |
11948
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
530 ResetSignalHandlers(); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
531 return false; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
532 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
533 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
534 /* The void tiles on the southern border used to belong to a wrong class (pre 4.3). |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
535 * This problem appears in savegame version 21 too, see r3455. But after loading the |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
536 * savegame and saving again, the buggy map array could be converted to new savegame |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
537 * version. It didn't show up before r12070. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
538 if (CheckSavegameVersion(87)) UpdateVoidTiles(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
539 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
540 /* If Load Scenario / New (Scenario) Game is used, |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
541 * a company does not exist yet. So create one here. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
542 * 1 exeption: network-games. Those can have 0 companies |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
543 * But this exeption is not true for non dedicated network_servers! */ |
11924
fccc9cea27a7
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents:
11922
diff
changeset
|
544 if (!Company::IsValidID(COMPANY_FIRST) && (!_networking || (_networking && _network_server && !_network_dedicated))) |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
545 DoStartupNewCompany(false); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
546 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
547 if (CheckSavegameVersion(72)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
548 /* Locks/shiplifts in very old savegames had OWNER_WATER as owner */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
549 for (TileIndex t = 0; t < MapSize(); t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
550 switch (GetTileType(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
551 default: break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
552 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
553 case MP_WATER: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
554 if (GetWaterTileType(t) == WATER_TILE_LOCK && GetTileOwner(t) == OWNER_WATER) SetTileOwner(t, OWNER_NONE); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
555 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
556 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
557 case MP_STATION: { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
558 if (HasBit(_m[t].m6, 3)) SetBit(_m[t].m6, 2); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
559 StationGfx gfx = GetStationGfx(t); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
560 StationType st; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
561 if ( IsInsideMM(gfx, 0, 8)) { // Railway station |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
562 st = STATION_RAIL; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
563 SetStationGfx(t, gfx - 0); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
564 } else if (IsInsideMM(gfx, 8, 67)) { // Airport |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
565 st = STATION_AIRPORT; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
566 SetStationGfx(t, gfx - 8); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
567 } else if (IsInsideMM(gfx, 67, 71)) { // Truck |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
568 st = STATION_TRUCK; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
569 SetStationGfx(t, gfx - 67); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
570 } else if (IsInsideMM(gfx, 71, 75)) { // Bus |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
571 st = STATION_BUS; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
572 SetStationGfx(t, gfx - 71); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
573 } else if (gfx == 75) { // Oil rig |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
574 st = STATION_OILRIG; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
575 SetStationGfx(t, gfx - 75); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
576 } else if (IsInsideMM(gfx, 76, 82)) { // Dock |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
577 st = STATION_DOCK; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
578 SetStationGfx(t, gfx - 76); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
579 } else if (gfx == 82) { // Buoy |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
580 st = STATION_BUOY; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
581 SetStationGfx(t, gfx - 82); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
582 } else if (IsInsideMM(gfx, 83, 168)) { // Extended airport |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
583 st = STATION_AIRPORT; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
584 SetStationGfx(t, gfx - 83 + 67 - 8); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
585 } else if (IsInsideMM(gfx, 168, 170)) { // Drive through truck |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
586 st = STATION_TRUCK; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
587 SetStationGfx(t, gfx - 168 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
588 } else if (IsInsideMM(gfx, 170, 172)) { // Drive through bus |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
589 st = STATION_BUS; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
590 SetStationGfx(t, gfx - 170 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
591 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
592 /* Restore the signals */ |
11948
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
593 ResetSignalHandlers(); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
594 return false; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
595 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
596 SB(_m[t].m6, 3, 3, st); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
597 } break; |
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 } |
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 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
602 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
603 switch (GetTileType(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
604 case MP_STATION: { |
12228
240adc64d01a
(svn r16643) -Codechange: replace GetStationByTile() by Station::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
605 Station *st = Station::GetByTile(t); |
10571
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 /* Set up station spread; buoys do not have one */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
608 if (!IsBuoy(t)) st->rect.BeforeAddTile(t, StationRect::ADD_FORCE); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
609 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
610 switch (GetStationType(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
611 case STATION_TRUCK: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
612 case STATION_BUS: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
613 if (CheckSavegameVersion(6)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
614 /* From this version on there can be multiple road stops of the |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
615 * same type per station. Convert the existing stops to the new |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
616 * internal data structure. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
617 RoadStop *rs = new RoadStop(t); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
618 if (rs == NULL) error("Too many road stops in savegame"); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
619 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
620 RoadStop **head = |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
621 IsTruckStop(t) ? &st->truck_stops : &st->bus_stops; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
622 *head = rs; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
623 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
624 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
625 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
626 case STATION_OILRIG: { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
627 /* Very old savegames sometimes have phantom oil rigs, i.e. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
628 * an oil rig which got shut down, but not completly removed from |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
629 * the map |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
630 */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
631 TileIndex t1 = TILE_ADDXY(t, 0, 1); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
632 if (IsTileType(t1, MP_INDUSTRY) && |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
633 GetIndustryGfx(t1) == GFX_OILRIG_1) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
634 /* The internal encoding of oil rigs was changed twice. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
635 * It was 3 (till 2.2) and later 5 (till 5.1). |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
636 * Setting it unconditionally does not hurt. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
637 */ |
12228
240adc64d01a
(svn r16643) -Codechange: replace GetStationByTile() by Station::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
638 Station::GetByTile(t)->airport_type = AT_OILRIG; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
639 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
640 DeleteOilRig(t); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
641 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
642 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
643 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
644 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
645 default: break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
646 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
647 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
648 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
649 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
650 default: break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
651 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
652 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
653 |
10845
0429d269cb59
(svn r15180) -Fix [FS#2560](r8498): old aircraft have to be updated after updating airport_type of oil rigs
smatz <smatz@openttd.org>
parents:
10844
diff
changeset
|
654 /* In version 2.2 of the savegame, we have new airports, so status of all aircraft is reset. |
0429d269cb59
(svn r15180) -Fix [FS#2560](r8498): old aircraft have to be updated after updating airport_type of oil rigs
smatz <smatz@openttd.org>
parents:
10844
diff
changeset
|
655 * This has to be called after the oilrig airport_type update above ^^^ ! */ |
0429d269cb59
(svn r15180) -Fix [FS#2560](r8498): old aircraft have to be updated after updating airport_type of oil rigs
smatz <smatz@openttd.org>
parents:
10844
diff
changeset
|
656 if (CheckSavegameVersionOldStyle(2, 2)) UpdateOldAircraft(); |
0429d269cb59
(svn r15180) -Fix [FS#2560](r8498): old aircraft have to be updated after updating airport_type of oil rigs
smatz <smatz@openttd.org>
parents:
10844
diff
changeset
|
657 |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
658 /* In version 6.1 we put the town index in the map-array. To do this, we need |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
659 * to use m2 (16bit big), so we need to clean m2, and that is where this is |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
660 * all about ;) */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
661 if (CheckSavegameVersionOldStyle(6, 1)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
662 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
663 switch (GetTileType(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
664 case MP_HOUSE: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
665 _m[t].m4 = _m[t].m2; |
11293
49968fa7d5e4
(svn r15642) -Codechange: use a default parameter value in CalcClosestTownFromTile
smatz <smatz@openttd.org>
parents:
11252
diff
changeset
|
666 SetTownIndex(t, CalcClosestTownFromTile(t)->index); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
667 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
668 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
669 case MP_ROAD: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
670 _m[t].m4 |= (_m[t].m2 << 4); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
671 if ((GB(_m[t].m5, 4, 2) == ROAD_TILE_CROSSING ? (Owner)_m[t].m3 : GetTileOwner(t)) == OWNER_TOWN) { |
11293
49968fa7d5e4
(svn r15642) -Codechange: use a default parameter value in CalcClosestTownFromTile
smatz <smatz@openttd.org>
parents:
11252
diff
changeset
|
672 SetTownIndex(t, CalcClosestTownFromTile(t)->index); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
673 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
674 SetTownIndex(t, 0); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
675 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
676 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
677 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
678 default: break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
679 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
680 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
681 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
682 |
10855
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10848
diff
changeset
|
683 /* Force the freeform edges to false for old savegames. */ |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10848
diff
changeset
|
684 if (CheckSavegameVersion(111)) { |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10848
diff
changeset
|
685 _settings_game.construction.freeform_edges = false; |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10848
diff
changeset
|
686 } |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10848
diff
changeset
|
687 |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
688 /* From version 9.0, we update the max passengers of a town (was sometimes negative |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
689 * before that. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
690 if (CheckSavegameVersion(9)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
691 Town *t; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
692 FOR_ALL_TOWNS(t) UpdateTownMaxPass(t); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
693 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
694 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
695 /* From version 16.0, we included autorenew on engines, which are now saved, but |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
696 * of course, we do need to initialize them for older savegames. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
697 if (CheckSavegameVersion(16)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
698 FOR_ALL_COMPANIES(c) { |
11913
f67b6243e05a
(svn r16315) -Codechange: move the autorenew settings to a new CompanySettings struct
yexo <yexo@openttd.org>
parents:
11852
diff
changeset
|
699 c->engine_renew_list = NULL; |
f67b6243e05a
(svn r16315) -Codechange: move the autorenew settings to a new CompanySettings struct
yexo <yexo@openttd.org>
parents:
11852
diff
changeset
|
700 c->settings.engine_renew = false; |
f67b6243e05a
(svn r16315) -Codechange: move the autorenew settings to a new CompanySettings struct
yexo <yexo@openttd.org>
parents:
11852
diff
changeset
|
701 c->settings.engine_renew_months = 6; |
f67b6243e05a
(svn r16315) -Codechange: move the autorenew settings to a new CompanySettings struct
yexo <yexo@openttd.org>
parents:
11852
diff
changeset
|
702 c->settings.engine_renew_money = 100000; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
703 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
704 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
705 /* When loading a game, _local_company is not yet set to the correct value. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
706 * However, in a dedicated server we are a spectator, so nothing needs to |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
707 * happen. In case we are not a dedicated server, the local company always |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
708 * becomes company 0, unless we are in the scenario editor where all the |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
709 * companies are 'invalid'. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
710 */ |
11949
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11948
diff
changeset
|
711 c = Company::GetIfValid(COMPANY_FIRST); |
c89301974eb8
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents:
11948
diff
changeset
|
712 if (!_network_dedicated && c != NULL) { |
11913
f67b6243e05a
(svn r16315) -Codechange: move the autorenew settings to a new CompanySettings struct
yexo <yexo@openttd.org>
parents:
11852
diff
changeset
|
713 c->settings = _settings_client.company; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
714 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
715 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
716 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
717 if (CheckSavegameVersion(48)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
718 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
719 switch (GetTileType(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
720 case MP_RAILWAY: |
11946
d5716f5a9844
(svn r16349) -Codechange: rename IsPlainRailTile() to IsPlainRail(), introduce shiny new IsPlainRailTile()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
721 if (IsPlainRail(t)) { |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
722 /* Swap ground type and signal type for plain rail tiles, so the |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
723 * ground type uses the same bits as for depots and waypoints. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
724 uint tmp = GB(_m[t].m4, 0, 4); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
725 SB(_m[t].m4, 0, 4, GB(_m[t].m2, 0, 4)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
726 SB(_m[t].m2, 0, 4, tmp); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
727 } else if (HasBit(_m[t].m5, 2)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
728 /* Split waypoint and depot rail type and remove the subtype. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
729 ClrBit(_m[t].m5, 2); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
730 ClrBit(_m[t].m5, 6); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
731 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
732 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
733 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
734 case MP_ROAD: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
735 /* Swap m3 and m4, so the track type for rail crossings is the |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
736 * same as for normal rail. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
737 Swap(_m[t].m3, _m[t].m4); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
738 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
739 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
740 default: break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
741 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
742 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
743 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
744 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
745 if (CheckSavegameVersion(61)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
746 /* Added the RoadType */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
747 bool old_bridge = CheckSavegameVersion(42); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
748 for (TileIndex t = 0; t < map_size; t++) { |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
749 switch (GetTileType(t)) { |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
750 case MP_ROAD: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
751 SB(_m[t].m5, 6, 2, GB(_m[t].m5, 4, 2)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
752 switch (GetRoadTileType(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
753 default: NOT_REACHED(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
754 case ROAD_TILE_NORMAL: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
755 SB(_m[t].m4, 0, 4, GB(_m[t].m5, 0, 4)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
756 SB(_m[t].m4, 4, 4, 0); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
757 SB(_m[t].m6, 2, 4, 0); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
758 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
759 case ROAD_TILE_CROSSING: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
760 SB(_m[t].m4, 5, 2, GB(_m[t].m5, 2, 2)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
761 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
762 case ROAD_TILE_DEPOT: break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
763 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
764 SetRoadTypes(t, ROADTYPES_ROAD); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
765 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
766 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
767 case MP_STATION: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
768 if (IsRoadStop(t)) SetRoadTypes(t, ROADTYPES_ROAD); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
769 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
770 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
771 case MP_TUNNELBRIDGE: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
772 /* Middle part of "old" bridges */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
773 if (old_bridge && IsBridge(t) && HasBit(_m[t].m5, 6)) break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
774 if (((old_bridge && IsBridge(t)) ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t)) == TRANSPORT_ROAD) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
775 SetRoadTypes(t, ROADTYPES_ROAD); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
776 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
777 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
778 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
779 default: break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
780 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
781 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
782 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
783 |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
784 if (CheckSavegameVersion(114)) { |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
785 bool fix_roadtypes = !CheckSavegameVersion(61); |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
786 bool old_bridge = CheckSavegameVersion(42); |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
787 |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
788 for (TileIndex t = 0; t < map_size; t++) { |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
789 switch (GetTileType(t)) { |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
790 case MP_ROAD: |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
791 if (fix_roadtypes) SetRoadTypes(t, (RoadTypes)GB(_me[t].m7, 5, 3)); |
11368
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11293
diff
changeset
|
792 SB(_me[t].m7, 5, 1, GB(_m[t].m3, 7, 1)); // snow/desert |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
793 switch (GetRoadTileType(t)) { |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
794 default: NOT_REACHED(); |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
795 case ROAD_TILE_NORMAL: |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
796 SB(_me[t].m7, 0, 4, GB(_m[t].m3, 0, 4)); // road works |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
797 SB(_m[t].m6, 3, 3, GB(_m[t].m3, 4, 3)); // ground |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
798 SB(_m[t].m3, 0, 4, GB(_m[t].m4, 4, 4)); // tram bits |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
799 SB(_m[t].m3, 4, 4, GB(_m[t].m5, 0, 4)); // tram owner |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
800 SB(_m[t].m5, 0, 4, GB(_m[t].m4, 0, 4)); // road bits |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
801 break; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
802 |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
803 case ROAD_TILE_CROSSING: |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
804 SB(_me[t].m7, 0, 5, GB(_m[t].m4, 0, 5)); // road owner |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
805 SB(_m[t].m6, 3, 3, GB(_m[t].m3, 4, 3)); // ground |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
806 SB(_m[t].m3, 4, 4, GB(_m[t].m5, 0, 4)); // tram owner |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
807 SB(_m[t].m5, 0, 1, GB(_m[t].m4, 6, 1)); // road axis |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
808 SB(_m[t].m5, 5, 1, GB(_m[t].m4, 5, 1)); // crossing state |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
809 break; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
810 |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
811 case ROAD_TILE_DEPOT: |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
812 break; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
813 } |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
814 if (!HasTownOwnedRoad(t)) { |
11293
49968fa7d5e4
(svn r15642) -Codechange: use a default parameter value in CalcClosestTownFromTile
smatz <smatz@openttd.org>
parents:
11252
diff
changeset
|
815 const Town *town = CalcClosestTownFromTile(t); |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
816 if (town != NULL) SetTownIndex(t, town->index); |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
817 } |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
818 _m[t].m4 = 0; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
819 break; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
820 |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
821 case MP_STATION: |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
822 if (!IsRoadStop(t)) break; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
823 |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
824 if (fix_roadtypes) SetRoadTypes(t, (RoadTypes)GB(_m[t].m3, 0, 3)); |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
825 SB(_me[t].m7, 0, 5, HasBit(_m[t].m6, 2) ? OWNER_TOWN : GetTileOwner(t)); |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
826 SB(_m[t].m3, 4, 4, _m[t].m1); |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
827 _m[t].m4 = 0; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
828 break; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
829 |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
830 case MP_TUNNELBRIDGE: |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
831 if (old_bridge && IsBridge(t) && HasBit(_m[t].m5, 6)) break; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
832 if (((old_bridge && IsBridge(t)) ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t)) == TRANSPORT_ROAD) { |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
833 if (fix_roadtypes) SetRoadTypes(t, (RoadTypes)GB(_m[t].m3, 0, 3)); |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
834 |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
835 Owner o = GetTileOwner(t); |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
836 SB(_me[t].m7, 0, 5, o); // road owner |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
837 SB(_m[t].m3, 4, 4, o == OWNER_NONE ? OWNER_TOWN : o); // tram owner |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
838 } |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
839 SB(_m[t].m6, 2, 4, GB(_m[t].m2, 4, 4)); // bridge type |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
840 SB(_me[t].m7, 5, 1, GB(_m[t].m4, 7, 1)); // snow/desert |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
841 |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
842 _m[t].m2 = 0; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
843 _m[t].m4 = 0; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
844 break; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
845 |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
846 default: break; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
847 } |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
848 } |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
849 } |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
850 |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
851 if (CheckSavegameVersion(42)) { |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10571
diff
changeset
|
852 Vehicle *v; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
853 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
854 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
855 if (MayHaveBridgeAbove(t)) ClearBridgeMiddle(t); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
856 if (IsBridgeTile(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
857 if (HasBit(_m[t].m5, 6)) { // middle part |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
858 Axis axis = (Axis)GB(_m[t].m5, 0, 1); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
859 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
860 if (HasBit(_m[t].m5, 5)) { // transport route under bridge? |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
861 if (GB(_m[t].m5, 3, 2) == TRANSPORT_RAIL) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
862 MakeRailNormal( |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
863 t, |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
864 GetTileOwner(t), |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
865 axis == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X, |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
866 GetRailType(t) |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
867 ); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
868 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
869 TownID town = IsTileOwner(t, OWNER_TOWN) ? ClosestTownFromTile(t, UINT_MAX)->index : 0; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
870 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
871 MakeRoadNormal( |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
872 t, |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
873 axis == AXIS_X ? ROAD_Y : ROAD_X, |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
874 ROADTYPES_ROAD, |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
875 town, |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11234
diff
changeset
|
876 GetTileOwner(t), OWNER_NONE |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
877 ); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
878 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
879 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
880 if (GB(_m[t].m5, 3, 2) == 0) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
881 MakeClear(t, CLEAR_GRASS, 3); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
882 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
883 if (GetTileSlope(t, NULL) != SLOPE_FLAT) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
884 MakeShore(t); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
885 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
886 if (GetTileOwner(t) == OWNER_WATER) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
887 MakeWater(t); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
888 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
889 MakeCanal(t, GetTileOwner(t), Random()); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
890 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
891 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
892 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
893 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
894 SetBridgeMiddle(t, axis); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
895 } else { // ramp |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
896 Axis axis = (Axis)GB(_m[t].m5, 0, 1); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
897 uint north_south = GB(_m[t].m5, 5, 1); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
898 DiagDirection dir = ReverseDiagDir(XYNSToDiagDir(axis, north_south)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
899 TransportType type = (TransportType)GB(_m[t].m5, 1, 2); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
900 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
901 _m[t].m5 = 1 << 7 | type << 2 | dir; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
902 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
903 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
904 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
905 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
906 FOR_ALL_VEHICLES(v) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
907 if (v->type != VEH_TRAIN && v->type != VEH_ROAD) continue; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
908 if (IsBridgeTile(v->tile)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
909 DiagDirection dir = GetTunnelBridgeDirection(v->tile); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
910 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
911 if (dir != DirToDiagDir(v->direction)) continue; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
912 switch (dir) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
913 default: NOT_REACHED(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
914 case DIAGDIR_NE: if ((v->x_pos & 0xF) != 0) continue; break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
915 case DIAGDIR_SE: if ((v->y_pos & 0xF) != TILE_SIZE - 1) continue; break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
916 case DIAGDIR_SW: if ((v->x_pos & 0xF) != TILE_SIZE - 1) continue; break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
917 case DIAGDIR_NW: if ((v->y_pos & 0xF) != 0) continue; break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
918 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
919 } else if (v->z_pos > GetSlopeZ(v->x_pos, v->y_pos)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
920 v->tile = GetNorthernBridgeEnd(v->tile); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
921 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
922 continue; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
923 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
924 if (v->type == VEH_TRAIN) { |
12114
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12112
diff
changeset
|
925 Train::From(v)->track = TRACK_BIT_WORMHOLE; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
926 } else { |
12114
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12112
diff
changeset
|
927 RoadVehicle::From(v)->state = RVSB_WORMHOLE; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
928 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
929 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
930 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
931 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
932 /* Elrails got added in rev 24 */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
933 if (CheckSavegameVersion(24)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
934 RailType min_rail = RAILTYPE_ELECTRIC; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
935 |
12034
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
936 Train *v; |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
937 FOR_ALL_TRAINS(v) { |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
938 RailType rt = RailVehInfo(v->engine_type)->railtype; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
939 |
12034
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
940 v->railtype = rt; |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
941 if (rt == RAILTYPE_ELECTRIC) min_rail = RAILTYPE_RAIL; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
942 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
943 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
944 /* .. so we convert the entire map from normal to elrail (so maintain "fairness") */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
945 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
946 switch (GetTileType(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
947 case MP_RAILWAY: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
948 SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
949 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
950 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
951 case MP_ROAD: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
952 if (IsLevelCrossing(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
953 SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
954 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
955 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
956 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
957 case MP_STATION: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
958 if (IsRailwayStation(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
959 SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
960 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
961 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
962 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
963 case MP_TUNNELBRIDGE: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
964 if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
965 SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
966 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
967 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
968 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
969 default: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
970 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
971 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
972 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
973 |
12034
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
974 FOR_ALL_TRAINS(v) { |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
975 if (IsFrontEngine(v) || IsFreeWagon(v)) TrainConsistChanged(v, true); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
976 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
977 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
978 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
979 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
980 /* In version 16.1 of the savegame a company can decide if trains, which get |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
981 * replaced, shall keep their old length. In all prior versions, just default |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
982 * to false */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
983 if (CheckSavegameVersionOldStyle(16, 1)) { |
11913
f67b6243e05a
(svn r16315) -Codechange: move the autorenew settings to a new CompanySettings struct
yexo <yexo@openttd.org>
parents:
11852
diff
changeset
|
984 FOR_ALL_COMPANIES(c) c->settings.renew_keep_length = false; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
985 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
986 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
987 /* In version 17, ground type is moved from m2 to m4 for depots and |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
988 * waypoints to make way for storing the index in m2. The custom graphics |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
989 * id which was stored in m4 is now saved as a grf/id reference in the |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
990 * waypoint struct. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
991 if (CheckSavegameVersion(17)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
992 Waypoint *wp; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
993 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
994 FOR_ALL_WAYPOINTS(wp) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
995 if (wp->deleted == 0) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
996 const StationSpec *statspec = NULL; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
997 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
998 if (HasBit(_m[wp->xy].m3, 4)) |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
999 statspec = GetCustomStationSpec(STAT_CLASS_WAYP, _m[wp->xy].m4 + 1); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1000 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1001 if (statspec != NULL) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1002 wp->stat_id = _m[wp->xy].m4 + 1; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1003 wp->grfid = statspec->grffile->grfid; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1004 wp->localidx = statspec->localidx; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1005 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1006 /* No custom graphics set, so set to default. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1007 wp->stat_id = 0; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1008 wp->grfid = 0; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1009 wp->localidx = 0; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1010 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1011 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1012 /* Move ground type bits from m2 to m4. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1013 _m[wp->xy].m4 = GB(_m[wp->xy].m2, 0, 4); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1014 /* Store waypoint index in the tile. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1015 _m[wp->xy].m2 = wp->index; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1016 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1017 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1018 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1019 /* As of version 17, we recalculate the custom graphic ID of waypoints |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1020 * from the GRF ID / station index. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1021 AfterLoadWaypoints(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1022 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1023 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1024 /* From version 15, we moved a semaphore bit from bit 2 to bit 3 in m4, making |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1025 * room for PBS. Now in version 21 move it back :P. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1026 if (CheckSavegameVersion(21) && !CheckSavegameVersion(15)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1027 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1028 switch (GetTileType(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1029 case MP_RAILWAY: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1030 if (HasSignals(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1031 /* convert PBS signals to combo-signals */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1032 if (HasBit(_m[t].m2, 2)) SetSignalType(t, TRACK_X, SIGTYPE_COMBO); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1033 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1034 /* move the signal variant back */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1035 SetSignalVariant(t, TRACK_X, HasBit(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1036 ClrBit(_m[t].m2, 3); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1037 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1038 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1039 /* Clear PBS reservation on track */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1040 if (!IsRailDepotTile(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1041 SB(_m[t].m4, 4, 4, 0); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1042 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1043 ClrBit(_m[t].m3, 6); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1044 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1045 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1046 |
11368
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11293
diff
changeset
|
1047 case MP_STATION: // Clear PBS reservation on station |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1048 ClrBit(_m[t].m3, 6); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1049 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1050 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1051 default: break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1052 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1053 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1054 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1055 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1056 if (CheckSavegameVersion(25)) { |
12034
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
1057 RoadVehicle *rv; |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
1058 FOR_ALL_ROADVEHICLES(rv) { |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
1059 rv->vehstatus &= ~0x40; |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
1060 rv->slot = NULL; |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
1061 rv->slot_age = 0; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1062 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1063 } else { |
12034
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
1064 RoadVehicle *rv; |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
1065 FOR_ALL_ROADVEHICLES(rv) { |
11984
b6d3e583be86
(svn r16390) -Codechange: move u.road to RoadVehicle.
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
1066 if (rv->slot != NULL) rv->slot->num_vehicles++; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1067 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1068 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1069 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1070 if (CheckSavegameVersion(26)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1071 Station *st; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1072 FOR_ALL_STATIONS(st) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1073 st->last_vehicle_type = VEH_INVALID; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1074 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1075 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1076 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1077 YapfNotifyTrackLayoutChange(INVALID_TILE, INVALID_TRACK); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1078 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1079 if (CheckSavegameVersion(34)) FOR_ALL_COMPANIES(c) ResetCompanyLivery(c); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1080 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1081 FOR_ALL_COMPANIES(c) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1082 c->avail_railtypes = GetCompanyRailtypes(c->index); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1083 c->avail_roadtypes = GetCompanyRoadtypes(c->index); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1084 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1085 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1086 if (!CheckSavegameVersion(27)) AfterLoadStations(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1087 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1088 /* Time starts at 0 instead of 1920. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1089 * Account for this in older games by adding an offset */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1090 if (CheckSavegameVersion(31)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1091 Station *st; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1092 Waypoint *wp; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1093 Engine *e; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1094 Industry *i; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1095 Vehicle *v; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1096 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1097 _date += DAYS_TILL_ORIGINAL_BASE_YEAR; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1098 _cur_year += ORIGINAL_BASE_YEAR; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1099 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1100 FOR_ALL_STATIONS(st) st->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1101 FOR_ALL_WAYPOINTS(wp) wp->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1102 FOR_ALL_ENGINES(e) e->intro_date += DAYS_TILL_ORIGINAL_BASE_YEAR; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1103 FOR_ALL_COMPANIES(c) c->inaugurated_year += ORIGINAL_BASE_YEAR; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1104 FOR_ALL_INDUSTRIES(i) i->last_prod_year += ORIGINAL_BASE_YEAR; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1105 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1106 FOR_ALL_VEHICLES(v) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1107 v->date_of_last_service += DAYS_TILL_ORIGINAL_BASE_YEAR; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1108 v->build_year += ORIGINAL_BASE_YEAR; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1109 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1110 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1111 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1112 /* From 32 on we save the industry who made the farmland. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1113 * To give this prettyness to old savegames, we remove all farmfields and |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1114 * plant new ones. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1115 if (CheckSavegameVersion(32)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1116 Industry *i; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1117 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1118 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1119 if (IsTileType(t, MP_CLEAR) && IsClearGround(t, CLEAR_FIELDS)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1120 /* remove fields */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1121 MakeClear(t, CLEAR_GRASS, 3); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1122 } else if (IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1123 /* remove fences around fields */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1124 SetFenceSE(t, 0); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1125 SetFenceSW(t, 0); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1126 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1127 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1128 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1129 FOR_ALL_INDUSTRIES(i) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1130 uint j; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1131 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1132 if (GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_PLANT_ON_BUILT) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1133 for (j = 0; j != 50; j++) PlantRandomFarmField(i); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1134 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1135 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1136 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1137 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1138 /* Setting no refit flags to all orders in savegames from before refit in orders were added */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1139 if (CheckSavegameVersion(36)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1140 Order *order; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1141 Vehicle *v; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1142 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1143 FOR_ALL_ORDERS(order) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1144 order->SetRefit(CT_NO_REFIT); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1145 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1146 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1147 FOR_ALL_VEHICLES(v) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1148 v->current_order.SetRefit(CT_NO_REFIT); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1149 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1150 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1151 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1152 /* from version 38 we have optional elrails, since we cannot know the |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1153 * preference of a user, let elrails enabled; it can be disabled manually */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1154 if (CheckSavegameVersion(38)) _settings_game.vehicle.disable_elrails = false; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1155 /* do the same as when elrails were enabled/disabled manually just now */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1156 SettingsDisableElrail(_settings_game.vehicle.disable_elrails); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1157 InitializeRailGUI(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1158 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1159 /* From version 53, the map array was changed for house tiles to allow |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1160 * space for newhouses grf features. A new byte, m7, was also added. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1161 if (CheckSavegameVersion(53)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1162 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1163 if (IsTileType(t, MP_HOUSE)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1164 if (GB(_m[t].m3, 6, 2) != TOWN_HOUSE_COMPLETED) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1165 /* Move the construction stage from m3[7..6] to m5[5..4]. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1166 * The construction counter does not have to move. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1167 SB(_m[t].m5, 3, 2, GB(_m[t].m3, 6, 2)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1168 SB(_m[t].m3, 6, 2, 0); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1169 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1170 /* The "house is completed" bit is now in m6[2]. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1171 SetHouseCompleted(t, false); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1172 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1173 /* The "lift has destination" bit has been moved from |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1174 * m5[7] to m7[0]. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1175 SB(_me[t].m7, 0, 1, HasBit(_m[t].m5, 7)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1176 ClrBit(_m[t].m5, 7); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1177 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1178 /* The "lift is moving" bit has been removed, as it does |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1179 * the same job as the "lift has destination" bit. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1180 ClrBit(_m[t].m1, 7); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1181 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1182 /* The position of the lift goes from m1[7..0] to m6[7..2], |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1183 * making m1 totally free, now. The lift position does not |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1184 * have to be a full byte since the maximum value is 36. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1185 SetLiftPosition(t, GB(_m[t].m1, 0, 6 )); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1186 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1187 _m[t].m1 = 0; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1188 _m[t].m3 = 0; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1189 SetHouseCompleted(t, true); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1190 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1191 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1192 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1193 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1194 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1195 /* Check and update house and town values */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1196 UpdateHousesAndTowns(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1197 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1198 if (CheckSavegameVersion(43)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1199 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1200 if (IsTileType(t, MP_INDUSTRY)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1201 switch (GetIndustryGfx(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1202 case GFX_POWERPLANT_SPARKS: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1203 SetIndustryAnimationState(t, GB(_m[t].m1, 2, 5)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1204 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1205 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1206 case GFX_OILWELL_ANIMATED_1: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1207 case GFX_OILWELL_ANIMATED_2: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1208 case GFX_OILWELL_ANIMATED_3: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1209 SetIndustryAnimationState(t, GB(_m[t].m1, 0, 2)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1210 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1211 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1212 case GFX_COAL_MINE_TOWER_ANIMATED: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1213 case GFX_COPPER_MINE_TOWER_ANIMATED: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1214 case GFX_GOLD_MINE_TOWER_ANIMATED: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1215 SetIndustryAnimationState(t, _m[t].m1); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1216 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1217 |
11368
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11293
diff
changeset
|
1218 default: // No animation states to change |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1219 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1220 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1221 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1222 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1223 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1224 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1225 if (CheckSavegameVersion(44)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1226 Vehicle *v; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1227 /* If we remove a station while cargo from it is still enroute, payment calculation will assume |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1228 * 0, 0 to be the source of the cargo, resulting in very high payments usually. v->source_xy |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1229 * stores the coordinates, preserving them even if the station is removed. However, if a game is loaded |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1230 * where this situation exists, the cargo-source information is lost. in this case, we set the source |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1231 * to the current tile of the vehicle to prevent excessive profits |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1232 */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1233 FOR_ALL_VEHICLES(v) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1234 const CargoList::List *packets = v->cargo.Packets(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1235 for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1236 CargoPacket *cp = *it; |
11924
fccc9cea27a7
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents:
11922
diff
changeset
|
1237 cp->source_xy = Station::IsValidID(cp->source) ? Station::Get(cp->source)->xy : v->tile; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1238 cp->loaded_at_xy = cp->source_xy; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1239 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1240 v->cargo.InvalidateCache(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1241 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1242 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1243 /* Store position of the station where the goods come from, so there |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1244 * are no very high payments when stations get removed. However, if the |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1245 * station where the goods came from is already removed, the source |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1246 * information is lost. In that case we set it to the position of this |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1247 * station */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1248 Station *st; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1249 FOR_ALL_STATIONS(st) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1250 for (CargoID c = 0; c < NUM_CARGO; c++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1251 GoodsEntry *ge = &st->goods[c]; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1252 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1253 const CargoList::List *packets = ge->cargo.Packets(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1254 for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1255 CargoPacket *cp = *it; |
11924
fccc9cea27a7
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents:
11922
diff
changeset
|
1256 cp->source_xy = Station::IsValidID(cp->source) ? Station::Get(cp->source)->xy : st->xy; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1257 cp->loaded_at_xy = cp->source_xy; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1258 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1259 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1260 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1261 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1262 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1263 if (CheckSavegameVersion(45)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1264 Vehicle *v; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1265 /* Originally just the fact that some cargo had been paid for was |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1266 * stored to stop people cheating and cashing in several times. This |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1267 * wasn't enough though as it was cleared when the vehicle started |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1268 * loading again, even if it didn't actually load anything, so now the |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1269 * amount of cargo that has been paid for is stored. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1270 FOR_ALL_VEHICLES(v) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1271 const CargoList::List *packets = v->cargo.Packets(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1272 for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1273 CargoPacket *cp = *it; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1274 cp->paid_for = HasBit(v->vehicle_flags, 2); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1275 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1276 ClrBit(v->vehicle_flags, 2); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1277 v->cargo.InvalidateCache(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1278 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1279 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1280 |
12001
2dd20683fcbb
(svn r16407) -Fix [FS#2913]: set CargoPacket::source to INVALID_STATION when source station is deleted
smatz <smatz@openttd.org>
parents:
11986
diff
changeset
|
1281 if (CheckSavegameVersion(120)) { |
2dd20683fcbb
(svn r16407) -Fix [FS#2913]: set CargoPacket::source to INVALID_STATION when source station is deleted
smatz <smatz@openttd.org>
parents:
11986
diff
changeset
|
1282 /* CargoPacket's source should be either INVALID_STATION or a valid station */ |
2dd20683fcbb
(svn r16407) -Fix [FS#2913]: set CargoPacket::source to INVALID_STATION when source station is deleted
smatz <smatz@openttd.org>
parents:
11986
diff
changeset
|
1283 CargoPacket *cp; |
2dd20683fcbb
(svn r16407) -Fix [FS#2913]: set CargoPacket::source to INVALID_STATION when source station is deleted
smatz <smatz@openttd.org>
parents:
11986
diff
changeset
|
1284 FOR_ALL_CARGOPACKETS(cp) { |
2dd20683fcbb
(svn r16407) -Fix [FS#2913]: set CargoPacket::source to INVALID_STATION when source station is deleted
smatz <smatz@openttd.org>
parents:
11986
diff
changeset
|
1285 if (!Station::IsValidID(cp->source)) cp->source = INVALID_STATION; |
2dd20683fcbb
(svn r16407) -Fix [FS#2913]: set CargoPacket::source to INVALID_STATION when source station is deleted
smatz <smatz@openttd.org>
parents:
11986
diff
changeset
|
1286 } |
2dd20683fcbb
(svn r16407) -Fix [FS#2913]: set CargoPacket::source to INVALID_STATION when source station is deleted
smatz <smatz@openttd.org>
parents:
11986
diff
changeset
|
1287 } |
2dd20683fcbb
(svn r16407) -Fix [FS#2913]: set CargoPacket::source to INVALID_STATION when source station is deleted
smatz <smatz@openttd.org>
parents:
11986
diff
changeset
|
1288 |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1289 /* Buoys do now store the owner of the previous water tile, which can never |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1290 * be OWNER_NONE. So replace OWNER_NONE with OWNER_WATER. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1291 if (CheckSavegameVersion(46)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1292 Station *st; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1293 FOR_ALL_STATIONS(st) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1294 if (st->IsBuoy() && IsTileOwner(st->xy, OWNER_NONE) && TileHeight(st->xy) == 0) SetTileOwner(st->xy, OWNER_WATER); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1295 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1296 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1297 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1298 if (CheckSavegameVersion(50)) { |
12035
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
1299 Aircraft *v; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1300 /* Aircraft units changed from 8 mph to 1 km/h */ |
12035
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
1301 FOR_ALL_AIRCRAFT(v) { |
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
1302 if (v->subtype <= AIR_AIRCRAFT) { |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1303 const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1304 v->cur_speed *= 129; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1305 v->cur_speed /= 10; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1306 v->max_speed = avi->max_speed; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1307 v->acceleration = avi->acceleration; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1308 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1309 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1310 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1311 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1312 if (CheckSavegameVersion(49)) FOR_ALL_COMPANIES(c) c->face = ConvertFromOldCompanyManagerFace(c->face); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1313 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1314 if (CheckSavegameVersion(52)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1315 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1316 if (IsStatueTile(t)) { |
11293
49968fa7d5e4
(svn r15642) -Codechange: use a default parameter value in CalcClosestTownFromTile
smatz <smatz@openttd.org>
parents:
11252
diff
changeset
|
1317 _m[t].m2 = CalcClosestTownFromTile(t)->index; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1318 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1319 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1320 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1321 |
11069
36d798171bfd
(svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents:
11000
diff
changeset
|
1322 /* A setting containing the proportion of towns that grow twice as |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1323 * fast was added in version 54. From version 56 this is now saved in the |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1324 * town as cities can be built specifically in the scenario editor. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1325 if (CheckSavegameVersion(56)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1326 Town *t; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1327 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1328 FOR_ALL_TOWNS(t) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1329 if (_settings_game.economy.larger_towns != 0 && (t->index % _settings_game.economy.larger_towns) == 0) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1330 t->larger_town = true; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1331 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1332 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1333 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1334 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1335 if (CheckSavegameVersion(57)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1336 Vehicle *v; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1337 /* Added a FIFO queue of vehicles loading at stations */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1338 FOR_ALL_VEHICLES(v) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1339 if ((v->type != VEH_TRAIN || IsFrontEngine(v)) && // for all locs |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1340 !(v->vehstatus & (VS_STOPPED | VS_CRASHED)) && // not stopped or crashed |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1341 v->current_order.IsType(OT_LOADING)) { // loading |
11922
0a4b63f3f3c3
(svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents:
11913
diff
changeset
|
1342 Station::Get(v->last_station_visited)->loading_vehicles.push_back(v); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1343 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1344 /* The loading finished flag is *only* set when actually completely |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1345 * finished. Because the vehicle is loading, it is not finished. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1346 ClrBit(v->vehicle_flags, VF_LOADING_FINISHED); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1347 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1348 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1349 } else if (CheckSavegameVersion(59)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1350 /* For some reason non-loading vehicles could be in the station's loading vehicle list */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1351 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1352 Station *st; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1353 FOR_ALL_STATIONS(st) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1354 std::list<Vehicle *>::iterator iter; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1355 for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end();) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1356 Vehicle *v = *iter; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1357 iter++; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1358 if (!v->current_order.IsType(OT_LOADING)) st->loading_vehicles.remove(v); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1359 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1360 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1361 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1362 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1363 if (CheckSavegameVersion(58)) { |
11069
36d798171bfd
(svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents:
11000
diff
changeset
|
1364 /* Setting difficulty number_industries other than zero get bumped to +1 |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1365 * since a new option (very low at position1) has been added */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1366 if (_settings_game.difficulty.number_industries > 0) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1367 _settings_game.difficulty.number_industries++; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1368 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1369 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1370 /* Same goes for number of towns, although no test is needed, just an increment */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1371 _settings_game.difficulty.number_towns++; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1372 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1373 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1374 if (CheckSavegameVersion(64)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1375 /* copy the signal type/variant and move signal states bits */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1376 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1377 if (IsTileType(t, MP_RAILWAY) && HasSignals(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1378 SetSignalStates(t, GB(_m[t].m2, 4, 4)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1379 SetSignalVariant(t, INVALID_TRACK, GetSignalVariant(t, TRACK_X)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1380 SetSignalType(t, INVALID_TRACK, GetSignalType(t, TRACK_X)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1381 ClrBit(_m[t].m2, 7); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1382 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1383 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1384 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1385 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1386 if (CheckSavegameVersion(69)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1387 /* In some old savegames a bit was cleared when it should not be cleared */ |
12034
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
1388 RoadVehicle *rv; |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
1389 FOR_ALL_ROADVEHICLES(rv) { |
11984
b6d3e583be86
(svn r16390) -Codechange: move u.road to RoadVehicle.
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
1390 if (rv->state == 250 || rv->state == 251) { |
b6d3e583be86
(svn r16390) -Codechange: move u.road to RoadVehicle.
rubidium <rubidium@openttd.org>
parents:
11972
diff
changeset
|
1391 SetBit(rv->state, RVS_IS_STOPPING); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1392 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1393 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1394 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1395 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1396 if (CheckSavegameVersion(70)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1397 /* Added variables to support newindustries */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1398 Industry *i; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1399 FOR_ALL_INDUSTRIES(i) i->founder = OWNER_NONE; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1400 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1401 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1402 /* From version 82, old style canals (above sealevel (0), WATER owner) are no longer supported. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1403 Replace the owner for those by OWNER_NONE. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1404 if (CheckSavegameVersion(82)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1405 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1406 if (IsTileType(t, MP_WATER) && |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1407 GetWaterTileType(t) == WATER_TILE_CLEAR && |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1408 GetTileOwner(t) == OWNER_WATER && |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1409 TileHeight(t) != 0) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1410 SetTileOwner(t, OWNER_NONE); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1411 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1412 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1413 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1414 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1415 /* |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1416 * Add the 'previous' owner to the ship depots so we can reset it with |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1417 * the correct values when it gets destroyed. This prevents that |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1418 * someone can remove canals owned by somebody else and it prevents |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1419 * making floods using the removal of ship depots. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1420 */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1421 if (CheckSavegameVersion(83)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1422 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1423 if (IsTileType(t, MP_WATER) && IsShipDepot(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1424 _m[t].m4 = (TileHeight(t) == 0) ? OWNER_WATER : OWNER_NONE; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1425 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1426 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1427 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1428 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1429 if (CheckSavegameVersion(74)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1430 Station *st; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1431 FOR_ALL_STATIONS(st) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1432 for (CargoID c = 0; c < NUM_CARGO; c++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1433 st->goods[c].last_speed = 0; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1434 if (st->goods[c].cargo.Count() != 0) SetBit(st->goods[c].acceptance_pickup, GoodsEntry::PICKUP); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1435 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1436 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1437 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1438 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1439 if (CheckSavegameVersion(78)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1440 Industry *i; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1441 uint j; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1442 FOR_ALL_INDUSTRIES(i) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1443 const IndustrySpec *indsp = GetIndustrySpec(i->type); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1444 for (j = 0; j < lengthof(i->produced_cargo); j++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1445 i->produced_cargo[j] = indsp->produced_cargo[j]; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1446 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1447 for (j = 0; j < lengthof(i->accepts_cargo); j++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1448 i->accepts_cargo[j] = indsp->accepts_cargo[j]; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1449 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1450 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1451 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1452 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1453 /* Before version 81, the density of grass was always stored as zero, and |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1454 * grassy trees were always drawn fully grassy. Furthermore, trees on rough |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1455 * land used to have zero density, now they have full density. Therefore, |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1456 * make all grassy/rough land trees have a density of 3. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1457 if (CheckSavegameVersion(81)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1458 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1459 if (GetTileType(t) == MP_TREES) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1460 TreeGround groundType = GetTreeGround(t); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1461 if (groundType != TREE_GROUND_SNOW_DESERT) SetTreeGroundDensity(t, groundType, 3); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1462 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1463 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1464 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1465 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1466 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1467 if (CheckSavegameVersion(93)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1468 /* Rework of orders. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1469 Order *order; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1470 FOR_ALL_ORDERS(order) order->ConvertFromOldSavegame(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1471 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1472 Vehicle *v; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1473 FOR_ALL_VEHICLES(v) { |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11949
diff
changeset
|
1474 if (v->orders.list != NULL && v->orders.list->GetFirstOrder() != NULL && v->orders.list->GetFirstOrder()->IsType(OT_NOTHING)) { |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1475 v->orders.list->FreeChain(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1476 v->orders.list = NULL; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1477 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1478 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1479 v->current_order.ConvertFromOldSavegame(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1480 if (v->type == VEH_ROAD && v->IsPrimaryVehicle() && v->FirstShared() == v) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1481 FOR_VEHICLE_ORDERS(v, order) order->SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1482 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1483 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1484 } else if (CheckSavegameVersion(94)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1485 /* Unload and transfer are now mutual exclusive. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1486 Order *order; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1487 FOR_ALL_ORDERS(order) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1488 if ((order->GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1489 order->SetUnloadType(OUFB_TRANSFER); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1490 order->SetLoadType(OLFB_NO_LOAD); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1491 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1492 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1493 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1494 Vehicle *v; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1495 FOR_ALL_VEHICLES(v) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1496 if ((v->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1497 v->current_order.SetUnloadType(OUFB_TRANSFER); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1498 v->current_order.SetLoadType(OLFB_NO_LOAD); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1499 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1500 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1501 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1502 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1503 if (CheckSavegameVersion(84)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1504 /* Update go to buoy orders because they are just waypoints */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1505 Order *order; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1506 FOR_ALL_ORDERS(order) { |
11922
0a4b63f3f3c3
(svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents:
11913
diff
changeset
|
1507 if (order->IsType(OT_GOTO_STATION) && Station::Get(order->GetDestination())->IsBuoy()) { |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1508 order->SetLoadType(OLF_LOAD_IF_POSSIBLE); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1509 order->SetUnloadType(OUF_UNLOAD_IF_POSSIBLE); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1510 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1511 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1512 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1513 /* Set all share owners to INVALID_COMPANY for |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1514 * 1) all inactive companies |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1515 * (when inactive companies were stored in the savegame - TTD, TTDP and some |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1516 * *really* old revisions of OTTD; else it is already set in InitializeCompanies()) |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1517 * 2) shares that are owned by inactive companies or self |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1518 * (caused by cheating clients in earlier revisions) */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1519 FOR_ALL_COMPANIES(c) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1520 for (uint i = 0; i < 4; i++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1521 CompanyID company = c->share_owners[i]; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1522 if (company == INVALID_COMPANY) continue; |
11924
fccc9cea27a7
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents:
11922
diff
changeset
|
1523 if (!Company::IsValidID(company) || company == c->index) c->share_owners[i] = INVALID_COMPANY; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1524 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1525 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1526 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1527 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1528 if (CheckSavegameVersion(86)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1529 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1530 /* Move river flag and update canals to use water class */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1531 if (IsTileType(t, MP_WATER)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1532 if (GetWaterClass(t) != WATER_CLASS_RIVER) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1533 if (IsWater(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1534 Owner o = GetTileOwner(t); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1535 if (o == OWNER_WATER) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1536 MakeWater(t); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1537 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1538 MakeCanal(t, o, Random()); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1539 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1540 } else if (IsShipDepot(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1541 Owner o = (Owner)_m[t].m4; // Original water owner |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1542 SetWaterClass(t, o == OWNER_WATER ? WATER_CLASS_SEA : WATER_CLASS_CANAL); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1543 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1544 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1545 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1546 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1547 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1548 /* Update locks, depots, docks and buoys to have a water class based |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1549 * on its neighbouring tiles. Done after river and canal updates to |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1550 * ensure neighbours are correct. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1551 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1552 if (GetTileSlope(t, NULL) != SLOPE_FLAT) continue; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1553 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1554 if (IsTileType(t, MP_WATER) && IsLock(t)) SetWaterClassDependingOnSurroundings(t, false); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1555 if (IsTileType(t, MP_STATION) && (IsDock(t) || IsBuoy(t))) SetWaterClassDependingOnSurroundings(t, false); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1556 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1557 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1558 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1559 if (CheckSavegameVersion(87)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1560 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1561 /* skip oil rigs at borders! */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1562 if ((IsTileType(t, MP_WATER) || IsBuoyTile(t)) && |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1563 (TileX(t) == 0 || TileY(t) == 0 || TileX(t) == MapMaxX() - 1 || TileY(t) == MapMaxY() - 1)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1564 /* Some version 86 savegames have wrong water class at map borders (under buoy, or after removing buoy). |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1565 * This conversion has to be done before buoys with invalid owner are removed. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1566 SetWaterClass(t, WATER_CLASS_SEA); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1567 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1568 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1569 if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1570 Owner o = GetTileOwner(t); |
11924
fccc9cea27a7
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents:
11922
diff
changeset
|
1571 if (o < MAX_COMPANIES && !Company::IsValidID(o)) { |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1572 _current_company = o; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1573 ChangeTileOwner(t, o, INVALID_OWNER); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1574 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1575 if (IsBuoyTile(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1576 /* reset buoy owner to OWNER_NONE in the station struct |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1577 * (even if it is owned by active company) */ |
12228
240adc64d01a
(svn r16643) -Codechange: replace GetStationByTile() by Station::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
1578 Station::GetByTile(t)->owner = OWNER_NONE; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1579 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1580 } else if (IsTileType(t, MP_ROAD)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1581 /* works for all RoadTileType */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1582 for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1583 /* update even non-existing road types to update tile owner too */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1584 Owner o = GetRoadOwner(t, rt); |
11924
fccc9cea27a7
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents:
11922
diff
changeset
|
1585 if (o < MAX_COMPANIES && !Company::IsValidID(o)) SetRoadOwner(t, rt, OWNER_NONE); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1586 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1587 if (IsLevelCrossing(t)) { |
11924
fccc9cea27a7
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents:
11922
diff
changeset
|
1588 if (!Company::IsValidID(GetTileOwner(t))) FixOwnerOfRailTrack(t); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1589 } |
11946
d5716f5a9844
(svn r16349) -Codechange: rename IsPlainRailTile() to IsPlainRail(), introduce shiny new IsPlainRailTile()
smatz <smatz@openttd.org>
parents:
11924
diff
changeset
|
1590 } else if (IsPlainRailTile(t)) { |
11924
fccc9cea27a7
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents:
11922
diff
changeset
|
1591 if (!Company::IsValidID(GetTileOwner(t))) FixOwnerOfRailTrack(t); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1592 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1593 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1594 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1595 /* Convert old PF settings to new */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1596 if (_settings_game.pf.yapf.rail_use_yapf || CheckSavegameVersion(28)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1597 _settings_game.pf.pathfinder_for_trains = VPF_YAPF; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1598 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1599 _settings_game.pf.pathfinder_for_trains = (_settings_game.pf.new_pathfinding_all ? VPF_NPF : VPF_NTP); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1600 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1601 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1602 if (_settings_game.pf.yapf.road_use_yapf || CheckSavegameVersion(28)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1603 _settings_game.pf.pathfinder_for_roadvehs = VPF_YAPF; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1604 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1605 _settings_game.pf.pathfinder_for_roadvehs = (_settings_game.pf.new_pathfinding_all ? VPF_NPF : VPF_OPF); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1606 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1607 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1608 if (_settings_game.pf.yapf.ship_use_yapf) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1609 _settings_game.pf.pathfinder_for_ships = VPF_YAPF; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1610 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1611 _settings_game.pf.pathfinder_for_ships = (_settings_game.pf.new_pathfinding_all ? VPF_NPF : VPF_OPF); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1612 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1613 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1614 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1615 if (CheckSavegameVersion(88)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1616 /* Profits are now with 8 bit fract */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1617 Vehicle *v; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1618 FOR_ALL_VEHICLES(v) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1619 v->profit_this_year <<= 8; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1620 v->profit_last_year <<= 8; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1621 v->running_ticks = 0; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1622 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1623 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1624 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1625 if (CheckSavegameVersion(91)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1626 /* Increase HouseAnimationFrame from 5 to 7 bits */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1627 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1628 if (IsTileType(t, MP_HOUSE) && GetHouseType(t) >= NEW_HOUSE_OFFSET) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1629 SetHouseAnimationFrame(t, GB(_m[t].m6, 3, 5)); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1630 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1631 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1632 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1633 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1634 if (CheckSavegameVersion(62)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1635 /* Remove all trams from savegames without tram support. |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1636 * There would be trams without tram track under causing crashes sooner or later. */ |
12035
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
1637 RoadVehicle *v; |
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
1638 FOR_ALL_ROADVEHICLES(v) { |
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
1639 if (v->First() == v && HasBit(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM)) { |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1640 if (_switch_mode_errorstr == INVALID_STRING_ID || _switch_mode_errorstr == STR_NEWGRF_COMPATIBLE_LOAD_WARNING) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1641 _switch_mode_errorstr = STR_LOADGAME_REMOVED_TRAMS; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1642 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1643 delete v; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1644 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1645 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1646 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1647 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1648 if (CheckSavegameVersion(99)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1649 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1650 /* Set newly introduced WaterClass of industry tiles */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1651 if (IsTileType(t, MP_STATION) && IsOilRig(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1652 SetWaterClassDependingOnSurroundings(t, true); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1653 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1654 if (IsTileType(t, MP_INDUSTRY)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1655 if ((GetIndustrySpec(GetIndustryType(t))->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1656 SetWaterClassDependingOnSurroundings(t, true); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1657 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1658 SetWaterClass(t, WATER_CLASS_INVALID); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1659 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1660 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1661 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1662 /* Replace "house construction year" with "house age" */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1663 if (IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1664 _m[t].m5 = Clamp(_cur_year - (_m[t].m5 + ORIGINAL_BASE_YEAR), 0, 0xFF); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1665 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1666 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1667 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1668 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1669 /* Move the signal variant back up one bit for PBS. We don't convert the old PBS |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1670 * format here, as an old layout wouldn't work properly anyway. To be safe, we |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1671 * clear any possible PBS reservations as well. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1672 if (CheckSavegameVersion(100)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1673 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1674 switch (GetTileType(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1675 case MP_RAILWAY: |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1676 if (HasSignals(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1677 /* move the signal variant */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1678 SetSignalVariant(t, TRACK_UPPER, HasBit(_m[t].m2, 2) ? SIG_SEMAPHORE : SIG_ELECTRIC); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1679 SetSignalVariant(t, TRACK_LOWER, HasBit(_m[t].m2, 6) ? SIG_SEMAPHORE : SIG_ELECTRIC); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1680 ClrBit(_m[t].m2, 2); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1681 ClrBit(_m[t].m2, 6); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1682 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1683 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1684 /* Clear PBS reservation on track */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1685 if (IsRailDepot(t) ||IsRailWaypoint(t)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1686 SetDepotWaypointReservation(t, false); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1687 } else { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1688 SetTrackReservation(t, TRACK_BIT_NONE); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1689 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1690 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1691 |
11368
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11293
diff
changeset
|
1692 case MP_ROAD: // Clear PBS reservation on crossing |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1693 if (IsLevelCrossing(t)) SetCrossingReservation(t, false); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1694 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1695 |
11368
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11293
diff
changeset
|
1696 case MP_STATION: // Clear PBS reservation on station |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1697 if (IsRailwayStation(t)) SetRailwayStationReservation(t, false); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1698 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1699 |
11368
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11293
diff
changeset
|
1700 case MP_TUNNELBRIDGE: // Clear PBS reservation on tunnels/birdges |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1701 if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) SetTunnelBridgeReservation(t, false); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1702 break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1703 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1704 default: break; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1705 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1706 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1707 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1708 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1709 /* Reserve all tracks trains are currently on. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1710 if (CheckSavegameVersion(101)) { |
12034
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
1711 Train *t; |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
12032
diff
changeset
|
1712 FOR_ALL_TRAINS(t) { |
12137
b3c5a6c9146a
(svn r16553) -Codechange: don't use TRACK_BIT_WORMHOLE and TRACK_BIT_DEPOT as bitmasks
smatz <smatz@openttd.org>
parents:
12114
diff
changeset
|
1713 switch (t->track) { |
b3c5a6c9146a
(svn r16553) -Codechange: don't use TRACK_BIT_WORMHOLE and TRACK_BIT_DEPOT as bitmasks
smatz <smatz@openttd.org>
parents:
12114
diff
changeset
|
1714 case TRACK_BIT_WORMHOLE: |
b3c5a6c9146a
(svn r16553) -Codechange: don't use TRACK_BIT_WORMHOLE and TRACK_BIT_DEPOT as bitmasks
smatz <smatz@openttd.org>
parents:
12114
diff
changeset
|
1715 TryReserveRailTrack(t->tile, DiagDirToDiagTrack(GetTunnelBridgeDirection(t->tile))); |
b3c5a6c9146a
(svn r16553) -Codechange: don't use TRACK_BIT_WORMHOLE and TRACK_BIT_DEPOT as bitmasks
smatz <smatz@openttd.org>
parents:
12114
diff
changeset
|
1716 break; |
b3c5a6c9146a
(svn r16553) -Codechange: don't use TRACK_BIT_WORMHOLE and TRACK_BIT_DEPOT as bitmasks
smatz <smatz@openttd.org>
parents:
12114
diff
changeset
|
1717 case TRACK_BIT_DEPOT: |
b3c5a6c9146a
(svn r16553) -Codechange: don't use TRACK_BIT_WORMHOLE and TRACK_BIT_DEPOT as bitmasks
smatz <smatz@openttd.org>
parents:
12114
diff
changeset
|
1718 break; |
b3c5a6c9146a
(svn r16553) -Codechange: don't use TRACK_BIT_WORMHOLE and TRACK_BIT_DEPOT as bitmasks
smatz <smatz@openttd.org>
parents:
12114
diff
changeset
|
1719 default: |
b3c5a6c9146a
(svn r16553) -Codechange: don't use TRACK_BIT_WORMHOLE and TRACK_BIT_DEPOT as bitmasks
smatz <smatz@openttd.org>
parents:
12114
diff
changeset
|
1720 TryReserveRailTrack(t->tile, TrackBitsToTrack(t->track)); |
b3c5a6c9146a
(svn r16553) -Codechange: don't use TRACK_BIT_WORMHOLE and TRACK_BIT_DEPOT as bitmasks
smatz <smatz@openttd.org>
parents:
12114
diff
changeset
|
1721 break; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1722 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1723 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1724 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1725 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1726 if (CheckSavegameVersion(102)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1727 for (TileIndex t = 0; t < map_size; t++) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1728 /* Now all crossings should be in correct state */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1729 if (IsLevelCrossingTile(t)) UpdateLevelCrossing(t, false); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1730 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1731 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1732 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1733 if (CheckSavegameVersion(103)) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1734 /* Non-town-owned roads now store the closest town */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1735 UpdateNearestTownForRoadTiles(false); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1736 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1737 /* signs with invalid owner left from older savegames */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1738 Sign *si; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1739 FOR_ALL_SIGNS(si) { |
11924
fccc9cea27a7
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents:
11922
diff
changeset
|
1740 if (si->owner != OWNER_NONE && !Company::IsValidID(si->owner)) si->owner = OWNER_NONE; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1741 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1742 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1743 /* Station can get named based on an industry type, but the current ones |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1744 * are not, so mark them as if they are not named by an industry. */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1745 Station *st; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1746 FOR_ALL_STATIONS(st) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1747 st->indtype = IT_INVALID; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1748 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1749 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1750 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1751 if (CheckSavegameVersion(104)) { |
12035
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
1752 Aircraft *a; |
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
1753 FOR_ALL_AIRCRAFT(a) { |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1754 /* Set engine_type of shadow and rotor */ |
12035
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
1755 if (!IsNormalAircraft(a)) { |
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
1756 a->engine_type = a->First()->engine_type; |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1757 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1758 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1759 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1760 /* More companies ... */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1761 Company *c; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1762 FOR_ALL_COMPANIES(c) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1763 if (c->bankrupt_asked == 0xFF) c->bankrupt_asked = 0xFFFF; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1764 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1765 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1766 Engine *e; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1767 FOR_ALL_ENGINES(e) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1768 if (e->company_avail == 0xFF) e->company_avail = 0xFFFF; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1769 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1770 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1771 Town *t; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1772 FOR_ALL_TOWNS(t) { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1773 if (t->have_ratings == 0xFF) t->have_ratings = 0xFFFF; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1774 for (uint i = 8; i != MAX_COMPANIES; i++) t->ratings[i] = RATING_INITIAL; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1775 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1776 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1777 |
10951
5077f19e169c
(svn r15290) -Codechange: Isolate size and section of the UnMovable HQ object, in order to keep the Unmovable type free of any irrelevant data
belugas <belugas@openttd.org>
parents:
10881
diff
changeset
|
1778 if (CheckSavegameVersion(112)) { |
5077f19e169c
(svn r15290) -Codechange: Isolate size and section of the UnMovable HQ object, in order to keep the Unmovable type free of any irrelevant data
belugas <belugas@openttd.org>
parents:
10881
diff
changeset
|
1779 for (TileIndex t = 0; t < map_size; t++) { |
5077f19e169c
(svn r15290) -Codechange: Isolate size and section of the UnMovable HQ object, in order to keep the Unmovable type free of any irrelevant data
belugas <belugas@openttd.org>
parents:
10881
diff
changeset
|
1780 /* Check for HQ bit being set, instead of using map accessor, |
5077f19e169c
(svn r15290) -Codechange: Isolate size and section of the UnMovable HQ object, in order to keep the Unmovable type free of any irrelevant data
belugas <belugas@openttd.org>
parents:
10881
diff
changeset
|
1781 * since we've already changed it code-wise */ |
5077f19e169c
(svn r15290) -Codechange: Isolate size and section of the UnMovable HQ object, in order to keep the Unmovable type free of any irrelevant data
belugas <belugas@openttd.org>
parents:
10881
diff
changeset
|
1782 if (IsTileType(t, MP_UNMOVABLE) && HasBit(_m[t].m5, 7)) { |
5077f19e169c
(svn r15290) -Codechange: Isolate size and section of the UnMovable HQ object, in order to keep the Unmovable type free of any irrelevant data
belugas <belugas@openttd.org>
parents:
10881
diff
changeset
|
1783 /* Move size and part identification of HQ out of the m5 attribute, |
5077f19e169c
(svn r15290) -Codechange: Isolate size and section of the UnMovable HQ object, in order to keep the Unmovable type free of any irrelevant data
belugas <belugas@openttd.org>
parents:
10881
diff
changeset
|
1784 * on new locations */ |
5077f19e169c
(svn r15290) -Codechange: Isolate size and section of the UnMovable HQ object, in order to keep the Unmovable type free of any irrelevant data
belugas <belugas@openttd.org>
parents:
10881
diff
changeset
|
1785 uint8 old_m5 = _m[t].m5; |
5077f19e169c
(svn r15290) -Codechange: Isolate size and section of the UnMovable HQ object, in order to keep the Unmovable type free of any irrelevant data
belugas <belugas@openttd.org>
parents:
10881
diff
changeset
|
1786 _m[t].m5 = UNMOVABLE_HQ; |
5077f19e169c
(svn r15290) -Codechange: Isolate size and section of the UnMovable HQ object, in order to keep the Unmovable type free of any irrelevant data
belugas <belugas@openttd.org>
parents:
10881
diff
changeset
|
1787 SetCompanyHQSize(t, GB(old_m5, 2, 3)); |
5077f19e169c
(svn r15290) -Codechange: Isolate size and section of the UnMovable HQ object, in order to keep the Unmovable type free of any irrelevant data
belugas <belugas@openttd.org>
parents:
10881
diff
changeset
|
1788 SetCompanyHQSection(t, GB(old_m5, 0, 2)); |
5077f19e169c
(svn r15290) -Codechange: Isolate size and section of the UnMovable HQ object, in order to keep the Unmovable type free of any irrelevant data
belugas <belugas@openttd.org>
parents:
10881
diff
changeset
|
1789 } |
5077f19e169c
(svn r15290) -Codechange: Isolate size and section of the UnMovable HQ object, in order to keep the Unmovable type free of any irrelevant data
belugas <belugas@openttd.org>
parents:
10881
diff
changeset
|
1790 } |
5077f19e169c
(svn r15290) -Codechange: Isolate size and section of the UnMovable HQ object, in order to keep the Unmovable type free of any irrelevant data
belugas <belugas@openttd.org>
parents:
10881
diff
changeset
|
1791 } |
5077f19e169c
(svn r15290) -Codechange: Isolate size and section of the UnMovable HQ object, in order to keep the Unmovable type free of any irrelevant data
belugas <belugas@openttd.org>
parents:
10881
diff
changeset
|
1792 |
11000
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1793 if (CheckSavegameVersion(113)) { |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1794 /* allow_town_roads is added, set it if town_layout wasn't TL_NO_ROADS */ |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1795 if (_settings_game.economy.town_layout == 0) { // was TL_NO_ROADS |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1796 _settings_game.economy.allow_town_roads = false; |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1797 _settings_game.economy.town_layout = TL_BETTER_ROADS; |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1798 } else { |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1799 _settings_game.economy.allow_town_roads = true; |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1800 _settings_game.economy.town_layout = _settings_game.economy.town_layout - 1; |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1801 } |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1802 |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1803 /* Initialize layout of all towns. Older versions were using different |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1804 * generator for random town layout, use it if needed. */ |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1805 Town *t; |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1806 FOR_ALL_TOWNS(t) { |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1807 if (_settings_game.economy.town_layout != TL_RANDOM) { |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1808 t->layout = _settings_game.economy.town_layout; |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1809 continue; |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1810 } |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1811 |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1812 /* Use old layout randomizer code */ |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1813 byte layout = TileHash(TileX(t->xy), TileY(t->xy)) % 6; |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1814 switch (layout) { |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1815 default: break; |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1816 case 5: layout = 1; break; |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1817 case 0: layout = 2; break; |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1818 } |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1819 t->layout = layout - 1; |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1820 } |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1821 } |
def5dbb7e314
(svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents:
10960
diff
changeset
|
1822 |
11234
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1823 if (CheckSavegameVersion(114)) { |
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1824 /* There could be (deleted) stations with invalid owner, set owner to OWNER NONE. |
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1825 * The conversion affects oil rigs and buoys too, but it doesn't matter as |
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1826 * they have st->owner == OWNER_NONE already. */ |
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1827 Station *st; |
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1828 FOR_ALL_STATIONS(st) { |
11924
fccc9cea27a7
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents:
11922
diff
changeset
|
1829 if (!Company::IsValidID(st->owner)) st->owner = OWNER_NONE; |
11234
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1830 } |
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1831 |
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1832 /* Give owners to waypoints, based on rail tracks it is sitting on. |
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1833 * If none is available, specify OWNER_NONE. |
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1834 * This code was in CheckSavegameVersion(101) in the past, but in some cases, |
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1835 * the owner of waypoints could be incorrect. */ |
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1836 Waypoint *wp; |
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1837 FOR_ALL_WAYPOINTS(wp) { |
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1838 Owner owner = IsTileType(wp->xy, MP_RAILWAY) ? GetTileOwner(wp->xy) : OWNER_NONE; |
11924
fccc9cea27a7
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents:
11922
diff
changeset
|
1839 wp->owner = Company::IsValidID(owner) ? owner : OWNER_NONE; |
11234
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1840 } |
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1841 } |
6ebdffe6e5e6
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
smatz <smatz@openttd.org>
parents:
11085
diff
changeset
|
1842 |
11657
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11441
diff
changeset
|
1843 /* Trains could now stop in a specific location. */ |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11441
diff
changeset
|
1844 if (CheckSavegameVersion(117)) { |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11441
diff
changeset
|
1845 Order *o; |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11441
diff
changeset
|
1846 FOR_ALL_ORDERS(o) { |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11441
diff
changeset
|
1847 if (o->IsType(OT_GOTO_STATION)) o->SetStopLocation(OSL_PLATFORM_FAR_END); |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11441
diff
changeset
|
1848 } |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11441
diff
changeset
|
1849 } |
ff1084d0d8a0
(svn r16037) -Feature: allow (per order) to let a train stop at the near end, middle or far end of a platform from the point of view of the driver of the train that enters the station.
rubidium <rubidium@openttd.org>
parents:
11441
diff
changeset
|
1850 |
12032
2afeb10ae6ba
(svn r16439) -Change: Make the default vehicle servicing settings company-based settings, so in a multiplayer game everyone can change them.
yexo <yexo@openttd.org>
parents:
12001
diff
changeset
|
1851 if (CheckSavegameVersion(120)) { |
2afeb10ae6ba
(svn r16439) -Change: Make the default vehicle servicing settings company-based settings, so in a multiplayer game everyone can change them.
yexo <yexo@openttd.org>
parents:
12001
diff
changeset
|
1852 extern VehicleDefaultSettings _old_vds; |
2afeb10ae6ba
(svn r16439) -Change: Make the default vehicle servicing settings company-based settings, so in a multiplayer game everyone can change them.
yexo <yexo@openttd.org>
parents:
12001
diff
changeset
|
1853 Company *c; |
2afeb10ae6ba
(svn r16439) -Change: Make the default vehicle servicing settings company-based settings, so in a multiplayer game everyone can change them.
yexo <yexo@openttd.org>
parents:
12001
diff
changeset
|
1854 FOR_ALL_COMPANIES(c) { |
2afeb10ae6ba
(svn r16439) -Change: Make the default vehicle servicing settings company-based settings, so in a multiplayer game everyone can change them.
yexo <yexo@openttd.org>
parents:
12001
diff
changeset
|
1855 c->settings.vehicle = _old_vds; |
2afeb10ae6ba
(svn r16439) -Change: Make the default vehicle servicing settings company-based settings, so in a multiplayer game everyone can change them.
yexo <yexo@openttd.org>
parents:
12001
diff
changeset
|
1856 } |
2afeb10ae6ba
(svn r16439) -Change: Make the default vehicle servicing settings company-based settings, so in a multiplayer game everyone can change them.
yexo <yexo@openttd.org>
parents:
12001
diff
changeset
|
1857 } |
2afeb10ae6ba
(svn r16439) -Change: Make the default vehicle servicing settings company-based settings, so in a multiplayer game everyone can change them.
yexo <yexo@openttd.org>
parents:
12001
diff
changeset
|
1858 |
12112
527e86d95414
(svn r16525) -Codechange: Notify small ufos on deletion of road vehicles, so they can head for somewhere else instead of stumbling over a ghost.
frosch <frosch@openttd.org>
parents:
12035
diff
changeset
|
1859 if (CheckSavegameVersion(121)) { |
527e86d95414
(svn r16525) -Codechange: Notify small ufos on deletion of road vehicles, so they can head for somewhere else instead of stumbling over a ghost.
frosch <frosch@openttd.org>
parents:
12035
diff
changeset
|
1860 /* Delete small ufos heading for non-existing vehicles */ |
527e86d95414
(svn r16525) -Codechange: Notify small ufos on deletion of road vehicles, so they can head for somewhere else instead of stumbling over a ghost.
frosch <frosch@openttd.org>
parents:
12035
diff
changeset
|
1861 Vehicle *v; |
527e86d95414
(svn r16525) -Codechange: Notify small ufos on deletion of road vehicles, so they can head for somewhere else instead of stumbling over a ghost.
frosch <frosch@openttd.org>
parents:
12035
diff
changeset
|
1862 FOR_ALL_DISASTERVEHICLES(v) { |
527e86d95414
(svn r16525) -Codechange: Notify small ufos on deletion of road vehicles, so they can head for somewhere else instead of stumbling over a ghost.
frosch <frosch@openttd.org>
parents:
12035
diff
changeset
|
1863 if (v->subtype == 2/*ST_SMALL_UFO*/ && v->current_order.GetDestination() != 0) { |
527e86d95414
(svn r16525) -Codechange: Notify small ufos on deletion of road vehicles, so they can head for somewhere else instead of stumbling over a ghost.
frosch <frosch@openttd.org>
parents:
12035
diff
changeset
|
1864 const Vehicle *u = Vehicle::GetIfValid(v->dest_tile); |
527e86d95414
(svn r16525) -Codechange: Notify small ufos on deletion of road vehicles, so they can head for somewhere else instead of stumbling over a ghost.
frosch <frosch@openttd.org>
parents:
12035
diff
changeset
|
1865 if (u == NULL || u->type != VEH_ROAD || !IsRoadVehFront(u)) { |
527e86d95414
(svn r16525) -Codechange: Notify small ufos on deletion of road vehicles, so they can head for somewhere else instead of stumbling over a ghost.
frosch <frosch@openttd.org>
parents:
12035
diff
changeset
|
1866 delete v; |
527e86d95414
(svn r16525) -Codechange: Notify small ufos on deletion of road vehicles, so they can head for somewhere else instead of stumbling over a ghost.
frosch <frosch@openttd.org>
parents:
12035
diff
changeset
|
1867 } |
527e86d95414
(svn r16525) -Codechange: Notify small ufos on deletion of road vehicles, so they can head for somewhere else instead of stumbling over a ghost.
frosch <frosch@openttd.org>
parents:
12035
diff
changeset
|
1868 } |
527e86d95414
(svn r16525) -Codechange: Notify small ufos on deletion of road vehicles, so they can head for somewhere else instead of stumbling over a ghost.
frosch <frosch@openttd.org>
parents:
12035
diff
changeset
|
1869 } |
527e86d95414
(svn r16525) -Codechange: Notify small ufos on deletion of road vehicles, so they can head for somewhere else instead of stumbling over a ghost.
frosch <frosch@openttd.org>
parents:
12035
diff
changeset
|
1870 } |
527e86d95414
(svn r16525) -Codechange: Notify small ufos on deletion of road vehicles, so they can head for somewhere else instead of stumbling over a ghost.
frosch <frosch@openttd.org>
parents:
12035
diff
changeset
|
1871 |
11441
9af29ff772fd
(svn r15799) -Codechange: Save rail type label list to savegame and perform mapping on load if necessary.
peter1138 <peter1138@openttd.org>
parents:
11368
diff
changeset
|
1872 AfterLoadLabelMaps(); |
9af29ff772fd
(svn r15799) -Codechange: Save rail type label list to savegame and perform mapping on load if necessary.
peter1138 <peter1138@openttd.org>
parents:
11368
diff
changeset
|
1873 |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1874 GamelogPrintDebug(1); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1875 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1876 bool ret = InitializeWindowsAndCaches(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1877 /* Restore the signals */ |
11948
ad1ecf6b26e4
(svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents:
11946
diff
changeset
|
1878 ResetSignalHandlers(); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1879 return ret; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1880 } |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1881 |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1882 /** Reload all NewGRF files during a running game. This is a cut-down |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1883 * version of AfterLoadGame(). |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1884 * XXX - We need to reset the vehicle position hash because with a non-empty |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1885 * hash AfterLoadVehicles() will loop infinitely. We need AfterLoadVehicles() |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1886 * to recalculate vehicle data as some NewGRF vehicle sets could have been |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1887 * removed or added and changed statistics */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1888 void ReloadNewGRFData() |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1889 { |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1890 /* reload grf data */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1891 GfxLoadSprites(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1892 LoadStringWidthTable(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1893 ResetEconomy(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1894 /* reload vehicles */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1895 ResetVehiclePosHash(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1896 AfterLoadVehicles(false); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1897 StartupEngines(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1898 SetCachedEngineCounts(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1899 /* update station and waypoint graphics */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1900 AfterLoadWaypoints(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1901 AfterLoadStations(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1902 /* Check and update house and town values */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1903 UpdateHousesAndTowns(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1904 /* Update livery selection windows */ |
11085
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
11069
diff
changeset
|
1905 for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) InvalidateWindowData(WC_COMPANY_COLOUR, i, _loaded_newgrf_features.has_2CC); |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1906 /* redraw the whole screen */ |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1907 MarkWholeScreenDirty(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1908 CheckTrainsLengths(); |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff
changeset
|
1909 } |