From 8d9fa0ea89192a3939d588861174348f8fb8e7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guilloux?= Date: Sun, 11 Feb 2024 19:58:41 +0100 Subject: [PATCH] Change: [Script] Use company randomizer when adding random deviation (#12065) --- src/ai/ai_core.cpp | 2 +- src/game/game_core.cpp | 2 +- src/script/script_config.cpp | 4 ++-- src/script/script_config.hpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp index 297318371a..37f3abb397 100644 --- a/src/ai/ai_core.cpp +++ b/src/ai/ai_core.cpp @@ -56,7 +56,7 @@ /* Load default data and store the name in the settings */ config->Change(info->GetName(), -1, false); } - if (deviate) config->AddRandomDeviation(); + if (deviate) config->AddRandomDeviation(company); config->AnchorUnchangeableSettings(); c->ai_info = info; diff --git a/src/game/game_core.cpp b/src/game/game_core.cpp index 0230ac23e2..ad3558c0e1 100644 --- a/src/game/game_core.cpp +++ b/src/game/game_core.cpp @@ -83,7 +83,7 @@ GameInfo *info = config->GetInfo(); if (info == nullptr) return; - if (deviate) config->AddRandomDeviation(); + if (deviate) config->AddRandomDeviation(OWNER_DEITY); config->AnchorUnchangeableSettings(); Backup cur_company(_current_company, FILE_LINE); diff --git a/src/script/script_config.cpp b/src/script/script_config.cpp index 21cee20925..e0fad59664 100644 --- a/src/script/script_config.cpp +++ b/src/script/script_config.cpp @@ -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()) { 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)); } } } diff --git a/src/script/script_config.hpp b/src/script/script_config.hpp index 42c77a845c..9ccc276051 100644 --- a/src/script/script_config.hpp +++ b/src/script/script_config.hpp @@ -135,7 +135,7 @@ public: /** * 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