Skip to content

refactor: Add override keyword to virtual function overrides in Generals code (2)#2604

Open
Caball009 wants to merge 5 commits intoTheSuperHackers:mainfrom
Caball009:override_keyword_gen
Open

refactor: Add override keyword to virtual function overrides in Generals code (2)#2604
Caball009 wants to merge 5 commits intoTheSuperHackers:mainfrom
Caball009:override_keyword_gen

Conversation

@Caball009
Copy link
Copy Markdown

@Caball009 Caball009 commented Apr 15, 2026

This PR adds the keyword override to 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

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 15, 2026

Greptile Summary

This PR adds the missing override keyword to virtual function overrides across 37 files, continuing the cleanup started in #2101. Beyond the keyword additions, it also removes redundant pure-virtual re-declarations from intermediate abstract classes (BodyModule, CollideModule, CreateModule, DamageModule, DestroyModule, DieModule, ObjectHelper, UpdateModule, UpgradeModule, ScriptActionsInterface, ScriptConditionsInterface) where the same pure virtuals are already enforced by the top-level interface, and fixes a silent const-correctness bug in SimpleSceneClass::Get_Scene_ID().

Confidence Score: 5/5

Safe to merge — all changes are additive override annotations or removal of redundant pure-virtual re-declarations; no logic is altered.

All 37 files contain mechanical refactoring: adding the missing override keyword, removing redundant re-declarations of pure virtuals that are already enforced by the top-level interface or Snapshot base class, and an incidental const-correctness fix in SimpleSceneClass::Get_Scene_ID(). No new logic is introduced, no signatures are broken, and every override added will be verified by the compiler at build time. No P0 or P1 findings exist.

No files require special attention.

Important Files Changed

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
Loading

Reviews (1): Last reviewed commit: "Added 'override' to pure virtual functio..." | Re-trigger Greptile

@xezon xezon changed the title refactor: Add override keyword to virtual function overrides in Generals code refactor: Add override keyword to virtual function overrides in Generals code (2) Apr 16, 2026
// ugh, hack
virtual const W3DModelDrawModuleData* getAsW3DModelDrawModuleData() const { return nullptr; }
// ugh, hack
virtual const W3DTreeDrawModuleData* getAsW3DTreeDrawModuleData() const { return nullptr; }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this hack added?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this is a merge from Zero Hour.


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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if this is omitted?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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; }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this fix a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Edits the code with insignificant behavior changes, is never user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants