Esempio n. 1
0
        public static void Load(WadFile wad, string path)
        {
            if (!File.Exists(path))
            {
                throw new FileNotFoundException("Wad file was not found.");
            }

            using (var stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                Load(wad, stream);
            }
        }
Esempio n. 2
0
        public static bool Save(WadFile wad, string path, WadVersion version)
        {
            if (File.Exists(path))
            {
                return(false);
            }

            using (var stream = File.Open(path, FileMode.CreateNew, FileAccess.Write, FileShare.None))
            {
                Save(wad, stream, version);
                return(true);
            }
        }
Esempio n. 3
0
        public static void Save(WadFile wad, Stream stream, WadVersion version)
        {
            switch (version)
            {
            // Wad2 (Quake I)
            case WadVersion.Wad2:
            {
                Wad2.Wad.Save(wad, stream);
                return;
            }

            // Wad3 (GoldSource)
            case WadVersion.Wad3:
            {
                Wad3.Wad.Save(wad, stream);
                return;
            }
            }
            throw new WadVersionNotSupportedException((uint)version);
        }
Esempio n. 4
0
        public static void Load(WadFile wad, Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            var reader = new BinaryReader(stream);


            var startPos = reader.BaseStream.Position;

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

            reader.BaseStream.Position = startPos;


            switch (version)
            {
            // Wad2 (Quake I)
            case (uint)WadVersion.Wad2:
            {
                Wad2.Wad.Load(wad, stream);
                Debug.Log("Loaded Wad2 file");
            }
            break;

            // Wad3 (GoldSource)
            case (uint)WadVersion.Wad3:
            {
                Wad3.Wad.Load(wad, stream);
                Debug.Log("Loaded Wad3 file");
            }
            break;

            default:
                //throw new WadVersionNotSupportedException(version);
                break;
            }
        }