Ejemplo n.º 1
0
        public Conversation(MpqFile file)
        {
            MpqFileStream stream = file.Open();

            this.Header           = new Header(stream);
            this.ConversationType = (ConversationTypes)stream.ReadValueS32();
            this.I0               = stream.ReadValueS32();
            this.I1               = stream.ReadValueS32();
            this.SNOQuest         = stream.ReadValueS32();
            this.I2               = stream.ReadValueS32();
            this.I3               = stream.ReadValueS32();
            this.SNOConvPiggyback = stream.ReadValueS32();
            this.SNOConvUnlock    = stream.ReadValueS32();
            this.I4               = stream.ReadValueS32();
            this.Unknown          = stream.ReadString(128, true);
            this.SNOPrimaryNpc    = stream.ReadValueS32();
            this.SNOAltNpc1       = stream.ReadValueS32();
            this.SNOAltNpc2       = stream.ReadValueS32();
            this.SNOAltNpc3       = stream.ReadValueS32();
            this.SNOAltNpc4       = stream.ReadValueS32();
            this.I5               = stream.ReadValueS32();

            stream.Position += (2 * 4);
            RootTreeNodes    = stream.ReadSerializedData <ConversationTreeNode>();

            this.Unknown2 = stream.ReadString(256, true);
            this.I6       = stream.ReadValueS32();

            stream.Position      += 12;
            CompiledScript        = Encoding.ASCII.GetString(stream.ReadSerializedByteArray());
            stream.Position      += 40;
            this.SNOBossEncounter = stream.ReadValueS32();
            stream.Close();
        }
Ejemplo n.º 2
0
 private void AddSoundToFolderSystem(Folder folder, MpqFile file, int offset)
 {
     if (file.Name.IndexOf("\\", offset) >= 0)
     {
         var splitOffset = file.Name.IndexOf("\\", offset);
         var folderName  = file.Name.Substring(offset, splitOffset - offset);
         var subFolder   = folder.folders.Where(f => f.name == folderName).FirstOrDefault();
         if (subFolder == null)
         {
             subFolder      = new Folder();
             subFolder.name = folderName + "\\\\";
             folder.folders.Add(subFolder);
         }
         var remainingPath = file.Name.Substring(file.Name.IndexOf("\\") + 1);
         AddSoundToFolderSystem(subFolder, file, splitOffset + 1);
     }
     else
     {
         var soundFile = new SoundFile();
         soundFile.name = file.Name.Substring(offset);
         soundFile.file = file;
         folder.sounds.Add(soundFile);
         soundsFound++;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets a file from the mpq storage.
        /// </summary>
        /// <param name="fileName">File to read.</param>
        /// <param name="startSearchingFromBaseMPQ">Use the most available patched version? If you supply false to useMostAvailablePatchedVersion, it'll be looking for file starting from the base mpq up to latest available patch.</param>
        /// <returns>The MpqFile</returns>
        private MpqFile GetFile(string fileName, bool startSearchingFromBaseMPQ = false)
        {
            MpqFile file = null;

            //Ignore loading lvl files for now.
            if (fileName.Contains(".lvl"))
            {
                return(null);
            }

            if (!startSearchingFromBaseMPQ)
            {
                file = this.FileSystem.FindFile(fileName);
            }
            else
            {
                foreach (MpqArchive archive in this.FileSystem.Archives.Reverse()) //search mpqs starting from base
                {
                    file = archive.FindFile(fileName);
                    if (file != null)
                    {
                        break;
                    }
                }
            }

            return(file);
        }
Ejemplo n.º 4
0
        public BossEncounter(MpqFile file)
        {
            var stream = file.Open();

            this.Header        = new Header(stream);
            this.I0            = stream.ReadValueS32();
            this.I1            = stream.ReadValueS32();
            this.I2            = stream.ReadValueS32();
            this.I3            = stream.ReadValueS32();
            this.I4            = stream.ReadValueS32();
            this.I5            = stream.ReadValueS32();
            this.I6            = stream.ReadValueS32();
            this.I7            = stream.ReadValueS32();
            this.I8            = stream.ReadValueS32();
            this.I9            = stream.ReadValueS32();
            this.SNOQuestRange = stream.ReadValueS32();
            this.Worlds        = new int[4];
            for (int i = 0; i < 4; i++)
            {
                this.Worlds[i] = stream.ReadValueS32();
            }
            this.Scripts = new int[3];
            for (int i = 0; i < 3; i++)
            {
                this.Scripts[i] = stream.ReadValueS32();
            }
            stream.Close();
        }
Ejemplo n.º 5
0
        public void TestWithPreArchiveData()
        {
            var memoryStream = new MemoryStream();
            var randomData   = new byte[999];

            randomData[100] = 99;
            memoryStream.Write(randomData, 0, randomData.Length);

            var randomFiles = new List <MpqFile>();

            for (var i = 0; i < 35; i++)
            {
                var fileStream = new MemoryStream();
                fileStream.Write(randomData, 0, randomData.Length);
                fileStream.Position = 0;
                randomFiles.Add(MpqFile.New(fileStream, $"file{i}"));
            }

            using var a = MpqArchive.Create(memoryStream, randomFiles, new MpqArchiveCreateOptions()
            {
                ListFileCreateMode = MpqFileCreateMode.None, AttributesCreateMode = MpqFileCreateMode.None
            });

            memoryStream.Position = 0;
            var archive = MpqArchive.Open(memoryStream);

            foreach (var file in archive.GetMpqFiles())
            {
                file.MpqStream.Seek(100, SeekOrigin.Begin);
                Assert.AreEqual(99, file.MpqStream.ReadByte());
            }

            archive.Dispose();
        }
Ejemplo n.º 6
0
        public Scene(MpqFile file)
        {
            var stream = file.Open();

            this.Header = new Header(stream);

            Int0                     = stream.ReadValueS32();
            this.AABBBounds          = new AABB(stream);
            this.AABBMarketSetBounds = new AABB(stream);

            this.NavMesh    = new NavMeshDef(stream);
            this.Exclusions = stream.ReadSerializedInts();

            stream.Position += (14 * 4);
            this.Inclusions  = stream.ReadSerializedInts();

            stream.Position += (14 * 4);
            this.MarkerSets  = stream.ReadSerializedInts();

            stream.Position += (14 * 4);
            this.LookLink    = stream.ReadString(64, true);

            this.MsgTriggeredEvent = stream.ReadSerializedData <MsgTriggeredEvent>();
            this.Int1 = stream.ReadValueS32();

            stream.Position   += (3 * 4);
            this.NavZone       = new NavZoneDef(stream);
            this.SNOAppearance = stream.ReadValueS32();
            this.SNOPhysMesh   = stream.ReadValueS32();
            stream.Close();
        }
Ejemplo n.º 7
0
        public Scene(MpqFile file)
        {
            var stream = file.Open();

            this.Header = new Header(stream);

            Int0                     = stream.ReadValueS32();
            this.AABBBounds          = new AABB(stream);
            this.AABBMarketSetBounds = new AABB(stream);

            this.NavMesh    = new NavMeshDef(stream); //load NavMeshDef
            this.Exclusions = stream.ReadSerializedInts();
            //var exclusions = stream.GetSerializedDataPointer();

            stream.Position += (14 * 4);
            this.Inclusions  = stream.ReadSerializedInts();
            //var inclusions = stream.GetSerializedDataPointer();

            stream.Position += (14 * 4);
            this.MarkerSets  = stream.ReadSerializedInts();

            stream.Position += (14 * 4);
            this.LookLink    = stream.ReadString(64, true);

            // Maybe this is a list/array - DarkLotus
            this.MsgTriggeredEvent = stream.ReadSerializedItem <MsgTriggeredEvent>();
            this.Int1 = stream.ReadValueS32();

            stream.Position += (3 * 4);
            this.NavZone     = new NavZoneDef(stream);

            stream.Close();
        }
Ejemplo n.º 8
0
        public Power(MpqFile file)
        {
            var stream = file.Open();

            this.Header      = new Header(stream);
            LuaName          = stream.ReadString(64, true);
            stream.Position += 4;   // pad 1
            Powerdef         = new PowerDef(stream);
            stream.Position  = 440; // Seems like theres a bit of a gap - DarkLotus
            I0                   = stream.ReadValueS32();
            I1                   = stream.ReadValueS32();
            Chararray2           = stream.ReadString(256, true);
            ScriptFormulaCount   = stream.ReadValueS32();
            ScriptFormulaDetails = stream.ReadSerializedData <ScriptFormulaDetails>();
            stream.Position     += (3 * 4);
            i3                   = stream.ReadValueS32();
            stream.Position     += (3 * 4);

            // TODO: please fix this - use our serializable-data readers instead! /raist
            // TODO add a class for complied script so it can be deserialized properly. - DarkLotus
            // none of the .pow appear to have any data here, and stream position appears to be correct, unsure - DarkLotus
            var serCompliedScript = stream.GetSerializedDataPointer();

            if (serCompliedScript.Size > 0)
            {
                long x = stream.Position;
                stream.Position = serCompliedScript.Offset + 16;
                var buf = new byte[serCompliedScript.Size];
                stream.Read(buf, 0, serCompliedScript.Size);
                stream.Position = x;
                CompliedScript.AddRange(buf);
            }
            SNOQuestMetaData = stream.ReadValueS32();
            stream.Close();
        }
Ejemplo n.º 9
0
        public LevelArea(MpqFile file)
        {
            if (file.Size == 0 || file.Size == 48) // Fixes crash on A4_dun_DIablo_Arena_Phase3 - DarkLotus
            {
                return;
            }
            var stream = file.Open();

            this.Header = new Header(stream);
            this.I0     = new int[4];
            for (int i = 0; i < 4; i++)
            {
                this.I0[i] = stream.ReadValueS32();
            }
            this.I1 = stream.ReadValueS32();
            this.SNOLevelAreaOverrideForGizmoLocs = stream.ReadValueS32();
            stream.Position            += 4;
            this.LocSet                 = new GizmoLocSet(stream);
            this.SpawnPopulationEntries = stream.ReadValueS32();
            stream.Position            += 12;

            //mpq reading of spawn populations is disabled because its not working anymore. data is loaded from database instead
            //this.SpawnPopulation = stream.ReadSerializedData<LevelAreaSpawnPopulation>();
            stream.Close();
        }
Ejemplo n.º 10
0
        public Act(MpqFile file)
        {
            var stream = file.Open();

            this.Header = new Header(stream);

            this.ActQuestInfo = stream.ReadSerializedData <ActQuestInfo>();
            stream.Position  += 12;

            this.WayPointInfo = new WaypointInfo[25];
            for (int i = 0; i < WayPointInfo.Length; i++)
            {
                this.WayPointInfo[i] = new WaypointInfo(stream);
            }

            this.ResolvedPortalDestination = new ResolvedPortalDestination(stream);

            this.ActStartLocOverrides = new ActStartLocOverride[6];
            for (int i = 0; i < ActStartLocOverrides.Length; i++)
            {
                this.ActStartLocOverrides[i] = new ActStartLocOverride(stream);
            }

            stream.Close();
        }
Ejemplo n.º 11
0
        private void GetNodeInfo(TreeNode node, out long size, out long compressedSize)
        {
            size           = 0;
            compressedSize = 0;

            if (node == null)
            {
                size           = 0;
                compressedSize = 0;
            }
            else if (node.Tag == null || !(node.Tag is MpqFile))
            {
                size           = 0;
                compressedSize = 0;
                foreach (TreeNode childNode in node.Nodes)
                {
                    long childSize, childCompressedSize;
                    GetNodeInfo(childNode, out childSize, out childCompressedSize);
                    size           += childSize;
                    compressedSize += childCompressedSize;
                }
            }
            else
            {
                MpqFile mpqFile = (MpqFile)node.Tag;

                size           = mpqFile.Size;
                compressedSize = mpqFile.CompressedSize;
            }
        }
Ejemplo n.º 12
0
        internal static void RunStreamRWTest(
            string filePath,
            Type type,
            string writeMethodName)
        {
            var readMethod = typeof(StreamReaderExtensions).GetMethod($"Read{type.Name}");

            Assert.IsNotNull(readMethod, $"Could not find extension method to read {type.Name}.");

            var writeMethod = typeof(StreamWriterExtensions).GetMethod(writeMethodName, new[] { typeof(StreamWriter), type });

            Assert.IsNotNull(writeMethod, $"Could not find extension method to write {type.Name}.");

            using var expectedStream = MpqFile.OpenRead(filePath);
            using var reader         = new StreamReader(expectedStream, new UTF8Encoding(false, true));
            var parsedFile = readMethod !.Invoke(null, new[] { reader });

            Assert.AreEqual(type, parsedFile !.GetType());

            using var actualStream = new MemoryStream();
            using var writer       = new StreamWriter(actualStream, reader.CurrentEncoding);
            writeMethod !.Invoke(null, new[] { writer, parsedFile });
            writer.Flush();

            StreamAssert.AreEqualText(expectedStream, actualStream, true);
        }
Ejemplo n.º 13
0
        private static IEnumerable <object[]> GetMapTriggersDataSpecificFormatVersion(MapTriggersFormatVersion?formatVersion)
        {
            foreach (var testData in GetMapTriggersData())
            {
                using var original = MpqFile.OpenRead((string)testData[0]);
                using var reader   = new BinaryReader(original);

                if (original.Length >= 8)
                {
                    if (reader.ReadInt32() == MapTriggers.FileFormatSignature)
                    {
                        var actualVersion = (MapTriggersFormatVersion?)reader.ReadInt32();
                        if (!Enum.IsDefined(typeof(MapTriggersFormatVersion), actualVersion))
                        {
                            actualVersion = null;
                        }

                        if (formatVersion == actualVersion)
                        {
                            yield return(testData);
                        }
                    }
                }
            }
        }
Ejemplo n.º 14
0
        public MarkerSet(MpqFile file)
        {
            var stream = file.Open();

            this.Header = new Header(stream);

            this.Markers = stream.ReadSerializedData <Marker>();

            stream.Position += (15 * 4);
            NoSpawns         = stream.ReadSerializedData <Circle>();
            stream.Position += (14 * 4);
            this.AABB        = new AABB(stream);
            int i0 = stream.ReadValueS32();

            if (i0 != 0 && i0 != 1)
            {
                throw new System.Exception("Farmy thought this field is a bool, but apparently its not");
            }
            this.ContainsActorLocations = i0 == 1;

            this.FileName          = stream.ReadString(256, true);
            this.NLabel            = stream.ReadValueS32();
            this.SpecialIndexCount = stream.ReadValueS32();
            this.SpecialIndexList  = stream.ReadSerializedShorts();
            stream.Close();
        }
Ejemplo n.º 15
0
        public Quest(MpqFile file)
        {
            MpqFileStream stream = file.Open();

            Header                  = new Header(stream);
            QuestType               = (QuestType)stream.ReadValueS32();
            NumberOfSteps           = stream.ReadValueS32();
            NumberOfCompletionSteps = stream.ReadValueS32();
            I2 = stream.ReadValueS32();
            I3 = stream.ReadValueS32();
            I4 = stream.ReadValueS32();
            I5 = stream.ReadValueS32();

            QuestUnassignedStep  = new QuestUnassignedStep(stream);
            stream.Position     += 8;
            QuestSteps           = stream.ReadSerializedData <QuestStep>();
            stream.Position     += 8;
            QuestCompletionSteps = stream.ReadSerializedData <QuestCompletionStep>();

            LevelRange1 = new QuestLevelRange(stream);
            LevelRange2 = new QuestLevelRange(stream);
            LevelRange3 = new QuestLevelRange(stream);
            LevelRange4 = new QuestLevelRange(stream);


            stream.Close();
        }
Ejemplo n.º 16
0
        public Globals(MpqFile file)
        {
            var stream = file.Open();

            this.Header      = new Header(stream);
            stream.Position += 8;
            this.ServerData  = stream.ReadSerializedData <GlobalServerData>();

            stream.Position        += 4;
            this.I0                 = stream.ReadValueS32(); //32
            stream.Position        += 12;
            this.StartLocationNames = new Dictionary <int, FileFormats.StartLocationName>();
            foreach (var startLocation in stream.ReadSerializedData <StartLocationName>())
            {
                StartLocationNames.Add(startLocation.I0, startLocation);
            }

            this.F0 = stream.ReadValueF32(); //56
            this.F1 = stream.ReadValueF32(); //60
            this.F2 = stream.ReadValueF32(); //64
            this.F3 = stream.ReadValueF32(); //68

            Colors = new RGBAColor[400];     //72
            for (int i = 0; i < 400; i++)
            {
                Colors[i] = new RGBAColor(stream);
            }

            this.I1  = stream.ReadValueS32();
            this.I2  = stream.ReadValueS32();
            this.F4  = stream.ReadValueF32();
            this.F5  = stream.ReadValueF32();
            this.I3  = stream.ReadValueS32();
            this.F6  = stream.ReadValueF32();
            this.F7  = stream.ReadValueF32();
            this.F8  = stream.ReadValueF32();
            this.F9  = stream.ReadValueF32();
            this.F10 = stream.ReadValueF32();
            this.I4  = stream.ReadValueS32();
            this.I6  = new int[4];
            for (int i = 0; i < 4; i++)
            {
                this.I6[i] = stream.ReadValueS32();
            }
            stream.Position  += 4;
            this.BannerParams = new BannerParams(stream);
            this.I5           = stream.ReadValueS32();
            this.I7           = stream.ReadValueS32();
            this.I8           = stream.ReadValueS32();
            this.I9           = stream.ReadValueS32();
            this.F11          = stream.ReadValueF32();
            this.F12          = stream.ReadValueF32();
            this.F13          = stream.ReadValueF32();
            this.F14          = stream.ReadValueF32();
            this.F15          = stream.ReadValueF32();
            this.F16          = stream.ReadValueF32();
            this.F17          = stream.ReadValueF32();
            this.F18          = stream.ReadValueF32();
            stream.Close();
        }
Ejemplo n.º 17
0
        public void TestStoreCompressedThenRetrieveFile(string filename)
        {
            var fileStream = File.OpenRead(filename);
            var mpqFile    = new MpqFile(fileStream, filename, MpqFileFlags.Exists | MpqFileFlags.Compressed, BlockSize);
            var archive    = MpqArchive.Create(new MemoryStream(), new List <MpqFile>()
            {
                mpqFile
            });

            var openedArchive = MpqArchive.Open(archive.BaseStream);
            var openedStream  = openedArchive.OpenFile(filename);

            // Reload file, since the filestream gets disposed when the mpqfile is added to an mpqarchive.
            fileStream = File.OpenRead(filename);

            Assert.AreEqual(fileStream.Length, openedStream.Length);

            using (var fileStreamReader = new StreamReader(fileStream))
            {
                using (var openedStreamReader = new StreamReader(openedStream))
                {
                    StringAssert.Equals(fileStreamReader.ReadToEnd(), openedStreamReader.ReadToEnd());
                }
            }
        }
Ejemplo n.º 18
0
        public Recipe(MpqFile file)
        {
            var stream = file.Open();

            this.Header       = new Header(stream);
            ItemSpecifierData = new ItemSpecifierData(stream);
            stream.Close();
        }
Ejemplo n.º 19
0
        public ConversationList(MpqFile file)
        {
            MpqFileStream stream = file.Open();

            this.Header             = new Header(stream);
            stream.Position        += (12);
            ConversationListEntries = stream.ReadSerializedData <ConversationListEntry>();
            stream.Close();
        }
Ejemplo n.º 20
0
        public QuestRange(MpqFile file)
        {
            var stream = file.Open();

            this.Header = new Header(stream);
            this.Start  = new QuestTime(stream);
            this.End    = new QuestTime(stream);
            stream.Close();
        }
Ejemplo n.º 21
0
        public static MpqFile GetInfoFile(this Campaign campaign, Encoding?encoding = null)
        {
            using var memoryStream = new MemoryStream();
            using var writer       = new BinaryWriter(memoryStream, encoding ?? _defaultEncoding, true);

            writer.Write(campaign.Info);
            writer.Flush();

            return(MpqFile.New(memoryStream, CampaignInfo.FileName));
        }
Ejemplo n.º 22
0
        public Encounter(MpqFile file)
        {
            var stream = file.Open();

            this.Header       = new Header(stream);
            this.SNOSpawn     = stream.ReadValueS32();
            stream.Position  += (2 * 4);// pad 2 int
            this.Spawnoptions = stream.ReadSerializedData <EncounterSpawnOptions>();
            stream.Close();
        }
Ejemplo n.º 23
0
        public static MpqFile GetScriptFile(this Map map, Encoding?encoding = null)
        {
            using var memoryStream = new MemoryStream();
            using var writer       = new StreamWriter(memoryStream, encoding ?? _defaultEncoding, leaveOpen: true);

            writer.Write(map.Script);
            writer.Flush();

            return(MpqFile.New(memoryStream, map.Info.ScriptLanguage == ScriptLanguage.Lua ? "war3map.lua" : "war3map.j"));
        }
Ejemplo n.º 24
0
        public static MpqFile GetEnvironmentFile(this Map map, Encoding?encoding = null)
        {
            using var memoryStream = new MemoryStream();
            using var writer       = new BinaryWriter(memoryStream, encoding ?? _defaultEncoding, true);

            writer.Write(map.Environment);
            writer.Flush();

            return(MpqFile.New(memoryStream, MapEnvironment.FileName));
        }
Ejemplo n.º 25
0
        }                                                    // 25 bits - better this this would be an uint

        public Actor(MpqFile file)
        {
            var stream = file.Open();

            Header = new Header(stream);

            this.Int0         = stream.ReadValueS32();
            this.Type         = (ActorType)stream.ReadValueS32();
            this.ApperanceSNO = stream.ReadValueS32();
            this.PhysMeshSNO  = stream.ReadValueS32();
            this.Cylinder     = new AxialCylinder(stream);
            this.Sphere       = new Sphere(stream);
            this.AABBBounds   = new AABB(stream);

            this.TagMap      = stream.ReadSerializedItem <TagMap>();
            stream.Position += (2 * 4);

            this.AnimSetSNO = stream.ReadValueS32();
            this.MonsterSNO = stream.ReadValueS32();

            MsgTriggeredEvents = stream.ReadSerializedData <MsgTriggeredEvent>();

            this.Int1        = stream.ReadValueS32();
            stream.Position += (3 * 4);
            this.V0          = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());

            this.Looks = new WeightedLook[8];
            for (int i = 0; i < 8; i++)
            {
                this.Looks[i] = new WeightedLook(stream);
            }

            this.PhysicsSNO = stream.ReadValueS32();
            this.Int2       = stream.ReadValueS32();
            this.Int3       = stream.ReadValueS32();
            this.Float0     = stream.ReadValueF32();
            this.Float1     = stream.ReadValueF32();
            this.Float2     = stream.ReadValueF32();

            this.ActorCollisionData = new ActorCollisionData(stream);

            this.InventoryImages = new int[10]; //Was 5*8/4 - Darklotus
            for (int i = 0; i < 10; i++)
            {
                this.InventoryImages[i] = stream.ReadValueS32();
            }
            this.Int4        = stream.ReadValueS32();
            stream.Position += 4;
            BitField0        = stream.ReadValueS32();
            CastingNotes     = stream.ReadSerializedString();
            VoiceOverRole    = stream.ReadSerializedString();

            // Updated based on BoyC's 010 template and Moack's work. Think we just about read all data from actor now.- DarkLotus
            stream.Close();
        }
Ejemplo n.º 26
0
 public static byte[] ReadAllBytes(MpqFile file)
 {
     UnityEngine.Profiling.Profiler.BeginSample("Mpq.ReadAllBytes");
     using (var stream = file.Open())
     {
         byte[] bytes = new byte[file.Size];
         stream.Read(bytes, 0, bytes.Length);
         UnityEngine.Profiling.Profiler.EndSample();
         return(bytes);
     }
 }
Ejemplo n.º 27
0
 public void AddAll(string folder)
 {
     if (mpqArchiveBuilder != null)
     {
         foreach ((var fileName, var _, var stream) in EnumerateFiles(folder))
         {
             mpqArchiveBuilder.RemoveFile(fileName);
             mpqArchiveBuilder.AddFile(MpqFile.New(stream, fileName));
         }
     }
 }
Ejemplo n.º 28
0
        public SkillKit(MpqFile file)
        {
            var stream = file.Open();

            this.Header             = new Header(stream);
            stream.Position        += 12;
            this.TraitEntries       = stream.ReadSerializedData <TraitEntry>();
            stream.Position        += 8;
            this.ActiveSkillEntries = stream.ReadSerializedData <ActiveSkillEntry>();
            stream.Close();
        }
Ejemplo n.º 29
0
        public SceneGroup(MpqFile file)
        {
            var stream = file.Open();

            this.Header      = new Header(stream);
            this.I0          = stream.ReadValueS32();
            this.Items       = stream.ReadSerializedData <SceneGroupItem>();
            stream.Position += 8;
            this.I1          = stream.ReadValueS32();
            stream.Close();
        }
Ejemplo n.º 30
0
        public Tutorial(MpqFile file)
        {
            var stream = file.Open();

            this.Header = new Header(stream);
            this.I0     = stream.ReadValueS32();
            this.I1     = stream.ReadValueS32();
            this.Time   = stream.ReadValueS32();
            this.I2     = stream.ReadValueS32();
            this.V0     = new Vector2D(stream);
            stream.Close();
        }
Ejemplo n.º 31
0
        public MpqFileSourceFilter(MpqFile file)
        {
            CopyMediaTypes(detectedMediaType, defaultMediaType);
            name = "Stream Source Filter";
            filterState = FilterState.Stopped;
            var extension = Path.GetExtension(file.Name);
            try
            {
                using (var mediaTypeKey = Registry.ClassesRoot.OpenSubKey(@"Media Type"))
                {
                    if (extension != null && extension.Length > 1)
                        try
                        {
                            using (var extensionsKey = mediaTypeKey.OpenSubKey(@"Extensions"))
                            using (var extensionKey = extensionsKey.OpenSubKey(extension))
                            {
                                var mediaType = new Guid(extensionKey.GetValue("Media Type", MediaType.Stream.ToString()) as string);
                                var subType = new Guid(extensionKey.GetValue("SubType", MediaSubType.None.ToString()) as string);

                                if (mediaType == MediaType.Stream && subType != MediaSubType.None && subType != MediaSubType.Null)
                                {
                                    detectedMediaType.majorType = mediaType;
                                    detectedMediaType.subType = subType;

                                    return;
                                }
                            }
                        }
                        catch (Exception) { }
                    using (var streamMediaKey = mediaTypeKey.OpenSubKey(MediaType.Stream.ToString()))
                        foreach (var subTypeKeyName in streamMediaKey.GetSubKeyNames())
                            try
                            {
                                using (var subTypeKey = streamMediaKey.OpenSubKey(subTypeKeyName))
                                    ;
                            }
                            catch (Exception) { }
                }
            }
            catch (Exception) { }
            finally { outputPin = new StreamOutputPin(this); }
        }