diff --git a/FFXIVAPP.Client/Memory/InventoryWorker.cs b/FFXIVAPP.Client/Memory/InventoryWorker.cs index 8f7f23f1..163449fc 100644 --- a/FFXIVAPP.Client/Memory/InventoryWorker.cs +++ b/FFXIVAPP.Client/Memory/InventoryWorker.cs @@ -38,6 +38,7 @@ using FFXIVAPP.Client.Properties; using FFXIVAPP.Common.Core.Memory; using FFXIVAPP.Common.Core.Memory.Enums; +using FFXIVAPP.Common.Core.Constant; using Newtonsoft.Json; using NLog; @@ -92,7 +93,36 @@ public void StopScanning() #region Threads public Stopwatch Stopwatch = new Stopwatch(); - + // when CharacterName is not set in FFXIVAPP, get it from CHARMAP. + private void SetCharacterName() + { + if (Settings.Default.CharacterName.Length == 0) + { + var characterAddressMap = MemoryHandler.Instance.SigScanner.Locations["CHARMAP"]; + uint characterAddress = MemoryHandler.Instance.GetUInt32(characterAddressMap); + String tempName = MemoryHandler.Instance.GetString(characterAddress, 0x30); + if (!tempName.Equals(Constants.CharacterName)) + { + Constants.CharacterName = tempName; + ConstantsEntity lce = new ConstantsEntity + { + AutoTranslate = Constants.AutoTranslate, + CharacterName = Constants.CharacterName, + ChatCodes = Constants.ChatCodes, + ChatCodesXml = Constants.ChatCodesXml, + Colors = Constants.Colors, + CultureInfo = Constants.CultureInfo, + EnableHelpLabels = Constants.EnableHelpLabels, + GameLanguage = Constants.GameLanguage, + ServerName = Constants.ServerName, + Theme = Constants.Theme, + UIScale = Constants.UIScale + }; + AppContextHelper.Instance.RaiseNewConstants(lce); + } + } + + } /// /// /// @@ -127,6 +157,20 @@ private void ScanTimerElapsed(object sender, ElapsedEventArgs e) GetItems(InventoryPointerMap, Inventory.Container.EXTRA_EQ), GetItems(InventoryPointerMap, Inventory.Container.CRYSTALS), GetItems(InventoryPointerMap, Inventory.Container.QUESTS_KI), + + GetItems(InventoryPointerMap, Inventory.Container.HIRE_1), + GetItems(InventoryPointerMap, Inventory.Container.HIRE_2), + GetItems(InventoryPointerMap, Inventory.Container.HIRE_3), + GetItems(InventoryPointerMap, Inventory.Container.HIRE_4), + GetItems(InventoryPointerMap, Inventory.Container.HIRE_5), + GetItems(InventoryPointerMap, Inventory.Container.HIRE_6), + GetItems(InventoryPointerMap, Inventory.Container.HIRE_7), + + GetItems(InventoryPointerMap, Inventory.Container.COMPANY_1), + GetItems(InventoryPointerMap, Inventory.Container.COMPANY_2), + GetItems(InventoryPointerMap, Inventory.Container.COMPANY_3), + GetItems(InventoryPointerMap, Inventory.Container.COMPANY_CRYSTALS), + GetItems(InventoryPointerMap, Inventory.Container.AC_MH), GetItems(InventoryPointerMap, Inventory.Container.AC_OH), GetItems(InventoryPointerMap, Inventory.Container.AC_HEAD), @@ -161,6 +205,7 @@ private void ScanTimerElapsed(object sender, ElapsedEventArgs e) } if (notify) { + SetCharacterName(); AppContextHelper.Instance.RaiseNewInventoryEntries(inventoryEntities); } } @@ -186,8 +231,21 @@ private InventoryEntity GetItems(uint address, Inventory.Container type) Items = new List(), Type = type }; + // The number of item is 50 in COMPANY's locker + int MAX_AMOUNT; + switch (type) + { + case Inventory.Container.COMPANY_1: + case Inventory.Container.COMPANY_2: + case Inventory.Container.COMPANY_3: + MAX_AMOUNT = 3200; + break; + default: + MAX_AMOUNT = 1600; + break; + } - for (var ci = 0; ci < 1600; ci += 64) + for (var ci = 0; ci < MAX_AMOUNT; ci += 64) { var itemOffset = (uint) (containerAddress + ci); var id = MemoryHandler.Instance.GetUInt32(itemOffset, 0x8); @@ -200,7 +258,9 @@ private InventoryEntity GetItems(uint address, Inventory.Container type) Amount = MemoryHandler.Instance.GetByte(itemOffset, 0xC), SB = MemoryHandler.Instance.GetUInt16(itemOffset, 0x10), Durability = MemoryHandler.Instance.GetUInt16(itemOffset, 0x12), - GlamourID = MemoryHandler.Instance.GetUInt32(itemOffset, 0x30) + GlamourID = MemoryHandler.Instance.GetUInt32(itemOffset, 0x30), + //get the flag that show if the item is hq or not + IsHQ = (MemoryHandler.Instance.GetByte(itemOffset, 0x14) == 0x01)? true:false }); } }