public MtpIndexEntry(int position, MtpParser parser, MtpIndexEntry prev) { _position = position; _parser = parser; _previous = prev; _id = new MxeWord(position, "hId"); _actor = new MxeWord(position + 0x4, "hActor"); _start = new MxeWord(position + 0x8, "hStart"); _unknown = new MxeWord(position + 0xC, "hUnknown"); }
public MtpIndexExtendedEntry(int position, MtpParser parser, MtpIndexEntry prev) { _position = position; _parser = parser; _previous = prev; _id = new MxeWord(position, "hId"); _start = new MxeWord(position + 0x4, "hStart"); _actor = new MxeWord(position + 0x10, "hActor"); _unknown = new MxeWord(position + 0x14, "hUnknown"); }
private bool HandleSentenceLengthChanges(List<string> data, MtpIndexEntry index) { string d0 = data[0]; int previousSentenceLength = index.Sentence.Size.GetValueAsRawInt(); bool thisOneChanged = index.ReadCsvLineData(data); if (thisOneChanged) { int diff = index.Sentence.Size.GetValueAsRawInt() - previousSentenceLength; if (diff != 0) { if (diff % 4 != 0) { diff += 4 - diff % 4; // addresses are word aligned, so difference changes need to be word aligned as well. } Console.Out.WriteLine(String.Format(@"Adjusting positions of other objects due to length change of [{0}]", d0)); _eofcOne.SetValue(_eofcOne.Header, String.Empty + (_eofcOne.GetValueAsRawInt() + diff), true); _eofcTwo.SetValue(_eofcTwo.Header, String.Empty + (_eofcTwo.GetValueAsRawInt() + diff), true); _restOfIt.Position += diff; int changePosition = index.Sentence.Size.Position; foreach (MtpIndexEntry mie in _indexes.Values) { if (mie.Sentence.Size.Position > changePosition) { mie.Sentence.Size.Position += diff; mie.Sentence.Sentence.Position += diff; int thisStart = mie.Start.GetValueAsRawInt(); mie.Start.SetValue("ziStart", String.Empty + (thisStart + diff), true); } } Console.Out.WriteLine(String.Format(@"Done with positions of other objects due to length change of [{0}]", d0)); } } return thisOneChanged; }
protected override void ReadTableMeta(FileStream stream) { _sentenceCount = new MxeWord(_sentenceCountPos, "i"); _aCount = new MxeWord(_aCountPos, "i"); _bCount = new MxeWord(_bCountPos, "i"); _eofcOne = new MxeWord(_eofcOnePos, "i"); _eofcTwo = new MxeWord(_eofcTwoPos, "i"); _sentenceCount.ReadFromFile(stream); _aCount.ReadFromFile(stream); _bCount.ReadFromFile(stream); _eofcOne.ReadFromFile(stream); _eofcTwo.ReadFromFile(stream); int sc = (int)_sentenceCount.GetValueAsRawInt(); int ac = (int)_aCount.GetValueAsRawInt(); // this is also the size of the index entries int bc = (int)_bCount.GetValueAsRawInt(); int pos = _aBlockPos + _aCount.Length * ac + _bCount.Length * bc; Console.Out.WriteLine("Sentence count: " + sc); _indexesStart = pos; List<MtpIndexEntry> entries = new List<MtpIndexEntry>(); MtpIndexEntry prevE = null; for (int i = 0; i < sc; i++) { MtpIndexEntry e = new MtpIndexEntry(pos, this, prevE); if (ac == 0x14) { e = new MtpIndexExtendedEntry(pos, this, prevE); } entries.Add(e); prevE = e; pos += _sentenceCount.Length * ac; } _sentencesStart = pos; //can't read or setup all this stuff until after _sentencesStart is set. foreach (MtpIndexEntry e in entries) { e.ReadEntry(stream); _indexes.Add(e.Id.GetValueAsRawInt(), e); } int endingLoc = prevE.Sentence.Sentence.Position + prevE.Sentence.Sentence.Length; _restOfIt = new ByteString(endingLoc, (int)stream.Length - endingLoc); _restOfIt.ReadFromFile(stream); }