/// <summary> /// If the entry isn't null, /// adds the size of the entry to the current part length /// and adds the entry's lookup count to the main lookup count. /// </summary> protected void GetSize(SakuraiEntryNode entry) { if (entry != null) { _lengths[_lengths.Count - 1] += entry.GetSize(); _lookup += entry.GetLookupCount(); } }
/// <summary> /// If the entry isn't null, /// adds the size of the entry to the current part length /// and adds the entry's lookup count to the main lookup count. /// the incrementLookup argument will add a lookup offset for the offset to the entry /// </summary> protected void GetSize(SakuraiEntryNode entry, bool incrementLookup = false) { if (entry != null) { _currentSize += entry.GetSize(); _currentLookupCount += entry.GetLookupCount(); //Increment lookup for the offset in a header to this data if (incrementLookup && entry._calcSize > 0) { IncLookup(); } } }
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); }