public GameCache(FileInfo file) { File = file; Stream = file.OpenRead(); Reader = new EndianReader(Stream); var mapFile = new MapFile(); mapFile.Read(Reader); switch (mapFile.Version) { case CacheVersion.HaloPC: case CacheVersion.HaloXbox: case CacheVersion.Halo2Vista: case CacheVersion.Halo2Xbox: throw new Exception("Not implemented!"); case CacheVersion.Halo3Beta: case CacheVersion.Halo3ODST: case CacheVersion.Halo3Retail: case CacheVersion.HaloReach: case CacheVersion.HaloReachMCC824: CacheContext = new GameCacheContextGen3(mapFile, Reader); break; case CacheVersion.HaloOnline106708: case CacheVersion.HaloOnline235640: case CacheVersion.HaloOnline301003: case CacheVersion.HaloOnline327043: case CacheVersion.HaloOnline372731: case CacheVersion.HaloOnline416097: case CacheVersion.HaloOnline430475: case CacheVersion.HaloOnline454665: case CacheVersion.HaloOnline449175: case CacheVersion.HaloOnline498295: case CacheVersion.HaloOnline530605: case CacheVersion.HaloOnline532911: case CacheVersion.HaloOnline554482: case CacheVersion.HaloOnline571627: case CacheVersion.HaloOnline700123: break; } }
public void DetermineMapFlags() { foreach (var mapFile in MapFileStreams) { var reader = new EndianReader(mapFile); MapFile map = new MapFile(); map.Read(reader); var type = map.Header.CacheType; if (type == CacheFileType.Campaign) { Header.MapFlags |= MapFlags.CampaignMaps; } else if (type == CacheFileType.MainMenu) { Header.MapFlags |= MapFlags.MainmenuMaps; } else if (type == CacheFileType.Multiplayer) { Header.MapFlags |= MapFlags.MultiplayerMaps; } } }
public static GameCache Open(FileInfo file) { MapFile map = new MapFile(); var estimatedVersion = CacheVersion.HaloOnline106708; using (var stream = file.OpenRead()) using (var reader = new EndianReader(stream)) { if (file.Name.Contains(".map")) { map.Read(reader); estimatedVersion = map.Version; } else if (file.Name.Equals("tags.dat")) { estimatedVersion = CacheVersion.HaloOnline106708; } else if (file.Name.Contains(".pak")) { return(new GameCacheModPackage(file)); } else { throw new Exception("Invalid file passed to GameCache constructor"); } } switch (estimatedVersion) { case CacheVersion.HaloXbox: case CacheVersion.HaloPC: case CacheVersion.HaloCustomEdition: return(new GameCacheGen1(map, file)); case CacheVersion.Halo2Vista: case CacheVersion.Halo2Xbox: return(new GameCacheGen2(map, file)); case CacheVersion.Halo3Beta: case CacheVersion.Halo3Retail: case CacheVersion.Halo3ODST: case CacheVersion.HaloReach: case CacheVersion.HaloReachMCC0824: case CacheVersion.HaloReachMCC0887: case CacheVersion.HaloReachMCC1035: case CacheVersion.HaloReachMCC1211: return(new GameCacheGen3(map, file)); case CacheVersion.HaloOnline106708: case CacheVersion.HaloOnline235640: case CacheVersion.HaloOnline301003: case CacheVersion.HaloOnline327043: case CacheVersion.HaloOnline372731: case CacheVersion.HaloOnline416097: case CacheVersion.HaloOnline430475: case CacheVersion.HaloOnline454665: case CacheVersion.HaloOnline449175: case CacheVersion.HaloOnline498295: case CacheVersion.HaloOnline530605: case CacheVersion.HaloOnline532911: case CacheVersion.HaloOnline554482: case CacheVersion.HaloOnline571627: case CacheVersion.HaloOnline700123: { var directory = file.Directory.FullName; var tagsPath = Path.Combine(directory, "tags.dat"); var tagsFile = new FileInfo(tagsPath); if (!tagsFile.Exists) { throw new Exception("Failed to find tags.dat"); } return(new GameCacheHaloOnline(tagsFile.Directory)); } } return(null); }