annotate src/saveload/afterload.cpp @ 19843:9a8968c733ba draft

(svn r24776) -Doc: Typo fixes, additions, and additional dots collected from various sources (including Eagle_rainbow, MinchinWeb)
author alberth <alberth@openttd.org>
date Sat, 01 Dec 2012 13:12:39 +0000
parents 3c4d042d5e72
children 74b60883eeca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1 /* $Id$ */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12749
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12749
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12749
diff changeset
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12749
diff changeset
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12749
diff changeset
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12749
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12749
diff changeset
9
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
10 /** @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
11
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
12 #include "../stdafx.h"
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
13 #include "../void_map.h"
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
14 #include "../signs_base.h"
12999
07a634b14de8 (svn r17493) -Codechange: store the depot index on the map
rubidium <rubidium@openttd.org>
parents: 12998
diff changeset
15 #include "../depot_base.h"
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
16 #include "../fios.h"
12786
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
17 #include "../gamelog_internal.h"
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
18 #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
19 #include "../gfxinit.h"
17277
5b204f51b151 (svn r22017) -Codechange: move MarkTileDirtyByTile to viewport_func.h
rubidium <rubidium@openttd.org>
parents: 17261
diff changeset
20 #include "../viewport_func.h"
12826
c2f3eaf3b353 (svn r17316) -Codechange: use Industry::GetByTile() instead of GetIndustryByTile()
smatz <smatz@openttd.org>
parents: 12810
diff changeset
21 #include "../industry.h"
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
22 #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
23 #include "../vehicle_func.h"
13850
da5eda07b403 (svn r18379) -Codechange: move the cache updating function to its own header to reduce the include 'pathfinder' dependencies
rubidium <rubidium@openttd.org>
parents: 13835
diff changeset
24 #include "../string_func.h"
da5eda07b403 (svn r18379) -Codechange: move the cache updating function to its own header to reduce the include 'pathfinder' dependencies
rubidium <rubidium@openttd.org>
parents: 13835
diff changeset
25 #include "../date_func.h"
da5eda07b403 (svn r18379) -Codechange: move the cache updating function to its own header to reduce the include 'pathfinder' dependencies
rubidium <rubidium@openttd.org>
parents: 13835
diff changeset
26 #include "../roadveh.h"
da5eda07b403 (svn r18379) -Codechange: move the cache updating function to its own header to reduce the include 'pathfinder' dependencies
rubidium <rubidium@openttd.org>
parents: 13835
diff changeset
27 #include "../train.h"
da5eda07b403 (svn r18379) -Codechange: move the cache updating function to its own header to reduce the include 'pathfinder' dependencies
rubidium <rubidium@openttd.org>
parents: 13835
diff changeset
28 #include "../station_base.h"
da5eda07b403 (svn r18379) -Codechange: move the cache updating function to its own header to reduce the include 'pathfinder' dependencies
rubidium <rubidium@openttd.org>
parents: 13835
diff changeset
29 #include "../waypoint_base.h"
13859
e6ee12f4541d (svn r18388) -Codechange: move entering/leaving of road stops to functions of RoadStop
rubidium <rubidium@openttd.org>
parents: 13856
diff changeset
30 #include "../roadstop_base.h"
13850
da5eda07b403 (svn r18379) -Codechange: move the cache updating function to its own header to reduce the include 'pathfinder' dependencies
rubidium <rubidium@openttd.org>
parents: 13835
diff changeset
31 #include "../tunnelbridge_map.h"
da5eda07b403 (svn r18379) -Codechange: move the cache updating function to its own header to reduce the include 'pathfinder' dependencies
rubidium <rubidium@openttd.org>
parents: 13835
diff changeset
32 #include "../pathfinder/yapf/yapf_cache.h"
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
33 #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
34 #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
35 #include "../aircraft.h"
15744
f9e8032ac213 (svn r20411) -Codechange: rename unmovables as quite a lot of them are actually movable; e.g. HQ and owned land are pretty movable.
rubidium <rubidium@openttd.org>
parents: 15709
diff changeset
36 #include "../object_map.h"
15807
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
37 #include "../object_base.h"
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
38 #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
39 #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
40 #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
41 #include "../ai/ai.hpp"
14805
1d2b20b90ce2 (svn r19395) -Fix [FS#3669]: the AI Debug window didn't open if an AI or library fails to compile when loading a savegame
Yexo <Yexo@openttd.org>
parents: 14793
diff changeset
42 #include "../ai/ai_gui.hpp"
12249
559350145373 (svn r16664) -Codechange: move house-related stuff from town.h and town_type.h to separate files
smatz <smatz@openttd.org>
parents: 12239
diff changeset
43 #include "../town.h"
12279
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
44 #include "../economy_base.h"
12292
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
45 #include "../animated_tile_func.h"
12297
39ea618c207e (svn r16714) -Codechange: use pool-like accessors for Subsidy
smatz <smatz@openttd.org>
parents: 12294
diff changeset
46 #include "../subsidy_base.h"
12658
b75d8c6681bd (svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
smatz <smatz@openttd.org>
parents: 12652
diff changeset
47 #include "../subsidy_func.h"
14258
a899d4e5ee1a (svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, if a header require a header make it include that header
rubidium <rubidium@openttd.org>
parents: 14213
diff changeset
48 #include "../newgrf.h"
a899d4e5ee1a (svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, if a header require a header make it include that header
rubidium <rubidium@openttd.org>
parents: 14213
diff changeset
49 #include "../engine_func.h"
15221
0d1472229334 (svn r19850) -Codechange: move declaration of InitializeRailGUI() to rail_gui.h
smatz <smatz@openttd.org>
parents: 15170
diff changeset
50 #include "../rail_gui.h"
15279
4e1862aebea2 (svn r19914) -Codechange: Wrap a helper class around temporary assignments of _current_company to ensure proper restoration.
frosch <frosch@openttd.org>
parents: 15221
diff changeset
51 #include "../core/backup_type.hpp"
16982
27ab8bdc8e03 (svn r21718) -Feature: Show a list of companies in the owner legend.
terkhen <terkhen@openttd.org>
parents: 16922
diff changeset
52 #include "../smallmap_gui.h"
17247
5221777879f1 (svn r21987) -Fix: Make news items, engine previews and AI preview events deal with no longer existing Engine items after resetting the pool.
frosch <frosch@openttd.org>
parents: 17229
diff changeset
53 #include "../news_func.h"
18629
a55c2ad0bf2c (svn r23476) -Codechange: use the error queue to replace switch mode error strings, again making it possible to return multiple errors
rubidium <rubidium@openttd.org>
parents: 18566
diff changeset
54 #include "../error.h"
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
55
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
56
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
57 #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
58
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
59 #include <signal.h>
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
60
12810
0400e81a3cc9 (svn r17298) -Fix [FS#3153]: reloading an AI started a new AI in the first available company slot causing other AIs to be started
yexo <yexo@openttd.org>
parents: 12786
diff changeset
61 extern Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
62
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 * 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
65 *
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
66 * 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
67 *
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
68 * 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
69 * 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
70 * @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
71 * @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
72 */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
73 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
74 {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
75 /* 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
76 * Note: Wrt. autosloping under industry tiles this is the most fool-proof behaviour. */
18257
b6026cba5dae (svn r23093) -Codechange: add a default NULL for the Z of GetTileSlope and use it
rubidium <rubidium@openttd.org>
parents: 18255
diff changeset
77 if (GetTileSlope(t) != SLOPE_FLAT) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
78 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
79 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
80 return;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
81 } else {
16123
a73c48c80b5d (svn r20819) -Fix [FS#3714]: be a bit more "lenient" w.r.t. invalid savegames; don't crash on saveload related NOT_REACHEDs, just show the user an error that the savegame is corrupted
rubidium <rubidium@openttd.org>
parents: 16122
diff changeset
82 SlErrorCorrupt("Invalid water class for dry tile");
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
83 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
84 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
85
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
86 /* 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
87 MarkTileDirtyByTile(t);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
88
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
89 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
90 /* 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
91 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
92 return;
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
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
95 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
96 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
97 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
98
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
99 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
100 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
101 switch (GetTileType(neighbour)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
102 case MP_WATER:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
103 /* 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
104 if (IsCoast(neighbour)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
105 has_water = true;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
106 } 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
107 switch (GetWaterClass(neighbour)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
108 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
109 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
110 case WATER_CLASS_RIVER: has_river = true; break;
16123
a73c48c80b5d (svn r20819) -Fix [FS#3714]: be a bit more "lenient" w.r.t. invalid savegames; don't crash on saveload related NOT_REACHEDs, just show the user an error that the savegame is corrupted
rubidium <rubidium@openttd.org>
parents: 16122
diff changeset
111 default: SlErrorCorrupt("Invalid water class for tile");
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
112 }
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 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
115
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
116 case MP_RAILWAY:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
117 /* 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
118 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
119 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
120
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
121 case MP_TREES:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
122 /* trees on shore */
14171
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
123 has_water |= (GB(_m[neighbour].m2, 4, 2) == TREE_GROUND_SHORE);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
124 break;
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 default: break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
127 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
128 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
129
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
130 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
131 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
132 return;
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
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
135 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
136 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
137 } 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
138 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
139 } else {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
140 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
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
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
144 static void ConvertTownOwner()
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 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
147 switch (GetTileType(tile)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
148 case MP_ROAD:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
149 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
150 _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
151 }
15579
5f128be91f59 (svn r20239) -Doc: Give a common name to all fall throughs (FALL THROUGH).
terkhen <terkhen@openttd.org>
parents: 15552
diff changeset
152 /* FALL THROUGH */
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
153
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
154 case MP_TUNNELBRIDGE:
17056
8d85ca97b9b1 (svn r21793) -Fix (r20446): broken usage of GetTileOwner() caused wrong conversion of old savegames
smatz <smatz@openttd.org>
parents: 17049
diff changeset
155 if (_m[tile].m1 & 0x80) SetTileOwner(tile, OWNER_TOWN);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
156 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
157
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
158 default: break;
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
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
163 /* 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
164 static void UpdateExclusiveRights()
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
165 {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
166 Town *t;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
167
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
168 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
169 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
170 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
171
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
172 /* 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
173 * 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
174 * 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
175 * 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
176 * 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
177 * 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
178 * 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
179 */
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
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
182 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
183 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
184 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
185 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
186 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
187 18, 2, 20,
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
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
190 /* 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
191 static void UpdateCurrencies()
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 _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
194 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
195
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
196 /* 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
197 * 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
198 */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
199 static void UpdateVoidTiles()
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 uint i;
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 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
204 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
205 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
206
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
207 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
208 {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
209 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
210 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
211
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
212 /**
13950
77bfe67f23bd (svn r18486) -Fix: when switching language and you're getting a different font, recalculate the coordinates/sizes of the viewport signs. Otherwise it gets glitchy or abbreviated (in the smallmap)
rubidium <rubidium@openttd.org>
parents: 13875
diff changeset
213 * Update the viewport coordinates of all signs.
77bfe67f23bd (svn r18486) -Fix: when switching language and you're getting a different font, recalculate the coordinates/sizes of the viewport signs. Otherwise it gets glitchy or abbreviated (in the smallmap)
rubidium <rubidium@openttd.org>
parents: 13875
diff changeset
214 */
77bfe67f23bd (svn r18486) -Fix: when switching language and you're getting a different font, recalculate the coordinates/sizes of the viewport signs. Otherwise it gets glitchy or abbreviated (in the smallmap)
rubidium <rubidium@openttd.org>
parents: 13875
diff changeset
215 void UpdateAllVirtCoords()
77bfe67f23bd (svn r18486) -Fix: when switching language and you're getting a different font, recalculate the coordinates/sizes of the viewport signs. Otherwise it gets glitchy or abbreviated (in the smallmap)
rubidium <rubidium@openttd.org>
parents: 13875
diff changeset
216 {
77bfe67f23bd (svn r18486) -Fix: when switching language and you're getting a different font, recalculate the coordinates/sizes of the viewport signs. Otherwise it gets glitchy or abbreviated (in the smallmap)
rubidium <rubidium@openttd.org>
parents: 13875
diff changeset
217 UpdateAllStationVirtCoords();
77bfe67f23bd (svn r18486) -Fix: when switching language and you're getting a different font, recalculate the coordinates/sizes of the viewport signs. Otherwise it gets glitchy or abbreviated (in the smallmap)
rubidium <rubidium@openttd.org>
parents: 13875
diff changeset
218 UpdateAllSignVirtCoords();
77bfe67f23bd (svn r18486) -Fix: when switching language and you're getting a different font, recalculate the coordinates/sizes of the viewport signs. Otherwise it gets glitchy or abbreviated (in the smallmap)
rubidium <rubidium@openttd.org>
parents: 13875
diff changeset
219 UpdateAllTownVirtCoords();
77bfe67f23bd (svn r18486) -Fix: when switching language and you're getting a different font, recalculate the coordinates/sizes of the viewport signs. Otherwise it gets glitchy or abbreviated (in the smallmap)
rubidium <rubidium@openttd.org>
parents: 13875
diff changeset
220 }
77bfe67f23bd (svn r18486) -Fix: when switching language and you're getting a different font, recalculate the coordinates/sizes of the viewport signs. Otherwise it gets glitchy or abbreviated (in the smallmap)
rubidium <rubidium@openttd.org>
parents: 13875
diff changeset
221
77bfe67f23bd (svn r18486) -Fix: when switching language and you're getting a different font, recalculate the coordinates/sizes of the viewport signs. Otherwise it gets glitchy or abbreviated (in the smallmap)
rubidium <rubidium@openttd.org>
parents: 13875
diff changeset
222 /**
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
223 * 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
224 * 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
225 * 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
226 * 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
227 * 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
228 * had been made.
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
229 * 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
230 */
12749
27a938bed307 (svn r17215) -Cleanup: remove unused return value
yexo <yexo@openttd.org>
parents: 12669
diff changeset
231 static void InitializeWindowsAndCaches()
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
232 {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
233 /* Initialize windows */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
234 ResetWindowSystem();
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11069
diff changeset
235 SetupColoursAndInitialWindow();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
236
13950
77bfe67f23bd (svn r18486) -Fix: when switching language and you're getting a different font, recalculate the coordinates/sizes of the viewport signs. Otherwise it gets glitchy or abbreviated (in the smallmap)
rubidium <rubidium@openttd.org>
parents: 13875
diff changeset
237 /* Update coordinates of the signs. */
77bfe67f23bd (svn r18486) -Fix: when switching language and you're getting a different font, recalculate the coordinates/sizes of the viewport signs. Otherwise it gets glitchy or abbreviated (in the smallmap)
rubidium <rubidium@openttd.org>
parents: 13875
diff changeset
238 UpdateAllVirtCoords();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
239 ResetViewportAfterLoadGame();
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
240
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
241 Company *c;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
242 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
243 /* 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
244 * 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
245 * 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
246 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
247 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
248 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
249 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
250
12940
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
251 RecomputePrices();
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
252
18152
545be3b5f43e (svn r22977) -Codechange: Rename SetCachedEngineCounts() to GroupStatistics::UpdateAfterLoad().
frosch <frosch@openttd.org>
parents: 17853
diff changeset
253 GroupStatistics::UpdateAfterLoad();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
254
12239
b1d30d9d4025 (svn r16654) -Codechange: cache industries in station's coverage area instead of searching them everytime payment is made
smatz <smatz@openttd.org>
parents: 12228
diff changeset
255 Station::RecomputeIndustriesNearForAll();
12658
b75d8c6681bd (svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
smatz <smatz@openttd.org>
parents: 12652
diff changeset
256 RebuildSubsidisedSourceAndDestinationCache();
12239
b1d30d9d4025 (svn r16654) -Codechange: cache industries in station's coverage area instead of searching them everytime payment is made
smatz <smatz@openttd.org>
parents: 12228
diff changeset
257
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
258 /* 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
259 * 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
260 * 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
261 UpdateAirportsNoise();
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
262
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
263 CheckTrainsLengths();
13968
070572f1272d (svn r18506) -Fix [FS#3368]: no error message was created for the first fatal NewGRF error.
rubidium <rubidium@openttd.org>
parents: 13950
diff changeset
264 ShowNewGRFError();
14805
1d2b20b90ce2 (svn r19395) -Fix [FS#3669]: the AI Debug window didn't open if an AI or library fails to compile when loading a savegame
Yexo <Yexo@openttd.org>
parents: 14793
diff changeset
265 ShowAIDebugWindowIfAIError();
16982
27ab8bdc8e03 (svn r21718) -Feature: Show a list of companies in the owner legend.
terkhen <terkhen@openttd.org>
parents: 16922
diff changeset
266
27ab8bdc8e03 (svn r21718) -Feature: Show a list of companies in the owner legend.
terkhen <terkhen@openttd.org>
parents: 16922
diff changeset
267 /* Rebuild the smallmap list of owners. */
27ab8bdc8e03 (svn r21718) -Feature: Show a list of companies in the owner legend.
terkhen <terkhen@openttd.org>
parents: 16922
diff changeset
268 BuildOwnerLegend();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
269 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
270
11948
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
271 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
272 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
273 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
274 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
275
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
276 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
277
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
278 /**
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
279 * 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
280 * 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
281 */
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
282 static void SetSignalHandlers()
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
283 {
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
284 _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
285 _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
286 _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
287 }
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
288
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
289 /**
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
290 * 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
291 */
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
292 static void ResetSignalHandlers()
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
293 {
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
294 signal(SIGSEGV, _prev_segfault);
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
295 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
296 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
297 }
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
298
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
299 /**
12786
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
300 * Try to find the overridden GRF identifier of the given GRF.
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
301 * @param c the GRF to get the 'previous' version of.
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
302 * @return the GRF identifier or \a c if none could be found.
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
303 */
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
304 static const GRFIdentifier *GetOverriddenIdentifier(const GRFConfig *c)
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
305 {
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
306 const LoggedAction *la = &_gamelog_action[_gamelog_actions - 1];
14676
353df593bee0 (svn r19255) -Codechange: encapsulate GRFIdentifier in GRFConfig instead of subclassing it
yexo <yexo@openttd.org>
parents: 14621
diff changeset
307 if (la->at != GLAT_LOAD) return &c->ident;
12786
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
308
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
309 const LoggedChange *lcend = &la->change[la->changes];
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
310 for (const LoggedChange *lc = la->change; lc != lcend; lc++) {
14676
353df593bee0 (svn r19255) -Codechange: encapsulate GRFIdentifier in GRFConfig instead of subclassing it
yexo <yexo@openttd.org>
parents: 14621
diff changeset
311 if (lc->ct == GLCT_GRFCOMPAT && lc->grfcompat.grfid == c->ident.grfid) return &lc->grfcompat;
12786
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
312 }
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
313
14676
353df593bee0 (svn r19255) -Codechange: encapsulate GRFIdentifier in GRFConfig instead of subclassing it
yexo <yexo@openttd.org>
parents: 14621
diff changeset
314 return &c->ident;
12786
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
315 }
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
316
14279
22e76a982410 (svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents: 14261
diff changeset
317 /** Was the saveload crash because of missing NewGRFs? */
22e76a982410 (svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents: 14261
diff changeset
318 static bool _saveload_crash_with_missing_newgrfs = false;
22e76a982410 (svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents: 14261
diff changeset
319
22e76a982410 (svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents: 14261
diff changeset
320 /**
22e76a982410 (svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents: 14261
diff changeset
321 * Did loading the savegame cause a crash? If so,
22e76a982410 (svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents: 14261
diff changeset
322 * were NewGRFs missing?
22e76a982410 (svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents: 14261
diff changeset
323 * @return when the saveload crashed due to missing NewGRFs.
22e76a982410 (svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents: 14261
diff changeset
324 */
22e76a982410 (svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents: 14261
diff changeset
325 bool SaveloadCrashWithMissingNewGRFs()
22e76a982410 (svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents: 14261
diff changeset
326 {
22e76a982410 (svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents: 14261
diff changeset
327 return _saveload_crash_with_missing_newgrfs;
22e76a982410 (svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents: 14261
diff changeset
328 }
22e76a982410 (svn r18831) -Change [FS#3537]: do not go into the crashlog handler in case loading a savegame misses with missing NewGRFs. This way the load game crash handler gets better visibility and the user is instructed to find the missing NewGRFs before filing a bug report
rubidium <rubidium@openttd.org>
parents: 14261
diff changeset
329
12786
0745055d8e85 (svn r17267) -Change [FS#3139]: mention the MD5 checksum of the original NewGRF in the "saveload failed horribly"-error message and make it more clear that the filename is of the current NewGRF
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
330 /**
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
331 * 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
332 * 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
333 * 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
334 * @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
335 */
11948
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
336 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
337 {
11948
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
338 ResetSignalHandlers();
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
339
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
340 char buffer[8192];
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
341 char *p = buffer;
16122
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
342 p += seprintf(p, lastof(buffer), "Loading your savegame caused OpenTTD to crash.\n");
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
343
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
344 for (const GRFConfig *c = _grfconfig; !_saveload_crash_with_missing_newgrfs && c != NULL; c = c->next) {
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
345 _saveload_crash_with_missing_newgrfs = HasBit(c->flags, GCF_COMPATIBLE) || c->status == GCS_NOT_FOUND;
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
346 }
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
347
16122
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
348 if (_saveload_crash_with_missing_newgrfs) {
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
349 p += seprintf(p, lastof(buffer),
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
350 "This is most likely caused by a missing NewGRF or a NewGRF that\n"
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
351 "has been loaded as replacement for a missing NewGRF. OpenTTD\n"
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
352 "cannot easily determine whether a replacement NewGRF is of a newer\n"
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
353 "or older version.\n"
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
354 "It will load a NewGRF with the same GRF ID as the missing NewGRF.\n"
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
355 "This means that if the author makes incompatible NewGRFs with the\n"
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
356 "same GRF ID OpenTTD cannot magically do the right thing. In most\n"
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
357 "cases OpenTTD will load the savegame and not crash, but this is an\n"
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
358 "exception.\n"
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
359 "Please load the savegame with the appropriate NewGRFs installed.\n"
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
360 "The missing/compatible NewGRFs are:\n");
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
361
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
362 for (const GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
363 if (HasBit(c->flags, GCF_COMPATIBLE)) {
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
364 const GRFIdentifier *replaced = GetOverriddenIdentifier(c);
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
365 char buf[40];
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
366 md5sumToString(buf, lastof(buf), replaced->md5sum);
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
367 p += seprintf(p, lastof(buffer), "NewGRF %08X (checksum %s) not found.\n Loaded NewGRF \"%s\" with same GRF ID instead.\n", BSWAP32(c->ident.grfid), buf, c->filename);
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
368 }
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
369 if (c->status == GCS_NOT_FOUND) {
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
370 char buf[40];
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
371 md5sumToString(buf, lastof(buf), c->ident.md5sum);
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
372 p += seprintf(p, lastof(buffer), "NewGRF %08X (%s) not found; checksum %s.\n", BSWAP32(c->ident.grfid), c->filename, buf);
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
373 }
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
374 }
16122
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
375 } else {
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
376 p += seprintf(p, lastof(buffer),
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
377 "This is probably caused by a corruption in the savegame.\n"
9994b0118198 (svn r20818) -Fix [FS#3791]: make the crash-on-saveload message clearer and more correct
rubidium <rubidium@openttd.org>
parents: 16120
diff changeset
378 "Please file a bug report and attach this savegame.\n");
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
379 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
380
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
381 ShowInfo(buffer);
11948
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
382
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
383 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
384 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
385 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
386 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
387 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
388 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
389 }
11948
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
390 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
391 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
392
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
393 /**
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
394 * 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
395 * 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
396 * @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
397 */
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
398 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
399 {
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
400 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
401
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
402 /* 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
403 Train *v = NULL, *w;
dcc31c1d758a (svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents: 12034
diff changeset
404 FOR_ALL_TRAINS(w) {
dcc31c1d758a (svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents: 12034
diff changeset
405 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
406 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
407 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
408 }
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
409 }
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
410
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
411 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
412 /* 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
413 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
414 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
415 }
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
416
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
417 /* 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
418 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
419 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
420 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
421 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
422 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
423 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
424 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
425 }
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
426 }
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
427
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
428 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
429 /* 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
430 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
431 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
432 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
433 }
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
434
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
435 /* 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
436 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
437 }
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
438
17143
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
439 /**
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
440 * Fixes inclination of a vehicle. Older OpenTTD versions didn't update the bits correctly.
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
441 * @param v vehicle
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
442 * @param dir vehicle's direction, or # INVALID_DIR if it can be ignored
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
443 * @return inclination bits to set
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
444 */
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
445 static uint FixVehicleInclination(Vehicle *v, Direction dir)
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
446 {
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
447 /* Compute place where this vehicle entered the tile */
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
448 int entry_x = v->x_pos;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
449 int entry_y = v->y_pos;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
450 switch (dir) {
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
451 case DIR_NE: entry_x |= TILE_UNIT_MASK; break;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
452 case DIR_NW: entry_y |= TILE_UNIT_MASK; break;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
453 case DIR_SW: entry_x &= ~TILE_UNIT_MASK; break;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
454 case DIR_SE: entry_y &= ~TILE_UNIT_MASK; break;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
455 case INVALID_DIR: break;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
456 default: NOT_REACHED();
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
457 }
18255
b3cb40aab91b (svn r23091) -Codechange: rename some Get*Z functions to Get*PixelZ functions if they return the Z in pixels (like TilePixelHeight)
rubidium <rubidium@openttd.org>
parents: 18248
diff changeset
458 byte entry_z = GetSlopePixelZ(entry_x, entry_y);
17143
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
459
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
460 /* Compute middle of the tile. */
19631
0badfcb4cc4d (svn r24540) -Codechange: Remove the not-so-useful HALF_TILE_SIZE constant.
alberth <alberth@openttd.org>
parents: 19245
diff changeset
461 int middle_x = (v->x_pos & ~TILE_UNIT_MASK) + TILE_SIZE / 2;
0badfcb4cc4d (svn r24540) -Codechange: Remove the not-so-useful HALF_TILE_SIZE constant.
alberth <alberth@openttd.org>
parents: 19245
diff changeset
462 int middle_y = (v->y_pos & ~TILE_UNIT_MASK) + TILE_SIZE / 2;
18255
b3cb40aab91b (svn r23091) -Codechange: rename some Get*Z functions to Get*PixelZ functions if they return the Z in pixels (like TilePixelHeight)
rubidium <rubidium@openttd.org>
parents: 18248
diff changeset
463 byte middle_z = GetSlopePixelZ(middle_x, middle_y);
17143
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
464
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
465 /* middle_z == entry_z, no height change. */
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
466 if (middle_z == entry_z) return 0;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
467
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
468 /* middle_z < entry_z, we are going downwards. */
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
469 if (middle_z < entry_z) return 1U << GVF_GOINGDOWN_BIT;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
470
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
471 /* middle_z > entry_z, we are going upwards. */
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
472 return 1U << GVF_GOINGUP_BIT;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
473 }
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
474
17193
f84b0a9115e7 (svn r21932) -Document: some tidbits related to vehicles
rubidium <rubidium@openttd.org>
parents: 17143
diff changeset
475 /**
f84b0a9115e7 (svn r21932) -Document: some tidbits related to vehicles
rubidium <rubidium@openttd.org>
parents: 17143
diff changeset
476 * Perform a (large) amount of savegame conversion *magic* in order to
f84b0a9115e7 (svn r21932) -Document: some tidbits related to vehicles
rubidium <rubidium@openttd.org>
parents: 17143
diff changeset
477 * load older savegames and to fill the caches for various purposes.
f84b0a9115e7 (svn r21932) -Document: some tidbits related to vehicles
rubidium <rubidium@openttd.org>
parents: 17143
diff changeset
478 * @return True iff conversion went without a problem.
f84b0a9115e7 (svn r21932) -Document: some tidbits related to vehicles
rubidium <rubidium@openttd.org>
parents: 17143
diff changeset
479 */
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
480 bool AfterLoadGame()
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
481 {
11948
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
482 SetSignalHandlers();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
483
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
484 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
485
19243
3944b709b9bb (svn r24132) -Change [FS#4713]: Improve randomness of tile order in the tile loop. (monoid)
michi_cc <michi_cc@openttd.org>
parents: 19088
diff changeset
486 extern TileIndex _cur_tileloop_tile; // From landscape.cpp.
3944b709b9bb (svn r24132) -Change [FS#4713]: Improve randomness of tile order in the tile loop. (monoid)
michi_cc <michi_cc@openttd.org>
parents: 19088
diff changeset
487 /* The LFSR used in RunTileLoop iteration cannot have a zeroed state, make it non-zeroed. */
3944b709b9bb (svn r24132) -Change [FS#4713]: Improve randomness of tile order in the tile loop. (monoid)
michi_cc <michi_cc@openttd.org>
parents: 19088
diff changeset
488 if (_cur_tileloop_tile == 0) _cur_tileloop_tile = 1;
3944b709b9bb (svn r24132) -Change [FS#4713]: Improve randomness of tile order in the tile loop. (monoid)
michi_cc <michi_cc@openttd.org>
parents: 19088
diff changeset
489
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
490 if (IsSavegameVersionBefore(98)) GamelogOldver();
10571
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 GamelogTestRevision();
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
493 GamelogTestMode();
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
494
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
495 if (IsSavegameVersionBefore(98)) GamelogGRFAddList(_grfconfig);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
496
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
497 if (IsSavegameVersionBefore(119)) {
11852
862dd1024fe7 (svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents: 11657
diff changeset
498 _pause_mode = (_pause_mode == 2) ? PM_PAUSED_NORMAL : PM_UNPAUSED;
13178
ec4dc42ad747 (svn r17685) -Fix: autounpausing kept trying to unpause a loaded game that was paused due to an error. Just reject such savegames in dedicated servers.
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
499 } else if (_network_dedicated && (_pause_mode & PM_PAUSED_ERROR) != 0) {
ec4dc42ad747 (svn r17685) -Fix: autounpausing kept trying to unpause a loaded game that was paused due to an error. Just reject such savegames in dedicated servers.
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
500 DEBUG(net, 0, "The loading savegame was paused due to an error state.");
ec4dc42ad747 (svn r17685) -Fix: autounpausing kept trying to unpause a loaded game that was paused due to an error. Just reject such savegames in dedicated servers.
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
501 DEBUG(net, 0, " The savegame cannot be used for multiplayer!");
ec4dc42ad747 (svn r17685) -Fix: autounpausing kept trying to unpause a loaded game that was paused due to an error. Just reject such savegames in dedicated servers.
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
502 /* Restore the signals */
ec4dc42ad747 (svn r17685) -Fix: autounpausing kept trying to unpause a loaded game that was paused due to an error. Just reject such savegames in dedicated servers.
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
503 ResetSignalHandlers();
ec4dc42ad747 (svn r17685) -Fix: autounpausing kept trying to unpause a loaded game that was paused due to an error. Just reject such savegames in dedicated servers.
rubidium <rubidium@openttd.org>
parents: 13079
diff changeset
504 return false;
13617
7d3438d227a4 (svn r18141) -Fix (r18051): one couldn't (easily) continue a game in single player that was 'not enough players'/'waiting on join'-paused
rubidium <rubidium@openttd.org>
parents: 13370
diff changeset
505 } else if (!_networking || _network_server) {
7d3438d227a4 (svn r18141) -Fix (r18051): one couldn't (easily) continue a game in single player that was 'not enough players'/'waiting on join'-paused
rubidium <rubidium@openttd.org>
parents: 13370
diff changeset
506 /* If we are in single player, i.e. not networking, and loading the
7d3438d227a4 (svn r18141) -Fix (r18051): one couldn't (easily) continue a game in single player that was 'not enough players'/'waiting on join'-paused
rubidium <rubidium@openttd.org>
parents: 13370
diff changeset
507 * savegame or we are loading the savegame as network server we do
7d3438d227a4 (svn r18141) -Fix (r18051): one couldn't (easily) continue a game in single player that was 'not enough players'/'waiting on join'-paused
rubidium <rubidium@openttd.org>
parents: 13370
diff changeset
508 * not want to be bothered by being paused because of the automatic
7d3438d227a4 (svn r18141) -Fix (r18051): one couldn't (easily) continue a game in single player that was 'not enough players'/'waiting on join'-paused
rubidium <rubidium@openttd.org>
parents: 13370
diff changeset
509 * reason of a network server, e.g. joining clients or too few
7d3438d227a4 (svn r18141) -Fix (r18051): one couldn't (easily) continue a game in single player that was 'not enough players'/'waiting on join'-paused
rubidium <rubidium@openttd.org>
parents: 13370
diff changeset
510 * active clients. Note that resetting these values for a network
7d3438d227a4 (svn r18141) -Fix (r18051): one couldn't (easily) continue a game in single player that was 'not enough players'/'waiting on join'-paused
rubidium <rubidium@openttd.org>
parents: 13370
diff changeset
511 * client are very bad because then the client is going to execute
7d3438d227a4 (svn r18141) -Fix (r18051): one couldn't (easily) continue a game in single player that was 'not enough players'/'waiting on join'-paused
rubidium <rubidium@openttd.org>
parents: 13370
diff changeset
512 * the game loop when the server is not, i.e. it desyncs. */
7d3438d227a4 (svn r18141) -Fix (r18051): one couldn't (easily) continue a game in single player that was 'not enough players'/'waiting on join'-paused
rubidium <rubidium@openttd.org>
parents: 13370
diff changeset
513 _pause_mode &= ~PMB_PAUSED_NETWORK;
11852
862dd1024fe7 (svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents: 11657
diff changeset
514 }
862dd1024fe7 (svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents: 11657
diff changeset
515
17049
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
516 /* In very old versions, size of train stations was stored differently.
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
517 * They had swapped width and height if station was built along the Y axis.
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
518 * TTO and TTD used 3 bits for width/height, while OpenTTD used 4.
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
519 * Because the data stored by TTDPatch are unusable for rail stations > 7x7,
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
520 * recompute the width and height. Doing this unconditionally for all old
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
521 * savegames simplifies the code. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
522 if (IsSavegameVersionBefore(2)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
523 Station *st;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
524 FOR_ALL_STATIONS(st) {
17049
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
525 st->train_station.w = st->train_station.h = 0;
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
526 }
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
527 for (TileIndex t = 0; t < map_size; t++) {
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
528 if (!IsTileType(t, MP_STATION)) continue;
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
529 if (_m[t].m5 > 7) continue; // is it a rail station tile?
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
530 st = Station::Get(_m[t].m2);
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
531 assert(st->train_station.tile != 0);
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
532 int dx = TileX(t) - TileX(st->train_station.tile);
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
533 int dy = TileY(t) - TileY(st->train_station.tile);
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
534 assert(dx >= 0 && dy >= 0);
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
535 st->train_station.w = max<uint>(st->train_station.w, dx + 1);
fbd7cc9a81ab (svn r21786) -Fix [FS#4398]: don't trust rail station width and height data stored by TTDPatch, it is invalid for stations wider or higher than 7
smatz <smatz@openttd.org>
parents: 16992
diff changeset
536 st->train_station.h = max<uint>(st->train_station.h, dy + 1);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
537 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
538 }
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 /* in version 2.1 of the savegame, town owner was unified. */
16554
8db002e3e2d1 (svn r21282) -Codechange: Rename CheckSavegameVersionOldStyle() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16537
diff changeset
541 if (IsSavegameVersionBefore(2, 1)) ConvertTownOwner();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
542
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
543 /* from version 4.1 of the savegame, exclusive rights are stored at towns */
16554
8db002e3e2d1 (svn r21282) -Codechange: Rename CheckSavegameVersionOldStyle() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16537
diff changeset
544 if (IsSavegameVersionBefore(4, 1)) UpdateExclusiveRights();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
545
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
546 /* from version 4.2 of the savegame, currencies are in a different order */
16554
8db002e3e2d1 (svn r21282) -Codechange: Rename CheckSavegameVersionOldStyle() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16537
diff changeset
547 if (IsSavegameVersionBefore(4, 2)) UpdateCurrencies();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
548
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
549 /* 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
550 * 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
551 * (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
552 * walk through the whole map.. */
16554
8db002e3e2d1 (svn r21282) -Codechange: Rename CheckSavegameVersionOldStyle() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16537
diff changeset
553 if (IsSavegameVersionBefore(4, 3)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
554 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
555 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
556 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
557 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
558 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
559 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
560
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
561 if (IsSavegameVersionBefore(84)) {
15370
a7ff8375c2c4 (svn r20013) -Fix [FS#3890]: silence some warnings / take the advice of the warnings into account
rubidium <rubidium@openttd.org>
parents: 15362
diff changeset
562 Company *c;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
563 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
564 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
565 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
566 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
567 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
568 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
569
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
570 Station *st;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
571 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
572 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
573 /* 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
574 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
575 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
576
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
577 Town *t;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
578 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
579 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
580 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
581 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
582 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
583
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
584 /* 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
585 ResetOldNames();
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
586
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
587 if (IsSavegameVersionBefore(106)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
588 /* 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
589 Station *st;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
590 FOR_ALL_STATIONS(st) {
14621
562ed276a7d0 (svn r19198) -Codechange: store the size of stations in savegames
yexo <yexo@openttd.org>
parents: 14357
diff changeset
591 if (st->airport.tile == 0) st->airport.tile = INVALID_TILE;
12510
3e976121ced2 (svn r16947) -Codechange: use TileArea instead of train_tile, trainst_w and trainst_h.
rubidium <rubidium@openttd.org>
parents: 12502
diff changeset
592 if (st->dock_tile == 0) st->dock_tile = INVALID_TILE;
3e976121ced2 (svn r16947) -Codechange: use TileArea instead of train_tile, trainst_w and trainst_h.
rubidium <rubidium@openttd.org>
parents: 12502
diff changeset
593 if (st->train_station.tile == 0) st->train_station.tile = INVALID_TILE;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
594 }
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 /* 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
597 Company *c;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
598 FOR_ALL_COMPANIES(c) {
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
599 if (c->location_of_HQ == 0 || (IsSavegameVersionBefore(4) && c->location_of_HQ == 0xFFFF)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
600 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
601 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
602 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
603 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
604
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
605 /* 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
606 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
607
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
608 /* Check if all NewGRFs are present, we are very strict in MP mode */
15330
839bc68a738c (svn r19971) -Codechange: Make IsGoodGRFConfigList() operate on any given GRFConfig and move the GameLog operations directly to AfterLoad().
frosch <frosch@openttd.org>
parents: 15292
diff changeset
609 GRFListCompatibility gcf_res = IsGoodGRFConfigList(_grfconfig);
839bc68a738c (svn r19971) -Codechange: Make IsGoodGRFConfigList() operate on any given GRFConfig and move the GameLog operations directly to AfterLoad().
frosch <frosch@openttd.org>
parents: 15292
diff changeset
610 for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
839bc68a738c (svn r19971) -Codechange: Make IsGoodGRFConfigList() operate on any given GRFConfig and move the GameLog operations directly to AfterLoad().
frosch <frosch@openttd.org>
parents: 15292
diff changeset
611 if (c->status == GCS_NOT_FOUND) {
839bc68a738c (svn r19971) -Codechange: Make IsGoodGRFConfigList() operate on any given GRFConfig and move the GameLog operations directly to AfterLoad().
frosch <frosch@openttd.org>
parents: 15292
diff changeset
612 GamelogGRFRemove(c->ident.grfid);
839bc68a738c (svn r19971) -Codechange: Make IsGoodGRFConfigList() operate on any given GRFConfig and move the GameLog operations directly to AfterLoad().
frosch <frosch@openttd.org>
parents: 15292
diff changeset
613 } else if (HasBit(c->flags, GCF_COMPATIBLE)) {
839bc68a738c (svn r19971) -Codechange: Make IsGoodGRFConfigList() operate on any given GRFConfig and move the GameLog operations directly to AfterLoad().
frosch <frosch@openttd.org>
parents: 15292
diff changeset
614 GamelogGRFCompatible(&c->ident);
839bc68a738c (svn r19971) -Codechange: Make IsGoodGRFConfigList() operate on any given GRFConfig and move the GameLog operations directly to AfterLoad().
frosch <frosch@openttd.org>
parents: 15292
diff changeset
615 }
839bc68a738c (svn r19971) -Codechange: Make IsGoodGRFConfigList() operate on any given GRFConfig and move the GameLog operations directly to AfterLoad().
frosch <frosch@openttd.org>
parents: 15292
diff changeset
616 }
839bc68a738c (svn r19971) -Codechange: Make IsGoodGRFConfigList() operate on any given GRFConfig and move the GameLog operations directly to AfterLoad().
frosch <frosch@openttd.org>
parents: 15292
diff changeset
617
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
618 if (_networking && gcf_res != GLC_ALL_GOOD) {
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12555
diff changeset
619 SetSaveLoadError(STR_NETWORK_ERROR_CLIENT_NEWGRF_MISMATCH);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
620 /* Restore the signals */
11948
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
621 ResetSignalHandlers();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
622 return false;
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
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
625 switch (gcf_res) {
18629
a55c2ad0bf2c (svn r23476) -Codechange: use the error queue to replace switch mode error strings, again making it possible to return multiple errors
rubidium <rubidium@openttd.org>
parents: 18566
diff changeset
626 case GLC_COMPATIBLE: ShowErrorMessage(STR_NEWGRF_COMPATIBLE_LOAD_WARNING, INVALID_STRING_ID, WL_CRITICAL); break;
a55c2ad0bf2c (svn r23476) -Codechange: use the error queue to replace switch mode error strings, again making it possible to return multiple errors
rubidium <rubidium@openttd.org>
parents: 18566
diff changeset
627 case GLC_NOT_FOUND: ShowErrorMessage(STR_NEWGRF_DISABLED_WARNING, INVALID_STRING_ID, WL_CRITICAL); _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
628 default: break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
629 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
630
15908
434567b681a8 (svn r20592) -Fix (r2041): no (proper) savegame conversion was done when _date_fract got a new value range
rubidium <rubidium@openttd.org>
parents: 15907
diff changeset
631 /* The value of _date_fract got divided, so make sure that old games are converted correctly. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
632 if (IsSavegameVersionBefore(11, 1) || (IsSavegameVersionBefore(147) && _date_fract > DAY_TICKS)) _date_fract /= 885;
15908
434567b681a8 (svn r20592) -Fix (r2041): no (proper) savegame conversion was done when _date_fract got a new value range
rubidium <rubidium@openttd.org>
parents: 15907
diff changeset
633
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
634 /* Update current year
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
635 * must be done before loading sprites as some newgrfs check it */
15907
33fed3e36d65 (svn r20591) -Codechange: make sure _date_fract is set when SetDate is called. Some places wouldn't reset _date_fract correctly at all
rubidium <rubidium@openttd.org>
parents: 15846
diff changeset
636 SetDate(_date, _date_fract);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
637
18844
dc8ff68830a9 (svn r23693) -Fix [FS#4859]: hardcode the original defaults for loading old savegames if they could totally mess with the game's behaviour
rubidium <rubidium@openttd.org>
parents: 18678
diff changeset
638 /*
19843
9a8968c733ba (svn r24776) -Doc: Typo fixes, additions, and additional dots collected from various sources (including Eagle_rainbow, MinchinWeb)
alberth <alberth@openttd.org>
parents: 19784
diff changeset
639 * Force the old behaviour for compatibility reasons with old savegames.
18844
dc8ff68830a9 (svn r23693) -Fix [FS#4859]: hardcode the original defaults for loading old savegames if they could totally mess with the game's behaviour
rubidium <rubidium@openttd.org>
parents: 18678
diff changeset
640 *
dc8ff68830a9 (svn r23693) -Fix [FS#4859]: hardcode the original defaults for loading old savegames if they could totally mess with the game's behaviour
rubidium <rubidium@openttd.org>
parents: 18678
diff changeset
641 * Note that there is no non-stop in here. This is because the setting could have
dc8ff68830a9 (svn r23693) -Fix [FS#4859]: hardcode the original defaults for loading old savegames if they could totally mess with the game's behaviour
rubidium <rubidium@openttd.org>
parents: 18678
diff changeset
642 * either value in TTDPatch. To convert it properly the user has to make sure the
dc8ff68830a9 (svn r23693) -Fix [FS#4859]: hardcode the original defaults for loading old savegames if they could totally mess with the game's behaviour
rubidium <rubidium@openttd.org>
parents: 18678
diff changeset
643 * right value has been chosen in the settings. Otherwise we will be converting
dc8ff68830a9 (svn r23693) -Fix [FS#4859]: hardcode the original defaults for loading old savegames if they could totally mess with the game's behaviour
rubidium <rubidium@openttd.org>
parents: 18678
diff changeset
644 * it incorrectly in half of the times without a means to correct that.
dc8ff68830a9 (svn r23693) -Fix [FS#4859]: hardcode the original defaults for loading old savegames if they could totally mess with the game's behaviour
rubidium <rubidium@openttd.org>
parents: 18678
diff changeset
645 */
dc8ff68830a9 (svn r23693) -Fix [FS#4859]: hardcode the original defaults for loading old savegames if they could totally mess with the game's behaviour
rubidium <rubidium@openttd.org>
parents: 18678
diff changeset
646 if (IsSavegameVersionBefore(4, 2)) _settings_game.station.modified_catchment = false;
18845
6d8f101888d5 (svn r23694) -Fix (rprev): somehow compilers didn't understand what I meant...
rubidium <rubidium@openttd.org>
parents: 18844
diff changeset
647 if (IsSavegameVersionBefore(6, 1)) _settings_game.pf.forbid_90_deg = false;
18844
dc8ff68830a9 (svn r23693) -Fix [FS#4859]: hardcode the original defaults for loading old savegames if they could totally mess with the game's behaviour
rubidium <rubidium@openttd.org>
parents: 18678
diff changeset
648 if (IsSavegameVersionBefore(21)) _settings_game.vehicle.train_acceleration_model = 0;
dc8ff68830a9 (svn r23693) -Fix [FS#4859]: hardcode the original defaults for loading old savegames if they could totally mess with the game's behaviour
rubidium <rubidium@openttd.org>
parents: 18678
diff changeset
649 if (IsSavegameVersionBefore(90)) _settings_game.vehicle.plane_speed = 4;
dc8ff68830a9 (svn r23693) -Fix [FS#4859]: hardcode the original defaults for loading old savegames if they could totally mess with the game's behaviour
rubidium <rubidium@openttd.org>
parents: 18678
diff changeset
650 if (IsSavegameVersionBefore(95)) _settings_game.vehicle.dynamic_engines = 0;
dc8ff68830a9 (svn r23693) -Fix [FS#4859]: hardcode the original defaults for loading old savegames if they could totally mess with the game's behaviour
rubidium <rubidium@openttd.org>
parents: 18678
diff changeset
651 if (IsSavegameVersionBefore(133)) _settings_game.vehicle.roadveh_acceleration_model = 0;
dc8ff68830a9 (svn r23693) -Fix [FS#4859]: hardcode the original defaults for loading old savegames if they could totally mess with the game's behaviour
rubidium <rubidium@openttd.org>
parents: 18678
diff changeset
652 if (IsSavegameVersionBefore(159)) _settings_game.vehicle.max_train_length = 50;
dc8ff68830a9 (svn r23693) -Fix [FS#4859]: hardcode the original defaults for loading old savegames if they could totally mess with the game's behaviour
rubidium <rubidium@openttd.org>
parents: 18678
diff changeset
653 if (IsSavegameVersionBefore(166)) _settings_game.economy.infrastructure_maintenance = false;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
654
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
655 /* Load the sprites */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
656 GfxLoadSprites();
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
657 LoadStringWidthTable();
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
658
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
659 /* 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
660 CopyTempEngineData();
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
661
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
662 /* 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
663 * subtype to the new format */
16554
8db002e3e2d1 (svn r21282) -Codechange: Rename CheckSavegameVersionOldStyle() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16537
diff changeset
664 if (IsSavegameVersionBefore(17, 1)) ConvertOldMultiheadToNew();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
665
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
666 /* 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
667 ConnectMultiheadedTrains();
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
668
13307
d998ec8f4d78 (svn r17816) -Codechange: move the CargoList invalidation-after-saveload to the function that handles the CargoPackets instead of spreading it around over the saveload files. Also add some code to validate whether the caches are valid; to be removed later when no problems turn up
rubidium <rubidium@openttd.org>
parents: 13297
diff changeset
669 /* Fix the CargoPackets *and* fix the caches of CargoLists.
d998ec8f4d78 (svn r17816) -Codechange: move the CargoList invalidation-after-saveload to the function that handles the CargoPackets instead of spreading it around over the saveload files. Also add some code to validate whether the caches are valid; to be removed later when no problems turn up
rubidium <rubidium@openttd.org>
parents: 13297
diff changeset
670 * If this isn't done before Stations and especially Vehicles are
d998ec8f4d78 (svn r17816) -Codechange: move the CargoList invalidation-after-saveload to the function that handles the CargoPackets instead of spreading it around over the saveload files. Also add some code to validate whether the caches are valid; to be removed later when no problems turn up
rubidium <rubidium@openttd.org>
parents: 13297
diff changeset
671 * running their AfterLoad we might get in trouble. In the case of
d998ec8f4d78 (svn r17816) -Codechange: move the CargoList invalidation-after-saveload to the function that handles the CargoPackets instead of spreading it around over the saveload files. Also add some code to validate whether the caches are valid; to be removed later when no problems turn up
rubidium <rubidium@openttd.org>
parents: 13297
diff changeset
672 * vehicles we could give the wrong (cached) count of items in a
d998ec8f4d78 (svn r17816) -Codechange: move the CargoList invalidation-after-saveload to the function that handles the CargoPackets instead of spreading it around over the saveload files. Also add some code to validate whether the caches are valid; to be removed later when no problems turn up
rubidium <rubidium@openttd.org>
parents: 13297
diff changeset
673 * vehicle which causes different results when getting their caches
d998ec8f4d78 (svn r17816) -Codechange: move the CargoList invalidation-after-saveload to the function that handles the CargoPackets instead of spreading it around over the saveload files. Also add some code to validate whether the caches are valid; to be removed later when no problems turn up
rubidium <rubidium@openttd.org>
parents: 13297
diff changeset
674 * filled; and that could eventually lead to desyncs. */
d998ec8f4d78 (svn r17816) -Codechange: move the CargoList invalidation-after-saveload to the function that handles the CargoPackets instead of spreading it around over the saveload files. Also add some code to validate whether the caches are valid; to be removed later when no problems turn up
rubidium <rubidium@openttd.org>
parents: 13297
diff changeset
675 CargoPacket::AfterLoad();
d998ec8f4d78 (svn r17816) -Codechange: move the CargoList invalidation-after-saveload to the function that handles the CargoPackets instead of spreading it around over the saveload files. Also add some code to validate whether the caches are valid; to be removed later when no problems turn up
rubidium <rubidium@openttd.org>
parents: 13297
diff changeset
676
14791
718e326efa23 (svn r19380) -Fix [FS#3678] (r19322): updating the id of the oilrig airport should be done earlier as it can be used by newgrf code
yexo <yexo@openttd.org>
parents: 14753
diff changeset
677 /* Oilrig was moved from id 15 to 9. We have to do this conversion
718e326efa23 (svn r19380) -Fix [FS#3678] (r19322): updating the id of the oilrig airport should be done earlier as it can be used by newgrf code
yexo <yexo@openttd.org>
parents: 14753
diff changeset
678 * here as AfterLoadVehicles can check it indirectly via the newgrf
718e326efa23 (svn r19380) -Fix [FS#3678] (r19322): updating the id of the oilrig airport should be done earlier as it can be used by newgrf code
yexo <yexo@openttd.org>
parents: 14753
diff changeset
679 * code. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
680 if (IsSavegameVersionBefore(139)) {
14791
718e326efa23 (svn r19380) -Fix [FS#3678] (r19322): updating the id of the oilrig airport should be done earlier as it can be used by newgrf code
yexo <yexo@openttd.org>
parents: 14753
diff changeset
681 Station *st;
718e326efa23 (svn r19380) -Fix [FS#3678] (r19322): updating the id of the oilrig airport should be done earlier as it can be used by newgrf code
yexo <yexo@openttd.org>
parents: 14753
diff changeset
682 FOR_ALL_STATIONS(st) {
14859
304d377a82af (svn r19455) -Codechange: split all airport information in Station to a seperate class
yexo <yexo@openttd.org>
parents: 14805
diff changeset
683 if (st->airport.tile != INVALID_TILE && st->airport.type == 15) {
304d377a82af (svn r19455) -Codechange: split all airport information in Station to a seperate class
yexo <yexo@openttd.org>
parents: 14805
diff changeset
684 st->airport.type = AT_OILRIG;
14791
718e326efa23 (svn r19380) -Fix [FS#3678] (r19322): updating the id of the oilrig airport should be done earlier as it can be used by newgrf code
yexo <yexo@openttd.org>
parents: 14753
diff changeset
685 }
718e326efa23 (svn r19380) -Fix [FS#3678] (r19322): updating the id of the oilrig airport should be done earlier as it can be used by newgrf code
yexo <yexo@openttd.org>
parents: 14753
diff changeset
686 }
718e326efa23 (svn r19380) -Fix [FS#3678] (r19322): updating the id of the oilrig airport should be done earlier as it can be used by newgrf code
yexo <yexo@openttd.org>
parents: 14753
diff changeset
687 }
718e326efa23 (svn r19380) -Fix [FS#3678] (r19322): updating the id of the oilrig airport should be done earlier as it can be used by newgrf code
yexo <yexo@openttd.org>
parents: 14753
diff changeset
688
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
689 /* Update all vehicles */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
690 AfterLoadVehicles(true);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
691
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
692 /* 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
693 {
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
694 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
695 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
696 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
697 }
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
698 }
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
699
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
700 /* make sure there is a town in the game */
17383
028cef4dc3bd (svn r22129) -Codechange: use simpler check to test if there any towns in the game
smatz <smatz@openttd.org>
parents: 17321
diff changeset
701 if (_game_mode == GM_NORMAL && Town::GetNumItems() == 0) {
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12555
diff changeset
702 SetSaveLoadError(STR_ERROR_NO_TOWN_IN_SCENARIO);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
703 /* Restore the signals */
11948
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
704 ResetSignalHandlers();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
705 return false;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
706 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
707
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
708 /* 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
709 * 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
710 * 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
711 * version. It didn't show up before r12070. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
712 if (IsSavegameVersionBefore(87)) UpdateVoidTiles();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
713
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
714 /* 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
715 * 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
716 * 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
717 * But this exeption is not true for non dedicated network_servers! */
15552
683f2dbe75bb (svn r20211) -Codechange: Indented code should have curly braces around it.
alberth <alberth@openttd.org>
parents: 15511
diff changeset
718 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
719 DoStartupNewCompany(false);
19784
3c4d042d5e72 (svn r24717) -Fix [FS#5139]: When starting a scenario apply the local company settings to the new company.
frosch <frosch@openttd.org>
parents: 19698
diff changeset
720 Company *c = Company::Get(COMPANY_FIRST);
3c4d042d5e72 (svn r24717) -Fix [FS#5139]: When starting a scenario apply the local company settings to the new company.
frosch <frosch@openttd.org>
parents: 19698
diff changeset
721 c->settings = _settings_client.company;
15552
683f2dbe75bb (svn r20211) -Codechange: Indented code should have curly braces around it.
alberth <alberth@openttd.org>
parents: 15511
diff changeset
722 }
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
723
12279
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
724 /* Fix the cache for cargo payments. */
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
725 CargoPayment *cp;
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
726 FOR_ALL_CARGO_PAYMENTS(cp) {
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
727 cp->front->cargo_payment = cp;
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
728 cp->current_station = cp->front->last_station_visited;
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
729 }
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
730
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
731 if (IsSavegameVersionBefore(72)) {
15089
e0fd48f3f61b (svn r19715) -Codechange: Rename all appareances of shiplift to lock.
terkhen <terkhen@openttd.org>
parents: 14859
diff changeset
732 /* Locks in very old savegames had OWNER_WATER as owner */
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
733 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
734 switch (GetTileType(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
735 default: break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
736
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
737 case MP_WATER:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
738 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
739 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
740
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
741 case MP_STATION: {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
742 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
743 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
744 StationType st;
12502
9472b49c61a1 (svn r16939) -Codechange: s/RailwayStation/RailStation/ to unify the way it's written.
rubidium <rubidium@openttd.org>
parents: 12501
diff changeset
745 if ( IsInsideMM(gfx, 0, 8)) { // Rail station
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
746 st = STATION_RAIL;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
747 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
748 } 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
749 st = STATION_AIRPORT;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
750 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
751 } 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
752 st = STATION_TRUCK;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
753 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
754 } 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
755 st = STATION_BUS;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
756 SetStationGfx(t, gfx - 71);
12502
9472b49c61a1 (svn r16939) -Codechange: s/RailwayStation/RailStation/ to unify the way it's written.
rubidium <rubidium@openttd.org>
parents: 12501
diff changeset
757 } else if (gfx == 75) { // Oil rig
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
758 st = STATION_OILRIG;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
759 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
760 } 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
761 st = STATION_DOCK;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
762 SetStationGfx(t, gfx - 76);
12502
9472b49c61a1 (svn r16939) -Codechange: s/RailwayStation/RailStation/ to unify the way it's written.
rubidium <rubidium@openttd.org>
parents: 12501
diff changeset
763 } else if (gfx == 82) { // Buoy
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
764 st = STATION_BUOY;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
765 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
766 } 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
767 st = STATION_AIRPORT;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
768 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
769 } 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
770 st = STATION_TRUCK;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
771 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
772 } 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
773 st = STATION_BUS;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
774 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
775 } else {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
776 /* Restore the signals */
11948
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
777 ResetSignalHandlers();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
778 return false;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
779 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
780 SB(_m[t].m6, 3, 3, st);
15618
e4640748f223 (svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents: 15579
diff changeset
781 break;
e4640748f223 (svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents: 15579
diff changeset
782 }
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
783 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
784 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
785 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
786
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
787 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
788 switch (GetTileType(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
789 case MP_STATION: {
12525
6ff0b71dee93 (svn r16962) -Codechange: more work towards multi tile waypoints
rubidium <rubidium@openttd.org>
parents: 12510
diff changeset
790 BaseStation *bst = BaseStation::GetByTile(t);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
791
12525
6ff0b71dee93 (svn r16962) -Codechange: more work towards multi tile waypoints
rubidium <rubidium@openttd.org>
parents: 12510
diff changeset
792 /* Set up station spread */
6ff0b71dee93 (svn r16962) -Codechange: more work towards multi tile waypoints
rubidium <rubidium@openttd.org>
parents: 12510
diff changeset
793 bst->rect.BeforeAddTile(t, StationRect::ADD_FORCE);
6ff0b71dee93 (svn r16962) -Codechange: more work towards multi tile waypoints
rubidium <rubidium@openttd.org>
parents: 12510
diff changeset
794
6ff0b71dee93 (svn r16962) -Codechange: more work towards multi tile waypoints
rubidium <rubidium@openttd.org>
parents: 12510
diff changeset
795 /* Waypoints don't have road stops/oil rigs in the old format */
6ff0b71dee93 (svn r16962) -Codechange: more work towards multi tile waypoints
rubidium <rubidium@openttd.org>
parents: 12510
diff changeset
796 if (!Station::IsExpected(bst)) break;
6ff0b71dee93 (svn r16962) -Codechange: more work towards multi tile waypoints
rubidium <rubidium@openttd.org>
parents: 12510
diff changeset
797 Station *st = Station::From(bst);
12479
7d22a958384f (svn r16916) -Fix (r16909): station acceptance was reset after game load
smatz <smatz@openttd.org>
parents: 12472
diff changeset
798
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
799 switch (GetStationType(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
800 case STATION_TRUCK:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
801 case STATION_BUS:
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
802 if (IsSavegameVersionBefore(6)) {
17285
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
803 /* Before version 5 you could not have more than 250 stations.
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
804 * Version 6 adds large maps, so you could only place 253*253
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
805 * road stops on a map (no freeform edges) = 64009. So, yes
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
806 * someone could in theory create such a full map to trigger
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
807 * this assertion, it's safe to assume that's only something
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
808 * theoretical and does not happen in normal games. */
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
809 assert(RoadStop::CanAllocateItem());
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
810
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
811 /* 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
812 * 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
813 * internal data structure. */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
814 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
815
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
816 RoadStop **head =
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
817 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
818 *head = rs;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
819 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
820 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
821
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
822 case STATION_OILRIG: {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
823 /* 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
824 * 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
825 * the map
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
826 */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
827 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
828 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
829 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
830 /* 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
831 * 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
832 * 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
833 */
14859
304d377a82af (svn r19455) -Codechange: split all airport information in Station to a seperate class
yexo <yexo@openttd.org>
parents: 14805
diff changeset
834 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
835 } else {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
836 DeleteOilRig(t);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
837 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
838 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
839 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
840
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
841 default: break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
842 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
843 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
844 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
845
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
846 default: break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
847 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
848 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
849
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
850 /* 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
851 * This has to be called after the oilrig airport_type update above ^^^ ! */
16554
8db002e3e2d1 (svn r21282) -Codechange: Rename CheckSavegameVersionOldStyle() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16537
diff changeset
852 if (IsSavegameVersionBefore(2, 2)) UpdateOldAircraft();
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
853
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
854 /* 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
855 * 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
856 * all about ;) */
16554
8db002e3e2d1 (svn r21282) -Codechange: Rename CheckSavegameVersionOldStyle() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16537
diff changeset
857 if (IsSavegameVersionBefore(6, 1)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
858 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
859 switch (GetTileType(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
860 case MP_HOUSE:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
861 _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
862 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
863 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
864
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
865 case MP_ROAD:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
866 _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
867 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
868 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
869 } else {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
870 SetTownIndex(t, 0);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
871 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
872 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
873
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
874 default: break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
875 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
876 }
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
10855
7881d9cd55ab (svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents: 10848
diff changeset
879 /* Force the freeform edges to false for old savegames. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
880 if (IsSavegameVersionBefore(111)) {
10855
7881d9cd55ab (svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents: 10848
diff changeset
881 _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
882 }
7881d9cd55ab (svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents: 10848
diff changeset
883
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
884 /* 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
885 * before that. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
886 if (IsSavegameVersionBefore(9)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
887 Town *t;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
888 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
889 }
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 /* 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
892 * of course, we do need to initialize them for older savegames. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
893 if (IsSavegameVersionBefore(16)) {
15370
a7ff8375c2c4 (svn r20013) -Fix [FS#3890]: silence some warnings / take the advice of the warnings into account
rubidium <rubidium@openttd.org>
parents: 15362
diff changeset
894 Company *c;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
895 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
896 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
897 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
898 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
899 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
900 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
901
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
902 /* 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
903 * 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
904 * 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
905 * 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
906 * companies are 'invalid'.
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
907 */
11949
c89301974eb8 (svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
smatz <smatz@openttd.org>
parents: 11948
diff changeset
908 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
909 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
910 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
911 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
912 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
913
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
914 if (IsSavegameVersionBefore(48)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
915 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
916 switch (GetTileType(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
917 case MP_RAILWAY:
11946
d5716f5a9844 (svn r16349) -Codechange: rename IsPlainRailTile() to IsPlainRail(), introduce shiny new IsPlainRailTile()
smatz <smatz@openttd.org>
parents: 11924
diff changeset
918 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
919 /* 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
920 * 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
921 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
922 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
923 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
924 } 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
925 /* 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
926 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
927 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
928 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
929 break;
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 case MP_ROAD:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
932 /* 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
933 * 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
934 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
935 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
936
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
937 default: break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
938 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
939 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
940 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
941
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
942 if (IsSavegameVersionBefore(61)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
943 /* Added the RoadType */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
944 bool old_bridge = IsSavegameVersionBefore(42);
10571
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++) {
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
946 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
947 case MP_ROAD:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
948 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
949 switch (GetRoadTileType(t)) {
16123
a73c48c80b5d (svn r20819) -Fix [FS#3714]: be a bit more "lenient" w.r.t. invalid savegames; don't crash on saveload related NOT_REACHEDs, just show the user an error that the savegame is corrupted
rubidium <rubidium@openttd.org>
parents: 16122
diff changeset
950 default: SlErrorCorrupt("Invalid road tile type");
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
951 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
952 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
953 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
954 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
955 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
956 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
957 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
958 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
959 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
960 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
961 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
962 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
963
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
964 case MP_STATION:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
965 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
966 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
967
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
968 case MP_TUNNELBRIDGE:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
969 /* 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
970 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
971 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
972 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
973 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
974 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
975
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
976 default: break;
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
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
981 if (IsSavegameVersionBefore(114)) {
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
982 bool fix_roadtypes = !IsSavegameVersionBefore(61);
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
983 bool old_bridge = IsSavegameVersionBefore(42);
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
984
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
985 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
986 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
987 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
988 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
989 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
990 switch (GetRoadTileType(t)) {
16123
a73c48c80b5d (svn r20819) -Fix [FS#3714]: be a bit more "lenient" w.r.t. invalid savegames; don't crash on saveload related NOT_REACHEDs, just show the user an error that the savegame is corrupted
rubidium <rubidium@openttd.org>
parents: 16122
diff changeset
991 default: SlErrorCorrupt("Invalid road tile type");
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
992 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
993 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
994 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
995 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
996 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
997 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
998 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
999
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
1000 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
1001 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
1002 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
1003 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
1004 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
1005 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
1006 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
1007
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
1008 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
1009 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
1010 }
12998
c71e77a71cad (svn r17492) -Codechange: don't store the town index for road depots.
rubidium <rubidium@openttd.org>
parents: 12946
diff changeset
1011 if (!IsRoadDepot(t) && !HasTownOwnedRoad(t)) {
11293
49968fa7d5e4 (svn r15642) -Codechange: use a default parameter value in CalcClosestTownFromTile
smatz <smatz@openttd.org>
parents: 11252
diff changeset
1012 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
1013 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
1014 }
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
1015 _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
1016 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
1017
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
1018 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
1019 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
1020
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
1021 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
1022 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
1023 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
1024 _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
1025 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
1026
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
1027 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
1028 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
1029 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
1030 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
1031
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
1032 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
1033 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
1034 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
1035 }
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
1036 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
1037 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
1038
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
1039 _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
1040 _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
1041 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
1042
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
1043 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
1044 }
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
1045 }
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
1046 }
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
1047
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1048 if (IsSavegameVersionBefore(42)) {
10647
592ae9307430 (svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents: 10571
diff changeset
1049 Vehicle *v;
10571
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 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
1052 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
1053 if (IsBridgeTile(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1054 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
1055 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
1056
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1057 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
1058 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
1059 MakeRailNormal(
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1060 t,
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1061 GetTileOwner(t),
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1062 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
1063 GetRailType(t)
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1064 );
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1065 } else {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1066 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
1067
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1068 MakeRoadNormal(
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1069 t,
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1070 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
1071 ROADTYPES_ROAD,
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1072 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
1073 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
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 } else {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1077 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
1078 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
1079 } else {
18257
b6026cba5dae (svn r23093) -Codechange: add a default NULL for the Z of GetTileSlope and use it
rubidium <rubidium@openttd.org>
parents: 18255
diff changeset
1080 if (GetTileSlope(t) != SLOPE_FLAT) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1081 MakeShore(t);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1082 } else {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1083 if (GetTileOwner(t) == OWNER_WATER) {
13308
e44c31238b3c (svn r17817) -Codechange: MakeWater actually made sea tiles, so rename it to MakeSea and unduplicate the code to make sea, rivers and canals.
rubidium <rubidium@openttd.org>
parents: 13307
diff changeset
1084 MakeSea(t);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1085 } else {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1086 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
1087 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1088 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1089 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1090 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1091 SetBridgeMiddle(t, axis);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1092 } else { // ramp
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1093 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
1094 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
1095 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
1096 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
1097
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1098 _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
1099 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1100 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1101 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1102
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1103 FOR_ALL_VEHICLES(v) {
16783
37b5683941fa (svn r21516) -Codechange: Add IsGroundVehicle function to the Vehicle class.
terkhen <terkhen@openttd.org>
parents: 16771
diff changeset
1104 if (!v->IsGroundVehicle()) continue;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1105 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
1106 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
1107
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1108 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
1109 switch (dir) {
16123
a73c48c80b5d (svn r20819) -Fix [FS#3714]: be a bit more "lenient" w.r.t. invalid savegames; don't crash on saveload related NOT_REACHEDs, just show the user an error that the savegame is corrupted
rubidium <rubidium@openttd.org>
parents: 16122
diff changeset
1110 default: SlErrorCorrupt("Invalid vehicle direction");
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1111 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
1112 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
1113 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
1114 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
1115 }
18255
b3cb40aab91b (svn r23091) -Codechange: rename some Get*Z functions to Get*PixelZ functions if they return the Z in pixels (like TilePixelHeight)
rubidium <rubidium@openttd.org>
parents: 18248
diff changeset
1116 } else if (v->z_pos > GetSlopePixelZ(v->x_pos, v->y_pos)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1117 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
1118 } else {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1119 continue;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1120 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1121 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
1122 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
1123 } 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
1124 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
1125 }
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 /* Elrails got added in rev 24 */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1130 if (IsSavegameVersionBefore(24)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1131 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
1132
12034
aa140a9c419c (svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents: 12032
diff changeset
1133 Train *v;
aa140a9c419c (svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents: 12032
diff changeset
1134 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
1135 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
1136
12034
aa140a9c419c (svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents: 12032
diff changeset
1137 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
1138 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
1139 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1140
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1141 /* .. 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
1142 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
1143 switch (GetTileType(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1144 case MP_RAILWAY:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1145 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
1146 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1147
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1148 case MP_ROAD:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1149 if (IsLevelCrossing(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1150 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
1151 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1152 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1153
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1154 case MP_STATION:
12501
44606771f552 (svn r16938) -Codechange: introduce helper function to tell whether a tile is either a rail station or rail waypoint tile
rubidium <rubidium@openttd.org>
parents: 12479
diff changeset
1155 if (HasStationRail(t)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1156 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
1157 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1158 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1159
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1160 case MP_TUNNELBRIDGE:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1161 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
1162 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
1163 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1164 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1165
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1166 default:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1167 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1168 }
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
12034
aa140a9c419c (svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents: 12032
diff changeset
1171 FOR_ALL_TRAINS(v) {
14261
2e1e5f37e2fb (svn r18812) -Codechange: make some functions in train.h functions of Train.
rubidium <rubidium@openttd.org>
parents: 14258
diff changeset
1172 if (v->IsFrontEngine() || v->IsFreeWagon()) v->ConsistChanged(true);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1173 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1174
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1175 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1176
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1177 /* 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
1178 * 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
1179 * to false */
16554
8db002e3e2d1 (svn r21282) -Codechange: Rename CheckSavegameVersionOldStyle() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16537
diff changeset
1180 if (IsSavegameVersionBefore(16, 1)) {
15370
a7ff8375c2c4 (svn r20013) -Fix [FS#3890]: silence some warnings / take the advice of the warnings into account
rubidium <rubidium@openttd.org>
parents: 15362
diff changeset
1181 Company *c;
11913
f67b6243e05a (svn r16315) -Codechange: move the autorenew settings to a new CompanySettings struct
yexo <yexo@openttd.org>
parents: 11852
diff changeset
1182 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
1183 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1184
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1185 if (IsSavegameVersionBefore(123)) {
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12471
diff changeset
1186 /* Waypoints became subclasses of stations ... */
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12471
diff changeset
1187 MoveWaypointsToBaseStations();
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12471
diff changeset
1188 /* ... and buoys were moved to waypoints. */
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12471
diff changeset
1189 MoveBuoysToWaypoints();
10571
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 /* 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
1193 * room for PBS. Now in version 21 move it back :P. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1194 if (IsSavegameVersionBefore(21) && !IsSavegameVersionBefore(15)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1195 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
1196 switch (GetTileType(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1197 case MP_RAILWAY:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1198 if (HasSignals(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1199 /* 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
1200 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
1201
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1202 /* 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
1203 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
1204 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
1205 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1206
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1207 /* 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
1208 if (!IsRailDepotTile(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1209 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
1210 } else {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1211 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
1212 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1213 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1214
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
1215 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
1216 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
1217 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1218
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1219 default: 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
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1224 if (IsSavegameVersionBefore(25)) {
12034
aa140a9c419c (svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents: 12032
diff changeset
1225 RoadVehicle *rv;
aa140a9c419c (svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents: 12032
diff changeset
1226 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
1227 rv->vehstatus &= ~0x40;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1228 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1229 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1230
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1231 if (IsSavegameVersionBefore(26)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1232 Station *st;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1233 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
1234 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
1235 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1236 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1237
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1238 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
1239
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1240 if (IsSavegameVersionBefore(34)) {
15370
a7ff8375c2c4 (svn r20013) -Fix [FS#3890]: silence some warnings / take the advice of the warnings into account
rubidium <rubidium@openttd.org>
parents: 15362
diff changeset
1241 Company *c;
a7ff8375c2c4 (svn r20013) -Fix [FS#3890]: silence some warnings / take the advice of the warnings into account
rubidium <rubidium@openttd.org>
parents: 15362
diff changeset
1242 FOR_ALL_COMPANIES(c) ResetCompanyLivery(c);
a7ff8375c2c4 (svn r20013) -Fix [FS#3890]: silence some warnings / take the advice of the warnings into account
rubidium <rubidium@openttd.org>
parents: 15362
diff changeset
1243 }
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1244
15370
a7ff8375c2c4 (svn r20013) -Fix [FS#3890]: silence some warnings / take the advice of the warnings into account
rubidium <rubidium@openttd.org>
parents: 15362
diff changeset
1245 Company *c;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1246 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
1247 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
1248 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
1249 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1250
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1251 if (!IsSavegameVersionBefore(27)) AfterLoadStations();
10571
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 /* 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
1254 * Account for this in older games by adding an offset */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1255 if (IsSavegameVersionBefore(31)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1256 Station *st;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1257 Waypoint *wp;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1258 Engine *e;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1259 Industry *i;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1260 Vehicle *v;
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 _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
1263 _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
1264
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1265 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
1266 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
1267 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
1268 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
1269 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
1270
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1271 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
1272 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
1273 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
1274 }
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
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1277 /* 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
1278 * 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
1279 * plant new ones. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1280 if (IsSavegameVersionBefore(32)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1281 Industry *i;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1282
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1283 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
1284 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
1285 /* remove fields */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1286 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
1287 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1288 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1289
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1290 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
1291 uint j;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1292
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1293 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
1294 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
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
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1299 /* Setting no refit flags to all orders in savegames from before refit in orders were added */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1300 if (IsSavegameVersionBefore(36)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1301 Order *order;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1302 Vehicle *v;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1303
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1304 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
1305 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
1306 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1307
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1308 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
1309 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
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
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1313 /* 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
1314 * preference of a user, let elrails enabled; it can be disabled manually */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1315 if (IsSavegameVersionBefore(38)) _settings_game.vehicle.disable_elrails = false;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1316 /* 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
1317 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
1318 InitializeRailGUI();
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 /* 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
1321 * space for newhouses grf features. A new byte, m7, was also added. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1322 if (IsSavegameVersionBefore(53)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1323 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
1324 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
1325 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
1326 /* 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
1327 * 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
1328 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
1329 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
1330
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1331 /* 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
1332 SetHouseCompleted(t, false);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1333 } else {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1334 /* 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
1335 * 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
1336 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
1337 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
1338
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1339 /* 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
1340 * 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
1341 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
1342
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1343 /* 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
1344 * 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
1345 * 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
1346 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
1347
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1348 _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
1349 _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
1350 SetHouseCompleted(t, true);
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 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1353 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1354 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1355
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1356 /* 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
1357 UpdateHousesAndTowns();
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1358
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1359 if (IsSavegameVersionBefore(43)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1360 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
1361 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
1362 switch (GetIndustryGfx(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1363 case GFX_POWERPLANT_SPARKS:
15933
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
1364 _m[t].m3 = GB(_m[t].m1, 2, 5);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1365 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1366
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1367 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
1368 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
1369 case GFX_OILWELL_ANIMATED_3:
15933
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
1370 _m[t].m3 = GB(_m[t].m1, 0, 2);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1371 break;
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 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
1374 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
1375 case GFX_GOLD_MINE_TOWER_ANIMATED:
15933
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
1376 _m[t].m3 = _m[t].m1;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1377 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1378
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
1379 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
1380 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1381 }
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
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1386 if (IsSavegameVersionBefore(45)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1387 Vehicle *v;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1388 /* 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
1389 * 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
1390 * 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
1391 * loading again, even if it didn't actually load anything, so now the
12279
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
1392 * amount that has been paid is stored. */
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1393 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
1394 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
1395 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1396 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1397
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1398 /* 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
1399 * be OWNER_NONE. So replace OWNER_NONE with OWNER_WATER. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1400 if (IsSavegameVersionBefore(46)) {
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12471
diff changeset
1401 Waypoint *wp;
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12471
diff changeset
1402 FOR_ALL_WAYPOINTS(wp) {
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12471
diff changeset
1403 if ((wp->facilities & FACIL_DOCK) != 0 && IsTileOwner(wp->xy, OWNER_NONE) && TileHeight(wp->xy) == 0) SetTileOwner(wp->xy, OWNER_WATER);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1404 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1405 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1406
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1407 if (IsSavegameVersionBefore(50)) {
12035
dcc31c1d758a (svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents: 12034
diff changeset
1408 Aircraft *v;
15511
fbbbb2791756 (svn r20164) -Fix [FS#3870]: inconsistencies w.r.t. to km/h vs km-ish/h as "base" unit for aircraft speeds
rubidium <rubidium@openttd.org>
parents: 15370
diff changeset
1409 /* Aircraft units changed from 8 mph to 1 km-ish/h */
12035
dcc31c1d758a (svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents: 12034
diff changeset
1410 FOR_ALL_AIRCRAFT(v) {
dcc31c1d758a (svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents: 12034
diff changeset
1411 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
1412 const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type);
15511
fbbbb2791756 (svn r20164) -Fix [FS#3870]: inconsistencies w.r.t. to km/h vs km-ish/h as "base" unit for aircraft speeds
rubidium <rubidium@openttd.org>
parents: 15370
diff changeset
1413 v->cur_speed *= 128;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1414 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
1415 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
1416 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1417 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1418 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1419
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1420 if (IsSavegameVersionBefore(49)) FOR_ALL_COMPANIES(c) c->face = ConvertFromOldCompanyManagerFace(c->face);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1421
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1422 if (IsSavegameVersionBefore(52)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1423 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
1424 if (IsStatueTile(t)) {
11293
49968fa7d5e4 (svn r15642) -Codechange: use a default parameter value in CalcClosestTownFromTile
smatz <smatz@openttd.org>
parents: 11252
diff changeset
1425 _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
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
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
1430 /* 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
1431 * 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
1432 * town as cities can be built specifically in the scenario editor. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1433 if (IsSavegameVersionBefore(56)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1434 Town *t;
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 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
1437 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
1438 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
1439 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1440 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1441 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1442
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1443 if (IsSavegameVersionBefore(57)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1444 Vehicle *v;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1445 /* 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
1446 FOR_ALL_VEHICLES(v) {
12300
7ec79afe8c18 (svn r16717) -Codechange: make IsFrontEngine() member of Train
smatz <smatz@openttd.org>
parents: 12297
diff changeset
1447 if ((v->type != VEH_TRAIN || Train::From(v)->IsFrontEngine()) && // for all locs
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1448 !(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
1449 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
1450 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
1451
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1452 /* 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
1453 * 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
1454 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
1455 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1456 }
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1457 } else if (IsSavegameVersionBefore(59)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1458 /* 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
1459
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1460 Station *st;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1461 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
1462 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
1463 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
1464 Vehicle *v = *iter;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1465 iter++;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1466 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
1467 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1468 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1469 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1470
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1471 if (IsSavegameVersionBefore(58)) {
17261
2d2cbb8602d2 (svn r22001) -Codechange: Rename difficulty.number_industries to difficulty.industry_density.
alberth <alberth@openttd.org>
parents: 17247
diff changeset
1472 /* Setting difficulty industry_density other than zero get bumped to +1
2d2cbb8602d2 (svn r22001) -Codechange: Rename difficulty.number_industries to difficulty.industry_density.
alberth <alberth@openttd.org>
parents: 17247
diff changeset
1473 * since a new option (very low at position 1) has been added */
2d2cbb8602d2 (svn r22001) -Codechange: Rename difficulty.number_industries to difficulty.industry_density.
alberth <alberth@openttd.org>
parents: 17247
diff changeset
1474 if (_settings_game.difficulty.industry_density > 0) {
2d2cbb8602d2 (svn r22001) -Codechange: Rename difficulty.number_industries to difficulty.industry_density.
alberth <alberth@openttd.org>
parents: 17247
diff changeset
1475 _settings_game.difficulty.industry_density++;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1476 }
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 /* 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
1479 _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
1480 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1481
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1482 if (IsSavegameVersionBefore(64)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1483 /* 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
1484 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
1485 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
1486 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
1487 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
1488 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
1489 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
1490 }
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
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1494 if (IsSavegameVersionBefore(69)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1495 /* 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
1496 RoadVehicle *rv;
aa140a9c419c (svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents: 12032
diff changeset
1497 FOR_ALL_ROADVEHICLES(rv) {
11984
b6d3e583be86 (svn r16390) -Codechange: move u.road to RoadVehicle.
rubidium <rubidium@openttd.org>
parents: 11972
diff changeset
1498 if (rv->state == 250 || rv->state == 251) {
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13859
diff changeset
1499 SetBit(rv->state, 2);
10571
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
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1504 if (IsSavegameVersionBefore(70)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1505 /* 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
1506 Industry *i;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1507 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
1508 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1509
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1510 /* 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
1511 Replace the owner for those by OWNER_NONE. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1512 if (IsSavegameVersionBefore(82)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1513 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
1514 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
1515 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
1516 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
1517 TileHeight(t) != 0) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1518 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
1519 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1520 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1521 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1522
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1523 /*
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1524 * 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
1525 * 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
1526 * 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
1527 * 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
1528 */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1529 if (IsSavegameVersionBefore(83)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1530 for (TileIndex t = 0; t < map_size; t++) {
17853
71b5046c83c4 (svn r22644) -Codechange: Use IsShipDepotTile() instead of single water- and depottests. (adf88)
frosch <frosch@openttd.org>
parents: 17788
diff changeset
1531 if (IsShipDepotTile(t)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1532 _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
1533 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1534 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1535 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1536
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1537 if (IsSavegameVersionBefore(74)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1538 Station *st;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1539 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
1540 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
1541 st->goods[c].last_speed = 0;
17756
6e539d6e9fe0 (svn r22540) -Codechange: Rename AcceptancePickup to GoodsEntryStatus.
terkhen <terkhen@openttd.org>
parents: 17693
diff changeset
1542 if (st->goods[c].cargo.Count() != 0) SetBit(st->goods[c].acceptance_pickup, GoodsEntry::GES_PICKUP);
10571
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
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1547 if (IsSavegameVersionBefore(78)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1548 Industry *i;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1549 uint j;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1550 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
1551 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
1552 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
1553 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
1554 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1555 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
1556 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
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 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1560
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1561 /* 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
1562 * 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
1563 * 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
1564 * make all grassy/rough land trees have a density of 3. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1565 if (IsSavegameVersionBefore(81)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1566 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
1567 if (GetTileType(t) == MP_TREES) {
14171
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
1568 TreeGround groundType = (TreeGround)GB(_m[t].m2, 4, 2);
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
1569 if (groundType != TREE_GROUND_SNOW_DESERT) SB(_m[t].m2, 6, 2, 3);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1570 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1571 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1572 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1573
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1574
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1575 if (IsSavegameVersionBefore(93)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1576 /* Rework of orders. */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1577 Order *order;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1578 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
1579
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1580 Vehicle *v;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1581 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
1582 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
1583 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
1584 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
1585 }
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 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
1588 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
1589 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
1590 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1591 }
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1592 } else if (IsSavegameVersionBefore(94)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1593 /* 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
1594 Order *order;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1595 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
1596 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
1597 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
1598 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
1599 }
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 Vehicle *v;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1603 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
1604 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
1605 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
1606 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
1607 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1608 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1609 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1610
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1611 if (IsSavegameVersionBefore(84)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1612 /* 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
1613 * 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
1614 * (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
1615 * *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
1616 * 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
1617 * (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
1618 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
1619 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
1620 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
1621 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
1622 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
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 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1626
15772
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1627 /* The water class was moved/unified. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1628 if (IsSavegameVersionBefore(146)) {
15772
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1629 for (TileIndex t = 0; t < map_size; t++) {
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1630 switch (GetTileType(t)) {
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1631 case MP_STATION:
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1632 switch (GetStationType(t)) {
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1633 case STATION_OILRIG:
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1634 case STATION_DOCK:
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1635 case STATION_BUOY:
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1636 SetWaterClass(t, (WaterClass)GB(_m[t].m3, 0, 2));
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1637 SB(_m[t].m3, 0, 2, 0);
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1638 break;
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1639
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1640 default:
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1641 SetWaterClass(t, WATER_CLASS_INVALID);
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1642 break;
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1643 }
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1644 break;
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1645
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1646 case MP_WATER:
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1647 SetWaterClass(t, (WaterClass)GB(_m[t].m3, 0, 2));
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1648 SB(_m[t].m3, 0, 2, 0);
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1649 break;
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1650
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1651 case MP_OBJECT:
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1652 SetWaterClass(t, WATER_CLASS_INVALID);
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1653 break;
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1654
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1655 default:
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1656 /* No water class. */
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1657 break;
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1658 }
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1659 }
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1660 }
1a21d8e5c3fa (svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents: 15744
diff changeset
1661
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1662 if (IsSavegameVersionBefore(86)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1663 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
1664 /* 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
1665 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
1666 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
1667 if (IsWater(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1668 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
1669 if (o == OWNER_WATER) {
13308
e44c31238b3c (svn r17817) -Codechange: MakeWater actually made sea tiles, so rename it to MakeSea and unduplicate the code to make sea, rivers and canals.
rubidium <rubidium@openttd.org>
parents: 13307
diff changeset
1670 MakeSea(t);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1671 } else {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1672 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
1673 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1674 } 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
1675 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
1676 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
1677 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1678 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1679 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1680 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1681
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1682 /* 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
1683 * 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
1684 * 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
1685 for (TileIndex t = 0; t < map_size; t++) {
18257
b6026cba5dae (svn r23093) -Codechange: add a default NULL for the Z of GetTileSlope and use it
rubidium <rubidium@openttd.org>
parents: 18255
diff changeset
1686 if (GetTileSlope(t) != SLOPE_FLAT) continue;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1687
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1688 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
1689 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
1690 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1691 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1692
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1693 if (IsSavegameVersionBefore(87)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1694 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
1695 /* 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
1696 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
1697 (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
1698 /* 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
1699 * 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
1700 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
1701 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1702
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1703 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
1704 Owner o = GetTileOwner(t);
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
1705 if (o < MAX_COMPANIES && !Company::IsValidID(o)) {
15292
e2c62d70dfcf (svn r19931) -Fix (r19914): Convert assertion in Backup<> destructor into DEBUG() output. It was triggered on exceptions, especially when aborting world generation.
frosch <frosch@openttd.org>
parents: 15279
diff changeset
1706 Backup<CompanyByte> cur_company(_current_company, o, FILE_LINE);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1707 ChangeTileOwner(t, o, INVALID_OWNER);
15279
4e1862aebea2 (svn r19914) -Codechange: Wrap a helper class around temporary assignments of _current_company to ensure proper restoration.
frosch <frosch@openttd.org>
parents: 15221
diff changeset
1708 cur_company.Restore();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1709 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1710 if (IsBuoyTile(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1711 /* 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
1712 * (even if it is owned by active company) */
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12471
diff changeset
1713 Waypoint::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
1714 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1715 } 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
1716 /* 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
1717 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
1718 /* 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
1719 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
1720 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
1721 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1722 if (IsLevelCrossing(t)) {
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
1723 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
1724 }
11946
d5716f5a9844 (svn r16349) -Codechange: rename IsPlainRailTile() to IsPlainRail(), introduce shiny new IsPlainRailTile()
smatz <smatz@openttd.org>
parents: 11924
diff changeset
1725 } else if (IsPlainRailTile(t)) {
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
1726 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
1727 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1728 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1729
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1730 /* Convert old PF settings to new */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1731 if (_settings_game.pf.yapf.rail_use_yapf || IsSavegameVersionBefore(28)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1732 _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
1733 } else {
13833
ad09d18a3e34 (svn r18362) -Cleanup: remove OPF for RVs and NTP to clean up lots of code and simplify some things for the future
rubidium <rubidium@openttd.org>
parents: 13617
diff changeset
1734 _settings_game.pf.pathfinder_for_trains = VPF_NPF;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1735 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1736
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1737 if (_settings_game.pf.yapf.road_use_yapf || IsSavegameVersionBefore(28)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1738 _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
1739 } else {
13833
ad09d18a3e34 (svn r18362) -Cleanup: remove OPF for RVs and NTP to clean up lots of code and simplify some things for the future
rubidium <rubidium@openttd.org>
parents: 13617
diff changeset
1740 _settings_game.pf.pathfinder_for_roadvehs = VPF_NPF;
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 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
1744 _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
1745 } else {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1746 _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
1747 }
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
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1750 if (IsSavegameVersionBefore(88)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1751 /* 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
1752 Vehicle *v;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1753 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
1754 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
1755 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
1756 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
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
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1760 if (IsSavegameVersionBefore(91)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1761 /* 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
1762 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
1763 if (IsTileType(t, MP_HOUSE) && GetHouseType(t) >= NEW_HOUSE_OFFSET) {
15933
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
1764 SB(_m[t].m6, 2, 6, GB(_m[t].m6, 3, 5));
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
1765 SB(_m[t].m3, 5, 1, 0);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1766 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1767 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1768 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1769
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1770 if (IsSavegameVersionBefore(62)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1771 /* 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
1772 * 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
1773 RoadVehicle *v;
dcc31c1d758a (svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents: 12034
diff changeset
1774 FOR_ALL_ROADVEHICLES(v) {
dcc31c1d758a (svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents: 12034
diff changeset
1775 if (v->First() == v && HasBit(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM)) {
18629
a55c2ad0bf2c (svn r23476) -Codechange: use the error queue to replace switch mode error strings, again making it possible to return multiple errors
rubidium <rubidium@openttd.org>
parents: 18566
diff changeset
1776 ShowErrorMessage(STR_WARNING_LOADGAME_REMOVED_TRAMS, INVALID_STRING_ID, WL_CRITICAL);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1777 delete v;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1778 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1779 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1780 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1781
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1782 if (IsSavegameVersionBefore(99)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1783 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
1784 /* 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
1785 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
1786 SetWaterClassDependingOnSurroundings(t, true);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1787 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1788 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
1789 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
1790 SetWaterClassDependingOnSurroundings(t, true);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1791 } else {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1792 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
1793 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1794 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1795
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1796 /* 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
1797 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
1798 _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
1799 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1800 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1801 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1802
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1803 /* 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
1804 * 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
1805 * clear any possible PBS reservations as well. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1806 if (IsSavegameVersionBefore(100)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1807 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
1808 switch (GetTileType(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1809 case MP_RAILWAY:
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1810 if (HasSignals(t)) {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1811 /* 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
1812 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
1813 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
1814 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
1815 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
1816 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1817
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1818 /* Clear PBS reservation on track */
12471
c0587ce9da72 (svn r16908) -Codechange: s/DepotWaypointReservation/DepotReservation/
rubidium <rubidium@openttd.org>
parents: 12463
diff changeset
1819 if (IsRailDepot(t)) {
c0587ce9da72 (svn r16908) -Codechange: s/DepotWaypointReservation/DepotReservation/
rubidium <rubidium@openttd.org>
parents: 12463
diff changeset
1820 SetDepotReservation(t, false);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1821 } else {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1822 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
1823 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1824 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1825
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
1826 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
1827 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
1828 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1829
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
1830 case MP_STATION: // Clear PBS reservation on station
12502
9472b49c61a1 (svn r16939) -Codechange: s/RailwayStation/RailStation/ to unify the way it's written.
rubidium <rubidium@openttd.org>
parents: 12501
diff changeset
1831 if (HasStationRail(t)) SetRailStationReservation(t, false);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1832 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1833
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
1834 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
1835 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
1836 break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1837
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1838 default: break;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1839 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1840 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1841 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1842
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1843 /* Reserve all tracks trains are currently on. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1844 if (IsSavegameVersionBefore(101)) {
12423
698a97a3744a (svn r16857) -Fix [FS#3036](r16652): crash when train partially in depot crashed
smatz <smatz@openttd.org>
parents: 12421
diff changeset
1845 const Train *t;
12034
aa140a9c419c (svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents: 12032
diff changeset
1846 FOR_ALL_TRAINS(t) {
12423
698a97a3744a (svn r16857) -Fix [FS#3036](r16652): crash when train partially in depot crashed
smatz <smatz@openttd.org>
parents: 12421
diff changeset
1847 if (t->First() == t) t->ReserveTrackUnderConsist();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1848 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1849 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1850
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1851 if (IsSavegameVersionBefore(102)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1852 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
1853 /* 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
1854 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
1855 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1856 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1857
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1858 if (IsSavegameVersionBefore(103)) {
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1859 /* 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
1860 UpdateNearestTownForRoadTiles(false);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1861
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1862 /* 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
1863 Sign *si;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1864 FOR_ALL_SIGNS(si) {
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
1865 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
1866 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1867
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1868 /* 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
1869 * 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
1870 Station *st;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1871 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
1872 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
1873 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1874 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1875
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1876 if (IsSavegameVersionBefore(104)) {
12035
dcc31c1d758a (svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents: 12034
diff changeset
1877 Aircraft *a;
dcc31c1d758a (svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents: 12034
diff changeset
1878 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
1879 /* Set engine_type of shadow and rotor */
12384
d4b73a406cf3 (svn r16814) -Codechange: make IsNormalAircraft() member of Aircraft
smatz <smatz@openttd.org>
parents: 12380
diff changeset
1880 if (!a->IsNormalAircraft()) {
12035
dcc31c1d758a (svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents: 12034
diff changeset
1881 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
1882 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1883 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1884
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1885 /* More companies ... */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1886 Company *c;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1887 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
1888 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
1889 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1890
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1891 Engine *e;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1892 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
1893 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
1894 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1895
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1896 Town *t;
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1897 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
1898 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
1899 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
1900 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1901 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
1902
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1903 if (IsSavegameVersionBefore(112)) {
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
1904 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
1905 /* 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
1906 * since we've already changed it code-wise */
15744
f9e8032ac213 (svn r20411) -Codechange: rename unmovables as quite a lot of them are actually movable; e.g. HQ and owned land are pretty movable.
rubidium <rubidium@openttd.org>
parents: 15709
diff changeset
1907 if (IsTileType(t, MP_OBJECT) && HasBit(_m[t].m5, 7)) {
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
1908 /* 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
1909 * on new locations */
15669
1cb744e35ef3 (svn r20334) -Codechange: reorder the unmovable bits a bit for futher extension
rubidium <rubidium@openttd.org>
parents: 15623
diff changeset
1910 _m[t].m3 = GB(_m[t].m5, 0, 5);
15744
f9e8032ac213 (svn r20411) -Codechange: rename unmovables as quite a lot of them are actually movable; e.g. HQ and owned land are pretty movable.
rubidium <rubidium@openttd.org>
parents: 15709
diff changeset
1911 _m[t].m5 = OBJECT_HQ;
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
1912 }
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
1913 }
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
1914 }
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1915 if (IsSavegameVersionBefore(144)) {
15669
1cb744e35ef3 (svn r20334) -Codechange: reorder the unmovable bits a bit for futher extension
rubidium <rubidium@openttd.org>
parents: 15623
diff changeset
1916 for (TileIndex t = 0; t < map_size; t++) {
15744
f9e8032ac213 (svn r20411) -Codechange: rename unmovables as quite a lot of them are actually movable; e.g. HQ and owned land are pretty movable.
rubidium <rubidium@openttd.org>
parents: 15709
diff changeset
1917 if (!IsTileType(t, MP_OBJECT)) continue;
15669
1cb744e35ef3 (svn r20334) -Codechange: reorder the unmovable bits a bit for futher extension
rubidium <rubidium@openttd.org>
parents: 15623
diff changeset
1918
15744
f9e8032ac213 (svn r20411) -Codechange: rename unmovables as quite a lot of them are actually movable; e.g. HQ and owned land are pretty movable.
rubidium <rubidium@openttd.org>
parents: 15709
diff changeset
1919 /* Reordering/generalisation of the object bits. */
f9e8032ac213 (svn r20411) -Codechange: rename unmovables as quite a lot of them are actually movable; e.g. HQ and owned land are pretty movable.
rubidium <rubidium@openttd.org>
parents: 15709
diff changeset
1920 ObjectType type = GetObjectType(t);
15807
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1921 SB(_m[t].m6, 2, 4, type == OBJECT_HQ ? GB(_m[t].m3, 2, 3) : 0);
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1922 _m[t].m3 = type == OBJECT_HQ ? GB(_m[t].m3, 1, 1) | GB(_m[t].m3, 0, 1) << 4 : 0;
15669
1cb744e35ef3 (svn r20334) -Codechange: reorder the unmovable bits a bit for futher extension
rubidium <rubidium@openttd.org>
parents: 15623
diff changeset
1923
1cb744e35ef3 (svn r20334) -Codechange: reorder the unmovable bits a bit for futher extension
rubidium <rubidium@openttd.org>
parents: 15623
diff changeset
1924 /* Make sure those bits are clear as well! */
1cb744e35ef3 (svn r20334) -Codechange: reorder the unmovable bits a bit for futher extension
rubidium <rubidium@openttd.org>
parents: 15623
diff changeset
1925 _m[t].m4 = 0;
1cb744e35ef3 (svn r20334) -Codechange: reorder the unmovable bits a bit for futher extension
rubidium <rubidium@openttd.org>
parents: 15623
diff changeset
1926 _me[t].m7 = 0;
1cb744e35ef3 (svn r20334) -Codechange: reorder the unmovable bits a bit for futher extension
rubidium <rubidium@openttd.org>
parents: 15623
diff changeset
1927 }
1cb744e35ef3 (svn r20334) -Codechange: reorder the unmovable bits a bit for futher extension
rubidium <rubidium@openttd.org>
parents: 15623
diff changeset
1928 }
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
1929
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1930 if (IsSavegameVersionBefore(147) && Object::GetNumItems() == 0) {
15807
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1931 /* Make real objects for object tiles. */
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1932 for (TileIndex t = 0; t < map_size; t++) {
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1933 if (!IsTileType(t, MP_OBJECT)) continue;
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1934
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1935 if (Town::GetNumItems() == 0) {
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1936 /* No towns, so remove all objects! */
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1937 DoClearSquare(t);
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1938 } else {
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1939 uint offset = _m[t].m3;
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1940
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1941 /* Also move the animation state. */
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1942 _m[t].m3 = GB(_m[t].m6, 2, 4);
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1943 SB(_m[t].m6, 2, 4, 0);
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1944
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1945 if (offset == 0) {
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1946 /* No offset, so make the object. */
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1947 ObjectType type = GetObjectType(t);
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1948 int size = type == OBJECT_HQ ? 2 : 1;
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1949
17285
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
1950 if (!Object::CanAllocateItem()) {
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
1951 /* Nice... you managed to place 64k lighthouses and
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
1952 * antennae on the map... boohoo. */
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
1953 SlError(STR_ERROR_TOO_MANY_OBJECTS);
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
1954 }
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
1955
15807
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1956 Object *o = new Object();
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1957 o->location.tile = t;
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1958 o->location.w = size;
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1959 o->location.h = size;
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1960 o->build_date = _date;
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1961 o->town = type == OBJECT_STATUE ? Town::Get(_m[t].m2) : CalcClosestTownFromTile(t, UINT_MAX);
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1962 _m[t].m2 = o->index;
15968
c8215bd591e2 (svn r20656) -Codechange: implement counting of objects
rubidium <rubidium@openttd.org>
parents: 15946
diff changeset
1963 Object::IncTypeCount(type);
15807
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1964 } else {
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1965 /* We're at an offset, so get the ID from our "root". */
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1966 TileIndex northern_tile = t - TileXY(GB(offset, 0, 4), GB(offset, 4, 4));
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1967 assert(IsTileType(northern_tile, MP_OBJECT));
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1968 _m[t].m2 = _m[northern_tile].m2;
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1969 }
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1970 }
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1971 }
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1972 }
9561d91e0869 (svn r20482) -Codechange: move some object related information off the map and unify the relation objects have to towns
rubidium <rubidium@openttd.org>
parents: 15772
diff changeset
1973
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
1974 if (IsSavegameVersionBefore(113)) {
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
1975 /* 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
1976 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
1977 _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
1978 _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
1979 } 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
1980 _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
1981 _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
1982 }
def5dbb7e314 (svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents: 10960
diff changeset
1983
def5dbb7e314 (svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents: 10960
diff changeset
1984 /* 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
1985 * 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
1986 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
1987 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
1988 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
1989 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
1990 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
1991 }
def5dbb7e314 (svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents: 10960
diff changeset
1992
def5dbb7e314 (svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents: 10960
diff changeset
1993 /* 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
1994 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
1995 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
1996 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
1997 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
1998 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
1999 }
def5dbb7e314 (svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents: 10960
diff changeset
2000 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
2001 }
def5dbb7e314 (svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents: 10960
diff changeset
2002 }
def5dbb7e314 (svn r15340) -Fix [FS#2121]: changing town road layout in-game caused ugly road networks
smatz <smatz@openttd.org>
parents: 10960
diff changeset
2003
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2004 if (IsSavegameVersionBefore(114)) {
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
2005 /* 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
2006 * 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
2007 * 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
2008 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
2009 FOR_ALL_STATIONS(st) {
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
2010 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
2011 }
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
2012 }
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
2013
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
2014 /* Trains could now stop in a specific location. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2015 if (IsSavegameVersionBefore(117)) {
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
2016 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
2017 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
2018 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
2019 }
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
2020 }
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
2021
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2022 if (IsSavegameVersionBefore(120)) {
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
2023 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
2024 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
2025 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
2026 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
2027 }
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
2028 }
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
2029
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2030 if (IsSavegameVersionBefore(121)) {
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
2031 /* 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
2032 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
2033 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
2034 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
2035 const Vehicle *u = Vehicle::GetIfValid(v->dest_tile);
17123
a18c14f0bb2b (svn r21860) -Codechange: Rename road vehicle subtype functions to match the train names.
terkhen <terkhen@openttd.org>
parents: 17058
diff changeset
2036 if (u == NULL || u->type != VEH_ROAD || !RoadVehicle::From(u)->IsFrontEngine()) {
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
2037 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
2038 }
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
2039 }
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
2040 }
12279
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
2041
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
2042 /* We didn't store cargo payment yet, so make them for vehicles that are
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
2043 * currently at a station and loading/unloading. If they don't get any
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
2044 * payment anymore they just removed in the next load/unload cycle.
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
2045 * However, some 0.7 versions might have cargo payment. For those we just
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
2046 * add cargopayment for the vehicles that don't have it.
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
2047 */
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
2048 Station *st;
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
2049 FOR_ALL_STATIONS(st) {
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
2050 std::list<Vehicle *>::iterator iter;
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
2051 for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); ++iter) {
17285
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
2052 /* There are always as many CargoPayments as Vehicles. We need to make the
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
2053 * assert() in Pool::GetNew() happy by calling CanAllocateItem(). */
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
2054 assert_compile(CargoPaymentPool::MAX_SIZE == VehiclePool::MAX_SIZE);
be523f4fc2cb (svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
smatz <smatz@openttd.org>
parents: 17277
diff changeset
2055 assert(CargoPayment::CanAllocateItem());
12279
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
2056 Vehicle *v = *iter;
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
2057 if (v->cargo_payment == NULL) v->cargo_payment = new CargoPayment(v);
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
2058 }
329b186db8cd (svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents: 12249
diff changeset
2059 }
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
2060 }
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
2061
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2062 if (IsSavegameVersionBefore(122)) {
12292
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2063 /* Animated tiles would sometimes not be actually animated or
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2064 * in case of old savegames duplicate. */
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2065
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2066 extern TileIndex *_animated_tile_list;
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2067 extern uint _animated_tile_count;
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2068
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2069 for (uint i = 0; i < _animated_tile_count; /* Nothing */) {
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2070 /* Remove if tile is not animated */
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2071 bool remove = _tile_type_procs[GetTileType(_animated_tile_list[i])]->animate_tile_proc == NULL;
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2072
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2073 /* and remove if duplicate */
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2074 for (uint j = 0; !remove && j < i; j++) {
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2075 remove = _animated_tile_list[i] == _animated_tile_list[j];
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2076 }
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2077
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2078 if (remove) {
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2079 DeleteAnimatedTile(_animated_tile_list[i]);
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2080 } else {
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2081 i++;
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2082 }
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2083 }
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2084 }
a6d140648fde (svn r16709) -Fix [FS#2994]: the list of animated tiles could have duplicates (only for old savegames) and tiles that weren't animated
rubidium <rubidium@openttd.org>
parents: 12279
diff changeset
2085
17058
2bbacb524f85 (svn r21795) -Fix (r21790): when converting TTDPatch train waypoints, convert the data on the map as well
rubidium <rubidium@openttd.org>
parents: 17056
diff changeset
2086 if (IsSavegameVersionBefore(124) && !IsSavegameVersionBefore(1)) {
2bbacb524f85 (svn r21795) -Fix (r21790): when converting TTDPatch train waypoints, convert the data on the map as well
rubidium <rubidium@openttd.org>
parents: 17056
diff changeset
2087 /* The train station tile area was added, but for really old (TTDPatch) it's already valid. */
12555
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12525
diff changeset
2088 Waypoint *wp;
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12525
diff changeset
2089 FOR_ALL_WAYPOINTS(wp) {
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12525
diff changeset
2090 if (wp->facilities & FACIL_TRAIN) {
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12525
diff changeset
2091 wp->train_station.tile = wp->xy;
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12525
diff changeset
2092 wp->train_station.w = 1;
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12525
diff changeset
2093 wp->train_station.h = 1;
16922
bb19fe74c797 (svn r21657) -Cleanup (r17107): remove superfluous semicolon
smatz <smatz@openttd.org>
parents: 16783
diff changeset
2094 } else {
12555
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12525
diff changeset
2095 wp->train_station.tile = INVALID_TILE;
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12525
diff changeset
2096 wp->train_station.w = 0;
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12525
diff changeset
2097 wp->train_station.h = 0;
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12525
diff changeset
2098 }
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12525
diff changeset
2099 }
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12525
diff changeset
2100 }
e814b879d2e1 (svn r16993) -Change: make the rail waypoint builder draggable
rubidium <rubidium@openttd.org>
parents: 12525
diff changeset
2101
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2102 if (IsSavegameVersionBefore(125)) {
12658
b75d8c6681bd (svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
smatz <smatz@openttd.org>
parents: 12652
diff changeset
2103 /* Convert old subsidies */
12652
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2104 Subsidy *s;
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2105 FOR_ALL_SUBSIDIES(s) {
12658
b75d8c6681bd (svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
smatz <smatz@openttd.org>
parents: 12652
diff changeset
2106 if (s->remaining < 12) {
13370
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2107 /* Converting nonawarded subsidy */
12658
b75d8c6681bd (svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
smatz <smatz@openttd.org>
parents: 12652
diff changeset
2108 s->remaining = 12 - s->remaining; // convert "age" to "remaining"
b75d8c6681bd (svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
smatz <smatz@openttd.org>
parents: 12652
diff changeset
2109 s->awarded = INVALID_COMPANY; // not awarded to anyone
12652
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2110 const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2111 switch (cs->town_effect) {
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2112 case TE_PASSENGERS:
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2113 case TE_MAIL:
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2114 /* Town -> Town */
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2115 s->src_type = s->dst_type = ST_TOWN;
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2116 if (Town::IsValidID(s->src) && Town::IsValidID(s->dst)) continue;
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2117 break;
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2118 case TE_GOODS:
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2119 case TE_FOOD:
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2120 /* Industry -> Town */
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2121 s->src_type = ST_INDUSTRY;
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2122 s->dst_type = ST_TOWN;
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2123 if (Industry::IsValidID(s->src) && Town::IsValidID(s->dst)) continue;
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2124 break;
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2125 default:
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2126 /* Industry -> Industry */
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2127 s->src_type = s->dst_type = ST_INDUSTRY;
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2128 if (Industry::IsValidID(s->src) && Industry::IsValidID(s->dst)) continue;
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2129 break;
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2130 }
13370
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2131 } else {
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2132 /* Do our best for awarded subsidies. The original source or destination industry
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2133 * can't be determined anymore for awarded subsidies, so invalidate them.
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2134 * Town -> Town subsidies are converted using simple heuristic */
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2135 s->remaining = 24 - s->remaining; // convert "age of awarded subsidy" to "remaining"
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2136 const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2137 switch (cs->town_effect) {
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2138 case TE_PASSENGERS:
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2139 case TE_MAIL: {
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2140 /* Town -> Town */
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2141 const Station *ss = Station::GetIfValid(s->src);
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2142 const Station *sd = Station::GetIfValid(s->dst);
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2143 if (ss != NULL && sd != NULL && ss->owner == sd->owner &&
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2144 Company::IsValidID(ss->owner)) {
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2145 s->src_type = s->dst_type = ST_TOWN;
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2146 s->src = ss->town->index;
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2147 s->dst = sd->town->index;
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2148 s->awarded = ss->owner;
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2149 continue;
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2150 }
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2151 break;
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2152 }
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2153 default:
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2154 break;
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2155 }
12652
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2156 }
13370
3b5a2d007df2 (svn r17879) -Codechange: convert awarded pax subsidies from old savegames using simple heuristic (instead of deleting them)
smatz <smatz@openttd.org>
parents: 13308
diff changeset
2157 /* Awarded non-town subsidy or invalid source/destination, invalidate */
12669
406f4ae1e2ca (svn r17124) -Codechange: store subsidies in a pool (instead of an array)
smatz <smatz@openttd.org>
parents: 12664
diff changeset
2158 delete s;
12652
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2159 }
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2160 }
0f7fab6a27e9 (svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
smatz <smatz@openttd.org>
parents: 12632
diff changeset
2161
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2162 if (IsSavegameVersionBefore(126)) {
12940
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2163 /* Recompute inflation based on old unround loan limit
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2164 * Note: Max loan is 500000. With an inflation of 4% across 170 years
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2165 * that results in a max loan of about 0.7 * 2^31.
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2166 * So taking the 16 bit fractional part into account there are plenty of bits left
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2167 * for unmodified savegames ...
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2168 */
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2169 uint64 aimed_inflation = (_economy.old_max_loan_unround << 16 | _economy.old_max_loan_unround_fract) / _settings_game.difficulty.max_loan;
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2170
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2171 /* ... well, just clamp it then. */
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2172 if (aimed_inflation > MAX_INFLATION) aimed_inflation = MAX_INFLATION;
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2173
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2174 /* Simulate the inflation, so we also get the payment inflation */
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2175 while (_economy.inflation_prices < aimed_inflation) {
19656
f681f6d5dc24 (svn r24565) -Fix: Stop both price and payment inflation if either of them has reached MAX_INFLATION.
frosch <frosch@openttd.org>
parents: 19655
diff changeset
2176 if (AddInflation(false)) break;
12940
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2177 }
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2178 }
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2179
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2180 if (IsSavegameVersionBefore(127)) {
12946
560c26f15688 (svn r17439) -Fix (r17436): you weren't paid for cargo delivered to houses and headquarters anymore
smatz <smatz@openttd.org>
parents: 12940
diff changeset
2181 Station *st;
560c26f15688 (svn r17439) -Fix (r17436): you weren't paid for cargo delivered to houses and headquarters anymore
smatz <smatz@openttd.org>
parents: 12940
diff changeset
2182 FOR_ALL_STATIONS(st) UpdateStationAcceptance(st, false);
560c26f15688 (svn r17439) -Fix (r17436): you weren't paid for cargo delivered to houses and headquarters anymore
smatz <smatz@openttd.org>
parents: 12940
diff changeset
2183 }
560c26f15688 (svn r17439) -Fix (r17436): you weren't paid for cargo delivered to houses and headquarters anymore
smatz <smatz@openttd.org>
parents: 12940
diff changeset
2184
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2185 if (IsSavegameVersionBefore(128)) {
12999
07a634b14de8 (svn r17493) -Codechange: store the depot index on the map
rubidium <rubidium@openttd.org>
parents: 12998
diff changeset
2186 const Depot *d;
07a634b14de8 (svn r17493) -Codechange: store the depot index on the map
rubidium <rubidium@openttd.org>
parents: 12998
diff changeset
2187 FOR_ALL_DEPOTS(d) {
07a634b14de8 (svn r17493) -Codechange: store the depot index on the map
rubidium <rubidium@openttd.org>
parents: 12998
diff changeset
2188 _m[d->xy].m2 = d->index;
07a634b14de8 (svn r17493) -Codechange: store the depot index on the map
rubidium <rubidium@openttd.org>
parents: 12998
diff changeset
2189 if (IsTileType(d->xy, MP_WATER)) _m[GetOtherShipDepotTile(d->xy)].m2 = d->index;
07a634b14de8 (svn r17493) -Codechange: store the depot index on the map
rubidium <rubidium@openttd.org>
parents: 12998
diff changeset
2190 }
07a634b14de8 (svn r17493) -Codechange: store the depot index on the map
rubidium <rubidium@openttd.org>
parents: 12998
diff changeset
2191 }
07a634b14de8 (svn r17493) -Codechange: store the depot index on the map
rubidium <rubidium@openttd.org>
parents: 12998
diff changeset
2192
13977
bb2258bdc43d (svn r18515) -Change: make it visible when you're to pass the next signal on danger and possible to cancel it
rubidium <rubidium@openttd.org>
parents: 13968
diff changeset
2193 /* The behaviour of force_proceed has been changed. Now
bb2258bdc43d (svn r18515) -Change: make it visible when you're to pass the next signal on danger and possible to cancel it
rubidium <rubidium@openttd.org>
parents: 13968
diff changeset
2194 * it counts signals instead of some random time out. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2195 if (IsSavegameVersionBefore(131)) {
13977
bb2258bdc43d (svn r18515) -Change: make it visible when you're to pass the next signal on danger and possible to cancel it
rubidium <rubidium@openttd.org>
parents: 13968
diff changeset
2196 Train *t;
bb2258bdc43d (svn r18515) -Change: make it visible when you're to pass the next signal on danger and possible to cancel it
rubidium <rubidium@openttd.org>
parents: 13968
diff changeset
2197 FOR_ALL_TRAINS(t) {
15362
834b4f9842c2 (svn r20005) -Codechange: Enumify force_proceed.
frosch <frosch@openttd.org>
parents: 15360
diff changeset
2198 if (t->force_proceed != TFP_NONE) {
834b4f9842c2 (svn r20005) -Codechange: Enumify force_proceed.
frosch <frosch@openttd.org>
parents: 15360
diff changeset
2199 t->force_proceed = TFP_STUCK;
834b4f9842c2 (svn r20005) -Codechange: Enumify force_proceed.
frosch <frosch@openttd.org>
parents: 15360
diff changeset
2200 }
13977
bb2258bdc43d (svn r18515) -Change: make it visible when you're to pass the next signal on danger and possible to cancel it
rubidium <rubidium@openttd.org>
parents: 13968
diff changeset
2201 }
bb2258bdc43d (svn r18515) -Change: make it visible when you're to pass the next signal on danger and possible to cancel it
rubidium <rubidium@openttd.org>
parents: 13968
diff changeset
2202 }
bb2258bdc43d (svn r18515) -Change: make it visible when you're to pass the next signal on danger and possible to cancel it
rubidium <rubidium@openttd.org>
parents: 13968
diff changeset
2203
14171
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2204 /* The bits for the tree ground and tree density have
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2205 * been swapped (m2 bits 7..6 and 5..4. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2206 if (IsSavegameVersionBefore(135)) {
14171
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2207 for (TileIndex t = 0; t < map_size; t++) {
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2208 if (IsTileType(t, MP_CLEAR)) {
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2209 if (GetRawClearGround(t) == CLEAR_SNOW) {
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2210 SetClearGroundDensity(t, CLEAR_GRASS, GetClearDensity(t));
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2211 SetBit(_m[t].m3, 4);
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2212 } else {
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2213 ClrBit(_m[t].m3, 4);
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2214 }
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2215 }
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2216 if (IsTileType(t, MP_TREES)) {
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2217 uint density = GB(_m[t].m2, 6, 2);
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2218 uint ground = GB(_m[t].m2, 4, 2);
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2219 uint counter = GB(_m[t].m2, 0, 4);
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2220 _m[t].m2 = ground << 6 | density << 4 | counter;
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2221 }
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2222 }
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2223 }
72a4eae02e7d (svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
yexo <yexo@openttd.org>
parents: 13977
diff changeset
2224
14213
41b2e7bf03da (svn r18764) -Fix [FS#3422]: split the (un)load ticks counter and signal wait counter; sometimes they might get into eachother's way
rubidium <rubidium@openttd.org>
parents: 14171
diff changeset
2225 /* Wait counter and load/unload ticks got split. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2226 if (IsSavegameVersionBefore(136)) {
14213
41b2e7bf03da (svn r18764) -Fix [FS#3422]: split the (un)load ticks counter and signal wait counter; sometimes they might get into eachother's way
rubidium <rubidium@openttd.org>
parents: 14171
diff changeset
2227 Aircraft *a;
41b2e7bf03da (svn r18764) -Fix [FS#3422]: split the (un)load ticks counter and signal wait counter; sometimes they might get into eachother's way
rubidium <rubidium@openttd.org>
parents: 14171
diff changeset
2228 FOR_ALL_AIRCRAFT(a) {
41b2e7bf03da (svn r18764) -Fix [FS#3422]: split the (un)load ticks counter and signal wait counter; sometimes they might get into eachother's way
rubidium <rubidium@openttd.org>
parents: 14171
diff changeset
2229 a->turn_counter = a->current_order.IsType(OT_LOADING) ? 0 : a->load_unload_ticks;
41b2e7bf03da (svn r18764) -Fix [FS#3422]: split the (un)load ticks counter and signal wait counter; sometimes they might get into eachother's way
rubidium <rubidium@openttd.org>
parents: 14171
diff changeset
2230 }
41b2e7bf03da (svn r18764) -Fix [FS#3422]: split the (un)load ticks counter and signal wait counter; sometimes they might get into eachother's way
rubidium <rubidium@openttd.org>
parents: 14171
diff changeset
2231
41b2e7bf03da (svn r18764) -Fix [FS#3422]: split the (un)load ticks counter and signal wait counter; sometimes they might get into eachother's way
rubidium <rubidium@openttd.org>
parents: 14171
diff changeset
2232 Train *t;
41b2e7bf03da (svn r18764) -Fix [FS#3422]: split the (un)load ticks counter and signal wait counter; sometimes they might get into eachother's way
rubidium <rubidium@openttd.org>
parents: 14171
diff changeset
2233 FOR_ALL_TRAINS(t) {
41b2e7bf03da (svn r18764) -Fix [FS#3422]: split the (un)load ticks counter and signal wait counter; sometimes they might get into eachother's way
rubidium <rubidium@openttd.org>
parents: 14171
diff changeset
2234 t->wait_counter = t->current_order.IsType(OT_LOADING) ? 0 : t->load_unload_ticks;
41b2e7bf03da (svn r18764) -Fix [FS#3422]: split the (un)load ticks counter and signal wait counter; sometimes they might get into eachother's way
rubidium <rubidium@openttd.org>
parents: 14171
diff changeset
2235 }
41b2e7bf03da (svn r18764) -Fix [FS#3422]: split the (un)load ticks counter and signal wait counter; sometimes they might get into eachother's way
rubidium <rubidium@openttd.org>
parents: 14171
diff changeset
2236 }
41b2e7bf03da (svn r18764) -Fix [FS#3422]: split the (un)load ticks counter and signal wait counter; sometimes they might get into eachother's way
rubidium <rubidium@openttd.org>
parents: 14171
diff changeset
2237
14357
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2238 /* Airport tile animation uses animation frame instead of other graphics id */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2239 if (IsSavegameVersionBefore(137)) {
14357
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2240 struct AirportTileConversion {
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2241 byte old_start;
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2242 byte num_frames;
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2243 };
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2244 static const AirportTileConversion atc[] = {
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2245 {31, 12}, // APT_RADAR_GRASS_FENCE_SW
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2246 {50, 4}, // APT_GRASS_FENCE_NE_FLAG
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2247 {62, 2}, // 1 unused tile
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2248 {66, 12}, // APT_RADAR_FENCE_SW
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2249 {78, 12}, // APT_RADAR_FENCE_NE
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2250 {101, 10}, // 9 unused tiles
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2251 {111, 8}, // 7 unused tiles
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2252 {119, 15}, // 14 unused tiles (radar)
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2253 {140, 4}, // APT_GRASS_FENCE_NE_FLAG_2
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2254 };
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2255 for (TileIndex t = 0; t < map_size; t++) {
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2256 if (IsAirportTile(t)) {
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2257 StationGfx old_gfx = GetStationGfx(t);
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2258 byte offset = 0;
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2259 for (uint i = 0; i < lengthof(atc); i++) {
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2260 if (old_gfx < atc[i].old_start) {
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2261 SetStationGfx(t, old_gfx - offset);
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2262 break;
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2263 }
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2264 if (old_gfx < atc[i].old_start + atc[i].num_frames) {
15934
3172190fa127 (svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents: 15933
diff changeset
2265 SetAnimationFrame(t, old_gfx - atc[i].old_start);
14357
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2266 SetStationGfx(t, atc[i].old_start - offset);
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2267 break;
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2268 }
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2269 offset += atc[i].num_frames - 1;
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2270 }
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2271 }
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2272 }
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2273 }
8c37cdc73f7f (svn r18912) -Codechange: free up a bunch of airporttile ids by using the tile animation frame
yexo <yexo@openttd.org>
parents: 14279
diff changeset
2274
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2275 if (IsSavegameVersionBefore(140)) {
14793
c9ea26de660d (svn r19382) -Fix (r19381): don't break savegame version 139
yexo <yexo@openttd.org>
parents: 14791
diff changeset
2276 Station *st;
c9ea26de660d (svn r19382) -Fix (r19381): don't break savegame version 139
yexo <yexo@openttd.org>
parents: 14791
diff changeset
2277 FOR_ALL_STATIONS(st) {
c9ea26de660d (svn r19382) -Fix (r19381): don't break savegame version 139
yexo <yexo@openttd.org>
parents: 14791
diff changeset
2278 if (st->airport.tile != INVALID_TILE) {
14859
304d377a82af (svn r19455) -Codechange: split all airport information in Station to a seperate class
yexo <yexo@openttd.org>
parents: 14805
diff changeset
2279 st->airport.w = st->airport.GetSpec()->size_x;
304d377a82af (svn r19455) -Codechange: split all airport information in Station to a seperate class
yexo <yexo@openttd.org>
parents: 14805
diff changeset
2280 st->airport.h = st->airport.GetSpec()->size_y;
14793
c9ea26de660d (svn r19382) -Fix (r19381): don't break savegame version 139
yexo <yexo@openttd.org>
parents: 14791
diff changeset
2281 }
c9ea26de660d (svn r19382) -Fix (r19381): don't break savegame version 139
yexo <yexo@openttd.org>
parents: 14791
diff changeset
2282 }
c9ea26de660d (svn r19382) -Fix (r19381): don't break savegame version 139
yexo <yexo@openttd.org>
parents: 14791
diff changeset
2283 }
c9ea26de660d (svn r19382) -Fix (r19381): don't break savegame version 139
yexo <yexo@openttd.org>
parents: 14791
diff changeset
2284
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2285 if (IsSavegameVersionBefore(141)) {
15140
8676e88fecb0 (svn r19769) -Fix [FS#3820]: MV_VOID tiles shall have no tropic zone.
frosch <frosch@openttd.org>
parents: 15089
diff changeset
2286 for (TileIndex t = 0; t < map_size; t++) {
8676e88fecb0 (svn r19769) -Fix [FS#3820]: MV_VOID tiles shall have no tropic zone.
frosch <frosch@openttd.org>
parents: 15089
diff changeset
2287 /* Reset tropic zone for VOID tiles, they shall not have any. */
8676e88fecb0 (svn r19769) -Fix [FS#3820]: MV_VOID tiles shall have no tropic zone.
frosch <frosch@openttd.org>
parents: 15089
diff changeset
2288 if (IsTileType(t, MP_VOID)) SetTropicZone(t, TROPICZONE_NORMAL);
8676e88fecb0 (svn r19769) -Fix [FS#3820]: MV_VOID tiles shall have no tropic zone.
frosch <frosch@openttd.org>
parents: 15089
diff changeset
2289 }
15170
432bee68ef70 (svn r19799) -Change: give depots an unique name in the same manner buoys and waypoints are named
rubidium <rubidium@openttd.org>
parents: 15140
diff changeset
2290
432bee68ef70 (svn r19799) -Change: give depots an unique name in the same manner buoys and waypoints are named
rubidium <rubidium@openttd.org>
parents: 15140
diff changeset
2291 /* We need to properly number/name the depots.
432bee68ef70 (svn r19799) -Change: give depots an unique name in the same manner buoys and waypoints are named
rubidium <rubidium@openttd.org>
parents: 15140
diff changeset
2292 * The first step is making sure none of the depots uses the
432bee68ef70 (svn r19799) -Change: give depots an unique name in the same manner buoys and waypoints are named
rubidium <rubidium@openttd.org>
parents: 15140
diff changeset
2293 * 'default' names, after that we can assign the names. */
432bee68ef70 (svn r19799) -Change: give depots an unique name in the same manner buoys and waypoints are named
rubidium <rubidium@openttd.org>
parents: 15140
diff changeset
2294 Depot *d;
432bee68ef70 (svn r19799) -Change: give depots an unique name in the same manner buoys and waypoints are named
rubidium <rubidium@openttd.org>
parents: 15140
diff changeset
2295 FOR_ALL_DEPOTS(d) d->town_cn = UINT16_MAX;
432bee68ef70 (svn r19799) -Change: give depots an unique name in the same manner buoys and waypoints are named
rubidium <rubidium@openttd.org>
parents: 15140
diff changeset
2296
432bee68ef70 (svn r19799) -Change: give depots an unique name in the same manner buoys and waypoints are named
rubidium <rubidium@openttd.org>
parents: 15140
diff changeset
2297 FOR_ALL_DEPOTS(d) MakeDefaultName(d);
15140
8676e88fecb0 (svn r19769) -Fix [FS#3820]: MV_VOID tiles shall have no tropic zone.
frosch <frosch@openttd.org>
parents: 15089
diff changeset
2298 }
8676e88fecb0 (svn r19769) -Fix [FS#3820]: MV_VOID tiles shall have no tropic zone.
frosch <frosch@openttd.org>
parents: 15089
diff changeset
2299
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2300 if (IsSavegameVersionBefore(142)) {
15360
22ec7da21bf0 (svn r20003) -Feature [FS#3886]: [NewGRF] var 43 depot build date for railtypes
yexo <yexo@openttd.org>
parents: 15330
diff changeset
2301 Depot *d;
22ec7da21bf0 (svn r20003) -Feature [FS#3886]: [NewGRF] var 43 depot build date for railtypes
yexo <yexo@openttd.org>
parents: 15330
diff changeset
2302 FOR_ALL_DEPOTS(d) d->build_date = _date;
22ec7da21bf0 (svn r20003) -Feature [FS#3886]: [NewGRF] var 43 depot build date for railtypes
yexo <yexo@openttd.org>
parents: 15330
diff changeset
2303 }
22ec7da21bf0 (svn r20003) -Feature [FS#3886]: [NewGRF] var 43 depot build date for railtypes
yexo <yexo@openttd.org>
parents: 15330
diff changeset
2304
15846
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2305 /* In old versions it was possible to remove an airport while a plane was
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2306 * taking off or landing. This gives all kind of problems when building
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2307 * another airport in the same station so we don't allow that anymore.
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2308 * For old savegames with such aircraft we just throw them in the air and
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2309 * treat the aircraft like they were flying already. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2310 if (IsSavegameVersionBefore(146)) {
15846
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2311 Aircraft *v;
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2312 FOR_ALL_AIRCRAFT(v) {
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2313 if (!v->IsNormalAircraft()) continue;
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2314 Station *st = GetTargetAirportIfValid(v);
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2315 if (st == NULL && v->state != FLYING) {
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2316 v->state = FLYING;
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2317 UpdateAircraftCache(v);
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2318 AircraftNextAirportPos_and_Order(v);
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2319 /* get aircraft back on running altitude */
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2320 if ((v->vehstatus & VS_CRASHED) == 0) SetAircraftPosition(v, v->x_pos, v->y_pos, GetAircraftFlyingAltitude(v));
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2321 }
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2322 }
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2323 }
c7db31e8c68a (svn r20528) -Fix: in old savegames aircraft can have an invalid state
yexo <yexo@openttd.org>
parents: 15807
diff changeset
2324
15933
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2325 /* Move the animation frame to the same location (m7) for all objects. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2326 if (IsSavegameVersionBefore(147)) {
15933
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2327 for (TileIndex t = 0; t < map_size; t++) {
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2328 switch (GetTileType(t)) {
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2329 case MP_HOUSE:
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2330 if (GetHouseType(t) >= NEW_HOUSE_OFFSET) {
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2331 uint per_proc = _me[t].m7;
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2332 _me[t].m7 = GB(_m[t].m6, 2, 6) | (GB(_m[t].m3, 5, 1) << 6);
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2333 SB(_m[t].m3, 5, 1, 0);
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2334 SB(_m[t].m6, 2, 6, min(per_proc, 63));
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2335 }
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2336 break;
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2337
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2338 case MP_INDUSTRY: {
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2339 uint rand = _me[t].m7;
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2340 _me[t].m7 = _m[t].m3;
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2341 _m[t].m3 = rand;
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2342 break;
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2343 }
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2344
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2345 case MP_OBJECT:
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2346 _me[t].m7 = _m[t].m3;
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2347 _m[t].m3 = 0;
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2348 break;
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2349
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2350 default:
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2351 /* For stations/airports it's already at m7 */
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2352 break;
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2353 }
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2354 }
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2355 }
8ac5258d7680 (svn r20621) -Codechange: move animation frames of houses, objects and industries to m7 (same as airports and stations)
rubidium <rubidium@openttd.org>
parents: 15908
diff changeset
2356
15970
8aa446dec4e5 (svn r20658) -Codechange: add the colour of an object to the object instance
rubidium <rubidium@openttd.org>
parents: 15968
diff changeset
2357 /* Add (random) colour to all objects. */
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2358 if (IsSavegameVersionBefore(148)) {
15970
8aa446dec4e5 (svn r20658) -Codechange: add the colour of an object to the object instance
rubidium <rubidium@openttd.org>
parents: 15968
diff changeset
2359 Object *o;
8aa446dec4e5 (svn r20658) -Codechange: add the colour of an object to the object instance
rubidium <rubidium@openttd.org>
parents: 15968
diff changeset
2360 FOR_ALL_OBJECTS(o) {
8aa446dec4e5 (svn r20658) -Codechange: add the colour of an object to the object instance
rubidium <rubidium@openttd.org>
parents: 15968
diff changeset
2361 Owner owner = GetTileOwner(o->location.tile);
8aa446dec4e5 (svn r20658) -Codechange: add the colour of an object to the object instance
rubidium <rubidium@openttd.org>
parents: 15968
diff changeset
2362 o->colour = (owner == OWNER_NONE) ? Random() & 0xF : Company::Get(owner)->livery->colour1;
8aa446dec4e5 (svn r20658) -Codechange: add the colour of an object to the object instance
rubidium <rubidium@openttd.org>
parents: 15968
diff changeset
2363 }
8aa446dec4e5 (svn r20658) -Codechange: add the colour of an object to the object instance
rubidium <rubidium@openttd.org>
parents: 15968
diff changeset
2364 }
8aa446dec4e5 (svn r20658) -Codechange: add the colour of an object to the object instance
rubidium <rubidium@openttd.org>
parents: 15968
diff changeset
2365
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2366 if (IsSavegameVersionBefore(149)) {
16024
6b3718ff071d (svn r20717) -Fix [FS#4103]: water class was not set for stations
yexo <yexo@openttd.org>
parents: 15970
diff changeset
2367 for (TileIndex t = 0; t < map_size; t++) {
6b3718ff071d (svn r20717) -Fix [FS#4103]: water class was not set for stations
yexo <yexo@openttd.org>
parents: 15970
diff changeset
2368 if (!IsTileType(t, MP_STATION)) continue;
18257
b6026cba5dae (svn r23093) -Codechange: add a default NULL for the Z of GetTileSlope and use it
rubidium <rubidium@openttd.org>
parents: 18255
diff changeset
2369 if (!IsBuoy(t) && !IsOilRig(t) && !(IsDock(t) && GetTileSlope(t) == SLOPE_FLAT)) {
16024
6b3718ff071d (svn r20717) -Fix [FS#4103]: water class was not set for stations
yexo <yexo@openttd.org>
parents: 15970
diff changeset
2370 SetWaterClass(t, WATER_CLASS_INVALID);
6b3718ff071d (svn r20717) -Fix [FS#4103]: water class was not set for stations
yexo <yexo@openttd.org>
parents: 15970
diff changeset
2371 }
6b3718ff071d (svn r20717) -Fix [FS#4103]: water class was not set for stations
yexo <yexo@openttd.org>
parents: 15970
diff changeset
2372 }
16120
9c19ce78d8ec (svn r20816) -Codechange [FS#3835]: make waypoint default names work like depots, stations and vehicles (Krille)
rubidium <rubidium@openttd.org>
parents: 16024
diff changeset
2373
9c19ce78d8ec (svn r20816) -Codechange [FS#3835]: make waypoint default names work like depots, stations and vehicles (Krille)
rubidium <rubidium@openttd.org>
parents: 16024
diff changeset
2374 /* Waypoints with custom name may have a non-unique town_cn,
9c19ce78d8ec (svn r20816) -Codechange [FS#3835]: make waypoint default names work like depots, stations and vehicles (Krille)
rubidium <rubidium@openttd.org>
parents: 16024
diff changeset
2375 * renumber those. First set all affected waypoints to the
9c19ce78d8ec (svn r20816) -Codechange [FS#3835]: make waypoint default names work like depots, stations and vehicles (Krille)
rubidium <rubidium@openttd.org>
parents: 16024
diff changeset
2376 * highest possible number to get them numbered in the
9c19ce78d8ec (svn r20816) -Codechange [FS#3835]: make waypoint default names work like depots, stations and vehicles (Krille)
rubidium <rubidium@openttd.org>
parents: 16024
diff changeset
2377 * order they have in the pool. */
9c19ce78d8ec (svn r20816) -Codechange [FS#3835]: make waypoint default names work like depots, stations and vehicles (Krille)
rubidium <rubidium@openttd.org>
parents: 16024
diff changeset
2378 Waypoint *wp;
9c19ce78d8ec (svn r20816) -Codechange [FS#3835]: make waypoint default names work like depots, stations and vehicles (Krille)
rubidium <rubidium@openttd.org>
parents: 16024
diff changeset
2379 FOR_ALL_WAYPOINTS(wp) {
9c19ce78d8ec (svn r20816) -Codechange [FS#3835]: make waypoint default names work like depots, stations and vehicles (Krille)
rubidium <rubidium@openttd.org>
parents: 16024
diff changeset
2380 if (wp->name != NULL) wp->town_cn = UINT16_MAX;
9c19ce78d8ec (svn r20816) -Codechange [FS#3835]: make waypoint default names work like depots, stations and vehicles (Krille)
rubidium <rubidium@openttd.org>
parents: 16024
diff changeset
2381 }
9c19ce78d8ec (svn r20816) -Codechange [FS#3835]: make waypoint default names work like depots, stations and vehicles (Krille)
rubidium <rubidium@openttd.org>
parents: 16024
diff changeset
2382
9c19ce78d8ec (svn r20816) -Codechange [FS#3835]: make waypoint default names work like depots, stations and vehicles (Krille)
rubidium <rubidium@openttd.org>
parents: 16024
diff changeset
2383 FOR_ALL_WAYPOINTS(wp) {
9c19ce78d8ec (svn r20816) -Codechange [FS#3835]: make waypoint default names work like depots, stations and vehicles (Krille)
rubidium <rubidium@openttd.org>
parents: 16024
diff changeset
2384 if (wp->name != NULL) MakeDefaultName(wp);
9c19ce78d8ec (svn r20816) -Codechange [FS#3835]: make waypoint default names work like depots, stations and vehicles (Krille)
rubidium <rubidium@openttd.org>
parents: 16024
diff changeset
2385 }
16024
6b3718ff071d (svn r20717) -Fix [FS#4103]: water class was not set for stations
yexo <yexo@openttd.org>
parents: 15970
diff changeset
2386 }
6b3718ff071d (svn r20717) -Fix [FS#4103]: water class was not set for stations
yexo <yexo@openttd.org>
parents: 15970
diff changeset
2387
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2388 if (IsSavegameVersionBefore(152)) {
16455
5eec51f031a9 (svn r21171) -Change: Reset industry build data at game start or load.
alberth <alberth@openttd.org>
parents: 16437
diff changeset
2389 _industry_builder.Reset(); // Initialize industry build data.
16437
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2390
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2391 /* The moment vehicles go from hidden to visible changed. This means
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2392 * that vehicles don't always get visible anymore causing things to
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2393 * get messed up just after loading the savegame. This fixes that. */
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2394 Vehicle *v;
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2395 FOR_ALL_VEHICLES(v) {
17201
f1a1be5504ef (svn r21940) -Fix [FS#4460]: Not all vehicles should be tested to be inside a tunnel upon savegame load (SmatZ)
planetmaker <planetmaker@openttd.org>
parents: 17194
diff changeset
2396 /* Not all vehicle types can be inside a tunnel. Furthermore,
f1a1be5504ef (svn r21940) -Fix [FS#4460]: Not all vehicles should be tested to be inside a tunnel upon savegame load (SmatZ)
planetmaker <planetmaker@openttd.org>
parents: 17194
diff changeset
2397 * testing IsTunnelTile() for invalid tiles causes a crash. */
f1a1be5504ef (svn r21940) -Fix [FS#4460]: Not all vehicles should be tested to be inside a tunnel upon savegame load (SmatZ)
planetmaker <planetmaker@openttd.org>
parents: 17194
diff changeset
2398 if (!v->IsGroundVehicle()) continue;
f1a1be5504ef (svn r21940) -Fix [FS#4460]: Not all vehicles should be tested to be inside a tunnel upon savegame load (SmatZ)
planetmaker <planetmaker@openttd.org>
parents: 17194
diff changeset
2399
16437
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2400 /* Is the vehicle in a tunnel? */
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2401 if (!IsTunnelTile(v->tile)) continue;
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2402
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2403 /* Is the vehicle actually at a tunnel entrance/exit? */
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2404 TileIndex vtile = TileVirtXY(v->x_pos, v->y_pos);
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2405 if (!IsTunnelTile(vtile)) continue;
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2406
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2407 /* Are we actually in this tunnel? Or maybe a lower tunnel? */
18255
b3cb40aab91b (svn r23091) -Codechange: rename some Get*Z functions to Get*PixelZ functions if they return the Z in pixels (like TilePixelHeight)
rubidium <rubidium@openttd.org>
parents: 18248
diff changeset
2408 if (GetSlopePixelZ(v->x_pos, v->y_pos) != v->z_pos) continue;
16437
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2409
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2410 /* What way are we going? */
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2411 const DiagDirection dir = GetTunnelBridgeDirection(vtile);
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2412 const DiagDirection vdir = DirToDiagDir(v->direction);
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2413
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2414 /* Have we passed the visibility "switch" state already? */
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2415 byte pos = (DiagDirToAxis(vdir) == AXIS_X ? v->x_pos : v->y_pos) & TILE_UNIT_MASK;
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2416 byte frame = (vdir == DIAGDIR_NE || vdir == DIAGDIR_NW) ? TILE_SIZE - 1 - pos : pos;
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2417 extern const byte _tunnel_visibility_frame[DIAGDIR_END];
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2418
16471
0916f941c60e (svn r21195) -Fix [FS#4230] (r21135): in some corner cases the savegame conversion didn't do the right thing
rubidium <rubidium@openttd.org>
parents: 16455
diff changeset
2419 /* Should the vehicle be hidden or not? */
0916f941c60e (svn r21195) -Fix [FS#4230] (r21135): in some corner cases the savegame conversion didn't do the right thing
rubidium <rubidium@openttd.org>
parents: 16455
diff changeset
2420 bool hidden;
0916f941c60e (svn r21195) -Fix [FS#4230] (r21135): in some corner cases the savegame conversion didn't do the right thing
rubidium <rubidium@openttd.org>
parents: 16455
diff changeset
2421 if (dir == vdir) { // Entering tunnel
0916f941c60e (svn r21195) -Fix [FS#4230] (r21135): in some corner cases the savegame conversion didn't do the right thing
rubidium <rubidium@openttd.org>
parents: 16455
diff changeset
2422 hidden = frame >= _tunnel_visibility_frame[dir];
17208
464eb74cd181 (svn r21947) -Fix (r21195): crash when converting a savegame with vehicles crashed in a tunnel entry, or with vehicles reversing there
smatz <smatz@openttd.org>
parents: 17203
diff changeset
2423 v->tile = vtile;
16471
0916f941c60e (svn r21195) -Fix [FS#4230] (r21135): in some corner cases the savegame conversion didn't do the right thing
rubidium <rubidium@openttd.org>
parents: 16455
diff changeset
2424 } else if (dir == ReverseDiagDir(vdir)) { // Leaving tunnel
0916f941c60e (svn r21195) -Fix [FS#4230] (r21135): in some corner cases the savegame conversion didn't do the right thing
rubidium <rubidium@openttd.org>
parents: 16455
diff changeset
2425 hidden = frame < TILE_SIZE - _tunnel_visibility_frame[dir];
17208
464eb74cd181 (svn r21947) -Fix (r21195): crash when converting a savegame with vehicles crashed in a tunnel entry, or with vehicles reversing there
smatz <smatz@openttd.org>
parents: 17203
diff changeset
2426 /* v->tile changes at the moment when the vehicle leaves the tunnel. */
464eb74cd181 (svn r21947) -Fix (r21195): crash when converting a savegame with vehicles crashed in a tunnel entry, or with vehicles reversing there
smatz <smatz@openttd.org>
parents: 17203
diff changeset
2427 v->tile = hidden ? GetOtherTunnelBridgeEnd(vtile) : vtile;
464eb74cd181 (svn r21947) -Fix (r21195): crash when converting a savegame with vehicles crashed in a tunnel entry, or with vehicles reversing there
smatz <smatz@openttd.org>
parents: 17203
diff changeset
2428 } else {
464eb74cd181 (svn r21947) -Fix (r21195): crash when converting a savegame with vehicles crashed in a tunnel entry, or with vehicles reversing there
smatz <smatz@openttd.org>
parents: 17203
diff changeset
2429 /* We could get here in two cases:
464eb74cd181 (svn r21947) -Fix (r21195): crash when converting a savegame with vehicles crashed in a tunnel entry, or with vehicles reversing there
smatz <smatz@openttd.org>
parents: 17203
diff changeset
2430 * - for road vehicles, it is reversing at the end of the tunnel
464eb74cd181 (svn r21947) -Fix (r21195): crash when converting a savegame with vehicles crashed in a tunnel entry, or with vehicles reversing there
smatz <smatz@openttd.org>
parents: 17203
diff changeset
2431 * - it is crashed in the tunnel entry (both train or RV destroyed by UFO)
464eb74cd181 (svn r21947) -Fix (r21195): crash when converting a savegame with vehicles crashed in a tunnel entry, or with vehicles reversing there
smatz <smatz@openttd.org>
parents: 17203
diff changeset
2432 * Whatever case it is, do not change anything and use the old values.
464eb74cd181 (svn r21947) -Fix (r21195): crash when converting a savegame with vehicles crashed in a tunnel entry, or with vehicles reversing there
smatz <smatz@openttd.org>
parents: 17203
diff changeset
2433 * Especially changing RV's state would break its reversing in the middle. */
464eb74cd181 (svn r21947) -Fix (r21195): crash when converting a savegame with vehicles crashed in a tunnel entry, or with vehicles reversing there
smatz <smatz@openttd.org>
parents: 17203
diff changeset
2434 continue;
16471
0916f941c60e (svn r21195) -Fix [FS#4230] (r21135): in some corner cases the savegame conversion didn't do the right thing
rubidium <rubidium@openttd.org>
parents: 16455
diff changeset
2435 }
0916f941c60e (svn r21195) -Fix [FS#4230] (r21135): in some corner cases the savegame conversion didn't do the right thing
rubidium <rubidium@openttd.org>
parents: 16455
diff changeset
2436
0916f941c60e (svn r21195) -Fix [FS#4230] (r21135): in some corner cases the savegame conversion didn't do the right thing
rubidium <rubidium@openttd.org>
parents: 16455
diff changeset
2437 if (hidden) {
16437
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2438 v->vehstatus |= VS_HIDDEN;
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2439
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2440 switch (v->type) {
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2441 case VEH_TRAIN: Train::From(v)->track = TRACK_BIT_WORMHOLE; break;
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2442 case VEH_ROAD: RoadVehicle::From(v)->state = RVSB_WORMHOLE; break;
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2443 default: NOT_REACHED();
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2444 }
16471
0916f941c60e (svn r21195) -Fix [FS#4230] (r21135): in some corner cases the savegame conversion didn't do the right thing
rubidium <rubidium@openttd.org>
parents: 16455
diff changeset
2445 } else {
16437
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2446 v->vehstatus &= ~VS_HIDDEN;
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2447
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2448 switch (v->type) {
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2449 case VEH_TRAIN: Train::From(v)->track = DiagDirToDiagTrackBits(vdir); break;
16651
73ff1504a61a (svn r21382) -Fix (r21153) [FS#4290]: the road vehicle's frame wasn't properly set upon savegame conversion *if* the vehicle would be hidden, but isn't going to be hidden anymore after the conversion
rubidium <rubidium@openttd.org>
parents: 16571
diff changeset
2450 case VEH_ROAD: RoadVehicle::From(v)->state = DiagDirToDiagTrackdir(vdir); RoadVehicle::From(v)->frame = frame; break;
16437
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2451 default: NOT_REACHED();
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2452 }
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2453 }
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2454 }
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2455 }
662a2210afac (svn r21153) -Change: unify the moment trains/road vehicles become (un)visible when entering/leaving a tunnel. As a side effect some tunnel related glitches are gone.
rubidium <rubidium@openttd.org>
parents: 16407
diff changeset
2456
16556
27c6e2c99511 (svn r21284) -Codechange: Rename CheckSavegameVersion() to IsSavegameVersionBefore().
alberth <alberth@openttd.org>
parents: 16554
diff changeset
2457 if (IsSavegameVersionBefore(153)) {
16537
abfc3321231b (svn r21263) -Fix [FS#3935]: under some circumstances two vehicles could leave a non-drive through road stop at once
rubidium <rubidium@openttd.org>
parents: 16471
diff changeset
2458 RoadVehicle *rv;
abfc3321231b (svn r21263) -Fix [FS#3935]: under some circumstances two vehicles could leave a non-drive through road stop at once
rubidium <rubidium@openttd.org>
parents: 16471
diff changeset
2459 FOR_ALL_ROADVEHICLES(rv) {
16571
3ef305c397f1 (svn r21299) -Fix (r21263): a road vehicle in a depot or wormhole could get into an incorrect state upon savegame conversion causing it to break up later in the game
rubidium <rubidium@openttd.org>
parents: 16556
diff changeset
2460 if (rv->state == RVSB_IN_DEPOT || rv->state == RVSB_WORMHOLE) continue;
3ef305c397f1 (svn r21299) -Fix (r21263): a road vehicle in a depot or wormhole could get into an incorrect state upon savegame conversion causing it to break up later in the game
rubidium <rubidium@openttd.org>
parents: 16556
diff changeset
2461
16537
abfc3321231b (svn r21263) -Fix [FS#3935]: under some circumstances two vehicles could leave a non-drive through road stop at once
rubidium <rubidium@openttd.org>
parents: 16471
diff changeset
2462 bool loading = rv->current_order.IsType(OT_LOADING) || rv->current_order.IsType(OT_LEAVESTATION);
abfc3321231b (svn r21263) -Fix [FS#3935]: under some circumstances two vehicles could leave a non-drive through road stop at once
rubidium <rubidium@openttd.org>
parents: 16471
diff changeset
2463 if (HasBit(rv->state, RVS_IN_ROAD_STOP)) {
abfc3321231b (svn r21263) -Fix [FS#3935]: under some circumstances two vehicles could leave a non-drive through road stop at once
rubidium <rubidium@openttd.org>
parents: 16471
diff changeset
2464 extern const byte _road_stop_stop_frame[];
abfc3321231b (svn r21263) -Fix [FS#3935]: under some circumstances two vehicles could leave a non-drive through road stop at once
rubidium <rubidium@openttd.org>
parents: 16471
diff changeset
2465 SB(rv->state, RVS_ENTERED_STOP, 1, loading || rv->frame > _road_stop_stop_frame[rv->state - RVSB_IN_ROAD_STOP + (_settings_game.vehicle.road_side << RVS_DRIVE_SIDE)]);
abfc3321231b (svn r21263) -Fix [FS#3935]: under some circumstances two vehicles could leave a non-drive through road stop at once
rubidium <rubidium@openttd.org>
parents: 16471
diff changeset
2466 } else if (HasBit(rv->state, RVS_IN_DT_ROAD_STOP)) {
abfc3321231b (svn r21263) -Fix [FS#3935]: under some circumstances two vehicles could leave a non-drive through road stop at once
rubidium <rubidium@openttd.org>
parents: 16471
diff changeset
2467 SB(rv->state, RVS_ENTERED_STOP, 1, loading || rv->frame > RVC_DRIVE_THROUGH_STOP_FRAME);
abfc3321231b (svn r21263) -Fix [FS#3935]: under some circumstances two vehicles could leave a non-drive through road stop at once
rubidium <rubidium@openttd.org>
parents: 16471
diff changeset
2468 }
abfc3321231b (svn r21263) -Fix [FS#3935]: under some circumstances two vehicles could leave a non-drive through road stop at once
rubidium <rubidium@openttd.org>
parents: 16471
diff changeset
2469 }
abfc3321231b (svn r21263) -Fix [FS#3935]: under some circumstances two vehicles could leave a non-drive through road stop at once
rubidium <rubidium@openttd.org>
parents: 16471
diff changeset
2470 }
abfc3321231b (svn r21263) -Fix [FS#3935]: under some circumstances two vehicles could leave a non-drive through road stop at once
rubidium <rubidium@openttd.org>
parents: 16471
diff changeset
2471
16771
86bdc4c9b81e (svn r21504) -Codechange: move the "lost" bit from the train's flags to vehicle flags
rubidium <rubidium@openttd.org>
parents: 16651
diff changeset
2472 if (IsSavegameVersionBefore(156)) {
86bdc4c9b81e (svn r21504) -Codechange: move the "lost" bit from the train's flags to vehicle flags
rubidium <rubidium@openttd.org>
parents: 16651
diff changeset
2473 /* The train's pathfinder lost flag got moved. */
86bdc4c9b81e (svn r21504) -Codechange: move the "lost" bit from the train's flags to vehicle flags
rubidium <rubidium@openttd.org>
parents: 16651
diff changeset
2474 Train *t;
86bdc4c9b81e (svn r21504) -Codechange: move the "lost" bit from the train's flags to vehicle flags
rubidium <rubidium@openttd.org>
parents: 16651
diff changeset
2475 FOR_ALL_TRAINS(t) {
86bdc4c9b81e (svn r21504) -Codechange: move the "lost" bit from the train's flags to vehicle flags
rubidium <rubidium@openttd.org>
parents: 16651
diff changeset
2476 if (!HasBit(t->flags, 5)) continue;
86bdc4c9b81e (svn r21504) -Codechange: move the "lost" bit from the train's flags to vehicle flags
rubidium <rubidium@openttd.org>
parents: 16651
diff changeset
2477
86bdc4c9b81e (svn r21504) -Codechange: move the "lost" bit from the train's flags to vehicle flags
rubidium <rubidium@openttd.org>
parents: 16651
diff changeset
2478 ClrBit(t->flags, 5);
86bdc4c9b81e (svn r21504) -Codechange: move the "lost" bit from the train's flags to vehicle flags
rubidium <rubidium@openttd.org>
parents: 16651
diff changeset
2479 SetBit(t->vehicle_flags, VF_PATHFINDER_LOST);
86bdc4c9b81e (svn r21504) -Codechange: move the "lost" bit from the train's flags to vehicle flags
rubidium <rubidium@openttd.org>
parents: 16651
diff changeset
2480 }
16992
e364b524e15a (svn r21728) -Fix/Feature [FS#4331]: (configurably) limit amount of tiles that can be cleared/terraformed by a company
rubidium <rubidium@openttd.org>
parents: 16982
diff changeset
2481
e364b524e15a (svn r21728) -Fix/Feature [FS#4331]: (configurably) limit amount of tiles that can be cleared/terraformed by a company
rubidium <rubidium@openttd.org>
parents: 16982
diff changeset
2482 /* Introduced terraform/clear limits. */
e364b524e15a (svn r21728) -Fix/Feature [FS#4331]: (configurably) limit amount of tiles that can be cleared/terraformed by a company
rubidium <rubidium@openttd.org>
parents: 16982
diff changeset
2483 Company *c;
e364b524e15a (svn r21728) -Fix/Feature [FS#4331]: (configurably) limit amount of tiles that can be cleared/terraformed by a company
rubidium <rubidium@openttd.org>
parents: 16982
diff changeset
2484 FOR_ALL_COMPANIES(c) {
e364b524e15a (svn r21728) -Fix/Feature [FS#4331]: (configurably) limit amount of tiles that can be cleared/terraformed by a company
rubidium <rubidium@openttd.org>
parents: 16982
diff changeset
2485 c->terraform_limit = _settings_game.construction.terraform_frame_burst << 16;
e364b524e15a (svn r21728) -Fix/Feature [FS#4331]: (configurably) limit amount of tiles that can be cleared/terraformed by a company
rubidium <rubidium@openttd.org>
parents: 16982
diff changeset
2486 c->clear_limit = _settings_game.construction.clear_frame_burst << 16;
e364b524e15a (svn r21728) -Fix/Feature [FS#4331]: (configurably) limit amount of tiles that can be cleared/terraformed by a company
rubidium <rubidium@openttd.org>
parents: 16982
diff changeset
2487 }
16771
86bdc4c9b81e (svn r21504) -Codechange: move the "lost" bit from the train's flags to vehicle flags
rubidium <rubidium@openttd.org>
parents: 16651
diff changeset
2488 }
86bdc4c9b81e (svn r21504) -Codechange: move the "lost" bit from the train's flags to vehicle flags
rubidium <rubidium@openttd.org>
parents: 16651
diff changeset
2489
17143
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2490 if (IsSavegameVersionBefore(158)) {
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2491 Vehicle *v;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2492 FOR_ALL_VEHICLES(v) {
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2493 switch (v->type) {
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2494 case VEH_TRAIN: {
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2495 Train *t = Train::From(v);
17203
87db8141d855 (svn r21942) -Codechange: no need to convert GOINGUP/GOINGDOWN flags if they are cleared afterwards during savegame conversion
smatz <smatz@openttd.org>
parents: 17201
diff changeset
2496
87db8141d855 (svn r21942) -Codechange: no need to convert GOINGUP/GOINGDOWN flags if they are cleared afterwards during savegame conversion
smatz <smatz@openttd.org>
parents: 17201
diff changeset
2497 /* Clear old GOINGUP / GOINGDOWN flags.
87db8141d855 (svn r21942) -Codechange: no need to convert GOINGUP/GOINGDOWN flags if they are cleared afterwards during savegame conversion
smatz <smatz@openttd.org>
parents: 17201
diff changeset
2498 * It was changed in savegame version 139, but savegame
87db8141d855 (svn r21942) -Codechange: no need to convert GOINGUP/GOINGDOWN flags if they are cleared afterwards during savegame conversion
smatz <smatz@openttd.org>
parents: 17201
diff changeset
2499 * version 158 doesn't use these bits, so it doesn't hurt
87db8141d855 (svn r21942) -Codechange: no need to convert GOINGUP/GOINGDOWN flags if they are cleared afterwards during savegame conversion
smatz <smatz@openttd.org>
parents: 17201
diff changeset
2500 * to clear them unconditionally. */
87db8141d855 (svn r21942) -Codechange: no need to convert GOINGUP/GOINGDOWN flags if they are cleared afterwards during savegame conversion
smatz <smatz@openttd.org>
parents: 17201
diff changeset
2501 ClrBit(t->flags, 1);
87db8141d855 (svn r21942) -Codechange: no need to convert GOINGUP/GOINGDOWN flags if they are cleared afterwards during savegame conversion
smatz <smatz@openttd.org>
parents: 17201
diff changeset
2502 ClrBit(t->flags, 2);
87db8141d855 (svn r21942) -Codechange: no need to convert GOINGUP/GOINGDOWN flags if they are cleared afterwards during savegame conversion
smatz <smatz@openttd.org>
parents: 17201
diff changeset
2503
17143
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2504 /* Clear both bits first. */
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2505 ClrBit(t->gv_flags, GVF_GOINGUP_BIT);
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2506 ClrBit(t->gv_flags, GVF_GOINGDOWN_BIT);
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2507
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2508 /* Crashed vehicles can't be going up/down. */
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2509 if (t->vehstatus & VS_CRASHED) break;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2510
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2511 /* Only X/Y tracks can be sloped. */
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2512 if (t->track != TRACK_BIT_X && t->track != TRACK_BIT_Y) break;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2513
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2514 t->gv_flags |= FixVehicleInclination(t, t->direction);
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2515 break;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2516 }
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2517 case VEH_ROAD: {
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2518 RoadVehicle *rv = RoadVehicle::From(v);
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2519 ClrBit(rv->gv_flags, GVF_GOINGUP_BIT);
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2520 ClrBit(rv->gv_flags, GVF_GOINGDOWN_BIT);
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2521
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2522 /* Crashed vehicles can't be going up/down. */
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2523 if (rv->vehstatus & VS_CRASHED) break;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2524
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2525 if (rv->state == RVSB_IN_DEPOT || rv->state == RVSB_WORMHOLE) break;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2526
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2527 TrackStatus ts = GetTileTrackStatus(rv->tile, TRANSPORT_ROAD, rv->compatible_roadtypes);
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2528 TrackBits trackbits = TrackStatusToTrackBits(ts);
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2529
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2530 /* Only X/Y tracks can be sloped. */
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2531 if (trackbits != TRACK_BIT_X && trackbits != TRACK_BIT_Y) break;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2532
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2533 Direction dir = rv->direction;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2534
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2535 /* Test if we are reversing. */
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2536 Axis a = trackbits == TRACK_BIT_X ? AXIS_X : AXIS_Y;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2537 if (AxisToDirection(a) != dir &&
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2538 AxisToDirection(a) != ReverseDir(dir)) {
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2539 /* When reversing, the road vehicle is on the edge of the tile,
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2540 * so it can be safely compared to the middle of the tile. */
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2541 dir = INVALID_DIR;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2542 }
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2543
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2544 rv->gv_flags |= FixVehicleInclination(rv, dir);
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2545 break;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2546 }
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2547 case VEH_SHIP:
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2548 break;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2549
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2550 default:
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2551 continue;
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2552 }
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2553
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2554 if (IsBridgeTile(v->tile) && TileVirtXY(v->x_pos, v->y_pos) == v->tile) {
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2555 /* In old versions, z_pos was 1 unit lower on bridge heads.
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2556 * However, this invalid state could be converted to new savegames
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2557 * by loading and saving the game in a new version. */
18255
b3cb40aab91b (svn r23091) -Codechange: rename some Get*Z functions to Get*PixelZ functions if they return the Z in pixels (like TilePixelHeight)
rubidium <rubidium@openttd.org>
parents: 18248
diff changeset
2558 v->z_pos = GetSlopePixelZ(v->x_pos, v->y_pos);
17143
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2559 DiagDirection dir = GetTunnelBridgeDirection(v->tile);
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2560 if (v->type == VEH_TRAIN && !(v->vehstatus & VS_CRASHED) &&
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2561 v->direction != DiagDirToDir(dir)) {
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2562 /* If the train has left the bridge, it shouldn't have
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2563 * track == TRACK_BIT_WORMHOLE - this could happen
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2564 * when the train was reversed while on the last "tick"
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2565 * on the ramp before leaving the ramp to the bridge. */
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2566 Train::From(v)->track = DiagDirToDiagTrackBits(dir);
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2567 }
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2568 }
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2569
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2570 /* If the vehicle is really above v->tile (not in a wormhole),
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2571 * it should have set v->z_pos correctly. */
18255
b3cb40aab91b (svn r23091) -Codechange: rename some Get*Z functions to Get*PixelZ functions if they return the Z in pixels (like TilePixelHeight)
rubidium <rubidium@openttd.org>
parents: 18248
diff changeset
2572 assert(v->tile != TileVirtXY(v->x_pos, v->y_pos) || v->z_pos == GetSlopePixelZ(v->x_pos, v->y_pos));
17143
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2573 }
17194
b590eca5d805 (svn r21933) -Codechange: Split cur_order_index into cur_auto_order_index and cur_real_order_index to keep track of the current real order in an unambiguous way.
frosch <frosch@openttd.org>
parents: 17193
diff changeset
2574
b590eca5d805 (svn r21933) -Codechange: Split cur_order_index into cur_auto_order_index and cur_real_order_index to keep track of the current real order in an unambiguous way.
frosch <frosch@openttd.org>
parents: 17193
diff changeset
2575 /* Fill Vehicle::cur_real_order_index */
b590eca5d805 (svn r21933) -Codechange: Split cur_order_index into cur_auto_order_index and cur_real_order_index to keep track of the current real order in an unambiguous way.
frosch <frosch@openttd.org>
parents: 17193
diff changeset
2576 FOR_ALL_VEHICLES(v) {
b590eca5d805 (svn r21933) -Codechange: Split cur_order_index into cur_auto_order_index and cur_real_order_index to keep track of the current real order in an unambiguous way.
frosch <frosch@openttd.org>
parents: 17193
diff changeset
2577 if (!v->IsPrimaryVehicle()) continue;
b590eca5d805 (svn r21933) -Codechange: Split cur_order_index into cur_auto_order_index and cur_real_order_index to keep track of the current real order in an unambiguous way.
frosch <frosch@openttd.org>
parents: 17193
diff changeset
2578
17306
2ed9720f1bb1 (svn r22046) -Fix [FS#4487]: Make sure order indices stay in range when copying, sharing, unsharing or deleting all orders.
frosch <frosch@openttd.org>
parents: 17285
diff changeset
2579 /* Older versions are less strict with indices being in range and fix them on the fly */
17693
cdeed5a57cdb (svn r22473) -Codechange: Automatic orders are better called implicit orders as no real order influencing path finding is added
planetmaker <planetmaker@openttd.org>
parents: 17383
diff changeset
2580 if (v->cur_implicit_order_index >= v->GetNumOrders()) v->cur_implicit_order_index = 0;
17306
2ed9720f1bb1 (svn r22046) -Fix [FS#4487]: Make sure order indices stay in range when copying, sharing, unsharing or deleting all orders.
frosch <frosch@openttd.org>
parents: 17285
diff changeset
2581
17693
cdeed5a57cdb (svn r22473) -Codechange: Automatic orders are better called implicit orders as no real order influencing path finding is added
planetmaker <planetmaker@openttd.org>
parents: 17383
diff changeset
2582 v->cur_real_order_index = v->cur_implicit_order_index;
17194
b590eca5d805 (svn r21933) -Codechange: Split cur_order_index into cur_auto_order_index and cur_real_order_index to keep track of the current real order in an unambiguous way.
frosch <frosch@openttd.org>
parents: 17193
diff changeset
2583 v->UpdateRealOrderIndex();
b590eca5d805 (svn r21933) -Codechange: Split cur_order_index into cur_auto_order_index and cur_real_order_index to keep track of the current real order in an unambiguous way.
frosch <frosch@openttd.org>
parents: 17193
diff changeset
2584 }
17143
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2585 }
d2394a934993 (svn r21881) -Codechange: ensure that vehicle's GOINGUP/DOWN bits are set correctly and that it has correct z_pos when converting from older savegames
smatz <smatz@openttd.org>
parents: 17123
diff changeset
2586
17223
a1dda316ecbe (svn r21962) -Feature-ish: GUI setting to disable reversing at signals
rubidium <rubidium@openttd.org>
parents: 17208
diff changeset
2587 if (IsSavegameVersionBefore(159)) {
a1dda316ecbe (svn r21962) -Feature-ish: GUI setting to disable reversing at signals
rubidium <rubidium@openttd.org>
parents: 17208
diff changeset
2588 /* If the savegame is old (before version 100), then the value of 255
a1dda316ecbe (svn r21962) -Feature-ish: GUI setting to disable reversing at signals
rubidium <rubidium@openttd.org>
parents: 17208
diff changeset
2589 * for these settings did not mean "disabled". As such everything
a1dda316ecbe (svn r21962) -Feature-ish: GUI setting to disable reversing at signals
rubidium <rubidium@openttd.org>
parents: 17208
diff changeset
2590 * before then did reverse.
a1dda316ecbe (svn r21962) -Feature-ish: GUI setting to disable reversing at signals
rubidium <rubidium@openttd.org>
parents: 17208
diff changeset
2591 * To simplify stuff we disable all turning around or we do not
a1dda316ecbe (svn r21962) -Feature-ish: GUI setting to disable reversing at signals
rubidium <rubidium@openttd.org>
parents: 17208
diff changeset
2592 * disable anything at all. So, if some reversing was disabled we
a1dda316ecbe (svn r21962) -Feature-ish: GUI setting to disable reversing at signals
rubidium <rubidium@openttd.org>
parents: 17208
diff changeset
2593 * will keep reversing disabled, otherwise it'll be turned on. */
a1dda316ecbe (svn r21962) -Feature-ish: GUI setting to disable reversing at signals
rubidium <rubidium@openttd.org>
parents: 17208
diff changeset
2594 _settings_game.pf.reverse_at_signals = IsSavegameVersionBefore(100) || (_settings_game.pf.wait_oneway_signal != 255 && _settings_game.pf.wait_twoway_signal != 255 && _settings_game.pf.wait_for_pbs_path != 255);
17321
e23208bb065b (svn r22061) -Change: when loading old savegames with long trains set the maximum train length to the length of the longest train
yexo <yexo@openttd.org>
parents: 17306
diff changeset
2595
e23208bb065b (svn r22061) -Change: when loading old savegames with long trains set the maximum train length to the length of the longest train
yexo <yexo@openttd.org>
parents: 17306
diff changeset
2596 Train *t;
e23208bb065b (svn r22061) -Change: when loading old savegames with long trains set the maximum train length to the length of the longest train
yexo <yexo@openttd.org>
parents: 17306
diff changeset
2597 FOR_ALL_TRAINS(t) {
e23208bb065b (svn r22061) -Change: when loading old savegames with long trains set the maximum train length to the length of the longest train
yexo <yexo@openttd.org>
parents: 17306
diff changeset
2598 _settings_game.vehicle.max_train_length = max<uint8>(_settings_game.vehicle.max_train_length, CeilDiv(t->gcache.cached_total_length, TILE_SIZE));
e23208bb065b (svn r22061) -Change: when loading old savegames with long trains set the maximum train length to the length of the longest train
yexo <yexo@openttd.org>
parents: 17306
diff changeset
2599 }
17223
a1dda316ecbe (svn r21962) -Feature-ish: GUI setting to disable reversing at signals
rubidium <rubidium@openttd.org>
parents: 17208
diff changeset
2600 }
a1dda316ecbe (svn r21962) -Feature-ish: GUI setting to disable reversing at signals
rubidium <rubidium@openttd.org>
parents: 17208
diff changeset
2601
17229
7b48e75bd53c (svn r21969) -Feature: Introduce 'minimal' number of industries as a replacment for the old 'none' setting in the newgame window.
alberth <alberth@openttd.org>
parents: 17223
diff changeset
2602 if (IsSavegameVersionBefore(160)) {
17261
2d2cbb8602d2 (svn r22001) -Codechange: Rename difficulty.number_industries to difficulty.industry_density.
alberth <alberth@openttd.org>
parents: 17247
diff changeset
2603 /* Setting difficulty industry_density other than zero get bumped to +1
2d2cbb8602d2 (svn r22001) -Codechange: Rename difficulty.number_industries to difficulty.industry_density.
alberth <alberth@openttd.org>
parents: 17247
diff changeset
2604 * since a new option (minimal at position 1) has been added */
2d2cbb8602d2 (svn r22001) -Codechange: Rename difficulty.number_industries to difficulty.industry_density.
alberth <alberth@openttd.org>
parents: 17247
diff changeset
2605 if (_settings_game.difficulty.industry_density > 0) {
2d2cbb8602d2 (svn r22001) -Codechange: Rename difficulty.number_industries to difficulty.industry_density.
alberth <alberth@openttd.org>
parents: 17247
diff changeset
2606 _settings_game.difficulty.industry_density++;
17229
7b48e75bd53c (svn r21969) -Feature: Introduce 'minimal' number of industries as a replacment for the old 'none' setting in the newgame window.
alberth <alberth@openttd.org>
parents: 17223
diff changeset
2607 }
7b48e75bd53c (svn r21969) -Feature: Introduce 'minimal' number of industries as a replacment for the old 'none' setting in the newgame window.
alberth <alberth@openttd.org>
parents: 17223
diff changeset
2608 }
7b48e75bd53c (svn r21969) -Feature: Introduce 'minimal' number of industries as a replacment for the old 'none' setting in the newgame window.
alberth <alberth@openttd.org>
parents: 17223
diff changeset
2609
17782
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2610 if (IsSavegameVersionBefore(161)) {
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2611 /* Before savegame version 161, persistent storages were not stored in a pool. */
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2612
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2613 if (!IsSavegameVersionBefore(76)) {
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2614 Industry *ind;
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2615 FOR_ALL_INDUSTRIES(ind) {
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2616 assert(ind->psa != NULL);
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2617
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2618 /* Check if the old storage was empty. */
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2619 bool is_empty = true;
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2620 for (uint i = 0; i < sizeof(ind->psa->storage); i++) {
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2621 if (ind->psa->GetValue(i) != 0) {
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2622 is_empty = false;
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2623 break;
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2624 }
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2625 }
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2626
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2627 if (!is_empty) {
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2628 ind->psa->grfid = _industry_mngr.GetGRFID(ind->type);
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2629 } else {
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2630 delete ind->psa;
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2631 ind->psa = NULL;
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2632 }
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2633 }
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2634 }
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2635
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2636 if (!IsSavegameVersionBefore(145)) {
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2637 Station *st;
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2638 FOR_ALL_STATIONS(st) {
17788
5d14fa020688 (svn r22573) -Fix (r22567): Fix operator precedence.
terkhen <terkhen@openttd.org>
parents: 17782
diff changeset
2639 if (!(st->facilities & FACIL_AIRPORT)) continue;
17782
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2640 assert(st->airport.psa != NULL);
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2641
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2642 /* Check if the old storage was empty. */
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2643 bool is_empty = true;
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2644 for (uint i = 0; i < sizeof(st->airport.psa->storage); i++) {
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2645 if (st->airport.psa->GetValue(i) != 0) {
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2646 is_empty = false;
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2647 break;
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2648 }
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2649 }
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2650
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2651 if (!is_empty) {
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2652 st->airport.psa->grfid = _airport_mngr.GetGRFID(st->airport.type);
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2653 } else {
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2654 delete st->airport.psa;
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2655 st->airport.psa = NULL;
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2656
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2657 }
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2658 }
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2659 }
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2660 }
043b87d0dbec (svn r22567) -Codechange: Store persistent storages inside a pool.
terkhen <terkhen@openttd.org>
parents: 17756
diff changeset
2661
18248
abe81a5bee85 (svn r23084) -Codechange: get rid of a redundant variable
rubidium <rubidium@openttd.org>
parents: 18247
diff changeset
2662 /* This triggers only when old snow_lines were copied into the snow_line_height. */
abe81a5bee85 (svn r23084) -Codechange: get rid of a redundant variable
rubidium <rubidium@openttd.org>
parents: 18247
diff changeset
2663 if (IsSavegameVersionBefore(164) && _settings_game.game_creation.snow_line_height >= MIN_SNOWLINE_HEIGHT * TILE_HEIGHT) {
abe81a5bee85 (svn r23084) -Codechange: get rid of a redundant variable
rubidium <rubidium@openttd.org>
parents: 18247
diff changeset
2664 _settings_game.game_creation.snow_line_height /= TILE_HEIGHT;
abe81a5bee85 (svn r23084) -Codechange: get rid of a redundant variable
rubidium <rubidium@openttd.org>
parents: 18247
diff changeset
2665 }
abe81a5bee85 (svn r23084) -Codechange: get rid of a redundant variable
rubidium <rubidium@openttd.org>
parents: 18247
diff changeset
2666
18332
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2667 if (IsSavegameVersionBefore(164) && !IsSavegameVersionBefore(32)) {
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2668 /* We store 4 fences in the field tiles instead of only SE and SW. */
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2669 for (TileIndex t = 0; t < map_size; t++) {
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2670 if (!IsTileType(t, MP_CLEAR) && !IsTileType(t, MP_TREES)) continue;
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2671 if (IsTileType(t, MP_CLEAR) && IsClearGround(t, CLEAR_FIELDS)) continue;
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2672 uint fence = GB(_m[t].m4, 5, 3);
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2673 if (fence != 0 && IsTileType(TILE_ADDXY(t, 1, 0), MP_CLEAR) && IsClearGround(TILE_ADDXY(t, 1, 0), CLEAR_FIELDS)) {
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2674 SetFenceNE(TILE_ADDXY(t, 1, 0), fence);
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2675 }
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2676 fence = GB(_m[t].m4, 2, 3);
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2677 if (fence != 0 && IsTileType(TILE_ADDXY(t, 0, 1), MP_CLEAR) && IsClearGround(TILE_ADDXY(t, 0, 1), CLEAR_FIELDS)) {
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2678 SetFenceNW(TILE_ADDXY(t, 0, 1), fence);
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2679 }
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2680 SB(_m[t].m4, 2, 3, 0);
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2681 SB(_m[t].m4, 5, 3, 0);
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2682 }
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2683 }
d1598ff3329e (svn r23168) -Feature [FS#1824]: always draw fences around field tiles
yexo <yexo@openttd.org>
parents: 18257
diff changeset
2684
18446
83cd95a883a3 (svn r23290) -Fix [FS#2379,FS#3569]: Change the centre of train vehicles to depend on the vehicle length instead of being fixed at 4/8th of the original vehicle length to make sure shortened vehicles don't block tiles they shouldn't block.
michi_cc <michi_cc@openttd.org>
parents: 18332
diff changeset
2685 /* The center of train vehicles was changed, fix up spacing. */
83cd95a883a3 (svn r23290) -Fix [FS#2379,FS#3569]: Change the centre of train vehicles to depend on the vehicle length instead of being fixed at 4/8th of the original vehicle length to make sure shortened vehicles don't block tiles they shouldn't block.
michi_cc <michi_cc@openttd.org>
parents: 18332
diff changeset
2686 if (IsSavegameVersionBefore(164)) FixupTrainLengths();
83cd95a883a3 (svn r23290) -Fix [FS#2379,FS#3569]: Change the centre of train vehicles to depend on the vehicle length instead of being fixed at 4/8th of the original vehicle length to make sure shortened vehicles don't block tiles they shouldn't block.
michi_cc <michi_cc@openttd.org>
parents: 18332
diff changeset
2687
18465
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2688 if (IsSavegameVersionBefore(165)) {
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2689 Town *t;
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2690
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2691 FOR_ALL_TOWNS(t) {
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2692 /* Set the default cargo requirement for town growth */
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2693 switch (_settings_game.game_creation.landscape) {
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2694 case LT_ARCTIC:
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2695 if (FindFirstCargoWithTownEffect(TE_FOOD) != NULL) t->goal[TE_FOOD] = TOWN_GROWTH_WINTER;
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2696 break;
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2697
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2698 case LT_TROPIC:
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2699 if (FindFirstCargoWithTownEffect(TE_FOOD) != NULL) t->goal[TE_FOOD] = TOWN_GROWTH_DESERT;
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2700 if (FindFirstCargoWithTownEffect(TE_WATER) != NULL) t->goal[TE_WATER] = TOWN_GROWTH_DESERT;
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2701 break;
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2702 }
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2703 }
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2704 }
4358f26ad8d1 (svn r23309) -Fix: loading old games didn't have goals set for towns (tnx to frosch for spotting)
truebrain <truebrain@openttd.org>
parents: 18446
diff changeset
2705
18472
11637619aa76 (svn r23316) -Feature: Add ability to zoom in to 2x and 4x level.
peter1138 <peter1138@openttd.org>
parents: 18465
diff changeset
2706 if (IsSavegameVersionBefore(165)) {
11637619aa76 (svn r23316) -Feature: Add ability to zoom in to 2x and 4x level.
peter1138 <peter1138@openttd.org>
parents: 18465
diff changeset
2707 /* Adjust zoom level to account for new levels */
11637619aa76 (svn r23316) -Feature: Add ability to zoom in to 2x and 4x level.
peter1138 <peter1138@openttd.org>
parents: 18465
diff changeset
2708 _saved_scrollpos_zoom = _saved_scrollpos_zoom + ZOOM_LVL_SHIFT;
11637619aa76 (svn r23316) -Feature: Add ability to zoom in to 2x and 4x level.
peter1138 <peter1138@openttd.org>
parents: 18465
diff changeset
2709 _saved_scrollpos_x *= ZOOM_LVL_BASE;
11637619aa76 (svn r23316) -Feature: Add ability to zoom in to 2x and 4x level.
peter1138 <peter1138@openttd.org>
parents: 18465
diff changeset
2710 _saved_scrollpos_y *= ZOOM_LVL_BASE;
11637619aa76 (svn r23316) -Feature: Add ability to zoom in to 2x and 4x level.
peter1138 <peter1138@openttd.org>
parents: 18465
diff changeset
2711 }
11637619aa76 (svn r23316) -Feature: Add ability to zoom in to 2x and 4x level.
peter1138 <peter1138@openttd.org>
parents: 18465
diff changeset
2712
18247
973050b62813 (svn r23083) -Fix: run StartupEngines() if NewGRFs changed during loading a savegame, just like it's running when NewGRFs are changed during a game
yexo <yexo@openttd.org>
parents: 18152
diff changeset
2713 /* When any NewGRF has been changed the availability of some vehicles might
973050b62813 (svn r23083) -Fix: run StartupEngines() if NewGRFs changed during loading a savegame, just like it's running when NewGRFs are changed during a game
yexo <yexo@openttd.org>
parents: 18152
diff changeset
2714 * have been changed too. e->company_avail must be set to 0 in that case
973050b62813 (svn r23083) -Fix: run StartupEngines() if NewGRFs changed during loading a savegame, just like it's running when NewGRFs are changed during a game
yexo <yexo@openttd.org>
parents: 18152
diff changeset
2715 * which is done by StartupEngines(). */
973050b62813 (svn r23083) -Fix: run StartupEngines() if NewGRFs changed during loading a savegame, just like it's running when NewGRFs are changed during a game
yexo <yexo@openttd.org>
parents: 18152
diff changeset
2716 if (gcf_res != GLC_ALL_GOOD) StartupEngines();
973050b62813 (svn r23083) -Fix: run StartupEngines() if NewGRFs changed during loading a savegame, just like it's running when NewGRFs are changed during a game
yexo <yexo@openttd.org>
parents: 18152
diff changeset
2717
18560
488cc0d0b505 (svn r23405) -Codechange: Keep a matrix of cargos accepted by houses for each town (michi_cc).
terkhen <terkhen@openttd.org>
parents: 18472
diff changeset
2718 if (IsSavegameVersionBefore(166)) {
488cc0d0b505 (svn r23405) -Codechange: Keep a matrix of cargos accepted by houses for each town (michi_cc).
terkhen <terkhen@openttd.org>
parents: 18472
diff changeset
2719 /* Update cargo acceptance map of towns. */
488cc0d0b505 (svn r23405) -Codechange: Keep a matrix of cargos accepted by houses for each town (michi_cc).
terkhen <terkhen@openttd.org>
parents: 18472
diff changeset
2720 for (TileIndex t = 0; t < map_size; t++) {
488cc0d0b505 (svn r23405) -Codechange: Keep a matrix of cargos accepted by houses for each town (michi_cc).
terkhen <terkhen@openttd.org>
parents: 18472
diff changeset
2721 if (!IsTileType(t, MP_HOUSE)) continue;
488cc0d0b505 (svn r23405) -Codechange: Keep a matrix of cargos accepted by houses for each town (michi_cc).
terkhen <terkhen@openttd.org>
parents: 18472
diff changeset
2722 Town::Get(GetTownIndex(t))->cargo_accepted.Add(t);
488cc0d0b505 (svn r23405) -Codechange: Keep a matrix of cargos accepted by houses for each town (michi_cc).
terkhen <terkhen@openttd.org>
parents: 18472
diff changeset
2723 }
488cc0d0b505 (svn r23405) -Codechange: Keep a matrix of cargos accepted by houses for each town (michi_cc).
terkhen <terkhen@openttd.org>
parents: 18472
diff changeset
2724
488cc0d0b505 (svn r23405) -Codechange: Keep a matrix of cargos accepted by houses for each town (michi_cc).
terkhen <terkhen@openttd.org>
parents: 18472
diff changeset
2725 Town *town;
488cc0d0b505 (svn r23405) -Codechange: Keep a matrix of cargos accepted by houses for each town (michi_cc).
terkhen <terkhen@openttd.org>
parents: 18472
diff changeset
2726 FOR_ALL_TOWNS(town) {
18678
5604c42fa1ce (svn r23526) -Codechange: unify cargos vs cargoes
rubidium <rubidium@openttd.org>
parents: 18629
diff changeset
2727 UpdateTownCargoes(town);
18560
488cc0d0b505 (svn r23405) -Codechange: Keep a matrix of cargos accepted by houses for each town (michi_cc).
terkhen <terkhen@openttd.org>
parents: 18472
diff changeset
2728 }
488cc0d0b505 (svn r23405) -Codechange: Keep a matrix of cargos accepted by houses for each town (michi_cc).
terkhen <terkhen@openttd.org>
parents: 18472
diff changeset
2729 }
488cc0d0b505 (svn r23405) -Codechange: Keep a matrix of cargos accepted by houses for each town (michi_cc).
terkhen <terkhen@openttd.org>
parents: 18472
diff changeset
2730
19088
7cd49ed5628c (svn r23942) -Fix: infrastructure cache of standard road stops would get messed up when buying a company with them
rubidium <rubidium@openttd.org>
parents: 18891
diff changeset
2731 /* The road owner of standard road stops was not properly accounted for. */
7cd49ed5628c (svn r23942) -Fix: infrastructure cache of standard road stops would get messed up when buying a company with them
rubidium <rubidium@openttd.org>
parents: 18891
diff changeset
2732 if (IsSavegameVersionBefore(172)) {
7cd49ed5628c (svn r23942) -Fix: infrastructure cache of standard road stops would get messed up when buying a company with them
rubidium <rubidium@openttd.org>
parents: 18891
diff changeset
2733 for (TileIndex t = 0; t < map_size; t++) {
7cd49ed5628c (svn r23942) -Fix: infrastructure cache of standard road stops would get messed up when buying a company with them
rubidium <rubidium@openttd.org>
parents: 18891
diff changeset
2734 if (!IsStandardRoadStopTile(t)) continue;
7cd49ed5628c (svn r23942) -Fix: infrastructure cache of standard road stops would get messed up when buying a company with them
rubidium <rubidium@openttd.org>
parents: 18891
diff changeset
2735 Owner o = GetTileOwner(t);
7cd49ed5628c (svn r23942) -Fix: infrastructure cache of standard road stops would get messed up when buying a company with them
rubidium <rubidium@openttd.org>
parents: 18891
diff changeset
2736 SetRoadOwner(t, ROADTYPE_ROAD, o);
7cd49ed5628c (svn r23942) -Fix: infrastructure cache of standard road stops would get messed up when buying a company with them
rubidium <rubidium@openttd.org>
parents: 18891
diff changeset
2737 SetRoadOwner(t, ROADTYPE_TRAM, o);
7cd49ed5628c (svn r23942) -Fix: infrastructure cache of standard road stops would get messed up when buying a company with them
rubidium <rubidium@openttd.org>
parents: 18891
diff changeset
2738 }
7cd49ed5628c (svn r23942) -Fix: infrastructure cache of standard road stops would get messed up when buying a company with them
rubidium <rubidium@openttd.org>
parents: 18891
diff changeset
2739 }
7cd49ed5628c (svn r23942) -Fix: infrastructure cache of standard road stops would get messed up when buying a company with them
rubidium <rubidium@openttd.org>
parents: 18891
diff changeset
2740
19245
018c0334584f (svn r24134) -Add: Configurable limits for tree planting.
michi_cc <michi_cc@openttd.org>
parents: 19243
diff changeset
2741 if (IsSavegameVersionBefore(175)) {
018c0334584f (svn r24134) -Add: Configurable limits for tree planting.
michi_cc <michi_cc@openttd.org>
parents: 19243
diff changeset
2742 /* Introduced tree planting limit. */
018c0334584f (svn r24134) -Add: Configurable limits for tree planting.
michi_cc <michi_cc@openttd.org>
parents: 19243
diff changeset
2743 Company *c;
018c0334584f (svn r24134) -Add: Configurable limits for tree planting.
michi_cc <michi_cc@openttd.org>
parents: 19243
diff changeset
2744 FOR_ALL_COMPANIES(c) c->tree_limit = _settings_game.construction.tree_frame_burst << 16;
018c0334584f (svn r24134) -Add: Configurable limits for tree planting.
michi_cc <michi_cc@openttd.org>
parents: 19243
diff changeset
2745 }
018c0334584f (svn r24134) -Add: Configurable limits for tree planting.
michi_cc <michi_cc@openttd.org>
parents: 19243
diff changeset
2746
19655
bd9f7150594c (svn r24564) -Fix [FS#5312] (r17433): Limiting the inflation did not quite work.
frosch <frosch@openttd.org>
parents: 19631
diff changeset
2747 if (IsSavegameVersionBefore(177)) {
bd9f7150594c (svn r24564) -Fix [FS#5312] (r17433): Limiting the inflation did not quite work.
frosch <frosch@openttd.org>
parents: 19631
diff changeset
2748 /* Fix too high inflation rates */
bd9f7150594c (svn r24564) -Fix [FS#5312] (r17433): Limiting the inflation did not quite work.
frosch <frosch@openttd.org>
parents: 19631
diff changeset
2749 if (_economy.inflation_prices > MAX_INFLATION) _economy.inflation_prices = MAX_INFLATION;
bd9f7150594c (svn r24564) -Fix [FS#5312] (r17433): Limiting the inflation did not quite work.
frosch <frosch@openttd.org>
parents: 19631
diff changeset
2750 if (_economy.inflation_payment > MAX_INFLATION) _economy.inflation_payment = MAX_INFLATION;
19698
dd021b9ddc69 (svn r24619) -Change: Check for bankruptcy on a monthly basis (ZxBioHazardZx)
planetmaker <planetmaker@openttd.org>
parents: 19656
diff changeset
2751
dd021b9ddc69 (svn r24619) -Change: Check for bankruptcy on a monthly basis (ZxBioHazardZx)
planetmaker <planetmaker@openttd.org>
parents: 19656
diff changeset
2752 /* We have to convert the quarters of bankruptcy into months of bankruptcy */
dd021b9ddc69 (svn r24619) -Change: Check for bankruptcy on a monthly basis (ZxBioHazardZx)
planetmaker <planetmaker@openttd.org>
parents: 19656
diff changeset
2753 FOR_ALL_COMPANIES(c) {
dd021b9ddc69 (svn r24619) -Change: Check for bankruptcy on a monthly basis (ZxBioHazardZx)
planetmaker <planetmaker@openttd.org>
parents: 19656
diff changeset
2754 c->months_of_bankruptcy = 3 * c->months_of_bankruptcy;
dd021b9ddc69 (svn r24619) -Change: Check for bankruptcy on a monthly basis (ZxBioHazardZx)
planetmaker <planetmaker@openttd.org>
parents: 19656
diff changeset
2755 }
19655
bd9f7150594c (svn r24564) -Fix [FS#5312] (r17433): Limiting the inflation did not quite work.
frosch <frosch@openttd.org>
parents: 19631
diff changeset
2756 }
bd9f7150594c (svn r24564) -Fix [FS#5312] (r17433): Limiting the inflation did not quite work.
frosch <frosch@openttd.org>
parents: 19631
diff changeset
2757
13875
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13859
diff changeset
2758 /* Road stops is 'only' updating some caches */
052c69fbc76b (svn r18404) -Codechange: link drive through stops better together
rubidium <rubidium@openttd.org>
parents: 13859
diff changeset
2759 AfterLoadRoadStops();
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
2760 AfterLoadLabelMaps();
18566
9b9dc36d3eb2 (svn r23411) -Add: Company infrastructure counts for rail.
michi_cc <michi_cc@openttd.org>
parents: 18565
diff changeset
2761 AfterLoadCompanyStats();
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
2762
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2763 GamelogPrintDebug(1);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2764
12749
27a938bed307 (svn r17215) -Cleanup: remove unused return value
yexo <yexo@openttd.org>
parents: 12669
diff changeset
2765 InitializeWindowsAndCaches();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2766 /* Restore the signals */
11948
ad1ecf6b26e4 (svn r16351) -Fix (r14773): signal handler could end in endless loop
smatz <smatz@openttd.org>
parents: 11946
diff changeset
2767 ResetSignalHandlers();
12749
27a938bed307 (svn r17215) -Cleanup: remove unused return value
yexo <yexo@openttd.org>
parents: 12669
diff changeset
2768 return true;
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2769 }
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2770
15620
f8e9a3f0c140 (svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents: 15618
diff changeset
2771 /**
f8e9a3f0c140 (svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents: 15618
diff changeset
2772 * Reload all NewGRF files during a running game. This is a cut-down
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2773 * version of AfterLoadGame().
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2774 * 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
2775 * 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
2776 * to recalculate vehicle data as some NewGRF vehicle sets could have been
15623
c62577640878 (svn r20286) -Codechange: Unify end of doxygen comments.
frosch <frosch@openttd.org>
parents: 15620
diff changeset
2777 * removed or added and changed statistics
c62577640878 (svn r20286) -Codechange: Unify end of doxygen comments.
frosch <frosch@openttd.org>
parents: 15620
diff changeset
2778 */
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2779 void ReloadNewGRFData()
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2780 {
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2781 /* reload grf data */
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2782 GfxLoadSprites();
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2783 LoadStringWidthTable();
12940
1b090e0c4f93 (svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
frosch <frosch@openttd.org>
parents: 12826
diff changeset
2784 RecomputePrices();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2785 /* reload vehicles */
18863
58840c62f6da (svn r23712) -Codechange: rename the two vehicle hashes we have to names that make clear where they differ in
truebrain <truebrain@openttd.org>
parents: 18845
diff changeset
2786 ResetVehicleHash();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2787 AfterLoadVehicles(false);
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2788 StartupEngines();
18152
545be3b5f43e (svn r22977) -Codechange: Rename SetCachedEngineCounts() to GroupStatistics::UpdateAfterLoad().
frosch <frosch@openttd.org>
parents: 17853
diff changeset
2789 GroupStatistics::UpdateAfterLoad();
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12471
diff changeset
2790 /* update station graphics */
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2791 AfterLoadStations();
18566
9b9dc36d3eb2 (svn r23411) -Add: Company infrastructure counts for rail.
michi_cc <michi_cc@openttd.org>
parents: 18565
diff changeset
2792 /* Update company statistics. */
9b9dc36d3eb2 (svn r23411) -Add: Company infrastructure counts for rail.
michi_cc <michi_cc@openttd.org>
parents: 18565
diff changeset
2793 AfterLoadCompanyStats();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2794 /* 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
2795 UpdateHousesAndTowns();
17247
5221777879f1 (svn r21987) -Fix: Make news items, engine previews and AI preview events deal with no longer existing Engine items after resetting the pool.
frosch <frosch@openttd.org>
parents: 17229
diff changeset
2796 /* Delete news referring to no longer existing entities */
5221777879f1 (svn r21987) -Fix: Make news items, engine previews and AI preview events deal with no longer existing Engine items after resetting the pool.
frosch <frosch@openttd.org>
parents: 17229
diff changeset
2797 DeleteInvalidEngineNews();
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2798 /* Update livery selection windows */
12380
4be044af31ec (svn r16809) -Fix [FS#3021](r13096): automatic resizing of SelectCompanyLiveryWindow wasn't working as expected
smatz <smatz@openttd.org>
parents: 12361
diff changeset
2799 for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) InvalidateWindowData(WC_COMPANY_COLOUR, i);
18565
021a10db1a99 (svn r23410) -Add: A window with a detailed overview over the infrastructure of a company.
michi_cc <michi_cc@openttd.org>
parents: 18560
diff changeset
2800 /* Update company infrastructure counts. */
021a10db1a99 (svn r23410) -Add: A window with a detailed overview over the infrastructure of a company.
michi_cc <michi_cc@openttd.org>
parents: 18560
diff changeset
2801 InvalidateWindowClassesData(WC_COMPANY_INFRASTRUCTURE);
10571
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2802 /* 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
2803 MarkWholeScreenDirty();
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2804 CheckTrainsLengths();
b6779abf2e96 (svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
diff changeset
2805 }