Ejemplo n.º 1
0
 private void ParseAndCheckLumpData <T>(Stream str, eLumpIndex index, out T[] data, int max, string name) where T : struct
 {
     data = ParseLumpData <T>(str, index);
     if (data.Length > max)
     {
         throw new Exception($"{_bspStr} {name} has too many entries!");
     }
     if (data.Length == 0)
     {
         throw new Exception($"{_bspStr} {name} has no entries!");
     }
 }
Ejemplo n.º 2
0
 private void ParseAndCheckLumpData <T>(Stream str, eLumpIndex index, out T[] data, int max, string name) where T : struct
 {
     data = ParseLumpData <T>(str, index);
     if (data.Length > max)
     {
         throw new Exception(string.Format("[BSP] {0} has too many entries; Parsed more than required.", name));
     }
     else if (data.Length == 0)
     {
         throw new Exception(string.Format("[BSP] {0} has no entries.", name));
     }
 }
Ejemplo n.º 3
0
        private T[] ParseLumpData <T>(Stream str, eLumpIndex index) where T : struct
        {
            var lump = m_BSPHeader.m_Lumps[(int)index];

            if (lump.m_FourCC != 0)
            {
                throw new Exception("LZMA!");
            }
            var count = lump.m_Filelen / MarshalSize <T> .Size;

            if (count <= 0)
            {
                return(new T[0]);
            }

            return(str.ReadArray <T>(lump.m_Fileofs, count));
        }