Beispiel #1
0
        private static async Task SaveEstFile(EstType type, Dictionary <XivRace, Dictionary <ushort, ExtraSkeletonEntry> > entries, IItem referenceItem = null, IndexFile cachedIndexFile = null, ModList cachedModList = null)
        {
            var count = entries.Select(x => x.Value.Count).Aggregate((x, y) => x + y);

            var data = new byte[4 + (count * 6)];

            IOUtil.ReplaceBytesAt(data, BitConverter.GetBytes(count), 0);

            var races = entries.Keys.ToList();

            races.Sort();


            var index = 0;

            foreach (var race in races)
            {
                var sets = entries[race].Keys.ToList();
                sets.Sort();
                foreach (var set in sets)
                {
                    var entry = entries[race][set];
                    ExtraSkeletonEntry.Write(data, entry, count, index);
                    index++;
                }
            }


            var _dat = new Dat(_gameDirectory);
            await _dat.ImportType2Data(data, EstFiles[type], Constants.InternalModSourceName, referenceItem, cachedIndexFile, cachedModList);
        }
Beispiel #2
0
        private static async Task <Dictionary <XivRace, Dictionary <ushort, ExtraSkeletonEntry> > > GetEstFile(EstType type, bool forceDefault = false)
        {
            var _dat = new Dat(_gameDirectory);
            var data = await _dat.GetType2Data(EstFiles[type], forceDefault);

            var count = BitConverter.ToUInt32(data, 0);

            Dictionary <XivRace, Dictionary <ushort, ExtraSkeletonEntry> > entries = new Dictionary <XivRace, Dictionary <ushort, ExtraSkeletonEntry> >();

            for (int i = 0; i < count; i++)
            {
                var entry = ExtraSkeletonEntry.Read(data, count, (uint)i);
                if (!entries.ContainsKey(entry.Race))
                {
                    entries.Add(entry.Race, new Dictionary <ushort, ExtraSkeletonEntry>());
                }

                if (!entries[entry.Race].ContainsKey(entry.SetId))
                {
                    // For whatever reason there is exactly one dupe in the game files, where a Lalafell M face has two identical entries.
                    // Doesn't seem to matter to SE, so shouldn't matter to us.
                    entries[entry.Race].Add(entry.SetId, entry);
                }
            }

            return(entries);
        }
Beispiel #3
0
            public static void Write(byte[] data, ExtraSkeletonEntry entry, int count, int index)
            {
                int   offset = (int)(4 + (index * 4));
                short raceId = short.Parse(GetRaceCode(entry.Race));

                ReplaceBytesAt(data, BitConverter.GetBytes(entry.SetId), offset);
                ReplaceBytesAt(data, BitConverter.GetBytes(raceId), offset + 2);

                int baseOffset = 4 + (count * 4);

                offset = (int)(baseOffset + (index * 2));
                ReplaceBytesAt(data, BitConverter.GetBytes(entry.SkelId), offset);
            }
Beispiel #4
0
            public static ExtraSkeletonEntry Read(byte[] data, uint count, uint index)
            {
                int offset = (int)(4 + (index * 4));

                ushort  setId  = BitConverter.ToUInt16(data, offset);
                ushort  raceId = BitConverter.ToUInt16(data, offset + 2);
                XivRace race   = GetXivRace(raceId.ToString().PadLeft(4, '0'));

                uint baseOffset = 4 + (count * 4);

                offset = (int)(baseOffset + (index * 2));

                ushort skelId = BitConverter.ToUInt16(data, offset);

                ExtraSkeletonEntry ret = new ExtraSkeletonEntry(race, setId, skelId);

                return(ret);
            }