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