Skip to content

chore: Remove trailing commas in braced initializers that break clang-format's compact layout - #3274

Merged
xezon merged 1 commit into
TheSuperHackers:mainfrom
mirelle7:fix/remove-trailing-commas
Sep 14, 2026
Merged

xezon merged 1 commit into
TheSuperHackers:mainfrom
mirelle7:fix/remove-trailing-commas

Conversation

@mirelle7

Copy link
Copy Markdown

In preparation for the clang-format PR. This removes all trailing commas inside braced initializers to avoid unwanted multi-line formatting.

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Remove trailing commas from braced initializers for clang-format

✨ Enhancement 🕐 Less than 10 minutes

Grey Divider

AI Description

• Remove trailing commas from braced initializers across engine, game, and tool code.
• Prevent clang-format from forcing unchanged initializers into unwanted multi-line layouts.
High-Level Assessment

The targeted source cleanup is appropriate because it directly prevents clang-format's unwanted initializer expansion without changing runtime behavior. A broader formatter configuration change was considered, but it could alter formatting rules beyond these specific initializers.

Files changed (19) +89 / -89

Refactor (19) +89 / -89
BezierSegment.cppRemove trailing commas from coordinate initializers +9/-9

Remove trailing commas from coordinate initializers

• Removes final commas from Coord3D initializers used by Bezier length and segment-splitting calculations without changing their values.

Core/GameEngine/Source/Common/Bezier/BezierSegment.cpp

GameMemoryInitPools_Generals.inlNormalize Generals memory pool records +4/-4

Normalize Generals memory pool records

• Removes trailing commas from selected pool-size records, including conditionally compiled surrender and demoralize entries.

Core/GameEngine/Source/Common/System/GameMemoryInitPools_Generals.inl

GameMemoryInitPools_GeneralsMD.inlNormalize GeneralsMD memory pool records +4/-4

Normalize GeneralsMD memory pool records

• Removes trailing commas from selected GeneralsMD pool-size records without changing pool names or capacities.

Core/GameEngine/Source/Common/System/GameMemoryInitPools_GeneralsMD.inl

Chat.cppNormalize the GameSpy color array terminator +1/-1

Normalize the GameSpy color array terminator

• Removes the trailing comma from the final GameSpy chat color entry.

Core/GameEngine/Source/GameNetwork/GameSpy/Chat.cpp

GameSpyOverlay.cppNormalize the GameSpy overlay array terminator +1/-1

Normalize the GameSpy overlay array terminator

• Removes the trailing comma from the final overlay menu path.

Core/GameEngine/Source/GameNetwork/GameSpyOverlay.cpp

Win32DIMouse.cppNormalize the mouse buffer enum initializer +1/-1

Normalize the mouse buffer enum initializer

• Removes the trailing comma from the single-value mouse buffer size enum.

Core/GameEngineDevice/Source/Win32Device/GameClient/Win32DIMouse.cpp

formconv.cppNormalize the depth-format conversion array +1/-1

Normalize the depth-format conversion array

• Removes the trailing comma from the final Direct3D depth-format mapping.

Core/Libraries/Source/WWVegas/WW3D2/formconv.cpp

GETCD.cppNormalize CD volume label arrays +2/-2

Normalize CD volume label arrays

• Removes trailing commas from the final CD volume labels in both mission-disk and base-game configurations.

Core/Tools/Autorun/GETCD.cpp

BFISH.cppNormalize nested Blowfish S-box initializers +3/-3

Normalize nested Blowfish S-box initializers

• Removes trailing commas from the final values of the first three nested Blowfish S-box arrays.

Core/Tools/Launcher/BFISH.cpp

GameMtl.cppNormalize material parameter descriptor arrays +6/-6

Normalize material parameter descriptor arrays

• Removes trailing commas from the final descriptors in the main and versioned material parameter blocks.

Core/Tools/WW3D/max2w3d/GameMtl.cpp

PS2GameMtlShaderDlg.cppNormalize PS2 shader preset initialization +1/-1

Normalize PS2 shader preset initialization

• Removes the trailing comma from the final PS2 shader blend preset.

Core/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.cpp

BorderColors.hNormalize Generals border color records +8/-8

Normalize Generals border color records

• Removes trailing commas inside all Generals border color record initializers.

Generals/Code/GameEngine/Include/Common/BorderColors.h

Scripts.cppNormalize Generals script lookup arrays +2/-2

Normalize Generals script lookup arrays

• Removes final trailing commas from the shell hook names and surface names arrays.

Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp

Properties.cppNormalize the Generals color control record +1/-1

Normalize the Generals color control record

• Removes the trailing comma from the button color control initializer.

Generals/Code/Tools/GUIEdit/Source/Properties.cpp

TeamGeneric.cppNormalize Generals team control mappings +17/-17

Normalize Generals team control mappings

• Removes trailing commas from all team script control pairs and the terminating sentinel record.

Generals/Code/Tools/WorldBuilder/src/TeamGeneric.cpp

BorderColors.hNormalize GeneralsMD border color records +8/-8

Normalize GeneralsMD border color records

• Removes trailing commas inside all GeneralsMD border color record initializers.

GeneralsMD/Code/GameEngine/Include/Common/BorderColors.h

Scripts.cppNormalize GeneralsMD script lookup arrays +2/-2

Normalize GeneralsMD script lookup arrays

• Removes final trailing commas from the shell hook names and surface names arrays.

GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp

Properties.cppNormalize the GeneralsMD color control record +1/-1

Normalize the GeneralsMD color control record

• Removes the trailing comma from the button color control initializer.

GeneralsMD/Code/Tools/GUIEdit/Source/Properties.cpp

TeamGeneric.cppNormalize GeneralsMD team control mappings +17/-17

Normalize GeneralsMD team control mappings

• Removes trailing commas from all team script control pairs and the terminating sentinel record.

GeneralsMD/Code/Tools/WorldBuilder/src/TeamGeneric.cpp

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Generals builds fail on border color initialization 🐞 Bug ≡ Correctness
Description
The updated BORDER_COLORS entries omit the commas separating adjacent array elements. The compiler
reaches the next braced initializer immediately after each element, so both Generals and its
consumers fail to compile.
Code

Generals/Code/GameEngine/Include/Common/BorderColors.h[R32-35]

+	{ "Orange",					0xFFFF8700 },
+	{ "Green",					0xFF00FF00 },
+	{ "Blue",						0xFF0000FF },
+	{ "Cyan",						0xFF00FFFF },
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The `BORDER_COLORS` array entries no longer have commas after their closing braces, so adjacent braced initializers are not separated and the file cannot compile.
### Fix Focus Areas
- Generals/Code/GameEngine/Include/Common/BorderColors.h[32-39]
- GeneralsMD/Code/GameEngine/Include/Common/BorderColors.h[32-39]
### Recommended Fix
Keep the trailing comma inside each inner initializer removed, but add a comma after each closing brace except where the array ends, for example `{ "Orange", 0xFFFF8700 },`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can ask Qodo to dismiss a finding you disagree with, with your reason on record

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread Generals/Code/GameEngine/Include/Common/BorderColors.h
@greptile-apps

greptile-apps Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR removes trailing commas from nested C++ braced initializers to prevent unwanted clang-format expansion.

  • Preserves all initializer values, element counts, ordering, and sentinel entries.
  • Applies equivalent cleanup across the Generals and GeneralsMD variants.
  • Retains outer array-element trailing commas where appropriate.

Confidence Score: 5/5

The PR appears safe to merge because the changes are syntactic cleanup that preserves initializer contents and behavior.

No actionable correctness, security, build, or repository-rule violations remain in the reviewed changes.

Important Files Changed

Filename Overview
Core/GameEngine/Source/Common/Bezier/BezierSegment.cpp Removes trailing commas from local Coord3D initializers without changing their values.
Core/Tools/Launcher/BFISH.cpp Removes trailing commas from nested Blowfish S-box rows while preserving every constant and array boundary.
Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp Cleans up the Surfaces initializer while retaining the valid outer trailing comma in TheShellHookNames.
GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp Mirrors the safe initializer cleanup and outer-array comma handling in the Zero Hour variant.
Generals/Code/Tools/WorldBuilder/src/TeamGeneric.cpp Removes inner row-ending commas without changing control ID pairs or the terminating sentinel.
GeneralsMD/Code/Tools/WorldBuilder/src/TeamGeneric.cpp Applies the equivalent non-behavioral initializer cleanup to the Zero Hour WorldBuilder table.

Reviews (5): Last reviewed commit: "chore: Remove trailing commas that break..." | Re-trigger Greptile

@mirelle7
mirelle7 marked this pull request as draft September 10, 2026 17:21
@mirelle7
mirelle7 marked this pull request as ready for review September 10, 2026 17:43
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit f502b38

@Caball009

Copy link
Copy Markdown

If the second commit is necessary to avoid the same issue, doesn't that mean there are many more instances of this issue? I'd expect all cases that match these queries to be the same:
,\s*\n\s*}
,\s*//.*\n\s*}

@mirelle7

mirelle7 commented Sep 10, 2026 •

Copy link
Copy Markdown
Author

,\s*//.\n\s} not needed.

added ,\s*\n\s*}

@Skyaero42

Copy link
Copy Markdown

What is the modern C++ convention on using trailing comma's on the last line?

C#'s Stylecop enforced it (SA1413 - Use trailing comma in multi-line initializers). Python, Javascript and Typescript have similar rules that can be enabled.

There are pro- and cons for using trailing comma's, but removing shouldn't be based on formatting only

@mirelle7
mirelle7 force-pushed the fix/remove-trailing-commas branch from 69e3fca to f6dc518 Compare September 10, 2026 20:42
Scoped to comment-free array/struct literals (BorderColors, TeamGeneric,
BezierSegment, GameMemoryInitPools, BFISH, Properties, Scripts) where
clang-format explodes each element onto its own line without this.
Enums are left alone; EnumTrailingComma: Remove in .clang-format handles
those automatically instead of needing manual edits.
@mirelle7
mirelle7 force-pushed the fix/remove-trailing-commas branch from f6dc518 to 55c7d6b Compare September 10, 2026 20:48
@mirelle7

mirelle7 commented Sep 10, 2026 •

Copy link
Copy Markdown
Author

I'm adding looking into "EnumTrailingComma" in the clang format PR.
Reverted all changes that weren't actually affected by clang-format but found by the regex.

Comment thread Core/Tools/Launcher/BFISH.cpp
@xezon xezon changed the title chore: Remove trailing commas in braced initializers to help clang-fomat chore: Remove trailing commas in braced initializers to help clang-format Sep 12, 2026
@CryoTheRenegade

Copy link
Copy Markdown

What is the modern C++ convention on using trailing comma's on the last line?

C#'s Stylecop enforced it (SA1413 - Use trailing comma in multi-line initializers). Python, Javascript and Typescript have similar rules that can be enabled.

There are pro- and cons for using trailing comma's, but removing shouldn't be based on formatting only

Looks like its still in the proposal stages for c++ std
https://lists.isocpp.org/std-proposals/2025/08/14829.php

But google and LLVM coding standards allow it
https://releases.llvm.org/20.1.0/docs/CodingStandards.html
https://google.github.io/styleguide/cppguide.html

@xezon

xezon commented Sep 12, 2026

Copy link
Copy Markdown

I think the main reason why trailing comma exists is for unrolling type of macros (a macro that unrolls a list). It cannot omit the last trailing comma, because the macro is not that clever.

@xezon xezon added the Refactor Edits the code with insignificant behavior changes, is never user facing label Sep 13, 2026
@xezon xezon changed the title chore: Remove trailing commas in braced initializers to help clang-format chore: Remove trailing commas in braced initializers that break clang-format's compact layout Sep 14, 2026
@xezon
xezon merged commit 318d55a into TheSuperHackers:main Sep 14, 2026
23 checks passed
@mirelle7
mirelle7 deleted the fix/remove-trailing-commas branch September 14, 2026 13:40
fbraz3 added a commit to fbraz3/GeneralsX that referenced this pull request Sep 16, 2026
* bugfix(gamewindow): Remove destroyed windows from the modal stack and prevent duplicate modals for the same window (TheSuperHackers#3224)

* feat(commandline): Add working directory command line options (TheSuperHackers#3149)

Append -useCwd to apply the startup working directory, -setCwd "path" to apply a custom working directory, otherwise it falls back to the default executable working directory

* bugfix(neutronmissile): Fix and improve Nuke Missile damage for large objects inside the outer blast radius (TheSuperHackers#3161)

* bugfix(dozeraiupdate): Fix issue where builders could resume completed tasks after being disabled (TheSuperHackers#2793)

* refactor(milesaudiomanager): Use consistent variable names for PlayingAudio in MilesAudioManager (TheSuperHackers#3254)

* refactor(milesaudiomanager): Simplify MilesAudioManager::notifyOfAudioCompletion() (TheSuperHackers#3254)

* refactor(milesaudiomanager): Simplify MilesAudioManager::findLowestPrioritySound() (TheSuperHackers#3254)

* bugfix(milesaudiomanager): Fix premature 2d and 3d sound cancellations from MilesAudioManager::stopAudioEvent() (TheSuperHackers#3254)

* bugfix(milesaudiomanager): No longer use stopped audio in queries and updates (TheSuperHackers#3254)

* refactor(bink): Replace the Bink SDK stub with a Bink runtime loader (TheSuperHackers#3272)

The Bink SDK stub was linked as an import library, so binkw32.dll had to be
resolvable while the process image was still loading, long before WinMain and
therefore long before the command line was parsed. That is why -setCwd could not
point a build at a retail installation: the working directory it selects is set
far too late to influence how the library is found.

BinkLoader loads binkw32.dll explicitly once BinkVideoPlayer is initialized, at
which point the working directory is final. The Bink functions declared in bink.h
are now ordinary functions that forward to the matching export of the loaded
module, so no call site changes. An unresolved function returns the same neutral
value the stub library returned, which means a missing binkw32.dll disables video
playback instead of preventing the game from starting.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* refactor(miles): Replace the Miles SDK stub with a Miles runtime loader (TheSuperHackers#3272)

The Miles SDK stub was linked as an import library, so mss32.dll had to be
resolvable while the process image was still loading, long before WinMain and
therefore long before the command line was parsed. That is why -setCwd could not
point a build at a retail installation: the working directory it selects is set
far too late to influence how the library is found.

MilesLoader loads mss32.dll explicitly once the audio device is opened, at which
point the working directory is final. The Miles functions declared in mss/mss.h
are now ordinary functions that forward to the matching export of the loaded
module, so no call site changes. An unresolved function returns the same neutral
value the stub library returned, which means a missing mss32.dll turns audio off
instead of preventing the game from starting.

Nine declarations were dropped along the way, because the retail mss32.dll does
not export them and nothing has called them since they were replaced by their
volume_pan counterparts: AIL_sample_volume, AIL_set_sample_volume, AIL_sample_pan,
AIL_set_sample_pan and the four stream equivalents, plus AIL_open_stream_by_sample.
The MSS_auto_cleanup hook was dropped as well, because its atexit handler would
have called AIL_shutdown after the module was already freed. All 92 remaining
exports were verified to resolve against the retail mss32.dll.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* refactor(miles): Fix the written primitive types in mss.h and all its call sites; no ABI changes (TheSuperHackers#3272)

* perf(productionupdate): Simplify and correct implementations of cancel functions in ProductionUpdate (TheSuperHackers#3270)

* chore(gamememory): Compile out the memory link tester in Release (TheSuperHackers#3266)

* perf(gamememory): Early exit delete and free functions on null pointer (TheSuperHackers#3266)

* perf(gamememory): Inline preMainInitMemoryManager (TheSuperHackers#3266)

* perf(gamememory): Add overloads for the deletes with size_t argument (TheSuperHackers#3266)

* chore(gamememory): Remove superfluous extern keywords from operator overloads (TheSuperHackers#3266)

* perf(gamememory): Remove unnecessary calls to preMainInitMemoryManager from delete and free functions and make freeBytes noexcept to get rid of EH frame (TheSuperHackers#3266)

* fix(gamefont): Ceil font glyph buffer size to the actual glyph size to prevent a buffer write overflow (TheSuperHackers#3268)

* refactor(particlesys): Parse IsGroundAligned as an enum instead of a boolean (TheSuperHackers#3265)

* ci(release): Stop requesting permissions from the reusable workflow (TheSuperHackers#3276)

* refactor(basetype): Add utility functions to Region and Coord types (TheSuperHackers#3271)

New functions are:
intersectWith, uniteWith for IRegion3D, IRegion2D, Region3D, Region2D
updateMin, updateMax for ICoord3D, ICoord2D, Coord3D, Coord2D
asICoord2D, asCoord2D for ICoord3D, Coord3D

* build(cmake): Add retail compatibility option in CMake config (TheSuperHackers#2379)

RTS_BUILD_OPTION_RETAIL_COMPATIBLE_GAME=DEFAULT/ON/OFF

* bugfix(meshmatdesc): Fix mesh material color processing (TheSuperHackers#3246)

* ci: Restore CI workflow permission compatibility (TheSuperHackers#3286)

* chore: Remove trailing commas in braced initializers that break clang-format's compact layout (TheSuperHackers#3274)

Scoped to comment-free array/struct literals (BorderColors, TeamGeneric,
BezierSegment, GameMemoryInitPools, BFISH, Properties, Scripts) where
clang-format explodes each element onto its own line without this.

* chore(license): Add SPDX-License-Identifier to LICENSE.md (TheSuperHackers#3290)

Helps github detect the license version

* bugfix(pathfinder): Restore Generals retail compatibility after crash fix changes to Pathfinder::findAttackPath (TheSuperHackers#3289)

* feat(recorder): Play a replay file from the command line (TheSuperHackers#3227)

Use -loadreplay <file> as a command line argument to load the replay with full game context

* fix(audio): Copy SoundSceneObjClass state safely (TheSuperHackers#3247)

* fix(hash): Fix initialization of HashTableIteratorClass and make it work with an empty HashTableClass (TheSuperHackers#3284)

* chore(pathfinder): Remove superfluous CPOP_STARTS_FROM_PREV_SEG macro (TheSuperHackers#3295)

* fix(milesaudiomanager): Prevent heap-buffer-overflow read in MilesAudioManager::selectProvider() (TheSuperHackers#3281)

* bugfix(filesystem): Preserve write paths with missing directories (TheSuperHackers#3104)

* perf(pathfinder): Optimize appending node to end of the path (TheSuperHackers#3198)

PathNode::appendToList() walks the entire list from the head to find the tail on every call, making repeated appendNode() calls O(n^2) in path length. Path already tracks m_pathTail, so append directly onto it in O(1) instead. Removed PathNode::appendToList() as it is not used anywhere else.

* perf(pathfinder): Take parents cell's position outside of for-loop for optimization (TheSuperHackers#3198)

The parent cell's world position fromPos never changes across the neighbour loop, so compute it once instead.

* perf(pathfinder): Remove redundant isCrusher recomputation for optimization (TheSuperHackers#3198)

* ci(windows): make bink and miles runtime stubs optional in build artifacts

* fix(platform): preserve POSIX startup working directory and set Flatpak asset paths

* docs(worklog): document CI fixes and verification for upstream sync PR 304

---------

Co-authored-by: ArcticDolphin <5984296+tintinhamans@users.noreply.github.com>
Co-authored-by: Jacob Lane Ledbetter <23038070+CryoTheRenegade@users.noreply.github.com>
Co-authored-by: xezon <4720891+xezon@users.noreply.github.com>
Co-authored-by: Stubbjax <11547761+Stubbjax@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: stm <14291421+stephanmeesters@users.noreply.github.com>
Co-authored-by: mirelle7 <115191165+mirelle7@users.noreply.github.com>
Co-authored-by: Caball009 <82909616+Caball009@users.noreply.github.com>
Co-authored-by: Bobby Battista <bobtista@gmail.com>
Co-authored-by: SkyAero <21192585+Skyaero42@users.noreply.github.com>
gamezerve pushed a commit to gamezerve/Reborn-Omega that referenced this pull request Sep 17, 2026
…-format's compact layout (TheSuperHackers#3274)

Scoped to comment-free array/struct literals (BorderColors, TeamGeneric,
BezierSegment, GameMemoryInitPools, BFISH, Properties, Scripts) where
clang-format explodes each element onto its own line without this.
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.

5 participants