From 45e788d524b4ce088b1f3e4ba27ed3a5340fdcda Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 25 Mar 2007 19:21:22 +0000 Subject: (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked. --- src/settings_gui.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/settings_gui.cpp') diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index a536ad396..bfe3d54f9 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -369,6 +369,23 @@ void SetDifficultyLevel(int mode, GameOptions *gm_opt) } } +/** + * Checks the difficulty levels read from the configuration and + * forces them to be correct when invalid. + */ +void CheckDifficultyLevels() +{ + if (_opt_newgame.diff_level != 3) { + SetDifficultyLevel(_opt_newgame.diff_level, &_opt_newgame); + } else { + for (uint i = 0; i < GAME_DIFFICULTY_NUM; i++) { + int *diff = ((int*)&_opt_newgame.diff) + i; + *diff = clamp(*diff, _game_setting_info[i].min, _game_setting_info[i].max); + *diff -= *diff % _game_setting_info[i].step; + } + } +} + extern void StartupEconomy(); enum { -- cgit v1.2.3-54-g00ecf