예제 #1
0
        private WadHeader ReadHeader(BinaryReader reader)
        {
            var header = new WadHeader
            {
                Magic     = reader.ReadString(4),
                Dirs      = reader.ReadInt32(),
                DirOffset = reader.ReadInt32()
            };

            if (header.Magic != "WAD2" && header.Magic != "WAD3")
            {
                throw new InvalidDataException();
            }

            return(header);
        }
예제 #2
0
        public BspTextureData[] Load()
        {
            using (var mapReader = new BinaryReader(new FileStream(_mapFileName, FileMode.Open)))
            {
                foreach (var fileName in _wadFileNames)
                {
                    if (!File.Exists(fileName))
                    {
                        throw new FileNotFoundException(fileName);
                    }

                    using (var reader = new BinaryReader(new FileStream(fileName, FileMode.Open)))
                    {
                        _header = ReadHeader(reader);
                    }

                    LoadTextures(mapReader);
                }
            }

            return(_textureLookup.ToArray());
        }