(svn r26538) -Codechange: remove double accounting of the drivers

This commit is contained in:
rubidium
2014-04-28 21:06:51 +00:00
parent 39e2e5af1e
commit beb540ec55
24 changed files with 97 additions and 75 deletions

View File

@@ -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();
}