Пример #1
0
        public void Serialize(ServerMessage Message)
        {
            Message.AppendString(this.Name);
            Message.AppendInt32(this.ItemId);
            Message.AppendInt32(this.X);
            Message.AppendInt32(this.Y);
            Message.AppendInt32(0); // Z
            Message.AppendInt32(1);
            Message.AppendInt32(this.Sprite);
            Message.AppendInt32(this.Rot);
            Message.AppendInt32(0);

            if (this.Name.Contains("background"))
            {
                Message.AppendBoolean(true);
                Message.AppendInt32(1);
                Message.AppendInt32(5);
                Message.AppendString("state");
                Message.AppendString("0");
                Message.AppendString("offsetZ");
                Message.AppendString("9920");
                Message.AppendString("offsetY");
                Message.AppendString("1520");
                Message.AppendString("imageUrl");
                Message.AppendString("http://localhost/c_images/DEV_tests/snst_bg_2_big.png");
                Message.AppendString("offsetX");
                Message.AppendString("-1070");
            }
            else
            {
                Message.AppendBoolean(false);
                Message.AppendInt32(0);
                Message.AppendString(this.Extradata);
            }
        }
Пример #2
0
        internal static ServerMessage Compose(GameClient Session, Quest Quest)
        {
            //  518:S,I,I,I,I,B,S,S,I,S,I,I,I,S,S,B,B

            int AmountInCat = SilverwaveEnvironment.GetGame().GetQuestManager().GetAmountOfQuestsInCategory(Quest.Category);
            int Number = Quest == null ? AmountInCat : Quest.Number;
            int UserProgress = Quest == null ? 0 : Session.GetHabbo().GetQuestProgress(Quest.Id);
            ServerMessage Message = new ServerMessage(Outgoing.QuestCompletedCompser);
            Message.AppendString(Quest.Category);
            Message.AppendInt32(Number); // Quest progress in this cat
            Message.AppendInt32((Quest.Name.Contains("xmas2012")) ? 1 : AmountInCat); // Total quests in this cat
            Message.AppendInt32(Quest == null ? 3 : Quest.RewardType); // Reward type (1 = Snowflakes, 2 = Love hearts, 3 = Pixels, 4 = Seashells, everything else is pixels
            Message.AppendInt32(Quest == null ? 0 : Quest.Id); // Quest id
            Message.AppendBoolean(Quest == null ? false : Session.GetHabbo().CurrentQuestId == Quest.Id); // Quest started
            Message.AppendString(Quest == null ? string.Empty : Quest.ActionName);
            Message.AppendString(Quest == null ? string.Empty : Quest.DataBit);
            Message.AppendInt32(Quest == null ? 0 : Quest.Reward);
            Message.AppendString(Quest == null ? string.Empty : Quest.Name);
            Message.AppendInt32(UserProgress); // Current progress
            Message.AppendInt32(Quest == null ? 0 : Quest.GoalData); // Target progress
            Message.AppendInt32(Quest == null ? 0 : Quest.TimeUnlock); // "Next quest available countdown" in seconds
            Message.AppendString("");
            Message.AppendString("");
            Message.AppendBoolean(true); // ?
            Message.AppendBoolean(true); // Activate next quest..
            return Message;
        }
Пример #3
0
        internal void SerializeWall(ServerMessage Message, Boolean Inventory)
        {
            Message.AppendInt32(Id);
            Message.AppendString(mBaseItem.Type.ToString().ToUpper());
            Message.AppendInt32(Id);
            Message.AppendInt32(GetBaseItem().SpriteId);

            if (GetBaseItem().Name.Contains("a2"))
            {
                Message.AppendInt32(3);
            }
            else if (GetBaseItem().Name.Contains("wallpaper"))
            {
                Message.AppendInt32(2);
            }
            else if (GetBaseItem().Name.Contains("landscape"))
            {
                Message.AppendInt32(4);
            }
            else
            {
                Message.AppendInt32(1);
            }
            Message.AppendInt32(0);
            Message.AppendString(ExtraData);
            Message.AppendBoolean(GetBaseItem().AllowRecycle);
            Message.AppendBoolean(GetBaseItem().AllowTrade);
            Message.AppendBoolean(GetBaseItem().AllowInventoryStack);
            Message.AppendBoolean(false);
            Message.AppendInt32(-1);
            Message.AppendBoolean(true);
            Message.AppendInt32(-1);
        }
Пример #4
0
        internal static ServerMessage Compose(GameClient Session, List<Achievement> Achievements)
        {
            ServerMessage Message = new ServerMessage(Outgoing.AchievementList);
            Message.AppendInt32(Achievements.Count);
            foreach (Achievement Achievement in Achievements)
            {
                UserAchievement UserData = Session.GetHabbo().GetAchievementData(Achievement.GroupName);
                int TargetLevel = (UserData != null ? UserData.Level + 1 : 1);
                int TotalLevels = Achievement.Levels.Count;

                if (TargetLevel > TotalLevels)
                {
                    TargetLevel = TotalLevels;
                }
                AchievementLevel TargetLevelData = Achievement.Levels[TargetLevel];
                Message.AppendInt32(Achievement.Id);                                                           // Unknown (ID?)
                Message.AppendInt32(TargetLevel);                                                   // Target level
                Message.AppendString(Achievement.GroupName + TargetLevel);                 // Target name/desc/badge
                Message.AppendInt32(TargetLevelData.RewardPixels);
                Message.AppendInt32(TargetLevelData.Requirement);                                   // Progress req/target
                Message.AppendInt32(TargetLevelData.RewardPoints);
                Message.AppendInt32(0); // Type of reward
                Message.AppendInt32(UserData != null ? UserData.Progress : 0);                      // Current progress
                Message.AppendBoolean(UserData != null ? (UserData.Level >= TotalLevels) : false);  // Set 100% completed(??)
                Message.AppendString(Achievement.Category);                                // Category
                Message.AppendString(String.Empty);
                Message.AppendInt32(TotalLevels);                                                   // Total amount of levels
                Message.AppendInt32(0);
            }
            Message.AppendString("");
            return Message;
        }
Пример #5
0
        internal void Searialize(ServerMessage reply)
        {
            reply.AppendInt32(userID);
            reply.AppendString(username);
            reply.AppendString(motto);

            bool Online = (SilverwaveEnvironment.GetGame().GetClientManager().GetClient(userID) != null);

            reply.AppendBoolean(Online);

            reply.AppendBoolean(false);

            reply.AppendString(string.Empty);
            reply.AppendInt32(0);
            reply.AppendString(look);
            reply.AppendString(last_online);
        }
        internal static ServerMessage Compose(Achievement Achievement, int Level, int PointReward, int PixelReward)
        {
            //2210:I,I,I,S,I,I,I,I,I,S,S,B

            ServerMessage Message = new ServerMessage(Outgoing.UnlockAchievement);
            Message.AppendInt32(Achievement.Id);                                           // Achievement ID
            Message.AppendInt32(Level);                                                     // Achieved level
            Message.AppendInt32(144);                                                         // Unknown. Random useless number.
            Message.AppendString(Achievement.GroupName + Level);                   // Achieved name
            Message.AppendInt32(PointReward);                                               // Point reward
            Message.AppendInt32(PixelReward);                                               // Pixel reward
            Message.AppendInt32(0);                                                         // Unknown.
            Message.AppendInt32(10);                                                         // Unknown.
            Message.AppendInt32(21);                                                         // Unknown. (Extra reward?)
            Message.AppendString(Level > 1 ? Achievement.GroupName + (Level - 1) : string.Empty);
            Message.AppendString(Achievement.Category);
            Message.AppendBoolean(true);
            return Message;
        }
        internal static ServerMessage Compose(Achievement Achievement, int TargetLevel, AchievementLevel TargetLevelData,
            int TotalLevels, UserAchievement UserData)
        {
            //I,I,S,I,I,I,I,I,B,S,S,I,I

            ServerMessage Message = new ServerMessage(Outgoing.AchievementProgress);
            Message.AppendInt32(Achievement.Id);                                               // Unknown (ID?)
            Message.AppendInt32(TargetLevel);                                                   // Target level
            Message.AppendString(Achievement.GroupName + TargetLevel);                 // Target name/desc/badge
            Message.AppendInt32(TargetLevelData.Requirement);                                   // Progress req/target
            Message.AppendInt32(TargetLevelData.Requirement);                                   // Reward in Pixels
            Message.AppendInt32(TargetLevelData.RewardPixels);                                  // Reward Ach Score
            Message.AppendInt32(0); // ?
            Message.AppendInt32(UserData != null ? UserData.Progress : 0);                      // Current progress
            Message.AppendBoolean(UserData != null ? (UserData.Level >= TotalLevels) : false);  // Set 100% completed(??)
            Message.AppendString(Achievement.Category);                               // Category
            Message.AppendString(String.Empty);
            Message.AppendInt32(TotalLevels);                                                   // Total amount of levels
            Message.AppendInt32(0);
            return Message;
        }
Пример #8
0
        internal static ServerMessage Compose(GameClient Session, List<Quest> Quests, bool Send)
        {
            Dictionary<string, int> UserQuestGoals = new Dictionary<string, int>();
            Dictionary<string, Quest> UserQuests = new Dictionary<string, Quest>();

            foreach (Quest Quest in Quests)
            {
                if (Quest.Category.Contains("xmas2012"))
                    continue;
                if (!UserQuestGoals.ContainsKey(Quest.Category))
                {
                    UserQuestGoals.Add(Quest.Category, 1);
                    UserQuests.Add(Quest.Category, null);
                }

                if (Quest.Number >= UserQuestGoals[Quest.Category])
                {
                    int UserProgress = Session.GetHabbo().GetQuestProgress(Quest.Id);

                    if (Session.GetHabbo().CurrentQuestId != Quest.Id && UserProgress >= Quest.GoalData)
                    {
                        UserQuestGoals[Quest.Category] = Quest.Number + 1;
                    }
                }
            }

            foreach (Quest Quest in Quests)
            {
                foreach (KeyValuePair<string, int> Goal in UserQuestGoals)
                {
                    if (Quest.Category.Contains("xmas2012"))
                        continue;
                    if (Quest.Category == Goal.Key && Quest.Number == Goal.Value)
                    {
                        UserQuests[Goal.Key] = Quest;
                        break;
                    }
                }
            }

            ServerMessage Message = new ServerMessage(Outgoing.QuestListComposer);
            Message.AppendInt32(UserQuests.Count);

            // Active ones first
            foreach (KeyValuePair<string, Quest> UserQuest in UserQuests)
            {
                if (UserQuest.Value == null)
                {
                    continue;
                }

                SerializeQuest(Message, Session, UserQuest.Value, UserQuest.Key);
            }

            // Dead ones last
            foreach (KeyValuePair<string, Quest> UserQuest in UserQuests)
            {
                if (UserQuest.Value != null)
                {
                    continue;
                }

                SerializeQuest(Message, Session, UserQuest.Value, UserQuest.Key);
            }

            Message.AppendBoolean(Send);
            return Message;
        }
Пример #9
0
 internal ServerMessage RoomFloorAndWallComposer(Room room)
 {
     //Habbo owner = SilverwaveEnvironment.getHabboForId((uint)room.OwnerId);
     //if (owner.GetSubscriptionManager().HasSubscription)
     {
         ServerMessage m = new ServerMessage(Outgoing.RoomFloorAndWallComposer);
         m.AppendBoolean(room.Hidewall == 1);
         m.AppendInt32(room.WallThickness);
         m.AppendInt32(room.FloorThickness);
         return m;
     }
 }
Пример #10
0
        internal void AllowAllRide()
        {
            Room Room = SilverwaveEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            uint PetID = Request.PopWiredUInt();
            RoomUser Pet = Room.GetRoomUserManager().GetPet(PetID);

            if (Pet.PetData.AnyoneCanRide == 1)
            {
                using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                    dbClient.runFastQuery("UPDATE bots_petdata SET anyone_ride=0 WHERE id=" + PetID + " LIMIT 1");
                Pet.PetData.AnyoneCanRide = 0;
            }
            else
            {
                using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                    dbClient.runFastQuery("UPDATE bots_petdata SET anyone_ride=1 WHERE id=" + PetID + " LIMIT 1");
                Pet.PetData.AnyoneCanRide = 1;
            }

            ServerMessage Nfo = new ServerMessage(Outgoing.PetInformation);
            Nfo.AppendInt32(Pet.PetData.PetId);
            Nfo.AppendString(Pet.PetData.Name);
            Nfo.AppendInt32(Pet.PetData.Level);
            Nfo.AppendInt32(20);
            Nfo.AppendInt32(Pet.PetData.experience);
            Nfo.AppendInt32(Pet.PetData.experienceGoal);
            Nfo.AppendInt32(Pet.PetData.Energy);
            Nfo.AppendInt32(100);
            Nfo.AppendInt32(Pet.PetData.Nutrition);
            Nfo.AppendInt32(150);
            //Nfo.AppendString(Color.ToLower());
            Nfo.AppendInt32(Pet.PetData.Respect);
            Nfo.AppendInt32(Pet.PetData.OwnerId);
            Nfo.AppendInt32(Pet.PetData.Age);
            Nfo.AppendString(Pet.PetData.OwnerName);
            Nfo.AppendInt32(1);

            Nfo.AppendBoolean(Pet.PetData.HaveSaddle);

            Nfo.AppendBoolean(SilverwaveEnvironment.GetGame().GetRoomManager().GetRoom(Pet.PetData.RoomId).GetRoomUserManager().GetRoomUserByVirtualId(Pet.PetData.VirtualId).RidingHorse);
            Nfo.AppendInt32(0);
            Nfo.AppendInt32(Pet.PetData.AnyoneCanRide); // Anyone can ride horse
            Nfo.AppendInt32(0);
            Nfo.AppendInt32(0);
            Nfo.AppendInt32(0);
            Nfo.AppendInt32(0);
            Nfo.AppendInt32(0);
            Nfo.AppendInt32(0);
            Nfo.AppendString("");
            Nfo.AppendBoolean(false);
            Nfo.AppendInt32(-1);
            Nfo.AppendInt32(-1);
            Nfo.AppendInt32(-1);
            Nfo.AppendBoolean(false);
            Room.SendMessage(Nfo);
        }
Пример #11
0
        internal void AddSaddle()
        {
            Room Room = SilverwaveEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null || (Room.AllowPets == 0 && !Room.CheckRights(Session, true)))
            {
                return;
            }

            uint ItemId = Request.PopWiredUInt();
            RoomItem Item = Room.GetRoomItemHandler().GetItem(ItemId);
            if (Item == null)
                return; ;

            uint PetId = Request.PopWiredUInt();
            RoomUser PetUser = Room.GetRoomUserManager().GetPet(PetId);

            if (PetUser == null || PetUser.PetData == null || PetUser.PetData.OwnerId != Session.GetHabbo().Id)
            {
                return;
            }

            Room.GetRoomItemHandler().RemoveFurniture(Session, Item.Id, false);

            if (Item.GetBaseItem().Name.Contains("horse_hairdye"))
            {
                string HairType = Item.GetBaseItem().Name.Split('_')[2];
                int HairDye = 48;
                HairDye = HairDye + int.Parse(HairType);
                PetUser.PetData.HairDye = HairDye;

                using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE bots_petdata SET hairdye = '" + PetUser.PetData.HairDye + "' WHERE id = " + PetUser.PetData.PetId);
                }
            }
            else if (Item.GetBaseItem().Name.Contains("horse_dye"))
            {
                string Race = Item.GetBaseItem().Name.Split('_')[2];
                int Parse = int.Parse(Race);
                int RaceLast = 2 + (Parse * 4) - 4;
                if (Parse == 13)
                    RaceLast = 61;
                else if (Parse == 14)
                    RaceLast = 65;
                else if (Parse == 15)
                    RaceLast = 69;
                else if (Parse == 16)
                    RaceLast = 73;
                PetUser.PetData.Race = RaceLast.ToString();

                using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE bots_petdata SET race = '" + PetUser.PetData.Race + "' WHERE id = " + PetUser.PetData.PetId);
                    dbClient.runFastQuery("DELETE FROM items WHERE id=" + Item.Id + " LIMIT 1");
                }
            }
            else if (Item.GetBaseItem().Name.Contains("horse_hairstyle"))
            {
                string HairType = Item.GetBaseItem().Name.Split('_')[2];
                int Parse = 100;
                Parse = Parse + int.Parse(HairType);
                PetUser.PetData.PetHair = Parse;

                using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE bots_petdata SET pethair = '" + PetUser.PetData.PetHair + "' WHERE id = " + PetUser.PetData.PetId);
                    dbClient.runFastQuery("DELETE FROM items WHERE id=" + Item.Id + " LIMIT 1");
                }
            }
            else if (Item.GetBaseItem().Name.Contains("saddle"))
            {
                PetUser.PetData.HaveSaddle = true;

                using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE bots_petdata SET have_saddle = 1 WHERE id = " + PetUser.PetData.PetId);
                    dbClient.runFastQuery("DELETE FROM items WHERE id=" + Item.Id + " LIMIT 1");
                }
            }

            ServerMessage Message = new ServerMessage(Outgoing.PlaceBot);
            Message.AppendInt32(1);
            PetUser.Serialize(Message, false);
            Room.SendMessage(Message);

            ServerMessage AddToPet = new ServerMessage(Outgoing.PetData);
            AddToPet.AppendInt32(PetUser.PetData.VirtualId);
            AddToPet.AppendInt32(PetUser.PetData.PetId);
            AddToPet.AppendInt32(PetUser.PetData.Type);
            AddToPet.AppendInt32(int.Parse(PetUser.PetData.Race));
            AddToPet.AppendString(PetUser.PetData.Color.ToLower());
            if (PetUser.PetData.HaveSaddle)
            {
                AddToPet.AppendInt32(2);
                AddToPet.AppendInt32(3);
                AddToPet.AppendInt32(4);
                AddToPet.AppendInt32(9);
                AddToPet.AppendInt32(0);
                AddToPet.AppendInt32(3);
                AddToPet.AppendInt32(PetUser.PetData.PetHair);
                AddToPet.AppendInt32(PetUser.PetData.HairDye);
                AddToPet.AppendInt32(3);
                AddToPet.AppendInt32(PetUser.PetData.PetHair);
                AddToPet.AppendInt32(PetUser.PetData.HairDye);
            }
            else
            {
                AddToPet.AppendInt32(1);
                AddToPet.AppendInt32(2);
                AddToPet.AppendInt32(2);
                AddToPet.AppendInt32(PetUser.PetData.PetHair);
                AddToPet.AppendInt32(PetUser.PetData.HairDye);
                AddToPet.AppendInt32(3);
                AddToPet.AppendInt32(PetUser.PetData.PetHair);
                AddToPet.AppendInt32(PetUser.PetData.HairDye);
            }
            AddToPet.AppendBoolean(PetUser.PetData.HaveSaddle);
            AddToPet.AppendBoolean(PetUser.RidingHorse);
            Room.SendMessage(AddToPet);
        }
Пример #12
0
        internal bool tryLogin(string AuthTicket)
        {
            try
            {
                string ip = GetConnection().getIp();
                byte errorCode = 0;
                UserData userData = UserDataFactory.GetUserData(AuthTicket, ip, out errorCode);
                if (errorCode == 1)
                {
                    SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso"));
                    return false;
                }
                else if (errorCode == 2)
                {
                    SendNotifWithScroll(LanguageLocale.GetValue("login.loggedin"));
                    return false;
                }

                SilverwaveEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username);
                this.Habbo = userData.user;
                this.Habbo.SSOTicket = AuthTicket;
                userData.user.LoadData(userData);

                string banReason = SilverwaveEnvironment.GetGame().GetBanManager().GetBanReason(userData.user.Username, ip, MachineId);
                if (!string.IsNullOrEmpty(banReason) || userData.user.Username == null)
                {
                    SendNotifWithScroll(banReason);
                    Logging.WriteLine("Banned access from " + MachineId, ConsoleColor.Red);
                    using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        dbClient.setQuery("SELECT ip_last FROM users WHERE id=" + this.GetHabbo().Id + " LIMIT 1");
                        string IP = dbClient.getString();
                        dbClient.setQuery("SELECT COUNT(0) FROM bans_access WHERE user_id=" + this.Habbo.Id + " LIMIT 1");
                        int Count = dbClient.getInteger();
                        if (Count > 0)
                        {
                            dbClient.runFastQuery("UPDATE bans_access SET attempts = attempts + 1, ip='" + IP + "' WHERE user_id=" + this.GetHabbo().Id + " LIMIT 1");
                        }
                        else
                        {
                            dbClient.runFastQuery("INSERT INTO bans_access (user_id, ip) VALUES (" + this.GetHabbo().Id + ", '" + IP + "')");
                        }
                    }
                    return false;
                }

                userData.user.Init(this, userData);

                QueuedServerMessage response = new QueuedServerMessage(Connection);

                ServerMessage UniqueId = new ServerMessage(Outgoing.UniqueID);
                UniqueId.AppendString(this.MachineId);
                response.appendResponse(UniqueId);

                response.appendResponse(new AuthenticationOKComposer());

                if (this.Habbo != null)
                {

                    ServerMessage HomeRoom1 = new ServerMessage(Outgoing.HomeRoom);
                    HomeRoom1.AppendInt32(this.Habbo.HomeRoom); // first home
                    HomeRoom1.AppendInt32(this.Habbo.HomeRoom); // current home
                    response.appendResponse(HomeRoom1);
                }


                ServerMessage MiniMail = new ServerMessage(Outgoing.SerializeMiniMailCount);
                MiniMail.AppendInt32(0);
                response.appendResponse(MiniMail);


                ServerMessage FavouriteRooms = new ServerMessage(Outgoing.FavouriteRooms);
                FavouriteRooms.AppendInt32(30); // max rooms
                FavouriteRooms.AppendInt32(userData.user.FavoriteRooms.Count);
                foreach (uint Id in userData.user.FavoriteRooms.ToArray())
                {
                    FavouriteRooms.AppendInt32(Id);
                }
                response.appendResponse(FavouriteRooms);

                if (this.GetHabbo().GetAvatarEffectsInventoryComponent() != null)
                    SendMessage(this.GetHabbo().GetAvatarEffectsInventoryComponent().Serialize());

                response.appendResponse(new UserRightsComposer((this.Habbo == null) ? 1 : this.Habbo.Rank));

                ServerMessage bools1 = new ServerMessage(Outgoing.bools1);
                bools1.AppendBoolean(true);
                bools1.AppendBoolean(false);
                response.appendResponse(bools1);

                ServerMessage StartConsole = new ServerMessage(Outgoing.EnableConsole);
                StartConsole.AppendBoolean(true);
                response.appendResponse(StartConsole);

                //PixelManager.GivePixels(this, 0);

                ServerMessage mClient = new ServerMessage(Outgoing.ActivityPoints);
                mClient.AppendInt32(11); // ?
                mClient.AppendInt32(0);
                mClient.AppendInt32(Habbo.ActivityPoints);
                mClient.AppendInt32(1);
                mClient.AppendInt32(0);
                mClient.AppendInt32(2);
                mClient.AppendInt32(0);
                mClient.AppendInt32(3);
                mClient.AppendInt32(0);
                mClient.AppendInt32(4);
                mClient.AppendInt32(0); // Pixels
                mClient.AppendInt32(5);
                mClient.AppendInt32(Habbo.BelCredits);
                //seasonal currency
                mClient.AppendInt32(101);
                mClient.AppendInt32(0);
                mClient.AppendInt32(102);
                mClient.AppendInt32(0);
                mClient.AppendInt32(103);
                mClient.AppendInt32(0);
                mClient.AppendInt32(104);
                mClient.AppendInt32(0);
                mClient.AppendInt32(105);
                mClient.AppendInt32(Habbo.BelCredits);
                response.appendResponse(mClient);
                userData.user.UpdateCreditsBalance();

                ServerMessage fuserights = new ServerMessage(Outgoing.Fuserights);
                fuserights.AppendInt32(2);
                if (Habbo.GetSubscriptionManager().HasSubscription)
                {
                    fuserights.AppendInt32(1); //suscription
                }
                else 
                {
                    fuserights.AppendInt32(0); //no-suscription
                }
                //fuserights.AppendInt32(userData.user.Rank);
                fuserights.AppendInt32(0);
                response.appendResponse(fuserights);

                ServerMessage Constructors = new ServerMessage(Outgoing.ConstructorsClubLimits);
                Constructors.AppendInt32(0);  //current used furni
                Constructors.AppendInt32(100);  //max furni
                Constructors.AppendInt32(20000);  // club timestamp ? ye
                response.appendResponse(Constructors);

                ServerMessage KeysEvent = new ServerMessage(Outgoing.HabboColoredKeysEvent);
                KeysEvent.AppendString("");
                KeysEvent.AppendString("");
                response.appendResponse(KeysEvent);

                if (userData.user.HasFuse("fuse_mod"))
                {
                    response.appendResponse(SilverwaveEnvironment.GetGame().GetModerationTool().SerializeTool());
                }

                response.sendResponse();

                if (!string.IsNullOrWhiteSpace(SilverwaveEnvironment.GetDBConfig().DBData["welcome_message"]))
                {
                    this.SendBroadcastMessage(SilverwaveEnvironment.GetDBConfig().DBData["welcome_message"]);
                }
                return true;

            }
            catch (UserDataNotFoundException)
            {
                SendNotifWithScroll("User not found or already logged in.");
            }
            catch (Exception e)
            {
                Logging.LogCriticalException("Bug duing user login: " + e.ToString());
            }
            return false;
        }
Пример #13
0
        internal void SerializeRoomData(ServerMessage Response, bool FromView, GameClient Session, bool SendRoom = false)
        {
            Room Room = SilverwaveEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null || !Room.CheckRights(Session, true))
            {
                return;
            }

            Response.Init(Outgoing.RoomData);
            Response.AppendBoolean(true);
            Response.AppendInt32(Id);
            Response.AppendString(Name);
            Response.AppendBoolean(Type == "private");
            Response.AppendInt32(OwnerId);
            Response.AppendString(Owner);
            Response.AppendInt32(State);
            Response.AppendInt32(UsersNow);
            Response.AppendInt32(UsersMax);
            Response.AppendString(Description);
            Response.AppendInt32(0); //unused, let be 0
            Response.AppendInt32(2);
            Response.AppendInt32(Score);
            Response.AppendInt32(0); // visible for rank > x
            Response.AppendInt32(Category);
            if (GroupId > 0)
            {
                Response.AppendInt32(Group.Id);
                Response.AppendString(Group.Name);
                Response.AppendString(Group.Badge);
                Response.AppendString("");
            }
            else
            {
                Response.AppendInt32(0);
                Response.AppendString("");
                Response.AppendString("");
                Response.AppendString("");
            }
            Response.AppendInt32(TagCount);
            foreach (string Tag in Tags.ToArray())
            {
                Response.AppendString(Tag);
            }
            //GUESTROOM THUMBNAIL^?  disabled
            Response.AppendInt32(0); //
            Response.AppendInt32(0); //
            Response.AppendInt32(0);
            //Response.AppendInt32(0);
            //GUESROOM THUBNAILS ^
            Response.AppendBoolean(AllowPets == 1);
            Response.AppendBoolean(AllowPetsEating == 1);
            Response.AppendString("");  // EVENT related stuff
            Response.AppendString("");  // EVENT related stuff
            Response.AppendInt32(0); // EVENT Time Left, in seconds
            Response.AppendBoolean(FromView); //staff moderation locking the room ?
            Response.AppendBoolean(false);
            Response.AppendBoolean(false);
            Response.AppendBoolean(false);
            Console.WriteLine(WhoCanBan + WhoCanKick + WhoCanMute + ChatType + ChatBalloon);
            Response.AppendInt32(WhoCanMute); // who can mute
            Response.AppendInt32(WhoCanKick); // who can kick
            Response.AppendInt32(WhoCanBan); // who can ban
            Response.AppendBoolean(Room.CheckRights(Session, true));
            Response.AppendInt32(ChatType);  //ChatMode, ChatSize, ChatSpeed, HearingDistance, ExtraFlood is the order.
            Response.AppendInt32(ChatBalloon);
            Response.AppendInt32(ChatSpeed);
            Response.AppendInt32(ChatMaxDistance);
            Response.AppendInt32(ChatFloodProtection);

            if (SendRoom)
            {
                if (SilverwaveEnvironment.GetGame().GetRoomManager().GetRoom(Id) != null)
                    SilverwaveEnvironment.GetGame().GetRoomManager().GetRoom(Id).SendMessage(Response);
            }
            else
                Session.SendMessage(Response);
        }
Пример #14
0
        internal ServerMessage SerializeSearchResults(string SearchQuery)
        {
            DataTable Data = new DataTable();

            using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (SearchQuery.Length > 0)
                {
                    if (SearchQuery.ToLower().StartsWith("owner:"))
                    {
                        dbClient.setQuery("SELECT * FROM rooms WHERE owner = @query AND roomtype = 'private' ORDER BY users_now DESC LIMIT 50");
                        dbClient.addParameter("query", SearchQuery.Remove(0, 6));
                    }
                    else
                    {
                        dbClient.setQuery("SELECT * FROM rooms WHERE caption LIKE @query OR owner LIKE @query AND roomtype = 'private' ORDER BY users_now DESC LIMIT 50");
                        dbClient.addParameter("query", "%" + SearchQuery + "%");
                    }
                    Data = dbClient.getTable();
                }
            }

            List<RoomData> Results = new List<RoomData>();

            if (Data != null)
            {
                foreach (DataRow Row in Data.Rows)
                {
                    RoomData RData = SilverwaveEnvironment.GetGame().GetRoomManager().FetchRoomData(Convert.ToUInt32(Row["id"]), Row);
                    Results.Add(RData);
                }
            }

            ServerMessage Message = new ServerMessage(Outgoing.NavigatorPacket);
            Message.AppendInt32(8);
            Message.AppendString(SearchQuery);
            Message.AppendInt32(Results.Count);

            foreach (RoomData Room in Results)
            {
                Room.Serialize(Message, false);
            }
            Message.AppendBoolean(false);
            return Message;
        }
Пример #15
0
        internal ServerMessage SerializeRecentRooms(GameClient Session)
        {
            ServerMessage Rooms = new ServerMessage(Outgoing.NavigatorPacket);
                Rooms.AppendInt32(7);
                Rooms.AppendString("");
                //Rooms.AppendInt32(ValidRecentRooms.Count);
                Rooms.AppendInt32(0);
                Rooms.AppendBoolean(false);

                return Rooms;
        }
Пример #16
0
        internal void SerializeGroupInfo(Group Group, ServerMessage Response, GameClient Session, Room Room, bool NewWindow = false)
        {
            DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            DateTime Time = origin.AddSeconds(Group.CreateTime);
            Response.Init(Outgoing.SerializeGroupInfo);
            Response.AppendInt32(Group.Id);
            Response.AppendBoolean(true);
            Response.AppendInt32(Group.State); // Type (0 = 50k users, 1 = Request, 2 = blocked, 3 = ?, 4 = ?..
            Response.AppendString(Group.Name);
            Response.AppendString(Group.Description);
            Response.AppendString(Group.Badge);
            Response.AppendInt32(Group.RoomId);
            Response.AppendString((SilverwaveEnvironment.GetGame().GetRoomManager().GenerateRoomData(Group.RoomId) == null) ? "No room found.." : SilverwaveEnvironment.GetGame().GetRoomManager().GenerateRoomData(Group.RoomId).Name); // room name
            Response.AppendInt32((Group.CreatorId == Session.GetHabbo().Id) ? 3 : (Group.Requests.Contains(Session.GetHabbo().Id)) ? 2 : (Group.Members.ContainsKey(Session.GetHabbo().Id)) ? 1 : 0); //Member
            Response.AppendInt32(Group.Members.Count); // Members
            Response.AppendBoolean(Session.GetHabbo().FavouriteGroup == Group.Id);
            Response.AppendString(Time.Day + "-" + Time.Month + "-" + Time.Year);
            Response.AppendBoolean(Group.CreatorId == Session.GetHabbo().Id);
            Response.AppendBoolean((Group.Admins.ContainsKey(Session.GetHabbo().Id)));
            Response.AppendString((SilverwaveEnvironment.getHabboForId(Group.CreatorId) == null) ? "" : SilverwaveEnvironment.getHabboForId(Group.CreatorId).Username);
            Response.AppendBoolean(NewWindow); // Show group info
            Response.AppendBoolean(Group.AdminOnlyDeco == 0); // Any user can place furni in home room
            Response.AppendInt32(Group.Requests.Count); // Pending users
            Response.AppendBoolean(true);
            if (Room != null)
                Room.SendMessage(Response);
            else if (Session != null)
                Session.SendMessage(Response);

            /*if (Session.GetHabbo().Id == Group.CreatorId)
                SerializeGroupInfo(Group, Response, Session, false);*/
        }
Пример #17
0
        internal void Serialize(ServerMessage Message, Boolean ShowEvents)
        {
            Message.AppendInt32(Id);
            Message.AppendString(Name);
            Message.AppendBoolean((411510 != OwnerId) && Type == "private"); // display owner info
            Message.AppendInt32(OwnerId);
            Message.AppendString(Owner);
            Message.AppendInt32(State); // room state
            Message.AppendInt32(UsersNow);
            Message.AppendInt32(UsersMax);
            Message.AppendString(Description);
            Message.AppendInt32(0); // dunno!
            Message.AppendInt32(2); // can trade?
            Message.AppendInt32(Score);
            Message.AppendInt32(0);
            Message.AppendInt32(Category);

            if (Group != null)
            {
                Message.AppendInt32(Group.Id);
                Message.AppendString(Group.Name);
                Message.AppendString(Group.Badge);
                Message.AppendString("");
            }
            else
            {
                Message.AppendInt32(0);
                Message.AppendString("");
                Message.AppendString("");
                Message.AppendString("");
            }
            Message.AppendInt32(TagCount);

            foreach (string Tag in Tags)
            {
                Message.AppendString(Tag);
            }
            Message.AppendInt32(0);
            Message.AppendInt32(0);
            Message.AppendBoolean(false);
            Message.AppendBoolean(false);

            if (Event != null)
            {
                if (Event.HasExpired)
                {
                    SilverwaveEnvironment.GetGame().GetRoomEvents().RemoveEvent(Id);
                }
                Message.AppendInt32(1);
                Message.AppendString(Event.Name);
                Message.AppendString(Event.Description);
                Message.AppendInt32((int)Math.Floor((double)(Event.Time - SilverwaveEnvironment.GetUnixTimestamp()) / 60));
            }
            else
            {
                Message.AppendInt32(0);
                Message.AppendString("");
                Message.AppendString("");
                Message.AppendInt32(0);
            }
        }
Пример #18
0
        private void SerializeNavigatorPopularRooms(ref ServerMessage reply, KeyValuePair<RoomData, int>[] rooms, int Category)
        {
            reply.AppendInt32(rooms.Length);
            int i = 0;
            foreach (KeyValuePair<RoomData, int> pair in rooms)
            {
                RoomData data = pair.Key;
                if (data.Category.Equals(Category))
                {
                    data.Serialize(reply, false);
                    i++;
                }
                else
                    continue;
            }
            reply.setInt(i, 8 + Category.ToString().Length);

            reply.AppendInt32(0);
            reply.AppendInt32(0);
            reply.AppendBoolean(false);
        }
Пример #19
0
        internal void Serialize(ServerMessage Message)
        {
            try
            {
                Message.AppendInt32(Id);
                Message.AppendString(Caption);
                Message.AppendString(Description); // description
                Message.AppendInt32(Type); // image size
                Message.AppendString(Caption);
                Message.AppendString(Image);
                Message.AppendInt32(ParentId > 0 ? ParentId : 0);
                Message.AppendInt32(RoomInfo != null ? RoomInfo.UsersNow : 0);
                Message.AppendInt32(itemType == PublicItemType.NONE ? 0 : (itemType == PublicItemType.TAG ? 1 : (itemType == PublicItemType.FLAT ? 2 : (itemType == PublicItemType.PUBLIC_FLAT ? 2 : (itemType == PublicItemType.CATEGORY ? 4 : 0)))));

                if (this.itemType == PublicItemType.TAG)
                {
                    Message.AppendString(TagsToSearch); return;
                }
                else if (this.itemType == PublicItemType.CATEGORY)
                {
                    Message.AppendBoolean(false); return;
                }
                else if (this.itemType == PublicItemType.FLAT)
                {
                    this.RoomInfo.Serialize(Message, false);
                }
                else if (this.itemType == PublicItemType.PUBLIC_FLAT)
                {
                    this.RoomInfo.Serialize(Message, false);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on publicitems composing: " + e.ToString());
            }
        }
Пример #20
0
        private void SerializeNavigatorRooms(ref ServerMessage reply, List<RoomData> rooms)
        {
            reply.AppendString("");
            reply.AppendInt32(rooms.Count);
            foreach (RoomData data in rooms)
            {

                data.Serialize(reply, false);
            }
            reply.AppendBoolean(false);
        }
Пример #21
0
        internal void Serialize(ServerMessage Message)
        {
            try
            {
                if (PageID == 5)
                    return; // club
                {
                    Message.AppendInt32(this.Id);
                    Message.AppendString(this.Name);
                    Message.AppendBoolean(false);
                    Message.AppendInt32(this.CreditsCost);
                    if (this.BelCreditsCost > 0)
                    {
                        Message.AppendInt32(BelCreditsCost);
                        Message.AppendInt32(105);
                    }
                    else
                    {
                        Message.AppendInt32(DucketsCost);
                        Message.AppendInt32(0); //
                    }
                    Message.AppendBoolean(true);//false sul pac   true
                    if (Badge == "")
                    {
                        Message.AppendInt32(Items.Count);
                    }
                    else
                    {
                        Message.AppendInt32(Items.Count + 1);
                        Message.AppendString("b");
                        Message.AppendString(Badge);
                    }
                }

                foreach (uint i in Items)
                {
                    Message.AppendString(GetBaseItem(i).Type.ToString());
                    if (GetBaseItem(i).Type.ToString().ToLower() == "b")
                    {
                        Message.AppendString("RADZZ");
                        Message.AppendInt32(0);
                    }
                    else
                    {
                        Message.AppendInt32(GetBaseItem(i).SpriteId);
                        // extradata
                        if (Name.Contains("wallpaper_single") || Name.Contains("floor_single") || Name.Contains("landscape_single"))
                        {
                            string[] Analyze = Name.Split('_');
                            Message.AppendString(Analyze[2]);
                        }
                        else if (Name.Contains("rentable_bot"))
                        {
                            Message.AppendString("hr-3020-34.hd-3091-2.ch-225-92.lg-3058-100.sh-3089-1338.ca-3084-78-108.wa-2005");
                        }
                        else if (this.songID > 0 && GetBaseItem(i).InteractionType == InteractionType.musicdisc)
                        {
                            Message.AppendString(songID.ToString());
                        }
                        else
                        {
                            Message.AppendString(string.Empty);
                        }
                        Message.AppendInt32(Amount);

                        Message.AppendBoolean(this.IsLimited); // IsLimited
                        if (this.IsLimited)
                        {
                            Message.AppendInt32(this.LimitedStack);
                            Message.AppendInt32(this.LimitedStack - this.LimitedSelled);
                        }
                    }
                    Message.AppendInt32(0); // club_level
                    if (this.IsLimited || this.Amount != 1 || Name.ToLower().StartsWith("cf_") || Name.ToLower().StartsWith("cfc_"))
                        Message.AppendBoolean(false); // IsOffer
                    else
                        Message.AppendBoolean(this.HaveOffer);
                }
            }

            catch
            {
                Logging.WriteLine("Unable to load furniture item " + Id + ": " + Name, ConsoleColor.Red);
            }
        }
Пример #22
0
 private void SerializeNavigatorRooms(ref ServerMessage reply, Dictionary<uint, RoomEvent> Events)
 {
     reply.AppendString("");
     reply.AppendInt32(Events.Count);
     foreach (RoomEvent e in Events.Values)
     {
         RoomData data = SilverwaveEnvironment.GetGame().GetRoomManager().GenerateRoomData(e.RoomId);
         data.Serialize(reply, false);
     }
     reply.AppendBoolean(false);
 }
Пример #23
0
        internal void MountOnPet()
        {
            Room Room = SilverwaveEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            //if (Room == null || Room.IsPublic || (!Room.AllowPets && !Room.CheckRights(Session, true)))
            if (Room == null)
            {
                return;
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (User == null)
                return;

            uint PetId = Request.PopWiredUInt();
            bool Type = Request.PopWiredBoolean();
            RoomUser Pet = Room.GetRoomUserManager().GetPet(PetId);

            //if (Pet == null || Pet.PetData == null || Pet.PetData.OwnerId != Session.GetHabbo().Id)
            if (Pet == null || Pet.PetData == null)
            {
                return;
            }
            if (Pet.PetData.AnyoneCanRide == 0 && Pet.PetData.OwnerId != User.userID)
            {
                Session.SendNotif("You are unable to ride this horse.\nThe owner of the pet has not selected for anyone to ride it.");
                return;
            }

            if (Type)
            {

                if (Pet.RidingHorse == true)
                {
                    string[] Speech2 = PetLocale.GetValue("pet.alreadymounted");
                    Random RandomSpeech2 = new Random();
                    Pet.Chat(null, Speech2[RandomSpeech2.Next(0, Speech2.Length - 1)], false, 0, 0);
                }
                else if (User.RidingHorse == true)
                {
                    Session.SendNotif("You are already riding a horse!");
                }
                else
                {
                    Pet.Statusses.Remove("sit");
                    Pet.Statusses.Remove("lay");
                    Pet.Statusses.Remove("snf");
                    Pet.Statusses.Remove("eat");
                    Pet.Statusses.Remove("ded");
                    Pet.Statusses.Remove("jmp");
                    int NewX2 = User.X;
                    int NewY2 = User.Y;
                    //Pet.PetData.Addexperience(10); // Give XP
                    Room.SendMessage(Room.GetRoomItemHandler().UpdateUserOnRoller(Pet, new Point(NewX2, NewY2), 0, Room.GetGameMap().SqAbsoluteHeight(NewX2, NewY2)));
                    Room.GetRoomUserManager().UpdateUserStatus(Pet, false);
                    Room.SendMessage(Room.GetRoomItemHandler().UpdateUserOnRoller(User, new Point(NewX2, NewY2), 0, Room.GetGameMap().SqAbsoluteHeight(NewX2, NewY2) + 1));
                    Room.GetRoomUserManager().UpdateUserStatus(User, false);
                    Pet.ClearMovement(true);
                    User.RidingHorse = true;
                    Pet.RidingHorse = true;
                    Pet.HorseID = (uint)User.VirtualId;
                    User.HorseID = Convert.ToUInt32(Pet.VirtualId);
                    User.ApplyEffect(77);
                    User.Z += 1;
                    User.UpdateNeeded = true;
                    Pet.UpdateNeeded = true;
                }
            }
            else
            {
                if (User.VirtualId == Pet.HorseID)
                {
                    Pet.Statusses.Remove("sit");
                    Pet.Statusses.Remove("lay");
                    Pet.Statusses.Remove("snf");
                    Pet.Statusses.Remove("eat");
                    Pet.Statusses.Remove("ded");
                    Pet.Statusses.Remove("jmp");
                    User.RidingHorse = false;
                    User.HorseID = 0;
                    Pet.RidingHorse = false;
                    Pet.HorseID = 0;
                    User.MoveTo(new Point(User.X + 2, User.Y + 2));
                    User.ApplyEffect(-1);
                    User.UpdateNeeded = true;
                    Pet.UpdateNeeded = true;
                }
                else
                {
                    Session.SendNotif("Could not dismount this horse - You are not riding it!");
                }
            }

            ServerMessage AddToPet = new ServerMessage(Outgoing.PetData);
            AddToPet.AppendInt32(Pet.PetData.VirtualId);
            AddToPet.AppendInt32(Pet.PetData.PetId);
            AddToPet.AppendInt32(Pet.PetData.Type);
            AddToPet.AppendInt32(int.Parse(Pet.PetData.Race));
            AddToPet.AppendString(Pet.PetData.Color.ToLower());
            AddToPet.AppendInt32(2);
            AddToPet.AppendInt32(3);
            AddToPet.AppendInt32(4);
            AddToPet.AppendInt32(9);
            AddToPet.AppendInt32(0);
            AddToPet.AppendInt32(3);
            AddToPet.AppendInt32(Pet.PetData.PetHair);
            AddToPet.AppendInt32(Pet.PetData.HairDye);
            AddToPet.AppendInt32(3);
            AddToPet.AppendInt32(Pet.PetData.PetHair);
            AddToPet.AppendInt32(Pet.PetData.HairDye);
            AddToPet.AppendBoolean(Pet.PetData.HaveSaddle);
            AddToPet.AppendBoolean((Pet.RidingHorse) ? true : false);
            Room.SendMessage(AddToPet);
        }
Пример #24
0
        private void SerializeNavigatorRooms(ref ServerMessage reply, KeyValuePair<RoomData, int>[] rooms)
        {
            reply.AppendString(string.Empty);
            reply.AppendInt32(rooms.Length);

            foreach (KeyValuePair<RoomData,int> pair in rooms)
            {
                pair.Key.Serialize(reply, false);
            }
            reply.AppendBoolean(false);
        }
Пример #25
0
        internal void RemoveSaddle()
        {
            Room Room = SilverwaveEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null || (Room.AllowPets == 0 && !Room.CheckRights(Session, true)))
            {
                return;
            }

            uint PetId = Request.PopWiredUInt();
            RoomUser PetUser = Room.GetRoomUserManager().GetPet(PetId);

            if (PetUser == null || PetUser.PetData == null || PetUser.PetData.OwnerId != Session.GetHabbo().Id)
            {
                return;
            }

            //SilverwaveEnvironment.GetGame().GetCatalog().DeliverItems(Session, SilverwaveEnvironment.GetGame().GetItemManager().GetItem((uint)2804), 1, "");
            PetUser.PetData.HaveSaddle = false;

            using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
            {
                //dbClient.addParameter("userid", Session.GetHabbo().Id);
                dbClient.runFastQuery("UPDATE bots_petdata SET have_saddle = 0 WHERE id = " + PetUser.PetData.PetId);
                dbClient.runFastQuery("INSERT INTO items (user_id, base_item) VALUES (" + Session.GetHabbo().Id + ", 4221);");
            }
            Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
            ServerMessage Message = new ServerMessage(Outgoing.PlaceBot);
            Message.AppendInt32(1);
            PetUser.Serialize(Message, false);
            Room.SendMessage(Message);

            ServerMessage AddToPet = new ServerMessage(Outgoing.PetData);
            AddToPet.AppendInt32(PetUser.PetData.VirtualId);
            AddToPet.AppendInt32(PetUser.PetData.PetId);
            AddToPet.AppendInt32(PetUser.PetData.Type);
            AddToPet.AppendInt32(int.Parse(PetUser.PetData.Race));
            AddToPet.AppendString(PetUser.PetData.Color.ToLower());
            AddToPet.AppendInt32(1);
            AddToPet.AppendInt32(2);
            AddToPet.AppendInt32(2);
            AddToPet.AppendInt32(PetUser.PetData.PetHair);
            AddToPet.AppendInt32(PetUser.PetData.HairDye);
            AddToPet.AppendInt32(3);
            AddToPet.AppendInt32(PetUser.PetData.PetHair);
            AddToPet.AppendInt32(PetUser.PetData.HairDye);
            AddToPet.AppendBoolean(PetUser.PetData.HaveSaddle);
            AddToPet.AppendBoolean(PetUser.RidingHorse);
            Room.SendMessage(AddToPet);
        }
Пример #26
0
        internal ServerMessage SerializeFavoriteRooms(GameClient Session)
        {
            ServerMessage Rooms = new ServerMessage(Outgoing.NavigatorPacket);
            Rooms.AppendInt32(6);
            Rooms.AppendString("");
            Rooms.AppendInt32(Session.GetHabbo().FavoriteRooms.Count);

            RoomData room;
            foreach (uint Id in Session.GetHabbo().FavoriteRooms.ToArray())
            {
                room = SilverwaveEnvironment.GetGame().GetRoomManager().GenerateRoomData(Id);
                if (room != null)
                    room.Serialize(Rooms, false);
            }
            Rooms.AppendBoolean(false);
            return Rooms;
        }
Пример #27
0
        internal void FlushSettings()
        {
            List<ServerMessage> messages = new List<ServerMessage>();

            lock (GetRoomItemHandler().mFloorItems)
            {
                foreach (RoomItem Item in GetRoomItemHandler().mFloorItems.Values)
                {
                    ServerMessage Message = new ServerMessage(94);
                    Message.AppendRawUInt(Item.Id);
                    Message.AppendString("");
                    Message.AppendBoolean(false);
                    messages.Add(Message);
                }
            }

            lock (GetRoomItemHandler().mWallItems)
            {
                foreach (RoomItem Item in GetRoomItemHandler().mWallItems.Values)
                {
                    ServerMessage Message = new ServerMessage(84);
                    Message.AppendRawUInt(Item.Id);
                    Message.AppendString("");
                    Message.AppendBoolean(false);
                    messages.Add(Message);
                }
            }

            SendMessage(messages);

            mCycleEnded = true;
            using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                GetRoomItemHandler().SaveFurniture(dbClient);

            Tags.Clear();
            UsersWithRights.Clear();
            Bans.Clear();
            ActiveTrades.Clear();
            LoadedGroups.Clear();

            if (GotFreeze())
                freeze = new Freeze(this);
            if (GotBanzai())
                banzai = new BattleBanzai(this);
            if (GotSoccer())
                soccer = new Soccer(this);
            if (gameItemHandler != null)
                gameItemHandler = new GameItemHandler(this);
        }
Пример #28
0
        internal void LoadSettings()
        {
            String[] Row;
            int CurrentVolume = 0;
            using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT volume FROM users WHERE id = '" + Session.GetHabbo().Id + "' LIMIT 1");
                Row = dbClient.getString().Split(',');

                ServerMessage LoadSettings = new ServerMessage(Outgoing.LoadVolume);
                foreach (String String in Row)
                {
                    CurrentVolume = Convert.ToInt32(String);
                    if (CurrentVolume > 100 || CurrentVolume < 0)
                        CurrentVolume = 100;
                    LoadSettings.AppendInt32(CurrentVolume);
                }
                LoadSettings.AppendBoolean(false);
                Session.SendMessage(LoadSettings);
            }
        }
Пример #29
0
        internal static void SerializeQuest(ServerMessage Message, GameClient Session, Quest Quest, string Category)
        {
            if (Message == null || Session == null)
                return;
            int AmountInCat = SilverwaveEnvironment.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.AppendString(Category);
            Message.AppendInt32(Quest == null ? 0 : ((Quest.Category.Contains("xmas2012")) ? 0 : Number)); // Quest progress in this cat
            Message.AppendInt32(Quest == null ? 0 : (Quest.Category.Contains("xmas2012")) ? 0 : AmountInCat); // Total quests in this cat
            Message.AppendInt32(Quest == null ? 3 : Quest.RewardType); // Reward type (1 = Snowflakes, 2 = Love hearts, 3 = Pixels, 4 = Seashells, everything else is pixels
            Message.AppendInt32(Quest == null ? 0 : Quest.Id); // Quest id
            Message.AppendBoolean(Quest == null ? false : Session.GetHabbo().CurrentQuestId == Quest.Id); // Quest started
            Message.AppendString(Quest == null ? string.Empty : Quest.ActionName);
            Message.AppendString(Quest == null ? string.Empty : Quest.DataBit);
            Message.AppendInt32(Quest == null ? 0 : Quest.Reward);
            Message.AppendString(Quest == null ? string.Empty : Quest.Name);
            Message.AppendInt32(UserProgress); // Current progress
            Message.AppendInt32(Quest == null ? 0 : Quest.GoalData); // Target progress
            Message.AppendInt32(Quest == null ? 0 : Quest.TimeUnlock); // "Next quest available countdown" in seconds
            Message.AppendString("");
            Message.AppendString("");
            Message.AppendBoolean(true);
        }
Пример #30
0
        internal ServerMessage SerializeGroupMembers(ServerMessage Response, Group Group, uint ReqType, GameClient Session, string SearchVal = "", int Page = 0)
        {
            if (Group == null || Session == null)
                return null;

            if (Page < 1)
                Page = 0;

            List<List<GroupUser>> Users = Split(GetGroupUsersByString(Group, SearchVal, ReqType));
            Response.AppendInt32(Group.Id);
            Response.AppendString(Group.Name);
            Response.AppendInt32(Group.RoomId);
            Response.AppendString(Group.Badge);
            switch (ReqType)
            {
                case 0:
                    Response.AppendInt32(Group.Members.Count);
                    Response.AppendInt32(Users[(int)Page].Count);
                    foreach (GroupUser User in Users[(int)Page])
                    {
                        Habbo Habbo = SilverwaveEnvironment.getHabboForId(User.Id);
                        if (Habbo == null)
                        {
                            Response.AppendInt32(0);
                            Response.AppendInt32(0);
                            Response.AppendString("");
                            Response.AppendString("");
                            Response.AppendString("");
                        }
                        else
                        {
                            Response.AppendInt32((User.Rank == 2) ? 0 : (User.Rank == 1) ? 1 : 2);
                            Response.AppendInt32(Habbo.Id);
                            Response.AppendString(Habbo.Username);
                            Response.AppendString(Habbo.Look);
                            Response.AppendString("");
                        }
                    }
                    break;
                case 1:
                    Response.AppendInt32(Group.Admins.Count);
                    if (Group.Admins.Count > 0)
                    {
                        Response.AppendInt32(Users[(int)Page].Count);
                        foreach (GroupUser User in Users[(int)Page])
                        {
                            Habbo Habbo = SilverwaveEnvironment.getHabboForId(User.Id);
                            if (Habbo == null)
                            {
                                Response.AppendInt32(0);
                                Response.AppendInt32(0);
                                Response.AppendString("");
                                Response.AppendString("");
                                Response.AppendString("");
                            }
                            else
                            {
                                Response.AppendInt32((User.Rank == 2) ? 0 : (User.Rank == 1) ? 1 : 2);
                                Response.AppendInt32(Habbo.Id);
                                Response.AppendString(Habbo.Username);
                                Response.AppendString(Habbo.Look);
                                Response.AppendString("");
                            }
                        }
                    }
                    else
                        Response.AppendInt32(0);
                    break;

                case 2:
                    List<List<uint>> Userx = Split(GetGroupRequestsByString(Group, SearchVal, ReqType));
                    Response.AppendInt32(Group.Requests.Count);
                    if (Group.Requests.Count > 0)
                    {
                        Response.AppendInt32(Userx[(int)Page].Count);
                        foreach (uint User in Userx[(int)Page])
                        {
                            Habbo Habbo = SilverwaveEnvironment.getHabboForId(User);
                            if (Habbo == null)
                            {
                                Response.AppendInt32(0);
                                Response.AppendInt32(0);
                                Response.AppendString("");
                                Response.AppendString("");
                                Response.AppendString("");
                            }
                            else
                            {
                                Response.AppendInt32(3);
                                Response.AppendInt32(Habbo.Id);
                                Response.AppendString(Habbo.Username);
                                Response.AppendString(Habbo.Look);
                                Response.AppendString("");
                            }
                        }
                    }
                    else
                        Response.AppendInt32(0);
                    break;
            }
            Response.AppendBoolean((Session.GetHabbo().Id == Group.CreatorId));
            Response.AppendInt32(14);
            Response.AppendInt32(Page);
            Response.AppendInt32(ReqType); // 0 = all users, 1 = admins, 2 = requests
            Response.AppendString(SearchVal);
            return Response;
        }