public Entry(ref FileBase file) { mTable = new Dictionary <string, uint>(); mEntries = new List <TableEntry>(); int size = file.ReadInt32(); file.Skip(0x8); int loc = file.Position(); uint count = file.ReadUInt32(); for (int i = 0; i < count; i++) { TableEntry e = new TableEntry(); e.mIsValid = file.ReadUInt32(); e.mPtr = file.ReadInt32(); mEntries.Add(e); if (e.mIsValid == 1) { string str = file.ReadStringAt(loc + e.mPtr); uint val = file.ReadUInt32At(loc + e.mPtr + str.Length + 1); mTable.Add(str, val); } } file.Seek(loc + size); while ((file.Position() % 0x10) != 0) { file.Skip(0x1); } }
public LBL1(ref FileBase file) { int start = file.ReadInt32(); file.Skip(0x8); int baseOffs = file.Position(); uint count = file.ReadUInt32(); mEntries = new List <LabelEntry>(); for (int i = 0; i < count; i++) { LabelEntry e = new LabelEntry(); e.PairCount = file.ReadUInt32(); int offs = file.ReadInt32(); List <LabelPair> pairs = new List <LabelPair>(); int pos = file.Position(); file.Seek(baseOffs + offs); for (int j = 0; j < e.PairCount; j++) { LabelPair p = new LabelPair(); p.Label = file.ReadStringLenPrefix(); p.TextOffset = file.ReadUInt32(); pairs.Add(p); } file.Seek(pos); e.Pairs = pairs; mEntries.Add(e); } file.Seek(start + baseOffs); while (file.Position() % 0x10 != 0) { file.Skip(0x1); } }
public BCSV(FileBase file) { mFile = file; mFields = new Dictionary <uint, Field>(); mEntries = new List <Entry>(); if (mFile.GetLength() == 0) { return; } int entryCount = mFile.ReadInt32(); int fieldCount = mFile.ReadInt32(); int dataOffs = mFile.ReadInt32(); int entryDataSize = mFile.ReadInt32(); int stringTableOffs = (dataOffs + (entryCount * entryDataSize)); for (int i = 0; i < fieldCount; i++) { Field f = new Field(); mFile.Seek(0x10 + (0xC * i)); f.mHash = mFile.ReadUInt32(); f.mMask = mFile.ReadUInt32(); f.mEntryOffset = mFile.ReadUInt16(); f.mShiftAmount = mFile.ReadByte(); f.mType = mFile.ReadByte(); string fieldName = HashToFieldName(f.mHash); f.mName = fieldName; mFields.Add(f.mHash, f); } for (int i = 0; i < entryCount; i++) { Entry e = new Entry(); foreach (Field f in mFields.Values) { mFile.Seek(dataOffs + (i * entryDataSize) + f.mEntryOffset); object val = null; switch (f.mType) { case 0: case 3: val = Convert.ToUInt32((mFile.ReadUInt32() & f.mMask) >> f.mShiftAmount); break; case 4: val = Convert.ToUInt16((mFile.ReadUInt16() & f.mMask) >> f.mShiftAmount); break; case 5: val = Convert.ToByte((mFile.ReadByte() & f.mMask) >> f.mShiftAmount); break; case 2: val = mFile.ReadSingle(); break; case 6: int offs = mFile.ReadInt32(); mFile.Seek(stringTableOffs + offs); val = mFile.ReadString(); break; default: throw new Exception($"BCSV::BCSV() - Unknown field type {f.mType}."); } e[f.mHash] = val; } mEntries.Add(e); } }