fix: add some instance checks

This commit is contained in:
Anna 2022-06-01 17:43:19 -04:00
parent e1c6a88012
commit 8ef91ef640
2 changed files with 15 additions and 3 deletions

View File

@ -33,6 +33,9 @@ internal unsafe class GameFunctions : IDisposable {
[Signature("E8 ?? ?? ?? ?? EB 20 48 8B 46 28", Fallibility = Fallibility.Fallible)]
private readonly delegate* unmanaged<AgentInterface*, uint, void> _openAchievement = null!;
[Signature("E8 ?? ?? ?? ?? 84 C0 49 8B DE", Fallibility = Fallibility.Fallible)]
private readonly delegate* unmanaged<byte> _inInstance = null!;
#endregion
#region Hooks
@ -255,6 +258,14 @@ internal unsafe class GameFunctions : IDisposable {
}
}
internal bool IsInInstance() {
if (this._inInstance == null) {
return false;
}
return this._inInstance() != 0;
}
internal void ClickNoviceNetworkButton() {
var agent = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.ChatLog);
// case 3

View File

@ -450,14 +450,15 @@ 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 inInstance = this.Ui.Plugin.Functions.IsInInstance();
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 (!isInParty) {
if (inPartyInstance) {
if (inInstance && 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")) {
} else if (!inInstance && 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);
}
@ -470,7 +471,7 @@ internal sealed class PayloadHandler {
}
}
if (isInParty && member != null) {
if (isInParty && member != null && (!inInstance || (inInstance && inPartyInstance))) {
if (ImGui.Selectable("Promote")) {
this.Ui.Plugin.Functions.Party.Promote(player.PlayerName, (ulong) member.ContentId);
}