fix: check cross realm properly

This commit is contained in:
Anna 2024-08-01 16:12:10 -04:00
parent 74914bef0c
commit 1f85158c68
Signed by: anna
GPG Key ID: D0943384CD9F87D1

View File

@ -319,9 +319,40 @@ public class Plugin : IDalamudPlugin {
}
var names = new List<ListInfo>();
var members = AgentHUD.Instance()->PartyMembers;
for (var i = 0; i < members.Length && i < list->PartyMembers.Length; i++) {
var member = members[i];
if (member.Name == null) {
continue;
}
// controller soft target not handled by hoveredindex above
if (chara->GetSoftTargetId() == member.EntityId) {
return true;
}
var name = MemoryHelper.ReadStringNullTerminated((nint) member.Name);
var isChocobo = member.Object != null
&& member.Object->GetObjectKind() == ObjectKind.BattleNpc
&& member.Object->CompanionOwnerId == player.GameObjectId;
if (isChocobo) {
name += " (YOU)";
}
var info = new ListInfo {
Name = name,
IsChocobo = isChocobo,
Mana = member.Object != null ? member.Object->Mana : null,
PartyListIndex = i,
ClassJob = member.Object != null ? member.Object->ClassJob : null,
};
names.Add(info);
}
// check cross realm party for any members we may have missed
var crossInfo = InfoProxyCrossRealm.Instance();
if (crossInfo->IsCrossRealm != 0) {
if (crossInfo->IsInCrossRealmParty != 0) {
var crossGroup = crossInfo->CrossRealmGroups[crossInfo->LocalPlayerGroupIndex];
for (var i = 0; i < crossGroup.GroupMemberCount && i < list->PartyMembers.Length; i++) {
@ -335,43 +366,17 @@ public class Plugin : IDalamudPlugin {
return true;
}
var info = new ListInfo {
Name = name,
IsChocobo = false,
Mana = null,
PartyListIndex = i,
ClassJob = member.ClassJobId,
};
names.Add(info);
}
} else {
var members = AgentHUD.Instance()->PartyMembers;
for (var i = 0; i < members.Length && i < list->PartyMembers.Length; i++) {
var member = members[i];
if (member.Name == null) {
if (names.FirstOrDefault(info => info.Name == name) is { } info) {
info.PartyListIndex = member.MemberIndex;
continue;
}
// controller soft target not handled by hoveredindex above
if (chara->GetSoftTargetId() == member.EntityId) {
return true;
}
var name = MemoryHelper.ReadStringNullTerminated((nint) member.Name);
var isChocobo = member.Object != null
&& member.Object->GetObjectKind() == ObjectKind.BattleNpc
&& member.Object->CompanionOwnerId == player.GameObjectId;
if (isChocobo) {
name += " (YOU)";
}
var info = new ListInfo {
info = new ListInfo {
Name = name,
IsChocobo = isChocobo,
Mana = member.Object != null ? member.Object->Mana : null,
PartyListIndex = i,
ClassJob = member.Object != null ? member.Object->ClassJob : null,
IsChocobo = false,
Mana = null,
PartyListIndex = member.MemberIndex,
ClassJob = member.ClassJobId,
};
names.Add(info);
@ -385,8 +390,10 @@ public class Plugin : IDalamudPlugin {
this._showDps ^= true;
}
names.Sort((a, b) => a.PartyListIndex.CompareTo(b.PartyListIndex));
for (var i = 0; i < names.Count; i++) {
var info = names[i];
Plugin.Log.Info($"{info.Name} at {info.PartyListIndex}");
var lookupName = info.Name == playerName
? "YOU"
: info.Name;
@ -407,7 +414,9 @@ public class Plugin : IDalamudPlugin {
bool includeBar,
bool includeTargeted
) {
var unit = info.IsChocobo ? list->Chocobo : list->PartyMembers[info.PartyListIndex];
var unit = info.IsChocobo
? list->Chocobo
: list->PartyMembers[info.PartyListIndex];
if (includeBar && unit.TargetGlow != null && (includeTargeted || list->TargetedIndex != info.PartyListIndex)) {
unit.TargetGlow->SetAlpha(255);
unit.TargetGlow->SetScaleX(0);
@ -572,7 +581,9 @@ public class Plugin : IDalamudPlugin {
Combatant combatant,
IEnumerable<Combatant> combatants
) {
var member = info.IsChocobo ? list->Chocobo : list->PartyMembers[info.PartyListIndex];
var member = info.IsChocobo
? list->Chocobo
: list->PartyMembers[info.PartyListIndex];
if (this.Config.UseDpsBar && member.TargetGlow != null) {
float denominator;
switch (this.Config.DpsBarMode) {
@ -726,7 +737,7 @@ public class Plugin : IDalamudPlugin {
public class ListInfo {
public required string Name { get; init; }
public required bool IsChocobo { get; init; }
public required int PartyListIndex { get; init; }
public required int PartyListIndex { get; set; }
public required uint? Mana { get; init; }
public required byte? ClassJob { get; init; }
}