summaryrefslogtreecommitdiff
path: root/src/settings_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-03-25 19:21:22 +0000
committerrubidium <rubidium@openttd.org>2007-03-25 19:21:22 +0000
commit45e788d524b4ce088b1f3e4ba27ed3a5340fdcda (patch)
tree42c2659d5af4c40e76cdb608d997f13e633de45d /src/settings_gui.cpp
parent1a70cf53ff1890eaef5652975d0c16857ed9ecbb (diff)
downloadopenttd-45e788d524b4ce088b1f3e4ba27ed3a5340fdcda.tar.xz
(svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
Diffstat (limited to 'src/settings_gui.cpp')
-rw-r--r--src/settings_gui.cpp17
1 files changed, 17 insertions, 0 deletions
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 {