Exemple #1
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)
        {
            ServerMessage message = new ServerMessage();

            RoomData room = Yupi.GetGame().GetRoomManager().GenerateRoomData(ticket.RoomId);

            if (room != null)
            {
                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);

                List<Chatlog> tempChatlogs =
                    room.RoomChat.Reverse().Skip(Math.Max(0, room.RoomChat.Count() - 60)).Take(60).ToList();

                message.AppendShort(tempChatlogs.Count);

                foreach (Chatlog chatLog in tempChatlogs)
                    chatLog.Serialize(ref message);

                return message;
            }
            return null;
        }
Exemple #2
0
        /// <summary>
        ///     Serializes the room chatlog.
        /// </summary>
        /// <param name="roomId">The room identifier.</param>
        /// <returns>ServerMessage.</returns>
        /// <exception cref="System.NullReferenceException">No room found.</exception>
        internal static ServerMessage SerializeRoomChatlog(uint roomId)
        {
            ServerMessage message = new ServerMessage();

            Room room = Yupi.GetGame().GetRoomManager().LoadRoom(roomId);

            if (room?.RoomData != null)
            {
                message.Init(LibraryParser.OutgoingRequest("ModerationToolRoomChatlogMessageComposer"));
                message.AppendByte(1);
                message.AppendShort(2);
                message.AppendString("roomName");
                message.AppendByte(2);
                message.AppendString(room.RoomData.Name);
                message.AppendString("roomId");
                message.AppendByte(1);
                message.AppendInteger(room.RoomData.Id);

                List<Chatlog> tempChatlogs =
                    room.RoomData.RoomChat.Reverse()
                        .Skip(Math.Max(0, room.RoomData.RoomChat.Count - 60))
                        .Take(60)
                        .ToList();

                message.AppendShort(tempChatlogs.Count);

                foreach (Chatlog chatLog in tempChatlogs)
                    chatLog.Serialize(ref message);

                return message;
            }

            return null;
        }
Exemple #3
0
        /// <summary>
        ///     Serializes the user chatlog.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <returns>ServerMessage.</returns>
        internal static ServerMessage SerializeUserChatlog(uint userId)
        {
            ServerMessage result;

            using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                commitableQueryReactor.SetQuery($"SELECT DISTINCT room_id FROM users_chatlogs WHERE user_id = '{userId}' ORDER BY timestamp DESC LIMIT 4");

                DataTable table = commitableQueryReactor.GetTable();

                ServerMessage serverMessage =  new ServerMessage(LibraryParser.OutgoingRequest("ModerationToolUserChatlogMessageComposer"));
                serverMessage.AppendInteger(userId);
                serverMessage.AppendString(Yupi.GetGame().GetClientManager().GetNameById(userId));

                if (table != null)
                {
                    serverMessage.AppendInteger(table.Rows.Count);
                    IEnumerator enumerator = table.Rows.GetEnumerator();

                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            DataRow dataRow = (DataRow) enumerator.Current;

                            commitableQueryReactor.SetQuery($"SELECT user_id,timestamp,message FROM users_chatlogs WHERE room_id = {dataRow["room_id"]} AND user_id = {userId} ORDER BY timestamp DESC LIMIT 30");

                            DataTable table2 = commitableQueryReactor.GetTable();
                            RoomData roomData = Yupi.GetGame().GetRoomManager().GenerateRoomData((uint) dataRow["room_id"]);

                            if (table2 != null)
                            {
                                serverMessage.AppendByte(1);
                                serverMessage.AppendShort(2);
                                serverMessage.AppendString("roomName");
                                serverMessage.AppendByte(2);
                                serverMessage.AppendString(roomData == null ? "This room was deleted" : roomData.Name);
                                serverMessage.AppendString("roomId");
                                serverMessage.AppendByte(1);
                                serverMessage.AppendInteger((uint) dataRow["room_id"]);
                                serverMessage.AppendShort(table2.Rows.Count);
                                IEnumerator enumerator2 = table2.Rows.GetEnumerator();
                                try
                                {
                                    while (enumerator2.MoveNext())
                                    {
                                        DataRow dataRow2 = (DataRow) enumerator2.Current;

                                        Habbo habboForId = Yupi.GetHabboById((uint) dataRow2["user_id"]);
                                        Yupi.UnixToDateTime((double) dataRow2["timestamp"]);

                                        if (habboForId == null)
                                            return null;

                                        serverMessage.AppendInteger(
                                            (int) (Yupi.GetUnixTimeStamp() - (double) dataRow2["timestamp"]));

                                        serverMessage.AppendInteger(habboForId.Id);
                                        serverMessage.AppendString(habboForId.UserName);
                                        serverMessage.AppendString(dataRow2["message"].ToString());
                                        serverMessage.AppendBool(false);
                                    }
                                    continue;
                                }
                                finally
                                {
                                    IDisposable disposable = enumerator2 as IDisposable;

                                    disposable?.Dispose();
                                }
                            }

                            serverMessage.AppendByte(1);
                            serverMessage.AppendShort(0);
                            serverMessage.AppendShort(0);
                        }

                        result = serverMessage;
                        return result;
                    }
                    finally
                    {
                        IDisposable disposable2 = enumerator as IDisposable;

                        disposable2?.Dispose();
                    }
                }

                serverMessage.AppendInteger(0);
                result = serverMessage;
            }
            return result;
        }
Exemple #4
0
 /// <summary>
 ///     News the height map.
 /// </summary>
 /// <returns>ServerMessage.</returns>
 private ServerMessage NewHeightMap()
 {
     ServerMessage serverMessage = new ServerMessage();
     serverMessage.Init(LibraryParser.OutgoingRequest("HeightMapMessageComposer"));
     serverMessage.AppendInteger(Model.MapSizeX);
     serverMessage.AppendInteger(Model.MapSizeX*Model.MapSizeY);
     for (int i = 0; i < Model.MapSizeY; i++)
     {
         for (int j = 0; j < Model.MapSizeX; j++)
         {
             serverMessage.AppendShort((short) (SqAbsoluteHeight(j, i)*256));
         }
     }
     //  serverMessage.AppendShort(this.Model.SqFloorHeight[j, i] * 256);
     return serverMessage;
 }
Exemple #5
0
        /// <summary>
        ///     Called when [height map update].
        /// </summary>
        /// <param name="affectedTiles">The affected tiles.</param>
        internal void OnHeightMapUpdate(Dictionary<int, ThreeDCoord> affectedTiles)
        {
            ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("UpdateFurniStackMapMessageComposer"));
            message.AppendByte((byte) affectedTiles.Count);

            foreach (ThreeDCoord coord in affectedTiles.Values)
            {
                message.AppendByte((byte) coord.X);
                message.AppendByte((byte) coord.Y);
                message.AppendShort((short) (_room.GetGameMap().SqAbsoluteHeight(coord.X, coord.Y)*256));
            }

            _room.SendMessage(message);
        }
Exemple #6
0
        /// <summary>
        ///     Called when [height map update].
        /// </summary>
        /// <param name="oldCoords">The old coords.</param>
        /// <param name="newCoords">The new coords.</param>
        internal void OnHeightMapUpdate(List<Point> oldCoords, List<Point> newCoords)
        {
            ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("UpdateFurniStackMapMessageComposer"));
            message.AppendByte((byte) (oldCoords.Count + newCoords.Count));

            foreach (Point coord in oldCoords)
            {
                message.AppendByte((byte) coord.X);
                message.AppendByte((byte) coord.Y);
                message.AppendShort((short) (_room.GetGameMap().SqAbsoluteHeight(coord.X, coord.Y)*256));
            }

            foreach (Point nCoord in newCoords)
            {
                message.AppendByte((byte) nCoord.X);
                message.AppendByte((byte) nCoord.Y);
                message.AppendShort((short) (_room.GetGameMap().SqAbsoluteHeight(nCoord.X, nCoord.Y)*256));
            }

            _room.SendMessage(message);
        }
Exemple #7
0
        /// <summary>
        ///     Serializes the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="session">The session.</param>
        internal void Serialize(ServerMessage message, GameClient session)
        {
            Relationship value =
                session.GetHabbo().Relationships.FirstOrDefault(x => x.Value.UserId == Convert.ToInt32(Id)).Value;

            int i = value?.Type ?? 0;

            message.AppendInteger(Id);
            message.AppendString(UserName);
            message.AppendInteger(IsOnline || Id == 0);

            message.AppendBool(Id == 0 || (!_appearOffline || session.GetHabbo().Rank >= 4) && IsOnline);
            message.AppendBool(Id != 0 && (!_hideInroom || session.GetHabbo().Rank >= 4) && InRoom);

            message.AppendString(IsOnline || Id == 0 ? _look : string.Empty);

            message.AppendInteger(0);
            message.AppendString(_motto);
            message.AppendString(string.Empty);
            message.AppendString(string.Empty);
            message.AppendBool(true);
            message.AppendBool(false);
            message.AppendBool(false);
            message.AppendShort(i);
        }