Beispiel #1
0
        public void ReadEntries(DSBinaryReader bin, ObservableCollection <FMGEntryRef> entries)
        {
            count = (LastStringID - FirstStringID) + 1;

            if (count > buffer.Length)
            {
                Array.Resize(ref buffer, count * 2 /*Extra "wiggle room"*/);
            }

            bin.StepIn(StringOffsetsBeginOffset + (FirstStringIndex * 4));
            {
                for (int i = 0; i < count; i++)
                {
                    buffer[i] = bin.ReadInt32();
                }

                for (int i = 0; i < count; i++)
                {
                    string stringContents = null;

                    if (buffer[i] == 0)
                    {
                        stringContents = DataFiles.FMG.NullString;
                    }
                    else
                    {
                        bin.Position   = buffer[i];
                        stringContents = bin.ReadStringUnicode(length: null);

                        if (string.IsNullOrWhiteSpace(stringContents.Trim()))
                        {
                            stringContents = DataFiles.FMG.EmptyString;
                        }
                    }

                    if (stringContents == null)
                    {
                        throw new Exception(":trashcat:");
                    }

                    entries.Add(new FMGEntryRef(FirstStringID + i, stringContents));
                }
            }
            bin.StepOut();
        }