Skip to content

refactor: Add override keyword to virtual function overrides in Core code (2)#2603

Open
Caball009 wants to merge 7 commits intoTheSuperHackers:mainfrom
Caball009:override_keyword_core
Open

refactor: Add override keyword to virtual function overrides in Core code (2)#2603
Caball009 wants to merge 7 commits intoTheSuperHackers:mainfrom
Caball009:override_keyword_core

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 Core code that were missed in the previous round of refactoring.

Check out the commits as they separate different types of changes.

Related PRs:
#2604
#2605

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 15, 2026

Greptile Summary

This PR is a follow-up to #2101, adding the override keyword to virtual function overrides across 69 files in the Core codebase. Beyond the purely mechanical override additions, it also corrects several real const-qualifier mismatches that were silently hiding base-class virtual functions, removes redundant pure-virtual redeclarations of init()/reset()/update() in subsystem interfaces (already declared in SubsystemInterface), and adds W3DMPO as a base class for TextureClass so that the W3DMPO_GLUE macro's glueEnforcer() const override compiles correctly.

Confidence Score: 5/5

Safe to merge — all changes are correct override annotations with no functional regressions introduced.

All 69 files contain either mechanical override additions or correct const-qualifier fixes that resolve latent virtual-dispatch hiding bugs. The TextureClass/always.h pairing is correctly coordinated. No P0 or P1 findings.

No files require special attention; the texture.h + always.h coupling is intentional and correct.

Important Files Changed

Filename Overview
Core/Libraries/Source/WWVegas/WW3D2/texture.h Adds W3DMPO as a base class to TextureClass — necessary companion to the glueEnforcer() override fix in always.h; all W3DMPO_GLUE users that chain through TextureClass now resolve correctly.
Core/Libraries/Source/WWVegas/WWLib/always.h Adds override to glueEnforcer() in W3DMPO_GLUE macro; requires all users of the macro to derive from W3DMPO — coordinated with texture.h change.
Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.h Adds const + override to Get_Class_ID(); fixes a real dispatch bug — non-const version was hiding, not overriding, the base-class const virtual.
Core/Libraries/Source/WWVegas/WWAudio/Sound3D.h Adds const + override to Get_DropOff_Radius(); fixes same hiding-vs-override bug as FilteredSound.h.
Core/Libraries/Source/WWVegas/WWMath/cardinalspline.h Adds unsigned int extra=0 parameter to Add_Key to match HermiteSpline1DClass signature, enabling correct override; implementation updated accordingly.
Core/GameEngine/Include/GameNetwork/LANGameInfo.h amIHost() gets const + override to match GameInfo base; implementation correctly switches to getConstLANSlot().
Core/GameEngine/Include/Common/LocalFileSystem.h Removes redundant pure-virtual redeclarations of init/reset/update (already required by SubsystemInterface); matching empty implementations removed from .cpp.
Generals/Code/GameEngine/Include/Common/Module.h Adds getAsW3DTreeDrawModuleData() virtual with nullptr default and forward declaration of W3DTreeDrawModuleData, consistent with existing getAsW3DModelDrawModuleData() pattern.
Core/GameEngine/Include/Common/ArchiveFileSystem.h Removes redundant init/reset/update pure-virtual redeclarations; adds override to postProcessLoad() which re-declares it as pure virtual (overriding SubsystemInterface's non-pure default).
Core/GameEngine/Include/Common/GameMemory.h Adds override to destructor and getObjectMemoryPool() in MEMORY_POOL_GLUE macros; straightforward correctness fix.
Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h Adds override to several methods including private setUserControlled; all changes are mechanically correct.

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class W3DMPO {
        +virtual ~W3DMPO()
        #virtual glueEnforcer() const = 0
    }
    class TextureBaseClass {
        +RefCountClass
    }
    class TextureClass {
        W3DMPO_GLUE(TextureClass)
        #virtual glueEnforcer() const override
    }
    class TerrainTextureClass {
        W3DMPO_GLUE(TerrainTextureClass)
    }
    class W3DTreeTextureClass {
        W3DMPO_GLUE(W3DTreeTextureClass)
    }

    W3DMPO <|-- TextureClass : added in PR
    TextureBaseClass <|-- TextureClass
    TextureClass <|-- TerrainTextureClass
    TextureClass <|-- W3DTreeTextureClass

    note for TextureClass "Before PR: TextureClass only inherited from TextureBaseClass, causing W3DMPO_GLUE override to fail"
Loading

Reviews (2): Last reviewed commit: "Fixed compilation error." | Re-trigger Greptile

@xezon xezon changed the title refactor: Add override keyword to virtual function overrides in Core code refactor: Add override keyword to virtual function overrides in Core code (2) Apr 16, 2026
Copy link
Copy Markdown

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

It looks like there are a few actual fixes for bugged overrides.

virtual void update() = 0;
virtual void reset() = 0;
virtual void postProcessLoad() = 0;
virtual void postProcessLoad() override = 0;
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 was removed?

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.

}

Bool LANGameInfo::amIHost()
Bool LANGameInfo::amIHost() const
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 change behavior? Meaning a different function is called now?

virtual RenderObjClass * Clone() const override;
virtual int Class_ID() const override;
virtual void Render(RenderInfoClass & rinfo) = 0;
virtual void Render(RenderInfoClass & rinfo) override = 0;
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.

Comment thread Core/Tools/W3DView/ViewerAssetMgr.h
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This looks like it does not belong here.

@xezon
Copy link
Copy Markdown

xezon commented Apr 17, 2026

Needs rebase

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