summaryrefslogtreecommitdiff
path: root/src/openttd.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-05-08 23:26:17 +0000
committersmatz <smatz@openttd.org>2008-05-08 23:26:17 +0000
commit5e51833ee5b6ca7db5c529c894bdac2bba49fbd8 (patch)
tree628a45bcfaef9713dcc41143b5bbb8485228b100 /src/openttd.cpp
parent2ba05f898759269ba72b2ffd73aed7268e0ff56e (diff)
downloadopenttd-5e51833ee5b6ca7db5c529c894bdac2bba49fbd8.tar.xz
(svn r13022) -Fix: driver list wasn't freed, replace by statically allocated one
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r--src/openttd.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index dd3448543..c07ca1db8 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -288,8 +288,20 @@ static void InitializeDynamicVariables()
}
-static void UnInitializeGame()
+/** Unitializes drivers, frees allocated memory, cleans pools, ...
+ * Generally, prepares the game for shutting down
+ */
+static void ShutdownGame()
{
+ /* stop the AI */
+ AI_Uninitialize();
+
+ IConsoleFree();
+
+ if (_network_available) NetworkShutDown(); // Shut down the network and close any open connections
+
+ DriverFactoryBase::ShutdownDrivers();
+
UnInitWindowSystem();
/* Uninitialize airport state machines */
@@ -310,6 +322,9 @@ static void UnInitializeGame()
free((void*)_industry_sort);
free(_config_file);
+
+ /* Close all and any open filehandles */
+ FioCloseAll();
}
static void LoadIntroGame()
@@ -623,13 +638,6 @@ int ttd_main(int argc, char *argv[])
_video_driver->MainLoop();
WaitTillSaved();
- IConsoleFree();
-
- if (_network_available) NetworkShutDown(); // Shut down the network and close any open connections
-
- _video_driver->Stop();
- _music_driver->Stop();
- _sound_driver->Stop();
/* only save config if we have to */
if (save_config) {
@@ -637,14 +645,8 @@ int ttd_main(int argc, char *argv[])
SaveToHighScore();
}
- /* Reset windowing system and free config file */
- UnInitializeGame();
-
- /* stop the AI */
- AI_Uninitialize();
-
- /* Close all and any open filehandles */
- FioCloseAll();
+ /* Reset windowing system, stop drivers, free used memory, ... */
+ ShutdownGame();
return 0;
}