fix: invite multiples times

This commit is contained in:
Anna 2022-01-28 04:34:11 -05:00
parent fab97a7a5f
commit 893743d72a
2 changed files with 16 additions and 5 deletions

View File

@ -9,7 +9,10 @@ namespace ChatTwo.GameFunctions;
internal sealed unsafe class Party { internal sealed unsafe class Party {
[Signature("E8 ?? ?? ?? ?? 33 C0 EB 51", Fallibility = Fallibility.Fallible)] [Signature("E8 ?? ?? ?? ?? 33 C0 EB 51", Fallibility = Fallibility.Fallible)]
private readonly delegate* unmanaged<IntPtr, ulong, byte*, ushort, void> _inviteToParty = null!; private readonly delegate* unmanaged<IntPtr, ulong, byte*, ushort, byte> _inviteToParty = null!;
[Signature("48 83 EC 38 41 B1 09", Fallibility = Fallibility.Fallible)]
private readonly delegate* unmanaged<IntPtr, ulong, ushort, byte> _inviteToPartyContentId = 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!;
@ -24,7 +27,7 @@ internal sealed unsafe class Party {
Siggingway.Siggingway.Initialise(this.Plugin.SigScanner, this); Siggingway.Siggingway.Initialise(this.Plugin.SigScanner, this);
} }
internal void Invite(string name, ushort world) { internal void Invite(string name, ushort world, ulong contentId) {
if (this._inviteToParty == null || this.Plugin.Functions.Indexer == null) { if (this._inviteToParty == null || this.Plugin.Functions.Indexer == null) {
return; return;
} }
@ -35,9 +38,17 @@ internal sealed unsafe class Party {
var toIndex = func(uiModule); var toIndex = func(uiModule);
var a1 = this.Plugin.Functions.Indexer(toIndex, 1); var a1 = this.Plugin.Functions.Indexer(toIndex, 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._inviteToPartyContentId(a1, contentId, 0);
}
fixed (byte* namePtr = name.ToTerminatedBytes()) { fixed (byte* namePtr = name.ToTerminatedBytes()) {
// can specify content id if we have it, but there's no need // this only works if target is on the same world
this._inviteToParty(a1, 0, namePtr, world); this._inviteToParty(a1, contentId, namePtr, world);
} }
} }

View File

@ -298,7 +298,7 @@ internal sealed class PayloadHandler {
var isInParty = member != default; var isInParty = member != default;
if (isLeader) { if (isLeader) {
if (!isInParty && ImGui.Selectable("Invite to Party")) { if (!isInParty && ImGui.Selectable("Invite to Party")) {
this.Ui.Plugin.Functions.Party.Invite(player.PlayerName, (ushort) player.World.RowId); this.Ui.Plugin.Functions.Party.Invite(player.PlayerName, (ushort) player.World.RowId, chunk.Message?.ContentId ?? 0);
} }
if (isInParty && member != null) { if (isInParty && member != null) {