Skip to content

Commit b87de30

Browse files
committed
bugfix(supply): Implement proportional supply bonus scaling
Signed-off-by: tintinhamans <5984296+tintinhamans@users.noreply.github.com>
1 parent 4c72d32 commit b87de30

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ class SupplyTruckAIInterface
161161
// who look this up by name.
162162
public:
163163
virtual Int getNumberBoxes() const = 0;
164+
// TheSuperHackers @refactor arcticdolphin 09/03/2026 Expose MaxBoxes for proportional supply bonus.
165+
virtual Int getMaxBoxes() const = 0;
164166
virtual Bool loseOneBox() = 0;
165167
virtual Bool gainOneBox( Int remainingStock ) = 0;
166168

@@ -197,6 +199,8 @@ class SupplyTruckAIUpdate : public AIUpdateInterface, public SupplyTruckAIInterf
197199
virtual const SupplyTruckAIInterface* getSupplyTruckAIInterface() const {return this;}
198200

199201
virtual Int getNumberBoxes() const { return m_numberBoxes; }
202+
// TheSuperHackers @refactor arcticdolphin 09/03/2026 Expose MaxBoxes for proportional supply bonus.
203+
virtual Int getMaxBoxes() const { return getSupplyTruckAIUpdateModuleData()->m_maxBoxesData; }
200204
virtual Bool loseOneBox();
201205
virtual Bool gainOneBox( Int remainingStock );
202206

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ class WorkerAIUpdate : public AIUpdateInterface, public DozerAIInterface, public
180180

181181
// Supply truck stuff
182182
virtual Int getNumberBoxes() const { return m_numberBoxes; }
183+
// TheSuperHackers @refactor arcticdolphin 09/03/2026 Expose MaxBoxes for proportional supply bonus.
184+
virtual Int getMaxBoxes() const { return getWorkerAIUpdateModuleData()->m_maxBoxesData; }
183185
virtual Bool loseOneBox();
184186
virtual Bool gainOneBox( Int remainingStock );
185187

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,25 @@ Bool SupplyCenterDockUpdate::action( Object* docker, Object *drone )
9595
return FALSE;
9696

9797
UnsignedInt value = 0;
98+
#if !RETAIL_COMPATIBLE_CRC
99+
// TheSuperHackers @refactor arcticdolphin 09/03/2026 Snapshot box count before unload loop.
100+
Int deliveredBoxes = supplyTruckAI->getNumberBoxes();
101+
#endif
98102
Player *ownerPlayer = getObject()->getControllingPlayer();
99103
while( supplyTruckAI->loseOneBox() )
100104
value += ownerPlayer->getSupplyBoxValue();
101105

102106
// Add money boost from upgrades that give extra money
107+
#if !RETAIL_COMPATIBLE_CRC
108+
// TheSuperHackers @bugfix arcticdolphin 09/03/2026 Scale supply bonus proportionally to delivered boxes.
109+
Int upgradedSupplyBoost = supplyTruckAI->getUpgradedSupplyBoost();
110+
if( upgradedSupplyBoost > 0 && deliveredBoxes > 0 )
111+
{
112+
value += upgradedSupplyBoost * deliveredBoxes / supplyTruckAI->getMaxBoxes(); // Intentional integer truncation.
113+
}
114+
#else
103115
value += supplyTruckAI->getUpgradedSupplyBoost();
116+
#endif
104117

105118
if( value > 0)
106119
{

0 commit comments

Comments
 (0)