Fix design migrations and cma import.

This commit is contained in:
Ottermandias 2024-07-17 02:01:14 +02:00
parent e7d5cf02e6
commit b3818a90df
3 changed files with 16 additions and 13 deletions

View file

@ -95,8 +95,8 @@ public class DesignBase64Migration
fixed (byte* ptr = bytes) fixed (byte* ptr = bytes)
{ {
var cur = (CharacterWeapon*)(ptr + 30); var cur = (LegacyCharacterWeapon*)(ptr + 30);
var eq = (CharacterArmor*)(cur + 2); var eq = (LegacyCharacterArmor*)(cur + 2);
if (!humans.IsHuman(data.ModelId)) if (!humans.IsHuman(data.ModelId))
{ {
@ -116,7 +116,7 @@ public class DesignBase64Migration
} }
data.SetItem(slot, item); data.SetItem(slot, item);
data.SetStain(slot, mdl.Stains); data.SetStain(slot, mdl.Stain);
} }
var main = cur[0].Skeleton.Id == 0 var main = cur[0].Skeleton.Id == 0
@ -129,7 +129,7 @@ public class DesignBase64Migration
} }
data.SetItem(EquipSlot.MainHand, main); data.SetItem(EquipSlot.MainHand, main);
data.SetStain(EquipSlot.MainHand, cur[0].Stains); data.SetStain(EquipSlot.MainHand, cur[0].Stain);
EquipItem off; EquipItem off;
// Fist weapon hack // Fist weapon hack
@ -140,7 +140,7 @@ public class DesignBase64Migration
if (gauntlet.Valid) if (gauntlet.Valid)
{ {
data.SetItem(EquipSlot.Hands, gauntlet); data.SetItem(EquipSlot.Hands, gauntlet);
data.SetStain(EquipSlot.Hands, cur[0].Stains); data.SetStain(EquipSlot.Hands, cur[0].Stain);
} }
} }
else else
@ -157,12 +157,13 @@ public class DesignBase64Migration
} }
data.SetItem(EquipSlot.OffHand, off); data.SetItem(EquipSlot.OffHand, off);
data.SetStain(EquipSlot.OffHand, cur[1].Stains); data.SetStain(EquipSlot.OffHand, cur[1].Stain);
return data; 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]; var data = stackalloc byte[Base64SizeV4];
data[0] = 5; data[0] = 5;
@ -185,10 +186,12 @@ public class DesignBase64Migration
| (equipFlags.HasFlag(EquipFlag.RFinger) ? 0x04 : 0) | (equipFlags.HasFlag(EquipFlag.RFinger) ? 0x04 : 0)
| (equipFlags.HasFlag(EquipFlag.LFinger) ? 0x08 : 0)); | (equipFlags.HasFlag(EquipFlag.LFinger) ? 0x08 : 0));
save.Customize.Write(data + 4); save.Customize.Write(data + 4);
((CharacterWeapon*)(data + 30))[0] = save.Item(EquipSlot.MainHand).Weapon(save.Stain(EquipSlot.MainHand)); ((LegacyCharacterWeapon*)(data + 30))[0] =
((CharacterWeapon*)(data + 30))[1] = save.Item(EquipSlot.OffHand).Weapon(save.Stain(EquipSlot.OffHand)); 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) 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. *(ushort*)(data + 84) = 1; // IsSet.
*(float*)(data + 86) = 1f; *(float*)(data + 86) = 1f;
data[90] = (byte)((save.IsHatVisible() ? 0x00 : 0x01) data[90] = (byte)((save.IsHatVisible() ? 0x00 : 0x01)

View file

@ -58,10 +58,10 @@ public sealed class CmaFile
if (idx * 4 + 3 >= byteData.Length) if (idx * 4 + 3 >= byteData.Length)
continue; continue;
var armor = ((CharacterArmor*)ptr)[idx]; var armor = ((LegacyCharacterArmor*)ptr)[idx];
var item = items.Identify(slot, armor.Set, armor.Variant); var item = items.Identify(slot, armor.Set, armor.Variant);
data.SetItem(slot, item); data.SetItem(slot, item);
data.SetStain(slot, armor.Stains); data.SetStain(slot, armor.Stain);
} }
data.Customize.Read(ptr); data.Customize.Read(ptr);

@ -1 +1 @@
Subproject commit 45f2c901b3a0131eaee18b3520184baeb0d1049d Subproject commit c25ea7b19a6db37dd36e12b9a7a71f72a192ab57