You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR removes superfluous return; (and return ;) statements at the end of void functions across ~196 files in the Core/, Generals/, and GeneralsMD/ directories. The changes were applied using the newly added Python script at scripts/cpp/remove_return.py, with some additional manual cleanup in a follow-up commit.
Confidence Score: 5/5
Safe to merge — purely mechanical removal of superfluous void returns with no behavioral change.
All 196 files contain only deletions of trailing return; lines from void functions. The script's column-0 brace guard correctly prevents accidental removal of non-superfluous returns inside nested blocks. Spot-checks across game logic, audio, tools, and template headers all confirmed correct removals.
No files require special attention.
Important Files Changed
Filename
Overview
scripts/cpp/remove_return.py
New Python script that automates removal of superfluous void returns; logic is sound and conservative (column-0 brace check prevents false positives on nested block returns).
Core/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp
Multiple superfluous void returns removed across several methods; all removals are at the end of top-level function bodies.
Core/Libraries/Source/WWVegas/WW3D2/prim_anim.h
Template method implementations in header had trailing returns cleaned up; no behavioral change.
Four stub functions had their single-line returns cleaned up.
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Iterate over all .cpp .h .inl files] --> B[Read each line]
B --> C{Is last line?}
C -- Yes --> D[Append unchanged to output]
C -- No --> E[Find next non-blank line]
E --> F{Line strips to return semicolon?}
F -- No --> D
F -- Yes --> G{Next non-blank line starts with brace at col 0?}
G -- No --> D
G -- Yes --> H[Remove the return line]
H --> I[Pop preceding blank lines from output]
I --> D
D --> J{More lines?}
J -- Yes --> B
J -- No --> K[Write modified file]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RefactorEdits the code with insignificant behavior changes, is never user facing
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change removes superfluous returns at the end of functions.
Applied with python script and a bit of hand holding.