Exemplo n.º 1
0
        /// <summary>
        /// Extract the resource from the volume.
        /// </summary>
        /// <param name="container">Game container.</param>
        /// <param name="fileName">Volume file name.</param>
        /// <param name="dirEntry">Resource map entry for the resource to extract.</param>
        /// <param name="wasCompressed">Resource was compressed in the volume, so it was decompressed.</param>
        /// <returns>Binary data for the resource.  This is always uncompressed.  If the data is compressed in the volume, the volume decoder must decompress it.</returns>
        byte[] IVolumeDecoder.ExtractResource(IGameContainer container, string fileName, VolumeResourceMapEntry dirEntry, out bool wasCompressed)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            if (fileName == null)
            {
                throw new ArgumentNullException(nameof(fileName));
            }

            if (fileName.Length == 0)
            {
                throw new ArgumentException(Errors.FilePathEmpty, nameof(fileName));
            }

            if (dirEntry == null)
            {
                throw new ArgumentNullException(nameof(dirEntry));
            }

            wasCompressed = false;

            byte[] volumeData = container.Read(fileName);

            if (dirEntry.Offset >= volumeData.Length)
            {
                throw new VolumeDecoderInvalidResourceOffsetException();
            }

            return(VolumeDecoderV2.ExtractResource(volumeData, dirEntry.Offset));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load the resource map located in the specified folder.
        /// </summary>
        /// <param name="container">Game container where the resource map file(s) are located.</param>
        /// <returns>Resource map.</returns>
        VolumeResourceMap IVolumeDecoder.LoadResourceMap(IGameContainer container)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            var map = new VolumeResourceMap();

            VolumeDecoderV2.LoadResourceMapFile(container.Read(LogMapFile), map.LogicResources);
            VolumeDecoderV2.LoadResourceMapFile(container.Read(ViewMapFile), map.ViewResources);
            VolumeDecoderV2.LoadResourceMapFile(container.Read(PicMapFile), map.PictureResources);
            VolumeDecoderV2.LoadResourceMapFile(container.Read(SndMapFile), map.SoundResources);

            return(map);
        }