Esempio n. 1
0
 internal void QueueRemoveEvent(RoomData data)
 {
     lock (removeQueue.SyncRoot)
     {
         removeQueue.Enqueue(data);
     }
 }
Esempio n. 2
0
 internal void QueueUpdateEvent(RoomData data)
 {
     lock (updateQueue.SyncRoot)
     {
         updateQueue.Enqueue(data);
     }
 }
Esempio n. 3
0
 internal void QueueAddEvent(RoomData data)
 {
     lock (addQueue.SyncRoot)
     {
         addQueue.Enqueue(data);
     }
 }
Esempio n. 4
0
 internal void QueueAddActiveRooms(RoomData data)
 {
     lock (addActiveRoomQueue.SyncRoot)
     {
         addActiveRoomQueue.Enqueue(data);
     }
 }
Esempio n. 5
0
 internal void QueueRemoveActiveRooms(RoomData data)
 {
     lock (removeActiveRoomQueue.SyncRoot)
     {
         removeActiveRoomQueue.Enqueue(data);
     }
 }
Esempio n. 6
0
 internal void QueueUpdateActiveRooms(RoomData data)
 {
     lock (updateActiveRoomQueue.SyncRoot)
     {
         updateActiveRoomQueue.Enqueue(data);
     }
 }
Esempio n. 7
0
 internal void QueueUpdateEvent(RoomData data, int roomEventCategory)
 {
     lock (updateQueue.SyncRoot)
     {
         updateQueue.Enqueue(data);
     }
     eventCategories[roomEventCategory].QueueUpdateEvent(data);
 }
Esempio n. 8
0
 internal void QueueRemoveEvent(RoomData data, int roomEventCategory)
 {
     lock (removeQueue.SyncRoot)
     {
         removeQueue.Enqueue(data);
     }
     eventCategories[roomEventCategory].QueueRemoveEvent(data);
 }
Esempio n. 9
0
        internal void QueueAddEvent(RoomData data, int roomEventCategory)
        {
            lock (addQueue.SyncRoot)
            {
                addQueue.Enqueue(data);
            }

            eventCategories[roomEventCategory].QueueAddEvent(data);
        }
Esempio n. 10
0
        internal void QueueActiveRoomRemove(RoomData data)
        {
            lock (activeRoomsRemoveQueue.SyncRoot)
            {
                activeRoomsRemoveQueue.Enqueue(data);
            }

            if (!roomCategories.ContainsKey(data.Category))
                roomCategories.Add(data.Category, new RoomCategory(data.Category, "MISSING CATEGORY"));
                roomCategories[data.Category].QueueRemoveActiveRooms(data);
        }
Esempio n. 11
0
 internal void QueueVoteRemove(RoomData data)
 {
     lock (votedRoomsRemoveQueue.SyncRoot)
     {
         votedRoomsRemoveQueue.Enqueue(data);
     }
 }
Esempio n. 12
0
 internal void QueueVoteAdd(RoomData data)
 {
     lock (votedRoomsAddQueue.SyncRoot)
     {
         votedRoomsAddQueue.Enqueue(data);
     }
 }
Esempio n. 13
0
 internal RoomData FetchRoomData(uint roomID, DataRow dRow)
 {
     if (CachedRoomdata.ContainsKey(roomID))
         return (RoomData)CachedRoomdata[roomID];
     else
     {
         RoomData data = new RoomData();
         data.Fill(dRow);
         CachedRoomdata.Add(roomID, data);
         return data;
     }
 }
Esempio n. 14
0
        internal RoomData GenerateRoomData(UInt32 RoomId, bool fromcache = true)
        {
            if (CachedRoomdata.ContainsKey(RoomId) && fromcache)
                return (RoomData)CachedRoomdata[RoomId];

            RoomData Data = new RoomData();

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT rooms.*, room_active.active_users, users.id AS ownerid FROM rooms LEFT JOIN room_active ON (room_active.roomid = rooms.id) JOIN users ON (users.username = rooms.owner) WHERE rooms.id = " + RoomId);
                DataRow Row = dbClient.getRow();

                if (Row == null)
                    return null;

                Data.Fill(Row);
                CachedRoomdata.Add(RoomId, Data);
            }

            return Data;
        }
Esempio n. 15
0
        internal RoomData GenerateNullableRoomData(UInt32 RoomId)
        {
            if (GenerateRoomData(RoomId) != null)
            {
                return GenerateRoomData(RoomId);
            }

            RoomData Data = new RoomData();
            Data.FillNull(RoomId);
            return Data;
        }
Esempio n. 16
0
 private void InitializeFromRoomData(RoomData Data)
 {
     Initialize(Data.Id, Data.Name, Data.Description, Data.Type, Data.Owner, Data.Category, Data.State,
                Data.UsersMax, Data.ModelName, Data.CCTs, Data.Score, Data.Tags, Data.AllowPets, Data.AllowPetsEating,
                Data.AllowWalkthrough, Data.Hidewall, Data.Icon, Data.Password, Data.Wallpaper, Data.Floor, Data.Landscape, Data, Data.AllowRightsOverride, Data.WallThickness, Data.FloorThickness);
 }
Esempio n. 17
0
        internal static ServerMessage SerializeTicketChatlog(SupportTicket Ticket, RoomData RoomData, Double Timestamp)
        {
            Room currentRoom = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(RoomData.Id);

            ServerMessage Message = new ServerMessage(534);
            Message.AppendUInt(Ticket.TicketId);
            Message.AppendUInt(Ticket.SenderId);
            Message.AppendUInt(Ticket.ReportedId);
            Message.AppendBoolean(RoomData.IsPublicRoom);
            Message.AppendUInt(RoomData.Id);
            Message.AppendStringWithBreak(RoomData.Name);

            if (currentRoom == null)
            {
                Message.AppendInt32(0);
                return Message;
            }
            else
            {
                ChatMessageManager manager = currentRoom.GetChatMessageManager();
                Message.AppendInt32(manager.messageCount);
                manager.Serialize(ref Message);

                return Message;
            }

            //using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            //{
            //    dbClient.setQuery("SELECT user_id,user_name,hour,minute,message FROM chatlogs WHERE room_id = " + RoomData.Id + " AND timestamp >= " + (Timestamp - 300) + " AND timestamp <= " + Timestamp + " ORDER BY timestamp DESC");
            //    DataTable Data = dbClient.getTable();

            //    ServerMessage Message = new ServerMessage(534);
            //    Message.AppendUInt(Ticket.TicketId);
            //    Message.AppendUInt(Ticket.SenderId);
            //    Message.AppendUInt(Ticket.ReportedId);
            //    Message.AppendBoolean(RoomData.IsPublicRoom);
            //    Message.AppendUInt(RoomData.Id);
            //    Message.AppendStringWithBreak(RoomData.Name);

            //    if (Data != null)
            //    {
            //        Message.AppendInt32(Data.Rows.Count);

            //        foreach (DataRow Row in Data.Rows)
            //        {
            //            Message.AppendInt32((int)Row["hour"]);
            //            Message.AppendInt32((int)Row["minute"]);
            //            Message.AppendUInt((UInt32)Row["user_id"]);
            //            Message.AppendStringWithBreak((String)Row["user_name"]);
            //            Message.AppendStringWithBreak((String)Row["message"]);
            //        }
            //    }
            //    else
            //    {
            //        Message.AppendInt32(0);
            //    }

            //    return Message;
            //}
        }
Esempio n. 18
0
        internal static ServerMessage SerializeRoomTool(RoomData Data)
        {
            Room Room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(Data.Id);
            UInt32 OwnerId = 0;

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                try
                {
                    dbClient.setQuery("SELECT id FROM users WHERE username = @owner");
                    dbClient.addParameter("owner", Data.Owner);
                    OwnerId = Convert.ToUInt32(dbClient.getRow()[0]);
                }
                catch (Exception e)
                {
                    Logging.HandleException(e, "ModerationTool.SerializeRoomTool");
                }
            }

            ServerMessage Message = PacketHandelingManager.GetRecycledItem(OutputCode.ModeratorRoomInfoEvent);
            Message.AddUInt32(Data.Id);
            Message.AddInt32(Data.UsersNow); // user count

            if (Room != null)
            {
                Message.AddBoolean((Room.GetRoomUserManager().GetRoomUserByHabbo(Data.Owner) != null));
            }
            else
            {
                Message.AddBoolean(false);
            }

            Message.AddUInt32(OwnerId);
            Message.AddString(Data.Owner);
            Message.AddBoolean(true);
            Message.AddString(Data.Name);
            Message.AddString(Data.Description);
            Message.AddInt32(Data.TagCount);

            foreach (string Tag in Data.Tags)
            {
                Message.AddString(Tag);
            }

            return Message;
        }
Esempio n. 19
0
        private void Initialize(UInt32 Id, string Name, string Description, string Type, string Owner, int Category,
                                int State, int UsersMax, string ModelName, string CCTs, int Score, List <string> pTags, bool AllowPets,
                                bool AllowPetsEating, bool AllowWalkthrough, bool Hidewall, RoomIcon Icon, string Password, string Wallpaper, string Floor,
                                string Landscape, RoomData RoomData, bool RightOverride, int walltickness, int floorthickness)
        {
            this.mDisposed   = false;
            this.Id          = Id;
            this.Name        = Name;
            this.Description = Description;
            this.Owner       = Owner;
            this.Category    = Category;
            this.Type        = Type;
            this.State       = State;
            this.UsersNow    = 0;
            this.UsersMax    = UsersMax;
            this.ModelName   = ModelName;
            this.CCTs        = CCTs;
            this.Score       = Score;

            tagCount  = 0;
            this.Tags = new ArrayList();
            foreach (string tag in pTags)
            {
                tagCount++;
                Tags.Add(tag);
            }

            this.AllowPets        = AllowPets;
            this.AllowPetsEating  = AllowPetsEating;
            this.AllowWalkthrough = AllowWalkthrough;
            this.Hidewall         = Hidewall;


            this.myIcon             = Icon;
            this.Password           = Password;
            this.Bans               = new Dictionary <UInt32, double>();
            this.Wallpaper          = Wallpaper;
            this.Floor              = Floor;
            this.Landscape          = Landscape;
            this.chatMessageManager = new ChatMessageManager();
            this.groups             = new QueuedDictionary <int, Group>();
            this.ActiveTrades       = new ArrayList();


            this.mCycleEnded = false;

            this.mRoomData         = RoomData;
            this.EveryoneGotRights = RightOverride;

            this.roomMessages     = new Queue();
            this.chatMessageQueue = new Queue();
            this.rnd = new Random();

            this.roomMessages       = new Queue();
            this.roomAlerts         = new Queue();
            this.roomBadge          = new Queue();
            this.roomKick           = new Queue();
            this.roomServerMessages = new Queue();
            this.IdleTime           = 0;
            this.RoomMuted          = false;
            this.WallThickness      = walltickness;
            this.FloorThickness     = floorthickness;

            this.gamemap          = new Gamemap(this);
            this.roomItemHandling = new RoomItemHandling(this);
            this.roomUserManager  = new RoomUserManager(this);
            this.wiredHandler     = new WiredHandler(this);

            LoadRights();
            GetRoomItemHandler().LoadFurniture();
            wiredHandler.LoadWired();
            GetGameMap().GenerateMaps();
            LoadMusic();
            //LoadBots();
            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (dbClient.dbType == Database_Manager.Database.DatabaseType.MySQL)
                {
                    dbClient.runFastQuery("REPLACE INTO room_active VALUES (" + Id + ",1)");
                }
                else
                {
                    dbClient.runFastQuery("IF EXISTS (SELECT roomid FROM room_active WHERE roomid = " + Id + ") " +
                                          "UPDATE room_active SET active_users = 1 WHERE roomid = " + Id + " " +
                                          "ELSE " +
                                          "INSERT INTO room_active VALUES (" + Id + ",1)");
                }
            }

            ButterflyEnvironment.GetGame().GetRoomManager().QueueActiveRoomAdd(mRoomData);
        }
Esempio n. 20
0
 internal Room(RoomData Data)
 {
     Initialize(Data);
 }
Esempio n. 21
0
        internal ServerMessage SerializeNavigator(GameClient session, int mode)
        {
            if (mode > -1)
                return SerializeActiveRooms(mode);

            ServerMessage reply = PacketHandelingManager.GetRecycledItem(OutputCode.GuestRoomSearchResultEvent);

            switch (mode)
            {
                case -5:
                    {
                        reply.AddInt32(mode);

                        List<RoomData> activeFriends = session.GetHabboDataContainer().GetChatMessenger().GetActiveFriendsRooms().OrderByDescending(p => p.UsersNow).ToList();
                        SerializeNavigatorRooms(ref reply, activeFriends);

                        return reply;
                    }
                case -4:
                    {
                        reply.AddInt32(mode);

                        List<string> FriendsNames = session.GetHabboDataContainer().GetChatMessenger().GetFriendUsernames().ToList();

                        if (FriendsNames.Count == 0)
                        {
                            SerializeNavigatorRooms(ref reply, new List<RoomData>());

                            return reply;
                        }

                        QueryChunk Query = new QueryChunk("SELECT rooms.*, room_active.active_users FROM rooms LEFT JOIN room_active ON (room_active.roomid = rooms.id) WHERE");

                        int i = 0;
                        foreach (string Name in FriendsNames)
                        {
                            if (i > 0)
                                Query.AddSpecialRawQuery(" OR");

                            Query.AddSpecialRawQuery(" owner = '" + ButterflyEnvironment.FilterInjectionChars(Name, true) + "'");

                            i++;
                        }

                        Query.AddQuery(" ORDER BY room_active.active_users DESC LIMIT 40;");

                        using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                        {
                            Query.Execute(dbClient);
                            DataTable dTable = dbClient.getTable();

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

                            foreach (DataRow dRow in dTable.Rows)
                            {
                                RoomData data = new RoomData();
                                data.Fill(dRow);

                                bool any = false;

                                foreach (RoomData p in parsedRoomData)
                                {
                                    if (p.Id == data.Id)
                                    {
                                        any = true;
                                        break;
                                    }

                                    if (p.Name == data.Name)
                                    {
                                        any = true;
                                        break;
                                    }
                                }

                                if (any)
                                    continue;

                                parsedRoomData.Add(data);
                            }

                            SerializeNavigatorRooms(ref reply, parsedRoomData);

                            Query.Dispose();
                        }

                        FriendsNames = null;

                        return reply;
                    }

                case -3:
                    {
                        reply.AddInt32(mode);

                        SerializeNavigatorRooms(ref reply, session.GetHabbo().UsersRooms);

                        return reply;
                    }

                case -2:
                    {
                        reply.AddInt32(mode);

                        int count = 0;
                        ISortable<RoomData>[] rooms = ButterflyEnvironment.GetGame().GetRoomManager().GetActiveRooms(out count);

                        SerializeNavigatorRooms(reply, rooms, count);

                        rooms = null;

                        return reply;
                    }

                case -1:
                    {
                        reply.AddInt32(mode);

                        int count = 0;
                        ISortable<RoomData>[] rooms = ButterflyEnvironment.GetGame().GetRoomManager().GetActiveRooms(out count);

                        SerializeNavigatorRooms(reply, rooms, count);

                        rooms = null;

                        return reply;
                    }
            }

            return reply;
        }
Esempio n. 22
0
        private void Initialize(RoomData RoomData)
        {
            this.Id = RoomData.Id;

            this.mDisposed         = false;
            this.RoomMuted         = false;
            this.muteSignalEnabled = false;

            this.Bans               = new Dictionary <UInt32, double>();
            this.Mutes              = new Dictionary <UInt32, MuteUser>();
            this.FilterWords        = new List <string>();
            this.chatMessageManager = new ChatMessageManager();
            this.lastTimerReset     = DateTime.Now;
            this.IsRoomLoaded       = false;

            this.mCycleEnded     = false;
            this.HeightMapLoaded = false;

            this.mRoomData = RoomData;

            this.roomMessages     = new Queue();
            this.chatMessageQueue = new Queue();

            this.roomMessages           = new Queue();
            this.roomAlerts             = new Queue();
            this.roomBadge              = new Queue();
            this.roomDiamonds           = new Queue();
            this.roomCredits            = new Queue();
            this.roomPiruletas          = new Queue();
            this.roomKick               = new Queue();
            this.roomServerMessages     = new Queue();
            this.roomChatServerMessages = new Queue();

            this.groupAddQueue    = new Queue();
            this.groupRemoveQueue = new Queue();
            this.groupsOnRoom     = new Dictionary <uint, int>();

            this.roomUserFloorItems = new Dictionary <uint, uint>();
            this.roomUserWallItems  = new Dictionary <uint, uint>();

            this.gamemap          = new Gamemap(this);
            this.roomUserManager  = new RoomUserManager(this);
            this.roomItemHandling = new RoomItemHandling(this);
            this.wiredHandler     = new WiredHandler(this);
            this.games            = new GameManager(this);

            this.roomPoll = new RoomQuestionary();
            if (!this.roomPoll.LoadQuestionary(this.Id))
            {
                this.roomPoll = null;
            }

            this.LoadFilterWords();
            this.LoadRights();
            this.GetRoomItemHandler().LoadFurniture();
            this.GetGameMap().GenerateMaps();
            this.GetRoomUserManager().OnUserUpdateStatus(); // Update Bots State.
            this.LoadMusic();

            if (this.RoomData.State != 3)
            {
                OtanixEnvironment.GetGame().GetRoomManager().QueueActiveRoomAdd(mRoomData);
            }
        }
Esempio n. 23
0
 internal Room(RoomData Data)
 {
     InitializeFromRoomData(Data);
 }
Esempio n. 24
0
        internal static ServerMessage SerializeTicketChatlog(SupportTicket Ticket, RoomData RoomData, Double Timestamp)
        {
            Room currentRoom = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(RoomData.Id);

            ServerMessage Message = PacketHandelingManager.GetRecycledItem(OutputCode.CfhChatlogEvent);
            Message.AddUInt32(Ticket.TicketId);
            Message.AddUInt32(Ticket.SenderId);
            Message.AddUInt32(Ticket.ReportedId);
            Message.AddBoolean(false);
            Message.AddUInt32(RoomData.Id);
            Message.AddString(RoomData.Name);

            if (currentRoom == null)
            {
                Message.AddInt32(0);
                return Message;
            }
            else
            {
                ChatMessageManager manager = currentRoom.GetChatMessageManager();
                Message.AddInt32(manager.messageCount);
                manager.Serialize(ref Message);

                return Message;
            }
        }
Esempio n. 25
0
        internal static ServerMessage SerializeRoomTool(RoomData Data)
        {
            Room Room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(Data.Id);
            UInt32 OwnerId = 0;

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                try
                {
                    dbClient.setQuery("SELECT id FROM users WHERE username = @owner");
                    dbClient.addParameter("owner", Data.Owner);
                    OwnerId = Convert.ToUInt32(dbClient.getRow()[0]);
                }
                catch (Exception e)
                {
                    Logging.HandleException(e, "ModerationTool.SerializeRoomTool");
                }
            }

            ServerMessage Message = new ServerMessage(538);
            Message.AppendUInt(Data.Id);
            Message.AppendInt32(Data.UsersNow); // user count

            if (Room != null)
            {
                Message.AppendBoolean((Room.GetRoomUserManager().GetRoomUserByHabbo(Data.Owner) != null));
            }
            else
            {
                Message.AppendBoolean(false);
            }

            Message.AppendUInt(OwnerId);
            Message.AppendStringWithBreak(Data.Owner);
            Message.AppendUInt(Data.Id);
            Message.AppendStringWithBreak(Data.Name);
            Message.AppendStringWithBreak(Data.Description);
            Message.AppendInt32(Data.TagCount);

            foreach (string Tag in Data.Tags)
            {
                Message.AppendStringWithBreak(Tag);
            }

            if (Room != null)
            {
                Message.AppendBoolean(Room.HasOngoingEvent);

                if (Room.Event != null)
                {
                    Message.AppendStringWithBreak(Room.Event.Name);
                    Message.AppendStringWithBreak(Room.Event.Description);
                    Message.AppendInt32(Room.Event.Tags.Count);

                    foreach (string Tag in Room.Event.Tags.ToArray())
                    {
                        Message.AppendStringWithBreak(Tag);
                    }
                }
            }
            else
            {
                Message.AppendBoolean(false);
            }

            return Message;
        }