update to lumina 2.0.0, fix related breakages in dalamud

This commit is contained in:
NotAdam 2020-06-09 20:43:18 +10:00
parent 75b722eae0
commit 2bbe4fc4ba
19 changed files with 69 additions and 49 deletions

View file

@ -197,6 +197,8 @@ namespace Dalamud {
this.WinSock2.Dispose(); this.WinSock2.Dispose();
this.SigScanner.Dispose(); this.SigScanner.Dispose();
this.Data.Dispose();
} }
#region Interface #region Interface

View file

@ -38,7 +38,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CheapLoc" Version="1.1.3" /> <PackageReference Include="CheapLoc" Version="1.1.3" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" /> <PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Lumina" Version="1.1.4" /> <PackageReference Include="Lumina" Version="2.0.0" />
<PackageReference Include="Lumina.Generated" Version="5.25.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="PropertyChanged.Fody" Version="2.6.1" /> <PackageReference Include="PropertyChanged.Fody" Version="2.6.1" />
<PackageReference Include="Serilog" Version="2.6.0" /> <PackageReference Include="Serilog" Version="2.6.0" />

View file

@ -5,6 +5,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Dalamud.Data.LuminaExtensions; using Dalamud.Data.LuminaExtensions;
using Lumina.Data; using Lumina.Data;
@ -21,7 +22,7 @@ namespace Dalamud.Data
/// <summary> /// <summary>
/// This class provides data for Dalamud-internal features, but can also be used by plugins if needed. /// This class provides data for Dalamud-internal features, but can also be used by plugins if needed.
/// </summary> /// </summary>
public class DataManager { public class DataManager : IDisposable {
/// <summary> /// <summary>
/// OpCodes sent by the server to the client. /// OpCodes sent by the server to the client.
/// </summary> /// </summary>
@ -50,6 +51,8 @@ namespace Dalamud.Data
private const string IconFileFormat = "ui/icon/{0:D3}000/{1}{2:D6}.tex"; private const string IconFileFormat = "ui/icon/{0:D3}000/{1}{2:D6}.tex";
private Thread luminaResourceThread;
public DataManager(ClientLanguage language) public DataManager(ClientLanguage language)
{ {
// Set up default values so plugins do not null-reference when data is being loaded. // 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); Log.Information("Lumina is ready: {0}", gameData.DataPath);
IsDataReady = true; IsDataReady = true;
this.luminaResourceThread = new Thread( () =>
{
while( true )
{
gameData.ProcessFileHandleQueue();
Thread.Yield();
}
// ReSharper disable once FunctionNeverReturns
});
this.luminaResourceThread.Start();
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -211,5 +225,10 @@ namespace Dalamud.Data
} }
#endregion #endregion
public void Dispose()
{
this.luminaResourceThread.Abort();
}
} }
} }

View file

@ -24,8 +24,8 @@ namespace Dalamud.Data.TransientSheet
public ushort Key; public ushort Key;
public int RowId { get; set; } public uint RowId { get; set; }
public int SubRowId { get; set; } public uint SubRowId { get; set; }
public void PopulateData( RowParser parser, Lumina.Lumina lumina ) public void PopulateData( RowParser parser, Lumina.Lumina lumina )
{ {

View file

@ -592,8 +592,8 @@ namespace Dalamud.Data.TransientSheet
public bool unknown62_40 => (packed62 & 0x40) == 0x40; public bool unknown62_40 => (packed62 & 0x40) == 0x40;
public int RowId { get; set; } public uint RowId { get; set; }
public int SubRowId { get; set; } public uint SubRowId { get; set; }
public void PopulateData(RowParser parser, Lumina.Lumina lumina) public void PopulateData(RowParser parser, Lumina.Lumina lumina)
{ {

View file

@ -239,8 +239,8 @@ namespace Dalamud.Data.TransientSheet
public bool AlwaysCollectable => (packeda0 & 0x1) == 0x1; public bool AlwaysCollectable => (packeda0 & 0x1) == 0x1;
public int RowId { get; set; } public uint RowId { get; set; }
public int SubRowId { get; set; } public uint SubRowId { get; set; }
public void PopulateData(RowParser parser, global::Lumina.Lumina lumina) public void PopulateData(RowParser parser, global::Lumina.Lumina lumina)
{ {

View file

@ -198,8 +198,8 @@ namespace Dalamud.Data.TransientSheet
public ushort unknown80; public ushort unknown80;
public int RowId { get; set; } public uint RowId { get; set; }
public int SubRowId { get; set; } public uint SubRowId { get; set; }
public void PopulateData( RowParser parser, Lumina.Lumina lumina ) public void PopulateData( RowParser parser, Lumina.Lumina lumina )
{ {

View file

@ -98,7 +98,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
// try to get the row in the Completion table itself, because this is 'easiest' // 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 // 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) // (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 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 // 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 actualTableName = row.LookupTable.Split('[')[0];
var ikey = (int)this.key;
var name = actualTableName switch var name = actualTableName switch
{ {
"Action" => this.dataResolver.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>().GetRow(ikey).Name, "Action" => this.dataResolver.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>().GetRow(this.key).Name,
"ActionComboRoute" => this.dataResolver.GetExcelSheet<ActionComboRoute>().GetRow(ikey).Name, "ActionComboRoute" => this.dataResolver.GetExcelSheet<ActionComboRoute>().GetRow(this.key).Name,
"BuddyAction" => this.dataResolver.GetExcelSheet<BuddyAction>().GetRow(ikey).Name, "BuddyAction" => this.dataResolver.GetExcelSheet<BuddyAction>().GetRow(this.key).Name,
"ClassJob" => this.dataResolver.GetExcelSheet<ClassJob>().GetRow(ikey).Name, "ClassJob" => this.dataResolver.GetExcelSheet<ClassJob>().GetRow(this.key).Name,
"Companion" => this.dataResolver.GetExcelSheet<Companion>().GetRow(ikey).Singular, "Companion" => this.dataResolver.GetExcelSheet<Companion>().GetRow(this.key).Singular,
"CraftAction" => this.dataResolver.GetExcelSheet<CraftAction>().GetRow(ikey).Name, "CraftAction" => this.dataResolver.GetExcelSheet<CraftAction>().GetRow(this.key).Name,
"GeneralAction" => this.dataResolver.GetExcelSheet<GeneralAction>().GetRow(ikey).Name, "GeneralAction" => this.dataResolver.GetExcelSheet<GeneralAction>().GetRow(this.key).Name,
"GuardianDeity" => this.dataResolver.GetExcelSheet<GuardianDeity>().GetRow(ikey).Name, "GuardianDeity" => this.dataResolver.GetExcelSheet<GuardianDeity>().GetRow(this.key).Name,
"MainCommand" => this.dataResolver.GetExcelSheet<MainCommand>().GetRow(ikey).Name, "MainCommand" => this.dataResolver.GetExcelSheet<MainCommand>().GetRow(this.key).Name,
"Mount" => this.dataResolver.GetExcelSheet<Mount>().GetRow(ikey).Singular, "Mount" => this.dataResolver.GetExcelSheet<Mount>().GetRow(this.key).Singular,
"Pet" => this.dataResolver.GetExcelSheet<Pet>().GetRow(ikey).Name, "Pet" => this.dataResolver.GetExcelSheet<Pet>().GetRow(this.key).Name,
"PetAction" => this.dataResolver.GetExcelSheet<PetAction>().GetRow(ikey).Name, "PetAction" => this.dataResolver.GetExcelSheet<PetAction>().GetRow(this.key).Name,
"PetMirage" => this.dataResolver.GetExcelSheet<PetMirage>().GetRow(ikey).Name, "PetMirage" => this.dataResolver.GetExcelSheet<PetMirage>().GetRow(this.key).Name,
"PlaceName" => this.dataResolver.GetExcelSheet<PlaceName>().GetRow(ikey).Name, "PlaceName" => this.dataResolver.GetExcelSheet<PlaceName>().GetRow(this.key).Name,
"Race" => this.dataResolver.GetExcelSheet<Race>().GetRow(ikey).Masculine, "Race" => this.dataResolver.GetExcelSheet<Race>().GetRow(this.key).Masculine,
"TextCommand" => this.dataResolver.GetExcelSheet<TextCommand>().GetRow(ikey).Command, "TextCommand" => this.dataResolver.GetExcelSheet<TextCommand>().GetRow(this.key).Command,
"Tribe" => this.dataResolver.GetExcelSheet<Tribe>().GetRow(ikey).Masculine, "Tribe" => this.dataResolver.GetExcelSheet<Tribe>().GetRow(this.key).Masculine,
"Weather" => this.dataResolver.GetExcelSheet<Weather>().GetRow(ikey).Name, "Weather" => this.dataResolver.GetExcelSheet<Weather>().GetRow(this.key).Name,
_ => throw new Exception(actualTableName) _ => throw new Exception(actualTableName)
}; };

View file

@ -25,7 +25,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
{ {
get get
{ {
this.item ??= this.dataResolver.GetExcelSheet<Item>().GetRow((int)this.itemId); this.item ??= this.dataResolver.GetExcelSheet<Item>().GetRow(this.itemId);
return this.item; return this.item;
} }
} }

View file

@ -23,7 +23,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
{ {
get get
{ {
this.map ??= this.dataResolver.GetExcelSheet<Map>().GetRow((int)this.mapId); this.map ??= this.dataResolver.GetExcelSheet<Map>().GetRow(this.mapId);
return this.map; return this.map;
} }
} }
@ -39,7 +39,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
{ {
get get
{ {
this.territoryType ??= this.dataResolver.GetExcelSheet<TerritoryType>().GetRow((int)this.territoryTypeId); this.territoryType ??= this.dataResolver.GetExcelSheet<TerritoryType>().GetRow(this.territoryTypeId);
return this.territoryType; return this.territoryType;
} }
} }
@ -105,7 +105,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
{ {
get get
{ {
this.placeNameRegion ??= this.dataResolver.GetExcelSheet<PlaceName>().GetRow(TerritoryType.PlaceNameRegion).Name; this.placeNameRegion ??= TerritoryType.PlaceNameRegion.Value?.Name;
return this.placeNameRegion; return this.placeNameRegion;
} }
} }
@ -118,7 +118,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
{ {
get get
{ {
this.placeName ??= this.dataResolver.GetExcelSheet<PlaceName>().GetRow(TerritoryType.PlaceName).Name; this.placeName ??= TerritoryType.PlaceName.Value?.Name;
return this.placeName; return this.placeName;
} }
} }

View file

@ -38,7 +38,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
{ {
get get
{ {
this.world ??= this.dataResolver.GetExcelSheet<World>().GetRow((int)this.serverId); this.world ??= this.dataResolver.GetExcelSheet<World>().GetRow(this.serverId);
return this.world; return this.world;
} }
} }

View file

@ -23,7 +23,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
{ {
get get
{ {
status ??= this.dataResolver.GetExcelSheet<Status>().GetRow((int)this.statusId); status ??= this.dataResolver.GetExcelSheet<Status>().GetRow(this.statusId);
return status; return status;
} }
} }

View file

@ -22,7 +22,7 @@ namespace Dalamud.Game.Chat.SeStringHandling
/// <returns>An SeString containing all the payloads necessary to display an item link in the chat log.</returns> /// <returns>An SeString containing all the payloads necessary to display an item link in the chat log.</returns>
public static SeString CreateItemLink(uint itemId, bool isHQ, string displayNameOverride = null) public static SeString CreateItemLink(uint itemId, bool isHQ, string displayNameOverride = null)
{ {
string displayName = displayNameOverride ?? SeString.Dalamud.Data.GetExcelSheet<DalamudItem>().GetRow((int)itemId).Name; string displayName = displayNameOverride ?? SeString.Dalamud.Data.GetExcelSheet<DalamudItem>().GetRow(itemId).Name;
if (isHQ) if (isHQ)
{ {
displayName += $" {(char)SeIconChar.HighQuality}"; displayName += $" {(char)SeIconChar.HighQuality}";
@ -118,10 +118,10 @@ namespace Dalamud.Game.Chat.SeStringHandling
foreach (var place in matches) 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) if (map != null)
{ {
return CreateMapLink(map.TerritoryType, (uint)map.RowId, xCoord, yCoord); return CreateMapLink(map.TerritoryType.Row, (uint)map.RowId, xCoord, yCoord);
} }
} }

View file

@ -13,7 +13,7 @@ namespace Dalamud.Game.ClientState.Actors.Resolvers
/// <summary> /// <summary>
/// ID of the ClassJob. /// ID of the ClassJob.
/// </summary> /// </summary>
public readonly int Id; public readonly uint Id;
/// <summary> /// <summary>
/// GameData linked to this ClassJob. /// GameData linked to this ClassJob.

View file

@ -13,7 +13,7 @@ namespace Dalamud.Game.ClientState.Actors.Resolvers
/// <summary> /// <summary>
/// ID of the world. /// ID of the world.
/// </summary> /// </summary>
public readonly int Id; public readonly uint Id;
/// <summary> /// <summary>
/// GameData linked to this world. /// GameData linked to this world.

View file

@ -4,7 +4,7 @@ using Newtonsoft.Json;
namespace Dalamud.Game.Network.MarketBoardUploaders.Universalis { namespace Dalamud.Game.Network.MarketBoardUploaders.Universalis {
internal class UniversalisHistoryUploadRequest { internal class UniversalisHistoryUploadRequest {
[JsonProperty("worldID")] [JsonProperty("worldID")]
public int WorldId { get; set; } public uint WorldId { get; set; }
[JsonProperty("itemID")] [JsonProperty("itemID")]
public uint ItemId { get; set; } public uint ItemId { get; set; }

View file

@ -4,7 +4,7 @@ using Newtonsoft.Json;
namespace Dalamud.Game.Network.MarketBoardUploaders.Universalis { namespace Dalamud.Game.Network.MarketBoardUploaders.Universalis {
internal class UniversalisItemListingsUploadRequest { internal class UniversalisItemListingsUploadRequest {
[JsonProperty("worldID")] [JsonProperty("worldID")]
public int WorldId { get; set; } public uint WorldId { get; set; }
[JsonProperty("itemID")] [JsonProperty("itemID")]
public uint ItemId { get; set; } public uint ItemId { get; set; }

View file

@ -28,7 +28,7 @@ namespace Dalamud.Game.Network.Universalis.MarketBoardUploaders {
var uploader = this.dalamud.ClientState.LocalContentId; var uploader = this.dalamud.ClientState.LocalContentId;
var listingsRequestObject = new UniversalisItemListingsUploadRequest(); 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.UploaderId = uploader;
listingsRequestObject.ItemId = request.CatalogId; listingsRequestObject.ItemId = request.CatalogId;
@ -63,7 +63,7 @@ namespace Dalamud.Game.Network.Universalis.MarketBoardUploaders {
Log.Verbose(upload); Log.Verbose(upload);
var historyRequestObject = new UniversalisHistoryUploadRequest(); 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.UploaderId = uploader;
historyRequestObject.ItemId = request.CatalogId; historyRequestObject.ItemId = request.CatalogId;
@ -92,7 +92,7 @@ namespace Dalamud.Game.Network.Universalis.MarketBoardUploaders {
using (var client = new WebClient()) using (var client = new WebClient())
{ {
var taxRatesRequest = new UniversalisTaxUploadRequest(); 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.UploaderId = this.dalamud.ClientState.LocalContentId;
taxRatesRequest.TaxData = new UniversalisTaxData { taxRatesRequest.TaxData = new UniversalisTaxData {

View file

@ -13,7 +13,7 @@ namespace Dalamud.Game.Network.MarketBoardUploaders.Universalis
public ulong UploaderId { get; set; } public ulong UploaderId { get; set; }
[JsonProperty("worldID")] [JsonProperty("worldID")]
public int WorldId { get; set; } public uint WorldId { get; set; }
[JsonProperty("marketTaxRates")] [JsonProperty("marketTaxRates")]
public UniversalisTaxData TaxData { get; set; } public UniversalisTaxData TaxData { get; set; }