mirror of https://github.com/OpenTTD/OpenTTD
Change: [Script] Use company randomizer when adding random deviation (#12065)
parent
378dab3750
commit
8d9fa0ea89
|
@ -56,7 +56,7 @@
|
||||||
/* Load default data and store the name in the settings */
|
/* Load default data and store the name in the settings */
|
||||||
config->Change(info->GetName(), -1, false);
|
config->Change(info->GetName(), -1, false);
|
||||||
}
|
}
|
||||||
if (deviate) config->AddRandomDeviation();
|
if (deviate) config->AddRandomDeviation(company);
|
||||||
config->AnchorUnchangeableSettings();
|
config->AnchorUnchangeableSettings();
|
||||||
|
|
||||||
c->ai_info = info;
|
c->ai_info = info;
|
||||||
|
|
|
@ -83,7 +83,7 @@
|
||||||
GameInfo *info = config->GetInfo();
|
GameInfo *info = config->GetInfo();
|
||||||
if (info == nullptr) return;
|
if (info == nullptr) return;
|
||||||
|
|
||||||
if (deviate) config->AddRandomDeviation();
|
if (deviate) config->AddRandomDeviation(OWNER_DEITY);
|
||||||
config->AnchorUnchangeableSettings();
|
config->AnchorUnchangeableSettings();
|
||||||
|
|
||||||
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||||
|
|
|
@ -123,11 +123,11 @@ void ScriptConfig::ResetEditableSettings(bool yet_to_start)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptConfig::AddRandomDeviation()
|
void ScriptConfig::AddRandomDeviation(CompanyID owner)
|
||||||
{
|
{
|
||||||
for (const auto &item : *this->GetConfigList()) {
|
for (const auto &item : *this->GetConfigList()) {
|
||||||
if (item.random_deviation != 0) {
|
if (item.random_deviation != 0) {
|
||||||
this->SetSetting(item.name, ScriptObject::GetRandomizer(OWNER_NONE).Next(item.random_deviation * 2 + 1) - item.random_deviation + this->GetSetting(item.name));
|
this->SetSetting(item.name, ScriptObject::GetRandomizer(owner).Next(item.random_deviation * 2 + 1) - item.random_deviation + this->GetSetting(item.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Randomize all settings the Script requested to be randomized.
|
* Randomize all settings the Script requested to be randomized.
|
||||||
*/
|
*/
|
||||||
void AddRandomDeviation();
|
void AddRandomDeviation(CompanyID owner);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this config attached to an Script? In other words, is there a Script
|
* Is this config attached to an Script? In other words, is there a Script
|
||||||
|
|
Loading…
Reference in New Issue