private static void LoadStaticIndex(string fileName, ref StaticIndexRecord[] staticsIndex) { if (File.Exists(fileName)) { byte[] fileBytes = File.ReadAllBytes(fileName); staticsIndex = new StaticIndexRecord[fileBytes.Length / 12]; for (int x = 0; x < staticsIndex.Length; x++) { staticsIndex[x].start = BitConverter.ToInt32(fileBytes, x * 12); staticsIndex[x].length = BitConverter.ToInt32(fileBytes, x * 12 + 4); } } }
private static StaticIndexRecord GetStaticIndexRecord(int blockIndex, FileStream fileStream) { StaticIndexRecord indexRecord = new StaticIndexRecord(); byte[] startBytes = new byte[4], lengthBytes = new byte[4]; lock (fileStream) { fileStream.Seek(blockIndex * 12, SeekOrigin.Begin); fileStream.Read(startBytes, 0, 4); fileStream.Read(lengthBytes, 0, 4); } indexRecord.start = BitConverter.ToInt32(startBytes, 0); indexRecord.length = BitConverter.ToInt32(lengthBytes, 0); return(indexRecord); }
private static StaticRecord[] GetStaticRecords(StaticIndexRecord indexRecord, FileStream fileStream) { if (indexRecord.length == -1) { return(null); } StaticRecord[] staticRecords = new StaticRecord[indexRecord.length / 7]; byte[] fileBytes = new byte[indexRecord.length]; lock (fileStream) { fileStream.Seek(indexRecord.start, SeekOrigin.Begin); fileStream.Read(fileBytes, 0, indexRecord.length); } for (int x = 0; x < staticRecords.Length; x++) { staticRecords[x].id = BitConverter.ToUInt16(fileBytes, x * 7); staticRecords[x].x = fileBytes[x * 7 + 2]; staticRecords[x].y = fileBytes[x * 7 + 3]; staticRecords[x].z = (sbyte)fileBytes[x * 7 + 4]; } return(staticRecords); }
private static void LoadStatics(string fileName, ref StaticIndexRecord[] staticIndexRecord, ref StaticRecord[][] staticItems) { if (File.Exists(fileName)) { byte[] fileBytes = File.ReadAllBytes(fileName); for (int x = 0; x < staticIndexRecord.Length; x++) { if (staticIndexRecord[x].start == -1) continue; int recordsToFetch = staticIndexRecord[x].length / 7; staticItems[x] = new StaticRecord[recordsToFetch]; for (int y = 0; y < recordsToFetch; y++) { staticItems[x][y].id = BitConverter.ToUInt16(fileBytes, staticIndexRecord[x].start + y * 7); staticItems[x][y].x = fileBytes[staticIndexRecord[x].start + y * 7 + 2]; staticItems[x][y].y = fileBytes[staticIndexRecord[x].start + y * 7 + 3]; staticItems[x][y].z = (sbyte)fileBytes[staticIndexRecord[x].start + y * 7 + 4]; } } } }
private static StaticRecord[] GetStaticRecords(StaticIndexRecord indexRecord, FileStream fileStream) { if (indexRecord.length == -1) return null; StaticRecord[] staticRecords = new StaticRecord[indexRecord.length / 7]; byte[] fileBytes = new byte[indexRecord.length]; lock (fileStreamLock) { fileStream.Seek(indexRecord.start, SeekOrigin.Begin); fileStream.Read(fileBytes, 0, indexRecord.length); } for (int x = 0; x < staticRecords.Length; x++) { staticRecords[x].id = BitConverter.ToUInt16(fileBytes, x * 7); staticRecords[x].x = fileBytes[x * 7 + 2]; staticRecords[x].y = fileBytes[x * 7 + 3]; staticRecords[x].z = (sbyte)fileBytes[x * 7 + 4]; } return staticRecords; }
private static StaticIndexRecord GetStaticIndexRecord(int blockIndex, FileStream fileStream) { StaticIndexRecord indexRecord = new StaticIndexRecord(); byte[] startBytes = new byte[4], lengthBytes = new byte[4]; lock (fileStreamLock) { fileStream.Seek(blockIndex * 12, SeekOrigin.Begin); fileStream.Read(startBytes, 0, 4); fileStream.Read(lengthBytes, 0, 4); } indexRecord.start = BitConverter.ToInt32(startBytes, 0); indexRecord.length = BitConverter.ToInt32(lengthBytes, 0); return indexRecord; }