Mercurial > hg > openttd
annotate src/openttd.cpp @ 11148:3cb2d503c4e8 draft
(svn r15495) -Revert (r15383,r15422): Loading NewGRFs depends on correct settings, but the economy can only be started after loading NewGRFs. In short: r15383 causes more problems then it's worth.
author | yexo <yexo@openttd.org> |
---|---|
date | Sat, 14 Feb 2009 23:17:32 +0000 |
parents | d202ea73cf73 |
children | e49bc8f3aa3b |
rev | line source |
---|---|
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2 |
9111
d48433370037
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents:
9095
diff
changeset
|
3 /** @file openttd.cpp Functions related to starting OpenTTD. */ |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
4 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
5 #include "stdafx.h" |
8788
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
6 |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
7 #define VARDEF |
8788
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
8 #include "variables.h" |
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
9 #undef VARDEF |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
10 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
11 #include "openttd.h" |
8788
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
12 |
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
13 #include "blitter/factory.hpp" |
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
14 #include "sound/sound_driver.hpp" |
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
15 #include "music/music_driver.hpp" |
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
16 #include "video/video_driver.hpp" |
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
17 |
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
18 #include "fontcache.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
19 #include "gfxinit.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
20 #include "gui.h" |
8788
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
21 #include "mixer.h" |
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
22 #include "sound_func.h" |
8107
f65cf2bc3255
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents:
8106
diff
changeset
|
23 #include "window_func.h" |
8788
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
24 |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
10558
diff
changeset
|
25 #include "saveload/saveload.h" |
8788
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
26 #include "landscape.h" |
10208
39cf8eebfda5
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
10207
diff
changeset
|
27 #include "company_func.h" |
8116
9cc845deddfe
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents:
8114
diff
changeset
|
28 #include "command_func.h" |
8763
d6e363672edb
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium <rubidium@openttd.org>
parents:
8707
diff
changeset
|
29 #include "news_func.h" |
10039
6301378f3e0f
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium <rubidium@openttd.org>
parents:
10037
diff
changeset
|
30 #include "fileio_func.h" |
8151
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8144
diff
changeset
|
31 #include "fios.h" |
6193
0d05fec9d384
(svn r8973) -Feature/Codechange: Changed the internal unit for aircraft velocities to from 8mph to 1km/h (peter1138), also give aircraft realsitic velocities (so that 1km/h is 1km/h independent of vehicle type) (peter1138). Introduce a flag to reduce aircraft speed in holding patterns to some realistic velocity. Use this flag for the city airport for the time being and make use of the different entry points for this airport type.
celestar <celestar@openttd.org>
parents:
6190
diff
changeset
|
32 #include "aircraft.h" |
9336
5287277c4972
(svn r13228) -Codechange: split console.h.
rubidium <rubidium@openttd.org>
parents:
9334
diff
changeset
|
33 #include "console_func.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
34 #include "screenshot.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
35 #include "network/network.h" |
9428
ba7cdcf21f4c
(svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers.
rubidium <rubidium@openttd.org>
parents:
9420
diff
changeset
|
36 #include "network/network_func.h" |
8790
5ef0059ccfc0
(svn r12501) -Codechange: split signs.h.
rubidium <rubidium@openttd.org>
parents:
8788
diff
changeset
|
37 #include "signs_base.h" |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
38 #include "ai/ai.hpp" |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
39 #include "ai/ai_config.hpp" |
8208
ddc34919158f
(svn r11771) -Codechange: split settings.h into better separated headers.
rubidium <rubidium@openttd.org>
parents:
8179
diff
changeset
|
40 #include "settings_func.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
41 #include "genworld.h" |
8788
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
42 #include "group.h" |
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
43 #include "strings_func.h" |
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
44 #include "date_func.h" |
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
45 #include "vehicle_func.h" |
9457
267a95510fdf
(svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents:
9429
diff
changeset
|
46 #include "gamelog.h" |
10960
a4e5b5d2837c
(svn r15299) -Cleanup: remove many redundant includes
smatz <smatz@openttd.org>
parents:
10908
diff
changeset
|
47 #include "cheat_type.h" |
9005
5bb8efb6051a
(svn r12800) -Codechange: move the animated tile related functions out of texteff.cpp (it isn't a text effect after all). Also remove a few more functions from functions.
rubidium <rubidium@openttd.org>
parents:
8989
diff
changeset
|
48 #include "animated_tile_func.h" |
9006
9bf1de259ada
(svn r12801) -Codechange: remove the dependency of function.h in town_map.h
rubidium <rubidium@openttd.org>
parents:
9005
diff
changeset
|
49 #include "functions.h" |
9154
046d0b6e0218
(svn r13016) -Codechange: unify the detection if rail catenary should be drawn
smatz <smatz@openttd.org>
parents:
9111
diff
changeset
|
50 #include "elrail_func.h" |
9085
31575b0db757
(svn r12944) -Codechange: use rev.h instead of externs at many places
smatz <smatz@openttd.org>
parents:
9070
diff
changeset
|
51 #include "rev.h" |
10558
15517829eb17
(svn r14815) -Codechange: separate 'highscore' code from 'company' code
smatz <smatz@openttd.org>
parents:
10555
diff
changeset
|
52 #include "highscore.h" |
8788
cb5ca4d081de
(svn r12498) -Codechange: bring a little 'order' to openttd.cpp's includes and do not 'define' VARDEF for files that do not have them anymore.
rubidium <rubidium@openttd.org>
parents:
8787
diff
changeset
|
53 |
6629
188437dffcff
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas <belugas@openttd.org>
parents:
6626
diff
changeset
|
54 #include "newgrf_commons.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
55 |
10960
a4e5b5d2837c
(svn r15299) -Cleanup: remove many redundant includes
smatz <smatz@openttd.org>
parents:
10908
diff
changeset
|
56 #include "town.h" |
a4e5b5d2837c
(svn r15299) -Cleanup: remove many redundant includes
smatz <smatz@openttd.org>
parents:
10908
diff
changeset
|
57 #include "industry.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
58 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
59 #include <stdarg.h> |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
60 |
8264
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8258
diff
changeset
|
61 #include "table/strings.h" |
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8258
diff
changeset
|
62 |
8973
f8dda7737158
(svn r12765) -Codechange: move some stuff out of variables.h that required including other headers in variables.h.
rubidium <rubidium@openttd.org>
parents:
8965
diff
changeset
|
63 StringID _switch_mode_errorstr; |
f8dda7737158
(svn r12765) -Codechange: move some stuff out of variables.h that required including other headers in variables.h.
rubidium <rubidium@openttd.org>
parents:
8965
diff
changeset
|
64 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
65 void CallLandscapeTick(); |
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
66 void IncreaseDate(); |
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
67 void DoPaletteAnimations(); |
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
68 void MusicLoop(); |
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
69 void ResetMusic(); |
8989
4ecc117ebb22
(svn r12784) -Codechange: handle the asynchronious save 'handlers' in saveload.cpp instead of openttd.cpp.
rubidium <rubidium@openttd.org>
parents:
8987
diff
changeset
|
70 void ProcessAsyncSaveFinish(); |
9161
0106126c478a
(svn r13024) -Codechange: do not use WE_MOUSELOOP when WE_TICK suffices, rename WE_4 to something more descriptive and correct some (completely incorrect) comments.
rubidium <rubidium@openttd.org>
parents:
9159
diff
changeset
|
71 void CallWindowTickEvent(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
72 |
9358
12f4585b2124
(svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents:
9354
diff
changeset
|
73 extern void SetDifficultyLevel(int mode, DifficultySettings *gm_opt); |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
74 extern Company *DoStartupNewCompany(bool is_ai); |
9470
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
75 extern void ShowOSErrorBox(const char *buf, bool system); |
8809
6f39a645401a
(svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents:
8790
diff
changeset
|
76 extern void InitializeRailGUI(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
77 |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
78 /** |
9470
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
79 * Error handling for fatal user errors. |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
80 * @param s the string to print. |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
81 * @note Does NEVER return. |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
82 */ |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
83 void CDECL usererror(const char *s, ...) |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
84 { |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
85 va_list va; |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
86 char buf[512]; |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
87 |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
88 va_start(va, s); |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
89 vsnprintf(buf, lengthof(buf), s, va); |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
90 va_end(va); |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
91 |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
92 ShowOSErrorBox(buf, false); |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
93 if (_video_driver != NULL) _video_driver->Stop(); |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
94 |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
95 exit(1); |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
96 } |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
97 |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
98 /** |
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
99 * Error handling for fatal non-user errors. |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
100 * @param s the string to print. |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
101 * @note Does NEVER return. |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
102 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
103 void CDECL error(const char *s, ...) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
104 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
105 va_list va; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
106 char buf[512]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
107 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
108 va_start(va, s); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
109 vsnprintf(buf, lengthof(buf), s, va); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
110 va_end(va); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
111 |
9470
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
112 ShowOSErrorBox(buf, true); |
7170
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
113 if (_video_driver != NULL) _video_driver->Stop(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
114 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
115 assert(0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
116 exit(1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
117 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
118 |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
119 /** |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
120 * Shows some information on the console/a popup box depending on the OS. |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
121 * @param str the text to show. |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
122 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
123 void CDECL ShowInfoF(const char *str, ...) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
124 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
125 va_list va; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
126 char buf[1024]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
127 va_start(va, str); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
128 vsnprintf(buf, lengthof(buf), str, va); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
129 va_end(va); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
130 ShowInfo(buf); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
131 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
132 |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
133 /** |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
134 * Show the help message when someone passed a wrong parameter. |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
135 */ |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
136 static void ShowHelp() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
137 { |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
138 char buf[8192]; |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
139 char *p = buf; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
140 |
10299
26fd53f1fd8d
(svn r14540) -Codechange: introduce [v]seprintf which are like [v]snprintf but do return the number of characters written instead of the number of characters that would be written; as size_t is unsigned substraction can cause integer underflows quite quickly.
rubidium <rubidium@openttd.org>
parents:
10296
diff
changeset
|
141 p += seprintf(p, lastof(buf), "OpenTTD %s\n", _openttd_revision); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
142 p = strecpy(p, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
143 "\n" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
144 "\n" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
145 "Command line options:\n" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
146 " -v drv = Set video driver (see below)\n" |
5885
e0a6ce7c45b8
(svn r8497) -Codechange: Increase the size of the sound/video/music-drivers to 32 bytes (instead of 16) so their actual parameters can be passed. Sound has for example 'bufsize' and 'hz'. Also use the recently introduced StrEmpty().
Darkvater <Darkvater@openttd.org>
parents:
5884
diff
changeset
|
147 " -s drv = Set sound driver (see below) (param bufsize,hz)\n" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
148 " -m drv = Set music driver (see below)\n" |
6852
31184effcea5
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight <truelight@openttd.org>
parents:
6770
diff
changeset
|
149 " -b drv = Set the blitter to use (see below)\n" |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
150 " -a ai = Force use of specific AI (see below)\n" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
151 " -r res = Set resolution (for instance 800x600)\n" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
152 " -h = Display this help text\n" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
153 " -t year = Set starting year\n" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
154 " -d [[fac=]lvl[,...]]= Debug mode\n" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
155 " -e = Start Editor\n" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
156 " -g [savegame] = Start new/save game immediately\n" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
157 " -G seed = Set random seed\n" |
5692
47e97da9c104
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents:
5683
diff
changeset
|
158 #if defined(ENABLE_NETWORK) |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
159 " -n [ip:port#company]= Start networkgame\n" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
160 " -D [ip][:port] = Start dedicated server\n" |
5959
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
161 " -l ip[:port] = Redirect DEBUG()\n" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
162 #if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
163 " -f = Fork into the background (dedicated only)\n" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
164 #endif |
5692
47e97da9c104
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents:
5683
diff
changeset
|
165 #endif /* ENABLE_NETWORK */ |
10296
c8d9457bd5c5
(svn r14535) -Fix: Description of '-i' commandline option.
frosch <frosch@openttd.org>
parents:
10289
diff
changeset
|
166 " -i palette = Force to use the DOS (0) or Windows (1) palette\n" |
c8d9457bd5c5
(svn r14535) -Fix: Description of '-i' commandline option.
frosch <frosch@openttd.org>
parents:
10289
diff
changeset
|
167 " (defines default setting when adding newgrfs)\n" |
10361
b822f913edb3
(svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents:
10360
diff
changeset
|
168 " Default value (2) lets OpenTTD use the palette\n" |
b822f913edb3
(svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents:
10360
diff
changeset
|
169 " specified in graphics set file (see below)\n" |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
170 " -I graphics_set = Force the graphics set (see below)\n" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
171 " -c config_file = Use 'config_file' instead of 'openttd.cfg'\n" |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
172 " -x = Do not automatically save to config file on exit\n" |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
173 "\n", |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
174 lastof(buf) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
175 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
176 |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
177 /* List the graphics packs */ |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
178 p = GetGraphicsSetsList(p, lastof(buf)); |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
179 |
7170
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
180 /* List the drivers */ |
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
181 p = VideoDriverFactoryBase::GetDriversInfo(p, lastof(buf)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
182 |
6852
31184effcea5
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight <truelight@openttd.org>
parents:
6770
diff
changeset
|
183 /* List the blitters */ |
31184effcea5
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight <truelight@openttd.org>
parents:
6770
diff
changeset
|
184 p = BlitterFactoryBase::GetBlittersInfo(p, lastof(buf)); |
31184effcea5
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight <truelight@openttd.org>
parents:
6770
diff
changeset
|
185 |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
186 /* We need to initialize the AI, so it finds the AIs */ |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
187 AI::Initialize(); |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
188 p = AI::GetConsoleList(p, lastof(buf)); |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
189 AI::Uninitialize(true); |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
190 |
5723
2fc1cb6d4885
(svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater <Darkvater@openttd.org>
parents:
5707
diff
changeset
|
191 /* ShowInfo put output to stderr, but version information should go |
2fc1cb6d4885
(svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater <Darkvater@openttd.org>
parents:
5707
diff
changeset
|
192 * to stdout; this is the only exception */ |
2fc1cb6d4885
(svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater <Darkvater@openttd.org>
parents:
5707
diff
changeset
|
193 #if !defined(WIN32) && !defined(WIN64) |
2fc1cb6d4885
(svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater <Darkvater@openttd.org>
parents:
5707
diff
changeset
|
194 printf("%s\n", buf); |
2fc1cb6d4885
(svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater <Darkvater@openttd.org>
parents:
5707
diff
changeset
|
195 #else |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
196 ShowInfo(buf); |
5723
2fc1cb6d4885
(svn r8240) -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo)
Darkvater <Darkvater@openttd.org>
parents:
5707
diff
changeset
|
197 #endif |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
198 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
199 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
200 |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
201 struct MyGetOptData { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
202 char *opt; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
203 int numleft; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
204 char **argv; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
205 const char *options; |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
206 const char *cont; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
207 |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
208 MyGetOptData(int argc, char **argv, const char *options) |
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
209 { |
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
210 opt = NULL; |
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
211 numleft = argc; |
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
212 this->argv = argv; |
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
213 this->options = options; |
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
214 cont = NULL; |
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
215 } |
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
216 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
217 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
218 static int MyGetOpt(MyGetOptData *md) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
219 { |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
220 const char *s,*r,*t; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
221 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
222 s = md->cont; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
223 if (s != NULL) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
224 goto md_continue_here; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
225 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
226 for (;;) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
227 if (--md->numleft < 0) return -1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
228 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
229 s = *md->argv++; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
230 if (*s == '-') { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
231 md_continue_here:; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
232 s++; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
233 if (*s != 0) { |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
234 /* Found argument, try to locate it in options. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
235 if (*s == ':' || (r = strchr(md->options, *s)) == NULL) { |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
236 /* ERROR! */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
237 return -2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
238 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
239 if (r[1] == ':') { |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
240 /* Item wants an argument. Check if the argument follows, or if it comes as a separate arg. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
241 if (!*(t = s + 1)) { |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
242 /* It comes as a separate arg. Check if out of args? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
243 if (--md->numleft < 0 || *(t = *md->argv) == '-') { |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
244 /* Check if item is optional? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
245 if (r[2] != ':') |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
246 return -2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
247 md->numleft++; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
248 t = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
249 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
250 md->argv++; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
251 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
252 } |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
253 md->opt = (char*)t; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
254 md->cont = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
255 return *s; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
256 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
257 md->opt = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
258 md->cont = s; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
259 return *s; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
260 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
261 } else { |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
262 /* This is currently not supported. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
263 return -2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
264 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
265 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
266 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
267 |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
268 /** |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
269 * Extract the resolution from the given string and store |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
270 * it in the 'res' parameter. |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
271 * @param res variable to store the resolution in. |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
272 * @param s the string to decompose. |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
273 */ |
9533
176a9fe1018f
(svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents:
9470
diff
changeset
|
274 static void ParseResolution(Dimension *res, const char *s) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
275 { |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
276 const char *t = strchr(s, 'x'); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
277 if (t == NULL) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
278 ShowInfoF("Invalid resolution '%s'", s); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
279 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
280 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
281 |
9533
176a9fe1018f
(svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents:
9470
diff
changeset
|
282 res->width = max(strtoul(s, NULL, 0), 64UL); |
176a9fe1018f
(svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents:
9470
diff
changeset
|
283 res->height = max(strtoul(t + 1, NULL, 0), 64UL); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
284 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
285 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
286 static void InitializeDynamicVariables() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
287 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
288 /* Dynamic stuff needs to be initialized somewhere... */ |
7152
70c7afefcca5
(svn r10426) -Codechange: Activate the reset of industry/tiles mapping upon initialization or new game.
belugas <belugas@openttd.org>
parents:
7091
diff
changeset
|
289 _industry_mngr.ResetMapping(); |
70c7afefcca5
(svn r10426) -Codechange: Activate the reset of industry/tiles mapping upon initialization or new game.
belugas <belugas@openttd.org>
parents:
7091
diff
changeset
|
290 _industile_mngr.ResetMapping(); |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
291 _Company_pool.AddBlockToPool(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
292 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
293 |
5659
78a7505fd513
(svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents:
5652
diff
changeset
|
294 |
9159
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
295 /** Unitializes drivers, frees allocated memory, cleans pools, ... |
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
296 * Generally, prepares the game for shutting down |
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
297 */ |
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
298 static void ShutdownGame() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
299 { |
9159
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
300 /* stop the AI */ |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
301 AI::Uninitialize(false); |
9159
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
302 |
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
303 IConsoleFree(); |
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
304 |
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
305 if (_network_available) NetworkShutDown(); // Shut down the network and close any open connections |
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
306 |
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
307 DriverFactoryBase::ShutdownDrivers(); |
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
308 |
5659
78a7505fd513
(svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents:
5652
diff
changeset
|
309 UnInitWindowSystem(); |
78a7505fd513
(svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents:
5652
diff
changeset
|
310 |
78a7505fd513
(svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents:
5652
diff
changeset
|
311 /* Uninitialize airport state machines */ |
78a7505fd513
(svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents:
5652
diff
changeset
|
312 UnInitializeAirports(); |
78a7505fd513
(svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents:
5652
diff
changeset
|
313 |
78a7505fd513
(svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents:
5652
diff
changeset
|
314 /* Uninitialize variables that are allocated dynamically */ |
9457
267a95510fdf
(svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents:
9429
diff
changeset
|
315 GamelogReset(); |
7401
1e97c047c9f6
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents:
7393
diff
changeset
|
316 _Town_pool.CleanPool(); |
1e97c047c9f6
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents:
7393
diff
changeset
|
317 _Industry_pool.CleanPool(); |
1e97c047c9f6
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents:
7393
diff
changeset
|
318 _Station_pool.CleanPool(); |
1e97c047c9f6
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents:
7393
diff
changeset
|
319 _Vehicle_pool.CleanPool(); |
1e97c047c9f6
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents:
7393
diff
changeset
|
320 _Sign_pool.CleanPool(); |
1e97c047c9f6
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents:
7393
diff
changeset
|
321 _Order_pool.CleanPool(); |
1e97c047c9f6
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents:
7393
diff
changeset
|
322 _Group_pool.CleanPool(); |
1e97c047c9f6
(svn r10773) -Codechange: use pool.CleanPool instead of CleanPool(&pool) and similarly for AddBlock*.
rubidium <rubidium@openttd.org>
parents:
7393
diff
changeset
|
323 _CargoPacket_pool.CleanPool(); |
9070
11b5b3f4175d
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138 <peter1138@openttd.org>
parents:
9069
diff
changeset
|
324 _Engine_pool.CleanPool(); |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
325 _Company_pool.CleanPool(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
326 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
327 free(_config_file); |
9159
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
328 |
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
329 /* Close all and any open filehandles */ |
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
330 FioCloseAll(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
331 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
332 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
333 static void LoadIntroGame() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
334 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
335 _game_mode = GM_MENU; |
6427
2437ed7b277c
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
6351
diff
changeset
|
336 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
337 ResetGRFConfig(false); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
338 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
339 /* Setup main window */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
340 ResetWindowSystem(); |
11085
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
11079
diff
changeset
|
341 SetupColoursAndInitialWindow(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
342 |
6929
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
343 /* Load the default opening screen savegame */ |
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
344 if (SaveOrLoad("opntitle.dat", SL_LOAD, DATA_DIR) != SL_OK) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
345 GenerateWorld(GW_EMPTY, 64, 64); // if failed loading, make empty world. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
346 WaitTillGeneratedWorld(); |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
347 SetLocalCompany(COMPANY_SPECTATOR); |
10152
2590e56e45f3
(svn r14339) -Fix (r13731): crash when loading the intro game failed
smatz <smatz@openttd.org>
parents:
10150
diff
changeset
|
348 } else { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
349 SetLocalCompany(COMPANY_FIRST); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
350 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
351 |
6231
a4e11dd2d7c6
(svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight <truelight@openttd.org>
parents:
6229
diff
changeset
|
352 _pause_game = 0; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
353 _cursor.fix_at = false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
354 |
8085
b6bf6634fcca
(svn r11646) -Codechange: check whether (some) characters are missing in the current 'font' for the 'currently' chosen language and give a warning when that does happen.
rubidium <rubidium@openttd.org>
parents:
8083
diff
changeset
|
355 CheckForMissingGlyphsInLoadedLanguagePack(); |
b6bf6634fcca
(svn r11646) -Codechange: check whether (some) characters are missing in the current 'font' for the 'currently' chosen language and give a warning when that does happen.
rubidium <rubidium@openttd.org>
parents:
8083
diff
changeset
|
356 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
357 /* Play main theme */ |
7170
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
358 if (_music_driver->IsSongPlaying()) ResetMusic(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
359 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
360 |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
361 void MakeNewgameSettingsLive() |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
362 { |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
363 for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
364 if (_settings_game.ai_config[c] != NULL) { |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
365 delete _settings_game.ai_config[c]; |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
366 } |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
367 } |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
368 |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
369 _settings_game = _settings_newgame; |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
370 |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
371 for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
372 _settings_game.ai_config[c] = NULL; |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
373 if (_settings_newgame.ai_config[c] != NULL) { |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
374 _settings_game.ai_config[c] = new AIConfig(_settings_newgame.ai_config[c]); |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
375 } |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
376 } |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
377 } |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
378 |
8268
ab53b3bf7100
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium <rubidium@openttd.org>
parents:
8265
diff
changeset
|
379 byte _savegame_sort_order; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
380 #if defined(UNIX) && !defined(__MORPHOS__) |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
381 extern void DedicatedFork(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
382 #endif |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
383 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
384 int ttd_main(int argc, char *argv[]) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
385 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
386 int i; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
387 const char *optformat; |
10615
a7c0533f0263
(svn r14907) -Codechange: Remove 32 character limit from driver/blitter selection and parameters.
peter1138 <peter1138@openttd.org>
parents:
10571
diff
changeset
|
388 char *musicdriver = NULL; |
a7c0533f0263
(svn r14907) -Codechange: Remove 32 character limit from driver/blitter selection and parameters.
peter1138 <peter1138@openttd.org>
parents:
10571
diff
changeset
|
389 char *sounddriver = NULL; |
a7c0533f0263
(svn r14907) -Codechange: Remove 32 character limit from driver/blitter selection and parameters.
peter1138 <peter1138@openttd.org>
parents:
10571
diff
changeset
|
390 char *videodriver = NULL; |
a7c0533f0263
(svn r14907) -Codechange: Remove 32 character limit from driver/blitter selection and parameters.
peter1138 <peter1138@openttd.org>
parents:
10571
diff
changeset
|
391 char *blitter = NULL; |
a7c0533f0263
(svn r14907) -Codechange: Remove 32 character limit from driver/blitter selection and parameters.
peter1138 <peter1138@openttd.org>
parents:
10571
diff
changeset
|
392 char *graphics_set = NULL; |
9533
176a9fe1018f
(svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents:
9470
diff
changeset
|
393 Dimension resolution = {0, 0}; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
394 Year startyear = INVALID_YEAR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
395 uint generation_seed = GENERATE_NEW_SEED; |
5692
47e97da9c104
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents:
5683
diff
changeset
|
396 bool save_config = true; |
47e97da9c104
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents:
5683
diff
changeset
|
397 #if defined(ENABLE_NETWORK) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
398 bool dedicated = false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
399 bool network = false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
400 char *network_conn = NULL; |
5959
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
401 char *debuglog_conn = NULL; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
402 char *dedicated_host = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
403 uint16 dedicated_port = 0; |
5692
47e97da9c104
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents:
5683
diff
changeset
|
404 #endif /* ENABLE_NETWORK */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
405 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
406 _game_mode = GM_MENU; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
407 _switch_mode = SM_MENU; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
408 _switch_mode_errorstr = INVALID_STRING_ID; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
409 _dedicated_forks = false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
410 _config_file = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
411 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
412 /* The last param of the following function means this: |
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
413 * a letter means: it accepts that param (e.g.: -h) |
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
414 * a ':' behind it means: it need a param (e.g.: -m<driver>) |
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
415 * a '::' behind it means: it can optional have a param (e.g.: -d<debug>) */ |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
416 optformat = "m:s:v:b:hD::n::ei::I:t:d::r:g::G:c:xl:" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
417 #if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
418 "f" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
419 #endif |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
420 ; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
421 |
6491
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6486
diff
changeset
|
422 MyGetOptData mgo(argc - 1, argv + 1, optformat); |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
423 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
424 while ((i = MyGetOpt(&mgo)) != -1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
425 switch (i) { |
10615
a7c0533f0263
(svn r14907) -Codechange: Remove 32 character limit from driver/blitter selection and parameters.
peter1138 <peter1138@openttd.org>
parents:
10571
diff
changeset
|
426 case 'I': free(graphics_set); graphics_set = strdup(mgo.opt); break; |
a7c0533f0263
(svn r14907) -Codechange: Remove 32 character limit from driver/blitter selection and parameters.
peter1138 <peter1138@openttd.org>
parents:
10571
diff
changeset
|
427 case 'm': free(musicdriver); musicdriver = strdup(mgo.opt); break; |
a7c0533f0263
(svn r14907) -Codechange: Remove 32 character limit from driver/blitter selection and parameters.
peter1138 <peter1138@openttd.org>
parents:
10571
diff
changeset
|
428 case 's': free(sounddriver); sounddriver = strdup(mgo.opt); break; |
a7c0533f0263
(svn r14907) -Codechange: Remove 32 character limit from driver/blitter selection and parameters.
peter1138 <peter1138@openttd.org>
parents:
10571
diff
changeset
|
429 case 'v': free(videodriver); videodriver = strdup(mgo.opt); break; |
a7c0533f0263
(svn r14907) -Codechange: Remove 32 character limit from driver/blitter selection and parameters.
peter1138 <peter1138@openttd.org>
parents:
10571
diff
changeset
|
430 case 'b': free(blitter); blitter = strdup(mgo.opt); break; |
5692
47e97da9c104
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents:
5683
diff
changeset
|
431 #if defined(ENABLE_NETWORK) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
432 case 'D': |
10619
ee6aceffc966
(svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents:
10615
diff
changeset
|
433 free(musicdriver); |
ee6aceffc966
(svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents:
10615
diff
changeset
|
434 free(sounddriver); |
ee6aceffc966
(svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents:
10615
diff
changeset
|
435 free(videodriver); |
ee6aceffc966
(svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents:
10615
diff
changeset
|
436 free(blitter); |
ee6aceffc966
(svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents:
10615
diff
changeset
|
437 musicdriver = strdup("null"); |
ee6aceffc966
(svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents:
10615
diff
changeset
|
438 sounddriver = strdup("null"); |
ee6aceffc966
(svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents:
10615
diff
changeset
|
439 videodriver = strdup("dedicated"); |
ee6aceffc966
(svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents:
10615
diff
changeset
|
440 blitter = strdup("null"); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
441 dedicated = true; |
5885
e0a6ce7c45b8
(svn r8497) -Codechange: Increase the size of the sound/video/music-drivers to 32 bytes (instead of 16) so their actual parameters can be passed. Sound has for example 'bufsize' and 'hz'. Also use the recently introduced StrEmpty().
Darkvater <Darkvater@openttd.org>
parents:
5884
diff
changeset
|
442 if (mgo.opt != NULL) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
443 /* Use the existing method for parsing (openttd -n). |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
444 * However, we do ignore the #company part. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
445 const char *temp = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
446 const char *port = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
447 ParseConnectionString(&temp, &port, mgo.opt); |
5885
e0a6ce7c45b8
(svn r8497) -Codechange: Increase the size of the sound/video/music-drivers to 32 bytes (instead of 16) so their actual parameters can be passed. Sound has for example 'bufsize' and 'hz'. Also use the recently introduced StrEmpty().
Darkvater <Darkvater@openttd.org>
parents:
5884
diff
changeset
|
448 if (!StrEmpty(mgo.opt)) dedicated_host = mgo.opt; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
449 if (port != NULL) dedicated_port = atoi(port); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
450 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
451 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
452 case 'f': _dedicated_forks = true; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
453 case 'n': |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
454 network = true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
455 network_conn = mgo.opt; // optional IP parameter, NULL if unset |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
456 break; |
5959
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
457 case 'l': |
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
458 debuglog_conn = mgo.opt; |
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
459 break; |
5692
47e97da9c104
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents:
5683
diff
changeset
|
460 #endif /* ENABLE_NETWORK */ |
9533
176a9fe1018f
(svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents:
9470
diff
changeset
|
461 case 'r': ParseResolution(&resolution, mgo.opt); break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
462 case 't': startyear = atoi(mgo.opt); break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
463 case 'd': { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
464 #if defined(WIN32) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
465 CreateConsole(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
466 #endif |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
467 if (mgo.opt != NULL) SetDebugString(mgo.opt); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
468 } break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
469 case 'e': _switch_mode = SM_EDITOR; break; |
10361
b822f913edb3
(svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents:
10360
diff
changeset
|
470 case 'i': |
b822f913edb3
(svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents:
10360
diff
changeset
|
471 /* there is an argument, it is not empty, and it is exactly 1 char long */ |
b822f913edb3
(svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents:
10360
diff
changeset
|
472 if (!StrEmpty(mgo.opt) && mgo.opt[1] == '\0') { |
b822f913edb3
(svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents:
10360
diff
changeset
|
473 _use_palette = (PaletteType)(mgo.opt[0] - '0'); |
b822f913edb3
(svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents:
10360
diff
changeset
|
474 if (_use_palette <= MAX_PAL) break; |
b822f913edb3
(svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents:
10360
diff
changeset
|
475 } |
b822f913edb3
(svn r14612) -Change: force the argument given to '-i' parameter to be valid. Accept '2', too
smatz <smatz@openttd.org>
parents:
10360
diff
changeset
|
476 usererror("Valid value for '-i' is 0, 1 or 2"); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
477 case 'g': |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
478 if (mgo.opt != NULL) { |
10310
5cefbb1c3fd7
(svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents:
10299
diff
changeset
|
479 strecpy(_file_to_saveload.name, mgo.opt, lastof(_file_to_saveload.name)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
480 _switch_mode = SM_LOAD; |
9730
6d3372e45a23
(svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents:
9729
diff
changeset
|
481 _file_to_saveload.mode = SL_LOAD; |
6d3372e45a23
(svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents:
9729
diff
changeset
|
482 |
6d3372e45a23
(svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents:
9729
diff
changeset
|
483 /* if the file doesn't exist or it is not a valid savegame, let the saveload code show an error */ |
6d3372e45a23
(svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents:
9729
diff
changeset
|
484 const char *t = strrchr(_file_to_saveload.name, '.'); |
6d3372e45a23
(svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents:
9729
diff
changeset
|
485 if (t != NULL) { |
10809
0b7a4eee5b46
(svn r15144) -Codechange: make sure we don't run out of bounds while determining old savegame name
smatz <smatz@openttd.org>
parents:
10696
diff
changeset
|
486 FiosType ft = FiosGetSavegameListCallback(SLD_LOAD_GAME, _file_to_saveload.name, t, NULL, NULL); |
9730
6d3372e45a23
(svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents:
9729
diff
changeset
|
487 if (ft != FIOS_TYPE_INVALID) SetFiosType(ft); |
6d3372e45a23
(svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents:
9729
diff
changeset
|
488 } |
6d3372e45a23
(svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents:
9729
diff
changeset
|
489 |
6d3372e45a23
(svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents:
9729
diff
changeset
|
490 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
491 } |
9730
6d3372e45a23
(svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents:
9729
diff
changeset
|
492 |
6d3372e45a23
(svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents:
9729
diff
changeset
|
493 _switch_mode = SM_NEWGAME; |
10195
9f2f34f48a26
(svn r14408) -Fix (r9205): generation seed set using -G was always overwritten by -g
glx <glx@openttd.org>
parents:
10167
diff
changeset
|
494 /* Give a random map if no seed has been given */ |
9f2f34f48a26
(svn r14408) -Fix (r9205): generation seed set using -G was always overwritten by -g
glx <glx@openttd.org>
parents:
10167
diff
changeset
|
495 if (generation_seed == GENERATE_NEW_SEED) { |
9f2f34f48a26
(svn r14408) -Fix (r9205): generation seed set using -G was always overwritten by -g
glx <glx@openttd.org>
parents:
10167
diff
changeset
|
496 generation_seed = InteractiveRandom(); |
9f2f34f48a26
(svn r14408) -Fix (r9205): generation seed set using -G was always overwritten by -g
glx <glx@openttd.org>
parents:
10167
diff
changeset
|
497 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
498 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
499 case 'G': generation_seed = atoi(mgo.opt); break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
500 case 'c': _config_file = strdup(mgo.opt); break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
501 case 'x': save_config = false; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
502 case -2: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
503 case 'h': |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
504 /* The next two functions are needed to list the graphics sets. |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
505 * We can't do them earlier because then we can't show it on |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
506 * the debug console as that hasn't been configured yet. */ |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
507 DeterminePaths(argv[0]); |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
508 FindGraphicsSets(); |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
509 ShowHelp(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
510 return 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
511 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
512 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
513 |
7408
53fa9a58449a
(svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents:
7401
diff
changeset
|
514 #if defined(WINCE) && defined(_DEBUG) |
53fa9a58449a
(svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents:
7401
diff
changeset
|
515 /* Switch on debug lvl 4 for WinCE if Debug release, as you can't give params, and you most likely do want this information */ |
53fa9a58449a
(svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents:
7401
diff
changeset
|
516 SetDebugString("4"); |
53fa9a58449a
(svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents:
7401
diff
changeset
|
517 #endif |
53fa9a58449a
(svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents:
7401
diff
changeset
|
518 |
6317
d5d3f3379eb0
(svn r9266) -Codechange: unify the retrieval of the base paths a little more.
rubidium <rubidium@openttd.org>
parents:
6309
diff
changeset
|
519 DeterminePaths(argv[0]); |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
520 FindGraphicsSets(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
521 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
522 #if defined(UNIX) && !defined(__MORPHOS__) |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
523 /* We must fork here, or we'll end up without some resources we need (like sockets) */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
524 if (_dedicated_forks) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
525 DedicatedFork(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
526 #endif |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
527 |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
528 AI::Initialize(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
529 LoadFromConfig(); |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
530 AI::Uninitialize(true); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
531 CheckConfig(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
532 LoadFromHighScore(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
533 |
9533
176a9fe1018f
(svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents:
9470
diff
changeset
|
534 if (resolution.width != 0) { _cur_resolution = resolution; } |
9354
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
535 if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear; |
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
536 if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
537 |
6892
556994541424
(svn r10139) -Fix: all inner parts of OpenTTD assume that the resolution is at least 1 by 1, so force the resolution to be always at least 1 by 1.
rubidium <rubidium@openttd.org>
parents:
6878
diff
changeset
|
538 /* The width and height must be at least 1 pixel, this |
556994541424
(svn r10139) -Fix: all inner parts of OpenTTD assume that the resolution is at least 1 by 1, so force the resolution to be always at least 1 by 1.
rubidium <rubidium@openttd.org>
parents:
6878
diff
changeset
|
539 * way all internal drawing routines work correctly. */ |
9533
176a9fe1018f
(svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents:
9470
diff
changeset
|
540 if (_cur_resolution.width <= 0) _cur_resolution.width = 1; |
176a9fe1018f
(svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
smatz <smatz@openttd.org>
parents:
9470
diff
changeset
|
541 if (_cur_resolution.height <= 0) _cur_resolution.height = 1; |
6892
556994541424
(svn r10139) -Fix: all inner parts of OpenTTD assume that the resolution is at least 1 by 1, so force the resolution to be always at least 1 by 1.
rubidium <rubidium@openttd.org>
parents:
6878
diff
changeset
|
542 |
5692
47e97da9c104
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents:
5683
diff
changeset
|
543 #if defined(ENABLE_NETWORK) |
9420
ec47ec544964
(svn r13334) -Codechange: move the network settings variables from network/network_internal to settings.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
544 if (dedicated_host) snprintf(_settings_client.network.server_bind_ip, sizeof(_settings_client.network.server_bind_ip), "%s", dedicated_host); |
ec47ec544964
(svn r13334) -Codechange: move the network settings variables from network/network_internal to settings.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
545 if (dedicated_port) _settings_client.network.server_port = dedicated_port; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
546 if (_dedicated_forks && !dedicated) _dedicated_forks = false; |
5692
47e97da9c104
(svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents:
5683
diff
changeset
|
547 #endif /* ENABLE_NETWORK */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
548 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
549 /* enumerate language files */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
550 InitializeLanguagePacks(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
551 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
552 /* initialize screenshot formats */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
553 InitializeScreenshotFormats(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
554 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
555 /* initialize airport state machines */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
556 InitializeAirports(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
557 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
558 /* initialize all variables that are allocated dynamically */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
559 InitializeDynamicVariables(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
560 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
561 /* Sample catalogue */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
562 DEBUG(misc, 1, "Loading sound effects..."); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
563 MxInitialize(11025); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
564 SoundInitialize("sample.cat"); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
565 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
566 /* Initialize FreeType */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
567 InitFreeType(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
568 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
569 /* This must be done early, since functions use the InvalidateWindow* calls */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
570 InitWindowSystem(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
571 |
11046
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
572 if (graphics_set == NULL) graphics_set = _ini_graphics_set; |
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
573 if (!SetGraphicsSet(graphics_set)) { |
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
574 StrEmpty(graphics_set) ? |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
575 usererror("Failed to find a graphics set. Please acquire a graphics set for OpenTTD.") : |
11046
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
576 usererror("Failed to select requested graphics set '%s'", graphics_set); |
9994
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
577 } |
4687a554c837
(svn r14151) -Codechange: make it possible to choose between the DOS and Windows graphics packs while retaining the possibility to override the palette.
rubidium <rubidium@openttd.org>
parents:
9989
diff
changeset
|
578 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
579 /* Initialize game palette */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
580 GfxInitPalettes(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
581 |
7567
5e3238300b22
(svn r11092) -Add: allow 'blitter=<value>' in openttd.cfg to set the blitter (so you don't have to keep on doing 'openttd -b 32bpp-optimized'..)
truelight <truelight@openttd.org>
parents:
7515
diff
changeset
|
582 DEBUG(misc, 1, "Loading blitter..."); |
11046
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
583 if (blitter == NULL) blitter = _ini_blitter; |
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
584 if (BlitterFactoryBase::SelectBlitter(blitter) == NULL) |
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
585 StrEmpty(blitter) ? |
9470
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
586 usererror("Failed to autoprobe blitter") : |
11046
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
587 usererror("Failed to select requested blitter '%s'; does it exist?", blitter); |
7170
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
588 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
589 DEBUG(driver, 1, "Loading drivers..."); |
7170
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
590 |
11046
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
591 if (sounddriver == NULL) sounddriver = _ini_sounddriver; |
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
592 _sound_driver = (SoundDriver*)SoundDriverFactoryBase::SelectDriver(sounddriver, Driver::DT_SOUND); |
7170
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
593 if (_sound_driver == NULL) { |
11046
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
594 StrEmpty(sounddriver) ? |
9470
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
595 usererror("Failed to autoprobe sound driver") : |
11046
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
596 usererror("Failed to select requested sound driver '%s'", sounddriver); |
7170
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
597 } |
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
598 |
11046
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
599 if (musicdriver == NULL) musicdriver = _ini_musicdriver; |
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
600 _music_driver = (MusicDriver*)MusicDriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC); |
7170
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
601 if (_music_driver == NULL) { |
11046
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
602 StrEmpty(musicdriver) ? |
9470
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
603 usererror("Failed to autoprobe music driver") : |
11046
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
604 usererror("Failed to select requested music driver '%s'", musicdriver); |
7170
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
605 } |
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
606 |
11046
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
607 if (videodriver == NULL) videodriver = _ini_videodriver; |
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
608 _video_driver = (VideoDriver*)VideoDriverFactoryBase::SelectDriver(videodriver, Driver::DT_VIDEO); |
7170
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
609 if (_video_driver == NULL) { |
11046
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
610 StrEmpty(videodriver) ? |
9470
47924a4b2ad4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx <glx@openttd.org>
parents:
9466
diff
changeset
|
611 usererror("Failed to autoprobe video driver") : |
11046
6aabd80be58f
(svn r15386) -Codechange: During start up, store driver/blitter/graphicsset selection in local variable instead of in the global _ini_* variables. This means that specifying a driver/blitter/graphicsset on the command line does not clobber the configuration value, which can now be saved like other values.
peter1138 <peter1138@openttd.org>
parents:
11043
diff
changeset
|
612 usererror("Failed to select requested video driver '%s'", videodriver); |
7170
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
613 } |
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
614 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
615 _savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING; |
6654
860f3e5f70ec
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight <truelight@openttd.org>
parents:
6643
diff
changeset
|
616 /* Initialize the zoom level of the screen to normal */ |
860f3e5f70ec
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight <truelight@openttd.org>
parents:
6643
diff
changeset
|
617 _screen.zoom = ZOOM_LVL_NORMAL; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
618 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
619 /* restore saved music volume */ |
7170
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
620 _music_driver->SetVolume(msf.music_vol); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
621 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
622 NetworkStartUp(); // initialize network-core |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
623 |
5959
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
624 #if defined(ENABLE_NETWORK) |
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
625 if (debuglog_conn != NULL && _network_available) { |
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
626 const char *not_used = NULL; |
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
627 const char *port = NULL; |
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
628 uint16 rport; |
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
629 |
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
630 rport = NETWORK_DEFAULT_DEBUGLOG_PORT; |
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
631 |
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
632 ParseConnectionString(¬_used, &port, debuglog_conn); |
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
633 if (port != NULL) rport = atoi(port); |
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
634 |
10822
db2fdef51d46
(svn r15157) -Codechange: wrap the hostname/ip and port into a single structure so we can pass either one of them and not convert an ip to a string and then back again.
rubidium <rubidium@openttd.org>
parents:
10809
diff
changeset
|
635 NetworkStartDebugLog(NetworkAddress(debuglog_conn, rport)); |
5959
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
636 } |
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
637 #endif /* ENABLE_NETWORK */ |
a34cb5eb18ca
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
truelight <truelight@openttd.org>
parents:
5890
diff
changeset
|
638 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
639 ScanNewGRFFiles(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
640 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
641 ResetGRFConfig(false); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
642 |
11148
3cb2d503c4e8
(svn r15495) -Revert (r15383,r15422): Loading NewGRFs depends on correct settings, but the economy can only be started after loading NewGRFs. In short: r15383 causes more problems then it's worth.
yexo <yexo@openttd.org>
parents:
11109
diff
changeset
|
643 /* Make sure _settings is filled with _settings_newgame if we switch to a game directly */ |
3cb2d503c4e8
(svn r15495) -Revert (r15383,r15422): Loading NewGRFs depends on correct settings, but the economy can only be started after loading NewGRFs. In short: r15383 causes more problems then it's worth.
yexo <yexo@openttd.org>
parents:
11109
diff
changeset
|
644 if (_switch_mode != SM_NONE) MakeNewgameSettingsLive(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
645 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
646 /* initialize the ingame console */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
647 IConsoleInit(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
648 _cursor.in_window = true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
649 InitializeGUI(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
650 IConsoleCmdExec("exec scripts/autoexec.scr 0"); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
651 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
652 GenerateWorld(GW_EMPTY, 64, 64); // Make the viewport initialization happy |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
653 WaitTillGeneratedWorld(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
654 |
11109
d202ea73cf73
(svn r15455) -Fix: font autodetection didn't occur when directly loading a game via e.g. -g.
rubidium <rubidium@openttd.org>
parents:
11085
diff
changeset
|
655 CheckForMissingGlyphsInLoadedLanguagePack(); |
d202ea73cf73
(svn r15455) -Fix: font autodetection didn't occur when directly loading a game via e.g. -g.
rubidium <rubidium@openttd.org>
parents:
11085
diff
changeset
|
656 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
657 #ifdef ENABLE_NETWORK |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
658 if (network && _network_available) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
659 if (network_conn != NULL) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
660 const char *port = NULL; |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
661 const char *company = NULL; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
662 uint16 rport; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
663 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
664 rport = NETWORK_DEFAULT_PORT; |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
665 _network_playas = COMPANY_NEW_COMPANY; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
666 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
667 ParseConnectionString(&company, &port, network_conn); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
668 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
669 if (company != NULL) { |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
670 _network_playas = (CompanyID)atoi(company); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
671 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
672 if (_network_playas != COMPANY_SPECTATOR) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
673 _network_playas--; |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
674 if (_network_playas >= MAX_COMPANIES) return false; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
675 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
676 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
677 if (port != NULL) rport = atoi(port); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
678 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
679 LoadIntroGame(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
680 _switch_mode = SM_NONE; |
10822
db2fdef51d46
(svn r15157) -Codechange: wrap the hostname/ip and port into a single structure so we can pass either one of them and not convert an ip to a string and then back again.
rubidium <rubidium@openttd.org>
parents:
10809
diff
changeset
|
681 NetworkClientConnectGame(NetworkAddress(network_conn, rport)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
682 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
683 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
684 #endif /* ENABLE_NETWORK */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
685 |
7170
c6917d8e8c25
(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138 <peter1138@openttd.org>
parents:
7152
diff
changeset
|
686 _video_driver->MainLoop(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
687 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
688 WaitTillSaved(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
689 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
690 /* only save config if we have to */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
691 if (save_config) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
692 SaveToConfig(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
693 SaveToHighScore(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
694 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
695 |
9159
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
696 /* Reset windowing system, stop drivers, free used memory, ... */ |
68da59de5396
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
697 ShutdownGame(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
698 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
699 return 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
700 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
701 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
702 void HandleExitGameRequest() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
703 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
704 if (_game_mode == GM_MENU) { // do not ask to quit on the main screen |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
705 _exit_game = true; |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9411
diff
changeset
|
706 } else if (_settings_client.gui.autosave_on_exit) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
707 DoExitSave(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
708 _exit_game = true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
709 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
710 AskExitGame(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
711 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
712 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
713 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
714 static void ShowScreenshotResult(bool b) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
715 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
716 if (b) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
717 SetDParamStr(0, _screenshot_name); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
718 ShowErrorMessage(INVALID_STRING_ID, STR_031B_SCREENSHOT_SUCCESSFULLY, 0, 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
719 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
720 ShowErrorMessage(INVALID_STRING_ID, STR_031C_SCREENSHOT_FAILED, 0, 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
721 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
722 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
723 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
724 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
725 static void MakeNewGameDone() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
726 { |
9617
67791dec09fd
(svn r13673) -Fix [FS#2122]: desync when building electrified trains on a dedicated server that was started with electrification disabled.
rubidium <rubidium@openttd.org>
parents:
9533
diff
changeset
|
727 SettingsDisableElrail(_settings_game.vehicle.disable_elrails); |
67791dec09fd
(svn r13673) -Fix [FS#2122]: desync when building electrified trains on a dedicated server that was started with electrification disabled.
rubidium <rubidium@openttd.org>
parents:
9533
diff
changeset
|
728 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
729 /* In a dedicated server, the server does not play */ |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
730 if (BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() == 0) { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
731 SetLocalCompany(COMPANY_SPECTATOR); |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
732 IConsoleCmdExec("exec scripts/game_start.scr 0"); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
733 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
734 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
735 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
736 /* Create a single company */ |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
737 DoStartupNewCompany(false); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
738 |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
739 IConsoleCmdExec("exec scripts/game_start.scr 0"); |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
740 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
741 SetLocalCompany(COMPANY_FIRST); |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
742 _current_company = _local_company; |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10489
diff
changeset
|
743 DoCommandP(0, (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4, _settings_client.gui.autorenew_money, CMD_SET_AUTOREPLACE); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
744 |
8809
6f39a645401a
(svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
smatz <smatz@openttd.org>
parents:
8790
diff
changeset
|
745 InitializeRailGUI(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
746 |
8247
c0449b1df5e1
(svn r11811) -Fix: make compilation without networking work again (and thus move the debugdumpcommand stuff out of the network 'area').
rubidium <rubidium@openttd.org>
parents:
8224
diff
changeset
|
747 #ifdef ENABLE_NETWORK |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
748 /* We are the server, we start a new company (not dedicated), |
7998
c23b6367e55b
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents:
7981
diff
changeset
|
749 * so set the default password *if* needed. */ |
9420
ec47ec544964
(svn r13334) -Codechange: move the network settings variables from network/network_internal to settings.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
750 if (_network_server && !StrEmpty(_settings_client.network.default_company_pass)) { |
ec47ec544964
(svn r13334) -Codechange: move the network settings variables from network/network_internal to settings.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
751 char *password = _settings_client.network.default_company_pass; |
7998
c23b6367e55b
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents:
7981
diff
changeset
|
752 NetworkChangeCompanyPassword(1, &password); |
c23b6367e55b
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents:
7981
diff
changeset
|
753 } |
8247
c0449b1df5e1
(svn r11811) -Fix: make compilation without networking work again (and thus move the debugdumpcommand stuff out of the network 'area').
rubidium <rubidium@openttd.org>
parents:
8224
diff
changeset
|
754 #endif /* ENABLE_NETWORK */ |
7998
c23b6367e55b
(svn r11556) -Feature: allow setting a default password for new companies in network games.
rubidium <rubidium@openttd.org>
parents:
7981
diff
changeset
|
755 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
756 MarkWholeScreenDirty(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
757 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
758 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
759 static void MakeNewGame(bool from_heightmap) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
760 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
761 _game_mode = GM_NORMAL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
762 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
763 ResetGRFConfig(true); |
6629
188437dffcff
(svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas <belugas@openttd.org>
parents:
6626
diff
changeset
|
764 _house_mngr.ResetMapping(); |
7152
70c7afefcca5
(svn r10426) -Codechange: Activate the reset of industry/tiles mapping upon initialization or new game.
belugas <belugas@openttd.org>
parents:
7091
diff
changeset
|
765 _industile_mngr.ResetMapping(); |
70c7afefcca5
(svn r10426) -Codechange: Activate the reset of industry/tiles mapping upon initialization or new game.
belugas <belugas@openttd.org>
parents:
7091
diff
changeset
|
766 _industry_mngr.ResetMapping(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
767 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
768 GenerateWorldSetCallback(&MakeNewGameDone); |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9411
diff
changeset
|
769 GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
770 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
771 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
772 static void MakeNewEditorWorldDone() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
773 { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
774 SetLocalCompany(OWNER_NONE); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
775 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
776 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
777 static void MakeNewEditorWorld() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
778 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
779 _game_mode = GM_EDITOR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
780 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
781 ResetGRFConfig(true); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
782 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
783 GenerateWorldSetCallback(&MakeNewEditorWorldDone); |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9411
diff
changeset
|
784 GenerateWorld(GW_EMPTY, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
785 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
786 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
787 void StartupCompanies(); |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
788 void StartupDisasters(); |
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
789 extern void StartupEconomy(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
790 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
791 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
792 * Start Scenario starts a new game based on a scenario. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
793 * Eg 'New Game' --> select a preset scenario |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
794 * This starts a scenario based on your current difficulty settings |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
795 */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
796 static void StartScenario() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
797 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
798 _game_mode = GM_NORMAL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
799 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
800 /* invalid type */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
801 if (_file_to_saveload.mode == SL_INVALID) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
802 DEBUG(sl, 0, "Savegame is obsolete or invalid format: '%s'", _file_to_saveload.name); |
10489
071264f7160e
(svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
803 SetDParamStr(0, GetSaveLoadErrorString()); |
071264f7160e
(svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
804 ShowErrorMessage(INVALID_STRING_ID, STR_JUST_RAW_STRING, 0, 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
805 _game_mode = GM_MENU; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
806 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
807 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
808 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
809 /* Reinitialize windows */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
810 ResetWindowSystem(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
811 |
11085
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
11079
diff
changeset
|
812 SetupColoursAndInitialWindow(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
813 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
814 ResetGRFConfig(true); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
815 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
816 /* Load game */ |
6929
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
817 if (SaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, SCENARIO_DIR) != SL_OK) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
818 LoadIntroGame(); |
10489
071264f7160e
(svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
819 SetDParamStr(0, GetSaveLoadErrorString()); |
071264f7160e
(svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
820 ShowErrorMessage(INVALID_STRING_ID, STR_JUST_RAW_STRING, 0, 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
821 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
822 |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9411
diff
changeset
|
823 _settings_game.difficulty = _settings_newgame.difficulty; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
824 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
825 /* Inititalize data */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
826 StartupEconomy(); |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
827 StartupCompanies(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
828 StartupEngines(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
829 StartupDisasters(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
830 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
831 SetLocalCompany(COMPANY_FIRST); |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
832 _current_company = _local_company; |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10489
diff
changeset
|
833 DoCommandP(0, (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4, _settings_client.gui.autorenew_money, CMD_SET_AUTOREPLACE); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
834 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
835 MarkWholeScreenDirty(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
836 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
837 |
6929
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
838 /** Load the specified savegame but on error do different things. |
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
839 * If loading fails due to corrupt savegame, bad version, etc. go back to |
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
840 * a previous correct state. In the menu for example load the intro game again. |
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
841 * @param filename file to be loaded |
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
842 * @param mode mode of loading, either SL_LOAD or SL_OLD_LOAD |
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
843 * @param newgm switch to this mode of loading fails due to some unknown error |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
844 * @param subdir default directory to look for filename, set to 0 if not needed |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
845 */ |
6929
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
846 bool SafeSaveOrLoad(const char *filename, int mode, int newgm, Subdirectory subdir) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
847 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
848 byte ogm = _game_mode; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
849 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
850 _game_mode = newgm; |
6929
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
851 assert(mode == SL_LOAD || mode == SL_OLD_LOAD); |
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
852 switch (SaveOrLoad(filename, mode, subdir)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
853 case SL_OK: return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
854 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
855 case SL_REINIT: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
856 switch (ogm) { |
8619
4cf1201e6f50
(svn r12202) -Fix: When loading a savegame fails, don't start creating a new game, just go straight back to the intro screen.
peter1138 <peter1138@openttd.org>
parents:
8613
diff
changeset
|
857 default: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
858 case GM_MENU: LoadIntroGame(); break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
859 case GM_EDITOR: MakeNewEditorWorld(); break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
860 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
861 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
862 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
863 default: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
864 _game_mode = ogm; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
865 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
866 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
867 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
868 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
869 void SwitchMode(int new_mode) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
870 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
871 #ifdef ENABLE_NETWORK |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
872 /* If we are saving something, the network stays in his current state */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
873 if (new_mode != SM_SAVE) { |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
874 /* If the network is active, make it not-active */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
875 if (_networking) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
876 if (_network_server && (new_mode == SM_LOAD || new_mode == SM_NEWGAME)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
877 NetworkReboot(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
878 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
879 NetworkDisconnect(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
880 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
881 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
882 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
883 /* If we are a server, we restart the server */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
884 if (_is_network_server) { |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
885 /* But not if we are going to the menu */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
886 if (new_mode != SM_MENU) { |
8265
bfae01b80d25
(svn r11829) -Feature: allow reloading openttd.cfg when starting a new game on a dedicated server. Patch by dihedral.
rubidium <rubidium@openttd.org>
parents:
8264
diff
changeset
|
887 /* check if we should reload the config */ |
9420
ec47ec544964
(svn r13334) -Codechange: move the network settings variables from network/network_internal to settings.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
888 if (_settings_client.network.reload_cfg) { |
8265
bfae01b80d25
(svn r11829) -Feature: allow reloading openttd.cfg when starting a new game on a dedicated server. Patch by dihedral.
rubidium <rubidium@openttd.org>
parents:
8264
diff
changeset
|
889 LoadFromConfig(); |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
890 MakeNewgameSettingsLive(); |
8265
bfae01b80d25
(svn r11829) -Feature: allow reloading openttd.cfg when starting a new game on a dedicated server. Patch by dihedral.
rubidium <rubidium@openttd.org>
parents:
8264
diff
changeset
|
891 ResetGRFConfig(false); |
bfae01b80d25
(svn r11829) -Feature: allow reloading openttd.cfg when starting a new game on a dedicated server. Patch by dihedral.
rubidium <rubidium@openttd.org>
parents:
8264
diff
changeset
|
892 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
893 NetworkServerStart(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
894 } else { |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
895 /* This client no longer wants to be a network-server */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
896 _is_network_server = false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
897 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
898 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
899 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
900 #endif /* ENABLE_NETWORK */ |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
901 /* Make sure all AI controllers are gone at quiting game */ |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
902 if (new_mode != SM_SAVE) AI::KillAll(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
903 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
904 switch (new_mode) { |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
905 case SM_EDITOR: /* Switch to scenario editor */ |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
906 MakeNewEditorWorld(); |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
907 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
908 |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
909 case SM_NEWGAME: /* New Game --> 'Random game' */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
910 #ifdef ENABLE_NETWORK |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
911 if (_network_server) { |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
912 snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "Random Map"); |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
913 } |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
914 #endif /* ENABLE_NETWORK */ |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
915 MakeNewGame(false); |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
916 break; |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
917 |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
918 case SM_START_SCENARIO: /* New Game --> Choose one of the preset scenarios */ |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
919 #ifdef ENABLE_NETWORK |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
920 if (_network_server) { |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
921 snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Loaded scenario)", _file_to_saveload.title); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
922 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
923 #endif /* ENABLE_NETWORK */ |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
924 StartScenario(); |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
925 break; |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
926 |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
927 case SM_LOAD: { /* Load game, Play Scenario */ |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
928 ResetGRFConfig(true); |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
929 ResetWindowSystem(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
930 |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
931 if (!SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_NORMAL, NO_DIRECTORY)) { |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
932 LoadIntroGame(); |
10489
071264f7160e
(svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
933 SetDParamStr(0, GetSaveLoadErrorString()); |
071264f7160e
(svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
934 ShowErrorMessage(INVALID_STRING_ID, STR_JUST_RAW_STRING, 0, 0); |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
935 } else { |
9089
0fdd16c9c709
(svn r12948) -Fix [FS#1982]: all vehicles would be available when an original scenario would be played.
rubidium <rubidium@openttd.org>
parents:
9085
diff
changeset
|
936 if (_saveload_mode == SLD_LOAD_SCENARIO) { |
0fdd16c9c709
(svn r12948) -Fix [FS#1982]: all vehicles would be available when an original scenario would be played.
rubidium <rubidium@openttd.org>
parents:
9085
diff
changeset
|
937 StartupEngines(); |
0fdd16c9c709
(svn r12948) -Fix [FS#1982]: all vehicles would be available when an original scenario would be played.
rubidium <rubidium@openttd.org>
parents:
9085
diff
changeset
|
938 } |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
939 /* Update the local company for a loaded game. It is either always |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
940 * company #1 (eg 0) or in the case of a dedicated server a spectator */ |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
941 SetLocalCompany(_network_dedicated ? COMPANY_SPECTATOR : COMPANY_FIRST); |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
942 /* Execute the game-start script */ |
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
943 IConsoleCmdExec("exec scripts/game_start.scr 0"); |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
944 /* Decrease pause counter (was increased from opening load dialog) */ |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10489
diff
changeset
|
945 DoCommandP(0, 0, 0, CMD_PAUSE); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
946 #ifdef ENABLE_NETWORK |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
947 if (_network_server) { |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
948 snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Loaded game)", _file_to_saveload.title); |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
949 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
950 #endif /* ENABLE_NETWORK */ |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
951 } |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
952 break; |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
953 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
954 |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
955 case SM_START_HEIGHTMAP: /* Load a heightmap and start a new game from it */ |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
956 #ifdef ENABLE_NETWORK |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
957 if (_network_server) { |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
958 snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Heightmap)", _file_to_saveload.title); |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
959 } |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
960 #endif /* ENABLE_NETWORK */ |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
961 MakeNewGame(true); |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
962 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
963 |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
964 case SM_LOAD_HEIGHTMAP: /* Load heightmap from scenario editor */ |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
965 SetLocalCompany(OWNER_NONE); |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
966 |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9411
diff
changeset
|
967 GenerateWorld(GW_HEIGHTMAP, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y); |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
968 MarkWholeScreenDirty(); |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
969 break; |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
970 |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
971 case SM_LOAD_SCENARIO: { /* Load scenario from scenario editor */ |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
972 if (SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_EDITOR, NO_DIRECTORY)) { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
973 SetLocalCompany(OWNER_NONE); |
9354
2b0c6e62535e
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
rubidium <rubidium@openttd.org>
parents:
9346
diff
changeset
|
974 _settings_newgame.game_creation.starting_year = _cur_year; |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
975 } else { |
10489
071264f7160e
(svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
976 SetDParamStr(0, GetSaveLoadErrorString()); |
071264f7160e
(svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
977 ShowErrorMessage(INVALID_STRING_ID, STR_JUST_RAW_STRING, 0, 0); |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
978 } |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
979 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
980 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
981 |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
982 case SM_MENU: /* Switch to game intro menu */ |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
983 LoadIntroGame(); |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
984 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
985 |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
986 case SM_SAVE: /* Save game */ |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
987 /* Make network saved games on pause compatible to singleplayer */ |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
988 if (_networking && _pause_game == 1) _pause_game = 2; |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
989 if (SaveOrLoad(_file_to_saveload.name, SL_SAVE, NO_DIRECTORY) != SL_OK) { |
10489
071264f7160e
(svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
990 SetDParamStr(0, GetSaveLoadErrorString()); |
071264f7160e
(svn r14744) -Fix [FS#2474]: don't tell loading a savegame failed in two distinct ways.
rubidium <rubidium@openttd.org>
parents:
10488
diff
changeset
|
991 ShowErrorMessage(INVALID_STRING_ID, STR_JUST_RAW_STRING, 0, 0); |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
992 } else { |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
993 DeleteWindowById(WC_SAVELOAD, 0); |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
994 } |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
995 if (_networking && _pause_game == 2) _pause_game = 1; |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
996 break; |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
997 |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
998 case SM_GENRANDLAND: /* Generate random land within scenario editor */ |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
999 SetLocalCompany(OWNER_NONE); |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9411
diff
changeset
|
1000 GenerateWorld(GW_RANDOM, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y); |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
1001 /* XXX: set date */ |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
1002 MarkWholeScreenDirty(); |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
1003 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1004 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1005 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1006 if (_switch_mode_errorstr != INVALID_STRING_ID) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1007 ShowErrorMessage(INVALID_STRING_ID, _switch_mode_errorstr, 0, 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1008 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1009 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1010 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1011 |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
1012 /** |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
1013 * State controlling game loop. |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
1014 * The state must not be changed from anywhere but here. |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
1015 * That check is enforced in DoCommand. |
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
1016 */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
1017 void StateGameLoop() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1018 { |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
1019 /* dont execute the state loop during pause */ |
8179
a0879dc1b54d
(svn r11742) -Codechange [FS#1319]: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused.
peter1138 <peter1138@openttd.org>
parents:
8172
diff
changeset
|
1020 if (_pause_game) { |
a0879dc1b54d
(svn r11742) -Codechange [FS#1319]: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused.
peter1138 <peter1138@openttd.org>
parents:
8172
diff
changeset
|
1021 CallWindowTickEvent(); |
a0879dc1b54d
(svn r11742) -Codechange [FS#1319]: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused.
peter1138 <peter1138@openttd.org>
parents:
8172
diff
changeset
|
1022 return; |
a0879dc1b54d
(svn r11742) -Codechange [FS#1319]: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused.
peter1138 <peter1138@openttd.org>
parents:
8172
diff
changeset
|
1023 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1024 if (IsGeneratingWorld()) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1025 |
8303
0ab35f1b5949
(svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents:
8291
diff
changeset
|
1026 ClearStorageChanges(false); |
0ab35f1b5949
(svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents:
8291
diff
changeset
|
1027 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1028 if (_game_mode == GM_EDITOR) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1029 RunTileLoop(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1030 CallVehicleTicks(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1031 CallLandscapeTick(); |
8303
0ab35f1b5949
(svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents:
8291
diff
changeset
|
1032 ClearStorageChanges(true); |
0ab35f1b5949
(svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents:
8291
diff
changeset
|
1033 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1034 CallWindowTickEvent(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1035 NewsLoop(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1036 } else { |
10515
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1037 if (_debug_desync_level > 1) { |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1038 Vehicle *v; |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1039 FOR_ALL_VEHICLES(v) { |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1040 if (v != v->First()) continue; |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1041 |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1042 switch (v->type) { |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1043 case VEH_ROAD: { |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1044 extern byte GetRoadVehLength(const Vehicle *v); |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1045 if (GetRoadVehLength(v) != v->u.road.cached_veh_length) { |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1046 DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i\n", v->index, (int)v->owner, v->unitnumber); |
9039
54d5d16c50c5
(svn r12858) -Add: small piece of code that can help hunting desyncs. Has to be enabled by --enable-desync-debug=1 though.
rubidium <rubidium@openttd.org>
parents:
9029
diff
changeset
|
1047 } |
10515
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1048 } break; |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1049 |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1050 case VEH_TRAIN: { |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1051 uint length = 0; |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1052 for (Vehicle *u = v; u != NULL; u = u->Next()) length++; |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1053 |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1054 VehicleRail *wagons = MallocT<VehicleRail>(length); |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1055 length = 0; |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1056 for (Vehicle *u = v; u != NULL; u = u->Next()) wagons[length++] = u->u.rail; |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1057 |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1058 TrainConsistChanged(v, true); |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1059 |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1060 length = 0; |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1061 for (Vehicle *u = v; u != NULL; u = u->Next()) { |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1062 if (memcmp(&wagons[length], &u->u.rail, sizeof(VehicleRail)) != 0) { |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1063 DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i, wagon %i\n", v->index, (int)v->owner, v->unitnumber, length); |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1064 } |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1065 length++; |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1066 } |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1067 |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1068 free(wagons); |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1069 } break; |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1070 |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1071 case VEH_AIRCRAFT: { |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1072 uint speed = v->u.air.cached_max_speed; |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1073 UpdateAircraftCache(v); |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1074 if (speed != v->u.air.cached_max_speed) { |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1075 DEBUG(desync, 2, "cache mismatch: vehicle %i, company %i, unit number %i\n", v->index, (int)v->owner, v->unitnumber); |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1076 } |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1077 } break; |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1078 |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1079 default: |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1080 break; |
7156262cf0c9
(svn r14772) -Codechange: make the "dump log of game to reproduce" desync debug stuff a runtime configurable debug option instead of a compile time option.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1081 } |
9039
54d5d16c50c5
(svn r12858) -Add: small piece of code that can help hunting desyncs. Has to be enabled by --enable-desync-debug=1 though.
rubidium <rubidium@openttd.org>
parents:
9029
diff
changeset
|
1082 } |
54d5d16c50c5
(svn r12858) -Add: small piece of code that can help hunting desyncs. Has to be enabled by --enable-desync-debug=1 though.
rubidium <rubidium@openttd.org>
parents:
9029
diff
changeset
|
1083 } |
54d5d16c50c5
(svn r12858) -Add: small piece of code that can help hunting desyncs. Has to be enabled by --enable-desync-debug=1 though.
rubidium <rubidium@openttd.org>
parents:
9029
diff
changeset
|
1084 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
1085 /* All these actions has to be done from OWNER_NONE |
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
1086 * for multiplayer compatibility */ |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
1087 CompanyID old_company = _current_company; |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
1088 _current_company = OWNER_NONE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1089 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1090 AnimateAnimatedTiles(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1091 IncreaseDate(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1092 RunTileLoop(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1093 CallVehicleTicks(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1094 CallLandscapeTick(); |
8303
0ab35f1b5949
(svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents:
8291
diff
changeset
|
1095 ClearStorageChanges(true); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1096 |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10619
diff
changeset
|
1097 AI::GameLoop(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1098 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1099 CallWindowTickEvent(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1100 NewsLoop(); |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
1101 _current_company = old_company; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1102 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1103 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1104 |
6929
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
1105 /** Create an autosave. The default name is "autosave#.sav". However with |
11069
36d798171bfd
(svn r15410) -Cleanup: get rid of most of the references to the 'patches' except where it's used for backward compatability.
rubidium <rubidium@openttd.org>
parents:
11050
diff
changeset
|
1106 * the setting 'keep_all_autosave' the name defaults to company-name + date */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
1107 static void DoAutosave() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1108 { |
6929
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
1109 char buf[MAX_PATH]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1110 |
5977
03f33d102c56
(svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight <truelight@openttd.org>
parents:
5959
diff
changeset
|
1111 #if defined(PSP) |
03f33d102c56
(svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight <truelight@openttd.org>
parents:
5959
diff
changeset
|
1112 /* Autosaving in networking is too time expensive for the PSP */ |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
1113 if (_networking) return; |
5977
03f33d102c56
(svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight <truelight@openttd.org>
parents:
5959
diff
changeset
|
1114 #endif /* PSP */ |
03f33d102c56
(svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight <truelight@openttd.org>
parents:
5959
diff
changeset
|
1115 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10195
diff
changeset
|
1116 if (_settings_client.gui.keep_all_autosave && _local_company != COMPANY_SPECTATOR) { |
10533
53a8506c2079
(svn r14790) -Codechange: unify generation of default savegame/screenshot names (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10516
diff
changeset
|
1117 GenerateDefaultSaveName(buf, lastof(buf)); |
10310
5cefbb1c3fd7
(svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
skidd13 <skidd13@openttd.org>
parents:
10299
diff
changeset
|
1118 strecat(buf, ".sav", lastof(buf)); |
6929
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
1119 } else { |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9411
diff
changeset
|
1120 /* generate a savegame name and number according to _settings_client.gui.max_num_autosaves */ |
6929
bb43858bed10
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium <rubidium@openttd.org>
parents:
6928
diff
changeset
|
1121 snprintf(buf, sizeof(buf), "autosave%d.sav", _autosave_ctr); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1122 |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9411
diff
changeset
|
1123 if (++_autosave_ctr >= _settings_client.gui.max_num_autosaves) _autosave_ctr = 0; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1124 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1125 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1126 DEBUG(sl, 2, "Autosaving to '%s'", buf); |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
1127 if (SaveOrLoad(buf, SL_SAVE, AUTOSAVE_DIR) != SL_OK) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1128 ShowErrorMessage(INVALID_STRING_ID, STR_AUTOSAVE_FAILED, 0, 0); |
9069
249e64399da0
(svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents:
9057
diff
changeset
|
1129 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1130 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1131 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6231
diff
changeset
|
1132 void GameLoop() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1133 { |
8989
4ecc117ebb22
(svn r12784) -Codechange: handle the asynchronious save 'handlers' in saveload.cpp instead of openttd.cpp.
rubidium <rubidium@openttd.org>
parents:
8987
diff
changeset
|
1134 ProcessAsyncSaveFinish(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1135 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
1136 /* autosave game? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1137 if (_do_autosave) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1138 _do_autosave = false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1139 DoAutosave(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1140 RedrawAutosave(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1141 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1142 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
1143 /* make a screenshot? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1144 if (IsScreenshotRequested()) ShowScreenshotResult(MakeScreenshot()); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1145 |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
1146 /* switch game mode? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1147 if (_switch_mode != SM_NONE) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1148 SwitchMode(_switch_mode); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1149 _switch_mode = SM_NONE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1150 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1151 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1152 IncreaseSpriteLRU(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1153 InteractiveRandom(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1154 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1155 _caret_timer += 3; |
7018
a05bbdc788a2
(svn r10276) -Codechange: made a counter based on milliseconds and independent of the game-state to base double-click and TGP Generation Process on
truelight <truelight@openttd.org>
parents:
7012
diff
changeset
|
1156 _palette_animation_counter += 8; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1157 CursorTick(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1158 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1159 #ifdef ENABLE_NETWORK |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
1160 /* Check for UDP stuff */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1161 if (_network_available) NetworkUDPGameLoop(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1162 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1163 if (_networking && !IsGeneratingWorld()) { |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
1164 /* Multiplayer */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1165 NetworkGameLoop(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1166 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1167 if (_network_reconnect > 0 && --_network_reconnect == 0) { |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
1168 /* This means that we want to reconnect to the last host |
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
1169 * We do this here, because it means that the network is really closed */ |
10908
ee1bc768c051
(svn r15243) -Fix [FS#2446]: rejoining a server would abort the join (and kick the client) because trying to join with an invalid player ID
rubidium <rubidium@openttd.org>
parents:
10822
diff
changeset
|
1170 _network_playas = COMPANY_SPECTATOR; |
10822
db2fdef51d46
(svn r15157) -Codechange: wrap the hostname/ip and port into a single structure so we can pass either one of them and not convert an ip to a string and then back again.
rubidium <rubidium@openttd.org>
parents:
10809
diff
changeset
|
1171 NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1172 } |
6351
1dcf39ea9b9b
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents:
6333
diff
changeset
|
1173 /* Singleplayer */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1174 StateGameLoop(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1175 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1176 #else |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1177 StateGameLoop(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1178 #endif /* ENABLE_NETWORK */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1179 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
1180 if (!_pause_game && HasBit(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1181 |
6231
a4e11dd2d7c6
(svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight <truelight@openttd.org>
parents:
6229
diff
changeset
|
1182 if (!_pause_game || _cheats.build_in_pause.value) MoveAllTextEffects(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1183 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1184 InputLoop(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1185 |
10380
1bd9537f246c
(svn r14631) -Add: support for Allegro as sound backend.
rubidium <rubidium@openttd.org>
parents:
10361
diff
changeset
|
1186 _sound_driver->MainLoop(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1187 MusicLoop(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1188 } |