diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs index 6a9332b9d..3caa5e35f 100644 --- a/Dalamud/Dalamud.cs +++ b/Dalamud/Dalamud.cs @@ -197,6 +197,8 @@ namespace Dalamud { this.WinSock2.Dispose(); this.SigScanner.Dispose(); + + this.Data.Dispose(); } #region Interface diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index c3663d077..df086f0ff 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -38,7 +38,8 @@ - + + diff --git a/Dalamud/Data/DataManager.cs b/Dalamud/Data/DataManager.cs index 35945f6e2..6b400ce2d 100644 --- a/Dalamud/Data/DataManager.cs +++ b/Dalamud/Data/DataManager.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.IO; using System.Net; using System.Net.Http; +using System.Threading; using System.Threading.Tasks; using Dalamud.Data.LuminaExtensions; using Lumina.Data; @@ -21,7 +22,7 @@ namespace Dalamud.Data /// /// This class provides data for Dalamud-internal features, but can also be used by plugins if needed. /// - public class DataManager { + public class DataManager : IDisposable { /// /// OpCodes sent by the server to the client. /// @@ -50,6 +51,8 @@ namespace Dalamud.Data private const string IconFileFormat = "ui/icon/{0:D3}000/{1}{2:D6}.tex"; + private Thread luminaResourceThread; + public DataManager(ClientLanguage language) { // Set up default values so plugins do not null-reference when data is being loaded. @@ -96,6 +99,17 @@ namespace Dalamud.Data Log.Information("Lumina is ready: {0}", gameData.DataPath); IsDataReady = true; + + this.luminaResourceThread = new Thread( () => + { + while( true ) + { + gameData.ProcessFileHandleQueue(); + Thread.Yield(); + } + // ReSharper disable once FunctionNeverReturns + }); + this.luminaResourceThread.Start(); } catch (Exception ex) { @@ -211,5 +225,10 @@ namespace Dalamud.Data } #endregion + + public void Dispose() + { + this.luminaResourceThread.Abort(); + } } } diff --git a/Dalamud/Data/TransientSheet/Completion.cs b/Dalamud/Data/TransientSheet/Completion.cs index e437971c3..2e36b97b2 100644 --- a/Dalamud/Data/TransientSheet/Completion.cs +++ b/Dalamud/Data/TransientSheet/Completion.cs @@ -24,8 +24,8 @@ namespace Dalamud.Data.TransientSheet public ushort Key; - public int RowId { get; set; } - public int SubRowId { get; set; } + public uint RowId { get; set; } + public uint SubRowId { get; set; } public void PopulateData( RowParser parser, Lumina.Lumina lumina ) { diff --git a/Dalamud/Data/TransientSheet/ContentFinderCondition.cs b/Dalamud/Data/TransientSheet/ContentFinderCondition.cs index 20d589024..35aa8505e 100644 --- a/Dalamud/Data/TransientSheet/ContentFinderCondition.cs +++ b/Dalamud/Data/TransientSheet/ContentFinderCondition.cs @@ -592,8 +592,8 @@ namespace Dalamud.Data.TransientSheet public bool unknown62_40 => (packed62 & 0x40) == 0x40; - public int RowId { get; set; } - public int SubRowId { get; set; } + public uint RowId { get; set; } + public uint SubRowId { get; set; } public void PopulateData(RowParser parser, Lumina.Lumina lumina) { diff --git a/Dalamud/Data/TransientSheet/Item.cs b/Dalamud/Data/TransientSheet/Item.cs index 2b6018042..e263ad4c8 100644 --- a/Dalamud/Data/TransientSheet/Item.cs +++ b/Dalamud/Data/TransientSheet/Item.cs @@ -239,8 +239,8 @@ namespace Dalamud.Data.TransientSheet public bool AlwaysCollectable => (packeda0 & 0x1) == 0x1; - public int RowId { get; set; } - public int SubRowId { get; set; } + public uint RowId { get; set; } + public uint SubRowId { get; set; } public void PopulateData(RowParser parser, global::Lumina.Lumina lumina) { diff --git a/Dalamud/Data/TransientSheet/PetMirage.cs b/Dalamud/Data/TransientSheet/PetMirage.cs index 42e39337d..ee3eb63d3 100644 --- a/Dalamud/Data/TransientSheet/PetMirage.cs +++ b/Dalamud/Data/TransientSheet/PetMirage.cs @@ -198,8 +198,8 @@ namespace Dalamud.Data.TransientSheet public ushort unknown80; - public int RowId { get; set; } - public int SubRowId { get; set; } + public uint RowId { get; set; } + public uint SubRowId { get; set; } public void PopulateData( RowParser parser, Lumina.Lumina lumina ) { diff --git a/Dalamud/Game/Chat/SeStringHandling/Payloads/AutoTranslatePayload.cs b/Dalamud/Game/Chat/SeStringHandling/Payloads/AutoTranslatePayload.cs index 97e925b11..1fc32bf06 100644 --- a/Dalamud/Game/Chat/SeStringHandling/Payloads/AutoTranslatePayload.cs +++ b/Dalamud/Game/Chat/SeStringHandling/Payloads/AutoTranslatePayload.cs @@ -98,7 +98,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads // try to get the row in the Completion table itself, because this is 'easiest' // The row may not exist at all (if the Key is for another table), or it could be the wrong row // (again, if it's meant for another table) - row = sheet.GetRow((int)this.key); + row = sheet.GetRow(this.key); } catch { } // don't care, row will be null @@ -117,28 +117,26 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads // many of the names contain valid id ranges after the table name, but we don't need those var actualTableName = row.LookupTable.Split('[')[0]; - var ikey = (int)this.key; - var name = actualTableName switch { - "Action" => this.dataResolver.GetExcelSheet().GetRow(ikey).Name, - "ActionComboRoute" => this.dataResolver.GetExcelSheet().GetRow(ikey).Name, - "BuddyAction" => this.dataResolver.GetExcelSheet().GetRow(ikey).Name, - "ClassJob" => this.dataResolver.GetExcelSheet().GetRow(ikey).Name, - "Companion" => this.dataResolver.GetExcelSheet().GetRow(ikey).Singular, - "CraftAction" => this.dataResolver.GetExcelSheet().GetRow(ikey).Name, - "GeneralAction" => this.dataResolver.GetExcelSheet().GetRow(ikey).Name, - "GuardianDeity" => this.dataResolver.GetExcelSheet().GetRow(ikey).Name, - "MainCommand" => this.dataResolver.GetExcelSheet().GetRow(ikey).Name, - "Mount" => this.dataResolver.GetExcelSheet().GetRow(ikey).Singular, - "Pet" => this.dataResolver.GetExcelSheet().GetRow(ikey).Name, - "PetAction" => this.dataResolver.GetExcelSheet().GetRow(ikey).Name, - "PetMirage" => this.dataResolver.GetExcelSheet().GetRow(ikey).Name, - "PlaceName" => this.dataResolver.GetExcelSheet().GetRow(ikey).Name, - "Race" => this.dataResolver.GetExcelSheet().GetRow(ikey).Masculine, - "TextCommand" => this.dataResolver.GetExcelSheet().GetRow(ikey).Command, - "Tribe" => this.dataResolver.GetExcelSheet().GetRow(ikey).Masculine, - "Weather" => this.dataResolver.GetExcelSheet().GetRow(ikey).Name, + "Action" => this.dataResolver.GetExcelSheet().GetRow(this.key).Name, + "ActionComboRoute" => this.dataResolver.GetExcelSheet().GetRow(this.key).Name, + "BuddyAction" => this.dataResolver.GetExcelSheet().GetRow(this.key).Name, + "ClassJob" => this.dataResolver.GetExcelSheet().GetRow(this.key).Name, + "Companion" => this.dataResolver.GetExcelSheet().GetRow(this.key).Singular, + "CraftAction" => this.dataResolver.GetExcelSheet().GetRow(this.key).Name, + "GeneralAction" => this.dataResolver.GetExcelSheet().GetRow(this.key).Name, + "GuardianDeity" => this.dataResolver.GetExcelSheet().GetRow(this.key).Name, + "MainCommand" => this.dataResolver.GetExcelSheet().GetRow(this.key).Name, + "Mount" => this.dataResolver.GetExcelSheet().GetRow(this.key).Singular, + "Pet" => this.dataResolver.GetExcelSheet().GetRow(this.key).Name, + "PetAction" => this.dataResolver.GetExcelSheet().GetRow(this.key).Name, + "PetMirage" => this.dataResolver.GetExcelSheet().GetRow(this.key).Name, + "PlaceName" => this.dataResolver.GetExcelSheet().GetRow(this.key).Name, + "Race" => this.dataResolver.GetExcelSheet().GetRow(this.key).Masculine, + "TextCommand" => this.dataResolver.GetExcelSheet().GetRow(this.key).Command, + "Tribe" => this.dataResolver.GetExcelSheet().GetRow(this.key).Masculine, + "Weather" => this.dataResolver.GetExcelSheet().GetRow(this.key).Name, _ => throw new Exception(actualTableName) }; diff --git a/Dalamud/Game/Chat/SeStringHandling/Payloads/ItemPayload.cs b/Dalamud/Game/Chat/SeStringHandling/Payloads/ItemPayload.cs index 87b3ab87d..90980fb89 100644 --- a/Dalamud/Game/Chat/SeStringHandling/Payloads/ItemPayload.cs +++ b/Dalamud/Game/Chat/SeStringHandling/Payloads/ItemPayload.cs @@ -25,7 +25,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads { get { - this.item ??= this.dataResolver.GetExcelSheet().GetRow((int)this.itemId); + this.item ??= this.dataResolver.GetExcelSheet().GetRow(this.itemId); return this.item; } } diff --git a/Dalamud/Game/Chat/SeStringHandling/Payloads/MapLinkPayload.cs b/Dalamud/Game/Chat/SeStringHandling/Payloads/MapLinkPayload.cs index e73eb8393..c222c4101 100644 --- a/Dalamud/Game/Chat/SeStringHandling/Payloads/MapLinkPayload.cs +++ b/Dalamud/Game/Chat/SeStringHandling/Payloads/MapLinkPayload.cs @@ -23,7 +23,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads { get { - this.map ??= this.dataResolver.GetExcelSheet().GetRow((int)this.mapId); + this.map ??= this.dataResolver.GetExcelSheet().GetRow(this.mapId); return this.map; } } @@ -39,7 +39,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads { get { - this.territoryType ??= this.dataResolver.GetExcelSheet().GetRow((int)this.territoryTypeId); + this.territoryType ??= this.dataResolver.GetExcelSheet().GetRow(this.territoryTypeId); return this.territoryType; } } @@ -105,7 +105,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads { get { - this.placeNameRegion ??= this.dataResolver.GetExcelSheet().GetRow(TerritoryType.PlaceNameRegion).Name; + this.placeNameRegion ??= TerritoryType.PlaceNameRegion.Value?.Name; return this.placeNameRegion; } } @@ -118,7 +118,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads { get { - this.placeName ??= this.dataResolver.GetExcelSheet().GetRow(TerritoryType.PlaceName).Name; + this.placeName ??= TerritoryType.PlaceName.Value?.Name; return this.placeName; } } diff --git a/Dalamud/Game/Chat/SeStringHandling/Payloads/PlayerPayload.cs b/Dalamud/Game/Chat/SeStringHandling/Payloads/PlayerPayload.cs index d2c0cbfb8..084bb2279 100644 --- a/Dalamud/Game/Chat/SeStringHandling/Payloads/PlayerPayload.cs +++ b/Dalamud/Game/Chat/SeStringHandling/Payloads/PlayerPayload.cs @@ -38,7 +38,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads { get { - this.world ??= this.dataResolver.GetExcelSheet().GetRow((int)this.serverId); + this.world ??= this.dataResolver.GetExcelSheet().GetRow(this.serverId); return this.world; } } diff --git a/Dalamud/Game/Chat/SeStringHandling/Payloads/StatusPayload.cs b/Dalamud/Game/Chat/SeStringHandling/Payloads/StatusPayload.cs index d5753e40c..0ddbe927a 100644 --- a/Dalamud/Game/Chat/SeStringHandling/Payloads/StatusPayload.cs +++ b/Dalamud/Game/Chat/SeStringHandling/Payloads/StatusPayload.cs @@ -23,7 +23,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads { get { - status ??= this.dataResolver.GetExcelSheet().GetRow((int)this.statusId); + status ??= this.dataResolver.GetExcelSheet().GetRow(this.statusId); return status; } } diff --git a/Dalamud/Game/Chat/SeStringHandling/SeStringUtils.cs b/Dalamud/Game/Chat/SeStringHandling/SeStringUtils.cs index e7b4cc43f..edd2c72c6 100644 --- a/Dalamud/Game/Chat/SeStringHandling/SeStringUtils.cs +++ b/Dalamud/Game/Chat/SeStringHandling/SeStringUtils.cs @@ -22,7 +22,7 @@ namespace Dalamud.Game.Chat.SeStringHandling /// An SeString containing all the payloads necessary to display an item link in the chat log. public static SeString CreateItemLink(uint itemId, bool isHQ, string displayNameOverride = null) { - string displayName = displayNameOverride ?? SeString.Dalamud.Data.GetExcelSheet().GetRow((int)itemId).Name; + string displayName = displayNameOverride ?? SeString.Dalamud.Data.GetExcelSheet().GetRow(itemId).Name; if (isHQ) { displayName += $" {(char)SeIconChar.HighQuality}"; @@ -118,10 +118,10 @@ namespace Dalamud.Game.Chat.SeStringHandling foreach (var place in matches) { - var map = mapSheet.GetRows().FirstOrDefault(row => row.PlaceName == place.RowId); + var map = mapSheet.GetRows().FirstOrDefault(row => row.PlaceName.Row == place.RowId); if (map != null) { - return CreateMapLink(map.TerritoryType, (uint)map.RowId, xCoord, yCoord); + return CreateMapLink(map.TerritoryType.Row, (uint)map.RowId, xCoord, yCoord); } } diff --git a/Dalamud/Game/ClientState/Actors/Resolvers/ClassJob.cs b/Dalamud/Game/ClientState/Actors/Resolvers/ClassJob.cs index ecb8cbcc4..f2a323bda 100644 --- a/Dalamud/Game/ClientState/Actors/Resolvers/ClassJob.cs +++ b/Dalamud/Game/ClientState/Actors/Resolvers/ClassJob.cs @@ -13,7 +13,7 @@ namespace Dalamud.Game.ClientState.Actors.Resolvers /// /// ID of the ClassJob. /// - public readonly int Id; + public readonly uint Id; /// /// GameData linked to this ClassJob. diff --git a/Dalamud/Game/ClientState/Actors/Resolvers/World.cs b/Dalamud/Game/ClientState/Actors/Resolvers/World.cs index 4ba4d9396..23d89d22e 100644 --- a/Dalamud/Game/ClientState/Actors/Resolvers/World.cs +++ b/Dalamud/Game/ClientState/Actors/Resolvers/World.cs @@ -13,7 +13,7 @@ namespace Dalamud.Game.ClientState.Actors.Resolvers /// /// ID of the world. /// - public readonly int Id; + public readonly uint Id; /// /// GameData linked to this world. diff --git a/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisHistoryUploadRequest.cs b/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisHistoryUploadRequest.cs index 51bcbacb8..9f3ae9212 100644 --- a/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisHistoryUploadRequest.cs +++ b/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisHistoryUploadRequest.cs @@ -4,7 +4,7 @@ using Newtonsoft.Json; namespace Dalamud.Game.Network.MarketBoardUploaders.Universalis { internal class UniversalisHistoryUploadRequest { [JsonProperty("worldID")] - public int WorldId { get; set; } + public uint WorldId { get; set; } [JsonProperty("itemID")] public uint ItemId { get; set; } diff --git a/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisItemListingsUploadRequest.cs b/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisItemListingsUploadRequest.cs index e07525f13..491fdef8f 100644 --- a/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisItemListingsUploadRequest.cs +++ b/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisItemListingsUploadRequest.cs @@ -4,7 +4,7 @@ using Newtonsoft.Json; namespace Dalamud.Game.Network.MarketBoardUploaders.Universalis { internal class UniversalisItemListingsUploadRequest { [JsonProperty("worldID")] - public int WorldId { get; set; } + public uint WorldId { get; set; } [JsonProperty("itemID")] public uint ItemId { get; set; } diff --git a/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisMarketBoardUploader.cs b/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisMarketBoardUploader.cs index 83c657b14..dec11d50d 100644 --- a/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisMarketBoardUploader.cs +++ b/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisMarketBoardUploader.cs @@ -28,7 +28,7 @@ namespace Dalamud.Game.Network.Universalis.MarketBoardUploaders { var uploader = this.dalamud.ClientState.LocalContentId; var listingsRequestObject = new UniversalisItemListingsUploadRequest(); - listingsRequestObject.WorldId = this.dalamud.ClientState.LocalPlayer.CurrentWorld.Id; + listingsRequestObject.WorldId = this.dalamud.ClientState.LocalPlayer?.CurrentWorld.Id ?? 0; listingsRequestObject.UploaderId = uploader; listingsRequestObject.ItemId = request.CatalogId; @@ -63,7 +63,7 @@ namespace Dalamud.Game.Network.Universalis.MarketBoardUploaders { Log.Verbose(upload); var historyRequestObject = new UniversalisHistoryUploadRequest(); - historyRequestObject.WorldId = this.dalamud.ClientState.LocalPlayer.CurrentWorld.Id; + historyRequestObject.WorldId = this.dalamud.ClientState.LocalPlayer?.CurrentWorld.Id ?? 0; historyRequestObject.UploaderId = uploader; historyRequestObject.ItemId = request.CatalogId; @@ -92,7 +92,7 @@ namespace Dalamud.Game.Network.Universalis.MarketBoardUploaders { using (var client = new WebClient()) { var taxRatesRequest = new UniversalisTaxUploadRequest(); - taxRatesRequest.WorldId = this.dalamud.ClientState.LocalPlayer.CurrentWorld.Id; + taxRatesRequest.WorldId = this.dalamud.ClientState.LocalPlayer?.CurrentWorld.Id ?? 0; taxRatesRequest.UploaderId = this.dalamud.ClientState.LocalContentId; taxRatesRequest.TaxData = new UniversalisTaxData { diff --git a/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisTaxUploadRequest.cs b/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisTaxUploadRequest.cs index 0e142c17c..a64770ab1 100644 --- a/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisTaxUploadRequest.cs +++ b/Dalamud/Game/Network/MarketBoardUploaders/Universalis/UniversalisTaxUploadRequest.cs @@ -13,7 +13,7 @@ namespace Dalamud.Game.Network.MarketBoardUploaders.Universalis public ulong UploaderId { get; set; } [JsonProperty("worldID")] - public int WorldId { get; set; } + public uint WorldId { get; set; } [JsonProperty("marketTaxRates")] public UniversalisTaxData TaxData { get; set; }