refactor: Add override keyword to virtual function overrides in Zero Hour code (2)#2605
refactor: Add override keyword to virtual function overrides in Zero Hour code (2)#2605Caball009 wants to merge 6 commits intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Include/Common/Module.h | Adds override to crc/xfer/loadPostProcess in both MAKE_STANDARD_MODULE_MACRO and MAKE_STANDARD_MODULE_MACRO_ABC macros, providing compile-time verification for all consuming classes |
| GeneralsMD/Code/GameEngine/Include/Common/StateMachine.h | Removes redundant pure-virtual redeclarations of crc/xfer/loadPostProcess from State — these are already inherited as pure virtuals from the Snapshot base class |
| GeneralsMD/Code/GameEngine/Include/GameLogic/Module/FlightDeckBehavior.h | Adds const and override to getNaturalRallyPoint — previously missing const meant it silently shadowed the base class const version rather than overriding it; also adds override to getTaxiLocations and getCreationLocations |
| GeneralsMD/Code/GameEngine/Include/GameLogic/Module/OverlordContain.h | Adds const override to isBustable — the missing const meant it shadowed OpenContain::isBustable() const rather than overriding it; also adds override to addToContainList |
| GeneralsMD/Code/GameEngine/Include/GameLogic/Module/BodyModule.h | Removes redundant pure-virtual redeclarations (attemptDamage, attemptHealing, getHealth, getDamageState, etc.) already declared in BodyModuleInterface |
| GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerUpdateModule.h | Removes redundant pure-virtual redeclarations already present in SpecialPowerUpdateInterface |
| GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptActions.h | Removes redundant init/reset/update pure-virtual redeclarations already present in SubsystemInterface base class |
| GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptConditions.h | Removes redundant init/reset/update pure-virtual redeclarations already present in SubsystemInterface base class |
| GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h | Adds override to all debugGetName() implementations across ~20 PartitionFilter subclasses; purely mechanical but comprehensive |
| GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h | Adds override to draw() = 0 — valid C++11 syntax correctly indicating InGameUI inherits a virtual draw() and re-declares it pure virtual for its own subclasses |
| GeneralsMD/Code/GameEngine/Include/GameLogic/Module/UpgradeModule.h | Removes isSubObjectsUpgrade() = 0 — already declared pure-virtual in both UpgradeMux and UpgradeModuleInterface, making the UpgradeModule redeclaration redundant |
| GeneralsMD/Code/GameEngine/Include/GameLogic/Module/UpdateModule.h | Removes redundant update() = 0 redeclaration from UpdateModule, already in UpdateModuleInterface |
| GeneralsMD/Code/GameEngine/Include/GameLogic/AIStateMachine.h | Adds override to 9 getName() / getCurrentStateName() declarations gated behind STATE_MACHINE_DEBUG; purely mechanical |
Class Diagram
%%{init: {'theme': 'neutral'}}%%
classDiagram
class Snapshot {
+crc(xfer) virtual=0
+xfer(xfer) virtual=0
+loadPostProcess() virtual=0
}
class State {
<<abstract>>
note: pure-virtual redecls removed
}
class StateMachine {
+crc(xfer) override
+xfer(xfer) override
+loadPostProcess() override
}
class Module {
<<macro MAKE_STANDARD_MODULE_MACRO>>
+crc(xfer) override
+xfer(xfer) override
+loadPostProcess() override
}
class OpenContain {
+isBustable() const override
+addToContainList(obj) override
+getNaturalRallyPoint(...) const override
}
class OverlordContain {
+isBustable() const override
note: const added — now correctly overrides
}
class FlightDeckBehavior {
+getNaturalRallyPoint(...) const override
note: const added — now correctly overrides
+getTaxiLocations(id) const override
+getCreationLocations(id) const override
}
Snapshot <|-- State
Snapshot <|-- StateMachine
Snapshot <|-- Module
OpenContain <|-- OverlordContain
OpenContain <|-- FlightDeckBehavior
Reviews (2): Last reviewed commit: "Restored 'override' on destructor of 'Sc..." | Re-trigger Greptile
|
|
||
| virtual void preDraw(); ///< Logic which needs to occur before the UI renders | ||
| virtual void draw() = 0; ///< Render the in-game user interface | ||
| virtual void draw() override = 0; ///< Render the in-game user interface |
There was a problem hiding this comment.
Nothing. It's just to acknowledge that the base class also has this exact function, but it's not pure virtual. If that were removed that would lead to a compilation error here, which seems desirable.
| virtual void exitObjectByBudding( Object *newObj, Object *budHost ) override { return; } | ||
| virtual Bool getExitPosition( Coord3D& rallyPoint ) const override { return FALSE; } | ||
| virtual Bool getNaturalRallyPoint( Coord3D& rallyPoint, Bool offset = TRUE ) { return FALSE; } | ||
| virtual Bool getNaturalRallyPoint( Coord3D& rallyPoint, Bool offset = TRUE ) const override { return FALSE; } |
| virtual OpenContain *asOpenContain() override { return this; } ///< treat as open container | ||
| virtual Bool isGarrisonable() const override; ///< can this unit be Garrisoned? (ick) | ||
| virtual Bool isBustable() { return false;}; ///< can this container get busted by bunkerbuster? (ick) | ||
| virtual Bool isBustable() const override { return false;}; ///< can this container get busted by bunkerbuster? (ick) |
This PR adds the keyword
overrideto a number of virtual functions in the Zero Hour code that were missed in the previous round of refactoring.Check out the commits as they separate different types of changes.
Related PRs:
#2603
#2604