Пример #1
0
 private void OnCreatureLight(Packet props)
 {
     ClientCreature Creature = (ClientCreature)props["Creature"];
     Creature.Light.Color = (int)props["Color"];
     Creature.Light.Level = (int)props["Level"];
 }
Пример #2
0
        private void OnMagicEffect(Packet props)
        {
            MapPosition Position = (MapPosition)props["Position"];
            MagicEffect Effect = new MagicEffect(Viewport.GameData, (int)props["Effect"]);

            TileAnimations Animations = null;
            if (!PlayingAnimations.TryGetValue(Position, out Animations))
            {
                Animations = new TileAnimations();
                PlayingAnimations.Add(Position, Animations);
            }
            Animations.Effects.Add(Effect);
        }
Пример #3
0
 private void OnPlayerLogin(Packet props)
 {
     // Next map description will contain the player
     Protocol.MapDescription.Add(OnMapDescription);
 }
Пример #4
0
 private void OnVIPState(Packet props)
 {
     ClientCreature Creature = null;
     if (!VIPList.TryGetValue((UInt32)props["CreatureID"], out Creature))
     {
         Creature = new ClientCreature((UInt32)props["CreatureID"]);
         VIPList[Creature.ID] = Creature;
     }
     Creature.Name = (String)props["Name"];
     Creature.Online = (Boolean)props["Online"];
     if (VIPStatusChanged != null)
         VIPStatusChanged(this, Creature);
 }
 public void Invoke(Packet props)
 {
     if (evt != null)
         evt(props);
 }
Пример #6
0
 private void OnUpdateInventory(Packet props)
 {
     int slot = (int)props["Slot"];
     Inventory[slot] = (ClientItem)props["Thing"];
 }
Пример #7
0
        private void OnUpdateStats(Packet props)
        {
            if (Player == null)
                throw new ProtocolException("Received stat update before PlayerLogin");

            Player.Health = (int)props["Health"];
            Player.MaxHealth = (int)props["MaxHealth"];
            Player.Mana = (int)props["Mana"];
            Player.MaxMana = (int)props["MaxMana"];
            Player.Capacity = (int)props["Capacity"];
            Player.Experience = (int)props["Experience"];

            Player.Level.Value = (int)props["Level"];
            Player.Level.Percent = (int)props["LevelPercent"];
            Player.MagicLevel.Value = (int)props["MagicLevel"];
            Player.MagicLevel.Percent = (int)props["MagicLevelPercent"];
        }
Пример #8
0
 private void OnCreatureTurn(Packet props)
 {
     ClientCreature Creature = (ClientCreature)props["Creature"];
     Creature.Direction = (Direction)props["Direction"];
 }
Пример #9
0
        private void OnMapDescription(Packet props)
        {
            ViewPosition = (MapPosition)props["Center"];
            List<ClientTile> tiles = (List<ClientTile>)props["Tiles"];

            Map.Clear(ViewPosition);
            foreach (ClientTile Tile in tiles)
            {
                if (Tile != null)
                {
                    ProbeTileForCreatures(Tile);
                    Map[Tile.Position] = Tile;
                }
            }
        }
Пример #10
0
        private void OnCreatureSpeak(Packet props)
        {
            ClientMessage Message = (ClientMessage)props["Message"];

            //Log.Debug(Message.Speaker + ": " + Message.Text, this);

            ClientChannel Channel = DefaultChannel;
            if (props["ChannelID"] != null && Channels.ContainsKey((UInt16)props["ChannelID"]))
            {
                Channel = Channels[(UInt16)props["ChannelID"]];
            }
            Channel.Add(Message);
        }
Пример #11
0
 private void OnCreatureSpeed(Packet props)
 {
     ClientCreature Creature = (ClientCreature)props["Creature"];
     Creature.Speed = (int)props["Speed"];
 }
Пример #12
0
 private void OnCreatureSkull(Packet props)
 {
     ClientCreature Creature = (ClientCreature)props["Creature"];
     Creature.Skull = (CreatureSkull)props["Skull"];
 }
Пример #13
0
 private void OnCreatureShield(Packet props)
 {
     ClientCreature Creature = (ClientCreature)props["Creature"];
     Creature.Shield = (PartyShield)props["PartyShield"];
 }
Пример #14
0
        private void OnCreatureMove(Packet props)
        {
            MapPosition OldPosition = (MapPosition)props["OldPosition"];
            int StackIndex = (int)props["OldStackIndex"];
            MapPosition ToPosition = (MapPosition)props["Position"];

            ClientTile FromTile = Map[OldPosition];
            ClientTile ToTile = Map[ToPosition];

            if (FromTile == null || ToTile == null)
            {
                Log.Warning("OnCreatureMove - Tile is missing.");
                return;
            }

            ClientCreature Creature = (ClientCreature)FromTile.GetByIndex(StackIndex);
            FromTile.Remove(Creature);
            ToTile.Add(Creature, true);

            Creature.Move(OldPosition, ToPosition);
        }
Пример #15
0
 private void OnTextMessage(Packet props)
 {
     ClientMessage Message = (ClientMessage)props["Message"];
     DefaultChannel.Add(Message);
     //Log.Debug(Message.Text, this);
 }
Пример #16
0
        private void OnOpenChannel(Packet props)
        {
            UInt16 ChannelID = (UInt16)props["ChannelID"];
            String ChannelName = (String)props["ChannelName"];

            Channels[ChannelID] = new ClientChannel(ChannelID, ChannelName);
        }
Пример #17
0
        private void OnTransformThing(Packet props)
        {
            MapPosition Position = (MapPosition)props["Position"];
            int StackIndex = (int)props["StackIndex"];
            ClientThing Thing = (ClientThing)props["Thing"];

            if (props.Has("Direction"))
                if (Thing is ClientCreature)
                    ((ClientCreature)Thing).Direction = (Direction)props["Direction"];

            Map[Position].Replace(StackIndex, Thing);
        }
Пример #18
0
        private void OnOpenContainer(Packet props)
        {
            int ContainerID = (int)props["ContainerID"];
            ClientContainer Container = (ClientContainer)props["Thing"];
            Container.Name = (String)props["Name"];
            Container.MaximumVolume = (int)props["Volume"];
            Container.HasParent = (bool)props["IsChild"];
            Container.Contents = (List<ClientItem>)props["Contents"];

            bool update = Containers.ContainsKey(ContainerID);

            Containers[ContainerID] = Container;

            // Dispatch an event
            if (update)
            {
                if (UpdateContainer != null)
                    UpdateContainer(this, Container);
            }
            else
            {
                if (OpenContainer != null)
                    OpenContainer(this, Container);
            }
        }
Пример #19
0
        private void OnUpdateSkills(Packet props)
        {
            if (Player == null)
                throw new ProtocolException("Received skill update before PlayerLogin");

            Player.Skill["Fist"].Value   = (int)props["Fist"];
            Player.Skill["Club"].Value   = (int)props["Club"];
            Player.Skill["Sword"].Value  = (int)props["Sword"];
            Player.Skill["Axe"].Value    = (int)props["Axe"];
            Player.Skill["Dist"].Value   = (int)props["Dist"];
            Player.Skill["Shield"].Value = (int)props["Shield"];
            Player.Skill["Fish"].Value   = (int)props["Fish"];

            Player.Skill["Fist"].Percent   = (int)props["FistPercent"];
            Player.Skill["Club"].Percent   = (int)props["ClubPercent"];
            Player.Skill["Sword"].Percent  = (int)props["SwordPercent"];
            Player.Skill["Axe"].Percent    = (int)props["AxePercent"];
            Player.Skill["Dist"].Percent   = (int)props["DistPercent"];
            Player.Skill["Shield"].Percent = (int)props["ShieldPercent"];
            Player.Skill["Fish"].Percent   = (int)props["FishPercent"];
        }
Пример #20
0
 private void OnOpenPrivateChat(Packet props)
 {
 }
Пример #21
0
 private void OnVIPLogout(Packet props)
 {
     ClientCreature Creature = VIPList[(UInt32)props["CreatureID"]];
     if (Creature != null)
     {
         Creature.Online = false;
         if (VIPStatusChanged != null)
             VIPStatusChanged(this, Creature);
     }
     else
         Log.Warning("Receieved vip login for unknown creature (" + props["CreatureID"] + ")");
 }
Пример #22
0
 private void OnPlayerIcons(Packet props)
 {
     Player.Conditions = (ConditionState)props["ConditionState"];
 }
        /// <summary>
        /// Internal use only, fetches the correct handler for a given handler name. One packet name may map to multiple handler names.
        /// </summary>
        /// <param name="parserName">The packet handler to fetch</param>
        /// <returns></returns>
        private GamePacketParser GetPacketParser(String parserName)
        {
            if (parserName == "ErrorMessage")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    props["Message"] = nmsg.ReadString();
                    return props;
                };
            else if (parserName == "MOTD")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    props["Message"] = nmsg.ReadString();
                    return props;
                };
            else if (parserName == "Ping")
                return delegate(NetworkMessage nmsg)
                {
                    return new Packet(parserName);
                };

            else if (parserName == "PlayerLogin")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    Player = new ClientPlayer(nmsg.ReadU32());
                    props["DrawSpeed"] = nmsg.ReadU16();
                    props["CanReportBugs"] = nmsg.ReadByte() != 0;
                    props["Player"] = Player;
                    KnownCreatures[Player.ID] = Player;

                    return props;
                };
            else if (parserName == "MapDescription")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    CurrentPosition = ReadMapPosition(nmsg);
                    props["Center"] = CurrentPosition;
                    props["Tiles"] = ReadMapDescription(nmsg, CurrentPosition.X - 8, CurrentPosition.Y - 6, CurrentPosition.Z, 18, 14);
                    return props;
                };

            else if (parserName == "UpdateInventory")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    props["Slot"] = (int)nmsg.ReadByte();
                    props["Thing"] = ReadThing(nmsg);
                    return props;
                };
            else if (parserName == "ClearInventory")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    props["Slot"] = (int)nmsg.ReadByte();
                    return props;
                };
            else if (parserName == "OpenContainer")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    int ContainerID = (int)nmsg.ReadByte();
                    props["ContainerID"] = ContainerID;
                    int ClientID = nmsg.ReadU16();
                    ItemType it = GameData.GetItemType(ClientID);
                    if (it == null)
                    {
                        Log.Warning("OpenContainer contains unrecognized item type (" + ClientID.ToString() + ").", this);
                        it = ItemType.NullType;
                    }
                    props["Thing"] = new ClientContainer(it, ContainerID);
                    props["Name"] = nmsg.ReadString();
                    props["Volume"] = (int)nmsg.ReadByte();
                    props["IsChild"] = nmsg.ReadByte() != 0;
                    int ItemCount = nmsg.ReadByte();
                    props["ItemCount"] = (int)ItemCount;
                    List<ClientItem> contents = new List<ClientItem>();
                    for (int i = 0; i < ItemCount; ++i)
                        contents.Add((ClientItem)ReadThing(nmsg));
                    props["Contents"] = contents;
                    return props;
                };
            else if (parserName == "CloseContainer")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    props["ContainerID"] = (int)nmsg.ReadByte();
                    return props;
                };
            else if (parserName == "ContainerAddItem")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    props["ContainerID"] = (int)nmsg.ReadByte();
                    props["Item"] = ReadItem(nmsg);
                    return props;
                };
            else if (parserName == "ContainerTransformItem")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    props["ContainerID"] = (int)nmsg.ReadByte();
                    props["Slot"] = (int)nmsg.ReadByte();
                    props["Item"] = ReadItem(nmsg);
                    return props;
                };
            else if (parserName == "ContainerRemoveItem")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    props["ContainerID"] = (int)nmsg.ReadByte();
                    props["Slot"] = (int)nmsg.ReadByte();
                    return props;
                };

            else if (parserName == "UpdateStats")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    props["Health"] = (int)nmsg.ReadU16();
                    props["MaxHealth"] = (int)nmsg.ReadU16();
                    props["Capacity"] = (int)nmsg.ReadU16();
                    props["Experience"] = (int)nmsg.ReadU32();
                    props["Level"] = (int)nmsg.ReadByte();
                    props["LevelPercent"] = (int)nmsg.ReadByte();
                    props["Mana"] = (int)nmsg.ReadU16();
                    props["MaxMana"] = (int)nmsg.ReadU16();
                    props["MagicLevel"] = (int)nmsg.ReadByte();
                    props["MagicLevelPercent"] = (int)nmsg.ReadByte();
                    // TODO: Stamina for some versions
                    //int soul = nmsg.ReadByte();
                    //int staminaMinutes = nmsg.ReadU16();

                    return props;
                };
            else if (parserName == "UpdateSkills")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    props["Fist"] = (int)nmsg.ReadByte();
                    props["FistPercent"] = (int)nmsg.ReadByte();
                    props["Club"] = (int)nmsg.ReadByte();
                    props["ClubPercent"] = (int)nmsg.ReadByte();
                    props["Sword"] = (int)nmsg.ReadByte();
                    props["SwordPercent"] = (int)nmsg.ReadByte();
                    props["Axe"] = (int)nmsg.ReadByte();
                    props["AxePercent"] = (int)nmsg.ReadByte();
                    props["Dist"] = (int)nmsg.ReadByte();
                    props["DistPercent"] = (int)nmsg.ReadByte();
                    props["Shield"] = (int)nmsg.ReadByte();
                    props["ShieldPercent"] = (int)nmsg.ReadByte();
                    props["Fish"] = (int)nmsg.ReadByte();
                    props["FishPercent"] = (int)nmsg.ReadByte();

                    return props;
                };
            else if (parserName == "PlayerIcons")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    props["ConditionState"] = (ConditionState)nmsg.ReadByte();
                    return props;
                };
            else if (parserName == "CancelAttack")
                return delegate(NetworkMessage nmsg)
                {
                    return new Packet(parserName);
                };
            else if (parserName == "CancelWalk")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    props["Direction"] = (Direction)nmsg.ReadByte();
                    return props;
                };
            else if (parserName == "Death")
                return delegate(NetworkMessage nmsg)
                {
                    return new Packet(parserName);
                };
            else if (parserName == "CanReport")
                return delegate(NetworkMessage nmsg)
                {
                    return new Packet(parserName);
                };
            else if (parserName == "MoveNorth")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    CurrentPosition.Y--;
                    props["Center"] = CurrentPosition;
                    props["Tiles"] = ReadMapDescription(nmsg, CurrentPosition.X - 8, CurrentPosition.Y - 6, CurrentPosition.Z, 18, 1);
                    return props;
                };
            else if (parserName == "MoveSouth")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    CurrentPosition.Y++;
                    props["Center"] = CurrentPosition;
                    props["Tiles"] = ReadMapDescription(nmsg, CurrentPosition.X - 8, CurrentPosition.Y + 7, CurrentPosition.Z, 18, 1);
                    return props;
                };
            else if (parserName == "MoveWest")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    CurrentPosition.X--;
                    props["Center"] = CurrentPosition;
                    props["Tiles"] = ReadMapDescription(nmsg, CurrentPosition.X - 8, CurrentPosition.Y - 6, CurrentPosition.Z, 1, 14);
                    return props;
                };
            else if (parserName == "MoveEast")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    CurrentPosition.X++;
                    props["Center"] = CurrentPosition;
                    props["Tiles"] = ReadMapDescription(nmsg, CurrentPosition.X + 9, CurrentPosition.Y - 6, CurrentPosition.Z, 1, 14);
                    return props;
                };
            else if (parserName == "FloorUp")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    List<ClientTile> Tiles = new List<ClientTile>();
                    int skipTiles = 0;

                    CurrentPosition.Z--;
                    if (CurrentPosition.Z == 7)
                    {
                        for (int i = 5; i >= 0; i--)
                        {
                            Tiles.AddRange(ReadFloorDescription(nmsg, ref skipTiles, CurrentPosition.X - 8, CurrentPosition.Y - 6, i, 18, 14, 8 - i));
                        }
                    }
                    else if (CurrentPosition.Z > 7)
                    {
                        Tiles.AddRange(ReadFloorDescription(nmsg, ref skipTiles, CurrentPosition.X - 8, CurrentPosition.Y - 6, CurrentPosition.Z - 2, 18, 14, 3));
                    }
                    CurrentPosition.X++;
                    CurrentPosition.Y++;

                    props["Tiles"] = Tiles;
                    props["Center"] = CurrentPosition;
                    return props;
                };
            else if (parserName == "FloorDown")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    List<ClientTile> Tiles = new List<ClientTile>();
                    int skipTiles = 0;

                    CurrentPosition.Z++;
                    if (CurrentPosition.Z == 8)
                    {
                        int j = -1;
                        for (int i = CurrentPosition.Z; i < CurrentPosition.Z + 3; ++i, --j)
                        {
                            Tiles.AddRange(ReadFloorDescription(nmsg, ref skipTiles, CurrentPosition.X - 8, CurrentPosition.Y - 6, i, 18, 14, j));
                        }
                    }
                    else if (CurrentPosition.Z > 8 && CurrentPosition.Z < 14)
                    {
                        Tiles.AddRange(ReadFloorDescription(nmsg, ref skipTiles, CurrentPosition.X - 8, CurrentPosition.Y - 6, CurrentPosition.Z + 2, 18, 14, -3));
                    }
                    CurrentPosition.X--;
                    CurrentPosition.Y--;

                    props["Tiles"] = Tiles;
                    props["Center"] = CurrentPosition;
                    return props;
                };

            else if (parserName == "RefreshTile")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    MapPosition pos = ReadMapPosition(nmsg);
                    props["Position"] = pos;
                    props["Clear"] = false;
                    if (nmsg.PeekU16() == 0xFF01)
                    {
                        nmsg.ReadU16();
                        props["Clear"] = true;
                        return props;
                    }
                    else
                    {
                        props["NewTile"] = ReadTileDescription(nmsg, pos);
                        // Skip extra bytes after data (it signifies the end of data)
                        nmsg.ReadU16();
                        return props;
                    }
                };
            else if (parserName == "AddThing")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["Position"] = ReadMapPosition(nmsg);
                    props["Thing"] = ReadThing(nmsg);
                    props["Push"] = true;
                    // TODO: >= 8.53, push thing should be false
                    return props;
                };
            else if (parserName == "TransformThing")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["Position"] = ReadMapPosition(nmsg);
                    props["StackIndex"] = (int)nmsg.ReadByte();

                    if (nmsg.PeekU16() == 0x63)
                    {
                        nmsg.Skip(2);
                        // CreatureTurn2
                        props["Thing"] = KnownCreatures[nmsg.ReadU32()];
                        props["Direction"] = (Direction)nmsg.ReadByte();
                    }
                    else
                    {
                        props["Thing"] = ReadThing(nmsg);
                    }
                    return props;
                };
            else if (parserName == "RemoveThing")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["Position"] = ReadMapPosition(nmsg);
                    props["StackIndex"] = (int)nmsg.ReadByte();

                    return props;
                };
            else if (parserName == "CreatureMove")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["OldPosition"] = ReadMapPosition(nmsg);
                    props["OldStackIndex"] = (int)nmsg.ReadByte();
                    props["Position"] = ReadMapPosition(nmsg);

                    if ((int)props["OldStackIndex"] > 9)
                        Log.Warning("CreatureMove - Old stack pos out of range.", this);

                    props["Push"] = true;
                    // TODO: >= 8.53, pushThing = false
                    return props;
                };

            else if (parserName == "WorldLight")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["Level"] = (int)nmsg.ReadByte();
                    props["Color"] = (int)nmsg.ReadByte();
                    return props;
                };
            else if (parserName == "Effect")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["Position"] = ReadMapPosition(nmsg);
                    props["Effect"] = 1 + (int)nmsg.ReadByte();
                    return props;
                };
            else if (parserName == "AnimatedText")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["Position"] = ReadMapPosition(nmsg);
                    props["Color"] = (int)nmsg.ReadByte();
                    props["Text"] = nmsg.ReadString();
                    return props;
                };
            else if (parserName == "ShootEffect")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["From"] = ReadMapPosition(nmsg);
                    props["To"] = ReadMapPosition(nmsg);
                    props["Effect"] = (int)nmsg.ReadByte();
                    return props;
                };
            else if (parserName == "SquareEffect")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["Creature"] = KnownCreatures[nmsg.ReadU32()];
                    props["Color"] = nmsg.ReadByte();
                    return props;
                };

            else if (parserName == "CreatureHealth")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["Creature"] = KnownCreatures[nmsg.ReadU32()];
                    props["Health"] = (int)nmsg.ReadByte();
                    return props;
                };
            else if (parserName == "CreatureLight")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["Creature"] = KnownCreatures[nmsg.ReadU32()];
                    props["Level"] = (int)nmsg.ReadByte();
                    props["Color"] = (int)nmsg.ReadByte();
                    return props;
                };
            else if (parserName == "CreatureRefresh")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["Creature"] = KnownCreatures[nmsg.ReadU32()];
                    return props;
                };
            else if (parserName == "CreatureTurn")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["Creature"] = KnownCreatures[nmsg.ReadU32()];
                    props["Direction"] = (Direction)nmsg.ReadByte();
                    return props;
                };
            else if (parserName == "CreatureSpeed")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["Creature"] = KnownCreatures[nmsg.ReadU32()];
                    props["Speed"] = (int)nmsg.ReadU16();
                    return props;
                };
            else if (parserName == "CreatureSkull")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["Creature"] = KnownCreatures[nmsg.ReadU32()];
                    props["Skull"] = (CreatureSkull)nmsg.ReadByte();
                    return props;
                };
            else if (parserName == "CreatureShield")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["Creature"] = KnownCreatures[nmsg.ReadU32()];
                    props["PartyShield"] = (PartyShield)nmsg.ReadByte();
                    return props;
                };

            else if (parserName == "CreatureSpeak")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    ClientMessage Message = new ClientMessage();

                    //props["Creature"] = KnownCreatures[nmsg.ReadU32()];
                    Message.Speaker = nmsg.ReadString();
                    //props["Level"] = nmsg.ReadU16();
                    Message.Type = (MessageType)nmsg.ReadByte();

                    switch (Message.Type)
                    {
                        case MessageType.Say:
                        case MessageType.Whisper:
                        case MessageType.Yell:
                        case MessageType.MonsterSay:
                        case MessageType.MonsterYell:
                        case MessageType.PrivateNPCToPlayer:
                        case MessageType.PrivatePlayerToNPC:
                            {
                                props["Position"] = ReadMapPosition(nmsg);
                                Message.Text = nmsg.ReadString();
                                break;
                            }
                        case MessageType.ChannelAnonymousRed:
                        case MessageType.ChannelOrange:
                        case MessageType.ChannelRed:
                        case MessageType.ChannelYellow:
                            {
                                props["ChannelID"] = nmsg.ReadU16();
                                Message.Text = nmsg.ReadString();
                                break;
                            }
                        case MessageType.Private:
                        case MessageType.Broadcast:
                        case MessageType.PrivateRed:
                            {
                                Message.Text = nmsg.ReadString();
                                break;
                            }
                        case MessageType.ReportRuleViolation:
                            {
                                Message.Time = Common.UnixTime(nmsg.ReadU32()); // time
                                Message.Text = nmsg.ReadString();
                                break;
                            }
                        case MessageType.RuleViolationGameMaster:
                        case MessageType.RuleViolationPlayer:
                            {
                                Message.Text = nmsg.ReadString();
                                break;
                            }
                        default:
                            Log.Warning("Unknown speak class " + (int)props["MessageType"], this);
                            return null;
                    }
                    props["Message"] = Message;
                    return props;
                };
            else if (parserName == "ChannelList")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    int count = nmsg.ReadByte();
                    props["ChannelCount"] = count;
                    while (count > 0)
                    {
                        int channelID = nmsg.ReadU16();
                        string channelName = nmsg.ReadString();
                        --count;
                    }
                    return null;
                };
            else if (parserName == "OpenChannel")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["ChannelID"] = nmsg.ReadU16();
                    props["ChannelName"] = nmsg.ReadString();
                    return props;
                };
            else if (parserName == "OpenPrivateChat")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["PlayerName"] = nmsg.ReadString();
                    return props;
                };
            else if (parserName == "TextMessage")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    MessageType Type = (MessageType)nmsg.ReadByte();
                    String Text = nmsg.ReadString();
                    props["Message"] = new ClientMessage(Type, DateTime.Now, Text);
                    return props;
                };

            else if (parserName == "VIPState")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);

                    props["CreatureID"] = nmsg.ReadU32();
                    props["Name"] = nmsg.ReadString();
                    props["Online"] = nmsg.ReadByte() != 0;
                    return props;
                };
            else if (parserName == "VIPLogin")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    props["CreatureID"] = nmsg.ReadU32();
                    return props;
                };
            else if (parserName == "VIPLogout")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    props["CreatureID"] = nmsg.ReadU32();
                    return props;
                };
            else if (parserName == "RuleViolationChannel")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    return props;
                };
            else if (parserName == "RuleViolationRemove")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    return props;
                };
            else if (parserName == "RuleViolationCancel")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    return props;
                };
            else if (parserName == "RuleViolationLock")
                return delegate(NetworkMessage nmsg)
                {
                    Packet props = new Packet(parserName);
                    return props;
                };

            throw new System.ArgumentException("Unknown packet handler.");
        }
Пример #24
0
 private void OnPlayerLogin(Packet props)
 {
     Player = (ClientPlayer)props["Player"];
     if (Login != null)
         Login(this);
 }
Пример #25
0
        private void OnAnimatedText(Packet props)
        {
            MapPosition Position = (MapPosition)props["Position"];
            String Text = (String)props["Text"];
            int Color = (int)props["Color"];

            TileAnimations Animations = null;
            if (!PlayingAnimations.TryGetValue(Position, out Animations))
            {
                Animations = new TileAnimations();
                PlayingAnimations.Add(Position, Animations);
            }
            Animations.Effects.Add(new AnimatedText(Text, Color));
        }
Пример #26
0
        private void OnRefreshTile(Packet props)
        {
            ClientTile Tile = Map[(MapPosition)props["Position"]];
            Boolean Clear = (Boolean)props["Clear"];

            if (Clear)
                Tile.Objects.Clear();
            else
                Map[Tile.Position] = (ClientTile)props["NewTile"];
        }
Пример #27
0
 private void OnMapDescription(Packet props)
 {
     // Update the name of the window
     UpdateName();
     // Don't need to receive further updates
     Protocol.MapDescription.Remove(OnMapDescription);
 }
Пример #28
0
 private void OnRemoveThing(Packet props)
 {
     MapPosition Position = (MapPosition)props["Position"];
     int StackIndex = (int)props["StackIndex"];
     Map[Position].Remove(StackIndex);
 }
Пример #29
0
        private void OnShootEffect(Packet props)
        {
            MapPosition FromPosition = (MapPosition)props["From"];
            MapPosition ToPosition = (MapPosition)props["To"];
            int Type = (int)props["Effect"];

            MapPosition Max = new MapPosition();
            Max.X = Math.Max(FromPosition.X, ToPosition.X);
            Max.Y = Math.Max(FromPosition.Y, ToPosition.Y);
            Max.Z = ToPosition.Z;

            TileAnimations Animations = null;
            if (!PlayingAnimations.TryGetValue(Max, out Animations))
            {
                Animations = new TileAnimations();
                PlayingAnimations.Add(Max, Animations);
            }
            Animations.Effects.Add(new DistanceEffect(Viewport.GameData, Type, FromPosition, ToPosition));
        }
Пример #30
0
 private void OnCreatureHealth(Packet props)
 {
     ClientCreature Creature = (ClientCreature)props["Creature"];
     Creature.Health = (int)props["Health"];
 }