Skip to content

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

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

refactor(GameEngine): Add override keyword to virtual function overrides#2392
bobtista wants to merge 7 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 (Part 4/6 of splitting #2101) performs a purely mechanical addition of the override keyword to virtual function overrides across 291 files spanning Core/, Generals/, and GeneralsMD/ — covering Include/Common, Include/GameClient, Include/GameNetwork, Include/GameLogic (non-Module), and their corresponding Source/ directories.

  • Mechanical override additions — the vast majority of changes simply append override to existing virtual declarations, improving code clarity and enabling the compiler to detect accidental signature mismatches at compile time.
  • Non-mechanical promotions (bug fixes) — in ScriptActions.h, ScriptConditions.h, VictoryConditions.cpp, GSConfig.cpp, and BuddyThread.cpp, several previously non-virtual methods that do in fact override base-class pure virtuals gain both virtual and override. All promotions were verified against their respective interface classes (ScriptActionsInterface, ScriptConditionsInterface, VictoryConditionsInterface, NetworkInterface, ThreadClass).
  • Style inconsistency in VictoryConditions.cpp and GSConfig.cpp — within the same class, some newly promoted overrides gain the virtual keyword (e.g. hasAchievedVictory, getPointsForRank) while others only receive override (e.g. init, reset, cachePlayerPtrs). This is harmless since override alone is sufficient, but it is inconsistent with the PR note that "all lines retain the virtual keyword." No behavioral difference.
  • No logic bugs, null dereferences, security issues, or data-loss paths were introduced. All override usages were confirmed to match valid virtual signatures in their respective base classes.

Confidence Score: 5/5

  • This PR is safe to merge — it is a purely mechanical refactor with no behavioral changes outside the already-reviewed ScriptActions/ScriptConditions bug fixes.
  • All 291 files contain only override keyword additions (and a small number of virtual promotions) verified against their base-class interface declarations. No new logic, no new allocations, no new control flow. The compiler itself will reject any incorrect override at build time, providing a strong automatic correctness guarantee.
  • No files require special attention.

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Include/GameLogic/ScriptActions.h Promotes previously non-virtual methods (executeAction, closeWindows, doEnableOrDisableObjectDifficultyBonuses, ~ScriptActions) to virtual override — a legitimate polymorphism bug fix on top of the mechanical refactor.
GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptActions.h Same promotions to virtual override as the Generals counterpart — correct fixes for previously missing virtual dispatch on executeAction, closeWindows, and doEnableOrDisableObjectDifficultyBonuses.
Generals/Code/GameEngine/Include/GameLogic/ScriptConditions.h evaluateCondition, evaluateTeamIsContained, and evaluateSkirmishCommandButtonIsReady are correctly promoted to virtual override — all are declared pure virtual in ScriptConditionsInterface.
GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptConditions.h Same correct virtual override promotions as the Generals counterpart for evaluateCondition, evaluateTeamIsContained, and evaluateSkirmishCommandButtonIsReady.
Core/GameEngine/Source/GameNetwork/Network.cpp All method declarations (sendChat, sendDisconnectChat, etc.) correctly gain override — verified against the pure-virtual signatures in NetworkInterface.
Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/VictoryConditions.cpp override added to all VictoryConditions implementations; minor style inconsistency where some previously non-virtual methods (hasAchievedVictory, hasBeenDefeated, hasSinglePlayerBeenDefeated) gain the virtual keyword while others (init, reset, update) only get override — harmless but inconsistent with the PR's stated goal of retaining virtual.
GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/VictoryConditions.cpp Same override additions with the same minor style inconsistency as the Generals version; all changes are logically correct.
Core/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp Mechanical override additions; getPointsForRank gains the virtual keyword while other previously non-virtual methods (getPingServers, getNumPingRepetitions, etc.) do not — same style inconsistency pattern as VictoryConditions, harmless.
Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp Thread_Function() correctly gains virtual override — confirmed as pure virtual in ThreadClass (WWLib/thread.h).
Core/GameEngine/Include/GameNetwork/LANAPI.h All 90 LANAPI method declarations correctly gain override; all verified as pure virtual in LANAPIInterface.
Core/GameEngine/Include/GameNetwork/GameSpy/PeerDefsImplementation.h All 196 changed lines correctly add override to GameSpyInfo method declarations; purely mechanical.
Core/GameEngine/Include/GameClient/GameWindowTransitions.h 190 line changes across many Transition subclasses — all purely mechanical override additions with no signature changes.
GeneralsMD/Code/GameEngine/Include/GameLogic/AIGuardRetaliate.h GeneralsMD-only file; shouldExit, onEnter, update, onExit, crc, xfer, loadPostProcess all correctly gain override across several AI state classes.
Core/GameEngine/Source/GameClient/FXList.cpp All doFXPos and doFXObj overrides correctly marked with override; purely mechanical with no signature alterations.

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 executeAction() = 0
        +virtual closeWindows() = 0
        +virtual doEnableOrDisableObjectDifficultyBonuses() = 0
    }

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

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

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

    class VictoryConditionsInterface {
        +virtual init() = 0
        +virtual reset() = 0
        +virtual hasAchievedVictory() = 0
        +virtual hasBeenDefeated() = 0
        +virtual getEndFrame() = 0
    }

    class VictoryConditions {
        +init() override
        +reset() override
        +virtual hasAchievedVictory() override
        +virtual hasBeenDefeated() override
        +virtual getEndFrame() override
    }

    class NetworkInterface {
        +virtual init() = 0
        +virtual sendChat() = 0
        +virtual sendDisconnectChat() = 0
        +virtual isStalling() = 0
        +virtual quitGame() = 0
    }

    class Network {
        +init() override
        +virtual sendChat() override
        +virtual sendDisconnectChat() override
        +virtual isStalling() override
        +virtual quitGame() override
    }

    SubsystemInterface <|-- ScriptActionsInterface
    ScriptActionsInterface <|-- ScriptActions
    SubsystemInterface <|-- ScriptConditionsInterface
    ScriptConditionsInterface <|-- ScriptConditions
    SubsystemInterface <|-- VictoryConditionsInterface
    VictoryConditionsInterface <|-- VictoryConditions
    SubsystemInterface <|-- NetworkInterface
    NetworkInterface <|-- Network
Loading

Last reviewed commit: 949b25a

@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
virtual void crc( Xfer *xfer ){};
virtual void xfer( Xfer *xfer ){XferVersion cv = 1; XferVersion v = cv; xfer->xferVersion( &v, cv );}
virtual void loadPostProcess(){};
virtual void crc( Xfer *xfer ) override{};

Choose a reason for hiding this comment

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

spacing issues, multiple times

@bobtista bobtista force-pushed the bobtista/override-keyword-gameengine branch from f2574b2 to 949b25a Compare March 12, 2026 20:17
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