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.Game.ClientState.Objects.Types;
using Dalamud.IoC; using Dalamud.IoC;
using Dalamud.IoC.Internal; using Dalamud.IoC.Internal;
using JetBrains.Annotations;
using Serilog; using Serilog;
namespace Dalamud.Game.ClientState.Objects namespace Dalamud.Game.ClientState.Objects
@ -65,6 +64,9 @@ namespace Dalamud.Game.ClientState.Objects
/// <returns>A game object or null.</returns> /// <returns>A game object or null.</returns>
public GameObject? SearchById(uint objectId) public GameObject? SearchById(uint objectId)
{ {
if (objectId is GameObject.InvalidGameObjectId or 0)
return null;
foreach (var obj in this) foreach (var obj in this)
{ {
if (obj == null) 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. /// This iterates the actor table, it should be used with care.
/// </remarks> /// </remarks>
// TODO: Fix for non-networked GameObjects // 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> /// <summary>
/// Gets the underlying structure. /// Gets the underlying structure.