Esempio n. 1
0
        public void Deserialize(YodaReader stream)
        {
            int n;
            stream.ExpectAtCurrentPos("IACT");
            stream.ReadN(4);
            stream.ReadLong(); // length
            n = stream.ReadShort();
            this.Conditions = stream.ReadObjectArray<ScriptCondition>(n);

            n = stream.ReadShort();
            this.Actions = stream.ReadObjectArray<ScriptAction>(n);
        }
Esempio n. 2
0
File: Zone.cs Progetto: a-kr/jsyoda
        public void Deserialize(YodaReader stream)
        {
            this.Magic = stream.ReadLong();
            this.Size = stream.ReadLong();
            this.Pad = stream.ReadShort();

            int n;
            n = stream.ReadShort();
            this.Entries1 = stream.ReadObjectArray<IzaxEntry1>(n);
            n = stream.ReadShort();
            this.Entries2 = stream.ReadObjectArray<IzaxEntry2>(n);
            n = stream.ReadShort();
            this.Entries3 = stream.ReadObjectArray<IzaxEntry3>(n);
        }
Esempio n. 3
0
        public void SetThings(YodaReader yodesk_reader, int[] zoneOffsets)
        {
            this.yodesk = yodesk_reader;
            this.zoneOffsets = zoneOffsets;

            Func<int, byte[]> attrs = delegate(int i)
            {
                byte[] header = new byte[20];
                yodesk.Seek(zoneOffsets[i], 0);
                yodesk.Read(header, 0, 20);

                //return header[12].ToString("X02") + " " + header[18].ToString("X02");
                return new byte[] { header[12], header[18] };
            };

            var zone_list = Enumerable.Range(0, zoneOffsets.Length)
                .Select(i => new
                {
                    index = i,
                    attr = attrs(i)
                })
                .Select(o => new ZoneListEntry
                {
                    index = o.index,
                    offset = zoneOffsets[o.index],
                    planet = o.attr[1],
                    type = o.attr[0]
                })
                ;//.OrderBy(o => o.type).OrderBy(o => o.planet);

            ZonesForm.entries = zone_list.ToArray();

            cbZoneTypeFilter.Items.Clear();
            cbZoneTypeFilter.Items.AddRange(Zone.ZONE_TYPE);

            lbZoneIndex.Items.Clear();
            lbZoneIndex.Items.AddRange(ZonesForm.entries);
        }
Esempio n. 4
0
        public void Deserialize(YodaReader stream)
        {
            this.Id = stream.ReadShort();
            stream.ExpectAtCurrentPos("IPUZ");
            stream.ReadLong(); // skip IPUZ
            this.ByteLength = stream.ReadLong();
            var endPosition = stream.S.Position + this.ByteLength;
            this.TailSize = 8;// GetTailSize(this.Id);

            var tailPosition = endPosition - this.TailSize;
            this.PuzzleType = stream.ReadUnsignedLong();
            this.Head2_u32 = stream.ReadUnsignedLong();
            this.Head3_u32 = stream.ReadUnsignedLong();
            this.Head4_u16 = stream.ReadShort();
            var strings = new List<string>();
            while (stream.S.Position < tailPosition)
            {
                strings.Add(stream.ReadLengthPrefixedString().Replace("\r", "\\r").Replace("\n", "\\n").Replace(";", ","));
            }
            this.Strings = strings.ToArray();

            this.Tail1_u16 = stream.ReadShort();
            this.Tail2_u16 = stream.ReadShort();
            this.RewardItem = stream.ReadShort();
            if (this.TailSize > 6)
            {
                this.Tail3_u16 = stream.ReadShort();
            }

            if (stream.S.Position != endPosition)
            {
                this.SizeError = (int)(stream.S.Position - endPosition);
                stream.S.Seek(endPosition, System.IO.SeekOrigin.Begin);
                //throw new Exception(string.Format("Expected to end at {0}, actual position is {1}", endPosition, stream.S.Position));
            }
        }
Esempio n. 5
0
        public ItemCollection(YodaReader stream)
        {
            stream.Seek(TNAM_OFFSET, SeekOrigin.Begin);
            Items = new GameItem[ITEM_COUNT];

            stream.Seek(4, SeekOrigin.Current); // skip "TNAM"
            stream.Seek(4, SeekOrigin.Current); // skip 4-byte header
            for (int i = 0; i < ITEM_COUNT; i++)
            {
                byte[] buf = new byte[26];
                stream.Read(buf, 0, 26);
                Items[i].Index = i;
                Items[i].Sprite = buf[0] + buf[1] * 0x100;
                /*StringBuilder builder = new StringBuilder();
                for (int k = 2; k < 26; k++)
                {
                    if (buf[k] == 0)
                        break;
                    builder.Append((char)buf[k]);
                }*/
                Items[i].Name = Encoding.ASCII.GetString(buf, 2, 24);
                Items[i].Name = Items[i].Name.Substring(0, Items[i].Name.IndexOf('\0'));
            }
        }
Esempio n. 6
0
File: Zone.cs Progetto: a-kr/jsyoda
 private void ReadObjectInfo(YodaReader s)
 {
     var n = s.ReadShort();
     this.ObjectInfos = new ZoneObjectInfo[n];
     for (var i = 0; i < n; i++)
     {
         var obj = new ZoneObjectInfo();
         obj.Type = s.ReadLong();
         obj.X = s.ReadShort();
         obj.Y = s.ReadShort();
         obj.Unk1 = s.ReadShort();
         obj.Arg = s.ReadShort();
         this.ObjectInfos[i] = obj;
     }
 }
Esempio n. 7
0
File: Zone.cs Progetto: a-kr/jsyoda
 private void ReadIzax(YodaReader stream)
 {
     this.IZAX = new Izax();
     this.IZAX.Deserialize(stream);
 }
Esempio n. 8
0
File: Zone.cs Progetto: a-kr/jsyoda
 private void ReadIzaStuff(YodaReader stream)
 {
     //stream.ReadUntil("IZAX");
     stream.ExpectAtCurrentPos("IZAX");
     this.ReadIzax(stream);
     stream.ExpectAtCurrentPos("IZX2");
     //IZAXTail = stream.ReadUntil("IZX2").Bytes;
     IZX2 = stream.ReadUntil("IZX3").Bytes;
     IZX3 = stream.ReadUntil("IZX4").Bytes;
     IZX4 = stream.ReadUntil("IACT", "IZON", "PUZ2").Bytes;
 }
Esempio n. 9
0
File: Zone.cs Progetto: a-kr/jsyoda
        private void ReadIacts(YodaReader stream)
        {
            List<Iact> iacts = new List<Iact>();

            while (stream.CurrentPosContains("IACT")) {
                var iact = new Iact();
                iact.Deserialize(stream);
                iacts.Add(iact);
            }

            this.Iacts = iacts.ToArray();

            // TODO read PUZ2, IPUZ
        }
Esempio n. 10
0
File: Zone.cs Progetto: a-kr/jsyoda
        private void ReadHeader(YodaReader stream)
        {
            byte[] header = new byte[20];
            Header = header;
            stream.Read(header, 0, 20);

            Width = header[8];
            Height = header[10];

            this.Planet = header[18] >= PLANET.Length ? "UNK" : PLANET[header[18]];
            this.ZoneType = header[12] >= ZONE_TYPE.Length ? "UNK" : ZONE_TYPE[header[12]];
        }
Esempio n. 11
0
File: Zone.cs Progetto: a-kr/jsyoda
 /// <summary>
 /// assuming that Stream is at the beginning of "IZON" string
 /// </summary>
 /// <param name="stream"></param>
 public Zone(YodaReader stream)
 {
     this.ReadHeader(stream);
     this.ReadCells(stream);
     this.ReadObjectInfo(stream);
     this.ReadIzaStuff(stream);
     this.ReadIacts(stream);
 }
Esempio n. 12
0
File: Zone.cs Progetto: a-kr/jsyoda
 public void Deserialize(YodaReader stream)
 {
     this.Item = stream.ReadShort();
 }
Esempio n. 13
0
        public void Deserialize(YodaReader stream)
        {
            var puzzles = new List<Ipuz>();

            stream.Seek(0x457048, System.IO.SeekOrigin.Begin);

            stream.ExpectAtCurrentPos("PUZ2");
            stream.ReadLong(); // PUZ2
            stream.ReadLong(); // skip length
            while (stream.CurrentPosContainsAtOffset("IPUZ", 2))
            {
                var ipuz = new Ipuz();
                ipuz.Deserialize(stream);
                puzzles.Add(ipuz);
            }

            this.Puzzles = puzzles.ToArray();
        }
Esempio n. 14
0
        public void Deserialize(YodaReader stream)
        {
            this.Code = stream.ReadShort();
            this.Arg1 = stream.ReadShort();
            this.Arg2 = stream.ReadShort();
            this.Arg3 = stream.ReadShort();
            this.Arg4 = stream.ReadShort();
            this.Arg5 = stream.ReadShort();

            this.Str = stream.ReadLengthPrefixedString();
        }
Esempio n. 15
0
File: Zone.cs Progetto: a-kr/jsyoda
 public void Deserialize(YodaReader stream)
 {
     this.EntityId = stream.ReadShort();
     this.X = stream.ReadShort();
     this.Y = stream.ReadShort();
     this.Item = stream.ReadShort();
     this.NumItems = stream.ReadShort();
     this.Unk3 = stream.ReadShort();
     this.UnkTail = stream.ReadN(2 * 0x10);
 }
Esempio n. 16
0
File: Zone.cs Progetto: a-kr/jsyoda
        private void ReadCells(YodaReader stream)
        {
            Cells = new Cell[Width, Height];

            byte[] buf = new Byte[6];

            for (int i = 0; i < Width; i++)
            {
                for (int j = 0; j < Height; j++)
                {
                    Cells[i, j].Bytes = new byte[6];
                    stream.Read(Cells[i, j].Bytes, 0, 6);
                }
            }
        }
Esempio n. 17
0
 public void Deserialize(YodaReader stream)
 {
     this.Code = stream.ReadShort();
     this.Arg1 = stream.ReadShort();
     this.Arg2 = stream.ReadShort();
     this.Arg3 = stream.ReadShort();
     this.Arg4 = stream.ReadShort();
     this.Arg5 = stream.ReadShort();
     this.Arg6 = stream.ReadShort();
 }