Exemplo n.º 1
0
        /// <summary>
        /// Generates the room data.
        /// </summary>
        /// <param name="roomId">The room identifier.</param>
        /// <returns>RoomData.</returns>
        internal RoomData GenerateRoomData(uint roomId)
        {
            if (LoadedRoomData.ContainsKey(roomId))
            {
                LoadedRoomData[roomId].LastUsed = DateTime.Now;
                return LoadedRoomData[roomId];
            }

            var roomData = new RoomData();

            if (LoadedRooms.ContainsKey(roomId))
                return GetRoom(roomId).RoomData;

            using (var queryReactor = AzureEmulator.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(string.Format("SELECT * FROM rooms_data WHERE id = {0} LIMIT 1", roomId));

                DataRow dataRow = queryReactor.GetRow();
                if (dataRow == null)
                    return null;

                roomData.Fill(dataRow);
            }

            LoadedRoomData.TryAdd(roomId, roomData);

            return roomData;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Queues the active room add.
 /// </summary>
 /// <param name="data">The data.</param>
 internal void QueueActiveRoomAdd(RoomData data)
 {
     lock (_activeRoomsAddQueue.SyncRoot)
     {
         _activeRoomsAddQueue.Enqueue(data);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Fetches the room data.
 /// </summary>
 /// <param name="roomId">The room identifier.</param>
 /// <param name="dRow">The d row.</param>
 /// <returns>RoomData.</returns>
 internal RoomData FetchRoomData(uint roomId, DataRow dRow)
 {
     if (LoadedRoomData.ContainsKey(roomId))
     {
         LoadedRoomData[roomId].LastUsed = DateTime.Now;
         return LoadedRoomData[roomId];
     }
     var roomData = new RoomData();
     roomData.Fill(dRow);
     LoadedRoomData.TryAdd(roomId, roomData);
     return roomData;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Generates the nullable room data.
 /// </summary>
 /// <param name="roomId">The room identifier.</param>
 /// <returns>RoomData.</returns>
 internal RoomData GenerateNullableRoomData(uint roomId)
 {
     if (GenerateRoomData(roomId) != null) return GenerateRoomData(roomId);
     var roomData = new RoomData();
     roomData.FillNull(roomId);
     return roomData;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="roomData">The room data.</param>
        /// <param name="rightOverride">if set to <c>true</c> [right override].</param>
        /// <param name="wordFilter">The word filter.</param>
        private void Initialize(uint id, RoomData roomData, bool rightOverride, List<string> wordFilter)
        {
            RoomData = roomData;

            Disposed = false;
            RoomId = id;
            Bans = new Dictionary<long, double>();
            MutedUsers = new Dictionary<uint, uint>();
            ActiveTrades = new ArrayList();
            MutedBots = false;
            MutedPets = false;
            _mCycleEnded = false;
            EveryoneGotRights = rightOverride;
            LoadedGroups = new Dictionary<int, string>();
            UserRoomQueue = new Dictionary<uint, uint>();
            _roomKick = new Queue();
            _idleTime = 0;
            RoomMuted = false;
            _gameMap = new Gamemap(this);
            _roomItemHandling = new RoomItemHandling(this);
            _roomUserManager = new RoomUserManager(this);
            WordFilter = wordFilter;

            LoadRights();
            LoadMusic();
            LoadBans();
            InitUserBots();

            _roomThread = new Thread(StartRoomProcessing);
            _roomThread.Name = "Room Loader";
            _roomThread.Start();
            AzureEmulator.GetGame().GetRoomManager().QueueActiveRoomAdd(RoomData);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Queues the add event.
 /// </summary>
 /// <param name="data">The data.</param>
 internal void QueueAddEvent(RoomData data)
 {
     lock (_addQueue.SyncRoot)
         _addQueue.Enqueue(data);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Queues the add event.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <param name="roomEventCategory">The room event category.</param>
 internal void QueueAddEvent(RoomData data, int roomEventCategory)
 {
     lock (_addQueue.SyncRoot)
         _addQueue.Enqueue(data);
     _eventCategories[roomEventCategory].QueueAddEvent(data);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Queues the vote add.
 /// </summary>
 /// <param name="data">The data.</param>
 internal void QueueVoteAdd(RoomData data)
 {
     lock (_votedRoomsAddQueue.SyncRoot)
     {
         _votedRoomsAddQueue.Enqueue(data);
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Serializes the ticket chatlog.
        /// </summary>
        /// <param name="ticket">The ticket.</param>
        /// <param name="roomData">The room data.</param>
        /// <param name="timestamp">The timestamp.</param>
        /// <returns>ServerMessage.</returns>
        /// <exception cref="System.NullReferenceException">No room found.</exception>
        internal static ServerMessage SerializeTicketChatlog(SupportTicket ticket, RoomData roomData, double timestamp)
        {
            var message = new ServerMessage();
            RoomData room = AzureEmulator.GetGame().GetRoomManager().GenerateRoomData(ticket.RoomId);
            //if (room == null)
            //{
            //    throw new NullReferenceException("No room found.");
            //}

            message.Init(LibraryParser.OutgoingRequest("ModerationToolIssueChatlogMessageComposer"));

            message.AppendInteger(ticket.TicketId);
            message.AppendInteger(ticket.SenderId);
            message.AppendInteger(ticket.ReportedId);
            message.AppendInteger(ticket.RoomId);

            message.AppendByte(1);
            message.AppendShort(2);
            message.AppendString("roomName");
            message.AppendByte(2);
            message.AppendString(ticket.RoomName);
            message.AppendString("roomId");
            message.AppendByte(1);
            message.AppendInteger(ticket.RoomId);

            var tempChatlogs = room.RoomChat.Reverse().Skip(Math.Max(0, room.RoomChat.Count() - 60)).Take(60).ToList();

            message.AppendShort(tempChatlogs.Count());
            foreach (var chatLog in tempChatlogs)
            {
                chatLog.Serialize(ref message);
            }
            tempChatlogs = null;

            return message;
        }
Exemplo n.º 10
0
 /// <summary>
 /// Queues the remove event.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <param name="roomEventCategory">The room event category.</param>
 internal void QueueRemoveEvent(RoomData data, int roomEventCategory)
 {
     lock (_removeQueue.SyncRoot)
         _removeQueue.Enqueue(data);
     _eventCategories[roomEventCategory].QueueRemoveEvent(data);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Serializes the room tool.
 /// </summary>
 /// <param name="Data">The data.</param>
 /// <returns>ServerMessage.</returns>
 internal static ServerMessage SerializeRoomTool(RoomData Data)
 {
     Room room = AzureEmulator.GetGame().GetRoomManager().GetRoom(Data.Id);
     var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ModerationRoomToolMessageComposer"));
     serverMessage.AppendInteger(Data.Id);
     serverMessage.AppendInteger(Data.UsersNow);
     if (room != null)
     {
         serverMessage.AppendBool(room.GetRoomUserManager().GetRoomUserByHabbo(Data.Owner) != null);
     }
     else
     {
         serverMessage.AppendBool(false);
     }
     serverMessage.AppendInteger(room != null ? room.RoomData.OwnerId : 0);
     serverMessage.AppendString(Data.Owner);
     serverMessage.AppendBool(room != null);
     serverMessage.AppendString(Data.Name);
     serverMessage.AppendString(Data.Description);
     serverMessage.AppendInteger(Data.TagCount);
     foreach (string current in Data.Tags)
     {
         serverMessage.AppendString(current);
     }
     serverMessage.AppendBool(false);
     return serverMessage;
 }
Exemplo n.º 12
0
 /// <summary>
 /// News the method.
 /// </summary>
 /// <param name="current2">The current2.</param>
 private void NewMethod(RoomData current2)
 {
     Response.AppendInteger(current2.Id);
     Response.AppendString(current2.Name);
     Response.AppendBool(false);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes from room data.
 /// </summary>
 /// <param name="data">The data.</param>
 private void InitializeFromRoomData(RoomData data)
 {
     Initialize(data.Id, data, data.AllowRightsOverride, data.WordFilter);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Queues the active room remove.
 /// </summary>
 /// <param name="data">The data.</param>
 internal void QueueActiveRoomRemove(RoomData data)
 {
     lock (ActiveRoomsRemoveQueue.SyncRoot)
     {
         ActiveRoomsRemoveQueue.Enqueue(data);
     }
 }
Exemplo n.º 15
0
 /// <summary>
 /// Queues the remove event.
 /// </summary>
 /// <param name="data">The data.</param>
 internal void QueueRemoveEvent(RoomData data)
 {
     lock (_removeQueue.SyncRoot)
         _removeQueue.Enqueue(data);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Queues the active room update.
 /// </summary>
 /// <param name="data">The data.</param>
 internal void QueueActiveRoomUpdate(RoomData data)
 {
     lock (_activeRoomsUpdateQueue.SyncRoot)
     {
         _activeRoomsUpdateQueue.Enqueue(data);
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// Queues the update event.
 /// </summary>
 /// <param name="data">The data.</param>
 internal void QueueUpdateEvent(RoomData data)
 {
     lock (_updateQueue.SyncRoot)
         _updateQueue.Enqueue(data);
 }
Exemplo n.º 18
0
 /// <summary>
 /// Queues the vote remove.
 /// </summary>
 /// <param name="data">The data.</param>
 internal void QueueVoteRemove(RoomData data)
 {
     lock (_votedRoomsRemoveQueue.SyncRoot)
     {
         _votedRoomsRemoveQueue.Enqueue(data);
     }
 }
Exemplo n.º 19
0
 internal void Start(RoomData data)
 {
     InitializeFromRoomData(data);
     GetRoomItemHandler().LoadFurniture();
     GetGameMap().GenerateMaps(true);
 }