From 4e9816283c8015ba724fc3148d972347f63de2b4 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Sun, 25 Oct 2020 14:37:29 -0400 Subject: [PATCH] minor refactoring. no significant fixes --- Projectiles/Summon/MechwormBody.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Projectiles/Summon/MechwormBody.cs b/Projectiles/Summon/MechwormBody.cs index 8f85a410a6..06bceaae88 100644 --- a/Projectiles/Summon/MechwormBody.cs +++ b/Projectiles/Summon/MechwormBody.cs @@ -95,10 +95,8 @@ namespace CalamityMod.Projectiles.Summon playerMinionSlots = owner.maxMinions; } - Projectile segmentAhead = Main.projectile[aheadSegmentWhoAmI]; - Projectile head = segmentAhead; - // Accumulate the total segments of the worm. + Projectile segmentAhead = Main.projectile[aheadSegmentWhoAmI]; segmentAhead.localAI[0] = projectile.localAI[0] + 1f; // Delete the player's entire mechworm if it's attaching to something weird. @@ -118,9 +116,11 @@ namespace CalamityMod.Projectiles.Summon return; } - // Locate the head segment by looping through all worm segments until it is found. + // Locate the head segment by sliding up the worm linked list until it is found. + // If the worm terminates or an infinite loop occurs, kill this segment. int tries = 0; - while (head.type != ModContent.ProjectileType()) + Projectile head = segmentAhead; + while (head.active && head.type != headProjType) { int aheadUUID = Projectile.GetByUUID(head.owner, head.ai[0]); if (aheadUUID == -1)