Skip to content

Commit

Permalink
Implements MultipleFactoryCap for RulesClass.
Browse files Browse the repository at this point in the history
  • Loading branch information
CCHyper committed Mar 28, 2023
1 parent b04a53a commit 6207d36
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/extensions/rules/rulesext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ RulesClassExtension::RulesClassExtension(const RulesClass *this_ptr) :
IsMPPrePlacedConYards(false),
IsBuildOffAlly(true),
IsShowSuperWeaponTimers(true),
LowPowerPenaltyModifier(1.0f)
LowPowerPenaltyModifier(1.0f),
MultipleFactoryCap(0)
{
//if (this_ptr) EXT_DEBUG_TRACE("RulesClassExtension::RulesClassExtension - 0x%08X\n", (uintptr_t)(ThisPtr));

Expand Down Expand Up @@ -446,13 +447,15 @@ bool RulesClassExtension::AudioVisual(CCINIClass &ini)
{
//EXT_DEBUG_TRACE("RulesClassExtension::General - 0x%08X\n", (uintptr_t)(This()));

static char const * const GENERAL = "General";
static char const * const AUDIOVISUAL = "AudioVisual";

if (!ini.Is_Present(AUDIOVISUAL)) {
return false;
}

IsShowSuperWeaponTimers = ini.Get_Bool(AUDIOVISUAL, "ShowSuperWeaponTimers", IsShowSuperWeaponTimers);
MultipleFactoryCap = ini.Get_Int(GENERAL, "MultipleFactoryCap", MultipleFactoryCap);

return true;
}
Expand Down
6 changes: 6 additions & 0 deletions src/extensions/rules/rulesext.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,10 @@ class RulesClassExtension final : public GlobalExtensionClass<RulesClass>
* units you are short of to get the actual penalty to the build speed.
*/
float LowPowerPenaltyModifier;

/**
* The maximum number of factories that can be considered when calculating
* the multiple factory bonus on an object's build time.
*/
int MultipleFactoryCap;
};
14 changes: 14 additions & 0 deletions src/extensions/techno/technoext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,20 @@ int TechnoClassExtension::Time_To_Build() const
* @author: CCHyper
*/
if (Rule->MultipleFactory > 0.0 && (divisor-1) > 0) {

/**
* #issue-659
*
* Implements MultipleFactoryCap for RulesClass.
*
* @author: CCHyper
*/
if (RuleExtension->MultipleFactoryCap > 0) {
divisor = RuleExtension->MultipleFactoryCap;
}

divisor = (divisor-1);

while (divisor) {
time *= Rule->MultipleFactory;
--divisor;
Expand Down

0 comments on commit 6207d36

Please sign in to comment.