summaryrefslogtreecommitdiff
path: root/src/industry_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/industry_cmd.cpp')
-rw-r--r--src/industry_cmd.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 5cedd4e3a..f549334ff 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1972,6 +1972,8 @@ void IndustryTypeBuildData::Reset()
{
this->probability = 0;
this->target_count = 0;
+ this->max_wait = 1;
+ this->wait_count = 0;
}
/** Completely reset the industry build data. */
@@ -2150,6 +2152,7 @@ void IndustryBuildData::TryBuildNewIndustry()
for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) {
int difference = this->builddata[it].target_count - Industry::GetIndustryTypeCount(it);
missing += difference;
+ if (this->builddata[it].wait_count > 0) continue; // This type may not be built now.
if (difference > 0) {
total_prob += difference;
count++;
@@ -2166,6 +2169,7 @@ void IndustryBuildData::TryBuildNewIndustry()
uint32 r = 0; // Initialized to silence the compiler.
if (count > 1) r = RandomRange(total_prob);
for (it = 0; it < NUM_INDUSTRYTYPES; it++) {
+ if (this->builddata[it].wait_count > 0) continue; // Type may not be built now.
int difference = this->builddata[it].target_count - Industry::GetIndustryTypeCount(it);
if (difference <= 0) continue; // Too many of this kind.
if (count == 1) break;
@@ -2176,10 +2180,19 @@ void IndustryBuildData::TryBuildNewIndustry()
/* Try to create the industry. */
const Industry *ind = PlaceIndustry(it, IACT_RANDOMCREATION, false);
- if (ind != NULL) {
+ if (ind == NULL) {
+ this->builddata[it].wait_count = this->builddata[it].max_wait + 1; // Compensate for decrementing below.
+ this->builddata[it].max_wait = min(1000, this->builddata[it].max_wait + 2);
+ } else {
AdvertiseIndustryOpening(ind);
+ this->builddata[it].max_wait = max(this->builddata[it].max_wait / 2, 1); // Reduce waiting time of the industry type.
}
}
+
+ /* Decrement wait counters. */
+ for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) {
+ if (this->builddata[it].wait_count > 0) this->builddata[it].wait_count--;
+ }
}
/**