Skip to content

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

Open
stephanmeesters wants to merge 4 commits into
TheSuperHackers:mainfrom
stephanmeesters:chore/isgroundaligned-enum
Open

refactor(particlesys): Parse IsGroundAligned as an enum instead of a boolean#3265
stephanmeesters wants to merge 4 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

Refactors particle ground alignment from a boolean into an enum while preserving the existing No and Yes INI representations.

  • Renames the stored alignment field and updates runtime, renderer, editor, and script-export consumers.
  • Introduces version 2 serialization for non-retail-compatible saves while retaining version 1 boolean compatibility.
  • Keeps the parallel Generals and GeneralsMD script exporters aligned.

Confidence Score: 5/5

The PR appears safe to merge; no outstanding correctness, compatibility, security, or repository-rule issue was identified.

The latest changes only improve documentation, while the full PR consistently maps the existing boolean behavior to the two enum values across parsing, rendering, editing, exporting, and versioned save transfer.

Important Files Changed

Filename Overview
Core/GameEngine/Include/GameClient/ParticleSys.h Defines the alignment enum, INI value names, renamed state field, and billboard query.
Core/GameEngine/Source/GameClient/System/ParticleSys.cpp Initializes, parses, copies, evaluates, and version-serializes the new alignment representation.
Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp Uses the common billboard query when accounting for ground-aligned area-effect particles.
Core/Tools/ParticleEditor/ParticleEditorDialog.cpp Maps the editor’s existing alignment checkbox to the two current enum values.
Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptEngine.cpp Exports the Generals particle alignment using the enum’s canonical INI name.
GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptEngine.cpp Mirrors the enum-based particle alignment export for Zero Hour.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  INI["IsGroundAligned = No / Yes"] --> Parse["parseIndexList"]
  Parse --> Enum["ParticleAlignmentType"]
  Enum --> Runtime["Particle system behavior"]
  Enum --> Renderer["W3D batching and field count"]
  Enum --> Editor["ParticleEditor alignment switch"]
  Enum --> Export["Generals and GeneralsMD INI export"]
  Enum --> Save{"Transfer version"}
  Save -->|"v1 / retail-compatible"| Boolean["Boolean compatibility mapping"]
  Save -->|"v2"| EnumData["Enum serialization"]
Loading

Reviews (2): Last reviewed commit: "Update 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
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.

1 participant