Skip to content

fix(particlesys): Prevent accumulation of particle systems in headless mode#3006

Merged
xezon merged 1 commit into
TheSuperHackers:mainfrom
Caball009:fix_particle_system_update
Jul 23, 2026
Merged

fix(particlesys): Prevent accumulation of particle systems in headless mode#3006
xezon merged 1 commit into
TheSuperHackers:mainfrom
Caball009:fix_particle_system_update

Conversation

@Caball009

Copy link
Copy Markdown

#2740 removed function GameClient::updateHeadless, which ensured that particle systems wouldn't accumulate and take up a lot of memory unnecessarily. This works when ParticleSystemManagerDummy overloads the init function, but that's not possible with retail compatibility.

This PR adds a dummy overload for createParticleSystem, so that no particle systems get created in headless mode.

I tested > 2500 short replays and did not see a mismatch because of this change.

@Caball009 Caball009 added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour ThisProject The issue was introduced by this project, or this task is specific to this project Memory Is memory related labels Jul 22, 2026
@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a memory accumulation issue in headless mode introduced when GameClient::updateHeadless was removed: in RETAIL_COMPATIBLE_CRC builds, ParticleSystemManagerDummy can no longer override init() to skip template loading (needed for CRC correctness), so particle systems created during replays were never cleaned up. The fix makes createParticleSystem virtual in the base class and adds a dummy override that immediately returns nullptr, short-circuiting all particle system creation without affecting template loading.

  • createParticleSystem is conditionally marked virtual only under RETAIL_COMPATIBLE_CRC, and all existing call sites already null-check the return value, so the change is safe throughout the engine.
  • The #else (non-retail) branch formatting diverges slightly from the surrounding codebase pointer style (Type* vs Type *).

Confidence Score: 5/5

Safe to merge — the change is surgical and all existing call sites already null-check the return value of createParticleSystem.

The virtual override cleanly short-circuits particle system creation in headless retail mode, and every engine call site that invokes createParticleSystem already guards against a nullptr result, so no downstream breakage is possible. The non-retail path is untouched in behavior.

No files require special attention.

Important Files Changed

Filename Overview
Core/GameEngine/Include/GameClient/ParticleSys.h Adds a virtual createParticleSystem override to ParticleSystemManagerDummy under RETAIL_COMPATIBLE_CRC that returns nullptr, preventing particle system accumulation in headless mode without disturbing template loading needed for CRC compatibility. Minor pointer-style inconsistency introduced in the #else branch.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant TPSM as TheParticleSystemManager<br/>(ParticleSystemManagerDummy)
    participant PSM as ParticleSystemManager

    Note over TPSM: RETAIL_COMPATIBLE_CRC mode

    Caller->>TPSM: createParticleSystem(sysTemplate, createSlaves)
    Note over TPSM: virtual override — returns nullptr immediately
    TPSM-->>Caller: nullptr (no system created, no accumulation)

    Note over PSM: Non-retail mode

    Caller->>PSM: createParticleSystem(sysTemplate, createSlaves)
    Note over PSM: init() no-op → no templates loaded<br/>sysTemplate == nullptr → early return
    PSM-->>Caller: nullptr
Loading

Reviews (3): Last reviewed commit: "bugfix(particlesys): Prevent accumulatio..." | Re-trigger Greptile

@Caball009 Caball009 changed the title bugfix(particlesys): Prevent accumulation of particle systems in headless mode fix(particlesys): Prevent accumulation of particle systems in headless mode Jul 23, 2026
@xezon xezon added the Fix Is fixing something, but is not user facing label Jul 23, 2026
Comment thread Core/GameEngine/Include/GameClient/ParticleSys.h
Comment thread Core/GameEngine/Include/GameClient/ParticleSys.h
@Caball009
Caball009 force-pushed the fix_particle_system_update branch from 62d4dea to 47fd102 Compare July 23, 2026 18:10
@Caball009
Caball009 force-pushed the fix_particle_system_update branch from 47fd102 to a16fda1 Compare July 23, 2026 18:33
@xezon
xezon merged commit f74fbee into TheSuperHackers:main Jul 23, 2026
17 checks passed
@Caball009
Caball009 deleted the fix_particle_system_update branch July 23, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fix Is fixing something, but is not user facing Gen Relates to Generals Memory Is memory related Minor Severity: Minor < Major < Critical < Blocker ThisProject The issue was introduced by this project, or this task is specific to this project ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants