Fix exception when changing zones

This commit is contained in:
Liza 2023-10-13 01:03:08 +02:00
parent fbb9df392c
commit 00ac92b152
Signed by: liza
GPG Key ID: 7199F8D727D55F67
2 changed files with 6 additions and 14 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<Version>2.8</Version>
<Version>2.9</Version>
<LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

View File

@ -50,26 +50,18 @@ partial class DeliverooPlugin
internal unsafe byte GetGrandCompanyRank() => PlayerState.Instance()->GetGrandCompanyRank();
private float GetDistanceToNpc(int npcId, out GameObject? o)
{
try
{
foreach (var obj in _objectTable)
{
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (obj != null && obj.ObjectKind == ObjectKind.EventNpc && obj is Character c)
if (obj.ObjectKind == ObjectKind.EventNpc && obj is Character c)
{
if (GetNpcId(obj) == npcId)
{
o = obj;
return Vector3.Distance(_clientState.LocalPlayer!.Position, c.Position);
return Vector3.Distance(_clientState.LocalPlayer?.Position ?? Vector3.Zero, c.Position);
}
}
}
}
catch (Exception)
{
// ignore
}
o = null;
return float.MaxValue;