summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-05-29 23:27:01 +0200
committerGitHub <noreply@github.com>2021-05-29 23:27:01 +0200
commitd70fb74ac669bdb64b5f594894629ec91801fd76 (patch)
tree344150f3a69cd97cf774eec16eed291ed4e2467c /src/script
parent5799402f7a4872d03809838dd7fa01db42bbd282 (diff)
downloadopenttd-d70fb74ac669bdb64b5f594894629ec91801fd76.tar.xz
Codechange: use setting name instead of index for CmdChange(Company)Setting (#9306)
This is mostly done as there are now constraints on settings.ini you might not expected. For example, conditional settings always have to come last, as otherwise they would influence the index.
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/script_company.cpp6
-rw-r--r--src/script/api/script_gamesettings.cpp2
-rw-r--r--src/script/api/script_group.cpp2
3 files changed, 5 insertions, 5 deletions
diff --git a/src/script/api/script_company.cpp b/src/script/api/script_company.cpp
index 20f1b3f7a..9f5722c10 100644
--- a/src/script/api/script_company.cpp
+++ b/src/script/api/script_company.cpp
@@ -260,7 +260,7 @@
/* static */ bool ScriptCompany::SetAutoRenewStatus(bool autorenew)
{
- return ScriptObject::DoCommand(0, ::GetCompanySettingIndex("company.engine_renew"), autorenew ? 1 : 0, CMD_CHANGE_COMPANY_SETTING);
+ return ScriptObject::DoCommand(0, 0, autorenew ? 1 : 0, CMD_CHANGE_COMPANY_SETTING, "company.engine_renew");
}
/* static */ bool ScriptCompany::GetAutoRenewStatus(CompanyID company)
@@ -273,7 +273,7 @@
/* static */ bool ScriptCompany::SetAutoRenewMonths(int16 months)
{
- return ScriptObject::DoCommand(0, ::GetCompanySettingIndex("company.engine_renew_months"), months, CMD_CHANGE_COMPANY_SETTING);
+ return ScriptObject::DoCommand(0, 0, months, CMD_CHANGE_COMPANY_SETTING, "company.engine_renew_months");
}
/* static */ int16 ScriptCompany::GetAutoRenewMonths(CompanyID company)
@@ -288,7 +288,7 @@
{
EnforcePrecondition(false, money >= 0);
EnforcePrecondition(false, (int64)money <= UINT32_MAX);
- return ScriptObject::DoCommand(0, ::GetCompanySettingIndex("company.engine_renew_money"), money, CMD_CHANGE_COMPANY_SETTING);
+ return ScriptObject::DoCommand(0, 0, money, CMD_CHANGE_COMPANY_SETTING, "company.engine_renew_money");
}
/* static */ Money ScriptCompany::GetAutoRenewMoney(CompanyID company)
diff --git a/src/script/api/script_gamesettings.cpp b/src/script/api/script_gamesettings.cpp
index 8b0459367..0ade2d7cc 100644
--- a/src/script/api/script_gamesettings.cpp
+++ b/src/script/api/script_gamesettings.cpp
@@ -39,7 +39,7 @@
if ((sd->save.conv & SLF_NO_NETWORK_SYNC) != 0) return false;
- return ScriptObject::DoCommand(0, GetSettingIndex(sd), value, CMD_CHANGE_SETTING);
+ return ScriptObject::DoCommand(0, 0, value, CMD_CHANGE_SETTING, sd->name);
}
/* static */ bool ScriptGameSettings::IsDisabledVehicleType(ScriptVehicle::VehicleType vehicle_type)
diff --git a/src/script/api/script_group.cpp b/src/script/api/script_group.cpp
index 9cf6c7c95..0295c67aa 100644
--- a/src/script/api/script_group.cpp
+++ b/src/script/api/script_group.cpp
@@ -118,7 +118,7 @@
{
if (HasWagonRemoval() == enable_removal) return true;
- return ScriptObject::DoCommand(0, ::GetCompanySettingIndex("company.renew_keep_length"), enable_removal ? 1 : 0, CMD_CHANGE_COMPANY_SETTING);
+ return ScriptObject::DoCommand(0, 0, enable_removal ? 1 : 0, CMD_CHANGE_COMPANY_SETTING, "company.renew_keep_length");
}
/* static */ bool ScriptGroup::HasWagonRemoval()