author | skidd13 |
Tue, 20 Nov 2007 14:11:19 +0000 | |
changeset 8428 | f8300c908bd9 |
parent 8427 | 143b0be22af1 |
child 8436 | f52eebc3fc20 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
3 |
/** @file openttd.cpp */ |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
6 |
#define VARDEF |
1317
f382f1b439c7
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
1314
diff
changeset
|
7 |
#include "string.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1296
diff
changeset
|
8 |
#include "debug.h" |
2171
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
2163
diff
changeset
|
9 |
#include "driver.h" |
2162
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
2147
diff
changeset
|
10 |
#include "saveload.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
659
diff
changeset
|
11 |
#include "map.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1199
diff
changeset
|
12 |
#include "tile.h" |
3144
426b825578f9
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3121
diff
changeset
|
13 |
#include "void_map.h" |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
14 |
#include "helpers.hpp" |
0 | 15 |
|
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1885
diff
changeset
|
16 |
#include "openttd.h" |
7889
f167f5959c24
(svn r10762) -Codechange: Change enum StringIDEnum { to static const StringID = for
peter1138
parents:
7866
diff
changeset
|
17 |
#include "table/strings.h" |
7762
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7682
diff
changeset
|
18 |
#include "strings.h" |
3367 | 19 |
#include "bridge_map.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2162
diff
changeset
|
20 |
#include "functions.h" |
1496
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1482
diff
changeset
|
21 |
#include "mixer.h" |
1349
07514c2cc6d1
(svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
1329
diff
changeset
|
22 |
#include "spritecache.h" |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4880
diff
changeset
|
23 |
#include "strings.h" |
0 | 24 |
#include "gfx.h" |
2340
0a9f3eeccb96
(svn r2866) Move all functions and tables which aren't directly involved in managing the sprite heap to a new file gfxinit.c.
tron
parents:
2322
diff
changeset
|
25 |
#include "gfxinit.h" |
0 | 26 |
#include "gui.h" |
6949
72d11a1e1e60
(svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros
parents:
6947
diff
changeset
|
27 |
#include "landscape.h" |
0 | 28 |
#include "station.h" |
3367 | 29 |
#include "station_map.h" |
3558 | 30 |
#include "town_map.h" |
3367 | 31 |
#include "tunnel_map.h" |
0 | 32 |
#include "vehicle.h" |
33 |
#include "viewport.h" |
|
34 |
#include "window.h" |
|
35 |
#include "player.h" |
|
36 |
#include "command.h" |
|
37 |
#include "town.h" |
|
38 |
#include "industry.h" |
|
39 |
#include "news.h" |
|
40 |
#include "engine.h" |
|
41 |
#include "sound.h" |
|
42 |
#include "economy.h" |
|
43 |
#include "fileio.h" |
|
44 |
#include "airport.h" |
|
6519
367d6f96e23f
(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
parents:
6516
diff
changeset
|
45 |
#include "aircraft.h" |
126 | 46 |
#include "console.h" |
430 | 47 |
#include "screenshot.h" |
5720
cc0ceeafaa55
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
5687
diff
changeset
|
48 |
#include "network/network.h" |
988
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
983
diff
changeset
|
49 |
#include "signs.h" |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1310
diff
changeset
|
50 |
#include "depot.h" |
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1501
diff
changeset
|
51 |
#include "waypoint.h" |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
52 |
#include "ai/ai.h" |
2855
950b5a56f9d5
(svn r3403) -Codechange: [multiheaded engines] the references between the front and rear engines are no longer saved
bjarni
parents:
2848
diff
changeset
|
53 |
#include "train.h" |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3891
diff
changeset
|
54 |
#include "yapf/yapf.h" |
3889
cc4a8556c19d
(svn r4945) Fix (r3726): make -t command line option (set starting date/year) work again
rubidium
parents:
3765
diff
changeset
|
55 |
#include "settings.h" |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
56 |
#include "genworld.h" |
4261
2ec8f5a9747b
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
4260
diff
changeset
|
57 |
#include "date.h" |
4328
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
58 |
#include "clear_map.h" |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5024
diff
changeset
|
59 |
#include "fontcache.h" |
6947
c21859ab4493
(svn r9601) -Codechange: Store grf file reference in station spec, not just GRF ID
peter1138
parents:
6923
diff
changeset
|
60 |
#include "newgrf.h" |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5197
diff
changeset
|
61 |
#include "newgrf_config.h" |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
62 |
#include "newgrf_house.h" |
7125
4ce0c7a12a3f
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
7122
diff
changeset
|
63 |
#include "newgrf_commons.h" |
8105
8f7fcf4d2b7e
(svn r11138) -Codechange: prepare some subsystems for persistent storage for NewGRFs.
rubidium
parents:
8063
diff
changeset
|
64 |
#include "newgrf_storage.h" |
6516
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6501
diff
changeset
|
65 |
#include "player_face.h" |
7139
4ae3ab180d05
(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
parents:
7125
diff
changeset
|
66 |
#include "group.h" |
7433
8e410e7ec0d7
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
7431
diff
changeset
|
67 |
#include "blitter/factory.hpp" |
7666
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
68 |
#include "sound/sound_driver.hpp" |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
69 |
#include "music/music_driver.hpp" |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
70 |
#include "video/video_driver.hpp" |
0 | 71 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
72 |
#include "bridge_map.h" |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
73 |
#include "clear_map.h" |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
74 |
#include "rail_map.h" |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
75 |
#include "road_map.h" |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
76 |
#include "water_map.h" |
5687
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
77 |
#include "industry_map.h" |
6583
82012e77b10c
(svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents:
6573
diff
changeset
|
78 |
#include "unmovable_map.h" |
8206
573a2d359695
(svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight
parents:
8141
diff
changeset
|
79 |
#include "tree_map.h" |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
80 |
|
0 | 81 |
#include <stdarg.h> |
82 |
||
6573 | 83 |
void CallLandscapeTick(); |
84 |
void IncreaseDate(); |
|
85 |
void DoPaletteAnimations(); |
|
86 |
void MusicLoop(); |
|
87 |
void ResetMusic(); |
|
0 | 88 |
|
89 |
extern void SetDifficultyLevel(int mode, GameOptions *gm_opt); |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
90 |
extern Player* DoStartupNewPlayer(bool is_ai); |
0 | 91 |
extern void ShowOSErrorBox(const char *buf); |
7560
f7b5ab184882
(svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium
parents:
7554
diff
changeset
|
92 |
extern void SetDefaultRailGui(); |
0 | 93 |
|
1436 | 94 |
/* TODO: usrerror() for errors which are not of an internal nature but |
95 |
* caused by the user, i.e. missing files or fatal configuration errors. |
|
96 |
* Post-0.4.0 since Celestar doesn't want this in SVN before. --pasky */ |
|
97 |
||
4171 | 98 |
void CDECL error(const char *s, ...) |
2639 | 99 |
{ |
0 | 100 |
va_list va; |
101 |
char buf[512]; |
|
2639 | 102 |
|
0 | 103 |
va_start(va, s); |
5170
56c12a62af49
(svn r7280) -Codechange: Replace some sprintf() functions with the safer snprintf() functions
Darkvater
parents:
5166
diff
changeset
|
104 |
vsnprintf(buf, lengthof(buf), s, va); |
0 | 105 |
va_end(va); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
106 |
|
0 | 107 |
ShowOSErrorBox(buf); |
7666
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
108 |
if (_video_driver != NULL) _video_driver->Stop(); |
0 | 109 |
|
110 |
assert(0); |
|
111 |
exit(1); |
|
112 |
} |
|
113 |
||
114 |
void CDECL ShowInfoF(const char *str, ...) |
|
115 |
{ |
|
116 |
va_list va; |
|
117 |
char buf[1024]; |
|
118 |
va_start(va, str); |
|
5170
56c12a62af49
(svn r7280) -Codechange: Replace some sprintf() functions with the safer snprintf() functions
Darkvater
parents:
5166
diff
changeset
|
119 |
vsnprintf(buf, lengthof(buf), str, va); |
0 | 120 |
va_end(va); |
121 |
ShowInfo(buf); |
|
122 |
} |
|
123 |
||
124 |
||
1310
85cde2193afc
(svn r1814) Let ReadFileToMem() return void* (instead of byte*) because we don't know what the caller wants to do with the data
tron
parents:
1309
diff
changeset
|
125 |
void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize) |
0 | 126 |
{ |
127 |
FILE *in; |
|
1105 | 128 |
byte *mem; |
0 | 129 |
size_t len; |
130 |
||
131 |
in = fopen(filename, "rb"); |
|
2639 | 132 |
if (in == NULL) return NULL; |
0 | 133 |
|
134 |
fseek(in, 0, SEEK_END); |
|
135 |
len = ftell(in); |
|
136 |
fseek(in, 0, SEEK_SET); |
|
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5838
diff
changeset
|
137 |
if (len > maxsize || (mem = MallocT<byte>(len + 1)) == NULL) { |
0 | 138 |
fclose(in); |
139 |
return NULL; |
|
140 |
} |
|
1105 | 141 |
mem[len] = 0; |
0 | 142 |
if (fread(mem, len, 1, in) != 1) { |
143 |
fclose(in); |
|
144 |
free(mem); |
|
145 |
return NULL; |
|
146 |
} |
|
147 |
fclose(in); |
|
148 |
||
149 |
*lenp = len; |
|
150 |
return mem; |
|
151 |
} |
|
152 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
153 |
extern const char _openttd_revision[]; |
6573 | 154 |
static void showhelp() |
0 | 155 |
{ |
156 |
char buf[4096], *p; |
|
157 |
||
5170
56c12a62af49
(svn r7280) -Codechange: Replace some sprintf() functions with the safer snprintf() functions
Darkvater
parents:
5166
diff
changeset
|
158 |
p = buf; |
2831
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
159 |
|
5170
56c12a62af49
(svn r7280) -Codechange: Replace some sprintf() functions with the safer snprintf() functions
Darkvater
parents:
5166
diff
changeset
|
160 |
p += snprintf(p, lengthof(buf), "OpenTTD %s\n", _openttd_revision); |
56c12a62af49
(svn r7280) -Codechange: Replace some sprintf() functions with the safer snprintf() functions
Darkvater
parents:
5166
diff
changeset
|
161 |
p = strecpy(p, |
2831
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
162 |
"\n" |
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
163 |
"\n" |
0 | 164 |
"Command line options:\n" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
165 |
" -v drv = Set video driver (see below)\n" |
6136
1262d3c24277
(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
parents:
6135
diff
changeset
|
166 |
" -s drv = Set sound driver (see below) (param bufsize,hz)\n" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
167 |
" -m drv = Set music driver (see below)\n" |
7348
becce3f57dc7
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
7266
diff
changeset
|
168 |
" -b drv = Set the blitter to use (see below)\n" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
169 |
" -r res = Set resolution (for instance 800x600)\n" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
170 |
" -h = Display this help text\n" |
4285
72b3f7d6c891
(svn r5915) -Cleanup: some variables were named *_date while they were only holding years; rename these variables to match this.
rubidium
parents:
4277
diff
changeset
|
171 |
" -t year = Set starting year\n" |
1440
2eb4dd1e0465
(svn r1944) Make --help output for -d at least somewhat useful.
pasky
parents:
1436
diff
changeset
|
172 |
" -d [[fac=]lvl[,...]]= Debug mode\n" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
173 |
" -e = Start Editor\n" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
174 |
" -g [savegame] = Start new/save game immediately\n" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
175 |
" -G seed = Set random seed\n" |
5943
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
176 |
#if defined(ENABLE_NETWORK) |
5676
74a4ba0f4196
(svn r7629) -Fix: the CLI parameter for joining a network game is "-n ip:port#player", not "-n ip#player:port" as the help text suggests.
rubidium
parents:
5573
diff
changeset
|
177 |
" -n [ip:port#player] = Start networkgame\n" |
5759
5c0d748579a0
(svn r7802) -Feature: make it possible to override the bind address and port of a dedicated server from the command line.
rubidium
parents:
5758
diff
changeset
|
178 |
" -D [ip][:port] = Start dedicated server\n" |
6210
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
179 |
" -l ip[:port] = Redirect DEBUG()\n" |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
180 |
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32) |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
181 |
" -f = Fork into the background (dedicated only)\n" |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
182 |
#endif |
5943
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
183 |
#endif /* ENABLE_NETWORK */ |
2831
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
184 |
" -i = Force to use the DOS palette\n" |
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
185 |
" (use this if you see a lot of pink)\n" |
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
186 |
" -c config_file = Use 'config_file' instead of 'openttd.cfg'\n" |
5827
20879afb77f6
(svn r8013) -Codechange (r6921, rUnknown): Show the error message of corrupt or missing (own) files
Darkvater
parents:
5772
diff
changeset
|
187 |
" -x = Do not automatically save to config file on exit\n", |
5170
56c12a62af49
(svn r7280) -Codechange: Replace some sprintf() functions with the safer snprintf() functions
Darkvater
parents:
5166
diff
changeset
|
188 |
lastof(buf) |
0 | 189 |
); |
190 |
||
7666
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
191 |
/* List the drivers */ |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
192 |
p = VideoDriverFactoryBase::GetDriversInfo(p, lastof(buf)); |
0 | 193 |
|
7348
becce3f57dc7
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
7266
diff
changeset
|
194 |
/* List the blitters */ |
becce3f57dc7
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
7266
diff
changeset
|
195 |
p = BlitterFactoryBase::GetBlittersInfo(p, lastof(buf)); |
becce3f57dc7
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
7266
diff
changeset
|
196 |
|
5974
7de3ff0166f8
(svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater
parents:
5958
diff
changeset
|
197 |
/* ShowInfo put output to stderr, but version information should go |
7de3ff0166f8
(svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater
parents:
5958
diff
changeset
|
198 |
* to stdout; this is the only exception */ |
7de3ff0166f8
(svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater
parents:
5958
diff
changeset
|
199 |
#if !defined(WIN32) && !defined(WIN64) |
7de3ff0166f8
(svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater
parents:
5958
diff
changeset
|
200 |
printf("%s\n", buf); |
7de3ff0166f8
(svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater
parents:
5958
diff
changeset
|
201 |
#else |
0 | 202 |
ShowInfo(buf); |
5974
7de3ff0166f8
(svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater
parents:
5958
diff
changeset
|
203 |
#endif |
0 | 204 |
} |
205 |
||
206 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
207 |
struct MyGetOptData { |
0 | 208 |
char *opt; |
209 |
int numleft; |
|
210 |
char **argv; |
|
211 |
const char *options; |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
212 |
const char *cont; |
0 | 213 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
214 |
MyGetOptData(int argc, char **argv, const char *options) |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
215 |
{ |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
216 |
opt = NULL; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
217 |
numleft = argc; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
218 |
this->argv = argv; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
219 |
this->options = options; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
220 |
cont = NULL; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
221 |
} |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
222 |
}; |
0 | 223 |
|
224 |
static int MyGetOpt(MyGetOptData *md) |
|
225 |
{ |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
226 |
const char *s,*r,*t; |
0 | 227 |
|
2639 | 228 |
s = md->cont; |
229 |
if (s != NULL) |
|
0 | 230 |
goto md_continue_here; |
231 |
||
2639 | 232 |
for (;;) { |
233 |
if (--md->numleft < 0) return -1; |
|
0 | 234 |
|
235 |
s = *md->argv++; |
|
236 |
if (*s == '-') { |
|
237 |
md_continue_here:; |
|
238 |
s++; |
|
239 |
if (*s != 0) { |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
240 |
/* Found argument, try to locate it in options. */ |
0 | 241 |
if (*s == ':' || (r = strchr(md->options, *s)) == NULL) { |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
242 |
/* ERROR! */ |
0 | 243 |
return -2; |
244 |
} |
|
245 |
if (r[1] == ':') { |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
246 |
/* Item wants an argument. Check if the argument follows, or if it comes as a separate arg. */ |
0 | 247 |
if (!*(t = s + 1)) { |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
248 |
/* It comes as a separate arg. Check if out of args? */ |
0 | 249 |
if (--md->numleft < 0 || *(t = *md->argv) == '-') { |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
250 |
/* Check if item is optional? */ |
0 | 251 |
if (r[2] != ':') |
252 |
return -2; |
|
253 |
md->numleft++; |
|
254 |
t = NULL; |
|
255 |
} else { |
|
256 |
md->argv++; |
|
257 |
} |
|
258 |
} |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
259 |
md->opt = (char*)t; |
0 | 260 |
md->cont = NULL; |
261 |
return *s; |
|
262 |
} |
|
263 |
md->opt = NULL; |
|
264 |
md->cont = s; |
|
265 |
return *s; |
|
266 |
} |
|
267 |
} else { |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
268 |
/* This is currently not supported. */ |
0 | 269 |
return -2; |
270 |
} |
|
271 |
} |
|
272 |
} |
|
273 |
||
274 |
||
4171 | 275 |
static void ParseResolution(int res[2], const char *s) |
0 | 276 |
{ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
277 |
const char *t = strchr(s, 'x'); |
0 | 278 |
if (t == NULL) { |
279 |
ShowInfoF("Invalid resolution '%s'", s); |
|
280 |
return; |
|
281 |
} |
|
282 |
||
8418
b49fc6be1ab9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents:
8345
diff
changeset
|
283 |
res[0] = Clamp(strtoul(s, NULL, 0), 64, MAX_SCREEN_WIDTH); |
b49fc6be1ab9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents:
8345
diff
changeset
|
284 |
res[1] = Clamp(strtoul(t + 1, NULL, 0), 64, MAX_SCREEN_HEIGHT); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
285 |
} |
0 | 286 |
|
6573 | 287 |
static void InitializeDynamicVariables() |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
288 |
{ |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
289 |
/* Dynamic stuff needs to be initialized somewhere... */ |
1267
cbd68e5e31ac
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1264
diff
changeset
|
290 |
_town_sort = NULL; |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
291 |
_industry_sort = NULL; |
7648
dde14ba48325
(svn r10426) -Codechange: Activate the reset of industry/tiles mapping upon initialization or new game.
belugas
parents:
7587
diff
changeset
|
292 |
_industry_mngr.ResetMapping(); |
dde14ba48325
(svn r10426) -Codechange: Activate the reset of industry/tiles mapping upon initialization or new game.
belugas
parents:
7587
diff
changeset
|
293 |
_industile_mngr.ResetMapping(); |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
294 |
} |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
295 |
|
5910
61e264641a8d
(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
parents:
5903
diff
changeset
|
296 |
|
6573 | 297 |
static void UnInitializeGame() |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
298 |
{ |
5910
61e264641a8d
(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
parents:
5903
diff
changeset
|
299 |
UnInitWindowSystem(); |
61e264641a8d
(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
parents:
5903
diff
changeset
|
300 |
|
61e264641a8d
(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
parents:
5903
diff
changeset
|
301 |
/* Uninitialize airport state machines */ |
61e264641a8d
(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
parents:
5903
diff
changeset
|
302 |
UnInitializeAirports(); |
61e264641a8d
(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
parents:
5903
diff
changeset
|
303 |
|
61e264641a8d
(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
parents:
5903
diff
changeset
|
304 |
/* Uninitialize variables that are allocated dynamically */ |
7897
222641b84fc4
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium
parents:
7889
diff
changeset
|
305 |
_Town_pool.CleanPool(); |
222641b84fc4
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium
parents:
7889
diff
changeset
|
306 |
_Industry_pool.CleanPool(); |
222641b84fc4
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium
parents:
7889
diff
changeset
|
307 |
_Station_pool.CleanPool(); |
222641b84fc4
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium
parents:
7889
diff
changeset
|
308 |
_Vehicle_pool.CleanPool(); |
222641b84fc4
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium
parents:
7889
diff
changeset
|
309 |
_Sign_pool.CleanPool(); |
222641b84fc4
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium
parents:
7889
diff
changeset
|
310 |
_Order_pool.CleanPool(); |
222641b84fc4
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium
parents:
7889
diff
changeset
|
311 |
_Group_pool.CleanPool(); |
222641b84fc4
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium
parents:
7889
diff
changeset
|
312 |
_CargoPacket_pool.CleanPool(); |
1260
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1246
diff
changeset
|
313 |
|
4277
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4268
diff
changeset
|
314 |
free((void*)_town_sort); |
3539bd14f023
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4268
diff
changeset
|
315 |
free((void*)_industry_sort); |
1482
46a8146adecf
(svn r1986) - Fix: free _config_file when shutting down openttd. Strange that Valgrind didn't catch this, kudos to TrueLight
Darkvater
parents:
1478
diff
changeset
|
316 |
|
46a8146adecf
(svn r1986) - Fix: free _config_file when shutting down openttd. Strange that Valgrind didn't catch this, kudos to TrueLight
Darkvater
parents:
1478
diff
changeset
|
317 |
free(_config_file); |
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
318 |
} |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
319 |
|
6573 | 320 |
static void LoadIntroGame() |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
321 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
322 |
_game_mode = GM_MENU; |
6923
6913c8a82cc0
(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
parents:
6677
diff
changeset
|
323 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
324 |
_opt_ptr = &_opt_newgame; |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5197
diff
changeset
|
325 |
ResetGRFConfig(false); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
326 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
327 |
/* Setup main window */ |
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
328 |
ResetWindowSystem(); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
329 |
SetupColorsAndInitialWindow(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
330 |
|
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
331 |
/* Load the default opening screen savegame */ |
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
332 |
if (SaveOrLoad("opntitle.dat", SL_LOAD, DATA_DIR) != SL_OK) { |
3033
e4f7c60a1742
(svn r3613) Some more const, indentation, whitespace and similar stuff
tron
parents:
3024
diff
changeset
|
333 |
GenerateWorld(GW_EMPTY, 64, 64); // if failed loading, make empty world. |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
334 |
WaitTillGeneratedWorld(); |
921 | 335 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
336 |
|
6557
8381016f71f3
(svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents:
6555
diff
changeset
|
337 |
_pause_game = 0; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
338 |
SetLocalPlayer(PLAYER_FIRST); |
4336
d5cd47d24092
(svn r6037) -Fix: never allow scrolling the map in the main menu (scroll-settings weren't reset if switched to mainmenu)
truelight
parents:
4328
diff
changeset
|
339 |
/* Make sure you can't scroll in the menu */ |
d5cd47d24092
(svn r6037) -Fix: never allow scrolling the map in the main menu (scroll-settings weren't reset if switched to mainmenu)
truelight
parents:
4328
diff
changeset
|
340 |
_scrolling_viewport = 0; |
d5cd47d24092
(svn r6037) -Fix: never allow scrolling the map in the main menu (scroll-settings weren't reset if switched to mainmenu)
truelight
parents:
4328
diff
changeset
|
341 |
_cursor.fix_at = false; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
342 |
MarkWholeScreenDirty(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
343 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
344 |
/* Play main theme */ |
7666
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
345 |
if (_music_driver->IsSongPlaying()) ResetMusic(); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
346 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
347 |
|
2290 | 348 |
#if defined(UNIX) && !defined(__MORPHOS__) |
6573 | 349 |
extern void DedicatedFork(); |
2290 | 350 |
#endif |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
351 |
|
4171 | 352 |
int ttd_main(int argc, char *argv[]) |
0 | 353 |
{ |
354 |
int i; |
|
1010
17470a8e5eb7
(svn r1509) Const correctness and add static where appropriate while touching the lines anyway
tron
parents:
1009
diff
changeset
|
355 |
const char *optformat; |
7348
becce3f57dc7
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
7266
diff
changeset
|
356 |
char musicdriver[32], sounddriver[32], videodriver[32], blitter[32]; |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6982
diff
changeset
|
357 |
int resolution[2] = {0, 0}; |
4293
2c24234a7aec
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4285
diff
changeset
|
358 |
Year startyear = INVALID_YEAR; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
359 |
uint generation_seed = GENERATE_NEW_SEED; |
5943
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
360 |
bool save_config = true; |
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
361 |
#if defined(ENABLE_NETWORK) |
3058
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
362 |
bool dedicated = false; |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
363 |
bool network = false; |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
364 |
char *network_conn = NULL; |
6210
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
365 |
char *debuglog_conn = NULL; |
5759
5c0d748579a0
(svn r7802) -Feature: make it possible to override the bind address and port of a dedicated server from the command line.
rubidium
parents:
5758
diff
changeset
|
366 |
char *dedicated_host = NULL; |
5c0d748579a0
(svn r7802) -Feature: make it possible to override the bind address and port of a dedicated server from the command line.
rubidium
parents:
5758
diff
changeset
|
367 |
uint16 dedicated_port = 0; |
5943
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
368 |
#endif /* ENABLE_NETWORK */ |
1406
2d5baabe4046
(svn r1910) Move two variables out of variables.h which are only used locally
tron
parents:
1397
diff
changeset
|
369 |
|
7348
becce3f57dc7
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
7266
diff
changeset
|
370 |
musicdriver[0] = sounddriver[0] = videodriver[0] = blitter[0] = '\0'; |
0 | 371 |
|
372 |
_game_mode = GM_MENU; |
|
373 |
_switch_mode = SM_MENU; |
|
172
8d8b3383470d
(svn r173) -Network: [1023231] Debug Code + ErrorBoxes + Load Game/Scenario. Added some more desync debug code and replaced some of the error() calls with some better error boxes. Hopefully find desyncs easier (sign_de)
darkvater
parents:
168
diff
changeset
|
374 |
_switch_mode_errorstr = INVALID_STRING_ID; |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
375 |
_dedicated_forks = false; |
1482
46a8146adecf
(svn r1986) - Fix: free _config_file when shutting down openttd. Strange that Valgrind didn't catch this, kudos to TrueLight
Darkvater
parents:
1478
diff
changeset
|
376 |
_config_file = NULL; |
0 | 377 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
378 |
/* The last param of the following function means this: |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
379 |
* a letter means: it accepts that param (e.g.: -h) |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
380 |
* a ':' behind it means: it need a param (e.g.: -m<driver>) |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
381 |
* a '::' behind it means: it can optional have a param (e.g.: -d<debug>) */ |
7348
becce3f57dc7
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
7266
diff
changeset
|
382 |
optformat = "m:s:v:b:hD::n::eit:d::r:g::G:c:xl:" |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
383 |
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32) |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
384 |
"f" |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
385 |
#endif |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
386 |
; |
770
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
768
diff
changeset
|
387 |
|
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6982
diff
changeset
|
388 |
MyGetOptData mgo(argc - 1, argv + 1, optformat); |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
389 |
|
0 | 390 |
while ((i = MyGetOpt(&mgo)) != -1) { |
2951 | 391 |
switch (i) { |
0 | 392 |
case 'm': ttd_strlcpy(musicdriver, mgo.opt, sizeof(musicdriver)); break; |
393 |
case 's': ttd_strlcpy(sounddriver, mgo.opt, sizeof(sounddriver)); break; |
|
394 |
case 'v': ttd_strlcpy(videodriver, mgo.opt, sizeof(videodriver)); break; |
|
7348
becce3f57dc7
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
7266
diff
changeset
|
395 |
case 'b': ttd_strlcpy(blitter, mgo.opt, sizeof(blitter)); break; |
5943
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
396 |
#if defined(ENABLE_NETWORK) |
3058
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
397 |
case 'D': |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
398 |
strcpy(musicdriver, "null"); |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
399 |
strcpy(sounddriver, "null"); |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
400 |
strcpy(videodriver, "dedicated"); |
7374
54c06f06ecc8
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents:
7363
diff
changeset
|
401 |
strcpy(blitter, "null"); |
3058
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
402 |
dedicated = true; |
6136
1262d3c24277
(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
parents:
6135
diff
changeset
|
403 |
if (mgo.opt != NULL) { |
5759
5c0d748579a0
(svn r7802) -Feature: make it possible to override the bind address and port of a dedicated server from the command line.
rubidium
parents:
5758
diff
changeset
|
404 |
/* Use the existing method for parsing (openttd -n). |
5c0d748579a0
(svn r7802) -Feature: make it possible to override the bind address and port of a dedicated server from the command line.
rubidium
parents:
5758
diff
changeset
|
405 |
* However, we do ignore the #player part. */ |
5c0d748579a0
(svn r7802) -Feature: make it possible to override the bind address and port of a dedicated server from the command line.
rubidium
parents:
5758
diff
changeset
|
406 |
const char *temp = NULL; |
5c0d748579a0
(svn r7802) -Feature: make it possible to override the bind address and port of a dedicated server from the command line.
rubidium
parents:
5758
diff
changeset
|
407 |
const char *port = NULL; |
5c0d748579a0
(svn r7802) -Feature: make it possible to override the bind address and port of a dedicated server from the command line.
rubidium
parents:
5758
diff
changeset
|
408 |
ParseConnectionString(&temp, &port, mgo.opt); |
6136
1262d3c24277
(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
parents:
6135
diff
changeset
|
409 |
if (!StrEmpty(mgo.opt)) dedicated_host = mgo.opt; |
5759
5c0d748579a0
(svn r7802) -Feature: make it possible to override the bind address and port of a dedicated server from the command line.
rubidium
parents:
5758
diff
changeset
|
410 |
if (port != NULL) dedicated_port = atoi(port); |
5c0d748579a0
(svn r7802) -Feature: make it possible to override the bind address and port of a dedicated server from the command line.
rubidium
parents:
5758
diff
changeset
|
411 |
} |
3058
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
412 |
break; |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
413 |
case 'f': _dedicated_forks = true; break; |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
414 |
case 'n': |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
415 |
network = true; |
3059
9f25d987c6ae
(svn r3648) - Fix typo in r3647, don't ask me how it got there s/_/./
Darkvater
parents:
3058
diff
changeset
|
416 |
network_conn = mgo.opt; // optional IP parameter, NULL if unset |
3058
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
417 |
break; |
6210
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
418 |
case 'l': |
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
419 |
debuglog_conn = mgo.opt; |
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
420 |
break; |
5943
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
421 |
#endif /* ENABLE_NETWORK */ |
0 | 422 |
case 'r': ParseResolution(resolution, mgo.opt); break; |
4285
72b3f7d6c891
(svn r5915) -Cleanup: some variables were named *_date while they were only holding years; rename these variables to match this.
rubidium
parents:
4277
diff
changeset
|
423 |
case 't': startyear = atoi(mgo.opt); break; |
0 | 424 |
case 'd': { |
425 |
#if defined(WIN32) |
|
426 |
CreateConsole(); |
|
427 |
#endif |
|
2639 | 428 |
if (mgo.opt != NULL) SetDebugString(mgo.opt); |
0 | 429 |
} break; |
430 |
case 'e': _switch_mode = SM_EDITOR; break; |
|
614
e016770cb781
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
561
diff
changeset
|
431 |
case 'i': _use_dos_palette = true; break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
432 |
case 'g': |
2639 | 433 |
if (mgo.opt != NULL) { |
0 | 434 |
strcpy(_file_to_saveload.name, mgo.opt); |
435 |
_switch_mode = SM_LOAD; |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
436 |
} else { |
0 | 437 |
_switch_mode = SM_NEWGAME; |
6635
8a2f24f0c746
(svn r9205) -Fix: if you started openttd with '-g' you got the same map every run
truelight
parents:
6630
diff
changeset
|
438 |
/* Give a random map */ |
8a2f24f0c746
(svn r9205) -Fix: if you started openttd with '-g' you got the same map every run
truelight
parents:
6630
diff
changeset
|
439 |
generation_seed = InteractiveRandom(); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
440 |
} |
0 | 441 |
break; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
442 |
case 'G': generation_seed = atoi(mgo.opt); break; |
3058
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
443 |
case 'c': _config_file = strdup(mgo.opt); break; |
5758
c508f77aedd7
(svn r7801) -Feature: add command line option to prevent saving of highscore and configuration on exit and a console command to manually initiate a configuration save (Aloysha).
rubidium
parents:
5726
diff
changeset
|
444 |
case 'x': save_config = false; break; |
0 | 445 |
case -2: |
2026 | 446 |
case 'h': |
0 | 447 |
showhelp(); |
448 |
return 0; |
|
449 |
} |
|
450 |
} |
|
451 |
||
7904
238db1373ca3
(svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight
parents:
7897
diff
changeset
|
452 |
#if defined(WINCE) && defined(_DEBUG) |
238db1373ca3
(svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight
parents:
7897
diff
changeset
|
453 |
/* Switch on debug lvl 4 for WinCE if Debug release, as you can't give params, and you most likely do want this information */ |
238db1373ca3
(svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight
parents:
7897
diff
changeset
|
454 |
SetDebugString("4"); |
238db1373ca3
(svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight
parents:
7897
diff
changeset
|
455 |
#endif |
238db1373ca3
(svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight
parents:
7897
diff
changeset
|
456 |
|
6643
7fad81bde617
(svn r9266) -Codechange: unify the retrieval of the base paths a little more.
rubidium
parents:
6635
diff
changeset
|
457 |
DeterminePaths(argv[0]); |
961 | 458 |
CheckExternalFiles(); |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
459 |
|
2290 | 460 |
#if defined(UNIX) && !defined(__MORPHOS__) |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
461 |
/* We must fork here, or we'll end up without some resources we need (like sockets) */ |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
462 |
if (_dedicated_forks) |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
463 |
DedicatedFork(); |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
464 |
#endif |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
465 |
|
0 | 466 |
LoadFromConfig(); |
1688
787400219027
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1608
diff
changeset
|
467 |
CheckConfig(); |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
961
diff
changeset
|
468 |
LoadFromHighScore(); |
0 | 469 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
470 |
/* override config? */ |
6136
1262d3c24277
(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
parents:
6135
diff
changeset
|
471 |
if (!StrEmpty(musicdriver)) ttd_strlcpy(_ini_musicdriver, musicdriver, sizeof(_ini_musicdriver)); |
1262d3c24277
(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
parents:
6135
diff
changeset
|
472 |
if (!StrEmpty(sounddriver)) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver)); |
1262d3c24277
(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
parents:
6135
diff
changeset
|
473 |
if (!StrEmpty(videodriver)) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver)); |
8063
0e907a0b5add
(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
parents:
8011
diff
changeset
|
474 |
if (!StrEmpty(blitter)) ttd_strlcpy(_ini_blitter, blitter, sizeof(_ini_blitter)); |
6136
1262d3c24277
(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
parents:
6135
diff
changeset
|
475 |
if (resolution[0] != 0) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; } |
4293
2c24234a7aec
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4285
diff
changeset
|
476 |
if (startyear != INVALID_YEAR) _patches_newgame.starting_year = startyear; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
477 |
if (generation_seed != GENERATE_NEW_SEED) _patches_newgame.generation_seed = generation_seed; |
0 | 478 |
|
7388
0ea10e15e891
(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
parents:
7374
diff
changeset
|
479 |
/* The width and height must be at least 1 pixel, this |
0ea10e15e891
(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
parents:
7374
diff
changeset
|
480 |
* way all internal drawing routines work correctly. */ |
0ea10e15e891
(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
parents:
7374
diff
changeset
|
481 |
if (_cur_resolution[0] == 0) _cur_resolution[0] = 1; |
0ea10e15e891
(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
parents:
7374
diff
changeset
|
482 |
if (_cur_resolution[1] == 0) _cur_resolution[1] = 1; |
0ea10e15e891
(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
parents:
7374
diff
changeset
|
483 |
|
5943
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
484 |
#if defined(ENABLE_NETWORK) |
5759
5c0d748579a0
(svn r7802) -Feature: make it possible to override the bind address and port of a dedicated server from the command line.
rubidium
parents:
5758
diff
changeset
|
485 |
if (dedicated_host) snprintf(_network_server_bind_ip_host, NETWORK_HOSTNAME_LENGTH, "%s", dedicated_host); |
5c0d748579a0
(svn r7802) -Feature: make it possible to override the bind address and port of a dedicated server from the command line.
rubidium
parents:
5758
diff
changeset
|
486 |
if (dedicated_port) _network_server_port = dedicated_port; |
2951 | 487 |
if (_dedicated_forks && !dedicated) _dedicated_forks = false; |
5943
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
488 |
#endif /* ENABLE_NETWORK */ |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
489 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
490 |
/* enumerate language files */ |
0 | 491 |
InitializeLanguagePacks(); |
492 |
||
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
493 |
/* initialize screenshot formats */ |
0 | 494 |
InitializeScreenshotFormats(); |
495 |
||
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
496 |
/* initialize airport state machines */ |
105 | 497 |
InitializeAirports(); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
498 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
499 |
/* initialize all variables that are allocated dynamically */ |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
500 |
InitializeDynamicVariables(); |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
501 |
|
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
502 |
/* start the AI */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
503 |
AI_Initialize(); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
504 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
505 |
/* Sample catalogue */ |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5564
diff
changeset
|
506 |
DEBUG(misc, 1, "Loading sound effects..."); |
1496
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1482
diff
changeset
|
507 |
MxInitialize(11025); |
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1482
diff
changeset
|
508 |
SoundInitialize("sample.cat"); |
0 | 509 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5024
diff
changeset
|
510 |
/* Initialize FreeType */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5024
diff
changeset
|
511 |
InitFreeType(); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5024
diff
changeset
|
512 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
513 |
/* This must be done early, since functions use the InvalidateWindow* calls */ |
139 | 514 |
InitWindowSystem(); |
0 | 515 |
|
5166
c40f2b19eca9
(svn r7273) -Fix (r7250): Initialise game palette before driver initialisation. This fixes a 'black screen' problem with fullscreen with the win32 video driver.
peter1138
parents:
5155
diff
changeset
|
516 |
/* Initialize game palette */ |
c40f2b19eca9
(svn r7273) -Fix (r7250): Initialise game palette before driver initialisation. This fixes a 'black screen' problem with fullscreen with the win32 video driver.
peter1138
parents:
5155
diff
changeset
|
517 |
GfxInitPalettes(); |
c40f2b19eca9
(svn r7273) -Fix (r7250): Initialise game palette before driver initialisation. This fixes a 'black screen' problem with fullscreen with the win32 video driver.
peter1138
parents:
5155
diff
changeset
|
518 |
|
8063
0e907a0b5add
(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
parents:
8011
diff
changeset
|
519 |
DEBUG(misc, 1, "Loading blitter..."); |
0e907a0b5add
(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
parents:
8011
diff
changeset
|
520 |
if (BlitterFactoryBase::SelectBlitter(_ini_blitter) == NULL) |
0e907a0b5add
(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
parents:
8011
diff
changeset
|
521 |
StrEmpty(_ini_blitter) ? |
0e907a0b5add
(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
parents:
8011
diff
changeset
|
522 |
error("Failed to autoprobe blitter") : |
0e907a0b5add
(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
parents:
8011
diff
changeset
|
523 |
error("Failed to select requested blitter '%s'; does it exist?", _ini_blitter); |
7666
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
524 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5564
diff
changeset
|
525 |
DEBUG(driver, 1, "Loading drivers..."); |
7666
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
526 |
|
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
527 |
_sound_driver = (SoundDriver*)SoundDriverFactoryBase::SelectDriver(_ini_sounddriver, Driver::DT_SOUND); |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
528 |
if (_sound_driver == NULL) { |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
529 |
StrEmpty(_ini_sounddriver) ? |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
530 |
error("Failed to autoprobe sound driver") : |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
531 |
error("Failed to select requested sound driver '%s'", _ini_sounddriver); |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
532 |
} |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
533 |
|
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
534 |
_music_driver = (MusicDriver*)MusicDriverFactoryBase::SelectDriver(_ini_musicdriver, Driver::DT_MUSIC); |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
535 |
if (_music_driver == NULL) { |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
536 |
StrEmpty(_ini_musicdriver) ? |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
537 |
error("Failed to autoprobe music driver") : |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
538 |
error("Failed to select requested music driver '%s'", _ini_musicdriver); |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
539 |
} |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
540 |
|
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
541 |
_video_driver = (VideoDriver*)VideoDriverFactoryBase::SelectDriver(_ini_videodriver, Driver::DT_VIDEO); |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
542 |
if (_video_driver == NULL) { |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
543 |
StrEmpty(_ini_videodriver) ? |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
544 |
error("Failed to autoprobe video driver") : |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
545 |
error("Failed to select requested video driver '%s'", _ini_videodriver); |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
546 |
} |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
547 |
|
2526
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
548 |
_savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING; |
7150
2cfe4a46fa1c
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents:
7139
diff
changeset
|
549 |
/* Initialize the zoom level of the screen to normal */ |
2cfe4a46fa1c
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents:
7139
diff
changeset
|
550 |
_screen.zoom = ZOOM_LVL_NORMAL; |
0 | 551 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
552 |
/* restore saved music volume */ |
7666
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
553 |
_music_driver->SetVolume(msf.music_vol); |
3678
599ea808a4f8
(svn r4595) - Fix (FS#63) Music volume is now restored to the value saved in openttd.cfg
glx
parents:
3676
diff
changeset
|
554 |
|
4830
0ff2a14e90be
(svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents:
4829
diff
changeset
|
555 |
NetworkStartUp(); // initialize network-core |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
556 |
|
6210
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
557 |
#if defined(ENABLE_NETWORK) |
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
558 |
if (debuglog_conn != NULL && _network_available) { |
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
559 |
const char *not_used = NULL; |
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
560 |
const char *port = NULL; |
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
561 |
uint16 rport; |
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
562 |
|
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
563 |
rport = NETWORK_DEFAULT_DEBUGLOG_PORT; |
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
564 |
|
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
565 |
ParseConnectionString(¬_used, &port, debuglog_conn); |
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
566 |
if (port != NULL) rport = atoi(port); |
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
567 |
|
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
568 |
NetworkStartDebugLog(debuglog_conn, rport); |
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
569 |
} |
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
570 |
#endif /* ENABLE_NETWORK */ |
717cc12ac0a9
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight
parents:
6141
diff
changeset
|
571 |
|
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5197
diff
changeset
|
572 |
ScanNewGRFFiles(); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5197
diff
changeset
|
573 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
574 |
_opt_ptr = &_opt_newgame; |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5197
diff
changeset
|
575 |
ResetGRFConfig(false); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
576 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
577 |
/* XXX - ugly hack, if diff_level is 9, it means we got no setting from the config file */ |
2951 | 578 |
if (_opt_newgame.diff_level == 9) SetDifficultyLevel(0, &_opt_newgame); |
0 | 579 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
580 |
/* Make sure _patches is filled with _patches_newgame if we switch to a game directly */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
581 |
if (_switch_mode != SM_NONE) { |
5024
f13f2f2d43f9
(svn r7065) Use simple assignment instead of memcpy()
tron
parents:
5015
diff
changeset
|
582 |
_opt = _opt_newgame; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
583 |
UpdatePatches(); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
584 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
585 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
586 |
/* initialize the ingame console */ |
139 | 587 |
IConsoleInit(); |
3312
593789444b01
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3274
diff
changeset
|
588 |
_cursor.in_window = true; |
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1243
diff
changeset
|
589 |
InitializeGUI(); |
644
e833509107ad
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
630
diff
changeset
|
590 |
IConsoleCmdExec("exec scripts/autoexec.scr 0"); |
656
01540e6c0fed
(svn r1090) -Fix: Made the _openttd_revision variable global, and with that
truelight
parents:
644
diff
changeset
|
591 |
|
2828
996de8e891c7
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2818
diff
changeset
|
592 |
GenerateWorld(GW_EMPTY, 64, 64); // Make the viewport initialization happy |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
593 |
WaitTillGeneratedWorld(); |
1268
306ebfea663a
(svn r1772) -Fix: [ 1114100 ] Dedicated server boots again
truelight
parents:
1267
diff
changeset
|
594 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
595 |
#ifdef ENABLE_NETWORK |
2951 | 596 |
if (network && _network_available) { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
597 |
if (network_conn != NULL) { |
1329 | 598 |
const char *port = NULL; |
599 |
const char *player = NULL; |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
600 |
uint16 rport; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
601 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
602 |
rport = NETWORK_DEFAULT_PORT; |
4878
744717de172e
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
Darkvater
parents:
4861
diff
changeset
|
603 |
_network_playas = PLAYER_NEW_COMPANY; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
604 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
605 |
ParseConnectionString(&player, &port, network_conn); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
606 |
|
4861
f28bfa84f9ad
(svn r6787) -Codechange: Use PLAYER_NEW_COMPANY as a player identifier wishing to become a
Darkvater
parents:
4854
diff
changeset
|
607 |
if (player != NULL) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
608 |
_network_playas = (PlayerID)atoi(player); |
4878
744717de172e
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
Darkvater
parents:
4861
diff
changeset
|
609 |
|
4880
0708f34e3586
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
610 |
if (_network_playas != PLAYER_SPECTATOR) { |
0708f34e3586
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
611 |
_network_playas--; |
4878
744717de172e
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
Darkvater
parents:
4861
diff
changeset
|
612 |
if (!IsValidPlayer(_network_playas)) return false; |
744717de172e
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
Darkvater
parents:
4861
diff
changeset
|
613 |
} |
4861
f28bfa84f9ad
(svn r6787) -Codechange: Use PLAYER_NEW_COMPANY as a player identifier wishing to become a
Darkvater
parents:
4854
diff
changeset
|
614 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
615 |
if (port != NULL) rport = atoi(port); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
616 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
617 |
LoadIntroGame(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
618 |
_switch_mode = SM_NONE; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
619 |
NetworkClientConnectGame(network_conn, rport); |
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1105
diff
changeset
|
620 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
621 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
622 |
#endif /* ENABLE_NETWORK */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
623 |
|
7666
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
624 |
_video_driver->MainLoop(); |
139 | 625 |
|
2285
3193cbd1ba88
(svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
2234
diff
changeset
|
626 |
WaitTillSaved(); |
139 | 627 |
IConsoleFree(); |
0 | 628 |
|
4830
0ff2a14e90be
(svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents:
4829
diff
changeset
|
629 |
if (_network_available) NetworkShutDown(); // Shut down the network and close any open connections |
0 | 630 |
|
7666
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
631 |
_video_driver->Stop(); |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
632 |
_music_driver->Stop(); |
a5fccd76176a
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents:
7648
diff
changeset
|
633 |
_sound_driver->Stop(); |
0 | 634 |
|
5758
c508f77aedd7
(svn r7801) -Feature: add command line option to prevent saving of highscore and configuration on exit and a console command to manually initiate a configuration save (Aloysha).
rubidium
parents:
5726
diff
changeset
|
635 |
/* only save config if we have to */ |
c508f77aedd7
(svn r7801) -Feature: add command line option to prevent saving of highscore and configuration on exit and a console command to manually initiate a configuration save (Aloysha).
rubidium
parents:
5726
diff
changeset
|
636 |
if (save_config) { |
c508f77aedd7
(svn r7801) -Feature: add command line option to prevent saving of highscore and configuration on exit and a console command to manually initiate a configuration save (Aloysha).
rubidium
parents:
5726
diff
changeset
|
637 |
SaveToConfig(); |
c508f77aedd7
(svn r7801) -Feature: add command line option to prevent saving of highscore and configuration on exit and a console command to manually initiate a configuration save (Aloysha).
rubidium
parents:
5726
diff
changeset
|
638 |
SaveToHighScore(); |
c508f77aedd7
(svn r7801) -Feature: add command line option to prevent saving of highscore and configuration on exit and a console command to manually initiate a configuration save (Aloysha).
rubidium
parents:
5726
diff
changeset
|
639 |
} |
0 | 640 |
|
5910
61e264641a8d
(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
parents:
5903
diff
changeset
|
641 |
/* Reset windowing system and free config file */ |
61e264641a8d
(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
parents:
5903
diff
changeset
|
642 |
UnInitializeGame(); |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
643 |
|
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
644 |
/* stop the AI */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
645 |
AI_Uninitialize(); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
646 |
|
1036
5f0c307fbadd
(svn r1537) -Fix: Close all and any open filehandles open at shutdown (tamlin)
darkvater
parents:
1035
diff
changeset
|
647 |
/* Close all and any open filehandles */ |
5f0c307fbadd
(svn r1537) -Fix: Close all and any open filehandles open at shutdown (tamlin)
darkvater
parents:
1035
diff
changeset
|
648 |
FioCloseAll(); |
5f0c307fbadd
(svn r1537) -Fix: Close all and any open filehandles open at shutdown (tamlin)
darkvater
parents:
1035
diff
changeset
|
649 |
|
0 | 650 |
return 0; |
651 |
} |
|
652 |
||
6573 | 653 |
void HandleExitGameRequest() |
4548
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
654 |
{ |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
655 |
if (_game_mode == GM_MENU) { // do not ask to quit on the main screen |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
656 |
_exit_game = true; |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
657 |
} else if (_patches.autosave_on_exit) { |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
658 |
DoExitSave(); |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
659 |
_exit_game = true; |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
660 |
} else { |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
661 |
AskExitGame(); |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
662 |
} |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
663 |
} |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
664 |
|
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
665 |
|
2380
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
666 |
/** Mutex so that only one thread can communicate with the main program |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
667 |
* at any given time */ |
4323
78204e7c3100
(svn r5977) -Fix [FS#78]: never set I-am-a-thread bool to true IN the thread. Machines with
truelight
parents:
4300
diff
changeset
|
668 |
static ThreadMsg _message = MSG_OTTD_NO_MESSAGE; |
2380
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
669 |
|
6573 | 670 |
static inline void OTTD_ReleaseMutex() {_message = MSG_OTTD_NO_MESSAGE;} |
671 |
static inline ThreadMsg OTTD_PollThreadEvent() {return _message;} |
|
2380
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
672 |
|
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
673 |
/** Called by running thread to execute some action in the main game. |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
674 |
* It will stall as long as the mutex is not freed (handled) by the game */ |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
675 |
void OTTD_SendThreadMessage(ThreadMsg msg) |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
676 |
{ |
2383
80ff60d10aed
(svn r2909) Game would hang where the autosave_on_exit was activated.
Darkvater
parents:
2380
diff
changeset
|
677 |
if (_exit_game) return; |
4323
78204e7c3100
(svn r5977) -Fix [FS#78]: never set I-am-a-thread bool to true IN the thread. Machines with
truelight
parents:
4300
diff
changeset
|
678 |
while (_message != MSG_OTTD_NO_MESSAGE) CSleep(10); |
2380
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
679 |
|
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
680 |
_message = msg; |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
681 |
} |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
682 |
|
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
683 |
|
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
684 |
/** Handle the user-messages sent to us |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
685 |
* @param message message sent |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
686 |
*/ |
2817 | 687 |
static void ProcessSentMessage(ThreadMsg message) |
2380
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
688 |
{ |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
689 |
switch (message) { |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
690 |
case MSG_OTTD_SAVETHREAD_DONE: SaveFileDone(); break; |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
691 |
case MSG_OTTD_SAVETHREAD_ERROR: SaveFileError(); break; |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
692 |
default: NOT_REACHED(); |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
693 |
} |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
694 |
|
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
695 |
OTTD_ReleaseMutex(); // release mutex so that other threads, messages can be handled |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
696 |
} |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
697 |
|
0 | 698 |
static void ShowScreenshotResult(bool b) |
699 |
{ |
|
700 |
if (b) { |
|
2055
9361b56db8ba
(svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents:
2051
diff
changeset
|
701 |
SetDParamStr(0, _screenshot_name); |
0 | 702 |
ShowErrorMessage(INVALID_STRING_ID, STR_031B_SCREENSHOT_SUCCESSFULLY, 0, 0); |
703 |
} else { |
|
704 |
ShowErrorMessage(INVALID_STRING_ID, STR_031C_SCREENSHOT_FAILED, 0, 0); |
|
705 |
} |
|
706 |
||
707 |
} |
|
708 |
||
6573 | 709 |
static void MakeNewGameDone() |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
710 |
{ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
711 |
/* In a dedicated server, the server does not play */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
712 |
if (_network_dedicated) { |
5564
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
713 |
SetLocalPlayer(PLAYER_SPECTATOR); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
714 |
return; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
715 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
716 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
717 |
/* Create a single player */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
718 |
DoStartupNewPlayer(false); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
719 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
720 |
SetLocalPlayer(PLAYER_FIRST); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
721 |
_current_player = _local_player; |
4661
59492734db06
(svn r6544) - Codechange: Rename CmdReplaceVehicle to CmdSetAutoReplace, to reflect what it does.
peter1138
parents:
4603
diff
changeset
|
722 |
DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
723 |
|
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5108
diff
changeset
|
724 |
SettingsDisableElrail(_patches.disable_elrails); |
7560
f7b5ab184882
(svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium
parents:
7554
diff
changeset
|
725 |
SetDefaultRailGui(); |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5108
diff
changeset
|
726 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
727 |
MarkWholeScreenDirty(); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
728 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
729 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
730 |
static void MakeNewGame(bool from_heightmap) |
0 | 731 |
{ |
732 |
_game_mode = GM_NORMAL; |
|
733 |
||
5313
ea491c0b40f1
(svn r7469) -Fix (r7348): NewGRF settings weren't loaded in cases.
peter1138
parents:
5296
diff
changeset
|
734 |
ResetGRFConfig(true); |
7125
4ce0c7a12a3f
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas
parents:
7122
diff
changeset
|
735 |
_house_mngr.ResetMapping(); |
7648
dde14ba48325
(svn r10426) -Codechange: Activate the reset of industry/tiles mapping upon initialization or new game.
belugas
parents:
7587
diff
changeset
|
736 |
_industile_mngr.ResetMapping(); |
dde14ba48325
(svn r10426) -Codechange: Activate the reset of industry/tiles mapping upon initialization or new game.
belugas
parents:
7587
diff
changeset
|
737 |
_industry_mngr.ResetMapping(); |
5313
ea491c0b40f1
(svn r7469) -Fix (r7348): NewGRF settings weren't loaded in cases.
peter1138
parents:
5296
diff
changeset
|
738 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
739 |
GenerateWorldSetCallback(&MakeNewGameDone); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
740 |
GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _patches.map_x, 1 << _patches.map_y); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
741 |
} |
0 | 742 |
|
6573 | 743 |
static void MakeNewEditorWorldDone() |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
744 |
{ |
5564
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
745 |
SetLocalPlayer(OWNER_NONE); |
0 | 746 |
|
747 |
MarkWholeScreenDirty(); |
|
748 |
} |
|
749 |
||
6573 | 750 |
static void MakeNewEditorWorld() |
0 | 751 |
{ |
752 |
_game_mode = GM_EDITOR; |
|
753 |
||
5313
ea491c0b40f1
(svn r7469) -Fix (r7348): NewGRF settings weren't loaded in cases.
peter1138
parents:
5296
diff
changeset
|
754 |
ResetGRFConfig(true); |
ea491c0b40f1
(svn r7469) -Fix (r7348): NewGRF settings weren't loaded in cases.
peter1138
parents:
5296
diff
changeset
|
755 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
756 |
GenerateWorldSetCallback(&MakeNewEditorWorldDone); |
2828
996de8e891c7
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2818
diff
changeset
|
757 |
GenerateWorld(GW_EMPTY, 1 << _patches.map_x, 1 << _patches.map_y); |
0 | 758 |
} |
759 |
||
6573 | 760 |
void StartupPlayers(); |
761 |
void StartupDisasters(); |
|
762 |
extern void StartupEconomy(); |
|
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
115
diff
changeset
|
763 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
764 |
/** |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
765 |
* Start Scenario starts a new game based on a scenario. |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
766 |
* Eg 'New Game' --> select a preset scenario |
1501
0faec0f792b0
(svn r2005) - Fix: fix previous commit. Using 'New Game (scenario)' will use YOUR difficulty settings but ingame options (eg townnames, currency). Also settings are correctly saved when closing the difficulty window now.
Darkvater
parents:
1500
diff
changeset
|
767 |
* This starts a scenario based on your current difficulty settings |
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
768 |
*/ |
6573 | 769 |
static void StartScenario() |
0 | 770 |
{ |
771 |
_game_mode = GM_NORMAL; |
|
772 |
||
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
773 |
/* invalid type */ |
0 | 774 |
if (_file_to_saveload.mode == SL_INVALID) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5564
diff
changeset
|
775 |
DEBUG(sl, 0, "Savegame is obsolete or invalid format: '%s'", _file_to_saveload.name); |
7532
66c79dd999af
(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
parents:
7514
diff
changeset
|
776 |
SetDParamStr(0, GetSaveLoadErrorString()); |
66c79dd999af
(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
parents:
7514
diff
changeset
|
777 |
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0); |
0 | 778 |
_game_mode = GM_MENU; |
779 |
return; |
|
780 |
} |
|
781 |
||
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
782 |
/* Reinitialize windows */ |
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
783 |
ResetWindowSystem(); |
0 | 784 |
|
785 |
SetupColorsAndInitialWindow(); |
|
786 |
||
5313
ea491c0b40f1
(svn r7469) -Fix (r7348): NewGRF settings weren't loaded in cases.
peter1138
parents:
5296
diff
changeset
|
787 |
ResetGRFConfig(true); |
ea491c0b40f1
(svn r7469) -Fix (r7348): NewGRF settings weren't loaded in cases.
peter1138
parents:
5296
diff
changeset
|
788 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
789 |
/* Load game */ |
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
790 |
if (SaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, SCENARIO_DIR) != SL_OK) { |
0 | 791 |
LoadIntroGame(); |
7532
66c79dd999af
(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
parents:
7514
diff
changeset
|
792 |
SetDParamStr(0, GetSaveLoadErrorString()); |
66c79dd999af
(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
parents:
7514
diff
changeset
|
793 |
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0); |
0 | 794 |
} |
795 |
||
1501
0faec0f792b0
(svn r2005) - Fix: fix previous commit. Using 'New Game (scenario)' will use YOUR difficulty settings but ingame options (eg townnames, currency). Also settings are correctly saved when closing the difficulty window now.
Darkvater
parents:
1500
diff
changeset
|
796 |
_opt_ptr = &_opt; |
5024
f13f2f2d43f9
(svn r7065) Use simple assignment instead of memcpy()
tron
parents:
5015
diff
changeset
|
797 |
_opt_ptr->diff = _opt_newgame.diff; |
1501
0faec0f792b0
(svn r2005) - Fix: fix previous commit. Using 'New Game (scenario)' will use YOUR difficulty settings but ingame options (eg townnames, currency). Also settings are correctly saved when closing the difficulty window now.
Darkvater
parents:
1500
diff
changeset
|
798 |
_opt.diff_level = _opt_newgame.diff_level; |
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
799 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
800 |
/* Inititalize data */ |
3891
b39019cd32cf
(svn r4947) - Fix [FS#145]: Starting scenarios did not adhere to local difficulty settings
Darkvater
parents:
3889
diff
changeset
|
801 |
StartupEconomy(); |
115
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
802 |
StartupPlayers(); |
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
803 |
StartupEngines(); |
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
804 |
StartupDisasters(); |
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
805 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
806 |
SetLocalPlayer(PLAYER_FIRST); |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
807 |
_current_player = _local_player; |
4661
59492734db06
(svn r6544) - Codechange: Rename CmdReplaceVehicle to CmdSetAutoReplace, to reflect what it does.
peter1138
parents:
4603
diff
changeset
|
808 |
DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE); |
0 | 809 |
|
810 |
MarkWholeScreenDirty(); |
|
811 |
} |
|
812 |
||
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
813 |
/** Load the specified savegame but on error do different things. |
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
814 |
* If loading fails due to corrupt savegame, bad version, etc. go back to |
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
815 |
* a previous correct state. In the menu for example load the intro game again. |
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
816 |
* @param filename file to be loaded |
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
817 |
* @param mode mode of loading, either SL_LOAD or SL_OLD_LOAD |
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
818 |
* @param newgm switch to this mode of loading fails due to some unknown error |
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
819 |
* @param subdir default directory to look for filename, set to 0 if not needed */ |
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
820 |
bool SafeSaveOrLoad(const char *filename, int mode, int newgm, Subdirectory subdir) |
0 | 821 |
{ |
822 |
byte ogm = _game_mode; |
|
823 |
||
824 |
_game_mode = newgm; |
|
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
825 |
assert(mode == SL_LOAD || mode == SL_OLD_LOAD); |
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
826 |
switch (SaveOrLoad(filename, mode, subdir)) { |
3024 | 827 |
case SL_OK: return true; |
828 |
||
829 |
case SL_REINIT: |
|
830 |
switch (ogm) { |
|
831 |
case GM_MENU: LoadIntroGame(); break; |
|
832 |
case GM_EDITOR: MakeNewEditorWorld(); break; |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
833 |
default: MakeNewGame(false); break; |
3024 | 834 |
} |
835 |
return false; |
|
836 |
||
837 |
default: |
|
838 |
_game_mode = ogm; |
|
839 |
return false; |
|
2639 | 840 |
} |
0 | 841 |
} |
842 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
843 |
void SwitchMode(int new_mode) |
0 | 844 |
{ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
845 |
#ifdef ENABLE_NETWORK |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
846 |
/* If we are saving something, the network stays in his current state */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
847 |
if (new_mode != SM_SAVE) { |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
848 |
/* If the network is active, make it not-active */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
849 |
if (_networking) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
850 |
if (_network_server && (new_mode == SM_LOAD || new_mode == SM_NEWGAME)) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
851 |
NetworkReboot(); |
5870
86e55167c9e3
(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
parents:
5860
diff
changeset
|
852 |
NetworkUDPCloseAll(); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
853 |
} else { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
854 |
NetworkDisconnect(); |
5870
86e55167c9e3
(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
parents:
5860
diff
changeset
|
855 |
NetworkUDPCloseAll(); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
856 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
857 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
858 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
859 |
/* If we are a server, we restart the server */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
860 |
if (_is_network_server) { |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
861 |
/* But not if we are going to the menu */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
862 |
if (new_mode != SM_MENU) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
863 |
NetworkServerStart(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
864 |
} else { |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
865 |
/* This client no longer wants to be a network-server */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
866 |
_is_network_server = false; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
867 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
868 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
869 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
870 |
#endif /* ENABLE_NETWORK */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
871 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
872 |
switch (new_mode) { |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
873 |
case SM_EDITOR: /* Switch to scenario editor */ |
0 | 874 |
MakeNewEditorWorld(); |
875 |
break; |
|
876 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
877 |
case SM_NEWGAME: /* New Game --> 'Random game' */ |
630
fd3c36132342
(svn r1061) -Fix: [Network] Compiling without ENABLE_NETWORK now works again correctly
truelight
parents:
614
diff
changeset
|
878 |
#ifdef ENABLE_NETWORK |
2951 | 879 |
if (_network_server) { |
2989 | 880 |
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "Random Map"); |
2951 | 881 |
} |
630
fd3c36132342
(svn r1061) -Fix: [Network] Compiling without ENABLE_NETWORK now works again correctly
truelight
parents:
614
diff
changeset
|
882 |
#endif /* ENABLE_NETWORK */ |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
883 |
MakeNewGame(false); |
0 | 884 |
break; |
885 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
886 |
case SM_START_SCENARIO: /* New Game --> Choose one of the preset scenarios */ |
2951 | 887 |
#ifdef ENABLE_NETWORK |
888 |
if (_network_server) { |
|
2989 | 889 |
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Loaded scenario)", _file_to_saveload.title); |
2951 | 890 |
} |
891 |
#endif /* ENABLE_NETWORK */ |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
892 |
StartScenario(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
893 |
break; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
894 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
895 |
case SM_LOAD: { /* Load game, Play Scenario */ |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
896 |
_opt_ptr = &_opt; |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5197
diff
changeset
|
897 |
ResetGRFConfig(true); |
0 | 898 |
|
7431
f340111a55ec
(svn r10188) -Codechange: make it a little easier to load a savegame from the console:
rubidium
parents:
7425
diff
changeset
|
899 |
if (!SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_NORMAL, NO_DIRECTORY)) { |
942
31f28eedd2b8
(svn r1430) -Fix: starting openttd with -g <invalid_name> now acts normal
truelight
parents:
929
diff
changeset
|
900 |
LoadIntroGame(); |
7532
66c79dd999af
(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
parents:
7514
diff
changeset
|
901 |
SetDParamStr(0, GetSaveLoadErrorString()); |
66c79dd999af
(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
parents:
7514
diff
changeset
|
902 |
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0); |
0 | 903 |
} else { |
5197
a441951424e7
(svn r7312) -Fix: When loading a game from a dedicated server the local player global variable was
Darkvater
parents:
5170
diff
changeset
|
904 |
/* Update the local player for a loaded game. It is either always |
a441951424e7
(svn r7312) -Fix: When loading a game from a dedicated server the local player global variable was
Darkvater
parents:
5170
diff
changeset
|
905 |
* player #1 (eg 0) or in the case of a dedicated server a spectator */ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
906 |
SetLocalPlayer(_network_dedicated ? PLAYER_SPECTATOR : PLAYER_FIRST); |
0 | 907 |
DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // decrease pause counter (was increased from opening load dialog) |
630
fd3c36132342
(svn r1061) -Fix: [Network] Compiling without ENABLE_NETWORK now works again correctly
truelight
parents:
614
diff
changeset
|
908 |
#ifdef ENABLE_NETWORK |
2951 | 909 |
if (_network_server) { |
2989 | 910 |
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Loaded game)", _file_to_saveload.title); |
2951 | 911 |
} |
630
fd3c36132342
(svn r1061) -Fix: [Network] Compiling without ENABLE_NETWORK now works again correctly
truelight
parents:
614
diff
changeset
|
912 |
#endif /* ENABLE_NETWORK */ |
0 | 913 |
} |
914 |
break; |
|
915 |
} |
|
916 |
||
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
917 |
case SM_START_HEIGHTMAP: /* Load a heightmap and start a new game from it */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
918 |
#ifdef ENABLE_NETWORK |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
919 |
if (_network_server) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
920 |
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Heightmap)", _file_to_saveload.title); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
921 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
922 |
#endif /* ENABLE_NETWORK */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
923 |
MakeNewGame(true); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
924 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
925 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
926 |
case SM_LOAD_HEIGHTMAP: /* Load heightmap from scenario editor */ |
5564
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
927 |
SetLocalPlayer(OWNER_NONE); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
928 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
929 |
GenerateWorld(GW_HEIGHTMAP, 1 << _patches.map_x, 1 << _patches.map_y); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
930 |
MarkWholeScreenDirty(); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
931 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
932 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
933 |
case SM_LOAD_SCENARIO: { /* Load scenario from scenario editor */ |
7431
f340111a55ec
(svn r10188) -Codechange: make it a little easier to load a savegame from the console:
rubidium
parents:
7425
diff
changeset
|
934 |
if (SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_EDITOR, NO_DIRECTORY)) { |
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
935 |
_opt_ptr = &_opt; |
0 | 936 |
|
5564
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
937 |
SetLocalPlayer(OWNER_NONE); |
4537
fefcd6142977
(svn r6366) -Fix (FS#324): when opening a scenario, the date was set 1920 years into the future.
rubidium
parents:
4536
diff
changeset
|
938 |
_patches_newgame.starting_year = _cur_year; |
2639 | 939 |
} else { |
7532
66c79dd999af
(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
parents:
7514
diff
changeset
|
940 |
SetDParamStr(0, GetSaveLoadErrorString()); |
66c79dd999af
(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
parents:
7514
diff
changeset
|
941 |
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0); |
2639 | 942 |
} |
0 | 943 |
break; |
944 |
} |
|
945 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
946 |
case SM_MENU: /* Switch to game intro menu */ |
0 | 947 |
LoadIntroGame(); |
948 |
break; |
|
949 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
950 |
case SM_SAVE: /* Save game */ |
7431
f340111a55ec
(svn r10188) -Codechange: make it a little easier to load a savegame from the console:
rubidium
parents:
7425
diff
changeset
|
951 |
if (SaveOrLoad(_file_to_saveload.name, SL_SAVE, NO_DIRECTORY) != SL_OK) { |
7532
66c79dd999af
(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
parents:
7514
diff
changeset
|
952 |
SetDParamStr(0, GetSaveLoadErrorString()); |
66c79dd999af
(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
parents:
7514
diff
changeset
|
953 |
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0); |
2639 | 954 |
} else { |
0 | 955 |
DeleteWindowById(WC_SAVELOAD, 0); |
2639 | 956 |
} |
0 | 957 |
break; |
958 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
959 |
case SM_GENRANDLAND: /* Generate random land within scenario editor */ |
5564
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
960 |
SetLocalPlayer(OWNER_NONE); |
2951 | 961 |
GenerateWorld(GW_RANDOM, 1 << _patches.map_x, 1 << _patches.map_y); |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
962 |
/* XXX: set date */ |
0 | 963 |
MarkWholeScreenDirty(); |
964 |
break; |
|
965 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
966 |
|
2951 | 967 |
if (_switch_mode_errorstr != INVALID_STRING_ID) { |
968 |
ShowErrorMessage(INVALID_STRING_ID, _switch_mode_errorstr, 0, 0); |
|
969 |
} |
|
0 | 970 |
} |
971 |
||
972 |
||
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
973 |
/* State controlling game loop. |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
974 |
* The state must not be changed from anywhere |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
975 |
* but here. |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
976 |
* That check is enforced in DoCommand. */ |
6573 | 977 |
void StateGameLoop() |
0 | 978 |
{ |
8105
8f7fcf4d2b7e
(svn r11138) -Codechange: prepare some subsystems for persistent storage for NewGRFs.
rubidium
parents:
8063
diff
changeset
|
979 |
ClearStorageChanges(false); |
8f7fcf4d2b7e
(svn r11138) -Codechange: prepare some subsystems for persistent storage for NewGRFs.
rubidium
parents:
8063
diff
changeset
|
980 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
981 |
/* dont execute the state loop during pause */ |
6557
8381016f71f3
(svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents:
6555
diff
changeset
|
982 |
if (_pause_game) return; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
983 |
if (IsGeneratingWorld()) return; |
213
770e504a6e51
(svn r214) -Feature: CMD_NET_INSTANT [just in time command handling over network] (sign_de)
darkvater
parents:
208
diff
changeset
|
984 |
|
0 | 985 |
if (_game_mode == GM_EDITOR) { |
986 |
RunTileLoop(); |
|
987 |
CallVehicleTicks(); |
|
988 |
CallLandscapeTick(); |
|
989 |
CallWindowTickEvent(); |
|
990 |
NewsLoop(); |
|
991 |
} else { |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
992 |
/* All these actions has to be done from OWNER_NONE |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
993 |
* for multiplayer compatibility */ |
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2469
diff
changeset
|
994 |
PlayerID p = _current_player; |
206 | 995 |
_current_player = OWNER_NONE; |
996 |
||
0 | 997 |
AnimateAnimatedTiles(); |
998 |
IncreaseDate(); |
|
999 |
RunTileLoop(); |
|
1000 |
CallVehicleTicks(); |
|
1001 |
CallLandscapeTick(); |
|
1002 |
||
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
1003 |
AI_RunGameLoop(); |
0 | 1004 |
|
1005 |
CallWindowTickEvent(); |
|
1006 |
NewsLoop(); |
|
206 | 1007 |
_current_player = p; |
0 | 1008 |
} |
1009 |
} |
|
1010 |
||
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
1011 |
/** Create an autosave. The default name is "autosave#.sav". However with |
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
1012 |
* the patch setting 'keep_all_autosave' the name defaults to company-name + date */ |
6573 | 1013 |
static void DoAutosave() |
0 | 1014 |
{ |
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
1015 |
char buf[MAX_PATH]; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1016 |
|
6228
2de23d5a2b11
(svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight
parents:
6210
diff
changeset
|
1017 |
#if defined(PSP) |
2de23d5a2b11
(svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight
parents:
6210
diff
changeset
|
1018 |
/* Autosaving in networking is too time expensive for the PSP */ |
2de23d5a2b11
(svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight
parents:
6210
diff
changeset
|
1019 |
if (_networking) |
2de23d5a2b11
(svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight
parents:
6210
diff
changeset
|
1020 |
return; |
2de23d5a2b11
(svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight
parents:
6210
diff
changeset
|
1021 |
#endif /* PSP */ |
2de23d5a2b11
(svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight
parents:
6210
diff
changeset
|
1022 |
|
4848
56549aa3e234
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4840
diff
changeset
|
1023 |
if (_patches.keep_all_autosave && _local_player != PLAYER_SPECTATOR) { |
7554
076c42f44a83
(svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents:
7532
diff
changeset
|
1024 |
SetDParam(0, _local_player); |
076c42f44a83
(svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents:
7532
diff
changeset
|
1025 |
SetDParam(1, _date); |
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
1026 |
GetString(buf, STR_4004, lastof(buf)); |
7910
3d75028bb4d0
(svn r10807) -Fix [FS#1108]: keep_all_autosaves always got ".sav" as filename, which basically means that it only kept the last autosave.
rubidium
parents:
7904
diff
changeset
|
1027 |
ttd_strlcat(buf, ".sav", lengthof(buf)); |
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
1028 |
} else { |
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
1029 |
/* generate a savegame name and number according to _patches.max_num_autosaves */ |
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
1030 |
snprintf(buf, sizeof(buf), "autosave%d.sav", _autosave_ctr); |
2672
ea469d7b34ff
(svn r3214) -Feature: openttd.cfg can now set how many autosaves to keep before starting to overwrite old ones
bjarni
parents:
2670
diff
changeset
|
1031 |
|
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
1032 |
if (++_autosave_ctr >= _patches.max_num_autosaves) _autosave_ctr = 0; |
0 | 1033 |
} |
1034 |
||
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5564
diff
changeset
|
1035 |
DEBUG(sl, 2, "Autosaving to '%s'", buf); |
7425
350b9265b7a2
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
7424
diff
changeset
|
1036 |
if (SaveOrLoad(buf, SL_SAVE, AUTOSAVE_DIR) != SL_OK) |
0 | 1037 |
ShowErrorMessage(INVALID_STRING_ID, STR_AUTOSAVE_FAILED, 0, 0); |
1038 |
} |
|
1039 |
||
1397
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1040 |
static void ScrollMainViewport(int x, int y) |
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1041 |
{ |
4536
f13408cba18f
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4502
diff
changeset
|
1042 |
if (_game_mode != GM_MENU) { |
1397
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1043 |
Window *w = FindWindowById(WC_MAIN_WINDOW, 0); |
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1044 |
assert(w); |
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1045 |
|
7226
a8650d6ecb53
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
7222
diff
changeset
|
1046 |
WP(w,vp_d).dest_scrollpos_x += ScaleByZoom(x, w->viewport->zoom); |
a8650d6ecb53
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
7222
diff
changeset
|
1047 |
WP(w,vp_d).dest_scrollpos_y += ScaleByZoom(y, w->viewport->zoom); |
1397
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1048 |
} |
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1049 |
} |
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1050 |
|
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1051 |
static const int8 scrollamt[16][2] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4336
diff
changeset
|
1052 |
{ 0, 0}, |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1053 |
{-2, 0}, ///< 1 : left |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1054 |
{ 0, -2}, ///< 2 : up |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1055 |
{-2, -1}, ///< 3 : left + up |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1056 |
{ 2, 0}, ///< 4 : right |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1057 |
{ 0, 0}, ///< 5 : left + right |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1058 |
{ 2, -1}, ///< 6 : right + up |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1059 |
{ 0, -2}, ///< 7 : left + right + up = up |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1060 |
{ 0 ,2}, ///< 8 : down |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1061 |
{-2 ,1}, ///< 9 : down+left |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1062 |
{ 0, 0}, ///< 10 : impossible |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1063 |
{-2, 0}, ///< 11 : left + up + down = left |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1064 |
{ 2, 1}, ///< 12 : down+right |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1065 |
{ 0, 2}, ///< 13 : left + right + down = down |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1066 |
{ 0, -2}, ///< 14 : left + right + up = up |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1067 |
{ 0, 0}, ///< 15 : impossible |
1397
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1068 |
}; |
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1069 |
|
6573 | 1070 |
static void HandleKeyScrolling() |
1397
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1071 |
{ |
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1072 |
if (_dirkeys && !_no_scroll) { |
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1073 |
int factor = _shift_pressed ? 50 : 10; |
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1074 |
ScrollMainViewport(scrollamt[_dirkeys][0] * factor, scrollamt[_dirkeys][1] * factor); |
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1075 |
} |
b04402b901cd
(svn r1901) - Fix: unwanted behaviour of the savegame dialog, as well as a bug with a sloppy termination of a string. When any editbox is open, scrolling is disabled. If any new types of editboxes come up, please use SET/CLRBIT of _no_scroll with its unique identifier (ttd.h)
Darkvater
parents:
1385
diff
changeset
|
1076 |
} |
1199
15d0c3424a45
(svn r1703) - Fix: Scrolling with the arrow keys is now smooth and it now also scrolls exactly in tile direction if e.g. up and left are pressed
dominik
parents:
1181
diff
changeset
|
1077 |
|
6573 | 1078 |
void GameLoop() |
0 | 1079 |
{ |
2380
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
1080 |
ThreadMsg message; |
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
1081 |
|
3b26659b4a9a
(svn r2906) Fix some threaded saving problems. Now the thread only interfaces with the main program through a sort of mutex. Communication uses the function OTTD_SendThreadMessage() with the approiate message which is handled in ProcessSentMessage() during the main loop.
Darkvater
parents:
2360
diff
changeset
|
1082 |
if ((message = OTTD_PollThreadEvent()) != 0) ProcessSentMessage(message); |
0 | 1083 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1084 |
/* autosave game? */ |
0 | 1085 |
if (_do_autosave) { |
1086 |
_do_autosave = false; |
|
1087 |
DoAutosave(); |
|
1088 |
RedrawAutosave(); |
|
1089 |
} |
|
1090 |
||
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1091 |
/* handle scrolling of the main window */ |
4502 | 1092 |
HandleKeyScrolling(); |
1199
15d0c3424a45
(svn r1703) - Fix: Scrolling with the arrow keys is now smooth and it now also scrolls exactly in tile direction if e.g. up and left are pressed
dominik
parents:
1181
diff
changeset
|
1093 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1094 |
/* make a screenshot? */ |
4184
f38abcb8b18d
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
1095 |
if (IsScreenshotRequested()) ShowScreenshotResult(MakeScreenshot()); |
0 | 1096 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1097 |
/* switch game mode? */ |
3024 | 1098 |
if (_switch_mode != SM_NONE) { |
1099 |
SwitchMode(_switch_mode); |
|
0 | 1100 |
_switch_mode = SM_NONE; |
1101 |
} |
|
1102 |
||
1103 |
IncreaseSpriteLRU(); |
|
1104 |
InteractiveRandom(); |
|
1105 |
||
2639 | 1106 |
if (_scroller_click_timeout > 3) { |
0 | 1107 |
_scroller_click_timeout -= 3; |
2639 | 1108 |
} else { |
0 | 1109 |
_scroller_click_timeout = 0; |
2639 | 1110 |
} |
0 | 1111 |
|
1112 |
_caret_timer += 3; |
|
7514
98a024616010
(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
parents:
7508
diff
changeset
|
1113 |
_palette_animation_counter += 8; |
0 | 1114 |
CursorTick(); |
1115 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1116 |
#ifdef ENABLE_NETWORK |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1117 |
/* Check for UDP stuff */ |
4830
0ff2a14e90be
(svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents:
4829
diff
changeset
|
1118 |
if (_network_available) NetworkUDPGameLoop(); |
0 | 1119 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
1120 |
if (_networking && !IsGeneratingWorld()) { |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1121 |
/* Multiplayer */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1122 |
NetworkGameLoop(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1123 |
} else { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1124 |
if (_network_reconnect > 0 && --_network_reconnect == 0) { |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1125 |
/* This means that we want to reconnect to the last host |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1126 |
* We do this here, because it means that the network is really closed */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1127 |
NetworkClientConnectGame(_network_last_host, _network_last_port); |
206 | 1128 |
} |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1129 |
/* Singleplayer */ |
213
770e504a6e51
(svn r214) -Feature: CMD_NET_INSTANT [just in time command handling over network] (sign_de)
darkvater
parents:
208
diff
changeset
|
1130 |
StateGameLoop(); |
0 | 1131 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1132 |
#else |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1133 |
StateGameLoop(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1134 |
#endif /* ENABLE_NETWORK */ |
0 | 1135 |
|
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8418
diff
changeset
|
1136 |
if (!_pause_game && HasBit(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations(); |
0 | 1137 |
|
6557
8381016f71f3
(svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents:
6555
diff
changeset
|
1138 |
if (!_pause_game || _cheats.build_in_pause.value) MoveAllTextEffects(); |
0 | 1139 |
|
1570
c470380facb9
(svn r2074) MouseLoop -> InputLoop(), factor out a real mouse-specific MouseLoop from the new InitLoop() (more in the spirit of HandleKeypress()).
pasky
parents:
1542
diff
changeset
|
1140 |
InputLoop(); |
0 | 1141 |
|
1608
074dff2e4890
(svn r2112) -Fix: ExtMidi no longer halts the game while starting a song
tron
parents:
1570
diff
changeset
|
1142 |
MusicLoop(); |
0 | 1143 |
} |
1144 |
||
6573 | 1145 |
void BeforeSaveGame() |
0 | 1146 |
{ |
4171 | 1147 |
const Window *w = FindWindowById(WC_MAIN_WINDOW, 0); |
0 | 1148 |
|
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
961
diff
changeset
|
1149 |
if (w != NULL) { |
2643 | 1150 |
_saved_scrollpos_x = WP(w, const vp_d).scrollpos_x; |
1151 |
_saved_scrollpos_y = WP(w, const vp_d).scrollpos_y; |
|
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
961
diff
changeset
|
1152 |
_saved_scrollpos_zoom = w->viewport->zoom; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
961
diff
changeset
|
1153 |
} |
0 | 1154 |
} |
1155 |
||
6573 | 1156 |
static void ConvertTownOwner() |
0 | 1157 |
{ |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
1158 |
TileIndex tile; |
0 | 1159 |
|
863
8d09f9331a80
(svn r1344) Use MapSize[XY]() (or MapSize()/MapMax[XY]() where appropriate) instead of TILES_[XY]
tron
parents:
861
diff
changeset
|
1160 |
for (tile = 0; tile != MapSize(); tile++) { |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3984
diff
changeset
|
1161 |
switch (GetTileType(tile)) { |
7866
e19fda04e8d3
(svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents:
7768
diff
changeset
|
1162 |
case MP_ROAD: |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8418
diff
changeset
|
1163 |
if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HasBit(_m[tile].m4, 7)) { |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1164 |
_m[tile].m4 = OWNER_TOWN; |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3984
diff
changeset
|
1165 |
} |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3984
diff
changeset
|
1166 |
/* FALLTHROUGH */ |
0 | 1167 |
|
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3984
diff
changeset
|
1168 |
case MP_TUNNELBRIDGE: |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3984
diff
changeset
|
1169 |
if (GetTileOwner(tile) & 0x80) SetTileOwner(tile, OWNER_TOWN); |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3984
diff
changeset
|
1170 |
break; |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3984
diff
changeset
|
1171 |
|
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3984
diff
changeset
|
1172 |
default: break; |
0 | 1173 |
} |
1174 |
} |
|
1175 |
} |
|
1176 |
||
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1177 |
/* before savegame version 4, the name of the company determined if it existed */ |
6573 | 1178 |
static void CheckIsPlayerActive() |
0 | 1179 |
{ |
4171 | 1180 |
Player *p; |
2639 | 1181 |
|
0 | 1182 |
FOR_ALL_PLAYERS(p) { |
2639 | 1183 |
if (p->name_1 != 0) p->is_active = true; |
0 | 1184 |
} |
1185 |
} |
|
1186 |
||
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1187 |
/* since savegame version 4.1, exclusive transport rights are stored at towns */ |
6573 | 1188 |
static void UpdateExclusiveRights() |
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1189 |
{ |
4171 | 1190 |
Town *t; |
2639 | 1191 |
|
1192 |
FOR_ALL_TOWNS(t) { |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1193 |
t->exclusivity = INVALID_PLAYER; |
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1194 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1195 |
|
123
d550772c61e6
(svn r124) Prepared code for removal of block_months variable in next major savegame version
dominik
parents:
121
diff
changeset
|
1196 |
/* FIXME old exclusive rights status is not being imported (stored in s->blocked_months_obsolete) |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4548
diff
changeset
|
1197 |
* could be implemented this way: |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4548
diff
changeset
|
1198 |
* 1.) Go through all stations |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4548
diff
changeset
|
1199 |
* Build an array town_blocked[ town_id ][ player_id ] |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4548
diff
changeset
|
1200 |
* that stores if at least one station in that town is blocked for a player |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4548
diff
changeset
|
1201 |
* 2.) Go through that array, if you find a town that is not blocked for |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4548
diff
changeset
|
1202 |
* one player, but for all others, then give him exclusivity. |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4548
diff
changeset
|
1203 |
*/ |
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1204 |
} |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1205 |
|
2756 | 1206 |
static const byte convert_currency[] = { |
762
7afe6c8554cb
(svn r1222) Currency cleanup. Changed some currency symbols according to forum suggestions (thx ChrisCF) and rearranged the currencies alphabetically (except for the major ones).
dominik
parents:
760
diff
changeset
|
1207 |
0, 1, 12, 8, 3, |
7afe6c8554cb
(svn r1222) Currency cleanup. Changed some currency symbols according to forum suggestions (thx ChrisCF) and rearranged the currencies alphabetically (except for the major ones).
dominik
parents:
760
diff
changeset
|
1208 |
10, 14, 19, 4, 5, |
7afe6c8554cb
(svn r1222) Currency cleanup. Changed some currency symbols according to forum suggestions (thx ChrisCF) and rearranged the currencies alphabetically (except for the major ones).
dominik
parents:
760
diff
changeset
|
1209 |
9, 11, 13, 6, 17, |
7afe6c8554cb
(svn r1222) Currency cleanup. Changed some currency symbols according to forum suggestions (thx ChrisCF) and rearranged the currencies alphabetically (except for the major ones).
dominik
parents:
760
diff
changeset
|
1210 |
16, 22, 21, 7, 15, |
7afe6c8554cb
(svn r1222) Currency cleanup. Changed some currency symbols according to forum suggestions (thx ChrisCF) and rearranged the currencies alphabetically (except for the major ones).
dominik
parents:
760
diff
changeset
|
1211 |
18, 2, 20, }; |
7afe6c8554cb
(svn r1222) Currency cleanup. Changed some currency symbols according to forum suggestions (thx ChrisCF) and rearranged the currencies alphabetically (except for the major ones).
dominik
parents:
760
diff
changeset
|
1212 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1213 |
/* since savegame version 4.2 the currencies are arranged differently */ |
6573 | 1214 |
static void UpdateCurrencies() |
762
7afe6c8554cb
(svn r1222) Currency cleanup. Changed some currency symbols according to forum suggestions (thx ChrisCF) and rearranged the currencies alphabetically (except for the major ones).
dominik
parents:
760
diff
changeset
|
1215 |
{ |
768
deb40d3554a2
(svn r1233) Fixed several currency issues. Now currencies should work correctly again.
dominik
parents:
762
diff
changeset
|
1216 |
_opt.currency = convert_currency[_opt.currency]; |
762
7afe6c8554cb
(svn r1222) Currency cleanup. Changed some currency symbols according to forum suggestions (thx ChrisCF) and rearranged the currencies alphabetically (except for the major ones).
dominik
parents:
760
diff
changeset
|
1217 |
} |
7afe6c8554cb
(svn r1222) Currency cleanup. Changed some currency symbols according to forum suggestions (thx ChrisCF) and rearranged the currencies alphabetically (except for the major ones).
dominik
parents:
760
diff
changeset
|
1218 |
|
1181
6231b823d796
(svn r1683) Fix placement of MP_VOID tiles. On square maps it accidently works, but on non-square maps the wrong tiles would get marked as MP_VOID
tron
parents:
1165
diff
changeset
|
1219 |
/* Up to revision 1413 the invisible tiles at the southern border have not been |
6231b823d796
(svn r1683) Fix placement of MP_VOID tiles. On square maps it accidently works, but on non-square maps the wrong tiles would get marked as MP_VOID
tron
parents:
1165
diff
changeset
|
1220 |
* MP_VOID, even though they should have. This is fixed by this function |
6231b823d796
(svn r1683) Fix placement of MP_VOID tiles. On square maps it accidently works, but on non-square maps the wrong tiles would get marked as MP_VOID
tron
parents:
1165
diff
changeset
|
1221 |
*/ |
6573 | 1222 |
static void UpdateVoidTiles() |
929
1a071a06af3f
(svn r1417) Fix: The invisible tiles on the southern border are now converted to class MP_VOID when an old map (with wrong classified invisible tiles) is loaded.
dominik
parents:
921
diff
changeset
|
1223 |
{ |
959
b031d88c76f3
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
950
diff
changeset
|
1224 |
uint i; |
1181
6231b823d796
(svn r1683) Fix placement of MP_VOID tiles. On square maps it accidently works, but on non-square maps the wrong tiles would get marked as MP_VOID
tron
parents:
1165
diff
changeset
|
1225 |
|
3075
f0d692c60465
(svn r3664) Add a function to turn a tile into a void tile
tron
parents:
3059
diff
changeset
|
1226 |
for (i = 0; i < MapMaxY(); ++i) MakeVoid(i * MapSizeX() + MapMaxX()); |
f0d692c60465
(svn r3664) Add a function to turn a tile into a void tile
tron
parents:
3059
diff
changeset
|
1227 |
for (i = 0; i < MapSizeX(); ++i) MakeVoid(MapSizeX() * MapMaxY() + i); |
929
1a071a06af3f
(svn r1417) Fix: The invisible tiles on the southern border are now converted to class MP_VOID when an old map (with wrong classified invisible tiles) is loaded.
dominik
parents:
921
diff
changeset
|
1228 |
} |
1a071a06af3f
(svn r1417) Fix: The invisible tiles on the southern border are now converted to class MP_VOID when an old map (with wrong classified invisible tiles) is loaded.
dominik
parents:
921
diff
changeset
|
1229 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1230 |
/* since savegame version 6.0 each sign has an "owner", signs without owner (from old games are set to 255) */ |
6573 | 1231 |
static void UpdateSignOwner() |
1165
2cdf7a0e217a
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1232 |
{ |
4349
2fc39ff2626e
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
1233 |
Sign *si; |
2639 | 1234 |
|
4349
2fc39ff2626e
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
1235 |
FOR_ALL_SIGNS(si) si->owner = OWNER_NONE; |
1165
2cdf7a0e217a
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1236 |
} |
2cdf7a0e217a
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1237 |
|
6573 | 1238 |
extern void UpdateOldAircraft(); |
0 | 1239 |
|
3656
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1240 |
|
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1241 |
static inline RailType UpdateRailType(RailType rt, RailType min) |
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1242 |
{ |
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1243 |
return rt >= min ? (RailType)(rt + 1): rt; |
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1244 |
} |
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1245 |
|
6573 | 1246 |
bool AfterLoadGame() |
0 | 1247 |
{ |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1248 |
TileIndex map_size = MapSize(); |
0 | 1249 |
Window *w; |
1250 |
ViewPort *vp; |
|
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
2100
diff
changeset
|
1251 |
Player *p; |
988
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
983
diff
changeset
|
1252 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1253 |
/* in version 2.1 of the savegame, town owner was unified. */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1254 |
if (CheckSavegameVersionOldStyle(2, 1)) ConvertTownOwner(); |
0 | 1255 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1256 |
/* from version 4.1 of the savegame, exclusive rights are stored at towns */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1257 |
if (CheckSavegameVersionOldStyle(4, 1)) UpdateExclusiveRights(); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1258 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1259 |
/* from version 4.2 of the savegame, currencies are in a different order */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1260 |
if (CheckSavegameVersionOldStyle(4, 2)) UpdateCurrencies(); |
762
7afe6c8554cb
(svn r1222) Currency cleanup. Changed some currency symbols according to forum suggestions (thx ChrisCF) and rearranged the currencies alphabetically (except for the major ones).
dominik
parents:
760
diff
changeset
|
1261 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1262 |
/* from version 6.1 of the savegame, signs have an "owner" */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1263 |
if (CheckSavegameVersionOldStyle(6, 1)) UpdateSignOwner(); |
1165
2cdf7a0e217a
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1264 |
|
831
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1265 |
/* In old version there seems to be a problem that water is owned by |
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1266 |
OWNER_NONE, not OWNER_WATER.. I can't replicate it for the current |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1267 |
(4.3) version, so I just check when versions are older, and then |
831
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1268 |
walk through the whole map.. */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1269 |
if (CheckSavegameVersionOldStyle(4, 3)) { |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1270 |
for (TileIndex t = 0; t < map_size; t++) { |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1271 |
if (IsTileType(t, MP_WATER) && GetTileOwner(t) >= MAX_PLAYERS) { |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1272 |
SetTileOwner(t, OWNER_WATER); |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1273 |
} |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1274 |
} |
831
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1275 |
} |
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1276 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1277 |
/* convert road side to my format. */ |
0 | 1278 |
if (_opt.road_side) _opt.road_side = 1; |
1279 |
||
5898
2ee7d23291fa
(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
parents:
5887
diff
changeset
|
1280 |
/* Check if all NewGRFs are present, we are very strict in MP mode */ |
6555
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6522
diff
changeset
|
1281 |
GRFListCompatibility gcf_res = IsGoodGRFConfigList(); |
7532
66c79dd999af
(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
parents:
7514
diff
changeset
|
1282 |
if (_networking && gcf_res != GLC_ALL_GOOD) { |
66c79dd999af
(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
parents:
7514
diff
changeset
|
1283 |
SetSaveLoadError(STR_NETWORK_ERR_CLIENT_NEWGRF_MISMATCH); |
66c79dd999af
(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
parents:
7514
diff
changeset
|
1284 |
return false; |
66c79dd999af
(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
parents:
7514
diff
changeset
|
1285 |
} |
5898
2ee7d23291fa
(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
parents:
5887
diff
changeset
|
1286 |
|
2ee7d23291fa
(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
parents:
5887
diff
changeset
|
1287 |
switch (gcf_res) { |
6555
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6522
diff
changeset
|
1288 |
case GLC_COMPATIBLE: _switch_mode_errorstr = STR_NEWGRF_COMPATIBLE_LOAD_WARNING; break; |
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6522
diff
changeset
|
1289 |
case GLC_NOT_FOUND: _switch_mode_errorstr = STR_NEWGRF_DISABLED_WARNING; break; |
5903 | 1290 |
default: break; |
5898
2ee7d23291fa
(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
parents:
5887
diff
changeset
|
1291 |
} |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5197
diff
changeset
|
1292 |
|
5340
82c981816fcb
(svn r7506) -Codechange: [NewGRF] Add action 7/9/D variable 0x81 (current year)
glx
parents:
5314
diff
changeset
|
1293 |
/* Update current year |
82c981816fcb
(svn r7506) -Codechange: [NewGRF] Add action 7/9/D variable 0x81 (current year)
glx
parents:
5314
diff
changeset
|
1294 |
* must be done before loading sprites as some newgrfs check it */ |
82c981816fcb
(svn r7506) -Codechange: [NewGRF] Add action 7/9/D variable 0x81 (current year)
glx
parents:
5314
diff
changeset
|
1295 |
SetDate(_date); |
82c981816fcb
(svn r7506) -Codechange: [NewGRF] Add action 7/9/D variable 0x81 (current year)
glx
parents:
5314
diff
changeset
|
1296 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1297 |
/* Load the sprites */ |
0 | 1298 |
GfxLoadSprites(); |
5155
64f930853bea
(svn r7250) -Codechange: Shuffle sprite loading and character width caching around a bit. This reduces the number of times the sprites are loaded from 5 to 2, just for the intro game.
peter1138
parents:
5116
diff
changeset
|
1299 |
LoadStringWidthTable(); |
0 | 1300 |
|
2814
0f534d66544e
(svn r3362) Fix issue with loading old (TTD) savegames:
peter1138
parents:
2808
diff
changeset
|
1301 |
/* Connect front and rear engines of multiheaded trains and converts |
0f534d66544e
(svn r3362) Fix issue with loading old (TTD) savegames:
peter1138
parents:
2808
diff
changeset
|
1302 |
* subtype to the new format */ |
0f534d66544e
(svn r3362) Fix issue with loading old (TTD) savegames:
peter1138
parents:
2808
diff
changeset
|
1303 |
if (CheckSavegameVersionOldStyle(17, 1)) ConvertOldMultiheadToNew(); |
0f534d66544e
(svn r3362) Fix issue with loading old (TTD) savegames:
peter1138
parents:
2808
diff
changeset
|
1304 |
|
2928
414b96d4d4fb
(svn r3484) -fix: fixed issue in last commit where loading savegame versions 18 and 19 didn't init the multiheaded engine pointers
bjarni
parents:
2916
diff
changeset
|
1305 |
/* Connect front and rear engines of multiheaded trains */ |
414b96d4d4fb
(svn r3484) -fix: fixed issue in last commit where loading savegame versions 18 and 19 didn't init the multiheaded engine pointers
bjarni
parents:
2916
diff
changeset
|
1306 |
ConnectMultiheadedTrains(); |
2855
950b5a56f9d5
(svn r3403) -Codechange: [multiheaded engines] the references between the front and rear engines are no longer saved
bjarni
parents:
2848
diff
changeset
|
1307 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1308 |
/* reinit the landscape variables (landscape might have changed) */ |
0 | 1309 |
InitializeLandscapeVariables(true); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1310 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1311 |
/* Update all vehicles */ |
0 | 1312 |
AfterLoadVehicles(); |
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1501
diff
changeset
|
1313 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1314 |
/* Update all waypoints */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1315 |
if (CheckSavegameVersion(12)) FixOldWaypoints(); |
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1501
diff
changeset
|
1316 |
|
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1501
diff
changeset
|
1317 |
UpdateAllWaypointSigns(); |
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1501
diff
changeset
|
1318 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1319 |
/* in version 2.2 of the savegame, we have new airports */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1320 |
if (CheckSavegameVersionOldStyle(2, 2)) UpdateOldAircraft(); |
0 | 1321 |
|
1322 |
UpdateAllStationVirtCoord(); |
|
1323 |
||
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1324 |
/* Setup town coords */ |
0 | 1325 |
AfterLoadTown(); |
1326 |
UpdateAllSignVirtCoords(); |
|
1327 |
||
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1328 |
/* make sure there is a town in the game */ |
2639 | 1329 |
if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, (uint)-1)) { |
7532
66c79dd999af
(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
parents:
7514
diff
changeset
|
1330 |
SetSaveLoadError(STR_NO_TOWN_IN_SCENARIO); |
0 | 1331 |
return false; |
1332 |
} |
|
1333 |
||
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1334 |
/* Initialize windows */ |
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
1335 |
ResetWindowSystem(); |
0 | 1336 |
SetupColorsAndInitialWindow(); |
1337 |
||
1338 |
w = FindWindowById(WC_MAIN_WINDOW, 0); |
|
1339 |
||
1340 |
WP(w,vp_d).scrollpos_x = _saved_scrollpos_x; |
|
1341 |
WP(w,vp_d).scrollpos_y = _saved_scrollpos_y; |
|
7226
a8650d6ecb53
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
7222
diff
changeset
|
1342 |
WP(w,vp_d).dest_scrollpos_x = _saved_scrollpos_x; |
a8650d6ecb53
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
7222
diff
changeset
|
1343 |
WP(w,vp_d).dest_scrollpos_y = _saved_scrollpos_y; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1344 |
|
0 | 1345 |
vp = w->viewport; |
7424
f1cc2b39a2aa
(svn r10181) -Fix (r10093): clamp the zoom level so it won't try to use a wrong zoom level when loading an old savegame.
rubidium
parents:
7388
diff
changeset
|
1346 |
vp->zoom = (ZoomLevel)min(_saved_scrollpos_zoom, ZOOM_LVL_MAX); |
7122
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7115
diff
changeset
|
1347 |
vp->virtual_width = ScaleByZoom(vp->width, vp->zoom); |
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7115
diff
changeset
|
1348 |
vp->virtual_height = ScaleByZoom(vp->height, vp->zoom); |
0 | 1349 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1350 |
/* in version 4.1 of the savegame, is_active was introduced to determine |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1351 |
* if a player does exist, rather then checking name_1 */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1352 |
if (CheckSavegameVersionOldStyle(4, 1)) CheckIsPlayerActive(); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1353 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1354 |
/* the void tiles on the southern border used to belong to a wrong class (pre 4.3). */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1355 |
if (CheckSavegameVersionOldStyle(4, 3)) UpdateVoidTiles(); |
929
1a071a06af3f
(svn r1417) Fix: The invisible tiles on the southern border are now converted to class MP_VOID when an old map (with wrong classified invisible tiles) is loaded.
dominik
parents:
921
diff
changeset
|
1356 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1357 |
/* If Load Scenario / New (Scenario) Game is used, |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1358 |
* a player does not exist yet. So create one here. |
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1359 |
* 1 exeption: network-games. Those can have 0 players |
7070
e12be4319af5
(svn r9785) -Fix (r942, FS#765): only non dedicated servers can't have 0 players
glx
parents:
7056
diff
changeset
|
1360 |
* But this exeption is not true for non dedicated network_servers! */ |
e12be4319af5
(svn r9785) -Fix (r942, FS#765): only non dedicated servers can't have 0 players
glx
parents:
7056
diff
changeset
|
1361 |
if (!_players[0].is_active && (!_networking || (_networking && _network_server && !_network_dedicated))) |
139 | 1362 |
DoStartupNewPlayer(false); |
0 | 1363 |
|
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
139
diff
changeset
|
1364 |
DoZoomInOutWindow(ZOOM_NONE, w); // update button status |
0 | 1365 |
MarkWholeScreenDirty(); |
1366 |
||
7768
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1367 |
if (CheckSavegameVersion(72)) { |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1368 |
/* Locks/shiplifts in very old savegames had OWNER_WATER as owner */ |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1369 |
for (TileIndex t = 0; t < MapSize(); t++) { |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1370 |
switch (GetTileType(t)) { |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1371 |
default: break; |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1372 |
|
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1373 |
case MP_WATER: |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1374 |
if (GetWaterTileType(t) == WATER_TILE_LOCK && GetTileOwner(t) == OWNER_WATER) SetTileOwner(t, OWNER_NONE); |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1375 |
break; |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1376 |
|
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1377 |
case MP_STATION: { |
8427
143b0be22af1
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
8425
diff
changeset
|
1378 |
if (HasBit(_m[t].m6, 3)) SetBit(_m[t].m6, 2); |
7768
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1379 |
StationGfx gfx = GetStationGfx(t); |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1380 |
StationType st; |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1381 |
if ( IS_INT_INSIDE(gfx, 0, 8)) { // Railway station |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1382 |
st = STATION_RAIL; |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1383 |
SetStationGfx(t, gfx - 0); |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1384 |
} else if (IS_INT_INSIDE(gfx, 8, 67)) { // Airport |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1385 |
st = STATION_AIRPORT; |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1386 |
SetStationGfx(t, gfx - 8); |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1387 |
} else if (IS_INT_INSIDE(gfx, 67, 71)) { // Truck |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1388 |
st = STATION_TRUCK; |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1389 |
SetStationGfx(t, gfx - 67); |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1390 |
} else if (IS_INT_INSIDE(gfx, 71, 75)) { // Bus |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1391 |
st = STATION_BUS; |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1392 |
SetStationGfx(t, gfx - 71); |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1393 |
} else if (gfx == 75) { // Oil rig |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1394 |
st = STATION_OILRIG; |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1395 |
SetStationGfx(t, gfx - 75); |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1396 |
} else if (IS_INT_INSIDE(gfx, 76, 82)) { // Dock |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1397 |
st = STATION_DOCK; |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1398 |
SetStationGfx(t, gfx - 76); |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1399 |
} else if (gfx == 82) { // Buoy |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1400 |
st = STATION_BUOY; |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1401 |
SetStationGfx(t, gfx - 82); |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1402 |
} else if (IS_INT_INSIDE(gfx, 83, 168)) { // Extended airport |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1403 |
st = STATION_AIRPORT; |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1404 |
SetStationGfx(t, gfx - 83 + 67 - 8); |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1405 |
} else if (IS_INT_INSIDE(gfx, 168, 170)) { // Drive through truck |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1406 |
st = STATION_TRUCK; |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1407 |
SetStationGfx(t, gfx - 168 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET); |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1408 |
} else if (IS_INT_INSIDE(gfx, 170, 172)) { // Drive through bus |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1409 |
st = STATION_BUS; |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1410 |
SetStationGfx(t, gfx - 170 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET); |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1411 |
} else { |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1412 |
return false; |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1413 |
} |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1414 |
SB(_m[t].m6, 3, 3, st); |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1415 |
} break; |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1416 |
} |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1417 |
} |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1418 |
} |
2060e8d65a72
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents:
7766
diff
changeset
|
1419 |
|
6131 | 1420 |
for (TileIndex t = 0; t < map_size; t++) { |
1421 |
switch (GetTileType(t)) { |
|
6419 | 1422 |
case MP_STATION: { |
1423 |
Station *st = GetStationByTile(t); |
|
1424 |
||
1425 |
st->rect.BeforeAddTile(t, StationRect::ADD_FORCE); |
|
1426 |
||
6131 | 1427 |
switch (GetStationType(t)) { |
1428 |
case STATION_TRUCK: |
|
1429 |
case STATION_BUS: |
|
1430 |
if (CheckSavegameVersion(6)) { |
|
6419 | 1431 |
/* From this version on there can be multiple road stops of the |
1432 |
* same type per station. Convert the existing stops to the new |
|
1433 |
* internal data structure. */ |
|
6131 | 1434 |
RoadStop *rs = new RoadStop(t); |
1435 |
if (rs == NULL) error("Too many road stops in savegame"); |
|
6130 | 1436 |
|
6131 | 1437 |
RoadStop **head = |
1438 |
IsTruckStop(t) ? &st->truck_stops : &st->bus_stops; |
|
1439 |
*head = rs; |
|
1440 |
} |
|
1441 |
break; |
|
1442 |
||
6135 | 1443 |
case STATION_OILRIG: { |
1444 |
/* Very old savegames sometimes have phantom oil rigs, i.e. |
|
1445 |
* an oil rig which got shut down, but not completly removed from |
|
1446 |
* the map |
|
1447 |
*/ |
|
8236
a8905f3a9af7
(svn r11277) -Fix (r8498): the check for ghost station (on water industries) always removed station for non-oilrig
glx
parents:
8235
diff
changeset
|
1448 |
TileIndex t1 = TILE_ADDXY(t, 0, 1); |
6137 | 1449 |
if (IsTileType(t1, MP_INDUSTRY) && |
8236
a8905f3a9af7
(svn r11277) -Fix (r8498): the check for ghost station (on water industries) always removed station for non-oilrig
glx
parents:
8235
diff
changeset
|
1450 |
GetIndustryGfx(t1) == GFX_OILRIG_1) { |
6137 | 1451 |
/* The internal encoding of oil rigs was changed twice. |
1452 |
* It was 3 (till 2.2) and later 5 (till 5.1). |
|
1453 |
* Setting it unconditionally does not hurt. |
|
1454 |
*/ |
|
1455 |
GetStationByTile(t)->airport_type = AT_OILRIG; |
|
1456 |
} else { |
|
6135 | 1457 |
DeleteOilRig(t); |
1458 |
} |
|
1459 |
break; |
|
1460 |
} |
|
1461 |
||
6131 | 1462 |
default: break; |
1463 |
} |
|
1464 |
break; |
|
6419 | 1465 |
} |
6131 | 1466 |
|
1467 |
default: break; |
|
6130 | 1468 |
} |
1469 |
} |
|
1470 |
||
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1471 |
/* In version 6.1 we put the town index in the map-array. To do this, we need |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1472 |
* to use m2 (16bit big), so we need to clean m2, and that is where this is |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1473 |
* all about ;) */ |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1474 |
if (CheckSavegameVersionOldStyle(6, 1)) { |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1475 |
for (TileIndex t = 0; t < map_size; t++) { |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1476 |
switch (GetTileType(t)) { |
3983
d2d6496238e4
(svn r5171) Get rid of an ungly hack in the load routine, which temporarily turned house and road tiles into void tiles to calculate the closest town
tron
parents:
3977
diff
changeset
|
1477 |
case MP_HOUSE: |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1478 |
_m[t].m4 = _m[t].m2; |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1479 |
SetTownIndex(t, CalcClosestTownFromTile(t, (uint)-1)->index); |
3983
d2d6496238e4
(svn r5171) Get rid of an ungly hack in the load routine, which temporarily turned house and road tiles into void tiles to calculate the closest town
tron
parents:
3977
diff
changeset
|
1480 |
break; |
d2d6496238e4
(svn r5171) Get rid of an ungly hack in the load routine, which temporarily turned house and road tiles into void tiles to calculate the closest town
tron
parents:
3977
diff
changeset
|
1481 |
|
7866
e19fda04e8d3
(svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents:
7768
diff
changeset
|
1482 |
case MP_ROAD: |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1483 |
_m[t].m4 |= (_m[t].m2 << 4); |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1484 |
if (IsTileOwner(t, OWNER_TOWN)) { |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1485 |
SetTownIndex(t, CalcClosestTownFromTile(t, (uint)-1)->index); |
3983
d2d6496238e4
(svn r5171) Get rid of an ungly hack in the load routine, which temporarily turned house and road tiles into void tiles to calculate the closest town
tron
parents:
3977
diff
changeset
|
1486 |
} else { |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1487 |
SetTownIndex(t, 0); |
3983
d2d6496238e4
(svn r5171) Get rid of an ungly hack in the load routine, which temporarily turned house and road tiles into void tiles to calculate the closest town
tron
parents:
3977
diff
changeset
|
1488 |
} |
d2d6496238e4
(svn r5171) Get rid of an ungly hack in the load routine, which temporarily turned house and road tiles into void tiles to calculate the closest town
tron
parents:
3977
diff
changeset
|
1489 |
break; |
d2d6496238e4
(svn r5171) Get rid of an ungly hack in the load routine, which temporarily turned house and road tiles into void tiles to calculate the closest town
tron
parents:
3977
diff
changeset
|
1490 |
|
d2d6496238e4
(svn r5171) Get rid of an ungly hack in the load routine, which temporarily turned house and road tiles into void tiles to calculate the closest town
tron
parents:
3977
diff
changeset
|
1491 |
default: break; |
1264
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1492 |
} |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1493 |
} |
1264
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1494 |
} |
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1495 |
|
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1496 |
/* From version 9.0, we update the max passengers of a town (was sometimes negative |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1497 |
* before that. */ |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1498 |
if (CheckSavegameVersion(9)) { |
1377
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1349
diff
changeset
|
1499 |
Town *t; |
2639 | 1500 |
FOR_ALL_TOWNS(t) UpdateTownMaxPass(t); |
1377
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1349
diff
changeset
|
1501 |
} |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1349
diff
changeset
|
1502 |
|
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1503 |
/* From version 16.0, we included autorenew on engines, which are now saved, but |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1504 |
* of course, we do need to initialize them for older savegames. */ |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1505 |
if (CheckSavegameVersion(16)) { |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1506 |
FOR_ALL_PLAYERS(p) { |
5564
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
1507 |
p->engine_renew_list = NULL; |
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
1508 |
p->engine_renew = false; |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1509 |
p->engine_renew_months = -6; |
5564
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
1510 |
p->engine_renew_money = 100000; |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1511 |
} |
5564
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
1512 |
|
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
1513 |
/* When loading a game, _local_player is not yet set to the correct value. |
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
1514 |
* However, in a dedicated server we are a spectator, so nothing needs to |
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
1515 |
* happen. In case we are not a dedicated server, the local player always |
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
1516 |
* becomes player 0, unless we are in the scenario editor where all the |
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
1517 |
* players are 'invalid'. |
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
1518 |
*/ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1519 |
if (!_network_dedicated && IsValidPlayer(PLAYER_FIRST)) { |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1520 |
p = GetPlayer(PLAYER_FIRST); |
5564
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
1521 |
p->engine_renew = _patches.autorenew; |
2322
962f8825ff6b
(svn r2848) -Fix: [ 1256044 ] fixed crash when loading a map made before rev 2817 in scenario editor. This was introduced in 2817
bjarni
parents:
2297
diff
changeset
|
1522 |
p->engine_renew_months = _patches.autorenew_months; |
5564
6e1b3ea1ba7f
(svn r7561) -Fix (FS#431): core and (patches) GUI were not in-sync with respect to autorenew settings. This is only a temporary fix, as the definite fix needs to move the autorenew settings to a per-company settings window.
rubidium
parents:
5352
diff
changeset
|
1523 |
p->engine_renew_money = _patches.autorenew_money; |
2322
962f8825ff6b
(svn r2848) -Fix: [ 1256044 ] fixed crash when loading a map made before rev 2817 in scenario editor. This was introduced in 2817
bjarni
parents:
2297
diff
changeset
|
1524 |
} |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1525 |
} |
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1526 |
|
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1527 |
if (CheckSavegameVersion(48)) { |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1528 |
for (TileIndex t = 0; t < map_size; t++) { |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1529 |
switch (GetTileType(t)) { |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1530 |
case MP_RAILWAY: |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1531 |
if (IsPlainRailTile(t)) { |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1532 |
/* Swap ground type and signal type for plain rail tiles, so the |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1533 |
* ground type uses the same bits as for depots and waypoints. */ |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1534 |
uint tmp = GB(_m[t].m4, 0, 4); |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1535 |
SB(_m[t].m4, 0, 4, GB(_m[t].m2, 0, 4)); |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1536 |
SB(_m[t].m2, 0, 4, tmp); |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8418
diff
changeset
|
1537 |
} else if (HasBit(_m[t].m5, 2)) { |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1538 |
/* Split waypoint and depot rail type and remove the subtype. */ |
8425
72a71d480c5f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
8424
diff
changeset
|
1539 |
ClrBit(_m[t].m5, 2); |
72a71d480c5f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
8424
diff
changeset
|
1540 |
ClrBit(_m[t].m5, 6); |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1541 |
} |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1542 |
break; |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1543 |
|
7866
e19fda04e8d3
(svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents:
7768
diff
changeset
|
1544 |
case MP_ROAD: |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1545 |
/* Swap m3 and m4, so the track type for rail crossings is the |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1546 |
* same as for normal rail. */ |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1547 |
Swap(_m[t].m3, _m[t].m4); |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1548 |
break; |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1549 |
|
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1550 |
default: break; |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1551 |
} |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1552 |
} |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1553 |
} |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1554 |
|
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1555 |
if (CheckSavegameVersion(61)) { |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1556 |
/* Added the RoadType */ |
7234
4103cd45db12
(svn r9971) -Fix (r9892, r9958): loading of post-'bridges over "everything"' messed with the railtype of bridges.
rubidium
parents:
7226
diff
changeset
|
1557 |
bool old_bridge = CheckSavegameVersion(42); |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1558 |
for (TileIndex t = 0; t < map_size; t++) { |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1559 |
switch(GetTileType(t)) { |
7866
e19fda04e8d3
(svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents:
7768
diff
changeset
|
1560 |
case MP_ROAD: |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1561 |
SB(_m[t].m5, 6, 2, GB(_m[t].m5, 4, 2)); |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1562 |
switch (GetRoadTileType(t)) { |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1563 |
default: NOT_REACHED(); |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1564 |
case ROAD_TILE_NORMAL: |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1565 |
SB(_m[t].m4, 0, 4, GB(_m[t].m5, 0, 4)); |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1566 |
SB(_m[t].m4, 4, 4, 0); |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1567 |
SB(_m[t].m6, 2, 4, 0); |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1568 |
break; |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1569 |
case ROAD_TILE_CROSSING: |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1570 |
SB(_m[t].m4, 5, 2, GB(_m[t].m5, 2, 2)); |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1571 |
break; |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1572 |
case ROAD_TILE_DEPOT: break; |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1573 |
} |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1574 |
SetRoadTypes(t, ROADTYPES_ROAD); |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1575 |
break; |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1576 |
|
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1577 |
case MP_STATION: |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1578 |
if (IsRoadStop(t)) SetRoadTypes(t, ROADTYPES_ROAD); |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1579 |
break; |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1580 |
|
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1581 |
case MP_TUNNELBRIDGE: |
7234
4103cd45db12
(svn r9971) -Fix (r9892, r9958): loading of post-'bridges over "everything"' messed with the railtype of bridges.
rubidium
parents:
7226
diff
changeset
|
1582 |
/* Middle part of "old" bridges */ |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8418
diff
changeset
|
1583 |
if (old_bridge && IsBridgeTile(t) && HasBit(_m[t].m5, 6)) break; |
7234
4103cd45db12
(svn r9971) -Fix (r9892, r9958): loading of post-'bridges over "everything"' messed with the railtype of bridges.
rubidium
parents:
7226
diff
changeset
|
1584 |
if ((IsTunnel(t) ? GetTunnelTransportType(t) : (old_bridge ? (TransportType)GB(_m[t].m5, 1, 2) : GetBridgeTransportType(t))) == TRANSPORT_ROAD) { |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1585 |
SetRoadTypes(t, ROADTYPES_ROAD); |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1586 |
} |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1587 |
break; |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1588 |
|
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1589 |
default: break; |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1590 |
} |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1591 |
} |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1592 |
} |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1593 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1594 |
if (CheckSavegameVersion(42)) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1595 |
Vehicle* v; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1596 |
|
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1597 |
for (TileIndex t = 0; t < map_size; t++) { |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1598 |
if (MayHaveBridgeAbove(t)) ClearBridgeMiddle(t); |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1599 |
if (IsBridgeTile(t)) { |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8418
diff
changeset
|
1600 |
if (HasBit(_m[t].m5, 6)) { // middle part |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1601 |
Axis axis = (Axis)GB(_m[t].m5, 0, 1); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1602 |
|
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8418
diff
changeset
|
1603 |
if (HasBit(_m[t].m5, 5)) { // transport route under bridge? |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1604 |
if (GB(_m[t].m5, 3, 2) == TRANSPORT_RAIL) { |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1605 |
MakeRailNormal( |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1606 |
t, |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1607 |
GetTileOwner(t), |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1608 |
axis == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X, |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1609 |
GetRailType(t) |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1610 |
); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1611 |
} else { |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1612 |
TownID town = IsTileOwner(t, OWNER_TOWN) ? ClosestTownFromTile(t, (uint)-1)->index : 0; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1613 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1614 |
MakeRoadNormal( |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1615 |
t, |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1616 |
axis == AXIS_X ? ROAD_Y : ROAD_X, |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1617 |
ROADTYPES_ROAD, |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1618 |
town, |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7150
diff
changeset
|
1619 |
GetTileOwner(t), OWNER_NONE, OWNER_NONE |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1620 |
); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1621 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1622 |
} else { |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1623 |
if (GB(_m[t].m5, 3, 2) == 0) { |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1624 |
MakeClear(t, CLEAR_GRASS, 3); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1625 |
} else { |
8235
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8206
diff
changeset
|
1626 |
MakeCanal(t, (GetTileOwner(t) == OWNER_WATER) ? OWNER_NONE : GetTileOwner(t)); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1627 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1628 |
} |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1629 |
SetBridgeMiddle(t, axis); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1630 |
} else { // ramp |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1631 |
Axis axis = (Axis)GB(_m[t].m5, 0, 1); |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1632 |
uint north_south = GB(_m[t].m5, 5, 1); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1633 |
DiagDirection dir = ReverseDiagDir(XYNSToDiagDir(axis, north_south)); |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1634 |
TransportType type = (TransportType)GB(_m[t].m5, 1, 2); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1635 |
|
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1636 |
_m[t].m5 = 1 << 7 | type << 2 | dir; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1637 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1638 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1639 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1640 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1641 |
FOR_ALL_VEHICLES(v) { |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6583
diff
changeset
|
1642 |
if (v->type != VEH_TRAIN && v->type != VEH_ROAD) continue; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1643 |
if (IsBridgeTile(v->tile)) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1644 |
DiagDirection dir = GetBridgeRampDirection(v->tile); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1645 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1646 |
if (dir != DirToDiagDir(v->direction)) continue; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1647 |
switch (dir) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1648 |
default: NOT_REACHED(); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1649 |
case DIAGDIR_NE: if ((v->x_pos & 0xF) != 0) continue; break; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1650 |
case DIAGDIR_SE: if ((v->y_pos & 0xF) != TILE_SIZE - 1) continue; break; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1651 |
case DIAGDIR_SW: if ((v->x_pos & 0xF) != TILE_SIZE - 1) continue; break; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1652 |
case DIAGDIR_NW: if ((v->y_pos & 0xF) != 0) continue; break; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1653 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1654 |
} else if (v->z_pos > GetSlopeZ(v->x_pos, v->y_pos)) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1655 |
v->tile = GetNorthernBridgeEnd(v->tile); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1656 |
} else { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1657 |
continue; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1658 |
} |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6583
diff
changeset
|
1659 |
if (v->type == VEH_TRAIN) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1660 |
v->u.rail.track = TRACK_BIT_WORMHOLE; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1661 |
} else { |
6326
c904c7ea1c8d
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents:
6312
diff
changeset
|
1662 |
v->u.road.state = RVSB_WORMHOLE; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1663 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1664 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1665 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1666 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1667 |
/* Elrails got added in rev 24 */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1668 |
if (CheckSavegameVersion(24)) { |
4171 | 1669 |
Vehicle *v; |
3656
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1670 |
RailType min_rail = RAILTYPE_ELECTRIC; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1671 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1672 |
FOR_ALL_VEHICLES(v) { |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6583
diff
changeset
|
1673 |
if (v->type == VEH_TRAIN) { |
6074 | 1674 |
RailType rt = RailVehInfo(v->engine_type)->railtype; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1675 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1676 |
v->u.rail.railtype = rt; |
3656
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1677 |
if (rt == RAILTYPE_ELECTRIC) min_rail = RAILTYPE_RAIL; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1678 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1679 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1680 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1681 |
/* .. so we convert the entire map from normal to elrail (so maintain "fairness") */ |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1682 |
for (TileIndex t = 0; t < map_size; t++) { |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1683 |
switch (GetTileType(t)) { |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1684 |
case MP_RAILWAY: |
3656
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1685 |
SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1686 |
break; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1687 |
|
7866
e19fda04e8d3
(svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents:
7768
diff
changeset
|
1688 |
case MP_ROAD: |
3656
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1689 |
if (IsLevelCrossing(t)) { |
6498
aff910a05c6e
(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
parents:
6419
diff
changeset
|
1690 |
SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); |
3656
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1691 |
} |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1692 |
break; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1693 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1694 |
case MP_STATION: |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
1695 |
if (IsRailwayStation(t)) { |
3656
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1696 |
SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); |
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1697 |
} |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1698 |
break; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1699 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1700 |
case MP_TUNNELBRIDGE: |
3367 | 1701 |
if (IsTunnel(t)) { |
1702 |
if (GetTunnelTransportType(t) == TRANSPORT_RAIL) { |
|
3656
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1703 |
SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1704 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1705 |
} else { |
3367 | 1706 |
if (GetBridgeTransportType(t) == TRANSPORT_RAIL) { |
3656
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1707 |
SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1708 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1709 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1710 |
break; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1711 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1712 |
default: |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1713 |
break; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1714 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1715 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1716 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1717 |
FOR_ALL_VEHICLES(v) { |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6583
diff
changeset
|
1718 |
if (v->type == VEH_TRAIN && (IsFrontEngine(v) || IsFreeWagon(v))) TrainConsistChanged(v); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1719 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1720 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1721 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3312
diff
changeset
|
1722 |
|
2805
b6098e7ca457
(svn r3353) Simplify the automatic length adjustment algorithm for replacing trains: Use the length of the train before the replacement as reference length
tron
parents:
2769
diff
changeset
|
1723 |
/* In version 16.1 of the savegame a player can decide if trains, which get |
b6098e7ca457
(svn r3353) Simplify the automatic length adjustment algorithm for replacing trains: Use the length of the train before the replacement as reference length
tron
parents:
2769
diff
changeset
|
1724 |
* replaced, shall keep their old length. In all prior versions, just default |
b6098e7ca457
(svn r3353) Simplify the automatic length adjustment algorithm for replacing trains: Use the length of the train before the replacement as reference length
tron
parents:
2769
diff
changeset
|
1725 |
* to false */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1726 |
if (CheckSavegameVersionOldStyle(16, 1)) { |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
1727 |
FOR_ALL_PLAYERS(p) p->renew_keep_length = false; |
2617
a9e1a187de99
(svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
bjarni
parents:
2572
diff
changeset
|
1728 |
} |
a9e1a187de99
(svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
bjarni
parents:
2572
diff
changeset
|
1729 |
|
2670
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1730 |
/* In version 17, ground type is moved from m2 to m4 for depots and |
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1731 |
* waypoints to make way for storing the index in m2. The custom graphics |
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1732 |
* id which was stored in m4 is now saved as a grf/id reference in the |
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1733 |
* waypoint struct. */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1734 |
if (CheckSavegameVersion(17)) { |
2670
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1735 |
Waypoint *wp; |
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1736 |
|
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1737 |
FOR_ALL_WAYPOINTS(wp) { |
4346
3f00094f2670
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
1738 |
if (wp->deleted == 0) { |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3656
diff
changeset
|
1739 |
const StationSpec *statspec = NULL; |
2670
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1740 |
|
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8418
diff
changeset
|
1741 |
if (HasBit(_m[wp->xy].m3, 4)) |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3656
diff
changeset
|
1742 |
statspec = GetCustomStationSpec(STAT_CLASS_WAYP, _m[wp->xy].m4 + 1); |
2670
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1743 |
|
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3656
diff
changeset
|
1744 |
if (statspec != NULL) { |
2670
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1745 |
wp->stat_id = _m[wp->xy].m4 + 1; |
6947
c21859ab4493
(svn r9601) -Codechange: Store grf file reference in station spec, not just GRF ID
peter1138
parents:
6923
diff
changeset
|
1746 |
wp->grfid = statspec->grffile->grfid; |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3656
diff
changeset
|
1747 |
wp->localidx = statspec->localidx; |
2670
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1748 |
} else { |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1749 |
/* No custom graphics set, so set to default. */ |
2670
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1750 |
wp->stat_id = 0; |
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1751 |
wp->grfid = 0; |
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1752 |
wp->localidx = 0; |
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1753 |
} |
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1754 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1755 |
/* Move ground type bits from m2 to m4. */ |
2670
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1756 |
_m[wp->xy].m4 = GB(_m[wp->xy].m2, 0, 4); |
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1757 |
/* Store waypoint index in the tile. */ |
2670
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1758 |
_m[wp->xy].m2 = wp->index; |
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1759 |
} |
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1760 |
} |
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1761 |
} else { |
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1762 |
/* As of version 17, we recalculate the custom graphic ID of waypoints |
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1763 |
* from the GRF ID / station index. */ |
5350
db5f6bf223d7
(svn r7521) -Codechange: Rename UpdateAllWaypointCustomGraphics to AfterLoadWaypoints to be more conforming with other such functions.
Darkvater
parents:
5340
diff
changeset
|
1764 |
AfterLoadWaypoints(); |
2670
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1765 |
} |
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2649
diff
changeset
|
1766 |
|
2916
8f1aa489701f
(svn r3472) - [PBS] Remove from trunk. Anyone interested can still find it in branch/pbs. This reverts revisions r3158, r3140, r3075, r2977, r2674, r2625, r2621, r2529, r2528, r2525, r2524, r2519, r2517, r2516, r2507, r2499. (in conjunction with Tron)
Darkvater
parents:
2899
diff
changeset
|
1767 |
/* From version 15, we moved a semaphore bit from bit 2 to bit 3 in m4, making |
8f1aa489701f
(svn r3472) - [PBS] Remove from trunk. Anyone interested can still find it in branch/pbs. This reverts revisions r3158, r3140, r3075, r2977, r2674, r2625, r2621, r2529, r2528, r2525, r2524, r2519, r2517, r2516, r2507, r2499. (in conjunction with Tron)
Darkvater
parents:
2899
diff
changeset
|
1768 |
* room for PBS. Now in version 21 move it back :P. */ |
8f1aa489701f
(svn r3472) - [PBS] Remove from trunk. Anyone interested can still find it in branch/pbs. This reverts revisions r3158, r3140, r3075, r2977, r2674, r2625, r2621, r2529, r2528, r2525, r2524, r2519, r2517, r2516, r2507, r2499. (in conjunction with Tron)
Darkvater
parents:
2899
diff
changeset
|
1769 |
if (CheckSavegameVersion(21) && !CheckSavegameVersion(15)) { |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1770 |
for (TileIndex t = 0; t < map_size; t++) { |
5958 | 1771 |
switch (GetTileType(t)) { |
1772 |
case MP_RAILWAY: |
|
1773 |
if (HasSignals(t)) { |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1774 |
/* convert PBS signals to combo-signals */ |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8418
diff
changeset
|
1775 |
if (HasBit(_m[t].m2, 2)) SetSignalType(t, TRACK_X, SIGTYPE_COMBO); |
2916
8f1aa489701f
(svn r3472) - [PBS] Remove from trunk. Anyone interested can still find it in branch/pbs. This reverts revisions r3158, r3140, r3075, r2977, r2674, r2625, r2621, r2529, r2528, r2525, r2524, r2519, r2517, r2516, r2507, r2499. (in conjunction with Tron)
Darkvater
parents:
2899
diff
changeset
|
1776 |
|
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1777 |
/* move the signal variant back */ |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8418
diff
changeset
|
1778 |
SetSignalVariant(t, TRACK_X, HasBit(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC); |
8425
72a71d480c5f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
8424
diff
changeset
|
1779 |
ClrBit(_m[t].m2, 3); |
5958 | 1780 |
} |
1781 |
||
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1782 |
/* Clear PBS reservation on track */ |
5958 | 1783 |
if (!IsTileDepotType(t, TRANSPORT_RAIL)) { |
1784 |
SB(_m[t].m4, 4, 4, 0); |
|
1785 |
} else { |
|
8425
72a71d480c5f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
8424
diff
changeset
|
1786 |
ClrBit(_m[t].m3, 6); |
5958 | 1787 |
} |
1788 |
break; |
|
1789 |
||
7866
e19fda04e8d3
(svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents:
7768
diff
changeset
|
1790 |
case MP_ROAD: /* Clear PBS reservation on crossing */ |
8425
72a71d480c5f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
8424
diff
changeset
|
1791 |
if (IsLevelCrossing(t)) ClrBit(_m[t].m5, 0); |
5958 | 1792 |
break; |
1793 |
||
6677
0578c2e31ed1
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6659
diff
changeset
|
1794 |
case MP_STATION: /* Clear PBS reservation on station */ |
8425
72a71d480c5f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
8424
diff
changeset
|
1795 |
ClrBit(_m[t].m3, 6); |
5958 | 1796 |
break; |
2916
8f1aa489701f
(svn r3472) - [PBS] Remove from trunk. Anyone interested can still find it in branch/pbs. This reverts revisions r3158, r3140, r3075, r2977, r2674, r2625, r2621, r2529, r2528, r2525, r2524, r2519, r2517, r2516, r2507, r2499. (in conjunction with Tron)
Darkvater
parents:
2899
diff
changeset
|
1797 |
|
5958 | 1798 |
default: break; |
1799 |
} |
|
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1800 |
} |
2916
8f1aa489701f
(svn r3472) - [PBS] Remove from trunk. Anyone interested can still find it in branch/pbs. This reverts revisions r3158, r3140, r3075, r2977, r2674, r2625, r2621, r2529, r2528, r2525, r2524, r2519, r2517, r2516, r2507, r2499. (in conjunction with Tron)
Darkvater
parents:
2899
diff
changeset
|
1801 |
} |
8f1aa489701f
(svn r3472) - [PBS] Remove from trunk. Anyone interested can still find it in branch/pbs. This reverts revisions r3158, r3140, r3075, r2977, r2674, r2625, r2621, r2529, r2528, r2525, r2524, r2519, r2517, r2516, r2507, r2499. (in conjunction with Tron)
Darkvater
parents:
2899
diff
changeset
|
1802 |
|
3121
2e50f731567a
(svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents:
3075
diff
changeset
|
1803 |
if (CheckSavegameVersion(22)) UpdatePatches(); |
2e50f731567a
(svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents:
3075
diff
changeset
|
1804 |
|
3431 | 1805 |
if (CheckSavegameVersion(25)) { |
1806 |
Vehicle *v; |
|
1807 |
FOR_ALL_VEHICLES(v) { |
|
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6583
diff
changeset
|
1808 |
if (v->type == VEH_ROAD) { |
3431 | 1809 |
v->vehstatus &= ~0x40; |
1810 |
v->u.road.slot = NULL; |
|
1811 |
v->u.road.slot_age = 0; |
|
1812 |
} |
|
1813 |
} |
|
5928
d57921d78ee6
(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
parents:
5910
diff
changeset
|
1814 |
} else { |
d57921d78ee6
(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
parents:
5910
diff
changeset
|
1815 |
Vehicle *v; |
d57921d78ee6
(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
parents:
5910
diff
changeset
|
1816 |
FOR_ALL_VEHICLES(v) { |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6583
diff
changeset
|
1817 |
if (v->type == VEH_ROAD && v->u.road.slot != NULL) v->u.road.slot->num_vehicles++; |
5928
d57921d78ee6
(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
parents:
5910
diff
changeset
|
1818 |
} |
3431 | 1819 |
} |
1820 |
||
3580
607e4245d024
(svn r4466) -Fix: (FS#71) Game no longer crashes when the last vehicle serving a station has been deleted.
celestar
parents:
3558
diff
changeset
|
1821 |
if (CheckSavegameVersion(26)) { |
607e4245d024
(svn r4466) -Fix: (FS#71) Game no longer crashes when the last vehicle serving a station has been deleted.
celestar
parents:
3558
diff
changeset
|
1822 |
Station *st; |
607e4245d024
(svn r4466) -Fix: (FS#71) Game no longer crashes when the last vehicle serving a station has been deleted.
celestar
parents:
3558
diff
changeset
|
1823 |
FOR_ALL_STATIONS(st) { |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6583
diff
changeset
|
1824 |
st->last_vehicle_type = VEH_INVALID; |
3580
607e4245d024
(svn r4466) -Fix: (FS#71) Game no longer crashes when the last vehicle serving a station has been deleted.
celestar
parents:
3558
diff
changeset
|
1825 |
} |
607e4245d024
(svn r4466) -Fix: (FS#71) Game no longer crashes when the last vehicle serving a station has been deleted.
celestar
parents:
3558
diff
changeset
|
1826 |
} |
607e4245d024
(svn r4466) -Fix: (FS#71) Game no longer crashes when the last vehicle serving a station has been deleted.
celestar
parents:
3558
diff
changeset
|
1827 |
|
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3891
diff
changeset
|
1828 |
YapfNotifyTrackLayoutChange(INVALID_TILE, INVALID_TRACK); |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3891
diff
changeset
|
1829 |
|
4603
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4574
diff
changeset
|
1830 |
if (CheckSavegameVersion(34)) FOR_ALL_PLAYERS(p) ResetPlayerLivery(p); |
3ccd4ee0a2e2
(svn r6455) - Feature: Add 2cc (two company colours) livery schemes. This replaces the original colour selection window and bumps the saveload version. Liveries are supported for all vehicles, not just those with 2cc support. Thanks to lakie for GUI inspiration.
peter1138
parents:
4574
diff
changeset
|
1831 |
|
7181
f966d75af3a6
(svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents:
7157
diff
changeset
|
1832 |
FOR_ALL_PLAYERS(p) { |
f966d75af3a6
(svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents:
7157
diff
changeset
|
1833 |
p->avail_railtypes = GetPlayerRailtypes(p->index); |
f966d75af3a6
(svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents:
7157
diff
changeset
|
1834 |
p->avail_roadtypes = GetPlayerRoadtypes(p->index); |
f966d75af3a6
(svn r9917) -Codechange: prepare some more areas for more road types.
rubidium
parents:
7157
diff
changeset
|
1835 |
} |
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
2100
diff
changeset
|
1836 |
|
3765
e057e2b740d4
(svn r4757) - Newstations: add saveload support for custom station speclists
peter1138
parents:
3678
diff
changeset
|
1837 |
if (!CheckSavegameVersion(27)) AfterLoadStations(); |
e057e2b740d4
(svn r4757) - Newstations: add saveload support for custom station speclists
peter1138
parents:
3678
diff
changeset
|
1838 |
|
4574
497540b4a75f
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents:
4549
diff
changeset
|
1839 |
{ |
497540b4a75f
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents:
4549
diff
changeset
|
1840 |
/* Set up the engine count for all players */ |
497540b4a75f
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents:
4549
diff
changeset
|
1841 |
Player *players[MAX_PLAYERS]; |
497540b4a75f
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents:
4549
diff
changeset
|
1842 |
const Vehicle *v; |
497540b4a75f
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents:
4549
diff
changeset
|
1843 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1844 |
for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) players[i] = GetPlayer(i); |
4574
497540b4a75f
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents:
4549
diff
changeset
|
1845 |
|
497540b4a75f
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents:
4549
diff
changeset
|
1846 |
FOR_ALL_VEHICLES(v) { |
497540b4a75f
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents:
4549
diff
changeset
|
1847 |
if (!IsEngineCountable(v)) continue; |
497540b4a75f
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents:
4549
diff
changeset
|
1848 |
players[v->owner]->num_engines[v->engine_type]++; |
497540b4a75f
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents:
4549
diff
changeset
|
1849 |
} |
497540b4a75f
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents:
4549
diff
changeset
|
1850 |
} |
497540b4a75f
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents:
4549
diff
changeset
|
1851 |
|
4326
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1852 |
/* Time starts at 0 instead of 1920. |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1853 |
* Account for this in older games by adding an offset */ |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1854 |
if (CheckSavegameVersion(31)) { |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1855 |
Station *st; |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1856 |
Waypoint *wp; |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1857 |
Engine *e; |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1858 |
Player *player; |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1859 |
Industry *i; |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1860 |
Vehicle *v; |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1861 |
|
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1862 |
_date += DAYS_TILL_ORIGINAL_BASE_YEAR; |
4383
3dcf52b1efd9
(svn r6136) -Fix: _cur_year wasn't converting when reading pre-31 savegames, causing nasty desyncs
truelight
parents:
4349
diff
changeset
|
1863 |
_cur_year += ORIGINAL_BASE_YEAR; |
4326
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1864 |
|
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1865 |
FOR_ALL_STATIONS(st) st->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR; |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1866 |
FOR_ALL_WAYPOINTS(wp) wp->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR; |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1867 |
FOR_ALL_ENGINES(e) e->intro_date += DAYS_TILL_ORIGINAL_BASE_YEAR; |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1868 |
FOR_ALL_PLAYERS(player) player->inaugurated_year += ORIGINAL_BASE_YEAR; |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1869 |
FOR_ALL_INDUSTRIES(i) i->last_prod_year += ORIGINAL_BASE_YEAR; |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1870 |
|
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1871 |
FOR_ALL_VEHICLES(v) { |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1872 |
v->date_of_last_service += DAYS_TILL_ORIGINAL_BASE_YEAR; |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1873 |
v->build_year += ORIGINAL_BASE_YEAR; |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1874 |
} |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1875 |
} |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1876 |
|
4328
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1877 |
/* From 32 on we save the industry who made the farmland. |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1878 |
* To give this prettyness to old savegames, we remove all farmfields and |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1879 |
* plant new ones. */ |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1880 |
if (CheckSavegameVersion(32)) { |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1881 |
Industry *i; |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1882 |
|
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1883 |
for (TileIndex t = 0; t < map_size; t++) { |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1884 |
if (IsTileType(t, MP_CLEAR) && IsClearGround(t, CLEAR_FIELDS)) { |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1885 |
MakeClear(t, CLEAR_GRASS, 3); |
4328
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1886 |
} |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1887 |
} |
4328
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1888 |
|
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1889 |
FOR_ALL_INDUSTRIES(i) { |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1890 |
uint j; |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1891 |
|
7253
18dca03d0c67
(svn r9992) -Codechange: Remove some hardcoded references to Industry IDs.
belugas
parents:
7234
diff
changeset
|
1892 |
if (GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_PLANT_ON_BUILT) { |
4328
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1893 |
for (j = 0; j != 50; j++) PlantRandomFarmField(i); |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1894 |
} |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1895 |
} |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1896 |
} |
23dd79414386
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1897 |
|
4712
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1898 |
/* Setting no refit flags to all orders in savegames from before refit in orders were added */ |
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1899 |
if (CheckSavegameVersion(36)) { |
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1900 |
Order *order; |
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1901 |
Vehicle *v; |
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1902 |
|
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1903 |
FOR_ALL_ORDERS(order) { |
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1904 |
order->refit_cargo = CT_NO_REFIT; |
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1905 |
order->refit_subtype = CT_NO_REFIT; |
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1906 |
} |
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1907 |
|
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1908 |
FOR_ALL_VEHICLES(v) { |
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1909 |
v->current_order.refit_cargo = CT_NO_REFIT; |
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1910 |
v->current_order.refit_subtype = CT_NO_REFIT; |
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1911 |
} |
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1912 |
} |
273ec3b182bf
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4661
diff
changeset
|
1913 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5024
diff
changeset
|
1914 |
if (CheckSavegameVersion(37)) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5024
diff
changeset
|
1915 |
ConvertNameArray(); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5024
diff
changeset
|
1916 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5024
diff
changeset
|
1917 |
|
5314
021dbca1d6da
(svn r7470) -Codechange: Leave elrails enabled after loading old (pre-optional) and very old (pre-elrails) games. Let the user manually disable if if undesired.
Darkvater
parents:
5313
diff
changeset
|
1918 |
/* from version 38 we have optional elrails, since we cannot know the |
021dbca1d6da
(svn r7470) -Codechange: Leave elrails enabled after loading old (pre-optional) and very old (pre-elrails) games. Let the user manually disable if if undesired.
Darkvater
parents:
5313
diff
changeset
|
1919 |
* preference of a user, let elrails enabled; it can be disabled manually */ |
6099 | 1920 |
if (CheckSavegameVersion(38)) _patches.disable_elrails = false; |
1921 |
/* do the same as when elrails were enabled/disabled manually just now */ |
|
1922 |
SettingsDisableElrail(_patches.disable_elrails); |
|
7560
f7b5ab184882
(svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium
parents:
7554
diff
changeset
|
1923 |
SetDefaultRailGui(); |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5108
diff
changeset
|
1924 |
|
6659
9e786755ed61
(svn r9316) -Fix (r9315): Bump the savegame version for the newhouses merge.
maedhros
parents:
6658
diff
changeset
|
1925 |
/* From version 53, the map array was changed for house tiles to allow |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1926 |
* space for newhouses grf features. A new byte, m7, was also added. */ |
6659
9e786755ed61
(svn r9316) -Fix (r9315): Bump the savegame version for the newhouses merge.
maedhros
parents:
6658
diff
changeset
|
1927 |
if (CheckSavegameVersion(53)) { |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1928 |
for (TileIndex t = 0; t < map_size; t++) { |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1929 |
if (IsTileType(t, MP_HOUSE)) { |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1930 |
if (GB(_m[t].m3, 6, 2) != TOWN_HOUSE_COMPLETED) { |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1931 |
/* Move the construction stage from m3[7..6] to m5[5..4]. |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1932 |
* The construction counter does not have to move. */ |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1933 |
SB(_m[t].m5, 3, 2, GB(_m[t].m3, 6, 2)); |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1934 |
SB(_m[t].m3, 6, 2, 0); |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1935 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1936 |
/* The "house is completed" bit is now in m6[2]. */ |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1937 |
SetHouseCompleted(t, false); |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1938 |
} else { |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1939 |
/* The "lift has destination" bit has been moved from |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1940 |
* m5[7] to m7[0]. */ |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8418
diff
changeset
|
1941 |
SB(_me[t].m7, 0, 1, HasBit(_m[t].m5, 7)); |
8425
72a71d480c5f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
8424
diff
changeset
|
1942 |
ClrBit(_m[t].m5, 7); |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1943 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1944 |
/* The "lift is moving" bit has been removed, as it does |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1945 |
* the same job as the "lift has destination" bit. */ |
8425
72a71d480c5f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
8424
diff
changeset
|
1946 |
ClrBit(_m[t].m1, 7); |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1947 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1948 |
/* The position of the lift goes from m1[7..0] to m6[7..2], |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1949 |
* making m1 totally free, now. The lift position does not |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1950 |
* have to be a full byte since the maximum value is 36. */ |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1951 |
SetLiftPosition(t, GB(_m[t].m1, 0, 6 )); |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1952 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1953 |
_m[t].m1 = 0; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1954 |
_m[t].m3 = 0; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1955 |
SetHouseCompleted(t, true); |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1956 |
} |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1957 |
} |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1958 |
} |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1959 |
} |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1960 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1961 |
/* Count the buildings after updating the map array. */ |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1962 |
AfterLoadCountBuildings(); |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
1963 |
|
5687
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1964 |
if (CheckSavegameVersion(43)) { |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1965 |
for (TileIndex t = 0; t < map_size; t++) { |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1966 |
if (IsTileType(t, MP_INDUSTRY)) { |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1967 |
switch (GetIndustryGfx(t)) { |
5687
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1968 |
case GFX_POWERPLANT_SPARKS: |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1969 |
SetIndustryAnimationState(t, GB(_m[t].m1, 2, 5)); |
5687
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1970 |
break; |
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1971 |
|
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1972 |
case GFX_OILWELL_ANIMATED_1: |
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1973 |
case GFX_OILWELL_ANIMATED_2: |
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1974 |
case GFX_OILWELL_ANIMATED_3: |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1975 |
SetIndustryAnimationState(t, GB(_m[t].m1, 0, 2)); |
5687
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1976 |
break; |
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1977 |
|
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1978 |
case GFX_COAL_MINE_TOWER_ANIMATED: |
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1979 |
case GFX_COPPER_MINE_TOWER_ANIMATED: |
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1980 |
case GFX_GOLD_MINE_TOWER_ANIMATED: |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1981 |
SetIndustryAnimationState(t, _m[t].m1); |
5687
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1982 |
break; |
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1983 |
|
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1984 |
default: /* No animation states to change */ |
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1985 |
break; |
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1986 |
} |
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1987 |
} |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1988 |
} |
5687
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1989 |
} |
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
1990 |
|
5934
9f91cc4e2b17
(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
parents:
5928
diff
changeset
|
1991 |
if (CheckSavegameVersion(44)) { |
9f91cc4e2b17
(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
parents:
5928
diff
changeset
|
1992 |
Vehicle *v; |
9f91cc4e2b17
(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
parents:
5928
diff
changeset
|
1993 |
/* If we remove a station while cargo from it is still enroute, payment calculation will assume |
7506
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
1994 |
* 0, 0 to be the source of the cargo, resulting in very high payments usually. v->source_xy |
5934
9f91cc4e2b17
(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
parents:
5928
diff
changeset
|
1995 |
* stores the coordinates, preserving them even if the station is removed. However, if a game is loaded |
7506
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
1996 |
* where this situation exists, the cargo-source information is lost. in this case, we set the source |
5934
9f91cc4e2b17
(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
parents:
5928
diff
changeset
|
1997 |
* to the current tile of the vehicle to prevent excessive profits |
9f91cc4e2b17
(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
parents:
5928
diff
changeset
|
1998 |
*/ |
9f91cc4e2b17
(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
parents:
5928
diff
changeset
|
1999 |
FOR_ALL_VEHICLES(v) { |
7506
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2000 |
const CargoList::List *packets = v->cargo.Packets(); |
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2001 |
for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) { |
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2002 |
CargoPacket *cp = *it; |
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2003 |
cp->source_xy = IsValidStationID(cp->source) ? GetStation(cp->source)->xy : v->tile; |
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2004 |
cp->loaded_at_xy = cp->source_xy; |
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2005 |
} |
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2006 |
v->cargo.InvalidateCache(); |
5934
9f91cc4e2b17
(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
parents:
5928
diff
changeset
|
2007 |
} |
6630
4fa4f6d883ba
(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
parents:
6585
diff
changeset
|
2008 |
|
4fa4f6d883ba
(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
parents:
6585
diff
changeset
|
2009 |
/* Store position of the station where the goods come from, so there |
4fa4f6d883ba
(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
parents:
6585
diff
changeset
|
2010 |
* are no very high payments when stations get removed. However, if the |
4fa4f6d883ba
(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
parents:
6585
diff
changeset
|
2011 |
* station where the goods came from is already removed, the source |
4fa4f6d883ba
(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
parents:
6585
diff
changeset
|
2012 |
* information is lost. In that case we set it to the position of this |
4fa4f6d883ba
(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
parents:
6585
diff
changeset
|
2013 |
* station */ |
4fa4f6d883ba
(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
parents:
6585
diff
changeset
|
2014 |
Station *st; |
4fa4f6d883ba
(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
parents:
6585
diff
changeset
|
2015 |
FOR_ALL_STATIONS(st) { |
4fa4f6d883ba
(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
parents:
6585
diff
changeset
|
2016 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
4fa4f6d883ba
(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
parents:
6585
diff
changeset
|
2017 |
GoodsEntry *ge = &st->goods[c]; |
4fa4f6d883ba
(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
parents:
6585
diff
changeset
|
2018 |
|
7506
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2019 |
const CargoList::List *packets = ge->cargo.Packets(); |
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2020 |
for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) { |
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2021 |
CargoPacket *cp = *it; |
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2022 |
cp->source_xy = IsValidStationID(cp->source) ? GetStation(cp->source)->xy : st->xy; |
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2023 |
cp->loaded_at_xy = cp->source_xy; |
6630
4fa4f6d883ba
(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
parents:
6585
diff
changeset
|
2024 |
} |
4fa4f6d883ba
(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
parents:
6585
diff
changeset
|
2025 |
} |
4fa4f6d883ba
(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
parents:
6585
diff
changeset
|
2026 |
} |
5934
9f91cc4e2b17
(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
parents:
5928
diff
changeset
|
2027 |
} |
9f91cc4e2b17
(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
parents:
5928
diff
changeset
|
2028 |
|
6139
e80b90da75e5
(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
parents:
6137
diff
changeset
|
2029 |
if (CheckSavegameVersion(45)) { |
e80b90da75e5
(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
parents:
6137
diff
changeset
|
2030 |
Vehicle *v; |
e80b90da75e5
(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
parents:
6137
diff
changeset
|
2031 |
/* Originally just the fact that some cargo had been paid for was |
e80b90da75e5
(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
parents:
6137
diff
changeset
|
2032 |
* stored to stop people cheating and cashing in several times. This |
e80b90da75e5
(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
parents:
6137
diff
changeset
|
2033 |
* wasn't enough though as it was cleared when the vehicle started |
e80b90da75e5
(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
parents:
6137
diff
changeset
|
2034 |
* loading again, even if it didn't actually load anything, so now the |
e80b90da75e5
(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
parents:
6137
diff
changeset
|
2035 |
* amount of cargo that has been paid for is stored. */ |
e80b90da75e5
(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
parents:
6137
diff
changeset
|
2036 |
FOR_ALL_VEHICLES(v) { |
7506
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2037 |
const CargoList::List *packets = v->cargo.Packets(); |
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2038 |
for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) { |
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2039 |
CargoPacket *cp = *it; |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8418
diff
changeset
|
2040 |
cp->paid_for = HasBit(v->vehicle_flags, 2); |
6139
e80b90da75e5
(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
parents:
6137
diff
changeset
|
2041 |
} |
8425
72a71d480c5f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
8424
diff
changeset
|
2042 |
ClrBit(v->vehicle_flags, 2); |
7506
e52d89f5c7c1
(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
parents:
7433
diff
changeset
|
2043 |
v->cargo.InvalidateCache(); |
6139
e80b90da75e5
(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
parents:
6137
diff
changeset
|
2044 |
} |
e80b90da75e5
(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
parents:
6137
diff
changeset
|
2045 |
} |
e80b90da75e5
(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
parents:
6137
diff
changeset
|
2046 |
|
6312
eeb950ae2a1b
(svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium
parents:
6228
diff
changeset
|
2047 |
/* Buoys do now store the owner of the previous water tile, which can never |
eeb950ae2a1b
(svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium
parents:
6228
diff
changeset
|
2048 |
* be OWNER_NONE. So replace OWNER_NONE with OWNER_WATER. */ |
eeb950ae2a1b
(svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium
parents:
6228
diff
changeset
|
2049 |
if (CheckSavegameVersion(46)) { |
eeb950ae2a1b
(svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium
parents:
6228
diff
changeset
|
2050 |
Station *st; |
eeb950ae2a1b
(svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium
parents:
6228
diff
changeset
|
2051 |
FOR_ALL_STATIONS(st) { |
8284
7e3f75c6e824
(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
parents:
8236
diff
changeset
|
2052 |
if (st->IsBuoy() && IsTileOwner(st->xy, OWNER_NONE) && TileHeight(st->xy) == 0) SetTileOwner(st->xy, OWNER_WATER); |
6312
eeb950ae2a1b
(svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium
parents:
6228
diff
changeset
|
2053 |
} |
eeb950ae2a1b
(svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium
parents:
6228
diff
changeset
|
2054 |
} |
eeb950ae2a1b
(svn r8689) -Fix [FS#613] (r8619): crash when an old savegame had buoys on the northern edge of the map.
rubidium
parents:
6228
diff
changeset
|
2055 |
|
6519
367d6f96e23f
(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
parents:
6516
diff
changeset
|
2056 |
if (CheckSavegameVersion(50)) { |
367d6f96e23f
(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
parents:
6516
diff
changeset
|
2057 |
Vehicle *v; |
367d6f96e23f
(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
parents:
6516
diff
changeset
|
2058 |
/* Aircraft units changed from 8 mph to 1 km/h */ |
367d6f96e23f
(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
parents:
6516
diff
changeset
|
2059 |
FOR_ALL_VEHICLES(v) { |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6583
diff
changeset
|
2060 |
if (v->type == VEH_AIRCRAFT && v->subtype <= AIR_AIRCRAFT) { |
6519
367d6f96e23f
(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
parents:
6516
diff
changeset
|
2061 |
const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type); |
367d6f96e23f
(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
parents:
6516
diff
changeset
|
2062 |
v->cur_speed *= 129; |
367d6f96e23f
(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
parents:
6516
diff
changeset
|
2063 |
v->cur_speed /= 10; |
367d6f96e23f
(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
parents:
6516
diff
changeset
|
2064 |
v->max_speed = avi->max_speed; |
367d6f96e23f
(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
parents:
6516
diff
changeset
|
2065 |
v->acceleration = avi->acceleration; |
367d6f96e23f
(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
parents:
6516
diff
changeset
|
2066 |
} |
367d6f96e23f
(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
parents:
6516
diff
changeset
|
2067 |
} |
367d6f96e23f
(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
parents:
6516
diff
changeset
|
2068 |
} |
367d6f96e23f
(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
parents:
6516
diff
changeset
|
2069 |
|
6516
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6501
diff
changeset
|
2070 |
if (CheckSavegameVersion(49)) FOR_ALL_PLAYERS(p) p->face = ConvertFromOldPlayerFace(p->face); |
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6501
diff
changeset
|
2071 |
|
6583
82012e77b10c
(svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents:
6573
diff
changeset
|
2072 |
if (CheckSavegameVersion(52)) { |
82012e77b10c
(svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents:
6573
diff
changeset
|
2073 |
for (TileIndex t = 0; t < map_size; t++) { |
82012e77b10c
(svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents:
6573
diff
changeset
|
2074 |
if (IsStatueTile(t)) { |
82012e77b10c
(svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents:
6573
diff
changeset
|
2075 |
_m[t].m2 = CalcClosestTownFromTile(t, (uint)-1)->index; |
82012e77b10c
(svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents:
6573
diff
changeset
|
2076 |
} |
82012e77b10c
(svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents:
6573
diff
changeset
|
2077 |
} |
82012e77b10c
(svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents:
6573
diff
changeset
|
2078 |
} |
82012e77b10c
(svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
truelight
parents:
6573
diff
changeset
|
2079 |
|
6982
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6949
diff
changeset
|
2080 |
/* A patch option containing the proportion of towns that grow twice as |
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6949
diff
changeset
|
2081 |
* fast was added in version 54. From version 56 this is now saved in the |
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6949
diff
changeset
|
2082 |
* town as cities can be built specifically in the scenario editor. */ |
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6949
diff
changeset
|
2083 |
if (CheckSavegameVersion(56)) { |
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6949
diff
changeset
|
2084 |
Town *t; |
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6949
diff
changeset
|
2085 |
|
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6949
diff
changeset
|
2086 |
FOR_ALL_TOWNS(t) { |
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6949
diff
changeset
|
2087 |
if (_patches.larger_towns != 0 && (t->index % _patches.larger_towns) == 0) { |
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6949
diff
changeset
|
2088 |
t->larger_town = true; |
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6949
diff
changeset
|
2089 |
} |
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6949
diff
changeset
|
2090 |
} |
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6949
diff
changeset
|
2091 |
} |
c414fad6c440
(svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents:
6949
diff
changeset
|
2092 |
|
6996
99dd61b18d69
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium
parents:
6987
diff
changeset
|
2093 |
if (CheckSavegameVersion(57)) { |
99dd61b18d69
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium
parents:
6987
diff
changeset
|
2094 |
Vehicle *v; |
99dd61b18d69
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium
parents:
6987
diff
changeset
|
2095 |
/* Added a FIFO queue of vehicles loading at stations */ |
99dd61b18d69
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium
parents:
6987
diff
changeset
|
2096 |
FOR_ALL_VEHICLES(v) { |
99dd61b18d69
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium
parents:
6987
diff
changeset
|
2097 |
if ((v->type != VEH_TRAIN || IsFrontEngine(v)) && // for all locs |
99dd61b18d69
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium
parents:
6987
diff
changeset
|
2098 |
!(v->vehstatus & (VS_STOPPED | VS_CRASHED)) && // not stopped or crashed |
99dd61b18d69
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium
parents:
6987
diff
changeset
|
2099 |
v->current_order.type == OT_LOADING) { // loading |
99dd61b18d69
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium
parents:
6987
diff
changeset
|
2100 |
GetStation(v->last_station_visited)->loading_vehicles.push_back(v); |
7115
ef36e40739c9
(svn r9839) -Fix: vehicles in old savegames could leave the station because the changed loading algorithm thought it was already finished.
rubidium
parents:
7087
diff
changeset
|
2101 |
|
ef36e40739c9
(svn r9839) -Fix: vehicles in old savegames could leave the station because the changed loading algorithm thought it was already finished.
rubidium
parents:
7087
diff
changeset
|
2102 |
/* The loading finished flag is *only* set when actually completely |
ef36e40739c9
(svn r9839) -Fix: vehicles in old savegames could leave the station because the changed loading algorithm thought it was already finished.
rubidium
parents:
7087
diff
changeset
|
2103 |
* finished. Because the vehicle is loading, it is not finished. */ |
8425
72a71d480c5f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
8424
diff
changeset
|
2104 |
ClrBit(v->vehicle_flags, VF_LOADING_FINISHED); |
6996
99dd61b18d69
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium
parents:
6987
diff
changeset
|
2105 |
} |
99dd61b18d69
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium
parents:
6987
diff
changeset
|
2106 |
} |
7971
c1b1fa49885a
(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
parents:
7910
diff
changeset
|
2107 |
} else if (CheckSavegameVersion(59)) { |
c1b1fa49885a
(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
parents:
7910
diff
changeset
|
2108 |
/* For some reason non-loading vehicles could be in the station's loading vehicle list */ |
c1b1fa49885a
(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
parents:
7910
diff
changeset
|
2109 |
|
c1b1fa49885a
(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
parents:
7910
diff
changeset
|
2110 |
Station *st; |
c1b1fa49885a
(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
parents:
7910
diff
changeset
|
2111 |
FOR_ALL_STATIONS(st) { |
c1b1fa49885a
(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
parents:
7910
diff
changeset
|
2112 |
std::list<Vehicle *>::iterator iter; |
c1b1fa49885a
(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
parents:
7910
diff
changeset
|
2113 |
for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end();) { |
c1b1fa49885a
(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
parents:
7910
diff
changeset
|
2114 |
Vehicle *v = *iter; |
c1b1fa49885a
(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
parents:
7910
diff
changeset
|
2115 |
iter++; |
c1b1fa49885a
(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
parents:
7910
diff
changeset
|
2116 |
if (v->current_order.type != OT_LOADING) st->loading_vehicles.remove(v); |
c1b1fa49885a
(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
parents:
7910
diff
changeset
|
2117 |
} |
c1b1fa49885a
(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
parents:
7910
diff
changeset
|
2118 |
} |
6996
99dd61b18d69
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium
parents:
6987
diff
changeset
|
2119 |
} |
99dd61b18d69
(svn r9683) -Fix [FS#423]: improved loading does not use a huge amount of processing power anymore when having a lot of trains.
rubidium
parents:
6987
diff
changeset
|
2120 |
|
7056
b4f146586c97
(svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents:
6996
diff
changeset
|
2121 |
if (CheckSavegameVersion(58)) { |
b4f146586c97
(svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents:
6996
diff
changeset
|
2122 |
/* patch difficulty number_industries other then zero get bumped to +1 |
b4f146586c97
(svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents:
6996
diff
changeset
|
2123 |
* since a new option (very low at position1) has been added */ |
b4f146586c97
(svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents:
6996
diff
changeset
|
2124 |
if (_opt.diff.number_industries > 0) { |
b4f146586c97
(svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents:
6996
diff
changeset
|
2125 |
_opt.diff.number_industries++; |
b4f146586c97
(svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents:
6996
diff
changeset
|
2126 |
} |
b4f146586c97
(svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents:
6996
diff
changeset
|
2127 |
|
b4f146586c97
(svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents:
6996
diff
changeset
|
2128 |
/* Same goes for number of towns, although no test is needed, just an increment */ |
b4f146586c97
(svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents:
6996
diff
changeset
|
2129 |
_opt.diff.number_towns++; |
b4f146586c97
(svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents:
6996
diff
changeset
|
2130 |
} |
b4f146586c97
(svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents:
6996
diff
changeset
|
2131 |
|
7266
4b75e7b9fa91
(svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents:
7253
diff
changeset
|
2132 |
if (CheckSavegameVersion(64)) { |
4b75e7b9fa91
(svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents:
7253
diff
changeset
|
2133 |
/* copy the signal type/variant and move signal states bits */ |
4b75e7b9fa91
(svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents:
7253
diff
changeset
|
2134 |
for (TileIndex t = 0; t < map_size; t++) { |
4b75e7b9fa91
(svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents:
7253
diff
changeset
|
2135 |
if (IsTileType(t, MP_RAILWAY) && HasSignals(t)) { |
4b75e7b9fa91
(svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents:
7253
diff
changeset
|
2136 |
SetSignalStates(t, GB(_m[t].m2, 4, 4)); |
4b75e7b9fa91
(svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents:
7253
diff
changeset
|
2137 |
SetSignalVariant(t, INVALID_TRACK, GetSignalVariant(t, TRACK_X)); |
4b75e7b9fa91
(svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents:
7253
diff
changeset
|
2138 |
SetSignalType(t, INVALID_TRACK, GetSignalType(t, TRACK_X)); |
8425
72a71d480c5f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
8424
diff
changeset
|
2139 |
ClrBit(_m[t].m2, 7); |
7266
4b75e7b9fa91
(svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents:
7253
diff
changeset
|
2140 |
} |
4b75e7b9fa91
(svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents:
7253
diff
changeset
|
2141 |
} |
4b75e7b9fa91
(svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents:
7253
diff
changeset
|
2142 |
} |
4b75e7b9fa91
(svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents:
7253
diff
changeset
|
2143 |
|
7508
d1c4fa7461c6
(svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium
parents:
7506
diff
changeset
|
2144 |
if (CheckSavegameVersion(69)) { |
d1c4fa7461c6
(svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium
parents:
7506
diff
changeset
|
2145 |
/* In some old savegames a bit was cleared when it should not be cleared */ |
d1c4fa7461c6
(svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium
parents:
7506
diff
changeset
|
2146 |
Vehicle *v; |
d1c4fa7461c6
(svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium
parents:
7506
diff
changeset
|
2147 |
FOR_ALL_VEHICLES(v) { |
d1c4fa7461c6
(svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium
parents:
7506
diff
changeset
|
2148 |
if (v->type == VEH_ROAD && (v->u.road.state == 250 || v->u.road.state == 251)) { |
8427
143b0be22af1
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
8425
diff
changeset
|
2149 |
SetBit(v->u.road.state, RVS_IS_STOPPING); |
7508
d1c4fa7461c6
(svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium
parents:
7506
diff
changeset
|
2150 |
} |
d1c4fa7461c6
(svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium
parents:
7506
diff
changeset
|
2151 |
} |
d1c4fa7461c6
(svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium
parents:
7506
diff
changeset
|
2152 |
} |
d1c4fa7461c6
(svn r10268) -Fix: some old savegames could have the wrong bits unset (follow up of r10147)
rubidium
parents:
7506
diff
changeset
|
2153 |
|
7682
263dbeceba12
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7666
diff
changeset
|
2154 |
if (CheckSavegameVersion(70)) { |
263dbeceba12
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7666
diff
changeset
|
2155 |
/* Added variables to support newindustries */ |
263dbeceba12
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7666
diff
changeset
|
2156 |
Industry *i; |
263dbeceba12
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7666
diff
changeset
|
2157 |
FOR_ALL_INDUSTRIES(i) i->founder = OWNER_NONE; |
263dbeceba12
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7666
diff
changeset
|
2158 |
} |
263dbeceba12
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7666
diff
changeset
|
2159 |
|
8235
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8206
diff
changeset
|
2160 |
/* From version 82, old style canals (above sealevel (0), WATER owner) are no longer supported. |
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8206
diff
changeset
|
2161 |
Replace the owner for those by OWNER_NONE. */ |
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8206
diff
changeset
|
2162 |
if (CheckSavegameVersion(82)) { |
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8206
diff
changeset
|
2163 |
for (TileIndex t = 0; t < map_size; t++) { |
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8206
diff
changeset
|
2164 |
if (IsTileType(t, MP_WATER) && |
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8206
diff
changeset
|
2165 |
GetWaterTileType(t) == WATER_TILE_CLEAR && |
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8206
diff
changeset
|
2166 |
GetTileOwner(t) == OWNER_WATER && |
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8206
diff
changeset
|
2167 |
TileHeight(t) != 0) { |
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8206
diff
changeset
|
2168 |
SetTileOwner(t, OWNER_NONE); |
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8206
diff
changeset
|
2169 |
} |
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8206
diff
changeset
|
2170 |
} |
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8206
diff
changeset
|
2171 |
} |
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8206
diff
changeset
|
2172 |
|
7139
4ae3ab180d05
(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
parents:
7125
diff
changeset
|
2173 |
/* Recalculate */ |
4ae3ab180d05
(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
parents:
7125
diff
changeset
|
2174 |
Group *g; |
4ae3ab180d05
(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
parents:
7125
diff
changeset
|
2175 |
FOR_ALL_GROUPS(g) { |
4ae3ab180d05
(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
parents:
7125
diff
changeset
|
2176 |
const Vehicle *v; |
4ae3ab180d05
(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
parents:
7125
diff
changeset
|
2177 |
FOR_ALL_VEHICLES(v) { |
4ae3ab180d05
(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
parents:
7125
diff
changeset
|
2178 |
if (!IsEngineCountable(v)) continue; |
4ae3ab180d05
(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
parents:
7125
diff
changeset
|
2179 |
|
4ae3ab180d05
(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
parents:
7125
diff
changeset
|
2180 |
if (v->group_id != g->index || v->type != g->vehicle_type || v->owner != g->owner) continue; |
4ae3ab180d05
(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
parents:
7125
diff
changeset
|
2181 |
|
4ae3ab180d05
(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
parents:
7125
diff
changeset
|
2182 |
g->num_engines[v->engine_type]++; |
4ae3ab180d05
(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
parents:
7125
diff
changeset
|
2183 |
} |
4ae3ab180d05
(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
parents:
7125
diff
changeset
|
2184 |
} |
4ae3ab180d05
(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
parents:
7125
diff
changeset
|
2185 |
|
8011
8e95362021d5
(svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium
parents:
7971
diff
changeset
|
2186 |
if (CheckSavegameVersion(74)) { |
8e95362021d5
(svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium
parents:
7971
diff
changeset
|
2187 |
Station *st; |
8e95362021d5
(svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium
parents:
7971
diff
changeset
|
2188 |
FOR_ALL_STATIONS(st) { |
8e95362021d5
(svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium
parents:
7971
diff
changeset
|
2189 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
8e95362021d5
(svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium
parents:
7971
diff
changeset
|
2190 |
st->goods[c].last_speed = 0; |
8427
143b0be22af1
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
8425
diff
changeset
|
2191 |
if (st->goods[c].cargo.Count() != 0) SetBit(st->goods[c].acceptance_pickup, GoodsEntry::PICKUP); |
8011
8e95362021d5
(svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium
parents:
7971
diff
changeset
|
2192 |
} |
8e95362021d5
(svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium
parents:
7971
diff
changeset
|
2193 |
} |
8e95362021d5
(svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium
parents:
7971
diff
changeset
|
2194 |
} |
8e95362021d5
(svn r11030) -Revert r11016, Fix [FS#1178]: the way to determine whether a station should get goods was not done properly.
rubidium
parents:
7971
diff
changeset
|
2195 |
|
8141
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx
parents:
8105
diff
changeset
|
2196 |
if (CheckSavegameVersion(78)) { |
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx
parents:
8105
diff
changeset
|
2197 |
Industry *i; |
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx
parents:
8105
diff
changeset
|
2198 |
uint j; |
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx
parents:
8105
diff
changeset
|
2199 |
FOR_ALL_INDUSTRIES(i) { |
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx
parents:
8105
diff
changeset
|
2200 |
const IndustrySpec *indsp = GetIndustrySpec(i->type); |
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx
parents:
8105
diff
changeset
|
2201 |
for (j = 0; j < lengthof(i->produced_cargo); j++) { |
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx
parents:
8105
diff
changeset
|
2202 |
i->produced_cargo[j] = indsp->produced_cargo[j]; |
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx
parents:
8105
diff
changeset
|
2203 |
} |
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx
parents:
8105
diff
changeset
|
2204 |
for (j = 0; j < lengthof(i->accepts_cargo); j++) { |
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx
parents:
8105
diff
changeset
|
2205 |
i->accepts_cargo[j] = indsp->accepts_cargo[j]; |
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx
parents:
8105
diff
changeset
|
2206 |
} |
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx
parents:
8105
diff
changeset
|
2207 |
} |
c052dc0dc029
(svn r11176) -Revert (r9867): as it is needed for newgrf callbacks 14B and 14C
glx
parents:
8105
diff
changeset
|
2208 |
} |
7139
4ae3ab180d05
(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
parents:
7125
diff
changeset
|
2209 |
|
8206
573a2d359695
(svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight
parents:
8141
diff
changeset
|
2210 |
/* Before version 81, the density of grass was always stored as zero, and |
573a2d359695
(svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight
parents:
8141
diff
changeset
|
2211 |
* grassy trees were always drawn fully grassy. Furthermore, trees on rough |
573a2d359695
(svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight
parents:
8141
diff
changeset
|
2212 |
* land used to have zero density, now they have full density. Therefore, |
573a2d359695
(svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight
parents:
8141
diff
changeset
|
2213 |
* make all grassy/rough land trees have a density of 3. */ |
573a2d359695
(svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight
parents:
8141
diff
changeset
|
2214 |
if (CheckSavegameVersion(81)) { |
573a2d359695
(svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight
parents:
8141
diff
changeset
|
2215 |
for (TileIndex t = 0; t < map_size; t++) { |
573a2d359695
(svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight
parents:
8141
diff
changeset
|
2216 |
if (GetTileType(t) == MP_TREES) { |
573a2d359695
(svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight
parents:
8141
diff
changeset
|
2217 |
TreeGround groundType = GetTreeGround(t); |
573a2d359695
(svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight
parents:
8141
diff
changeset
|
2218 |
if (groundType != TREE_GROUND_SNOW_DESERT) SetTreeGroundDensity(t, groundType, 3); |
573a2d359695
(svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight
parents:
8141
diff
changeset
|
2219 |
} |
573a2d359695
(svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight
parents:
8141
diff
changeset
|
2220 |
} |
573a2d359695
(svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight
parents:
8141
diff
changeset
|
2221 |
} |
573a2d359695
(svn r11244) -Fix: trees can now be planted on bare land without making it grassy (Csaboka)
truelight
parents:
8141
diff
changeset
|
2222 |
|
0 | 2223 |
return true; |
2224 |
} |
|
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2225 |
|
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2226 |
/** Reload all NewGRF files during a running game. This is a cut-down |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2227 |
* version of AfterLoadGame(). |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2228 |
* XXX - We need to reset the vehicle position hash because with a non-empty |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2229 |
* hash AfterLoadVehicles() will loop infinitely. We need AfterLoadVehicles() |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2230 |
* to recalculate vehicle data as some NewGRF vehicle sets could have been |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2231 |
* removed or added and changed statistics */ |
6573 | 2232 |
void ReloadNewGRFData() |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2233 |
{ |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2234 |
/* reload grf data */ |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2235 |
GfxLoadSprites(); |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2236 |
LoadStringWidthTable(); |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2237 |
/* reload vehicles */ |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2238 |
ResetVehiclePosHash(); |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2239 |
AfterLoadVehicles(); |
6522
bf0da9f42953
(svn r8976) -Codechange: Reinitialize all engines after grf files have been reloaded/changed.
Darkvater
parents:
6519
diff
changeset
|
2240 |
StartupEngines(); |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2241 |
/* update station and waypoint graphics */ |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2242 |
AfterLoadWaypoints(); |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2243 |
AfterLoadStations(); |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
2244 |
/* check that house ids are still valid */ |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6643
diff
changeset
|
2245 |
CheckHouseIDs(); |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2246 |
/* redraw the whole screen */ |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2247 |
MarkWholeScreenDirty(); |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2248 |
} |