author | Darkvater |
Sun, 19 Mar 2006 09:03:25 +0000 | |
branch | 0.4.5 |
changeset 9941 | 2dd05b8458d9 |
parent 2944 | 7c392e7b51c6 |
child 2949 | 54f07f2a201a |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1317
f382f1b439c7
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
1314
diff
changeset
|
4 |
#include "string.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
497
diff
changeset
|
5 |
#include "table/strings.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1296
diff
changeset
|
6 |
#include "debug.h" |
2171
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
2163
diff
changeset
|
7 |
#include "driver.h" |
2162
c1ded3bd3d0c
(svn r2672) Move saving/loading related declarations to saveload.h
tron
parents:
2147
diff
changeset
|
8 |
#include "saveload.h" |
1309
dab90d4cbf2d
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
1301
diff
changeset
|
9 |
#include "strings.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
659
diff
changeset
|
10 |
#include "map.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1199
diff
changeset
|
11 |
#include "tile.h" |
0 | 12 |
|
13 |
#define VARDEF |
|
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1885
diff
changeset
|
14 |
#include "openttd.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2162
diff
changeset
|
15 |
#include "functions.h" |
1496
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1482
diff
changeset
|
16 |
#include "mixer.h" |
1349
07514c2cc6d1
(svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
1329
diff
changeset
|
17 |
#include "spritecache.h" |
0 | 18 |
#include "gfx.h" |
2340
0a9f3eeccb96
(svn r2866) Move all functions and tables which aren't directly involved in managing the sprite heap to a new file gfxinit.c.
tron
parents:
2322
diff
changeset
|
19 |
#include "gfxinit.h" |
0 | 20 |
#include "gui.h" |
21 |
#include "station.h" |
|
22 |
#include "vehicle.h" |
|
23 |
#include "viewport.h" |
|
24 |
#include "window.h" |
|
25 |
#include "player.h" |
|
26 |
#include "command.h" |
|
27 |
#include "town.h" |
|
28 |
#include "industry.h" |
|
29 |
#include "news.h" |
|
30 |
#include "engine.h" |
|
31 |
#include "sound.h" |
|
32 |
#include "economy.h" |
|
33 |
#include "fileio.h" |
|
34 |
#include "hal.h" |
|
35 |
#include "airport.h" |
|
126 | 36 |
#include "console.h" |
430 | 37 |
#include "screenshot.h" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
38 |
#include "network.h" |
988
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
983
diff
changeset
|
39 |
#include "signs.h" |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1310
diff
changeset
|
40 |
#include "depot.h" |
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1501
diff
changeset
|
41 |
#include "waypoint.h" |
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
42 |
#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
|
43 |
#include "train.h" |
0 | 44 |
|
45 |
#include <stdarg.h> |
|
46 |
||
2051 | 47 |
void GenerateWorld(int mode, uint size_x, uint size_y); |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1036
diff
changeset
|
48 |
void CallLandscapeTick(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1036
diff
changeset
|
49 |
void IncreaseDate(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1036
diff
changeset
|
50 |
void DoPaletteAnimations(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1036
diff
changeset
|
51 |
void MusicLoop(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1036
diff
changeset
|
52 |
void ResetMusic(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1036
diff
changeset
|
53 |
void InitializeStations(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1036
diff
changeset
|
54 |
void DeleteAllPlayerStations(void); |
0 | 55 |
|
56 |
extern void SetDifficultyLevel(int mode, GameOptions *gm_opt); |
|
57 |
extern void DoStartupNewPlayer(bool is_ai); |
|
58 |
extern void ShowOSErrorBox(const char *buf); |
|
59 |
||
1436 | 60 |
/* TODO: usrerror() for errors which are not of an internal nature but |
61 |
* caused by the user, i.e. missing files or fatal configuration errors. |
|
62 |
* Post-0.4.0 since Celestar doesn't want this in SVN before. --pasky */ |
|
63 |
||
2639 | 64 |
void CDECL error(const char* s, ...) |
65 |
{ |
|
0 | 66 |
va_list va; |
67 |
char buf[512]; |
|
2639 | 68 |
|
0 | 69 |
va_start(va, s); |
70 |
vsprintf(buf, s, va); |
|
71 |
va_end(va); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
72 |
|
0 | 73 |
ShowOSErrorBox(buf); |
2639 | 74 |
if (_video_driver != NULL) _video_driver->stop(); |
0 | 75 |
|
76 |
assert(0); |
|
77 |
exit(1); |
|
78 |
} |
|
79 |
||
80 |
void CDECL ShowInfoF(const char *str, ...) |
|
81 |
{ |
|
82 |
va_list va; |
|
83 |
char buf[1024]; |
|
84 |
va_start(va, str); |
|
85 |
vsprintf(buf, str, va); |
|
86 |
va_end(va); |
|
87 |
ShowInfo(buf); |
|
88 |
} |
|
89 |
||
90 |
||
1310
85cde2193afc
(svn r1814) Let ReadFileToMem() return void* (instead of byte*) because we don't know what the caller wants to do with the data
tron
parents:
1309
diff
changeset
|
91 |
void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize) |
0 | 92 |
{ |
93 |
FILE *in; |
|
1105 | 94 |
byte *mem; |
0 | 95 |
size_t len; |
96 |
||
97 |
in = fopen(filename, "rb"); |
|
2639 | 98 |
if (in == NULL) return NULL; |
0 | 99 |
|
100 |
fseek(in, 0, SEEK_END); |
|
101 |
len = ftell(in); |
|
102 |
fseek(in, 0, SEEK_SET); |
|
1105 | 103 |
if (len > maxsize || (mem = malloc(len + 1)) == NULL) { |
0 | 104 |
fclose(in); |
105 |
return NULL; |
|
106 |
} |
|
1105 | 107 |
mem[len] = 0; |
0 | 108 |
if (fread(mem, len, 1, in) != 1) { |
109 |
fclose(in); |
|
110 |
free(mem); |
|
111 |
return NULL; |
|
112 |
} |
|
113 |
fclose(in); |
|
114 |
||
115 |
*lenp = len; |
|
116 |
return mem; |
|
117 |
} |
|
118 |
||
2831
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
119 |
extern const char _openttd_revision[]; |
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
120 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1036
diff
changeset
|
121 |
static void showhelp(void) |
0 | 122 |
{ |
123 |
char buf[4096], *p; |
|
124 |
||
2831
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
125 |
p = buf; |
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
126 |
|
2832
acf08469a0c6
(svn r3380) -Fix: removed 'size' from r3379, because it was pretty silly
truelight
parents:
2831
diff
changeset
|
127 |
p += sprintf(p, "OpenTTD %s\n", _openttd_revision); |
acf08469a0c6
(svn r3380) -Fix: removed 'size' from r3379, because it was pretty silly
truelight
parents:
2831
diff
changeset
|
128 |
p += sprintf(p, |
2831
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
129 |
"\n" |
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
130 |
"\n" |
0 | 131 |
"Command line options:\n" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
132 |
" -v drv = Set video driver (see below)\n" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
133 |
" -s drv = Set sound driver (see below)\n" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
134 |
" -m drv = Set music driver (see below)\n" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
135 |
" -r res = Set resolution (for instance 800x600)\n" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
136 |
" -h = Display this help text\n" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
137 |
" -t date = Set starting date\n" |
1440
2eb4dd1e0465
(svn r1944) Make --help output for -d at least somewhat useful.
pasky
parents:
1436
diff
changeset
|
138 |
" -d [[fac=]lvl[,...]]= Debug mode\n" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
139 |
" -e = Start Editor\n" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
140 |
" -g [savegame] = Start new/save game immediately\n" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
141 |
" -G seed = Set random seed\n" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
142 |
" -n [ip#player:port] = Start networkgame\n" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
143 |
" -D = Start dedicated server\n" |
770
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
768
diff
changeset
|
144 |
#if !defined(__MORPHOS__) && !defined(__AMIGA__) |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
145 |
" -f = Fork into the background (dedicated only)\n" |
770
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
768
diff
changeset
|
146 |
#endif |
2831
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
147 |
" -i = Force to use the DOS palette\n" |
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
148 |
" (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
|
149 |
" -c config_file = Use 'config_file' instead of 'openttd.cfg'\n" |
510c08cd43d2
(svn r3379) -Fix: protect showhelp against any possible overflow
truelight
parents:
2828
diff
changeset
|
150 |
"\n" |
0 | 151 |
); |
152 |
||
2832
acf08469a0c6
(svn r3380) -Fix: removed 'size' from r3379, because it was pretty silly
truelight
parents:
2831
diff
changeset
|
153 |
p = GetDriverList(p); |
0 | 154 |
|
155 |
ShowInfo(buf); |
|
156 |
} |
|
157 |
||
158 |
||
159 |
typedef struct { |
|
160 |
char *opt; |
|
161 |
int numleft; |
|
162 |
char **argv; |
|
163 |
const char *options; |
|
164 |
char *cont; |
|
165 |
} MyGetOptData; |
|
166 |
||
167 |
static void MyGetOptInit(MyGetOptData *md, int argc, char **argv, const char *options) |
|
168 |
{ |
|
169 |
md->cont = NULL; |
|
170 |
md->numleft = argc; |
|
171 |
md->argv = argv; |
|
172 |
md->options = options; |
|
173 |
} |
|
174 |
||
175 |
static int MyGetOpt(MyGetOptData *md) |
|
176 |
{ |
|
177 |
char *s,*r,*t; |
|
178 |
||
2639 | 179 |
s = md->cont; |
180 |
if (s != NULL) |
|
0 | 181 |
goto md_continue_here; |
182 |
||
2639 | 183 |
for (;;) { |
184 |
if (--md->numleft < 0) return -1; |
|
0 | 185 |
|
186 |
s = *md->argv++; |
|
187 |
if (*s == '-') { |
|
188 |
md_continue_here:; |
|
189 |
s++; |
|
190 |
if (*s != 0) { |
|
191 |
// Found argument, try to locate it in options. |
|
192 |
if (*s == ':' || (r = strchr(md->options, *s)) == NULL) { |
|
193 |
// ERROR! |
|
194 |
return -2; |
|
195 |
} |
|
196 |
if (r[1] == ':') { |
|
197 |
// Item wants an argument. Check if the argument follows, or if it comes as a separate arg. |
|
198 |
if (!*(t = s + 1)) { |
|
199 |
// It comes as a separate arg. Check if out of args? |
|
200 |
if (--md->numleft < 0 || *(t = *md->argv) == '-') { |
|
201 |
// Check if item is optional? |
|
202 |
if (r[2] != ':') |
|
203 |
return -2; |
|
204 |
md->numleft++; |
|
205 |
t = NULL; |
|
206 |
} else { |
|
207 |
md->argv++; |
|
208 |
} |
|
209 |
} |
|
210 |
md->opt = t; |
|
211 |
md->cont = NULL; |
|
212 |
return *s; |
|
213 |
} |
|
214 |
md->opt = NULL; |
|
215 |
md->cont = s; |
|
216 |
return *s; |
|
217 |
} |
|
218 |
} else { |
|
219 |
// This is currently not supported. |
|
220 |
return -2; |
|
221 |
} |
|
222 |
} |
|
223 |
} |
|
224 |
||
225 |
||
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2526
diff
changeset
|
226 |
static void ParseResolution(int res[2], const char* s) |
0 | 227 |
{ |
228 |
char *t = strchr(s, 'x'); |
|
229 |
if (t == NULL) { |
|
230 |
ShowInfoF("Invalid resolution '%s'", s); |
|
231 |
return; |
|
232 |
} |
|
233 |
||
1764
a976570cdbd9
(svn r2268) - Fix [ 1195595 ] high resolutions don't work. Clamp all possible inputs of resolutions to the maximum availble
Darkvater
parents:
1688
diff
changeset
|
234 |
res[0] = clamp(strtoul(s, NULL, 0), 64, MAX_SCREEN_WIDTH); |
a976570cdbd9
(svn r2268) - Fix [ 1195595 ] high resolutions don't work. Clamp all possible inputs of resolutions to the maximum availble
Darkvater
parents:
1688
diff
changeset
|
235 |
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
|
236 |
} |
0 | 237 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
238 |
static void InitializeDynamicVariables(void) |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
239 |
{ |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
240 |
/* 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
|
241 |
_station_sort = NULL; |
cbd68e5e31ac
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1264
diff
changeset
|
242 |
_town_sort = NULL; |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
243 |
_industry_sort = NULL; |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
244 |
} |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
245 |
|
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
246 |
static void UnInitializeDynamicVariables(void) |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
247 |
{ |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
248 |
/* Dynamic stuff needs to be free'd somewhere... */ |
1260
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1246
diff
changeset
|
249 |
CleanPool(&_town_pool); |
1267
cbd68e5e31ac
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1264
diff
changeset
|
250 |
CleanPool(&_industry_pool); |
1272
d3e09adb7736
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1268
diff
changeset
|
251 |
CleanPool(&_station_pool); |
1279
4f83fbde72de
(svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents:
1272
diff
changeset
|
252 |
CleanPool(&_vehicle_pool); |
1283
b9569cc0644f
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1279
diff
changeset
|
253 |
CleanPool(&_sign_pool); |
1314
d6a253cf92c3
(svn r1818) -Add: Dynamic orders (up to 64k orders)
truelight
parents:
1313
diff
changeset
|
254 |
CleanPool(&_order_pool); |
1260
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1246
diff
changeset
|
255 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
256 |
free(_station_sort); |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
257 |
free(_town_sort); |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
258 |
free(_industry_sort); |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
259 |
} |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
260 |
|
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
261 |
static void UnInitializeGame(void) |
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
262 |
{ |
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
263 |
UnInitWindowSystem(); |
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
|
264 |
|
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
|
265 |
free(_config_file); |
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
266 |
} |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
267 |
|
1095 | 268 |
static void LoadIntroGame(void) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
269 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
270 |
char filename[256]; |
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
271 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
272 |
_game_mode = GM_MENU; |
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
273 |
CLRBITS(_display_opt, DO_TRANS_BUILDINGS); // don't make buildings transparent in intro |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
274 |
_opt_ptr = &_opt_newgame; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
275 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
276 |
GfxLoadSprites(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
277 |
LoadStringWidthTable(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
278 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
279 |
// Setup main window |
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
280 |
ResetWindowSystem(); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
281 |
SetupColorsAndInitialWindow(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
282 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
283 |
// Generate a world. |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
284 |
sprintf(filename, "%sopntitle.dat", _path.data_dir); |
921 | 285 |
if (SaveOrLoad(filename, SL_LOAD) != SL_OK) { |
561
e3b9689745ab
(svn r970) Added 2nd data path for all non-windows OSes
bjarni
parents:
557
diff
changeset
|
286 |
#if defined SECOND_DATA_DIR |
e3b9689745ab
(svn r970) Added 2nd data path for all non-windows OSes
bjarni
parents:
557
diff
changeset
|
287 |
sprintf(filename, "%sopntitle.dat", _path.second_data_dir); |
e3b9689745ab
(svn r970) Added 2nd data path for all non-windows OSes
bjarni
parents:
557
diff
changeset
|
288 |
if (SaveOrLoad(filename, SL_LOAD) != SL_OK) |
e3b9689745ab
(svn r970) Added 2nd data path for all non-windows OSes
bjarni
parents:
557
diff
changeset
|
289 |
#endif |
2828
996de8e891c7
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2818
diff
changeset
|
290 |
GenerateWorld(GW_EMPTY, 64, 64); // if failed loading, make empty world. |
921 | 291 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
292 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
293 |
_pause = 0; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
294 |
_local_player = 0; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
295 |
MarkWholeScreenDirty(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
296 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
297 |
// Play main theme |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
298 |
if (_music_driver->is_song_playing()) ResetMusic(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
299 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
300 |
|
2290 | 301 |
#if defined(UNIX) && !defined(__MORPHOS__) |
774
258c11431acb
(svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents:
770
diff
changeset
|
302 |
extern void DedicatedFork(void); |
2290 | 303 |
#endif |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
304 |
|
0 | 305 |
int ttd_main(int argc, char* argv[]) |
306 |
{ |
|
307 |
MyGetOptData mgo; |
|
308 |
int i; |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
309 |
bool network = false; |
0 | 310 |
char *network_conn = NULL; |
1010
17470a8e5eb7
(svn r1509) Const correctness and add static where appropriate while touching the lines anyway
tron
parents:
1009
diff
changeset
|
311 |
const char *optformat; |
469
d26f0e5705dc
(svn r702) -Fix: Buffer overflow in music/sound/video-driver-parameter (Oskar_)
truelight
parents:
430
diff
changeset
|
312 |
char musicdriver[16], sounddriver[16], videodriver[16]; |
0 | 313 |
int resolution[2] = {0,0}; |
314 |
uint startdate = -1; |
|
1406
2d5baabe4046
(svn r1910) Move two variables out of variables.h which are only used locally
tron
parents:
1397
diff
changeset
|
315 |
bool dedicated; |
2d5baabe4046
(svn r1910) Move two variables out of variables.h which are only used locally
tron
parents:
1397
diff
changeset
|
316 |
|
0 | 317 |
musicdriver[0] = sounddriver[0] = videodriver[0] = 0; |
318 |
||
319 |
_game_mode = GM_MENU; |
|
320 |
_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
|
321 |
_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
|
322 |
_dedicated_forks = false; |
1406
2d5baabe4046
(svn r1910) Move two variables out of variables.h which are only used locally
tron
parents:
1397
diff
changeset
|
323 |
dedicated = 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
|
324 |
_config_file = NULL; |
0 | 325 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
326 |
// The last param of the following function means this: |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
327 |
// a letter means: it accepts that param (e.g.: -h) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
328 |
// a ':' behind it means: it need a param (e.g.: -m<driver>) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
329 |
// a '::' behind it means: it can optional have a param (e.g.: -d<debug>) |
1478
00b0798b34d5
(svn r1982) -Fix: also windows has no 'fork' option
truelight
parents:
1474
diff
changeset
|
330 |
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32) |
2767 | 331 |
optformat = "bm:s:v:hDfn::eit:d::r:g::G:p:c:"; |
770
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
768
diff
changeset
|
332 |
#else |
2767 | 333 |
optformat = "bm:s:v:hDn::eit:d::r:g::G:p:c:"; // no fork option |
770
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
768
diff
changeset
|
334 |
#endif |
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
768
diff
changeset
|
335 |
|
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
768
diff
changeset
|
336 |
MyGetOptInit(&mgo, argc-1, argv+1, optformat); |
0 | 337 |
while ((i = MyGetOpt(&mgo)) != -1) { |
338 |
switch(i) { |
|
339 |
case 'm': ttd_strlcpy(musicdriver, mgo.opt, sizeof(musicdriver)); break; |
|
340 |
case 's': ttd_strlcpy(sounddriver, mgo.opt, sizeof(sounddriver)); break; |
|
341 |
case 'v': ttd_strlcpy(videodriver, mgo.opt, sizeof(videodriver)); break; |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
342 |
case 'D': { |
2639 | 343 |
strcpy(musicdriver, "null"); |
344 |
strcpy(sounddriver, "null"); |
|
345 |
strcpy(videodriver, "dedicated"); |
|
1406
2d5baabe4046
(svn r1910) Move two variables out of variables.h which are only used locally
tron
parents:
1397
diff
changeset
|
346 |
dedicated = true; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
347 |
} break; |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
348 |
case 'f': { |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
349 |
_dedicated_forks = true; |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
350 |
}; break; |
1 | 351 |
case 'n': { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
352 |
network = true; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
353 |
if (mgo.opt) |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
354 |
// Optional, you can give an IP |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
355 |
network_conn = mgo.opt; |
1 | 356 |
else |
357 |
network_conn = NULL; |
|
358 |
} break; |
|
2684
8aba54c245cc
(svn r3226) -Fix: GPMI implementation had minor glitches
truelight
parents:
2672
diff
changeset
|
359 |
case 'b': _ai.network_client = true; break; |
0 | 360 |
case 'r': ParseResolution(resolution, mgo.opt); break; |
2639 | 361 |
case 't': startdate = atoi(mgo.opt); break; |
0 | 362 |
case 'd': { |
363 |
#if defined(WIN32) |
|
364 |
CreateConsole(); |
|
365 |
#endif |
|
2639 | 366 |
if (mgo.opt != NULL) SetDebugString(mgo.opt); |
0 | 367 |
} break; |
368 |
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
|
369 |
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
|
370 |
case 'g': |
2639 | 371 |
if (mgo.opt != NULL) { |
0 | 372 |
strcpy(_file_to_saveload.name, mgo.opt); |
373 |
_switch_mode = SM_LOAD; |
|
374 |
} else |
|
375 |
_switch_mode = SM_NEWGAME; |
|
376 |
break; |
|
377 |
case 'G': |
|
206 | 378 |
_random_seeds[0][0] = atoi(mgo.opt); |
0 | 379 |
break; |
380 |
case 'p': { |
|
381 |
int i = atoi(mgo.opt); |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
382 |
// Play as an other player in network games |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
383 |
if (IS_INT_INSIDE(i, 1, MAX_PLAYERS)) _network_playas = i; |
0 | 384 |
break; |
385 |
} |
|
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
|
386 |
case 'c': |
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
|
387 |
_config_file = strdup(mgo.opt); |
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
|
388 |
break; |
0 | 389 |
case -2: |
2026 | 390 |
case 'h': |
0 | 391 |
showhelp(); |
392 |
return 0; |
|
393 |
} |
|
394 |
} |
|
395 |
||
2684
8aba54c245cc
(svn r3226) -Fix: GPMI implementation had minor glitches
truelight
parents:
2672
diff
changeset
|
396 |
if (_ai.network_client && !network) { |
8aba54c245cc
(svn r3226) -Fix: GPMI implementation had minor glitches
truelight
parents:
2672
diff
changeset
|
397 |
_ai.network_client = false; |
8aba54c245cc
(svn r3226) -Fix: GPMI implementation had minor glitches
truelight
parents:
2672
diff
changeset
|
398 |
DEBUG(ai, 0)("[AI] Can't enable network-AI, because '-n' is not used\n"); |
8aba54c245cc
(svn r3226) -Fix: GPMI implementation had minor glitches
truelight
parents:
2672
diff
changeset
|
399 |
} |
8aba54c245cc
(svn r3226) -Fix: GPMI implementation had minor glitches
truelight
parents:
2672
diff
changeset
|
400 |
|
0 | 401 |
DeterminePaths(); |
961 | 402 |
CheckExternalFiles(); |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
403 |
|
2290 | 404 |
#if defined(UNIX) && !defined(__MORPHOS__) |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
405 |
// We must fork here, or we'll end up without some resources we need (like sockets) |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
406 |
if (_dedicated_forks) |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
407 |
DedicatedFork(); |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
408 |
#endif |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
409 |
|
0 | 410 |
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
|
411 |
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
|
412 |
LoadFromHighScore(); |
0 | 413 |
|
414 |
// override config? |
|
469
d26f0e5705dc
(svn r702) -Fix: Buffer overflow in music/sound/video-driver-parameter (Oskar_)
truelight
parents:
430
diff
changeset
|
415 |
if (musicdriver[0]) ttd_strlcpy(_ini_musicdriver, musicdriver, sizeof(_ini_musicdriver)); |
d26f0e5705dc
(svn r702) -Fix: Buffer overflow in music/sound/video-driver-parameter (Oskar_)
truelight
parents:
430
diff
changeset
|
416 |
if (sounddriver[0]) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver)); |
d26f0e5705dc
(svn r702) -Fix: Buffer overflow in music/sound/video-driver-parameter (Oskar_)
truelight
parents:
430
diff
changeset
|
417 |
if (videodriver[0]) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver)); |
0 | 418 |
if (resolution[0]) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; } |
990
5cbf62b64f36
(svn r1488) -Fix: fixed some spelling mistakes (tnx to Tron)
truelight
parents:
988
diff
changeset
|
419 |
if (startdate != (uint)-1) _patches.starting_date = startdate; |
0 | 420 |
|
1406
2d5baabe4046
(svn r1910) Move two variables out of variables.h which are only used locally
tron
parents:
1397
diff
changeset
|
421 |
if (_dedicated_forks && !dedicated) |
704
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
422 |
_dedicated_forks = false; |
a526dc96fbfc
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
423 |
|
0 | 424 |
// enumerate language files |
425 |
InitializeLanguagePacks(); |
|
426 |
||
427 |
// initialize screenshot formats |
|
428 |
InitializeScreenshotFormats(); |
|
429 |
||
105 | 430 |
// initialize airport state machines |
431 |
InitializeAirports(); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
432 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
433 |
/* 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
|
434 |
InitializeDynamicVariables(); |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
435 |
|
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
436 |
/* start the AI */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
437 |
AI_Initialize(); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
438 |
|
0 | 439 |
// Sample catalogue |
440 |
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
|
441 |
MxInitialize(11025); |
3d0b86f5dcb8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1482
diff
changeset
|
442 |
SoundInitialize("sample.cat"); |
0 | 443 |
|
444 |
// This must be done early, since functions use the InvalidateWindow* calls |
|
139 | 445 |
InitWindowSystem(); |
0 | 446 |
|
447 |
GfxLoadSprites(); |
|
448 |
LoadStringWidthTable(); |
|
449 |
||
450 |
DEBUG(misc, 1) ("Loading drivers..."); |
|
451 |
LoadDriver(SOUND_DRIVER, _ini_sounddriver); |
|
452 |
LoadDriver(MUSIC_DRIVER, _ini_musicdriver); |
|
453 |
LoadDriver(VIDEO_DRIVER, _ini_videodriver); // load video last, to prevent an empty window while sound and music loads |
|
2526
cae4842086a9
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
tron
parents:
2498
diff
changeset
|
454 |
_savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING; |
0 | 455 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
456 |
#ifdef ENABLE_NETWORK |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
457 |
// initialize network-core |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
458 |
NetworkStartUp(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
459 |
#endif /* ENABLE_NETWORK */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
460 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
461 |
_opt_ptr = &_opt_newgame; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
462 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
463 |
/* XXX - ugly hack, if diff_level is 9, it means we got no setting from the config file */ |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
464 |
if (_opt_newgame.diff_level == 9) |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
465 |
SetDifficultyLevel(0, &_opt_newgame); |
0 | 466 |
|
139 | 467 |
// initialize the ingame console |
468 |
IConsoleInit(); |
|
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1243
diff
changeset
|
469 |
InitializeGUI(); |
644
e833509107ad
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
630
diff
changeset
|
470 |
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
|
471 |
|
2828
996de8e891c7
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2818
diff
changeset
|
472 |
GenerateWorld(GW_EMPTY, 64, 64); // Make the viewport initialization happy |
1268
306ebfea663a
(svn r1772) -Fix: [ 1114100 ] Dedicated server boots again
truelight
parents:
1267
diff
changeset
|
473 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
474 |
#ifdef ENABLE_NETWORK |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
475 |
if ((network) && (_network_available)) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
476 |
if (network_conn != NULL) { |
1329 | 477 |
const char *port = NULL; |
478 |
const char *player = NULL; |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
479 |
uint16 rport; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
480 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
481 |
rport = NETWORK_DEFAULT_PORT; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
482 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
483 |
ParseConnectionString(&player, &port, network_conn); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
484 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
485 |
if (player != NULL) _network_playas = atoi(player); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
486 |
if (port != NULL) rport = atoi(port); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
487 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
488 |
LoadIntroGame(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
489 |
_switch_mode = SM_NONE; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
490 |
NetworkClientConnectGame(network_conn, rport); |
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1105
diff
changeset
|
491 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
492 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
493 |
#endif /* ENABLE_NETWORK */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
494 |
|
2228 | 495 |
_video_driver->main_loop(); |
139 | 496 |
|
2285
3193cbd1ba88
(svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
2234
diff
changeset
|
497 |
WaitTillSaved(); |
139 | 498 |
IConsoleFree(); |
0 | 499 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
500 |
#ifdef ENABLE_NETWORK |
105 | 501 |
if (_network_available) { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
502 |
// Shut down the network and close any open connections |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
503 |
NetworkDisconnect(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
504 |
NetworkUDPClose(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
505 |
NetworkShutDown(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
506 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
507 |
#endif /* ENABLE_NETWORK */ |
0 | 508 |
|
509 |
_video_driver->stop(); |
|
510 |
_music_driver->stop(); |
|
511 |
_sound_driver->stop(); |
|
512 |
||
513 |
SaveToConfig(); |
|
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
|
514 |
SaveToHighScore(); |
0 | 515 |
|
105 | 516 |
// uninitialize airport state machines |
517 |
UnInitializeAirports(); |
|
0 | 518 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
519 |
/* uninitialize variables that are allocated dynamic */ |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
520 |
UnInitializeDynamicVariables(); |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
521 |
|
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
522 |
/* stop the AI */ |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
523 |
AI_Uninitialize(); |
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
524 |
|
1036
5f0c307fbadd
(svn r1537) -Fix: Close all and any open filehandles open at shutdown (tamlin)
darkvater
parents:
1035
diff
changeset
|
525 |
/* 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
|
526 |
FioCloseAll(); |
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
527 |
UnInitializeGame(); |
1036
5f0c307fbadd
(svn r1537) -Fix: Close all and any open filehandles open at shutdown (tamlin)
darkvater
parents:
1035
diff
changeset
|
528 |
|
0 | 529 |
return 0; |
530 |
} |
|
531 |
||
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
|
532 |
/** 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
|
533 |
* at any given time */ |
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
|
534 |
static ThreadMsg _message = 0; |
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
|
535 |
|
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
|
536 |
static inline void OTTD_ReleaseMutex(void) {_message = 0;} |
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
|
537 |
static inline ThreadMsg OTTD_PollThreadEvent(void) {return _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
|
538 |
|
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
|
539 |
/** 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
|
540 |
* 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
|
541 |
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
|
542 |
{ |
2383
80ff60d10aed
(svn r2909) Game would hang where the autosave_on_exit was activated.
Darkvater
parents:
2380
diff
changeset
|
543 |
if (_exit_game) return; |
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
|
544 |
while (_message != 0) CSleep(10); |
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
|
545 |
|
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
|
546 |
_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
|
547 |
} |
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
|
548 |
|
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
|
549 |
|
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
|
550 |
/** 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
|
551 |
* @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
|
552 |
*/ |
2817 | 553 |
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
|
554 |
{ |
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
|
555 |
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
|
556 |
case MSG_OTTD_SAVETHREAD_START: SaveFileStart(); 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
|
557 |
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
|
558 |
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
|
559 |
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
|
560 |
} |
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
|
561 |
|
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
|
562 |
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
|
563 |
} |
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
|
564 |
|
0 | 565 |
static void ShowScreenshotResult(bool b) |
566 |
{ |
|
567 |
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
|
568 |
SetDParamStr(0, _screenshot_name); |
0 | 569 |
ShowErrorMessage(INVALID_STRING_ID, STR_031B_SCREENSHOT_SUCCESSFULLY, 0, 0); |
570 |
} else { |
|
571 |
ShowErrorMessage(INVALID_STRING_ID, STR_031C_SCREENSHOT_FAILED, 0, 0); |
|
572 |
} |
|
573 |
||
574 |
} |
|
575 |
||
1095 | 576 |
static void MakeNewGame(void) |
0 | 577 |
{ |
578 |
_game_mode = GM_NORMAL; |
|
579 |
||
580 |
// Copy in game options |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
581 |
_opt_ptr = &_opt; |
2639 | 582 |
memcpy(_opt_ptr, &_opt_newgame, sizeof(*_opt_ptr)); |
0 | 583 |
|
584 |
GfxLoadSprites(); |
|
585 |
||
136
78ac8de2b2b8
(svn r137) Fix: console sometime didn't open (sign_de)
dominik
parents:
126
diff
changeset
|
586 |
// Reinitialize windows |
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
587 |
ResetWindowSystem(); |
0 | 588 |
LoadStringWidthTable(); |
589 |
||
590 |
SetupColorsAndInitialWindow(); |
|
591 |
||
592 |
// Randomize world |
|
2828
996de8e891c7
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2818
diff
changeset
|
593 |
GenerateWorld(GW_NEWGAME, 1<<_patches.map_x, 1<<_patches.map_y); |
0 | 594 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
595 |
// In a dedicated server, the server does not play |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
596 |
if (_network_dedicated) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
597 |
_local_player = OWNER_SPECTATOR; |
2026 | 598 |
} else { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
599 |
// Create a single player |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
600 |
DoStartupNewPlayer(false); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
601 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
602 |
_local_player = 0; |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
603 |
_current_player = _local_player; |
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
604 |
DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_REPLACE_VEHICLE); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
605 |
} |
0 | 606 |
|
607 |
MarkWholeScreenDirty(); |
|
608 |
} |
|
609 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1036
diff
changeset
|
610 |
static void MakeNewEditorWorld(void) |
0 | 611 |
{ |
612 |
_game_mode = GM_EDITOR; |
|
613 |
||
614 |
// Copy in game options |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
615 |
_opt_ptr = &_opt; |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
616 |
memcpy(_opt_ptr, &_opt_newgame, sizeof(GameOptions)); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
617 |
|
0 | 618 |
GfxLoadSprites(); |
619 |
||
136
78ac8de2b2b8
(svn r137) Fix: console sometime didn't open (sign_de)
dominik
parents:
126
diff
changeset
|
620 |
// Re-init the windowing system |
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
621 |
ResetWindowSystem(); |
0 | 622 |
|
623 |
// Create toolbars |
|
624 |
SetupColorsAndInitialWindow(); |
|
625 |
||
626 |
// Startup the game system |
|
2828
996de8e891c7
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2818
diff
changeset
|
627 |
GenerateWorld(GW_EMPTY, 1 << _patches.map_x, 1 << _patches.map_y); |
0 | 628 |
|
629 |
_local_player = OWNER_NONE; |
|
630 |
MarkWholeScreenDirty(); |
|
631 |
} |
|
632 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1036
diff
changeset
|
633 |
void StartupPlayers(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1036
diff
changeset
|
634 |
void StartupDisasters(void); |
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
115
diff
changeset
|
635 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
636 |
/** |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
637 |
* Start Scenario starts a new game based on a scenario. |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
638 |
* 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
|
639 |
* This starts a scenario based on your current difficulty settings |
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
640 |
*/ |
1095 | 641 |
static void StartScenario(void) |
0 | 642 |
{ |
643 |
_game_mode = GM_NORMAL; |
|
644 |
||
645 |
// invalid type |
|
646 |
if (_file_to_saveload.mode == SL_INVALID) { |
|
647 |
printf("Savegame is obsolete or invalid format: %s\n", _file_to_saveload.name); |
|
2749
46aba09ca365
(svn r3294) - Fix: use INVALID_STRING_ID instead of -1.
Darkvater
parents:
2701
diff
changeset
|
648 |
ShowErrorMessage(INVALID_STRING_ID, STR_4009_GAME_LOAD_FAILED, 0, 0); |
0 | 649 |
_game_mode = GM_MENU; |
650 |
return; |
|
651 |
} |
|
652 |
||
653 |
GfxLoadSprites(); |
|
654 |
||
136
78ac8de2b2b8
(svn r137) Fix: console sometime didn't open (sign_de)
dominik
parents:
126
diff
changeset
|
655 |
// Reinitialize windows |
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
656 |
ResetWindowSystem(); |
0 | 657 |
LoadStringWidthTable(); |
658 |
||
659 |
SetupColorsAndInitialWindow(); |
|
660 |
||
661 |
// Load game |
|
662 |
if (SaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode) != SL_OK) { |
|
663 |
LoadIntroGame(); |
|
2749
46aba09ca365
(svn r3294) - Fix: use INVALID_STRING_ID instead of -1.
Darkvater
parents:
2701
diff
changeset
|
664 |
ShowErrorMessage(INVALID_STRING_ID, STR_4009_GAME_LOAD_FAILED, 0, 0); |
0 | 665 |
} |
666 |
||
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
|
667 |
_opt_ptr = &_opt; |
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
|
668 |
memcpy(&_opt_ptr->diff, &_opt_newgame.diff, sizeof(GameDifficulty)); |
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
|
669 |
_opt.diff_level = _opt_newgame.diff_level; |
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
670 |
|
115
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
671 |
// Inititalize data |
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
672 |
StartupPlayers(); |
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
673 |
StartupEngines(); |
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
674 |
StartupDisasters(); |
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
675 |
|
0 | 676 |
_local_player = 0; |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
677 |
_current_player = _local_player; |
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
678 |
DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_REPLACE_VEHICLE); |
0 | 679 |
|
680 |
MarkWholeScreenDirty(); |
|
681 |
} |
|
682 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
683 |
bool SafeSaveOrLoad(const char *filename, int mode, int newgm) |
0 | 684 |
{ |
685 |
byte ogm = _game_mode; |
|
686 |
int r; |
|
687 |
||
688 |
_game_mode = newgm; |
|
689 |
r = SaveOrLoad(filename, mode); |
|
690 |
if (r == SL_REINIT) { |
|
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2620
diff
changeset
|
691 |
switch (ogm) { |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2620
diff
changeset
|
692 |
case GM_MENU: LoadIntroGame(); break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2620
diff
changeset
|
693 |
case GM_EDITOR: MakeNewEditorWorld(); break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2620
diff
changeset
|
694 |
default: MakeNewGame(); break; |
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2620
diff
changeset
|
695 |
} |
0 | 696 |
return false; |
697 |
} else if (r != SL_OK) { |
|
698 |
_game_mode = ogm; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
699 |
return false; |
2639 | 700 |
} else { |
0 | 701 |
return true; |
2639 | 702 |
} |
0 | 703 |
} |
704 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
705 |
void SwitchMode(int new_mode) |
0 | 706 |
{ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
707 |
#ifdef ENABLE_NETWORK |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
708 |
// If we are saving something, the network stays in his current state |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
709 |
if (new_mode != SM_SAVE) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
710 |
// If the network is active, make it not-active |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
711 |
if (_networking) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
712 |
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
|
713 |
NetworkReboot(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
714 |
NetworkUDPClose(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
715 |
} else { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
716 |
NetworkDisconnect(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
717 |
NetworkUDPClose(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
718 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
719 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
720 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
721 |
// If we are a server, we restart the server |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
722 |
if (_is_network_server) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
723 |
// But not if we are going to the menu |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
724 |
if (new_mode != SM_MENU) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
725 |
NetworkServerStart(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
726 |
} else { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
727 |
// This client no longer wants to be a network-server |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
728 |
_is_network_server = false; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
729 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
730 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
731 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
732 |
#endif /* ENABLE_NETWORK */ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
733 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
734 |
switch (new_mode) { |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
735 |
case SM_EDITOR: /* Switch to scenario editor */ |
0 | 736 |
MakeNewEditorWorld(); |
737 |
break; |
|
738 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
739 |
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
|
740 |
#ifdef ENABLE_NETWORK |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
741 |
if (_network_server) |
2100
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2096
diff
changeset
|
742 |
snprintf(_network_game_info.map_name, NETWORK_NAME_LENGTH, "Random Map"); |
630
fd3c36132342
(svn r1061) -Fix: [Network] Compiling without ENABLE_NETWORK now works again correctly
truelight
parents:
614
diff
changeset
|
743 |
#endif /* ENABLE_NETWORK */ |
0 | 744 |
MakeNewGame(); |
745 |
break; |
|
746 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
747 |
case SM_START_SCENARIO: /* New Game --> Choose one of the preset scenarios */ |
2100
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2096
diff
changeset
|
748 |
#ifdef ENABLE_NETWORK |
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2096
diff
changeset
|
749 |
if (_network_server) |
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2096
diff
changeset
|
750 |
snprintf(_network_game_info.map_name, NETWORK_NAME_LENGTH, "%s (Loaded scenario)", _file_to_saveload.title); |
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2096
diff
changeset
|
751 |
#endif /* ENABLE_NETWORK */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
752 |
StartScenario(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
753 |
break; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
754 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
755 |
case SM_LOAD: { /* Load game, Play Scenario */ |
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
756 |
_opt_ptr = &_opt; |
0 | 757 |
|
758 |
if (!SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_NORMAL)) { |
|
942
31f28eedd2b8
(svn r1430) -Fix: starting openttd with -g <invalid_name> now acts normal
truelight
parents:
929
diff
changeset
|
759 |
LoadIntroGame(); |
2749
46aba09ca365
(svn r3294) - Fix: use INVALID_STRING_ID instead of -1.
Darkvater
parents:
2701
diff
changeset
|
760 |
ShowErrorMessage(INVALID_STRING_ID, STR_4009_GAME_LOAD_FAILED, 0, 0); |
0 | 761 |
} else { |
762 |
_local_player = 0; |
|
763 |
DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // decrease pause counter (was increased from opening load dialog) |
|
630
fd3c36132342
(svn r1061) -Fix: [Network] Compiling without ENABLE_NETWORK now works again correctly
truelight
parents:
614
diff
changeset
|
764 |
#ifdef ENABLE_NETWORK |
2944
7c392e7b51c6
(svn r3500) - Workaround the inaccurate count of spectators/companies that can happen in certain border-cases. For now just dynamically get this value when requested so it is always right. To do properly all player/client creation/destruction needs a hook for networking.
Darkvater
parents:
2929
diff
changeset
|
765 |
if (_network_server) |
2100
868d62687c9a
(svn r2610) - Feature: set server map name to the loaded name of the game/scenario. Also truncate where neccessary
Darkvater
parents:
2096
diff
changeset
|
766 |
snprintf(_network_game_info.map_name, NETWORK_NAME_LENGTH, "%s (Loaded game)", _file_to_saveload.title); |
630
fd3c36132342
(svn r1061) -Fix: [Network] Compiling without ENABLE_NETWORK now works again correctly
truelight
parents:
614
diff
changeset
|
767 |
#endif /* ENABLE_NETWORK */ |
0 | 768 |
} |
769 |
break; |
|
770 |
} |
|
771 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
772 |
case SM_LOAD_SCENARIO: { /* Load scenario from scenario editor */ |
2634
16334e1a4862
(svn r3176) Use proper types, not some variants of int
tron
parents:
2631
diff
changeset
|
773 |
if (SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_EDITOR)) { |
16334e1a4862
(svn r3176) Use proper types, not some variants of int
tron
parents:
2631
diff
changeset
|
774 |
PlayerID i; |
0 | 775 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
776 |
_opt_ptr = &_opt; |
0 | 777 |
|
778 |
_local_player = OWNER_NONE; |
|
779 |
_generating_world = true; |
|
780 |
// delete all players. |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
781 |
for (i = 0; i != MAX_PLAYERS; i++) { |
2469
1bfbb0dc0b75
(svn r2995) Replace 0xFF/0xFFFF with CT_INVALID/OWNER_SPECTATOR/INVALID_STATION where appropriate
tron
parents:
2437
diff
changeset
|
782 |
ChangeOwnershipOfPlayerItems(i, OWNER_SPECTATOR); |
0 | 783 |
_players[i].is_active = false; |
784 |
} |
|
785 |
_generating_world = false; |
|
786 |
// delete all stations owned by a player |
|
787 |
DeleteAllPlayerStations(); |
|
2639 | 788 |
} else { |
0 | 789 |
ShowErrorMessage(INVALID_STRING_ID, STR_4009_GAME_LOAD_FAILED, 0, 0); |
2639 | 790 |
} |
0 | 791 |
break; |
792 |
} |
|
793 |
||
794 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
795 |
case SM_MENU: /* Switch to game intro menu */ |
0 | 796 |
LoadIntroGame(); |
797 |
break; |
|
798 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
799 |
case SM_SAVE: /* Save game */ |
2639 | 800 |
if (SaveOrLoad(_file_to_saveload.name, SL_SAVE) != SL_OK) { |
0 | 801 |
ShowErrorMessage(INVALID_STRING_ID, STR_4007_GAME_SAVE_FAILED, 0, 0); |
2639 | 802 |
} else { |
0 | 803 |
DeleteWindowById(WC_SAVELOAD, 0); |
2639 | 804 |
} |
0 | 805 |
break; |
806 |
||
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
807 |
case SM_GENRANDLAND: /* Generate random land within scenario editor */ |
2828
996de8e891c7
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2818
diff
changeset
|
808 |
GenerateWorld(GW_RANDOM, 1<<_patches.map_x, 1<<_patches.map_y); |
0 | 809 |
// XXX: set date |
810 |
_local_player = OWNER_NONE; |
|
811 |
MarkWholeScreenDirty(); |
|
812 |
break; |
|
813 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
814 |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
815 |
if (_switch_mode_errorstr != INVALID_STRING_ID) |
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
|
816 |
ShowErrorMessage(INVALID_STRING_ID,_switch_mode_errorstr,0,0); |
0 | 817 |
} |
818 |
||
819 |
||
820 |
// State controlling game loop. |
|
821 |
// The state must not be changed from anywhere |
|
822 |
// but here. |
|
823 |
// That check is enforced in DoCommand. |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1036
diff
changeset
|
824 |
void StateGameLoop(void) |
0 | 825 |
{ |
213
770e504a6e51
(svn r214) -Feature: CMD_NET_INSTANT [just in time command handling over network] (sign_de)
darkvater
parents:
208
diff
changeset
|
826 |
// dont execute the state loop during pause |
770e504a6e51
(svn r214) -Feature: CMD_NET_INSTANT [just in time command handling over network] (sign_de)
darkvater
parents:
208
diff
changeset
|
827 |
if (_pause) return; |
770e504a6e51
(svn r214) -Feature: CMD_NET_INSTANT [just in time command handling over network] (sign_de)
darkvater
parents:
208
diff
changeset
|
828 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
829 |
// _frame_counter is increased somewhere else when in network-mode |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
830 |
// Sidenote: _frame_counter is ONLY used for _savedump in non-MP-games |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
831 |
// Should that not be deleted? If so, the next 2 lines can also be deleted |
2639 | 832 |
if (!_networking) _frame_counter++; |
0 | 833 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
834 |
if (_savedump_path[0] && (uint)_frame_counter >= _savedump_first && (uint)(_frame_counter -_savedump_first) % _savedump_freq == 0 ) { |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
835 |
char buf[100]; |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
836 |
sprintf(buf, "%s%.5d.sav", _savedump_path, _frame_counter); |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
837 |
SaveOrLoad(buf, SL_SAVE); |
0 | 838 |
if ((uint)_frame_counter >= _savedump_last) exit(1); |
839 |
} |
|
840 |
||
841 |
if (_game_mode == GM_EDITOR) { |
|
842 |
RunTileLoop(); |
|
843 |
CallVehicleTicks(); |
|
844 |
CallLandscapeTick(); |
|
845 |
CallWindowTickEvent(); |
|
846 |
NewsLoop(); |
|
847 |
} else { |
|
206 | 848 |
// All these actions has to be done from OWNER_NONE |
849 |
// 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
|
850 |
PlayerID p = _current_player; |
206 | 851 |
_current_player = OWNER_NONE; |
852 |
||
0 | 853 |
AnimateAnimatedTiles(); |
854 |
IncreaseDate(); |
|
855 |
RunTileLoop(); |
|
856 |
CallVehicleTicks(); |
|
857 |
CallLandscapeTick(); |
|
858 |
||
2395
19b4da30806b
(svn r2921) -Codechange: moved all AI-code to 1 central place (ai/ai.c)
truelight
parents:
2383
diff
changeset
|
859 |
AI_RunGameLoop(); |
0 | 860 |
|
861 |
CallWindowTickEvent(); |
|
862 |
NewsLoop(); |
|
206 | 863 |
_current_player = p; |
0 | 864 |
} |
865 |
} |
|
866 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1036
diff
changeset
|
867 |
static void DoAutosave(void) |
0 | 868 |
{ |
869 |
char buf[200]; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
870 |
|
1 | 871 |
if (_patches.keep_all_autosave && _local_player != OWNER_SPECTATOR) { |
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1927
diff
changeset
|
872 |
const Player *p = GetPlayer(_local_player); |
0 | 873 |
char *s; |
874 |
sprintf(buf, "%s%s", _path.autosave_dir, PATHSEP); |
|
1500
228f77e88adf
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
875 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
876 |
SetDParam(0, p->name_1); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
877 |
SetDParam(1, p->name_2); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
878 |
SetDParam(2, _date); |
2644 | 879 |
s = GetString(buf + strlen(_path.autosave_dir) + strlen(PATHSEP), STR_4004); |
0 | 880 |
strcpy(s, ".sav"); |
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
|
881 |
} else { /* generate a savegame name and number according to _patches.max_num_autosaves */ |
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
|
882 |
sprintf(buf, "%s%sautosave%d.sav", _path.autosave_dir, PATHSEP, _autosave_ctr); |
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
|
883 |
|
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
|
884 |
_autosave_ctr++; |
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
|
885 |
if (_autosave_ctr >= _patches.max_num_autosaves) { |
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
|
886 |
// we reached the limit for numbers of autosaves. We will start over |
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
|
887 |
_autosave_ctr = 0; |
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
|
888 |
} |
0 | 889 |
} |
890 |
||
557
8540788a827e
(svn r959) -Fix: fix previous typo for workaround of braindead MSVC6 (Tron)
darkvater
parents:
543
diff
changeset
|
891 |
DEBUG(misc, 2) ("Autosaving to %s", buf); |
0 | 892 |
if (SaveOrLoad(buf, SL_SAVE) != SL_OK) |
893 |
ShowErrorMessage(INVALID_STRING_ID, STR_AUTOSAVE_FAILED, 0, 0); |
|
894 |
} |
|
895 |
||
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
|
896 |
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
|
897 |
{ |
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
|
898 |
if (_game_mode != GM_MENU) { |
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
|
899 |
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
|
900 |
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
|
901 |
|
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
|
902 |
WP(w,vp_d).scrollpos_x += x << w->viewport->zoom; |
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
|
903 |
WP(w,vp_d).scrollpos_y += y << w->viewport->zoom; |
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
|
904 |
} |
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
|
905 |
} |
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
|
906 |
|
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
|
907 |
static const int8 scrollamt[16][2] = { |
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
|
908 |
{ 0, 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
|
909 |
{-2, 0}, // 1:left |
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
|
910 |
{ 0,-2}, // 2:up |
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
|
911 |
{-2,-1}, // 3:left + up |
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
|
912 |
{ 2, 0}, // 4:right |
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
|
913 |
{ 0, 0}, // 5:left + right |
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
|
914 |
{ 2,-1}, // 6:right + up |
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
|
915 |
{ 0,-2}, // 7:left + right + up = up |
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
|
916 |
{ 0 ,2}, // 8:down |
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
|
917 |
{-2 ,1}, // 9:down+left |
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
|
918 |
{ 0, 0}, // 10:impossible |
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
|
919 |
{-2, 0}, // 11:left + up + down = left |
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
|
920 |
{ 2, 1}, // 12:down+right |
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
|
921 |
{ 0, 2}, // 13:left + right + down = down |
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
|
922 |
{ 0,-2}, // 14:left + right + up = up |
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
|
923 |
{ 0, 0}, // 15:impossible |
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
|
924 |
}; |
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
|
925 |
|
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
|
926 |
static void HandleKeyScrolling(void) |
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
|
927 |
{ |
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
|
928 |
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
|
929 |
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
|
930 |
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
|
931 |
} |
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
|
932 |
} |
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
|
933 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1036
diff
changeset
|
934 |
void GameLoop(void) |
0 | 935 |
{ |
936 |
int m; |
|
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
|
937 |
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
|
938 |
|
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
|
939 |
if ((message = OTTD_PollThreadEvent()) != 0) ProcessSentMessage(message); |
0 | 940 |
|
941 |
// autosave game? |
|
942 |
if (_do_autosave) { |
|
943 |
_do_autosave = false; |
|
944 |
DoAutosave(); |
|
945 |
RedrawAutosave(); |
|
946 |
} |
|
947 |
||
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
|
948 |
// handle scrolling of the main window |
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
|
949 |
if (_dirkeys) HandleKeyScrolling(); |
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
|
950 |
|
0 | 951 |
// make a screenshot? |
952 |
if ((m=_make_screenshot) != 0) { |
|
953 |
_make_screenshot = 0; |
|
954 |
switch(m) { |
|
955 |
case 1: // make small screenshot |
|
956 |
UndrawMouseCursor(); |
|
957 |
ShowScreenshotResult(MakeScreenshot()); |
|
958 |
break; |
|
959 |
case 2: // make large screenshot |
|
2437
e3e2fe024267
(svn r2963) Fix: calculate proportions of non-square giant screenshot correctly.
peter1138
parents:
2395
diff
changeset
|
960 |
ShowScreenshotResult(MakeWorldScreenshot(-(int)MapMaxX() * TILE_PIXELS, 0, (MapMaxX() + MapMaxY()) * TILE_PIXELS, (MapMaxX() + MapMaxY()) * TILE_PIXELS >> 1, 0)); |
0 | 961 |
break; |
962 |
} |
|
963 |
} |
|
964 |
||
965 |
// switch game mode? |
|
966 |
if ((m=_switch_mode) != SM_NONE) { |
|
967 |
_switch_mode = SM_NONE; |
|
968 |
SwitchMode(m); |
|
969 |
} |
|
970 |
||
971 |
IncreaseSpriteLRU(); |
|
972 |
InteractiveRandom(); |
|
973 |
||
2639 | 974 |
if (_scroller_click_timeout > 3) { |
0 | 975 |
_scroller_click_timeout -= 3; |
2639 | 976 |
} else { |
0 | 977 |
_scroller_click_timeout = 0; |
2639 | 978 |
} |
0 | 979 |
|
980 |
_caret_timer += 3; |
|
2639 | 981 |
_timer_counter += 8; |
0 | 982 |
CursorTick(); |
983 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
984 |
#ifdef ENABLE_NETWORK |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
985 |
// Check for UDP stuff |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
986 |
NetworkUDPGameLoop(); |
0 | 987 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
988 |
if (_networking) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
989 |
// Multiplayer |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
990 |
NetworkGameLoop(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
991 |
} else { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
992 |
if (_network_reconnect > 0 && --_network_reconnect == 0) { |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
993 |
// This means that we want to reconnect to the last host |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
994 |
// We do this here, because it means that the network is really closed |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
995 |
NetworkClientConnectGame(_network_last_host, _network_last_port); |
206 | 996 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
997 |
// Singleplayer |
213
770e504a6e51
(svn r214) -Feature: CMD_NET_INSTANT [just in time command handling over network] (sign_de)
darkvater
parents:
208
diff
changeset
|
998 |
StateGameLoop(); |
0 | 999 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1000 |
#else |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1001 |
StateGameLoop(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1002 |
#endif /* ENABLE_NETWORK */ |
0 | 1003 |
|
2639 | 1004 |
if (!_pause && _display_opt & DO_FULL_ANIMATION) DoPaletteAnimations(); |
0 | 1005 |
|
2639 | 1006 |
if (!_pause || _cheats.build_in_pause.value) MoveAllTextEffects(); |
0 | 1007 |
|
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
|
1008 |
InputLoop(); |
0 | 1009 |
|
1608
074dff2e4890
(svn r2112) -Fix: ExtMidi no longer halts the game while starting a song
tron
parents:
1570
diff
changeset
|
1010 |
MusicLoop(); |
0 | 1011 |
} |
1012 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1036
diff
changeset
|
1013 |
void BeforeSaveGame(void) |
0 | 1014 |
{ |
2643 | 1015 |
const Window* w = FindWindowById(WC_MAIN_WINDOW, 0); |
0 | 1016 |
|
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
|
1017 |
if (w != NULL) { |
2643 | 1018 |
_saved_scrollpos_x = WP(w, const vp_d).scrollpos_x; |
1019 |
_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
|
1020 |
_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
|
1021 |
} |
0 | 1022 |
} |
1023 |
||
1095 | 1024 |
static void ConvertTownOwner(void) |
0 | 1025 |
{ |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
1026 |
TileIndex tile; |
0 | 1027 |
|
863
8d09f9331a80
(svn r1344) Use MapSize[XY]() (or MapSize()/MapMax[XY]() where appropriate) instead of TILES_[XY]
tron
parents:
861
diff
changeset
|
1028 |
for (tile = 0; tile != MapSize(); tile++) { |
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
1027
diff
changeset
|
1029 |
if (IsTileType(tile, MP_STREET)) { |
2639 | 1030 |
if (IsLevelCrossing(tile) && _m[tile].m3 & 0x80) _m[tile].m3 = OWNER_TOWN; |
0 | 1031 |
|
2360
09e42e4ee139
(svn r2886) Rename the "owner" attribute to "m1", because when it stores an owner it is accessed by [GS]etOwner anyway and when it doesn't store an owner, but arbitrary data, accessing a field called "owner" is confusing.
tron
parents:
2340
diff
changeset
|
1032 |
if (_m[tile].m1 & 0x80) SetTileOwner(tile, OWNER_TOWN); |
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
1027
diff
changeset
|
1033 |
} else if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
2360
09e42e4ee139
(svn r2886) Rename the "owner" attribute to "m1", because when it stores an owner it is accessed by [GS]etOwner anyway and when it doesn't store an owner, but arbitrary data, accessing a field called "owner" is confusing.
tron
parents:
2340
diff
changeset
|
1034 |
if (_m[tile].m1 & 0x80) SetTileOwner(tile, OWNER_TOWN); |
0 | 1035 |
} |
1036 |
} |
|
1037 |
} |
|
1038 |
||
1039 |
// before savegame version 4, the name of the company determined if it existed |
|
1095 | 1040 |
static void CheckIsPlayerActive(void) |
0 | 1041 |
{ |
2639 | 1042 |
Player* p; |
1043 |
||
0 | 1044 |
FOR_ALL_PLAYERS(p) { |
2639 | 1045 |
if (p->name_1 != 0) p->is_active = true; |
0 | 1046 |
} |
1047 |
} |
|
1048 |
||
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1049 |
// since savegame version 4.1, exclusive transport rights are stored at towns |
1095 | 1050 |
static void UpdateExclusiveRights(void) |
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1051 |
{ |
2639 | 1052 |
Town* t; |
1053 |
||
1054 |
FOR_ALL_TOWNS(t) { |
|
1055 |
if (t->xy != 0) t->exclusivity = (byte)-1; |
|
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1056 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1057 |
|
123
d550772c61e6
(svn r124) Prepared code for removal of block_months variable in next major savegame version
dominik
parents:
121
diff
changeset
|
1058 |
/* FIXME old exclusive rights status is not being imported (stored in s->blocked_months_obsolete) |
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1059 |
could be implemented this way: |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1060 |
1.) Go through all stations |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1061 |
Build an array town_blocked[ town_id ][ player_id ] |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1062 |
that stores if at least one station in that town is blocked for a player |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1063 |
2.) Go through that array, if you find a town that is not blocked for |
2026 | 1064 |
one player, but for all others, then give him exclusivity. |
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1065 |
*/ |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1066 |
} |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1067 |
|
2756 | 1068 |
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
|
1069 |
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
|
1070 |
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
|
1071 |
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
|
1072 |
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
|
1073 |
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
|
1074 |
|
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
|
1075 |
// since savegame version 4.2 the currencies are arranged differently |
1095 | 1076 |
static void UpdateCurrencies(void) |
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
|
1077 |
{ |
768
deb40d3554a2
(svn r1233) Fixed several currency issues. Now currencies should work correctly again.
dominik
parents:
762
diff
changeset
|
1078 |
_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
|
1079 |
} |
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
|
1080 |
|
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
|
1081 |
/* 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
|
1082 |
* 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
|
1083 |
*/ |
1095 | 1084 |
static void UpdateVoidTiles(void) |
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
|
1085 |
{ |
959
b031d88c76f3
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
950
diff
changeset
|
1086 |
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
|
1087 |
|
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
|
1088 |
for (i = 0; i < MapMaxY(); ++i) |
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
|
1089 |
SetTileType(i * MapSizeX() + MapMaxX(), MP_VOID); |
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
|
1090 |
for (i = 0; i < MapSizeX(); ++i) |
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
|
1091 |
SetTileType(MapSizeX() * MapMaxY() + i, MP_VOID); |
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
|
1092 |
} |
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
|
1093 |
|
1165
2cdf7a0e217a
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1094 |
// since savegame version 6.0 each sign has an "owner", signs without owner (from old games are set to 255) |
2cdf7a0e217a
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1095 |
static void UpdateSignOwner(void) |
2cdf7a0e217a
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1096 |
{ |
2cdf7a0e217a
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1097 |
SignStruct *ss; |
2639 | 1098 |
|
1099 |
FOR_ALL_SIGNS(ss) ss->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
|
1100 |
} |
2cdf7a0e217a
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1101 |
|
950
1f6546ea35a3
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
942
diff
changeset
|
1102 |
extern void UpdateOldAircraft( void ); |
1f6546ea35a3
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
942
diff
changeset
|
1103 |
extern void UpdateOilRig( void ); |
0 | 1104 |
|
2808
35e0e9c6c227
(svn r3356) - Remove unused parameter of AfterLoadGame().
peter1138
parents:
2805
diff
changeset
|
1105 |
bool AfterLoadGame(void) |
0 | 1106 |
{ |
1107 |
Window *w; |
|
1108 |
ViewPort *vp; |
|
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
2100
diff
changeset
|
1109 |
Player *p; |
988
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
983
diff
changeset
|
1110 |
|
0 | 1111 |
// 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
|
1112 |
if (CheckSavegameVersionOldStyle(2, 1)) ConvertTownOwner(); |
0 | 1113 |
|
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1114 |
// 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
|
1115 |
if (CheckSavegameVersionOldStyle(4, 1)) UpdateExclusiveRights(); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1116 |
|
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
|
1117 |
// 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
|
1118 |
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
|
1119 |
|
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1120 |
// from version 6.1 of the savegame, signs have an "owner" |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1121 |
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
|
1122 |
|
831
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1123 |
/* In old version there seems to be a problem that water is owned by |
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1124 |
OWNER_NONE, not OWNER_WATER.. I can't replicate it for the current |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1125 |
(4.3) version, so I just check when versions are older, and then |
831
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1126 |
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
|
1127 |
if (CheckSavegameVersionOldStyle(4, 3)) { |
1981 | 1128 |
TileIndex tile = TileXY(0, 0); |
831
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1129 |
uint w = MapSizeX(); |
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1130 |
uint h = MapSizeY(); |
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1131 |
|
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1132 |
BEGIN_TILE_LOOP(tile_cur, w, h, tile) |
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
1133 |
if (IsTileType(tile_cur, MP_WATER) && GetTileOwner(tile_cur) >= MAX_PLAYERS) |
1902 | 1134 |
SetTileOwner(tile_cur, OWNER_WATER); |
831
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1135 |
END_TILE_LOOP(tile_cur, w, h, tile) |
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1136 |
} |
f1cee10e3422
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1137 |
|
0 | 1138 |
// convert road side to my format. |
1139 |
if (_opt.road_side) _opt.road_side = 1; |
|
1140 |
||
1141 |
// Load the sprites |
|
1142 |
GfxLoadSprites(); |
|
1143 |
||
2814
0f534d66544e
(svn r3362) Fix issue with loading old (TTD) savegames:
peter1138
parents:
2808
diff
changeset
|
1144 |
/* 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
|
1145 |
* subtype to the new format */ |
0f534d66544e
(svn r3362) Fix issue with loading old (TTD) savegames:
peter1138
parents:
2808
diff
changeset
|
1146 |
if (CheckSavegameVersionOldStyle(17, 1)) ConvertOldMultiheadToNew(); |
0f534d66544e
(svn r3362) Fix issue with loading old (TTD) savegames:
peter1138
parents:
2808
diff
changeset
|
1147 |
|
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
|
1148 |
/* 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
|
1149 |
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
|
1150 |
|
0 | 1151 |
// Update current year |
1152 |
SetDate(_date); |
|
1153 |
||
1154 |
// reinit the landscape variables (landscape might have changed) |
|
1155 |
InitializeLandscapeVariables(true); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1156 |
|
0 | 1157 |
// Update all vehicles |
1158 |
AfterLoadVehicles(); |
|
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1501
diff
changeset
|
1159 |
|
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1501
diff
changeset
|
1160 |
// Update all waypoints |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1161 |
if (CheckSavegameVersion(12)) FixOldWaypoints(); |
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1501
diff
changeset
|
1162 |
|
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1501
diff
changeset
|
1163 |
UpdateAllWaypointSigns(); |
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1501
diff
changeset
|
1164 |
|
0 | 1165 |
// 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
|
1166 |
if (CheckSavegameVersionOldStyle(2, 2)) UpdateOldAircraft(); |
0 | 1167 |
|
1168 |
UpdateAllStationVirtCoord(); |
|
1169 |
||
1170 |
// Setup town coords |
|
1171 |
AfterLoadTown(); |
|
1172 |
UpdateAllSignVirtCoords(); |
|
1173 |
||
1174 |
// make sure there is a town in the game |
|
2639 | 1175 |
if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, (uint)-1)) { |
0 | 1176 |
_error_message = STR_NO_TOWN_IN_SCENARIO; |
1177 |
return false; |
|
1178 |
} |
|
1179 |
||
1180 |
// Initialize windows |
|
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
1181 |
ResetWindowSystem(); |
0 | 1182 |
SetupColorsAndInitialWindow(); |
1183 |
||
1184 |
w = FindWindowById(WC_MAIN_WINDOW, 0); |
|
1185 |
||
1186 |
WP(w,vp_d).scrollpos_x = _saved_scrollpos_x; |
|
1187 |
WP(w,vp_d).scrollpos_y = _saved_scrollpos_y; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1188 |
|
0 | 1189 |
vp = w->viewport; |
1190 |
vp->zoom = _saved_scrollpos_zoom; |
|
1191 |
vp->virtual_width = vp->width << vp->zoom; |
|
1192 |
vp->virtual_height = vp->height << vp->zoom; |
|
1193 |
||
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1194 |
// in version 4.1 of the savegame, is_active was introduced to determine |
0 | 1195 |
// 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
|
1196 |
if (CheckSavegameVersionOldStyle(4, 1)) CheckIsPlayerActive(); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1197 |
|
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1198 |
// the void tiles on the southern border used to belong to a wrong class (pre 4.3). |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1199 |
if (CheckSavegameVersionOldStyle(4, 3)) UpdateVoidTiles(); |
929
1a071a06af3f
(svn r1417) Fix: The invisible tiles on the southern border are now converted to class MP_VOID when an old map (with wrong classified invisible tiles) is loaded.
dominik
parents:
921
diff
changeset
|
1200 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1201 |
// If Load Scenario / New (Scenario) Game is used, |
139 | 1202 |
// a player does not exist yet. So create one here. |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1203 |
// 1 exeption: network-games. Those can have 0 players |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1204 |
// But this exeption is not true for network_servers! |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1205 |
if (!_players[0].is_active && (!_networking || (_networking && _network_server))) |
139 | 1206 |
DoStartupNewPlayer(false); |
0 | 1207 |
|
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
139
diff
changeset
|
1208 |
DoZoomInOutWindow(ZOOM_NONE, w); // update button status |
0 | 1209 |
MarkWholeScreenDirty(); |
1210 |
||
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1211 |
// In 5.1, Oilrigs have been moved (again) |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1212 |
if (CheckSavegameVersionOldStyle(5, 1)) UpdateOilRig(); |
950
1f6546ea35a3
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
942
diff
changeset
|
1213 |
|
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1214 |
/* 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
|
1215 |
* 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
|
1216 |
* all about ;) */ |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1217 |
if (CheckSavegameVersionOldStyle(6, 1)) { |
1264
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1218 |
BEGIN_TILE_LOOP(tile, MapSizeX(), MapSizeY(), 0) { |
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1219 |
if (IsTileType(tile, MP_HOUSE)) { |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2033
diff
changeset
|
1220 |
_m[tile].m4 = _m[tile].m2; |
1264
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1221 |
//XXX magic |
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1222 |
SetTileType(tile, MP_VOID); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2033
diff
changeset
|
1223 |
_m[tile].m2 = ClosestTownFromTile(tile,(uint)-1)->index; |
1264
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1224 |
SetTileType(tile, MP_HOUSE); |
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1225 |
} else if (IsTileType(tile, MP_STREET)) { |
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1226 |
//XXX magic |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2033
diff
changeset
|
1227 |
_m[tile].m4 |= (_m[tile].m2 << 4); |
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
1228 |
if (IsTileOwner(tile, OWNER_TOWN)) { |
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
1229 |
SetTileType(tile, MP_VOID); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2033
diff
changeset
|
1230 |
_m[tile].m2 = ClosestTownFromTile(tile,(uint)-1)->index; |
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
1231 |
SetTileType(tile, MP_STREET); |
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
1232 |
} else { |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2033
diff
changeset
|
1233 |
_m[tile].m2 = 0; |
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
1234 |
} |
1264
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1235 |
} |
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1236 |
} END_TILE_LOOP(tile, MapSizeX(), MapSizeY(), 0); |
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1237 |
} |
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1238 |
|
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1239 |
/* 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
|
1240 |
* before that. */ |
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1241 |
if (CheckSavegameVersion(9)) { |
1377
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1349
diff
changeset
|
1242 |
Town *t; |
2639 | 1243 |
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
|
1244 |
} |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1349
diff
changeset
|
1245 |
|
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1246 |
/* 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
|
1247 |
* 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
|
1248 |
if (CheckSavegameVersion(16)) { |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1249 |
FOR_ALL_PLAYERS(p) { |
2848 | 1250 |
p->engine_renew_list = NULL; |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1251 |
p->engine_renew = false; |
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1252 |
p->engine_renew_months = -6; |
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1253 |
p->engine_renew_money = 100000; |
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1254 |
} |
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
|
1255 |
if (_local_player < MAX_PLAYERS) { |
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
|
1256 |
// Set the human controlled player to the patch settings |
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
|
1257 |
// Scenario editor do not have any companies |
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
|
1258 |
p = GetPlayer(_local_player); |
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
|
1259 |
p->engine_renew = _patches.autorenew; |
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
|
1260 |
p->engine_renew_months = _patches.autorenew_months; |
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
|
1261 |
p->engine_renew_money = _patches.autorenew_money; |
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
|
1262 |
} |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1263 |
} |
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2290
diff
changeset
|
1264 |
|
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
|
1265 |
/* 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
|
1266 |
* 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
|
1267 |
* to false */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1268 |
if (CheckSavegameVersionOldStyle(16, 1)) { |
2617
a9e1a187de99
(svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
bjarni
parents:
2572
diff
changeset
|
1269 |
FOR_ALL_PLAYERS(p) { |
a9e1a187de99
(svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
bjarni
parents:
2572
diff
changeset
|
1270 |
p->renew_keep_length = false; |
a9e1a187de99
(svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
bjarni
parents:
2572
diff
changeset
|
1271 |
} |
a9e1a187de99
(svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
bjarni
parents:
2572
diff
changeset
|
1272 |
} |
a9e1a187de99
(svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
bjarni
parents:
2572
diff
changeset
|
1273 |
|
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
|
1274 |
/* 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
|
1275 |
* 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
|
1276 |
* 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
|
1277 |
* waypoint struct. */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2684
diff
changeset
|
1278 |
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
|
1279 |
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
|
1280 |
|
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
|
1281 |
FOR_ALL_WAYPOINTS(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
|
1282 |
if (wp->xy != 0 && wp->deleted == 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
|
1283 |
const StationSpec *spec = NULL; |
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
|
1284 |
|
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
|
1285 |
if (HASBIT(_m[wp->xy].m3, 4)) |
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
|
1286 |
spec = GetCustomStation(STAT_CLASS_WAYP, _m[wp->xy].m4 + 1); |
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
|
1287 |
|
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
|
1288 |
if (spec != NULL) { |
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
|
1289 |
wp->stat_id = _m[wp->xy].m4 + 1; |
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
|
1290 |
wp->grfid = spec->grfid; |
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
|
1291 |
wp->localidx = spec->localidx; |
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
|
1292 |
} 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
|
1293 |
// No custom graphics set, so set to default. |
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
|
1294 |
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
|
1295 |
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
|
1296 |
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
|
1297 |
} |
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
|
1298 |
|
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
|
1299 |
// Move ground type bits from m2 to m4. |
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
|
1300 |
_m[wp->xy].m4 = GB(_m[wp->xy].m2, 0, 4); |
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
|
1301 |
// Store waypoint index in the tile. |
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
|
1302 |
_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
|
1303 |
} |
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
|
1304 |
} |
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
|
1305 |
} 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
|
1306 |
/* 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
|
1307 |
* from the GRF ID / station 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
|
1308 |
UpdateAllWaypointCustomGraphics(); |
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
|
1309 |
} |
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
|
1310 |
|
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
|
1311 |
/* 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
|
1312 |
* 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
|
1313 |
if (CheckSavegameVersion(21) && !CheckSavegameVersion(15)) { |
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
|
1314 |
BEGIN_TILE_LOOP(tile, MapSizeX(), MapSizeY(), 0) { |
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
|
1315 |
if (IsTileType(tile, MP_RAILWAY)) { |
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
|
1316 |
// Clear PBS signals, move back sempahore bit to 2 |
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
|
1317 |
if (HasSignals(tile)) { |
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
|
1318 |
// convert PBS signals to combo-signals |
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
|
1319 |
if (HASBIT(_m[tile].m4, 2)) SB(_m[tile].m4, 0, 2, 3); |
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
|
1320 |
|
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
|
1321 |
SB(_m[tile].m4, 2, 2, HASBIT(_m[tile].m4, 3)); |
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
|
1322 |
CLRBIT(_m[tile].m4, 3); |
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
|
1323 |
} |
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
|
1324 |
|
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
|
1325 |
// Clear PBS reservation on track |
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
|
1326 |
if (!IsTileDepotType(tile, TRANSPORT_RAIL)) |
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
|
1327 |
SB(_m[tile].m4, 4, 4, 0); |
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
|
1328 |
else |
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
|
1329 |
CLRBIT(_m[tile].m3, 6); |
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
|
1330 |
} |
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
|
1331 |
|
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
|
1332 |
// Clear PBS reservation on crossing |
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
|
1333 |
if (IsTileType(tile, MP_STREET) && IsLevelCrossing(tile)) |
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
|
1334 |
CLRBIT(_m[tile].m5, 0); |
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
|
1335 |
|
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
|
1336 |
// Clear PBS reservation on station |
2929
f54492d3dea8
(svn r3485) - [Post-PBS]: when reverting PBS and removing station-tile reservations a station can of course not be a crossing as well. Thanks glx.
Darkvater
parents:
2928
diff
changeset
|
1337 |
if (IsTileType(tile, MP_STATION)) |
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
|
1338 |
CLRBIT(_m[tile].m3, 6); |
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
|
1339 |
} END_TILE_LOOP(tile, MapSizeX(), MapSizeY(), 0); |
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
|
1340 |
} |
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
|
1341 |
|
2639 | 1342 |
FOR_ALL_PLAYERS(p) p->avail_railtypes = GetPlayerRailtypes(p->index); |
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
2100
diff
changeset
|
1343 |
|
0 | 1344 |
return true; |
1345 |
} |