Exemple #1
0
        /// <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);
        }
        /// <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);
        }