public static void LoadM2Cameras(string dataPath) { FlyByCameraStorage.Clear(); Log.outInfo(LogFilter.ServerLoading, "Loading Cinematic Camera files"); uint oldMSTime = Time.GetMSTime(); foreach (CinematicCameraRecord cameraEntry in CliDB.CinematicCameraStorage.Values) { string filename = dataPath + "/cameras/" + $"FILE{cameraEntry.FileDataID:x8}.xxx"; try { using (BinaryReader m2file = new BinaryReader(new FileStream(filename, FileMode.Open, FileAccess.Read))) { // Check file has correct magic (MD21) if (m2file.ReadUInt32() != 0x3132444D) //"MD21" { Log.outError(LogFilter.ServerLoading, "Camera file {0} is damaged. File identifier not found.", filename); continue; } m2file.ReadUInt32(); //unknown size // Read header M2Header header = m2file.Read <M2Header>(); // Get camera(s) - Main header, then dump them. m2file.BaseStream.Position = 8 + header.ofsCameras; M2Camera cam = m2file.Read <M2Camera>(); m2file.BaseStream.Position = 8; readCamera(cam, new BinaryReader(new MemoryStream(m2file.ReadBytes((int)m2file.BaseStream.Length - 8))), cameraEntry); } } catch (EndOfStreamException) { Log.outError(LogFilter.ServerLoading, "Camera file {0} is damaged. Camera references position beyond file end", filename); } catch (FileNotFoundException) { Log.outError(LogFilter.ServerLoading, "File {0} not found!!!!", filename); } } Log.outInfo(LogFilter.ServerLoading, "Loaded {0} cinematic waypoint sets in {1} ms", FlyByCameraStorage.Keys.Count, Time.GetMSTimeDiffToNow(oldMSTime)); }
public static void LoadM2Cameras(string dataPath) { FlyByCameraStorage.Clear(); Log.outInfo(LogFilter.ServerLoading, "Loading Cinematic Camera files"); uint oldMSTime = Time.GetMSTime(); foreach (CinematicCameraRecord cameraEntry in CliDB.CinematicCameraStorage.Values) { string filename = dataPath + "/cameras/" + string.Format("FILE{0:x8}.xxx", cameraEntry.ModelFileDataID); try { using (BinaryReader m2file = new BinaryReader(new FileStream(filename, FileMode.Open, FileAccess.Read))) { // Check file has correct magic (MD21) if (m2file.ReadStringFromChars(4) != "MD21") { Log.outError(LogFilter.ServerLoading, "Camera file {0} is damaged. File identifier not found.", filename); continue; } var unknownSize = m2file.ReadUInt32(); //unknown size // Read header M2Header header = m2file.ReadStruct <M2Header>(); var buffer = new BinaryReader(new MemoryStream(m2file.ToByteArray(), 8, (int)(m2file.BaseStream.Length - 8))); // Get camera(s) - Main header, then dump them. M2Camera cam = m2file.ReadStruct <M2Camera>(8 + header.ofsCameras); readCamera(cam, (uint)m2file.BaseStream.Length - 8, buffer, cameraEntry); } } catch (EndOfStreamException) { Log.outError(LogFilter.ServerLoading, "Camera file {0} is damaged. Camera references position beyond file end", filename); } catch (FileNotFoundException) { Log.outError(LogFilter.ServerLoading, "File {0} not found!!!!", filename); } } Log.outInfo(LogFilter.ServerLoading, "Loaded {0} cinematic waypoint sets in {1} ms", FlyByCameraStorage.Count, Time.GetMSTimeDiffToNow(oldMSTime)); }
public static List <FlyByCamera> GetFlyByCameras(uint cameraId) { return(FlyByCameraStorage.LookupByKey(cameraId)); }