Skip to content

Commit 95e1440

Browse files
authored
Merge pull request #39 from nt153133/cleanup-executes
Remove unneeded lock and cache state calls
2 parents 1fadada + eeb3287 commit 95e1440

15 files changed

+167
-351
lines changed

Extensions/BagSlotExtensions.cs

Lines changed: 114 additions & 240 deletions
Large diffs are not rendered by default.

Extensions/LocalPlayerExtensions.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,8 @@ public static int MaxGCSeals(this LocalPlayer player)
8686
{
8787
var gcRank = player.GCRank();
8888

89-
IntPtr rankRow;
90-
lock (Core.Memory.Executor.AssemblyLock)
91-
{
92-
rankRow = Core.Memory.CallInjectedWraper<IntPtr>(LocalPlayerExtensionsOffsets.GCGetMaxSealsByRank,
93-
gcRank);
94-
}
89+
IntPtr rankRow = Core.Memory.CallInjectedWraper<IntPtr>(LocalPlayerExtensionsOffsets.GCGetMaxSealsByRank,
90+
gcRank);
9591

9692
return Core.Memory.Read<int>(rankRow);
9793
}

Helpers/Achievements.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,7 @@ public static void RequestAchievement(int achievementId)
3636

3737
public static bool HasAchievement(int achievementId)
3838
{
39-
bool done;
40-
41-
lock (Core.Memory.Executor.AssemblyLock)
42-
{
43-
done = Core.Memory.CallInjectedWraper<bool>(AchievementsOffsets.IsCompletePtr, AchievementsOffsets.AchievementInstancePtr, achievementId);
44-
}
45-
46-
return done;
39+
return Core.Memory.CallInjectedWraper<bool>(AchievementsOffsets.IsCompletePtr, AchievementsOffsets.AchievementInstancePtr, achievementId);
4740
}
4841

4942
public static async Task<AchievementStatus> GetSingleAchievement(int achievementId)

Helpers/ChatBroadcaster.cs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -196,25 +196,22 @@ public void SetType(MessageType messageType)
196196

197197
public static void SendChat(byte[] array)
198198
{
199-
lock (Core.Memory.Executor.AssemblyLock)
200-
{
201-
using var allocatedMemory2 = Core.Memory.CreateAllocatedMemory(400);
202-
using var allocatedMemory = Core.Memory.CreateAllocatedMemory(array.Length + 30);
203-
allocatedMemory.AllocateOfChunk("start", array.Length);
204-
allocatedMemory.WriteBytes("start", array);
205-
allocatedMemory2.AllocateOfChunk<IntPtr>("dword0");
206-
allocatedMemory2.AllocateOfChunk<long>("dword4");
207-
allocatedMemory2.AllocateOfChunk<long>("dword8");
208-
allocatedMemory2.AllocateOfChunk<long>("dwordC");
209-
allocatedMemory2.Write("dword0", allocatedMemory.Address);
210-
allocatedMemory2.Write("dword4", 64);
211-
allocatedMemory2.Write("dword8", array.Length + 1);
212-
allocatedMemory2.Write("dwordC", 0);
213-
Core.Memory.CallInjectedWraper<int>(Offsets.ExecuteCommandInner,
214-
UiManagerProxy.RaptureShellModule,
215-
allocatedMemory2.Address,
216-
UiManagerProxy.UIModule);
217-
}
199+
using var allocatedMemory2 = Core.Memory.CreateAllocatedMemory(400);
200+
using var allocatedMemory = Core.Memory.CreateAllocatedMemory(array.Length + 30);
201+
allocatedMemory.AllocateOfChunk("start", array.Length);
202+
allocatedMemory.WriteBytes("start", array);
203+
allocatedMemory2.AllocateOfChunk<IntPtr>("dword0");
204+
allocatedMemory2.AllocateOfChunk<long>("dword4");
205+
allocatedMemory2.AllocateOfChunk<long>("dword8");
206+
allocatedMemory2.AllocateOfChunk<long>("dwordC");
207+
allocatedMemory2.Write("dword0", allocatedMemory.Address);
208+
allocatedMemory2.Write("dword4", 64);
209+
allocatedMemory2.Write("dword8", array.Length + 1);
210+
allocatedMemory2.Write("dwordC", 0);
211+
Core.Memory.CallInjectedWraper<int>(Offsets.ExecuteCommandInner,
212+
UiManagerProxy.RaptureShellModule,
213+
allocatedMemory2.Address,
214+
UiManagerProxy.UIModule);
218215
}
219216
}
220217
}

Helpers/CraftingHelper.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,9 @@ public static class CraftingHelper
2626

2727
public static bool HasCraftedRecipe(ushort recipeId)
2828
{
29-
using (Core.Memory.TemporaryCacheState(false))
30-
{
31-
return Core.Memory.CallInjectedWraper<bool>(
32-
CraftingHelperOffsets.HasCraftedRecipe,
33-
recipeId);
34-
}
29+
return Core.Memory.CallInjectedWraper<bool>(
30+
CraftingHelperOffsets.HasCraftedRecipe,
31+
recipeId);
3532
}
3633

3734
public static ushort[] CraftedRecipes()

Helpers/CurrencyHelper.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,10 @@ public static uint GetCurrencyItemId(uint index)
3535
return CurrencyCache[index];
3636
}
3737

38-
uint result;
39-
lock (Core.Memory.Executor.AssemblyLock)
40-
{
41-
result = Core.Memory.CallInjectedWraper<uint>(
38+
uint result = Core.Memory.CallInjectedWraper<uint>(
4239
CurrencyHelperOffsets.GetSpecialCurrencyItemId,
4340
SpecialCurrencyStorage,
4441
(byte)index);
45-
}
4642

4743
CurrencyCache.Add(index, result);
4844

@@ -56,13 +52,9 @@ public static uint GetTomeItemId(uint index)
5652
return TomeCache[index];
5753
}
5854

59-
uint result;
60-
lock (Core.Memory.Executor.AssemblyLock)
61-
{
62-
result = Core.Memory.CallInjectedWraper<uint>(
55+
uint result = Core.Memory.CallInjectedWraper<uint>(
6356
CurrencyHelperOffsets.GetTomeItemId,
6457
(int)index);
65-
}
6658

6759
TomeCache.Add(index, result);
6860

Helpers/GeneralFunctions.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -744,14 +744,11 @@ public static async Task RepairAll()
744744
var repairAgent = AgentModule.FindAgentIdByVtable(repairVTable);
745745
var AgentId = repairAgent;
746746
Log.Information($"OPEN: AgentId {AgentId} Offset {repairVendor.ToInt64():X} Func {repairWindow.ToInt64():X}");
747-
lock (Core.Memory.Executor.AssemblyLock)
748-
{
749-
Core.Memory.CallInjectedWraper<IntPtr>(repairWindow,
750-
ff14bot.Managers.AgentModule.GetAgentInterfaceById(AgentId).Pointer,
751-
0,
752-
0,
753-
repairVendor);
754-
}
747+
Core.Memory.CallInjectedWraper<IntPtr>(repairWindow,
748+
ff14bot.Managers.AgentModule.GetAgentInterfaceById(AgentId).Pointer,
749+
0,
750+
0,
751+
repairVendor);
755752
756753
await Coroutine.Wait(1500, () => Repair.IsOpen);
757754
}
@@ -1432,6 +1429,7 @@ public static async Task TurninCNSplendorousCrafting()
14321429
{ 38763, new CraftingRelicTurnin(38763, 7, 1, 540, 38779) },
14331430
{ 38790, new CraftingRelicTurnin(38790, 8, 1, 570, 38801) },
14341431
{ 38788, new CraftingRelicTurnin(38788, 9, 1, 570, 38804) },
1432+
14351433
{ 38799, new CraftingRelicTurnin(38799, 10, 1, 425, 38807) },
14361434

14371435
{ 38792, new CraftingRelicTurnin(38792, 10, 2, 47, 38802) },

RemoteAgents/AgentAetherWheel.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ public AetherWheelSlot[] GetWheelSlots()
2626
count = AetherialWheel.Instance.MaxSlots;
2727
}
2828

29-
using (Core.Memory.TemporaryCacheState(enabledTemporarily: false))
30-
{
31-
return Core.Memory.ReadArray<AetherWheelSlot>(Pointer + AgentAetherWheelOffsets.ArrayOffset, count);
32-
}
29+
return Core.Memory.ReadArray<AetherWheelSlot>(Pointer + AgentAetherWheelOffsets.ArrayOffset, count);
3330
}
3431
}
3532
}

RemoteAgents/AgentBankaCraftworksSupply.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,9 @@ public IntPtr InstancePointerWithOffset
3838
public void HandIn(BagSlot slot)
3939
{
4040
//var instance = Core.Memory.Read<IntPtr>(Pointer) + Offsets.PointerOffset;
41-
lock (Core.Memory.Executor.AssemblyLock)
42-
{
43-
Core.Memory.CallInjectedWraper<uint>(InstancePointerWithOffset,
44-
Pointer,
45-
slot.Slot,
46-
(int)slot.BagId);
47-
}
41+
Core.Memory.CallInjectedWraper<uint>(InstancePointerWithOffset,
42+
Pointer,
43+
slot.Slot,
44+
(int)slot.BagId);
4845
}
4946
}

RemoteAgents/AgentFishGuide.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-

2-
//#if RB_CN
1+
//#if RB_CN
32
/*
43
namespace LlamaLibrary.RemoteAgents
54
{
@@ -34,11 +33,8 @@ protected AgentFishGuide(IntPtr pointer) : base(pointer)
3433
3534
public FishGuideItem[] GetTabList()
3635
{
37-
using (Core.Memory.TemporaryCacheState(enabledTemporarily: false))
38-
{
39-
//Log.Information($"{Pointer + Offsets.TabStart - 0x6} {Offsets.TabSlotCount}");
40-
return Core.Memory.ReadArray<FishGuideItem>(Pointer + Offsets.TabStart - 0x6, Offsets.TabSlotCount); //.Select(x => x.FishItem) as List<uint>;
41-
}
36+
//Log.Information($"{Pointer + Offsets.TabStart - 0x6} {Offsets.TabSlotCount}");
37+
return Core.Memory.ReadArray<FishGuideItem>(Pointer + Offsets.TabStart - 0x6, Offsets.TabSlotCount); //.Select(x => x.FishItem) as List<uint>;
4238
}
4339
}
4440

0 commit comments

Comments
 (0)