author | truelight |
Thu, 24 Mar 2005 14:43:40 +0000 | |
changeset 1540 | 6eef12dab5bf |
parent 1501 | 0fc808b4e375 |
child 1542 | 62a03537ad0b |
permissions | -rw-r--r-- |
0 | 1 |
#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
|
2 |
#include "string.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
497
diff
changeset
|
3 |
#include "table/strings.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1296
diff
changeset
|
4 |
#include "debug.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
|
5 |
#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
|
6 |
#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
|
7 |
#include "tile.h" |
0 | 8 |
|
9 |
#define VARDEF |
|
10 |
#include "ttd.h" |
|
1496
15d859a626e8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1482
diff
changeset
|
11 |
#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
|
12 |
#include "spritecache.h" |
0 | 13 |
#include "gfx.h" |
14 |
#include "gui.h" |
|
15 |
#include "station.h" |
|
16 |
#include "vehicle.h" |
|
17 |
#include "viewport.h" |
|
18 |
#include "window.h" |
|
19 |
#include "player.h" |
|
20 |
#include "command.h" |
|
21 |
#include "town.h" |
|
22 |
#include "industry.h" |
|
23 |
#include "news.h" |
|
24 |
#include "engine.h" |
|
25 |
#include "sound.h" |
|
26 |
#include "economy.h" |
|
27 |
#include "fileio.h" |
|
28 |
#include "hal.h" |
|
29 |
#include "airport.h" |
|
30 |
#include "saveload.h" |
|
139 | 31 |
#include "ai.h" |
126 | 32 |
#include "console.h" |
430 | 33 |
#include "screenshot.h" |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
34 |
#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
|
35 |
#include "signs.h" |
1313
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1310
diff
changeset
|
36 |
#include "depot.h" |
0 | 37 |
|
38 |
#include <stdarg.h> |
|
39 |
||
1218 | 40 |
void GenerateWorld(int mode, uint log_x, uint log_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
|
41 |
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
|
42 |
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
|
43 |
void RunOtherPlayersLoop(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
|
44 |
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
|
45 |
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
|
46 |
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
|
47 |
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
|
48 |
void DeleteAllPlayerStations(void); |
0 | 49 |
|
50 |
extern void SetDifficultyLevel(int mode, GameOptions *gm_opt); |
|
51 |
extern void DoStartupNewPlayer(bool is_ai); |
|
52 |
extern void ShowOSErrorBox(const char *buf); |
|
53 |
||
54 |
void redsq_debug(int tile); |
|
55 |
bool LoadSavegame(const char *filename); |
|
56 |
||
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
|
57 |
extern void HalGameLoop(void); |
0 | 58 |
|
59 |
uint32 _pixels_redrawn; |
|
60 |
bool _dbg_screen_rect; |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
61 |
bool disable_computer; // We should get ride of this thing.. is only used for a debug-cheat |
223
0e5cc5a65df6
(svn r224) -Fix: Music now finally works on WinXP. DirectMusic is now default for an OS >= WinNT4 (WinNT4, Win2k, WinXP), and MIDI driver for lower OS's (Win95, Win98, WinME, etc).
darkvater
parents:
222
diff
changeset
|
62 |
static byte _os_version = 0; |
0 | 63 |
|
1436 | 64 |
/* TODO: usrerror() for errors which are not of an internal nature but |
65 |
* caused by the user, i.e. missing files or fatal configuration errors. |
|
66 |
* Post-0.4.0 since Celestar doesn't want this in SVN before. --pasky */ |
|
67 |
||
0 | 68 |
void CDECL error(const char *s, ...) { |
69 |
va_list va; |
|
70 |
char buf[512]; |
|
71 |
va_start(va, s); |
|
72 |
vsprintf(buf, s, va); |
|
73 |
va_end(va); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
74 |
|
0 | 75 |
ShowOSErrorBox(buf); |
76 |
if (_video_driver) |
|
77 |
_video_driver->stop(); |
|
78 |
||
79 |
assert(0); |
|
80 |
exit(1); |
|
81 |
} |
|
82 |
||
83 |
void CDECL ShowInfoF(const char *str, ...) |
|
84 |
{ |
|
85 |
va_list va; |
|
86 |
char buf[1024]; |
|
87 |
va_start(va, str); |
|
88 |
vsprintf(buf, str, va); |
|
89 |
va_end(va); |
|
90 |
ShowInfo(buf); |
|
91 |
} |
|
92 |
||
93 |
char * CDECL str_fmt(const char *str, ...) |
|
94 |
{ |
|
95 |
char buf[4096]; |
|
96 |
va_list va; |
|
97 |
int len; |
|
98 |
char *p; |
|
99 |
||
100 |
va_start(va, str); |
|
101 |
len = vsprintf(buf, str, va); |
|
102 |
va_end(va); |
|
103 |
p = malloc(len + 1); |
|
104 |
if (p) |
|
105 |
memcpy(p, buf, len + 1); |
|
106 |
return p; |
|
107 |
} |
|
108 |
||
109 |
||
110 |
// NULL midi driver |
|
1301
bf64ba5b6774
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
111 |
static const char *NullMidiStart(const char * const *parm) { return NULL; } |
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
|
112 |
static void NullMidiStop(void) {} |
0 | 113 |
static void NullMidiPlaySong(const char *filename) {} |
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
|
114 |
static void NullMidiStopSong(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
|
115 |
static bool NullMidiIsSongPlaying(void) { return true; } |
0 | 116 |
static void NullMidiSetVolume(byte vol) {} |
117 |
||
118 |
const HalMusicDriver _null_music_driver = { |
|
119 |
NullMidiStart, |
|
120 |
NullMidiStop, |
|
121 |
NullMidiPlaySong, |
|
122 |
NullMidiStopSong, |
|
123 |
NullMidiIsSongPlaying, |
|
124 |
NullMidiSetVolume, |
|
125 |
}; |
|
126 |
||
127 |
// NULL video driver |
|
128 |
static void *_null_video_mem; |
|
1301
bf64ba5b6774
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
129 |
static const char *NullVideoStart(const char * const *parm) |
bf64ba5b6774
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
130 |
{ |
0 | 131 |
_screen.width = _screen.pitch = _cur_resolution[0]; |
132 |
_screen.height = _cur_resolution[1]; |
|
133 |
_null_video_mem = malloc(_cur_resolution[0]*_cur_resolution[1]); |
|
134 |
return NULL; |
|
135 |
} |
|
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
|
136 |
static void NullVideoStop(void) { free(_null_video_mem); } |
0 | 137 |
static void NullVideoMakeDirty(int left, int top, int width, int height) {} |
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
|
138 |
static int NullVideoMainLoop(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
|
139 |
{ |
0 | 140 |
int i = 1000; |
141 |
do { |
|
142 |
GameLoop(); |
|
143 |
_screen.dst_ptr = _null_video_mem; |
|
144 |
UpdateWindows(); |
|
145 |
} while (--i); |
|
146 |
return ML_QUIT; |
|
147 |
} |
|
148 |
||
149 |
static bool NullVideoChangeRes(int w, int h) { return false; } |
|
150 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
151 |
|
0 | 152 |
const HalVideoDriver _null_video_driver = { |
153 |
NullVideoStart, |
|
154 |
NullVideoStop, |
|
155 |
NullVideoMakeDirty, |
|
156 |
NullVideoMainLoop, |
|
157 |
NullVideoChangeRes, |
|
158 |
}; |
|
159 |
||
160 |
// NULL sound driver |
|
1301
bf64ba5b6774
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
161 |
static const char *NullSoundStart(const char * const *parm) { return NULL; } |
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
|
162 |
static void NullSoundStop(void) {} |
0 | 163 |
const HalSoundDriver _null_sound_driver = { |
164 |
NullSoundStart, |
|
165 |
NullSoundStop, |
|
166 |
}; |
|
167 |
||
168 |
enum { |
|
169 |
DF_PRIORITY_MASK = 0xf, |
|
170 |
}; |
|
171 |
||
172 |
typedef struct { |
|
173 |
const DriverDesc *descs; |
|
174 |
const char *name; |
|
175 |
void *var; |
|
176 |
} DriverClass; |
|
177 |
||
178 |
static DriverClass _driver_classes[] = { |
|
179 |
{_video_driver_descs, "video", &_video_driver}, |
|
180 |
{_sound_driver_descs, "sound", &_sound_driver}, |
|
181 |
{_music_driver_descs, "music", &_music_driver}, |
|
182 |
}; |
|
183 |
||
184 |
static const DriverDesc *GetDriverByName(const DriverDesc *dd, const char *name) |
|
185 |
{ |
|
186 |
do { |
|
187 |
if (!strcmp(dd->name, name)) |
|
188 |
return dd; |
|
189 |
} while ((++dd)->name); |
|
190 |
return NULL; |
|
191 |
} |
|
192 |
||
193 |
static const DriverDesc *ChooseDefaultDriver(const DriverDesc *dd) |
|
194 |
{ |
|
195 |
const DriverDesc *best = NULL; |
|
196 |
int best_pri = -1; |
|
197 |
do { |
|
223
0e5cc5a65df6
(svn r224) -Fix: Music now finally works on WinXP. DirectMusic is now default for an OS >= WinNT4 (WinNT4, Win2k, WinXP), and MIDI driver for lower OS's (Win95, Win98, WinME, etc).
darkvater
parents:
222
diff
changeset
|
198 |
if ((int)(dd->flags&DF_PRIORITY_MASK) > best_pri && _os_version >= (byte)dd->flags) { |
0 | 199 |
best_pri = dd->flags&DF_PRIORITY_MASK; |
200 |
best = dd; |
|
201 |
} |
|
202 |
} while ((++dd)->name); |
|
203 |
return best; |
|
204 |
} |
|
205 |
||
206 |
||
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
|
207 |
void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize) |
0 | 208 |
{ |
209 |
FILE *in; |
|
1105 | 210 |
byte *mem; |
0 | 211 |
size_t len; |
212 |
||
213 |
in = fopen(filename, "rb"); |
|
214 |
if (in == NULL) |
|
215 |
return NULL; |
|
216 |
||
217 |
fseek(in, 0, SEEK_END); |
|
218 |
len = ftell(in); |
|
219 |
fseek(in, 0, SEEK_SET); |
|
1105 | 220 |
if (len > maxsize || (mem = malloc(len + 1)) == NULL) { |
0 | 221 |
fclose(in); |
222 |
return NULL; |
|
223 |
} |
|
1105 | 224 |
mem[len] = 0; |
0 | 225 |
if (fread(mem, len, 1, in) != 1) { |
226 |
fclose(in); |
|
227 |
free(mem); |
|
228 |
return NULL; |
|
229 |
} |
|
230 |
fclose(in); |
|
231 |
||
232 |
*lenp = len; |
|
233 |
return mem; |
|
234 |
} |
|
235 |
||
236 |
void LoadDriver(int driver, const char *name) |
|
237 |
{ |
|
238 |
const DriverClass *dc = &_driver_classes[driver]; |
|
239 |
const DriverDesc *dd; |
|
240 |
const void **var; |
|
241 |
const void *drv; |
|
242 |
const char *err; |
|
243 |
char *parm; |
|
244 |
char buffer[256]; |
|
1301
bf64ba5b6774
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
245 |
const char *parms[32]; |
0 | 246 |
|
247 |
parms[0] = NULL; |
|
248 |
||
249 |
if (!*name) { |
|
250 |
dd = ChooseDefaultDriver(dc->descs); |
|
251 |
} else { |
|
252 |
// Extract the driver name and put parameter list in parm |
|
253 |
ttd_strlcpy(buffer, name, sizeof(buffer)); |
|
254 |
parm = strchr(buffer, ':'); |
|
255 |
if (parm) { |
|
959
e6a3bbda610f
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
950
diff
changeset
|
256 |
uint np = 0; |
0 | 257 |
// Tokenize the parm. |
258 |
do { |
|
259 |
*parm++ = 0; |
|
260 |
if (np < lengthof(parms) - 1) |
|
261 |
parms[np++] = parm; |
|
262 |
while (*parm != 0 && *parm != ',') |
|
263 |
parm++; |
|
264 |
} while (*parm == ','); |
|
265 |
parms[np] = NULL; |
|
266 |
} |
|
267 |
dd = GetDriverByName(dc->descs, buffer); |
|
268 |
if (dd == NULL) |
|
269 |
error("No such %s driver: %s\n", dc->name, buffer); |
|
270 |
} |
|
271 |
var = dc->var; |
|
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
213
diff
changeset
|
272 |
if (*var != NULL) ((const HalCommonDriver*)*var)->stop(); |
0 | 273 |
*var = NULL; |
274 |
drv = dd->drv; |
|
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
213
diff
changeset
|
275 |
if ((err=((const HalCommonDriver*)drv)->start(parms)) != NULL) |
0 | 276 |
error("Unable to load driver %s(%s). The error was: %s\n", dd->name, dd->longname, err); |
277 |
*var = drv; |
|
278 |
} |
|
279 |
||
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
|
280 |
static void showhelp(void) |
0 | 281 |
{ |
282 |
char buf[4096], *p; |
|
283 |
const DriverClass *dc = _driver_classes; |
|
284 |
const DriverDesc *dd; |
|
285 |
int i; |
|
286 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
287 |
p = strecpy(buf, |
0 | 288 |
"Command line options:\n" |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
289 |
" -v drv = Set video driver (see below)\n" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
290 |
" -s drv = Set sound driver (see below)\n" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
291 |
" -m drv = Set music driver (see below)\n" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
292 |
" -r res = Set resolution (for instance 800x600)\n" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
293 |
" -h = Display this help text\n" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
294 |
" -t date = Set starting date\n" |
1440
08722492ee27
(svn r1944) Make --help output for -d at least somewhat useful.
pasky
parents:
1436
diff
changeset
|
295 |
" -d [[fac=]lvl[,...]]= Debug mode\n" |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
296 |
" -l lng = Select Language\n" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
297 |
" -e = Start Editor\n" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
298 |
" -g [savegame] = Start new/save game immediately\n" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
299 |
" -G seed = Set random seed\n" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
300 |
" -n [ip#player:port] = Start networkgame\n" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
301 |
" -D = Start dedicated server\n" |
770
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
768
diff
changeset
|
302 |
#if !defined(__MORPHOS__) && !defined(__AMIGA__) |
704
e843dd369938
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
303 |
" -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
|
304 |
#endif |
614
b96f987dbf80
(svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents:
561
diff
changeset
|
305 |
" -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
|
306 |
" -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
|
307 |
" -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
|
308 |
lastof(buf) |
0 | 309 |
); |
310 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
311 |
for(i=0; i!=lengthof(_driver_classes); i++,dc++) { |
0 | 312 |
p += sprintf(p, "List of %s drivers:\n", dc->name); |
313 |
dd = dc->descs; |
|
314 |
do { |
|
315 |
p += sprintf(p, "%10s: %s\n", dd->name, dd->longname); |
|
316 |
} while ((++dd)->name); |
|
317 |
} |
|
318 |
||
319 |
ShowInfo(buf); |
|
320 |
} |
|
321 |
||
322 |
||
1301
bf64ba5b6774
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
323 |
const char *GetDriverParam(const char * const *parm, const char *name) |
0 | 324 |
{ |
1301
bf64ba5b6774
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
325 |
const char *p; |
0 | 326 |
int len = strlen(name); |
327 |
while ((p = *parm++) != NULL) { |
|
328 |
if (!strncmp(p,name,len)) { |
|
329 |
if (p[len] == '=') return p + len + 1; |
|
330 |
if (p[len] == 0) return p + len; |
|
331 |
} |
|
332 |
} |
|
333 |
return NULL; |
|
334 |
} |
|
335 |
||
1301
bf64ba5b6774
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
336 |
bool GetDriverParamBool(const char * const *parm, const char *name) |
0 | 337 |
{ |
1301
bf64ba5b6774
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
338 |
const char *p = GetDriverParam(parm, name); |
0 | 339 |
return p != NULL; |
340 |
} |
|
341 |
||
1301
bf64ba5b6774
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
342 |
int GetDriverParamInt(const char * const *parm, const char *name, int def) |
0 | 343 |
{ |
1301
bf64ba5b6774
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1299
diff
changeset
|
344 |
const char *p = GetDriverParam(parm, name); |
0 | 345 |
return p != NULL ? atoi(p) : def; |
346 |
} |
|
347 |
||
348 |
typedef struct { |
|
349 |
char *opt; |
|
350 |
int numleft; |
|
351 |
char **argv; |
|
352 |
const char *options; |
|
353 |
char *cont; |
|
354 |
} MyGetOptData; |
|
355 |
||
356 |
static void MyGetOptInit(MyGetOptData *md, int argc, char **argv, const char *options) |
|
357 |
{ |
|
358 |
md->cont = NULL; |
|
359 |
md->numleft = argc; |
|
360 |
md->argv = argv; |
|
361 |
md->options = options; |
|
362 |
} |
|
363 |
||
364 |
static int MyGetOpt(MyGetOptData *md) |
|
365 |
{ |
|
366 |
char *s,*r,*t; |
|
367 |
||
368 |
if ((s=md->cont) != NULL) |
|
369 |
goto md_continue_here; |
|
370 |
||
371 |
while(true) { |
|
372 |
if (--md->numleft < 0) |
|
373 |
return -1; |
|
374 |
||
375 |
s = *md->argv++; |
|
376 |
if (*s == '-') { |
|
377 |
md_continue_here:; |
|
378 |
s++; |
|
379 |
if (*s != 0) { |
|
380 |
// Found argument, try to locate it in options. |
|
381 |
if (*s == ':' || (r = strchr(md->options, *s)) == NULL) { |
|
382 |
// ERROR! |
|
383 |
return -2; |
|
384 |
} |
|
385 |
if (r[1] == ':') { |
|
386 |
// Item wants an argument. Check if the argument follows, or if it comes as a separate arg. |
|
387 |
if (!*(t = s + 1)) { |
|
388 |
// It comes as a separate arg. Check if out of args? |
|
389 |
if (--md->numleft < 0 || *(t = *md->argv) == '-') { |
|
390 |
// Check if item is optional? |
|
391 |
if (r[2] != ':') |
|
392 |
return -2; |
|
393 |
md->numleft++; |
|
394 |
t = NULL; |
|
395 |
} else { |
|
396 |
md->argv++; |
|
397 |
} |
|
398 |
} |
|
399 |
md->opt = t; |
|
400 |
md->cont = NULL; |
|
401 |
return *s; |
|
402 |
} |
|
403 |
md->opt = NULL; |
|
404 |
md->cont = s; |
|
405 |
return *s; |
|
406 |
} |
|
407 |
} else { |
|
408 |
// This is currently not supported. |
|
409 |
return -2; |
|
410 |
} |
|
411 |
} |
|
412 |
} |
|
413 |
||
414 |
||
1095 | 415 |
static void ParseResolution(int res[2], char *s) |
0 | 416 |
{ |
417 |
char *t = strchr(s, 'x'); |
|
418 |
if (t == NULL) { |
|
419 |
ShowInfoF("Invalid resolution '%s'", s); |
|
420 |
return; |
|
421 |
} |
|
422 |
||
310 | 423 |
res[0] = strtoul(s, NULL, 0); |
424 |
res[1] = strtoul(t + 1, NULL, 0); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
425 |
} |
0 | 426 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
427 |
static void InitializeDynamicVariables(void) |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
428 |
{ |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
429 |
/* 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
|
430 |
_station_sort = NULL; |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1264
diff
changeset
|
431 |
_vehicle_sort = NULL; |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1264
diff
changeset
|
432 |
_town_sort = NULL; |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
433 |
_industry_sort = NULL; |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
434 |
} |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
435 |
|
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
436 |
static void UnInitializeDynamicVariables(void) |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
437 |
{ |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
438 |
/* 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
|
439 |
CleanPool(&_town_pool); |
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1264
diff
changeset
|
440 |
CleanPool(&_industry_pool); |
1272
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1268
diff
changeset
|
441 |
CleanPool(&_station_pool); |
1279
bc761aad52b3
(svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents:
1272
diff
changeset
|
442 |
CleanPool(&_vehicle_pool); |
1283
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1279
diff
changeset
|
443 |
CleanPool(&_sign_pool); |
1314
10c3417e9c22
(svn r1818) -Add: Dynamic orders (up to 64k orders)
truelight
parents:
1313
diff
changeset
|
444 |
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
|
445 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
446 |
free(_station_sort); |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
447 |
free(_vehicle_sort); |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
448 |
free(_town_sort); |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
449 |
free(_industry_sort); |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
450 |
} |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
451 |
|
1474
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
452 |
static void UnInitializeGame(void) |
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
453 |
{ |
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
454 |
UnInitWindowSystem(); |
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
455 |
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
|
456 |
|
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
|
457 |
free(_config_file); |
1474
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
458 |
} |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
459 |
|
1095 | 460 |
static void LoadIntroGame(void) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
461 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
462 |
char filename[256]; |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
463 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
464 |
_game_mode = GM_MENU; |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
465 |
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
|
466 |
_opt_ptr = &_opt_newgame; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
467 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
468 |
GfxLoadSprites(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
469 |
LoadStringWidthTable(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
470 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
471 |
// Setup main window |
1474
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
472 |
ResetWindowSystem(); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
473 |
SetupColorsAndInitialWindow(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
474 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
475 |
// Generate a world. |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
476 |
sprintf(filename, "%sopntitle.dat", _path.data_dir); |
921 | 477 |
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
|
478 |
#if defined SECOND_DATA_DIR |
9a0c469a251c
(svn r970) Added 2nd data path for all non-windows OSes
bjarni
parents:
557
diff
changeset
|
479 |
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
|
480 |
if (SaveOrLoad(filename, SL_LOAD) != SL_OK) |
9a0c469a251c
(svn r970) Added 2nd data path for all non-windows OSes
bjarni
parents:
557
diff
changeset
|
481 |
#endif |
1218 | 482 |
GenerateWorld(1, 6, 6); // if failed loading, make empty world. |
921 | 483 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
484 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
485 |
_pause = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
486 |
_local_player = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
487 |
MarkWholeScreenDirty(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
488 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
489 |
// Play main theme |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
490 |
if (_music_driver->is_song_playing()) ResetMusic(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
491 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
492 |
|
774
bb9ec520a1b1
(svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.
darkvater
parents:
770
diff
changeset
|
493 |
extern void DedicatedFork(void); |
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
|
494 |
extern void CheckExternalFiles(void); |
704
e843dd369938
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
495 |
|
0 | 496 |
int ttd_main(int argc, char* argv[]) |
497 |
{ |
|
498 |
MyGetOptData mgo; |
|
499 |
int i; |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
500 |
bool network = false; |
0 | 501 |
char *network_conn = NULL; |
502 |
char *language = NULL; |
|
1010
977aafc6b8e3
(svn r1509) Const correctness and add static where appropriate while touching the lines anyway
tron
parents:
1009
diff
changeset
|
503 |
const char *optformat; |
469
d8c423a7a5f0
(svn r702) -Fix: Buffer overflow in music/sound/video-driver-parameter (Oskar_)
truelight
parents:
430
diff
changeset
|
504 |
char musicdriver[16], sounddriver[16], videodriver[16]; |
0 | 505 |
int resolution[2] = {0,0}; |
506 |
uint startdate = -1; |
|
1406
f5da270a654f
(svn r1910) Move two variables out of variables.h which are only used locally
tron
parents:
1397
diff
changeset
|
507 |
bool dedicated; |
f5da270a654f
(svn r1910) Move two variables out of variables.h which are only used locally
tron
parents:
1397
diff
changeset
|
508 |
|
0 | 509 |
musicdriver[0] = sounddriver[0] = videodriver[0] = 0; |
510 |
||
511 |
_game_mode = GM_MENU; |
|
512 |
_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
|
513 |
_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
|
514 |
_dedicated_forks = false; |
1406
f5da270a654f
(svn r1910) Move two variables out of variables.h which are only used locally
tron
parents:
1397
diff
changeset
|
515 |
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
|
516 |
_config_file = NULL; |
0 | 517 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
518 |
// The last param of the following function means this: |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
519 |
// 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
|
520 |
// 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
|
521 |
// 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
|
522 |
#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
|
523 |
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
|
524 |
#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
|
525 |
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
|
526 |
#endif |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
768
diff
changeset
|
527 |
|
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
768
diff
changeset
|
528 |
MyGetOptInit(&mgo, argc-1, argv+1, optformat); |
0 | 529 |
while ((i = MyGetOpt(&mgo)) != -1) { |
530 |
switch(i) { |
|
531 |
case 'm': ttd_strlcpy(musicdriver, mgo.opt, sizeof(musicdriver)); break; |
|
532 |
case 's': ttd_strlcpy(sounddriver, mgo.opt, sizeof(sounddriver)); break; |
|
533 |
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
|
534 |
case 'D': { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
535 |
sprintf(musicdriver,"null"); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
536 |
sprintf(sounddriver,"null"); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
537 |
sprintf(videodriver,"dedicated"); |
1406
f5da270a654f
(svn r1910) Move two variables out of variables.h which are only used locally
tron
parents:
1397
diff
changeset
|
538 |
dedicated = true; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
539 |
} break; |
704
e843dd369938
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
540 |
case 'f': { |
e843dd369938
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
541 |
_dedicated_forks = true; |
e843dd369938
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
542 |
}; break; |
1 | 543 |
case 'n': { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
544 |
network = true; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
545 |
if (mgo.opt) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
546 |
// Optional, you can give an IP |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
547 |
network_conn = mgo.opt; |
1 | 548 |
else |
549 |
network_conn = NULL; |
|
550 |
} break; |
|
0 | 551 |
case 'r': ParseResolution(resolution, mgo.opt); break; |
552 |
case 'l': { |
|
553 |
language = mgo.opt; |
|
554 |
} break; |
|
555 |
case 't': { |
|
556 |
startdate = atoi(mgo.opt); |
|
557 |
} break; |
|
558 |
case 'd': { |
|
559 |
#if defined(WIN32) |
|
560 |
CreateConsole(); |
|
561 |
#endif |
|
562 |
if (mgo.opt) |
|
563 |
SetDebugString(mgo.opt); |
|
564 |
} break; |
|
565 |
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
|
566 |
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
|
567 |
case 'g': |
0 | 568 |
if (mgo.opt) { |
569 |
strcpy(_file_to_saveload.name, mgo.opt); |
|
570 |
_switch_mode = SM_LOAD; |
|
571 |
} else |
|
572 |
_switch_mode = SM_NEWGAME; |
|
573 |
break; |
|
574 |
case 'G': |
|
206 | 575 |
_random_seeds[0][0] = atoi(mgo.opt); |
0 | 576 |
break; |
577 |
case 'p': { |
|
578 |
int i = atoi(mgo.opt); |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
579 |
// Play as an other player in network games |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
580 |
if (IS_INT_INSIDE(i, 1, MAX_PLAYERS)) _network_playas = i; |
0 | 581 |
break; |
582 |
} |
|
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
|
583 |
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
|
584 |
_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
|
585 |
break; |
0 | 586 |
case -2: |
587 |
case 'h': |
|
588 |
showhelp(); |
|
589 |
return 0; |
|
590 |
} |
|
591 |
} |
|
592 |
||
593 |
DeterminePaths(); |
|
961 | 594 |
CheckExternalFiles(); |
704
e843dd369938
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
595 |
|
e843dd369938
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
596 |
#ifdef UNIX |
e843dd369938
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
597 |
// 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
|
598 |
if (_dedicated_forks) |
e843dd369938
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
599 |
DedicatedFork(); |
e843dd369938
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
600 |
#endif |
e843dd369938
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
601 |
|
0 | 602 |
LoadFromConfig(); |
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
|
603 |
LoadFromHighScore(); |
0 | 604 |
|
605 |
// override config? |
|
469
d8c423a7a5f0
(svn r702) -Fix: Buffer overflow in music/sound/video-driver-parameter (Oskar_)
truelight
parents:
430
diff
changeset
|
606 |
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
|
607 |
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
|
608 |
if (videodriver[0]) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver)); |
0 | 609 |
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
|
610 |
if (startdate != (uint)-1) _patches.starting_date = startdate; |
0 | 611 |
|
1406
f5da270a654f
(svn r1910) Move two variables out of variables.h which are only used locally
tron
parents:
1397
diff
changeset
|
612 |
if (_dedicated_forks && !dedicated) |
704
e843dd369938
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
613 |
_dedicated_forks = false; |
e843dd369938
(svn r1154) -Add: [Network] Forked dedicated server (start openttd with -Df) (GeniusDex)
truelight
parents:
679
diff
changeset
|
614 |
|
0 | 615 |
// enumerate language files |
616 |
InitializeLanguagePacks(); |
|
617 |
||
618 |
// initialize screenshot formats |
|
619 |
InitializeScreenshotFormats(); |
|
620 |
||
105 | 621 |
// initialize airport state machines |
622 |
InitializeAirports(); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
623 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
624 |
/* 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
|
625 |
InitializeDynamicVariables(); |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
626 |
|
0 | 627 |
// Sample catalogue |
628 |
DEBUG(misc, 1) ("Loading sound effects..."); |
|
223
0e5cc5a65df6
(svn r224) -Fix: Music now finally works on WinXP. DirectMusic is now default for an OS >= WinNT4 (WinNT4, Win2k, WinXP), and MIDI driver for lower OS's (Win95, Win98, WinME, etc).
darkvater
parents:
222
diff
changeset
|
629 |
_os_version = GetOSVersion(); |
1496
15d859a626e8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1482
diff
changeset
|
630 |
MxInitialize(11025); |
15d859a626e8
(svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
1482
diff
changeset
|
631 |
SoundInitialize("sample.cat"); |
0 | 632 |
|
633 |
// This must be done early, since functions use the InvalidateWindow* calls |
|
139 | 634 |
InitWindowSystem(); |
0 | 635 |
|
636 |
GfxLoadSprites(); |
|
637 |
LoadStringWidthTable(); |
|
638 |
||
639 |
DEBUG(misc, 1) ("Loading drivers..."); |
|
640 |
LoadDriver(SOUND_DRIVER, _ini_sounddriver); |
|
641 |
LoadDriver(MUSIC_DRIVER, _ini_musicdriver); |
|
642 |
LoadDriver(VIDEO_DRIVER, _ini_videodriver); // load video last, to prevent an empty window while sound and music loads |
|
643 |
MusicLoop(); |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
152
diff
changeset
|
644 |
_savegame_sort_order = 1; // default sorting of savegames is by date, newest first |
0 | 645 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
646 |
#ifdef ENABLE_NETWORK |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
647 |
// initialize network-core |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
648 |
NetworkStartUp(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
649 |
#endif /* ENABLE_NETWORK */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
650 |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
651 |
_opt_ptr = &_opt_newgame; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
652 |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
653 |
/* 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
|
654 |
if (_opt_newgame.diff_level == 9) |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
655 |
SetDifficultyLevel(0, &_opt_newgame); |
0 | 656 |
|
139 | 657 |
// initialize the ingame console |
658 |
IConsoleInit(); |
|
1246
eb66ff34348f
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1243
diff
changeset
|
659 |
InitializeGUI(); |
644
cd687cdec701
(svn r1077) Implements scripts/autoexec.scr to get executed on game starting (sign_de)
dominik
parents:
630
diff
changeset
|
660 |
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
|
661 |
|
206 | 662 |
InitPlayerRandoms(); |
0 | 663 |
|
1268
bcbbc18f5c3e
(svn r1772) -Fix: [ 1114100 ] Dedicated server boots again
truelight
parents:
1267
diff
changeset
|
664 |
GenerateWorld(1, 6, 6); // Make the viewport initialization happy |
bcbbc18f5c3e
(svn r1772) -Fix: [ 1114100 ] Dedicated server boots again
truelight
parents:
1267
diff
changeset
|
665 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
666 |
#ifdef ENABLE_NETWORK |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
667 |
if ((network) && (_network_available)) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
668 |
if (network_conn != NULL) { |
1329 | 669 |
const char *port = NULL; |
670 |
const char *player = NULL; |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
671 |
uint16 rport; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
672 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
673 |
rport = NETWORK_DEFAULT_PORT; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
674 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
675 |
ParseConnectionString(&player, &port, network_conn); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
676 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
677 |
if (player != NULL) _network_playas = atoi(player); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
678 |
if (port != NULL) rport = atoi(port); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
679 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
680 |
LoadIntroGame(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
681 |
_switch_mode = SM_NONE; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
682 |
NetworkClientConnectGame(network_conn, rport); |
1109
ecb98f43ba2c
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1105
diff
changeset
|
683 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
684 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
685 |
#endif /* ENABLE_NETWORK */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
686 |
|
0 | 687 |
while (_video_driver->main_loop() == ML_SWITCHDRIVER) {} |
139 | 688 |
|
689 |
IConsoleFree(); |
|
0 | 690 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
691 |
#ifdef ENABLE_NETWORK |
105 | 692 |
if (_network_available) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
693 |
// Shut down the network and close any open connections |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
694 |
NetworkDisconnect(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
695 |
NetworkUDPClose(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
696 |
NetworkShutDown(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
697 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
698 |
#endif /* ENABLE_NETWORK */ |
0 | 699 |
|
700 |
_video_driver->stop(); |
|
701 |
_music_driver->stop(); |
|
702 |
_sound_driver->stop(); |
|
703 |
||
704 |
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
|
705 |
SaveToHighScore(); |
0 | 706 |
|
105 | 707 |
// uninitialize airport state machines |
708 |
UnInitializeAirports(); |
|
0 | 709 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
710 |
/* uninitialize variables that are allocated dynamic */ |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
711 |
UnInitializeDynamicVariables(); |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
865
diff
changeset
|
712 |
|
1036
8a82ce28b724
(svn r1537) -Fix: Close all and any open filehandles open at shutdown (tamlin)
darkvater
parents:
1035
diff
changeset
|
713 |
/* 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
|
714 |
FioCloseAll(); |
1474
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
715 |
UnInitializeGame(); |
1036
8a82ce28b724
(svn r1537) -Fix: Close all and any open filehandles open at shutdown (tamlin)
darkvater
parents:
1035
diff
changeset
|
716 |
|
0 | 717 |
return 0; |
718 |
} |
|
719 |
||
720 |
static void ShowScreenshotResult(bool b) |
|
721 |
{ |
|
722 |
if (b) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
723 |
SetDParam(0, STR_SPEC_SCREENSHOT_NAME); |
0 | 724 |
ShowErrorMessage(INVALID_STRING_ID, STR_031B_SCREENSHOT_SUCCESSFULLY, 0, 0); |
725 |
} else { |
|
726 |
ShowErrorMessage(INVALID_STRING_ID, STR_031C_SCREENSHOT_FAILED, 0, 0); |
|
727 |
} |
|
728 |
||
729 |
} |
|
730 |
||
1095 | 731 |
static void MakeNewGame(void) |
0 | 732 |
{ |
733 |
_game_mode = GM_NORMAL; |
|
734 |
||
735 |
// Copy in game options |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
736 |
_opt_ptr = &_opt; |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
737 |
memcpy(_opt_ptr, &_opt_newgame, sizeof(GameOptions)); |
0 | 738 |
|
739 |
GfxLoadSprites(); |
|
740 |
||
136
78ac8de2b2b8
(svn r137) Fix: console sometime didn't open (sign_de)
dominik
parents:
126
diff
changeset
|
741 |
// Reinitialize windows |
1474
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
742 |
ResetWindowSystem(); |
0 | 743 |
LoadStringWidthTable(); |
744 |
||
745 |
SetupColorsAndInitialWindow(); |
|
746 |
||
747 |
// Randomize world |
|
1218 | 748 |
GenerateWorld(0, _patches.map_x, _patches.map_y); |
0 | 749 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
750 |
// In a dedicated server, the server does not play |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
751 |
if (_network_dedicated) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
752 |
_local_player = OWNER_SPECTATOR; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
753 |
} else { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
754 |
// Create a single player |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
755 |
DoStartupNewPlayer(false); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
756 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
757 |
_local_player = 0; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
758 |
} |
0 | 759 |
|
760 |
MarkWholeScreenDirty(); |
|
761 |
} |
|
762 |
||
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
|
763 |
static void MakeNewEditorWorld(void) |
0 | 764 |
{ |
765 |
_game_mode = GM_EDITOR; |
|
766 |
||
767 |
// Copy in game options |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
768 |
_opt_ptr = &_opt; |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
769 |
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
|
770 |
|
0 | 771 |
GfxLoadSprites(); |
772 |
||
136
78ac8de2b2b8
(svn r137) Fix: console sometime didn't open (sign_de)
dominik
parents:
126
diff
changeset
|
773 |
// Re-init the windowing system |
1474
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
774 |
ResetWindowSystem(); |
0 | 775 |
|
776 |
// Create toolbars |
|
777 |
SetupColorsAndInitialWindow(); |
|
778 |
||
779 |
// Startup the game system |
|
1218 | 780 |
GenerateWorld(1, _patches.map_x, _patches.map_y); |
0 | 781 |
|
782 |
_local_player = OWNER_NONE; |
|
783 |
MarkWholeScreenDirty(); |
|
784 |
} |
|
785 |
||
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
|
786 |
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
|
787 |
void StartupDisasters(void); |
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
115
diff
changeset
|
788 |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
789 |
/** |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
790 |
* Start Scenario starts a new game based on a scenario. |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
791 |
* 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
|
792 |
* This starts a scenario based on your current difficulty settings |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
793 |
*/ |
1095 | 794 |
static void StartScenario(void) |
0 | 795 |
{ |
796 |
_game_mode = GM_NORMAL; |
|
797 |
||
798 |
// invalid type |
|
799 |
if (_file_to_saveload.mode == SL_INVALID) { |
|
800 |
printf("Savegame is obsolete or invalid format: %s\n", _file_to_saveload.name); |
|
801 |
ShowErrorMessage(_error_message, STR_4009_GAME_LOAD_FAILED, 0, 0); |
|
802 |
_game_mode = GM_MENU; |
|
803 |
return; |
|
804 |
} |
|
805 |
||
806 |
GfxLoadSprites(); |
|
807 |
||
136
78ac8de2b2b8
(svn r137) Fix: console sometime didn't open (sign_de)
dominik
parents:
126
diff
changeset
|
808 |
// Reinitialize windows |
1474
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
809 |
ResetWindowSystem(); |
0 | 810 |
LoadStringWidthTable(); |
811 |
||
812 |
SetupColorsAndInitialWindow(); |
|
813 |
||
814 |
// Load game |
|
815 |
if (SaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode) != SL_OK) { |
|
816 |
LoadIntroGame(); |
|
817 |
ShowErrorMessage(_error_message, STR_4009_GAME_LOAD_FAILED, 0, 0); |
|
818 |
} |
|
819 |
||
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
|
820 |
_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
|
821 |
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
|
822 |
_opt.diff_level = _opt_newgame.diff_level; |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
823 |
|
115
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
824 |
// Inititalize data |
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
825 |
StartupPlayers(); |
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
826 |
StartupEngines(); |
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
827 |
StartupDisasters(); |
3a3c64e7be82
(svn r116) Fix: [ 963056 ] Wrong trains you can buy with scenarios
dominik
parents:
105
diff
changeset
|
828 |
|
0 | 829 |
_local_player = 0; |
830 |
||
831 |
MarkWholeScreenDirty(); |
|
832 |
} |
|
833 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
834 |
bool SafeSaveOrLoad(const char *filename, int mode, int newgm) |
0 | 835 |
{ |
836 |
byte ogm = _game_mode; |
|
837 |
int r; |
|
838 |
||
839 |
_game_mode = newgm; |
|
840 |
r = SaveOrLoad(filename, mode); |
|
841 |
if (r == SL_REINIT) { |
|
842 |
if (ogm == GM_MENU) |
|
843 |
LoadIntroGame(); |
|
844 |
else if (ogm == GM_EDITOR) |
|
845 |
MakeNewEditorWorld(); |
|
846 |
else |
|
847 |
MakeNewGame(); |
|
848 |
return false; |
|
849 |
} else if (r != SL_OK) { |
|
850 |
_game_mode = ogm; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
851 |
return false; |
0 | 852 |
} else |
853 |
return true; |
|
854 |
} |
|
855 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
856 |
void SwitchMode(int new_mode) |
0 | 857 |
{ |
139 | 858 |
_in_state_game_loop = true; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
859 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
860 |
#ifdef ENABLE_NETWORK |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
861 |
// 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
|
862 |
if (new_mode != SM_SAVE) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
863 |
// If the network is active, make it not-active |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
864 |
if (_networking) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
865 |
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
|
866 |
NetworkReboot(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
867 |
NetworkUDPClose(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
868 |
} else { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
869 |
NetworkDisconnect(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
870 |
NetworkUDPClose(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
871 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
872 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
873 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
874 |
// If we are a server, we restart the server |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
875 |
if (_is_network_server) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
876 |
// But not if we are going to the menu |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
877 |
if (new_mode != SM_MENU) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
878 |
NetworkServerStart(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
879 |
} else { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
880 |
// 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
|
881 |
_is_network_server = false; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
882 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
883 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
884 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
885 |
#endif /* ENABLE_NETWORK */ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
886 |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
887 |
switch (new_mode) { |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
888 |
case SM_EDITOR: /* Switch to scenario editor */ |
0 | 889 |
MakeNewEditorWorld(); |
890 |
break; |
|
891 |
||
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
892 |
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
|
893 |
#ifdef ENABLE_NETWORK |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
894 |
if (_network_server) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
895 |
snprintf(_network_game_info.map_name, 40, "Random"); |
630
3eb6abf08860
(svn r1061) -Fix: [Network] Compiling without ENABLE_NETWORK now works again correctly
truelight
parents:
614
diff
changeset
|
896 |
#endif /* ENABLE_NETWORK */ |
0 | 897 |
MakeNewGame(); |
898 |
break; |
|
899 |
||
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
900 |
case SM_START_SCENARIO: /* New Game --> Choose one of the preset scenarios */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
901 |
StartScenario(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
902 |
break; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
903 |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
904 |
case SM_LOAD: { /* Load game, Play Scenario */ |
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
905 |
_opt_ptr = &_opt; |
0 | 906 |
|
907 |
_error_message = INVALID_STRING_ID; |
|
908 |
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
|
909 |
LoadIntroGame(); |
0 | 910 |
ShowErrorMessage(_error_message, STR_4009_GAME_LOAD_FAILED, 0, 0); |
911 |
} else { |
|
912 |
_local_player = 0; |
|
913 |
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
|
914 |
#ifdef ENABLE_NETWORK |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
915 |
if (_network_server) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
916 |
snprintf(_network_game_info.map_name, 40, "Loaded game"); |
630
3eb6abf08860
(svn r1061) -Fix: [Network] Compiling without ENABLE_NETWORK now works again correctly
truelight
parents:
614
diff
changeset
|
917 |
#endif /* ENABLE_NETWORK */ |
0 | 918 |
} |
919 |
break; |
|
920 |
} |
|
921 |
||
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
922 |
case SM_LOAD_SCENARIO: { /* Load scenario from scenario editor */ |
0 | 923 |
int i; |
924 |
||
925 |
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
|
926 |
_opt_ptr = &_opt; |
0 | 927 |
|
928 |
_local_player = OWNER_NONE; |
|
929 |
_generating_world = true; |
|
930 |
// delete all players. |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
931 |
for (i = 0; i != MAX_PLAYERS; i++) { |
0 | 932 |
ChangeOwnershipOfPlayerItems(i, 0xff); |
933 |
_players[i].is_active = false; |
|
934 |
} |
|
935 |
_generating_world = false; |
|
936 |
// delete all stations owned by a player |
|
937 |
DeleteAllPlayerStations(); |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
938 |
|
630
3eb6abf08860
(svn r1061) -Fix: [Network] Compiling without ENABLE_NETWORK now works again correctly
truelight
parents:
614
diff
changeset
|
939 |
#ifdef ENABLE_NETWORK |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
940 |
if (_network_server) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
941 |
snprintf(_network_game_info.map_name, 40, "Loaded scenario"); |
630
3eb6abf08860
(svn r1061) -Fix: [Network] Compiling without ENABLE_NETWORK now works again correctly
truelight
parents:
614
diff
changeset
|
942 |
#endif /* ENABLE_NETWORK */ |
0 | 943 |
} else |
944 |
ShowErrorMessage(INVALID_STRING_ID, STR_4009_GAME_LOAD_FAILED, 0, 0); |
|
945 |
||
946 |
break; |
|
947 |
} |
|
948 |
||
949 |
||
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
950 |
case SM_MENU: /* Switch to game intro menu */ |
0 | 951 |
LoadIntroGame(); |
952 |
break; |
|
953 |
||
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
954 |
case SM_SAVE: /* Save game */ |
0 | 955 |
if (SaveOrLoad(_file_to_saveload.name, SL_SAVE) != SL_OK) |
956 |
ShowErrorMessage(INVALID_STRING_ID, STR_4007_GAME_SAVE_FAILED, 0, 0); |
|
957 |
else |
|
958 |
DeleteWindowById(WC_SAVELOAD, 0); |
|
959 |
break; |
|
960 |
||
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
961 |
case SM_GENRANDLAND: /* Generate random land within scenario editor */ |
1218 | 962 |
GenerateWorld(2, _patches.map_x, _patches.map_y); |
0 | 963 |
// XXX: set date |
964 |
_local_player = OWNER_NONE; |
|
965 |
MarkWholeScreenDirty(); |
|
966 |
break; |
|
967 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
968 |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
969 |
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
|
970 |
ShowErrorMessage(INVALID_STRING_ID,_switch_mode_errorstr,0,0); |
0 | 971 |
|
972 |
_in_state_game_loop = false; |
|
973 |
} |
|
974 |
||
975 |
||
976 |
// State controlling game loop. |
|
977 |
// The state must not be changed from anywhere |
|
978 |
// but here. |
|
979 |
// 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
|
980 |
void StateGameLoop(void) |
0 | 981 |
{ |
213
770e504a6e51
(svn r214) -Feature: CMD_NET_INSTANT [just in time command handling over network] (sign_de)
darkvater
parents:
208
diff
changeset
|
982 |
// 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
|
983 |
if (_pause) return; |
770e504a6e51
(svn r214) -Feature: CMD_NET_INSTANT [just in time command handling over network] (sign_de)
darkvater
parents:
208
diff
changeset
|
984 |
|
0 | 985 |
_in_state_game_loop = true; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
986 |
// _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
|
987 |
// 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
|
988 |
// 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
|
989 |
if (!_networking) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
990 |
_frame_counter++; |
0 | 991 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
992 |
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
|
993 |
char buf[100]; |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
994 |
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
|
995 |
SaveOrLoad(buf, SL_SAVE); |
0 | 996 |
if ((uint)_frame_counter >= _savedump_last) exit(1); |
997 |
} |
|
998 |
||
999 |
if (_game_mode == GM_EDITOR) { |
|
1000 |
RunTileLoop(); |
|
1001 |
CallVehicleTicks(); |
|
1002 |
CallLandscapeTick(); |
|
1003 |
CallWindowTickEvent(); |
|
1004 |
NewsLoop(); |
|
1005 |
} else { |
|
206 | 1006 |
// All these actions has to be done from OWNER_NONE |
1007 |
// for multiplayer compatibility |
|
1008 |
uint p = _current_player; |
|
1009 |
_current_player = OWNER_NONE; |
|
1010 |
||
0 | 1011 |
AnimateAnimatedTiles(); |
1012 |
IncreaseDate(); |
|
1013 |
RunTileLoop(); |
|
1014 |
CallVehicleTicks(); |
|
1015 |
CallLandscapeTick(); |
|
1016 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1017 |
// To bad the AI does not work in multiplayer, because states are not saved |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1018 |
// perfectly |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1019 |
if (!disable_computer && !_networking) |
0 | 1020 |
RunOtherPlayersLoop(); |
1021 |
||
1022 |
CallWindowTickEvent(); |
|
1023 |
NewsLoop(); |
|
206 | 1024 |
_current_player = p; |
0 | 1025 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1026 |
|
0 | 1027 |
_in_state_game_loop = false; |
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 |
static void DoAutosave(void) |
0 | 1031 |
{ |
1032 |
char buf[200]; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1033 |
|
1 | 1034 |
if (_patches.keep_all_autosave && _local_player != OWNER_SPECTATOR) { |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
1035 |
const Player *p = DEREF_PLAYER(_local_player); |
0 | 1036 |
char *s; |
1037 |
sprintf(buf, "%s%s", _path.autosave_dir, PATHSEP); |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
1038 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1039 |
SetDParam(0, p->name_1); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1040 |
SetDParam(1, p->name_2); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1041 |
SetDParam(2, _date); |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
1042 |
s = (char*)GetString(buf + strlen(_path.autosave_dir) + strlen(PATHSEP), STR_4004); |
0 | 1043 |
strcpy(s, ".sav"); |
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
1044 |
} else { /* Save a maximum of 15 autosaves */ |
0 | 1045 |
int n = _autosave_ctr; |
1046 |
_autosave_ctr = (_autosave_ctr + 1) & 15; |
|
1047 |
sprintf(buf, "%s%sautosave%d.sav", _path.autosave_dir, PATHSEP, n); |
|
1048 |
} |
|
1049 |
||
557
a61a9aee1ade
(svn r959) -Fix: fix previous typo for workaround of braindead MSVC6 (Tron)
darkvater
parents:
543
diff
changeset
|
1050 |
DEBUG(misc, 2) ("Autosaving to %s", buf); |
0 | 1051 |
if (SaveOrLoad(buf, SL_SAVE) != SL_OK) |
1052 |
ShowErrorMessage(INVALID_STRING_ID, STR_AUTOSAVE_FAILED, 0, 0); |
|
1053 |
} |
|
1054 |
||
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
|
1055 |
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
|
1056 |
{ |
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
|
1057 |
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
|
1058 |
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
|
1059 |
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
|
1060 |
|
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
|
1061 |
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
|
1062 |
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
|
1063 |
} |
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
|
1064 |
} |
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
|
1065 |
|
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
|
1066 |
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
|
1067 |
{ 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
|
1068 |
{-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
|
1069 |
{ 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
|
1070 |
{-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
|
1071 |
{ 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
|
1072 |
{ 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
|
1073 |
{ 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
|
1074 |
{ 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
|
1075 |
{ 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
|
1076 |
{-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
|
1077 |
{ 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
|
1078 |
{-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
|
1079 |
{ 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
|
1080 |
{ 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
|
1081 |
{ 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
|
1082 |
{ 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
|
1083 |
}; |
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
|
1084 |
|
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
|
1085 |
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
|
1086 |
{ |
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
|
1087 |
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
|
1088 |
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
|
1089 |
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
|
1090 |
} |
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
|
1091 |
} |
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
|
1092 |
|
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
|
1093 |
void GameLoop(void) |
0 | 1094 |
{ |
1095 |
int m; |
|
1096 |
||
1097 |
// autosave game? |
|
1098 |
if (_do_autosave) { |
|
1099 |
_do_autosave = false; |
|
1100 |
DoAutosave(); |
|
1101 |
RedrawAutosave(); |
|
1102 |
} |
|
1103 |
||
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
|
1104 |
// 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
|
1105 |
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
|
1106 |
|
0 | 1107 |
// make a screenshot? |
1108 |
if ((m=_make_screenshot) != 0) { |
|
1109 |
_make_screenshot = 0; |
|
1110 |
switch(m) { |
|
1111 |
case 1: // make small screenshot |
|
1112 |
UndrawMouseCursor(); |
|
1113 |
ShowScreenshotResult(MakeScreenshot()); |
|
1114 |
break; |
|
1115 |
case 2: // make large screenshot |
|
863
6a1444534f62
(svn r1344) Use MapSize[XY]() (or MapSize()/MapMax[XY]() where appropriate) instead of TILES_[XY]
tron
parents:
861
diff
changeset
|
1116 |
ShowScreenshotResult(MakeWorldScreenshot(-(int)MapMaxX() * 32, 0, MapMaxX() * 64, MapSizeY() * 32, 0)); |
0 | 1117 |
break; |
1118 |
} |
|
1119 |
} |
|
1120 |
||
1121 |
// switch game mode? |
|
1122 |
if ((m=_switch_mode) != SM_NONE) { |
|
1123 |
_switch_mode = SM_NONE; |
|
1124 |
SwitchMode(m); |
|
1125 |
} |
|
1126 |
||
1127 |
IncreaseSpriteLRU(); |
|
1128 |
InteractiveRandom(); |
|
1129 |
||
1130 |
if (_scroller_click_timeout > 3) |
|
1131 |
_scroller_click_timeout -= 3; |
|
1132 |
else |
|
1133 |
_scroller_click_timeout = 0; |
|
1134 |
||
1135 |
_caret_timer += 3; |
|
1136 |
_timer_counter+=8; |
|
1137 |
CursorTick(); |
|
1138 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1139 |
#ifdef ENABLE_NETWORK |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1140 |
// Check for UDP stuff |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1141 |
NetworkUDPGameLoop(); |
0 | 1142 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1143 |
if (_networking) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1144 |
// Multiplayer |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1145 |
NetworkGameLoop(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1146 |
} else { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1147 |
if (_network_reconnect > 0 && --_network_reconnect == 0) { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1148 |
// 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
|
1149 |
// 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
|
1150 |
NetworkClientConnectGame(_network_last_host, _network_last_port); |
206 | 1151 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1152 |
// Singleplayer |
213
770e504a6e51
(svn r214) -Feature: CMD_NET_INSTANT [just in time command handling over network] (sign_de)
darkvater
parents:
208
diff
changeset
|
1153 |
StateGameLoop(); |
0 | 1154 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1155 |
#else |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1156 |
StateGameLoop(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1157 |
#endif /* ENABLE_NETWORK */ |
0 | 1158 |
|
1159 |
if (!_pause && _display_opt&DO_FULL_ANIMATION) |
|
1160 |
DoPaletteAnimations(); |
|
1161 |
||
67
b2b551af3d9f
(svn r68) -Fix: [1009621] build in pause is now a cheat instead of a patch (truesatan)
darkvater
parents:
65
diff
changeset
|
1162 |
if (!_pause || _cheats.build_in_pause.value) |
0 | 1163 |
MoveAllTextEffects(); |
1164 |
||
1165 |
MouseLoop(); |
|
1166 |
||
1167 |
if (_game_mode != GM_MENU) |
|
1168 |
MusicLoop(); |
|
1169 |
} |
|
1170 |
||
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
|
1171 |
void BeforeSaveGame(void) |
0 | 1172 |
{ |
1173 |
Window *w = FindWindowById(WC_MAIN_WINDOW, 0); |
|
1174 |
||
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
|
1175 |
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
|
1176 |
_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
|
1177 |
_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
|
1178 |
_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
|
1179 |
} |
0 | 1180 |
} |
1181 |
||
1095 | 1182 |
static void ConvertTownOwner(void) |
0 | 1183 |
{ |
1184 |
uint tile; |
|
1185 |
||
863
6a1444534f62
(svn r1344) Use MapSize[XY]() (or MapSize()/MapMax[XY]() where appropriate) instead of TILES_[XY]
tron
parents:
861
diff
changeset
|
1186 |
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
|
1187 |
if (IsTileType(tile, MP_STREET)) { |
0 | 1188 |
if ((_map5[tile] & 0xF0) == 0x10 && _map3_lo[tile] & 0x80) |
1189 |
_map3_lo[tile] = OWNER_TOWN; |
|
1190 |
||
1191 |
if (_map_owner[tile] & 0x80) |
|
1192 |
_map_owner[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
|
1193 |
} else if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
0 | 1194 |
if (_map_owner[tile] & 0x80) |
1195 |
_map_owner[tile] = OWNER_TOWN; |
|
1196 |
} |
|
1197 |
} |
|
1198 |
} |
|
1199 |
||
1200 |
// before savegame version 4, the name of the company determined if it existed |
|
1095 | 1201 |
static void CheckIsPlayerActive(void) |
0 | 1202 |
{ |
1203 |
Player *p; |
|
1204 |
FOR_ALL_PLAYERS(p) { |
|
1205 |
if (p->name_1 != 0) { |
|
1206 |
p->is_active = true; |
|
1207 |
} |
|
1208 |
} |
|
1209 |
} |
|
1210 |
||
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1211 |
// since savegame version 4.1, exclusive transport rights are stored at towns |
1095 | 1212 |
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
|
1213 |
{ |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1214 |
Town *t; |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1215 |
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
|
1216 |
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
|
1217 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1218 |
|
123
d550772c61e6
(svn r124) Prepared code for removal of block_months variable in next major savegame version
dominik
parents:
121
diff
changeset
|
1219 |
/* 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
|
1220 |
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
|
1221 |
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
|
1222 |
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
|
1223 |
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
|
1224 |
2.) Go through that array, if you find a town that is not blocked for |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1225 |
one player, but for all others, then give him exclusivity. |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1226 |
*/ |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1227 |
} |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1228 |
|
1500
a66721629bc0
(svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents:
1496
diff
changeset
|
1229 |
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
|
1230 |
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
|
1231 |
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
|
1232 |
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
|
1233 |
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
|
1234 |
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
|
1235 |
|
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
|
1236 |
// since savegame version 4.2 the currencies are arranged differently |
1095 | 1237 |
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
|
1238 |
{ |
768
c833f6f2742d
(svn r1233) Fixed several currency issues. Now currencies should work correctly again.
dominik
parents:
762
diff
changeset
|
1239 |
_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
|
1240 |
} |
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
|
1241 |
|
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
|
1242 |
/* 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
|
1243 |
* 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
|
1244 |
*/ |
1095 | 1245 |
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
|
1246 |
{ |
959
e6a3bbda610f
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
950
diff
changeset
|
1247 |
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
|
1248 |
|
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
|
1249 |
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
|
1250 |
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
|
1251 |
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
|
1252 |
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
|
1253 |
} |
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
|
1254 |
|
1165
8fa7d3e235c6
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1255 |
// 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
|
1256 |
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
|
1257 |
{ |
8fa7d3e235c6
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1258 |
SignStruct *ss; |
8fa7d3e235c6
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1259 |
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
|
1260 |
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
|
1261 |
} |
8fa7d3e235c6
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1262 |
} |
8fa7d3e235c6
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1263 |
|
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
942
diff
changeset
|
1264 |
extern void UpdateOldAircraft( void ); |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
942
diff
changeset
|
1265 |
extern void UpdateOilRig( void ); |
0 | 1266 |
|
1267 |
bool AfterLoadGame(uint version) |
|
1268 |
{ |
|
1269 |
Window *w; |
|
1270 |
ViewPort *vp; |
|
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
983
diff
changeset
|
1271 |
|
0 | 1272 |
// in version 2.1 of the savegame, town owner was unified. |
1273 |
if (version <= 0x200) { |
|
1274 |
ConvertTownOwner(); |
|
1275 |
} |
|
1276 |
||
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1277 |
// 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
|
1278 |
if (version <= 0x400) { |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1279 |
UpdateExclusiveRights(); |
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
116
diff
changeset
|
1280 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1281 |
|
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
|
1282 |
// 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
|
1283 |
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
|
1284 |
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
|
1285 |
} |
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
|
1286 |
|
1165
8fa7d3e235c6
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1287 |
// 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
|
1288 |
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
|
1289 |
UpdateSignOwner(); |
8fa7d3e235c6
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1290 |
} |
8fa7d3e235c6
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1115
diff
changeset
|
1291 |
|
831
d706427d9e23
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1292 |
/* 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
|
1293 |
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
|
1294 |
(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
|
1295 |
walk through the whole map.. */ |
d706427d9e23
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1296 |
if (version <= 0x402) { |
d706427d9e23
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1297 |
TileIndex tile = TILE_XY(0,0); |
d706427d9e23
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1298 |
uint w = MapSizeX(); |
d706427d9e23
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1299 |
uint h = MapSizeY(); |
d706427d9e23
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1300 |
|
d706427d9e23
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1301 |
BEGIN_TILE_LOOP(tile_cur, w, h, 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
|
1302 |
if (IsTileType(tile_cur, MP_WATER) && _map_owner[tile_cur] >= MAX_PLAYERS) |
831
d706427d9e23
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1303 |
_map_owner[tile_cur] = OWNER_WATER; |
d706427d9e23
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1304 |
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
|
1305 |
} |
d706427d9e23
(svn r1302) -Fix: [ 1091655 ] In some older maps somehow water is owned by
truelight
parents:
802
diff
changeset
|
1306 |
|
0 | 1307 |
// convert road side to my format. |
1308 |
if (_opt.road_side) _opt.road_side = 1; |
|
1309 |
||
1310 |
// Load the sprites |
|
1311 |
GfxLoadSprites(); |
|
1312 |
||
1313 |
// Update current year |
|
1314 |
SetDate(_date); |
|
1315 |
||
1316 |
// reinit the landscape variables (landscape might have changed) |
|
1317 |
InitializeLandscapeVariables(true); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1318 |
|
0 | 1319 |
// Update all vehicles |
1320 |
AfterLoadVehicles(); |
|
1321 |
// in version 2.2 of the savegame, we have new airports |
|
1322 |
if (version <= 0x201) { |
|
1323 |
UpdateOldAircraft(); |
|
1324 |
} |
|
1325 |
||
1326 |
UpdateAllStationVirtCoord(); |
|
1327 |
||
1328 |
// Setup town coords |
|
1329 |
AfterLoadTown(); |
|
1330 |
UpdateAllSignVirtCoords(); |
|
1331 |
||
1332 |
// make sure there is a town in the game |
|
1333 |
if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, (uint)-1)) |
|
1334 |
{ |
|
1335 |
_error_message = STR_NO_TOWN_IN_SCENARIO; |
|
1336 |
return false; |
|
1337 |
} |
|
1338 |
||
1339 |
// Initialize windows |
|
1474
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1440
diff
changeset
|
1340 |
ResetWindowSystem(); |
0 | 1341 |
SetupColorsAndInitialWindow(); |
1342 |
||
1343 |
w = FindWindowById(WC_MAIN_WINDOW, 0); |
|
1344 |
||
1345 |
WP(w,vp_d).scrollpos_x = _saved_scrollpos_x; |
|
1346 |
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
|
1347 |
|
0 | 1348 |
vp = w->viewport; |
1349 |
vp->zoom = _saved_scrollpos_zoom; |
|
1350 |
vp->virtual_width = vp->width << vp->zoom; |
|
1351 |
vp->virtual_height = vp->height << vp->zoom; |
|
1352 |
||
1353 |
||
1354 |
// in version 4.0 of the savegame, is_active was introduced to determine |
|
1355 |
// if a player does exist, rather then checking name_1 |
|
1356 |
if (version <= 0x400) { |
|
1357 |
CheckIsPlayerActive(); |
|
1358 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1359 |
|
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
|
1360 |
// 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
|
1361 |
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
|
1362 |
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
|
1363 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
185
diff
changeset
|
1364 |
// If Load Scenario / New (Scenario) Game is used, |
139 | 1365 |
// 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
|
1366 |
// 1 exeption: network-games. Those can have 0 players |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1367 |
// But this exeption is not true for network_servers! |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
1368 |
if (!_players[0].is_active && (!_networking || (_networking && _network_server))) |
139 | 1369 |
DoStartupNewPlayer(false); |
0 | 1370 |
|
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
|
1371 |
DoZoomInOutWindow(ZOOM_NONE, w); // update button status |
0 | 1372 |
MarkWholeScreenDirty(); |
1373 |
||
950
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
942
diff
changeset
|
1374 |
//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
|
1375 |
if (version <= 0x500) { |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
942
diff
changeset
|
1376 |
UpdateOilRig(); |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
942
diff
changeset
|
1377 |
} |
165341d74973
(svn r1440) -Feature: Allows more flexible airport layouts now, as the number of
celestar
parents:
942
diff
changeset
|
1378 |
|
1264
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1379 |
if (version <= 0x600) { |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1380 |
BEGIN_TILE_LOOP(tile, MapSizeX(), MapSizeY(), 0) { |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1381 |
if (IsTileType(tile, MP_HOUSE)) { |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1382 |
_map3_hi[tile] = _map2[tile]; |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1383 |
//XXX magic |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1384 |
SetTileType(tile, MP_VOID); |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1385 |
_map2[tile] = ClosestTownFromTile(tile,(uint)-1)->index; |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1386 |
SetTileType(tile, MP_HOUSE); |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1387 |
} else if (IsTileType(tile, MP_STREET)) { |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1388 |
//XXX magic |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1389 |
SetTileType(tile, MP_VOID); |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1390 |
_map3_hi[tile] |= (_map2[tile] << 4); |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1391 |
if ( _map_owner[tile] == OWNER_TOWN) |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1392 |
_map2[tile] = ClosestTownFromTile(tile,(uint)-1)->index; |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1393 |
else |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1394 |
_map2[tile] = 0; |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1395 |
SetTileType(tile, MP_STREET); |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1396 |
} |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1397 |
} END_TILE_LOOP(tile, MapSizeX(), MapSizeY(), 0); |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1398 |
} |
acebb2b01e32
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1260
diff
changeset
|
1399 |
|
1377
7ab329d1fc28
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1349
diff
changeset
|
1400 |
if (version < 0x900) { |
7ab329d1fc28
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1349
diff
changeset
|
1401 |
Town *t; |
7ab329d1fc28
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1349
diff
changeset
|
1402 |
FOR_ALL_TOWNS(t) { |
7ab329d1fc28
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1349
diff
changeset
|
1403 |
UpdateTownMaxPass(t); |
7ab329d1fc28
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1349
diff
changeset
|
1404 |
} |
7ab329d1fc28
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1349
diff
changeset
|
1405 |
} |
7ab329d1fc28
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1349
diff
changeset
|
1406 |
|
0 | 1407 |
return true; |
1408 |
} |
|
1409 |
||
1410 |
void DebugProc(int i) |
|
1411 |
{ |
|
1412 |
switch(i) { |
|
1413 |
case 0: |
|
1414 |
*(byte*)0 = 0; |
|
1415 |
break; |
|
1416 |
case 1: |
|
795
d3dc1a63e57f
(svn r1265) -Fix: the server can also no longer use the money cheat if the
truelight
parents:
774
diff
changeset
|
1417 |
/* Server can not cheat in advertise mode either! */ |
802
2bd6011b28e8
(svn r1272) -Fix: game compiles again with network disabled
truelight
parents:
795
diff
changeset
|
1418 |
#ifdef ENABLE_NETWORK |
795
d3dc1a63e57f
(svn r1265) -Fix: the server can also no longer use the money cheat if the
truelight
parents:
774
diff
changeset
|
1419 |
if (!_networking || !_network_server || !_network_advertise) |
802
2bd6011b28e8
(svn r1272) -Fix: game compiles again with network disabled
truelight
parents:
795
diff
changeset
|
1420 |
#endif /* ENABLE_NETWORK */ |
795
d3dc1a63e57f
(svn r1265) -Fix: the server can also no longer use the money cheat if the
truelight
parents:
774
diff
changeset
|
1421 |
DoCommandP(0, -10000000, 0, NULL, CMD_MONEY_CHEAT); |
0 | 1422 |
break; |
1423 |
case 2: |
|
1424 |
UpdateAllStationVirtCoord(); |
|
1425 |
break; |
|
1426 |
} |
|
1427 |
} |