/// <summary> /// Build dictionary of locations. /// </summary> private void EnumerateMaps() { //System.Diagnostics.Stopwatch s = System.Diagnostics.Stopwatch.StartNew(); //long startTime = s.ElapsedMilliseconds; mapDict = new Dictionary <int, MapSummary>(); locationIdToMapIdDict = new Dictionary <int, int>(); for (int region = 0; region < mapFileReader.RegionCount; region++) { DFRegion dfRegion = mapFileReader.GetRegion(region); for (int location = 0; location < dfRegion.LocationCount; location++) { // Get map summary MapSummary summary = new MapSummary(); DFRegion.RegionMapTable mapTable = dfRegion.MapTable[location]; summary.ID = mapTable.MapId & 0x000fffff; summary.RegionIndex = region; summary.MapIndex = location; summary.LocationType = mapTable.LocationType; summary.DungeonType = mapTable.DungeonType; mapDict.Add(summary.ID, summary); // Link locationId with mapId - adds ~25ms overhead int locationId = mapFileReader.ReadLocationIdFast(region, location); locationIdToMapIdDict.Add(locationId, summary.ID); } } //long totalTime = s.ElapsedMilliseconds - startTime; //Debug.LogFormat("Total time to enum maps: {0}ms", totalTime); }
static void Main(string[] args) { // Specify Arena2 path of local Daggerfall installation string MyArena2Path = "C:\\dosgames\\DAGGER\\ARENA2"; // Path to BSA file string FilePath = Path.Combine(MyArena2Path, "MAPS.BSA"); // Open file MapsFile mapsFile = new MapsFile( FilePath, FileUsage.UseDisk, true); // Loop through regions for (int r = 0; r < mapsFile.RegionCount; r++) { // Get the region object DFRegion region = mapsFile.GetRegion(r); // Loop through locations to look for largest dungeon int maxDungeonBlocks = -1; DFLocation maxDungeonLocation = new DFLocation(); for (int l = 0; l < region.LocationCount; l++) { // Get the location object DFLocation location = mapsFile.GetLocation(r, l); // Continue if location does not have a dungeon if (!location.HasDungeon) { continue; } // Find dungeon with most number of blocks if (location.Dungeon.Blocks.Length > maxDungeonBlocks) { maxDungeonBlocks = location.Dungeon.Blocks.Length; maxDungeonLocation = location; } } // Output information if dungeon found if (maxDungeonBlocks != -1) { Console.WriteLine("{0}, {1}, {2}", region.Name, maxDungeonLocation.Name, maxDungeonLocation.Dungeon.Blocks.Length); } } }
/// <summary> /// Build dictionary of locations. /// </summary> private void EnumerateMaps() { mapDict = new Dictionary <int, MapSummary>(); for (int region = 0; region < mapFileReader.RegionCount; region++) { DFRegion dfRegion = mapFileReader.GetRegion(region); for (int location = 0; location < dfRegion.LocationCount; location++) { MapSummary summary = new MapSummary(); DFRegion.RegionMapTable mapTable = dfRegion.MapTable[location]; summary.ID = mapTable.MapId & 0x000fffff; summary.RegionIndex = region; summary.MapIndex = location; mapDict.Add(summary.ID, summary); } } }
/// <summary> /// Build dictionary of locations. /// </summary> private void EnumerateMaps() { //System.Diagnostics.Stopwatch s = System.Diagnostics.Stopwatch.StartNew(); //long startTime = s.ElapsedMilliseconds; mapDict = new Dictionary <int, MapSummary>(); locationIdToMapIdDict = new Dictionary <int, int>(); for (int region = 0; region < mapFileReader.RegionCount; region++) { DFRegion dfRegion = mapFileReader.GetRegion(region); for (int location = 0; location < dfRegion.LocationCount; location++) { MapSummary summary = new MapSummary(); try { // Get map summary DFRegion.RegionMapTable mapTable = dfRegion.MapTable[location]; summary.ID = mapTable.MapId & 0x000fffff; summary.RegionIndex = region; summary.MapIndex = location; summary.LocationType = mapTable.LocationType; summary.DungeonType = mapTable.DungeonType; // TODO: This by itself doesn't account for DFRegion.LocationTypes.GraveyardForgotten locations that start the game discovered in classic summary.Discovered = mapTable.Discovered; mapDict.Add(summary.ID, summary); // Link locationId with mapId - adds ~25ms overhead int locationId = mapFileReader.ReadLocationIdFast(region, location); locationIdToMapIdDict.Add(locationId, summary.ID); } catch (ArgumentException) { Debug.LogErrorFormat("Colliding location for MapId:{0} found when enumerating maps! Unable to initialise content reader. ", summary.ID); } } } //long totalTime = s.ElapsedMilliseconds - startTime; //Debug.LogFormat("Total time to enum maps: {0}ms", totalTime); }