示例#1
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);
        }
示例#2
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 += (2 * 4);
            SerializableDataPointer compiledScriptPointer = stream.GetSerializedDataPointer();

            stream.Position      += 44; // these bytes are unaccounted for in the xml
            this.SNOBossEncounter = stream.ReadValueS32();

            // reading compiled script, placed it here so i dont have to move the offset around
            CompiledScript  = new byte[compiledScriptPointer.Size];
            stream.Position = compiledScriptPointer.Offset + 16;
            stream.Read(CompiledScript, 0, compiledScriptPointer.Size);

            stream.Close();
        }