From c9786eba50aa9c0204f4b36066a29727dd50c995 Mon Sep 17 00:00:00 2001 From: Joywayer Date: Thu, 30 Jul 2026 16:02:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(bullet):=20=5Fswap=5Fand=5Fpop=20=E5=9B=9E?= =?UTF-8?q?=E6=94=B6=E6=9C=AB=E5=B0=BE=E5=AD=90=E5=BC=B9=E6=97=B6=E9=81=97?= =?UTF-8?q?=E7=95=99=E5=86=B7=E6=95=B0=E6=8D=AE=EF=BC=8C=E8=A2=AB=E4=B8=8B?= =?UTF-8?q?=E4=B8=80=E9=A2=97=E5=A4=8D=E7=94=A8=E6=A7=BD=E4=BD=8D=E7=9A=84?= =?UTF-8?q?=E5=AD=90=E5=BC=B9=E7=BB=A7=E6=89=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pre-existing bug(非本期归航引入):冷数据的搬移与擦除都写在 if idx != last 分支内, 故 idx == last(回收最后一颗子弹)时它的 _bullet_contexts[idx] 被原样留在该 key 上, 下一颗复用该槽位的普通子弹会继承整份冷数据。运行时已复现: after recycle: active=0 ctx_keys=[0] plain bullet idx=0 inherits_cold=true cold={"homing_strength":3.0,...,"pierce_remaining":7} 归航之前症状只是一次隐形的多余穿透,故长期未被发现;归航把它放大成肉眼可见的 「普通子弹拐弯追敌」,且继承 homing 的幽灵弹会持续走重选路径付出查询开销。 修法是把 erase 移出该 if(缺键时 erase 为安全 no-op),idx != last 的搬移行为一行不改。 Co-Authored-By: Claude Opus 5 --- scripts/autoloads/bullet_manager.gd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/autoloads/bullet_manager.gd b/scripts/autoloads/bullet_manager.gd index af900e8..a22ffb8 100644 --- a/scripts/autoloads/bullet_manager.gd +++ b/scripts/autoloads/bullet_manager.gd @@ -148,6 +148,10 @@ func _swap_and_pop(idx: int) -> void: _bullet_contexts.erase(last) elif _bullet_contexts.has(idx): _bullet_contexts.erase(idx) + else: + # idx == last:无搬移,但它的冷数据同样必须清掉, + # 否则遗留在该 key 上被下一颗复用此槽位的子弹继承(erase 缺键为安全 no-op) + _bullet_contexts.erase(idx) _active_count -= 1 # ── 对外接口 ─────────────────────────────────────────────────────