refactor: Add override keyword to virtual function overrides in Generals code (2)#2604
refactor: Add override keyword to virtual function overrides in Generals code (2)#2604Caball009 wants to merge 5 commits intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| Generals/Code/Libraries/Source/WWVegas/WW3D2/scene.h | Fixes pre-existing bug: adds const + override to Get_Scene_ID(); previously the non-const version silently hid the base-class const method instead of overriding it |
| Generals/Code/GameEngine/Include/Common/Module.h | Adds override to MAKE_STANDARD_MODULE_MACRO and MAKE_STANDARD_MODULE_MACRO_ABC macros; also adds new forward declaration and virtual getAsW3DTreeDrawModuleData() following existing W3DModelDrawModuleData pattern |
| Generals/Code/GameEngine/Include/Common/StateMachine.h | Removes redundant crc/xfer/loadPostProcess pure-virtual re-declarations from the State class; these are still enforced by the Snapshot base class |
| Generals/Code/GameEngine/Include/GameLogic/Module/BodyModule.h | Removes redundant pure-virtual declarations (attemptDamage, attemptHealing, estimateDamage, getHealth, etc.) from intermediate BodyModule; interface class still enforces them |
| Generals/Code/GameEngine/Include/GameLogic/ScriptActions.h | Removes init()/reset()/update() pure-virtual re-declarations; already declared as pure virtuals in SubsystemInterface base class |
| Generals/Code/GameEngine/Include/GameLogic/ScriptConditions.h | Same as ScriptActions.h — removes redundant init()/reset()/update() pure-virtual re-declarations already in SubsystemInterface |
| Generals/Code/GameEngine/Include/GameLogic/PartitionManager.h | Adds override to ~20 PartitionFilter*::debugGetName() methods inside #if defined(RTS_DEBUG) guards; straightforward mechanical change |
| Generals/Code/GameEngine/Include/GameClient/InGameUI.h | Adds override to draw() = 0; virtual … override = 0 is valid C++11 and documents that this re-declared pure virtual overrides a base-class virtual |
| Generals/Code/GameEngine/Include/GameLogic/AIStateMachine.h | Adds override to eight getName() const debug-only methods inside #ifdef STATE_MACHINE_DEBUG guards |
| Generals/Code/GameEngine/Include/GameLogic/Module/UpdateModule.h | Removes redundant virtual UpdateSleepTime update() = 0 re-declaration from UpdateModule; still enforced through the interface hierarchy |
| Generals/Code/GameEngine/Include/GameLogic/Module/OpenContain.h | Adds override to addToContainList(); mirrors matching change in OverlordContain.h |
Class Diagram
%%{init: {'theme': 'neutral'}}%%
classDiagram
class SubsystemInterface {
+init()*
+reset()*
+update()*
}
class ScriptActionsInterface {
+executeAction()*
+closeWindows()*
}
class ScriptConditionsInterface {
+evaluateCondition()*
}
SubsystemInterface <|-- ScriptActionsInterface
SubsystemInterface <|-- ScriptConditionsInterface
class Snapshot {
+crc()*
+xfer()*
+loadPostProcess()*
}
class State {
+update()*
}
Snapshot <|-- State
class SceneClass {
+Get_Scene_ID() const
}
class SimpleSceneClass {
+Get_Scene_ID() const override
}
SceneClass <|-- SimpleSceneClass
class PartitionFilter {
+allow()*
+debugGetName()
}
class PartitionFilterIsFlying {
+allow() override
+debugGetName() override
}
PartitionFilter <|-- PartitionFilterIsFlying
Reviews (1): Last reviewed commit: "Added 'override' to pure virtual functio..." | Re-trigger Greptile
| // ugh, hack | ||
| virtual const W3DModelDrawModuleData* getAsW3DModelDrawModuleData() const { return nullptr; } | ||
| // ugh, hack | ||
| virtual const W3DTreeDrawModuleData* getAsW3DTreeDrawModuleData() const { return nullptr; } |
|
|
||
| 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 ~SimpleSceneClass() override; | ||
|
|
||
| virtual int Get_Scene_ID() { return SCENE_ID_SIMPLE; } | ||
| virtual int Get_Scene_ID() const override { return SCENE_ID_SIMPLE; } |
This PR adds the keyword
overrideto a number of virtual functions in the Generals code that were missed in the previous round of refactoring.Check out the commits as they separate different types of changes.
Related PRs:
#2603
#2605