Skip to content

Commit

Permalink
Fix design migrations and cma import.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottermandias committed Jul 17, 2024
1 parent e7d5cf0 commit b3818a9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
23 changes: 13 additions & 10 deletions Glamourer/Designs/DesignBase64Migration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ static void CheckSize(int length, int requiredLength)

fixed (byte* ptr = bytes)
{
var cur = (CharacterWeapon*)(ptr + 30);
var eq = (CharacterArmor*)(cur + 2);
var cur = (LegacyCharacterWeapon*)(ptr + 30);
var eq = (LegacyCharacterArmor*)(cur + 2);

if (!humans.IsHuman(data.ModelId))
{
Expand All @@ -116,7 +116,7 @@ static void CheckSize(int length, int requiredLength)
}

data.SetItem(slot, item);
data.SetStain(slot, mdl.Stains);
data.SetStain(slot, mdl.Stain);
}

var main = cur[0].Skeleton.Id == 0
Expand All @@ -129,7 +129,7 @@ static void CheckSize(int length, int requiredLength)
}

data.SetItem(EquipSlot.MainHand, main);
data.SetStain(EquipSlot.MainHand, cur[0].Stains);
data.SetStain(EquipSlot.MainHand, cur[0].Stain);

EquipItem off;
// Fist weapon hack
Expand All @@ -140,7 +140,7 @@ static void CheckSize(int length, int requiredLength)
if (gauntlet.Valid)
{
data.SetItem(EquipSlot.Hands, gauntlet);
data.SetStain(EquipSlot.Hands, cur[0].Stains);
data.SetStain(EquipSlot.Hands, cur[0].Stain);
}
}
else
Expand All @@ -157,12 +157,13 @@ static void CheckSize(int length, int requiredLength)
}

data.SetItem(EquipSlot.OffHand, off);
data.SetStain(EquipSlot.OffHand, cur[1].Stains);
data.SetStain(EquipSlot.OffHand, cur[1].Stain);
return data;
}
}

public static unsafe string CreateOldBase64(in DesignData save, EquipFlag equipFlags, CustomizeFlag customizeFlags, MetaFlag meta, bool writeProtected, float alpha = 1.0f)
public static unsafe string CreateOldBase64(in DesignData save, EquipFlag equipFlags, CustomizeFlag customizeFlags, MetaFlag meta,
bool writeProtected, float alpha = 1.0f)
{
var data = stackalloc byte[Base64SizeV4];
data[0] = 5;
Expand All @@ -185,10 +186,12 @@ public static unsafe string CreateOldBase64(in DesignData save, EquipFlag equipF
| (equipFlags.HasFlag(EquipFlag.RFinger) ? 0x04 : 0)
| (equipFlags.HasFlag(EquipFlag.LFinger) ? 0x08 : 0));
save.Customize.Write(data + 4);
((CharacterWeapon*)(data + 30))[0] = save.Item(EquipSlot.MainHand).Weapon(save.Stain(EquipSlot.MainHand));
((CharacterWeapon*)(data + 30))[1] = save.Item(EquipSlot.OffHand).Weapon(save.Stain(EquipSlot.OffHand));
((LegacyCharacterWeapon*)(data + 30))[0] =
new LegacyCharacterWeapon(save.Item(EquipSlot.MainHand).Weapon(save.Stain(EquipSlot.MainHand)));
((LegacyCharacterWeapon*)(data + 30))[1] =
new LegacyCharacterWeapon(save.Item(EquipSlot.OffHand).Weapon(save.Stain(EquipSlot.OffHand)));
foreach (var slot in EquipSlotExtensions.EqdpSlots)
((CharacterArmor*)(data + 44))[slot.ToIndex()] = save.Item(slot).Armor(save.Stain(slot));
((LegacyCharacterArmor*)(data + 44))[slot.ToIndex()] = new LegacyCharacterArmor(save.Item(slot).Armor(save.Stain(slot)));
*(ushort*)(data + 84) = 1; // IsSet.
*(float*)(data + 86) = 1f;
data[90] = (byte)((save.IsHatVisible() ? 0x00 : 0x01)
Expand Down
4 changes: 2 additions & 2 deletions Glamourer/Interop/CharaFile/CmaFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ private static unsafe void ParseEquipment(ItemManager items, JObject jObj, ref D
if (idx * 4 + 3 >= byteData.Length)
continue;

var armor = ((CharacterArmor*)ptr)[idx];
var armor = ((LegacyCharacterArmor*)ptr)[idx];
var item = items.Identify(slot, armor.Set, armor.Variant);
data.SetItem(slot, item);
data.SetStain(slot, armor.Stains);
data.SetStain(slot, armor.Stain);
}

data.Customize.Read(ptr);
Expand Down
2 changes: 1 addition & 1 deletion Penumbra.GameData

0 comments on commit b3818a9

Please sign in to comment.