Пример #1
0
        public object Deserialize()
        {
            byte[] b = new byte[4];
            stream.Read(b, 0, b.Length);

            pack = new ByteArray(b);
            uint pos = pack.GetDWord();

            stream.Seek(pos, SeekOrigin.Begin);
            b = new byte[stream.Length - pos];
            stream.Read(b, 0, b.Length);
            pack = new ByteArray(b);

            codes.Clear();
            ArrayList n = Get() as ArrayList;

            for (int i = 0; i < n.Count; i++)
            {
                codes.Add((uint)i, n[i]);
            }

            stream.Seek(4, SeekOrigin.Begin);
            b = new byte[pos - 4];
            stream.Read(b, 0, b.Length);
            pack = new ByteArray(b);

            return(Get());
        }
Пример #2
0
        protected override bool Create(Character c, Hashtable data, ByteArrayBase moredata)
        {
            if (!base.Create(c, data, moredata))
            {
                return(false);
            }

            items = new Item[(int)data["containerslots"]];
            SetUpdateValue(UpdateFields.CONTAINER_FIELD_NUM_SLOTS, (uint)items.Length);

            while (moredata != null)
            {
                SlotID slot = (SlotID)moredata.GetByte();
                if (slot == SlotID.CHARACTER)
                {
                    break;
                }
                uint   e   = moredata.GetDWord();
                ushort len = moredata.GetWord();
                Item   n   = new Item(gameServer);
                n = n.Create(c, e, new ByteArray(moredata.GetArray(len)));
                if (n != null)
                {
                    n.SetUpdateValue(UpdateFields.ITEM_FIELD_CONTAINED, GUID);
                    //n.SetUpdateValue(UpdateFields.ITEM_FIELD_CONTAINED_01, GUID);
                    SetItem(slot, n);
                }
            }
            return(true);
        }
Пример #3
0
        public object Get()
        {
            byte type = pack.GetByte();

            switch (type)
            {
            case 0:
            {
                int n = (int)pack.GetDWord();
                return(n);
            }

            case 1:
            {
                uint  cnt = pack.GetDWord();
                int[] n   = new int[cnt];
                for (uint i = 0; i < cnt; i++)
                {
                    n[i] = (int)pack.GetDWord();
                }
                return(n);
            }

            case 2:
            {
                float n = pack.GetFloat();
                return(n);
            }

            case 3:
            {
                uint    cnt = pack.GetDWord();
                float[] n   = new float[cnt];
                for (uint i = 0; i < cnt; i++)
                {
                    n[i] = pack.GetFloat();
                }
                return(n);
            }

            case 4:
            {
                return(pack.GetString());
            }

            case 5:
            {
                uint c = pack.GetDWord();
                return(codes[c]);
            }

            case 6:
            {
                uint cnt = pack.GetDWord();
                return(pack.GetArray((int)cnt));
            }

            case 10:
            {
                uint cnt = pack.GetDWord();

                ArrayList n = new ArrayList();
                while (cnt > 0)
                {
                    n.Add(Get());
                    cnt--;
                }
                return(n);
            }

            case 11:
            {
                uint cnt = pack.GetDWord();

                Hashtable n = new Hashtable();
                while (cnt > 0)
                {
                    object ob = Get();
                    n[ob] = Get();
                    cnt--;
                }
                return(n);
            }

            case 12:                     // SpawnData
            {
                return(new SpawnData(this));
            }

            case 13:                     // MapPosition
            {
                return(new MapPosition(this));
            }
            }
            return(null);
        }