Skip to content

Commit 5ef5031

Browse files
committed
Implements MultipleFactoryCap for RulesClass.
1 parent 335cc24 commit 5ef5031

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/extensions/rules/rulesext.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ RulesClassExtension::RulesClassExtension(RulesClass *this_ptr) :
4646
IsMPAutoDeployMCV(false),
4747
IsMPPrePlacedConYards(false),
4848
IsBuildOffAlly(true),
49-
LowPowerPenaltyModifier(1.0f)
49+
LowPowerPenaltyModifier(1.0f),
50+
MultipleFactoryCap(0)
5051
{
5152
ASSERT(ThisPtr != nullptr);
5253
//EXT_DEBUG_TRACE("RulesClassExtension constructor - 0x%08X\n", (uintptr_t)(ThisPtr));
@@ -206,6 +207,7 @@ bool RulesClassExtension::General(CCINIClass &ini)
206207
}
207208

208209
LowPowerPenaltyModifier = ini.Get_Float(GENERAL, "LowPowerPenaltyModifier", LowPowerPenaltyModifier);
210+
MultipleFactoryCap = ini.Get_Int(GENERAL, "MultipleFactoryCap", MultipleFactoryCap);
209211

210212
return true;
211213
}

src/extensions/rules/rulesext.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ class RulesClassExtension final : public Extension<RulesClass>
105105
* units you are short of to get the actual penalty to the build speed.
106106
*/
107107
float LowPowerPenaltyModifier;
108+
109+
/**
110+
* The maximum number of factories that can be considered when calculating
111+
* the multiple factory bonus on an object's build time.
112+
*/
113+
int MultipleFactoryCap;
108114
};
109115

110116

src/extensions/techno/technoext.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,22 @@ int TechnoClassExtension::Time_To_Build() const
418418
* @author: CCHyper
419419
*/
420420
if (Rule->MultipleFactory > 0.0 && (divisor-1) > 0) {
421-
while (divisor) {
421+
422+
/**
423+
* #issue-659
424+
*
425+
* Implements MultipleFactoryCap for RulesClass.
426+
*
427+
* @author: CCHyper
428+
*/
429+
if (RulesExtension && RulesExtension->MultipleFactoryCap > 0) {
430+
divisor = RulesExtension->MultipleFactoryCap;
431+
}
432+
433+
divisor = (divisor-1);
434+
435+
while (divisor--) {
422436
time *= Rule->MultipleFactory;
423-
--divisor;
424437
}
425438
}
426439
#endif

0 commit comments

Comments
 (0)