Skip to content

Commit

Permalink
add GetZoneInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaksuhn committed Aug 17, 2024
1 parent c1de306 commit 35026a9
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
10 changes: 2 additions & 8 deletions SomethingNeedDoing/Exceptions/MacroActionTimeoutError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@ internal class MacroActionTimeoutError : MacroCommandError
/// Initializes a new instance of the <see cref="MacroActionTimeoutError"/> class.
/// </summary>
/// <param name="message">Message to show.</param>
public MacroActionTimeoutError(string message)
: base(message)
{
}
public MacroActionTimeoutError(string message) : base(message) { }

/// <summary>
/// Initializes a new instance of the <see cref="MacroActionTimeoutError"/> class.
/// </summary>
/// <param name="message">Message to show.</param>
/// <param name="innerException">The exception that is the cause of the current exception.</param>
public MacroActionTimeoutError(string message, Exception? innerException)
: base(message, innerException)
{
}
public MacroActionTimeoutError(string message, Exception? innerException) : base(message, innerException) { }
}
2 changes: 1 addition & 1 deletion SomethingNeedDoing/Grammar/Commands/ActionCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public override async Task Execute(ActiveMacro macro, CancellationToken token)
{
await PerformWait(token);

if (!unsafeMod.IsUnsafe && !DataWaiter.WaitOne(SafeCraftMaxWait))
if (!unsafeMod.IsUnsafe && !DataWaiter.WaitOne(SafeCraftMaxWait) && Service.Configuration.StopMacroIfActionTimeout)
throw new MacroActionTimeoutError("Did not receive a timely response");
}
}
Expand Down
1 change: 0 additions & 1 deletion SomethingNeedDoing/Grammar/Commands/ClickCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using ECommons.UIHelpers.AddonMasterImplementations;
using FFXIVClientStructs.FFXIV.Component.GUI;
using SomethingNeedDoing.Exceptions;
using SomethingNeedDoing.Grammar.Modifiers;
using SomethingNeedDoing.Misc;
using System;
using System.Collections;
Expand Down
2 changes: 1 addition & 1 deletion SomethingNeedDoing/Grammar/Commands/MacroCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal abstract class MacroCommand
{
private static readonly Random Rand = new();

protected MacroCommand(string text) : this(text, 0, 0) { }
protected MacroCommand(string text) => Text = text;
protected MacroCommand(string text, WaitModifier waitMod) : this(text, waitMod.Wait, waitMod.Until) { }

protected MacroCommand(string text, WaitModifier waitMod, IndexModifier indexMod) : this(text, waitMod.Wait, waitMod.Until, indexMod.ObjectId) { }
Expand Down
4 changes: 4 additions & 0 deletions SomethingNeedDoing/Misc/Changelog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ static void DisplayChangelog(string date, string changes, bool separator = true)
}
using var font = ImRaii.PushFont(UiBuilder.MonoFont);

DisplayChangelog(
"2024-08-24",
"- Added GetZoneInstance()\n");

DisplayChangelog(
"2024-07-29",
"- Added dalamud services to lua\n" +
Expand Down
8 changes: 7 additions & 1 deletion SomethingNeedDoing/Misc/Commands/InventoryCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public unsafe int GetFreeSlotsInContainer(uint container)
}

public unsafe void MoveItemToContainer(uint itemID, uint srcContainer, uint dstContainer)
=> InventoryManager.Instance()->MoveItemSlot((InventoryType)srcContainer, (ushort)GetItemInInventory(itemID, (InventoryType)srcContainer)->Slot, (InventoryType)dstContainer, GetFirstAvailableSlot((InventoryType)dstContainer));
{
InventoryManager.Instance()->MoveItemSlot((InventoryType)srcContainer, (ushort)GetItemInInventory(itemID, (InventoryType)srcContainer)->Slot, (InventoryType)dstContainer, GetFirstAvailableSlot((InventoryType)dstContainer));
}

private static unsafe InventoryItem* GetItemInInventory(uint itemId, InventoryType inv, bool mustBeHQ = false)
{
Expand All @@ -82,5 +84,9 @@ private static unsafe ushort GetFirstAvailableSlot(InventoryType container)
return 0;
}

private static unsafe InventoryItem* GetItemForSlot(InventoryType type, int slot)
=> InventoryManager.Instance()->GetInventoryContainer(type)->GetInventorySlot(slot);


public List<uint> GetTradeableWhiteItemIDs() => Svc.Data.GetExcelSheet<Item>()!.Where(x => !x.IsUntradable && x.Rarity == (byte)ItemRarity.White).Select(x => x.RowId).ToList();
}
2 changes: 2 additions & 0 deletions SomethingNeedDoing/Misc/Commands/WorldStateCommands.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FFXIVClientStructs.FFXIV.Client.Game.Event;
using FFXIVClientStructs.FFXIV.Client.Game.Fate;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Client.Graphics.Environment;
using FFXIVClientStructs.FFXIV.Client.System.Framework;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
Expand Down Expand Up @@ -74,6 +75,7 @@ public unsafe ushort GetNearestFate() => FateManager.Instance()->Fates.AsSpan().

public unsafe int GetLastInstanceServerID() => WatchedValues.InstanceServerID;
public unsafe int GetLastInstanceZoneID() => WatchedValues.InstanceServerID;
public unsafe uint GetZoneInstance() => UIState.Instance()->PublicInstance.InstanceId;

#region OceanFishing
public unsafe uint GetCurrentOceanFishingRoute() => EventFramework.Instance()->GetInstanceContentOceanFishing()->CurrentRoute;
Expand Down

0 comments on commit 35026a9

Please sign in to comment.