Skip to content

Fix null reference in HolyBurnOrb trail drawing - #121

Open
jankrom wants to merge 1 commit into
CalamityTeam:1.4.4from
jankrom:patch-2
Open

Fix null reference in HolyBurnOrb trail drawing#121
jankrom wants to merge 1 commit into
CalamityTeam:1.4.4from
jankrom:patch-2

Conversation

@jankrom

@jankrom jankrom commented Aug 10, 2026

Copy link
Copy Markdown

HolyBurnOrbDrawer stores Projectile references for HolyBurnOrb and HolyLight projectiles and later assumes that their ModProjectile still matches the original type.

Projectile slots may be reused after the original projectile becomes inactive. In that case, a cached Projectile reference can point to a newly active projectile of another type. The existing cleanup only checks active and timeLeft, so the stale reference can remain in the list.

This causes:

System.NullReferenceException
at CalamityMod.Projectiles.Boss.HolyBurnOrbDrawer.DrawOrbTrails()

when either of these returns null:

item.ModProjectile()
item.ModProjectile()

This change restores a type check before calling DrawTrail(), preventing stale/reused projectile references from causing a rendering crash.

The issue has been observed in multiplayer during Profaned Guardians and can also occur later during unrelated fights after projectile slots have been reused.

Changes

  • Check that item.ModProjectile is still a HolyBurnOrb before drawing its trail.
  • Check that item.ModProjectile is still a HolyLight before drawing its trail.
  • No behavioral change for valid projectiles.

HolyBurnOrbDrawer stores Projectile references for HolyBurnOrb and HolyLight projectiles and later assumes that their ModProjectile still matches the original type.

Projectile slots may be reused after the original projectile becomes inactive. In that case, a cached Projectile reference can point to a newly active projectile of another type. The existing cleanup only checks active and timeLeft, so the stale reference can remain in the list.

This causes:

System.NullReferenceException
at CalamityMod.Projectiles.Boss.HolyBurnOrbDrawer.DrawOrbTrails()

when either of these returns null:

item.ModProjectile<HolyBurnOrb>()
item.ModProjectile<HolyLight>()

This change restores a type check before calling DrawTrail(), preventing stale/reused projectile references from causing a rendering crash.

The issue has been observed in multiplayer during Profaned Guardians and can also occur later during unrelated fights after projectile slots have been reused.

Changes
- Check that item.ModProjectile is still a HolyBurnOrb before drawing its trail.
- Check that item.ModProjectile is still a HolyLight before drawing its trail.
- No behavioral change for valid projectiles.
@Solxanich

Copy link
Copy Markdown

HolyBurnOrb.txt

Attached the uploaded file in 2.2.4 for posterity.
Same conclusion, slightly cleaner code and eliminating from future loops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants