author | rubidium |
Sun, 06 Apr 2008 23:07:42 +0000 | |
branch | noai |
changeset 9869 | 6404afe43575 |
parent 9837 | c9ec4f82e0d0 |
child 10142 | 56ee7da4ad56 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9505 | 3 |
/** @file openttd.cpp */ |
4 |
||
0 | 5 |
#include "stdafx.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
6 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
7 |
#define VARDEF |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
8 |
#include "variables.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
9 |
#include "network/network_internal.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
10 |
#undef VARDEF |
0 | 11 |
|
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1885
diff
changeset
|
12 |
#include "openttd.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
13 |
|
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
14 |
#include "driver.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
15 |
#include "blitter/factory.hpp" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
16 |
#include "sound/sound_driver.hpp" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
17 |
#include "music/music_driver.hpp" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
18 |
#include "video/video_driver.hpp" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
19 |
#include "ai/ai_factory.hpp" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
20 |
|
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
21 |
#include "fontcache.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
|
22 |
#include "gfxinit.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
23 |
#include "gfx_func.h" |
0 | 24 |
#include "gui.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
25 |
#include "mixer.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
26 |
#include "sound_func.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
27 |
#include "viewport_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
28 |
#include "window_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
29 |
#include "window_gui.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
30 |
#include "zoom_func.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
31 |
|
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
32 |
#include "debug.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
33 |
#include "saveload.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
34 |
#include "landscape.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
35 |
#include "player_func.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
36 |
#include "player_base.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
37 |
#include "command_func.h" |
0 | 38 |
#include "town.h" |
39 |
#include "industry.h" |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
40 |
#include "news_func.h" |
0 | 41 |
#include "fileio.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
42 |
#include "fios.h" |
0 | 43 |
#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
|
44 |
#include "aircraft.h" |
126 | 45 |
#include "console.h" |
430 | 46 |
#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
|
47 |
#include "network/network.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
48 |
#include "signs_base.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
49 |
#include "signs_func.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" |
9429
25b7d020a3a9
(svn r9232) [NoAI] -Fix r9230: incode update about file/dir moving
truelight
parents:
9408
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" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
55 |
#include "settings_func.h" |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
56 |
#include "genworld.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
57 |
#include "player_face.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
58 |
#include "group.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
59 |
#include "strings_func.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
60 |
#include "date_func.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
61 |
#include "vehicle_func.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
62 |
|
9599 | 63 |
#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
|
64 |
#include "newgrf_config.h" |
9476 | 65 |
#include "newgrf_house.h" |
9624 | 66 |
#include "newgrf_commons.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
67 |
#include "newgrf_station.h" |
0 | 68 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
69 |
#include "clear_map.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
70 |
#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
|
71 |
#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
|
72 |
#include "road_map.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
73 |
#include "station_map.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
74 |
#include "town_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
|
75 |
#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
|
76 |
#include "unmovable_map.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
77 |
#include "tunnel_map.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
78 |
#include "bridge_map.h" |
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9826
diff
changeset
|
79 |
#include "water_map.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
80 |
#include "tunnelbridge_map.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
81 |
#include "void_map.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
82 |
#include "water.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
83 |
#include "settings_type.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
|
84 |
|
0 | 85 |
#include <stdarg.h> |
86 |
||
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
87 |
#include "table/strings.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
88 |
|
6573 | 89 |
void CallLandscapeTick(); |
90 |
void IncreaseDate(); |
|
91 |
void DoPaletteAnimations(); |
|
92 |
void MusicLoop(); |
|
93 |
void ResetMusic(); |
|
0 | 94 |
|
95 |
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
|
96 |
extern Player* DoStartupNewPlayer(bool is_ai); |
0 | 97 |
extern void ShowOSErrorBox(const char *buf); |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
98 |
extern void InitializeRailGUI(); |
0 | 99 |
|
1436 | 100 |
/* TODO: usrerror() for errors which are not of an internal nature but |
101 |
* caused by the user, i.e. missing files or fatal configuration errors. |
|
102 |
* Post-0.4.0 since Celestar doesn't want this in SVN before. --pasky */ |
|
103 |
||
4171 | 104 |
void CDECL error(const char *s, ...) |
2639 | 105 |
{ |
0 | 106 |
va_list va; |
107 |
char buf[512]; |
|
2639 | 108 |
|
0 | 109 |
va_start(va, s); |
5170
56c12a62af49
(svn r7280) -Codechange: Replace some sprintf() functions with the safer snprintf() functions
Darkvater
parents:
5166
diff
changeset
|
110 |
vsnprintf(buf, lengthof(buf), s, va); |
0 | 111 |
va_end(va); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
112 |
|
0 | 113 |
ShowOSErrorBox(buf); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
114 |
if (_video_driver != NULL) _video_driver->Stop(); |
0 | 115 |
|
116 |
assert(0); |
|
117 |
exit(1); |
|
118 |
} |
|
119 |
||
120 |
void CDECL ShowInfoF(const char *str, ...) |
|
121 |
{ |
|
122 |
va_list va; |
|
123 |
char buf[1024]; |
|
124 |
va_start(va, str); |
|
5170
56c12a62af49
(svn r7280) -Codechange: Replace some sprintf() functions with the safer snprintf() functions
Darkvater
parents:
5166
diff
changeset
|
125 |
vsnprintf(buf, lengthof(buf), str, va); |
0 | 126 |
va_end(va); |
127 |
ShowInfo(buf); |
|
128 |
} |
|
129 |
||
130 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
131 |
extern const char _openttd_revision[]; |
6573 | 132 |
static void showhelp() |
0 | 133 |
{ |
9467
730cae121ae3
(svn r9305) [NoAI] -Add: option to force-select an AI from the console.
rubidium
parents:
9429
diff
changeset
|
134 |
char buf[8192], *p; |
0 | 135 |
|
5170
56c12a62af49
(svn r7280) -Codechange: Replace some sprintf() functions with the safer snprintf() functions
Darkvater
parents:
5166
diff
changeset
|
136 |
p = buf; |
2831
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
137 |
|
5170
56c12a62af49
(svn r7280) -Codechange: Replace some sprintf() functions with the safer snprintf() functions
Darkvater
parents:
5166
diff
changeset
|
138 |
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
|
139 |
p = strecpy(p, |
2831
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
140 |
"\n" |
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
141 |
"\n" |
0 | 142 |
"Command line options:\n" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
143 |
" -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
|
144 |
" -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
|
145 |
" -m drv = Set music driver (see below)\n" |
9626 | 146 |
" -b drv = Set the blitter to use (see below)\n" |
9467
730cae121ae3
(svn r9305) [NoAI] -Add: option to force-select an AI from the console.
rubidium
parents:
9429
diff
changeset
|
147 |
" -a ai = Force use of specific AI (see below)\n" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
148 |
" -r res = Set resolution (for instance 800x600)\n" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
149 |
" -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
|
150 |
" -t year = Set starting year\n" |
1440
2eb4dd1e0465
(svn r1944) Make --help output for -d at least somewhat useful.
pasky
parents:
1436
diff
changeset
|
151 |
" -d [[fac=]lvl[,...]]= Debug mode\n" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
152 |
" -e = Start Editor\n" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
153 |
" -g [savegame] = Start new/save game immediately\n" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
154 |
" -G seed = Set random seed\n" |
5943
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
155 |
#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
|
156 |
" -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
|
157 |
" -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
|
158 |
" -l ip[:port] = Redirect DEBUG()\n" |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
159 |
#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
|
160 |
" -f = Fork into the background (dedicated only)\n" |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
161 |
#endif |
5943
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
162 |
#endif /* ENABLE_NETWORK */ |
2831
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
163 |
" -i = Force to use the DOS palette\n" |
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
164 |
" (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
|
165 |
" -c config_file = Use 'config_file' instead of 'openttd.cfg'\n" |
9467
730cae121ae3
(svn r9305) [NoAI] -Add: option to force-select an AI from the console.
rubidium
parents:
9429
diff
changeset
|
166 |
" -x = Do not automatically save to config file on exit\n\n", |
5170
56c12a62af49
(svn r7280) -Codechange: Replace some sprintf() functions with the safer snprintf() functions
Darkvater
parents:
5166
diff
changeset
|
167 |
lastof(buf) |
0 | 168 |
); |
169 |
||
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
170 |
/* List the drivers */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
171 |
p = VideoDriverFactoryBase::GetDriversInfo(p, lastof(buf)); |
0 | 172 |
|
9626 | 173 |
/* List the blitters */ |
174 |
p = BlitterFactoryBase::GetBlittersInfo(p, lastof(buf)); |
|
175 |
||
9467
730cae121ae3
(svn r9305) [NoAI] -Add: option to force-select an AI from the console.
rubidium
parents:
9429
diff
changeset
|
176 |
/* We need to initialize the AI, so it finds the AIs */ |
730cae121ae3
(svn r9305) [NoAI] -Add: option to force-select an AI from the console.
rubidium
parents:
9429
diff
changeset
|
177 |
AI_Initialize(); |
730cae121ae3
(svn r9305) [NoAI] -Add: option to force-select an AI from the console.
rubidium
parents:
9429
diff
changeset
|
178 |
p = AIFactoryBase::GetAIConsoleList(p, lastof(buf)); |
730cae121ae3
(svn r9305) [NoAI] -Add: option to force-select an AI from the console.
rubidium
parents:
9429
diff
changeset
|
179 |
AI_Uninitialize(); |
730cae121ae3
(svn r9305) [NoAI] -Add: option to force-select an AI from the console.
rubidium
parents:
9429
diff
changeset
|
180 |
|
5974
7de3ff0166f8
(svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater
parents:
5958
diff
changeset
|
181 |
/* 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
|
182 |
* 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
|
183 |
#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
|
184 |
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
|
185 |
#else |
0 | 186 |
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
|
187 |
#endif |
0 | 188 |
} |
189 |
||
190 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
191 |
struct MyGetOptData { |
0 | 192 |
char *opt; |
193 |
int numleft; |
|
194 |
char **argv; |
|
195 |
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
|
196 |
const char *cont; |
0 | 197 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
198 |
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
|
199 |
{ |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
200 |
opt = NULL; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
201 |
numleft = argc; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
202 |
this->argv = argv; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
203 |
this->options = options; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
204 |
cont = NULL; |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
205 |
} |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
206 |
}; |
0 | 207 |
|
208 |
static int MyGetOpt(MyGetOptData *md) |
|
209 |
{ |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
210 |
const char *s,*r,*t; |
0 | 211 |
|
2639 | 212 |
s = md->cont; |
213 |
if (s != NULL) |
|
0 | 214 |
goto md_continue_here; |
215 |
||
2639 | 216 |
for (;;) { |
217 |
if (--md->numleft < 0) return -1; |
|
0 | 218 |
|
219 |
s = *md->argv++; |
|
220 |
if (*s == '-') { |
|
221 |
md_continue_here:; |
|
222 |
s++; |
|
223 |
if (*s != 0) { |
|
9505 | 224 |
/* Found argument, try to locate it in options. */ |
0 | 225 |
if (*s == ':' || (r = strchr(md->options, *s)) == NULL) { |
9505 | 226 |
/* ERROR! */ |
0 | 227 |
return -2; |
228 |
} |
|
229 |
if (r[1] == ':') { |
|
9505 | 230 |
/* Item wants an argument. Check if the argument follows, or if it comes as a separate arg. */ |
0 | 231 |
if (!*(t = s + 1)) { |
9505 | 232 |
/* It comes as a separate arg. Check if out of args? */ |
0 | 233 |
if (--md->numleft < 0 || *(t = *md->argv) == '-') { |
9505 | 234 |
/* Check if item is optional? */ |
0 | 235 |
if (r[2] != ':') |
236 |
return -2; |
|
237 |
md->numleft++; |
|
238 |
t = NULL; |
|
239 |
} else { |
|
240 |
md->argv++; |
|
241 |
} |
|
242 |
} |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
243 |
md->opt = (char*)t; |
0 | 244 |
md->cont = NULL; |
245 |
return *s; |
|
246 |
} |
|
247 |
md->opt = NULL; |
|
248 |
md->cont = s; |
|
249 |
return *s; |
|
250 |
} |
|
251 |
} else { |
|
9505 | 252 |
/* This is currently not supported. */ |
0 | 253 |
return -2; |
254 |
} |
|
255 |
} |
|
256 |
} |
|
257 |
||
258 |
||
4171 | 259 |
static void ParseResolution(int res[2], const char *s) |
0 | 260 |
{ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
261 |
const char *t = strchr(s, 'x'); |
0 | 262 |
if (t == NULL) { |
263 |
ShowInfoF("Invalid resolution '%s'", s); |
|
264 |
return; |
|
265 |
} |
|
266 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
267 |
res[0] = Clamp(strtoul(s, NULL, 0), 64, MAX_SCREEN_WIDTH); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
268 |
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
|
269 |
} |
0 | 270 |
|
6573 | 271 |
static void InitializeDynamicVariables() |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
272 |
{ |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
273 |
/* 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
|
274 |
_town_sort = NULL; |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
275 |
_industry_sort = NULL; |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
276 |
_industry_mngr.ResetMapping(); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
277 |
_industile_mngr.ResetMapping(); |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
278 |
} |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
279 |
|
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
|
280 |
|
6573 | 281 |
static void UnInitializeGame() |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
282 |
{ |
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
|
283 |
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
|
284 |
|
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
|
285 |
/* 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
|
286 |
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
|
287 |
|
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
|
288 |
/* Uninitialize variables that are allocated dynamically */ |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
289 |
_Town_pool.CleanPool(); |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
290 |
_Industry_pool.CleanPool(); |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
291 |
_Station_pool.CleanPool(); |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
292 |
_Vehicle_pool.CleanPool(); |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
293 |
_Sign_pool.CleanPool(); |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
294 |
_Order_pool.CleanPool(); |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
295 |
_Group_pool.CleanPool(); |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
296 |
_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
|
297 |
|
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
|
298 |
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
|
299 |
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
|
300 |
|
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
|
301 |
free(_config_file); |
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
302 |
} |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
303 |
|
6573 | 304 |
static void LoadIntroGame() |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
305 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
306 |
_game_mode = GM_MENU; |
9574 | 307 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
308 |
_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
|
309 |
ResetGRFConfig(false); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
310 |
|
9505 | 311 |
/* Setup main window */ |
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
312 |
ResetWindowSystem(); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
313 |
SetupColorsAndInitialWindow(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
314 |
|
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
315 |
/* Load the default opening screen savegame */ |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
316 |
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
|
317 |
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
|
318 |
WaitTillGeneratedWorld(); |
921 | 319 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
320 |
|
6557
8381016f71f3
(svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents:
6555
diff
changeset
|
321 |
_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
|
322 |
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
|
323 |
/* 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
|
324 |
_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
|
325 |
_cursor.fix_at = false; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
326 |
MarkWholeScreenDirty(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
327 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
328 |
CheckForMissingGlyphsInLoadedLanguagePack(); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
329 |
|
9505 | 330 |
/* Play main theme */ |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
331 |
if (_music_driver->IsSongPlaying()) ResetMusic(); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
332 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
333 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
334 |
byte _no_scroll; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
335 |
byte _savegame_sort_order; |
2290 | 336 |
#if defined(UNIX) && !defined(__MORPHOS__) |
6573 | 337 |
extern void DedicatedFork(); |
2290 | 338 |
#endif |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
339 |
|
4171 | 340 |
int ttd_main(int argc, char *argv[]) |
0 | 341 |
{ |
342 |
int i; |
|
1010
17470a8e5eb7
(svn r1509) Const correctness and add static where appropriate while touching the lines anyway
tron
parents:
1009
diff
changeset
|
343 |
const char *optformat; |
9626 | 344 |
char musicdriver[32], sounddriver[32], videodriver[32], blitter[32], ai[32]; |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
345 |
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
|
346 |
Year startyear = INVALID_YEAR; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
347 |
uint generation_seed = GENERATE_NEW_SEED; |
5943
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
348 |
bool save_config = true; |
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
349 |
#if defined(ENABLE_NETWORK) |
3058
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
350 |
bool dedicated = false; |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
351 |
bool network = false; |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
352 |
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
|
353 |
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
|
354 |
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
|
355 |
uint16 dedicated_port = 0; |
5943
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
356 |
#endif /* ENABLE_NETWORK */ |
1406
2d5baabe4046
(svn r1910) Move two variables out of variables.h which are only used locally
tron
parents:
1397
diff
changeset
|
357 |
|
9626 | 358 |
musicdriver[0] = sounddriver[0] = videodriver[0] = blitter[0] = ai[0] = '\0'; |
0 | 359 |
|
360 |
_game_mode = GM_MENU; |
|
361 |
_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
|
362 |
_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
|
363 |
_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
|
364 |
_config_file = NULL; |
0 | 365 |
|
9505 | 366 |
/* The last param of the following function means this: |
367 |
* a letter means: it accepts that param (e.g.: -h) |
|
368 |
* a ':' behind it means: it need a param (e.g.: -m<driver>) |
|
369 |
* a '::' behind it means: it can optional have a param (e.g.: -d<debug>) */ |
|
9626 | 370 |
optformat = "m:s:v:b:a: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
|
371 |
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32) |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
372 |
"f" |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
373 |
#endif |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
374 |
; |
770
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
768
diff
changeset
|
375 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
376 |
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
|
377 |
|
0 | 378 |
while ((i = MyGetOpt(&mgo)) != -1) { |
2951 | 379 |
switch (i) { |
0 | 380 |
case 'm': ttd_strlcpy(musicdriver, mgo.opt, sizeof(musicdriver)); break; |
381 |
case 's': ttd_strlcpy(sounddriver, mgo.opt, sizeof(sounddriver)); break; |
|
382 |
case 'v': ttd_strlcpy(videodriver, mgo.opt, sizeof(videodriver)); break; |
|
9626 | 383 |
case 'b': ttd_strlcpy(blitter, mgo.opt, sizeof(blitter)); break; |
9467
730cae121ae3
(svn r9305) [NoAI] -Add: option to force-select an AI from the console.
rubidium
parents:
9429
diff
changeset
|
384 |
case 'a': ttd_strlcpy(ai, mgo.opt, sizeof(ai)); break; |
5943
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
385 |
#if defined(ENABLE_NETWORK) |
3058
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
386 |
case 'D': |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
387 |
strcpy(musicdriver, "null"); |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
388 |
strcpy(sounddriver, "null"); |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
389 |
strcpy(videodriver, "dedicated"); |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
390 |
strcpy(blitter, "null"); |
3058
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
391 |
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
|
392 |
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
|
393 |
/* 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
|
394 |
* 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
|
395 |
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
|
396 |
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
|
397 |
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
|
398 |
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
|
399 |
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
|
400 |
} |
3058
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
401 |
break; |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
402 |
case 'f': _dedicated_forks = true; break; |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
403 |
case 'n': |
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
404 |
network = true; |
3059
9f25d987c6ae
(svn r3648) - Fix typo in r3647, don't ask me how it got there s/_/./
Darkvater
parents:
3058
diff
changeset
|
405 |
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
|
406 |
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
|
407 |
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
|
408 |
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
|
409 |
break; |
5943
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
410 |
#endif /* ENABLE_NETWORK */ |
0 | 411 |
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
|
412 |
case 't': startyear = atoi(mgo.opt); break; |
0 | 413 |
case 'd': { |
414 |
#if defined(WIN32) |
|
415 |
CreateConsole(); |
|
416 |
#endif |
|
2639 | 417 |
if (mgo.opt != NULL) SetDebugString(mgo.opt); |
0 | 418 |
} break; |
419 |
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
|
420 |
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
|
421 |
case 'g': |
2639 | 422 |
if (mgo.opt != NULL) { |
0 | 423 |
strcpy(_file_to_saveload.name, mgo.opt); |
424 |
_switch_mode = SM_LOAD; |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
425 |
} else { |
0 | 426 |
_switch_mode = SM_NEWGAME; |
9408 | 427 |
/* Give a random map */ |
428 |
generation_seed = InteractiveRandom(); |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
429 |
} |
0 | 430 |
break; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
431 |
case 'G': generation_seed = atoi(mgo.opt); break; |
3058
32bbf65085e8
(svn r3647) Some style-changes to the parameter parser
Darkvater
parents:
3033
diff
changeset
|
432 |
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
|
433 |
case 'x': save_config = false; break; |
0 | 434 |
case -2: |
2026 | 435 |
case 'h': |
0 | 436 |
showhelp(); |
437 |
return 0; |
|
438 |
} |
|
439 |
} |
|
440 |
||
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
441 |
#if defined(WINCE) && defined(_DEBUG) |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
442 |
/* Switch on debug lvl 4 for WinCE if Debug release, as you can't give params, and you most likely do want this information */ |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
443 |
SetDebugString("4"); |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
444 |
#endif |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
445 |
|
9476 | 446 |
DeterminePaths(argv[0]); |
961 | 447 |
CheckExternalFiles(); |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
448 |
|
2290 | 449 |
#if defined(UNIX) && !defined(__MORPHOS__) |
9505 | 450 |
/* 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
|
451 |
if (_dedicated_forks) |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
452 |
DedicatedFork(); |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
453 |
#endif |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
454 |
|
0 | 455 |
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
|
456 |
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
|
457 |
LoadFromHighScore(); |
0 | 458 |
|
9505 | 459 |
/* 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
|
460 |
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
|
461 |
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
|
462 |
if (!StrEmpty(videodriver)) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver)); |
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
463 |
if (!StrEmpty(blitter)) ttd_strlcpy(_ini_blitter, blitter, sizeof(_ini_blitter)); |
9467
730cae121ae3
(svn r9305) [NoAI] -Add: option to force-select an AI from the console.
rubidium
parents:
9429
diff
changeset
|
464 |
if (!StrEmpty(ai)) AI_ForceAI(ai); |
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
|
465 |
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
|
466 |
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
|
467 |
if (generation_seed != GENERATE_NEW_SEED) _patches_newgame.generation_seed = generation_seed; |
0 | 468 |
|
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
469 |
/* The width and height must be at least 1 pixel, this |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
470 |
* way all internal drawing routines work correctly. */ |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
471 |
if (_cur_resolution[0] == 0) _cur_resolution[0] = 1; |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
472 |
if (_cur_resolution[1] == 0) _cur_resolution[1] = 1; |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
473 |
|
5943
9acc30eb83cd
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni
parents:
5934
diff
changeset
|
474 |
#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
|
475 |
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
|
476 |
if (dedicated_port) _network_server_port = dedicated_port; |
2951 | 477 |
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
|
478 |
#endif /* ENABLE_NETWORK */ |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
479 |
|
9505 | 480 |
/* enumerate language files */ |
0 | 481 |
InitializeLanguagePacks(); |
482 |
||
9505 | 483 |
/* initialize screenshot formats */ |
0 | 484 |
InitializeScreenshotFormats(); |
485 |
||
9505 | 486 |
/* initialize airport state machines */ |
105 | 487 |
InitializeAirports(); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
488 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
489 |
/* 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
|
490 |
InitializeDynamicVariables(); |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
491 |
|
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
492 |
/* start the AI */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
493 |
AI_Initialize(); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
494 |
|
9505 | 495 |
/* Sample catalogue */ |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5564
diff
changeset
|
496 |
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
|
497 |
MxInitialize(11025); |
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1482
diff
changeset
|
498 |
SoundInitialize("sample.cat"); |
0 | 499 |
|
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
|
500 |
/* 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
|
501 |
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
|
502 |
|
9505 | 503 |
/* This must be done early, since functions use the InvalidateWindow* calls */ |
139 | 504 |
InitWindowSystem(); |
0 | 505 |
|
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
|
506 |
/* 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
|
507 |
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
|
508 |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
509 |
DEBUG(misc, 1, "Loading blitter..."); |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
510 |
if (BlitterFactoryBase::SelectBlitter(_ini_blitter) == NULL) |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
511 |
StrEmpty(_ini_blitter) ? |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
512 |
error("Failed to autoprobe blitter") : |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
513 |
error("Failed to select requested blitter '%s'; does it exist?", _ini_blitter); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
514 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5564
diff
changeset
|
515 |
DEBUG(driver, 1, "Loading drivers..."); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
516 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
517 |
_sound_driver = (SoundDriver*)SoundDriverFactoryBase::SelectDriver(_ini_sounddriver, Driver::DT_SOUND); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
518 |
if (_sound_driver == NULL) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
519 |
StrEmpty(_ini_sounddriver) ? |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
520 |
error("Failed to autoprobe sound driver") : |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
521 |
error("Failed to select requested sound driver '%s'", _ini_sounddriver); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
522 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
523 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
524 |
_music_driver = (MusicDriver*)MusicDriverFactoryBase::SelectDriver(_ini_musicdriver, Driver::DT_MUSIC); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
525 |
if (_music_driver == NULL) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
526 |
StrEmpty(_ini_musicdriver) ? |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
527 |
error("Failed to autoprobe music driver") : |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
528 |
error("Failed to select requested music driver '%s'", _ini_musicdriver); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
529 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
530 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
531 |
_video_driver = (VideoDriver*)VideoDriverFactoryBase::SelectDriver(_ini_videodriver, Driver::DT_VIDEO); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
532 |
if (_video_driver == NULL) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
533 |
StrEmpty(_ini_videodriver) ? |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
534 |
error("Failed to autoprobe video driver") : |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
535 |
error("Failed to select requested video driver '%s'", _ini_videodriver); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
536 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
537 |
|
2526
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
538 |
_savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING; |
9624 | 539 |
/* Initialize the zoom level of the screen to normal */ |
540 |
_screen.zoom = ZOOM_LVL_NORMAL; |
|
0 | 541 |
|
9505 | 542 |
/* restore saved music volume */ |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
543 |
_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
|
544 |
|
4830
0ff2a14e90be
(svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents:
4829
diff
changeset
|
545 |
NetworkStartUp(); // initialize network-core |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
546 |
|
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
|
547 |
#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
|
548 |
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
|
549 |
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
|
550 |
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
|
551 |
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
|
552 |
|
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
|
553 |
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
|
554 |
|
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
|
555 |
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
|
556 |
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
|
557 |
|
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 |
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
|
559 |
} |
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 |
#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
|
561 |
|
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5197
diff
changeset
|
562 |
ScanNewGRFFiles(); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5197
diff
changeset
|
563 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
564 |
_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
|
565 |
ResetGRFConfig(false); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
566 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
567 |
/* XXX - ugly hack, if diff_level is 9, it means we got no setting from the config file */ |
2951 | 568 |
if (_opt_newgame.diff_level == 9) SetDifficultyLevel(0, &_opt_newgame); |
0 | 569 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
570 |
/* 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
|
571 |
if (_switch_mode != SM_NONE) { |
5024
f13f2f2d43f9
(svn r7065) Use simple assignment instead of memcpy()
tron
parents:
5015
diff
changeset
|
572 |
_opt = _opt_newgame; |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
573 |
UpdatePatches(); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
574 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
575 |
|
9505 | 576 |
/* initialize the ingame console */ |
139 | 577 |
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
|
578 |
_cursor.in_window = true; |
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1243
diff
changeset
|
579 |
InitializeGUI(); |
644
e833509107ad
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
630
diff
changeset
|
580 |
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
|
581 |
|
2828
996de8e891c7
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2818
diff
changeset
|
582 |
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
|
583 |
WaitTillGeneratedWorld(); |
1268
306ebfea663a
(svn r1772) -Fix: [ 1114100 ] Dedicated server boots again
truelight
parents:
1267
diff
changeset
|
584 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
585 |
#ifdef ENABLE_NETWORK |
2951 | 586 |
if (network && _network_available) { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
587 |
if (network_conn != NULL) { |
1329 | 588 |
const char *port = NULL; |
589 |
const char *player = NULL; |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
590 |
uint16 rport; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
591 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
592 |
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
|
593 |
_network_playas = PLAYER_NEW_COMPANY; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
594 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
595 |
ParseConnectionString(&player, &port, network_conn); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
596 |
|
4861
f28bfa84f9ad
(svn r6787) -Codechange: Use PLAYER_NEW_COMPANY as a player identifier wishing to become a
Darkvater
parents:
4854
diff
changeset
|
597 |
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
|
598 |
_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
|
599 |
|
4880
0708f34e3586
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
600 |
if (_network_playas != PLAYER_SPECTATOR) { |
0708f34e3586
(svn r6816) -Codechange: Some coding style, variable localization, const correctness.
Darkvater
parents:
4878
diff
changeset
|
601 |
_network_playas--; |
4878
744717de172e
(svn r6814) -Codechange: For network games ci->client_playas was always p->index + 1. To
Darkvater
parents:
4861
diff
changeset
|
602 |
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
|
603 |
} |
4861
f28bfa84f9ad
(svn r6787) -Codechange: Use PLAYER_NEW_COMPANY as a player identifier wishing to become a
Darkvater
parents:
4854
diff
changeset
|
604 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
605 |
if (port != NULL) rport = atoi(port); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
606 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
607 |
LoadIntroGame(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
608 |
_switch_mode = SM_NONE; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
609 |
NetworkClientConnectGame(network_conn, rport); |
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1105
diff
changeset
|
610 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
611 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
612 |
#endif /* ENABLE_NETWORK */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
613 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
614 |
_video_driver->MainLoop(); |
139 | 615 |
|
2285
3193cbd1ba88
(svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
2234
diff
changeset
|
616 |
WaitTillSaved(); |
139 | 617 |
IConsoleFree(); |
0 | 618 |
|
4830
0ff2a14e90be
(svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents:
4829
diff
changeset
|
619 |
if (_network_available) NetworkShutDown(); // Shut down the network and close any open connections |
0 | 620 |
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
621 |
_video_driver->Stop(); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
622 |
_music_driver->Stop(); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
623 |
_sound_driver->Stop(); |
0 | 624 |
|
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
|
625 |
/* 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
|
626 |
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
|
627 |
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
|
628 |
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
|
629 |
} |
0 | 630 |
|
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
|
631 |
/* 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
|
632 |
UnInitializeGame(); |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
633 |
|
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
634 |
/* stop the AI */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
635 |
AI_Uninitialize(); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
636 |
|
1036
5f0c307fbadd
(svn r1537) -Fix: Close all and any open filehandles open at shutdown (tamlin)
darkvater
parents:
1035
diff
changeset
|
637 |
/* 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
|
638 |
FioCloseAll(); |
5f0c307fbadd
(svn r1537) -Fix: Close all and any open filehandles open at shutdown (tamlin)
darkvater
parents:
1035
diff
changeset
|
639 |
|
0 | 640 |
return 0; |
641 |
} |
|
642 |
||
6573 | 643 |
void HandleExitGameRequest() |
4548
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
644 |
{ |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
645 |
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
|
646 |
_exit_game = true; |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
647 |
} else if (_patches.autosave_on_exit) { |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
648 |
DoExitSave(); |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
649 |
_exit_game = true; |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
650 |
} else { |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
651 |
AskExitGame(); |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
652 |
} |
23b56455df33
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4537
diff
changeset
|
653 |
} |
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 |
|
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
|
656 |
/** 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
|
657 |
* 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
|
658 |
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
|
659 |
|
6573 | 660 |
static inline void OTTD_ReleaseMutex() {_message = MSG_OTTD_NO_MESSAGE;} |
661 |
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
|
662 |
|
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
|
663 |
/** 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
|
664 |
* 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
|
665 |
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
|
666 |
{ |
2383
80ff60d10aed
(svn r2909) Game would hang where the autosave_on_exit was activated.
Darkvater
parents:
2380
diff
changeset
|
667 |
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
|
668 |
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
|
669 |
|
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
|
670 |
_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
|
671 |
} |
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 |
|
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 |
/** 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
|
675 |
* @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
|
676 |
*/ |
2817 | 677 |
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
|
678 |
{ |
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 |
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
|
680 |
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
|
681 |
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
|
682 |
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
|
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 |
|
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 |
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
|
686 |
} |
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
|
687 |
|
0 | 688 |
static void ShowScreenshotResult(bool b) |
689 |
{ |
|
690 |
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
|
691 |
SetDParamStr(0, _screenshot_name); |
0 | 692 |
ShowErrorMessage(INVALID_STRING_ID, STR_031B_SCREENSHOT_SUCCESSFULLY, 0, 0); |
693 |
} else { |
|
694 |
ShowErrorMessage(INVALID_STRING_ID, STR_031C_SCREENSHOT_FAILED, 0, 0); |
|
695 |
} |
|
696 |
||
697 |
} |
|
698 |
||
6573 | 699 |
static void MakeNewGameDone() |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
700 |
{ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
701 |
/* 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
|
702 |
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
|
703 |
SetLocalPlayer(PLAYER_SPECTATOR); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
704 |
return; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
705 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
706 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
707 |
/* Create a single player */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
708 |
DoStartupNewPlayer(false); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
709 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
710 |
SetLocalPlayer(PLAYER_FIRST); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
711 |
_current_player = _local_player; |
4661
59492734db06
(svn r6544) - Codechange: Rename CmdReplaceVehicle to CmdSetAutoReplace, to reflect what it does.
peter1138
parents:
4603
diff
changeset
|
712 |
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
|
713 |
|
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5108
diff
changeset
|
714 |
SettingsDisableElrail(_patches.disable_elrails); |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
715 |
InitializeRailGUI(); |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5108
diff
changeset
|
716 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
717 |
#ifdef ENABLE_NETWORK |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
718 |
/* We are the server, we start a new player (not dedicated), |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
719 |
* so set the default password *if* needed. */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
720 |
if (_network_server && !StrEmpty(_network_default_company_pass)) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
721 |
char *password = _network_default_company_pass; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
722 |
NetworkChangeCompanyPassword(1, &password); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
723 |
} |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
724 |
#endif /* ENABLE_NETWORK */ |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
725 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
726 |
MarkWholeScreenDirty(); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
727 |
} |
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 |
static void MakeNewGame(bool from_heightmap) |
0 | 730 |
{ |
731 |
_game_mode = GM_NORMAL; |
|
732 |
||
5313
ea491c0b40f1
(svn r7469) -Fix (r7348): NewGRF settings weren't loaded in cases.
peter1138
parents:
5296
diff
changeset
|
733 |
ResetGRFConfig(true); |
9624 | 734 |
_house_mngr.ResetMapping(); |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
735 |
_industile_mngr.ResetMapping(); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
736 |
_industry_mngr.ResetMapping(); |
5313
ea491c0b40f1
(svn r7469) -Fix (r7348): NewGRF settings weren't loaded in cases.
peter1138
parents:
5296
diff
changeset
|
737 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
738 |
GenerateWorldSetCallback(&MakeNewGameDone); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
739 |
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
|
740 |
} |
0 | 741 |
|
6573 | 742 |
static void MakeNewEditorWorldDone() |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
743 |
{ |
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
|
744 |
SetLocalPlayer(OWNER_NONE); |
0 | 745 |
|
746 |
MarkWholeScreenDirty(); |
|
747 |
} |
|
748 |
||
6573 | 749 |
static void MakeNewEditorWorld() |
0 | 750 |
{ |
751 |
_game_mode = GM_EDITOR; |
|
752 |
||
5313
ea491c0b40f1
(svn r7469) -Fix (r7348): NewGRF settings weren't loaded in cases.
peter1138
parents:
5296
diff
changeset
|
753 |
ResetGRFConfig(true); |
ea491c0b40f1
(svn r7469) -Fix (r7348): NewGRF settings weren't loaded in cases.
peter1138
parents:
5296
diff
changeset
|
754 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
755 |
GenerateWorldSetCallback(&MakeNewEditorWorldDone); |
2828
996de8e891c7
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2818
diff
changeset
|
756 |
GenerateWorld(GW_EMPTY, 1 << _patches.map_x, 1 << _patches.map_y); |
0 | 757 |
} |
758 |
||
6573 | 759 |
void StartupPlayers(); |
760 |
void StartupDisasters(); |
|
761 |
extern void StartupEconomy(); |
|
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
115
diff
changeset
|
762 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
763 |
/** |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
764 |
* Start Scenario starts a new game based on a scenario. |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
765 |
* 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
|
766 |
* This starts a scenario based on your current difficulty settings |
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
767 |
*/ |
6573 | 768 |
static void StartScenario() |
0 | 769 |
{ |
770 |
_game_mode = GM_NORMAL; |
|
771 |
||
9505 | 772 |
/* invalid type */ |
0 | 773 |
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
|
774 |
DEBUG(sl, 0, "Savegame is obsolete or invalid format: '%s'", _file_to_saveload.name); |
9629 | 775 |
SetDParamStr(0, GetSaveLoadErrorString()); |
776 |
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0); |
|
0 | 777 |
_game_mode = GM_MENU; |
778 |
return; |
|
779 |
} |
|
780 |
||
9505 | 781 |
/* Reinitialize windows */ |
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
782 |
ResetWindowSystem(); |
0 | 783 |
|
784 |
SetupColorsAndInitialWindow(); |
|
785 |
||
5313
ea491c0b40f1
(svn r7469) -Fix (r7348): NewGRF settings weren't loaded in cases.
peter1138
parents:
5296
diff
changeset
|
786 |
ResetGRFConfig(true); |
ea491c0b40f1
(svn r7469) -Fix (r7348): NewGRF settings weren't loaded in cases.
peter1138
parents:
5296
diff
changeset
|
787 |
|
9505 | 788 |
/* Load game */ |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
789 |
if (SaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, SCENARIO_DIR) != SL_OK) { |
0 | 790 |
LoadIntroGame(); |
9629 | 791 |
SetDParamStr(0, GetSaveLoadErrorString()); |
792 |
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0); |
|
0 | 793 |
} |
794 |
||
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
|
795 |
_opt_ptr = &_opt; |
5024
f13f2f2d43f9
(svn r7065) Use simple assignment instead of memcpy()
tron
parents:
5015
diff
changeset
|
796 |
_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
|
797 |
_opt.diff_level = _opt_newgame.diff_level; |
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
798 |
|
9505 | 799 |
/* Inititalize data */ |
3891
b39019cd32cf
(svn r4947) - Fix [FS#145]: Starting scenarios did not adhere to local difficulty settings
Darkvater
parents:
3889
diff
changeset
|
800 |
StartupEconomy(); |
115
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
801 |
StartupPlayers(); |
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
802 |
StartupEngines(); |
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
803 |
StartupDisasters(); |
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
804 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
805 |
SetLocalPlayer(PLAYER_FIRST); |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
806 |
_current_player = _local_player; |
4661
59492734db06
(svn r6544) - Codechange: Rename CmdReplaceVehicle to CmdSetAutoReplace, to reflect what it does.
peter1138
parents:
4603
diff
changeset
|
807 |
DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE); |
0 | 808 |
|
809 |
MarkWholeScreenDirty(); |
|
810 |
} |
|
811 |
||
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
812 |
/** Load the specified savegame but on error do different things. |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
813 |
* If loading fails due to corrupt savegame, bad version, etc. go back to |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
814 |
* a previous correct state. In the menu for example load the intro game again. |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
815 |
* @param filename file to be loaded |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
816 |
* @param mode mode of loading, either SL_LOAD or SL_OLD_LOAD |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
817 |
* @param newgm switch to this mode of loading fails due to some unknown error |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
818 |
* @param subdir default directory to look for filename, set to 0 if not needed */ |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
819 |
bool SafeSaveOrLoad(const char *filename, int mode, int newgm, Subdirectory subdir) |
0 | 820 |
{ |
821 |
byte ogm = _game_mode; |
|
822 |
||
823 |
_game_mode = newgm; |
|
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
824 |
assert(mode == SL_LOAD || mode == SL_OLD_LOAD); |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
825 |
switch (SaveOrLoad(filename, mode, subdir)) { |
3024 | 826 |
case SL_OK: return true; |
827 |
||
828 |
case SL_REINIT: |
|
829 |
switch (ogm) { |
|
9732 | 830 |
default: |
3024 | 831 |
case GM_MENU: LoadIntroGame(); break; |
832 |
case GM_EDITOR: MakeNewEditorWorld(); break; |
|
833 |
} |
|
834 |
return false; |
|
835 |
||
836 |
default: |
|
837 |
_game_mode = ogm; |
|
838 |
return false; |
|
2639 | 839 |
} |
0 | 840 |
} |
841 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
842 |
void SwitchMode(int new_mode) |
0 | 843 |
{ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
844 |
#ifdef ENABLE_NETWORK |
9505 | 845 |
/* 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
|
846 |
if (new_mode != SM_SAVE) { |
9505 | 847 |
/* 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
|
848 |
if (_networking) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
849 |
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
|
850 |
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
|
851 |
NetworkUDPCloseAll(); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
852 |
} else { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
853 |
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
|
854 |
NetworkUDPCloseAll(); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
855 |
} |
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 |
|
9505 | 858 |
/* 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
|
859 |
if (_is_network_server) { |
9505 | 860 |
/* 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
|
861 |
if (new_mode != SM_MENU) { |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
862 |
/* check if we should reload the config */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
863 |
if (_network_reload_cfg) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
864 |
LoadFromConfig(); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
865 |
_patches = _patches_newgame; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
866 |
_opt = _opt_newgame; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
867 |
ResetGRFConfig(false); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
868 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
869 |
NetworkServerStart(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
870 |
} else { |
9505 | 871 |
/* 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
|
872 |
_is_network_server = false; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
873 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
874 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
875 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
876 |
#endif /* ENABLE_NETWORK */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
877 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
878 |
switch (new_mode) { |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
879 |
case SM_EDITOR: /* Switch to scenario editor */ |
0 | 880 |
MakeNewEditorWorld(); |
881 |
break; |
|
882 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
883 |
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
|
884 |
#ifdef ENABLE_NETWORK |
2951 | 885 |
if (_network_server) { |
2989 | 886 |
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "Random Map"); |
2951 | 887 |
} |
630
fd3c36132342
(svn r1061) -Fix: [Network] Compiling without ENABLE_NETWORK now works again correctly
truelight
parents:
614
diff
changeset
|
888 |
#endif /* ENABLE_NETWORK */ |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
889 |
MakeNewGame(false); |
0 | 890 |
break; |
891 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
892 |
case SM_START_SCENARIO: /* New Game --> Choose one of the preset scenarios */ |
2951 | 893 |
#ifdef ENABLE_NETWORK |
894 |
if (_network_server) { |
|
2989 | 895 |
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Loaded scenario)", _file_to_saveload.title); |
2951 | 896 |
} |
897 |
#endif /* ENABLE_NETWORK */ |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
898 |
StartScenario(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
899 |
break; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
900 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
901 |
case SM_LOAD: { /* Load game, Play Scenario */ |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
902 |
_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
|
903 |
ResetGRFConfig(true); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
904 |
ResetWindowSystem(); |
0 | 905 |
|
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
906 |
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
|
907 |
LoadIntroGame(); |
9629 | 908 |
SetDParamStr(0, GetSaveLoadErrorString()); |
909 |
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0); |
|
0 | 910 |
} 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
|
911 |
/* 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
|
912 |
* 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
|
913 |
SetLocalPlayer(_network_dedicated ? PLAYER_SPECTATOR : PLAYER_FIRST); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
914 |
/* Decrease pause counter (was increased from opening load dialog) */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
915 |
DoCommandP(0, 0, 0, NULL, CMD_PAUSE); |
630
fd3c36132342
(svn r1061) -Fix: [Network] Compiling without ENABLE_NETWORK now works again correctly
truelight
parents:
614
diff
changeset
|
916 |
#ifdef ENABLE_NETWORK |
2951 | 917 |
if (_network_server) { |
2989 | 918 |
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Loaded game)", _file_to_saveload.title); |
2951 | 919 |
} |
630
fd3c36132342
(svn r1061) -Fix: [Network] Compiling without ENABLE_NETWORK now works again correctly
truelight
parents:
614
diff
changeset
|
920 |
#endif /* ENABLE_NETWORK */ |
0 | 921 |
} |
922 |
break; |
|
923 |
} |
|
924 |
||
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
925 |
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
|
926 |
#ifdef ENABLE_NETWORK |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
927 |
if (_network_server) { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
928 |
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
|
929 |
} |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
930 |
#endif /* ENABLE_NETWORK */ |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
931 |
MakeNewGame(true); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
932 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
933 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
934 |
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
|
935 |
SetLocalPlayer(OWNER_NONE); |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
936 |
|
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
937 |
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
|
938 |
MarkWholeScreenDirty(); |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
939 |
break; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
940 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
941 |
case SM_LOAD_SCENARIO: { /* Load scenario from scenario editor */ |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
942 |
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
|
943 |
_opt_ptr = &_opt; |
0 | 944 |
|
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
|
945 |
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
|
946 |
_patches_newgame.starting_year = _cur_year; |
2639 | 947 |
} else { |
9629 | 948 |
SetDParamStr(0, GetSaveLoadErrorString()); |
949 |
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0); |
|
2639 | 950 |
} |
0 | 951 |
break; |
952 |
} |
|
953 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
954 |
case SM_MENU: /* Switch to game intro menu */ |
0 | 955 |
LoadIntroGame(); |
956 |
break; |
|
957 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
958 |
case SM_SAVE: /* Save game */ |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
959 |
/* Make network saved games on pause compatible to singleplayer */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
960 |
if (_networking && _pause_game == 1) _pause_game = 2; |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
961 |
if (SaveOrLoad(_file_to_saveload.name, SL_SAVE, NO_DIRECTORY) != SL_OK) { |
9629 | 962 |
SetDParamStr(0, GetSaveLoadErrorString()); |
963 |
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0); |
|
2639 | 964 |
} else { |
0 | 965 |
DeleteWindowById(WC_SAVELOAD, 0); |
2639 | 966 |
} |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
967 |
if (_networking && _pause_game == 2) _pause_game = 1; |
0 | 968 |
break; |
969 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
970 |
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
|
971 |
SetLocalPlayer(OWNER_NONE); |
2951 | 972 |
GenerateWorld(GW_RANDOM, 1 << _patches.map_x, 1 << _patches.map_y); |
9505 | 973 |
/* XXX: set date */ |
0 | 974 |
MarkWholeScreenDirty(); |
975 |
break; |
|
976 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
977 |
|
2951 | 978 |
if (_switch_mode_errorstr != INVALID_STRING_ID) { |
979 |
ShowErrorMessage(INVALID_STRING_ID, _switch_mode_errorstr, 0, 0); |
|
980 |
} |
|
0 | 981 |
} |
982 |
||
983 |
||
9505 | 984 |
/* State controlling game loop. |
985 |
* The state must not be changed from anywhere |
|
986 |
* but here. |
|
987 |
* That check is enforced in DoCommand. */ |
|
6573 | 988 |
void StateGameLoop() |
0 | 989 |
{ |
9505 | 990 |
/* dont execute the state loop during pause */ |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
991 |
if (_pause_game) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
992 |
CallWindowTickEvent(); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
993 |
return; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
994 |
} |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
995 |
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
|
996 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
997 |
ClearStorageChanges(false); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
998 |
|
0 | 999 |
if (_game_mode == GM_EDITOR) { |
1000 |
RunTileLoop(); |
|
1001 |
CallVehicleTicks(); |
|
1002 |
CallLandscapeTick(); |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1003 |
ClearStorageChanges(true); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1004 |
|
0 | 1005 |
CallWindowTickEvent(); |
1006 |
NewsLoop(); |
|
1007 |
} else { |
|
9505 | 1008 |
/* All these actions has to be done from OWNER_NONE |
1009 |
* 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
|
1010 |
PlayerID p = _current_player; |
206 | 1011 |
_current_player = OWNER_NONE; |
1012 |
||
0 | 1013 |
AnimateAnimatedTiles(); |
1014 |
IncreaseDate(); |
|
1015 |
RunTileLoop(); |
|
1016 |
CallVehicleTicks(); |
|
1017 |
CallLandscapeTick(); |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1018 |
ClearStorageChanges(true); |
0 | 1019 |
|
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
1020 |
AI_RunGameLoop(); |
0 | 1021 |
|
1022 |
CallWindowTickEvent(); |
|
1023 |
NewsLoop(); |
|
206 | 1024 |
_current_player = p; |
0 | 1025 |
} |
1026 |
} |
|
1027 |
||
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
1028 |
/** Create an autosave. The default name is "autosave#.sav". However with |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
1029 |
* the patch setting 'keep_all_autosave' the name defaults to company-name + date */ |
6573 | 1030 |
static void DoAutosave() |
0 | 1031 |
{ |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
1032 |
char buf[MAX_PATH]; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1033 |
|
6228
2de23d5a2b11
(svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight
parents:
6210
diff
changeset
|
1034 |
#if defined(PSP) |
2de23d5a2b11
(svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight
parents:
6210
diff
changeset
|
1035 |
/* 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
|
1036 |
if (_networking) |
2de23d5a2b11
(svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight
parents:
6210
diff
changeset
|
1037 |
return; |
2de23d5a2b11
(svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight
parents:
6210
diff
changeset
|
1038 |
#endif /* PSP */ |
2de23d5a2b11
(svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight
parents:
6210
diff
changeset
|
1039 |
|
4848
56549aa3e234
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4840
diff
changeset
|
1040 |
if (_patches.keep_all_autosave && _local_player != PLAYER_SPECTATOR) { |
9629 | 1041 |
SetDParam(0, _local_player); |
1042 |
SetDParam(1, _date); |
|
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
1043 |
GetString(buf, STR_4004, lastof(buf)); |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
1044 |
ttd_strlcat(buf, ".sav", lengthof(buf)); |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
1045 |
} else { |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
1046 |
/* generate a savegame name and number according to _patches.max_num_autosaves */ |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
1047 |
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
|
1048 |
|
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
1049 |
if (++_autosave_ctr >= _patches.max_num_autosaves) _autosave_ctr = 0; |
0 | 1050 |
} |
1051 |
||
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5564
diff
changeset
|
1052 |
DEBUG(sl, 2, "Autosaving to '%s'", buf); |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
1053 |
if (SaveOrLoad(buf, SL_SAVE, AUTOSAVE_DIR) != SL_OK) |
0 | 1054 |
ShowErrorMessage(INVALID_STRING_ID, STR_AUTOSAVE_FAILED, 0, 0); |
1055 |
} |
|
1056 |
||
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
|
1057 |
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
|
1058 |
{ |
4536
f13408cba18f
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4502
diff
changeset
|
1059 |
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
|
1060 |
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
|
1061 |
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
|
1062 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1063 |
WP(w, vp_d).dest_scrollpos_x += ScaleByZoom(x, w->viewport->zoom); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1064 |
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
|
1065 |
} |
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
|
1066 |
} |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1067 |
/** |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1068 |
* Describes all the different arrow key combinations the game allows |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1069 |
* when it is in scrolling mode. |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1070 |
* The real arrow keys are bitwise numbered as |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1071 |
* 1 = left |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1072 |
* 2 = up |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1073 |
* 4 = right |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1074 |
* 8 = down |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1075 |
*/ |
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
|
1076 |
static const int8 scrollamt[16][2] = { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1077 |
{ 0, 0}, ///< no key specified |
9505 | 1078 |
{-2, 0}, ///< 1 : left |
1079 |
{ 0, -2}, ///< 2 : up |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1080 |
{-2, -1}, ///< 3 : left + up |
9505 | 1081 |
{ 2, 0}, ///< 4 : right |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1082 |
{ 0, 0}, ///< 5 : left + right = nothing |
9505 | 1083 |
{ 2, -1}, ///< 6 : right + up |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1084 |
{ 0, -2}, ///< 7 : right + left + up = up |
9505 | 1085 |
{ 0 ,2}, ///< 8 : down |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1086 |
{-2 ,1}, ///< 9 : down + left |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1087 |
{ 0, 0}, ///< 10 : down + up = nothing |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1088 |
{-2, 0}, ///< 11 : left + up + down = left |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1089 |
{ 2, 1}, ///< 12 : down + right |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1090 |
{ 0, 2}, ///< 13 : left + right + down = down |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1091 |
{ 2, 0}, ///< 14 : right + up + down = right |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1092 |
{ 0, 0}, ///< 15 : left + up + right + down = nothing |
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
|
1093 |
}; |
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
|
1094 |
|
6573 | 1095 |
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
|
1096 |
{ |
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
|
1097 |
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
|
1098 |
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
|
1099 |
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
|
1100 |
} |
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
|
1101 |
} |
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
|
1102 |
|
6573 | 1103 |
void GameLoop() |
0 | 1104 |
{ |
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
|
1105 |
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
|
1106 |
|
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
|
1107 |
if ((message = OTTD_PollThreadEvent()) != 0) ProcessSentMessage(message); |
0 | 1108 |
|
9505 | 1109 |
/* autosave game? */ |
0 | 1110 |
if (_do_autosave) { |
1111 |
_do_autosave = false; |
|
1112 |
DoAutosave(); |
|
1113 |
RedrawAutosave(); |
|
1114 |
} |
|
1115 |
||
9505 | 1116 |
/* handle scrolling of the main window */ |
4502 | 1117 |
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
|
1118 |
|
9505 | 1119 |
/* make a screenshot? */ |
4184
f38abcb8b18d
(svn r5626) CodeChange : Remove the global _make_screenshot and implement a more flexible mechanism
belugas
parents:
4171
diff
changeset
|
1120 |
if (IsScreenshotRequested()) ShowScreenshotResult(MakeScreenshot()); |
0 | 1121 |
|
9505 | 1122 |
/* switch game mode? */ |
3024 | 1123 |
if (_switch_mode != SM_NONE) { |
1124 |
SwitchMode(_switch_mode); |
|
0 | 1125 |
_switch_mode = SM_NONE; |
1126 |
} |
|
1127 |
||
1128 |
IncreaseSpriteLRU(); |
|
1129 |
InteractiveRandom(); |
|
1130 |
||
2639 | 1131 |
if (_scroller_click_timeout > 3) { |
0 | 1132 |
_scroller_click_timeout -= 3; |
2639 | 1133 |
} else { |
0 | 1134 |
_scroller_click_timeout = 0; |
2639 | 1135 |
} |
0 | 1136 |
|
1137 |
_caret_timer += 3; |
|
9629 | 1138 |
_palette_animation_counter += 8; |
0 | 1139 |
CursorTick(); |
1140 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1141 |
#ifdef ENABLE_NETWORK |
9505 | 1142 |
/* Check for UDP stuff */ |
4830
0ff2a14e90be
(svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
Darkvater
parents:
4829
diff
changeset
|
1143 |
if (_network_available) NetworkUDPGameLoop(); |
0 | 1144 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4293
diff
changeset
|
1145 |
if (_networking && !IsGeneratingWorld()) { |
9505 | 1146 |
/* Multiplayer */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1147 |
NetworkGameLoop(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1148 |
} else { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1149 |
if (_network_reconnect > 0 && --_network_reconnect == 0) { |
9505 | 1150 |
/* This means that we want to reconnect to the last host |
1151 |
* 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
|
1152 |
NetworkClientConnectGame(_network_last_host, _network_last_port); |
206 | 1153 |
} |
9505 | 1154 |
/* Singleplayer */ |
213
770e504a6e51
(svn r214) -Feature: CMD_NET_INSTANT [just in time command handling over network] (sign_de)
darkvater
parents:
208
diff
changeset
|
1155 |
StateGameLoop(); |
0 | 1156 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1157 |
#else |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1158 |
StateGameLoop(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1159 |
#endif /* ENABLE_NETWORK */ |
0 | 1160 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1161 |
if (!_pause_game && HasBit(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations(); |
0 | 1162 |
|
6557
8381016f71f3
(svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents:
6555
diff
changeset
|
1163 |
if (!_pause_game || _cheats.build_in_pause.value) MoveAllTextEffects(); |
0 | 1164 |
|
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
|
1165 |
InputLoop(); |
0 | 1166 |
|
1608
074dff2e4890
(svn r2112) -Fix: ExtMidi no longer halts the game while starting a song
tron
parents:
1570
diff
changeset
|
1167 |
MusicLoop(); |
0 | 1168 |
} |
1169 |
||
6573 | 1170 |
void BeforeSaveGame() |
0 | 1171 |
{ |
4171 | 1172 |
const Window *w = FindWindowById(WC_MAIN_WINDOW, 0); |
0 | 1173 |
|
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
|
1174 |
if (w != NULL) { |
2643 | 1175 |
_saved_scrollpos_x = WP(w, const vp_d).scrollpos_x; |
1176 |
_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
|
1177 |
_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
|
1178 |
} |
0 | 1179 |
} |
1180 |
||
6573 | 1181 |
static void ConvertTownOwner() |
0 | 1182 |
{ |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
1183 |
TileIndex tile; |
0 | 1184 |
|
863
8d09f9331a80
(svn r1344) Use MapSize[XY]() (or MapSize()/MapMax[XY]() where appropriate) instead of TILES_[XY]
tron
parents:
861
diff
changeset
|
1185 |
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
|
1186 |
switch (GetTileType(tile)) { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1187 |
case MP_ROAD: |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1188 |
if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HasBit(_m[tile].m4, 7)) { |
9624 | 1189 |
_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
|
1190 |
} |
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
|
1191 |
/* FALLTHROUGH */ |
0 | 1192 |
|
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
|
1193 |
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
|
1194 |
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
|
1195 |
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
|
1196 |
|
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
|
1197 |
default: break; |
0 | 1198 |
} |
1199 |
} |
|
1200 |
} |
|
1201 |
||
9505 | 1202 |
/* before savegame version 4, the name of the company determined if it existed */ |
6573 | 1203 |
static void CheckIsPlayerActive() |
0 | 1204 |
{ |
4171 | 1205 |
Player *p; |
2639 | 1206 |
|
0 | 1207 |
FOR_ALL_PLAYERS(p) { |
2639 | 1208 |
if (p->name_1 != 0) p->is_active = true; |
0 | 1209 |
} |
1210 |
} |
|
1211 |
||
9505 | 1212 |
/* since savegame version 4.1, exclusive transport rights are stored at towns */ |
6573 | 1213 |
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
|
1214 |
{ |
4171 | 1215 |
Town *t; |
2639 | 1216 |
|
1217 |
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
|
1218 |
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
|
1219 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1220 |
|
123
d550772c61e6
(svn r124) Prepared code for removal of block_months variable in next major savegame version
dominik
parents:
121
diff
changeset
|
1221 |
/* 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
|
1222 |
* could be implemented this way: |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4548
diff
changeset
|
1223 |
* 1.) Go through all stations |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4548
diff
changeset
|
1224 |
* 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
|
1225 |
* 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
|
1226 |
* 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
|
1227 |
* 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
|
1228 |
*/ |
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1229 |
} |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1230 |
|
2756 | 1231 |
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
|
1232 |
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
|
1233 |
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
|
1234 |
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
|
1235 |
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
|
1236 |
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
|
1237 |
|
9505 | 1238 |
/* since savegame version 4.2 the currencies are arranged differently */ |
6573 | 1239 |
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
|
1240 |
{ |
768
deb40d3554a2
(svn r1233) Fixed several currency issues. Now currencies should work correctly again.
dominik
parents:
762
diff
changeset
|
1241 |
_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
|
1242 |
} |
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
|
1243 |
|
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
|
1244 |
/* 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
|
1245 |
* 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
|
1246 |
*/ |
6573 | 1247 |
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
|
1248 |
{ |
959
b031d88c76f3
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
950
diff
changeset
|
1249 |
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
|
1250 |
|
3075
f0d692c60465
(svn r3664) Add a function to turn a tile into a void tile
tron
parents:
3059
diff
changeset
|
1251 |
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
|
1252 |
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
|
1253 |
} |
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
|
1254 |
|
9505 | 1255 |
/* since savegame version 6.0 each sign has an "owner", signs without owner (from old games are set to 255) */ |
6573 | 1256 |
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
|
1257 |
{ |
4349
2fc39ff2626e
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
1258 |
Sign *si; |
2639 | 1259 |
|
4349
2fc39ff2626e
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
1260 |
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
|
1261 |
} |
2cdf7a0e217a
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1262 |
|
6573 | 1263 |
extern void UpdateOldAircraft(); |
0 | 1264 |
|
3656
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1265 |
|
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1266 |
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
|
1267 |
{ |
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1268 |
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
|
1269 |
} |
4e75522d698d
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
tron
parents:
3580
diff
changeset
|
1270 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1271 |
/** |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1272 |
* Initialization of the windows and several kinds of caches. |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1273 |
* This is not done directly in AfterLoadGame because these |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1274 |
* functions require that all saveload conversions have been |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1275 |
* done. As people tend to add savegame conversion stuff after |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1276 |
* the intialization of the windows and caches quite some bugs |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1277 |
* had been made. |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1278 |
* Moving this out of there is both cleaner and less bug-prone. |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1279 |
* |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1280 |
* @return true if everything went according to plan, otherwise false. |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1281 |
*/ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1282 |
static bool InitializeWindowsAndCaches() |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1283 |
{ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1284 |
/* Initialize windows */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1285 |
ResetWindowSystem(); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1286 |
SetupColorsAndInitialWindow(); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1287 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1288 |
Window *w = FindWindowById(WC_MAIN_WINDOW, 0); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1289 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1290 |
WP(w, vp_d).scrollpos_x = _saved_scrollpos_x; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1291 |
WP(w, vp_d).scrollpos_y = _saved_scrollpos_y; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1292 |
WP(w, vp_d).dest_scrollpos_x = _saved_scrollpos_x; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1293 |
WP(w, vp_d).dest_scrollpos_y = _saved_scrollpos_y; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1294 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1295 |
ViewPort *vp = w->viewport; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1296 |
vp->zoom = min(_saved_scrollpos_zoom, ZOOM_LVL_MAX); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1297 |
vp->virtual_width = ScaleByZoom(vp->width, vp->zoom); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1298 |
vp->virtual_height = ScaleByZoom(vp->height, vp->zoom); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1299 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1300 |
DoZoomInOutWindow(ZOOM_NONE, w); // update button status |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1301 |
MarkWholeScreenDirty(); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1302 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1303 |
/* Update coordinates of the signs. */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1304 |
UpdateAllStationVirtCoord(); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1305 |
UpdateAllSignVirtCoords(); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1306 |
UpdateAllTownVirtCoords(); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1307 |
UpdateAllWaypointSigns(); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1308 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1309 |
/* Recalculate */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1310 |
Group *g; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1311 |
FOR_ALL_GROUPS(g) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1312 |
const Vehicle *v; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1313 |
FOR_ALL_VEHICLES(v) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1314 |
if (!IsEngineCountable(v)) continue; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1315 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1316 |
if (v->group_id != g->index || v->type != g->vehicle_type || v->owner != g->owner) continue; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1317 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1318 |
g->num_engines[v->engine_type]++; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1319 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1320 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1321 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1322 |
/* Set up the engine count for all players */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1323 |
Player *players[MAX_PLAYERS]; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1324 |
const Vehicle *v; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1325 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1326 |
for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1327 |
players[i] = GetPlayer(i); |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1328 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1329 |
/* For each player, verify (while loading a scenario) that the inauguration date is the current year and set it |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1330 |
* accordingly if it is not the case. No need to set it on players that are not been used already, |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1331 |
* thus the MIN_YEAR (which is really nothing more than Zero, initialized value) test */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1332 |
if (_file_to_saveload.filetype == FT_SCENARIO && players[i]->inaugurated_year != MIN_YEAR) |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1333 |
players[i]->inaugurated_year = _cur_year; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1334 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1335 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1336 |
FOR_ALL_VEHICLES(v) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1337 |
if (!IsEngineCountable(v)) continue; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1338 |
players[v->owner]->num_engines[v->engine_type]++; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1339 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1340 |
|
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1341 |
return true; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1342 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1343 |
|
6573 | 1344 |
bool AfterLoadGame() |
0 | 1345 |
{ |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1346 |
TileIndex map_size = MapSize(); |
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
2100
diff
changeset
|
1347 |
Player *p; |
988
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
983
diff
changeset
|
1348 |
|
9505 | 1349 |
/* 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
|
1350 |
if (CheckSavegameVersionOldStyle(2, 1)) ConvertTownOwner(); |
0 | 1351 |
|
9505 | 1352 |
/* 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
|
1353 |
if (CheckSavegameVersionOldStyle(4, 1)) UpdateExclusiveRights(); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1354 |
|
9505 | 1355 |
/* 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
|
1356 |
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
|
1357 |
|
9505 | 1358 |
/* 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
|
1359 |
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
|
1360 |
|
831
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1361 |
/* In old version there seems to be a problem that water is owned by |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1362 |
* OWNER_NONE, not OWNER_WATER.. I can't replicate it for the current |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1363 |
* (4.3) version, so I just check when versions are older, and then |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1364 |
* 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
|
1365 |
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
|
1366 |
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
|
1367 |
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
|
1368 |
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
|
1369 |
} |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1370 |
} |
831
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1371 |
} |
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1372 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1373 |
if (CheckSavegameVersion(84)) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1374 |
Player *p; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1375 |
FOR_ALL_PLAYERS(p) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1376 |
p->name = CopyFromOldName(p->name_1); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1377 |
if (p->name != NULL) p->name_1 = STR_SV_UNNAMED; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1378 |
p->president_name = CopyFromOldName(p->president_name_1); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1379 |
if (p->president_name != NULL) p->president_name_1 = SPECSTR_PRESIDENT_NAME; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1380 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1381 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1382 |
Station *st; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1383 |
FOR_ALL_STATIONS(st) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1384 |
st->name = CopyFromOldName(st->string_id); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1385 |
if (st->name != NULL) st->string_id = STR_EMPTY; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1386 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1387 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1388 |
Town *t; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1389 |
FOR_ALL_TOWNS(t) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1390 |
t->name = CopyFromOldName(t->townnametype); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1391 |
if (t->name != NULL) t->townnametype = SPECSTR_TOWNNAME_START + _opt.town_name; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1392 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1393 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1394 |
Waypoint *wp; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1395 |
FOR_ALL_WAYPOINTS(wp) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1396 |
wp->name = CopyFromOldName(wp->string); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1397 |
wp->string = STR_EMPTY; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1398 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1399 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1400 |
|
9505 | 1401 |
/* convert road side to my format. */ |
0 | 1402 |
if (_opt.road_side) _opt.road_side = 1; |
1403 |
||
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
|
1404 |
/* 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
|
1405 |
GRFListCompatibility gcf_res = IsGoodGRFConfigList(); |
9629 | 1406 |
if (_networking && gcf_res != GLC_ALL_GOOD) { |
1407 |
SetSaveLoadError(STR_NETWORK_ERR_CLIENT_NEWGRF_MISMATCH); |
|
1408 |
return false; |
|
1409 |
} |
|
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
|
1410 |
|
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
|
1411 |
switch (gcf_res) { |
6555
c27c9d5b459f
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6522
diff
changeset
|
1412 |
case GLC_COMPATIBLE: _switch_mode_errorstr = STR_NEWGRF_COMPATIBLE_LOAD_WARNING; break; |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
1413 |
case GLC_NOT_FOUND: _switch_mode_errorstr = STR_NEWGRF_DISABLED_WARNING; _pause_game = -1; break; |
5903 | 1414 |
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
|
1415 |
} |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
5197
diff
changeset
|
1416 |
|
5340
82c981816fcb
(svn r7506) -Codechange: [NewGRF] Add action 7/9/D variable 0x81 (current year)
glx
parents:
5314
diff
changeset
|
1417 |
/* Update current year |
82c981816fcb
(svn r7506) -Codechange: [NewGRF] Add action 7/9/D variable 0x81 (current year)
glx
parents:
5314
diff
changeset
|
1418 |
* 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
|
1419 |
SetDate(_date); |
82c981816fcb
(svn r7506) -Codechange: [NewGRF] Add action 7/9/D variable 0x81 (current year)
glx
parents:
5314
diff
changeset
|
1420 |
|
9505 | 1421 |
/* Load the sprites */ |
0 | 1422 |
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
|
1423 |
LoadStringWidthTable(); |
0 | 1424 |
|
2814
0f534d66544e
(svn r3362) Fix issue with loading old (TTD) savegames:
peter1138
parents:
2808
diff
changeset
|
1425 |
/* 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
|
1426 |
* subtype to the new format */ |
0f534d66544e
(svn r3362) Fix issue with loading old (TTD) savegames:
peter1138
parents:
2808
diff
changeset
|
1427 |
if (CheckSavegameVersionOldStyle(17, 1)) ConvertOldMultiheadToNew(); |
0f534d66544e
(svn r3362) Fix issue with loading old (TTD) savegames:
peter1138
parents:
2808
diff
changeset
|
1428 |
|
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
|
1429 |
/* 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
|
1430 |
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
|
1431 |
|
9505 | 1432 |
/* reinit the landscape variables (landscape might have changed) */ |
0 | 1433 |
InitializeLandscapeVariables(true); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1434 |
|
9505 | 1435 |
/* Update all vehicles */ |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1436 |
AfterLoadVehicles(true); |
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1501
diff
changeset
|
1437 |
|
9505 | 1438 |
/* Update all waypoints */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1439 |
if (CheckSavegameVersion(12)) FixOldWaypoints(); |
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1501
diff
changeset
|
1440 |
|
9505 | 1441 |
/* 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
|
1442 |
if (CheckSavegameVersionOldStyle(2, 2)) UpdateOldAircraft(); |
0 | 1443 |
|
1444 |
AfterLoadTown(); |
|
1445 |
||
9505 | 1446 |
/* make sure there is a town in the game */ |
2639 | 1447 |
if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, (uint)-1)) { |
9629 | 1448 |
SetSaveLoadError(STR_NO_TOWN_IN_SCENARIO); |
0 | 1449 |
return false; |
1450 |
} |
|
1451 |
||
9505 | 1452 |
/* in version 4.1 of the savegame, is_active was introduced to determine |
1453 |
* 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
|
1454 |
if (CheckSavegameVersionOldStyle(4, 1)) CheckIsPlayerActive(); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1455 |
|
9732 | 1456 |
/* The void tiles on the southern border used to belong to a wrong class (pre 4.3). |
1457 |
* This problem appears in savegame version 21 too, see r3455. But after loading the |
|
1458 |
* savegame and saving again, the buggy map array could be converted to new savegame |
|
1459 |
* version. It didn't show up before r12070. */ |
|
1460 |
if (CheckSavegameVersion(87)) 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
|
1461 |
|
9505 | 1462 |
/* If Load Scenario / New (Scenario) Game is used, |
1463 |
* a player does not exist yet. So create one here. |
|
1464 |
* 1 exeption: network-games. Those can have 0 players |
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
1465 |
* But this exeption is not true for non dedicated network_servers! */ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
1466 |
if (!_players[0].is_active && (!_networking || (_networking && _network_server && !_network_dedicated))) |
139 | 1467 |
DoStartupNewPlayer(false); |
0 | 1468 |
|
9686
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1469 |
if (CheckSavegameVersion(72)) { |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1470 |
/* Locks/shiplifts in very old savegames had OWNER_WATER as owner */ |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1471 |
for (TileIndex t = 0; t < MapSize(); t++) { |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1472 |
switch (GetTileType(t)) { |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1473 |
default: break; |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1474 |
|
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1475 |
case MP_WATER: |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1476 |
if (GetWaterTileType(t) == WATER_TILE_LOCK && GetTileOwner(t) == OWNER_WATER) SetTileOwner(t, OWNER_NONE); |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1477 |
break; |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1478 |
|
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1479 |
case MP_STATION: { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1480 |
if (HasBit(_m[t].m6, 3)) SetBit(_m[t].m6, 2); |
9686
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1481 |
StationGfx gfx = GetStationGfx(t); |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1482 |
StationType st; |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1483 |
if ( IsInsideMM(gfx, 0, 8)) { // Railway station |
9686
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1484 |
st = STATION_RAIL; |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1485 |
SetStationGfx(t, gfx - 0); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1486 |
} else if (IsInsideMM(gfx, 8, 67)) { // Airport |
9686
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1487 |
st = STATION_AIRPORT; |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1488 |
SetStationGfx(t, gfx - 8); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1489 |
} else if (IsInsideMM(gfx, 67, 71)) { // Truck |
9686
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1490 |
st = STATION_TRUCK; |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1491 |
SetStationGfx(t, gfx - 67); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1492 |
} else if (IsInsideMM(gfx, 71, 75)) { // Bus |
9686
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1493 |
st = STATION_BUS; |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1494 |
SetStationGfx(t, gfx - 71); |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1495 |
} else if (gfx == 75) { // Oil rig |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1496 |
st = STATION_OILRIG; |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1497 |
SetStationGfx(t, gfx - 75); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1498 |
} else if (IsInsideMM(gfx, 76, 82)) { // Dock |
9686
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1499 |
st = STATION_DOCK; |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1500 |
SetStationGfx(t, gfx - 76); |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1501 |
} else if (gfx == 82) { // Buoy |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1502 |
st = STATION_BUOY; |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1503 |
SetStationGfx(t, gfx - 82); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1504 |
} else if (IsInsideMM(gfx, 83, 168)) { // Extended airport |
9686
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1505 |
st = STATION_AIRPORT; |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1506 |
SetStationGfx(t, gfx - 83 + 67 - 8); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1507 |
} else if (IsInsideMM(gfx, 168, 170)) { // Drive through truck |
9686
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1508 |
st = STATION_TRUCK; |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1509 |
SetStationGfx(t, gfx - 168 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1510 |
} else if (IsInsideMM(gfx, 170, 172)) { // Drive through bus |
9686
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1511 |
st = STATION_BUS; |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1512 |
SetStationGfx(t, gfx - 170 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET); |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1513 |
} else { |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1514 |
return false; |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1515 |
} |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1516 |
SB(_m[t].m6, 3, 3, st); |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1517 |
} break; |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1518 |
} |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1519 |
} |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1520 |
} |
d3c195c226f9
(svn r10636) [NoAI] -Sync with trunk r10532:10635.
rubidium
parents:
9631
diff
changeset
|
1521 |
|
6131 | 1522 |
for (TileIndex t = 0; t < map_size; t++) { |
1523 |
switch (GetTileType(t)) { |
|
6419 | 1524 |
case MP_STATION: { |
1525 |
Station *st = GetStationByTile(t); |
|
1526 |
||
1527 |
st->rect.BeforeAddTile(t, StationRect::ADD_FORCE); |
|
1528 |
||
6131 | 1529 |
switch (GetStationType(t)) { |
1530 |
case STATION_TRUCK: |
|
1531 |
case STATION_BUS: |
|
1532 |
if (CheckSavegameVersion(6)) { |
|
6419 | 1533 |
/* From this version on there can be multiple road stops of the |
1534 |
* same type per station. Convert the existing stops to the new |
|
1535 |
* internal data structure. */ |
|
6131 | 1536 |
RoadStop *rs = new RoadStop(t); |
1537 |
if (rs == NULL) error("Too many road stops in savegame"); |
|
6130 | 1538 |
|
6131 | 1539 |
RoadStop **head = |
1540 |
IsTruckStop(t) ? &st->truck_stops : &st->bus_stops; |
|
1541 |
*head = rs; |
|
1542 |
} |
|
1543 |
break; |
|
1544 |
||
6135 | 1545 |
case STATION_OILRIG: { |
1546 |
/* Very old savegames sometimes have phantom oil rigs, i.e. |
|
1547 |
* an oil rig which got shut down, but not completly removed from |
|
1548 |
* the map |
|
1549 |
*/ |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
1550 |
TileIndex t1 = TILE_ADDXY(t, 0, 1); |
6137 | 1551 |
if (IsTileType(t1, MP_INDUSTRY) && |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
1552 |
GetIndustryGfx(t1) == GFX_OILRIG_1) { |
6137 | 1553 |
/* The internal encoding of oil rigs was changed twice. |
1554 |
* It was 3 (till 2.2) and later 5 (till 5.1). |
|
1555 |
* Setting it unconditionally does not hurt. |
|
1556 |
*/ |
|
1557 |
GetStationByTile(t)->airport_type = AT_OILRIG; |
|
1558 |
} else { |
|
6135 | 1559 |
DeleteOilRig(t); |
1560 |
} |
|
1561 |
break; |
|
1562 |
} |
|
1563 |
||
6131 | 1564 |
default: break; |
1565 |
} |
|
1566 |
break; |
|
6419 | 1567 |
} |
6131 | 1568 |
|
1569 |
default: break; |
|
6130 | 1570 |
} |
1571 |
} |
|
1572 |
||
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1573 |
/* 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
|
1574 |
* 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
|
1575 |
* all about ;) */ |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1576 |
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
|
1577 |
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
|
1578 |
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
|
1579 |
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
|
1580 |
_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
|
1581 |
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
|
1582 |
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
|
1583 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1584 |
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
|
1585 |
_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
|
1586 |
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
|
1587 |
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
|
1588 |
} 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
|
1589 |
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
|
1590 |
} |
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
|
1591 |
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
|
1592 |
|
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
|
1593 |
default: break; |
1264
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1594 |
} |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1595 |
} |
1264
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1596 |
} |
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1597 |
|
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1598 |
/* 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
|
1599 |
* before that. */ |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1600 |
if (CheckSavegameVersion(9)) { |
1377
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1349
diff
changeset
|
1601 |
Town *t; |
2639 | 1602 |
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
|
1603 |
} |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1349
diff
changeset
|
1604 |
|
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1605 |
/* 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
|
1606 |
* 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
|
1607 |
if (CheckSavegameVersion(16)) { |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1608 |
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
|
1609 |
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
|
1610 |
p->engine_renew = false; |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1611 |
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
|
1612 |
p->engine_renew_money = 100000; |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1613 |
} |
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
|
1614 |
|
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
|
1615 |
/* 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
|
1616 |
* 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
|
1617 |
* 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
|
1618 |
* 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
|
1619 |
* 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
|
1620 |
*/ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1621 |
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
|
1622 |
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
|
1623 |
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
|
1624 |
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
|
1625 |
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
|
1626 |
} |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1627 |
} |
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1628 |
|
9624 | 1629 |
if (CheckSavegameVersion(48)) { |
1630 |
for (TileIndex t = 0; t < map_size; t++) { |
|
1631 |
switch (GetTileType(t)) { |
|
1632 |
case MP_RAILWAY: |
|
1633 |
if (IsPlainRailTile(t)) { |
|
1634 |
/* Swap ground type and signal type for plain rail tiles, so the |
|
1635 |
* ground type uses the same bits as for depots and waypoints. */ |
|
1636 |
uint tmp = GB(_m[t].m4, 0, 4); |
|
1637 |
SB(_m[t].m4, 0, 4, GB(_m[t].m2, 0, 4)); |
|
1638 |
SB(_m[t].m2, 0, 4, tmp); |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1639 |
} else if (HasBit(_m[t].m5, 2)) { |
9624 | 1640 |
/* Split waypoint and depot rail type and remove the subtype. */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1641 |
ClrBit(_m[t].m5, 2); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1642 |
ClrBit(_m[t].m5, 6); |
9624 | 1643 |
} |
1644 |
break; |
|
1645 |
||
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1646 |
case MP_ROAD: |
9624 | 1647 |
/* Swap m3 and m4, so the track type for rail crossings is the |
1648 |
* same as for normal rail. */ |
|
1649 |
Swap(_m[t].m3, _m[t].m4); |
|
1650 |
break; |
|
1651 |
||
1652 |
default: break; |
|
1653 |
} |
|
1654 |
} |
|
1655 |
} |
|
1656 |
||
1657 |
if (CheckSavegameVersion(61)) { |
|
1658 |
/* Added the RoadType */ |
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
1659 |
bool old_bridge = CheckSavegameVersion(42); |
9624 | 1660 |
for (TileIndex t = 0; t < map_size; t++) { |
1661 |
switch(GetTileType(t)) { |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1662 |
case MP_ROAD: |
9624 | 1663 |
SB(_m[t].m5, 6, 2, GB(_m[t].m5, 4, 2)); |
1664 |
switch (GetRoadTileType(t)) { |
|
1665 |
default: NOT_REACHED(); |
|
1666 |
case ROAD_TILE_NORMAL: |
|
1667 |
SB(_m[t].m4, 0, 4, GB(_m[t].m5, 0, 4)); |
|
1668 |
SB(_m[t].m4, 4, 4, 0); |
|
1669 |
SB(_m[t].m6, 2, 4, 0); |
|
1670 |
break; |
|
1671 |
case ROAD_TILE_CROSSING: |
|
1672 |
SB(_m[t].m4, 5, 2, GB(_m[t].m5, 2, 2)); |
|
1673 |
break; |
|
1674 |
case ROAD_TILE_DEPOT: break; |
|
1675 |
} |
|
1676 |
SetRoadTypes(t, ROADTYPES_ROAD); |
|
1677 |
break; |
|
1678 |
||
1679 |
case MP_STATION: |
|
1680 |
if (IsRoadStop(t)) SetRoadTypes(t, ROADTYPES_ROAD); |
|
1681 |
break; |
|
1682 |
||
1683 |
case MP_TUNNELBRIDGE: |
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
1684 |
/* Middle part of "old" bridges */ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1685 |
if (old_bridge && IsBridge(t) && HasBit(_m[t].m5, 6)) break; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1686 |
if (((old_bridge && IsBridge(t)) ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t)) == TRANSPORT_ROAD) { |
9624 | 1687 |
SetRoadTypes(t, ROADTYPES_ROAD); |
1688 |
} |
|
1689 |
break; |
|
1690 |
||
1691 |
default: break; |
|
1692 |
} |
|
1693 |
} |
|
1694 |
} |
|
1695 |
||
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1696 |
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
|
1697 |
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
|
1698 |
|
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1699 |
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
|
1700 |
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
|
1701 |
if (IsBridgeTile(t)) { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1702 |
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
|
1703 |
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
|
1704 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1705 |
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
|
1706 |
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
|
1707 |
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
|
1708 |
t, |
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1709 |
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
|
1710 |
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
|
1711 |
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
|
1712 |
); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1713 |
} 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
|
1714 |
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
|
1715 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1716 |
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
|
1717 |
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
|
1718 |
axis == AXIS_X ? ROAD_Y : ROAD_X, |
9624 | 1719 |
ROADTYPES_ROAD, |
1720 |
town, |
|
1721 |
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
|
1722 |
); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1723 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1724 |
} 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
|
1725 |
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
|
1726 |
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
|
1727 |
} else { |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1728 |
if (GetTileSlope(t, NULL) != SLOPE_FLAT) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1729 |
MakeShore(t); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1730 |
} else { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1731 |
if (GetTileOwner(t) == OWNER_WATER) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1732 |
MakeWater(t); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1733 |
} else { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1734 |
MakeCanal(t, GetTileOwner(t), Random()); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1735 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
1736 |
} |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1737 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1738 |
} |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1739 |
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
|
1740 |
} 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
|
1741 |
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
|
1742 |
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
|
1743 |
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
|
1744 |
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
|
1745 |
|
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1746 |
_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
|
1747 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1748 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1749 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1750 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1751 |
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
|
1752 |
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
|
1753 |
if (IsBridgeTile(v->tile)) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1754 |
DiagDirection dir = GetTunnelBridgeDirection(v->tile); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1755 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1756 |
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
|
1757 |
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
|
1758 |
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
|
1759 |
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
|
1760 |
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
|
1761 |
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
|
1762 |
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
|
1763 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1764 |
} 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
|
1765 |
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
|
1766 |
} else { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1767 |
continue; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1768 |
} |
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
|
1769 |
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
|
1770 |
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
|
1771 |
} 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
|
1772 |
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
|
1773 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1774 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1775 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1776 |
|
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
|
1777 |
/* 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
|
1778 |
if (CheckSavegameVersion(24)) { |
4171 | 1779 |
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
|
1780 |
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
|
1781 |
|
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
|
1782 |
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
|
1783 |
if (v->type == VEH_TRAIN) { |
6074 | 1784 |
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
|
1785 |
|
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
|
1786 |
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
|
1787 |
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
|
1788 |
} |
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
|
1789 |
} |
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
|
1790 |
|
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
|
1791 |
/* .. 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
|
1792 |
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
|
1793 |
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
|
1794 |
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
|
1795 |
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
|
1796 |
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
|
1797 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1798 |
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
|
1799 |
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
|
1800 |
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
|
1801 |
} |
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
|
1802 |
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
|
1803 |
|
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
|
1804 |
case MP_STATION: |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
1805 |
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
|
1806 |
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
|
1807 |
} |
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
|
1808 |
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
|
1809 |
|
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
|
1810 |
case MP_TUNNELBRIDGE: |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1811 |
if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
1812 |
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
|
1813 |
} |
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
|
1814 |
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
|
1815 |
|
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
|
1816 |
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
|
1817 |
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
|
1818 |
} |
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
|
1819 |
} |
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
|
1820 |
|
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
|
1821 |
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
|
1822 |
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
|
1823 |
} |
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
|
1824 |
|
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
|
1825 |
} |
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
|
1826 |
|
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
|
1827 |
/* 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
|
1828 |
* 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
|
1829 |
* to false */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1830 |
if (CheckSavegameVersionOldStyle(16, 1)) { |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4032
diff
changeset
|
1831 |
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
|
1832 |
} |
a9e1a187de99
(svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
bjarni
parents:
2572
diff
changeset
|
1833 |
|
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
|
1834 |
/* 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
|
1835 |
* 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
|
1836 |
* 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
|
1837 |
* waypoint struct. */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1838 |
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
|
1839 |
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
|
1840 |
|
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
|
1841 |
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
|
1842 |
if (wp->deleted == 0) { |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3656
diff
changeset
|
1843 |
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
|
1844 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1845 |
if (HasBit(_m[wp->xy].m3, 4)) |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3656
diff
changeset
|
1846 |
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
|
1847 |
|
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3656
diff
changeset
|
1848 |
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
|
1849 |
wp->stat_id = _m[wp->xy].m4 + 1; |
9599 | 1850 |
wp->grfid = statspec->grffile->grfid; |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3656
diff
changeset
|
1851 |
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
|
1852 |
} else { |
9505 | 1853 |
/* 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
|
1854 |
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
|
1855 |
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
|
1856 |
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
|
1857 |
} |
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
|
1858 |
|
9505 | 1859 |
/* 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
|
1860 |
_m[wp->xy].m4 = GB(_m[wp->xy].m2, 0, 4); |
9505 | 1861 |
/* 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
|
1862 |
_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
|
1863 |
} |
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
|
1864 |
} |
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
|
1865 |
} 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
|
1866 |
/* 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
|
1867 |
* 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
|
1868 |
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
|
1869 |
} |
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
|
1870 |
|
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
|
1871 |
/* 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
|
1872 |
* 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
|
1873 |
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
|
1874 |
for (TileIndex t = 0; t < map_size; t++) { |
5958 | 1875 |
switch (GetTileType(t)) { |
1876 |
case MP_RAILWAY: |
|
1877 |
if (HasSignals(t)) { |
|
9505 | 1878 |
/* convert PBS signals to combo-signals */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1879 |
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
|
1880 |
|
9505 | 1881 |
/* move the signal variant back */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1882 |
SetSignalVariant(t, TRACK_X, HasBit(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1883 |
ClrBit(_m[t].m2, 3); |
5958 | 1884 |
} |
1885 |
||
9505 | 1886 |
/* Clear PBS reservation on track */ |
5958 | 1887 |
if (!IsTileDepotType(t, TRANSPORT_RAIL)) { |
1888 |
SB(_m[t].m4, 4, 4, 0); |
|
1889 |
} else { |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1890 |
ClrBit(_m[t].m3, 6); |
5958 | 1891 |
} |
1892 |
break; |
|
1893 |
||
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9686
diff
changeset
|
1894 |
case MP_ROAD: /* Clear PBS reservation on crossing */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1895 |
if (IsLevelCrossing(t)) ClrBit(_m[t].m5, 0); |
5958 | 1896 |
break; |
1897 |
||
9505 | 1898 |
case MP_STATION: /* Clear PBS reservation on station */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
1899 |
ClrBit(_m[t].m3, 6); |
5958 | 1900 |
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
|
1901 |
|
5958 | 1902 |
default: break; |
1903 |
} |
|
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1904 |
} |
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
|
1905 |
} |
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
|
1906 |
|
3121
2e50f731567a
(svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents:
3075
diff
changeset
|
1907 |
if (CheckSavegameVersion(22)) UpdatePatches(); |
2e50f731567a
(svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents:
3075
diff
changeset
|
1908 |
|
3431 | 1909 |
if (CheckSavegameVersion(25)) { |
1910 |
Vehicle *v; |
|
1911 |
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
|
1912 |
if (v->type == VEH_ROAD) { |
3431 | 1913 |
v->vehstatus &= ~0x40; |
1914 |
v->u.road.slot = NULL; |
|
1915 |
v->u.road.slot_age = 0; |
|
1916 |
} |
|
1917 |
} |
|
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
|
1918 |
} 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
|
1919 |
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
|
1920 |
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
|
1921 |
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
|
1922 |
} |
3431 | 1923 |
} |
1924 |
||
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
|
1925 |
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
|
1926 |
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
|
1927 |
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
|
1928 |
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
|
1929 |
} |
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
|
1930 |
} |
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
|
1931 |
|
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3891
diff
changeset
|
1932 |
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
|
1933 |
|
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
|
1934 |
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
|
1935 |
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
1936 |
FOR_ALL_PLAYERS(p) { |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
1937 |
p->avail_railtypes = GetPlayerRailtypes(p->index); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
1938 |
p->avail_roadtypes = GetPlayerRoadtypes(p->index); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
1939 |
} |
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
2100
diff
changeset
|
1940 |
|
3765
e057e2b740d4
(svn r4757) - Newstations: add saveload support for custom station speclists
peter1138
parents:
3678
diff
changeset
|
1941 |
if (!CheckSavegameVersion(27)) AfterLoadStations(); |
e057e2b740d4
(svn r4757) - Newstations: add saveload support for custom station speclists
peter1138
parents:
3678
diff
changeset
|
1942 |
|
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
|
1943 |
/* 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
|
1944 |
* 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
|
1945 |
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
|
1946 |
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
|
1947 |
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
|
1948 |
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
|
1949 |
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
|
1950 |
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
|
1951 |
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
|
1952 |
|
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1953 |
_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
|
1954 |
_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
|
1955 |
|
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1956 |
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
|
1957 |
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
|
1958 |
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
|
1959 |
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
|
1960 |
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
|
1961 |
|
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1962 |
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
|
1963 |
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
|
1964 |
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
|
1965 |
} |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1966 |
} |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4323
diff
changeset
|
1967 |
|
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
|
1968 |
/* 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
|
1969 |
* 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
|
1970 |
* 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
|
1971 |
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
|
1972 |
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
|
1973 |
|
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1974 |
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
|
1975 |
if (IsTileType(t, MP_CLEAR) && IsClearGround(t, CLEAR_FIELDS)) { |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1976 |
/* remove fields */ |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1977 |
MakeClear(t, CLEAR_GRASS, 3); |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1978 |
} else if (IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)) { |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1979 |
/* remove fences around fields */ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1980 |
SetFenceSE(t, 0); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
1981 |
SetFenceSW(t, 0); |
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
|
1982 |
} |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
1983 |
} |
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
|
1984 |
|
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
|
1985 |
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
|
1986 |
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
|
1987 |
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
1988 |
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
|
1989 |
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
|
1990 |
} |
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
|
1991 |
} |
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
|
1992 |
} |
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
|
1993 |
|
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
|
1994 |
/* 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
|
1995 |
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
|
1996 |
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
|
1997 |
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
|
1998 |
|
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
|
1999 |
FOR_ALL_ORDERS(order) { |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
2000 |
order->SetRefit(CT_NO_REFIT); |
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
|
2001 |
} |
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
|
2002 |
|
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
|
2003 |
FOR_ALL_VEHICLES(v) { |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
2004 |
v->current_order.SetRefit(CT_NO_REFIT); |
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
|
2005 |
} |
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
|
2006 |
} |
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
|
2007 |
|
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
|
2008 |
/* 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
|
2009 |
* preference of a user, let elrails enabled; it can be disabled manually */ |
6099 | 2010 |
if (CheckSavegameVersion(38)) _patches.disable_elrails = false; |
2011 |
/* do the same as when elrails were enabled/disabled manually just now */ |
|
2012 |
SettingsDisableElrail(_patches.disable_elrails); |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
2013 |
InitializeRailGUI(); |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5108
diff
changeset
|
2014 |
|
9476 | 2015 |
/* From version 53, the map array was changed for house tiles to allow |
2016 |
* space for newhouses grf features. A new byte, m7, was also added. */ |
|
2017 |
if (CheckSavegameVersion(53)) { |
|
2018 |
for (TileIndex t = 0; t < map_size; t++) { |
|
2019 |
if (IsTileType(t, MP_HOUSE)) { |
|
2020 |
if (GB(_m[t].m3, 6, 2) != TOWN_HOUSE_COMPLETED) { |
|
2021 |
/* Move the construction stage from m3[7..6] to m5[5..4]. |
|
2022 |
* The construction counter does not have to move. */ |
|
2023 |
SB(_m[t].m5, 3, 2, GB(_m[t].m3, 6, 2)); |
|
2024 |
SB(_m[t].m3, 6, 2, 0); |
|
2025 |
||
2026 |
/* The "house is completed" bit is now in m6[2]. */ |
|
2027 |
SetHouseCompleted(t, false); |
|
2028 |
} else { |
|
2029 |
/* The "lift has destination" bit has been moved from |
|
2030 |
* m5[7] to m7[0]. */ |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2031 |
SB(_me[t].m7, 0, 1, HasBit(_m[t].m5, 7)); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2032 |
ClrBit(_m[t].m5, 7); |
9476 | 2033 |
|
2034 |
/* The "lift is moving" bit has been removed, as it does |
|
2035 |
* the same job as the "lift has destination" bit. */ |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2036 |
ClrBit(_m[t].m1, 7); |
9476 | 2037 |
|
2038 |
/* The position of the lift goes from m1[7..0] to m6[7..2], |
|
2039 |
* making m1 totally free, now. The lift position does not |
|
2040 |
* have to be a full byte since the maximum value is 36. */ |
|
2041 |
SetLiftPosition(t, GB(_m[t].m1, 0, 6 )); |
|
2042 |
||
2043 |
_m[t].m1 = 0; |
|
2044 |
_m[t].m3 = 0; |
|
2045 |
SetHouseCompleted(t, true); |
|
2046 |
} |
|
2047 |
} |
|
2048 |
} |
|
2049 |
} |
|
2050 |
||
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
2051 |
/* Check and update house and town values */ |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
2052 |
UpdateHousesAndTowns(); |
9476 | 2053 |
|
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
|
2054 |
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
|
2055 |
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
|
2056 |
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
|
2057 |
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
|
2058 |
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
|
2059 |
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
|
2060 |
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
|
2061 |
|
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
2062 |
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
|
2063 |
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
|
2064 |
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
|
2065 |
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
|
2066 |
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
|
2067 |
|
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
2068 |
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
|
2069 |
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
|
2070 |
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
|
2071 |
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
|
2072 |
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
|
2073 |
|
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
2074 |
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
|
2075 |
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
|
2076 |
} |
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
2077 |
} |
5957
b28cf25e7e18
(svn r8183) When iterating over the map in AfterLoadGame() do it the same way for all loops
tron
parents:
5943
diff
changeset
|
2078 |
} |
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
|
2079 |
} |
a6f0e780d714
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5676
diff
changeset
|
2080 |
|
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
|
2081 |
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
|
2082 |
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
|
2083 |
/* If we remove a station while cargo from it is still enroute, payment calculation will assume |
9629 | 2084 |
* 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
|
2085 |
* stores the coordinates, preserving them even if the station is removed. However, if a game is loaded |
9629 | 2086 |
* 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
|
2087 |
* 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
|
2088 |
*/ |
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
|
2089 |
FOR_ALL_VEHICLES(v) { |
9629 | 2090 |
const CargoList::List *packets = v->cargo.Packets(); |
2091 |
for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) { |
|
2092 |
CargoPacket *cp = *it; |
|
2093 |
cp->source_xy = IsValidStationID(cp->source) ? GetStation(cp->source)->xy : v->tile; |
|
2094 |
cp->loaded_at_xy = cp->source_xy; |
|
2095 |
} |
|
2096 |
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
|
2097 |
} |
9403 | 2098 |
|
2099 |
/* Store position of the station where the goods come from, so there |
|
2100 |
* are no very high payments when stations get removed. However, if the |
|
2101 |
* station where the goods came from is already removed, the source |
|
2102 |
* information is lost. In that case we set it to the position of this |
|
2103 |
* station */ |
|
2104 |
Station *st; |
|
2105 |
FOR_ALL_STATIONS(st) { |
|
2106 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
|
2107 |
GoodsEntry *ge = &st->goods[c]; |
|
2108 |
||
9629 | 2109 |
const CargoList::List *packets = ge->cargo.Packets(); |
2110 |
for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) { |
|
2111 |
CargoPacket *cp = *it; |
|
2112 |
cp->source_xy = IsValidStationID(cp->source) ? GetStation(cp->source)->xy : st->xy; |
|
2113 |
cp->loaded_at_xy = cp->source_xy; |
|
9403 | 2114 |
} |
2115 |
} |
|
2116 |
} |
|
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
|
2117 |
} |
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
|
2118 |
|
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
|
2119 |
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
|
2120 |
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
|
2121 |
/* 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
|
2122 |
* 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
|
2123 |
* 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
|
2124 |
* 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
|
2125 |
* 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
|
2126 |
FOR_ALL_VEHICLES(v) { |
9629 | 2127 |
const CargoList::List *packets = v->cargo.Packets(); |
2128 |
for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) { |
|
2129 |
CargoPacket *cp = *it; |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2130 |
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
|
2131 |
} |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2132 |
ClrBit(v->vehicle_flags, 2); |
9629 | 2133 |
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
|
2134 |
} |
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
|
2135 |
} |
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
|
2136 |
|
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
|
2137 |
/* 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
|
2138 |
* 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
|
2139 |
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
|
2140 |
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
|
2141 |
FOR_ALL_STATIONS(st) { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2142 |
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
|
2143 |
} |
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
|
2144 |
} |
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
|
2145 |
|
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
|
2146 |
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
|
2147 |
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
|
2148 |
/* 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
|
2149 |
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
|
2150 |
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
|
2151 |
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
|
2152 |
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
|
2153 |
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
|
2154 |
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
|
2155 |
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
|
2156 |
} |
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
|
2157 |
} |
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
|
2158 |
} |
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
|
2159 |
|
6516
ee6d057b9850
(svn r8969) -Codechange: rework of the player face bits.
rubidium
parents:
6501
diff
changeset
|
2160 |
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
|
2161 |
|
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
|
2162 |
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
|
2163 |
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
|
2164 |
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
|
2165 |
_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
|
2166 |
} |
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
|
2167 |
} |
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
|
2168 |
} |
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
|
2169 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2170 |
/* A patch option containing the proportion of towns that grow twice as |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2171 |
* fast was added in version 54. From version 56 this is now saved in the |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2172 |
* town as cities can be built specifically in the scenario editor. */ |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2173 |
if (CheckSavegameVersion(56)) { |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2174 |
Town *t; |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2175 |
|
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2176 |
FOR_ALL_TOWNS(t) { |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2177 |
if (_patches.larger_towns != 0 && (t->index % _patches.larger_towns) == 0) { |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2178 |
t->larger_town = true; |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2179 |
} |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2180 |
} |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2181 |
} |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2182 |
|
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2183 |
if (CheckSavegameVersion(57)) { |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2184 |
Vehicle *v; |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2185 |
/* Added a FIFO queue of vehicles loading at stations */ |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2186 |
FOR_ALL_VEHICLES(v) { |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2187 |
if ((v->type != VEH_TRAIN || IsFrontEngine(v)) && // for all locs |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2188 |
!(v->vehstatus & (VS_STOPPED | VS_CRASHED)) && // not stopped or crashed |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
2189 |
v->current_order.IsType(OT_LOADING)) { // loading |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2190 |
GetStation(v->last_station_visited)->loading_vehicles.push_back(v); |
9624 | 2191 |
|
2192 |
/* The loading finished flag is *only* set when actually completely |
|
2193 |
* finished. Because the vehicle is loading, it is not finished. */ |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2194 |
ClrBit(v->vehicle_flags, VF_LOADING_FINISHED); |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2195 |
} |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2196 |
} |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2197 |
} else if (CheckSavegameVersion(59)) { |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2198 |
/* For some reason non-loading vehicles could be in the station's loading vehicle list */ |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2199 |
|
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2200 |
Station *st; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2201 |
FOR_ALL_STATIONS(st) { |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2202 |
std::list<Vehicle *>::iterator iter; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2203 |
for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end();) { |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2204 |
Vehicle *v = *iter; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2205 |
iter++; |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
2206 |
if (!v->current_order.IsType(OT_LOADING)) st->loading_vehicles.remove(v); |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2207 |
} |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2208 |
} |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2209 |
} |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
2210 |
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2211 |
if (CheckSavegameVersion(58)) { |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2212 |
/* patch difficulty number_industries other then zero get bumped to +1 |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2213 |
* since a new option (very low at position1) has been added */ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2214 |
if (_opt.diff.number_industries > 0) { |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2215 |
_opt.diff.number_industries++; |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2216 |
} |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2217 |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2218 |
/* Same goes for number of towns, although no test is needed, just an increment */ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2219 |
_opt.diff.number_towns++; |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2220 |
} |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
2221 |
|
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
2222 |
if (CheckSavegameVersion(64)) { |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
2223 |
/* copy the signal type/variant and move signal states bits */ |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
2224 |
for (TileIndex t = 0; t < map_size; t++) { |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
2225 |
if (IsTileType(t, MP_RAILWAY) && HasSignals(t)) { |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
2226 |
SetSignalStates(t, GB(_m[t].m2, 4, 4)); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
2227 |
SetSignalVariant(t, INVALID_TRACK, GetSignalVariant(t, TRACK_X)); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
2228 |
SetSignalType(t, INVALID_TRACK, GetSignalType(t, TRACK_X)); |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2229 |
ClrBit(_m[t].m2, 7); |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
2230 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
2231 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
2232 |
} |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
2233 |
|
9629 | 2234 |
if (CheckSavegameVersion(69)) { |
2235 |
/* In some old savegames a bit was cleared when it should not be cleared */ |
|
2236 |
Vehicle *v; |
|
2237 |
FOR_ALL_VEHICLES(v) { |
|
2238 |
if (v->type == VEH_ROAD && (v->u.road.state == 250 || v->u.road.state == 251)) { |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2239 |
SetBit(v->u.road.state, RVS_IS_STOPPING); |
9629 | 2240 |
} |
2241 |
} |
|
2242 |
} |
|
2243 |
||
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2244 |
if (CheckSavegameVersion(70)) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2245 |
/* Added variables to support newindustries */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2246 |
Industry *i; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2247 |
FOR_ALL_INDUSTRIES(i) i->founder = OWNER_NONE; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2248 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
2249 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2250 |
/* From version 82, old style canals (above sealevel (0), WATER owner) are no longer supported. |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2251 |
Replace the owner for those by OWNER_NONE. */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2252 |
if (CheckSavegameVersion(82)) { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2253 |
for (TileIndex t = 0; t < map_size; t++) { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2254 |
if (IsTileType(t, MP_WATER) && |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2255 |
GetWaterTileType(t) == WATER_TILE_CLEAR && |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2256 |
GetTileOwner(t) == OWNER_WATER && |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2257 |
TileHeight(t) != 0) { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2258 |
SetTileOwner(t, OWNER_NONE); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2259 |
} |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2260 |
} |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2261 |
} |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2262 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2263 |
/* |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2264 |
* Add the 'previous' owner to the ship depots so we can reset it with |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2265 |
* the correct values when it gets destroyed. This prevents that |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2266 |
* someone can remove canals owned by somebody else and it prevents |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2267 |
* making floods using the removal of ship depots. |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2268 |
*/ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2269 |
if (CheckSavegameVersion(83)) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2270 |
for (TileIndex t = 0; t < map_size; t++) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2271 |
if (IsTileType(t, MP_WATER) && IsShipDepot(t)) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2272 |
_m[t].m4 = (TileHeight(t) == 0) ? OWNER_WATER : OWNER_NONE; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2273 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2274 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2275 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2276 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2277 |
if (CheckSavegameVersion(74)) { |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2278 |
Station *st; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2279 |
FOR_ALL_STATIONS(st) { |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2280 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2281 |
st->goods[c].last_speed = 0; |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2282 |
if (st->goods[c].cargo.Count() != 0) SetBit(st->goods[c].acceptance_pickup, GoodsEntry::PICKUP); |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2283 |
} |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2284 |
} |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2285 |
} |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
2286 |
|
9704 | 2287 |
if (CheckSavegameVersion(78)) { |
2288 |
Industry *i; |
|
2289 |
uint j; |
|
2290 |
FOR_ALL_INDUSTRIES(i) { |
|
2291 |
const IndustrySpec *indsp = GetIndustrySpec(i->type); |
|
2292 |
for (j = 0; j < lengthof(i->produced_cargo); j++) { |
|
2293 |
i->produced_cargo[j] = indsp->produced_cargo[j]; |
|
2294 |
} |
|
2295 |
for (j = 0; j < lengthof(i->accepts_cargo); j++) { |
|
2296 |
i->accepts_cargo[j] = indsp->accepts_cargo[j]; |
|
2297 |
} |
|
2298 |
} |
|
2299 |
} |
|
9624 | 2300 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2301 |
/* Before version 81, the density of grass was always stored as zero, and |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2302 |
* grassy trees were always drawn fully grassy. Furthermore, trees on rough |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2303 |
* land used to have zero density, now they have full density. Therefore, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2304 |
* make all grassy/rough land trees have a density of 3. */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2305 |
if (CheckSavegameVersion(81)) { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2306 |
for (TileIndex t = 0; t < map_size; t++) { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2307 |
if (GetTileType(t) == MP_TREES) { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2308 |
TreeGround groundType = GetTreeGround(t); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2309 |
if (groundType != TREE_GROUND_SNOW_DESERT) SetTreeGroundDensity(t, groundType, 3); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2310 |
} |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2311 |
} |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2312 |
} |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9704
diff
changeset
|
2313 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2314 |
if (CheckSavegameVersion(84)) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2315 |
/* Update go to buoy orders because they are just waypoints */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2316 |
Order *order; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2317 |
FOR_ALL_ORDERS(order) { |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
2318 |
if (order->IsType(OT_GOTO_STATION) && GetStation(order->GetDestination())->IsBuoy()) { |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
2319 |
order->SetLoadType(0); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
2320 |
order->SetUnloadType(0); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2321 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2322 |
} |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2323 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2324 |
/* Set all share owners to PLAYER_SPECTATOR for |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2325 |
* 1) all inactive players |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2326 |
* (when inactive players were stored in the savegame - TTD, TTDP and some |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2327 |
* *really* old revisions of OTTD; else it is already set in InitializePlayers()) |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2328 |
* 2) shares that are owned by inactive players or self |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2329 |
* (caused by cheating players in earlier revisions) */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2330 |
Player *p; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2331 |
FOR_ALL_PLAYERS(p) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2332 |
if (!p->is_active) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2333 |
for (uint i = 0; i < 4; i++) { p->share_owners[i] = PLAYER_SPECTATOR; } |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2334 |
} else { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2335 |
for (uint i = 0; i < 4; i++) { |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2336 |
PlayerID o = p->share_owners[i]; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2337 |
if (o == PLAYER_SPECTATOR) continue; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2338 |
if (!IsValidPlayer(o) || o == p->index || !GetPlayer(o)->is_active) p->share_owners[i] = PLAYER_SPECTATOR; |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2339 |
} |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2340 |
} |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2341 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2342 |
} |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
2343 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2344 |
if (CheckSavegameVersion(86)) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2345 |
for (TileIndex t = 0; t < map_size; t++) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2346 |
/* Now all crossings should be in correct state */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2347 |
if (IsLevelCrossingTile(t)) UpdateLevelCrossing(t, false); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2348 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2349 |
/* Move river flag and update canals to use water class */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2350 |
if (IsTileType(t, MP_WATER)) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2351 |
if (_m[t].m5 == 2) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2352 |
MakeRiver(t, Random()); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2353 |
} else { |
9732 | 2354 |
if (IsWater(t)) { |
2355 |
Owner o = GetTileOwner(t); |
|
2356 |
if (o == OWNER_WATER) { |
|
2357 |
MakeWater(t); |
|
2358 |
} else { |
|
2359 |
MakeCanal(t, o, Random()); |
|
2360 |
} |
|
2361 |
} else if (IsShipDepot(t)) { |
|
2362 |
Owner o = (Owner)_m[t].m4; // Original water owner |
|
2363 |
SetWaterClass(t, o == OWNER_WATER ? WATER_CLASS_SEA : WATER_CLASS_CANAL); |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2364 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2365 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2366 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2367 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2368 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2369 |
/* Update locks, depots, docks and buoys to have a water class based |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2370 |
* on its neighbouring tiles. Done after river and canal updates to |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2371 |
* ensure neighbours are correct. */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2372 |
for (TileIndex t = 0; t < map_size; t++) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2373 |
if (GetTileSlope(t, NULL) != SLOPE_FLAT) continue; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2374 |
|
9732 | 2375 |
if (IsTileType(t, MP_WATER) && IsLock(t)) SetWaterClassDependingOnSurroundings(t); |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2376 |
if (IsTileType(t, MP_STATION) && (IsDock(t) || IsBuoy(t))) SetWaterClassDependingOnSurroundings(t); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2377 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2378 |
} |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
2379 |
|
9732 | 2380 |
if (CheckSavegameVersion(87)) { |
2381 |
for (TileIndex t = 0; t < map_size; t++) { |
|
2382 |
/* skip oil rigs at borders! */ |
|
2383 |
if ((IsTileType(t, MP_WATER) || IsBuoyTile(t)) && |
|
2384 |
(TileX(t) == 0 || TileY(t) == 0 || TileX(t) == MapMaxX() - 1 || TileY(t) == MapMaxY() - 1)) { |
|
2385 |
/* Some version 86 savegames have wrong water class at map borders (under buoy, or after removing buoy). |
|
2386 |
* This conversion has to be done before buoys with invalid owner are removed. */ |
|
2387 |
SetWaterClass(t, WATER_CLASS_SEA); |
|
2388 |
} |
|
2389 |
||
2390 |
if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) { |
|
2391 |
Owner o = GetTileOwner(t); |
|
2392 |
if (IsValidPlayer(o) && !GetPlayer(o)->is_active) { |
|
2393 |
_current_player = o; |
|
2394 |
ChangeTileOwner(t, o, PLAYER_SPECTATOR); |
|
2395 |
} |
|
2396 |
if (IsBuoyTile(t)) { |
|
2397 |
/* reset buoy owner to OWNER_NONE in the station struct |
|
2398 |
* (even if it is owned by active player) */ |
|
2399 |
GetStationByTile(t)->owner = OWNER_NONE; |
|
2400 |
} |
|
2401 |
} else if (IsTileType(t, MP_ROAD)) { |
|
2402 |
/* works for all RoadTileType */ |
|
2403 |
for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) { |
|
2404 |
/* update even non-existing road types to update tile owner too */ |
|
2405 |
Owner o = GetRoadOwner(t, rt); |
|
2406 |
if (IsValidPlayer(o) && !GetPlayer(o)->is_active) SetRoadOwner(t, rt, OWNER_NONE); |
|
2407 |
} |
|
2408 |
if (IsLevelCrossing(t)) { |
|
2409 |
Owner o = GetTileOwner(t); |
|
2410 |
if (!GetPlayer(o)->is_active) { |
|
2411 |
/* remove leftover rail piece from crossing (from very old savegames) */ |
|
2412 |
_current_player = o; |
|
2413 |
DoCommand(t, 0, GetCrossingRailTrack(t), DC_EXEC | DC_BANKRUPT, CMD_REMOVE_SINGLE_RAIL); |
|
2414 |
} |
|
2415 |
} |
|
2416 |
} |
|
2417 |
} |
|
2418 |
||
2419 |
/* Convert old PF settings to new */ |
|
2420 |
if (_patches.yapf.rail_use_yapf) { |
|
2421 |
_patches.pathfinder_for_trains = VPF_YAPF; |
|
2422 |
} else { |
|
2423 |
_patches.pathfinder_for_trains = (_patches.new_pathfinding_all ? VPF_NPF : VPF_NTP); |
|
2424 |
} |
|
2425 |
||
2426 |
if (_patches.yapf.road_use_yapf) { |
|
2427 |
_patches.pathfinder_for_roadvehs = VPF_YAPF; |
|
2428 |
} else { |
|
2429 |
_patches.pathfinder_for_roadvehs = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF); |
|
2430 |
} |
|
2431 |
||
2432 |
if (_patches.yapf.ship_use_yapf) { |
|
2433 |
_patches.pathfinder_for_ships = VPF_YAPF; |
|
2434 |
} else { |
|
2435 |
_patches.pathfinder_for_ships = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF); |
|
2436 |
} |
|
2437 |
} |
|
2438 |
||
2439 |
if (CheckSavegameVersion(88)) { |
|
2440 |
/* Profits are now with 8 bit fract */ |
|
2441 |
Vehicle *v; |
|
2442 |
FOR_ALL_VEHICLES(v) { |
|
2443 |
v->profit_this_year <<= 8; |
|
2444 |
v->profit_last_year <<= 8; |
|
2445 |
v->running_ticks = 0; |
|
2446 |
} |
|
2447 |
} |
|
2448 |
||
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
2449 |
if (CheckSavegameVersion(91)) { |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
2450 |
/* Increase HouseAnimationFrame from 5 to 7 bits */ |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
2451 |
for (TileIndex t = 0; t < map_size; t++) { |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
2452 |
if (IsTileType(t, MP_HOUSE) && GetHouseType(t) >= NEW_HOUSE_OFFSET) { |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
2453 |
SetHouseAnimationFrame(t, GB(_m[t].m6, 3, 5)); |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
2454 |
} |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
2455 |
} |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
2456 |
} |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
2457 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2458 |
return InitializeWindowsAndCaches(); |
0 | 2459 |
} |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2460 |
|
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2461 |
/** 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
|
2462 |
* version of AfterLoadGame(). |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2463 |
* 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
|
2464 |
* 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
|
2465 |
* 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
|
2466 |
* removed or added and changed statistics */ |
6573 | 2467 |
void ReloadNewGRFData() |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2468 |
{ |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2469 |
/* reload grf data */ |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2470 |
GfxLoadSprites(); |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2471 |
LoadStringWidthTable(); |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2472 |
/* reload vehicles */ |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2473 |
ResetVehiclePosHash(); |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
2474 |
AfterLoadVehicles(false); |
6522
bf0da9f42953
(svn r8976) -Codechange: Reinitialize all engines after grf files have been reloaded/changed.
Darkvater
parents:
6519
diff
changeset
|
2475 |
StartupEngines(); |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2476 |
/* 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
|
2477 |
AfterLoadWaypoints(); |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2478 |
AfterLoadStations(); |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
2479 |
/* Check and update house and town values */ |
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
2480 |
UpdateHousesAndTowns(); |
5352
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2481 |
/* 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
|
2482 |
MarkWholeScreenDirty(); |
82a50c80b0c4
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5350
diff
changeset
|
2483 |
} |