refactor: Add override keyword to virtual function overrides in Tools and set compile option -Wsuggest-override#2394
Conversation
|
| Filename | Overview |
|---|---|
| cmake/compilers.cmake | Adds -Wsuggest-override for non-MSVC non-VS6 compilers in the correct branch; MSVC equivalent deferred to a future PR per previous review discussion. |
| Core/GameEngine/Include/GameClient/ParticleSys.h | Adds virtual to ParticleSystemManagerDummy override declarations to match codebase conventions; was missed in the prior PR (#2392). |
| Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp | Adds override to most PlaceholderView overrides; also correctly adds const to isZoomLimited to match View::isZoomLimited() const; four pure/virtual overrides (isDoingScriptedCamera, stopDoingScriptedCamera, lookAt, initHeightForMap) are missing override and will trigger the newly enabled -Wsuggest-override warning. |
| GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp | Same as Generals counterpart; override correctly added to most PlaceholderView overrides, but isDoingScriptedCamera, stopDoingScriptedCamera, lookAt, and initHeightForMap are still missing override. |
| Generals/Code/Tools/GUIEdit/Include/GUIEditDisplay.h | Adds override to all GUIEditDisplay virtual function overrides; setBorderShroudLevel gains both virtual and override for consistency. |
| GeneralsMD/Code/Tools/wdump/wdump.cpp | Adds override to CWDumpCommandLineInfo::ParseParam and CAboutDlg::DoDataExchange; straightforward. |
| Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp | Adds override to three local OutputStream subclass write() overrides; no logic changes. |
| Generals/Code/Tools/WorldBuilder/src/WorldBuilder.cpp | Adds override to WBGameFileClass::Set_Name, WB_W3DFileSystem::Get_File, and CAboutDlg::DoDataExchange; no logic changes. |
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[cmake/compilers.cmake] -->|adds -Wsuggest-override| B{non-MSVC, non-VS6?} B -->|Yes| C[GCC / Clang warns on missing override] B -->|No| D[MSVC: no change — deferred to future PR] C --> E[201 header/source files] E --> F[override added to matching virtual overrides] E --> G[isZoomLimited gains const — fixes silent shadow] E --> H[ParticleSystemManagerDummy gains virtual keyword] F --> I{4 functions in PlaceholderView} I -->|isDoingScriptedCamera / stopDoingScriptedCamera\nlookAt / initHeightForMap| J[⚠️ override still missing — will trigger warning] Prompt To Fix All With AI
This is a comment left during a code review. Path: Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp Line: 199-203 Comment: **Missing `override` will trigger `-Wsuggest-override` warnings** This PR enables `-Wsuggest-override` in `cmake/compilers.cmake`, but `PlaceholderView` in this file still has several functions that override base class virtuals without the `override` keyword. These will produce warnings on GCC/Clang builds: - `isDoingScriptedCamera()` — pure virtual in `View` - `stopDoingScriptedCamera()` — pure virtual in `View` - `lookAt(const Coord3D *o)` — virtual in `View` - `initHeightForMap(void)` — virtual in `View` The same four functions in `GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp` (lines 200–204) have the same omission. Note: `scrollBy(Coord2D *delta)` and `resetCamera`/`rotateCamera`/etc. are intentionally left without `override` because their signatures differ from the base class (missing the `easeIn`/`easeOut` default parameters or a missing `const` qualifier), so `override` would cause a compile error there. ```suggestion virtual Bool isDoingScriptedCamera() override { return false; } virtual void stopDoingScriptedCamera() override {} virtual void lookAt( const Coord3D *o ) override {}; virtual void initHeightForMap( void ) override {}; ``` How can I resolve this? If you propose a fix, please make it concise.Reviews (8): Last reviewed commit: "fix: Add missing virtual keyword to Part..." | Re-trigger Greptile
1630354 to b7df0dc Compare | Might want to do a quick spacing check before I review? |
Looks good - found some mixed tab/space stuff for indentation but the override {} spacing seems good |
ee24d63 to 58990fc Compare
Summary
overridekeyword to virtual function overrides in Tools (WorldBuilder, GUIEdit, wdump)-Wsuggest-overridecompiler warning for GCC and Clangvirtualkeyword toParticleSystemManagerDummyoverrides in Core (missed in refactor: Add override keyword to virtual function overrides in GameEngine (2) #2392 since the class was added after that PR merged)Context
Part 6/6 of splitting #2101. Depends on #2389 merging first.
Notes
virtualkeyword-Wsuggest-overridecompiler warning ensures future virtual overrides use the keyword