Exemple #1
0
 private MpqHash(ulong name, MpqLocale locale, uint blockIndex)
     : this()
 {
     Name       = name;
     Locale     = locale;
     BlockIndex = blockIndex;
 }
Exemple #2
0
 private MpqHash(uint name1, uint name2, MpqLocale locale, uint blockIndex)
     : this()
 {
     Name1      = name1;
     Name2      = name2;
     Locale     = locale;
     BlockIndex = blockIndex;
 }
Exemple #3
0
        internal MpqFile(ulong?hashedName, MpqStream mpqStream, MpqFileFlags flags, MpqLocale locale, bool leaveOpen)
        {
            _name          = hashedName;
            _mpqStream     = mpqStream ?? throw new ArgumentNullException(nameof(mpqStream));
            _isStreamOwner = !leaveOpen;

            _flags           = flags;
            _locale          = locale;
            _compressionType = MpqCompressionType.ZLib;
        }
Exemple #4
0
        // public MpqArchive Archive => _archive;

        /*public void AddToArchive( MpqArchive archive )
         * {
         *  if ( _archive != null )
         *  {
         *      throw new InvalidOperationException();
         *  }
         *
         *  _archive = archive;
         *  _entry.SetPos( 0 );
         * }*/

        public void AddToArchive(uint headerOffset, uint index, uint filePos, MpqLocale locale, uint mask)
        {
            _entry.SetPos(headerOffset, filePos);

            // This file came from another archive, and has an unknown filename.
            if (_hash.HasValue)
            {
                // Overwrite blockIndex from old archive.
                var hash = _hash.Value;
                _hash = new MpqHash(hash.Name1, hash.Name2, hash.Locale, index, hash.Mask);
            }
            else
            {
                _hash      = new MpqHash(_fileName, mask, locale, index);
                _hashIndex = MpqHash.GetIndex(_fileName, mask);
            }
        }
Exemple #5
0
        public void AddToArchive(uint headerOffset, uint index, uint filePos, MpqLocale locale, uint mask)
        {
            // TODO: verify that blocksize of mpqfile and mpqarchive to which it gets added are the same, otherwise throw an exception

            _entry.SetPos(headerOffset, filePos);

            // This file came from another archive, and has an unknown filename.
            if (_hash.HasValue)
            {
                // Overwrite blockIndex from old archive.
                var hash = _hash.Value;
                _hash = new MpqHash(hash.Name1, hash.Name2, hash.Locale, index, hash.Mask);
            }
            else
            {
                _hash      = new MpqHash(_fileName, mask, locale, index);
                _hashIndex = MpqHash.GetIndex(_fileName, mask);
            }
        }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MpqKnownFile"/> class.
 /// </summary>
 internal MpqKnownFile(string fileName, MpqStream mpqStream, MpqFileFlags flags, MpqLocale locale, bool leaveOpen = false)
     : base(MpqHash.GetHashedFileName(fileName), mpqStream, flags, locale, leaveOpen)
 {
     _fileName = fileName;
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MpqHash"/> struct.
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="mask"></param>
 /// <param name="locale"></param>
 /// <param name="blockIndex"></param>
 public MpqHash(string fileName, uint mask, MpqLocale locale, uint blockIndex)
     : this(StormBuffer.HashString(fileName, 0x100), StormBuffer.HashString(fileName, 0x200), locale, blockIndex, mask)
 {
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MpqHash"/> struct.
 /// </summary>
 /// <param name="name1"></param>
 /// <param name="name2"></param>
 /// <param name="locale"></param>
 /// <param name="blockIndex"></param>
 /// <param name="mask"></param>
 public MpqHash(uint name1, uint name2, MpqLocale locale, uint blockIndex, uint mask)
     : this(name1, name2, locale, blockIndex)
 {
     Mask = mask;
 }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MpqHash"/> struct.
 /// </summary>
 public MpqHash(string fileName, uint mask, MpqLocale locale, uint blockIndex)
     : this(GetHashedFileName(fileName), locale, blockIndex, mask)
 {
 }
Exemple #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MpqHash"/> struct.
 /// </summary>
 public MpqHash(ulong name, MpqLocale locale, uint blockIndex, uint mask)
     : this(name, locale, blockIndex)
 {
     Mask = mask;
 }