diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/openttd.cpp | 58 | ||||
-rw-r--r-- | src/settings.cpp | 10 |
2 files changed, 25 insertions, 43 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp index 3d7bdc094..cb2865842 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -531,29 +531,6 @@ int ttd_main(int argc, char *argv[]) CheckConfig(); LoadFromHighScore(); - - /* override config? */ - if (!StrEmpty(graphics_set)) { - free(_ini_graphics_set); - _ini_graphics_set = graphics_set; - } - if (!StrEmpty(musicdriver)) { - free(_ini_musicdriver); - _ini_musicdriver = musicdriver; - } - if (!StrEmpty(sounddriver)) { - free(_ini_sounddriver); - _ini_sounddriver = sounddriver; - } - if (!StrEmpty(videodriver)) { - free(_ini_videodriver); - _ini_videodriver = videodriver; - } - if (!StrEmpty(blitter)) { - free(_ini_blitter); - _ini_blitter = blitter; - } - if (resolution.width != 0) { _cur_resolution = resolution; } 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; @@ -592,42 +569,47 @@ int ttd_main(int argc, char *argv[]) /* This must be done early, since functions use the InvalidateWindow* calls */ InitWindowSystem(); - if (!SetGraphicsSet(_ini_graphics_set)) { - StrEmpty(_ini_graphics_set) ? + if (graphics_set == NULL) graphics_set = _ini_graphics_set; + if (!SetGraphicsSet(graphics_set)) { + StrEmpty(graphics_set) ? usererror("Failed to find a graphics set. Please acquire a graphics set for OpenTTD.") : - usererror("Failed to select requested graphics set '%s'", _ini_graphics_set); + usererror("Failed to select requested graphics set '%s'", graphics_set); } /* Initialize game palette */ GfxInitPalettes(); DEBUG(misc, 1, "Loading blitter..."); - if (BlitterFactoryBase::SelectBlitter(_ini_blitter) == NULL) - StrEmpty(_ini_blitter) ? + if (blitter == NULL) blitter = _ini_blitter; + if (BlitterFactoryBase::SelectBlitter(blitter) == NULL) + StrEmpty(blitter) ? usererror("Failed to autoprobe blitter") : - usererror("Failed to select requested blitter '%s'; does it exist?", _ini_blitter); + usererror("Failed to select requested blitter '%s'; does it exist?", blitter); DEBUG(driver, 1, "Loading drivers..."); - _sound_driver = (SoundDriver*)SoundDriverFactoryBase::SelectDriver(_ini_sounddriver, Driver::DT_SOUND); + if (sounddriver == NULL) sounddriver = _ini_sounddriver; + _sound_driver = (SoundDriver*)SoundDriverFactoryBase::SelectDriver(sounddriver, Driver::DT_SOUND); if (_sound_driver == NULL) { - StrEmpty(_ini_sounddriver) ? + StrEmpty(sounddriver) ? usererror("Failed to autoprobe sound driver") : - usererror("Failed to select requested sound driver '%s'", _ini_sounddriver); + usererror("Failed to select requested sound driver '%s'", sounddriver); } - _music_driver = (MusicDriver*)MusicDriverFactoryBase::SelectDriver(_ini_musicdriver, Driver::DT_MUSIC); + if (musicdriver == NULL) musicdriver = _ini_musicdriver; + _music_driver = (MusicDriver*)MusicDriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC); if (_music_driver == NULL) { - StrEmpty(_ini_musicdriver) ? + StrEmpty(musicdriver) ? usererror("Failed to autoprobe music driver") : - usererror("Failed to select requested music driver '%s'", _ini_musicdriver); + usererror("Failed to select requested music driver '%s'", musicdriver); } - _video_driver = (VideoDriver*)VideoDriverFactoryBase::SelectDriver(_ini_videodriver, Driver::DT_VIDEO); + if (videodriver == NULL) videodriver = _ini_videodriver; + _video_driver = (VideoDriver*)VideoDriverFactoryBase::SelectDriver(videodriver, Driver::DT_VIDEO); if (_video_driver == NULL) { - StrEmpty(_ini_videodriver) ? + StrEmpty(videodriver) ? usererror("Failed to autoprobe video driver") : - usererror("Failed to select requested video driver '%s'", _ini_videodriver); + usererror("Failed to select requested video driver '%s'", videodriver); } _savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING; diff --git a/src/settings.cpp b/src/settings.cpp index 072f04322..829a4b420 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1206,11 +1206,11 @@ static const SettingDescGlobVarList _misc_settings[] = { SDTG_MMANY("display_opt", SLE_UINT8, S, 0, _display_opt, (1 << DO_SHOW_TOWN_NAMES | 1 << DO_SHOW_STATION_NAMES | 1 << DO_SHOW_SIGNS | 1 << DO_FULL_ANIMATION | 1 << DO_FULL_DETAIL | 1 << DO_WAYPOINTS), "SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION||FULL_DETAIL|WAYPOINTS", STR_NULL, NULL), SDTG_BOOL("news_ticker_sound", S, 0, _news_ticker_sound, true, STR_NULL, NULL), SDTG_BOOL("fullscreen", S, 0, _fullscreen, false, STR_NULL, NULL), - SDTG_STR("graphicsset", SLE_STRQ,C|S,0, _ini_graphics_set, NULL, STR_NULL, NULL), - SDTG_STR("videodriver", SLE_STRQ,C|S,0, _ini_videodriver, NULL, STR_NULL, NULL), - SDTG_STR("musicdriver", SLE_STRQ,C|S,0, _ini_musicdriver, NULL, STR_NULL, NULL), - SDTG_STR("sounddriver", SLE_STRQ,C|S,0, _ini_sounddriver, NULL, STR_NULL, NULL), - SDTG_STR("blitter", SLE_STRQ,C|S,0, _ini_blitter, NULL, STR_NULL, NULL), + SDTG_STR("graphicsset", SLE_STRQ, S, 0, _ini_graphics_set, NULL, STR_NULL, NULL), + SDTG_STR("videodriver", SLE_STRQ, S, 0, _ini_videodriver, NULL, STR_NULL, NULL), + SDTG_STR("musicdriver", SLE_STRQ, S, 0, _ini_musicdriver, NULL, STR_NULL, NULL), + SDTG_STR("sounddriver", SLE_STRQ, S, 0, _ini_sounddriver, NULL, STR_NULL, NULL), + SDTG_STR("blitter", SLE_STRQ, S, 0, _ini_blitter, NULL, STR_NULL, NULL), SDTG_STR("language", SLE_STRB, S, 0, _dynlang.curr_file, NULL, STR_NULL, NULL), SDTG_CONDLIST("resolution", SLE_INT, 2, S, 0, _cur_resolution, "640,480", STR_NULL, NULL, 0, SL_MAX_VERSION), // workaround for implicit lengthof() in SDTG_LIST SDTG_STR("screenshot_format",SLE_STRB, S, 0, _screenshot_format_name,NULL, STR_NULL, NULL), |