Skip to content

refactor: Add override keyword to virtual function overrides in GameEngine (2)#2392

Merged
xezon merged 8 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/override-keyword-gameengine
Mar 18, 2026
Merged

refactor: Add override keyword to virtual function overrides in GameEngine (2)#2392
xezon merged 8 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/override-keyword-gameengine

Conversation

@bobtista
Copy link

@bobtista bobtista commented Mar 3, 2026

Summary

  • Add override keyword to virtual function overrides in GameEngine (excluding GameLogic/Module)
  • Covers Include/Common, Include/GameClient, Include/GameNetwork, Include/GameLogic (non-Module), and Source
  • Changes across Core, Generals, and GeneralsMD

Context

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

Notes

  • 294 files changed, purely mechanical override keyword additions
  • Includes bugfix: remove spurious virtual keyword from enum entries in Scripts.h
  • All lines retain the virtual keyword

@greptile-apps
Copy link

greptile-apps bot commented Mar 3, 2026

Greptile Summary

This PR is part 4/6 of a series splitting PR #2101, adding the override keyword to virtual function overrides across 291 files in Core, Generals, and GeneralsMD (covering Include/Common, Include/GameClient, Include/GameNetwork, Include/GameLogic non-Module, and Source). The changes are largely mechanical but also include genuine polymorphism bugfixes.

  • override additions — All existing virtual override declarations throughout the covered directories now carry override, bringing consistency and enabling compiler detection of signature mismatches.
  • Polymorphism bugfixes — Several functions that override pure-virtual base-class methods but were declared without virtual in the derived class have been correctly promoted to virtual … override in both Generals and GeneralsMD: ScriptActions (executeAction, closeWindows, doEnableOrDisableObjectDifficultyBonuses), ScriptConditions (evaluateCondition, evaluateTeamIsContained, evaluateSkirmishCommandButtonIsReady), and VictoryConditions (hasAchievedVictory, hasBeenDefeated, etc.). Without virtual, calls through a base-class pointer would not dispatch to the correct override.
  • Destructor chain fixes — Derived-class destructors (e.g. ~ScriptActions, ~ScriptConditions) that previously lacked virtual are now declared virtual … override, preventing undefined behaviour when deleting through a base-class pointer.
  • Missed overrideAudioManagerDummy::audioDebugDisplay inside its #if defined(RTS_DEBUG) block was not updated with override, leaving it inconsistent with every other method in that class.

Confidence Score: 5/5

  • Safe to merge — purely additive override annotations with targeted polymorphism bugfixes; no logic is altered.
  • All 291 changed files receive only override additions to pre-existing virtual declarations. The handful of functions newly promoted from non-virtual to virtual … override correctly correspond to pure-virtual methods in their base classes, fixing real (previously silent) bugs. The single missed override on audioDebugDisplay in AudioManagerDummy is a minor style inconsistency that does not affect runtime behaviour.
  • Core/GameEngine/Include/Common/GameAudio.h — audioDebugDisplay in AudioManagerDummy is the only virtual override in that class still lacking override.

Important Files Changed

Filename Overview
Core/GameEngine/Include/Common/GameAudio.h Adds override to all virtual overrides in AudioManager and AudioManagerDummy, except audioDebugDisplay in AudioManagerDummy which was skipped (inside #if defined(RTS_DEBUG) block).
Generals/Code/GameEngine/Include/GameLogic/ScriptActions.h Promotes executeAction, closeWindows, and doEnableOrDisableObjectDifficultyBonuses to virtual … override, fixing a real polymorphism issue where these pure-virtual overrides lacked virtual; also fixes the destructor chain.
GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptActions.h Same polymorphism bugfix as the Generals counterpart — executeAction, closeWindows, and doEnableOrDisableObjectDifficultyBonuses are now correctly virtual … override.
Generals/Code/GameEngine/Include/GameLogic/ScriptConditions.h Promotes evaluateCondition, evaluateTeamIsContained, and evaluateSkirmishCommandButtonIsReady — all pure-virtual overrides that previously lacked virtual — to virtual … override, fixing polymorphic dispatch through ScriptConditionsInterface*.
GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptConditions.h Same polymorphism bugfixes as the Generals counterpart — evaluateCondition, evaluateTeamIsContained, and evaluateSkirmishCommandButtonIsReady now correctly carry virtual … override.
Generals/Code/GameEngine/Include/GameLogic/Scripts.h Mechanical addition of override to crc, xfer, and loadPostProcess in ScriptGroup, Script, and ScriptList. All changes are correct.
GeneralsMD/Code/GameEngine/Include/GameLogic/Scripts.h Same mechanical override additions as the Generals counterpart.
GeneralsMD/Code/GameEngine/Include/GameLogic/AIGuardRetaliate.h Mechanical override additions to state machine virtual methods (onEnter, update, onExit, crc, xfer, loadPostProcess, shouldExit) — all correct and GeneralsMD-only.
Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/VictoryConditions.cpp Promotes several non-virtual overrides (init, reset, update, hasAchievedVictory, etc.) to virtual … override, fixing polymorphic dispatch through VictoryConditionsInterface*.
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpectreGunshipUpdate.cpp Adds override to PartitionFilterLiveMapEnemies::allow — correct and GeneralsMD-only.

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class SubsystemInterface {
        +virtual ~SubsystemInterface()
        +virtual void init() = 0
        +virtual void reset() = 0
        +virtual void update() = 0
        +virtual void postProcessLoad()
    }

    class ScriptActionsInterface {
        +virtual ~ScriptActionsInterface() override
        +virtual void init() = 0
        +virtual void reset() = 0
        +virtual void update() = 0
        +virtual void executeAction() = 0
        +virtual void closeWindows() = 0
        +virtual void doEnableOrDisableObjectDifficultyBonuses() = 0
    }

    class ScriptActions {
        +virtual ~ScriptActions() override
        +virtual void init() override
        +virtual void reset() override
        +virtual void update() override
        +virtual void executeAction() override
        +virtual void closeWindows() override
        +virtual void doEnableOrDisableObjectDifficultyBonuses() override
    }

    class ScriptConditionsInterface {
        +virtual ~ScriptConditionsInterface() override
        +virtual void init() = 0
        +virtual Bool evaluateCondition() = 0
        +virtual Bool evaluateTeamIsContained() = 0
        +virtual Bool evaluateSkirmishCommandButtonIsReady() = 0
    }

    class ScriptConditions {
        +virtual ~ScriptConditions() override
        +virtual void init() override
        +virtual Bool evaluateCondition() override
        +virtual Bool evaluateTeamIsContained() override
        +virtual Bool evaluateSkirmishCommandButtonIsReady() override
    }

    class AudioManager {
        +virtual ~AudioManager() override
        +virtual void init() override
        +virtual void stopAudio() = 0
    }

    class AudioManagerDummy {
        +virtual void audioDebugDisplay() [missing override]
        +virtual void stopAudio() override
        +virtual void pauseAudio() override
    }

    SubsystemInterface <|-- ScriptActionsInterface
    ScriptActionsInterface <|-- ScriptActions
    SubsystemInterface <|-- ScriptConditionsInterface
    ScriptConditionsInterface <|-- ScriptConditions
    SubsystemInterface <|-- AudioManager
    AudioManager <|-- AudioManagerDummy
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: Core/GameEngine/Include/Common/GameAudio.h
Line: 391

Comment:
**Missing `override` on `audioDebugDisplay` in `AudioManagerDummy`**

The `audioDebugDisplay` method in `AudioManagerDummy` (line 391) was not updated with the `override` keyword, while every other virtual override in this class was updated as part of this PR. Because the method is inside a `#if defined(RTS_DEBUG)` block, it appears to have been missed during the mechanical pass.

```suggestion
	virtual void audioDebugDisplay(DebugDisplayInterface* dd, void* userData, FILE* fp) override {}
```

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

Last reviewed commit: "refactor: Add missin..."

@bobtista bobtista force-pushed the bobtista/override-keyword-gameengine branch from 3b4cf3d to d8471a3 Compare March 9, 2026 20:11
@xezon xezon added the Refactor Edits the code with insignificant behavior changes, is never user facing label Mar 10, 2026
@bobtista bobtista force-pushed the bobtista/override-keyword-gameengine branch from f2574b2 to 949b25a Compare March 12, 2026 20:17
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.

Looks good

@xezon xezon changed the title refactor(GameEngine): Add override keyword to virtual function overrides refactor: Add override keyword to virtual function overrides in GameEngine (2) Mar 13, 2026
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.

I only glanced over it and it appears to be OK

@xezon xezon merged commit 73fea43 into TheSuperHackers:main Mar 18, 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