Example #1
0
 private bool ServerMessage_0x2F_DialogResponse(Client client, ServerPacket msg)
 {
     try
     {
         if ((int)msg.ReadByte() != 10)
         {
             int num1   = (int)msg.ReadByte();
             int serial = (int)msg.ReadUInt32();
             msg.Read(16);
             msg.Seek(29, PacketSeekOrigin.Begin); //goto 29
             string response = msg.ReadString();
             client.Base.currentDialogResponse = response;
             int result =
                 // The Convert (System) class comes in pretty handy every time
                 // you want to convert something.
                 Convert.ToInt32(
                     Regex.Replace(
                         client.Base.currentDialogResponse, // Our input
                         "[^0-9]",                          // Select everything that is not in the range of 0-9
                         ""                                 // Replace that with an empty string.
                         ));
             client.Base.dialogNumber = result;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
         return(false);
     }
     return(true);
 }
Example #2
0
        private bool ServerMessage_0x33_PlayerAdded(Client client, ServerPacket msg)
        {
            try
            {
                /*if ((int)msg.BodyData[10] == 0 && (int)msg.BodyData[11] == 0 && (int)msg.BodyData[12] == 0 && (int)msg.BodyData[13] == 0)
                 * {
                 *  msg.BodyData[10] = (byte)165;
                 *  msg.BodyData[11] = (byte)16;
                 *  msg.BodyData[12] = (byte)0;
                 *  msg.BodyData[13] = (byte)177;
                 * }*/
                try
                {
                    ushort num1 = msg.ReadUInt16();
                    ushort num2 = msg.ReadUInt16();
                    byte   num3 = msg.ReadByte();
                    uint   key  = msg.ReadUInt32();
                    msg.ReadUInt16();
                    int num4 = (int)msg.ReadUInt16();
                    int num5 = (int)msg.ReadUInt32();
                    msg.ReadByte();
                    ushort num6 = msg.ReadUInt16();
                    msg.ReadByte();
                    int num7 = (int)msg.ReadByte();
                    msg.ReadUInt16();
                    int num8 = (int)msg.ReadInt16();
                    msg.ReadUInt16();
                    int num9 = (int)msg.ReadUInt32();
                    msg.ReadByte();
                    msg.ReadUInt16();
                    int num10 = (int)msg.ReadUInt16();
                    msg.ReadByte();
                    int    num11 = (int)msg.ReadUInt16();
                    string str   = msg.ReadString8();
                    msg.ReadString8();
                    if (string.IsNullOrEmpty(str))
                    {
                        str = "f****t";
                    }

                    if (client.Base.Aislings[client.Base.Serial].Position.X != num1 || client.Base.Aislings[client.Base.Serial].Position.Y != num2)
                    {
                        client.ShouldUpdateMap = true;
                    }
                    //add players to onscreen players array
                    if ((int)client.Base.Serial == (int)key)
                    {
                        client.Base.Me.Name     = str;
                        client.Base.Me.Position = new Location()
                        {
                            X = num1,
                            Y = num2
                        };
                        client.Base.CurrentStaffID    = num6;
                        client.Base.MyPosition.X      = num1;
                        client.Base.MyPosition.Y      = num2;
                        client.Base.MyPosition.Facing = (Direction)num3;
                    }
                    else if (!client.Base.Entitys.ContainsKey(key))
                    {
                        client.Base.Entitys.Add(key, new Aisling()
                        {
                            Name     = str,
                            Position = new Location()
                            {
                                Facing = (Direction)num3,
                                X      = num1,
                                Y      = num2,
                            },
                            Serial = key,
                            Map    = client.Base.DaMap.Number
                        });
                    }
                    else
                    {
                        client.Base.Entitys[key].Name     = str;
                        client.Base.Entitys[key].Position = new Location()
                        {
                            X      = num1,
                            Y      = num2,
                            Facing = (Direction)num3
                        };
                        client.Base.Entitys[key].Map = client.Base.DaMap.Number;
                    }

                    /*else if (!client.Base.Players.ContainsKey(key))
                     * {
                     *  client.Base.Players.Add(key, new Aisling()
                     *  {
                     *      Name = str,
                     *      Position = new Location()
                     *      {
                     *          Facing = (Direction)num3,
                     *          X = num1,
                     *          Y = num2
                     *      },
                     *      Serial = key
                     *  });
                     * }
                     * else
                     * {
                     *  client.Base.Players[key].Name = str;
                     *  client.Base.Players[key].Position = new Location()
                     *  {
                     *      X = num1,
                     *      Y = num2,
                     *      Facing = (Direction)num3
                     *  };
                     * }*/
                    //add players to lasting seen players array
                    if (!client.Base.Aislings.ContainsKey(key))
                    {
                        client.Base.Aislings.Add(key, new Aisling()
                        {
                            Name     = str,
                            Position = new Location()
                            {
                                Facing = (Direction)num3,
                                X      = num1,
                                Y      = num2
                            },
                            Serial = key,
                            Map    = client.Base.DaMap.Number
                        });
                    }
                    else
                    {
                        client.Base.Aislings[key].Name     = str;
                        client.Base.Aislings[key].Position = new Location()
                        {
                            X      = num1,
                            Y      = num2,
                            Facing = (Direction)num3
                        };
                        client.Base.Aislings[key].Map = client.Base.DaMap.Number;
                        if (client.Base.Aislings[key].Map == client.Base.Aislings[key].lastMap)
                        {
                            client.Base.Aislings[key].lastMap = -1;
                        }
                    }
                }
                catch
                {
                    msg.Seek(0, PacketSeekOrigin.Begin);
                    ushort num1 = msg.ReadUInt16();
                    ushort num2 = msg.ReadUInt16();
                    byte   num3 = msg.ReadByte();
                    uint   key  = msg.ReadUInt32();
                    if ((int)client.Base.Serial == (int)key)
                    {
                        client.Base.Me.Name     = "form";
                        client.Base.Me.Position = client.Base.MyPosition;
                    }

                    /*else if (!client.Base.Players.ContainsKey(key))
                     * {
                     *  client.Base.Players.Add(key, new Aisling()
                     *  {
                     *      Name = "form",
                     *      Position = new Location()
                     *      {
                     *          Facing = (Direction)num3,
                     *          X = num1,
                     *          Y = num2
                     *      },
                     *      Serial = key
                     *  });
                     * }
                     * else
                     * {
                     *  client.Base.Players[key].Name = "form";
                     *  client.Base.Players[key].Position = new Location()
                     *  {
                     *      X = num1,
                     *      Y = num2,
                     *      Facing = (Direction)num3
                     *  };
                     * }*/

                    else if (!client.Base.Entitys.ContainsKey(key))
                    {
                        client.Base.Entitys.Add(key, new Aisling()
                        {
                            Name     = "form",
                            Position = new Location()
                            {
                                Facing = (Direction)num3,
                                X      = num1,
                                Y      = num2
                            },
                            Serial = key,
                            Map    = client.Base.DaMap.Number
                        });
                    }
                    else
                    {
                        client.Base.Entitys[key].Name     = "form";
                        client.Base.Entitys[key].Position = new Location()
                        {
                            X      = num1,
                            Y      = num2,
                            Facing = (Direction)num3
                        };
                        client.Base.Entitys[key].Map = client.Base.DaMap.Number;
                    }
                    //add players to lasting seen players array
                    if (!client.Base.Aislings.ContainsKey(key))
                    {
                        client.Base.Aislings.Add(key, new Aisling()
                        {
                            Name     = "form",
                            Position = new Location()
                            {
                                Facing = (Direction)num3,
                                X      = num1,
                                Y      = num2
                            },
                            Serial = key,
                            Map    = client.Base.DaMap.Number
                        });
                    }
                    else
                    {
                        client.Base.Aislings[key].Name     = "form";
                        client.Base.Aislings[key].Position = new Location()
                        {
                            X      = num1,
                            Y      = num2,
                            Facing = (Direction)num3
                        };
                        client.Base.Aislings[key].Map = client.Base.DaMap.Number;
                        if (client.Base.Aislings[key].Map == client.Base.Aislings[key].lastMap)
                        {
                            client.Base.Aislings[key].lastMap = -1;
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
                return(false);
            }
        }