private static void StepLoadArchives() { string[] archivePaths = Config.GetPaths("archive_paths"); List <IArchive> listArchives = new List <IArchive>(); foreach (var path in archivePaths) { if (File.Exists(path)) { listArchives.Add(ArchiveManager.LoadImageArchive(path)); } else if (Directory.Exists(path)) { listArchives.Add(ArchiveManager.LoadLooseArchive(path)); } else { // try to get case-sensitive file path string caseSensitivePath = ArchiveManager.GetCaseSensitiveFilePath(Path.GetFileName(path)); listArchives.Add(ArchiveManager.LoadImageArchive(caseSensitivePath)); // throw new System.Exception("Archive not found: " + path); } } s_archives = listArchives.FindAll(a => a != null).ToArray(); }
public static void ReadIde(string path) { var file = new ItemFile <Definition>(ArchiveManager.GetCaseSensitiveFilePath(Path.GetFileName(path))); foreach (var obj in file.GetItems <Definition>().OfType <IObjectDefinition>()) { _definitions.Add(obj.Id, obj); } }
public static void ReadIpl(string path) { var file = new ItemFile <Placement>(ArchiveManager.GetCaseSensitiveFilePath(Path.GetFileName(path))); foreach (var zone in file.GetSection <Zone>("zone")) { _zones.Add(zone); } foreach (var enex in file.GetSection <EntranceExit>("enex")) { _enexes.Add(enex); } var insts = file.GetSection <Instance>("inst"); var list = new List <Instance>(); list.AddRange(insts); var cars = new List <ParkedVehicle>(file.GetSection <ParkedVehicle>("cars")); string streamFormat = Path.GetFileNameWithoutExtension(path).ToLower() + "_stream{0}.ipl"; int missed = 0; for (int i = 0; ; ++i) { string streamFileName = string.Format(streamFormat, i); if (!ArchiveManager.FileExists(streamFileName)) { ++missed; if (missed > 10) { break; } continue; } file = new ItemFile <Placement>(ArchiveManager.ReadFile(streamFileName)); list.AddRange(file.GetSection <Instance>("inst")); cars.AddRange(file.GetSection <ParkedVehicle>("cars")); } list.ResolveLod(); int lastCell = -1; foreach (var inst in list) { int cell = inst.CellId & 0xff; if (lastCell != cell && !_placements.ContainsKey(lastCell = cell)) { _placements.Add(cell, new List <Placement>()); } _placements[cell].Add(inst); } if (!_placements.ContainsKey(0)) { _placements.Add(0, new List <Placement>()); } _placements[0].AddRange(cars.Cast <Placement>()); }