From 7e4f6e1ed704f4e5829827bcf931c754124d089e Mon Sep 17 00:00:00 2001 From: Anna Date: Tue, 31 May 2022 23:27:18 -0400 Subject: [PATCH] feat: add instanced inviting --- ChatTwo/GameFunctions/Party.cs | 21 ++++++++++++++++++++- ChatTwo/PayloadHandler.cs | 23 +++++++++++++++-------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/ChatTwo/GameFunctions/Party.cs b/ChatTwo/GameFunctions/Party.cs index 58bdf47..30dcb70 100755 --- a/ChatTwo/GameFunctions/Party.cs +++ b/ChatTwo/GameFunctions/Party.cs @@ -13,6 +13,9 @@ internal sealed unsafe class Party { [Signature("48 83 EC 38 41 B1 09", Fallibility = Fallibility.Fallible)] private readonly delegate* unmanaged _inviteToPartyContentId = null!; + [Signature("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 48 8B 83 ?? ?? ?? ?? 48 85 C0 74 62", Fallibility = Fallibility.Fallible)] + private readonly delegate* unmanaged _inviteToPartyInInstance = null!; + [Signature("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 49 8B 56 20", Fallibility = Fallibility.Fallible)] private readonly delegate* unmanaged _promote = null!; @@ -40,7 +43,7 @@ internal sealed unsafe class Party { } internal void InviteOtherWorld(ulong contentId) { - if (this._inviteToPartyContentId != null) { + if (this._inviteToPartyContentId == null) { return; } @@ -55,6 +58,22 @@ internal sealed unsafe class Party { } } + internal void InviteInInstance(ulong contentId) { + if (this._inviteToPartyInInstance == null) { + return; + } + + // 6.11: 214A55 + var a1 = this.Plugin.Functions.GetInfoProxyByIndex(1); + if (contentId != 0) { + // third param is world, but it requires a specific world + // if they're not on that world, it will fail + // pass 0 and it will work on any world EXCEPT for the world the + // current player is on + this._inviteToPartyInInstance(a1, contentId); + } + } + internal void Kick(string name, ulong contentId) { if (this._kick == null) { return; diff --git a/ChatTwo/PayloadHandler.cs b/ChatTwo/PayloadHandler.cs index 2bb1530..298abd4 100755 --- a/ChatTwo/PayloadHandler.cs +++ b/ChatTwo/PayloadHandler.cs @@ -450,17 +450,24 @@ internal sealed class PayloadHandler { var isLeader = party.Length == 0 || this.Ui.Plugin.ClientState.LocalContentId == leader; var member = party.FirstOrDefault(member => member.Name.TextValue == player.PlayerName && member.World.Id == player.World.RowId); var isInParty = member != default; + var inPartyInstance = this.Ui.Plugin.DataManager.GetExcelSheet()!.GetRow(this.Ui.Plugin.ClientState.TerritoryType)?.TerritoryIntendedUse is (41 or 47 or 48 or 52 or 53); if (isLeader) { - if (!isInParty && ImGui.BeginMenu("Invite to Party")) { - if (ImGui.Selectable("Same world")) { - this.Ui.Plugin.Functions.Party.InviteSameWorld(player.PlayerName, (ushort) player.World.RowId, chunk.Message?.ContentId ?? 0); - } + if (!isInParty) { + if (inPartyInstance) { + if (chunk.Message?.ContentId is not null or 0 && ImGui.Selectable("Invite to Party")) { + this.Ui.Plugin.Functions.Party.InviteInInstance(chunk.Message!.ContentId); + } + } else if (ImGui.BeginMenu("Invite to Party")) { + if (ImGui.Selectable("Same world")) { + this.Ui.Plugin.Functions.Party.InviteSameWorld(player.PlayerName, (ushort) player.World.RowId, chunk.Message?.ContentId ?? 0); + } - if (chunk.Message?.ContentId is not null or 0 && ImGui.Selectable("Different world")) { - this.Ui.Plugin.Functions.Party.InviteOtherWorld(chunk.Message!.ContentId); - } + if (chunk.Message?.ContentId is not null or 0 && ImGui.Selectable("Different world")) { + this.Ui.Plugin.Functions.Party.InviteOtherWorld(chunk.Message!.ContentId); + } - ImGui.EndMenu(); + ImGui.EndMenu(); + } } if (isInParty && member != null) {