Merge branch 'master' into jgrpp

# Conflicts:
#	src/cheat_gui.cpp
#	src/command.cpp
#	src/command_func.h
#	src/company_base.h
#	src/debug.cpp
#	src/debug.h
#	src/economy.cpp
#	src/engine_type.h
#	src/graph_gui.cpp
#	src/misc_cmd.cpp
#	src/misc_cmd.h
#	src/network/core/os_abstraction.cpp
#	src/openttd.cpp
#	src/saveload/saveload.cpp
#	src/saveload/saveload.h
#	src/settings_type.h
#	src/ship_cmd.cpp
#	src/stdafx.h
#	src/tests/bitmath_func.cpp
#	src/town_cmd.cpp
#	src/town_gui.cpp
This commit is contained in:
Jonathan G Rennison
2024-02-17 11:53:23 +00:00
66 changed files with 554 additions and 234 deletions

View File

@@ -31,8 +31,9 @@ public:
/**
* Start up a new GameScript.
* @param randomise Whether to randomise the configured GameScript.
*/
static void StartNew();
static void StartNew(bool randomise = true);
/**
* Uninitialize the Game system.

View File

@@ -69,7 +69,7 @@
}
}
/* static */ void Game::StartNew()
/* static */ void Game::StartNew(bool randomise)
{
if (Game::instance != nullptr) return;
@@ -83,6 +83,7 @@
GameInfo *info = config->GetInfo();
if (info == nullptr) return;
if (randomise) config->AddRandomDeviation();
config->AnchorUnchangeableSettings();
Backup<CompanyID> cur_company(_current_company, FILE_LINE);

View File

@@ -206,10 +206,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 {
str = STR_JUST_STRING1;
}
colour = TC_ORANGE;
} else {
str = STR_AI_SETTINGS_SETTING;
if (Game::GetInstance() == nullptr && config_item.random_deviation != 0) {
str = STR_AI_SETTINGS_SETTING_DEVIATION;
} else {
str = STR_AI_SETTINGS_SETTING;
}
colour = TC_LIGHT_BLUE;
SetDParamStr(idx++, config_item.description);
}
@@ -223,13 +231,36 @@ struct GSConfigWindow : public Window {
} else {
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) {
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);
} else {
SetDParam(idx++, STR_JUST_INT);
SetDParam(idx++, current_value);
}
} else {
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);
if (config_iterator != config_item.labels.end()) {
SetDParam(idx++, STR_JUST_RAW_STRING);
SetDParamStr(idx++, config_iterator->second);
} else {
SetDParam(idx++, STR_JUST_INT);
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);
if (config_iterator != config_item.labels.end()) {
SetDParam(idx++, STR_JUST_RAW_STRING);
SetDParamStr(idx++, config_iterator->second);
} else {
SetDParam(idx++, STR_JUST_INT);
SetDParam(idx++, max_deviated);
}
}
}

View File

@@ -42,7 +42,7 @@ template <> const char *GetClassName<GameInfo, ScriptType::GS>() { return "GSInf
SQGSInfo.DefSQAdvancedMethod(engine, &GameInfo::AddSetting, "AddSetting");
SQGSInfo.DefSQAdvancedMethod(engine, &GameInfo::AddLabels, "AddLabels");
SQGSInfo.DefSQConst(engine, SCRIPTCONFIG_NONE, "CONFIG_NONE");
SQGSInfo.DefSQConst(engine, SCRIPTCONFIG_RANDOM, "CONFIG_RANDOM");
SQGSInfo.DefSQConst(engine, SCRIPTCONFIG_NONE, "CONFIG_RANDOM"); // Deprecated, mapped to NONE.
SQGSInfo.DefSQConst(engine, SCRIPTCONFIG_BOOLEAN, "CONFIG_BOOLEAN");
SQGSInfo.DefSQConst(engine, SCRIPTCONFIG_INGAME, "CONFIG_INGAME");
SQGSInfo.DefSQConst(engine, SCRIPTCONFIG_DEVELOPER, "CONFIG_DEVELOPER");