/// <summary> /// Create a ReplicaItem hash from a BuddyItem instance /// </summary> /// <param name="pi"></param> /// <returns></returns> public static int GetHash(BuddyItem pi) { ReplicaItem replica = new ReplicaItem { BaseRecord = pi.BaseRecord, EnchantmentRecord = pi.EnchantmentRecord, EnchantmentSeed = (uint)pi.EnchantmentSeed, MateriaRecord = pi.MateriaRecord, ModifierRecord = pi.ModifierRecord, PrefixRecord = pi.PrefixRecord, RelicCompletionBonusRecord = string.Empty, RelicSeed = (uint)pi.RelicSeed, Seed = (uint)pi.Seed, SuffixRecord = pi.SuffixRecord, TransmuteRecord = pi.TransmuteRecord, }; return(ItemReplicaProcessor.GetHash(replica)); }
private static List <byte> Serialize(BuddyItem bi) { List <byte> buffer = new List <byte>(); if (bi.BaseRecord.Length > 255 || bi.SuffixRecord?.Length > 255 || bi.PrefixRecord?.Length > 255 || bi.MateriaRecord?.Length > 255 || bi.ModifierRecord?.Length > 255 || bi.EnchantmentRecord?.Length > 255 || bi.TransmuteRecord?.Length > 255) { Logger.Warn("Received a buddy item with one or more records having a length of >255. Stat reproduction not possible."); return(null); } int type = 2; // BuddyItem buffer.AddRange(BitConverter.GetBytes(type)); buffer.AddRange(BitConverter.GetBytes(bi.RemoteItemId.Length)); buffer.AddRange(Encoding.ASCII.GetBytes(bi.RemoteItemId)); buffer.AddRange(BitConverter.GetBytes((int)bi.Seed)); buffer.AddRange(BitConverter.GetBytes((int)bi.RelicSeed)); buffer.AddRange(BitConverter.GetBytes((int)bi.EnchantmentSeed)); buffer.AddRange(BitConverter.GetBytes(bi.BaseRecord.Length)); buffer.AddRange(Encoding.ASCII.GetBytes(bi.BaseRecord)); buffer.AddRange(BitConverter.GetBytes(bi.PrefixRecord?.Length ?? 0)); if (!string.IsNullOrEmpty(bi.PrefixRecord)) { buffer.AddRange(Encoding.ASCII.GetBytes(bi.PrefixRecord)); } buffer.AddRange(BitConverter.GetBytes(bi.SuffixRecord?.Length ?? 0)); if (!string.IsNullOrEmpty(bi.SuffixRecord)) { buffer.AddRange(Encoding.ASCII.GetBytes(bi.SuffixRecord)); } buffer.AddRange(BitConverter.GetBytes(bi.ModifierRecord?.Length ?? 0)); if (!string.IsNullOrEmpty(bi.ModifierRecord)) { buffer.AddRange(Encoding.ASCII.GetBytes(bi.ModifierRecord)); } buffer.AddRange(BitConverter.GetBytes(bi.MateriaRecord?.Length ?? 0)); if (!string.IsNullOrEmpty(bi.MateriaRecord)) { buffer.AddRange(Encoding.ASCII.GetBytes(bi.MateriaRecord)); } buffer.AddRange(BitConverter.GetBytes(bi.EnchantmentRecord?.Length ?? 0)); if (!string.IsNullOrEmpty(bi.EnchantmentRecord)) { buffer.AddRange(Encoding.ASCII.GetBytes(bi.EnchantmentRecord)); } buffer.AddRange(BitConverter.GetBytes(bi.TransmuteRecord?.Length ?? 0)); if (!string.IsNullOrEmpty(bi.TransmuteRecord)) { buffer.AddRange(Encoding.ASCII.GetBytes(bi.TransmuteRecord)); } return(buffer); }