Beispiel #1
0
        public static PUP_Entry GetEmptyEntry(int id)
        {
            PUP_Entry newEntry = new PUP_Entry();

            newEntry.ID = id;
            return(newEntry);
        }
Beispiel #2
0
        public int CheckForSequence(IList <PUP_Entry> entries)
        {
            if (entries.Count > 0)
            {
                int id = GetEntryId(entries[0]);

                if (id != -1)
                {
                    for (int i = 1; i < entries.Count; i++)
                    {
                        PUP_Entry existingEntry = GetEntry(id + i);

                        if (existingEntry == null)
                        {
                            return(-1);
                        }
                        if (!existingEntry.CompareEntry(entries[i]))
                        {
                            return(-1);
                        }
                    }

                    return(id);
                }
            }

            return(-1);
        }
Beispiel #3
0
        public int GetEntryId(PUP_Entry entry)
        {
            foreach (var _entry in PupEntries)
            {
                if (_entry.CompareEntry(entry))
                {
                    return(_entry.ID);
                }
            }

            return(-1);
        }
Beispiel #4
0
        public void AddEntry(PUP_Entry entry, int id)
        {
            //Remove existing
            var existing = PupEntries.FirstOrDefault(x => x.ID == id);

            if (existing != null)
            {
                PupEntries.Remove(existing);
            }

            //Add
            entry.ID = id;
            PupEntries.Add(entry);
        }
Beispiel #5
0
        public static PUP_File Load(byte[] bytes)
        {
            PUP_File pupFile = new PUP_File();

            int count  = BitConverter.ToInt32(bytes, 8);
            int offset = 16;

            for (int i = 0; i < count; i++)
            {
                pupFile.PupEntries.Add(PUP_Entry.Read(bytes, offset));
                offset += 152;
            }

            return(pupFile);
        }
Beispiel #6
0
        public List <PUP_Entry> GetSequence(ushort id, ushort count)
        {
            List <PUP_Entry> entries = new List <PUP_Entry>();

            if (id == ushort.MaxValue || count == ushort.MaxValue)
            {
                return(entries);
            }

            for (int i = id; i < id + count; i++)
            {
                var entry = GetEntry(i);
                if (entry != null)
                {
                    entries.Add(entry);
                }
                else
                {
                    entries.Add(PUP_Entry.GetEmptyEntry(i));
                }
            }

            return(entries);
        }
Beispiel #7
0
 public bool CompareEntry(PUP_Entry entry)
 {
     return(this.Compare(entry, nameof(Index), nameof(SortID), nameof(ID)));
 }