Compare commits

...

2 Commits

Author SHA1 Message Date
c53b4ac3eb
fix: invite multiples times 2022-01-28 04:34:11 -05:00
8f99aa7558
refactor: add unmanaged to function pointers 2022-01-28 04:31:26 -05:00
4 changed files with 19 additions and 8 deletions

View File

@ -40,7 +40,7 @@ internal sealed unsafe class Context {
var uiModule = Framework.Instance()->GetUiModule();
// 6.05: 20D722
var func = (delegate*<UIModule*, IntPtr>) uiModule->vfunc[33];
var func = (delegate* unmanaged<UIModule*, IntPtr>) uiModule->vfunc[33];
var toIndex = func(uiModule);
// 6.05: 20E4CB
var a1 = this.Plugin.Functions.Indexer(toIndex, 0x11);

View File

@ -174,7 +174,7 @@ internal unsafe class GameFunctions : IDisposable {
agent->AddonId = (uint) addon->ID;
// vcall from E8 ?? ?? ?? ?? 0F B7 C0 48 83 C4 60
var vf5 = (delegate*<AtkUnitBase*, byte, uint, void>*) ((IntPtr) addon->VTable + 40);
var vf5 = (delegate* unmanaged<AtkUnitBase*, byte, uint, void>*) ((IntPtr) addon->VTable + 40);
// E8872D: lets vf5 actually run
*(byte*) ((IntPtr) atkStage + 0x2B4) |= 2;
(*vf5)(addon, 0, 15);

View File

@ -9,7 +9,10 @@ namespace ChatTwo.GameFunctions;
internal sealed unsafe class Party {
[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)]
private readonly delegate* unmanaged<AgentInterface*, byte*, ushort, ulong, void> _promote = null!;
@ -24,20 +27,28 @@ internal sealed unsafe class Party {
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) {
return;
}
var uiModule = Framework.Instance()->GetUiModule();
// 6.05: 20D722
var func = (delegate*<UIModule*, IntPtr>) uiModule->vfunc[33];
var func = (delegate* unmanaged<UIModule*, IntPtr>) uiModule->vfunc[33];
var toIndex = func(uiModule);
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()) {
// can specify content id if we have it, but there's no need
this._inviteToParty(a1, 0, namePtr, world);
// this only works if target is on the same world
this._inviteToParty(a1, contentId, namePtr, world);
}
}

View File

@ -298,7 +298,7 @@ internal sealed class PayloadHandler {
var isInParty = member != default;
if (isLeader) {
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) {