Skip to content

Commit f24d2cc

Browse files
committed
bugfix(module): Fix missing horde condition of Nationalism and Fanaticism weapon bonuses (#1582)
This fix is opt-in by setting Action=HORDE_FIXED in HordeUpdate behavior modules
1 parent b6def3a commit f24d2cc

File tree

8 files changed

+124
-6
lines changed

8 files changed

+124
-6
lines changed

Generals/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ class AIUpdateInterface : public UpdateModule, public AICommandInterface
552552
Bool hasFanaticism() const;
553553
void evaluateMoraleBonus( Bool inHorde, Bool allowNationalism, HordeActionType type );
554554
void evaluateNationalismBonusClassic( Bool inHorde, Bool allowNationalism );
555+
void evaluateNationalismBonus( Bool inHorde, Bool allowNationalism );
555556

556557
#ifdef ALLOW_DEMORALIZE
557558
// demoralization ... what a nifty word to write.

Generals/Code/GameEngine/Include/GameLogic/Module/HordeUpdate.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,38 @@ class UpgradeTemplate;
4141
//-------------------------------------------------------------------------------------------------
4242
//-------------------------------------------------------------------------------------------------
4343

44+
// TheSuperHackers @bugfix xezon 15/09/2025 Adds a new horde action to select a fixed implementation.
45+
//
46+
// TheSuperHackers @todo If we want more control over the horde setup, then we need to implement
47+
// filters for separate weapon bonuses and required upgrades. But adding more behavior modules will
48+
// be a performance concern. Example INI setup:
49+
//
50+
// Behavior = HordeUpdate ModuleTag
51+
// Action = NATIONALISM
52+
// ;ApplyWeaponBonus = NATIONALISM
53+
// UpgradeRequired = Upgrade_Nationalism
54+
// End
55+
//
4456
enum HordeActionType CPP_11(: Int)
4557
{
46-
HORDEACTION_HORDE = 0,
58+
HORDEACTION_HORDE, ///< Classic action, applies the Horde bonus correctly, but Nationalism and Fanaticism bonuses are not removed after leaving horde.
59+
HORDEACTION_HORDE_FIXED, ///< Applies the Horde, Nationalism and Fanaticism bonuses correctly.
4760

48-
HORDEACTION_COUNT
61+
HORDEACTION_COUNT,
62+
63+
#if RETAIL_COMPATIBLE_CRC
64+
HORDEACTION_DEFAULT = HORDEACTION_HORDE,
65+
#else
66+
HORDEACTION_DEFAULT = HORDEACTION_HORDE_FIXED, ///< Does not change unmodified retail game behavior, because all its horde update modules explicitly set Action = HORDE.
67+
#endif
4968
};
5069

5170
#ifdef DEFINE_HORDEACTION_NAMES
5271
static const char *const TheHordeActionTypeNames[] =
5372
{
5473
"HORDE",
74+
"HORDE_FIXED",
75+
5576
NULL
5677
};
5778
static_assert(ARRAY_SIZE(TheHordeActionTypeNames) == HORDEACTION_COUNT + 1, "Incorrect array size");

Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4501,6 +4501,12 @@ void AIUpdateInterface::evaluateMoraleBonus( Bool inHorde, Bool allowNationalism
45014501
case HORDEACTION_HORDE:
45024502
evaluateNationalismBonusClassic(inHorde, allowNationalism);
45034503
break;
4504+
4505+
#if !RETAIL_COMPATIBLE_CRC
4506+
case HORDEACTION_HORDE_FIXED:
4507+
evaluateNationalismBonus(inHorde, allowNationalism);
4508+
break;
4509+
#endif
45044510
}
45054511
}
45064512

@@ -4540,6 +4546,37 @@ void AIUpdateInterface::evaluateNationalismBonusClassic( Bool inHorde, Bool allo
45404546
}
45414547
}
45424548

4549+
// ------------------------------------------------------------------------------------------------
4550+
// TheSuperHackers @bugfix The fixed Nationalism Bonus implementation.
4551+
// Nationalism and Fanaticism are now tied to the horde status.
4552+
// And Fanaticism is no longer dependent on Nationalism.
4553+
// ------------------------------------------------------------------------------------------------
4554+
void AIUpdateInterface::evaluateNationalismBonus( Bool inHorde, Bool allowNationalism )
4555+
{
4556+
Object *us = getObject();
4557+
4558+
if( inHorde )
4559+
{
4560+
us->setWeaponBonusCondition( WEAPONBONUSCONDITION_HORDE );
4561+
4562+
if( allowNationalism && hasNationalism() )
4563+
{
4564+
us->setWeaponBonusCondition( WEAPONBONUSCONDITION_NATIONALISM );
4565+
}
4566+
4567+
if( allowNationalism && hasFanaticism() )
4568+
{
4569+
us->setWeaponBonusCondition( WEAPONBONUSCONDITION_FANATICISM );
4570+
}
4571+
}
4572+
else
4573+
{
4574+
us->clearWeaponBonusCondition( WEAPONBONUSCONDITION_HORDE );
4575+
us->clearWeaponBonusCondition( WEAPONBONUSCONDITION_NATIONALISM );
4576+
us->clearWeaponBonusCondition( WEAPONBONUSCONDITION_FANATICISM );
4577+
}
4578+
}
4579+
45434580
#ifdef ALLOW_DEMORALIZE
45444581
// ------------------------------------------------------------------------------------------------
45454582
// ------------------------------------------------------------------------------------------------

Generals/Code/GameEngine/Source/GameLogic/Object/Update/HordeUpdate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ HordeUpdateModuleData::HordeUpdateModuleData()
121121
, m_alliesOnly(true)
122122
, m_exactMatch(false)
123123
, m_allowedNationalism(TRUE)
124-
, m_action(HORDEACTION_HORDE)
124+
, m_action(HORDEACTION_DEFAULT)
125125
{
126126
}
127127

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ class AIUpdateInterface : public UpdateModule, public AICommandInterface
565565
Bool hasFanaticism() const;
566566
void evaluateMoraleBonus( Bool inHorde, Bool allowNationalism, HordeActionType type );
567567
void evaluateNationalismBonusClassic( Bool inHorde, Bool allowNationalism );
568+
void evaluateNationalismBonus( Bool inHorde, Bool allowNationalism );
568569

569570
#ifdef ALLOW_DEMORALIZE
570571
// demoralization ... what a nifty word to write.

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/HordeUpdate.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,38 @@ class UpgradeTemplate;
4141
//-------------------------------------------------------------------------------------------------
4242
//-------------------------------------------------------------------------------------------------
4343

44+
// TheSuperHackers @bugfix xezon 15/09/2025 Adds a new horde action to select a fixed implementation.
45+
//
46+
// TheSuperHackers @todo If we want more control over the horde setup, then we need to implement
47+
// filters for separate weapon bonuses and required upgrades. But adding more behavior modules will
48+
// be a performance concern. Example INI setup:
49+
//
50+
// Behavior = HordeUpdate ModuleTag
51+
// Action = NATIONALISM
52+
// ;ApplyWeaponBonus = NATIONALISM
53+
// UpgradeRequired = Upgrade_Nationalism
54+
// End
55+
//
4456
enum HordeActionType CPP_11(: Int)
4557
{
46-
HORDEACTION_HORDE = 0,
58+
HORDEACTION_HORDE, ///< Classic action, applies the Horde bonus correctly, but Nationalism and Fanaticism bonuses are not removed after leaving horde.
59+
HORDEACTION_HORDE_FIXED, ///< Applies the Horde, Nationalism and Fanaticism bonuses correctly.
4760

48-
HORDEACTION_COUNT
61+
HORDEACTION_COUNT,
62+
63+
#if RETAIL_COMPATIBLE_CRC
64+
HORDEACTION_DEFAULT = HORDEACTION_HORDE,
65+
#else
66+
HORDEACTION_DEFAULT = HORDEACTION_HORDE_FIXED, ///< Does not change unmodified retail game behavior, because all its horde update modules explicitly set Action = HORDE.
67+
#endif
4968
};
5069

5170
#ifdef DEFINE_HORDEACTION_NAMES
5271
static const char *const TheHordeActionTypeNames[] =
5372
{
5473
"HORDE",
74+
"HORDE_FIXED",
75+
5576
NULL
5677
};
5778
static_assert(ARRAY_SIZE(TheHordeActionTypeNames) == HORDEACTION_COUNT + 1, "Incorrect array size");

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4753,6 +4753,12 @@ void AIUpdateInterface::evaluateMoraleBonus( Bool inHorde, Bool allowNationalism
47534753
case HORDEACTION_HORDE:
47544754
evaluateNationalismBonusClassic(inHorde, allowNationalism);
47554755
break;
4756+
4757+
#if !RETAIL_COMPATIBLE_CRC
4758+
case HORDEACTION_HORDE_FIXED:
4759+
evaluateNationalismBonus(inHorde, allowNationalism);
4760+
break;
4761+
#endif
47564762
}
47574763
}
47584764

@@ -4792,6 +4798,37 @@ void AIUpdateInterface::evaluateNationalismBonusClassic( Bool inHorde, Bool allo
47924798
}
47934799
}
47944800

4801+
// ------------------------------------------------------------------------------------------------
4802+
// TheSuperHackers @bugfix The fixed Nationalism Bonus implementation.
4803+
// Nationalism and Fanaticism are now tied to the horde status.
4804+
// And Fanaticism is no longer dependent on Nationalism.
4805+
// ------------------------------------------------------------------------------------------------
4806+
void AIUpdateInterface::evaluateNationalismBonus( Bool inHorde, Bool allowNationalism )
4807+
{
4808+
Object *us = getObject();
4809+
4810+
if( inHorde )
4811+
{
4812+
us->setWeaponBonusCondition( WEAPONBONUSCONDITION_HORDE );
4813+
4814+
if( allowNationalism && hasNationalism() )
4815+
{
4816+
us->setWeaponBonusCondition( WEAPONBONUSCONDITION_NATIONALISM );
4817+
}
4818+
4819+
if( allowNationalism && hasFanaticism() )
4820+
{
4821+
us->setWeaponBonusCondition( WEAPONBONUSCONDITION_FANATICISM );
4822+
}
4823+
}
4824+
else
4825+
{
4826+
us->clearWeaponBonusCondition( WEAPONBONUSCONDITION_HORDE );
4827+
us->clearWeaponBonusCondition( WEAPONBONUSCONDITION_NATIONALISM );
4828+
us->clearWeaponBonusCondition( WEAPONBONUSCONDITION_FANATICISM );
4829+
}
4830+
}
4831+
47954832
#ifdef ALLOW_DEMORALIZE
47964833
// ------------------------------------------------------------------------------------------------
47974834
// ------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/HordeUpdate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ HordeUpdateModuleData::HordeUpdateModuleData()
121121
, m_alliesOnly(true)
122122
, m_exactMatch(false)
123123
, m_allowedNationalism(TRUE)
124-
, m_action(HORDEACTION_HORDE)
124+
, m_action(HORDEACTION_DEFAULT)
125125
{
126126
}
127127

0 commit comments

Comments
 (0)