annotate src/openttd.cpp @ 9111:d48433370037 draft

(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.
author rubidium <rubidium@openttd.org>
date Tue, 06 May 2008 15:11:33 +0000
parents 1ee48402dd02
children 046d0b6e0218
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 #include "network/network_internal.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
10 #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
11
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
12 #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
13
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 "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
15 #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
16 #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
17 #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
18 #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
19
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
20 #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
21 #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
22 #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
23 #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
24 #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
25 #include "sound_func.h"
8224
c45446125bf0 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents: 8214
diff changeset
26 #include "viewport_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
27 #include "window_func.h"
8106
47b1794a7eca (svn r11667) -Codechange: split window.h into a header that defines some 'global' window related types, on that defined 'global' window functions and one that defines functions and types only used by *_gui.cpps.
rubidium <rubidium@openttd.org>
parents: 8095
diff changeset
28 #include "window_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
29 #include "zoom_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
30
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
31 #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
32 #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
33 #include "landscape.h"
8254
7d580c9c41fb (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium <rubidium@openttd.org>
parents: 8247
diff changeset
34 #include "player_func.h"
7d580c9c41fb (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium <rubidium@openttd.org>
parents: 8247
diff changeset
35 #include "player_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
36 #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
37 #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
38 #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
39 #include "news_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
40 #include "fileio.h"
8151
bee108a98a39 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents: 8144
diff changeset
41 #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
42 #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
43 #include "aircraft.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
44 #include "console.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
45 #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
46 #include "network/network.h"
8790
5ef0059ccfc0 (svn r12501) -Codechange: split signs.h.
rubidium <rubidium@openttd.org>
parents: 8788
diff changeset
47 #include "signs_base.h"
5ef0059ccfc0 (svn r12501) -Codechange: split signs.h.
rubidium <rubidium@openttd.org>
parents: 8788
diff changeset
48 #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
49 #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
50 #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
51 #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
52 #include "yapf/yapf.h"
8208
ddc34919158f (svn r11771) -Codechange: split settings.h into better separated headers.
rubidium <rubidium@openttd.org>
parents: 8179
diff changeset
53 #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
54 #include "genworld.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
55 #include "player_face.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 "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
57 #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
58 #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
59 #include "vehicle_func.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
60 #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
61 #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
62 #include "functions.h"
9085
31575b0db757 (svn r12944) -Codechange: use rev.h instead of externs at many places
smatz <smatz@openttd.org>
parents: 9070
diff changeset
63 #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
64
6451
25c7793c8d9a (svn r9601) -Codechange: Store grf file reference in station spec, not just GRF ID
peter1138 <peter1138@openttd.org>
parents: 6427
diff changeset
65 #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
66 #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
67 #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
68 #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
69 #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
70
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
71 #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
72 #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
73 #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
74 #include "road_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
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();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
99
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
100 extern void SetDifficultyLevel(int mode, GameOptions *gm_opt);
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
101 extern Player* DoStartupNewPlayer(bool is_ai);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
102 extern void ShowOSErrorBox(const char *buf);
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
103 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
104
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
105 /**
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
106 * Error handling for fatal errors.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
107 * @param s the string to print.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
108 * @note Does NEVER return.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
109 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
110 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
111 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
112 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
113 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
114
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
115 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
116 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
117 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
118
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
119 ShowOSErrorBox(buf);
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
120 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
121
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
122 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
123 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
124 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
125
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
126 /**
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
127 * 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
128 * @param str the text to show.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
129 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
130 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
131 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
132 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
133 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
134 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
135 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
136 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
137 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
138 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
139
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
140 /**
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
141 * 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
142 */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
143 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
144 {
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
145 char buf[4096];
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
146 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
147
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
148 p += snprintf(p, lengthof(buf), "OpenTTD %s\n", _openttd_revision);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
149 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
150 "\n"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
151 "\n"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
152 "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
153 " -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
154 " -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
155 " -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
156 " -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
157 " -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
158 " -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
159 " -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
160 " -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
161 " -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
162 " -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
163 " -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
164 #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
165 " -n [ip:port#player] = Start networkgame\n"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
166 " -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
167 " -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
168 #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
169 " -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
170 #endif
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
171 #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
172 " -i = Force to use the DOS palette\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 " (use this if you see a lot of pink)\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 " -c config_file = Use 'config_file' instead of 'openttd.cfg'\n"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
175 " -x = Do not automatically save to config file on exit\n",
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
176 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
177 );
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
178
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
179 /* 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
180 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
181
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
182 /* 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
183 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
184
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
185 /* 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
186 * 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
187 #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
188 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
189 #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
190 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
191 #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
192 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
193
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
194
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
195 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
196 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
197 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
198 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
199 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
200 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
201
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
202 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
203 {
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
204 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
205 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
206 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
207 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
208 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
209 }
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
210 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
211
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
212 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
213 {
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
214 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
215
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
216 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
217 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
218 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
219
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
220 for (;;) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
221 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
222
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
223 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
224 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
225 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
226 s++;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
227 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
228 /* 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
229 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
230 /* 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
231 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
232 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
233 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
234 /* 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
235 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
236 /* 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
237 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
238 /* 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
239 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
240 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
241 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
242 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
243 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
244 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
245 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
246 }
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
247 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
248 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
249 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
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 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
252 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
253 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
254 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
255 } 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
256 /* 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
257 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
258 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
259 }
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
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
262 /**
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
263 * 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
264 * it in the 'res' parameter.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
265 * @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
266 * @param s the string to decompose.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
267 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
268 static void ParseResolution(int res[2], 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
269 {
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
270 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
271 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
272 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
273 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
274 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
275
8985
480d464f5e24 (svn r12779) -Codechange: remove a few constants from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8973
diff changeset
276 res[0] = max(strtoul(s, NULL, 0), 64UL);
480d464f5e24 (svn r12779) -Codechange: remove a few constants from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8973
diff changeset
277 res[1] = 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
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
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
280 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
281 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
282 /* Dynamic stuff needs to be initialized somewhere... */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
283 _town_sort = NULL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
284 _industry_sort = NULL;
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
285 _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
286 _industile_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
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
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
289
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
290 static void UnInitializeGame()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
291 {
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
292 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
293
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
294 /* 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
295 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
296
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
297 /* Uninitialize variables that are allocated dynamically */
7401
1e97c047c9f6 (svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents: 7393
diff changeset
298 _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
299 _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
300 _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
301 _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
302 _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
303 _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
304 _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
305 _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
306 _Engine_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
307
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
308 free((void*)_town_sort);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
309 free((void*)_industry_sort);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
310
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
311 free(_config_file);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
312 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
313
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
314 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
315 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
316 _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
317
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
318 _opt_ptr = &_opt_newgame;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
319 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
320
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
321 /* 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
322 ResetWindowSystem();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
323 SetupColorsAndInitialWindow();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
324
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
325 /* 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
326 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
327 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
328 WaitTillGeneratedWorld();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
329 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
330
6231
a4e11dd2d7c6 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight <truelight@openttd.org>
parents: 6229
diff changeset
331 _pause_game = 0;
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
332 SetLocalPlayer(PLAYER_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
333 /* Make sure you can't scroll in the menu */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
334 _scrolling_viewport = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
335 _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
336 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
337
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
338 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
339
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
340 /* 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
341 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
342 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
343
8268
ab53b3bf7100 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium <rubidium@openttd.org>
parents: 8265
diff changeset
344 byte _no_scroll;
ab53b3bf7100 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium <rubidium@openttd.org>
parents: 8265
diff changeset
345 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
346 #if defined(UNIX) && !defined(__MORPHOS__)
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
347 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
348 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
349
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
350 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
351 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
352 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
353 const char *optformat;
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
354 char musicdriver[32], sounddriver[32], videodriver[32], blitter[32];
6491
696f0e1b046e (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents: 6486
diff changeset
355 int resolution[2] = {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
356 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
357 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
358 bool save_config = true;
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
359 #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
360 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
361 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
362 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
363 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
364 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
365 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
366 #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
367
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
368 musicdriver[0] = sounddriver[0] = videodriver[0] = blitter[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
369
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
370 _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
371 _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
372 _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
373 _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
374 _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
375
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
376 /* 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
377 * 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
378 * 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
379 * a '::' behind it means: it can optional have a param (e.g.: -d<debug>) */
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
380 optformat = "m:s:v:b:hD::n::eit: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
381 #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
382 "f"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
383 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
384 ;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
385
6491
696f0e1b046e (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents: 6486
diff changeset
386 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
387
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
388 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
389 switch (i) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
390 case 'm': ttd_strlcpy(musicdriver, mgo.opt, sizeof(musicdriver)); break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
391 case 's': ttd_strlcpy(sounddriver, mgo.opt, sizeof(sounddriver)); break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
392 case 'v': ttd_strlcpy(videodriver, mgo.opt, sizeof(videodriver)); break;
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
393 case 'b': ttd_strlcpy(blitter, mgo.opt, sizeof(blitter)); break;
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
394 #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
395 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
396 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
397 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
398 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
399 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
400 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
401 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
402 /* Use the existing method for parsing (openttd -n).
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
403 * However, we do ignore the #player part. */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
404 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
405 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
406 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
407 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
408 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
409 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
410 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
411 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
412 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
413 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
414 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
415 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
416 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
417 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
418 break;
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
419 #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
420 case 'r': ParseResolution(resolution, 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
421 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
422 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
423 #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
424 CreateConsole();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
425 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
426 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
427 } break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
428 case 'e': _switch_mode = SM_EDITOR; break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
429 case 'i': _use_dos_palette = 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
430 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
431 if (mgo.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
432 strcpy(_file_to_saveload.name, 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
433 _switch_mode = SM_LOAD;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
434 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
435 _switch_mode = SM_NEWGAME;
6309
3ae0ee930b53 (svn r9205) -Fix: if you started openttd with '-g' you got the same map every run
truelight <truelight@openttd.org>
parents: 6304
diff changeset
436 /* Give a random map */
3ae0ee930b53 (svn r9205) -Fix: if you started openttd with '-g' you got the same map every run
truelight <truelight@openttd.org>
parents: 6304
diff changeset
437 generation_seed = InteractiveRandom();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
438 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
439 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
440 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
441 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
442 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
443 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
444 case 'h':
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
445 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
446 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
447 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
448 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
449
7408
53fa9a58449a (svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents: 7401
diff changeset
450 #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
451 /* 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
452 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
453 #endif
53fa9a58449a (svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents: 7401
diff changeset
454
6317
d5d3f3379eb0 (svn r9266) -Codechange: unify the retrieval of the base paths a little more.
rubidium <rubidium@openttd.org>
parents: 6309
diff changeset
455 DeterminePaths(argv[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
456 CheckExternalFiles();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
457
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
458 #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
459 /* 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
460 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
461 DedicatedFork();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
462 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
463
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
464 LoadFromConfig();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
465 CheckConfig();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
466 LoadFromHighScore();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
467
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
468 /* override config? */
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
469 if (!StrEmpty(musicdriver)) ttd_strlcpy(_ini_musicdriver, musicdriver, sizeof(_ini_musicdriver));
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
470 if (!StrEmpty(sounddriver)) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
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
471 if (!StrEmpty(videodriver)) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
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
472 if (!StrEmpty(blitter)) ttd_strlcpy(_ini_blitter, blitter, sizeof(_ini_blitter));
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
473 if (resolution[0] != 0) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[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
474 if (startyear != INVALID_YEAR) _patches_newgame.starting_year = startyear;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
475 if (generation_seed != GENERATE_NEW_SEED) _patches_newgame.generation_seed = generation_seed;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
476
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
477 /* 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
478 * way all internal drawing routines work correctly. */
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
479 if (_cur_resolution[0] == 0) _cur_resolution[0] = 1;
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
480 if (_cur_resolution[1] == 0) _cur_resolution[1] = 1;
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
481
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
482 #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
483 if (dedicated_host) snprintf(_network_server_bind_ip_host, NETWORK_HOSTNAME_LENGTH, "%s", dedicated_host);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
484 if (dedicated_port) _network_server_port = dedicated_port;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
485 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
486 #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
487
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
488 /* 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
489 InitializeLanguagePacks();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
490
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
491 /* 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
492 InitializeScreenshotFormats();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
493
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
494 /* 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
495 InitializeAirports();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
496
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
497 /* 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
498 InitializeDynamicVariables();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
499
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
500 /* start the AI */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
501 AI_Initialize();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
502
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
503 /* 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
504 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
505 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
506 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
507
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
508 /* 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
509 InitFreeType();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
510
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
511 /* 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
512 InitWindowSystem();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
513
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
514 /* 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
515 GfxInitPalettes();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
516
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
517 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
518 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
519 StrEmpty(_ini_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
520 error("Failed to autoprobe 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
521 error("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
522
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 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
524
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
525 _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
526 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
527 StrEmpty(_ini_sounddriver) ?
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
528 error("Failed to autoprobe sound driver") :
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
529 error("Failed to select requested sound driver '%s'", _ini_sounddriver);
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
530 }
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
531
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
532 _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
533 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
534 StrEmpty(_ini_musicdriver) ?
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
535 error("Failed to autoprobe music driver") :
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
536 error("Failed to select requested music driver '%s'", _ini_musicdriver);
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
537 }
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
538
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
539 _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
540 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
541 StrEmpty(_ini_videodriver) ?
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
542 error("Failed to autoprobe video driver") :
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
543 error("Failed to select requested video driver '%s'", _ini_videodriver);
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
544 }
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
545
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
546 _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
547 /* 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
548 _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
549
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
550 /* 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
551 _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
552
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
553 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
554
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
555 #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
556 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
557 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
558 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
559 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
560
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
561 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
562
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
563 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
564 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
565
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
566 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
567 }
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
568 #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
569
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
570 ScanNewGRFFiles();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
571
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
572 _opt_ptr = &_opt_newgame;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
573 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
574
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
575 /* XXX - ugly hack, if diff_level is 9, it means we got no setting from the config file */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
576 if (_opt_newgame.diff_level == 9) SetDifficultyLevel(0, &_opt_newgame);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
577
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
578 /* Make sure _patches is filled with _patches_newgame if we switch to a game directly */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
579 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
580 _opt = _opt_newgame;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
581 UpdatePatches();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
582 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
583
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
584 /* 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
585 IConsoleInit();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
586 _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
587 InitializeGUI();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
588 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
589
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
590 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
591 WaitTillGeneratedWorld();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
592
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
593 #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
594 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
595 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
596 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
597 const char *player = NULL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
598 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
599
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
600 rport = NETWORK_DEFAULT_PORT;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
601 _network_playas = PLAYER_NEW_COMPANY;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
602
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
603 ParseConnectionString(&player, &port, network_conn);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
604
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
605 if (player != NULL) {
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
606 _network_playas = (PlayerID)atoi(player);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
607
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
608 if (_network_playas != PLAYER_SPECTATOR) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
609 _network_playas--;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
610 if (!IsValidPlayer(_network_playas)) 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
611 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
612 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
613 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
614
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
615 LoadIntroGame();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
616 _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
617 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
618 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
619 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
620 #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
621
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
622 _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
623
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
624 WaitTillSaved();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
625 IConsoleFree();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
626
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
627 if (_network_available) NetworkShutDown(); // Shut down the network and close any open connections
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
628
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
629 _video_driver->Stop();
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
630 _music_driver->Stop();
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
631 _sound_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
632
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
633 /* 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
634 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
635 SaveToConfig();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
636 SaveToHighScore();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
637 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
638
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
639 /* Reset windowing system and free config file */
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
640 UnInitializeGame();
5584
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 /* stop the AI */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
643 AI_Uninitialize();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
644
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
645 /* Close all and any open filehandles */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
646 FioCloseAll();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
647
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
648 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
649 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
650
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
651 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
652 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
653 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
654 _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
655 } else if (_patches.autosave_on_exit) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
656 DoExitSave();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
657 _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
658 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
659 AskExitGame();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
660 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
661 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
662
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
663 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
664 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
665 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
666 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
667 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
668 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
669 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
670 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
671
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
672 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
673
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
674 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
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 /* 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
677 if (_network_dedicated) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
678 SetLocalPlayer(PLAYER_SPECTATOR);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
679 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
680 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
681
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
682 /* Create a single player */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
683 DoStartupNewPlayer(false);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
684
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
685 SetLocalPlayer(PLAYER_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
686 _current_player = _local_player;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
687 DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
688
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
689 SettingsDisableElrail(_patches.disable_elrails);
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
690 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
691
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
692 #ifdef 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
693 /* We are the server, we start a new player (not dedicated),
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7981
diff changeset
694 * so set the default password *if* needed. */
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7981
diff changeset
695 if (_network_server && !StrEmpty(_network_default_company_pass)) {
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7981
diff changeset
696 char *password = _network_default_company_pass;
c23b6367e55b (svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents: 7981
diff changeset
697 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
698 }
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
699 #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
700
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
701 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
702 }
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 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
705 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
706 _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
707
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
708 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
709 _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
710 _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
711 _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
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 GenerateWorldSetCallback(&MakeNewGameDone);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
714 GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _patches.map_x, 1 << _patches.map_y);
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
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
717 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
718 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
719 SetLocalPlayer(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
720
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
721 MarkWholeScreenDirty();
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
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
724 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
725 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
726 _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
727
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
728 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
729
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
730 GenerateWorldSetCallback(&MakeNewEditorWorldDone);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
731 GenerateWorld(GW_EMPTY, 1 << _patches.map_x, 1 << _patches.map_y);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
732 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
733
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
734 void StartupPlayers();
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
735 void StartupDisasters();
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
736 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
737
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
738 /**
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
739 * 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
740 * 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
741 * 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
742 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
743 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
744 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
745 _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
746
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
747 /* 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
748 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
749 DEBUG(sl, 0, "Savegame is obsolete or invalid format: '%s'", _file_to_saveload.name);
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
750 SetDParamStr(0, GetSaveLoadErrorString());
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
751 ShowErrorMessage(INVALID_STRING_ID, STR_012D, 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
752 _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
753 return;
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
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
756 /* 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
757 ResetWindowSystem();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
758
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
759 SetupColorsAndInitialWindow();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
760
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
761 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
762
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
763 /* 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
764 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
765 LoadIntroGame();
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
766 SetDParamStr(0, GetSaveLoadErrorString());
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
767 ShowErrorMessage(INVALID_STRING_ID, STR_012D, 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
768 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
769
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
770 _opt_ptr = &_opt;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
771 _opt_ptr->diff = _opt_newgame.diff;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
772 _opt.diff_level = _opt_newgame.diff_level;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
773
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
774 /* 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
775 StartupEconomy();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
776 StartupPlayers();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
777 StartupEngines();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
778 StartupDisasters();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
779
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
780 SetLocalPlayer(PLAYER_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
781 _current_player = _local_player;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
782 DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
783
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
784 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
785 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
786
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
787 /** 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
788 * 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
789 * 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
790 * @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
791 * @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
792 * @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
793 * @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
794 */
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
795 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
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 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
798
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
799 _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
800 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
801 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
802 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
803
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
804 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
805 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
806 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
807 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
808 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
809 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
810 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
811
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
812 default:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
813 _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
814 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
815 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
816 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
817
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
818 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
819 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
820 #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
821 /* 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
822 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
823 /* 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
824 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
825 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
826 NetworkReboot();
5619
7b93afb2bd9f (svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium <rubidium@openttd.org>
parents: 5609
diff changeset
827 NetworkUDPCloseAll();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
828 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
829 NetworkDisconnect();
5619
7b93afb2bd9f (svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium <rubidium@openttd.org>
parents: 5609
diff changeset
830 NetworkUDPCloseAll();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
831 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
832 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
833
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
834 /* 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
835 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
836 /* 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
837 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
838 /* check if we should reload the config */
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
839 if (_network_reload_cfg) {
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
840 LoadFromConfig();
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
841 _patches = _patches_newgame;
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
842 _opt = _opt_newgame;
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
843 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
844 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
845 NetworkServerStart();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
846 } 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
847 /* 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
848 _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
849 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
850 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
851 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
852 #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
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 switch (new_mode) {
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
855 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
856 MakeNewEditorWorld();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
857 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
858
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
859 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
860 #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
861 if (_network_server) {
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
862 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
863 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
864 #endif /* ENABLE_NETWORK */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
865 MakeNewGame(false);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
866 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
867
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
868 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
869 #ifdef ENABLE_NETWORK
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
870 if (_network_server) {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
871 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
872 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
873 #endif /* ENABLE_NETWORK */
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
874 StartScenario();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
875 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
876
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
877 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
878 _opt_ptr = &_opt;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
879 ResetGRFConfig(true);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
880 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
881
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
882 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
883 LoadIntroGame();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
884 SetDParamStr(0, GetSaveLoadErrorString());
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
885 ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
886 } 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
887 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
888 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
889 }
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
890 /* Update the local player for a loaded game. It is either always
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
891 * player #1 (eg 0) or in the case of a dedicated server a spectator */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
892 SetLocalPlayer(_network_dedicated ? PLAYER_SPECTATOR : PLAYER_FIRST);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
893 /* Decrease pause counter (was increased from opening load dialog) */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
894 DoCommandP(0, 0, 0, NULL, 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
895 #ifdef ENABLE_NETWORK
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
896 if (_network_server) {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
897 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
898 }
5584
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 */
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
900 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
901 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
902 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
903
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
904 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
905 #ifdef ENABLE_NETWORK
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
906 if (_network_server) {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
907 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
908 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
909 #endif /* ENABLE_NETWORK */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
910 MakeNewGame(true);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
911 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
912
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
913 case SM_LOAD_HEIGHTMAP: /* Load heightmap from scenario editor */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
914 SetLocalPlayer(OWNER_NONE);
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
915
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
916 GenerateWorld(GW_HEIGHTMAP, 1 << _patches.map_x, 1 << _patches.map_y);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
917 MarkWholeScreenDirty();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
918 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
919
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
920 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
921 if (SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_EDITOR, NO_DIRECTORY)) {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
922 _opt_ptr = &_opt;
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 SetLocalPlayer(OWNER_NONE);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
925 _patches_newgame.starting_year = _cur_year;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
926 } else {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
927 SetDParamStr(0, GetSaveLoadErrorString());
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
928 ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
929 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
930 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
931 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
932
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
933 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
934 LoadIntroGame();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
935 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
936
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
937 case SM_SAVE: /* Save game */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
938 /* 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
939 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
940 if (SaveOrLoad(_file_to_saveload.name, SL_SAVE, NO_DIRECTORY) != SL_OK) {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
941 SetDParamStr(0, GetSaveLoadErrorString());
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
942 ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
943 } else {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
944 DeleteWindowById(WC_SAVELOAD, 0);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
945 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
946 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
947 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
948
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
949 case SM_GENRANDLAND: /* Generate random land within scenario editor */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
950 SetLocalPlayer(OWNER_NONE);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
951 GenerateWorld(GW_RANDOM, 1 << _patches.map_x, 1 << _patches.map_y);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
952 /* XXX: set date */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
953 MarkWholeScreenDirty();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
954 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
955 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
956
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
957 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
958 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
959 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
960 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
961
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
962
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
963 /**
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
964 * State controlling game loop.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
965 * 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
966 * That check is enforced in DoCommand.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
967 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
968 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
969 {
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
970 /* 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
971 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
972 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
973 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
974 }
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 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
976
8303
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
977 ClearStorageChanges(false);
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
978
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
979 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
980 RunTileLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
981 CallVehicleTicks();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
982 CallLandscapeTick();
8303
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
983 ClearStorageChanges(true);
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
984
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
985 CallWindowTickEvent();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
986 NewsLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
987 } else {
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
988 #ifdef DEBUG_DUMP_COMMANDS
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
989 Vehicle *v;
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
990 FOR_ALL_VEHICLES(v) {
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
991 if (v != v->First()) continue;
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
992
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
993 switch (v->type) {
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
994 case VEH_ROAD: {
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
995 extern byte GetRoadVehLength(const Vehicle *v);
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
996 if (GetRoadVehLength(v) != v->u.road.cached_veh_length) {
9095
1ee48402dd02 (svn r12955) -Fix (r12858): compilation with desync debug was broken
smatz <smatz@openttd.org>
parents: 9089
diff changeset
997 printf("cache mismatch: vehicle %i, player %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
998 }
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
999 } break;
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
1000
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
1001 case VEH_TRAIN: {
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
1002 uint length = 0;
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
1003 for (Vehicle *u = v; u != NULL; u = u->Next()) length++;
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
1004
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
1005 VehicleRail *wagons = MallocT<VehicleRail>(length);
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
1006 length = 0;
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
1007 for (Vehicle *u = v; u != NULL; u = u->Next()) wagons[length++] = u->u.rail;
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
1008
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
1009 TrainConsistChanged(v);
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
1010
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
1011 length = 0;
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
1012 for (Vehicle *u = v; u != NULL; u = u->Next()) {
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
1013 if (memcmp(&wagons[length], &u->u.rail, sizeof(VehicleRail)) != 0) {
9095
1ee48402dd02 (svn r12955) -Fix (r12858): compilation with desync debug was broken
smatz <smatz@openttd.org>
parents: 9089
diff changeset
1014 printf("cache mismatch: vehicle %i, player %i, unit number %i, wagon %i\n", v->index, (int)v->owner, v->unitnumber, length);
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
1015 }
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
1016 length++;
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
1017 }
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
1018
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
1019 free(wagons);
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
1020 } break;
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
1021
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
1022 case VEH_AIRCRAFT: {
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
1023 uint speed = v->u.air.cached_max_speed;
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
1024 UpdateAircraftCache(v);
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
1025 if (speed != v->u.air.cached_max_speed) {
9095
1ee48402dd02 (svn r12955) -Fix (r12858): compilation with desync debug was broken
smatz <smatz@openttd.org>
parents: 9089
diff changeset
1026 printf("cache mismatch: vehicle %i, player %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
1027 }
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
1028 } break;
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
1029
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
1030 default:
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
1031 break;
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
1032 }
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
1033 }
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
1034 #endif
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
1035
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
1036 /* 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
1037 * for multiplayer compatibility */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1038 PlayerID p = _current_player;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1039 _current_player = 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
1040
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1041 AnimateAnimatedTiles();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1042 IncreaseDate();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1043 RunTileLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1044 CallVehicleTicks();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1045 CallLandscapeTick();
8303
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1046 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
1047
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1048 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
1049
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1050 CallWindowTickEvent();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1051 NewsLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1052 _current_player = p;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1053 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1054 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1055
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
1056 /** 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
1057 * 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
1058 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
1059 {
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
1060 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
1061
5977
03f33d102c56 (svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight <truelight@openttd.org>
parents: 5959
diff changeset
1062 #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
1063 /* 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
1064 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
1065 #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
1066
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1067 if (_patches.keep_all_autosave && _local_player != PLAYER_SPECTATOR) {
7058
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7036
diff changeset
1068 SetDParam(0, _local_player);
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7036
diff changeset
1069 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
1070 GetString(buf, STR_4004, lastof(buf));
7414
2496ac7d0086 (svn r10807) -Fix [FS#1108]: keep_all_autosaves always got ".sav" as filename, which basically means that it only kept the last autosave.
rubidium <rubidium@openttd.org>
parents: 7408
diff changeset
1071 ttd_strlcat(buf, ".sav", lengthof(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
1072 } else {
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
1073 /* generate a savegame name and number according to _patches.max_num_autosaves */
bb43858bed10 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents: 6928
diff changeset
1074 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
1075
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
1076 if (++_autosave_ctr >= _patches.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
1077 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1078
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1079 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
1080 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
1081 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
1082 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1083 }
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 static void ScrollMainViewport(int x, int y)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1086 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1087 if (_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
1088 Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1089 assert(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1090
8082
4540919ba965 (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium <rubidium@openttd.org>
parents: 8065
diff changeset
1091 WP(w, vp_d).dest_scrollpos_x += ScaleByZoom(x, w->viewport->zoom);
4540919ba965 (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium <rubidium@openttd.org>
parents: 8065
diff changeset
1092 WP(w, vp_d).dest_scrollpos_y += ScaleByZoom(y, w->viewport->zoom);
5584
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 }
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1095
8063
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1096 /**
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1097 * Describes all the different arrow key combinations the game allows
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1098 * when it is in scrolling mode.
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1099 * The real arrow keys are bitwise numbered as
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1100 * 1 = left
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1101 * 2 = up
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1102 * 4 = right
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1103 * 8 = down
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1104 */
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 static const int8 scrollamt[16][2] = {
8063
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1106 { 0, 0}, ///< no key specified
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
1107 {-2, 0}, ///< 1 : left
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
1108 { 0, -2}, ///< 2 : up
8063
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1109 {-2, -1}, ///< 3 : left + up
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
1110 { 2, 0}, ///< 4 : right
8063
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1111 { 0, 0}, ///< 5 : left + right = nothing
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
1112 { 2, -1}, ///< 6 : right + up
8063
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1113 { 0, -2}, ///< 7 : right + left + up = up
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
1114 { 0 ,2}, ///< 8 : down
8063
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1115 {-2 ,1}, ///< 9 : down + left
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1116 { 0, 0}, ///< 10 : down + up = nothing
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1117 {-2, 0}, ///< 11 : left + up + down = left
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1118 { 2, 1}, ///< 12 : down + right
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1119 { 0, 2}, ///< 13 : left + right + down = down
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1120 { 2, 0}, ///< 14 : right + up + down = right
84f26bedd0d3 (svn r11624) -Fix[FS#1530]: An error in the translation of bitset to scroll directions made it so that up-down-right arrow keys did scrolled up, while it should have scrolled right instead. It was initially interpreted as left-right-up.
belugas <belugas@openttd.org>
parents: 8057
diff changeset
1121 { 0, 0}, ///< 15 : left + up + right + down = nothing
5584
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
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1124 static void HandleKeyScrolling()
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 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1126 if (_dirkeys && !_no_scroll) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1127 int factor = _shift_pressed ? 50 : 10;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1128 ScrollMainViewport(scrollamt[_dirkeys][0] * factor, scrollamt[_dirkeys][1] * factor);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1129 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1130 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1131
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1132 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
1133 {
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
1134 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
1135
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
1136 /* 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
1137 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
1138 _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
1139 DoAutosave();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1140 RedrawAutosave();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1141 }
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 /* handle scrolling of the 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
1144 HandleKeyScrolling();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1145
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
1146 /* 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
1147 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
1148
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
1149 /* 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
1150 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
1151 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
1152 _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
1153 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1154
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1155 IncreaseSpriteLRU();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1156 InteractiveRandom();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1157
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 (_scroller_click_timeout > 3) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1159 _scroller_click_timeout -= 3;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1160 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1161 _scroller_click_timeout = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1162 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1163
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1164 _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
1165 _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
1166 CursorTick();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1167
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1168 #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
1169 /* 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
1170 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
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 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
1173 /* 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
1174 NetworkGameLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1175 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1176 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
1177 /* 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
1178 * We do this here, because it means that the network is really closed */
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 NetworkClientConnectGame(_network_last_host, _network_last_port);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1180 }
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
1181 /* 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
1182 StateGameLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1183 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1184 #else
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1185 StateGameLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1186 #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
1187
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7922
diff changeset
1188 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
1189
6231
a4e11dd2d7c6 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight <truelight@openttd.org>
parents: 6229
diff changeset
1190 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
1191
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1192 InputLoop();
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 MusicLoop();
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
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1197 void BeforeSaveGame()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1198 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1199 const Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1200
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1201 if (w != NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1202 _saved_scrollpos_x = WP(w, const vp_d).scrollpos_x;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1203 _saved_scrollpos_y = WP(w, const vp_d).scrollpos_y;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1204 _saved_scrollpos_zoom = w->viewport->zoom;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1205 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1206 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1207
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1208 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
1209 {
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1210 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
1211 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
1212 case MP_ROAD:
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7922
diff changeset
1213 if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HasBit(_m[tile].m4, 7)) {
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
1214 _m[tile].m4 = 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
1215 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1216 /* FALLTHROUGH */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1217
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1218 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
1219 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
1220 break;
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 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
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 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1225 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1226
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
1227 /* before savegame version 4, the name of the company determined if it existed */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1228 static void CheckIsPlayerActive()
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1229 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1230 Player *p;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1231
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1232 FOR_ALL_PLAYERS(p) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1233 if (p->name_1 != 0) p->is_active = true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1234 }
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
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
1237 /* 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
1238 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
1239 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1240 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
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 FOR_ALL_TOWNS(t) {
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
1243 t->exclusivity = INVALID_PLAYER;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1244 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1245
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1246 /* 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
1247 * 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
1248 * 1.) Go through all stations
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1249 * Build an array town_blocked[ town_id ][ player_id ]
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1250 * that stores if at least one station in that town is blocked for a player
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1251 * 2.) Go through that array, if you find a town that is not blocked for
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1252 * one player, but for all others, then give him exclusivity.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1253 */
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
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1256 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
1257 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
1258 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
1259 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
1260 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
1261 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
1262
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
1263 /* 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
1264 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
1265 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1266 _opt.currency = convert_currency[_opt.currency];
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1267 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1268
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1269 /* 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
1270 * 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
1271 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1272 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
1273 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1274 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
1275
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1276 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
1277 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
1278 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1279
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
1280 /* 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
1281 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
1282 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1283 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
1284
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1285 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
1286 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1287
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1288 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
1289
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1290
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1291 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
1292 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1293 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
1294 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1295
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
1296 /**
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 * 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
1298 * 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
1299 * 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
1300 * 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
1301 * 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
1302 * 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
1303 * 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
1304 *
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
1305 * @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
1306 */
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
1307 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
1308 {
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 /* 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
1310 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
1311 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
1312
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
1313 Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
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
1314
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
1315 WP(w, vp_d).scrollpos_x = _saved_scrollpos_x;
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
1316 WP(w, vp_d).scrollpos_y = _saved_scrollpos_y;
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
1317 WP(w, vp_d).dest_scrollpos_x = _saved_scrollpos_x;
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
1318 WP(w, vp_d).dest_scrollpos_y = _saved_scrollpos_y;
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
1319
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
1320 ViewPort *vp = w->viewport;
8095
538d8ce486cd (svn r11656) -Codechange: add ZOOM_LVL_BEGIN and postfix operators so ZoomLevel can be used in some iterations
smatz <smatz@openttd.org>
parents: 8088
diff changeset
1321 vp->zoom = min(_saved_scrollpos_zoom, ZOOM_LVL_MAX);
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
1322 vp->virtual_width = ScaleByZoom(vp->width, vp->zoom);
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
1323 vp->virtual_height = ScaleByZoom(vp->height, vp->zoom);
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
1324
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
1325 DoZoomInOutWindow(ZOOM_NONE, w); // update button status
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
1326 MarkWholeScreenDirty();
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
1327
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
1328 /* 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
1329 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
1330 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
1331 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
1332 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
1333
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
1334 /* Recalculate */
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
1335 Group *g;
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
1336 FOR_ALL_GROUPS(g) {
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
1337 g->num_engines = CallocT<uint16>(GetEnginePoolSize());
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
1338
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
1339 const Vehicle *v;
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
1340 FOR_ALL_VEHICLES(v) {
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
1341 if (!IsEngineCountable(v)) continue;
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
1342
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
1343 if (v->group_id != g->index || v->type != g->vehicle_type || v->owner != g->owner) continue;
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
1344
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
1345 g->num_engines[v->engine_type]++;
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
1346 }
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
1347 }
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
1348
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
1349 /* Set up the engine count for all players */
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
1350 Player *players[MAX_PLAYERS];
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
1351 const Vehicle *v;
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
1352
8152
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8151
diff changeset
1353 for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8151
diff changeset
1354 players[i] = GetPlayer(i);
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8151
diff changeset
1355
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8151
diff changeset
1356 /* For each player, verify (while loading a scenario) that the inauguration date is the current year and set it
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8151
diff changeset
1357 * accordingly if it is not the case. No need to set it on players that are not been used already,
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8151
diff changeset
1358 * thus the MIN_YEAR (which is really nothing more than Zero, initialized value) test */
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8151
diff changeset
1359 if (_file_to_saveload.filetype == FT_SCENARIO && players[i]->inaugurated_year != MIN_YEAR)
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8151
diff changeset
1360 players[i]->inaugurated_year = _cur_year;
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
1361
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
1362 free(players[i]->num_engines);
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
1363 players[i]->num_engines = CallocT<uint16>(GetEnginePoolSize());
8152
32bfb56e7e0e (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents: 8151
diff changeset
1364 }
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
1365
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
1366 FOR_ALL_VEHICLES(v) {
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
1367 if (!IsEngineCountable(v)) continue;
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
1368 players[v->owner]->num_engines[v->engine_type]++;
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
1369 }
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
1370
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
1371 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
1372 }
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
1373
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1374 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
1375 {
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
1376 TileIndex map_size = MapSize();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1377 Player *p;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1378
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
1379 /* 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
1380 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
1381
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
1382 /* 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
1383 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
1384
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
1385 /* 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
1386 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
1387
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
1388 /* 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
1389 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
1390
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1391 /* 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
1392 * 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
1393 * (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
1394 * 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
1395 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
1396 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
1397 if (IsTileType(t, MP_WATER) && GetTileOwner(t) >= MAX_PLAYERS) {
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
1398 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
1399 }
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
1400 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1401 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1402
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
1403 if (CheckSavegameVersion(84)) {
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
1404 Player *p;
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
1405 FOR_ALL_PLAYERS(p) {
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
1406 p->name = CopyFromOldName(p->name_1);
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
1407 if (p->name != NULL) p->name_1 = STR_SV_UNNAMED;
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
1408 p->president_name = CopyFromOldName(p->president_name_1);
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
1409 if (p->president_name != NULL) p->president_name_1 = SPECSTR_PRESIDENT_NAME;
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
1410 }
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
1411
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
1412 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
1413 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
1414 st->name = CopyFromOldName(st->string_id);
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
1415 if (st->name != NULL) st->string_id = 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
1416 }
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
1417
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
1418 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
1419 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
1420 t->name = CopyFromOldName(t->townnametype);
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
1421 if (t->name != NULL) t->townnametype = SPECSTR_TOWNNAME_START + _opt.town_name;
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
1422 }
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
1423
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
1424 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
1425 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
1426 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
1427 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
1428 }
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
1429 }
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
1430
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
1431 /* 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
1432 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
1433
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
1434 /* convert road side to my format. */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1435 if (_opt.road_side) _opt.road_side = 1;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1436
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
1437 /* 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
1438 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
1439 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
1440 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
1441 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
1442 }
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
1443
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
1444 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
1445 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
1446 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
1447 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
1448 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1449
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1450 /* 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
1451 * 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
1452 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
1453
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
1454 /* Force dynamic engines off when loading older savegames */
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
1455 if (CheckSavegameVersion(95)) _patches.dynamic_engines = 0;
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
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 /* 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
1458 GfxLoadSprites();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1459 LoadStringWidthTable();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1460
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
1461 /* 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
1462 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
1463
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 /* 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
1465 * 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
1466 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
1467
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1468 /* 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
1469 ConnectMultiheadedTrains();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1470
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
1471 /* 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
1472 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
1473
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
1474 /* 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
1475 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
1476
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
1477 /* 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
1478 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
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 /* 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
1481 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
1482
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1483 AfterLoadTown();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1484
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
1485 /* make sure there is a town in the 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
1486 if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, (uint)-1)) {
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
1487 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
1488 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
1489 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1490
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
1491 /* in version 4.1 of the savegame, is_active was introduced to determine
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
1492 * if a player does exist, rather then checking name_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
1493 if (CheckSavegameVersionOldStyle(4, 1)) CheckIsPlayerActive();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1494
8513
4f13e896d29f (svn r12088) -Fix: assert when loading savegame with wrong tiletype at south map borders
smatz <smatz@openttd.org>
parents: 8495
diff changeset
1495 /* 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
1496 * 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
1497 * 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
1498 * 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
1499 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
1500
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
1501 /* If Load Scenario / New (Scenario) Game is used,
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
1502 * a player does not exist yet. So create one here.
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
1503 * 1 exeption: network-games. Those can have 0 players
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
1504 * But this exeption is not true for non dedicated network_servers! */
311a49fa8d46 (svn r9785) -Fix (r942, FS#765): only non dedicated servers can't have 0 players
glx <glx@openttd.org>
parents: 6560
diff changeset
1505 if (!_players[0].is_active && (!_networking || (_networking && _network_server && !_network_dedicated)))
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1506 DoStartupNewPlayer(false);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1507
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 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
1509 /* 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
1510 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
1511 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
1512 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
1513
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 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
1515 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
1516 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
1517
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 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
1519 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
1520 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
1521 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
1522 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
1523 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
1524 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
1525 } 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
1526 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
1527 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
1528 } 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
1529 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
1530 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
1531 } 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
1532 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
1533 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
1534 } 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
1535 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
1536 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
1537 } 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
1538 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
1539 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
1540 } 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
1541 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
1542 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
1543 } 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
1544 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
1545 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
1546 } 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
1547 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
1548 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
1549 } 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
1550 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
1551 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
1552 } 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
1553 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
1554 }
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
1555 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
1556 } 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
1557 }
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
1558 }
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
1559 }
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
1560
5880
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1561 for (TileIndex t = 0; t < map_size; t++) {
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1562 switch (GetTileType(t)) {
6093
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1563 case MP_STATION: {
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1564 Station *st = GetStationByTile(t);
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1565
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1566 st->rect.BeforeAddTile(t, StationRect::ADD_FORCE);
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1567
5880
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1568 switch (GetStationType(t)) {
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1569 case STATION_TRUCK:
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1570 case STATION_BUS:
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1571 if (CheckSavegameVersion(6)) {
6093
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1572 /* From this version on there can be multiple road stops of the
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1573 * same type per station. Convert the existing stops to the new
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1574 * internal data structure. */
5880
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1575 RoadStop *rs = new RoadStop(t);
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1576 if (rs == NULL) error("Too many road stops in savegame");
5879
abfe68a96c2f (svn r8477) -Fix
tron <tron@openttd.org>
parents: 5848
diff changeset
1577
5880
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1578 RoadStop **head =
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1579 IsTruckStop(t) ? &st->truck_stops : &st->bus_stops;
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1580 *head = rs;
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1581 }
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1582 break;
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1583
5884
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1584 case STATION_OILRIG: {
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1585 /* Very old savegames sometimes have phantom oil rigs, i.e.
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1586 * an oil rig which got shut down, but not completly removed from
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1587 * the map
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1588 */
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
1589 TileIndex t1 = TILE_ADDXY(t, 0, 1);
5886
28dcf755e961 (svn r8498) -Fix
tron <tron@openttd.org>
parents: 5885
diff changeset
1590 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
1591 GetIndustryGfx(t1) == GFX_OILRIG_1) {
5886
28dcf755e961 (svn r8498) -Fix
tron <tron@openttd.org>
parents: 5885
diff changeset
1592 /* The internal encoding of oil rigs was changed twice.
28dcf755e961 (svn r8498) -Fix
tron <tron@openttd.org>
parents: 5885
diff changeset
1593 * It was 3 (till 2.2) and later 5 (till 5.1).
28dcf755e961 (svn r8498) -Fix
tron <tron@openttd.org>
parents: 5885
diff changeset
1594 * Setting it unconditionally does not hurt.
28dcf755e961 (svn r8498) -Fix
tron <tron@openttd.org>
parents: 5885
diff changeset
1595 */
28dcf755e961 (svn r8498) -Fix
tron <tron@openttd.org>
parents: 5885
diff changeset
1596 GetStationByTile(t)->airport_type = AT_OILRIG;
28dcf755e961 (svn r8498) -Fix
tron <tron@openttd.org>
parents: 5885
diff changeset
1597 } else {
5884
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1598 DeleteOilRig(t);
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1599 }
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1600 break;
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1601 }
c36fd99592cb (svn r8485) -Fix
tron <tron@openttd.org>
parents: 5880
diff changeset
1602
5880
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1603 default: break;
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1604 }
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1605 break;
6093
1f2c064d8490 (svn r8828) -Fix
tron <tron@openttd.org>
parents: 6000
diff changeset
1606 }
5880
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1607
a44e494ecc90 (svn r8478) -Fix
tron <tron@openttd.org>
parents: 5879
diff changeset
1608 default: break;
5879
abfe68a96c2f (svn r8477) -Fix
tron <tron@openttd.org>
parents: 5848
diff changeset
1609 }
abfe68a96c2f (svn r8477) -Fix
tron <tron@openttd.org>
parents: 5848
diff changeset
1610 }
abfe68a96c2f (svn r8477) -Fix
tron <tron@openttd.org>
parents: 5848
diff changeset
1611
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1612 /* 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
1613 * 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
1614 * 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
1615 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
1616 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
1617 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
1618 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
1619 _m[t].m4 = _m[t].m2;
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
1620 SetTownIndex(t, CalcClosestTownFromTile(t, (uint)-1)->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
1621 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1622
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
1623 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
1624 _m[t].m4 |= (_m[t].m2 << 4);
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
1625 if (IsTileOwner(t, OWNER_TOWN)) {
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
1626 SetTownIndex(t, CalcClosestTownFromTile(t, (uint)-1)->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
1627 } 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
1628 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
1629 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1630 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1631
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1632 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
1633 }
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
1634 }
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 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1636
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1637 /* 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
1638 * 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
1639 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
1640 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
1641 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
1642 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1643
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1644 /* 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
1645 * 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
1646 if (CheckSavegameVersion(16)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1647 FOR_ALL_PLAYERS(p) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1648 p->engine_renew_list = NULL;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1649 p->engine_renew = false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1650 p->engine_renew_months = -6;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1651 p->engine_renew_money = 100000;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1652 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1653
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1654 /* When loading a game, _local_player is not yet set to the correct value.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1655 * However, in a dedicated server we are a spectator, so nothing needs to
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1656 * happen. In case we are not a dedicated server, the local player always
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1657 * becomes player 0, unless we are in the scenario editor where all the
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1658 * players are 'invalid'.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1659 */
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
1660 if (!_network_dedicated && IsValidPlayer(PLAYER_FIRST)) {
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
1661 p = GetPlayer(PLAYER_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
1662 p->engine_renew = _patches.autorenew;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1663 p->engine_renew_months = _patches.autorenew_months;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1664 p->engine_renew_money = _patches.autorenew_money;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1665 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1666 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1667
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
1668 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
1669 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
1670 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
1671 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
1672 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
1673 /* 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
1674 * 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
1675 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
1676 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
1677 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
1678 } 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
1679 /* 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
1680 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
1681 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
1682 }
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 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
1684
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
1685 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
1686 /* 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
1687 * 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
1688 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
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
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 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
1692 }
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 }
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
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 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
1697 /* 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
1698 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
1699 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
1700 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
1701 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
1702 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
1703 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
1704 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
1705 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
1706 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
1707 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
1708 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
1709 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
1710 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
1711 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
1712 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
1713 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
1714 }
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
1715 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
1716 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
1717
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
1718 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
1719 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
1720 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
1721
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
1722 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
1723 /* 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
1724 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
1725 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
1726 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
1727 }
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
1728 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
1729
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
1730 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
1731 }
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
1732 }
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
1733 }
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
1734
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1735 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
1736 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
1737
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
1738 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
1739 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
1740 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
1741 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
1742 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
1743
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7922
diff changeset
1744 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
1745 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
1746 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
1747 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
1748 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
1749 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
1750 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
1751 );
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1752 } 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
1753 TownID town = IsTileOwner(t, OWNER_TOWN) ? ClosestTownFromTile(t, (uint)-1)->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
1754
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1755 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
1756 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
1757 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
1758 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
1759 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
1760 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
1761 );
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1762 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1763 } 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
1764 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
1765 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
1766 } 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
1767 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
1768 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
1769 } 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
1770 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
1771 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
1772 } 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
1773 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
1774 }
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
1775 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1776 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1777 }
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
1778 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
1779 } 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
1780 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
1781 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
1782 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
1783 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
1784
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
1785 _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
1786 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1787 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1788 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1789
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1790 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
1791 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
1792 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
1793 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
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 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
1796 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
1797 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
1798 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
1799 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
1800 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
1801 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
1802 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1803 } 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
1804 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
1805 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1806 continue;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1807 }
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
1808 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
1809 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
1810 } 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
1811 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
1812 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1813 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1814 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1815
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1816 /* 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
1817 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
1818 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
1819 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
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 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
1822 if (v->type == VEH_TRAIN) {
5823
4f8ecdfccbd3 (svn r8385) -Fix
tron <tron@openttd.org>
parents: 5723
diff changeset
1823 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
1824
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1825 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
1826 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
1827 }
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
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1830 /* .. 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
1831 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
1832 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
1833 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
1834 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
1835 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1836
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
1837 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
1838 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
1839 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
1840 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1841 break;
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 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
1844 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
1845 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
1846 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1847 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1848
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1849 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
1850 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
1851 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
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 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1854
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1855 default:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1856 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1857 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1858 }
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_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
1861 if (v->type == VEH_TRAIN && (IsFrontEngine(v) || IsFreeWagon(v))) TrainConsistChanged(v);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1862 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1863
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1864 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1865
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1866 /* In version 16.1 of the savegame a player can decide if trains, which get
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1867 * 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
1868 * 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
1869 if (CheckSavegameVersionOldStyle(16, 1)) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1870 FOR_ALL_PLAYERS(p) p->renew_keep_length = false;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1871 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1872
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1873 /* 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
1874 * 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
1875 * 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
1876 * 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
1877 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
1878 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
1879
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1880 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
1881 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
1882 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
1883
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7922
diff changeset
1884 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
1885 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
1886
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1887 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
1888 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
1889 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
1890 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
1891 } 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
1892 /* 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
1893 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
1894 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
1895 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
1896 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1897
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
1898 /* 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
1899 _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
1900 /* 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
1901 _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
1902 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1903 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1904 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1905 /* 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
1906 * 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
1907 AfterLoadWaypoints();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1908 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1909
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1910 /* 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
1911 * 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
1912 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
1913 for (TileIndex t = 0; t < map_size; t++) {
5707
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1914 switch (GetTileType(t)) {
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1915 case MP_RAILWAY:
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1916 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
1917 /* 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
1918 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
1919
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
1920 /* 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
1921 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
1922 ClrBit(_m[t].m2, 3);
5707
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
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
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
1925 /* 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
1926 if (!IsRailDepotTile(t)) {
5707
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1927 SB(_m[t].m4, 4, 4, 0);
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1928 } 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
1929 ClrBit(_m[t].m3, 6);
5707
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1930 }
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1931 break;
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1932
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
1933 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
1934 if (IsLevelCrossing(t)) ClrBit(_m[t].m5, 0);
5707
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1935 break;
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1936
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
1937 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
1938 ClrBit(_m[t].m3, 6);
5707
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1939 break;
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1940
ec270c5719b1 (svn r8184) if cascade -> switch
tron <tron@openttd.org>
parents: 5706
diff changeset
1941 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
1942 }
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
1943 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1944 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1945
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1946 if (CheckSavegameVersion(22)) UpdatePatches();
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 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
1949 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
1950 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
1951 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
1952 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
1953 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
1954 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
1955 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1956 }
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
1957 } 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
1958 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
1959 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
1960 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
1961 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1962 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1963
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1964 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
1965 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
1966 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
1967 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
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 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1970
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1971 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
1972
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1973 if (CheckSavegameVersion(34)) FOR_ALL_PLAYERS(p) ResetPlayerLivery(p);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1974
6685
91a7c42b133c (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium <rubidium@openttd.org>
parents: 6661
diff changeset
1975 FOR_ALL_PLAYERS(p) {
91a7c42b133c (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium <rubidium@openttd.org>
parents: 6661
diff changeset
1976 p->avail_railtypes = GetPlayerRailtypes(p->index);
91a7c42b133c (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium <rubidium@openttd.org>
parents: 6661
diff changeset
1977 p->avail_roadtypes = GetPlayerRoadtypes(p->index);
91a7c42b133c (svn r9917) -Codechange: prepare some more areas for more road types.
rubidium <rubidium@openttd.org>
parents: 6661
diff changeset
1978 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1979
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1980 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
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 /* 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
1983 * 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
1984 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
1985 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
1986 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
1987 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
1988 Player *player;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1989 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
1990 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
1991
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1992 _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
1993 _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
1994
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1995 FOR_ALL_STATIONS(st) st->build_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
1996 FOR_ALL_WAYPOINTS(wp) wp->build_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
1997 FOR_ALL_ENGINES(e) e->intro_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
1998 FOR_ALL_PLAYERS(player) player->inaugurated_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
1999 FOR_ALL_INDUSTRIES(i) i->last_prod_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
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_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
2002 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
2003 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
2004 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2005 }
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 /* 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
2008 * 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
2009 * 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
2010 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
2011 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
2012
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
2013 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
2014 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
2015 /* 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
2016 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
2017 } 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
2018 /* 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
2019 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
2020 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
2021 }
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
2022 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2023
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2024 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
2025 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
2026
6757
d868c71fb346 (svn r9992) -Codechange: Remove some hardcoded references to Industry IDs.
belugas <belugas@openttd.org>
parents: 6738
diff changeset
2027 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
2028 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
2029 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2030 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2031 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2032
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2033 /* 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
2034 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
2035 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
2036 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
2037
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2038 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
2039 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
2040 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2041
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2042 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
2043 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
2044 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2045 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2046
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2047 /* from version 38 we have optional elrails, since we cannot know the
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2048 * preference of a user, let elrails enabled; it can be disabled manually */
5848
1ab2872708ff (svn r8422) -Fix
tron <tron@openttd.org>
parents: 5823
diff changeset
2049 if (CheckSavegameVersion(38)) _patches.disable_elrails = false;
1ab2872708ff (svn r8422) -Fix
tron <tron@openttd.org>
parents: 5823
diff changeset
2050 /* do the same as when elrails were enabled/disabled manually just now */
1ab2872708ff (svn r8422) -Fix
tron <tron@openttd.org>
parents: 5823
diff changeset
2051 SettingsDisableElrail(_patches.disable_elrails);
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
2052 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
2053
6333
273ef908beb8 (svn r9316) -Fix (r9315): Bump the savegame version for the newhouses merge.
maedhros <maedhros@openttd.org>
parents: 6332
diff changeset
2054 /* 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
2055 * 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
2056 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
2057 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
2058 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
2059 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
2060 /* 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
2061 * 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
2062 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
2063 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
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 /* 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
2066 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
2067 } else {
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2068 /* 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
2069 * 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
2070 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
2071 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
2072
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2073 /* 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
2074 * 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
2075 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
2076
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2077 /* 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
2078 * 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
2079 * 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
2080 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
2081
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2082 _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
2083 _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
2084 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
2085 }
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2086 }
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2087 }
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2088 }
60486b0b3e39 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros <maedhros@openttd.org>
parents: 6317
diff changeset
2089
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
2090 /* 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
2091 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
2092
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2093 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
2094 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
2095 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
2096 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
2097 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
2098 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
2099 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2100
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2101 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
2102 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
2103 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
2104 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
2105 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2106
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2107 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
2108 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
2109 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
2110 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
2111 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2112
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2113 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
2114 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2115 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2116 }
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
2117 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2118 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2119
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
2120 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
2121 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
2122 /* 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
2123 * 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
2124 * 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
2125 * 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
2126 * 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
2127 */
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
2128 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
2129 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
2130 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
2131 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
2132 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
2133 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
2134 }
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
2135 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
2136 }
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
2137
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
2138 /* 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
2139 * 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
2140 * 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
2141 * 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
2142 * 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
2143 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
2144 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
2145 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
2146 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
2147
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
2148 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
2149 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
2150 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
2151 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
2152 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
2153 }
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
2154 }
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
2155 }
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
2156 }
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
2157
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
2158 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
2159 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
2160 /* 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
2161 * 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
2162 * 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
2163 * 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
2164 * 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
2165 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
2166 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
2167 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
2168 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
2169 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
2170 }
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
2171 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
2172 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
2173 }
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
2174 }
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
2175
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
2176 /* 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
2177 * 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
2178 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
2179 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
2180 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
2181 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
2182 }
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
2183 }
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
2184
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
2185 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
2186 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
2187 /* 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
2188 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
2189 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
2190 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
2191 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
2192 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
2193 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
2194 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
2195 }
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
2196 }
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
2197 }
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
2198
6190
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 6175
diff changeset
2199 if (CheckSavegameVersion(49)) FOR_ALL_PLAYERS(p) p->face = ConvertFromOldPlayerFace(p->face);
f9ef22413f22 (svn r8969) -Codechange: rework of the player face bits.
rubidium <rubidium@openttd.org>
parents: 6175
diff changeset
2200
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
2201 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
2202 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
2203 if (IsStatueTile(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
2204 _m[t].m2 = CalcClosestTownFromTile(t, (uint)-1)->index;
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
2205 }
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
2206 }
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
2207 }
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
2208
6486
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2209 /* 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
2210 * 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
2211 * 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
2212 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
2213 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
2214
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2215 FOR_ALL_TOWNS(t) {
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2216 if (_patches.larger_towns != 0 && (t->index % _patches.larger_towns) == 0) {
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2217 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
2218 }
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2219 }
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2220 }
12262d0c44ed (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros <maedhros@openttd.org>
parents: 6453
diff changeset
2221
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
2222 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
2223 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
2224 /* 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
2225 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
2226 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
2227 !(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
2228 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
2229 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
2230
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
2231 /* 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
2232 * 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
2233 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
2234 }
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
2235 }
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
2236 } 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
2237 /* 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
2238
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
2239 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
2240 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
2241 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
2242 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
2243 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
2244 iter++;
8836
890a77315801 (svn r12584) -Codechange: do not access the order type directly.
rubidium <rubidium@openttd.org>
parents: 8811
diff changeset
2245 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
2246 }
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
2247 }
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
2248 }
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
2249
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
2250 if (CheckSavegameVersion(58)) {
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
2251 /* patch difficulty number_industries other then zero get bumped to +1
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
2252 * since a new option (very low at position1) has been added */
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
2253 if (_opt.diff.number_industries > 0) {
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
2254 _opt.diff.number_industries++;
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
2255 }
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
2256
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
2257 /* Same goes for number of towns, although no test is needed, just an increment */
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
2258 _opt.diff.number_towns++;
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
2259 }
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
2260
6770
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2261 if (CheckSavegameVersion(64)) {
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2262 /* 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
2263 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
2264 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
2265 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
2266 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
2267 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
2268 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
2269 }
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2270 }
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2271 }
93b0e6996fcc (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx <glx@openttd.org>
parents: 6757
diff changeset
2272
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
2273 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
2274 /* 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
2275 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
2276 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
2277 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
2278 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
2279 }
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
2280 }
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
2281 }
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
2282
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
2283 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
2284 /* 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
2285 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
2286 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
2287 }
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
2288
7739
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2289 /* 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
2290 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
2291 if (CheckSavegameVersion(82)) {
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2292 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
2293 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
2294 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
2295 GetTileOwner(t) == OWNER_WATER &&
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2296 TileHeight(t) != 0) {
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2297 SetTileOwner(t, OWNER_NONE);
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2298 }
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2299 }
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2300 }
3387a53e113f (svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium <rubidium@openttd.org>
parents: 7710
diff changeset
2301
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
2302 /*
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
2303 * 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
2304 * 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
2305 * 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
2306 * 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
2307 */
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
2308 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
2309 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
2310 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
2311 _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
2312 }
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
2313 }
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
2314 }
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
2315
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
2316 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
2317 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
2318 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
2319 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
2320 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
2321 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
2322 }
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
2323 }
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
2324 }
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
2325
7645
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2326 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
2327 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
2328 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
2329 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
2330 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
2331 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
2332 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
2333 }
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2334 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
2335 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
2336 }
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2337 }
5178857fa331 (svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx <glx@openttd.org>
parents: 7609
diff changeset
2338 }
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
2339
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
2340 /* 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
2341 * 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
2342 * 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
2343 * 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
2344 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
2345 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
2346 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
2347 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
2348 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
2349 }
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
2350 }
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
2351 }
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
2352
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
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 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
2355 /* 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
2356 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
2357 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
2358
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 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
2360 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
2361 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
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 v->current_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
2364 if (v->type == VEH_ROAD && v->IsPrimaryVehicle() && v->prev_shared == 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
2365 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
2366 }
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
2367 }
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
2368 } 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
2369 /* 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
2370 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
2371 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
2372 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
2373 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
2374 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
2375 }
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
2376 }
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
2377
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
2378 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
2379 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
2380 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
2381 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
2382 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
2383 }
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
2384 }
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
2385 }
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
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 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
2388 /* 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
2389 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
2390 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
2391 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
2392 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
2393 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
2394 }
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
2395 }
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
2396
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
2397 /* Set all share owners to PLAYER_SPECTATOR for
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
2398 * 1) all inactive players
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
2399 * (when inactive players were stored in the savegame - TTD, TTDP and some
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
2400 * *really* old revisions of OTTD; else it is already set in InitializePlayers())
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
2401 * 2) shares that are owned by inactive players or self
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
2402 * (caused by cheating players in earlier revisions) */
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
2403 Player *p;
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
2404 FOR_ALL_PLAYERS(p) {
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
2405 if (!p->is_active) {
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
2406 for (uint i = 0; i < 4; i++) { p->share_owners[i] = PLAYER_SPECTATOR; }
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
2407 } else {
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
2408 for (uint i = 0; i < 4; i++) {
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
2409 PlayerID o = p->share_owners[i];
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
2410 if (o == PLAYER_SPECTATOR) continue;
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
2411 if (!IsValidPlayer(o) || o == p->index || !GetPlayer(o)->is_active) p->share_owners[i] = PLAYER_SPECTATOR;
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
2412 }
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
2413 }
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
2414 }
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
2415 }
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
2416
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 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
2418 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
2419 /* Now all crossings should be in correct state */
8344
6312fafcfe47 (svn r11910) -Fix: play 'ding-ding' crossing sound in more cases (except gameload and crossing construction)
smatz <smatz@openttd.org>
parents: 8342
diff changeset
2420 if (IsLevelCrossingTile(t)) UpdateLevelCrossing(t, false);
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
2421
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
2422 /* 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
2423 if (IsTileType(t, MP_WATER)) {
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
2424 if (_m[t].m5 == 2) {
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
2425 MakeRiver(t, Random());
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
2426 } else {
8495
486b50380194 (svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch <frosch@openttd.org>
parents: 8471
diff changeset
2427 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
2428 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
2429 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
2430 MakeWater(t);
486b50380194 (svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch <frosch@openttd.org>
parents: 8471
diff changeset
2431 } else {
486b50380194 (svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch <frosch@openttd.org>
parents: 8471
diff changeset
2432 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
2433 }
486b50380194 (svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch <frosch@openttd.org>
parents: 8471
diff changeset
2434 } 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
2435 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
2436 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
2437 }
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
2438 }
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
2439 }
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
2440 }
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
2441
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
2442 /* 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
2443 * 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
2444 * 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
2445 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
2446 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
2447
8495
486b50380194 (svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch <frosch@openttd.org>
parents: 8471
diff changeset
2448 if (IsTileType(t, MP_WATER) && IsLock(t)) SetWaterClassDependingOnSurroundings(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
2449 if (IsTileType(t, MP_STATION) && (IsDock(t) || IsBuoy(t))) SetWaterClassDependingOnSurroundings(t);
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
2450 }
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
2451 }
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
2452
8521
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2453 if (CheckSavegameVersion(87)) {
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2454 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
2455 /* 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
2456 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
2457 (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
2458 /* 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
2459 * 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
2460 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
2461 }
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
2462
8521
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2463 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
2464 Owner o = GetTileOwner(t);
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2465 if (IsValidPlayer(o) && !GetPlayer(o)->is_active) {
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2466 _current_player = o;
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2467 ChangeTileOwner(t, o, PLAYER_SPECTATOR);
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2468 }
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2469 if (IsBuoyTile(t)) {
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2470 /* reset buoy owner to OWNER_NONE in the station struct
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2471 * (even if it is owned by active player) */
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2472 GetStationByTile(t)->owner = OWNER_NONE;
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2473 }
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2474 } 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
2475 /* works for all RoadTileType */
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2476 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
2477 /* 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
2478 Owner o = GetRoadOwner(t, rt);
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2479 if (IsValidPlayer(o) && !GetPlayer(o)->is_active) SetRoadOwner(t, rt, OWNER_NONE);
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2480 }
8563
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8556
diff changeset
2481 if (IsLevelCrossing(t)) {
8521
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2482 Owner o = GetTileOwner(t);
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2483 if (!GetPlayer(o)->is_active) {
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2484 /* remove leftover rail piece from crossing (from very old savegames) */
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2485 _current_player = o;
8598
ef2c93a9589d (svn r12179) -Codechange: use GetCrossingRailTrack() and GetCrossingRailAxis() to improve code readability
smatz <smatz@openttd.org>
parents: 8563
diff changeset
2486 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
2487 }
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2488 }
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2489 }
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2490 }
8551
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2491
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2492 /* Convert old PF settings to new */
9029
774180fd1ec8 (svn r12845) -Change: use YAPF for fairly old savegames from before YAPF was introduced.
rubidium <rubidium@openttd.org>
parents: 9006
diff changeset
2493 if (_patches.yapf.rail_use_yapf || CheckSavegameVersion(28)) {
8551
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2494 _patches.pathfinder_for_trains = VPF_YAPF;
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2495 } else {
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2496 _patches.pathfinder_for_trains = (_patches.new_pathfinding_all ? VPF_NPF : VPF_NTP);
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2497 }
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2498
9029
774180fd1ec8 (svn r12845) -Change: use YAPF for fairly old savegames from before YAPF was introduced.
rubidium <rubidium@openttd.org>
parents: 9006
diff changeset
2499 if (_patches.yapf.road_use_yapf || CheckSavegameVersion(28)) {
8551
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2500 _patches.pathfinder_for_roadvehs = VPF_YAPF;
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2501 } else {
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2502 _patches.pathfinder_for_roadvehs = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF);
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2503 }
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2504
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2505 if (_patches.yapf.ship_use_yapf) {
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2506 _patches.pathfinder_for_ships = VPF_YAPF;
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2507 } else {
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2508 _patches.pathfinder_for_ships = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF);
bfe75aee55ee (svn r12129) -Change [FS#1759]: simplified patch settings for pathfinders (Yorick)
smatz <smatz@openttd.org>
parents: 8526
diff changeset
2509 }
8521
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2510 }
3d8654a3dd94 (svn r12096) -Fix: remove leftover property when loading older savegames
smatz <smatz@openttd.org>
parents: 8513
diff changeset
2511
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
2512 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
2513 /* 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
2514 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
2515 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
2516 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
2517 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
2518 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
2519 }
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
2520 }
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
2521
8681
051357af9f76 (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch <frosch@openttd.org>
parents: 8670
diff changeset
2522 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
2523 /* 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
2524 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
2525 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
2526 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
2527 }
051357af9f76 (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch <frosch@openttd.org>
parents: 8670
diff changeset
2528 }
051357af9f76 (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch <frosch@openttd.org>
parents: 8670
diff changeset
2529 }
051357af9f76 (svn r12347) -Feature(ette): Increase house animation frame number from 32 to 128.
frosch <frosch@openttd.org>
parents: 8670
diff changeset
2530
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
2531 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
2532 /* 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
2533 * 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
2534 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
2535 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
2536 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
2537 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
2538 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
2539 _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
2540 }
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
2541 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
2542 }
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
2543 }
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
2544 }
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
2545
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
2546 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
2547 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2548
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2549 /** 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
2550 * 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
2551 * 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
2552 * 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
2553 * 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
2554 * removed or added and changed statistics */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
2555 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
2556 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2557 /* 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
2558 GfxLoadSprites();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2559 LoadStringWidthTable();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2560 /* 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
2561 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
2562 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
2563 StartupEngines();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2564 /* 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
2565 AfterLoadWaypoints();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2566 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
2567 /* 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
2568 UpdateHousesAndTowns();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2569 /* 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
2570 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2571 }