annotate src/openttd.cpp @ 10515:7156262cf0c9 draft

(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
author rubidium <rubidium@openttd.org>
date Mon, 29 Dec 2008 21:50:25 +0000
parents 45ca88a8de7d
children 4b968224d0fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
9111
d48433370037 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents: 9095
diff changeset
3 /** @file openttd.cpp Functions related to starting OpenTTD. */
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
4
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
5 #include "stdafx.h"
8788
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
6
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
7 #define VARDEF
8788
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
8 #include "variables.h"
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
9 #undef VARDEF
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
10
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
11 #include "openttd.h"
8788
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
12
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
13 #include "driver.h"
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
14 #include "blitter/factory.hpp"
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
15 #include "sound/sound_driver.hpp"
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
16 #include "music/music_driver.hpp"
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
17 #include "video/video_driver.hpp"
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
18
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
19 #include "fontcache.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
20 #include "gfxinit.h"
8788
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
21 #include "gfx_func.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
22 #include "gui.h"
8788
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
23 #include "mixer.h"
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
24 #include "sound_func.h"
8107
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
25 #include "window_func.h"
8788
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
26
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
27 #include "debug.h"
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
28 #include "saveload.h"
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
29 #include "landscape.h"
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents: 10207
diff changeset
30 #include "company_func.h"
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents: 10207
diff changeset
31 #include "company_base.h"
8116
9cc845deddfe (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents: 8114
diff changeset
32 #include "command_func.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
33 #include "town.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
34 #include "industry.h"
8763
d6e363672edb (svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium <rubidium@openttd.org>
parents: 8707
diff changeset
35 #include "news_func.h"
10039
6301378f3e0f (svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium <rubidium@openttd.org>
parents: 10037
diff changeset
36 #include "fileio_func.h"
8151
bee108a98a39 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents: 8144
diff changeset
37 #include "fios.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
38 #include "airport.h"
6193
0d05fec9d384 (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar <celestar@openttd.org>
parents: 6190
diff changeset
39 #include "aircraft.h"
9336
5287277c4972 (svn r13228) -Codechange: split console.h.
rubidium <rubidium@openttd.org>
parents: 9334
diff changeset
40 #include "console_func.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
41 #include "screenshot.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
42 #include "network/network.h"
9428
ba7cdcf21f4c (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium <rubidium@openttd.org>
parents: 9420
diff changeset
43 #include "network/network_func.h"
8790
5ef0059ccfc0 (svn r12501) -Codechange: split signs.h.
rubidium <rubidium@openttd.org>
parents: 8788
diff changeset
44 #include "signs_base.h"
5ef0059ccfc0 (svn r12501) -Codechange: split signs.h.
rubidium <rubidium@openttd.org>
parents: 8788
diff changeset
45 #include "signs_func.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
46 #include "waypoint.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
47 #include "ai/ai.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
48 #include "train.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
49 #include "yapf/yapf.h"
8208
ddc34919158f (svn r11771) -Codechange: split settings.h into better separated headers.
rubidium <rubidium@openttd.org>
parents: 8179
diff changeset
50 #include "settings_func.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
51 #include "genworld.h"
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents: 10207
diff changeset
52 #include "company_manager_face.h"
8788
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
53 #include "group.h"
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
54 #include "strings_func.h"
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
55 #include "date_func.h"
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
56 #include "vehicle_func.h"
9457
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9429
diff changeset
57 #include "gamelog.h"
8965
89de4625fe7d (svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium <rubidium@openttd.org>
parents: 8962
diff changeset
58 #include "cheat_func.h"
9005
5bb8efb6051a (svn r12800) -Codechange: move the animated tile related functions out of texteff.cpp (it isn't a text effect after all). Also remove a few more functions from functions.
rubidium <rubidium@openttd.org>
parents: 8989
diff changeset
59 #include "animated_tile_func.h"
9006
9bf1de259ada (svn r12801) -Codechange: remove the dependency of function.h in town_map.h
rubidium <rubidium@openttd.org>
parents: 9005
diff changeset
60 #include "functions.h"
9154
046d0b6e0218 (svn r13016) -Codechange: unify the detection if rail catenary should be drawn
smatz <smatz@openttd.org>
parents: 9111
diff changeset
61 #include "elrail_func.h"
9085
31575b0db757 (svn r12944) -Codechange: use rev.h instead of externs at many places
smatz <smatz@openttd.org>
parents: 9070
diff changeset
62 #include "rev.h"
8788
cb5ca4d081de (svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents: 8787
diff changeset
63
6451
25c7793c8d9a (svn r9601) -Codechange: Store grf file reference in station spec, not just GRF ID
peter1138 <peter1138@openttd.org>
parents: 6427
diff changeset
64 #include "newgrf.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
65 #include "newgrf_config.h"
6332
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
66 #include "newgrf_house.h"
6629
188437dffcff (svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas <belugas@openttd.org>
parents: 6626
diff changeset
67 #include "newgrf_commons.h"
8787
ff327b646d49 (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium <rubidium@openttd.org>
parents: 8786
diff changeset
68 #include "newgrf_station.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
69
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
70 #include "clear_map.h"
8787
ff327b646d49 (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium <rubidium@openttd.org>
parents: 8786
diff changeset
71 #include "tree_map.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
72 #include "rail_map.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
73 #include "road_map.h"
10289
5f3f0d0a6e07 (svn r14528) -Codechange: cache the closest town for all road tiles instead of only roads owned by tiles. This replaces a O(n) search over all towns from the road's tileloop with a O(1) lookup (PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10262
diff changeset
74 #include "road_cmd.h"
8787
ff327b646d49 (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium <rubidium@openttd.org>
parents: 8786
diff changeset
75 #include "station_map.h"
ff327b646d49 (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium <rubidium@openttd.org>
parents: 8786
diff changeset
76 #include "town_map.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
77 #include "industry_map.h"
6257
d7d39048e2ee (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight <truelight@openttd.org>
parents: 6247
diff changeset
78 #include "unmovable_map.h"
8787
ff327b646d49 (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium <rubidium@openttd.org>
parents: 8786
diff changeset
79 #include "tunnel_map.h"
ff327b646d49 (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium <rubidium@openttd.org>
parents: 8786
diff changeset
80 #include "bridge_map.h"
ff327b646d49 (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium <rubidium@openttd.org>
parents: 8786
diff changeset
81 #include "water_map.h"
8083
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents: 8082
diff changeset
82 #include "tunnelbridge_map.h"
8108
4faab45e2603 (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents: 8107
diff changeset
83 #include "void_map.h"
8471
1e4ea519bfaf (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents: 8404
diff changeset
84 #include "water.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
85
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
86 #include <stdarg.h>
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
87
8264
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8258
diff changeset
88 #include "table/strings.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8258
diff changeset
89
8973
f8dda7737158 (svn r12765) -Codechange: move some stuff out of variables.h that required including other headers in variables.h.
rubidium <rubidium@openttd.org>
parents: 8965
diff changeset
90 StringID _switch_mode_errorstr;
f8dda7737158 (svn r12765) -Codechange: move some stuff out of variables.h that required including other headers in variables.h.
rubidium <rubidium@openttd.org>
parents: 8965
diff changeset
91
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
92 void CallLandscapeTick();
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
93 void IncreaseDate();
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
94 void DoPaletteAnimations();
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
95 void MusicLoop();
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
96 void ResetMusic();
8987
7901d37c4329 (svn r12782) -Codechange: remove some functions from functions.h and do not statically 'waste' memory when the old name array is not needed anymore.
rubidium <rubidium@openttd.org>
parents: 8985
diff changeset
97 void ResetOldNames();
8989
4ecc117ebb22 (svn r12784) -Codechange: handle the asynchronious save 'handlers' in saveload.cpp instead of openttd.cpp.
rubidium <rubidium@openttd.org>
parents: 8987
diff changeset
98 void ProcessAsyncSaveFinish();
9161
0106126c478a (svn r13024) -Codechange: do not use WE_MOUSELOOP when WE_TICK suffices, rename WE_4 to something more descriptive and correct some (completely incorrect) comments.
rubidium <rubidium@openttd.org>
parents: 9159
diff changeset
99 void CallWindowTickEvent();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
100
9358
12f4585b2124 (svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
101 extern void SetDifficultyLevel(int mode, DifficultySettings *gm_opt);
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
102 extern Company *DoStartupNewCompany(bool is_ai);
9470
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
103 extern void ShowOSErrorBox(const char *buf, bool system);
8809
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8790
diff changeset
104 extern void InitializeRailGUI();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
105
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
106 /**
9470
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
107 * Error handling for fatal user errors.
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
108 * @param s the string to print.
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
109 * @note Does NEVER return.
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
110 */
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
111 void CDECL usererror(const char *s, ...)
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
112 {
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
113 va_list va;
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
114 char buf[512];
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
115
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
116 va_start(va, s);
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
117 vsnprintf(buf, lengthof(buf), s, va);
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
118 va_end(va);
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
119
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
120 ShowOSErrorBox(buf, false);
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
121 if (_video_driver != NULL) _video_driver->Stop();
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
122
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
123 exit(1);
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
124 }
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
125
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
126 /**
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
127 * Error handling for fatal non-user errors.
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
128 * @param s the string to print.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
129 * @note Does NEVER return.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
130 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
131 void CDECL error(const char *s, ...)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
132 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
133 va_list va;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
134 char buf[512];
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
135
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
136 va_start(va, s);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
137 vsnprintf(buf, lengthof(buf), s, va);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
138 va_end(va);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
139
9470
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
140 ShowOSErrorBox(buf, true);
7170
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
141 if (_video_driver != NULL) _video_driver->Stop();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
142
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
143 assert(0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
144 exit(1);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
145 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
146
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
147 /**
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
148 * Shows some information on the console/a popup box depending on the OS.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
149 * @param str the text to show.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
150 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
151 void CDECL ShowInfoF(const char *str, ...)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
152 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
153 va_list va;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
154 char buf[1024];
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
155 va_start(va, str);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
156 vsnprintf(buf, lengthof(buf), str, va);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
157 va_end(va);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
158 ShowInfo(buf);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
159 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
160
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
161 /**
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
162 * Show the help message when someone passed a wrong parameter.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
163 */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
164 static void ShowHelp()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
165 {
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
166 char buf[4096];
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
167 char *p = buf;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
168
10299
26fd53f1fd8d (svn r14540) -Codechange: introduce [v]seprintf which are like [v]snprintf but do return the number of characters written instead of the number of characters that would be written; as size_t is unsigned substraction can cause integer underflows quite quickly.
rubidium <rubidium@openttd.org>
parents: 10296
diff changeset
169 p += seprintf(p, lastof(buf), "OpenTTD %s\n", _openttd_revision);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
170 p = strecpy(p,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
171 "\n"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
172 "\n"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
173 "Command line options:\n"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
174 " -v drv = Set video driver (see below)\n"
5885
e0a6ce7c45b8 (svn r8497) -Codechange: Increase the size of the sound/video/music-drivers to 32 bytes (instead of 16) so their actual parameters can be passed. Sound has for example 'bufsize' and 'hz'. Also use the recently introduced StrEmpty().
Darkvater <Darkvater@openttd.org>
parents: 5884
diff changeset
175 " -s drv = Set sound driver (see below) (param bufsize,hz)\n"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
176 " -m drv = Set music driver (see below)\n"
6852
31184effcea5 (svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight <truelight@openttd.org>
parents: 6770
diff changeset
177 " -b drv = Set the blitter to use (see below)\n"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
178 " -r res = Set resolution (for instance 800x600)\n"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
179 " -h = Display this help text\n"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
180 " -t year = Set starting year\n"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
181 " -d [[fac=]lvl[,...]]= Debug mode\n"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
182 " -e = Start Editor\n"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
183 " -g [savegame] = Start new/save game immediately\n"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
184 " -G seed = Set random seed\n"
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
185 #if defined(ENABLE_NETWORK)
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
186 " -n [ip:port#company]= Start networkgame\n"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
187 " -D [ip][:port] = Start dedicated server\n"
5959
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
188 " -l ip[:port] = Redirect DEBUG()\n"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
189 #if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
190 " -f = Fork into the background (dedicated only)\n"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
191 #endif
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
192 #endif /* ENABLE_NETWORK */
10296
c8d9457bd5c5 (svn r14535) -Fix: Description of '-i' commandline option.
frosch <frosch@openttd.org>
parents: 10289
diff changeset
193 " -i palette = Force to use the DOS (0) or Windows (1) palette\n"
c8d9457bd5c5 (svn r14535) -Fix: Description of '-i' commandline option.
frosch <frosch@openttd.org>
parents: 10289
diff changeset
194 " (defines default setting when adding newgrfs)\n"
10361
b822f913edb3 (svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents: 10360
diff changeset
195 " Default value (2) lets OpenTTD use the palette\n"
b822f913edb3 (svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents: 10360
diff changeset
196 " specified in graphics set file (see below)\n"
9994
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
197 " -I graphics_set = Force the graphics set (see below)\n"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
198 " -c config_file = Use 'config_file' instead of 'openttd.cfg'\n"
9994
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
199 " -x = Do not automatically save to config file on exit\n"
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
200 "\n",
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
201 lastof(buf)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
202 );
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
203
9994
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
204 /* List the graphics packs */
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
205 p = GetGraphicsSetsList(p, lastof(buf));
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
206
7170
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
207 /* List the drivers */
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
208 p = VideoDriverFactoryBase::GetDriversInfo(p, lastof(buf));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
209
6852
31184effcea5 (svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight <truelight@openttd.org>
parents: 6770
diff changeset
210 /* List the blitters */
31184effcea5 (svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight <truelight@openttd.org>
parents: 6770
diff changeset
211 p = BlitterFactoryBase::GetBlittersInfo(p, lastof(buf));
31184effcea5 (svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight <truelight@openttd.org>
parents: 6770
diff changeset
212
5723
2fc1cb6d4885 (svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater <Darkvater@openttd.org>
parents: 5707
diff changeset
213 /* ShowInfo put output to stderr, but version information should go
2fc1cb6d4885 (svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater <Darkvater@openttd.org>
parents: 5707
diff changeset
214 * to stdout; this is the only exception */
2fc1cb6d4885 (svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater <Darkvater@openttd.org>
parents: 5707
diff changeset
215 #if !defined(WIN32) && !defined(WIN64)
2fc1cb6d4885 (svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater <Darkvater@openttd.org>
parents: 5707
diff changeset
216 printf("%s\n", buf);
2fc1cb6d4885 (svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater <Darkvater@openttd.org>
parents: 5707
diff changeset
217 #else
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
218 ShowInfo(buf);
5723
2fc1cb6d4885 (svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater <Darkvater@openttd.org>
parents: 5707
diff changeset
219 #endif
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
220 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
221
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
222
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
223 struct MyGetOptData {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
224 char *opt;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
225 int numleft;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
226 char **argv;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
227 const char *options;
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
228 const char *cont;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
229
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
230 MyGetOptData(int argc, char **argv, const char *options)
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
231 {
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
232 opt = NULL;
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
233 numleft = argc;
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
234 this->argv = argv;
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
235 this->options = options;
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
236 cont = NULL;
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
237 }
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
238 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
239
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
240 static int MyGetOpt(MyGetOptData *md)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
241 {
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
242 const char *s,*r,*t;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
243
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
244 s = md->cont;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
245 if (s != NULL)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
246 goto md_continue_here;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
247
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
248 for (;;) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
249 if (--md->numleft < 0) return -1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
250
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
251 s = *md->argv++;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
252 if (*s == '-') {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
253 md_continue_here:;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
254 s++;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
255 if (*s != 0) {
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
256 /* Found argument, try to locate it in options. */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
257 if (*s == ':' || (r = strchr(md->options, *s)) == NULL) {
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
258 /* ERROR! */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
259 return -2;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
260 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
261 if (r[1] == ':') {
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
262 /* Item wants an argument. Check if the argument follows, or if it comes as a separate arg. */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
263 if (!*(t = s + 1)) {
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
264 /* It comes as a separate arg. Check if out of args? */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
265 if (--md->numleft < 0 || *(t = *md->argv) == '-') {
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
266 /* Check if item is optional? */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
267 if (r[2] != ':')
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
268 return -2;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
269 md->numleft++;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
270 t = NULL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
271 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
272 md->argv++;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
273 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
274 }
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
275 md->opt = (char*)t;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
276 md->cont = NULL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
277 return *s;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
278 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
279 md->opt = NULL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
280 md->cont = s;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
281 return *s;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
282 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
283 } else {
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
284 /* This is currently not supported. */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
285 return -2;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
286 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
287 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
288 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
289
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
290 /**
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
291 * Extract the resolution from the given string and store
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
292 * it in the 'res' parameter.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
293 * @param res variable to store the resolution in.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
294 * @param s the string to decompose.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
295 */
9533
176a9fe1018f (svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents: 9470
diff changeset
296 static void ParseResolution(Dimension *res, const char *s)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
297 {
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
298 const char *t = strchr(s, 'x');
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
299 if (t == NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
300 ShowInfoF("Invalid resolution '%s'", s);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
301 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
302 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
303
9533
176a9fe1018f (svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents: 9470
diff changeset
304 res->width = max(strtoul(s, NULL, 0), 64UL);
176a9fe1018f (svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents: 9470
diff changeset
305 res->height = max(strtoul(t + 1, NULL, 0), 64UL);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
306 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
307
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
308 static void InitializeDynamicVariables()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
309 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
310 /* Dynamic stuff needs to be initialized somewhere... */
7152
70c7afefcca5 (svn r10426) -Codechange: Activate the reset of industry/tiles mapping upon initialization or new game.
belugas <belugas@openttd.org>
parents: 7091
diff changeset
311 _industry_mngr.ResetMapping();
70c7afefcca5 (svn r10426) -Codechange: Activate the reset of industry/tiles mapping upon initialization or new game.
belugas <belugas@openttd.org>
parents: 7091
diff changeset
312 _industile_mngr.ResetMapping();
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
313 _Company_pool.AddBlockToPool();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
314 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
315
5659
78a7505fd513 (svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents: 5652
diff changeset
316
9159
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
317 /** Unitializes drivers, frees allocated memory, cleans pools, ...
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
318 * Generally, prepares the game for shutting down
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
319 */
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
320 static void ShutdownGame()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
321 {
9159
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
322 /* stop the AI */
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
323 AI_Uninitialize();
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
324
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
325 IConsoleFree();
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
326
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
327 if (_network_available) NetworkShutDown(); // Shut down the network and close any open connections
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
328
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
329 DriverFactoryBase::ShutdownDrivers();
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
330
5659
78a7505fd513 (svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents: 5652
diff changeset
331 UnInitWindowSystem();
78a7505fd513 (svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents: 5652
diff changeset
332
78a7505fd513 (svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents: 5652
diff changeset
333 /* Uninitialize airport state machines */
78a7505fd513 (svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents: 5652
diff changeset
334 UnInitializeAirports();
78a7505fd513 (svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents: 5652
diff changeset
335
78a7505fd513 (svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents: 5652
diff changeset
336 /* Uninitialize variables that are allocated dynamically */
9457
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9429
diff changeset
337 GamelogReset();
7401
1e97c047c9f6 (svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents: 7393
diff changeset
338 _Town_pool.CleanPool();
1e97c047c9f6 (svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents: 7393
diff changeset
339 _Industry_pool.CleanPool();
1e97c047c9f6 (svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents: 7393
diff changeset
340 _Station_pool.CleanPool();
1e97c047c9f6 (svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents: 7393
diff changeset
341 _Vehicle_pool.CleanPool();
1e97c047c9f6 (svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents: 7393
diff changeset
342 _Sign_pool.CleanPool();
1e97c047c9f6 (svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents: 7393
diff changeset
343 _Order_pool.CleanPool();
1e97c047c9f6 (svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents: 7393
diff changeset
344 _Group_pool.CleanPool();
1e97c047c9f6 (svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents: 7393
diff changeset
345 _CargoPacket_pool.CleanPool();
9070
11b5b3f4175d (svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138 <peter1138@openttd.org>
parents: 9069
diff changeset
346 _Engine_pool.CleanPool();
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
347 _Company_pool.CleanPool();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
348
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
349 free(_config_file);
9159
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
350
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
351 /* Close all and any open filehandles */
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
352 FioCloseAll();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
353 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
354
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
355 static void LoadIntroGame()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
356 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
357 _game_mode = GM_MENU;
6427
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents: 6351
diff changeset
358
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
359 ResetGRFConfig(false);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
360
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
361 /* Setup main window */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
362 ResetWindowSystem();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
363 SetupColorsAndInitialWindow();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
364
6929
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
365 /* Load the default opening screen savegame */
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
366 if (SaveOrLoad("opntitle.dat", SL_LOAD, DATA_DIR) != SL_OK) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
367 GenerateWorld(GW_EMPTY, 64, 64); // if failed loading, make empty world.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
368 WaitTillGeneratedWorld();
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
369 SetLocalCompany(COMPANY_SPECTATOR);
10152
2590e56e45f3 (svn r14339) -Fix (r13731): crash when loading the intro game failed
smatz <smatz@openttd.org>
parents: 10150
diff changeset
370 } else {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
371 SetLocalCompany(COMPANY_FIRST);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
372 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
373
6231
a4e11dd2d7c6 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight <truelight@openttd.org>
parents: 6229
diff changeset
374 _pause_game = 0;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
375 _cursor.fix_at = false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
376 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
377
8085
b6bf6634fcca (svn r11646) -Codechange: check whether (some) characters are missing in the current 'font' for the 'currently' chosen language and give a warning when that does happen.
rubidium <rubidium@openttd.org>
parents: 8083
diff changeset
378 CheckForMissingGlyphsInLoadedLanguagePack();
b6bf6634fcca (svn r11646) -Codechange: check whether (some) characters are missing in the current 'font' for the 'currently' chosen language and give a warning when that does happen.
rubidium <rubidium@openttd.org>
parents: 8083
diff changeset
379
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
380 /* Play main theme */
7170
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
381 if (_music_driver->IsSongPlaying()) ResetMusic();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
382 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
383
8268
ab53b3bf7100 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium <rubidium@openttd.org>
parents: 8265
diff changeset
384 byte _savegame_sort_order;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
385 #if defined(UNIX) && !defined(__MORPHOS__)
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
386 extern void DedicatedFork();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
387 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
388
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
389 int ttd_main(int argc, char *argv[])
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
390 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
391 int i;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
392 const char *optformat;
9994
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
393 char musicdriver[32], sounddriver[32], videodriver[32], blitter[32], graphics_set[32];
9533
176a9fe1018f (svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents: 9470
diff changeset
394 Dimension resolution = {0, 0};
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
395 Year startyear = INVALID_YEAR;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
396 uint generation_seed = GENERATE_NEW_SEED;
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
397 bool save_config = true;
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
398 #if defined(ENABLE_NETWORK)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
399 bool dedicated = false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
400 bool network = false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
401 char *network_conn = NULL;
5959
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
402 char *debuglog_conn = NULL;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
403 char *dedicated_host = NULL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
404 uint16 dedicated_port = 0;
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
405 #endif /* ENABLE_NETWORK */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
406
9994
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
407 musicdriver[0] = sounddriver[0] = videodriver[0] = blitter[0] = graphics_set[0] = '\0';
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
408
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
409 _game_mode = GM_MENU;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
410 _switch_mode = SM_MENU;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
411 _switch_mode_errorstr = INVALID_STRING_ID;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
412 _dedicated_forks = false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
413 _config_file = NULL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
414
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
415 /* The last param of the following function means this:
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
416 * a letter means: it accepts that param (e.g.: -h)
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
417 * a ':' behind it means: it need a param (e.g.: -m<driver>)
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
418 * a '::' behind it means: it can optional have a param (e.g.: -d<debug>) */
9994
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
419 optformat = "m:s:v:b:hD::n::ei::I:t:d::r:g::G:c:xl:"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
420 #if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
421 "f"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
422 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
423 ;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
424
6491
696f0e1b046e (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents: 6486
diff changeset
425 MyGetOptData mgo(argc - 1, argv + 1, optformat);
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
426
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
427 while ((i = MyGetOpt(&mgo)) != -1) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
428 switch (i) {
10310
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10299
diff changeset
429 case 'I': strecpy(graphics_set, mgo.opt, lastof(graphics_set)); break;
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10299
diff changeset
430 case 'm': strecpy(musicdriver, mgo.opt, lastof(musicdriver)); break;
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10299
diff changeset
431 case 's': strecpy(sounddriver, mgo.opt, lastof(sounddriver)); break;
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10299
diff changeset
432 case 'v': strecpy(videodriver, mgo.opt, lastof(videodriver)); break;
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10299
diff changeset
433 case 'b': strecpy(blitter, mgo.opt, lastof(blitter)); break;
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
434 #if defined(ENABLE_NETWORK)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
435 case 'D':
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
436 strcpy(musicdriver, "null");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
437 strcpy(sounddriver, "null");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
438 strcpy(videodriver, "dedicated");
6878
385dce807566 (svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight <truelight@openttd.org>
parents: 6867
diff changeset
439 strcpy(blitter, "null");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
440 dedicated = true;
5885
e0a6ce7c45b8 (svn r8497) -Codechange: Increase the size of the sound/video/music-drivers to 32 bytes (instead of 16) so their actual parameters can be passed. Sound has for example 'bufsize' and 'hz'. Also use the recently introduced StrEmpty().
Darkvater <Darkvater@openttd.org>
parents: 5884
diff changeset
441 if (mgo.opt != NULL) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
442 /* Use the existing method for parsing (openttd -n).
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
443 * However, we do ignore the #company part. */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
444 const char *temp = NULL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
445 const char *port = NULL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
446 ParseConnectionString(&temp, &port, mgo.opt);
5885
e0a6ce7c45b8 (svn r8497) -Codechange: Increase the size of the sound/video/music-drivers to 32 bytes (instead of 16) so their actual parameters can be passed. Sound has for example 'bufsize' and 'hz'. Also use the recently introduced StrEmpty().
Darkvater <Darkvater@openttd.org>
parents: 5884
diff changeset
447 if (!StrEmpty(mgo.opt)) dedicated_host = mgo.opt;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
448 if (port != NULL) dedicated_port = atoi(port);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
449 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
450 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
451 case 'f': _dedicated_forks = true; break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
452 case 'n':
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
453 network = true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
454 network_conn = mgo.opt; // optional IP parameter, NULL if unset
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
455 break;
5959
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
456 case 'l':
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
457 debuglog_conn = mgo.opt;
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
458 break;
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
459 #endif /* ENABLE_NETWORK */
9533
176a9fe1018f (svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents: 9470
diff changeset
460 case 'r': ParseResolution(&resolution, mgo.opt); break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
461 case 't': startyear = atoi(mgo.opt); break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
462 case 'd': {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
463 #if defined(WIN32)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
464 CreateConsole();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
465 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
466 if (mgo.opt != NULL) SetDebugString(mgo.opt);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
467 } break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
468 case 'e': _switch_mode = SM_EDITOR; break;
10361
b822f913edb3 (svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents: 10360
diff changeset
469 case 'i':
b822f913edb3 (svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents: 10360
diff changeset
470 /* there is an argument, it is not empty, and it is exactly 1 char long */
b822f913edb3 (svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents: 10360
diff changeset
471 if (!StrEmpty(mgo.opt) && mgo.opt[1] == '\0') {
b822f913edb3 (svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents: 10360
diff changeset
472 _use_palette = (PaletteType)(mgo.opt[0] - '0');
b822f913edb3 (svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents: 10360
diff changeset
473 if (_use_palette <= MAX_PAL) break;
b822f913edb3 (svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents: 10360
diff changeset
474 }
b822f913edb3 (svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents: 10360
diff changeset
475 usererror("Valid value for '-i' is 0, 1 or 2");
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
476 case 'g':
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
477 if (mgo.opt != NULL) {
10310
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10299
diff changeset
478 strecpy(_file_to_saveload.name, mgo.opt, lastof(_file_to_saveload.name));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
479 _switch_mode = SM_LOAD;
9730
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
480 _file_to_saveload.mode = SL_LOAD;
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
481
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
482 /* if the file doesn't exist or it is not a valid savegame, let the saveload code show an error */
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
483 const char *t = strrchr(_file_to_saveload.name, '.');
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
484 if (t != NULL) {
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
485 FiosType ft = FiosGetSavegameListCallback(SLD_LOAD_GAME, _file_to_saveload.name, t, NULL);
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
486 if (ft != FIOS_TYPE_INVALID) SetFiosType(ft);
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
487 }
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
488
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
489 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
490 }
9730
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
491
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
492 _switch_mode = SM_NEWGAME;
10195
9f2f34f48a26 (svn r14408) -Fix (r9205): generation seed set using -G was always overwritten by -g
glx <glx@openttd.org>
parents: 10167
diff changeset
493 /* Give a random map if no seed has been given */
9f2f34f48a26 (svn r14408) -Fix (r9205): generation seed set using -G was always overwritten by -g
glx <glx@openttd.org>
parents: 10167
diff changeset
494 if (generation_seed == GENERATE_NEW_SEED) {
9f2f34f48a26 (svn r14408) -Fix (r9205): generation seed set using -G was always overwritten by -g
glx <glx@openttd.org>
parents: 10167
diff changeset
495 generation_seed = InteractiveRandom();
9f2f34f48a26 (svn r14408) -Fix (r9205): generation seed set using -G was always overwritten by -g
glx <glx@openttd.org>
parents: 10167
diff changeset
496 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
497 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
498 case 'G': generation_seed = atoi(mgo.opt); break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
499 case 'c': _config_file = strdup(mgo.opt); break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
500 case 'x': save_config = false; break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
501 case -2:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
502 case 'h':
9994
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
503 /* The next two functions are needed to list the graphics sets.
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
504 * We can't do them earlier because then we can't show it on
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
505 * the debug console as that hasn't been configured yet. */
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
506 DeterminePaths(argv[0]);
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
507 FindGraphicsSets();
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
508 ShowHelp();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
509 return 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
510 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
511 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
512
7408
53fa9a58449a (svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents: 7401
diff changeset
513 #if defined(WINCE) && defined(_DEBUG)
53fa9a58449a (svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents: 7401
diff changeset
514 /* Switch on debug lvl 4 for WinCE if Debug release, as you can't give params, and you most likely do want this information */
53fa9a58449a (svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents: 7401
diff changeset
515 SetDebugString("4");
53fa9a58449a (svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents: 7401
diff changeset
516 #endif
53fa9a58449a (svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents: 7401
diff changeset
517
6317
d5d3f3379eb0 (svn r9266) -Codechange: unify the retrieval of the base paths a little more.
rubidium <rubidium@openttd.org>
parents: 6309
diff changeset
518 DeterminePaths(argv[0]);
9994
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
519 FindGraphicsSets();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
520
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
521 #if defined(UNIX) && !defined(__MORPHOS__)
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
522 /* We must fork here, or we'll end up without some resources we need (like sockets) */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
523 if (_dedicated_forks)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
524 DedicatedFork();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
525 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
526
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
527 LoadFromConfig();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
528 CheckConfig();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
529 LoadFromHighScore();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
530
10037
83d0016c127e (svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents: 9994
diff changeset
531
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
532 /* override config? */
10310
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10299
diff changeset
533 if (!StrEmpty(graphics_set)) strecpy(_ini_graphics_set, graphics_set, lastof(_ini_graphics_set));
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10299
diff changeset
534 if (!StrEmpty(musicdriver)) strecpy(_ini_musicdriver, musicdriver, lastof(_ini_musicdriver));
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10299
diff changeset
535 if (!StrEmpty(sounddriver)) strecpy(_ini_sounddriver, sounddriver, lastof(_ini_sounddriver));
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10299
diff changeset
536 if (!StrEmpty(videodriver)) strecpy(_ini_videodriver, videodriver, lastof(_ini_videodriver));
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10299
diff changeset
537 if (!StrEmpty(blitter)) strecpy(_ini_blitter, blitter, lastof(_ini_blitter));
9533
176a9fe1018f (svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents: 9470
diff changeset
538 if (resolution.width != 0) { _cur_resolution = resolution; }
9354
2b0c6e62535e (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents: 9346
diff changeset
539 if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear;
2b0c6e62535e (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents: 9346
diff changeset
540 if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
541
6892
556994541424 (svn r10139) -Fix: all inner parts of OpenTTD assume that the resolution is at least 1 by 1, so force the resolution to be always at least 1 by 1.
rubidium <rubidium@openttd.org>
parents: 6878
diff changeset
542 /* The width and height must be at least 1 pixel, this
556994541424 (svn r10139) -Fix: all inner parts of OpenTTD assume that the resolution is at least 1 by 1, so force the resolution to be always at least 1 by 1.
rubidium <rubidium@openttd.org>
parents: 6878
diff changeset
543 * way all internal drawing routines work correctly. */
9533
176a9fe1018f (svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents: 9470
diff changeset
544 if (_cur_resolution.width <= 0) _cur_resolution.width = 1;
176a9fe1018f (svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents: 9470
diff changeset
545 if (_cur_resolution.height <= 0) _cur_resolution.height = 1;
6892
556994541424 (svn r10139) -Fix: all inner parts of OpenTTD assume that the resolution is at least 1 by 1, so force the resolution to be always at least 1 by 1.
rubidium <rubidium@openttd.org>
parents: 6878
diff changeset
546
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
547 #if defined(ENABLE_NETWORK)
9420
ec47ec544964 (svn r13334) -Codechange: move the network settings variables from network/network_internal to settings.
rubidium <rubidium@openttd.org>
parents: 9413
diff changeset
548 if (dedicated_host) snprintf(_settings_client.network.server_bind_ip, sizeof(_settings_client.network.server_bind_ip), "%s", dedicated_host);
ec47ec544964 (svn r13334) -Codechange: move the network settings variables from network/network_internal to settings.
rubidium <rubidium@openttd.org>
parents: 9413
diff changeset
549 if (dedicated_port) _settings_client.network.server_port = dedicated_port;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
550 if (_dedicated_forks && !dedicated) _dedicated_forks = false;
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
551 #endif /* ENABLE_NETWORK */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
552
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
553 /* enumerate language files */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
554 InitializeLanguagePacks();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
555
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
556 /* initialize screenshot formats */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
557 InitializeScreenshotFormats();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
558
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
559 /* initialize airport state machines */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
560 InitializeAirports();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
561
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
562 /* initialize all variables that are allocated dynamically */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
563 InitializeDynamicVariables();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
564
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
565 /* Sample catalogue */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
566 DEBUG(misc, 1, "Loading sound effects...");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
567 MxInitialize(11025);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
568 SoundInitialize("sample.cat");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
569
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
570 /* Initialize FreeType */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
571 InitFreeType();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
572
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
573 /* This must be done early, since functions use the InvalidateWindow* calls */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
574 InitWindowSystem();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
575
10037
83d0016c127e (svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents: 9994
diff changeset
576 if (!SetGraphicsSet(_ini_graphics_set)) {
83d0016c127e (svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents: 9994
diff changeset
577 StrEmpty(_ini_graphics_set) ?
9994
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
578 usererror("Failed to find a graphics set. Please acquire a graphics set for OpenTTD.") :
10037
83d0016c127e (svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
rubidium <rubidium@openttd.org>
parents: 9994
diff changeset
579 usererror("Failed to select requested graphics set '%s'", _ini_graphics_set);
9994
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
580 }
4687a554c837 (svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents: 9989
diff changeset
581
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
582 /* Initialize game palette */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
583 GfxInitPalettes();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
584
7567
5e3238300b22 (svn r11092) -Add: allow 'blitter=<value>' in openttd.cfg to set the blitter (so you don't have to keep on doing 'openttd -b 32bpp-optimized'..)
truelight <truelight@openttd.org>
parents: 7515
diff changeset
585 DEBUG(misc, 1, "Loading blitter...");
5e3238300b22 (svn r11092) -Add: allow 'blitter=<value>' in openttd.cfg to set the blitter (so you don't have to keep on doing 'openttd -b 32bpp-optimized'..)
truelight <truelight@openttd.org>
parents: 7515
diff changeset
586 if (BlitterFactoryBase::SelectBlitter(_ini_blitter) == NULL)
5e3238300b22 (svn r11092) -Add: allow 'blitter=<value>' in openttd.cfg to set the blitter (so you don't have to keep on doing 'openttd -b 32bpp-optimized'..)
truelight <truelight@openttd.org>
parents: 7515
diff changeset
587 StrEmpty(_ini_blitter) ?
9470
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
588 usererror("Failed to autoprobe blitter") :
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
589 usererror("Failed to select requested blitter '%s'; does it exist?", _ini_blitter);
7170
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
590
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
591 DEBUG(driver, 1, "Loading drivers...");
7170
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
592
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
593 _sound_driver = (SoundDriver*)SoundDriverFactoryBase::SelectDriver(_ini_sounddriver, Driver::DT_SOUND);
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
594 if (_sound_driver == NULL) {
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
595 StrEmpty(_ini_sounddriver) ?
9470
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
596 usererror("Failed to autoprobe sound driver") :
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
597 usererror("Failed to select requested sound driver '%s'", _ini_sounddriver);
7170
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
598 }
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
599
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
600 _music_driver = (MusicDriver*)MusicDriverFactoryBase::SelectDriver(_ini_musicdriver, Driver::DT_MUSIC);
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
601 if (_music_driver == NULL) {
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
602 StrEmpty(_ini_musicdriver) ?
9470
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
603 usererror("Failed to autoprobe music driver") :
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
604 usererror("Failed to select requested music driver '%s'", _ini_musicdriver);
7170
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
605 }
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
606
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
607 _video_driver = (VideoDriver*)VideoDriverFactoryBase::SelectDriver(_ini_videodriver, Driver::DT_VIDEO);
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
608 if (_video_driver == NULL) {
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
609 StrEmpty(_ini_videodriver) ?
9470
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
610 usererror("Failed to autoprobe video driver") :
47924a4b2ad4 (svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents: 9466
diff changeset
611 usererror("Failed to select requested video driver '%s'", _ini_videodriver);
7170
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
612 }
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
613
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
614 _savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING;
6654
860f3e5f70ec (svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight <truelight@openttd.org>
parents: 6643
diff changeset
615 /* Initialize the zoom level of the screen to normal */
860f3e5f70ec (svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight <truelight@openttd.org>
parents: 6643
diff changeset
616 _screen.zoom = ZOOM_LVL_NORMAL;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
617
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
618 /* restore saved music volume */
7170
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
619 _music_driver->SetVolume(msf.music_vol);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
620
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
621 NetworkStartUp(); // initialize network-core
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
622
5959
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
623 #if defined(ENABLE_NETWORK)
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
624 if (debuglog_conn != NULL && _network_available) {
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
625 const char *not_used = NULL;
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
626 const char *port = NULL;
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
627 uint16 rport;
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
628
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
629 rport = NETWORK_DEFAULT_DEBUGLOG_PORT;
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
630
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
631 ParseConnectionString(&not_used, &port, debuglog_conn);
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
632 if (port != NULL) rport = atoi(port);
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
633
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
634 NetworkStartDebugLog(debuglog_conn, rport);
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
635 }
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
636 #endif /* ENABLE_NETWORK */
a34cb5eb18ca (svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents: 5890
diff changeset
637
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
638 ScanNewGRFFiles();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
639
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
640 ResetGRFConfig(false);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
641
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
642 /* XXX - ugly hack, if diff_level is 9, it means we got no setting from the config file */
9358
12f4585b2124 (svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
643 if (_settings_newgame.difficulty.diff_level == 9) SetDifficultyLevel(0, &_settings_newgame.difficulty);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
644
9373
ab2633b3f053 (svn r13277) -Fix: opntitle 'jumping' to the temperate climate when closing the NewGRF settings window.
rubidium <rubidium@openttd.org>
parents: 9358
diff changeset
645 /* Make sure _settings is filled with _settings_newgame if we switch to a game directly */
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
646 if (_switch_mode != SM_NONE) _settings_game = _settings_newgame;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
647
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
648 /* initialize the ingame console */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
649 IConsoleInit();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
650 _cursor.in_window = true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
651 InitializeGUI();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
652 IConsoleCmdExec("exec scripts/autoexec.scr 0");
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
653
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
654 GenerateWorld(GW_EMPTY, 64, 64); // Make the viewport initialization happy
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
655 WaitTillGeneratedWorld();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
656
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
657 #ifdef ENABLE_NETWORK
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
658 if (network && _network_available) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
659 if (network_conn != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
660 const char *port = NULL;
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
661 const char *company = NULL;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
662 uint16 rport;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
663
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
664 rport = NETWORK_DEFAULT_PORT;
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
665 _network_playas = COMPANY_NEW_COMPANY;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
666
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
667 ParseConnectionString(&company, &port, network_conn);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
668
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
669 if (company != NULL) {
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
670 _network_playas = (CompanyID)atoi(company);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
671
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
672 if (_network_playas != COMPANY_SPECTATOR) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
673 _network_playas--;
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
674 if (_network_playas >= MAX_COMPANIES) return false;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
675 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
676 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
677 if (port != NULL) rport = atoi(port);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
678
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
679 LoadIntroGame();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
680 _switch_mode = SM_NONE;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
681 NetworkClientConnectGame(network_conn, rport);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
682 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
683 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
684 #endif /* ENABLE_NETWORK */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
685
7170
c6917d8e8c25 (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents: 7152
diff changeset
686 _video_driver->MainLoop();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
687
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
688 WaitTillSaved();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
689
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
690 /* only save config if we have to */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
691 if (save_config) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
692 SaveToConfig();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
693 SaveToHighScore();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
694 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
695
9159
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
696 /* Reset windowing system, stop drivers, free used memory, ... */
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
697 ShutdownGame();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
698
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
699 return 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
700 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
701
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
702 void HandleExitGameRequest()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
703 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
704 if (_game_mode == GM_MENU) { // do not ask to quit on the main screen
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
705 _exit_game = true;
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
706 } else if (_settings_client.gui.autosave_on_exit) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
707 DoExitSave();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
708 _exit_game = true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
709 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
710 AskExitGame();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
711 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
712 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
713
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
714 static void ShowScreenshotResult(bool b)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
715 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
716 if (b) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
717 SetDParamStr(0, _screenshot_name);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
718 ShowErrorMessage(INVALID_STRING_ID, STR_031B_SCREENSHOT_SUCCESSFULLY, 0, 0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
719 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
720 ShowErrorMessage(INVALID_STRING_ID, STR_031C_SCREENSHOT_FAILED, 0, 0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
721 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
722
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
723 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
724
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
725 static void MakeNewGameDone()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
726 {
9617
67791dec09fd (svn r13673) -Fix [FS#2122]: desync when building electrified trains on a dedicated server that was started with electrification disabled.
rubidium <rubidium@openttd.org>
parents: 9533
diff changeset
727 SettingsDisableElrail(_settings_game.vehicle.disable_elrails);
67791dec09fd (svn r13673) -Fix [FS#2122]: desync when building electrified trains on a dedicated server that was started with electrification disabled.
rubidium <rubidium@openttd.org>
parents: 9533
diff changeset
728
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
729 /* In a dedicated server, the server does not play */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
730 if (_network_dedicated) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
731 SetLocalCompany(COMPANY_SPECTATOR);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
732 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
733 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
734
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
735 /* Create a single company */
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
736 DoStartupNewCompany(false);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
737
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
738 SetLocalCompany(COMPANY_FIRST);
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
739 _current_company = _local_company;
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10489
diff changeset
740 DoCommandP(0, (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4, _settings_client.gui.autorenew_money, CMD_SET_AUTOREPLACE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
741
8809
6f39a645401a (svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents: 8790
diff changeset
742 InitializeRailGUI();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
743
8247
c0449b1df5e1 (svn r11811) -Fix: make compilation without networking work again (and thus move the debugdumpcommand stuff out of the network 'area').
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
744 #ifdef ENABLE_NETWORK
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
745 /* We are the server, we start a new company (not dedicated),
7998
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7981
diff changeset
746 * so set the default password *if* needed. */
9420
ec47ec544964 (svn r13334) -Codechange: move the network settings variables from network/network_internal to settings.
rubidium <rubidium@openttd.org>
parents: 9413
diff changeset
747 if (_network_server && !StrEmpty(_settings_client.network.default_company_pass)) {
ec47ec544964 (svn r13334) -Codechange: move the network settings variables from network/network_internal to settings.
rubidium <rubidium@openttd.org>
parents: 9413
diff changeset
748 char *password = _settings_client.network.default_company_pass;
7998
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7981
diff changeset
749 NetworkChangeCompanyPassword(1, &password);
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7981
diff changeset
750 }
8247
c0449b1df5e1 (svn r11811) -Fix: make compilation without networking work again (and thus move the debugdumpcommand stuff out of the network 'area').
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
751 #endif /* ENABLE_NETWORK */
7998
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7981
diff changeset
752
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
753 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
754 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
755
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
756 static void MakeNewGame(bool from_heightmap)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
757 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
758 _game_mode = GM_NORMAL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
759
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
760 ResetGRFConfig(true);
6629
188437dffcff (svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas <belugas@openttd.org>
parents: 6626
diff changeset
761 _house_mngr.ResetMapping();
7152
70c7afefcca5 (svn r10426) -Codechange: Activate the reset of industry/tiles mapping upon initialization or new game.
belugas <belugas@openttd.org>
parents: 7091
diff changeset
762 _industile_mngr.ResetMapping();
70c7afefcca5 (svn r10426) -Codechange: Activate the reset of industry/tiles mapping upon initialization or new game.
belugas <belugas@openttd.org>
parents: 7091
diff changeset
763 _industry_mngr.ResetMapping();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
764
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
765 GenerateWorldSetCallback(&MakeNewGameDone);
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
766 GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
767 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
768
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
769 static void MakeNewEditorWorldDone()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
770 {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
771 SetLocalCompany(OWNER_NONE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
772
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
773 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
774 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
775
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
776 static void MakeNewEditorWorld()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
777 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
778 _game_mode = GM_EDITOR;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
779
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
780 ResetGRFConfig(true);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
781
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
782 GenerateWorldSetCallback(&MakeNewEditorWorldDone);
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
783 GenerateWorld(GW_EMPTY, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
784 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
785
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
786 void StartupCompanies();
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
787 void StartupDisasters();
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
788 extern void StartupEconomy();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
789
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
790 /**
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
791 * Start Scenario starts a new game based on a scenario.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
792 * Eg 'New Game' --> select a preset scenario
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
793 * This starts a scenario based on your current difficulty settings
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
794 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
795 static void StartScenario()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
796 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
797 _game_mode = GM_NORMAL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
798
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
799 /* invalid type */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
800 if (_file_to_saveload.mode == SL_INVALID) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
801 DEBUG(sl, 0, "Savegame is obsolete or invalid format: '%s'", _file_to_saveload.name);
10489
071264f7160e (svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents: 10488
diff changeset
802 SetDParamStr(0, GetSaveLoadErrorString());
071264f7160e (svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents: 10488
diff changeset
803 ShowErrorMessage(INVALID_STRING_ID, STR_JUST_RAW_STRING, 0, 0);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
804 _game_mode = GM_MENU;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
805 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
806 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
807
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
808 /* Reinitialize windows */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
809 ResetWindowSystem();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
810
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
811 SetupColorsAndInitialWindow();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
812
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
813 ResetGRFConfig(true);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
814
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
815 /* Load game */
6929
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
816 if (SaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, SCENARIO_DIR) != SL_OK) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
817 LoadIntroGame();
10489
071264f7160e (svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents: 10488
diff changeset
818 SetDParamStr(0, GetSaveLoadErrorString());
071264f7160e (svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents: 10488
diff changeset
819 ShowErrorMessage(INVALID_STRING_ID, STR_JUST_RAW_STRING, 0, 0);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
820 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
821
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
822 _settings_game.difficulty = _settings_newgame.difficulty;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
823
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
824 /* Inititalize data */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
825 StartupEconomy();
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
826 StartupCompanies();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
827 StartupEngines();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
828 StartupDisasters();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
829
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
830 SetLocalCompany(COMPANY_FIRST);
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
831 _current_company = _local_company;
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10489
diff changeset
832 DoCommandP(0, (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4, _settings_client.gui.autorenew_money, CMD_SET_AUTOREPLACE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
833
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
834 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
835 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
836
6929
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
837 /** Load the specified savegame but on error do different things.
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
838 * If loading fails due to corrupt savegame, bad version, etc. go back to
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
839 * a previous correct state. In the menu for example load the intro game again.
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
840 * @param filename file to be loaded
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
841 * @param mode mode of loading, either SL_LOAD or SL_OLD_LOAD
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
842 * @param newgm switch to this mode of loading fails due to some unknown error
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
843 * @param subdir default directory to look for filename, set to 0 if not needed
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
844 */
6929
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
845 bool SafeSaveOrLoad(const char *filename, int mode, int newgm, Subdirectory subdir)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
846 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
847 byte ogm = _game_mode;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
848
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
849 _game_mode = newgm;
6929
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
850 assert(mode == SL_LOAD || mode == SL_OLD_LOAD);
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
851 switch (SaveOrLoad(filename, mode, subdir)) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
852 case SL_OK: return true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
853
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
854 case SL_REINIT:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
855 switch (ogm) {
8619
4cf1201e6f50 (svn r12202) -Fix: When loading a savegame fails, don't start creating a new game, just go straight back to the intro screen.
peter1138 <peter1138@openttd.org>
parents: 8613
diff changeset
856 default:
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
857 case GM_MENU: LoadIntroGame(); break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
858 case GM_EDITOR: MakeNewEditorWorld(); break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
859 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
860 return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
861
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
862 default:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
863 _game_mode = ogm;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
864 return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
865 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
866 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
867
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
868 void SwitchMode(int new_mode)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
869 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
870 #ifdef ENABLE_NETWORK
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
871 /* If we are saving something, the network stays in his current state */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
872 if (new_mode != SM_SAVE) {
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
873 /* If the network is active, make it not-active */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
874 if (_networking) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
875 if (_network_server && (new_mode == SM_LOAD || new_mode == SM_NEWGAME)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
876 NetworkReboot();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
877 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
878 NetworkDisconnect();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
879 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
880 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
881
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
882 /* If we are a server, we restart the server */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
883 if (_is_network_server) {
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
884 /* But not if we are going to the menu */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
885 if (new_mode != SM_MENU) {
8265
bfae01b80d25 (svn r11829) -Feature: allow reloading openttd.cfg when starting a new game on a dedicated server. Patch by dihedral.
rubidium <rubidium@openttd.org>
parents: 8264
diff changeset
886 /* check if we should reload the config */
9420
ec47ec544964 (svn r13334) -Codechange: move the network settings variables from network/network_internal to settings.
rubidium <rubidium@openttd.org>
parents: 9413
diff changeset
887 if (_settings_client.network.reload_cfg) {
8265
bfae01b80d25 (svn r11829) -Feature: allow reloading openttd.cfg when starting a new game on a dedicated server. Patch by dihedral.
rubidium <rubidium@openttd.org>
parents: 8264
diff changeset
888 LoadFromConfig();
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
889 _settings_game = _settings_newgame;
8265
bfae01b80d25 (svn r11829) -Feature: allow reloading openttd.cfg when starting a new game on a dedicated server. Patch by dihedral.
rubidium <rubidium@openttd.org>
parents: 8264
diff changeset
890 ResetGRFConfig(false);
bfae01b80d25 (svn r11829) -Feature: allow reloading openttd.cfg when starting a new game on a dedicated server. Patch by dihedral.
rubidium <rubidium@openttd.org>
parents: 8264
diff changeset
891 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
892 NetworkServerStart();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
893 } else {
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
894 /* This client no longer wants to be a network-server */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
895 _is_network_server = false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
896 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
897 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
898 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
899 #endif /* ENABLE_NETWORK */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
900
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
901 switch (new_mode) {
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
902 case SM_EDITOR: /* Switch to scenario editor */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
903 MakeNewEditorWorld();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
904 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
905
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
906 case SM_NEWGAME: /* New Game --> 'Random game' */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
907 #ifdef ENABLE_NETWORK
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
908 if (_network_server) {
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
909 snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "Random Map");
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
910 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
911 #endif /* ENABLE_NETWORK */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
912 MakeNewGame(false);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
913 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
914
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
915 case SM_START_SCENARIO: /* New Game --> Choose one of the preset scenarios */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
916 #ifdef ENABLE_NETWORK
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
917 if (_network_server) {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
918 snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Loaded scenario)", _file_to_saveload.title);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
919 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
920 #endif /* ENABLE_NETWORK */
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
921 StartScenario();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
922 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
923
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
924 case SM_LOAD: { /* Load game, Play Scenario */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
925 ResetGRFConfig(true);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
926 ResetWindowSystem();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
927
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
928 if (!SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_NORMAL, NO_DIRECTORY)) {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
929 LoadIntroGame();
10489
071264f7160e (svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents: 10488
diff changeset
930 SetDParamStr(0, GetSaveLoadErrorString());
071264f7160e (svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents: 10488
diff changeset
931 ShowErrorMessage(INVALID_STRING_ID, STR_JUST_RAW_STRING, 0, 0);
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
932 } else {
9089
0fdd16c9c709 (svn r12948) -Fix [FS#1982]: all vehicles would be available when an original scenario would be played.
rubidium <rubidium@openttd.org>
parents: 9085
diff changeset
933 if (_saveload_mode == SLD_LOAD_SCENARIO) {
0fdd16c9c709 (svn r12948) -Fix [FS#1982]: all vehicles would be available when an original scenario would be played.
rubidium <rubidium@openttd.org>
parents: 9085
diff changeset
934 StartupEngines();
0fdd16c9c709 (svn r12948) -Fix [FS#1982]: all vehicles would be available when an original scenario would be played.
rubidium <rubidium@openttd.org>
parents: 9085
diff changeset
935 }
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
936 /* Update the local company for a loaded game. It is either always
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
937 * company #1 (eg 0) or in the case of a dedicated server a spectator */
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
938 SetLocalCompany(_network_dedicated ? COMPANY_SPECTATOR : COMPANY_FIRST);
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
939 /* Decrease pause counter (was increased from opening load dialog) */
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10489
diff changeset
940 DoCommandP(0, 0, 0, CMD_PAUSE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
941 #ifdef ENABLE_NETWORK
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
942 if (_network_server) {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
943 snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Loaded game)", _file_to_saveload.title);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
944 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
945 #endif /* ENABLE_NETWORK */
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
946 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
947 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
948 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
949
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
950 case SM_START_HEIGHTMAP: /* Load a heightmap and start a new game from it */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
951 #ifdef ENABLE_NETWORK
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
952 if (_network_server) {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
953 snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Heightmap)", _file_to_saveload.title);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
954 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
955 #endif /* ENABLE_NETWORK */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
956 MakeNewGame(true);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
957 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
958
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
959 case SM_LOAD_HEIGHTMAP: /* Load heightmap from scenario editor */
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
960 SetLocalCompany(OWNER_NONE);
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
961
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
962 GenerateWorld(GW_HEIGHTMAP, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
963 MarkWholeScreenDirty();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
964 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
965
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
966 case SM_LOAD_SCENARIO: { /* Load scenario from scenario editor */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
967 if (SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_EDITOR, NO_DIRECTORY)) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
968 SetLocalCompany(OWNER_NONE);
9354
2b0c6e62535e (svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents: 9346
diff changeset
969 _settings_newgame.game_creation.starting_year = _cur_year;
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
970 } else {
10489
071264f7160e (svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents: 10488
diff changeset
971 SetDParamStr(0, GetSaveLoadErrorString());
071264f7160e (svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents: 10488
diff changeset
972 ShowErrorMessage(INVALID_STRING_ID, STR_JUST_RAW_STRING, 0, 0);
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
973 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
974 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
975 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
976
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
977 case SM_MENU: /* Switch to game intro menu */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
978 LoadIntroGame();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
979 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
980
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
981 case SM_SAVE: /* Save game */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
982 /* Make network saved games on pause compatible to singleplayer */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
983 if (_networking && _pause_game == 1) _pause_game = 2;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
984 if (SaveOrLoad(_file_to_saveload.name, SL_SAVE, NO_DIRECTORY) != SL_OK) {
10489
071264f7160e (svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents: 10488
diff changeset
985 SetDParamStr(0, GetSaveLoadErrorString());
071264f7160e (svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents: 10488
diff changeset
986 ShowErrorMessage(INVALID_STRING_ID, STR_JUST_RAW_STRING, 0, 0);
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
987 } else {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
988 DeleteWindowById(WC_SAVELOAD, 0);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
989 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
990 if (_networking && _pause_game == 2) _pause_game = 1;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
991 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
992
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
993 case SM_GENRANDLAND: /* Generate random land within scenario editor */
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
994 SetLocalCompany(OWNER_NONE);
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
995 GenerateWorld(GW_RANDOM, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
996 /* XXX: set date */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
997 MarkWholeScreenDirty();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
998 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
999 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1000
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1001 if (_switch_mode_errorstr != INVALID_STRING_ID) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1002 ShowErrorMessage(INVALID_STRING_ID, _switch_mode_errorstr, 0, 0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1003 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1004 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1005
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1006
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1007 /**
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1008 * State controlling game loop.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1009 * The state must not be changed from anywhere but here.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1010 * That check is enforced in DoCommand.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1011 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1012 void StateGameLoop()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1013 {
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1014 /* dont execute the state loop during pause */
8179
a0879dc1b54d (svn r11742) -Codechange [FS#1319]: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused.
peter1138 <peter1138@openttd.org>
parents: 8172
diff changeset
1015 if (_pause_game) {
a0879dc1b54d (svn r11742) -Codechange [FS#1319]: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused.
peter1138 <peter1138@openttd.org>
parents: 8172
diff changeset
1016 CallWindowTickEvent();
a0879dc1b54d (svn r11742) -Codechange [FS#1319]: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused.
peter1138 <peter1138@openttd.org>
parents: 8172
diff changeset
1017 return;
a0879dc1b54d (svn r11742) -Codechange [FS#1319]: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused.
peter1138 <peter1138@openttd.org>
parents: 8172
diff changeset
1018 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1019 if (IsGeneratingWorld()) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1020
8303
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1021 ClearStorageChanges(false);
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1022
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1023 if (_game_mode == GM_EDITOR) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1024 RunTileLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1025 CallVehicleTicks();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1026 CallLandscapeTick();
8303
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1027 ClearStorageChanges(true);
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1028
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1029 CallWindowTickEvent();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1030 NewsLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1031 } else {
10515
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1032 if (_debug_desync_level > 1) {
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1033 Vehicle *v;
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1034 FOR_ALL_VEHICLES(v) {
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1035 if (v != v->First()) continue;
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1036
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1037 switch (v->type) {
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1038 case VEH_ROAD: {
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1039 extern byte GetRoadVehLength(const Vehicle *v);
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1040 if (GetRoadVehLength(v) != v->u.road.cached_veh_length) {
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1041 DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i\n", v->index, (int)v->owner, v->unitnumber);
9039
54d5d16c50c5 (svn r12858) -Add: small piece of code that can help hunting desyncs. Has to be enabled by --enable-desync-debug=1 though.
rubidium <rubidium@openttd.org>
parents: 9029
diff changeset
1042 }
10515
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1043 } break;
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1044
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1045 case VEH_TRAIN: {
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1046 uint length = 0;
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1047 for (Vehicle *u = v; u != NULL; u = u->Next()) length++;
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1048
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1049 VehicleRail *wagons = MallocT<VehicleRail>(length);
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1050 length = 0;
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1051 for (Vehicle *u = v; u != NULL; u = u->Next()) wagons[length++] = u->u.rail;
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1052
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1053 TrainConsistChanged(v, true);
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1054
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1055 length = 0;
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1056 for (Vehicle *u = v; u != NULL; u = u->Next()) {
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1057 if (memcmp(&wagons[length], &u->u.rail, sizeof(VehicleRail)) != 0) {
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1058 DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i, wagon %i\n", v->index, (int)v->owner, v->unitnumber, length);
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1059 }
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1060 length++;
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1061 }
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1062
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1063 free(wagons);
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1064 } break;
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1065
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1066 case VEH_AIRCRAFT: {
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1067 uint speed = v->u.air.cached_max_speed;
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1068 UpdateAircraftCache(v);
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1069 if (speed != v->u.air.cached_max_speed) {
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1070 DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i\n", v->index, (int)v->owner, v->unitnumber);
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1071 }
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1072 } break;
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1073
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1074 default:
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1075 break;
7156262cf0c9 (svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
1076 }
9039
54d5d16c50c5 (svn r12858) -Add: small piece of code that can help hunting desyncs. Has to be enabled by --enable-desync-debug=1 though.
rubidium <rubidium@openttd.org>
parents: 9029
diff changeset
1077 }
54d5d16c50c5 (svn r12858) -Add: small piece of code that can help hunting desyncs. Has to be enabled by --enable-desync-debug=1 though.
rubidium <rubidium@openttd.org>
parents: 9029
diff changeset
1078 }
54d5d16c50c5 (svn r12858) -Add: small piece of code that can help hunting desyncs. Has to be enabled by --enable-desync-debug=1 though.
rubidium <rubidium@openttd.org>
parents: 9029
diff changeset
1079
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1080 /* All these actions has to be done from OWNER_NONE
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1081 * for multiplayer compatibility */
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1082 CompanyID old_company = _current_company;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1083 _current_company = OWNER_NONE;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1084
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1085 AnimateAnimatedTiles();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1086 IncreaseDate();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1087 RunTileLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1088 CallVehicleTicks();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1089 CallLandscapeTick();
8303
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1090 ClearStorageChanges(true);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1091
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1092 AI_RunGameLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1093
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1094 CallWindowTickEvent();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1095 NewsLoop();
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1096 _current_company = old_company;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1097 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1098 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1099
6929
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
1100 /** Create an autosave. The default name is "autosave#.sav". However with
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
1101 * the patch setting 'keep_all_autosave' the name defaults to company-name + date */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1102 static void DoAutosave()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1103 {
6929
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
1104 char buf[MAX_PATH];
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1105
5977
03f33d102c56 (svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight <truelight@openttd.org>
parents: 5959
diff changeset
1106 #if defined(PSP)
03f33d102c56 (svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight <truelight@openttd.org>
parents: 5959
diff changeset
1107 /* Autosaving in networking is too time expensive for the PSP */
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1108 if (_networking) return;
5977
03f33d102c56 (svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight <truelight@openttd.org>
parents: 5959
diff changeset
1109 #endif /* PSP */
03f33d102c56 (svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight <truelight@openttd.org>
parents: 5959
diff changeset
1110
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1111 if (_settings_client.gui.keep_all_autosave && _local_company != COMPANY_SPECTATOR) {
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1112 SetDParam(0, _local_company);
7058
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7036
diff changeset
1113 SetDParam(1, _date);
6929
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
1114 GetString(buf, STR_4004, lastof(buf));
10310
5cefbb1c3fd7 (svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents: 10299
diff changeset
1115 strecat(buf, ".sav", lastof(buf));
6929
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
1116 } else {
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
1117 /* generate a savegame name and number according to _settings_client.gui.max_num_autosaves */
6929
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
1118 snprintf(buf, sizeof(buf), "autosave%d.sav", _autosave_ctr);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1119
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
1120 if (++_autosave_ctr >= _settings_client.gui.max_num_autosaves) _autosave_ctr = 0;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1121 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1122
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1123 DEBUG(sl, 2, "Autosaving to '%s'", buf);
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1124 if (SaveOrLoad(buf, SL_SAVE, AUTOSAVE_DIR) != SL_OK) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1125 ShowErrorMessage(INVALID_STRING_ID, STR_AUTOSAVE_FAILED, 0, 0);
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1126 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1127 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1128
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1129 void GameLoop()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1130 {
8989
4ecc117ebb22 (svn r12784) -Codechange: handle the asynchronious save 'handlers' in saveload.cpp instead of openttd.cpp.
rubidium <rubidium@openttd.org>
parents: 8987
diff changeset
1131 ProcessAsyncSaveFinish();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1132
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1133 /* autosave game? */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1134 if (_do_autosave) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1135 _do_autosave = false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1136 DoAutosave();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1137 RedrawAutosave();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1138 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1139
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1140 /* make a screenshot? */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1141 if (IsScreenshotRequested()) ShowScreenshotResult(MakeScreenshot());
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1142
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1143 /* switch game mode? */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1144 if (_switch_mode != SM_NONE) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1145 SwitchMode(_switch_mode);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1146 _switch_mode = SM_NONE;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1147 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1148
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1149 IncreaseSpriteLRU();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1150 InteractiveRandom();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1151
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1152 _caret_timer += 3;
7018
a05bbdc788a2 (svn r10276) -Codechange: made a counter based on milliseconds and independent of the game-state to base double-click and TGP Generation Process on
truelight <truelight@openttd.org>
parents: 7012
diff changeset
1153 _palette_animation_counter += 8;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1154 CursorTick();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1155
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1156 #ifdef ENABLE_NETWORK
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1157 /* Check for UDP stuff */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1158 if (_network_available) NetworkUDPGameLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1159
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1160 if (_networking && !IsGeneratingWorld()) {
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1161 /* Multiplayer */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1162 NetworkGameLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1163 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1164 if (_network_reconnect > 0 && --_network_reconnect == 0) {
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1165 /* This means that we want to reconnect to the last host
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1166 * We do this here, because it means that the network is really closed */
9420
ec47ec544964 (svn r13334) -Codechange: move the network settings variables from network/network_internal to settings.
rubidium <rubidium@openttd.org>
parents: 9413
diff changeset
1167 NetworkClientConnectGame(_settings_client.network.last_host, _settings_client.network.last_port);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1168 }
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1169 /* Singleplayer */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1170 StateGameLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1171 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1172 #else
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1173 StateGameLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1174 #endif /* ENABLE_NETWORK */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1175
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7922
diff changeset
1176 if (!_pause_game && HasBit(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1177
6231
a4e11dd2d7c6 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight <truelight@openttd.org>
parents: 6229
diff changeset
1178 if (!_pause_game || _cheats.build_in_pause.value) MoveAllTextEffects();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1179
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1180 InputLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1181
10380
1bd9537f246c (svn r14631) -Add: support for Allegro as sound backend.
rubidium <rubidium@openttd.org>
parents: 10361
diff changeset
1182 _sound_driver->MainLoop();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1183 MusicLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1184 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1185
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1186 static void ConvertTownOwner()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1187 {
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1188 for (TileIndex tile = 0; tile != MapSize(); tile++) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1189 switch (GetTileType(tile)) {
7370
fba35a9abf79 (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium <rubidium@openttd.org>
parents: 7272
diff changeset
1190 case MP_ROAD:
10167
8d40f7671148 (svn r14359) -Fix [FS#2311]: the ownership of roadtiles was not properly set for very old savegames (including TTD's) making it impossible to remove some pieces of road.
rubidium <rubidium@openttd.org>
parents: 10158
diff changeset
1191 if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HasBit(_m[tile].m3, 7)) {
8d40f7671148 (svn r14359) -Fix [FS#2311]: the ownership of roadtiles was not properly set for very old savegames (including TTD's) making it impossible to remove some pieces of road.
rubidium <rubidium@openttd.org>
parents: 10158
diff changeset
1192 _m[tile].m3 = OWNER_TOWN;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1193 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1194 /* FALLTHROUGH */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1195
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1196 case MP_TUNNELBRIDGE:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1197 if (GetTileOwner(tile) & 0x80) SetTileOwner(tile, OWNER_TOWN);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1198 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1199
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1200 default: break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1201 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1202 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1203 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1204
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1205 /* since savegame version 4.1, exclusive transport rights are stored at towns */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1206 static void UpdateExclusiveRights()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1207 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1208 Town *t;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1209
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1210 FOR_ALL_TOWNS(t) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1211 t->exclusivity = INVALID_COMPANY;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1212 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1213
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1214 /* FIXME old exclusive rights status is not being imported (stored in s->blocked_months_obsolete)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1215 * could be implemented this way:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1216 * 1.) Go through all stations
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1217 * Build an array town_blocked[ town_id ][ company_id ]
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1218 * that stores if at least one station in that town is blocked for a company
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1219 * 2.) Go through that array, if you find a town that is not blocked for
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1220 * one company, but for all others, then give him exclusivity.
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1221 */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1222 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1223
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1224 static const byte convert_currency[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1225 0, 1, 12, 8, 3,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1226 10, 14, 19, 4, 5,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1227 9, 11, 13, 6, 17,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1228 16, 22, 21, 7, 15,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1229 18, 2, 20, };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1230
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1231 /* since savegame version 4.2 the currencies are arranged differently */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1232 static void UpdateCurrencies()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1233 {
9466
f81fe8c0065a (svn r13386) -Fix: global currency/units setting being overriden when loading a savegame.
rubidium <rubidium@openttd.org>
parents: 9457
diff changeset
1234 _settings_game.locale.currency = convert_currency[_settings_game.locale.currency];
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1235 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1236
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1237 /* Up to revision 1413 the invisible tiles at the southern border have not been
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1238 * MP_VOID, even though they should have. This is fixed by this function
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1239 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1240 static void UpdateVoidTiles()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1241 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1242 uint i;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1243
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1244 for (i = 0; i < MapMaxY(); ++i) MakeVoid(i * MapSizeX() + MapMaxX());
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1245 for (i = 0; i < MapSizeX(); ++i) MakeVoid(MapSizeX() * MapMaxY() + i);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1246 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1247
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1248 /* since savegame version 6.0 each sign has an "owner", signs without owner (from old games are set to 255) */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1249 static void UpdateSignOwner()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1250 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1251 Sign *si;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1252
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1253 FOR_ALL_SIGNS(si) si->owner = OWNER_NONE;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1254 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1255
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1256 extern void UpdateOldAircraft();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1257
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1258
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1259 static inline RailType UpdateRailType(RailType rt, RailType min)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1260 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1261 return rt >= min ? (RailType)(rt + 1): rt;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1262 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1263
7981
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1264 /**
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1265 * Initialization of the windows and several kinds of caches.
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1266 * This is not done directly in AfterLoadGame because these
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1267 * functions require that all saveload conversions have been
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1268 * done. As people tend to add savegame conversion stuff after
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1269 * the intialization of the windows and caches quite some bugs
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1270 * had been made.
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1271 * Moving this out of there is both cleaner and less bug-prone.
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1272 *
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1273 * @return true if everything went according to plan, otherwise false.
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1274 */
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1275 static bool InitializeWindowsAndCaches()
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1276 {
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1277 /* Initialize windows */
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1278 ResetWindowSystem();
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1279 SetupColorsAndInitialWindow();
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1280
9410
e34aea18d211 (svn r13321) -Codechange: move some GUI/viewport related functions out op openttd.cpp to viewport.cpp/window.cpp.
rubidium <rubidium@openttd.org>
parents: 9387
diff changeset
1281 extern void ResetViewportAfterLoadGame();
e34aea18d211 (svn r13321) -Codechange: move some GUI/viewport related functions out op openttd.cpp to viewport.cpp/window.cpp.
rubidium <rubidium@openttd.org>
parents: 9387
diff changeset
1282 ResetViewportAfterLoadGame();
7981
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1283
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1284 /* Update coordinates of the signs. */
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1285 UpdateAllStationVirtCoord();
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1286 UpdateAllSignVirtCoords();
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1287 UpdateAllTownVirtCoords();
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1288 UpdateAllWaypointSigns();
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1289
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1290 Company *c;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1291 FOR_ALL_COMPANIES(c) {
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1292 /* For each company, verify (while loading a scenario) that the inauguration date is the current year and set it
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1293 * accordingly if it is not the case. No need to set it on companies that are not been used already,
9211
30076ddd1741 (svn r13077) -Codechange: move function that updates cached num_engines to engine.cpp, make it run only 1 loop
smatz <smatz@openttd.org>
parents: 9200
diff changeset
1294 * thus the MIN_YEAR (which is really nothing more than Zero, initialized value) test */
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1295 if (_file_to_saveload.filetype == FT_SCENARIO && c->inaugurated_year != MIN_YEAR) {
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1296 c->inaugurated_year = _cur_year;
7981
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1297 }
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1298 }
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1299
9211
30076ddd1741 (svn r13077) -Codechange: move function that updates cached num_engines to engine.cpp, make it run only 1 loop
smatz <smatz@openttd.org>
parents: 9200
diff changeset
1300 SetCachedEngineCounts();
7981
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1301
9334
3945a8340531 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas <belugas@openttd.org>
parents: 9306
diff changeset
1302 /* Towns have a noise controlled number of airports system
3945a8340531 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas <belugas@openttd.org>
parents: 9306
diff changeset
1303 * So each airport's noise value must be added to the town->noise_reached value
3945a8340531 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas <belugas@openttd.org>
parents: 9306
diff changeset
1304 * Reset each town's noise_reached value to '0' before. */
3945a8340531 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas <belugas@openttd.org>
parents: 9306
diff changeset
1305 UpdateAirportsNoise();
3945a8340531 (svn r13226) -Feature: Allow to have more than only two airports per town. The number of airports is now controlled by the noise each of them generates, the distance from town's center and how tolerant the town is.
belugas <belugas@openttd.org>
parents: 9306
diff changeset
1306
9704
e1476334067a (svn r13816) -Fix [FS#2150]: check for vehicle length changes outside a depot (callback 0x11) and give a warning about that
smatz <smatz@openttd.org>
parents: 9667
diff changeset
1307 CheckTrainsLengths();
e1476334067a (svn r13816) -Fix [FS#2150]: check for vehicle length changes outside a depot (callback 0x11) and give a warning about that
smatz <smatz@openttd.org>
parents: 9667
diff changeset
1308
7981
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1309 return true;
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1310 }
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
1311
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1312 bool AfterLoadGame()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1313 {
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1314 TileIndex map_size = MapSize();
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1315 Company *c;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1316
9457
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9429
diff changeset
1317 if (CheckSavegameVersion(98)) GamelogOldver();
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9429
diff changeset
1318
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9429
diff changeset
1319 GamelogTestRevision();
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9429
diff changeset
1320 GamelogTestMode();
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9429
diff changeset
1321
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9429
diff changeset
1322 if (CheckSavegameVersion(98)) GamelogGRFAddList(_grfconfig);
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9429
diff changeset
1323
10445
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1324 /* in very old versions, size of train stations was stored differently */
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1325 if (CheckSavegameVersion(2)) {
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1326 Station *st;
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1327 FOR_ALL_STATIONS(st) {
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1328 if (st->train_tile != 0 && st->trainst_h == 0) {
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1329 extern SavegameType _savegame_type;
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1330 uint n = _savegame_type == SGT_OTTD ? 4 : 3; // OTTD uses 4 bits per dimensions, TTD 3 bits
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1331 uint w = GB(st->trainst_w, n, n);
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1332 uint h = GB(st->trainst_w, 0, n);
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1333
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1334 if (GetRailStationAxis(st->train_tile) != AXIS_X) Swap(w, h);
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1335
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1336 st->trainst_w = w;
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1337 st->trainst_h = h;
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1338
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1339 assert(GetStationIndex(st->train_tile + TileDiffXY(w - 1, h - 1)) == st->index);
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1340 }
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1341 }
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1342 }
642c4c52707d (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
smatz <smatz@openttd.org>
parents: 10429
diff changeset
1343
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1344 /* in version 2.1 of the savegame, town owner was unified. */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1345 if (CheckSavegameVersionOldStyle(2, 1)) ConvertTownOwner();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1346
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1347 /* from version 4.1 of the savegame, exclusive rights are stored at towns */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1348 if (CheckSavegameVersionOldStyle(4, 1)) UpdateExclusiveRights();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1349
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1350 /* from version 4.2 of the savegame, currencies are in a different order */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1351 if (CheckSavegameVersionOldStyle(4, 2)) UpdateCurrencies();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1352
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1353 /* from version 6.1 of the savegame, signs have an "owner" */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1354 if (CheckSavegameVersionOldStyle(6, 1)) UpdateSignOwner();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1355
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1356 /* In old version there seems to be a problem that water is owned by
8707
64bd5cfc6426 (svn r12381) -Fix [FS1835] [FS1535] (r11855): The number of houses wasn't computed right. A few other things regaring the updating had to be changed. Big thanks for support to frosch123 and SmatZ, to name just a few. (Inspired by a patch of bilbo)
skidd13 <skidd13@openttd.org>
parents: 8681
diff changeset
1357 * OWNER_NONE, not OWNER_WATER.. I can't replicate it for the current
64bd5cfc6426 (svn r12381) -Fix [FS1835] [FS1535] (r11855): The number of houses wasn't computed right. A few other things regaring the updating had to be changed. Big thanks for support to frosch123 and SmatZ, to name just a few. (Inspired by a patch of bilbo)
skidd13 <skidd13@openttd.org>
parents: 8681
diff changeset
1358 * (4.3) version, so I just check when versions are older, and then
64bd5cfc6426 (svn r12381) -Fix [FS1835] [FS1535] (r11855): The number of houses wasn't computed right. A few other things regaring the updating had to be changed. Big thanks for support to frosch123 and SmatZ, to name just a few. (Inspired by a patch of bilbo)
skidd13 <skidd13@openttd.org>
parents: 8681
diff changeset
1359 * walk through the whole map.. */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1360 if (CheckSavegameVersionOldStyle(4, 3)) {
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1361 for (TileIndex t = 0; t < map_size; t++) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1362 if (IsTileType(t, MP_WATER) && GetTileOwner(t) >= MAX_COMPANIES) {
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1363 SetTileOwner(t, OWNER_WATER);
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1364 }
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1365 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1366 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1367
8258
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1368 if (CheckSavegameVersion(84)) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1369 FOR_ALL_COMPANIES(c) {
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1370 c->name = CopyFromOldName(c->name_1);
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1371 if (c->name != NULL) c->name_1 = STR_SV_UNNAMED;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1372 c->president_name = CopyFromOldName(c->president_name_1);
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1373 if (c->president_name != NULL) c->president_name_1 = SPECSTR_PRESIDENT_NAME;
8258
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1374 }
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1375
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1376 Station *st;
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1377 FOR_ALL_STATIONS(st) {
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1378 st->name = CopyFromOldName(st->string_id);
10150
dabc02761232 (svn r14336) -Fix (r14334): when there was a station with custom name in an old savegame, it's default name was empty
smatz <smatz@openttd.org>
parents: 10106
diff changeset
1379 /* generating new name would be too much work for little effect, use the station name fallback */
dabc02761232 (svn r14336) -Fix (r14334): when there was a station with custom name in an old savegame, it's default name was empty
smatz <smatz@openttd.org>
parents: 10106
diff changeset
1380 if (st->name != NULL) st->string_id = STR_SV_STNAME_FALLBACK;
8258
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1381 }
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1382
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1383 Town *t;
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1384 FOR_ALL_TOWNS(t) {
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1385 t->name = CopyFromOldName(t->townnametype);
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
1386 if (t->name != NULL) t->townnametype = SPECSTR_TOWNNAME_START + _settings_game.game_creation.town_name;
8258
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1387 }
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1388
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1389 Waypoint *wp;
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1390 FOR_ALL_WAYPOINTS(wp) {
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1391 wp->name = CopyFromOldName(wp->string);
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1392 wp->string = STR_EMPTY;
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1393 }
10153
630fa8449fc4 (svn r14340) -Fix (r11822): signs from old savegames were lost (causing little memory leaks)
smatz <smatz@openttd.org>
parents: 10152
diff changeset
1394
630fa8449fc4 (svn r14340) -Fix (r11822): signs from old savegames were lost (causing little memory leaks)
smatz <smatz@openttd.org>
parents: 10152
diff changeset
1395 for (uint i = 0; i < GetSignPoolSize(); i++) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1396 /* invalid signs are determined by si->ower == INVALID_COMPANY now */
10153
630fa8449fc4 (svn r14340) -Fix (r11822): signs from old savegames were lost (causing little memory leaks)
smatz <smatz@openttd.org>
parents: 10152
diff changeset
1397 Sign *si = GetSign(i);
630fa8449fc4 (svn r14340) -Fix (r11822): signs from old savegames were lost (causing little memory leaks)
smatz <smatz@openttd.org>
parents: 10152
diff changeset
1398 if (!si->IsValid() && si->name != NULL) {
630fa8449fc4 (svn r14340) -Fix (r11822): signs from old savegames were lost (causing little memory leaks)
smatz <smatz@openttd.org>
parents: 10152
diff changeset
1399 si->owner = OWNER_NONE;
630fa8449fc4 (svn r14340) -Fix (r11822): signs from old savegames were lost (causing little memory leaks)
smatz <smatz@openttd.org>
parents: 10152
diff changeset
1400 }
630fa8449fc4 (svn r14340) -Fix (r11822): signs from old savegames were lost (causing little memory leaks)
smatz <smatz@openttd.org>
parents: 10152
diff changeset
1401 }
8258
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1402 }
6017c5ebeb7e (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents: 8254
diff changeset
1403
8987
7901d37c4329 (svn r12782) -Codechange: remove some functions from functions.h and do not statically 'waste' memory when the old name array is not needed anymore.
rubidium <rubidium@openttd.org>
parents: 8985
diff changeset
1404 /* From this point the old names array is cleared. */
7901d37c4329 (svn r12782) -Codechange: remove some functions from functions.h and do not statically 'waste' memory when the old name array is not needed anymore.
rubidium <rubidium@openttd.org>
parents: 8985
diff changeset
1405 ResetOldNames();
7901d37c4329 (svn r12782) -Codechange: remove some functions from functions.h and do not statically 'waste' memory when the old name array is not needed anymore.
rubidium <rubidium@openttd.org>
parents: 8985
diff changeset
1406
10488
a9ecb9be9814 (svn r14743) -Codechange: use INVALID_TILE to indicate station doesn't have queried facility (or station/roadstop is invalid) instead of 0 (Yexo)
smatz <smatz@openttd.org>
parents: 10480
diff changeset
1407 /* no station is determined by 'tile == INVALID_TILE' now (instead of '0') */
a9ecb9be9814 (svn r14743) -Codechange: use INVALID_TILE to indicate station doesn't have queried facility (or station/roadstop is invalid) instead of 0 (Yexo)
smatz <smatz@openttd.org>
parents: 10480
diff changeset
1408 if (CheckSavegameVersion(105)) {
a9ecb9be9814 (svn r14743) -Codechange: use INVALID_TILE to indicate station doesn't have queried facility (or station/roadstop is invalid) instead of 0 (Yexo)
smatz <smatz@openttd.org>
parents: 10480
diff changeset
1409 Station *st;
a9ecb9be9814 (svn r14743) -Codechange: use INVALID_TILE to indicate station doesn't have queried facility (or station/roadstop is invalid) instead of 0 (Yexo)
smatz <smatz@openttd.org>
parents: 10480
diff changeset
1410 FOR_ALL_STATIONS(st) {
a9ecb9be9814 (svn r14743) -Codechange: use INVALID_TILE to indicate station doesn't have queried facility (or station/roadstop is invalid) instead of 0 (Yexo)
smatz <smatz@openttd.org>
parents: 10480
diff changeset
1411 if (st->airport_tile == 0) st->airport_tile = INVALID_TILE;
a9ecb9be9814 (svn r14743) -Codechange: use INVALID_TILE to indicate station doesn't have queried facility (or station/roadstop is invalid) instead of 0 (Yexo)
smatz <smatz@openttd.org>
parents: 10480
diff changeset
1412 if (st->dock_tile == 0) st->dock_tile = INVALID_TILE;
a9ecb9be9814 (svn r14743) -Codechange: use INVALID_TILE to indicate station doesn't have queried facility (or station/roadstop is invalid) instead of 0 (Yexo)
smatz <smatz@openttd.org>
parents: 10480
diff changeset
1413 if (st->train_tile == 0) st->train_tile = INVALID_TILE;
a9ecb9be9814 (svn r14743) -Codechange: use INVALID_TILE to indicate station doesn't have queried facility (or station/roadstop is invalid) instead of 0 (Yexo)
smatz <smatz@openttd.org>
parents: 10480
diff changeset
1414 }
a9ecb9be9814 (svn r14743) -Codechange: use INVALID_TILE to indicate station doesn't have queried facility (or station/roadstop is invalid) instead of 0 (Yexo)
smatz <smatz@openttd.org>
parents: 10480
diff changeset
1415 }
a9ecb9be9814 (svn r14743) -Codechange: use INVALID_TILE to indicate station doesn't have queried facility (or station/roadstop is invalid) instead of 0 (Yexo)
smatz <smatz@openttd.org>
parents: 10480
diff changeset
1416
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1417 /* convert road side to my format. */
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
1418 if (_settings_game.vehicle.road_side) _settings_game.vehicle.road_side = 1;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1419
5647
716e263a739d (svn r8106) -Feature/Fix: Add the ability to load savegames when you don't have the exact GRF files in your list. GRF files that are found based on GRFID (but not on matching md5sum) are used instead of disabling them. This does not affect MP games, there you still need an exact match.
Darkvater <Darkvater@openttd.org>
parents: 5636
diff changeset
1420 /* Check if all NewGRFs are present, we are very strict in MP mode */
6229
a94c1dd65b46 (svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros <maedhros@openttd.org>
parents: 6196
diff changeset
1421 GRFListCompatibility gcf_res = IsGoodGRFConfigList();
7036
5facac7844e4 (svn r10300) -Fix [FS#917]: give a better explanation why the loading of a savegame failed and do not crash on loading savegames that were altered by patches or branches.
rubidium <rubidium@openttd.org>
parents: 7018
diff changeset
1422 if (_networking && gcf_res != GLC_ALL_GOOD) {
5facac7844e4 (svn r10300) -Fix [FS#917]: give a better explanation why the loading of a savegame failed and do not crash on loading savegames that were altered by patches or branches.
rubidium <rubidium@openttd.org>
parents: 7018
diff changeset
1423 SetSaveLoadError(STR_NETWORK_ERR_CLIENT_NEWGRF_MISMATCH);
5facac7844e4 (svn r10300) -Fix [FS#917]: give a better explanation why the loading of a savegame failed and do not crash on loading savegames that were altered by patches or branches.
rubidium <rubidium@openttd.org>
parents: 7018
diff changeset
1424 return false;
5facac7844e4 (svn r10300) -Fix [FS#917]: give a better explanation why the loading of a savegame failed and do not crash on loading savegames that were altered by patches or branches.
rubidium <rubidium@openttd.org>
parents: 7018
diff changeset
1425 }
5647
716e263a739d (svn r8106) -Feature/Fix: Add the ability to load savegames when you don't have the exact GRF files in your list. GRF files that are found based on GRFID (but not on matching md5sum) are used instead of disabling them. This does not affect MP games, there you still need an exact match.
Darkvater <Darkvater@openttd.org>
parents: 5636
diff changeset
1426
716e263a739d (svn r8106) -Feature/Fix: Add the ability to load savegames when you don't have the exact GRF files in your list. GRF files that are found based on GRFID (but not on matching md5sum) are used instead of disabling them. This does not affect MP games, there you still need an exact match.
Darkvater <Darkvater@openttd.org>
parents: 5636
diff changeset
1427 switch (gcf_res) {
6229
a94c1dd65b46 (svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros <maedhros@openttd.org>
parents: 6196
diff changeset
1428 case GLC_COMPATIBLE: _switch_mode_errorstr = STR_NEWGRF_COMPATIBLE_LOAD_WARNING; break;
8670
5ed9f1ef3eda (svn r12335) -Codechange: Don't stuff signed values into a unsigned variable when the variable can just be unsigned...
peter1138 <peter1138@openttd.org>
parents: 8619
diff changeset
1429 case GLC_NOT_FOUND: _switch_mode_errorstr = STR_NEWGRF_DISABLED_WARNING; _pause_game = -1; break;
5652
ce642f6d3e06 (svn r8111) -Fix r8106: silence warnings
glx <glx@openttd.org>
parents: 5647
diff changeset
1430 default: break;
5647
716e263a739d (svn r8106) -Feature/Fix: Add the ability to load savegames when you don't have the exact GRF files in your list. GRF files that are found based on GRFID (but not on matching md5sum) are used instead of disabling them. This does not affect MP games, there you still need an exact match.
Darkvater <Darkvater@openttd.org>
parents: 5636
diff changeset
1431 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1432
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1433 /* Update current year
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1434 * must be done before loading sprites as some newgrfs check it */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1435 SetDate(_date);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1436
9070
11b5b3f4175d (svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138 <peter1138@openttd.org>
parents: 9069
diff changeset
1437 /* Force dynamic engines off when loading older savegames */
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
1438 if (CheckSavegameVersion(95)) _settings_game.vehicle.dynamic_engines = 0;
9070
11b5b3f4175d (svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138 <peter1138@openttd.org>
parents: 9069
diff changeset
1439
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1440 /* Load the sprites */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1441 GfxLoadSprites();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1442 LoadStringWidthTable();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1443
9070
11b5b3f4175d (svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138 <peter1138@openttd.org>
parents: 9069
diff changeset
1444 /* Copy temporary data to Engine pool */
11b5b3f4175d (svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138 <peter1138@openttd.org>
parents: 9069
diff changeset
1445 CopyTempEngineData();
11b5b3f4175d (svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138 <peter1138@openttd.org>
parents: 9069
diff changeset
1446
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1447 /* Connect front and rear engines of multiheaded trains and converts
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1448 * subtype to the new format */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1449 if (CheckSavegameVersionOldStyle(17, 1)) ConvertOldMultiheadToNew();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1450
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1451 /* Connect front and rear engines of multiheaded trains */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1452 ConnectMultiheadedTrains();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1453
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1454 /* reinit the landscape variables (landscape might have changed) */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1455 InitializeLandscapeVariables(true);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1456
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1457 /* Update all vehicles */
8172
465c2493606f (svn r11735) -Fix [FS#1574]: Don't reset loading indicator IDs when only reloading NewGRFs.
peter1138 <peter1138@openttd.org>
parents: 8157
diff changeset
1458 AfterLoadVehicles(true);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1459
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1460 /* Update all waypoints */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1461 if (CheckSavegameVersion(12)) FixOldWaypoints();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1462
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1463 /* in version 2.2 of the savegame, we have new airports */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1464 if (CheckSavegameVersionOldStyle(2, 2)) UpdateOldAircraft();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1465
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1466 AfterLoadTown();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1467
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1468 /* make sure there is a town in the game */
10236
59398a628f10 (svn r14464) -Codechange: replace (uint)-1 with UINT_MAX (PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
1469 if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, UINT_MAX)) {
7036
5facac7844e4 (svn r10300) -Fix [FS#917]: give a better explanation why the loading of a savegame failed and do not crash on loading savegames that were altered by patches or branches.
rubidium <rubidium@openttd.org>
parents: 7018
diff changeset
1470 SetSaveLoadError(STR_NO_TOWN_IN_SCENARIO);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1471 return false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1472 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1473
8513
4f13e896d29f (svn r12088) -Fix: assert when loading savegame with wrong tiletype at south map borders
smatz <smatz@openttd.org>
parents: 8495
diff changeset
1474 /* The void tiles on the southern border used to belong to a wrong class (pre 4.3).
4f13e896d29f (svn r12088) -Fix: assert when loading savegame with wrong tiletype at south map borders
smatz <smatz@openttd.org>
parents: 8495
diff changeset
1475 * This problem appears in savegame version 21 too, see r3455. But after loading the
4f13e896d29f (svn r12088) -Fix: assert when loading savegame with wrong tiletype at south map borders
smatz <smatz@openttd.org>
parents: 8495
diff changeset
1476 * savegame and saving again, the buggy map array could be converted to new savegame
4f13e896d29f (svn r12088) -Fix: assert when loading savegame with wrong tiletype at south map borders
smatz <smatz@openttd.org>
parents: 8495
diff changeset
1477 * version. It didn't show up before r12070. */
4f13e896d29f (svn r12088) -Fix: assert when loading savegame with wrong tiletype at south map borders
smatz <smatz@openttd.org>
parents: 8495
diff changeset
1478 if (CheckSavegameVersion(87)) UpdateVoidTiles();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1479
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1480 /* If Load Scenario / New (Scenario) Game is used,
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1481 * a company does not exist yet. So create one here.
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1482 * 1 exeption: network-games. Those can have 0 companies
6574
311a49fa8d46 (svn r9785) -Fix (r942, FS#765): only non dedicated servers can't have 0 players
glx <glx@openttd.org>
parents: 6560
diff changeset
1483 * But this exeption is not true for non dedicated network_servers! */
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1484 if (!IsValidCompanyID(COMPANY_FIRST) && (!_networking || (_networking && _network_server && !_network_dedicated)))
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1485 DoStartupNewCompany(false);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1486
7272
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1487 if (CheckSavegameVersion(72)) {
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1488 /* Locks/shiplifts in very old savegames had OWNER_WATER as owner */
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1489 for (TileIndex t = 0; t < MapSize(); t++) {
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1490 switch (GetTileType(t)) {
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1491 default: break;
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1492
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1493 case MP_WATER:
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1494 if (GetWaterTileType(t) == WATER_TILE_LOCK && GetTileOwner(t) == OWNER_WATER) SetTileOwner(t, OWNER_NONE);
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1495 break;
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1496
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1497 case MP_STATION: {
7931
44ff7a6d801f (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7929
diff changeset
1498 if (HasBit(_m[t].m6, 3)) SetBit(_m[t].m6, 2);
7272
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1499 StationGfx gfx = GetStationGfx(t);
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1500 StationType st;
7954
38bb7c45688f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents: 7942
diff changeset
1501 if ( IsInsideMM(gfx, 0, 8)) { // Railway station
7272
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1502 st = STATION_RAIL;
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1503 SetStationGfx(t, gfx - 0);
7954
38bb7c45688f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents: 7942
diff changeset
1504 } else if (IsInsideMM(gfx, 8, 67)) { // Airport
7272
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1505 st = STATION_AIRPORT;
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1506 SetStationGfx(t, gfx - 8);
7954
38bb7c45688f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents: 7942
diff changeset
1507 } else if (IsInsideMM(gfx, 67, 71)) { // Truck
7272
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1508 st = STATION_TRUCK;
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1509 SetStationGfx(t, gfx - 67);
7954
38bb7c45688f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents: 7942
diff changeset
1510 } else if (IsInsideMM(gfx, 71, 75)) { // Bus
7272
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1511 st = STATION_BUS;
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1512 SetStationGfx(t, gfx - 71);
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1513 } else if (gfx == 75) { // Oil rig
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1514 st = STATION_OILRIG;
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1515 SetStationGfx(t, gfx - 75);
7954
38bb7c45688f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents: 7942
diff changeset
1516 } else if (IsInsideMM(gfx, 76, 82)) { // Dock
7272
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1517 st = STATION_DOCK;
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1518 SetStationGfx(t, gfx - 76);
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1519 } else if (gfx == 82) { // Buoy
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1520 st = STATION_BUOY;
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1521 SetStationGfx(t, gfx - 82);
7954
38bb7c45688f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents: 7942
diff changeset
1522 } else if (IsInsideMM(gfx, 83, 168)) { // Extended airport
7272
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1523 st = STATION_AIRPORT;
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1524 SetStationGfx(t, gfx - 83 + 67 - 8);
7954
38bb7c45688f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents: 7942
diff changeset
1525 } else if (IsInsideMM(gfx, 168, 170)) { // Drive through truck
7272
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1526 st = STATION_TRUCK;
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1527 SetStationGfx(t, gfx - 168 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
7954
38bb7c45688f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents: 7942
diff changeset
1528 } else if (IsInsideMM(gfx, 170, 172)) { // Drive through bus
7272
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1529 st = STATION_BUS;
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1530 SetStationGfx(t, gfx - 170 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1531 } else {
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1532 return false;
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1533 }
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1534 SB(_m[t].m6, 3, 3, st);
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1535 } break;
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1536 }
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1537 }
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1538 }
dc7fb38ec443 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents: 7270
diff changeset
1539
5880
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1540 for (TileIndex t = 0; t < map_size; t++) {
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1541 switch (GetTileType(t)) {
6093
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1542 case MP_STATION: {
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1543 Station *st = GetStationByTile(t);
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1544
10262
4c0cbbcc9459 (svn r14493) -Fix[FS#planetmaker]: Do not assign a station spread to buoys on loading games.
frosch <frosch@openttd.org>
parents: 10236
diff changeset
1545 /* Set up station spread; buoys do not have one */
4c0cbbcc9459 (svn r14493) -Fix[FS#planetmaker]: Do not assign a station spread to buoys on loading games.
frosch <frosch@openttd.org>
parents: 10236
diff changeset
1546 if (!IsBuoy(t)) st->rect.BeforeAddTile(t, StationRect::ADD_FORCE);
6093
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1547
5880
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1548 switch (GetStationType(t)) {
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1549 case STATION_TRUCK:
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1550 case STATION_BUS:
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1551 if (CheckSavegameVersion(6)) {
6093
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1552 /* From this version on there can be multiple road stops of the
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1553 * same type per station. Convert the existing stops to the new
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1554 * internal data structure. */
5880
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1555 RoadStop *rs = new RoadStop(t);
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1556 if (rs == NULL) error("Too many road stops in savegame");
5879
abfe68a96c2f (svn r8477) -Fix
tron <tron@openttd.org>
parents: 5848
diff changeset
1557
5880
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1558 RoadStop **head =
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1559 IsTruckStop(t) ? &st->truck_stops : &st->bus_stops;
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1560 *head = rs;
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1561 }
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1562 break;
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1563
5884
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1564 case STATION_OILRIG: {
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1565 /* Very old savegames sometimes have phantom oil rigs, i.e.
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1566 * an oil rig which got shut down, but not completly removed from
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1567 * the map
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1568 */
7740
723ec770aa42 (svn r11277) -Fix (r8498): the check for ghost station (on water industries) always removed station for non-oilrig
glx <glx@openttd.org>
parents: 7739
diff changeset
1569 TileIndex t1 = TILE_ADDXY(t, 0, 1);
5886
28dcf755e961 (svn r8498) -Fix
tron <tron@openttd.org>
parents: 5885
diff changeset
1570 if (IsTileType(t1, MP_INDUSTRY) &&
7740
723ec770aa42 (svn r11277) -Fix (r8498): the check for ghost station (on water industries) always removed station for non-oilrig
glx <glx@openttd.org>
parents: 7739
diff changeset
1571 GetIndustryGfx(t1) == GFX_OILRIG_1) {
5886
28dcf755e961 (svn r8498) -Fix
tron <tron@openttd.org>
parents: 5885
diff changeset
1572 /* The internal encoding of oil rigs was changed twice.
28dcf755e961 (svn r8498) -Fix
tron <tron@openttd.org>
parents: 5885
diff changeset
1573 * It was 3 (till 2.2) and later 5 (till 5.1).
28dcf755e961 (svn r8498) -Fix
tron <tron@openttd.org>
parents: 5885
diff changeset
1574 * Setting it unconditionally does not hurt.
28dcf755e961 (svn r8498) -Fix
tron <tron@openttd.org>
parents: 5885
diff changeset
1575 */
28dcf755e961 (svn r8498) -Fix
tron <tron@openttd.org>
parents: 5885
diff changeset
1576 GetStationByTile(t)->airport_type = AT_OILRIG;
28dcf755e961 (svn r8498) -Fix
tron <tron@openttd.org>
parents: 5885
diff changeset
1577 } else {
5884
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1578 DeleteOilRig(t);
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1579 }
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1580 break;
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1581 }
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1582
5880
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1583 default: break;
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1584 }
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1585 break;
6093
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1586 }
5880
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1587
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1588 default: break;
5879
abfe68a96c2f (svn r8477) -Fix
tron <tron@openttd.org>
parents: 5848
diff changeset
1589 }
abfe68a96c2f (svn r8477) -Fix
tron <tron@openttd.org>
parents: 5848
diff changeset
1590 }
abfe68a96c2f (svn r8477) -Fix
tron <tron@openttd.org>
parents: 5848
diff changeset
1591
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1592 /* In version 6.1 we put the town index in the map-array. To do this, we need
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1593 * to use m2 (16bit big), so we need to clean m2, and that is where this is
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1594 * all about ;) */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1595 if (CheckSavegameVersionOldStyle(6, 1)) {
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1596 for (TileIndex t = 0; t < map_size; t++) {
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1597 switch (GetTileType(t)) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1598 case MP_HOUSE:
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1599 _m[t].m4 = _m[t].m2;
10236
59398a628f10 (svn r14464) -Codechange: replace (uint)-1 with UINT_MAX (PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
1600 SetTownIndex(t, CalcClosestTownFromTile(t, UINT_MAX)->index);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1601 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1602
7370
fba35a9abf79 (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium <rubidium@openttd.org>
parents: 7272
diff changeset
1603 case MP_ROAD:
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1604 _m[t].m4 |= (_m[t].m2 << 4);
10167
8d40f7671148 (svn r14359) -Fix [FS#2311]: the ownership of roadtiles was not properly set for very old savegames (including TTD's) making it impossible to remove some pieces of road.
rubidium <rubidium@openttd.org>
parents: 10158
diff changeset
1605 if ((GB(_m[t].m5, 4, 2) == ROAD_TILE_CROSSING ? (Owner)_m[t].m3 : GetTileOwner(t)) == OWNER_TOWN) {
10236
59398a628f10 (svn r14464) -Codechange: replace (uint)-1 with UINT_MAX (PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
1606 SetTownIndex(t, CalcClosestTownFromTile(t, UINT_MAX)->index);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1607 } else {
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1608 SetTownIndex(t, 0);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1609 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1610 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1611
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1612 default: break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1613 }
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1614 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1615 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1616
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1617 /* From version 9.0, we update the max passengers of a town (was sometimes negative
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1618 * before that. */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1619 if (CheckSavegameVersion(9)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1620 Town *t;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1621 FOR_ALL_TOWNS(t) UpdateTownMaxPass(t);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1622 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1623
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1624 /* From version 16.0, we included autorenew on engines, which are now saved, but
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1625 * of course, we do need to initialize them for older savegames. */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1626 if (CheckSavegameVersion(16)) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1627 FOR_ALL_COMPANIES(c) {
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1628 c->engine_renew_list = NULL;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1629 c->engine_renew = false;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1630 c->engine_renew_months = -6;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1631 c->engine_renew_money = 100000;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1632 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1633
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1634 /* When loading a game, _local_company is not yet set to the correct value.
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1635 * However, in a dedicated server we are a spectator, so nothing needs to
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1636 * happen. In case we are not a dedicated server, the local company always
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1637 * becomes company 0, unless we are in the scenario editor where all the
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1638 * companies are 'invalid'.
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1639 */
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1640 if (!_network_dedicated && IsValidCompanyID(COMPANY_FIRST)) {
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1641 c = GetCompany(COMPANY_FIRST);
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1642 c->engine_renew = _settings_client.gui.autorenew;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1643 c->engine_renew_months = _settings_client.gui.autorenew_months;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1644 c->engine_renew_money = _settings_client.gui.autorenew_money;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1645 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1646 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1647
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1648 if (CheckSavegameVersion(48)) {
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1649 for (TileIndex t = 0; t < map_size; t++) {
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1650 switch (GetTileType(t)) {
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1651 case MP_RAILWAY:
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1652 if (IsPlainRailTile(t)) {
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1653 /* Swap ground type and signal type for plain rail tiles, so the
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1654 * ground type uses the same bits as for depots and waypoints. */
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1655 uint tmp = GB(_m[t].m4, 0, 4);
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1656 SB(_m[t].m4, 0, 4, GB(_m[t].m2, 0, 4));
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1657 SB(_m[t].m2, 0, 4, tmp);
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7922
diff changeset
1658 } else if (HasBit(_m[t].m5, 2)) {
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1659 /* Split waypoint and depot rail type and remove the subtype. */
7929
4d13dbed828c (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7928
diff changeset
1660 ClrBit(_m[t].m5, 2);
4d13dbed828c (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7928
diff changeset
1661 ClrBit(_m[t].m5, 6);
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1662 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1663 break;
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1664
7370
fba35a9abf79 (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium <rubidium@openttd.org>
parents: 7272
diff changeset
1665 case MP_ROAD:
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1666 /* Swap m3 and m4, so the track type for rail crossings is the
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1667 * same as for normal rail. */
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1668 Swap(_m[t].m3, _m[t].m4);
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1669 break;
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1670
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1671 default: break;
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1672 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1673 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1674 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1675
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1676 if (CheckSavegameVersion(61)) {
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1677 /* Added the RoadType */
6738
6caeba8fcd4d (svn r9971) -Fix (r9892, r9958): loading of post-'bridges over "everything"' messed with the railtype of bridges.
rubidium <rubidium@openttd.org>
parents: 6730
diff changeset
1678 bool old_bridge = CheckSavegameVersion(42);
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1679 for (TileIndex t = 0; t < map_size; t++) {
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1680 switch(GetTileType(t)) {
7370
fba35a9abf79 (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium <rubidium@openttd.org>
parents: 7272
diff changeset
1681 case MP_ROAD:
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1682 SB(_m[t].m5, 6, 2, GB(_m[t].m5, 4, 2));
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1683 switch (GetRoadTileType(t)) {
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1684 default: NOT_REACHED();
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1685 case ROAD_TILE_NORMAL:
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1686 SB(_m[t].m4, 0, 4, GB(_m[t].m5, 0, 4));
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1687 SB(_m[t].m4, 4, 4, 0);
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1688 SB(_m[t].m6, 2, 4, 0);
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1689 break;
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1690 case ROAD_TILE_CROSSING:
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1691 SB(_m[t].m4, 5, 2, GB(_m[t].m5, 2, 2));
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1692 break;
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1693 case ROAD_TILE_DEPOT: break;
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1694 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1695 SetRoadTypes(t, ROADTYPES_ROAD);
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1696 break;
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1697
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1698 case MP_STATION:
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1699 if (IsRoadStop(t)) SetRoadTypes(t, ROADTYPES_ROAD);
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1700 break;
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1701
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1702 case MP_TUNNELBRIDGE:
6738
6caeba8fcd4d (svn r9971) -Fix (r9892, r9958): loading of post-'bridges over "everything"' messed with the railtype of bridges.
rubidium <rubidium@openttd.org>
parents: 6730
diff changeset
1703 /* Middle part of "old" bridges */
8390
381a22f19287 (svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents: 8368
diff changeset
1704 if (old_bridge && IsBridge(t) && HasBit(_m[t].m5, 6)) break;
381a22f19287 (svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents: 8368
diff changeset
1705 if (((old_bridge && IsBridge(t)) ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t)) == TRANSPORT_ROAD) {
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1706 SetRoadTypes(t, ROADTYPES_ROAD);
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1707 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1708 break;
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1709
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1710 default: break;
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1711 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1712 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1713 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1714
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1715 if (CheckSavegameVersion(42)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1716 Vehicle* v;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1717
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1718 for (TileIndex t = 0; t < map_size; t++) {
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1719 if (MayHaveBridgeAbove(t)) ClearBridgeMiddle(t);
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1720 if (IsBridgeTile(t)) {
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7922
diff changeset
1721 if (HasBit(_m[t].m5, 6)) { // middle part
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1722 Axis axis = (Axis)GB(_m[t].m5, 0, 1);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1723
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7922
diff changeset
1724 if (HasBit(_m[t].m5, 5)) { // transport route under bridge?
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1725 if (GB(_m[t].m5, 3, 2) == TRANSPORT_RAIL) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1726 MakeRailNormal(
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1727 t,
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1728 GetTileOwner(t),
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1729 axis == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X,
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1730 GetRailType(t)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1731 );
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1732 } else {
10236
59398a628f10 (svn r14464) -Codechange: replace (uint)-1 with UINT_MAX (PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
1733 TownID town = IsTileOwner(t, OWNER_TOWN) ? ClosestTownFromTile(t, UINT_MAX)->index : 0;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1734
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1735 MakeRoadNormal(
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1736 t,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1737 axis == AXIS_X ? ROAD_Y : ROAD_X,
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1738 ROADTYPES_ROAD,
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1739 town,
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6654
diff changeset
1740 GetTileOwner(t), OWNER_NONE, OWNER_NONE
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1741 );
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1742 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1743 } else {
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1744 if (GB(_m[t].m5, 3, 2) == 0) {
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1745 MakeClear(t, CLEAR_GRASS, 3);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1746 } else {
8404
9f94795b6c5b (svn r11974) -Fix [FS#1684]: Shore and sea tiles under bridges were converted to canals in old savegames.
frosch <frosch@openttd.org>
parents: 8390
diff changeset
1747 if (GetTileSlope(t, NULL) != SLOPE_FLAT) {
9f94795b6c5b (svn r11974) -Fix [FS#1684]: Shore and sea tiles under bridges were converted to canals in old savegames.
frosch <frosch@openttd.org>
parents: 8390
diff changeset
1748 MakeShore(t);
9f94795b6c5b (svn r11974) -Fix [FS#1684]: Shore and sea tiles under bridges were converted to canals in old savegames.
frosch <frosch@openttd.org>
parents: 8390
diff changeset
1749 } else {
9f94795b6c5b (svn r11974) -Fix [FS#1684]: Shore and sea tiles under bridges were converted to canals in old savegames.
frosch <frosch@openttd.org>
parents: 8390
diff changeset
1750 if (GetTileOwner(t) == OWNER_WATER) {
9f94795b6c5b (svn r11974) -Fix [FS#1684]: Shore and sea tiles under bridges were converted to canals in old savegames.
frosch <frosch@openttd.org>
parents: 8390
diff changeset
1751 MakeWater(t);
9f94795b6c5b (svn r11974) -Fix [FS#1684]: Shore and sea tiles under bridges were converted to canals in old savegames.
frosch <frosch@openttd.org>
parents: 8390
diff changeset
1752 } else {
9f94795b6c5b (svn r11974) -Fix [FS#1684]: Shore and sea tiles under bridges were converted to canals in old savegames.
frosch <frosch@openttd.org>
parents: 8390
diff changeset
1753 MakeCanal(t, GetTileOwner(t), Random());
9f94795b6c5b (svn r11974) -Fix [FS#1684]: Shore and sea tiles under bridges were converted to canals in old savegames.
frosch <frosch@openttd.org>
parents: 8390
diff changeset
1754 }
9f94795b6c5b (svn r11974) -Fix [FS#1684]: Shore and sea tiles under bridges were converted to canals in old savegames.
frosch <frosch@openttd.org>
parents: 8390
diff changeset
1755 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1756 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1757 }
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1758 SetBridgeMiddle(t, axis);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1759 } else { // ramp
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1760 Axis axis = (Axis)GB(_m[t].m5, 0, 1);
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1761 uint north_south = GB(_m[t].m5, 5, 1);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1762 DiagDirection dir = ReverseDiagDir(XYNSToDiagDir(axis, north_south));
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1763 TransportType type = (TransportType)GB(_m[t].m5, 1, 2);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1764
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1765 _m[t].m5 = 1 << 7 | type << 2 | dir;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1766 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1767 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1768 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1769
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1770 FOR_ALL_VEHICLES(v) {
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6257
diff changeset
1771 if (v->type != VEH_TRAIN && v->type != VEH_ROAD) continue;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1772 if (IsBridgeTile(v->tile)) {
8083
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents: 8082
diff changeset
1773 DiagDirection dir = GetTunnelBridgeDirection(v->tile);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1774
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1775 if (dir != DirToDiagDir(v->direction)) continue;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1776 switch (dir) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1777 default: NOT_REACHED();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1778 case DIAGDIR_NE: if ((v->x_pos & 0xF) != 0) continue; break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1779 case DIAGDIR_SE: if ((v->y_pos & 0xF) != TILE_SIZE - 1) continue; break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1780 case DIAGDIR_SW: if ((v->x_pos & 0xF) != TILE_SIZE - 1) continue; break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1781 case DIAGDIR_NW: if ((v->y_pos & 0xF) != 0) continue; break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1782 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1783 } else if (v->z_pos > GetSlopeZ(v->x_pos, v->y_pos)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1784 v->tile = GetNorthernBridgeEnd(v->tile);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1785 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1786 continue;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1787 }
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6257
diff changeset
1788 if (v->type == VEH_TRAIN) {
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
1789 v->u.rail.track = TRACK_BIT_WORMHOLE;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1790 } else {
6000
2f43f0d4d589 (svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium <rubidium@openttd.org>
parents: 5986
diff changeset
1791 v->u.road.state = RVSB_WORMHOLE;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1792 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1793 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1794 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1795
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1796 /* Elrails got added in rev 24 */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1797 if (CheckSavegameVersion(24)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1798 Vehicle *v;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1799 RailType min_rail = RAILTYPE_ELECTRIC;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1800
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1801 FOR_ALL_VEHICLES(v) {
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6257
diff changeset
1802 if (v->type == VEH_TRAIN) {
5823
4f8ecdfccbd3 (svn r8385) -Fix
tron <tron@openttd.org>
parents: 5723
diff changeset
1803 RailType rt = RailVehInfo(v->engine_type)->railtype;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1804
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1805 v->u.rail.railtype = rt;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1806 if (rt == RAILTYPE_ELECTRIC) min_rail = RAILTYPE_RAIL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1807 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1808 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1809
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1810 /* .. so we convert the entire map from normal to elrail (so maintain "fairness") */
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1811 for (TileIndex t = 0; t < map_size; t++) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1812 switch (GetTileType(t)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1813 case MP_RAILWAY:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1814 SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1815 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1816
7370
fba35a9abf79 (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium <rubidium@openttd.org>
parents: 7272
diff changeset
1817 case MP_ROAD:
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1818 if (IsLevelCrossing(t)) {
6172
b3b8cbc5e854 (svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium <rubidium@openttd.org>
parents: 6093
diff changeset
1819 SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1820 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1821 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1822
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1823 case MP_STATION:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1824 if (IsRailwayStation(t)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1825 SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1826 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1827 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1828
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1829 case MP_TUNNELBRIDGE:
8088
5d7c61206209 (svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz <smatz@openttd.org>
parents: 8085
diff changeset
1830 if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) {
5d7c61206209 (svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz <smatz@openttd.org>
parents: 8085
diff changeset
1831 SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1832 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1833 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1834
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1835 default:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1836 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1837 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1838 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1839
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1840 FOR_ALL_VEHICLES(v) {
9704
e1476334067a (svn r13816) -Fix [FS#2150]: check for vehicle length changes outside a depot (callback 0x11) and give a warning about that
smatz <smatz@openttd.org>
parents: 9667
diff changeset
1841 if (v->type == VEH_TRAIN && (IsFrontEngine(v) || IsFreeWagon(v))) TrainConsistChanged(v, true);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1842 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1843
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1844 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1845
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1846 /* In version 16.1 of the savegame a company can decide if trains, which get
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1847 * replaced, shall keep their old length. In all prior versions, just default
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1848 * to false */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1849 if (CheckSavegameVersionOldStyle(16, 1)) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1850 FOR_ALL_COMPANIES(c) c->renew_keep_length = false;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1851 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1852
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1853 /* In version 17, ground type is moved from m2 to m4 for depots and
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1854 * waypoints to make way for storing the index in m2. The custom graphics
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1855 * id which was stored in m4 is now saved as a grf/id reference in the
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1856 * waypoint struct. */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1857 if (CheckSavegameVersion(17)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1858 Waypoint *wp;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1859
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1860 FOR_ALL_WAYPOINTS(wp) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1861 if (wp->deleted == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1862 const StationSpec *statspec = NULL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1863
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7922
diff changeset
1864 if (HasBit(_m[wp->xy].m3, 4))
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1865 statspec = GetCustomStationSpec(STAT_CLASS_WAYP, _m[wp->xy].m4 + 1);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1866
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1867 if (statspec != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1868 wp->stat_id = _m[wp->xy].m4 + 1;
6451
25c7793c8d9a (svn r9601) -Codechange: Store grf file reference in station spec, not just GRF ID
peter1138 <peter1138@openttd.org>
parents: 6427
diff changeset
1869 wp->grfid = statspec->grffile->grfid;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1870 wp->localidx = statspec->localidx;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1871 } else {
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1872 /* No custom graphics set, so set to default. */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1873 wp->stat_id = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1874 wp->grfid = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1875 wp->localidx = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1876 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1877
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1878 /* Move ground type bits from m2 to m4. */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1879 _m[wp->xy].m4 = GB(_m[wp->xy].m2, 0, 4);
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1880 /* Store waypoint index in the tile. */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1881 _m[wp->xy].m2 = wp->index;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1882 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1883 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1884 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1885 /* As of version 17, we recalculate the custom graphic ID of waypoints
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1886 * from the GRF ID / station index. */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1887 AfterLoadWaypoints();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1888 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1889
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1890 /* From version 15, we moved a semaphore bit from bit 2 to bit 3 in m4, making
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1891 * room for PBS. Now in version 21 move it back :P. */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1892 if (CheckSavegameVersion(21) && !CheckSavegameVersion(15)) {
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1893 for (TileIndex t = 0; t < map_size; t++) {
5707
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1894 switch (GetTileType(t)) {
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1895 case MP_RAILWAY:
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1896 if (HasSignals(t)) {
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1897 /* convert PBS signals to combo-signals */
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7922
diff changeset
1898 if (HasBit(_m[t].m2, 2)) SetSignalType(t, TRACK_X, SIGTYPE_COMBO);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1899
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1900 /* move the signal variant back */
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7922
diff changeset
1901 SetSignalVariant(t, TRACK_X, HasBit(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC);
7929
4d13dbed828c (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7928
diff changeset
1902 ClrBit(_m[t].m2, 3);
5707
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1903 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1904
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1905 /* Clear PBS reservation on track */
8961
b33bcd7fa037 (svn r12753) -Codechange: do not use IsDepotTypeTile() where simpler function can be used
smatz <smatz@openttd.org>
parents: 8954
diff changeset
1906 if (!IsRailDepotTile(t)) {
5707
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1907 SB(_m[t].m4, 4, 4, 0);
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1908 } else {
7929
4d13dbed828c (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7928
diff changeset
1909 ClrBit(_m[t].m3, 6);
5707
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1910 }
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1911 break;
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1912
7370
fba35a9abf79 (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium <rubidium@openttd.org>
parents: 7272
diff changeset
1913 case MP_ROAD: /* Clear PBS reservation on crossing */
7929
4d13dbed828c (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7928
diff changeset
1914 if (IsLevelCrossing(t)) ClrBit(_m[t].m5, 0);
5707
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1915 break;
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1916
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
1917 case MP_STATION: /* Clear PBS reservation on station */
7929
4d13dbed828c (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7928
diff changeset
1918 ClrBit(_m[t].m3, 6);
5707
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1919 break;
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1920
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1921 default: break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1922 }
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1923 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1924 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1925
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1926 if (CheckSavegameVersion(25)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1927 Vehicle *v;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1928 FOR_ALL_VEHICLES(v) {
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6257
diff changeset
1929 if (v->type == VEH_ROAD) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1930 v->vehstatus &= ~0x40;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1931 v->u.road.slot = NULL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1932 v->u.road.slot_age = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1933 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1934 }
5677
2eb2392c2550 (svn r8137) -Fix (FS#551, r4259, r4320): roadstop->num_vehicles was wrong for savegames with version 24 or lower and do not calculate roadstop->num_vehicles when reading the roadstops as the vehicles might not be loaded at that moment.
rubidium <rubidium@openttd.org>
parents: 5659
diff changeset
1935 } else {
2eb2392c2550 (svn r8137) -Fix (FS#551, r4259, r4320): roadstop->num_vehicles was wrong for savegames with version 24 or lower and do not calculate roadstop->num_vehicles when reading the roadstops as the vehicles might not be loaded at that moment.
rubidium <rubidium@openttd.org>
parents: 5659
diff changeset
1936 Vehicle *v;
2eb2392c2550 (svn r8137) -Fix (FS#551, r4259, r4320): roadstop->num_vehicles was wrong for savegames with version 24 or lower and do not calculate roadstop->num_vehicles when reading the roadstops as the vehicles might not be loaded at that moment.
rubidium <rubidium@openttd.org>
parents: 5659
diff changeset
1937 FOR_ALL_VEHICLES(v) {
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6257
diff changeset
1938 if (v->type == VEH_ROAD && v->u.road.slot != NULL) v->u.road.slot->num_vehicles++;
5677
2eb2392c2550 (svn r8137) -Fix (FS#551, r4259, r4320): roadstop->num_vehicles was wrong for savegames with version 24 or lower and do not calculate roadstop->num_vehicles when reading the roadstops as the vehicles might not be loaded at that moment.
rubidium <rubidium@openttd.org>
parents: 5659
diff changeset
1939 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1940 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1941
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1942 if (CheckSavegameVersion(26)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1943 Station *st;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1944 FOR_ALL_STATIONS(st) {
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6257
diff changeset
1945 st->last_vehicle_type = VEH_INVALID;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1946 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1947 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1948
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1949 YapfNotifyTrackLayoutChange(INVALID_TILE, INVALID_TRACK);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1950
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1951 if (CheckSavegameVersion(34)) FOR_ALL_COMPANIES(c) ResetCompanyLivery(c);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1952
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1953 FOR_ALL_COMPANIES(c) {
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1954 c->avail_railtypes = GetCompanyRailtypes(c->index);
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1955 c->avail_roadtypes = GetCompanyRoadtypes(c->index);
6685
91a7c42b133c (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium <rubidium@openttd.org>
parents: 6661
diff changeset
1956 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1957
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1958 if (!CheckSavegameVersion(27)) AfterLoadStations();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1959
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1960 /* Time starts at 0 instead of 1920.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1961 * Account for this in older games by adding an offset */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1962 if (CheckSavegameVersion(31)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1963 Station *st;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1964 Waypoint *wp;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1965 Engine *e;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1966 Industry *i;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1967 Vehicle *v;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1968
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1969 _date += DAYS_TILL_ORIGINAL_BASE_YEAR;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1970 _cur_year += ORIGINAL_BASE_YEAR;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1971
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1972 FOR_ALL_STATIONS(st) st->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1973 FOR_ALL_WAYPOINTS(wp) wp->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1974 FOR_ALL_ENGINES(e) e->intro_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1975 FOR_ALL_COMPANIES(c) c->inaugurated_year += ORIGINAL_BASE_YEAR;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
1976 FOR_ALL_INDUSTRIES(i) i->last_prod_year += ORIGINAL_BASE_YEAR;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1977
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1978 FOR_ALL_VEHICLES(v) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1979 v->date_of_last_service += DAYS_TILL_ORIGINAL_BASE_YEAR;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1980 v->build_year += ORIGINAL_BASE_YEAR;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1981 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1982 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1983
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1984 /* From 32 on we save the industry who made the farmland.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1985 * To give this prettyness to old savegames, we remove all farmfields and
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1986 * plant new ones. */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1987 if (CheckSavegameVersion(32)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1988 Industry *i;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1989
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1990 for (TileIndex t = 0; t < map_size; t++) {
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1991 if (IsTileType(t, MP_CLEAR) && IsClearGround(t, CLEAR_FIELDS)) {
8811
8e6d3b3fb0ba (svn r12556) -Fix (r6001): remove fences with fields when loading old savegames, looks better
smatz <smatz@openttd.org>
parents: 8809
diff changeset
1992 /* remove fields */
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1993 MakeClear(t, CLEAR_GRASS, 3);
8811
8e6d3b3fb0ba (svn r12556) -Fix (r6001): remove fences with fields when loading old savegames, looks better
smatz <smatz@openttd.org>
parents: 8809
diff changeset
1994 } else if (IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)) {
8e6d3b3fb0ba (svn r12556) -Fix (r6001): remove fences with fields when loading old savegames, looks better
smatz <smatz@openttd.org>
parents: 8809
diff changeset
1995 /* remove fences around fields */
8e6d3b3fb0ba (svn r12556) -Fix (r6001): remove fences with fields when loading old savegames, looks better
smatz <smatz@openttd.org>
parents: 8809
diff changeset
1996 SetFenceSE(t, 0);
8e6d3b3fb0ba (svn r12556) -Fix (r6001): remove fences with fields when loading old savegames, looks better
smatz <smatz@openttd.org>
parents: 8809
diff changeset
1997 SetFenceSW(t, 0);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1998 }
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
1999 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2000
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2001 FOR_ALL_INDUSTRIES(i) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2002 uint j;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2003
6757
d868c71fb346 (svn r9992) -Codechange: Remove some hardcoded references to Industry IDs.
belugas <belugas@openttd.org>
parents: 6738
diff changeset
2004 if (GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_PLANT_ON_BUILT) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2005 for (j = 0; j != 50; j++) PlantRandomFarmField(i);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2006 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2007 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2008 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2009
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2010 /* Setting no refit flags to all orders in savegames from before refit in orders were added */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2011 if (CheckSavegameVersion(36)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2012 Order *order;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2013 Vehicle *v;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2014
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2015 FOR_ALL_ORDERS(order) {
8838
db9c6b0c9f07 (svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium <rubidium@openttd.org>
parents: 8836
diff changeset
2016 order->SetRefit(CT_NO_REFIT);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2017 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2018
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2019 FOR_ALL_VEHICLES(v) {
8838
db9c6b0c9f07 (svn r12586) -Codechange: do not access an order's refit variables directly.
rubidium <rubidium@openttd.org>
parents: 8836
diff changeset
2020 v->current_order.SetRefit(CT_NO_REFIT);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2021 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2022 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2023
9622
667ace88dbc6 (svn r13678) -Fix (r13677): electric trains from pre elrail savegames would get stopped on load.
rubidium <rubidium@openttd.org>
parents: 9621
diff changeset
2024 /* from version 38 we have optional elrails, since we cannot know the
667ace88dbc6 (svn r13678) -Fix (r13677): electric trains from pre elrail savegames would get stopped on load.
rubidium <rubidium@openttd.org>
parents: 9621
diff changeset
2025 * preference of a user, let elrails enabled; it can be disabled manually */
667ace88dbc6 (svn r13678) -Fix (r13677): electric trains from pre elrail savegames would get stopped on load.
rubidium <rubidium@openttd.org>
parents: 9621
diff changeset
2026 if (CheckSavegameVersion(38)) _settings_game.vehicle.disable_elrails = false;
667ace88dbc6 (svn r13678) -Fix (r13677): electric trains from pre elrail savegames would get stopped on load.
rubidium <rubidium@openttd.org>
parents: 9621
diff changeset
2027 /* do the same as when elrails were enabled/disabled manually just now */
667ace88dbc6 (svn r13678) -Fix (r13677): electric trains from pre elrail savegames would get stopped on load.
rubidium <rubidium@openttd.org>
parents: 9621
diff changeset
2028 SettingsDisableElrail(_settings_game.vehicle.disable_elrails);
667ace88dbc6 (svn r13678) -Fix (r13677): electric trains from pre elrail savegames would get stopped on load.
rubidium <rubidium@openttd.org>
parents: 9621
diff changeset
2029 InitializeRailGUI();
667ace88dbc6 (svn r13678) -Fix (r13677): electric trains from pre elrail savegames would get stopped on load.
rubidium <rubidium@openttd.org>
parents: 9621
diff changeset
2030
6333
273ef908beb8 (svn r9316) -Fix (r9315): Bump the savegame version for the newhouses merge.
maedhros <maedhros@openttd.org>
parents: 6332
diff changeset
2031 /* From version 53, the map array was changed for house tiles to allow
6332
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2032 * space for newhouses grf features. A new byte, m7, was also added. */
6333
273ef908beb8 (svn r9316) -Fix (r9315): Bump the savegame version for the newhouses merge.
maedhros <maedhros@openttd.org>
parents: 6332
diff changeset
2033 if (CheckSavegameVersion(53)) {
6332
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2034 for (TileIndex t = 0; t < map_size; t++) {
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2035 if (IsTileType(t, MP_HOUSE)) {
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2036 if (GB(_m[t].m3, 6, 2) != TOWN_HOUSE_COMPLETED) {
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2037 /* Move the construction stage from m3[7..6] to m5[5..4].
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2038 * The construction counter does not have to move. */
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2039 SB(_m[t].m5, 3, 2, GB(_m[t].m3, 6, 2));
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2040 SB(_m[t].m3, 6, 2, 0);
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2041
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2042 /* The "house is completed" bit is now in m6[2]. */
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2043 SetHouseCompleted(t, false);
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2044 } else {
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2045 /* The "lift has destination" bit has been moved from
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2046 * m5[7] to m7[0]. */
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7922
diff changeset
2047 SB(_me[t].m7, 0, 1, HasBit(_m[t].m5, 7));
7929
4d13dbed828c (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7928
diff changeset
2048 ClrBit(_m[t].m5, 7);
6332
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2049
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2050 /* The "lift is moving" bit has been removed, as it does
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2051 * the same job as the "lift has destination" bit. */
7929
4d13dbed828c (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7928
diff changeset
2052 ClrBit(_m[t].m1, 7);
6332
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2053
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2054 /* The position of the lift goes from m1[7..0] to m6[7..2],
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2055 * making m1 totally free, now. The lift position does not
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2056 * have to be a full byte since the maximum value is 36. */
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2057 SetLiftPosition(t, GB(_m[t].m1, 0, 6 ));
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2058
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2059 _m[t].m1 = 0;
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2060 _m[t].m3 = 0;
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2061 SetHouseCompleted(t, true);
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2062 }
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2063 }
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2064 }
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2065 }
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2066
8707
64bd5cfc6426 (svn r12381) -Fix [FS1835] [FS1535] (r11855): The number of houses wasn't computed right. A few other things regaring the updating had to be changed. Big thanks for support to frosch123 and SmatZ, to name just a few. (Inspired by a patch of bilbo)
skidd13 <skidd13@openttd.org>
parents: 8681
diff changeset
2067 /* Check and update house and town values */
64bd5cfc6426 (svn r12381) -Fix [FS1835] [FS1535] (r11855): The number of houses wasn't computed right. A few other things regaring the updating had to be changed. Big thanks for support to frosch123 and SmatZ, to name just a few. (Inspired by a patch of bilbo)
skidd13 <skidd13@openttd.org>
parents: 8681
diff changeset
2068 UpdateHousesAndTowns();
6332
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2069
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2070 if (CheckSavegameVersion(43)) {
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
2071 for (TileIndex t = 0; t < map_size; t++) {
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
2072 if (IsTileType(t, MP_INDUSTRY)) {
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
2073 switch (GetIndustryGfx(t)) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2074 case GFX_POWERPLANT_SPARKS:
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
2075 SetIndustryAnimationState(t, GB(_m[t].m1, 2, 5));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2076 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2077
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2078 case GFX_OILWELL_ANIMATED_1:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2079 case GFX_OILWELL_ANIMATED_2:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2080 case GFX_OILWELL_ANIMATED_3:
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
2081 SetIndustryAnimationState(t, GB(_m[t].m1, 0, 2));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2082 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2083
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2084 case GFX_COAL_MINE_TOWER_ANIMATED:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2085 case GFX_COPPER_MINE_TOWER_ANIMATED:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2086 case GFX_GOLD_MINE_TOWER_ANIMATED:
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
2087 SetIndustryAnimationState(t, _m[t].m1);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2088 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2089
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2090 default: /* No animation states to change */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2091 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2092 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2093 }
5706
f7eba7e82662 (svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron <tron@openttd.org>
parents: 5692
diff changeset
2094 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2095 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2096
5683
809a5610092f (svn r8144) -Fix: [FS#163] When a station is removed, vehicles do not get excessive payment any longer, as the origin TILE is now stored as long as the origin STATION for the transported cargos. Basically this is only a temporary fix until cargopackets are implemented, but it fixes one of the oldest known bugs (Special Thanks to Darkvater for lots of testing)
celestar <celestar@openttd.org>
parents: 5677
diff changeset
2097 if (CheckSavegameVersion(44)) {
809a5610092f (svn r8144) -Fix: [FS#163] When a station is removed, vehicles do not get excessive payment any longer, as the origin TILE is now stored as long as the origin STATION for the transported cargos. Basically this is only a temporary fix until cargopackets are implemented, but it fixes one of the oldest known bugs (Special Thanks to Darkvater for lots of testing)
celestar <celestar@openttd.org>
parents: 5677
diff changeset
2098 Vehicle *v;
809a5610092f (svn r8144) -Fix: [FS#163] When a station is removed, vehicles do not get excessive payment any longer, as the origin TILE is now stored as long as the origin STATION for the transported cargos. Basically this is only a temporary fix until cargopackets are implemented, but it fixes one of the oldest known bugs (Special Thanks to Darkvater for lots of testing)
celestar <celestar@openttd.org>
parents: 5677
diff changeset
2099 /* If we remove a station while cargo from it is still enroute, payment calculation will assume
7010
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2100 * 0, 0 to be the source of the cargo, resulting in very high payments usually. v->source_xy
5683
809a5610092f (svn r8144) -Fix: [FS#163] When a station is removed, vehicles do not get excessive payment any longer, as the origin TILE is now stored as long as the origin STATION for the transported cargos. Basically this is only a temporary fix until cargopackets are implemented, but it fixes one of the oldest known bugs (Special Thanks to Darkvater for lots of testing)
celestar <celestar@openttd.org>
parents: 5677
diff changeset
2101 * stores the coordinates, preserving them even if the station is removed. However, if a game is loaded
7010
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2102 * where this situation exists, the cargo-source information is lost. in this case, we set the source
5683
809a5610092f (svn r8144) -Fix: [FS#163] When a station is removed, vehicles do not get excessive payment any longer, as the origin TILE is now stored as long as the origin STATION for the transported cargos. Basically this is only a temporary fix until cargopackets are implemented, but it fixes one of the oldest known bugs (Special Thanks to Darkvater for lots of testing)
celestar <celestar@openttd.org>
parents: 5677
diff changeset
2103 * to the current tile of the vehicle to prevent excessive profits
809a5610092f (svn r8144) -Fix: [FS#163] When a station is removed, vehicles do not get excessive payment any longer, as the origin TILE is now stored as long as the origin STATION for the transported cargos. Basically this is only a temporary fix until cargopackets are implemented, but it fixes one of the oldest known bugs (Special Thanks to Darkvater for lots of testing)
celestar <celestar@openttd.org>
parents: 5677
diff changeset
2104 */
809a5610092f (svn r8144) -Fix: [FS#163] When a station is removed, vehicles do not get excessive payment any longer, as the origin TILE is now stored as long as the origin STATION for the transported cargos. Basically this is only a temporary fix until cargopackets are implemented, but it fixes one of the oldest known bugs (Special Thanks to Darkvater for lots of testing)
celestar <celestar@openttd.org>
parents: 5677
diff changeset
2105 FOR_ALL_VEHICLES(v) {
7010
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2106 const CargoList::List *packets = v->cargo.Packets();
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2107 for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) {
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2108 CargoPacket *cp = *it;
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2109 cp->source_xy = IsValidStationID(cp->source) ? GetStation(cp->source)->xy : v->tile;
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2110 cp->loaded_at_xy = cp->source_xy;
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2111 }
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2112 v->cargo.InvalidateCache();
5683
809a5610092f (svn r8144) -Fix: [FS#163] When a station is removed, vehicles do not get excessive payment any longer, as the origin TILE is now stored as long as the origin STATION for the transported cargos. Basically this is only a temporary fix until cargopackets are implemented, but it fixes one of the oldest known bugs (Special Thanks to Darkvater for lots of testing)
celestar <celestar@openttd.org>
parents: 5677
diff changeset
2113 }
6304
dafe7e537d11 (svn r9147) -Fix (r1770, r8161): when loadin games, enroute_from and enroute_from_xy were updated in the wrong place, causing issues with TTD savegames/scenarios.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
2114
dafe7e537d11 (svn r9147) -Fix (r1770, r8161): when loadin games, enroute_from and enroute_from_xy were updated in the wrong place, causing issues with TTD savegames/scenarios.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
2115 /* Store position of the station where the goods come from, so there
dafe7e537d11 (svn r9147) -Fix (r1770, r8161): when loadin games, enroute_from and enroute_from_xy were updated in the wrong place, causing issues with TTD savegames/scenarios.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
2116 * are no very high payments when stations get removed. However, if the
dafe7e537d11 (svn r9147) -Fix (r1770, r8161): when loadin games, enroute_from and enroute_from_xy were updated in the wrong place, causing issues with TTD savegames/scenarios.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
2117 * station where the goods came from is already removed, the source
dafe7e537d11 (svn r9147) -Fix (r1770, r8161): when loadin games, enroute_from and enroute_from_xy were updated in the wrong place, causing issues with TTD savegames/scenarios.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
2118 * information is lost. In that case we set it to the position of this
dafe7e537d11 (svn r9147) -Fix (r1770, r8161): when loadin games, enroute_from and enroute_from_xy were updated in the wrong place, causing issues with TTD savegames/scenarios.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
2119 * station */
dafe7e537d11 (svn r9147) -Fix (r1770, r8161): when loadin games, enroute_from and enroute_from_xy were updated in the wrong place, causing issues with TTD savegames/scenarios.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
2120 Station *st;
dafe7e537d11 (svn r9147) -Fix (r1770, r8161): when loadin games, enroute_from and enroute_from_xy were updated in the wrong place, causing issues with TTD savegames/scenarios.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
2121 FOR_ALL_STATIONS(st) {
dafe7e537d11 (svn r9147) -Fix (r1770, r8161): when loadin games, enroute_from and enroute_from_xy were updated in the wrong place, causing issues with TTD savegames/scenarios.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
2122 for (CargoID c = 0; c < NUM_CARGO; c++) {
dafe7e537d11 (svn r9147) -Fix (r1770, r8161): when loadin games, enroute_from and enroute_from_xy were updated in the wrong place, causing issues with TTD savegames/scenarios.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
2123 GoodsEntry *ge = &st->goods[c];
dafe7e537d11 (svn r9147) -Fix (r1770, r8161): when loadin games, enroute_from and enroute_from_xy were updated in the wrong place, causing issues with TTD savegames/scenarios.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
2124
7010
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2125 const CargoList::List *packets = ge->cargo.Packets();
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2126 for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) {
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2127 CargoPacket *cp = *it;
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2128 cp->source_xy = IsValidStationID(cp->source) ? GetStation(cp->source)->xy : st->xy;
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2129 cp->loaded_at_xy = cp->source_xy;
6304
dafe7e537d11 (svn r9147) -Fix (r1770, r8161): when loadin games, enroute_from and enroute_from_xy were updated in the wrong place, causing issues with TTD savegames/scenarios.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
2130 }
dafe7e537d11 (svn r9147) -Fix (r1770, r8161): when loadin games, enroute_from and enroute_from_xy were updated in the wrong place, causing issues with TTD savegames/scenarios.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
2131 }
dafe7e537d11 (svn r9147) -Fix (r1770, r8161): when loadin games, enroute_from and enroute_from_xy were updated in the wrong place, causing issues with TTD savegames/scenarios.
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
2132 }
5683
809a5610092f (svn r8144) -Fix: [FS#163] When a station is removed, vehicles do not get excessive payment any longer, as the origin TILE is now stored as long as the origin STATION for the transported cargos. Basically this is only a temporary fix until cargopackets are implemented, but it fixes one of the oldest known bugs (Special Thanks to Darkvater for lots of testing)
celestar <celestar@openttd.org>
parents: 5677
diff changeset
2133 }
809a5610092f (svn r8144) -Fix: [FS#163] When a station is removed, vehicles do not get excessive payment any longer, as the origin TILE is now stored as long as the origin STATION for the transported cargos. Basically this is only a temporary fix until cargopackets are implemented, but it fixes one of the oldest known bugs (Special Thanks to Darkvater for lots of testing)
celestar <celestar@openttd.org>
parents: 5677
diff changeset
2134
5888
11683122ef51 (svn r8501) -Fix (r7377) [FS#539]: Keep track of how much cargo has been paid for, so that cargo cannot be paid for more than once.
maedhros <maedhros@openttd.org>
parents: 5886
diff changeset
2135 if (CheckSavegameVersion(45)) {
11683122ef51 (svn r8501) -Fix (r7377) [FS#539]: Keep track of how much cargo has been paid for, so that cargo cannot be paid for more than once.
maedhros <maedhros@openttd.org>
parents: 5886
diff changeset
2136 Vehicle *v;
11683122ef51 (svn r8501) -Fix (r7377) [FS#539]: Keep track of how much cargo has been paid for, so that cargo cannot be paid for more than once.
maedhros <maedhros@openttd.org>
parents: 5886
diff changeset
2137 /* Originally just the fact that some cargo had been paid for was
11683122ef51 (svn r8501) -Fix (r7377) [FS#539]: Keep track of how much cargo has been paid for, so that cargo cannot be paid for more than once.
maedhros <maedhros@openttd.org>
parents: 5886
diff changeset
2138 * stored to stop people cheating and cashing in several times. This
11683122ef51 (svn r8501) -Fix (r7377) [FS#539]: Keep track of how much cargo has been paid for, so that cargo cannot be paid for more than once.
maedhros <maedhros@openttd.org>
parents: 5886
diff changeset
2139 * wasn't enough though as it was cleared when the vehicle started
11683122ef51 (svn r8501) -Fix (r7377) [FS#539]: Keep track of how much cargo has been paid for, so that cargo cannot be paid for more than once.
maedhros <maedhros@openttd.org>
parents: 5886
diff changeset
2140 * loading again, even if it didn't actually load anything, so now the
11683122ef51 (svn r8501) -Fix (r7377) [FS#539]: Keep track of how much cargo has been paid for, so that cargo cannot be paid for more than once.
maedhros <maedhros@openttd.org>
parents: 5886
diff changeset
2141 * amount of cargo that has been paid for is stored. */
11683122ef51 (svn r8501) -Fix (r7377) [FS#539]: Keep track of how much cargo has been paid for, so that cargo cannot be paid for more than once.
maedhros <maedhros@openttd.org>
parents: 5886
diff changeset
2142 FOR_ALL_VEHICLES(v) {
7010
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2143 const CargoList::List *packets = v->cargo.Packets();
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2144 for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) {
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2145 CargoPacket *cp = *it;
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7922
diff changeset
2146 cp->paid_for = HasBit(v->vehicle_flags, 2);
5888
11683122ef51 (svn r8501) -Fix (r7377) [FS#539]: Keep track of how much cargo has been paid for, so that cargo cannot be paid for more than once.
maedhros <maedhros@openttd.org>
parents: 5886
diff changeset
2147 }
7929
4d13dbed828c (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7928
diff changeset
2148 ClrBit(v->vehicle_flags, 2);
7010
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6937
diff changeset
2149 v->cargo.InvalidateCache();
5888
11683122ef51 (svn r8501) -Fix (r7377) [FS#539]: Keep track of how much cargo has been paid for, so that cargo cannot be paid for more than once.
maedhros <maedhros@openttd.org>
parents: 5886
diff changeset
2150 }
11683122ef51 (svn r8501) -Fix (r7377) [FS#539]: Keep track of how much cargo has been paid for, so that cargo cannot be paid for more than once.
maedhros <maedhros@openttd.org>
parents: 5886
diff changeset
2151 }
11683122ef51 (svn r8501) -Fix (r7377) [FS#539]: Keep track of how much cargo has been paid for, so that cargo cannot be paid for more than once.
maedhros <maedhros@openttd.org>
parents: 5886
diff changeset
2152
5986
3828f4c73a88 (svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium <rubidium@openttd.org>
parents: 5977
diff changeset
2153 /* Buoys do now store the owner of the previous water tile, which can never
3828f4c73a88 (svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium <rubidium@openttd.org>
parents: 5977
diff changeset
2154 * be OWNER_NONE. So replace OWNER_NONE with OWNER_WATER. */
3828f4c73a88 (svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium <rubidium@openttd.org>
parents: 5977
diff changeset
2155 if (CheckSavegameVersion(46)) {
3828f4c73a88 (svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium <rubidium@openttd.org>
parents: 5977
diff changeset
2156 Station *st;
3828f4c73a88 (svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium <rubidium@openttd.org>
parents: 5977
diff changeset
2157 FOR_ALL_STATIONS(st) {
7788
3294d5b88b1b (svn r11338) -Fix [FS#1359]: water tiles not at sealevel (i.e. canals) should not be owned by water as that signals normal water.
rubidium <rubidium@openttd.org>
parents: 7740
diff changeset
2158 if (st->IsBuoy() && IsTileOwner(st->xy, OWNER_NONE) && TileHeight(st->xy) == 0) SetTileOwner(st->xy, OWNER_WATER);
5986
3828f4c73a88 (svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium <rubidium@openttd.org>
parents: 5977
diff changeset
2159 }
3828f4c73a88 (svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium <rubidium@openttd.org>
parents: 5977
diff changeset
2160 }
3828f4c73a88 (svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium <rubidium@openttd.org>
parents: 5977
diff changeset
2161
6193
0d05fec9d384 (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar <celestar@openttd.org>
parents: 6190
diff changeset
2162 if (CheckSavegameVersion(50)) {
0d05fec9d384 (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar <celestar@openttd.org>
parents: 6190
diff changeset
2163 Vehicle *v;
0d05fec9d384 (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar <celestar@openttd.org>
parents: 6190
diff changeset
2164 /* Aircraft units changed from 8 mph to 1 km/h */
0d05fec9d384 (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar <celestar@openttd.org>
parents: 6190
diff changeset
2165 FOR_ALL_VEHICLES(v) {
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6257
diff changeset
2166 if (v->type == VEH_AIRCRAFT && v->subtype <= AIR_AIRCRAFT) {
6193
0d05fec9d384 (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar <celestar@openttd.org>
parents: 6190
diff changeset
2167 const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type);
0d05fec9d384 (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar <celestar@openttd.org>
parents: 6190
diff changeset
2168 v->cur_speed *= 129;
0d05fec9d384 (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar <celestar@openttd.org>
parents: 6190
diff changeset
2169 v->cur_speed /= 10;
0d05fec9d384 (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar <celestar@openttd.org>
parents: 6190
diff changeset
2170 v->max_speed = avi->max_speed;
0d05fec9d384 (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar <celestar@openttd.org>
parents: 6190
diff changeset
2171 v->acceleration = avi->acceleration;
0d05fec9d384 (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar <celestar@openttd.org>
parents: 6190
diff changeset
2172 }
0d05fec9d384 (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar <celestar@openttd.org>
parents: 6190
diff changeset
2173 }
0d05fec9d384 (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar <celestar@openttd.org>
parents: 6190
diff changeset
2174 }
0d05fec9d384 (svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar <celestar@openttd.org>
parents: 6190
diff changeset
2175
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2176 if (CheckSavegameVersion(49)) FOR_ALL_COMPANIES(c) c->face = ConvertFromOldCompanyManagerFace(c->face);
6190
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 6175
diff changeset
2177
6257
d7d39048e2ee (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight <truelight@openttd.org>
parents: 6247
diff changeset
2178 if (CheckSavegameVersion(52)) {
d7d39048e2ee (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight <truelight@openttd.org>
parents: 6247
diff changeset
2179 for (TileIndex t = 0; t < map_size; t++) {
d7d39048e2ee (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight <truelight@openttd.org>
parents: 6247
diff changeset
2180 if (IsStatueTile(t)) {
10236
59398a628f10 (svn r14464) -Codechange: replace (uint)-1 with UINT_MAX (PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
2181 _m[t].m2 = CalcClosestTownFromTile(t, UINT_MAX)->index;
6257
d7d39048e2ee (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight <truelight@openttd.org>
parents: 6247
diff changeset
2182 }
d7d39048e2ee (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight <truelight@openttd.org>
parents: 6247
diff changeset
2183 }
d7d39048e2ee (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight <truelight@openttd.org>
parents: 6247
diff changeset
2184 }
d7d39048e2ee (svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight <truelight@openttd.org>
parents: 6247
diff changeset
2185
6486
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2186 /* A patch option containing the proportion of towns that grow twice as
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2187 * fast was added in version 54. From version 56 this is now saved in the
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2188 * town as cities can be built specifically in the scenario editor. */
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2189 if (CheckSavegameVersion(56)) {
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2190 Town *t;
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2191
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2192 FOR_ALL_TOWNS(t) {
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
2193 if (_settings_game.economy.larger_towns != 0 && (t->index % _settings_game.economy.larger_towns) == 0) {
6486
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2194 t->larger_town = true;
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2195 }
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2196 }
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2197 }
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2198
6500
ad8ea1f30c99 (svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium <rubidium@openttd.org>
parents: 6491
diff changeset
2199 if (CheckSavegameVersion(57)) {
ad8ea1f30c99 (svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium <rubidium@openttd.org>
parents: 6491
diff changeset
2200 Vehicle *v;
ad8ea1f30c99 (svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium <rubidium@openttd.org>
parents: 6491
diff changeset
2201 /* Added a FIFO queue of vehicles loading at stations */
ad8ea1f30c99 (svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium <rubidium@openttd.org>
parents: 6491
diff changeset
2202 FOR_ALL_VEHICLES(v) {
ad8ea1f30c99 (svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium <rubidium@openttd.org>
parents: 6491
diff changeset
2203 if ((v->type != VEH_TRAIN || IsFrontEngine(v)) && // for all locs
ad8ea1f30c99 (svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium <rubidium@openttd.org>
parents: 6491
diff changeset
2204 !(v->vehstatus & (VS_STOPPED | VS_CRASHED)) && // not stopped or crashed
8836
890a77315801 (svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents: 8811
diff changeset
2205 v->current_order.IsType(OT_LOADING)) { // loading
6500
ad8ea1f30c99 (svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium <rubidium@openttd.org>
parents: 6491
diff changeset
2206 GetStation(v->last_station_visited)->loading_vehicles.push_back(v);
6619
051933de87ad (svn r9839) -Fix: vehicles in old savegames could leave the station because the changed loading algorithm thought it was already finished.
rubidium <rubidium@openttd.org>
parents: 6591
diff changeset
2207
051933de87ad (svn r9839) -Fix: vehicles in old savegames could leave the station because the changed loading algorithm thought it was already finished.
rubidium <rubidium@openttd.org>
parents: 6591
diff changeset
2208 /* The loading finished flag is *only* set when actually completely
051933de87ad (svn r9839) -Fix: vehicles in old savegames could leave the station because the changed loading algorithm thought it was already finished.
rubidium <rubidium@openttd.org>
parents: 6591
diff changeset
2209 * finished. Because the vehicle is loading, it is not finished. */
7929
4d13dbed828c (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7928
diff changeset
2210 ClrBit(v->vehicle_flags, VF_LOADING_FINISHED);
6500
ad8ea1f30c99 (svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium <rubidium@openttd.org>
parents: 6491
diff changeset
2211 }
ad8ea1f30c99 (svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium <rubidium@openttd.org>
parents: 6491
diff changeset
2212 }
7475
a503a2529eac (svn r10982) -Fix [FS#1162]: some old savegames could be in a state that the current game logic does not like; in the list of vehicles loading at a station when the vehicle is not actually at the station.
rubidium <rubidium@openttd.org>
parents: 7414
diff changeset
2213 } else if (CheckSavegameVersion(59)) {
a503a2529eac (svn r10982) -Fix [FS#1162]: some old savegames could be in a state that the current game logic does not like; in the list of vehicles loading at a station when the vehicle is not actually at the station.
rubidium <rubidium@openttd.org>
parents: 7414
diff changeset
2214 /* For some reason non-loading vehicles could be in the station's loading vehicle list */
a503a2529eac (svn r10982) -Fix [FS#1162]: some old savegames could be in a state that the current game logic does not like; in the list of vehicles loading at a station when the vehicle is not actually at the station.
rubidium <rubidium@openttd.org>
parents: 7414
diff changeset
2215
a503a2529eac (svn r10982) -Fix [FS#1162]: some old savegames could be in a state that the current game logic does not like; in the list of vehicles loading at a station when the vehicle is not actually at the station.
rubidium <rubidium@openttd.org>
parents: 7414
diff changeset
2216 Station *st;
a503a2529eac (svn r10982) -Fix [FS#1162]: some old savegames could be in a state that the current game logic does not like; in the list of vehicles loading at a station when the vehicle is not actually at the station.
rubidium <rubidium@openttd.org>
parents: 7414
diff changeset
2217 FOR_ALL_STATIONS(st) {
a503a2529eac (svn r10982) -Fix [FS#1162]: some old savegames could be in a state that the current game logic does not like; in the list of vehicles loading at a station when the vehicle is not actually at the station.
rubidium <rubidium@openttd.org>
parents: 7414
diff changeset
2218 std::list<Vehicle *>::iterator iter;
a503a2529eac (svn r10982) -Fix [FS#1162]: some old savegames could be in a state that the current game logic does not like; in the list of vehicles loading at a station when the vehicle is not actually at the station.
rubidium <rubidium@openttd.org>
parents: 7414
diff changeset
2219 for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end();) {
a503a2529eac (svn r10982) -Fix [FS#1162]: some old savegames could be in a state that the current game logic does not like; in the list of vehicles loading at a station when the vehicle is not actually at the station.
rubidium <rubidium@openttd.org>
parents: 7414
diff changeset
2220 Vehicle *v = *iter;
a503a2529eac (svn r10982) -Fix [FS#1162]: some old savegames could be in a state that the current game logic does not like; in the list of vehicles loading at a station when the vehicle is not actually at the station.
rubidium <rubidium@openttd.org>
parents: 7414
diff changeset
2221 iter++;
8836
890a77315801 (svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents: 8811
diff changeset
2222 if (!v->current_order.IsType(OT_LOADING)) st->loading_vehicles.remove(v);
7475
a503a2529eac (svn r10982) -Fix [FS#1162]: some old savegames could be in a state that the current game logic does not like; in the list of vehicles loading at a station when the vehicle is not actually at the station.
rubidium <rubidium@openttd.org>
parents: 7414
diff changeset
2223 }
a503a2529eac (svn r10982) -Fix [FS#1162]: some old savegames could be in a state that the current game logic does not like; in the list of vehicles loading at a station when the vehicle is not actually at the station.
rubidium <rubidium@openttd.org>
parents: 7414
diff changeset
2224 }
6500
ad8ea1f30c99 (svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium <rubidium@openttd.org>
parents: 6491
diff changeset
2225 }
ad8ea1f30c99 (svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium <rubidium@openttd.org>
parents: 6491
diff changeset
2226
6560
838badc858d3 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas <belugas@openttd.org>
parents: 6500
diff changeset
2227 if (CheckSavegameVersion(58)) {
9950
dbf95da604b3 (svn r14105) -Fix: Some typos that are more grammatical errors, as it seems.
belugas <belugas@openttd.org>
parents: 9941
diff changeset
2228 /* patch difficulty number_industries other than zero get bumped to +1
6560
838badc858d3 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas <belugas@openttd.org>
parents: 6500
diff changeset
2229 * since a new option (very low at position1) has been added */
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
2230 if (_settings_game.difficulty.number_industries > 0) {
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
2231 _settings_game.difficulty.number_industries++;
6560
838badc858d3 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas <belugas@openttd.org>
parents: 6500
diff changeset
2232 }
838badc858d3 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas <belugas@openttd.org>
parents: 6500
diff changeset
2233
838badc858d3 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas <belugas@openttd.org>
parents: 6500
diff changeset
2234 /* Same goes for number of towns, although no test is needed, just an increment */
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
2235 _settings_game.difficulty.number_towns++;
6560
838badc858d3 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas <belugas@openttd.org>
parents: 6500
diff changeset
2236 }
838badc858d3 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas <belugas@openttd.org>
parents: 6500
diff changeset
2237
6770
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2238 if (CheckSavegameVersion(64)) {
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2239 /* copy the signal type/variant and move signal states bits */
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2240 for (TileIndex t = 0; t < map_size; t++) {
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2241 if (IsTileType(t, MP_RAILWAY) && HasSignals(t)) {
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2242 SetSignalStates(t, GB(_m[t].m2, 4, 4));
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2243 SetSignalVariant(t, INVALID_TRACK, GetSignalVariant(t, TRACK_X));
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2244 SetSignalType(t, INVALID_TRACK, GetSignalType(t, TRACK_X));
7929
4d13dbed828c (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7928
diff changeset
2245 ClrBit(_m[t].m2, 7);
6770
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2246 }
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2247 }
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2248 }
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2249
7012
e879a233044e (svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium <rubidium@openttd.org>
parents: 7010
diff changeset
2250 if (CheckSavegameVersion(69)) {
e879a233044e (svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium <rubidium@openttd.org>
parents: 7010
diff changeset
2251 /* In some old savegames a bit was cleared when it should not be cleared */
e879a233044e (svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium <rubidium@openttd.org>
parents: 7010
diff changeset
2252 Vehicle *v;
e879a233044e (svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium <rubidium@openttd.org>
parents: 7010
diff changeset
2253 FOR_ALL_VEHICLES(v) {
e879a233044e (svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium <rubidium@openttd.org>
parents: 7010
diff changeset
2254 if (v->type == VEH_ROAD && (v->u.road.state == 250 || v->u.road.state == 251)) {
7931
44ff7a6d801f (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7929
diff changeset
2255 SetBit(v->u.road.state, RVS_IS_STOPPING);
7012
e879a233044e (svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium <rubidium@openttd.org>
parents: 7010
diff changeset
2256 }
e879a233044e (svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium <rubidium@openttd.org>
parents: 7010
diff changeset
2257 }
e879a233044e (svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium <rubidium@openttd.org>
parents: 7010
diff changeset
2258 }
e879a233044e (svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium <rubidium@openttd.org>
parents: 7010
diff changeset
2259
7186
0a85b5cc61f4 (svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium <rubidium@openttd.org>
parents: 7170
diff changeset
2260 if (CheckSavegameVersion(70)) {
0a85b5cc61f4 (svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium <rubidium@openttd.org>
parents: 7170
diff changeset
2261 /* Added variables to support newindustries */
0a85b5cc61f4 (svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium <rubidium@openttd.org>
parents: 7170
diff changeset
2262 Industry *i;
0a85b5cc61f4 (svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium <rubidium@openttd.org>
parents: 7170
diff changeset
2263 FOR_ALL_INDUSTRIES(i) i->founder = OWNER_NONE;
0a85b5cc61f4 (svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium <rubidium@openttd.org>
parents: 7170
diff changeset
2264 }
0a85b5cc61f4 (svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium <rubidium@openttd.org>
parents: 7170
diff changeset
2265
7739
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2266 /* From version 82, old style canals (above sealevel (0), WATER owner) are no longer supported.
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2267 Replace the owner for those by OWNER_NONE. */
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2268 if (CheckSavegameVersion(82)) {
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2269 for (TileIndex t = 0; t < map_size; t++) {
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2270 if (IsTileType(t, MP_WATER) &&
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2271 GetWaterTileType(t) == WATER_TILE_CLEAR &&
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2272 GetTileOwner(t) == OWNER_WATER &&
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2273 TileHeight(t) != 0) {
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2274 SetTileOwner(t, OWNER_NONE);
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2275 }
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2276 }
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2277 }
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2278
8029
d9a4375b24c0 (svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium <rubidium@openttd.org>
parents: 8013
diff changeset
2279 /*
d9a4375b24c0 (svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium <rubidium@openttd.org>
parents: 8013
diff changeset
2280 * Add the 'previous' owner to the ship depots so we can reset it with
d9a4375b24c0 (svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium <rubidium@openttd.org>
parents: 8013
diff changeset
2281 * the correct values when it gets destroyed. This prevents that
d9a4375b24c0 (svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium <rubidium@openttd.org>
parents: 8013
diff changeset
2282 * someone can remove canals owned by somebody else and it prevents
d9a4375b24c0 (svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium <rubidium@openttd.org>
parents: 8013
diff changeset
2283 * making floods using the removal of ship depots.
d9a4375b24c0 (svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium <rubidium@openttd.org>
parents: 8013
diff changeset
2284 */
d9a4375b24c0 (svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium <rubidium@openttd.org>
parents: 8013
diff changeset
2285 if (CheckSavegameVersion(83)) {
d9a4375b24c0 (svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium <rubidium@openttd.org>
parents: 8013
diff changeset
2286 for (TileIndex t = 0; t < map_size; t++) {
d9a4375b24c0 (svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium <rubidium@openttd.org>
parents: 8013
diff changeset
2287 if (IsTileType(t, MP_WATER) && IsShipDepot(t)) {
d9a4375b24c0 (svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium <rubidium@openttd.org>
parents: 8013
diff changeset
2288 _m[t].m4 = (TileHeight(t) == 0) ? OWNER_WATER : OWNER_NONE;
d9a4375b24c0 (svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium <rubidium@openttd.org>
parents: 8013
diff changeset
2289 }
d9a4375b24c0 (svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium <rubidium@openttd.org>
parents: 8013
diff changeset
2290 }
d9a4375b24c0 (svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium <rubidium@openttd.org>
parents: 8013
diff changeset
2291 }
d9a4375b24c0 (svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium <rubidium@openttd.org>
parents: 8013
diff changeset
2292
7515
47b4eb921138 (svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium <rubidium@openttd.org>
parents: 7475
diff changeset
2293 if (CheckSavegameVersion(74)) {
47b4eb921138 (svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium <rubidium@openttd.org>
parents: 7475
diff changeset
2294 Station *st;
47b4eb921138 (svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium <rubidium@openttd.org>
parents: 7475
diff changeset
2295 FOR_ALL_STATIONS(st) {
47b4eb921138 (svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium <rubidium@openttd.org>
parents: 7475
diff changeset
2296 for (CargoID c = 0; c < NUM_CARGO; c++) {
47b4eb921138 (svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium <rubidium@openttd.org>
parents: 7475
diff changeset
2297 st->goods[c].last_speed = 0;
7931
44ff7a6d801f (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7929
diff changeset
2298 if (st->goods[c].cargo.Count() != 0) SetBit(st->goods[c].acceptance_pickup, GoodsEntry::PICKUP);
7515
47b4eb921138 (svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium <rubidium@openttd.org>
parents: 7475
diff changeset
2299 }
47b4eb921138 (svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium <rubidium@openttd.org>
parents: 7475
diff changeset
2300 }
47b4eb921138 (svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium <rubidium@openttd.org>
parents: 7475
diff changeset
2301 }
47b4eb921138 (svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium <rubidium@openttd.org>
parents: 7475
diff changeset
2302
7645
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2303 if (CheckSavegameVersion(78)) {
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2304 Industry *i;
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2305 uint j;
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2306 FOR_ALL_INDUSTRIES(i) {
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2307 const IndustrySpec *indsp = GetIndustrySpec(i->type);
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2308 for (j = 0; j < lengthof(i->produced_cargo); j++) {
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2309 i->produced_cargo[j] = indsp->produced_cargo[j];
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2310 }
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2311 for (j = 0; j < lengthof(i->accepts_cargo); j++) {
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2312 i->accepts_cargo[j] = indsp->accepts_cargo[j];
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2313 }
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2314 }
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2315 }
6643
18d58b36b9b3 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium <rubidium@openttd.org>
parents: 6629
diff changeset
2316
7710
b94ccc58ce55 (svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight <truelight@openttd.org>
parents: 7645
diff changeset
2317 /* Before version 81, the density of grass was always stored as zero, and
b94ccc58ce55 (svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight <truelight@openttd.org>
parents: 7645
diff changeset
2318 * grassy trees were always drawn fully grassy. Furthermore, trees on rough
b94ccc58ce55 (svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight <truelight@openttd.org>
parents: 7645
diff changeset
2319 * land used to have zero density, now they have full density. Therefore,
b94ccc58ce55 (svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight <truelight@openttd.org>
parents: 7645
diff changeset
2320 * make all grassy/rough land trees have a density of 3. */
b94ccc58ce55 (svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight <truelight@openttd.org>
parents: 7645
diff changeset
2321 if (CheckSavegameVersion(81)) {
b94ccc58ce55 (svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight <truelight@openttd.org>
parents: 7645
diff changeset
2322 for (TileIndex t = 0; t < map_size; t++) {
b94ccc58ce55 (svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight <truelight@openttd.org>
parents: 7645
diff changeset
2323 if (GetTileType(t) == MP_TREES) {
b94ccc58ce55 (svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight <truelight@openttd.org>
parents: 7645
diff changeset
2324 TreeGround groundType = GetTreeGround(t);
b94ccc58ce55 (svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight <truelight@openttd.org>
parents: 7645
diff changeset
2325 if (groundType != TREE_GROUND_SNOW_DESERT) SetTreeGroundDensity(t, groundType, 3);
b94ccc58ce55 (svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight <truelight@openttd.org>
parents: 7645
diff changeset
2326 }
b94ccc58ce55 (svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight <truelight@openttd.org>
parents: 7645
diff changeset
2327 }
b94ccc58ce55 (svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight <truelight@openttd.org>
parents: 7645
diff changeset
2328 }
b94ccc58ce55 (svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight <truelight@openttd.org>
parents: 7645
diff changeset
2329
8926
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2330
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2331 if (CheckSavegameVersion(93)) {
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2332 /* Rework of orders. */
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2333 Order *order;
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2334 FOR_ALL_ORDERS(order) order->ConvertFromOldSavegame();
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2335
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2336 Vehicle *v;
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2337 FOR_ALL_VEHICLES(v) {
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2338 if (v->orders != NULL && !v->orders->IsValid()) v->orders = NULL;
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2339
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2340 v->current_order.ConvertFromOldSavegame();
9941
53ba5561b1c2 (svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents: 9888
diff changeset
2341 if (v->type == VEH_ROAD && v->IsPrimaryVehicle() && v->FirstShared() == v) {
8926
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2342 FOR_VEHICLE_ORDERS(v, order) order->SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2343 }
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2344 }
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2345 } else if (CheckSavegameVersion(94)) {
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2346 /* Unload and transfer are now mutual exclusive. */
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2347 Order *order;
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2348 FOR_ALL_ORDERS(order) {
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2349 if ((order->GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) {
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2350 order->SetUnloadType(OUFB_TRANSFER);
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2351 order->SetLoadType(OLFB_NO_LOAD);
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2352 }
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2353 }
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2354
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2355 Vehicle *v;
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2356 FOR_ALL_VEHICLES(v) {
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2357 if ((v->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) {
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2358 v->current_order.SetUnloadType(OUFB_TRANSFER);
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2359 v->current_order.SetLoadType(OLFB_NO_LOAD);
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2360 }
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2361 }
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2362 }
9999383297b8 (svn r12696) -Fix: loading ancient savegames could result in invalid orders in order lists with all related problems.
rubidium <rubidium@openttd.org>
parents: 8919
diff changeset
2363
8057
99ade4087f55 (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx <glx@openttd.org>
parents: 8029
diff changeset
2364 if (CheckSavegameVersion(84)) {
8155
2ca155c0aef1 (svn r11717) -Fix [FS#1590]: make sure invalid players have all shares owned by PLAYER_SPECTATOR
smatz <smatz@openttd.org>
parents: 8152
diff changeset
2365 /* Update go to buoy orders because they are just waypoints */
8057
99ade4087f55 (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx <glx@openttd.org>
parents: 8029
diff changeset
2366 Order *order;
99ade4087f55 (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx <glx@openttd.org>
parents: 8029
diff changeset
2367 FOR_ALL_ORDERS(order) {
8840
c3d2f0eb69a1 (svn r12588) -Codechange: do not access the destination of an order directly.
rubidium <rubidium@openttd.org>
parents: 8838
diff changeset
2368 if (order->IsType(OT_GOTO_STATION) && GetStation(order->GetDestination())->IsBuoy()) {
8855
2acce887e7ec (svn r12617) -Codechange: add type safety to the Order's load and unload types.
rubidium <rubidium@openttd.org>
parents: 8843
diff changeset
2369 order->SetLoadType(OLF_LOAD_IF_POSSIBLE);
2acce887e7ec (svn r12617) -Codechange: add type safety to the Order's load and unload types.
rubidium <rubidium@openttd.org>
parents: 8843
diff changeset
2370 order->SetUnloadType(OUF_UNLOAD_IF_POSSIBLE);
8057
99ade4087f55 (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx <glx@openttd.org>
parents: 8029
diff changeset
2371 }
99ade4087f55 (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx <glx@openttd.org>
parents: 8029
diff changeset
2372 }
8155
2ca155c0aef1 (svn r11717) -Fix [FS#1590]: make sure invalid players have all shares owned by PLAYER_SPECTATOR
smatz <smatz@openttd.org>
parents: 8152
diff changeset
2373
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2374 /* Set all share owners to INVALID_COMPANY for
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2375 * 1) all inactive companies
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2376 * (when inactive companies were stored in the savegame - TTD, TTDP and some
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2377 * *really* old revisions of OTTD; else it is already set in InitializeCompanies())
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2378 * 2) shares that are owned by inactive companies or self
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2379 * (caused by cheating clients in earlier revisions) */
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2380 FOR_ALL_COMPANIES(c) {
9659
14e241fadc66 (svn r13731) -Codechange: make a pool of the array of players.
rubidium <rubidium@openttd.org>
parents: 9655
diff changeset
2381 for (uint i = 0; i < 4; i++) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2382 CompanyID company = c->share_owners[i];
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2383 if (company == INVALID_COMPANY) continue;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2384 if (!IsValidCompanyID(company) || company == c->index) c->share_owners[i] = INVALID_COMPANY;
8155
2ca155c0aef1 (svn r11717) -Fix [FS#1590]: make sure invalid players have all shares owned by PLAYER_SPECTATOR
smatz <smatz@openttd.org>
parents: 8152
diff changeset
2385 }
2ca155c0aef1 (svn r11717) -Fix [FS#1590]: make sure invalid players have all shares owned by PLAYER_SPECTATOR
smatz <smatz@openttd.org>
parents: 8152
diff changeset
2386 }
8057
99ade4087f55 (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx <glx@openttd.org>
parents: 8029
diff changeset
2387 }
99ade4087f55 (svn r11618) -Fix: buoys are just waypoints, so don't allow load/unload/transfert for them
glx <glx@openttd.org>
parents: 8029
diff changeset
2388
8342
441cda3cfbdb (svn r11908) -Fix: update crossing when merging a company, when building a crossing and after loading older savegame
smatz <smatz@openttd.org>
parents: 8303
diff changeset
2389 if (CheckSavegameVersion(86)) {
441cda3cfbdb (svn r11908) -Fix: update crossing when merging a company, when building a crossing and after loading older savegame
smatz <smatz@openttd.org>
parents: 8303
diff changeset
2390 for (TileIndex t = 0; t < map_size; t++) {
8471
1e4ea519bfaf (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents: 8404
diff changeset
2391 /* Move river flag and update canals to use water class */
1e4ea519bfaf (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents: 8404
diff changeset
2392 if (IsTileType(t, MP_WATER)) {
9200
6de115102b95 (svn r13066) -Fix [FS#2005]: loading of TTDP savegames with rivers in them.
rubidium <rubidium@openttd.org>
parents: 9184
diff changeset
2393 if (GetWaterClass(t) != WATER_CLASS_RIVER) {
8495
486b50380194 (svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch <frosch@openttd.org>
parents: 8471
diff changeset
2394 if (IsWater(t)) {
486b50380194 (svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch <frosch@openttd.org>
parents: 8471
diff changeset
2395 Owner o = GetTileOwner(t);
486b50380194 (svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch <frosch@openttd.org>
parents: 8471
diff changeset
2396 if (o == OWNER_WATER) {
486b50380194 (svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch <frosch@openttd.org>
parents: 8471
diff changeset
2397 MakeWater(t);
486b50380194 (svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch <frosch@openttd.org>
parents: 8471
diff changeset
2398 } else {
486b50380194 (svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch <frosch@openttd.org>
parents: 8471
diff changeset
2399 MakeCanal(t, o, Random());
486b50380194 (svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch <frosch@openttd.org>
parents: 8471
diff changeset
2400 }
486b50380194 (svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch <frosch@openttd.org>
parents: 8471
diff changeset
2401 } else if (IsShipDepot(t)) {
486b50380194 (svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch <frosch@openttd.org>
parents: 8471
diff changeset
2402 Owner o = (Owner)_m[t].m4; // Original water owner
486b50380194 (svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch <frosch@openttd.org>
parents: 8471
diff changeset
2403 SetWaterClass(t, o == OWNER_WATER ? WATER_CLASS_SEA : WATER_CLASS_CANAL);
8471
1e4ea519bfaf (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents: 8404
diff changeset
2404 }
1e4ea519bfaf (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents: 8404
diff changeset
2405 }
1e4ea519bfaf (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents: 8404
diff changeset
2406 }
1e4ea519bfaf (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents: 8404
diff changeset
2407 }
1e4ea519bfaf (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents: 8404
diff changeset
2408
1e4ea519bfaf (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents: 8404
diff changeset
2409 /* Update locks, depots, docks and buoys to have a water class based
1e4ea519bfaf (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents: 8404
diff changeset
2410 * on its neighbouring tiles. Done after river and canal updates to
1e4ea519bfaf (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents: 8404
diff changeset
2411 * ensure neighbours are correct. */
1e4ea519bfaf (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents: 8404
diff changeset
2412 for (TileIndex t = 0; t < map_size; t++) {
1e4ea519bfaf (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents: 8404
diff changeset
2413 if (GetTileSlope(t, NULL) != SLOPE_FLAT) continue;
1e4ea519bfaf (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents: 8404
diff changeset
2414
9718
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2415 if (IsTileType(t, MP_WATER) && IsLock(t)) SetWaterClassDependingOnSurroundings(t, false);
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2416 if (IsTileType(t, MP_STATION) && (IsDock(t) || IsBuoy(t))) SetWaterClassDependingOnSurroundings(t, false);
8342
441cda3cfbdb (svn r11908) -Fix: update crossing when merging a company, when building a crossing and after loading older savegame
smatz <smatz@openttd.org>
parents: 8303
diff changeset
2417 }
441cda3cfbdb (svn r11908) -Fix: update crossing when merging a company, when building a crossing and after loading older savegame
smatz <smatz@openttd.org>
parents: 8303
diff changeset
2418 }
441cda3cfbdb (svn r11908) -Fix: update crossing when merging a company, when building a crossing and after loading older savegame
smatz <smatz@openttd.org>
parents: 8303
diff changeset
2419
8521
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2420 if (CheckSavegameVersion(87)) {
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2421 for (TileIndex t = 0; t < map_size; t++) {
8613
35e7bec4c738 (svn r12195) -Fix [FS#1787](r12100): there can be oil rigs at map borders, do not set water class for them
smatz <smatz@openttd.org>
parents: 8598
diff changeset
2422 /* skip oil rigs at borders! */
35e7bec4c738 (svn r12195) -Fix [FS#1787](r12100): there can be oil rigs at map borders, do not set water class for them
smatz <smatz@openttd.org>
parents: 8598
diff changeset
2423 if ((IsTileType(t, MP_WATER) || IsBuoyTile(t)) &&
35e7bec4c738 (svn r12195) -Fix [FS#1787](r12100): there can be oil rigs at map borders, do not set water class for them
smatz <smatz@openttd.org>
parents: 8598
diff changeset
2424 (TileX(t) == 0 || TileY(t) == 0 || TileX(t) == MapMaxX() - 1 || TileY(t) == MapMaxY() - 1)) {
8525
433c2575e919 (svn r12100) -Fix (r12042): check for water class of surrounding tiles fails for buoys at map borders
smatz <smatz@openttd.org>
parents: 8521
diff changeset
2425 /* Some version 86 savegames have wrong water class at map borders (under buoy, or after removing buoy).
433c2575e919 (svn r12100) -Fix (r12042): check for water class of surrounding tiles fails for buoys at map borders
smatz <smatz@openttd.org>
parents: 8521
diff changeset
2426 * This conversion has to be done before buoys with invalid owner are removed. */
433c2575e919 (svn r12100) -Fix (r12042): check for water class of surrounding tiles fails for buoys at map borders
smatz <smatz@openttd.org>
parents: 8521
diff changeset
2427 SetWaterClass(t, WATER_CLASS_SEA);
433c2575e919 (svn r12100) -Fix (r12042): check for water class of surrounding tiles fails for buoys at map borders
smatz <smatz@openttd.org>
parents: 8521
diff changeset
2428 }
433c2575e919 (svn r12100) -Fix (r12042): check for water class of surrounding tiles fails for buoys at map borders
smatz <smatz@openttd.org>
parents: 8521
diff changeset
2429
8521
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2430 if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2431 Owner o = GetTileOwner(t);
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2432 if (o < MAX_COMPANIES && !IsValidCompanyID(o)) {
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2433 _current_company = o;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2434 ChangeTileOwner(t, o, INVALID_OWNER);
8521
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2435 }
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2436 if (IsBuoyTile(t)) {
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2437 /* reset buoy owner to OWNER_NONE in the station struct
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2438 * (even if it is owned by active company) */
8521
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2439 GetStationByTile(t)->owner = OWNER_NONE;
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2440 }
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2441 } else if (IsTileType(t, MP_ROAD)) {
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2442 /* works for all RoadTileType */
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2443 for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2444 /* update even non-existing road types to update tile owner too */
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2445 Owner o = GetRoadOwner(t, rt);
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2446 if (o < MAX_COMPANIES && !IsValidCompanyID(o)) SetRoadOwner(t, rt, OWNER_NONE);
8521
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2447 }
8563
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8556
diff changeset
2448 if (IsLevelCrossing(t)) {
8521
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2449 Owner o = GetTileOwner(t);
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2450 if (!IsValidCompanyID(o)) {
8521
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2451 /* remove leftover rail piece from crossing (from very old savegames) */
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2452 _current_company = o;
8598
ef2c93a9589d (svn r12179) -Codechange: use GetCrossingRailTrack() and GetCrossingRailAxis() to improve code readability
smatz <smatz@openttd.org>
parents: 8563
diff changeset
2453 DoCommand(t, 0, GetCrossingRailTrack(t), DC_EXEC | DC_BANKRUPT, CMD_REMOVE_SINGLE_RAIL);
8521
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2454 }
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2455 }
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2456 }
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2457 }
8551
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2458
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2459 /* Convert old PF settings to new */
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
2460 if (_settings_game.pf.yapf.rail_use_yapf || CheckSavegameVersion(28)) {
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
2461 _settings_game.pf.pathfinder_for_trains = VPF_YAPF;
8551
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2462 } else {
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
2463 _settings_game.pf.pathfinder_for_trains = (_settings_game.pf.new_pathfinding_all ? VPF_NPF : VPF_NTP);
8551
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2464 }
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2465
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
2466 if (_settings_game.pf.yapf.road_use_yapf || CheckSavegameVersion(28)) {
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
2467 _settings_game.pf.pathfinder_for_roadvehs = VPF_YAPF;
8551
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2468 } else {
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
2469 _settings_game.pf.pathfinder_for_roadvehs = (_settings_game.pf.new_pathfinding_all ? VPF_NPF : VPF_OPF);
8551
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2470 }
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2471
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
2472 if (_settings_game.pf.yapf.ship_use_yapf) {
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
2473 _settings_game.pf.pathfinder_for_ships = VPF_YAPF;
8551
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2474 } else {
9413
512ea64da840 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents: 9411
diff changeset
2475 _settings_game.pf.pathfinder_for_ships = (_settings_game.pf.new_pathfinding_all ? VPF_NPF : VPF_OPF);
8551
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2476 }
8521
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2477 }
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2478
8556
8aae08d562cc (svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz <smatz@openttd.org>
parents: 8551
diff changeset
2479 if (CheckSavegameVersion(88)) {
8aae08d562cc (svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz <smatz@openttd.org>
parents: 8551
diff changeset
2480 /* Profits are now with 8 bit fract */
8aae08d562cc (svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz <smatz@openttd.org>
parents: 8551
diff changeset
2481 Vehicle *v;
8aae08d562cc (svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz <smatz@openttd.org>
parents: 8551
diff changeset
2482 FOR_ALL_VEHICLES(v) {
8aae08d562cc (svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz <smatz@openttd.org>
parents: 8551
diff changeset
2483 v->profit_this_year <<= 8;
8aae08d562cc (svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz <smatz@openttd.org>
parents: 8551
diff changeset
2484 v->profit_last_year <<= 8;
8aae08d562cc (svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz <smatz@openttd.org>
parents: 8551
diff changeset
2485 v->running_ticks = 0;
8aae08d562cc (svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz <smatz@openttd.org>
parents: 8551
diff changeset
2486 }
8aae08d562cc (svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz <smatz@openttd.org>
parents: 8551
diff changeset
2487 }
8aae08d562cc (svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz <smatz@openttd.org>
parents: 8551
diff changeset
2488
8681
051357af9f76 (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch <frosch@openttd.org>
parents: 8670
diff changeset
2489 if (CheckSavegameVersion(91)) {
051357af9f76 (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch <frosch@openttd.org>
parents: 8670
diff changeset
2490 /* Increase HouseAnimationFrame from 5 to 7 bits */
051357af9f76 (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch <frosch@openttd.org>
parents: 8670
diff changeset
2491 for (TileIndex t = 0; t < map_size; t++) {
051357af9f76 (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch <frosch@openttd.org>
parents: 8670
diff changeset
2492 if (IsTileType(t, MP_HOUSE) && GetHouseType(t) >= NEW_HOUSE_OFFSET) {
051357af9f76 (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch <frosch@openttd.org>
parents: 8670
diff changeset
2493 SetHouseAnimationFrame(t, GB(_m[t].m6, 3, 5));
051357af9f76 (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch <frosch@openttd.org>
parents: 8670
diff changeset
2494 }
051357af9f76 (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch <frosch@openttd.org>
parents: 8670
diff changeset
2495 }
051357af9f76 (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch <frosch@openttd.org>
parents: 8670
diff changeset
2496 }
051357af9f76 (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch <frosch@openttd.org>
parents: 8670
diff changeset
2497
9057
590756c32881 (svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
smatz <smatz@openttd.org>
parents: 9039
diff changeset
2498 if (CheckSavegameVersion(62)) {
590756c32881 (svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
smatz <smatz@openttd.org>
parents: 9039
diff changeset
2499 /* Remove all trams from savegames without tram support.
590756c32881 (svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
smatz <smatz@openttd.org>
parents: 9039
diff changeset
2500 * There would be trams without tram track under causing crashes sooner or later. */
590756c32881 (svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
smatz <smatz@openttd.org>
parents: 9039
diff changeset
2501 Vehicle *v;
590756c32881 (svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
smatz <smatz@openttd.org>
parents: 9039
diff changeset
2502 FOR_ALL_VEHICLES(v) {
590756c32881 (svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
smatz <smatz@openttd.org>
parents: 9039
diff changeset
2503 if (v->type == VEH_ROAD && v->First() == v &&
590756c32881 (svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
smatz <smatz@openttd.org>
parents: 9039
diff changeset
2504 HasBit(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM)) {
590756c32881 (svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
smatz <smatz@openttd.org>
parents: 9039
diff changeset
2505 if (_switch_mode_errorstr == INVALID_STRING_ID || _switch_mode_errorstr == STR_NEWGRF_COMPATIBLE_LOAD_WARNING) {
590756c32881 (svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
smatz <smatz@openttd.org>
parents: 9039
diff changeset
2506 _switch_mode_errorstr = STR_LOADGAME_REMOVED_TRAMS;
590756c32881 (svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
smatz <smatz@openttd.org>
parents: 9039
diff changeset
2507 }
590756c32881 (svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
smatz <smatz@openttd.org>
parents: 9039
diff changeset
2508 delete v;
590756c32881 (svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
smatz <smatz@openttd.org>
parents: 9039
diff changeset
2509 }
590756c32881 (svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
smatz <smatz@openttd.org>
parents: 9039
diff changeset
2510 }
590756c32881 (svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
smatz <smatz@openttd.org>
parents: 9039
diff changeset
2511 }
590756c32881 (svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
smatz <smatz@openttd.org>
parents: 9039
diff changeset
2512
9718
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2513 if (CheckSavegameVersion(99)) {
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2514 for (TileIndex t = 0; t < map_size; t++) {
10360
d352cf399eb7 (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch <frosch@openttd.org>
parents: 10347
diff changeset
2515 /* Set newly introduced WaterClass of industry tiles */
9718
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2516 if (IsTileType(t, MP_STATION) && IsOilRig(t)) {
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2517 SetWaterClassDependingOnSurroundings(t, true);
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2518 }
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2519 if (IsTileType(t, MP_INDUSTRY)) {
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2520 if ((GetIndustrySpec(GetIndustryType(t))->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0) {
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2521 SetWaterClassDependingOnSurroundings(t, true);
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2522 } else {
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2523 SetWaterClass(t, WATER_CLASS_INVALID);
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2524 }
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2525 }
10360
d352cf399eb7 (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch <frosch@openttd.org>
parents: 10347
diff changeset
2526
d352cf399eb7 (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch <frosch@openttd.org>
parents: 10347
diff changeset
2527 /* Replace "house construction year" with "house age" */
d352cf399eb7 (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch <frosch@openttd.org>
parents: 10347
diff changeset
2528 if (IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)) {
d352cf399eb7 (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch <frosch@openttd.org>
parents: 10347
diff changeset
2529 _m[t].m5 = Clamp(_cur_year - (_m[t].m5 + ORIGINAL_BASE_YEAR), 0, 0xFF);
d352cf399eb7 (svn r14611) -Fix (r13437)[FS#2421]: Store the age of a house in the map array instead of the construction year.
frosch <frosch@openttd.org>
parents: 10347
diff changeset
2530 }
9718
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2531 }
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2532 }
3c66bb36c785 (svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch <frosch@openttd.org>
parents: 9717
diff changeset
2533
9790
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2534 /* Move the signal variant back up one bit for PBS. We don't convert the old PBS
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2535 * format here, as an old layout wouldn't work properly anyway. To be safe, we
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2536 * clear any possible PBS reservations as well. */
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2537 if (CheckSavegameVersion(100)) {
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2538 for (TileIndex t = 0; t < map_size; t++) {
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2539 switch (GetTileType(t)) {
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2540 case MP_RAILWAY:
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2541 if (HasSignals(t)) {
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2542 /* move the signal variant */
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2543 SetSignalVariant(t, TRACK_UPPER, HasBit(_m[t].m2, 2) ? SIG_SEMAPHORE : SIG_ELECTRIC);
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2544 SetSignalVariant(t, TRACK_LOWER, HasBit(_m[t].m2, 6) ? SIG_SEMAPHORE : SIG_ELECTRIC);
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2545 ClrBit(_m[t].m2, 2);
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2546 ClrBit(_m[t].m2, 6);
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2547 }
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2548
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2549 /* Clear PBS reservation on track */
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2550 if (IsRailDepot(t) ||IsRailWaypoint(t)) {
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2551 SetDepotWaypointReservation(t, false);
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2552 } else {
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2553 SetTrackReservation(t, TRACK_BIT_NONE);
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2554 }
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2555 break;
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2556
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2557 case MP_ROAD: /* Clear PBS reservation on crossing */
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2558 if (IsLevelCrossing(t)) SetCrossingReservation(t, false);
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2559 break;
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2560
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2561 case MP_STATION: /* Clear PBS reservation on station */
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2562 if (IsRailwayStation(t)) SetRailwayStationReservation(t, false);
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2563 break;
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2564
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2565 case MP_TUNNELBRIDGE: /* Clear PBS reservation on tunnels/birdges */
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2566 if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) SetTunnelBridgeReservation(t, false);
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2567 break;
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2568
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2569 default: break;
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2570 }
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2571 }
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2572 }
f5b8e5291165 (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9730
diff changeset
2573
9888
b849464ebe27 (svn r14036) -Fix [FS#2197,FS#2198]: trains crashing into eachother when signals are changed (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
2574 /* Reserve all tracks trains are currently on. */
b849464ebe27 (svn r14036) -Fix [FS#2197,FS#2198]: trains crashing into eachother when signals are changed (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
2575 if (CheckSavegameVersion(101)) {
b849464ebe27 (svn r14036) -Fix [FS#2197,FS#2198]: trains crashing into eachother when signals are changed (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
2576 Vehicle *v;
b849464ebe27 (svn r14036) -Fix [FS#2197,FS#2198]: trains crashing into eachother when signals are changed (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
2577 FOR_ALL_VEHICLES(v) {
b849464ebe27 (svn r14036) -Fix [FS#2197,FS#2198]: trains crashing into eachother when signals are changed (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
2578 if (v->type == VEH_TRAIN) {
b849464ebe27 (svn r14036) -Fix [FS#2197,FS#2198]: trains crashing into eachother when signals are changed (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
2579 if ((v->u.rail.track & TRACK_BIT_WORMHOLE) == TRACK_BIT_WORMHOLE) {
b849464ebe27 (svn r14036) -Fix [FS#2197,FS#2198]: trains crashing into eachother when signals are changed (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
2580 TryReserveRailTrack(v->tile, DiagDirToDiagTrack(GetTunnelBridgeDirection(v->tile)));
b849464ebe27 (svn r14036) -Fix [FS#2197,FS#2198]: trains crashing into eachother when signals are changed (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
2581 } else if ((v->u.rail.track & TRACK_BIT_MASK) != TRACK_BIT_NONE) {
b849464ebe27 (svn r14036) -Fix [FS#2197,FS#2198]: trains crashing into eachother when signals are changed (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
2582 TryReserveRailTrack(v->tile, TrackBitsToTrack(v->u.rail.track));
b849464ebe27 (svn r14036) -Fix [FS#2197,FS#2198]: trains crashing into eachother when signals are changed (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
2583 }
b849464ebe27 (svn r14036) -Fix [FS#2197,FS#2198]: trains crashing into eachother when signals are changed (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
2584 }
b849464ebe27 (svn r14036) -Fix [FS#2197,FS#2198]: trains crashing into eachother when signals are changed (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
2585 }
9978
793681882d37 (svn r14135) -Codechange: Add owner to waypoints. Previously, it was guessed from rail underneath it.
belugas <belugas@openttd.org>
parents: 9950
diff changeset
2586
793681882d37 (svn r14135) -Codechange: Add owner to waypoints. Previously, it was guessed from rail underneath it.
belugas <belugas@openttd.org>
parents: 9950
diff changeset
2587 /* Give owners to waypoints, based on rail tracks it is sitting on.
793681882d37 (svn r14135) -Codechange: Add owner to waypoints. Previously, it was guessed from rail underneath it.
belugas <belugas@openttd.org>
parents: 9950
diff changeset
2588 * If none is available, specify OWNER_NONE */
793681882d37 (svn r14135) -Codechange: Add owner to waypoints. Previously, it was guessed from rail underneath it.
belugas <belugas@openttd.org>
parents: 9950
diff changeset
2589 Waypoint *wp;
793681882d37 (svn r14135) -Codechange: Add owner to waypoints. Previously, it was guessed from rail underneath it.
belugas <belugas@openttd.org>
parents: 9950
diff changeset
2590 FOR_ALL_WAYPOINTS(wp) {
10099
3bb7e18e8b0a (svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
smatz <smatz@openttd.org>
parents: 10039
diff changeset
2591 Owner owner = (IsRailWaypointTile(wp->xy) ? GetTileOwner(wp->xy) : OWNER_NONE);
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2592 wp->owner = IsValidCompanyID(owner) ? owner : OWNER_NONE;
9978
793681882d37 (svn r14135) -Codechange: Add owner to waypoints. Previously, it was guessed from rail underneath it.
belugas <belugas@openttd.org>
parents: 9950
diff changeset
2593 }
9888
b849464ebe27 (svn r14036) -Fix [FS#2197,FS#2198]: trains crashing into eachother when signals are changed (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
2594 }
b849464ebe27 (svn r14036) -Fix [FS#2197,FS#2198]: trains crashing into eachother when signals are changed (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9790
diff changeset
2595
10106
791509dcfef5 (svn r14290) -Fix (r13932): level crossings could be barred when they shouldn't be after savegame conversion
smatz <smatz@openttd.org>
parents: 10099
diff changeset
2596 if (CheckSavegameVersion(102)) {
791509dcfef5 (svn r14290) -Fix (r13932): level crossings could be barred when they shouldn't be after savegame conversion
smatz <smatz@openttd.org>
parents: 10099
diff changeset
2597 for (TileIndex t = 0; t < map_size; t++) {
791509dcfef5 (svn r14290) -Fix (r13932): level crossings could be barred when they shouldn't be after savegame conversion
smatz <smatz@openttd.org>
parents: 10099
diff changeset
2598 /* Now all crossings should be in correct state */
791509dcfef5 (svn r14290) -Fix (r13932): level crossings could be barred when they shouldn't be after savegame conversion
smatz <smatz@openttd.org>
parents: 10099
diff changeset
2599 if (IsLevelCrossingTile(t)) UpdateLevelCrossing(t, false);
791509dcfef5 (svn r14290) -Fix (r13932): level crossings could be barred when they shouldn't be after savegame conversion
smatz <smatz@openttd.org>
parents: 10099
diff changeset
2600 }
791509dcfef5 (svn r14290) -Fix (r13932): level crossings could be barred when they shouldn't be after savegame conversion
smatz <smatz@openttd.org>
parents: 10099
diff changeset
2601 }
791509dcfef5 (svn r14290) -Fix (r13932): level crossings could be barred when they shouldn't be after savegame conversion
smatz <smatz@openttd.org>
parents: 10099
diff changeset
2602
10158
c429fccf1aea (svn r14348) -Fix (r1667): signs were not updated on company bankrupcy/sell, they have colour of invalid player
smatz <smatz@openttd.org>
parents: 10153
diff changeset
2603 if (CheckSavegameVersion(103)) {
10289
5f3f0d0a6e07 (svn r14528) -Codechange: cache the closest town for all road tiles instead of only roads owned by tiles. This replaces a O(n) search over all towns from the road's tileloop with a O(1) lookup (PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10262
diff changeset
2604 /* Non-town-owned roads now store the closest town */
10340
e3f0f062c7c3 (svn r14591) -Fix [FS#2388](r14528): cached nearest town could be invalid after importing older savegame and during town generation
smatz <smatz@openttd.org>
parents: 10310
diff changeset
2605 UpdateNearestTownForRoadTiles(false);
10289
5f3f0d0a6e07 (svn r14528) -Codechange: cache the closest town for all road tiles instead of only roads owned by tiles. This replaces a O(n) search over all towns from the road's tileloop with a O(1) lookup (PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10262
diff changeset
2606
10158
c429fccf1aea (svn r14348) -Fix (r1667): signs were not updated on company bankrupcy/sell, they have colour of invalid player
smatz <smatz@openttd.org>
parents: 10153
diff changeset
2607 /* signs with invalid owner left from older savegames */
c429fccf1aea (svn r14348) -Fix (r1667): signs were not updated on company bankrupcy/sell, they have colour of invalid player
smatz <smatz@openttd.org>
parents: 10153
diff changeset
2608 Sign *si;
c429fccf1aea (svn r14348) -Fix (r1667): signs were not updated on company bankrupcy/sell, they have colour of invalid player
smatz <smatz@openttd.org>
parents: 10153
diff changeset
2609 FOR_ALL_SIGNS(si) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2610 if (si->owner != OWNER_NONE && !IsValidCompanyID(si->owner)) si->owner = OWNER_NONE;
10158
c429fccf1aea (svn r14348) -Fix (r1667): signs were not updated on company bankrupcy/sell, they have colour of invalid player
smatz <smatz@openttd.org>
parents: 10153
diff changeset
2611 }
10347
001e5d0511d5 (svn r14598) -Feature: Action0Industries property 24 (industry suuplies default name for nearby station).
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
2612
001e5d0511d5 (svn r14598) -Feature: Action0Industries property 24 (industry suuplies default name for nearby station).
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
2613 /* Station can get named based on an industry type, but the current ones
001e5d0511d5 (svn r14598) -Feature: Action0Industries property 24 (industry suuplies default name for nearby station).
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
2614 * are not, so mark them as if they are not named by an industry. */
001e5d0511d5 (svn r14598) -Feature: Action0Industries property 24 (industry suuplies default name for nearby station).
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
2615 Station *st;
001e5d0511d5 (svn r14598) -Feature: Action0Industries property 24 (industry suuplies default name for nearby station).
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
2616 FOR_ALL_STATIONS(st) {
001e5d0511d5 (svn r14598) -Feature: Action0Industries property 24 (industry suuplies default name for nearby station).
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
2617 st->indtype = IT_INVALID;
001e5d0511d5 (svn r14598) -Feature: Action0Industries property 24 (industry suuplies default name for nearby station).
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
2618 }
10158
c429fccf1aea (svn r14348) -Fix (r1667): signs were not updated on company bankrupcy/sell, they have colour of invalid player
smatz <smatz@openttd.org>
parents: 10153
diff changeset
2619 }
10106
791509dcfef5 (svn r14290) -Fix (r13932): level crossings could be barred when they shouldn't be after savegame conversion
smatz <smatz@openttd.org>
parents: 10099
diff changeset
2620
10429
dd4c3a781f56 (svn r14682) -Fix (r14672): Check the correct savegame version. (Thanks SmatZ)
frosch <frosch@openttd.org>
parents: 10419
diff changeset
2621 if (CheckSavegameVersion(104)) {
10419
e723ec01b3a6 (svn r14672) -Fix [FS#2444]: Property 7 and callback 12 were broken for aircraft.
frosch <frosch@openttd.org>
parents: 10380
diff changeset
2622 Vehicle *v;
e723ec01b3a6 (svn r14672) -Fix [FS#2444]: Property 7 and callback 12 were broken for aircraft.
frosch <frosch@openttd.org>
parents: 10380
diff changeset
2623 FOR_ALL_VEHICLES(v) {
e723ec01b3a6 (svn r14672) -Fix [FS#2444]: Property 7 and callback 12 were broken for aircraft.
frosch <frosch@openttd.org>
parents: 10380
diff changeset
2624 /* Set engine_type of shadow and rotor */
e723ec01b3a6 (svn r14672) -Fix [FS#2444]: Property 7 and callback 12 were broken for aircraft.
frosch <frosch@openttd.org>
parents: 10380
diff changeset
2625 if (v->type == VEH_AIRCRAFT && !IsNormalAircraft(v)) {
e723ec01b3a6 (svn r14672) -Fix [FS#2444]: Property 7 and callback 12 were broken for aircraft.
frosch <frosch@openttd.org>
parents: 10380
diff changeset
2626 v->engine_type = v->First()->engine_type;
e723ec01b3a6 (svn r14672) -Fix [FS#2444]: Property 7 and callback 12 were broken for aircraft.
frosch <frosch@openttd.org>
parents: 10380
diff changeset
2627 }
e723ec01b3a6 (svn r14672) -Fix [FS#2444]: Property 7 and callback 12 were broken for aircraft.
frosch <frosch@openttd.org>
parents: 10380
diff changeset
2628 }
10480
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2629
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2630 /* More companies ... */
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2631 Company *c;
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2632 FOR_ALL_COMPANIES(c) {
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2633 if (c->bankrupt_asked == 0xFF) c->bankrupt_asked = 0xFFFF;
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2634 }
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2635
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2636 Engine *e;
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2637 FOR_ALL_ENGINES(e) {
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2638 if (e->company_avail == 0xFF) e->company_avail = 0xFFFF;
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2639 }
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2640
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2641 Town *t;
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2642 FOR_ALL_TOWNS(t) {
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2643 if (t->have_ratings == 0xFF) t->have_ratings = 0xFFFF;
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2644 for (uint i = 8; i != MAX_COMPANIES; i++) t->ratings[i] = RATING_INITIAL;
649ba332458f (svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
rubidium <rubidium@openttd.org>
parents: 10445
diff changeset
2645 }
10419
e723ec01b3a6 (svn r14672) -Fix [FS#2444]: Property 7 and callback 12 were broken for aircraft.
frosch <frosch@openttd.org>
parents: 10380
diff changeset
2646 }
e723ec01b3a6 (svn r14672) -Fix [FS#2444]: Property 7 and callback 12 were broken for aircraft.
frosch <frosch@openttd.org>
parents: 10380
diff changeset
2647
9655
8cff5d45a15f (svn r13727) -Fix (r13375): compilation with NO_DEBUG_MESSAGES was broken
smatz <smatz@openttd.org>
parents: 9652
diff changeset
2648 GamelogPrintDebug(1);
9457
267a95510fdf (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents: 9429
diff changeset
2649
7981
71f89e3a19f6 (svn r11537) -Codechange: make it much harder to 'accidentally' add savegame conversion code after the window and cache initializations.
rubidium <rubidium@openttd.org>
parents: 7969
diff changeset
2650 return InitializeWindowsAndCaches();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2651 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2652
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2653 /** Reload all NewGRF files during a running game. This is a cut-down
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2654 * version of AfterLoadGame().
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2655 * XXX - We need to reset the vehicle position hash because with a non-empty
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2656 * hash AfterLoadVehicles() will loop infinitely. We need AfterLoadVehicles()
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2657 * to recalculate vehicle data as some NewGRF vehicle sets could have been
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2658 * removed or added and changed statistics */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
2659 void ReloadNewGRFData()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2660 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2661 /* reload grf data */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2662 GfxLoadSprites();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2663 LoadStringWidthTable();
9717
57549f1e5133 (svn r13836) -Fix [FS#2074]: Automatically recalculate inflation if NewGRFs are changed and cargo types are added, so that cargo payment rates are correct.
peter1138 <peter1138@openttd.org>
parents: 9704
diff changeset
2664 ResetEconomy();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2665 /* reload vehicles */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2666 ResetVehiclePosHash();
8172
465c2493606f (svn r11735) -Fix [FS#1574]: Don't reset loading indicator IDs when only reloading NewGRFs.
peter1138 <peter1138@openttd.org>
parents: 8157
diff changeset
2667 AfterLoadVehicles(false);
6196
a68986f10bb5 (svn r8976) -Codechange: Reinitialize all engines after grf files have been reloaded/changed.
Darkvater <Darkvater@openttd.org>
parents: 6193
diff changeset
2668 StartupEngines();
9220
baa148485404 (svn r13086) -Fix: do not crash badly after loading a newgrf with engines in-game that often
smatz <smatz@openttd.org>
parents: 9211
diff changeset
2669 SetCachedEngineCounts();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2670 /* update station and waypoint graphics */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2671 AfterLoadWaypoints();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2672 AfterLoadStations();
8707
64bd5cfc6426 (svn r12381) -Fix [FS1835] [FS1535] (r11855): The number of houses wasn't computed right. A few other things regaring the updating had to be changed. Big thanks for support to frosch123 and SmatZ, to name just a few. (Inspired by a patch of bilbo)
skidd13 <skidd13@openttd.org>
parents: 8681
diff changeset
2673 /* Check and update house and town values */
64bd5cfc6426 (svn r12381) -Fix [FS1835] [FS1535] (r11855): The number of houses wasn't computed right. A few other things regaring the updating had to be changed. Big thanks for support to frosch123 and SmatZ, to name just a few. (Inspired by a patch of bilbo)
skidd13 <skidd13@openttd.org>
parents: 8681
diff changeset
2674 UpdateHousesAndTowns();
9230
d5aa4b27d75c (svn r13096) -Codechange: resize SelectPlayerLiveryWindow dynamically on _loaded_newgrf_feature.has_2CC changes
glx <glx@openttd.org>
parents: 9220
diff changeset
2675 /* Update livery selection windows */
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
2676 for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) InvalidateWindowData(WC_COMPANY_COLOR, i, _loaded_newgrf_features.has_2CC);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2677 /* redraw the whole screen */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2678 MarkWholeScreenDirty();
9704
e1476334067a (svn r13816) -Fix [FS#2150]: check for vehicle length changes outside a depot (callback 0x11) and give a warning about that
smatz <smatz@openttd.org>
parents: 9667
diff changeset
2679 CheckTrainsLengths();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2680 }