Ejemplo n.º 1
0
 public void Read(MpqFileStream stream)
 {
     this.Name        = stream.ReadString(128, true);
     CommandType      = stream.ReadValueS32();
     this.TagMap      = stream.ReadSerializedItem <TagMap>();
     stream.Position += (3 * 4);
 }
Ejemplo n.º 2
0
 public void Read(MpqFileStream stream)
 {
     this.DRLGParams      = stream.ReadSerializedData <DRLGParams>();
     stream.Position     += 8;
     this.SceneParams     = stream.ReadSerializedItem <SceneParams>();
     stream.Position     += 8;
     LabelRuleSet         = new LabelRuleSet(stream);
     this.Int1            = stream.ReadValueS32();
     this.SceneClusterSet = new SceneClusterSet(stream);
     for (int i = 0; i < SNONavMeshFunctions.Length; i++)
     {
         SNONavMeshFunctions[i] = stream.ReadValueS32();
     }
     SNOScript = stream.ReadValueS32();
     Int2      = stream.ReadValueS32();
 }
Ejemplo n.º 3
0
 public MonsterSkillDeclaration(MpqFileStream stream)
 {
     F0 = stream.ReadValueF32();
     F1 = stream.ReadValueF32();
     I0 = stream.ReadValueS32();
     F2 = stream.ReadValueF32();
 }
Ejemplo n.º 4
0
 public void Read(MpqFileStream stream)
 {
     this.F0          = stream.ReadValueF32();
     this.I1          = stream.ReadValueS32();
     stream.Position += 8;
     SpawnItems       = stream.ReadSerializedData <MonsterMinionSpawnItem>();
 }
Ejemplo n.º 5
0
 public MonsterDef(MpqFileStream stream)
 {
     F0 = stream.ReadValueF32();
     F1 = stream.ReadValueF32();
     F2 = stream.ReadValueF32();
     F3 = stream.ReadValueF32();
     I0 = stream.ReadValueS32();
 }
Ejemplo n.º 6
0
        public void Read(MpqFileStream stream)
        {
            var pointer = stream.GetSerializedDataPointer();

            this.ChunkCount  = stream.ReadValueS32();
            stream.Position += (3 * 4);
            this.SceneChunks = stream.ReadSerializedData <SceneChunk>(pointer, this.ChunkCount);
        }
Ejemplo n.º 7
0
        public void Read(MpqFileStream stream)
        {
            FollowUpStepID = stream.ReadValueS32();

            stream.Position += 4;
            stream.Position += 8;
            StepObjectives   = stream.ReadSerializedData <QuestStepObjective>();
        }
Ejemplo n.º 8
0
 public void Read(MpqFileStream stream)
 {
     this.Min            = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());
     this.Max            = new Vector3D(stream.ReadValueF32(), stream.ReadValueF32(), stream.ReadValueF32());
     this.Flags          = (NavCellFlags)stream.ReadValueS16();
     this.NeighbourCount = stream.ReadValueS16();
     this.NeighborsIndex = stream.ReadValueS32();
 }
Ejemplo n.º 9
0
        public TagMapEntry(MpqFileStream stream)
        {
            this.Type  = stream.ReadValueS32();
            this.TagID = stream.ReadValueS32();

            switch (this.Type)
            {
            case 0:
                this.Int = stream.ReadValueS32();
                break;

            case 1:
                Float = stream.ReadValueF32();
                break;

            case 2:     // SNO
                this.Int = stream.ReadValueS32();
                break;

            // TODO: Create strong type for gbid (at least i think they are)
            case 3:
                this.Int = stream.ReadValueS32();
                break;

            case 4:
                this.ScriptFormula = new ScriptFormula(stream);
                break;

            // TODO: Strong type for group hashes
            case 5:
                this.Int = stream.ReadValueS32();
                break;

            // Todo: Strong type for ... hmmm.. is that a gameattributeindex?
            case 6:
                this.Int = stream.ReadValueS32();
                break;

            // Todo: Strong type fo StartingLocationID
            case 7:
                this.Int = stream.ReadValueS32();
                break;

            default:
                // if this break hits, blizz introduced a new key type and most likey we should have to react to it
                System.Diagnostics.Debugger.Break();
                this.Int = stream.ReadValueS32();
                break;
            }
        }
Ejemplo n.º 10
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.º 11
0
        public void Read(MpqFileStream stream)
        {
            this.ActorGroups = new Dictionary <int, FileFormats.ActorGroup>();
            foreach (var group in stream.ReadSerializedData <ActorGroup>()) //166
            {
                this.ActorGroups.Add(group.UHash, group);
            }

            stream.Position      += 8;
            this.ScriptGlobalVars = stream.ReadSerializedData <GlobalScriptVariable>();
            stream.Position      += 8;
            this.TuningParams     = new DifficultyTuningParams[4];
            for (int i = 0; i < 4; i++)
            {
                this.TuningParams[i] = new DifficultyTuningParams(stream);
            }
            this.F0          = stream.ReadValueF32();
            this.F1          = stream.ReadValueF32();
            this.F2          = stream.ReadValueF32();
            this.F3          = stream.ReadValueF32();
            this.F4          = stream.ReadValueF32();
            this.I0          = stream.ReadValueS32();
            this.I1          = stream.ReadValueS32();
            this.F5          = stream.ReadValueF32();
            this.F6          = stream.ReadValueF32();
            this.F7          = stream.ReadValueF32();
            this.F8          = stream.ReadValueF32();
            this.I2          = stream.ReadValueS32();
            this.I3          = stream.ReadValueS32();
            this.I4          = stream.ReadValueS32();
            this.F9          = stream.ReadValueF32();
            this.F10         = stream.ReadValueF32();
            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();
            this.F19         = stream.ReadValueF32();
            this.F20         = stream.ReadValueF32();
            this.F21         = stream.ReadValueF32();
            stream.Position += 4;
        }
Ejemplo n.º 12
0
        public void Read(MpqFileStream stream)
        {
            this.Name        = stream.ReadString(128, true);
            this.Type        = (MarkerType)stream.ReadValueS32();
            this.PRTransform = new PRTransform(stream);
            this.SNOHandle   = new SNOHandle(stream);

            this.TagMap = stream.ReadSerializedItem <TagMap>();

            // Un sure about these 3 ints, 010template isnt the same as snodata.xml - DarkLotus
            // IntTagMap && Int2 are always 0 for beta. leave it here only because xml does not match either -farmy
            this.IntTagMap = stream.ReadValueS32();
            Int1           = stream.ReadValueS32();
            var int2 = stream.ReadValueS32();

            this.MarkerLinks = stream.ReadSerializedData <MarkerLink>();
            stream.Position += (3 * 4);
        }
Ejemplo n.º 13
0
 public void Read(MpqFileStream stream)
 {
     I0 = stream.ReadValueS32();
     I1 = stream.ReadValueS16();
     I2 = stream.ReadValueS16();
     B1 = stream.ReadValueS8();
     B2 = stream.ReadValueS8();
     stream.Position += 2;
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Reads a serialized byte array
        /// </summary>
        /// <param name="stream">The MPQFileStream to read from.</param>
        /// <returns>The serialized byte array</returns>
        public static byte[] ReadSerializedByteArray(this MpqFileStream stream)
        {
            int offset = stream.ReadValueS32(); // ofset for serialized data.
            int size   = stream.ReadValueS32(); // size of serialized data.

            byte[] buffer = new byte[size];
            if (size <= 0)
            {
                return(buffer);
            }

            var oldPos = stream.Position;

            stream.Position = offset + 16; // offset is relative to actual sno data start, so add that 16 bytes file header to get actual position. /raist
            stream.Read(buffer, 0, size);
            stream.Position = oldPos;
            return(buffer);
        }
Ejemplo n.º 15
0
        public QuestUnassignedStep(MpqFileStream stream)
        {
            ID = stream.ReadValueS32();
            stream.Position  += 4;      // unaccounted in xml
            stream.Position  += (2 * 4);
            StepObjectiveSets = stream.ReadSerializedData <QuestStepObjectiveSet>();

            stream.Position         += (2 * 4);
            StepFailureConditionSets = stream.ReadSerializedData <QuestStepFailureConditionSet>();
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Reads a single serialized item for given type. Warning: Use with caution.
        /// </summary>
        /// <typeparam name="T">Item type to read.</typeparam>
        /// <param name="stream">The MPQFileStream to read from.</param>
        /// <returns>The read item.</returns>
        public static T ReadSerializedItem <T>(this MpqFileStream stream) where T : ISerializableData, new()
        {
            int offset = stream.ReadValueS32(); // ofset for serialized data.
            int size   = stream.ReadValueS32(); // size of serialized data.

            var t = new T();

            if (size <= 0)
            {
                return(t);
            }

            var oldPos = stream.Position;

            stream.Position = offset + 16; // offset is relative to actual sno data start, so add that 16 bytes file header to get actual position. /raist
            t.Read(stream);
            stream.Position = oldPos;
            return(t);
        }
Ejemplo n.º 17
0
 public void Read(MpqFileStream stream)
 {
     this.I0 = stream.ReadValueS32();
     this.SNOSubTreasureClass = stream.ReadValueS32();
     this.Percentage          = stream.ReadValueF32();
     this.I1 = stream.ReadValueS32();
     this.GBIdQualityClass = stream.ReadValueS32();
     this.I2            = stream.ReadValueS32();
     this.I3            = stream.ReadValueS32();
     this.SNOCondition  = stream.ReadValueS32();
     this.ItemSpecifier = new ItemSpecifierData(stream);
     this.I5            = stream.ReadValueS32();
     this.I4            = new int[4];
     for (int i = 0; i < 4; i++)
     {
         this.I4[i] = stream.ReadValueS32();
     }
     this.I6 = stream.ReadValueS32();
 }
Ejemplo n.º 18
0
 public void Read(MpqFileStream stream)
 {
     I0             = stream.ReadValueS32();
     ObjectiveType  = (QuestStepObjectiveType)stream.ReadValueS32();
     I2             = stream.ReadValueS32();
     CounterTarget  = stream.ReadValueS32();
     SNOName1       = new SNOHandle(stream);
     SNOName2       = new SNOHandle(stream);
     GBID1          = stream.ReadValueS32();
     GBID2          = stream.ReadValueS32();
     Group1Name     = stream.ReadString(256, true);
     Unknown2       = stream.ReadString(256, true);
     I4             = stream.ReadValueS32();
     I5             = stream.ReadValueS32();
     GBIDItemToShow = stream.ReadValueS32();
 }
Ejemplo n.º 19
0
 public void Read(MpqFileStream stream)
 {
     this.Color = new RGBAColor[2];
     for (int i = 0; i < 2; i++)
     {
         this.Color[i] = new RGBAColor(stream);
     }
     this.String1 = stream.ReadString(64, true);
     this.I0      = stream.ReadValueS32();
     this.S0      = stream.ReadString(64, true);
 }
Ejemplo n.º 20
0
 public TriggerConditions(MpqFileStream stream)
 {
     Percent          = stream.ReadByte();
     stream.Position += 3;
     Int1             = stream.ReadValueS32();
     Int2             = stream.ReadValueS32();
     Int3             = stream.ReadValueS32();
     Int4             = stream.ReadValueS32();
     Int5             = stream.ReadValueS32();
     Int6             = stream.ReadValueS32();
     Int7             = stream.ReadValueS32();
     Int8             = stream.ReadValueS32();
 }
Ejemplo n.º 21
0
            public NavMeshDef(MpqFileStream stream)
            {
                this.SquaresCountX      = stream.ReadValueS32();
                this.SquaresCountY      = stream.ReadValueS32();
                this.Int0               = stream.ReadValueS32();
                this.NavMeshSquareCount = stream.ReadValueS32();
                this.Float0             = stream.ReadValueF32();
                this.Squares            = stream.ReadSerializedData <NavMeshSquare>();

                if (SquaresCountX <= 64 && SquaresCountY <= 64)
                {
                    WalkGrid = new byte[64, 64];
                }
                else if (SquaresCountX <= 128 && SquaresCountY <= 128)
                {
                    WalkGrid = new byte[128, 128]; //96*96
                }
                else if (SquaresCountX <= 256 && SquaresCountY <= 256)
                {
                    WalkGrid = new byte[256, 256];
                }
                else if (SquaresCountX <= 384 && SquaresCountY <= 384)
                {
                    WalkGrid = new byte[384, 384];
                }
                else if (SquaresCountX > 384 || SquaresCountY > 384)
                {
                    WalkGrid = new byte[512, 512];
                }


                // Loop thru each NavmeshSquare in the array, and fills the grid
                for (int i = 0; i < NavMeshSquareCount; i++)
                {
                    WalkGrid[i % SquaresCountX, i / SquaresCountY] = (byte)(Squares[i].Flags & Scene.NavCellFlags.AllowWalk);
                    // Set the grid to 0x1 if its walkable, left as 0 if not. - DarkLotus
                }

                stream.Position += (3 * 4);
                this.Filename    = stream.ReadString(256, true);
            }
Ejemplo n.º 22
0
        /// <summary>
        /// Reads a serialized string.
        /// </summary>
        /// <param name="stream">The MPQFileStream to read from.</param>
        /// <returns>Read string.</returns>
        public static string ReadSerializedString(this MpqFileStream stream)
        {
            int offset = stream.ReadValueS32(); // ofset for serialized data.
            int size   = stream.ReadValueS32(); // size of serialized data.

            var @string = string.Empty;

            if (size <= 0)
            {
                return(@string);
            }

            var oldPos = stream.Position;

            stream.Position = offset + 16; // offset is relative to actual sno data start, so add that 16 bytes file header to get actual position. /raist

            @string         = stream.ReadString((uint)size, true);
            stream.Position = oldPos;

            return(@string);
        }
Ejemplo n.º 23
0
 public WaypointInfo(MpqFileStream stream)
 {
     SNOWorld      = stream.ReadValueS32();
     SNOLevelArea  = stream.ReadValueS32();
     I0            = stream.ReadValueS32();
     I1            = stream.ReadValueS32();
     I2            = stream.ReadValueS32();
     SNOQuestRange = stream.ReadValueS32();
     I3            = stream.ReadValueS32();
 }
Ejemplo n.º 24
0
 public Header(MpqFileStream stream)
 {
     this.DeadBeef = stream.ReadValueS32();
     this.SnoType  = stream.ReadValueS32();
     this.Unknown1 = stream.ReadValueS32();
     this.Unknown2 = stream.ReadValueS32();
     this.SNOId    = stream.ReadValueS32();
     this.Unknown3 = stream.ReadValueS32();
     this.Unknown4 = stream.ReadValueS32();
 }
Ejemplo n.º 25
0
 public void Read(MpqFileStream stream)
 {
     VerticeOneIndex   = stream.ReadValueS32();
     VerticeTwoIndex   = stream.ReadValueS32();
     VerticeThreeIndex = stream.ReadValueS32();
     I3 = stream.ReadValueS32();
     I4 = stream.ReadValueS32();
     I5 = stream.ReadValueS32();
     I6 = (short)stream.ReadValueS32(); // i6 is a word, but struct is 28 bytes - DarkLotus
     //<Field Type="DT_WORD#30" Offset="24" Flags="1" EncodedBits="16" />
     //<Field Offset="28" Flags="0" />
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Reads all available items for given type.
        /// </summary>
        /// <typeparam name="T">Item type to read.</typeparam>
        /// <param name="stream">The MPQFileStream to read from.</param>
        /// <returns>List of items.</returns>
        public static List <T> ReadSerializedData <T>(this MpqFileStream stream) where T : ISerializableData, new()
        {
            int offset = stream.ReadValueS32(); // ofset for serialized data.
            int size   = stream.ReadValueS32(); // size of serialized data.

            if (offset == 0 && size != 0)
            {
                logger.Error("Pointer error while deserializing list of {0}. Make sure you dont read too much or too few fields!", typeof(T).Name);
            }

            var items = new List <T>(); // read-items if any.

            if (size <= 0 || offset == 0)
            {
                return(items);
            }

            var oldPos = stream.Position;

            stream.Position = offset + 16; // offset is relative to actual sno data start, so add that 16 bytes file header to get actual position. /raist

            while (stream.Position < offset + size + 16)
            {
                var t = new T();
                t.Read(stream);
                items.Add(t);
            }

            if (stream.Position != offset + size + 16)
            {
                logger.Error("Size mismatch while deserializing list of {0}. Make sure you dont read too much or too few fields!", typeof(T).Name);
            }

            stream.Position = oldPos;
            return(items);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Reads all available serialized shorts.
        /// </summary>
        /// <param name="stream">The MPQFileStream to read from.</param>
        /// <returns>The list of read shorts.</returns>
        public static List <short> ReadSerializedShorts(this MpqFileStream stream)
        {
            int offset = stream.ReadValueS32(); // ofset for serialized data.
            int size   = stream.ReadValueS32(); // size of serialized data.

            var items = new List <short>();     // read-items if any.

            if (size <= 0)
            {
                return(items);
            }

            var oldPos = stream.Position;

            stream.Position = offset + 16; // offset is relative to actual sno data start, so add that 16 bytes file header to get actual position. /raist

            while (stream.Position < offset + size + 16)
            {
                items.Add(stream.ReadValueS16());
            }

            stream.Position = oldPos;
            return(items);
        }
Ejemplo n.º 28
0
        public void Read(MpqFileStream stream)
        {
            Tiles = stream.ReadSerializedData <TileInfo>();

            stream.Position  += (14 * 4);
            this.CommandCount = stream.ReadValueS32();
            this.Commands     = stream.ReadSerializedData <DRLGCommand>();

            stream.Position   += (3 * 4);
            this.ParentIndices = stream.ReadSerializedInts();

            stream.Position += (2 * 4);
            this.TagMap      = stream.ReadSerializedItem <TagMap>();
            stream.Position += (2 * 4);
        }
Ejemplo n.º 29
0
        public void Read(MpqFileStream stream)
        {
            var pointer = stream.GetSerializedDataPointer();

            this.DRLGTiles = stream.ReadSerializedData <TileInfo>(pointer, pointer.Size / 72);

            stream.Position  += (14 * 4);
            this.CommandCount = stream.ReadValueS32();
            this.DRLGCommands = stream.ReadSerializedData <DRLGCommand>(this.CommandCount);

            stream.Position   += (3 * 4);
            this.ParentIndices = stream.ReadSerializedInts();

            stream.Position += (2 * 4);
            this.DRLGTagMap  = stream.ReadSerializedItem <TagMap>();
        }
Ejemplo n.º 30
0
 public void Read(MpqFileStream stream)
 {
     this.I0                    = stream.ReadValueS32();
     this.AnimName              = stream.ReadString(65, true);
     stream.Position           += 3;
     this.Velocity              = stream.ReadValueF32();
     this.F0                    = stream.ReadValueF32();
     this.F1                    = stream.ReadValueF32();
     this.F2                    = stream.ReadValueF32();
     this.F3                    = stream.ReadValueF32();
     this.Time1                 = stream.ReadValueS32();
     this.Time2                 = stream.ReadValueS32();
     this.I1                    = stream.ReadValueS32();
     this.F4                    = stream.ReadValueF32();
     this.F5                    = stream.ReadValueF32();
     this.F6                    = stream.ReadValueF32();
     this.F7                    = stream.ReadValueF32();
     this.BoneNameCount         = stream.ReadValueS32();
     this.BoneNames             = stream.ReadSerializedData <BoneName>();
     stream.Position           += 12;
     this.KeyframePosCount      = stream.ReadValueS32();
     this.TranslationCurves     = stream.ReadSerializedData <TranslationCurve>();
     stream.Position           += 12;
     this.RotationCurves        = stream.ReadSerializedData <RotationCurve>();
     stream.Position           += 8;
     this.ScaleCurves           = stream.ReadSerializedData <ScaleCurve>();
     stream.Position           += 8;
     this.F8                    = stream.ReadValueF32();
     this.F9                    = stream.ReadValueF32();
     this.F10                   = stream.ReadValueF32();
     this.F11                   = stream.ReadValueF32();
     this.V0                    = new Vector3D(stream);
     this.V1                    = new Vector3D(stream);
     this.V2                    = new Vector3D(stream);
     this.V3                    = new Vector3D(stream);
     this.F12                   = stream.ReadValueF32();
     this.KeyedAttachments      = stream.ReadSerializedData <KeyframedAttachment>();
     this.KeyedAttachmentsCount = stream.ReadValueS32();
     stream.Position           += 8;
     this.KeyframePosList       = stream.ReadSerializedData <Vector3D>();
     stream.Position           += 8;
     this.NonlinearOffset       = stream.ReadSerializedData <Vector3D>();
     stream.Position           += 8;
     this.Velocity3D            = new VelocityVector3D(stream);
     this.Link                  = new HardPointLink(stream);
     this.S0                    = stream.ReadString(256, true);
     this.S1                    = stream.ReadString(256, true);
     stream.Position           += 8;
 }