annotate src/openttd.cpp @ 11619:e34ab4ed2a72 draft

(svn r15999) -Codechange: VARDEF--;
author rubidium <rubidium@openttd.org>
date Thu, 09 Apr 2009 01:22:33 +0000
parents 82c90cd591ab
children bcc6cc0d7b33
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 {
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11296
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... */
11296
1b6a11831215 (svn r15645) -Fix (r12924)[FS#2612]: Add an EngineOverrideManager to give the term 'compatible newgrf' again some sense and to not crash because of trivial changes.
frosch <frosch@openttd.org>
parents: 11236
diff changeset
289 _engine_mngr.ResetToDefaultMapping();
1b6a11831215 (svn r15645) -Fix (r12924)[FS#2612]: Add an EngineOverrideManager to give the term 'compatible newgrf' again some sense and to not crash because of trivial changes.
frosch <frosch@openttd.org>
parents: 11236
diff changeset
290 _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
291 _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
292 _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
293 _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
294 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
295
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
296
9159
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
297 /** 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
298 * 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
299 */
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
300 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
301 {
9159
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
302 /* 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
303 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
304
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
305 IConsoleFree();
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 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
308
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
309 DriverFactoryBase::ShutdownDrivers();
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
310
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
311 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
312
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 /* 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
314 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
315
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
316 /* 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
317 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
318 _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
319 _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
320 _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
321 _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
322 _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
323 _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
324 _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
325 _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
326 _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
327 _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
328
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
329 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
330
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
331 /* 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
332 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
333 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
334
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
335 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
336 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
337 _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
338
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
339 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
340
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
341 /* 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
342 ResetWindowSystem();
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11079
diff changeset
343 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
344
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
345 /* 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
346 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
347 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
348 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
349 SetLocalCompany(COMPANY_SPECTATOR);
10152
2590e56e45f3 (svn r14339) -Fix (r13731): crash when loading the intro game failed
smatz <smatz@openttd.org>
parents: 10150
diff changeset
350 } 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
351 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
352 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
353
6231
a4e11dd2d7c6 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight <truelight@openttd.org>
parents: 6229
diff changeset
354 _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
355 _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
356
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
357 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
358
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
359 /* 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
360 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
361 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
362
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
363 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
364 {
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 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
366 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
367 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
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 }
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 _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
372
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 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
374 _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
375 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
376 _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
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 }
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
379 }
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
380
8268
ab53b3bf7100 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium <rubidium@openttd.org>
parents: 8265
diff changeset
381 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
382 #if defined(UNIX) && !defined(__MORPHOS__)
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
383 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
384 #endif
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 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
387 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
388 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
389 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
390 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
391 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
392 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
393 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
394 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
395 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
396 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
397 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
398 bool save_config = true;
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
399 #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
400 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
401 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
402 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
403 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
404 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
405 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
406 #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
407
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
408 _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
409 _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
410 _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
411 _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
412 _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
413
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
414 /* 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
415 * 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
416 * 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
417 * 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
418 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
419 #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
420 "f"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
421 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
422 ;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
423
6491
696f0e1b046e (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents: 6486
diff changeset
424 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
425
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
426 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
427 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
428 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
429 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
430 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
431 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
432 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
433 #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
434 case 'D':
10619
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
435 free(musicdriver);
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
436 free(sounddriver);
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
437 free(videodriver);
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
438 free(blitter);
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
439 musicdriver = strdup("null");
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
440 sounddriver = strdup("null");
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
441 videodriver = strdup("dedicated");
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
442 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
443 dedicated = true;
11190
e49bc8f3aa3b (svn r15543) -Change: allow the default debug level of 6 for a dedicated server to be overriden by -d (if used after -D).
rubidium <rubidium@openttd.org>
parents: 11148
diff changeset
444 SetDebugString("net=6");
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
445 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
446 /* 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
447 * 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
448 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
449 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
450 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
451 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
452 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
453 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
454 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
455 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
456 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
457 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
458 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
459 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
460 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
461 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
462 break;
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
463 #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
464 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
465 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
466 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
467 #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
468 CreateConsole();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
469 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
470 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
471 } break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
472 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
473 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
474 /* 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
475 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
476 _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
477 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
478 }
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
479 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
480 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
481 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
482 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
483 _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
484 _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
485
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
486 /* 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
487 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
488 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
489 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
490 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
491 }
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 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
494 }
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
495
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
496 _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
497 /* 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
498 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
499 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
500 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
501 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 '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
503 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
504 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
505 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
506 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
507 /* 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
508 * 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
509 * 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
510 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
511 FindGraphicsSets();
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
512 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
513 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
514 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
515 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
516
7408
53fa9a58449a (svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents: 7401
diff changeset
517 #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
518 /* 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
519 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
520 #endif
53fa9a58449a (svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents: 7401
diff changeset
521
6317
d5d3f3379eb0 (svn r9266) -Codechange: unify the retrieval of the base paths a little more.
rubidium <rubidium@openttd.org>
parents: 6309
diff changeset
522 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
523 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
524
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
525 #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
526 /* 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
527 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
528 DedicatedFork();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
529 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
530
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
531 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
532 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
533 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
534 CheckConfig();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
535 LoadFromHighScore();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
536
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
537 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
538 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
539 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
540
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
541 /* 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
542 * 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
543 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
544 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
545
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
546 #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
547 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
548 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
549 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
550 #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
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 /* 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
553 InitializeLanguagePacks();
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 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
556 InitializeScreenshotFormats();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
557
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
558 /* 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
559 InitializeAirports();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
560
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
561 /* 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
562 InitializeDynamicVariables();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
563
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
564 /* 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
565 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
566 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
567 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
568
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
569 /* 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
570 InitFreeType();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
571
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
572 /* 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
573 InitWindowSystem();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
574
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
575 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
576 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
577 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
578 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
579 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
580 }
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
581
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
582 /* 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
583 GfxInitPalettes();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
584
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
585 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
586 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
587 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
588 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
589 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
590 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
591
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
592 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
593
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 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
595 _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
596 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
597 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
598 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
599 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
600 }
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
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 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
603 _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
604 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
605 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
606 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
607 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
608 }
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
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 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
611 _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
612 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
613 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
614 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
615 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
616 }
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
617
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 _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
619 /* 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
620 _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
621
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
622 /* 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
623 _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
624
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
625 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
626
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
627 #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
628 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
629 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
630 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
631 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
632
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 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
634
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
635 ParseConnectionString(&not_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
636 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
637
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
638 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
639 }
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
640 #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
641
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
642 ScanNewGRFFiles();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
643
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
644 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
645
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
646 /* 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
647 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
648
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
649 /* 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
650 IConsoleInit();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
651 _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
652 InitializeGUI();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
653 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
654
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
655 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
656 WaitTillGeneratedWorld();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
657
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
658 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
659
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
660 #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
661 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
662 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
663 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
664 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
665 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
666
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
667 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
668 _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
669
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
670 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
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 (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
673 _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
674
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
675 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
676 _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
677 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
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 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
680 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
681
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
682 LoadIntroGame();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
683 _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
684 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
685 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
686 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
687 #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
688
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
689 _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
690
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
691 WaitTillSaved();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
692
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
693 /* 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
694 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
695 SaveToConfig();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
696 SaveToHighScore();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
697 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
698
9159
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
699 /* 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
700 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
701
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
702 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
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
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
705 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
706 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
707 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
708 _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
709 } 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
710 DoExitSave();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
711 _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
712 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
713 AskExitGame();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
714 }
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
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
717 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
718 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
719 if (b) {
11236
4b0715b41812 (svn r15590) -Fix (r15584): _screenshot_name is an array, not a char * pointer.
yexo <yexo@openttd.org>
parents: 11230
diff changeset
720 extern char _screenshot_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
721 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
722 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
723 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
724 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
725 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
726
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
727 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
728
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
729 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
730 {
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
731 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
732
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 /* 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
734 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
735 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
736 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
737 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
738 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
739
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
740 /* 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
741 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
742
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
743 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
744
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
745 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
746 _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
747 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
748
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
749 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
750
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
751 #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
752 /* 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
753 * 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
754 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
755 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
756 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
757 }
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
758 #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
759
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
760 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
761 }
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 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
764 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
765 _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
766
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
767 ResetGRFConfig(true);
11296
1b6a11831215 (svn r15645) -Fix (r12924)[FS#2612]: Add an EngineOverrideManager to give the term 'compatible newgrf' again some sense and to not crash because of trivial changes.
frosch <frosch@openttd.org>
parents: 11236
diff changeset
768 _engine_mngr.ResetToDefaultMapping();
6629
188437dffcff (svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas <belugas@openttd.org>
parents: 6626
diff changeset
769 _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
770 _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
771 _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
772
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
773 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
774 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
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 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
778 {
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
779 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
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
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
782 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
783 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
784 _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
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 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
787
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
788 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
789 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
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
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
792 void StartupCompanies();
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
793 void StartupDisasters();
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
794 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
795
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
796 /**
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
797 * 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
798 * 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
799 * 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
800 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
801 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
802 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
803 _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
804
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
805 /* 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
806 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
807 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
808 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
809 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
810 _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
811 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
812 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
813
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
814 /* 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
815 ResetWindowSystem();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
816
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11079
diff changeset
817 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
818
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
819 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
820
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
821 /* 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
822 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
823 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
824 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
825 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
826 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
827
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
828 _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
829
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
830 /* 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
831 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
832 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
833 StartupEngines();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
834 StartupDisasters();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
835
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
836 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
837 _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
838 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
839
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
840 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
841 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
842
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
843 /** 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
844 * 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
845 * 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
846 * @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
847 * @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
848 * @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
849 * @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
850 */
11222
d0328639d3a8 (svn r15575) -Codechange: Rename GameModes to GameMode and store _game_mode as GameMode instead of as byte.
yexo <yexo@openttd.org>
parents: 11193
diff changeset
851 bool SafeSaveOrLoad(const char *filename, int mode, GameMode 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
852 {
11222
d0328639d3a8 (svn r15575) -Codechange: Rename GameModes to GameMode and store _game_mode as GameMode instead of as byte.
yexo <yexo@openttd.org>
parents: 11193
diff changeset
853 GameMode ogm = _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
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 _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
856 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
857 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
858 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
859
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
860 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
861 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
862 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
863 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
864 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
865 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
866 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
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 default:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
869 _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
870 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
871 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
872 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
873
11223
4928ebb36453 (svn r15576) -Codechange: rename SwitchModes to SwitchMode and don't hardcode the values for that enum.
yexo <yexo@openttd.org>
parents: 11222
diff changeset
874 void SwitchToMode(SwitchMode new_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
875 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
876 #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
877 /* 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
878 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
879 /* 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
880 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
881 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
882 NetworkReboot();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
883 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
884 NetworkDisconnect();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
885 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
886 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
887
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
888 /* 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
889 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
890 /* 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
891 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
892 /* 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
893 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
894 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
895 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
896 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
897 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
898 NetworkServerStart();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
899 } 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
900 /* 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
901 _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
902 }
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 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
905 #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
906 /* 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
907 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
908
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
909 switch (new_mode) {
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
910 case SM_EDITOR: // Switch to scenario editor
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
911 MakeNewEditorWorld();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
912 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
913
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
914 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
915 #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
916 if (_network_server) {
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
917 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
918 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
919 #endif /* ENABLE_NETWORK */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
920 MakeNewGame(false);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
921 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
922
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
923 case SM_START_SCENARIO: // New Game --> Choose one of the preset scenarios
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
924 #ifdef ENABLE_NETWORK
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
925 if (_network_server) {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
926 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
927 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
928 #endif /* ENABLE_NETWORK */
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
929 StartScenario();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
930 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
931
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
932 case SM_LOAD: { // Load game, Play Scenario
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
933 ResetGRFConfig(true);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
934 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
935
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
936 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
937 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
938 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
939 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
940 } 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
941 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
942 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
943 }
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
944 /* Update the local company for a loaded game. It is either always
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11296
diff changeset
945 * company #1 (eg 0) or in the case of a dedicated server a spectator */
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
946 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
947 /* 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
948 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
949 /* 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
950 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
951 #ifdef ENABLE_NETWORK
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
952 if (_network_server) {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
953 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
954 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
955 #endif /* ENABLE_NETWORK */
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
956 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
957 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
958 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
959
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
960 case SM_START_HEIGHTMAP: // Load a heightmap and start a new game from it
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
961 #ifdef ENABLE_NETWORK
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
962 if (_network_server) {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
963 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
964 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
965 #endif /* ENABLE_NETWORK */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
966 MakeNewGame(true);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
967 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
968
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
969 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
970 SetLocalCompany(OWNER_NONE);
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
971
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
972 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
973 MarkWholeScreenDirty();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
974 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
975
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
976 case SM_LOAD_SCENARIO: { // Load scenario from scenario editor
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
977 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
978 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
979 _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
980 } 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
981 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
982 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
983 }
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 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
986
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
987 case SM_MENU: // Switch to game intro menu
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
988 LoadIntroGame();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
989 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
990
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
991 case SM_SAVE: // Save game
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
992 /* 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
993 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
994 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
995 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
996 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
997 } else {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
998 DeleteWindowById(WC_SAVELOAD, 0);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
999 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1000 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
1001 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1002
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
1003 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
1004 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
1005 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
1006 /* XXX: set date */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1007 MarkWholeScreenDirty();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1008 break;
11223
4928ebb36453 (svn r15576) -Codechange: rename SwitchModes to SwitchMode and don't hardcode the values for that enum.
yexo <yexo@openttd.org>
parents: 11222
diff changeset
1009
4928ebb36453 (svn r15576) -Codechange: rename SwitchModes to SwitchMode and don't hardcode the values for that enum.
yexo <yexo@openttd.org>
parents: 11222
diff changeset
1010 default: NOT_REACHED();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1011 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1012
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1013 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
1014 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
1015 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1016 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1017
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1018
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1019 /**
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1020 * State controlling game loop.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1021 * 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
1022 * That check is enforced in DoCommand.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1023 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1024 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
1025 {
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
1026 /* 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
1027 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
1028 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
1029 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
1030 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1031 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
1032
8303
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1033 ClearStorageChanges(false);
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1034
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1035 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
1036 RunTileLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1037 CallVehicleTicks();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1038 CallLandscapeTick();
8303
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1039 ClearStorageChanges(true);
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1040
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1041 CallWindowTickEvent();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1042 NewsLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1043 } 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
1044 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
1045 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
1046 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
1047 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
1048
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 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
1050 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
1051 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
1052 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
1053 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
1054 }
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
1055 } 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
1056
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 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
1058 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
1059 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
1060
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 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
1062 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
1063 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
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 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
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 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
1068 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
1069 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
1070 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
1071 }
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 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
1073 }
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
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 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
1076 } 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
1077
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 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
1079 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
1080 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
1081 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
1082 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
1083 }
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
1084 } 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
1085
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
1086 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
1087 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
1088 }
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
1089 }
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
1090 }
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
1091
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
1092 /* 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
1093 * 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
1094 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
1095 _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
1096
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1097 AnimateAnimatedTiles();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1098 IncreaseDate();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1099 RunTileLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1100 CallVehicleTicks();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1101 CallLandscapeTick();
8303
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1102 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
1103
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
1104 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
1105
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1106 CallWindowTickEvent();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1107 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
1108 _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
1109 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1110 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1111
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
1112 /** 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
1113 * 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
1114 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
1115 {
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
1116 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
1117
5977
03f33d102c56 (svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight <truelight@openttd.org>
parents: 5959
diff changeset
1118 #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
1119 /* 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
1120 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
1121 #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
1122
11193
22a093022e53 (svn r15546) -Fix [FS#2651]: keep_all_autosave ignored for dedicated servers/spectators.
rubidium <rubidium@openttd.org>
parents: 11190
diff changeset
1123 if (_settings_client.gui.keep_all_autosave) {
10533
53a8506c2079 (svn r14790) -Codechange: unify generation of default savegame/screenshot names (PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10516
diff changeset
1124 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
1125 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
1126 } else {
11619
e34ab4ed2a72 (svn r15999) -Codechange: VARDEF--;
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1127 static int _autosave_ctr = 0;
e34ab4ed2a72 (svn r15999) -Codechange: VARDEF--;
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1128
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
1129 /* 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
1130 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
1131
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
1132 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
1133 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1134
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1135 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
1136 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
1137 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
1138 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1139 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1140
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1141 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
1142 {
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
1143 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
1144
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
1145 /* 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
1146 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
1147 _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
1148 DoAutosave();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1149 RedrawAutosave();
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
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
1152 /* 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
1153 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
1154
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
1155 /* 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
1156 if (_switch_mode != SM_NONE) {
11223
4928ebb36453 (svn r15576) -Codechange: rename SwitchModes to SwitchMode and don't hardcode the values for that enum.
yexo <yexo@openttd.org>
parents: 11222
diff changeset
1157 SwitchToMode(_switch_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
1158 _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
1159 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1160
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1161 IncreaseSpriteLRU();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1162 InteractiveRandom();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1163
11230
4864c1e8957a (svn r15584) -Codechange: Move several variables from variables.h to more appropriate headers.
yexo <yexo@openttd.org>
parents: 11223
diff changeset
1164 extern int _caret_timer;
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 _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
1166 _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
1167 CursorTick();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1168
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1169 #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
1170 /* 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
1171 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
1172
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1173 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
1174 /* 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
1175 NetworkGameLoop();
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 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
1178 /* 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
1179 * 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
1180 _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
1181 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
1182 }
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
1183 /* 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
1184 StateGameLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1185 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1186 #else
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1187 StateGameLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1188 #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
1189
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7922
diff changeset
1190 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
1191
6231
a4e11dd2d7c6 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight <truelight@openttd.org>
parents: 6229
diff changeset
1192 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
1193
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1194 InputLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1195
10380
1bd9537f246c (svn r14631) -Add: support for Allegro as sound backend.
rubidium <rubidium@openttd.org>
parents: 10361
diff changeset
1196 _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
1197 MusicLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1198 }