perf(productionupdate): Simplify implementations of ProductionUpdate::cancelUnitCreate, ProductionUpdate::cancelUpgrade and revert ProductionUpdate::cancelAndRefundAllProduction closer to what it did originally - #3270
Conversation
…:cancelUnitCreate, ProductionUpdate::cancelUpgrade and revert ProductionUpdate::cancelAndRefundAllProduction closer to what it did originally
PR Summary by QodoSimplify production cancellation and preserve CRC-safe cleanup
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ProductionUpdate.h | Changes cancelUpgrade to return Bool and declares protected ProductionEntry-based cancellation helpers. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp | Implements pointer-based cancellation and explicit, deterministic failure handling during bulk cleanup. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[cancelAndRefundAllProduction] --> B{Queue head type}
B -->|Unit| C[cancelUnitCreate entry]
B -->|Upgrade| D[cancelUpgrade entry]
C -->|Success| E[Refund and remove head]
C -->|Failure| F[Remove head without refund]
D -->|Success| E
D -->|Failure, retail-compatible| G[Stop cleanup]
D -->|Failure, non-retail| F
E --> H{Queue remains and limit not reached?}
F --> H
H -->|Yes| B
H -->|No| I[Finish]
Reviews (1): Last reviewed commit: "perf(productionupdate): Simplify impleme..." | Re-trigger Greptile
Code Review by Qodo
1. Players lose queued-production refunds
|
This change simplifies the implementations of
ProductionUpdate::cancelUnitCreateandProductionUpdate::cancelUpgradeso that internally they can operate straight on the ProductionEntry pointer instead of looking for it in the list again by its ID.And it reverts
ProductionUpdate::cancelAndRefundAllProductioncloser to what it did originally to prevent potential CRC mismatches (ifcancelUpgradewould fail somehow) after #2399.TODO