示例#1
0
        public static void LoadAllFromBspStream(BspFile bsp, LoadFlags flags, Stream stream)
        {
            if (bsp == null)
            {
                throw new ArgumentNullException(nameof(bsp), "Target BSP is null.");
            }

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

            var reader = new BinaryReader(stream);


            var startPos = stream.Position;

            //4 bytes = 1 uint
            uint version = reader.ReadUInt32();

            stream.Position = startPos;


            switch (version)
            {
            case (uint)BspVersion.Quake1:
            {
                throw new BspVersionNotSupportedException(version, "Quake 1");
            }

            case (uint)BspVersion.GoldSource:
            {
                GoldSource.Bsp.LoadAllFromBspStream(bsp, flags, stream);
            }
            break;

            case (uint)BspVersion.ValveBSP:
            {
                throw new BspVersionNotSupportedException(version, "ValveBSP (Source engine)");
            }

            case (uint)BspVersion.RespawnBSP:
            {
                throw new BspVersionNotSupportedException(version, "rBSP (Titanfall)");
            }

            default:
                throw new BspVersionNotSupportedException(version);
            }
        }
示例#2
0
        public static void LoadAllFromFile(BspFile bsp, LoadFlags flags, string path)
        {
            if (bsp == null)
            {
                throw new ArgumentNullException(nameof(bsp), "Target BSP is null.");
            }

            if (!File.Exists(path))
            {
                throw new FileNotFoundException("BSP file not found", path);
            }

            using (var stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                LoadAllFromBspStream(bsp, flags, stream);
            }
        }
示例#3
0
        public static void LoadPackedTexturesFromBspStream(BspFile bsp, Stream stream)
        {
            if (bsp == null)
            {
                throw new ArgumentNullException(nameof(bsp), "Target BSP is null.");
            }

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

            var reader = new BinaryReader(stream);


            var startPos = stream.Position;

            //4 bytes = 1 uint
            uint version = reader.ReadUInt32();

            stream.Position = startPos;


            switch (version)
            {
            case (uint)BspVersion.Quake1:
            {
                throw new BspVersionNotSupportedException(version, "Quake 1");
            }

            case (uint)BspVersion.GoldSource:
            {
                GoldSource.Bsp.LoadPackedTexturesFromBspStream(bsp, stream);
            }
            break;

            default:
                break;
            }
        }