Skip to content

Commit

Permalink
Proper duty recorder playback support.
Browse files Browse the repository at this point in the history
  • Loading branch information
awgil committed Jun 6, 2024
1 parent 24979d6 commit 14d4930
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
4 changes: 3 additions & 1 deletion BossMod/Debug/DebugParty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ public void DrawPartyDalamud()
ImGui.EndTable();
}

public unsafe void DrawPartyCustom()
public unsafe void DrawPartyCustom(bool secondary)
{
// note: alliance slots, unlike normal slots, are more permanent - if a player leaves, other players retain their indices (leaving gaps)
// also content ID for all alliance members always seems to be 0; this isn't a huge deal, since alliance members are always in the same zone and thus have valid object IDs
var gm = GroupManager.Instance();
if (secondary)
gm += 1;
var ui = UIState.Instance();
ImGui.TextUnformatted($"Num members: {gm->MemberCount}, alliance={(!gm->IsAlliance ? "no" : gm->IsSmallGroupAlliance ? "small-group" : "yes")}, has-helpers={ui->Buddy.DutyHelperInfo.HasHelpers}");

Expand Down
6 changes: 5 additions & 1 deletion BossMod/Debug/MainDebugWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ public unsafe override void Draw()
}
if (ImGui.CollapsingHeader("Party (custom)"))
{
_debugParty.DrawPartyCustom();
_debugParty.DrawPartyCustom(false);
}
if (ImGui.CollapsingHeader("Party (duty recorder)"))
{
_debugParty.DrawPartyCustom(true);
}
if (ImGui.CollapsingHeader("Autorotation"))
{
Expand Down
17 changes: 16 additions & 1 deletion BossMod/Framework/WorldStateGameSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,24 @@ private unsafe void UpdateParty()
{
var gm = GroupManager.Instance();
var ui = UIState.Instance();
var pc = GameObjectManager.Instance()->Objects.IndexSorted[0].Value;
var pcContentId = UIState.Instance()->PlayerState.ContentId;
var pcEntityId = UIState.Instance()->PlayerState.EntityId;
if (Service.Condition[Dalamud.Game.ClientState.Conditions.ConditionFlag.DutyRecorderPlayback])
{
// when doing replay playback, game uses independent group manager
gm += 1;
pcEntityId = pc != null ? pc->EntityId : 0;
var member = pc != null ? gm->GetPartyMemberByObjectId(pcEntityId) : null;
pcContentId = member != null ? member->ContentId : 0;
}
else if (pc != null && pc->EntityId != pcEntityId)
{
Service.Log($"[WSG] Player entity id mismatch: {pcEntityId:X} vs {pc->EntityId:X}");
}

// update player slot
UpdatePartySlot(PartyState.PlayerSlot, UIState.Instance()->PlayerState.ContentId, UIState.Instance()->PlayerState.EntityId);
UpdatePartySlot(PartyState.PlayerSlot, pcContentId, pcEntityId);

// update normal party slots: first update/remove existing members, then add new ones
for (int i = PartyState.PlayerSlot + 1; i < PartyState.MaxPartySize; ++i)
Expand Down

0 comments on commit 14d4930

Please sign in to comment.