Skip to content

Prevent building fragments from hitting their source - #4661

Draft
WhiteGiverMa wants to merge 1 commit into
CombatExtended-Continued:Developmentfrom
WhiteGiverMa:fix/wall-fragment-self-hit
Draft

Prevent building fragments from hitting their source#4661
WhiteGiverMa wants to merge 1 commit into
CombatExtended-Continued:Developmentfrom
WhiteGiverMa:fix/wall-fragment-self-hit

Conversation

@WhiteGiverMa

@WhiteGiverMa WhiteGiverMa commented Jul 12, 2026

Copy link
Copy Markdown

Additions

  • None.

Changes

  • Mark fragments emitted from a damaged building with their source building.
  • Exclude that source building from the fragment projectile's collision candidates.
  • Serialize the exclusion reference so a fragment saved in flight retains the rule after loading.

References

  • Reproduction symptom: Tried to destroy already-destroyed thing Turret_AutoChargeBlaster...
  • No upstream issue opened; the causal chain is documented below.

Reasoning

  • Harmony_DamageWorker_Apply emits building fragments before the original damage worker runs.
  • CompFragments.FragRoutine ticks each emitted fragment immediately. A fragment can collide with the building that emitted it, destroy it, and return to the outer damage worker.
  • The outer vanilla damage worker then reaches Kill() for the same, already-destroyed building and emits a false duplicate-destroy error.
  • Excluding only the emission source preserves fragment damage to every other target and leaves ordinary fragment generation unchanged.

Alternatives

  • Disable Fragments from walls globally:
    • Avoids the error, but removes the feature instead of fixing it.
  • Use the source building as the projectile launcher:
    • Reuses existing self-collision logic, but misattributes fragment damage and combat logs.
  • Defer all building fragments until after damage resolution:
    • Avoids synchronous re-entry, but changes timing and allows surviving buildings to be hit by their own delayed fragments.

Testing

@github-actions

Copy link
Copy Markdown

You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-29182189983.zip

@github-actions github-actions Bot added the Download in Comments This PR has a zipfile download available. label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Download in Comments This PR has a zipfile download available.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant