src/settings_gui.cpp
branchnoai
changeset 9545 179f651eb116
parent 9382 509365aac243
child 9574 698395509d12
equal deleted inserted replaced
9544:54705d209c44 9545:179f651eb116
   364 
   364 
   365 	gm_opt->diff_level = mode;
   365 	gm_opt->diff_level = mode;
   366 	if (mode != 3) { // not custom
   366 	if (mode != 3) { // not custom
   367 		for (i = 0; i != GAME_DIFFICULTY_NUM; i++)
   367 		for (i = 0; i != GAME_DIFFICULTY_NUM; i++)
   368 			((int*)&gm_opt->diff)[i] = _default_game_diff[mode][i];
   368 			((int*)&gm_opt->diff)[i] = _default_game_diff[mode][i];
       
   369 	}
       
   370 }
       
   371 
       
   372 /**
       
   373  * Checks the difficulty levels read from the configuration and
       
   374  * forces them to be correct when invalid.
       
   375  */
       
   376 void CheckDifficultyLevels()
       
   377 {
       
   378 	if (_opt_newgame.diff_level != 3) {
       
   379 		SetDifficultyLevel(_opt_newgame.diff_level, &_opt_newgame);
       
   380 	} else {
       
   381 		for (uint i = 0; i < GAME_DIFFICULTY_NUM; i++) {
       
   382 			int *diff = ((int*)&_opt_newgame.diff) + i;
       
   383 			*diff = clamp(*diff, _game_setting_info[i].min, _game_setting_info[i].max);
       
   384 			*diff -= *diff % _game_setting_info[i].step;
       
   385 		}
   369 	}
   386 	}
   370 }
   387 }
   371 
   388 
   372 extern void StartupEconomy();
   389 extern void StartupEconomy();
   373 
   390