Skip to content

Commit

Permalink
Improve BiotaSQLWriter for ACLogView (#4071)
Browse files Browse the repository at this point in the history
This also fixes the missing order column for BiotaPropertiesPalette
  • Loading branch information
Mag-nus authored Dec 17, 2023
1 parent 964683d commit 5eea515
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
22 changes: 15 additions & 7 deletions Source/ACE.Database/SQLFormatters/Shard/BiotaSQLWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@ public class BiotaSQLWriter : SQLWriter
/// </summary>
public string GetDefaultFileName(Biota input)
{
var result = input.Id.ToString("X8");

var name = input.GetProperty(PropertyString.Name);

return GetDefaultFileName(input.Id, name);
}

/// <summary>
/// Default is formed from: id.ToString("X8") + " " + name
/// </summary>
public static string GetDefaultFileName(uint id, string name)
{
var result = id.ToString("X8");

if (!String.IsNullOrWhiteSpace(name))
result += " " + name;

Expand Down Expand Up @@ -153,17 +161,17 @@ public void CreateSQLINSERTStatement(Biota input, StreamWriter writer)
if (input.BiotaPropertiesPalette != null && input.BiotaPropertiesPalette.Count > 0)
{
writer.WriteLine();
CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesPalette.OrderBy(r => r.SubPaletteId).ToList(), writer);
CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesPalette.OrderBy(r => r.Order).ThenBy(r => r.SubPaletteId).ToList(), writer);
}
if (input.BiotaPropertiesTextureMap != null && input.BiotaPropertiesTextureMap.Count > 0)
{
writer.WriteLine();
CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesTextureMap.OrderBy(r => r.Index).ToList(), writer);
CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesTextureMap.OrderBy(r => r.Order).ThenBy(r => r.Index).ToList(), writer);
}
if (input.BiotaPropertiesAnimPart != null && input.BiotaPropertiesAnimPart.Count > 0)
{
writer.WriteLine();
CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesAnimPart.OrderBy(r => r.Index).ToList(), writer);
CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesAnimPart.OrderBy(r => r.Order).ThenBy(r => r.Index).ToList(), writer);
}

if (input.BiotaPropertiesEnchantmentRegistry != null && input.BiotaPropertiesEnchantmentRegistry.Count > 0)
Expand Down Expand Up @@ -644,9 +652,9 @@ public void CreateSQLINSERTStatement(uint id, IList<BiotaPropertiesGenerator> in

public void CreateSQLINSERTStatement(uint id, IList<BiotaPropertiesPalette> input, StreamWriter writer)
{
writer.WriteLine("INSERT INTO `biota_properties_palette` (`object_Id`, `sub_Palette_Id`, `offset`, `length`)");
writer.WriteLine("INSERT INTO `biota_properties_palette` (`object_Id`, `sub_Palette_Id`, `offset`, `length`, `order`)");

var lineGenerator = new Func<int, string>(i => $"{id}, {input[i].SubPaletteId}, {input[i].Offset}, {input[i].Length})");
var lineGenerator = new Func<int, string>(i => $"{id}, {input[i].SubPaletteId}, {input[i].Offset}, {input[i].Length}, {input[i].Order})");

ValuesWriter(input.Count, lineGenerator, writer);
}
Expand Down
4 changes: 2 additions & 2 deletions Source/ACE.Database/ShardDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public int GetBiotaCount()
}

[Flags]
enum PopulatedCollectionFlags
public enum PopulatedCollectionFlags
{
BiotaPropertiesAnimPart = 0x1,
BiotaPropertiesAttribute = 0x2,
Expand Down Expand Up @@ -159,7 +159,7 @@ enum PopulatedCollectionFlags
BiotaPropertiesAllegiance = 0x1000000,
}

protected static void SetBiotaPopulatedCollections(Biota biota)
public static void SetBiotaPopulatedCollections(Biota biota)
{
PopulatedCollectionFlags populatedCollectionFlags = 0;

Expand Down

0 comments on commit 5eea515

Please sign in to comment.