Skip to content

refactor: Add override keyword to virtual function overrides in Libraries#2390

Merged
xezon merged 7 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/override-keyword-libraries
Mar 26, 2026
Merged

refactor: Add override keyword to virtual function overrides in Libraries#2390
xezon merged 7 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/override-keyword-libraries

Conversation

@bobtista
Copy link
Copy Markdown

@bobtista bobtista commented Mar 3, 2026

Summary

  • Add override keyword to virtual function overrides in Libraries (WWVegas: WW3D2, WWAudio, WWLib, WWMath, WWSaveLoad, etc.)
  • Changes across Core/Libraries, Generals/Libraries, and GeneralsMD/Libraries

Context

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

Notes

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

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 3, 2026

Greptile Summary

This PR is part 2/6 of splitting a larger refactoring effort (#2101). It performs a purely mechanical addition of the override keyword to virtual function overrides across 156 files in Core/Libraries, Generals/Libraries, and GeneralsMD/Libraries (WWVegas subsystems: WW3D2, WWAudio, WWLib, WWMath, WWSaveLoad, and WWDebug).

Key observations:

  • All override annotations are correctly applied — every function marked with override has been verified to correspond to a virtual function in a base class.
  • The most notable non-trivial change is in Core/Libraries/Source/WWVegas/WW3D2/collect.h where void Update_Sub_Object_Transforms() (a non-virtual protected helper) is promoted to virtual void Update_Sub_Object_Transforms() override. This is valid: RenderObjClass already declares this function as virtual in its public interface, so CollectionClass was implicitly overriding it — the PR simply makes this explicit.
  • All virtual keyword additions to destructors (e.g., ~ActiveCategoryStackClass(), ~DLNodeClass(), ~ShareBufferClass()) are safe because their respective base classes (VectorClass, W3DMPO, RefCountClass) all declare virtual destructors.
  • No functional behaviour is altered — override is a compile-time-only annotation that causes the compiler to error if a function does not actually override a base class virtual, improving long-term safety.
  • The Generals/ and GeneralsMD/ files are mirrored duplicates, so the same changes are applied twice to parallel codebases.

Confidence Score: 5/5

  • This PR is safe to merge — it is a purely mechanical, zero-behaviour-change refactoring that only adds compile-time override annotations.
  • All 156 files contain only override keyword additions to functions that genuinely override base class virtuals. Verified key non-obvious cases (RenderObjClass destructor, CollectionClass::Update_Sub_Object_Transforms, ActiveCategoryStackClass destructor, DLNodeClass destructor) — all are correct. No null-pointer changes, no logic mutations, no new files, no include guard changes. The change strictly improves compiler-enforced correctness with no runtime risk.
  • No files require special attention.

Important Files Changed

Filename Overview
Core/Libraries/Source/WWVegas/WW3D2/collect.h Adds override to all virtual overrides in CollectionClass; notably also adds virtual + override to Update_Sub_Object_Transforms() which was previously a non-virtual protected helper — valid because RenderObjClass declares it virtual in its public interface.
Core/Libraries/Source/WWVegas/WW3D2/rendobj.h Adds override to Save/Load/Get_Factory and the virtual destructor; RenderObjClass inherits from RefCountClass and PersistClass (both with virtual destructors) so virtual ~RenderObjClass() override is valid.
Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.cpp Changes ~ActiveCategoryStackClass() to virtual ~ActiveCategoryStackClass() override — valid since it inherits from VectorClass which has a virtual destructor.
Core/Libraries/Source/WWVegas/WW3D2/dllist.h Adds virtual + override to ~DLNodeClass(); inherits from W3DMPO which has a virtual destructor, so the change is valid.
Core/Libraries/Source/profile/internal_result.h Adds override to WriteResults/Delete on ProfileResultFileCSV and ProfileResultFileDOT; GetName() is left without override but that is a pre-existing inconsistency outside this PR's scope.
Generals/Code/Libraries/Source/WWVegas/WW3D2/scene.h Adds override to all SimpleSceneClass virtual overrides; a handful of virtual methods like Get_Scene_ID() and Remove_All_Render_Objects() are left without override, which is a pre-existing pattern and not introduced by this PR.
Core/Libraries/Source/WWVegas/WWLib/Vector.h Adds override to Resize/Clear/ID in DynamicVectorClass; straightforward and correct.
Core/Libraries/Source/WWVegas/WW3D2/composite.h Mechanical addition of override to all virtual overrides in CompositeRenderObjClass; no functional changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Base class declares\nvirtual function] --> B{Derived class\noverride?}
    B -- Before PR\n'virtual' only --> C[Implicit override\nno compiler check]
    B -- After PR\n'virtual ... override' --> D[Explicit override\ncompiler verifies signature match]
    D --> E{Signature matches\nbase class?}
    E -- Yes --> F[Compiles OK\nno behaviour change]
    E -- No --> G[Compile error\nbug caught early]
    C --> H[Silent mismatch possible\ne.g. typo in signature]
Loading

Reviews (5): Last reviewed commit: "fix: Add missing virtual keyword to dest..." | Re-trigger Greptile

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

xezon commented Mar 10, 2026

This also needs rebase

@bobtista
Copy link
Copy Markdown
Author

This also needs rebase

do you have the latest pulled locally? Github doesn't show a merge conflict for me

@xezon
Copy link
Copy Markdown

xezon commented Mar 10, 2026

But it still 4 commits present that are already in main branch. Something is not right.

@bobtista bobtista force-pushed the bobtista/override-keyword-libraries branch from a0fc760 to 06c9db7 Compare March 11, 2026 01:47
@bobtista
Copy link
Copy Markdown
Author

You're right - rebased, looks better now

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

I did not look at every line but hopefully this is alright.

@xezon xezon merged commit 256c849 into TheSuperHackers:main Mar 26, 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