fix: move InvalidGameObjectId check into SearchById

This commit is contained in:
goat 2021-08-27 01:53:48 +02:00
parent ed1a6c7810
commit 8feb0a9c53
No known key found for this signature in database
GPG key ID: F18F057873895461
2 changed files with 4 additions and 2 deletions

View file

@ -7,7 +7,6 @@ using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using JetBrains.Annotations;
using Serilog;
namespace Dalamud.Game.ClientState.Objects
@ -65,6 +64,9 @@ namespace Dalamud.Game.ClientState.Objects
/// <returns>A game object or null.</returns>
public GameObject? SearchById(uint objectId)
{
if (objectId is GameObject.InvalidGameObjectId or 0)
return null;
foreach (var obj in this)
{
if (obj == null)

View file

@ -162,7 +162,7 @@ namespace Dalamud.Game.ClientState.Objects.Types
/// This iterates the actor table, it should be used with care.
/// </remarks>
// TODO: Fix for non-networked GameObjects
public virtual GameObject? TargetObject => this.TargetObjectId != InvalidGameObjectId ? Service<ObjectTable>.Get().SearchById(this.TargetObjectId) : null;
public virtual GameObject? TargetObject => Service<ObjectTable>.Get().SearchById(this.TargetObjectId);
/// <summary>
/// Gets the underlying structure.