Add setting to disable script parameter randomisation

pull/663/head
Jonathan G Rennison 2 months ago
parent e730956213
commit 2bb5c9ac84

@ -206,14 +206,14 @@ struct GSConfigWindow : public Window {
TextColour colour;
uint idx = 0;
if (config_item.description.empty()) {
if (Game::GetInstance() == nullptr && config_item.random_deviation != 0) {
if (Game::GetInstance() == nullptr && config_item.random_deviation != 0 && !GetGameSettings().script.script_disable_param_randomisation) {
str = STR_AI_SETTINGS_JUST_DEVIATION;
} else {
str = STR_JUST_STRING1;
}
colour = TC_ORANGE;
} else {
if (Game::GetInstance() == nullptr && config_item.random_deviation != 0) {
if (Game::GetInstance() == nullptr && config_item.random_deviation != 0 && !GetGameSettings().script.script_disable_param_randomisation) {
str = STR_AI_SETTINGS_SETTING_DEVIATION;
} else {
str = STR_AI_SETTINGS_SETTING;
@ -232,7 +232,7 @@ struct GSConfigWindow : public Window {
DrawArrowButtons(br.left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > config_item.min_value, editable && current_value < config_item.max_value);
}
if (Game::GetInstance() != nullptr || config_item.random_deviation == 0) {
if (Game::GetInstance() != nullptr || config_item.random_deviation == 0 || GetGameSettings().script.script_disable_param_randomisation) {
auto config_iterator = config_item.labels.find(current_value);
if (config_iterator != config_item.labels.end()) {
SetDParam(idx++, STR_JUST_RAW_STRING);

@ -2298,6 +2298,9 @@ STR_CONFIG_SETTING_CITY_IN_LABEL_HELPTEXT :Display if a to
STR_CONFIG_SETTING_CYCLE_SIGNAL_PBS :Path signals only
STR_CONFIG_SETTING_SCRIPT_DISABLE_PARAM_RANDOM :Disable script parameter randomisation: {STRING2}
STR_CONFIG_SETTING_SCRIPT_DISABLE_PARAM_RANDOM_HELPTEXT :Disable the randomisation of AI/GS script paraneters.
STR_CONFIG_SETTING_RESTRICT_PATCH :Non-standard settings which are not in vanilla OpenTTD
###length 4

@ -126,6 +126,7 @@ void ScriptConfig::ResetEditableSettings(bool yet_to_start)
void ScriptConfig::AddRandomDeviation(CompanyID owner)
{
if (GetGameSettings().script.script_disable_param_randomisation) return;
for (const auto &item : *this->GetConfigList()) {
if (item.random_deviation != 0) {
this->SetSetting(item.name, ScriptObject::GetRandomizer(owner).Next(item.random_deviation * 2 + 1) - item.random_deviation + this->GetSetting(item.name));

@ -393,14 +393,14 @@ struct ScriptSettingsWindow : public Window {
TextColour colour;
uint idx = 0;
if (config_item.description.empty()) {
if (this->slot != OWNER_DEITY && !Company::IsValidID(this->slot) && config_item.random_deviation != 0) {
if (this->slot != OWNER_DEITY && !Company::IsValidID(this->slot) && config_item.random_deviation != 0 && !GetGameSettings().script.script_disable_param_randomisation) {
str = STR_AI_SETTINGS_JUST_DEVIATION;
} else {
str = STR_JUST_STRING1;
}
colour = TC_ORANGE;
} else {
if (this->slot != OWNER_DEITY && !Company::IsValidID(this->slot) && config_item.random_deviation != 0) {
if (this->slot != OWNER_DEITY && !Company::IsValidID(this->slot) && config_item.random_deviation != 0 && !GetGameSettings().script.script_disable_param_randomisation) {
str = STR_AI_SETTINGS_SETTING_DEVIATION;
} else {
str = STR_AI_SETTINGS_SETTING;
@ -419,7 +419,7 @@ struct ScriptSettingsWindow : public Window {
DrawArrowButtons(br.left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > config_item.min_value, editable && current_value < config_item.max_value);
}
if (this->slot == OWNER_DEITY || Company::IsValidID(this->slot) || config_item.random_deviation == 0) {
if (this->slot == OWNER_DEITY || Company::IsValidID(this->slot) || config_item.random_deviation == 0 || GetGameSettings().script.script_disable_param_randomisation) {
auto config_iterator = config_item.labels.find(current_value);
if (config_iterator != config_item.labels.end()) {
SetDParam(idx++, STR_JUST_RAW_STRING);

@ -2701,6 +2701,7 @@ static SettingsContainer &GetSettingsTree()
{
npc->Add(new SettingEntry("script.script_max_opcode_till_suspend"));
npc->Add(new SettingEntry("script.script_max_memory_megabytes"));
npc->Add(new SettingEntry("script.script_disable_param_randomisation"));
npc->Add(new SettingEntry("difficulty.competitor_speed"));
npc->Add(new SettingEntry("ai.ai_in_multiplayer"));
npc->Add(new SettingEntry("ai.ai_disable_veh_train"));

@ -568,6 +568,7 @@ struct AISettings {
struct ScriptSettings {
uint32_t script_max_opcode_till_suspend; ///< max opcode calls till scripts will suspend
uint32_t script_max_memory_megabytes; ///< limit on memory a single script instance may have allocated
bool script_disable_param_randomisation; ///< disable script parameter randomisation
};
/** Settings related to the new pathfinder. */

@ -76,6 +76,15 @@ pre_cb = CheckScriptMaxMemoryChange
post_cb = ScriptMaxMemoryChange
cat = SC_EXPERT
[SDT_BOOL]
var = script.script_disable_param_randomisation
flags = SF_PATCH
def = false
str = STR_CONFIG_SETTING_SCRIPT_DISABLE_PARAM_RANDOM
strhelp = STR_CONFIG_SETTING_SCRIPT_DISABLE_PARAM_RANDOM_HELPTEXT
post_cb = [](auto) { InvalidateWindowClassesData(WC_SCRIPT_SETTINGS); InvalidateWindowClassesData(WC_GAME_OPTIONS); }
cat = SC_ADVANCED
[SDT_BOOL]
var = ai.ai_in_multiplayer
def = true

Loading…
Cancel
Save