Beispiel #1
0
        public int GetSize()
        {
            _calculatingSize = true;

            //Reset variables
            _lookupCount          = _lookupLen = 0;
            _lookupManager        = new LookupManager();
            _postProcessNodes     = new List <SakuraiEntryNode>();
            _referenceStringTable = new CompactStringTable();

            //Add header size
            _size = SakuraiArchiveHeader.Size;

            //Calculate the size of each section and add names to string table
            foreach (TableEntryNode section in _rootNode.SectionList)
            {
                SakuraiEntryNode entry = section;

                //Sections *usually* have only one reference in data or dataCommon
                //An example of an exception to this is the 'AnimCmd' section
                //If a reference exists, calculate the size of that reference instead
                if (section.References.Count > 0)
                {
                    entry = section.References[0];
                }

                //Add the size of the entry's data, and the entry itself
                _size += entry.GetSize() + 8;

                //Add the lookup count
                _lookupCount += entry.GetLookupCount();

                //Add the section's name to the string table
                _referenceStringTable.Add(entry.Name);
            }

            //Calculate reference table size and add names to string table
            foreach (TableEntryNode reference in _rootNode.ReferenceList)
            {
                if (reference.References.Count > 0 || AddUnreferencedReferences)
                {
                    //Add entry name to string table
                    _referenceStringTable.Add(reference.Name);

                    //Add entry size (reference don't have any actual 'data' size)
                    _size += 8;
                }

                //TODO: Does each reference offset throughout the file
                //have a lookup offset?
                //Also, subtract 1 because the initial offset has no lookup entry
                //lookupCount += e.References.Count - 1;
            }

            _calculatingSize = false;

            //Add the lookup size and reference table size
            _size += (_lookupLen = _lookupCount * 4) + _referenceStringTable.TotalSize;

            return(_size);
        }
Beispiel #2
0
 protected virtual void PostProcess(LookupManager lookupOffsets)
 {
 }