src/settings_gui.cpp
branchnoai
changeset 9545 179f651eb116
parent 9382 509365aac243
child 9574 698395509d12
--- a/src/settings_gui.cpp	Sun Mar 25 23:39:05 2007 +0000
+++ b/src/settings_gui.cpp	Sun Mar 25 23:51:30 2007 +0000
@@ -369,6 +369,23 @@
 	}
 }
 
+/**
+ * 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 {