Пример #1
0
        public override bool ParseMessage(NetworkMessage msg, PacketDestination destination)
        {
            if (msg.GetByte() != (byte)IncomingPacketType.TileAddThing)
                return false;

            Destination = destination;
            Type = IncomingPacketType.TileAddThing;

            Location = msg.GetLocation();
            Stack = msg.GetByte();
            ThingId = msg.GetUInt16();

            if (ThingId == 0x0061 || ThingId == 0x0062)
            {
                Creature = new PacketCreature(Client);

                if (ThingId == 0x0062)
                {
                    Creature.Type = PacketCreatureType.Known;
                    Creature.Id = msg.GetUInt32();
                }
                else if (ThingId == 0x0061)
                {
                    Creature.Type = PacketCreatureType.Unknown;
                    Creature.RemoveId = msg.GetUInt32();
                    Creature.Id = msg.GetUInt32();
                    Creature.Name = msg.GetString();
                }

                Creature.Health = msg.GetByte();
                Creature.Direction = msg.GetByte();

                Creature.Outfit = msg.GetOutfit();

                Creature.LightLevel = msg.GetByte();
                Creature.LightColor = msg.GetByte();

                Creature.Speed = msg.GetUInt16();
                Creature.Skull = (Constants.Skull)msg.GetByte();
                Creature.PartyShield = (PartyShield)msg.GetByte();
            }
            else if (ThingId == 0x0063)
            {
                Creature = new PacketCreature(Client);
                Creature.Type = PacketCreatureType.Turn;
                Creature.Id = msg.GetUInt32();
                Creature.Direction = msg.GetByte();
            }
            else
            {
                Item = new Pokemon.Objects.Item(Client, ThingId);
                Item.Location = Pokemon.Objects.ItemLocation.FromLocation(Location);

                if (Item.HasExtraByte)
                    Item.Count = msg.GetByte();
            }

            return true;
        }
Пример #2
0
        protected bool ParseThing(NetworkMessage msg, Location pos, Tile tile, int n, NetworkMessage outMsg)
        {
            //get thing type
            ushort thingId = msg.GetUInt16();
            outMsg.AddUInt16(thingId);

            PacketCreature c;

            if (thingId == 0x0061 || thingId == 0x0062)
            {

                c = new PacketCreature(Client);
                c.Location = pos;

                //creatures
                if (thingId == 0x0062) //creature is known
                {
                    c.Type = PacketCreatureType.Known;
                    c.Id = msg.GetUInt32();
                    outMsg.AddUInt32(c.Id); //creatureid
                }
                else if (thingId == 0x0061)
                { //creature is not known
                    //perhaps we have to remove a known creature
                    c.RemoveId = msg.GetUInt32();
                    outMsg.AddUInt32(c.RemoveId);

                    //add a new creature
                    c.Type = PacketCreatureType.Unknown;
                    c.Id = msg.GetUInt32();
                    outMsg.AddUInt32(c.Id);

                    c.Name = msg.GetString();
                    outMsg.AddString(c.Name);
                }

                //read creature properties
                c.Health = msg.GetByte();
                outMsg.AddByte(c.Health);

                c.Direction = msg.GetByte();
                outMsg.AddByte(c.Direction);

                c.Outfit = msg.GetOutfit();
                outMsg.AddOutfit(c.Outfit);

                c.LightLevel = msg.GetByte();
                outMsg.AddByte(c.LightLevel);

                c.LightColor = msg.GetByte();
                outMsg.AddByte(c.LightColor);

                c.Speed = msg.GetUInt16();
                outMsg.AddUInt16(c.Speed);

                c.Skull = (Constants.Skull)msg.GetByte();
                outMsg.AddByte((byte)c.Skull);

                c.PartyShield = (Constants.PartyShield)msg.GetByte();
                outMsg.AddByte((byte)c.PartyShield);

                creatures.Add(c);

                return true;
            }
            else if (thingId == 0x0063)
            {
                //creature turn
                c = new PacketCreature(Client);
                c.Location = pos;
                c.Type = PacketCreatureType.Turn;
                c.Id = msg.GetUInt32();
                outMsg.AddUInt32(c.Id);

                c.Direction = msg.GetByte();
                outMsg.AddByte(c.Direction);

                creatures.Add(c);

                return true;
            }
            else
            {
                //item
                UInt16 itemId;
                if (thingId == UInt16.MaxValue)
                {
                    itemId = msg.GetUInt16();
                    outMsg.AddUInt16(itemId);
                }
                else
                    itemId = thingId;

                Item item = new Item(Client, itemId, 0, "", ItemLocation.FromLocation(pos, (byte)n));

                if (item.HasExtraByte)
                {
                    item.Count = msg.GetByte();
                    outMsg.AddByte(item.Count);
                }

                if (n == 0)
                    tile.Ground = item;
                else
                    tile.Items.Add(item);

                return true;
            }
        }
Пример #3
0
        public override bool ParseMessage(NetworkMessage msg, PacketDestination destination)
        {
            if (msg.GetByte() != (byte)IncomingPacketType.TileAddThing)
            {
                return(false);
            }

            Destination = destination;
            Type        = IncomingPacketType.TileAddThing;

            Location = msg.GetLocation();
            Stack    = msg.GetByte();
            ThingId  = msg.GetUInt16();

            if (ThingId == 0x0061 || ThingId == 0x0062)
            {
                Creature = new PacketCreature(Client);

                if (ThingId == 0x0062)
                {
                    Creature.Type = PacketCreatureType.Known;
                    Creature.Id   = msg.GetUInt32();
                }
                else if (ThingId == 0x0061)
                {
                    Creature.Type     = PacketCreatureType.Unknown;
                    Creature.RemoveId = msg.GetUInt32();
                    Creature.Id       = msg.GetUInt32();
                    Creature.Name     = msg.GetString();
                }

                Creature.Health    = msg.GetByte();
                Creature.Direction = msg.GetByte();

                Creature.Outfit = msg.GetOutfit();

                Creature.LightLevel = msg.GetByte();
                Creature.LightColor = msg.GetByte();

                Creature.Speed       = msg.GetUInt16();
                Creature.Skull       = (Constants.Skull)msg.GetByte();
                Creature.PartyShield = (PartyShield)msg.GetByte();
            }
            else if (ThingId == 0x0063)
            {
                Creature           = new PacketCreature(Client);
                Creature.Type      = PacketCreatureType.Turn;
                Creature.Id        = msg.GetUInt32();
                Creature.Direction = msg.GetByte();
            }
            else
            {
                Item          = new Pokemon.Objects.Item(Client, ThingId);
                Item.Location = Pokemon.Objects.ItemLocation.FromLocation(Location);

                if (Item.HasExtraByte)
                {
                    Item.Count = msg.GetByte();
                }
            }

            return(true);
        }
Пример #4
0
        protected bool ParseThing(NetworkMessage msg, Location pos, Tile tile, int n, NetworkMessage outMsg)
        {
            //get thing type
            ushort thingId = msg.GetUInt16();

            outMsg.AddUInt16(thingId);

            PacketCreature c;

            if (thingId == 0x0061 || thingId == 0x0062)
            {
                c          = new PacketCreature(Client);
                c.Location = pos;

                //creatures
                if (thingId == 0x0062) //creature is known
                {
                    c.Type = PacketCreatureType.Known;
                    c.Id   = msg.GetUInt32();
                    outMsg.AddUInt32(c.Id); //creatureid
                }
                else if (thingId == 0x0061)
                { //creature is not known
                    //perhaps we have to remove a known creature
                    c.RemoveId = msg.GetUInt32();
                    outMsg.AddUInt32(c.RemoveId);

                    //add a new creature
                    c.Type = PacketCreatureType.Unknown;
                    c.Id   = msg.GetUInt32();
                    outMsg.AddUInt32(c.Id);

                    c.Name = msg.GetString();
                    outMsg.AddString(c.Name);
                }

                //read creature properties
                c.Health = msg.GetByte();
                outMsg.AddByte(c.Health);

                c.Direction = msg.GetByte();
                outMsg.AddByte(c.Direction);

                c.Outfit = msg.GetOutfit();
                outMsg.AddOutfit(c.Outfit);

                c.LightLevel = msg.GetByte();
                outMsg.AddByte(c.LightLevel);

                c.LightColor = msg.GetByte();
                outMsg.AddByte(c.LightColor);

                c.Speed = msg.GetUInt16();
                outMsg.AddUInt16(c.Speed);

                c.Skull = (Constants.Skull)msg.GetByte();
                outMsg.AddByte((byte)c.Skull);

                c.PartyShield = (Constants.PartyShield)msg.GetByte();
                outMsg.AddByte((byte)c.PartyShield);

                creatures.Add(c);

                return(true);
            }
            else if (thingId == 0x0063)
            {
                //creature turn
                c          = new PacketCreature(Client);
                c.Location = pos;
                c.Type     = PacketCreatureType.Turn;
                c.Id       = msg.GetUInt32();
                outMsg.AddUInt32(c.Id);

                c.Direction = msg.GetByte();
                outMsg.AddByte(c.Direction);

                creatures.Add(c);

                return(true);
            }
            else
            {
                //item
                UInt16 itemId;
                if (thingId == UInt16.MaxValue)
                {
                    itemId = msg.GetUInt16();
                    outMsg.AddUInt16(itemId);
                }
                else
                {
                    itemId = thingId;
                }

                Item item = new Item(Client, itemId, 0, "", ItemLocation.FromLocation(pos, (byte)n));

                if (item.HasExtraByte)
                {
                    item.Count = msg.GetByte();
                    outMsg.AddByte(item.Count);
                }

                if (n == 0)
                {
                    tile.Ground = item;
                }
                else
                {
                    tile.Items.Add(item);
                }

                return(true);
            }
        }