public static string[] ReadZeroTerminatedStringArrays(LimitedReader partialReader, bool withOffsets, out Dictionary <int, string>?offsets) { List <string> textures = new(); offsets = withOffsets ? new() : null; var startOffset = partialReader.Offset; while (!partialReader.IsFinished()) { int start = partialReader.Offset; while (partialReader.ReadByte() != 0) { ; } int end = partialReader.Offset - 1; if (end == start && partialReader.IsFinished()) { break; } partialReader.Offset = start; var textureNameBytes = partialReader.ReadBytes(end - start); var textureName = System.Text.Encoding.ASCII.GetString(textureNameBytes); textures.Add(textureName); if (withOffsets) { offsets ![start - startOffset] = textureName;
private WorldMapObjectPlacementData[] ReadWorldMapObjectPlacementData(LimitedReader reader, string[]?names) { Debug.Assert(names != null); int i = 0; WorldMapObjectPlacementData[] data = new WorldMapObjectPlacementData[reader.Size / 0x40]; while (!reader.IsFinished()) { data[i++] = new WorldMapObjectPlacementData(reader, names); } return(data); }
private M2PlacementData[] ReadM2PlacementData(LimitedReader reader, string[]?names) { Debug.Assert(names != null); int i = 0; M2PlacementData[] data = new M2PlacementData[reader.Size / 0x24]; while (!reader.IsFinished()) { data[i++] = new M2PlacementData(reader, names); } return(data); }
private string[] ReadNameOffsets(LimitedReader reader, Dictionary <int, string>?wmosNameOffsets) { Debug.Assert(wmosNameOffsets != null); int i = 0; string[] names = new string[reader.Size / 4]; while (!reader.IsFinished()) { names[i++] = wmosNameOffsets[reader.ReadInt32()]; } return(names); }