Exemplo n.º 1
0
        private FileValidity LoadFileSections()
        {
            m_sections.Clear();

            if (m_fileData.Length < MinimumFileSize)
            {
                return(FileValidity.NotDiablo2File);
            }

            int offset = 0;

            m_headerSection = new HeaderSection(m_fileData);
            m_sections.Add(m_headerSection);
            offset += m_headerSection.Size;

            var validity = ValidateData();

            if (validity == FileValidity.Valid)
            {
                m_questSection = new QuestSection(m_fileData, offset);
                m_sections.Add(m_questSection);
                offset += m_questSection.Size;

                m_waypointSection = new WaypointSection(m_fileData, offset);
                m_sections.Add(m_waypointSection);
                offset += m_waypointSection.Size;

                m_npcSection = new NpcSection(m_fileData, offset);
                m_sections.Add(m_npcSection);
                offset += m_npcSection.Size;

                m_statsSection = new StatsSection(m_fileData, offset);
                m_sections.Add(m_statsSection);
                offset += m_statsSection.Size;

                m_skillSection = new SkillSection(m_fileData, offset, m_headerSection.SkillSectionLength);
                m_sections.Add(m_skillSection);
                offset += m_skillSection.Size;

                m_itemSection = new ItemListSection(m_fileData, offset);
                m_sections.Add(m_itemSection);
                offset += m_itemSection.Size;

                m_corpseSection = new ItemListSection(m_fileData, offset);
                m_sections.Add(m_corpseSection);
                offset += m_corpseSection.Size;

                m_mercenarySection = new MercenaryItemSection(m_fileData, offset);
                m_sections.Add(m_mercenarySection);
                offset += m_mercenarySection.Size;

                //if (offset != m_fileData.Length)
                //    validity = FileValidity.UnknownError;
            }

            return(validity);
        }
Exemplo n.º 2
0
        private ReadOnlySpan <byte> ReadCorpseItemListSection(ReadOnlySpan <byte> fileData)
        {
            m_corpseSection = new ItemListSection(fileData);
            m_corpseSection.Validate();

            m_sections.Add(m_corpseSection);

            return(fileData.Slice(m_corpseSection.Size));
        }