annotate src/openttd.cpp @ 11984:b6d3e583be86 draft

(svn r16390) -Codechange: move u.road to RoadVehicle.
author rubidium <rubidium@openttd.org>
date Fri, 22 May 2009 20:22:20 +0000
parents 6fae1efe3ae2
children e05790b0a6c6
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"
11983
6fae1efe3ae2 (svn r16389) -Codechange: use RoadVehicle instead of Vehicle where appropriate
rubidium <rubidium@openttd.org>
parents: 11982
diff changeset
33 #include "roadveh.h"
9336
5287277c4972 (svn r13228) -Codechange: split console.h.
rubidium <rubidium@openttd.org>
parents: 9334
diff changeset
34 #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
35 #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
36 #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
37 #include "network/network_func.h"
8790
5ef0059ccfc0 (svn r12501) -Codechange: split signs.h.
rubidium <rubidium@openttd.org>
parents: 8788
diff changeset
38 #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
39 #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
40 #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
41 #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
42 #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
43 #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
44 #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
45 #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
46 #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
47 #include "gamelog.h"
10960
a4e5b5d2837c (svn r15299) -Cleanup: remove many redundant includes
smatz <smatz@openttd.org>
parents: 10908
diff changeset
48 #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
49 #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
50 #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
51 #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
52 #include "rev.h"
10558
15517829eb17 (svn r14815) -Codechange: separate 'highscore' code from 'company' code
smatz <smatz@openttd.org>
parents: 10555
diff changeset
53 #include "highscore.h"
11830
c6abfb5a42bd (svn r16220) -Fix [FS#2862]: possible crashes when quiting OpenTTD or forcing resizes/redraws of the screen during map generation
rubidium <rubidium@openttd.org>
parents: 11730
diff changeset
54 #include "thread.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
55
6629
188437dffcff (svn r9850) -Codechange: Introduction of the Override/Substitute manager. Currently only used for newhouses.
belugas <belugas@openttd.org>
parents: 6626
diff changeset
56 #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
57
10960
a4e5b5d2837c (svn r15299) -Cleanup: remove many redundant includes
smatz <smatz@openttd.org>
parents: 10908
diff changeset
58 #include "town.h"
a4e5b5d2837c (svn r15299) -Cleanup: remove many redundant includes
smatz <smatz@openttd.org>
parents: 10908
diff changeset
59 #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
60
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
61 #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
62
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
63 #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
64
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
65 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
66
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
67 void CallLandscapeTick();
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
68 void IncreaseDate();
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
69 void DoPaletteAnimations();
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
70 void MusicLoop();
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
71 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
72 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
73 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
74
9358
12f4585b2124 (svn r13255) -Codechange: move _opt to _settings.
rubidium <rubidium@openttd.org>
parents: 9354
diff changeset
75 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
76 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
77 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
78 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
79
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
80 /**
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
81 * 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
82 * @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
83 * @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
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 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
86 {
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 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
88 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
89
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_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
91 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
92 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
93
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 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
95 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
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 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
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
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
100 /**
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
101 * 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
102 * @param s the string to print.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
103 * @note Does NEVER return.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
104 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
105 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
106 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
107 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
108 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
109
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_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
111 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
112 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
113
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
114 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
115 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
116
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
117 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
118 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
119 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
120
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
121 /**
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
122 * 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
123 * @param str the text to show.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
124 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
125 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
126 {
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_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
128 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
129 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
130 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
131 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
132 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
133 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
134
9069
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 * 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
137 */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
138 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
139 {
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
140 char buf[8192];
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
141 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
142
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
143 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
144 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
145 "\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 "\n"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
147 "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
148 " -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
149 " -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
150 " -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
151 " -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
152 " -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
153 " -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
154 " -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
155 " -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
156 " -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
157 " -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
158 " -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
159 " -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
160 #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
161 " -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
162 " -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
163 " -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
164 #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
165 " -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
166 #endif
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
167 #endif /* ENABLE_NETWORK */
10296
c8d9457bd5c5 (svn r14535) -Fix: Description of '-i' commandline option.
frosch <frosch@openttd.org>
parents: 10289
diff changeset
168 " -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
169 " (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
170 " 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
171 " 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
172 " -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
173 " -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
174 " -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
175 "\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
176 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
177 );
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
178
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
179 /* 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
180 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
181
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
182 /* 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
183 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
184
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
185 /* 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
186 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
187
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
188 /* 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
189 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
190 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
191 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
192
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
193 /* 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
194 * 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
195 #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
196 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
197 #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
198 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
199 #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
200 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
201
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
202
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
203 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
204 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
205 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
206 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
207 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
208 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
209
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
210 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
211 {
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 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
213 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
214 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
215 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
216 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
217 }
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
218 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
219
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
220 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
221 {
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11296
diff changeset
222 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
223
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
224 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
225 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
226 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
227
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
228 for (;;) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
229 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
230
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
231 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
232 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
233 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
234 s++;
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 != 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
236 /* 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
237 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
238 /* 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
239 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
240 }
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 (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
242 /* 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
243 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
244 /* 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
245 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
246 /* 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
247 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
248 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
249 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
250 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
251 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
252 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
253 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
254 }
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
255 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
256 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
257 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
258 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
259 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
260 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
261 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
262 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
263 } 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
264 /* 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
265 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
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 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
268 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
269
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
270 /**
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
271 * 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
272 * it in the 'res' parameter.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
273 * @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
274 * @param s the string to decompose.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
275 */
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
276 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
277 {
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
278 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
279 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
280 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
281 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
282 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
283
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
284 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
285 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
286 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
287
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
288 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
289 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
290 /* 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
291 _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
292 _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
293 _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
294 _industile_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
295 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
296
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
297
9159
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
298 /** 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
299 * 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
300 */
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
301 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
302 {
9159
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
303 IConsoleFree();
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
304
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
305 if (_network_available) NetworkShutDown(); // Shut down the network and close any open connections
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
306
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
307 DriverFactoryBase::ShutdownDrivers();
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
308
5659
78a7505fd513 (svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents: 5652
diff changeset
309 UnInitWindowSystem();
78a7505fd513 (svn r8119) -Fix (r8101): Uninitializing windows should be called before freeing dynamic variables as windows could use those variables during cleanup (eg WE_DESTROY calling GetStation(w->window_number).
Darkvater <Darkvater@openttd.org>
parents: 5652
diff changeset
310
11906
e56f17f057fe (svn r16306) -Fix [FS#2901] (r15027): Close all windows before unloading the AI system as closing the content-download window will rescan for AIs
yexo <yexo@openttd.org>
parents: 11887
diff changeset
311 /* stop the AI */
e56f17f057fe (svn r16306) -Fix [FS#2901] (r15027): Close all windows before unloading the AI system as closing the content-download window will rescan for AIs
yexo <yexo@openttd.org>
parents: 11887
diff changeset
312 AI::Uninitialize(false);
e56f17f057fe (svn r16306) -Fix [FS#2901] (r15027): Close all windows before unloading the AI system as closing the content-download window will rescan for AIs
yexo <yexo@openttd.org>
parents: 11887
diff changeset
313
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
314 /* 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
315 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
316
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
317 /* 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
318 GamelogReset();
11972
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
319 _town_pool.CleanPool();
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
320 _industry_pool.CleanPool();
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
321 _station_pool.CleanPool();
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
322 _roadstop_pool.CleanPool();
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
323 _vehicle_pool.CleanPool();
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
324 _sign_pool.CleanPool();
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
325 _order_pool.CleanPool();
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
326 _group_pool.CleanPool();
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
327 _cargopacket_pool.CleanPool();
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
328 _engine_pool.CleanPool();
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
329 _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
330
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
331 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
332
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
333 /* 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
334 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
335 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
336
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
337 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
338 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
339 _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
340
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
341 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
342
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
343 /* 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
344 ResetWindowSystem();
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11079
diff changeset
345 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
346
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
347 /* 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
348 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
349 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
350 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
351 SetLocalCompany(COMPANY_SPECTATOR);
10152
2590e56e45f3 (svn r14339) -Fix (r13731): crash when loading the intro game failed
smatz <smatz@openttd.org>
parents: 10150
diff changeset
352 } 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
353 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
354 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
355
11852
862dd1024fe7 (svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents: 11830
diff changeset
356 _pause_mode = PM_UNPAUSED;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
357 _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
358
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
359 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
360
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
361 /* 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
362 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
363 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
364
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
365 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
366 {
7edccbb67398 (svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents: 10619
diff changeset
367 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
368 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
369 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
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 }
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 _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
374
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 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
376 _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
377 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
378 _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
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 }
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
381 }
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
382
8268
ab53b3bf7100 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium <rubidium@openttd.org>
parents: 8265
diff changeset
383 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
384 #if defined(UNIX) && !defined(__MORPHOS__)
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
385 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
386 #endif
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 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
389 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
390 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
391 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
392 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
393 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
394 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
395 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
396 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
397 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
398 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
399 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
400 bool save_config = true;
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
401 #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
402 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
403 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
404 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
405 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
406 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
407 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
408 #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
409
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
410 _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
411 _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
412 _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
413 _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
414 _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
415
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
416 /* 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
417 * 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
418 * 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
419 * 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
420 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
421 #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
422 "f"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
423 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
424 ;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
425
6491
696f0e1b046e (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents: 6486
diff changeset
426 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
427
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
428 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
429 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
430 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
431 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
432 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
433 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
434 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
435 #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
436 case 'D':
10619
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
437 free(musicdriver);
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
438 free(sounddriver);
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
439 free(videodriver);
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
440 free(blitter);
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
441 musicdriver = strdup("null");
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
442 sounddriver = strdup("null");
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
443 videodriver = strdup("dedicated");
ee6aceffc966 (svn r14911) -Fix (r14909): -D did not work
peter1138 <peter1138@openttd.org>
parents: 10615
diff changeset
444 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
445 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
446 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
447 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
448 /* 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
449 * 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
450 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
451 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
452 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
453 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
454 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
455 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
456 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
457 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
458 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
459 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
460 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
461 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
462 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
463 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
464 break;
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
465 #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
466 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
467 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
468 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
469 #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
470 CreateConsole();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
471 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
472 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
473 } break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
474 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
475 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
476 /* 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
477 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
478 _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
479 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
480 }
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
481 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
482 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
483 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
484 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
485 _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
486 _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
487
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 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
489 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
490 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
491 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
492 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
493 }
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
494
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 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
496 }
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
497
6d3372e45a23 (svn r13859) -Fix: loading of TTD(Patch) savegames from the command line didn't work
smatz <smatz@openttd.org>
parents: 9729
diff changeset
498 _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
499 /* 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
500 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
501 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
502 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
503 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 '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
505 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
506 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
507 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
508 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
509 /* 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
510 * 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
511 * 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
512 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
513 FindGraphicsSets();
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
514 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
515 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
516 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
517 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
518
7408
53fa9a58449a (svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents: 7401
diff changeset
519 #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
520 /* 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
521 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
522 #endif
53fa9a58449a (svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
truelight <truelight@openttd.org>
parents: 7401
diff changeset
523
6317
d5d3f3379eb0 (svn r9266) -Codechange: unify the retrieval of the base paths a little more.
rubidium <rubidium@openttd.org>
parents: 6309
diff changeset
524 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
525 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
526
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 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
528 /* 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
529 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
530 DedicatedFork();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
531 #endif
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
532
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::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
534 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
535 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
536 CheckConfig();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
537 LoadFromHighScore();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
538
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
539 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
540 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
541 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
542
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
543 /* 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
544 * 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
545 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
546 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
547
5692
47e97da9c104 (svn r8155) -Fix: fixed compilation when --disable-network is in use
bjarni <bjarni@openttd.org>
parents: 5683
diff changeset
548 #if defined(ENABLE_NETWORK)
11634
bcc6cc0d7b33 (svn r16014) -Feature(-ish): allow binding to several IPs; [network]:server_bind_ip doesn't exist anymore. Add the IPs/hostnames to [server_bind_addresses]
rubidium <rubidium@openttd.org>
parents: 11619
diff changeset
549 if (dedicated_host) {
bcc6cc0d7b33 (svn r16014) -Feature(-ish): allow binding to several IPs; [network]:server_bind_ip doesn't exist anymore. Add the IPs/hostnames to [server_bind_addresses]
rubidium <rubidium@openttd.org>
parents: 11619
diff changeset
550 _network_bind_list.Clear();
bcc6cc0d7b33 (svn r16014) -Feature(-ish): allow binding to several IPs; [network]:server_bind_ip doesn't exist anymore. Add the IPs/hostnames to [server_bind_addresses]
rubidium <rubidium@openttd.org>
parents: 11619
diff changeset
551 *_network_bind_list.Append() = strdup(dedicated_host);
bcc6cc0d7b33 (svn r16014) -Feature(-ish): allow binding to several IPs; [network]:server_bind_ip doesn't exist anymore. Add the IPs/hostnames to [server_bind_addresses]
rubidium <rubidium@openttd.org>
parents: 11619
diff changeset
552 }
9420
ec47ec544964 (svn r13334) -Codechange: move the network settings variables from network/network_internal to settings.
rubidium <rubidium@openttd.org>
parents: 9413
diff changeset
553 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
554 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
555 #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
556
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
557 /* 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
558 InitializeLanguagePacks();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
559
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
560 /* 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
561 InitializeScreenshotFormats();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
562
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
563 /* 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
564 InitializeAirports();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
565
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
566 /* initialize 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
567 InitializeDynamicVariables();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
568
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
569 /* 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
570 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
571 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
572 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
573
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
574 /* 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
575 InitFreeType();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
576
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
577 /* 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
578 InitWindowSystem();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
579
11954
92364e306ac7 (svn r16358) -Fix (r16343): strdup doesn't like NULL
glx <glx@openttd.org>
parents: 11940
diff changeset
580 if (graphics_set == NULL && _ini_graphics_set != NULL) graphics_set = strdup(_ini_graphics_set);
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
581 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
582 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
583 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
584 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
585 }
11940
75b7687b5cc3 (svn r16343) -Fix (r16066): Invalid free on exit after changing base graphics set in game.
frosch <frosch@openttd.org>
parents: 11922
diff changeset
586 free(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
587
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
588 /* 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
589 GfxInitPalettes();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
590
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
591 DEBUG(misc, 1, "Loading blitter...");
11954
92364e306ac7 (svn r16358) -Fix (r16343): strdup doesn't like NULL
glx <glx@openttd.org>
parents: 11940
diff changeset
592 if (blitter == NULL && _ini_blitter != NULL) blitter = strdup(_ini_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
593 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
594 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
595 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
596 usererror("Failed to select requested blitter '%s'; does it exist?", blitter);
11940
75b7687b5cc3 (svn r16343) -Fix (r16066): Invalid free on exit after changing base graphics set in game.
frosch <frosch@openttd.org>
parents: 11922
diff changeset
597 free(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
598
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
599 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
600
11954
92364e306ac7 (svn r16358) -Fix (r16343): strdup doesn't like NULL
glx <glx@openttd.org>
parents: 11940
diff changeset
601 if (sounddriver == NULL && _ini_sounddriver != NULL) sounddriver = strdup(_ini_sounddriver);
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 _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
603 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
604 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
605 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
606 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
607 }
11940
75b7687b5cc3 (svn r16343) -Fix (r16066): Invalid free on exit after changing base graphics set in game.
frosch <frosch@openttd.org>
parents: 11922
diff changeset
608 free(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
609
11954
92364e306ac7 (svn r16358) -Fix (r16343): strdup doesn't like NULL
glx <glx@openttd.org>
parents: 11940
diff changeset
610 if (musicdriver == NULL && _ini_musicdriver != NULL) musicdriver = strdup(_ini_musicdriver);
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
611 _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
612 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
613 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
614 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
615 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
616 }
11940
75b7687b5cc3 (svn r16343) -Fix (r16066): Invalid free on exit after changing base graphics set in game.
frosch <frosch@openttd.org>
parents: 11922
diff changeset
617 free(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
618
11954
92364e306ac7 (svn r16358) -Fix (r16343): strdup doesn't like NULL
glx <glx@openttd.org>
parents: 11940
diff changeset
619 if (videodriver == NULL && _ini_videodriver != NULL) videodriver = strdup(_ini_videodriver);
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
620 _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
621 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
622 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
623 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
624 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
625 }
11940
75b7687b5cc3 (svn r16343) -Fix (r16066): Invalid free on exit after changing base graphics set in game.
frosch <frosch@openttd.org>
parents: 11922
diff changeset
626 free(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
627
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
628 _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
629 /* 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
630 _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
631
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
632 /* 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
633 _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
634
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
635 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
636
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
637 #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
638 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
639 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
640 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
641 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
642
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
643 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
644
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
645 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
646 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
647
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
648 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
649 }
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
650 #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
651
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
652 ScanNewGRFFiles();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
653
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
654 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
655
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
656 /* 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
657 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
658
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
659 /* 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
660 IConsoleInit();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
661 _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
662 InitializeGUI();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
663 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
664
11830
c6abfb5a42bd (svn r16220) -Fix [FS#2862]: possible crashes when quiting OpenTTD or forcing resizes/redraws of the screen during map generation
rubidium <rubidium@openttd.org>
parents: 11730
diff changeset
665 /* Take our initial lock on whatever we might want to do! */
c6abfb5a42bd (svn r16220) -Fix [FS#2862]: possible crashes when quiting OpenTTD or forcing resizes/redraws of the screen during map generation
rubidium <rubidium@openttd.org>
parents: 11730
diff changeset
666 _genworld_paint_mutex->BeginCritical();
c6abfb5a42bd (svn r16220) -Fix [FS#2862]: possible crashes when quiting OpenTTD or forcing resizes/redraws of the screen during map generation
rubidium <rubidium@openttd.org>
parents: 11730
diff changeset
667 _genworld_mapgen_mutex->BeginCritical();
c6abfb5a42bd (svn r16220) -Fix [FS#2862]: possible crashes when quiting OpenTTD or forcing resizes/redraws of the screen during map generation
rubidium <rubidium@openttd.org>
parents: 11730
diff changeset
668
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 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
670 WaitTillGeneratedWorld();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
671
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
672 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
673
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 #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
675 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
676 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
677 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
678 const char *company = NULL;
11956
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11954
diff changeset
679 uint16 rport = NETWORK_DEFAULT_PORT;
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11954
diff changeset
680 CompanyID join_as = 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
681
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
682 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
683
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
684 if (company != NULL) {
11956
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11954
diff changeset
685 join_as = (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
686
11956
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11954
diff changeset
687 if (join_as != COMPANY_SPECTATOR) {
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11954
diff changeset
688 join_as--;
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11954
diff changeset
689 if (join_as >= 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
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 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
692 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
693
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
694 LoadIntroGame();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
695 _switch_mode = SM_NONE;
11956
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11954
diff changeset
696 NetworkClientConnectGame(NetworkAddress(network_conn, rport), join_as);
5584
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 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
699 #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
700
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
701 _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
702
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
703 WaitTillSaved();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
704
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
705 /* 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
706 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
707 SaveToConfig();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
708 SaveToHighScore();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
709 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
710
9159
68da59de5396 (svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
smatz <smatz@openttd.org>
parents: 9154
diff changeset
711 /* 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
712 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
713
11940
75b7687b5cc3 (svn r16343) -Fix (r16066): Invalid free on exit after changing base graphics set in game.
frosch <frosch@openttd.org>
parents: 11922
diff changeset
714 free(_ini_graphics_set);
75b7687b5cc3 (svn r16343) -Fix (r16066): Invalid free on exit after changing base graphics set in game.
frosch <frosch@openttd.org>
parents: 11922
diff changeset
715 free(_ini_musicdriver);
75b7687b5cc3 (svn r16343) -Fix (r16066): Invalid free on exit after changing base graphics set in game.
frosch <frosch@openttd.org>
parents: 11922
diff changeset
716 free(_ini_sounddriver);
75b7687b5cc3 (svn r16343) -Fix (r16066): Invalid free on exit after changing base graphics set in game.
frosch <frosch@openttd.org>
parents: 11922
diff changeset
717 free(_ini_videodriver);
75b7687b5cc3 (svn r16343) -Fix (r16066): Invalid free on exit after changing base graphics set in game.
frosch <frosch@openttd.org>
parents: 11922
diff changeset
718 free(_ini_blitter);
11683
93d27bbd1397 (svn r16066) -Fix: another memory leak.
rubidium <rubidium@openttd.org>
parents: 11634
diff changeset
719
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
720 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
721 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
722
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
723 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
724 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
725 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
726 _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
727 } 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
728 DoExitSave();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
729 _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
730 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
731 AskExitGame();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
732 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
733 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
734
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
735 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
736 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
737 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
738 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
739 SetDParamStr(0, _screenshot_name);
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11683
diff changeset
740 ShowErrorMessage(INVALID_STRING_ID, STR_MESSAGE_SCREENSHOT_SUCCESSFULLY, 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
741 } else {
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11683
diff changeset
742 ShowErrorMessage(INVALID_STRING_ID, STR_ERROR_SCREENSHOT_FAILED, 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
743 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
744
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
745 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
746
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
747 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
748 {
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
749 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
750
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
751 /* 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
752 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
753 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
754 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
755 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
756 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
757
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
758 /* 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
759 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
760
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11913
diff changeset
761 Company *c = Company::Get(COMPANY_FIRST);
11913
f67b6243e05a (svn r16315) -Codechange: move the autorenew settings to a new CompanySettings struct
yexo <yexo@openttd.org>
parents: 11906
diff changeset
762 c->settings = _settings_client.company;
11887
f0409562d9e2 (svn r16287) -Fix: fix possible (in theory) desync related to autorenew settings
yexo <yexo@openttd.org>
parents: 11852
diff changeset
763
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
764 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
765
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
766 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
767 _current_company = _local_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
768
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
769 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
770
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
771 #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
772 /* 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
773 * 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
774 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
775 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
776 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
777 }
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
778 #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
779
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 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
781 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
782
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
783 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
784 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
785 _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
786
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
787 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
788 _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
789 _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
790 _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
791 _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
792
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
793 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
794 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
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
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
797 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
798 {
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
799 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
800 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
801
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
802 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
803 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
804 _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
805
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
806 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
807
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
808 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
809 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
810 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
811
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
812 void StartupCompanies();
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
813 void StartupDisasters();
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
814 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
815
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
816 /**
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
817 * 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
818 * 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
819 * 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
820 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
821 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
822 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
823 _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
824
6351
1dcf39ea9b9b (svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas <belugas@openttd.org>
parents: 6333
diff changeset
825 /* 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
826 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
827 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
828 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
829 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
830 _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
831 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
832 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
833
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
834 /* 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
835 ResetWindowSystem();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
836
11085
8da1855e9f14 (svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents: 11079
diff changeset
837 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
838
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
839 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
840
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
841 /* 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
842 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
843 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
844 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
845 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
846 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
847
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
848 _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
849
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
850 /* 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
851 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
852 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
853 StartupEngines();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
854 StartupDisasters();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
855
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
856 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
857 _current_company = _local_company;
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11913
diff changeset
858 Company *c = Company::Get(COMPANY_FIRST);
11913
f67b6243e05a (svn r16315) -Codechange: move the autorenew settings to a new CompanySettings struct
yexo <yexo@openttd.org>
parents: 11906
diff changeset
859 c->settings = _settings_client.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
860
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
861 MarkWholeScreenDirty();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
862 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
863
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
864 /** 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
865 * 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
866 * 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
867 * @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
868 * @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
869 * @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
870 * @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
871 */
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
872 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
873 {
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
874 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
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 _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
877 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
878 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
879 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
880
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
881 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
882 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
883 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
884 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
885 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
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 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
888
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
889 default:
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
890 _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
891 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
892 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
893 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
894
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
895 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
896 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
897 #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
898 /* 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
899 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
900 /* 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
901 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
902 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
903 NetworkReboot();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
904 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
905 NetworkDisconnect();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
906 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
907 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
908
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
909 /* 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
910 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
911 /* 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
912 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
913 /* 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
914 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
915 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
916 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
917 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
918 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
919 NetworkServerStart();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
920 } 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
921 /* 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
922 _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
923 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
924 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
925 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
926 #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
927 /* 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
928 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
929
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
930 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
931 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
932 MakeNewEditorWorld();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
933 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
934
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
935 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
936 #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
937 if (_network_server) {
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
938 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
939 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
940 #endif /* ENABLE_NETWORK */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
941 MakeNewGame(false);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
942 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
943
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
944 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
945 #ifdef ENABLE_NETWORK
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
946 if (_network_server) {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
947 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
948 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
949 #endif /* ENABLE_NETWORK */
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
950 StartScenario();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
951 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
952
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
953 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
954 ResetGRFConfig(true);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
955 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
956
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
957 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
958 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
959 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
960 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
961 } 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
962 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
963 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
964 }
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10195
diff changeset
965 /* 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
966 * 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
967 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
968 /* 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
969 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
970 /* Decrease pause counter (was increased from opening load dialog) */
11852
862dd1024fe7 (svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents: 11830
diff changeset
971 DoCommandP(0, PM_PAUSED_SAVELOAD, 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
972 #ifdef ENABLE_NETWORK
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
973 if (_network_server) {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
974 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
975 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
976 #endif /* ENABLE_NETWORK */
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
977 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
978 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
979 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
980
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
981 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
982 #ifdef ENABLE_NETWORK
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
983 if (_network_server) {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
984 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
985 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
986 #endif /* ENABLE_NETWORK */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
987 MakeNewGame(true);
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
988 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
989
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
990 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
991 SetLocalCompany(OWNER_NONE);
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
992
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
993 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
994 MarkWholeScreenDirty();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
995 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
996
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
997 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
998 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
999 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
1000 _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
1001 } 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
1002 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
1003 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
1004 }
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1005 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
1006 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1007
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
1008 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
1009 LoadIntroGame();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1010 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
1011
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
1012 case SM_SAVE: // Save game
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1013 /* 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
1014 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
1015 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
1016 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
1017 } else {
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1018 DeleteWindowById(WC_SAVELOAD, 0);
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 break;
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1021
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
1022 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
1023 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
1024 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
1025 /* XXX: set date */
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1026 MarkWholeScreenDirty();
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1027 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
1028
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
1029 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
1030 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1031
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1032 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
1033 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
1034 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1035 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1036
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1037
11972
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1038 #include "depot_base.h"
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1039 #include "autoreplace_base.h"
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1040 #include "waypoint.h"
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1041 #include "network/core/tcp_game.h"
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1042 #include "network/network_base.h"
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1043 /** Make sure everything is valid. Will be removed in future. */
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1044 static void CheckPools()
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1045 {
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1046 const Depot *d;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1047 FOR_ALL_DEPOTS(d) assert(IsRoadDepotTile(d->xy) || IsRailDepotTile(d->xy) || IsShipDepotTile(d->xy) || IsHangarTile(d->xy));
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1048 const Industry *i;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1049 FOR_ALL_INDUSTRIES(i) assert(IsValidTile(i->xy));
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1050 const Engine *e;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1051 FOR_ALL_ENGINES(e) assert(e->info.climates != 0);
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1052 const Order *o;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1053 FOR_ALL_ORDERS(o) assert(!o->IsType(OT_NOTHING));
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1054 const OrderList *ol;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1055 FOR_ALL_ORDER_LISTS(ol) assert(ol->GetNumOrders() != INVALID_VEH_ORDER_ID && ol->GetNumVehicles() != 0);
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1056 const Town *t;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1057 FOR_ALL_TOWNS(t) assert(IsValidTile(t->xy));
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1058 const Group *g;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1059 FOR_ALL_GROUPS(g) assert(g->owner != INVALID_OWNER);
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1060 const EngineRenew *er;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1061 FOR_ALL_ENGINE_RENEWS(er) assert(er->from != INVALID_ENGINE);
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1062 const Waypoint *wp;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1063 FOR_ALL_WAYPOINTS(wp) assert(IsValidTile(wp->xy));
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1064 const Company *c;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1065 FOR_ALL_COMPANIES(c) assert(c->name_1 != 0);
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1066 const CargoPacket *cp;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1067 FOR_ALL_CARGOPACKETS(cp) assert(cp->count != 0);
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1068 #ifdef ENABLE_NETWORK
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1069 const NetworkClientSocket *ncs;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1070 FOR_ALL_CLIENT_SOCKETS(ncs) assert(ncs->IsConnected());
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1071 const NetworkClientInfo *nci;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1072 FOR_ALL_CLIENT_INFOS(nci) assert(nci->client_id != INVALID_CLIENT_ID);
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1073 #endif
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1074 const Station *st;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1075 FOR_ALL_STATIONS(st) assert(IsValidTile(st->xy));
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1076 const RoadStop *rs;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1077 FOR_ALL_ROADSTOPS(rs) assert(IsValidTile(rs->xy));
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1078 const Sign *si;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1079 FOR_ALL_SIGNS(si) assert(si->owner != INVALID_OWNER);
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1080 const Vehicle *v;
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1081 FOR_ALL_VEHICLES(v) assert(v->type != VEH_INVALID);
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1082
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1083 FOR_ALL_ORDER_LISTS(ol) ol->DebugCheckSanity();
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1084 }
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1085
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1086
9069
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1087 /**
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1088 * State controlling game loop.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1089 * 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
1090 * That check is enforced in DoCommand.
249e64399da0 (svn r12921) -Codechange: coding style fixes and documentation updates.
rubidium <rubidium@openttd.org>
parents: 9057
diff changeset
1091 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1092 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
1093 {
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
1094 /* dont execute the state loop during pause */
11852
862dd1024fe7 (svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents: 11830
diff changeset
1095 if (_pause_mode != PM_UNPAUSED) {
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
1096 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
1097 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
1098 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1099 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
1100
11972
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1101 CheckPools();
fd10870d74d4 (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents: 11956
diff changeset
1102
8303
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1103 ClearStorageChanges(false);
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1104
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 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
1106 RunTileLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1107 CallVehicleTicks();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1108 CallLandscapeTick();
8303
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1109 ClearStorageChanges(true);
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1110
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1111 CallWindowTickEvent();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1112 NewsLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1113 } 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
1114 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
1115 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
1116 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
1117 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
1118
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
1119 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
1120 case VEH_ROAD: {
11983
6fae1efe3ae2 (svn r16389) -Codechange: use RoadVehicle instead of Vehicle where appropriate
rubidium <rubidium@openttd.org>
parents: 11982
diff changeset
1121 extern byte GetRoadVehLength(const RoadVehicle *v);
11984
b6d3e583be86 (svn r16390) -Codechange: move u.road to RoadVehicle.
rubidium <rubidium@openttd.org>
parents: 11983
diff changeset
1122 if (GetRoadVehLength((RoadVehicle *)v) != ((RoadVehicle *)v)->cached_veh_length) {
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
1123 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
1124 }
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
1125 } 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
1126
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
1127 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
1128 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
1129 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
1130
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
1131 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
1132 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
1133 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
1134
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
1135 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
1136
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
1137 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
1138 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
1139 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
1140 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
1141 }
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
1142 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
1143 }
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
1144
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
1145 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
1146 } 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
1147
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
1148 case VEH_AIRCRAFT: {
11981
cf1aad9b971c (svn r16387) -Codechange: use Aircraft instead of Vehicle where appropriate
rubidium <rubidium@openttd.org>
parents: 11972
diff changeset
1149 Aircraft *a = (Aircraft *)v;
11982
9add5306a01e (svn r16388) -Codechange: move u.air to Aircraft
rubidium <rubidium@openttd.org>
parents: 11981
diff changeset
1150 uint speed = a->cached_max_speed;
11981
cf1aad9b971c (svn r16387) -Codechange: use Aircraft instead of Vehicle where appropriate
rubidium <rubidium@openttd.org>
parents: 11972
diff changeset
1151 UpdateAircraftCache(a);
11982
9add5306a01e (svn r16388) -Codechange: move u.air to Aircraft
rubidium <rubidium@openttd.org>
parents: 11981
diff changeset
1152 if (speed != a->cached_max_speed) {
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
1153 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
1154 }
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
1155 } 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
1156
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
1157 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
1158 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
1159 }
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
1160 }
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
1161 }
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
1162
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
1163 /* 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
1164 * 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
1165 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
1166 _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
1167
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1168 AnimateAnimatedTiles();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1169 IncreaseDate();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1170 RunTileLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1171 CallVehicleTicks();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1172 CallLandscapeTick();
8303
0ab35f1b5949 (svn r11867) -Fix: do not reset changes to persistent storages during world generation.
rubidium <rubidium@openttd.org>
parents: 8291
diff changeset
1173 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
1174
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
1175 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
1176
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1177 CallWindowTickEvent();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1178 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
1179 _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
1180 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1181 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1182
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
1183 /** 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
1184 * 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
1185 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
1186 {
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
1187 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
1188
5977
03f33d102c56 (svn r8675) [PSP] -Fix: don't autosave in networking for PSP, to time expensive
truelight <truelight@openttd.org>
parents: 5959
diff changeset
1189 #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
1190 /* 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
1191 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
1192 #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
1193
11193
22a093022e53 (svn r15546) -Fix [FS#2651]: keep_all_autosave ignored for dedicated servers/spectators.
rubidium <rubidium@openttd.org>
parents: 11190
diff changeset
1194 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
1195 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
1196 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
1197 } else {
11619
e34ab4ed2a72 (svn r15999) -Codechange: VARDEF--;
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1198 static int _autosave_ctr = 0;
e34ab4ed2a72 (svn r15999) -Codechange: VARDEF--;
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
1199
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
1200 /* 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
1201 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
1202
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
1203 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
1204 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1205
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1206 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
1207 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
1208 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
1209 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1210 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1211
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6231
diff changeset
1212 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
1213 {
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
1214 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
1215
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
1216 /* 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
1217 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
1218 _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
1219 DoAutosave();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1220 RedrawAutosave();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1221 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1222
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
1223 /* 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
1224 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
1225
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
1226 /* 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
1227 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
1228 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
1229 _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
1230 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1231
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1232 IncreaseSpriteLRU();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1233 InteractiveRandom();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1234
11230
4864c1e8957a (svn r15584) -Codechange: Move several variables from variables.h to more appropriate headers.
yexo <yexo@openttd.org>
parents: 11223
diff changeset
1235 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
1236 _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
1237 _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
1238 CursorTick();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1239
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1240 #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
1241 /* 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
1242 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
1243
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1244 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
1245 /* 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
1246 NetworkGameLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1247 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1248 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
1249 /* 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
1250 * We do this here, because it means that the network is really closed */
11956
6ec97548e188 (svn r16360) -Codechange: don't use _network_playas as a 'second' _local_company, but only as a storage location for the company you want to join in MP.
rubidium <rubidium@openttd.org>
parents: 11954
diff changeset
1251 NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), 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
1252 }
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
1253 /* 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
1254 StateGameLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1255 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1256 #else
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1257 StateGameLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1258 #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
1259
11852
862dd1024fe7 (svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents: 11830
diff changeset
1260 if (!_pause_mode && 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
1261
11852
862dd1024fe7 (svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents: 11830
diff changeset
1262 if (!_pause_mode || _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
1263
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1264 InputLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1265
10380
1bd9537f246c (svn r14631) -Add: support for Allegro as sound backend.
rubidium <rubidium@openttd.org>
parents: 10361
diff changeset
1266 _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
1267 MusicLoop();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1268 }