Changeset - r17817:8dc818f57e26
[Not reviewed]
master
0 3 0
frosch - 13 years ago 2011-07-02 12:58:37
frosch@openttd.org
(svn r22618) -Fix [FS#4653]: When changing difficulty settings over the network, do not just reopen the difficulty window if any game options window is opened; instead invalidate them properly.
3 files changed with 16 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/settings.cpp
Show inline comments
 
@@ -1006,15 +1006,13 @@ static bool DifficultyChange(int32)
 
		_settings_game.difficulty.diff_level = 3;
 
	}
 

	
 
	/* 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 */
 
	if (_networking && FindWindowById(WC_GAME_OPTIONS, 0) != NULL) {
 
		ShowGameDifficulty();
 
	}
 
	if (_networking) InvalidateWindowClassesData(WC_GAME_OPTIONS, GOID_DIFFICULTY_CHANGED);
 

	
 
	return true;
 
}
 

	
 
static bool DifficultyNoiseChange(int32 i)
 
{
src/settings_gui.cpp
Show inline comments
 
@@ -656,27 +656,25 @@ public:
 
	static const uint WIDGETS_PER_DIFFICULTY = 3;
 

	
 
	GameDifficultyWindow(const WindowDesc *desc) : Window()
 
	{
 
		this->InitNested(desc);
 

	
 
		/* Copy current settings (ingame or in intro) to temporary holding place
 
		 * change that when setting stuff, copy back on clicking 'OK' */
 
		this->opt_mod_temp = GetGameSettings();
 
		/* Setup disabled buttons when creating window
 
		 * disable all other difficulty buttons during gameplay except for 'custom' */
 
		this->SetWidgetsDisabledState(_game_mode != GM_MENU,
 
			GDW_LVL_EASY,
 
			GDW_LVL_MEDIUM,
 
			GDW_LVL_HARD,
 
			GDW_LVL_CUSTOM,
 
			WIDGET_LIST_END);
 
		this->SetWidgetDisabledState(GDW_HIGHSCORE, _game_mode == GM_EDITOR || _networking); // highscore chart in multiplayer
 
		this->SetWidgetDisabledState(GDW_ACCEPT, _networking && !_network_server); // Save-button in multiplayer (and if client)
 
		this->LowerWidget(GDW_LVL_EASY + this->opt_mod_temp.difficulty.diff_level);
 
		this->OnInvalidateData();
 

	
 
		/* Read data */
 
		this->OnInvalidateData(GOID_DIFFICULTY_CHANGED);
 
	}
 

	
 
	virtual void SetStringParameters(int widget) const
 
	{
 
		widget -= GDW_OPTIONS_START;
 
		if (widget < 0 || (widget % 3) != 2) return;
 
@@ -800,12 +798,23 @@ public:
 
	 * @param data Information about the changed data. @see GameOptionsInvalidationData
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (!gui_scope) return;
 

	
 
		if (data == GOID_DIFFICULTY_CHANGED) {
 
			/* Window was created or settings were changed on server. Reread everything. */
 

	
 
			/* Copy current settings (ingame or in intro) to temporary holding place
 
			 * change that when setting stuff, copy back on clicking 'OK' */
 
			this->opt_mod_temp = GetGameSettings();
 

	
 
			this->LowerWidget(GDW_LVL_EASY + this->opt_mod_temp.difficulty.diff_level);
 
		}
 

	
 
		uint i;
 
		const SettingDesc *sd = GetSettingFromName("difficulty.max_no_competitors", &i);
 
		for (i = 0; i < GAME_DIFFICULTY_NUM; i++, sd++) {
 
			const SettingDescBase *sdb = &sd->desc;
 
			/* skip deprecated difficulty options */
 
			if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
src/window_type.h
Show inline comments
 
@@ -120,12 +120,13 @@ enum WindowClass {
 
 */
 
enum GameOptionsInvalidationData {
 
	GOID_DEFAULT = 0,
 
	GOID_NEWGRF_RESCANNED,     ///< NewGRFs were just rescanned.
 
	GOID_NEWGRF_LIST_EDITED,   ///< List of active NewGRFs is being edited.
 
	GOID_NEWGRF_PRESET_LOADED, ///< A NewGRF preset was picked.
 
	GOID_DIFFICULTY_CHANGED,   ///< Difficulty settings were changed.
 
};
 

	
 
struct Window;
 

	
 
/** Number to differentiate different windows of the same class */
 
typedef int32 WindowNumber;
0 comments (0 inline, 0 general)