Exemple #1
0
        /// <summary>Reads the overlay.</summary>
        private void ReadOverlay()
        {
            IniSection overlaySection = GetSection("OverlayPack");

            if (overlaySection == null)
            {
                Logger.Info("OverlayPack section unavailable in {0}, overlay will be unavailable", Path.GetFileName(FileName));
                return;
            }

            byte[] format80Data = Convert.FromBase64String(overlaySection.ConcatenatedValues());
            var    overlayPack  = new byte[1 << 18];

            Format5.DecodeInto(format80Data, overlayPack, 80);

            IniSection overlayDataSection = GetSection("OverlayDataPack");

            if (overlayDataSection == null)
            {
                Logger.Debug("OverlayDataPack section unavailable in {0}, overlay will be unavailable", Path.GetFileName(FileName));
                return;
            }
            format80Data = Convert.FromBase64String(overlayDataSection.ConcatenatedValues());
            var overlayDataPack = new byte[1 << 18];

            Format5.DecodeInto(format80Data, overlayDataPack, 80);

            for (int y = 0; y < FullSize.Height; y++)
            {
                for (int x = FullSize.Width * 2 - 2; x >= 0; x--)
                {
                    var t = Tiles[x, y];
                    if (t == null)
                    {
                        continue;
                    }
                    int  idx        = t.Rx + 512 * t.Ry;
                    byte overlay_id = overlayPack[idx];
                    if (overlay_id != 0xFF)
                    {
                        byte overlay_value = overlayDataPack[idx];
                        var  ovl           = new Overlay(overlay_id, overlay_value);
                        ovl.Tile = t;
                        Overlays.Add(ovl);
                    }
                }
            }

            Logger.Debug("Read {0} overlay types", Overlays.Count);
        }