@@ -199,10 +199,18 @@ struct GSConfigWindow : public Window {
TextColour colour;
uint idx = 0;
if (config_item.description.empty()) {
str = STR_JUST_STRING1;
if (Game::GetInstance() == nullptr && config_item.random_deviation != 0) {
str = STR_AI_SETTINGS_JUST_DEVIATION;
} else {
}
colour = TC_ORANGE;
str = STR_AI_SETTINGS_SETTING;
str = STR_AI_SETTINGS_SETTING_DEVIATION;
colour = TC_LIGHT_BLUE;
SetDParamStr(idx++, config_item.description);
@@ -216,13 +224,36 @@ 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);
auto config_iterator = config_item.labels.find(current_value);
if (config_iterator != config_item.labels.end()) {
SetDParam(idx++, STR_JUST_RAW_STRING);
SetDParamStr(idx++, config_iterator->second);
if (Game::GetInstance() != nullptr || config_item.random_deviation == 0) {
SetDParam(idx++, STR_JUST_INT);
SetDParam(idx++, current_value);
int min_deviated = std::max(config_item.min_value, current_value - config_item.random_deviation);
auto config_iterator = config_item.labels.find(min_deviated);
SetDParam(idx++, min_deviated);
int max_deviated = std::min(config_item.max_value, current_value + config_item.random_deviation);
config_iterator = config_item.labels.find(max_deviated);
SetDParam(idx++, max_deviated);
@@ -4835,6 +4835,8 @@ STR_AI_SETTINGS_CAPTION_GAMESCRIPT
STR_AI_SETTINGS_CLOSE :{BLACK}Close
STR_AI_SETTINGS_RESET :{BLACK}Reset
STR_AI_SETTINGS_SETTING :{RAW_STRING}: {ORANGE}{STRING1}
STR_AI_SETTINGS_SETTING_DEVIATION :{RAW_STRING}: {ORANGE}[{STRING1}, {STRING1}]
STR_AI_SETTINGS_JUST_DEVIATION :[{STRING1}, {STRING1}]
# Textfile window
@@ -239,6 +239,7 @@ public:
* [user_configured_value - random_deviation, user_configured_value + random_deviation] (inclusive).
* random_deviation sign is ignored and the value is clamped in the range [0, MAX(int32_t)] (inclusive).
* The randomisation will happen just before the Script start.
* Not allowed if the CONFIG_BOOLEAN flag is set, otherwise optional.
* - step_size The increase/decrease of the value every time the user
* clicks one of the up/down arrow buttons. Optional, default is 1.
* - flags Bitmask of some flags, see ScriptConfigFlags. Required.
@@ -379,10 +379,18 @@ struct ScriptSettingsWindow : public Win
if (this->slot != OWNER_DEITY && !Company::IsValidID(this->slot) && config_item.random_deviation != 0) {
@@ -397,13 +405,35 @@ struct ScriptSettingsWindow : public Win
if (this->slot == OWNER_DEITY || Company::IsValidID(this->slot) || config_item.random_deviation == 0) {
@@ -162,6 +162,13 @@ SQInteger ScriptInfo::AddSetting(HSQUIRR
sq_pop(vm, 1);
/* Don't allow both random_deviation and SCRIPTCONFIG_BOOLEAN to
* be set for the same config item. */
if ((items & 0x200) != 0 && (config.flags & SCRIPTCONFIG_BOOLEAN) != 0) {
this->engine->ThrowError("setting both random_deviation and CONFIG_BOOLEAN is not allowed");
return SQ_ERROR;
/* Reset the bit for random_deviation as it's optional. */
items &= ~0x200;
Status change: