Beispiel #1
0
        internal bool UserGotAuthorization(GameClient session)
        {
            foreach(string subs in clubsAllowed){
                if (session.GetHabbo().GetSubscriptionManager().HasSubscription(subs))
                    return true;
            }

            if (minrank == 0)
                return true;
            else if (minrank > 0)
            {
                if (minrank <= session.GetHabbo().Rank)
                    return true;
            }
            else if (minrank < 0)
            {
                if (minrank == -1)
                {
                    if (session.GetHabbo().CurrentRoom.CheckRights(session, false))
                        return true;
                }
                else if (minrank == -2)
                {
                    if (session.GetHabbo().CurrentRoom.CheckRights(session, true))
                        return true;
                }
            }

            return false;
        }
Beispiel #2
0
        private static void AddToPlaylist(GameClient Session, ClientMessage Message)
        {
            Room Instance = Session.GetHabbo().CurrentRoom;

            if (Instance == null || !Instance.CheckRights(Session, true) || !Instance.GotMusicController() ||
                Instance.GetRoomMusicController().PlaylistSize >= Instance.GetRoomMusicController().PlaylistCapacity)
            {
                return;
            }

            UserItem DiskUserItem = Session.GetHabbo().GetInventoryComponent().GetItem(Message.ReadUInt32());

            if (DiskUserItem == null || DiskUserItem.GetBaseItem().InteractionType != InteractionType.musicdisc)
            {
                return;
            }

            SongItem item = new SongItem(DiskUserItem);

            int NewOrder = Instance.GetRoomMusicController().AddDisk(item);

            if (NewOrder < 0)
            {
                return;
            }

            Session.GetHabbo().GetInventoryComponent().RemoveItem(item.itemID, true);

            Session.SendMessage(JukeboxComposer.Compose(Instance.GetRoomMusicController().PlaylistCapacity,
                Instance.GetRoomMusicController().Playlist.Values.ToList()));
        }
Beispiel #3
0
        internal static void SellItem(GameClient Session, uint ItemId, int SellingPrice)
        {
            UserItem Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);

            if (Item == null || SellingPrice > 10000 || !CanSellItem(Item))
            {
                Session.GetMessageHandler().GetResponse().Init(610);
                Session.GetMessageHandler().GetResponse().AppendBoolean(false);
                Session.GetMessageHandler().GetResponse();
                Session.GetMessageHandler().SendResponse();
                return;
            }

            int Comission = CalculateComissionPrice(SellingPrice);
            int TotalPrice = SellingPrice + Comission;
            int ItemType = 1;

            if (Item.GetBaseItem().Type == 'i')
                ItemType++;

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("INSERT INTO catalog_marketplace_offers (item_id,user_id,asking_price,total_price,public_name,sprite_id,item_type,timestamp,extra_data) VALUES (" + Item.BaseItem + "," + Session.GetHabbo().Id + "," + SellingPrice + "," + TotalPrice + ",@public_name," + Item.GetBaseItem().SpriteId + "," + ItemType + "," + FirewindEnvironment.GetUnixTimestamp() + ",@extra_data)");
                dbClient.addParameter("public_name", "NEEDS REPLACMENT HERE");
                dbClient.addParameter("extra_data", Item.Data);
                dbClient.runQuery();
            }

            Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId, false);
            Session.GetHabbo().GetInventoryComponent().RunDBUpdate();

            Session.GetMessageHandler().GetResponse().Init(610);
            Session.GetMessageHandler().GetResponse().AppendBoolean(true);
            Session.GetMessageHandler().SendResponse();
        }
        internal AvatarEffectsInventoryComponent(int UserId, GameClient pClient, UserData data)
        {
            _removeQueue = new Queue();
            this.mClient = pClient;
            this.Effects = new ArrayList();
            this.UserId = UserId;
            this.CurrentEffect = -1;
            this.Effects.Clear();

            StringBuilder QueryBuilder = new StringBuilder();
            foreach (AvatarEffect effect in data.effects)
            {
                if (!effect.HasExpired)
                {
                    Effects.Add(effect);
                    EffectCount++;
                }
                else
                    QueryBuilder.Append("DELETE FROM user_effects WHERE user_id = " + UserId + " AND effect_id = " + effect.EffectId + "; ");
            }

            if (QueryBuilder.Length > 0)
            {
                using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
                    dbClient.runFastQuery(QueryBuilder.ToString());
            }
        }
Beispiel #5
0
        public Group CreateGroup(GameClient creator, string name, string description, int roomID, int color1, int color2, List<Tuple<int, int, int>> badgeData)
        {
            // We call this method after doing all checks.
            int groupID;
            string badgeCode = Group.GenerateBadgeImage(badgeData);
            string createTime = DateTime.Now.ToString("d-M-yyyy");
            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                // Insert the group
                dbClient.setQuery("INSERT INTO guild(name,description,badge,users_id,rooms_id,color1,color2,date_created) VALUES(@name,@desc,@badge,@ownerid,@roomid,@color1,@color2,@date)");
                dbClient.addParameter("name", name);
                dbClient.addParameter("desc", description);
                dbClient.addParameter("ownerid", creator.GetHabbo().Id);
                dbClient.addParameter("roomid", roomID);
                dbClient.addParameter("color1", color1);
                dbClient.addParameter("color2", color2);
                dbClient.addParameter("badge", badgeCode);
                dbClient.addParameter("date", createTime);
                groupID = (int)dbClient.insertQuery();
            }

            Group group = new Group()
            {
                ID = groupID,
                Name = name,
                Description = description,
                RoomID = roomID,
                ColorID1 = color1,
                ColorID2 = color2,
                BadgeCode = badgeCode,
                DateCreated = createTime,

            };
            return group;
        }
Beispiel #6
0
        internal static void AlertUser(GameClient ModSession, uint UserId, String Message, Boolean Caution)
        {
            GameClient Client = FirewindEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);

            if (Client == null || Client.GetHabbo().Id == ModSession.GetHabbo().Id)
            {
                return;
            }

            if (Caution && Client.GetHabbo().Rank >= ModSession.GetHabbo().Rank)
            {
                ModSession.SendNotif(LanguageLocale.GetValue("moderation.caution.missingrank"));
                Caution = false;
            }

            Client.SendNotif(Message, Caution);

            if (Caution)
            {
                using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE user_info SET cautions = cautions + 1 WHERE user_id = " + UserId + "");
                }
            }
        }
Beispiel #7
0
        internal static void GivePixels(GameClient Client, int amount)
        {
            Double Timestamp = FirewindEnvironment.GetUnixTimestamp();

            Client.GetHabbo().LastActivityPointsUpdate = Timestamp;
            Client.GetHabbo().ActivityPoints += amount;
            Client.GetHabbo().UpdateActivityPointsBalance(0);
        }
Beispiel #8
0
        public RoomUser(int virtualID, GameClient client, Room room)
            : base(virtualID, room)
        {
            // Base constructor already called
            this.Client = client;

            Habbo habbo = client.GetHabbo();
            this.ID = habbo.Id;
            this.Name = habbo.Username;
            this.Figure = habbo.Look;
            this.Motto = habbo.Motto;
        }
 internal static InventoryComponent GetInventory(int UserId, GameClient Client, UserData data)
 {
     return new InventoryComponent(UserId, Client, data);
     //InventoryComponent component;
     //if (storage.TryGetValue(UserId, out component))
     //    return component;
     //else
     //{
     //    InventoryComponent toReturn =
     //    storage.Add(UserId, toReturn);
     //    return toReturn;
     //}
 }
        internal static string GenerateCommandList(GameClient client)
        {
            StringBuilder notif = new StringBuilder();

            foreach (ChatCommand command in commandRegisterInvokeable.Values)
            {
                if (command.commandID == 43)
                    continue;

                if (command.UserGotAuthorization(client))
                    notif.Append(':' + command.input.TrimStart() + ' ' + command.prefix + " - " + command.description + "\r\r");
            }

            return notif.ToString();
        }
Beispiel #11
0
        internal override bool OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRights)
        {
            if (!UserHasRights)
            {
                return false;
            }

            if (Item.data.GetData() == "0")
            {
                ((StringData)Item.data).Data = "1";
                Item.UpdateState(false, true);
                Item.ReqUpdate(4, true);
                return true;
            }
            return false;
        }
Beispiel #12
0
        public Group CreateGroup(GameClient creator, string name, string description, int roomID, int color1, int color2, List<Tuple<int, int, int>> badgeData)
        {
            // We call this method after doing all checks.
            int groupID;
            //string badgeCode = Group.GenerateBadgeImage(badgeData);
            string createTime = DateTime.Now.ToString("d-M-yyyy");
            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                // Insert the group
                dbClient.setQuery("INSERT INTO groups(name,description,badge_data,users_id,rooms_id,color1,color2,date_created) VALUES(@name,@desc,@badge,@ownerid,@roomid,@color1,@color2,@date)");
                dbClient.addParameter("name", name);
                dbClient.addParameter("desc", description);
                dbClient.addParameter("ownerid", creator.GetHabbo().Id);
                dbClient.addParameter("roomid", roomID);
                dbClient.addParameter("color1", color1);
                dbClient.addParameter("color2", color2);
                dbClient.addParameter("badge", Group.ConvertBadgeForDatabase(badgeData));
                dbClient.addParameter("date", createTime);
                groupID = (int)dbClient.insertQuery();

                // Create membership for owner
                dbClient.setQuery("INSERT INTO group_memberships VALUES(@id,@groupid,3,1)");
                dbClient.addParameter("id", creator.GetHabbo().Id);
                dbClient.addParameter("groupid", groupID);
                dbClient.runQuery();

                // Update room
                dbClient.runFastQuery("UPDATE rooms SET groups_id = " + groupID + " WHERE id = " + roomID);
            }

            Group group = new Group()
            {
                ID = groupID,
                Name = name,
                Description = description,
                RoomID = roomID,
                ColorID1 = color1,
                ColorID2 = color2,
                BadgeData = badgeData,
                DateCreated = createTime

            };
            group.Members.Add(creator.GetHabbo().Id);
            string s = group.BadgeCode;

            return group;
        }
Beispiel #13
0
        internal override bool OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRights)
        {
            if (Session == null)
                return false;
            RoomUser interactingUser = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            Point userCoord = interactingUser.Coordinate;
            Point ballCoord = Item.Coordinate;

            int differenceX = userCoord.X - ballCoord.X;
            int differenceY = userCoord.Y - ballCoord.Y;

            if (differenceX <= 1 && differenceX >= -1 && differenceY <= 1 && differenceY >= -1)
            {
                differenceX = differenceX * 2;
                differenceY = differenceY * 2;

                int newX = Item.GetX + differenceX;
                int newY = Item.GetY + differenceY;

                Item.GetRoom().GetSoccer().MoveBall(Item, Session, newX, newY);
                interactingUser.MoveTo(ballCoord);
            }
            else //if (differenceX == 2 || differenceY == 2 || differenceY == - 2 || differenceX == -2)
            {
                Item.interactingBallUser = Session.GetHabbo().Id;

                differenceX = differenceX * (-1);
                differenceY = differenceY * (-1);

                if (differenceX > 1)
                    differenceX = 1;
                else if (differenceX < -1)
                    differenceX = -1;

                if (differenceY > 1)
                    differenceY = 1;
                else if (differenceY < -1)
                    differenceY = -1;

                int newX = Item.GetX + differenceX;
                int newY = Item.GetY + differenceY;

                interactingUser.MoveTo(new Point(newX, newY));
            }
            return true;
        }
Beispiel #14
0
        internal static Boolean NeedsUpdate(GameClient Client)
        {
            try
            {
                if (Client.GetHabbo() == null)
                    return false;

                Double PassedMins = (FirewindEnvironment.GetUnixTimestamp() - Client.GetHabbo().LastActivityPointsUpdate) / 60;

                if (PassedMins >= RCV_EVERY_MINS)
                    return true;
            }
            catch (Exception e)
            {
                Logging.HandleException(e, "PixelManager.NeedsUpdate");
            }
            return false;
        }
Beispiel #15
0
        internal ServerMessage Serialize(GameClient Session)
        {
            ServerMessage Message = new ServerMessage(Outgoing.RoomEvent);
            Message.AppendString(Session.GetHabbo().Id + "");
            Message.AppendString(Session.GetHabbo().Username);
            Message.AppendString(RoomId + "");
            Message.AppendInt32(Category);
            Message.AppendString(Name);
            Message.AppendString(Description);
            Message.AppendString(StartTime);
            Message.AppendInt32(Tags.Count);

            foreach (string Tag in Tags.ToArray())
            {
                Message.AppendString(Tag);
            }
            return Message;
        }
        internal static ChatMessage CreateMessage(string message, GameClient user, Room room)
        {
            int userID = user.GetHabbo().Id;
            string username = user.GetHabbo().Username;
            uint roomID = room.RoomId;
            string roomName = room.Name;
            DateTime timeSpoken = DateTime.Now;

            ChatMessage chatMessage = new ChatMessage(userID, username, roomID, roomName, message, timeSpoken);

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("INSERT into `chatlogs`(`user_id`, `room_id`, `hour`, `minute`, `full_date`, `timestamp`, `message`, `user_name`) VALUES(" + userID + ", " + roomID + ", " + timeSpoken.Hour + ", " + timeSpoken.Minute + ", '" + timeSpoken.ToString() + "', " + FirewindEnvironment.GetUnixTimestamp() + ", @msg, '" + user.GetHabbo().Username + "');");
                dbClient.addParameter("msg", message);
                dbClient.runQuery();
            }

            return chatMessage;
        }
Beispiel #17
0
        internal static void BanUser(GameClient ModSession, uint UserId, int Length, String Message)
        {
            GameClient Client = FirewindEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);

            if (Client == null || Client.GetHabbo().Id == ModSession.GetHabbo().Id)
            {
                return;
            }

            if (Client.GetHabbo().Rank >= ModSession.GetHabbo().Rank)
            {
                ModSession.SendNotif(LanguageLocale.GetValue("moderation.ban.missingrank"));
                return;
            }

            Double dLength = Length;

            FirewindEnvironment.GetGame().GetBanManager().BanUser(Client, ModSession.GetHabbo().Username, dLength, Message, false);
        }
Beispiel #18
0
        internal void ActivateQuest(GameClient Session, ClientMessage Message)
        {
            Quest Quest = GetQuest(Message.ReadUInt32());

            if (Quest == null)
            {
                return;
            }

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {

                dbClient.runFastQuery("REPLACE INTO user_quests VALUES (" + Session.GetHabbo().Id + ", " + Quest.Id + ", 0)");
                dbClient.runFastQuery("UPDATE users SET currentquestid = " + Quest.Id + " WHERE id = " + Session.GetHabbo().Id);
            }

            Session.GetHabbo().CurrentQuestId = Quest.Id;
            GetList(Session, null);
            Session.SendMessage(QuestStartedComposer.Compose(Session, Quest));
        }
        internal static void TryRedeemVoucher(GameClient Session, string Code)
        {
            if (!IsValidCode(Code))
            {
                ServerMessage Error = new ServerMessage(Outgoing.VoucherRedeemError);
                Error.AppendRawInt32(0); // 0=invalid code,1=technical issue,3=redeem at webpage
                Session.SendMessage(Error);
                return;
            }

            int Value = GetVoucherValue(Code);

            TryDeleteVoucher(Code);

            Session.GetHabbo().Credits += Value;
            Session.GetHabbo().UpdateCreditsBalance();

            ServerMessage message = new ServerMessage(Outgoing.VoucherRedeemOk);
            message.AppendString("Credits"); // productName
            message.AppendString("Awesome"); // productDescription
            Session.SendMessage(message);
        }
Beispiel #20
0
        internal InventoryComponent(uint UserId, GameClient Client, UserData UserData)
        {
            this.mClient = Client;
            this.UserId = UserId;
            this.floorItems = new Hashtable();
            this.wallItems = new Hashtable();
            this.discs = new Hashtable();

            foreach (UserItem item in UserData.inventory)
            {
                if (item.GetBaseItem().InteractionType == InteractionType.musicdisc)
                    discs.Add(item.Id, item);
                if (item.isWallItem)
                    wallItems.Add(item.Id, item);
                else
                    floorItems.Add(item.Id, item);
            }

            this.InventoryPets = new SafeDictionary<UInt32, Pet>(UserData.pets);
            this.mAddedItems = new Hashtable();
            this.mRemovedItems = new ArrayList();
            this.isUpdated = false;
        }
        internal static ServerMessage Compose(GameClient Session, List<Achievement> Achievements)
        {
            ServerMessage Message = new ServerMessage(Outgoing.AchievementList); //436
            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.AppendUInt(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.RewardPixels);                                   // Pixel reward
                Message.AppendInt32(TargetLevelData.RewardPoints);                                  // Unknown(??)
                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);
            }
            Message.AppendBoolean(false);
            Message.AppendBoolean(false);
            return Message;
        }
        internal void RegisterClient(GameClient client, int userID, string username)
        {
            if (usernameRegister.ContainsKey(username.ToLower()))
                usernameRegister[username.ToLower()] = client;
            else
                usernameRegister.Add(username.ToLower(), client);

            if (userIDRegister.ContainsKey(userID))
                userIDRegister[userID] = client;
            else
                userIDRegister.Add(userID, client);

            if (!usernameIdRegister.ContainsKey(username))
                usernameIdRegister.Add(username, userID);
            if (!idUsernameRegister.ContainsKey(userID))
                idUsernameRegister.Add(userID, username);

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("REPLACE INTO user_online VALUES (" + userID + ")");
            }
        }
        internal void CreateAndStartClient(uint clientID, ConnectionInformation connection)
        {
            GameClient client = new GameClient(clientID, connection);
            if (clients.ContainsKey(clientID))
                clients.Remove(clientID);

            lock (clientsAddQueue.SyncRoot)
            {
                clientsAddQueue.Enqueue(client);
            }
        }
 internal void ClientLoggedIn(GameClient client)
 {
     if (OnLoggedInClient != null)
         OnLoggedInClient.Invoke(client);
 }
Beispiel #25
0
 internal void Dispose()
 {
     Session = null;
     Array.Clear(this.Params, 0, Params.Length);
 }
Beispiel #26
0
 public ChatCommandHandler(string[] input, GameClient session)
 {
     Params = input;
     Session = session;
 }
Beispiel #27
0
        private void GroupManager_OnLoggedInClient(GameClient client)
        {
            // This is called when an user sucessfully authed.
            Habbo user = client.GetHabbo();
            if (user == null || user.Groups.Count == 0)
                return;

            client.GetConnection().connectionChanged += GroupManager_connectionChanged;

            foreach (int groupID in user.Groups)
            {
                if (GetGroup(groupID) == null)
                    return;
                // Add one more count to reference counter
                if (!_groupReferences.ContainsKey(groupID))
                    _groupReferences.Add(groupID, 1);
                else
                    _groupReferences[groupID]++;
            }
        }
 internal static ServerMessage Compose(GameClient Session)
 {
     return Session.GetHabbo().GetInventoryComponent().SerializeMusicDiscs();
 }
Beispiel #29
0
        internal int GetRightsLevel(GameClient Session)
        {
            try
            {
                if (Session == null || Session.GetHabbo() == null)
                    return 0;

                if (Session.GetHabbo().Username == Owner)
                {
                    return 4;
                }

                if (Session.GetHabbo().HasFuse("fuse_admin") || Session.GetHabbo().HasFuse("fuse_any_room_controller"))
                {
                    return 4;
                }

                if (Session.GetHabbo().HasFuse("fuse_any_room_rights"))
                        return 3;

                if (UsersWithRights.Contains(Session.GetHabbo().Id))
                        return 1;

                if (EveryoneGotRights)
                        return 1;

            }
            catch (Exception e) { Logging.HandleException(e, "GetRightsLevel"); }

            return 0;
        }
Beispiel #30
0
        internal Boolean CheckRights(GameClient Session, bool RequireOwnership)
        {
            try
            {
                if (Session == null || Session.GetHabbo() == null)
                    return false;

                if (Session.GetHabbo().Username == Owner)
                {
                    return true;
                }

                if (Session.GetHabbo().HasFuse("fuse_admin") || Session.GetHabbo().HasFuse("fuse_any_room_controller"))
                {
                    return true;
                }

                if (!RequireOwnership)
                {
                    if (Session.GetHabbo().HasFuse("fuse_any_room_rights"))
                        return true;
                    if (UsersWithRights.Contains(Session.GetHabbo().Id))
                        return true;
                    if (EveryoneGotRights)
                        return true;
                }
            }
            catch (Exception e) { Logging.HandleException(e, "Room.CheckRights"); }

            return false;
        }