Skip to content

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

Open
bobtista wants to merge 6 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/override-keyword-gameengine
Open

refactor(GameEngine): Add override keyword to virtual function overrides#2392
bobtista wants to merge 6 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 splitting PR #2101, adding the override keyword to virtual function overrides across 291 files in the GameEngine (Core, Generals, and GeneralsMD) — covering Include/Common, Include/GameClient, Include/GameNetwork, Include/GameLogic (non-Module), and Source. The changes are overwhelmingly mechanical and compiler-enforced: any incorrectly applied override would produce a compile error.

Notable non-trivial changes beyond pure mechanics:

  • ScriptActions.h (both Generals and GeneralsMD): executeAction, closeWindows, and doEnableOrDisableObjectDifficultyBonuses are promoted from non-virtual to virtual override, fixing previously silent polymorphism dispatch failures when these methods were called through a ScriptActionsInterface* pointer. The destructor chain (ScriptActions and ScriptActionsInterface) is also correctly annotated.
  • ScriptConditions.h (both Generals and GeneralsMD): evaluateCondition, evaluateTeamIsContained, and evaluateSkirmishCommandButtonIsReady are similarly promoted; all three are declared as pure-virtual in ScriptConditionsInterface, confirming the override is valid.
  • ScriptActionsInterface / ScriptConditionsInterface destructors: Now annotated override against SubsystemInterface::~SubsystemInterface(), which is confirmed virtual — no issue.
  • GameWindowTransitions.h: Multiple Transition subclasses gain override on init/update/reverse/draw/skip; the enum{} blocks following each class body are correctly left untouched.

Confidence Score: 5/5

  • This PR is safe to merge — all changes are compiler-enforced override annotations with no behavioral side effects.
  • 294 files changed with purely mechanical override additions. The C++ compiler statically verifies every override annotation, so any mistake would be a build error rather than a silent regression. The handful of non-trivial promotions (ScriptActions, ScriptConditions) are genuine bug fixes that align the declarations with their base-class pure-virtual counterparts, confirmed by reading both the interface and implementation headers.
  • No files require special attention beyond the already-reviewed ScriptActions.h and ScriptConditions.h promotions.

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Include/GameLogic/ScriptActions.h Non-virtual methods executeAction, closeWindows, and doEnableOrDisableObjectDifficultyBonuses are correctly promoted to virtual override, fixing previously silent polymorphism dispatch issues when called through a ScriptActionsInterface*.
GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptActions.h Mirror of Generals/ScriptActions.h - same virtual override promotion for executeAction, closeWindows, doEnableOrDisableObjectDifficultyBonuses, and the destructor chain.
Generals/Code/GameEngine/Include/GameLogic/ScriptConditions.h evaluateCondition, evaluateTeamIsContained, and evaluateSkirmishCommandButtonIsReady promoted to virtual override — all three are declared as pure-virtual in ScriptConditionsInterface, so the override keyword is correct.
GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptConditions.h Mirror of Generals/ScriptConditions.h — same virtual override promotions for evaluateCondition, evaluateTeamIsContained, and evaluateSkirmishCommandButtonIsReady.
Core/GameEngine/Include/Common/GameAudio.h AudioManager and AudioManagerDummy virtual overrides correctly annotated; SubsystemInterface has a virtual destructor so all override annotations are valid.
Core/GameEngine/Include/GameClient/GameWindowTransitions.h All Transition subclasses (TextOnFrame, ReverseSound, FullFade, ControlBarArrow, ScreenFade, CountUp, TextType) gain override annotations on init/update/reverse/draw/skip/destructor; the enum{} blocks immediately following are untouched as expected.
GeneralsMD/Code/GameEngine/Include/GameLogic/AIGuardRetaliate.h GeneralsMD-only file; all State subclass overrides (onEnter/update/onExit, crc/xfer/loadPostProcess, shouldExit) correctly annotated with override.
GeneralsMD/Code/GameEngine/Include/Common/AcademyStats.h GeneralsMD-only class; Snapshot virtual methods crc/xfer/loadPostProcess correctly annotated with override.

Class Diagram

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

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

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

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

    class ScriptConditions {
        +virtual ~ScriptConditions() override
        +virtual init() override
        +virtual reset() override
        +virtual update() override
        +virtual evaluateCondition() override
        +virtual evaluateTeamIsContained() override
        +virtual evaluateSkirmishCommandButtonIsReady() override
    }

    SubsystemInterface <|-- ScriptActionsInterface
    ScriptActionsInterface <|-- ScriptActions
    SubsystemInterface <|-- ScriptConditionsInterface
    ScriptConditionsInterface <|-- ScriptConditions
Loading

Last reviewed commit: f2574b2

@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
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