bugfix(supply): Implement proportional supply bonus scaling#2431
bugfix(supply): Implement proportional supply bonus scaling#2431tintinhamans wants to merge 1 commit intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SupplyTruckAIUpdate.h | Adds getMaxBoxes() as a pure virtual method to SupplyTruckAIInterface and provides an inline implementation in SupplyTruckAIUpdate returning m_maxBoxesData. ChinookAIUpdate, which extends SupplyTruckAIUpdate, inherits the implementation correctly via its SupplyTruckAIUpdateModuleData base. No issues. |
| GeneralsMD/Code/GameEngine/Include/GameLogic/Module/WorkerAIUpdate.h | Adds the getMaxBoxes() override to WorkerAIUpdate, delegating to m_maxBoxesData on its own module data. Consistent with the SupplyTruckAIUpdate implementation. No issues. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp | Introduces getUpgradedSupplyBoostValue() helper that correctly snapshots box count before unloading and computes proportional bonus. The maxBoxes > 0 guard prevents division by zero. However, when maxBoxes == 0 and upgradedSupplyBoost > 0, the bonus is silently dropped to 0 (regression vs. unconfigured units), though this case was accepted by the team in prior review threads. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["SupplyCenterDockUpdate::action()"] --> B["getUpgradedSupplyBoostValue(supplyTruckAI)"]
B --> C{RETAIL_COMPATIBLE_CRC?}
C -- Yes --> D["return getUpgradedSupplyBoost() (full flat bonus)"]
C -- No --> E["maxBoxes = getMaxBoxes()"]
E --> F{maxBoxes > 0?}
F -- No --> G["return 0"]
F -- Yes --> H["upgradedSupplyBoost = getUpgradedSupplyBoost()
deliveredBoxes = getNumberBoxes()"]
H --> I["return (upgradedSupplyBoost × deliveredBoxes) / maxBoxes"]
D --> J["value += boost"]
G --> J
I --> J
J --> K["while loseOneBox(): value += getSupplyBoxValue()"]
K --> L{value > 0?}
L -- Yes --> M["deposit(value) + floating text"]
L -- No --> N["return FALSE"]
M --> N
Last reviewed commit: 67212ba
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
7bfc70d to
0f2e2bf
Compare
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
| Int maxBoxes = supplyTruckAI->getMaxBoxes(); | ||
| if( maxBoxes > 0 ) | ||
| { | ||
| value += upgradedSupplyBoost * deliveredBoxes / maxBoxes; // Intentional integer truncation. |
There was a problem hiding this comment.
Is the idea that the supply boost is only applied up to maxBoxes?
So if we have a limit of 5 boxes but we deliver 7? we should only be applying the boost to 5 boxes?
Since the above will be under valuing the bonus if so.
There was a problem hiding this comment.
Nvm i misunderstood what it was doing.
But if max boxes is zero then should we be giving any kind of bonus since shouldn't it technically not be able to carry anything?
There was a problem hiding this comment.
Good point - units with maxBoxes 0 have no business docking supplies anyways.
0f2e2bf to
b87de30
Compare
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
e3eadf6 to
bab6097
Compare
GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SupplyTruckAIUpdate.h
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
|
Is this Zero Hour only? |
No Supply Lines upgrade in Generals, only in ZH. |
824e79e to
bb5a635
Compare
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/SupplyCenterDockUpdate.cpp
Outdated
Show resolved
Hide resolved
Signed-off-by: tintinhamans <5984296+tintinhamans@users.noreply.github.com>
bb5a635 to
67212ba
Compare
Added a new
getMaxBoxes()method toSupplyTruckAIInterfaceand implemented it in bothSupplyTruckAIUpdateandWorkerAIUpdateto expose the configured maximum box capacity.Updated
SupplyCenterDockUpdate::actionto snapshot the box count before unloading and scale the upgrade bonus proportionally to the delivered cargo.Closes #132