feat: add instanced inviting

This commit is contained in:
Anna 2022-05-31 23:27:18 -04:00
parent 9068199236
commit 7e4f6e1ed7
2 changed files with 35 additions and 9 deletions

View File

@ -13,6 +13,9 @@ internal sealed unsafe class Party {
[Signature("48 83 EC 38 41 B1 09", Fallibility = Fallibility.Fallible)] [Signature("48 83 EC 38 41 B1 09", Fallibility = Fallibility.Fallible)]
private readonly delegate* unmanaged<IntPtr, ulong, ushort, byte> _inviteToPartyContentId = null!; private readonly delegate* unmanaged<IntPtr, ulong, ushort, byte> _inviteToPartyContentId = null!;
[Signature("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 48 8B 83 ?? ?? ?? ?? 48 85 C0 74 62", Fallibility = Fallibility.Fallible)]
private readonly delegate* unmanaged<IntPtr, ulong, byte> _inviteToPartyInInstance = null!;
[Signature("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 49 8B 56 20", Fallibility = Fallibility.Fallible)] [Signature("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 49 8B 56 20", Fallibility = Fallibility.Fallible)]
private readonly delegate* unmanaged<AgentInterface*, byte*, ushort, ulong, void> _promote = null!; private readonly delegate* unmanaged<AgentInterface*, byte*, ushort, ulong, void> _promote = null!;
@ -40,7 +43,7 @@ internal sealed unsafe class Party {
} }
internal void InviteOtherWorld(ulong contentId) { internal void InviteOtherWorld(ulong contentId) {
if (this._inviteToPartyContentId != null) { if (this._inviteToPartyContentId == null) {
return; 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) { internal void Kick(string name, ulong contentId) {
if (this._kick == null) { if (this._kick == null) {
return; return;

View File

@ -450,8 +450,14 @@ internal sealed class PayloadHandler {
var isLeader = party.Length == 0 || this.Ui.Plugin.ClientState.LocalContentId == leader; 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 member = party.FirstOrDefault(member => member.Name.TextValue == player.PlayerName && member.World.Id == player.World.RowId);
var isInParty = member != default; var isInParty = member != default;
var inPartyInstance = this.Ui.Plugin.DataManager.GetExcelSheet<TerritoryType>()!.GetRow(this.Ui.Plugin.ClientState.TerritoryType)?.TerritoryIntendedUse is (41 or 47 or 48 or 52 or 53);
if (isLeader) { if (isLeader) {
if (!isInParty && ImGui.BeginMenu("Invite to Party")) { 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")) { if (ImGui.Selectable("Same world")) {
this.Ui.Plugin.Functions.Party.InviteSameWorld(player.PlayerName, (ushort) player.World.RowId, chunk.Message?.ContentId ?? 0); this.Ui.Plugin.Functions.Party.InviteSameWorld(player.PlayerName, (ushort) player.World.RowId, chunk.Message?.ContentId ?? 0);
} }
@ -462,6 +468,7 @@ internal sealed class PayloadHandler {
ImGui.EndMenu(); ImGui.EndMenu();
} }
}
if (isInParty && member != null) { if (isInParty && member != null) {
if (ImGui.Selectable("Promote")) { if (ImGui.Selectable("Promote")) {