Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class BattlePlanUpdate : public UpdateModule, public SpecialPowerUpdateInterface
virtual void onObjectCreated();
virtual void onDelete();
virtual UpdateSleepTime update();
virtual void onCapture(Player* oldOwner, Player* newOwner);

virtual CommandOption getCommandOption() const;
protected:
Expand Down
22 changes: 13 additions & 9 deletions Generals/Code/GameEngine/Source/Common/RTS/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2971,22 +2971,26 @@ void Player::changeBattlePlan( BattlePlanStatus plan, Int delta, BattlePlanBonus
else if( removeBonus )
{
//First, inverse the bonuses
bonus->m_armorScalar = 1.0f / __max( bonus->m_armorScalar, 0.01f );
bonus->m_sightRangeScalar = 1.0f / __max( bonus->m_sightRangeScalar, 0.01f );
if( bonus->m_bombardment > 0 )
BattlePlanBonuses* invertedBonus = newInstance(BattlePlanBonuses);
*invertedBonus = *bonus;

invertedBonus->m_armorScalar = 1.0f / __max( bonus->m_armorScalar, 0.01f );
invertedBonus->m_sightRangeScalar = 1.0f / __max( bonus->m_sightRangeScalar, 0.01f );
if( invertedBonus->m_bombardment > 0 )
{
bonus->m_bombardment = -1;
invertedBonus->m_bombardment = -1;
}
if( bonus->m_holdTheLine > 0 )
if( invertedBonus->m_holdTheLine > 0 )
{
bonus->m_holdTheLine = -1;
invertedBonus->m_holdTheLine = -1;
}
if( bonus->m_searchAndDestroy > 0 )
if( invertedBonus->m_searchAndDestroy > 0 )
{
bonus->m_searchAndDestroy = -1;
invertedBonus->m_searchAndDestroy = -1;
}

applyBattlePlanBonusesForPlayerObjects( bonus );
applyBattlePlanBonusesForPlayerObjects( invertedBonus );
deleteInstance(invertedBonus);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ void BattlePlanUpdate::onObjectCreated()
enableTurret( false );
}

//-------------------------------------------------------------------------------------------------
void BattlePlanUpdate::onCapture(Player* oldOwner, Player* newOwner)
{
#if !RETAIL_COMPATIBLE_CRC
// TheSuperHackers @bugfix Stubbjax 04/11/2025 Transfer battle plan bonuses on capture.
oldOwner->changeBattlePlan(m_planAffectingArmy, -1, m_bonuses);
newOwner->changeBattlePlan(m_planAffectingArmy, 1, m_bonuses);
#endif
}

//-------------------------------------------------------------------------------------------------
Bool BattlePlanUpdate::initiateIntentToDoSpecialPower(const SpecialPowerTemplate *specialPowerTemplate, const Object *targetObj, const Coord3D *targetPos, const Waypoint *way, UnsignedInt commandOptions )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class BattlePlanUpdate : public SpecialPowerUpdateModule
virtual void onObjectCreated();
virtual void onDelete();
virtual UpdateSleepTime update();
virtual void onCapture(Player* oldOwner, Player* newOwner);

virtual CommandOption getCommandOption() const;
protected:
Expand Down
22 changes: 13 additions & 9 deletions GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3462,22 +3462,26 @@ void Player::changeBattlePlan( BattlePlanStatus plan, Int delta, BattlePlanBonus
else if( removeBonus )
{
//First, inverse the bonuses
bonus->m_armorScalar = 1.0f / __max( bonus->m_armorScalar, 0.01f );
bonus->m_sightRangeScalar = 1.0f / __max( bonus->m_sightRangeScalar, 0.01f );
if( bonus->m_bombardment > 0 )
BattlePlanBonuses* invertedBonus = newInstance(BattlePlanBonuses);
*invertedBonus = *bonus;

invertedBonus->m_armorScalar = 1.0f / __max( bonus->m_armorScalar, 0.01f );
invertedBonus->m_sightRangeScalar = 1.0f / __max( bonus->m_sightRangeScalar, 0.01f );
if( invertedBonus->m_bombardment > 0 )
{
bonus->m_bombardment = -1;
invertedBonus->m_bombardment = -1;
}
if( bonus->m_holdTheLine > 0 )
if( invertedBonus->m_holdTheLine > 0 )
{
bonus->m_holdTheLine = -1;
invertedBonus->m_holdTheLine = -1;
}
if( bonus->m_searchAndDestroy > 0 )
if( invertedBonus->m_searchAndDestroy > 0 )
{
bonus->m_searchAndDestroy = -1;
invertedBonus->m_searchAndDestroy = -1;
}

applyBattlePlanBonusesForPlayerObjects( bonus );
applyBattlePlanBonusesForPlayerObjects( invertedBonus );
deleteInstance(invertedBonus);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ void BattlePlanUpdate::onObjectCreated()
enableTurret( false );
}

//-------------------------------------------------------------------------------------------------
void BattlePlanUpdate::onCapture(Player* oldOwner, Player* newOwner)
{
#if !RETAIL_COMPATIBLE_CRC
// TheSuperHackers @bugfix Stubbjax 04/11/2025 Transfer battle plan bonuses on capture.
oldOwner->changeBattlePlan(m_planAffectingArmy, -1, m_bonuses);
newOwner->changeBattlePlan(m_planAffectingArmy, 1, m_bonuses);
#endif
}

//-------------------------------------------------------------------------------------------------
Bool BattlePlanUpdate::initiateIntentToDoSpecialPower(const SpecialPowerTemplate *specialPowerTemplate, const Object *targetObj, const Coord3D *targetPos, const Waypoint *way, UnsignedInt commandOptions )
{
Expand Down
Loading