This commit is contained in:
Ottermandias 2023-02-09 18:52:53 +01:00
parent 145b64bb7a
commit 4cf082aa19
37 changed files with 1362 additions and 1255 deletions

View file

@ -59,7 +59,7 @@ public partial class CustomizationOptions
public partial class CustomizationOptions
{
internal readonly bool Valid;
private readonly bool _valid;
public string GetName(CustomName name)
=> _names[(int)name];
@ -68,7 +68,7 @@ public partial class CustomizationOptions
{
var tmp = new TemporaryData(gameData, this);
_icons = new IconStorage(pi, gameData, _customizationSets.Length * 50);
Valid = tmp.Valid;
_valid = tmp.Valid;
SetNames(gameData, tmp);
foreach (var race in Clans)
{
@ -77,7 +77,6 @@ public partial class CustomizationOptions
}
}
// Obtain localized names of customization options and race names from the game data.
private readonly string[] _names = new string[Enum.GetValues<CustomName>().Length];
@ -430,10 +429,14 @@ public partial class CustomizationOptions
// Hair Row from CustomizeSheet might not be set in case of unlockable hair.
var hairRow = _customizeSheet.GetRow(customizeIdx);
hairList.Add(hairRow != null
? new CustomizeData(CustomizeIndex.Hairstyle, (CustomizeValue)hairRow.FeatureID, hairRow.Icon,
(ushort)hairRow.RowId)
: new CustomizeData(CustomizeIndex.Hairstyle, (CustomizeValue)i, customizeIdx));
if (hairRow == null)
{
hairList.Add(new CustomizeData(CustomizeIndex.Hairstyle, (CustomizeValue)i, customizeIdx));
}
else if (_options._icons.IconExists(hairRow.Icon))
{
hairList.Add(new CustomizeData(CustomizeIndex.Hairstyle, (CustomizeValue)hairRow.FeatureID, hairRow.Icon, (ushort)hairRow.RowId));
}
}
return hairList.ToArray();

View file

@ -10,6 +10,14 @@ public unsafe struct Customize
public Customize(Penumbra.GameData.Structs.CustomizeData* data)
=> Data = data;
public Customize(ref Penumbra.GameData.Structs.CustomizeData data)
{
fixed (Penumbra.GameData.Structs.CustomizeData* ptr = &data)
{
Data = ptr;
}
}
public Race Race
{
get => (Race)Data->Get(CustomizeIndex.Race).Value;
@ -96,4 +104,18 @@ public unsafe struct Customize
public string WriteBase64()
=> Data->WriteBase64();
public static CustomizeFlag Compare(Customize lhs, Customize rhs)
{
CustomizeFlag ret = 0;
foreach (var idx in Enum.GetValues<CustomizeIndex>())
{
var l = lhs[idx];
var r = rhs[idx];
if (l.Value != r.Value)
ret |= idx.ToFlag();
}
return ret;
}
}

View file

@ -47,7 +47,11 @@ public enum CustomizeFlag : ulong
public static class CustomizeFlagExtensions
{
public const CustomizeFlag All = (CustomizeFlag)(((ulong)CustomizeFlag.FacePaintColor << 1) - 1ul);
public const CustomizeFlag All = (CustomizeFlag)(((ulong)CustomizeFlag.FacePaintColor << 1) - 1ul);
public const CustomizeFlag RedrawRequired = CustomizeFlag.Race | CustomizeFlag.Clan | CustomizeFlag.Gender | CustomizeFlag.Face;
public static bool RequiresRedraw(this CustomizeFlag flags)
=> (flags & RedrawRequired) != 0;
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
public static CustomizeIndex ToIndex(this CustomizeFlag flag)

View file

@ -31,4 +31,5 @@ public static class Sigs
{
public const string ChangeJob = "88 51 ?? 44 3B CA";
public const string FlagSlotForUpdate = "48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 8B DA 49 8B F0 48 8B F9 83 FA 0A";
public const string ChangeCustomize = "E8 ?? ?? ?? ?? 41 0F B6 C5 66 41 89 86";
}

View file

@ -21,7 +21,7 @@ public readonly struct JobGroup
Id = group.RowId;
Name = group.Name.ToString();
Debug.Assert(jobs.RowCount < 64);
Debug.Assert(jobs.RowCount < 64, $"Number of Jobs exceeded 63 ({jobs.RowCount}).");
foreach (var job in jobs)
{
var abbr = job.Abbreviation.ToString();
@ -29,7 +29,7 @@ public readonly struct JobGroup
continue;
var prop = group.GetType().GetProperty(abbr);
Debug.Assert(prop != null);
Debug.Assert(prop != null, $"Could not get job abbreviation {abbr} property.");
if (!(bool)prop.GetValue(group)!)
continue;