mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
(svn r17644) -Fix [FS#3219]: some inconsistencies with the difficulty settings in the scenario editor. Also re-enable changing some difficulty settings (e.g. max loan) in the scenario editor.
This commit is contained in:
parent
a47138ad34
commit
ac99610a05
@ -1422,7 +1422,11 @@ CommandCost CmdChangeSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
|||||||
|
|
||||||
if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking && _game_mode != GM_MENU) return CMD_ERROR;
|
if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking && _game_mode != GM_MENU) return CMD_ERROR;
|
||||||
if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return CMD_ERROR;
|
if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return CMD_ERROR;
|
||||||
if ((sd->desc.flags & SGF_NEWGAME_ONLY) && _game_mode != GM_MENU) return CMD_ERROR;
|
if ((sd->desc.flags & SGF_NEWGAME_ONLY) &&
|
||||||
|
(_game_mode == GM_NORMAL ||
|
||||||
|
(_game_mode == GM_EDITOR && (sd->desc.flags & SGF_SCENEDIT_TOO) == 0))) {
|
||||||
|
return CMD_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
GameSettings *s = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game;
|
GameSettings *s = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game;
|
||||||
|
@ -547,7 +547,7 @@ public:
|
|||||||
this->opt_mod_temp = (_game_mode == GM_MENU) ? _settings_newgame : _settings_game;
|
this->opt_mod_temp = (_game_mode == GM_MENU) ? _settings_newgame : _settings_game;
|
||||||
/* Setup disabled buttons when creating window
|
/* Setup disabled buttons when creating window
|
||||||
* disable all other difficulty buttons during gameplay except for 'custom' */
|
* disable all other difficulty buttons during gameplay except for 'custom' */
|
||||||
this->SetWidgetsDisabledState(_game_mode == GM_NORMAL,
|
this->SetWidgetsDisabledState(_game_mode != GM_MENU,
|
||||||
GDW_LVL_EASY,
|
GDW_LVL_EASY,
|
||||||
GDW_LVL_MEDIUM,
|
GDW_LVL_MEDIUM,
|
||||||
GDW_LVL_HARD,
|
GDW_LVL_HARD,
|
||||||
@ -610,10 +610,6 @@ public:
|
|||||||
const SettingDesc *sd = GetSettingFromName("difficulty.max_no_competitors", &i) + (widget / 3);
|
const SettingDesc *sd = GetSettingFromName("difficulty.max_no_competitors", &i) + (widget / 3);
|
||||||
const SettingDescBase *sdb = &sd->desc;
|
const SettingDescBase *sdb = &sd->desc;
|
||||||
|
|
||||||
/* Clicked disabled button? */
|
|
||||||
bool editable = (_game_mode == GM_MENU || (sdb->flags & SGF_NEWGAME_ONLY) == 0);
|
|
||||||
if (!editable) return;
|
|
||||||
|
|
||||||
int32 val = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv);
|
int32 val = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv);
|
||||||
if (widget % 3 == 1) {
|
if (widget % 3 == 1) {
|
||||||
/* Increase button clicked */
|
/* Increase button clicked */
|
||||||
@ -690,10 +686,12 @@ public:
|
|||||||
/* skip deprecated difficulty options */
|
/* skip deprecated difficulty options */
|
||||||
if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
|
if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
|
||||||
int32 value = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv);
|
int32 value = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv);
|
||||||
bool editable = (_game_mode == GM_MENU || (sdb->flags & SGF_NEWGAME_ONLY) == 0);
|
bool disable = (sd->desc.flags & SGF_NEWGAME_ONLY) &&
|
||||||
|
(_game_mode == GM_NORMAL ||
|
||||||
|
(_game_mode == GM_EDITOR && (sd->desc.flags & SGF_SCENEDIT_TOO) == 0));
|
||||||
|
|
||||||
this->SetWidgetDisabledState(GDW_OPTIONS_START + i * 3 + 0, !editable || sdb->min == value);
|
this->SetWidgetDisabledState(GDW_OPTIONS_START + i * 3 + 0, disable || sdb->min == value);
|
||||||
this->SetWidgetDisabledState(GDW_OPTIONS_START + i * 3 + 1, !editable || sdb->max == (uint32)value);
|
this->SetWidgetDisabledState(GDW_OPTIONS_START + i * 3 + 1, disable || sdb->max == (uint32)value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -44,11 +44,12 @@ enum SettingGuiFlagLong {
|
|||||||
SGF_NETWORK_ONLY = 1 << 3, ///< this setting only applies to network games
|
SGF_NETWORK_ONLY = 1 << 3, ///< this setting only applies to network games
|
||||||
SGF_CURRENCY = 1 << 4, ///< the number represents money, so when reading value multiply by exchange rate
|
SGF_CURRENCY = 1 << 4, ///< the number represents money, so when reading value multiply by exchange rate
|
||||||
SGF_NO_NETWORK = 1 << 5, ///< this setting does not apply to network games; it may not be changed during the game
|
SGF_NO_NETWORK = 1 << 5, ///< this setting does not apply to network games; it may not be changed during the game
|
||||||
SGF_NEWGAME_ONLY = 1 << 6, ///< this setting cannot be changed in inside a game
|
SGF_NEWGAME_ONLY = 1 << 6, ///< this setting cannot be changed in a game
|
||||||
SGF_PER_COMPANY = 1 << 7, ///< this setting can be different for each company (saved in company struct)
|
SGF_SCENEDIT_TOO = 1 << 7, ///< this setting can be changed in the scenario editor (only makes sense when SGF_NEWGAME_ONLY is set)
|
||||||
|
SGF_PER_COMPANY = 1 << 8, ///< this setting can be different for each company (saved in company struct)
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_AS_BIT_SET(SettingGuiFlagLong);
|
DECLARE_ENUM_AS_BIT_SET(SettingGuiFlagLong);
|
||||||
typedef SimpleTinyEnumT<SettingGuiFlagLong, byte> SettingGuiFlag;
|
typedef SimpleTinyEnumT<SettingGuiFlagLong, uint16> SettingGuiFlag;
|
||||||
|
|
||||||
|
|
||||||
typedef bool OnChange(int32 var); ///< callback prototype on data modification
|
typedef bool OnChange(int32 var); ///< callback prototype on data modification
|
||||||
|
@ -213,6 +213,7 @@ static bool UpdateClientConfigValues(int32 p1);
|
|||||||
#define CR SGF_CURRENCY
|
#define CR SGF_CURRENCY
|
||||||
#define NN SGF_NO_NETWORK
|
#define NN SGF_NO_NETWORK
|
||||||
#define NG SGF_NEWGAME_ONLY
|
#define NG SGF_NEWGAME_ONLY
|
||||||
|
#define NS (SGF_NEWGAME_ONLY | SGF_SCENEDIT_TOO)
|
||||||
#define PC SGF_PER_COMPANY
|
#define PC SGF_PER_COMPANY
|
||||||
|
|
||||||
static const SettingDesc _music_settings[] = {
|
static const SettingDesc _music_settings[] = {
|
||||||
@ -335,14 +336,14 @@ const SettingDesc _settings[] = {
|
|||||||
SDT_CONDNULL( 1, 97, 109),
|
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_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),
|
SDT_CONDVAR(GameSettings, difficulty.number_industries, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 4, 0, 4, 1, STR_NONE, DifficultyChange),
|
||||||
SDT_CONDVAR(GameSettings, difficulty.max_loan, SLE_UINT32, 97, SL_MAX_VERSION, 0,NG|CR,300000,100000,500000,50000,STR_NULL, DifficultyChange),
|
SDT_CONDVAR(GameSettings, difficulty.max_loan, SLE_UINT32, 97, SL_MAX_VERSION, 0,NS|CR,300000,100000,500000,50000,STR_NULL, DifficultyChange),
|
||||||
SDT_CONDVAR(GameSettings, difficulty.initial_interest, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 2, 2, 4, 1, STR_NULL, DifficultyChange),
|
SDT_CONDVAR(GameSettings, difficulty.initial_interest, SLE_UINT8, 97, SL_MAX_VERSION, 0,NS, 2, 2, 4, 1, STR_NULL, DifficultyChange),
|
||||||
SDT_CONDVAR(GameSettings, difficulty.vehicle_costs, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 0, 0, 2, 1, STR_SEA_LEVEL_LOW, DifficultyChange),
|
SDT_CONDVAR(GameSettings, difficulty.vehicle_costs, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 0, 0, 2, 1, STR_SEA_LEVEL_LOW, DifficultyChange),
|
||||||
SDT_CONDVAR(GameSettings, difficulty.competitor_speed, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 2, 0, 4, 1, STR_AI_SPEED_VERY_SLOW, DifficultyChange),
|
SDT_CONDVAR(GameSettings, difficulty.competitor_speed, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 2, 0, 4, 1, STR_AI_SPEED_VERY_SLOW, DifficultyChange),
|
||||||
SDT_CONDNULL( 1, 97, 109),
|
SDT_CONDNULL( 1, 97, 109),
|
||||||
SDT_CONDVAR(GameSettings, difficulty.vehicle_breakdowns, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 1, 0, 2, 1, STR_DISASTER_NONE, DifficultyChange),
|
SDT_CONDVAR(GameSettings, difficulty.vehicle_breakdowns, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 1, 0, 2, 1, STR_DISASTER_NONE, DifficultyChange),
|
||||||
SDT_CONDVAR(GameSettings, difficulty.subsidy_multiplier, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 2, 0, 3, 1, STR_SUBSIDY_X1_5, DifficultyChange),
|
SDT_CONDVAR(GameSettings, difficulty.subsidy_multiplier, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 2, 0, 3, 1, STR_SUBSIDY_X1_5, DifficultyChange),
|
||||||
SDT_CONDVAR(GameSettings, difficulty.construction_cost, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 0, 0, 2, 1, STR_SEA_LEVEL_LOW, DifficultyChange),
|
SDT_CONDVAR(GameSettings, difficulty.construction_cost, SLE_UINT8, 97, SL_MAX_VERSION, 0,NS, 0, 0, 2, 1, STR_SEA_LEVEL_LOW, DifficultyChange),
|
||||||
SDT_CONDVAR(GameSettings, difficulty.terrain_type, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 1, 0, 3, 1, STR_TERRAIN_TYPE_VERY_FLAT, DifficultyChange),
|
SDT_CONDVAR(GameSettings, difficulty.terrain_type, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 1, 0, 3, 1, STR_TERRAIN_TYPE_VERY_FLAT, DifficultyChange),
|
||||||
SDT_CONDVAR(GameSettings, difficulty.quantity_sea_lakes, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 0, 0, 3, 1, STR_SEA_LEVEL_VERY_LOW, DifficultyChange),
|
SDT_CONDVAR(GameSettings, difficulty.quantity_sea_lakes, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 0, 0, 3, 1, STR_SEA_LEVEL_VERY_LOW, DifficultyChange),
|
||||||
SDT_CONDVAR(GameSettings, difficulty.economy, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 0, 0, 1, 1, STR_ECONOMY_STEADY, DifficultyChange),
|
SDT_CONDVAR(GameSettings, difficulty.economy, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 0, 0, 1, 1, STR_ECONOMY_STEADY, DifficultyChange),
|
||||||
|
Loading…
Reference in New Issue
Block a user