summaryrefslogtreecommitdiff
path: root/src/openttd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-04-28 21:06:51 +0000
committerrubidium <rubidium@openttd.org>2014-04-28 21:06:51 +0000
commitb476086c394c6bcf893f292ef67565ef2b5496a2 (patch)
tree7bbdfcc4597cae1378070d82c5da36c8668171e0 /src/openttd.cpp
parent3b634b628c8b8ce30cdd11d38a38cf2f455a1c73 (diff)
downloadopenttd-b476086c394c6bcf893f292ef67565ef2b5496a2.tar.xz
(svn r26538) -Codechange: remove double accounting of the drivers
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r--src/openttd.cpp35
1 files changed, 10 insertions, 25 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 2d5b06e73..f289545ec 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -97,7 +97,7 @@ void CDECL usererror(const char *s, ...)
va_end(va);
ShowOSErrorBox(buf, false);
- if (_video_driver != NULL) _video_driver->Stop();
+ if (VideoDriver::GetInstance() != NULL) VideoDriver::GetInstance()->Stop();
exit(1);
}
@@ -343,7 +343,7 @@ static void LoadIntroGame(bool load_newgrfs = true)
CheckForMissingGlyphs();
/* Play main theme */
- if (_music_driver->IsSongPlaying()) ResetMusic();
+ if (MusicDriver::GetInstance()->IsSongPlaying()) ResetMusic();
}
void MakeNewgameSettingsLive()
@@ -436,7 +436,7 @@ struct AfterNewGRFScan : NewGRFScanCallback {
*save_config_ptr = save_config;
/* restore saved music volume */
- _music_driver->SetVolume(_settings_client.music.music_vol);
+ MusicDriver::GetInstance()->SetVolume(_settings_client.music.music_vol);
if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear;
if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
@@ -775,12 +775,7 @@ int openttd_main(int argc, char *argv[])
free(blitter);
if (videodriver == NULL && _ini_videodriver != NULL) videodriver = stredup(_ini_videodriver);
- _video_driver = (VideoDriver*)DriverFactoryBase::SelectDriver(videodriver, Driver::DT_VIDEO);
- if (_video_driver == NULL) {
- StrEmpty(videodriver) ?
- usererror("Failed to autoprobe video driver") :
- usererror("Failed to select requested video driver '%s'", videodriver);
- }
+ DriverFactoryBase::SelectDriver(videodriver, Driver::DT_VIDEO);
free(videodriver);
InitializeSpriteSorter();
@@ -811,7 +806,7 @@ int openttd_main(int argc, char *argv[])
goto exit_bootstrap;
}
- _video_driver->ClaimMousePointer();
+ VideoDriver::GetInstance()->ClaimMousePointer();
/* initialize screenshot formats */
InitializeScreenshotFormats();
@@ -843,21 +838,11 @@ int openttd_main(int argc, char *argv[])
free(music_set);
if (sounddriver == NULL && _ini_sounddriver != NULL) sounddriver = stredup(_ini_sounddriver);
- _sound_driver = (SoundDriver*)DriverFactoryBase::SelectDriver(sounddriver, Driver::DT_SOUND);
- if (_sound_driver == NULL) {
- StrEmpty(sounddriver) ?
- usererror("Failed to autoprobe sound driver") :
- usererror("Failed to select requested sound driver '%s'", sounddriver);
- }
+ DriverFactoryBase::SelectDriver(sounddriver, Driver::DT_SOUND);
free(sounddriver);
if (musicdriver == NULL && _ini_musicdriver != NULL) musicdriver = stredup(_ini_musicdriver);
- _music_driver = (MusicDriver*)DriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC);
- if (_music_driver == NULL) {
- StrEmpty(musicdriver) ?
- usererror("Failed to autoprobe music driver") :
- usererror("Failed to select requested music driver '%s'", musicdriver);
- }
+ DriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC);
free(musicdriver);
/* Take our initial lock on whatever we might want to do! */
@@ -875,7 +860,7 @@ int openttd_main(int argc, char *argv[])
ScanNewGRFFiles(scanner);
scanner = NULL;
- _video_driver->MainLoop();
+ VideoDriver::GetInstance()->MainLoop();
WaitTillSaved();
@@ -943,7 +928,7 @@ static void MakeNewGameDone()
SettingsDisableElrail(_settings_game.vehicle.disable_elrails);
/* In a dedicated server, the server does not play */
- if (!_video_driver->HasGUI()) {
+ if (!VideoDriver::GetInstance()->HasGUI()) {
SetLocalCompany(COMPANY_SPECTATOR);
if (_settings_client.gui.pause_on_newgame) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
IConsoleCmdExec("exec scripts/game_start.scr 0");
@@ -1509,6 +1494,6 @@ void GameLoop()
InputLoop();
- _sound_driver->MainLoop();
+ SoundDriver::GetInstance()->MainLoop();
MusicLoop();
}