Skip to content

bugfix(audio): Decouple Particle Cannon audio spawn point from visual beam to restore correct position and fix quiet beam audio#2415

Merged
xezon merged 3 commits intoTheSuperHackers:mainfrom
githubawn:fix/particle-cannon-audio-volume
Mar 8, 2026
Merged

bugfix(audio): Decouple Particle Cannon audio spawn point from visual beam to restore correct position and fix quiet beam audio#2415
xezon merged 3 commits intoTheSuperHackers:mainfrom
githubawn:fix/particle-cannon-audio-volume

Conversation

@githubawn
Copy link

@githubawn githubawn commented Mar 7, 2026

@greptile-apps
Copy link

greptile-apps bot commented Mar 7, 2026

Greptile Summary

This PR fixes the Particle Cannon's quiet beam audio by decoupling the positional audio emitter position from the visual beam's raised z-origin. When a previous fix elevated ORBITAL_BEAM_Z_OFFSET from 500.0f to 3500.0f to prevent camera clipping, it inadvertently pushed the audio emitter 3000 units higher than intended, causing 3D audio attenuation to make the beam nearly inaudible.

Key changes:

  • Introduces a new constant ORBITAL_BEAM_AUDIO_Z_OFFSET = 500.0f (the original emitter height) in both Generals/ and GeneralsMD/ variants.
  • In update(): calls beam->setPosition(&audioPos) with the lower offset after LaserUpdate::initLaser() sets the visual beam — overriding the drawable's world position (used by the audio system) without affecting the visual laser endpoints.
  • In createOrbitToTargetLaser(): applies the same override at beam creation time so the initial audio position is also correct.
  • Both files have proper GPL headers, correct game-title strings (Command & Conquer Generals(tm) / Command & Conquer Generals Zero Hour(tm)), and retain original EA copyright as required.

Confidence Score: 5/5

  • This PR is safe to merge — the change is minimal, well-scoped, and correctly decouples audio position from visual position without affecting game logic or CRC.
  • The fix is small (6 new lines of logic per file, one new constant) and directly addresses the root cause: the drawable's world position being used for 3D audio attenuation was accidentally elevated to 3500 units. The beam->setPosition() call is placed correctly inside the existing null-guard on beam, after initLaser(), so it safely overrides only the audio-relevant position. Both Generals and GeneralsMD variants are updated symmetrically. No existing logic, CRC path, or save/load code is touched.
  • No files require special attention.

Sequence Diagram

sequenceDiagram
    participant PUC as ParticleUplinkCannonUpdate
    participant LU as LaserUpdate (visual)
    participant DRW as Drawable (beam)
    participant AUD as AudioSystem

    Note over PUC: update() called each frame
    PUC->>DRW: findDrawableByID(m_orbitToTargetBeamID)
    PUC->>LU: findClientUpdateModule("LaserUpdate")
    PUC->>LU: initLaser(orbitPosition z=+3500, targetPos)<br/>Visual beam starts 3500 units high
    PUC->>DRW: setPosition(audioPos z=+500)<br/>Audio emitter pinned at 500 units (original height)
    DRW-->>AUD: positional audio event at z=+500
    Note over AUD: Correct volume — emitter is close to ground

    Note over PUC: createOrbitToTargetLaser() at beam spawn
    PUC->>DRW: newDrawable(thingTemplate)
    PUC->>LU: initLaser(orbitPosition z=+3500, initialTargetPos)
    PUC->>DRW: setPosition(audioPos z=+500)
    PUC->>AUD: addAudioEvent(m_annihilationSound @ drawable)
Loading

Last reviewed commit: 32bbb50

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

Looks good. Can be polished a bit.

@xezon xezon added Audio Is audio related Bug Something is not working right, typically is user facing Major Severity: Minor < Major < Critical < Blocker ThisProject The issue was introduced by this project, or this task is specific to this project labels Mar 7, 2026
@xezon xezon changed the title fix(audio): Decouple Particle Cannon audio spawn point from visual beam bugfix(audio): Decouple Particle Cannon audio spawn point from visual beam Mar 7, 2026
@xezon xezon changed the title bugfix(audio): Decouple Particle Cannon audio spawn point from visual beam bugfix(audio): Decouple Particle Cannon audio spawn point from visual beam to restore correct position and fix quiet beam audio Mar 7, 2026
@xezon xezon merged commit d93c905 into TheSuperHackers:main Mar 8, 2026
24 checks passed
@githubawn githubawn deleted the fix/particle-cannon-audio-volume branch March 8, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Audio Is audio related Bug Something is not working right, typically is user facing Major Severity: Minor < Major < Critical < Blocker ThisProject The issue was introduced by this project, or this task is specific to this project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Particle Beam audio is very quiet

2 participants