changeset 14800:ad960c31f4aa draft

(svn r19389) -Fix [FS3676]: only show the "No AIs available" error message when explicitly changing the number of AI opponents
author yexo <yexo@openttd.org>
date Fri, 12 Mar 2010 01:37:41 +0000
parents 9b6ca5d6d282
children c4285a663dbf
files src/settings.cpp src/table/settings.h
diffstat 2 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -905,14 +905,6 @@
 		_settings_game.difficulty.diff_level = 3;
 	}
 
-	if (((_game_mode == GM_MENU) ? _settings_newgame.difficulty : _settings_game.difficulty).max_no_competitors != 0 &&
-#ifdef ENABLE_AI
-			AI::GetInfoList()->size() == 0 &&
-#endif /* ENABLE_AI */
-			(!_networking || _network_server)) {
-		ShowErrorMessage(STR_WARNING_NO_SUITABLE_AI, INVALID_STRING_ID, WL_CRITICAL);
-	}
-
 	/* If we are a network-client, update the difficult setting (if it is open).
 	 * Use this instead of just dirtying the window because we need to load in
 	 * the new difficulty settings */
@@ -935,6 +927,19 @@
 	return DifficultyChange(i);
 }
 
+static bool MaxNoAIsChange(int32 i)
+{
+	if (((_game_mode == GM_MENU) ? _settings_newgame.difficulty : _settings_game.difficulty).max_no_competitors != 0 &&
+#ifdef ENABLE_AI
+			AI::GetInfoList()->size() == 0 &&
+#endif /* ENABLE_AI */
+			(!_networking || _network_server)) {
+		ShowErrorMessage(STR_WARNING_NO_SUITABLE_AI, INVALID_STRING_ID, WL_CRITICAL);
+	}
+
+	return DifficultyChange(i);
+}
+
 /**
  * Check whether the road side may be changed.
  * @param p1 unused
--- a/src/table/settings.h
+++ b/src/table/settings.h
@@ -31,6 +31,7 @@
 static bool DifficultyReset(int32 level);
 static bool DifficultyChange(int32);
 static bool DifficultyNoiseChange(int32 i);
+static bool MaxNoAIsChange(int32 i);
 static bool CheckRoadSide(int p1);
 static int32 ConvertLandscape(const char *value);
 static bool CheckFreeformEdges(int32 p1);
@@ -336,7 +337,7 @@
 	/***************************************************************************/
 	/* Saved settings variables. */
 	/* Do not ADD or REMOVE something in this "difficulty.XXX" table or before it. It breaks savegame compatability. */
-	 SDT_CONDVAR(GameSettings, difficulty.max_no_competitors,        SLE_UINT8, 97, SL_MAX_VERSION, 0, 0,     0,0,MAX_COMPANIES-1,1,STR_NULL,                                  DifficultyChange),
+	 SDT_CONDVAR(GameSettings, difficulty.max_no_competitors,        SLE_UINT8, 97, SL_MAX_VERSION, 0, 0,     0,0,MAX_COMPANIES-1,1,STR_NULL,                                  MaxNoAIsChange),
 	SDT_CONDNULL(                                                            1, 97, 109),
 	 SDT_CONDVAR(GameSettings, difficulty.number_towns,              SLE_UINT8, 97, SL_MAX_VERSION, 0,NG,     2,     0,      4,  1, STR_NUM_VERY_LOW,                          DifficultyChange),
 	 SDT_CONDVAR(GameSettings, difficulty.number_industries,         SLE_UINT8, 97, SL_MAX_VERSION, 0,NG,     4,     0,      4,  1, STR_NONE,                                  DifficultyChange),