Skip to content

refactor: Add override keyword to virtual function overrides in GameEngine#2391

Merged
xezon merged 6 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/override-keyword-gamelogic-module
Mar 13, 2026
Merged

refactor: Add override keyword to virtual function overrides in GameEngine#2391
xezon merged 6 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/override-keyword-gamelogic-module

Conversation

@bobtista
Copy link

@bobtista bobtista commented Mar 3, 2026

Summary

  • Add override keyword to virtual function overrides in GameEngine/Include/GameLogic/Module
  • Changes across Generals and GeneralsMD

Context

Part 3/6 of splitting #2101. Depends on #2389 merging first.

Notes

  • 397 files changed, purely mechanical override keyword additions
  • All lines retain the virtual keyword

@greptile-apps
Copy link

greptile-apps bot commented Mar 3, 2026

Greptile Summary

This PR is part 3 of 6 splitting a larger refactor (#2101), adding the override keyword to virtual function overrides across 397 header files in GameEngine/Include/GameLogic/Module for both the Generals and GeneralsMD codebases. The changes are purely mechanical and improve compile-time safety by enabling the compiler to verify that each marked function actually overrides a base-class virtual, while retaining the redundant (but harmless) virtual keyword on all declarations.

Key observations:

  • ~2,600 virtual function declarations across both codebases correctly received override
  • Non-override virtual declarations (e.g., first declarations in a class hierarchy such as BehaviorModule::getStealth()) were correctly left untouched
  • One inconsistency found in both Generals/Code/GameEngine/Include/GameLogic/Module/DieModule.h and GeneralsMD/Code/GameEngine/Include/GameLogic/Module/DieModule.h at line 100: DieModule::onDie() previously lacked the virtual keyword entirely (which this PR correctly restores), but the override specifier was not added — unlike every other changed declaration in the PR. Since DieModule inherits onDie from DieModuleInterface, this re-declaration is an override and should carry override for consistency.

Confidence Score: 5/5

  • Safe to merge — purely mechanical keyword additions with no behavioral changes and only one minor stylistic inconsistency.
  • All ~2,600 changes are additive-only keyword annotations that carry no runtime impact. The single inconsistency (DieModule::onDie gaining virtual but not override) is stylistic and does not affect compilation or behavior.
  • Generals/Code/GameEngine/Include/GameLogic/Module/DieModule.h and GeneralsMD/Code/GameEngine/Include/GameLogic/Module/DieModule.h — both have the onDie re-declaration that gained virtual but is missing override.

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Include/GameLogic/Module/DieModule.h Added override to getDie() and added missing virtual to onDie(), but onDie() is missing override for consistency with the rest of the PR.
GeneralsMD/Code/GameEngine/Include/GameLogic/Module/DieModule.h Same as Generals counterpart — virtual added to onDie() but override omitted; otherwise mechanical override additions are correct.
Generals/Code/GameEngine/Include/GameLogic/Module/BehaviorModule.h All virtual overrides in the BehaviorModule base correctly received override; non-override methods like getStealth() were appropriately left unchanged.
GeneralsMD/Code/GameEngine/Include/GameLogic/Module/BehaviorModule.h Consistent with Generals counterpart; getStealth() and getSpyVisionUpdate() (first declarations in hierarchy) correctly left without override.
Generals/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h Mechanical override additions to getAIUpdateInterface(), getDisabledTypesToProcess(), onObjectCreated(), aiDoCommand(), update(), and getUpdatePhase() look correct.
Generals/Code/GameEngine/Include/GameLogic/Module/DestroyModule.h override added to getDestroy(); the pure virtual onDestroy() which already had virtual was correctly left unchanged (consistent in that it wasn't touched, unlike the DieModule case).
GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h Correct mechanical override additions mirroring the Generals version.
Generals/Code/GameEngine/Include/GameLogic/Module/ActiveBody.h Large number of override additions to body-module overrides; all changes appear correct and consistent.

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class DieModuleInterface {
        +virtual onDie(damageInfo) = 0
    }
    class BehaviorModule {
        +virtual getDie() override
    }
    class DieModule {
        +virtual getDie() override
        +virtual onDie(damageInfo) = 0 %% missing override
    }
    class CrushDie {
        +virtual onDie(damageInfo) override
    }
    class DestroyDie {
        +virtual onDie(damageInfo) override
    }
    class FXListDie {
        +virtual onDie(damageInfo) override
    }

    BehaviorModule <|-- DieModule
    DieModuleInterface <|-- DieModule
    DieModule <|-- CrushDie
    DieModule <|-- DestroyDie
    DieModule <|-- FXListDie
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: Generals/Code/GameEngine/Include/GameLogic/Module/DieModule.h
Line: 100

Comment:
**Missing `override` on re-declared pure virtual**

This line previously read `void onDie( const DamageInfo *damageInfo ) = 0;` (without `virtual`). This PR correctly restores the `virtual` keyword, but unlike the rest of the changes in this PR the `override` specifier was not added. Since `DieModule` inherits from `DieModuleInterface`, which declares `virtual void onDie( const DamageInfo *damageInfo ) = 0;`, the re-declaration in `DieModule` is an override of that pure virtual and should carry `override` for consistency with every other modified declaration in this PR.

The same issue exists in `GeneralsMD/Code/GameEngine/Include/GameLogic/Module/DieModule.h` at line 100.

```suggestion
	virtual void onDie( const DamageInfo *damageInfo ) override = 0;
```

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: 9af9679

@bobtista bobtista force-pushed the bobtista/override-keyword-gamelogic-module branch from 89af460 to aa5c2ff Compare March 9, 2026 20:13
Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

override = 0 needs looking into. For all refactors of this kind.

@xezon xezon added the Refactor Edits the code with insignificant behavior changes, is never user facing label Mar 10, 2026
Copy link

@Skyaero42 Skyaero42 left a comment

Choose a reason for hiding this comment

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

This looks good now

@xezon xezon changed the title refactor(GameLogic/Module): Add override keyword to virtual function overrides refactor: Add override keyword to virtual function overrides in GameEngine Mar 13, 2026
@xezon xezon merged commit e18c47f into TheSuperHackers:main Mar 13, 2026
23 checks passed
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.

3 participants