Skip to content

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

Merged
xezon merged 5 commits into
TheSuperHackers:mainfrom
stephanmeesters:chore/isgroundaligned-enum
Sep 12, 2026
Merged

refactor(particlesys): Parse IsGroundAligned as an enum instead of a boolean#3265
xezon merged 5 commits into
TheSuperHackers:mainfrom
stephanmeesters:chore/isgroundaligned-enum

Conversation

@stephanmeesters

@stephanmeesters stephanmeesters commented Sep 7, 2026

Copy link
Copy Markdown

Parse the INI value IsGroundAligned as enum values No and Yes instead of boolean. This will make it possible to set IsGroundAligned = CONFORMING in the INI later.

  • Rename m_isGroundAligned to m_particleAlignment.
  • Rename F_ISXYPLANAR to F_PARTICLEALIGNMENT
  • Introduce enum type in place of the boolean type.
  • Update the ParticleSystemInfo xfer version to handle the new enum save.

Todo

  • Test new save

@stephanmeesters
stephanmeesters force-pushed the chore/isgroundaligned-enum branch from 3d6ab7a to a83386b Compare September 10, 2026 16:43
@stephanmeesters
stephanmeesters marked this pull request as ready for review September 10, 2026 16:46
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Parse particle ground alignment as an extensible enum

✨ Enhancement ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Replaces the ground-alignment boolean with an extensible particle-alignment enum.
• Parses and emits existing No/Yes INI values through enum mappings.
• Versions snapshot transfers while preserving legacy saves, rendering, and editor behavior.
Diagram

graph TD
  INI["Particle INI"] --> Parser["Enum parser"] --> Template["Particle template"] --> Runtime["Particle runtime"] --> Renderer["W3D renderer"]
  Editor["Particle editor"] --> Template --> Writers["INI writers"]
  Template --> Xfer["Snapshot xfer"]
Loading
High-Level Assessment

The enum-backed approach is appropriate because it preserves current No/Yes behavior while creating a clear extension point for future alignment modes. Keeping the old boolean alongside a new setting would create competing state, while string-based runtime storage would weaken type safety. The version-gated boolean-to-enum conversion and centralized shouldBillboard() query minimize compatibility and downstream behavior changes.

Files changed (6) +43 / -15

Enhancement (1) +22 / -6
ParticleSys.cppParse, propagate, and serialize particle alignment +22/-6

Parse, propagate, and serialize particle alignment

• Initializes and copies the alignment enum, parses 'IsGroundAligned' through the enum name list, and routes field-particle limits through 'shouldBillboard()'. Increases the snapshot version outside retail-compatible saves while translating version 1 booleans to and from enum values.

Core/GameEngine/Source/GameClient/System/ParticleSys.cpp

Refactor (3) +17 / -5
ParticleSys.hDefine particle alignment enum and billboard query +14/-2

Define particle alignment enum and billboard query

• Replaces 'm_isGroundAligned' with 'ParticleAlignmentType' and defines billboard and XY-planar modes. Adds the 'No'/'Yes' name mapping and updates 'shouldBillboard()' to evaluate the enum.

Core/GameEngine/Include/GameClient/ParticleSys.h

W3DParticleSys.cppCount aligned field particles through billboard semantics +1/-1

Count aligned field particles through billboard semantics

• Replaces direct ground-alignment member access with 'shouldBillboard()' when accumulating area-effect field particles.

Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp

ParticleEditorDialog.cppMap the alignment switch to enum values +2/-2

Map the alignment switch to enum values

• Reads the editor's XY-alignment switch from the enum and writes explicit XY-planar or billboard values when toggled.

Core/Tools/ParticleEditor/ParticleEditorDialog.cpp

Other (2) +4 / -4
ScriptEngine.cppEmit Generals particle alignment enum names +2/-2

Emit Generals particle alignment enum names

• Renames the particle field constant to reflect general alignment and serializes 'IsGroundAligned' using the enum name table instead of boolean strings.

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

ScriptEngine.cppEmit GeneralsMD particle alignment enum names +2/-2

Emit GeneralsMD particle alignment enum names

• Applies the alignment field rename and enum-based 'IsGroundAligned' serialization to the GeneralsMD script writer.

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

@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR replaces the particle system’s ground-alignment boolean with an extensible alignment enum while preserving existing INI behavior and save compatibility.

  • Parses IsGroundAligned through the No/Yes alignment-name table.
  • Maps legacy version-1 boolean save data to billboard or XY-planar alignment.
  • Writes version-2 alignment state as a fixed-underlying-type enum while retaining retail-compatible version-1 output.
  • Updates rendering, editor controls, particle limits, and both game variants’ INI exporters to use the new alignment representation.

Confidence Score: 5/5

The PR appears safe to merge, with no outstanding correctness or repository-rule findings identified.

The follow-up change gives the serialized enum a fixed 32-bit underlying type in the repository’s required C++20 configuration, and the complete change consistently preserves legacy save loading, retail-compatible saving, INI parsing, rendering behavior, editor controls, and both variant exporters.

Important Files Changed

Filename Overview
Core/GameEngine/Include/GameClient/ParticleSys.h Defines the fixed-underlying-type particle-alignment enum, its INI names, and billboard query.
Core/GameEngine/Source/GameClient/System/ParticleSys.cpp Initializes, parses, copies, and version-transfers particle alignment with legacy boolean compatibility.
Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp Uses the shared billboard query when counting area-effect field particles.
Core/Tools/ParticleEditor/ParticleEditorDialog.cpp Maps the existing XY-alignment editor switch to the new enum values.
Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptEngine.cpp Exports the Generals particle alignment through the enum-name table.
GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptEngine.cpp Keeps Zero Hour particle-system export aligned with the shared enum representation.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    INI["INI: IsGroundAligned = No / Yes"] --> Parse["Parse alignment enum"]
    V1["Version 1 save: boolean"] --> Map["Map false/true to billboard/XY-planar"]
    V2["Version 2 save: enum"] --> Load["Load particle alignment"]
    Parse --> State["ParticleAlignmentType"]
    Map --> State
    Load --> State
    State --> Render["Billboard or XY-planar rendering"]
    State --> Editor["Particle Editor switch"]
    State --> Export["Generals and Zero Hour INI export"]
Loading

Reviews (3): Last reviewed commit: "Process review comments" | Re-trigger Greptile

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can turn these tips off under Display preferences

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@stephanmeesters stephanmeesters added Gen Relates to Generals ZH Relates to Zero Hour Refactor Edits the code with insignificant behavior changes, is never user facing labels Sep 10, 2026
Comment thread Core/GameEngine/Include/GameClient/ParticleSys.h Outdated

@Skyaero42 Skyaero42 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looking good

Comment thread Core/GameEngine/Include/GameClient/ParticleSys.h Outdated
@xezon
xezon merged commit ab0e4fc into TheSuperHackers:main Sep 12, 2026
23 checks passed
@stephanmeesters
stephanmeesters deleted the chore/isgroundaligned-enum branch September 12, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Refactor Edits the code with insignificant behavior changes, is never user facing ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants