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