From 1ad590943b8c7517c9f50d1838aa04d22fecc84c Mon Sep 17 00:00:00 2001 From: AlexCube Date: Fri, 23 Oct 2026 15:37:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=B8=D0=B0=D0=B3=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B8=D0=BA=D0=B0:=20=D0=B2=D0=BE=20=D1=87=D1=82=D0=BE?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=BF=D0=B0=D0=BB=D0=B0=20=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=B5=D0=BB=D0=B0=20=D0=BF=D1=80=D0=B8=20NullReference=20?= =?UTF-8?q?=D0=B2=20ItemActionAttack.Hit=20(=D0=B2=D1=80=D0=B5=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D0=BE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- HarmonySrc/HitDiag.cs | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 HarmonySrc/HitDiag.cs diff --git a/HarmonySrc/HitDiag.cs b/HarmonySrc/HitDiag.cs new file mode 100644 index 0000000..5321563 --- /dev/null +++ b/HarmonySrc/HitDiag.cs @@ -0,0 +1,50 @@ +using System; +using HarmonyLib; +using UnityEngine; + +namespace NecromancerTome +{ + /// + /// Диагностика (23.10.2026): NullReferenceException внутри ItemActionAttack.Hit при попадании стрелы (ProjectileMoveScript.checkCollision) + /// - пачками по одной стреле (исключение вылетает раньше, чем стрела сменит состояние, и она «попадает» снова каждый шаг физики). + /// Было дважды, рядом с только что догруженными зомби спящих зон. Здесь только запись в лог, во что попала стрела; исключение + /// уходит дальше как было. Не больше MaxLogs записей за запуск. Убрать, когда причина найдена. + /// + [HarmonyPatch(typeof(ItemActionAttack), nameof(ItemActionAttack.Hit))] + public static class Patch_ItemActionAttack_Hit_Diag + { + const int MaxLogs = 5; + static int _logged; + + public static Exception Finalizer(Exception __exception, WorldRayHitInfo hitInfo, int _attackerEntityId, ItemValue damagingItemValue) + { + if (__exception == null || _logged >= MaxLogs) + { + return __exception; + } + _logged++; + try + { + string s = "tag=" + (hitInfo?.tag ?? "null") + ", transform=" + (hitInfo?.transform != null ? hitInfo.transform.name : "NULL") + + ", collider=" + (hitInfo?.hitCollider != null ? hitInfo.hitCollider.name : "NULL"); + if (hitInfo != null && hitInfo.tag != null && hitInfo.tag.StartsWith("E_")) + { + Entity e = ItemActionAttack.FindHitEntityNoTagCheck(hitInfo, out string part); + s += ", entity=" + (e == null ? "NULL" : e.GetType().Name + " " + EntityClass.list[e.entityClass].entityClassName + " " + e.entityId + + (e is EntityAlive ea ? (ea.IsDead() ? " dead" : " alive") + ", emodel " + (ea.emodel != null) : "")) + + ", part=" + (part ?? "null"); + } + Entity atk = GameManager.Instance?.World?.GetEntity(_attackerEntityId); + s += ", attacker=" + (atk == null ? "NULL " + _attackerEntityId : atk.GetType().Name + " " + atk.entityId) + + ", item=" + (damagingItemValue?.ItemClass?.Name ?? "null"); + Debug.Log("[NecromancerTome] HitDiag: исключение в ItemActionAttack.Hit (" + __exception.GetType().Name + "): " + s + + "\n" + __exception.StackTrace); + } + catch (Exception e2) + { + Debug.Log("[NecromancerTome] HitDiag: не удалось описать попадание - " + e2.Message); + } + return __exception; + } + } +}