Update enumerator in PartyList to match ActorTable

This commit is contained in:
Caraxi 2020-05-28 09:09:42 +09:30
parent dca6a2b815
commit 913807f42c

View file

@ -73,37 +73,14 @@ namespace Dalamud.Game.ClientState
} }
} }
private class PartyListEnumerator : IEnumerator<PartyMember> public IEnumerator<PartyMember> GetEnumerator() {
{ for (var i = 0; i < Length; i++) {
private readonly PartyList party; if (this[i] != null) {
private int currentIndex; yield return this[i];
}
public PartyListEnumerator(PartyList list)
{
this.party = list;
} }
public bool MoveNext()
{
this.currentIndex++;
return this.currentIndex != this.party.Length;
}
public void Reset()
{
this.currentIndex = 0;
}
public PartyMember Current => this.party[this.currentIndex];
object IEnumerator.Current => Current;
// Required by IEnumerator<T> even though we have nothing we want to dispose here.
public void Dispose() {}
} }
public IEnumerator<PartyMember> GetEnumerator() => new PartyListEnumerator(this);
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public int Length => !this.isReady ? 0 : Marshal.ReadByte(partyListBegin + 0xF0); public int Length => !this.isReady ? 0 : Marshal.ReadByte(partyListBegin + 0xF0);