Example #1
0
        /// <summary>
        /// Lazy initialization of handle fields. They are initialized on the first access.
        /// because the mpq storage may not have finished loading and thus, the referenced sno may not be found
        /// </summary>
        private void Initialize()
        {
            // Look up the group if it is not set. Maybe one big
            // asset dictionary would be more convenient here
            _isInitialized = true;
            if (!_group.HasValue)
            {
                foreach (var pair in MPQStorage.Data.Assets)
                {
                    if (pair.Value.ContainsKey(Id))
                    {
                        _group = pair.Key;
                        break;
                    }
                }
            }

            if (_group.HasValue)
            {
                if (MPQStorage.Data != null && MPQStorage.Data.Assets.ContainsKey(_group.Value))
                {
                    if (MPQStorage.Data.Assets[_group.Value].ContainsKey(Id))
                    {
                        _isValid = true;
                        _target  = MPQStorage.Data.Assets[_group.Value][Id].Data;
                        _name    = MPQStorage.Data.Assets[_group.Value][Id].Name;
                    }
                }
            }
        }
Example #2
0
 public SNOHandle(int snoId)
 {
     Id = snoId;
     if (snoId == NO_ID)
     {
         _group = SNOGroup.None;
     }
 }
Example #3
0
 /// <summary>
 /// Parses SNOName from given GameBitBuffer.
 /// </summary>
 /// <param name="buffer">The GameBitBuffer to parse from.</param>
 public void Parse(GameBitBuffer buffer)
 {
     _group = (SNOGroup)buffer.ReadInt(32);
     Id     = buffer.ReadInt(32);
 }
Example #4
0
 /// <summary>
 /// Reads SNOName from given MPQFileStream.
 /// </summary>
 /// <param name="stream">The MPQFileStream to read from.</param>
 public SNOHandle(MpqFileStream stream)
 {
     _group = (SNOGroup)stream.ReadValueS32();
     Id     = stream.ReadValueS32();
 }
Example #5
0
 public SNOHandle(SNOGroup group, int id)
 {
     _group = group;
     Id     = id;
 }
Example #6
0
 public SNOHandle(SNOGroup group, int id)
 {
     _group = group;
     Id = id;
 }
Example #7
0
 /// <summary>
 /// Parses SNOName from given GameBitBuffer.
 /// </summary>
 /// <param name="buffer">The GameBitBuffer to parse from.</param>
 public void Parse(GameBitBuffer buffer)
 {
     _group = (SNOGroup)buffer.ReadInt(32);
     Id = buffer.ReadInt(32);
 }
Example #8
0
 /// <summary>
 /// Reads SNOName from given MPQFileStream.
 /// </summary>
 /// <param name="stream">The MPQFileStream to read from.</param>
 public SNOHandle(MpqFileStream stream)
 {
     _group = (SNOGroup)stream.ReadValueS32();
     Id = stream.ReadValueS32();
 }
Example #9
0
        /// <summary>
        /// Lazy initialization of handle fields. They are initialized on the first access.
        /// because the mpq storage may not have finished loading and thus, the referenced sno may not be found
        /// </summary>
        private void Initialize()
        {
            // Look up the group if it is not set. Maybe one big
            // asset dictionary would be more convenient here
            _isInitialized = true;
            if (!_group.HasValue)
            {
                foreach (var pair in MPQStorage.Data.Assets)
                    if (pair.Value.ContainsKey(Id))
                    {
                        _group = pair.Key;
                        break;
                    }
            }

            if (_group.HasValue)
                if (MPQStorage.Data != null && MPQStorage.Data.Assets.ContainsKey(_group.Value))
                    if (MPQStorage.Data.Assets[_group.Value].ContainsKey(Id))
                    {
                        _isValid = true;
                        _target = MPQStorage.Data.Assets[_group.Value][Id].Data;
                        _name = MPQStorage.Data.Assets[_group.Value][Id].Name;
                    }
        }
Example #10
0
 public SNOHandle(int snoId)
 {
     Id = snoId;
     if (snoId == NO_ID)
         _group = SNOGroup.None;
 }