public static ServerMessage Compose(ModerationTicket Ticket, RoomInfo Info, ReadOnlyCollection<ModerationChatlogEntry> Entries)
        {
            ServerMessage Message = new ServerMessage(OpcodesOut.MODERATION_CHATLOGS_TICKET);
            Message.AppendUInt32(Ticket.Id);
            Message.AppendUInt32(Ticket.ReporteeUserId);
            Message.AppendUInt32(Ticket.ReportedUserId);
            Message.AppendUInt32(Ticket.Id); // Number to display in title. Chatlog ID?
            Message.AppendBoolean(Info != null ? Info.Type == RoomType.Public : false);
            Message.AppendUInt32(Info != null ? Info.Id : 0);
            Message.AppendStringWithBreak(Info != null ? Info.Name : "(Unknown room)");

            Message.AppendInt32(Entries.Count);

            foreach (ModerationChatlogEntry Entry in Entries)
            {
                DateTime Time = UnixTimestamp.GetDateTimeFromUnixTimestamp(Entry.Timestamp);

                Message.AppendInt32(Time.Hour);
                Message.AppendInt32(Time.Minute);
                Message.AppendUInt32(Entry.UserId);
                Message.AppendStringWithBreak(Entry.UserName);
                Message.AppendStringWithBreak(Entry.Message);
            }

            return Message;
        }
 public static ServerMessage Compose(RoomInfo Info)
 {
     ServerMessage Message = new ServerMessage(OpcodesOut.MESSENGER_FOLLOW_RESULT);
     Message.AppendBoolean(Info.Type == RoomType.Public);
     Message.AppendUInt32(Info.Id);
     return Message;
 }
        public static ServerMessage Compose(RoomInfo Info, ReadOnlyCollection<ModerationChatlogEntry> Entries)
        {
            ServerMessage Message = new ServerMessage(OpcodesOut.MODERATION_CHATLOGS_ROOM);
            Message.AppendBoolean(Info.Type == RoomType.Public);
            Message.AppendUInt32(Info.Id);
            Message.AppendStringWithBreak(Info.Name);
            Message.AppendInt32(Entries.Count);

            foreach (ModerationChatlogEntry Entry in Entries)
            {
                DateTime Time = UnixTimestamp.GetDateTimeFromUnixTimestamp(Entry.Timestamp);

                Message.AppendInt32(Time.Hour);
                Message.AppendInt32(Time.Minute);
                Message.AppendUInt32(Entry.UserId);
                Message.AppendStringWithBreak(CharacterResolverCache.GetNameFromUid(Entry.UserId));
                Message.AppendStringWithBreak(Entry.Message);
            }

            return Message;
        }
Beispiel #4
0
        public static ServerMessage Compose(RoomInfo Info, bool IsLoading = true, bool CheckEntry = false)
        {
            ServerMessage Message = new ServerMessage(OpcodesOut.ROOM_INFO);
            Message.AppendBoolean(IsLoading); // UPDATE=FALSE, DURINGLOAD=TRUE, STALKING=FALSE
            Message.AppendUInt32(Info.Id);
            Message.AppendInt32(0); // Nothing else has ever been logged
            Message.AppendStringWithBreak(Info.Name);
            Message.AppendStringWithBreak(Info.OwnerName);
            Message.AppendInt32((int)Info.AccessType);
            Message.AppendInt32(Info.CurrentUsers);
            Message.AppendInt32(Info.MaxUsers);
            Message.AppendStringWithBreak(Info.Description);
            Message.AppendInt32(0); // Nothing else has ever been logged
            Message.AppendBoolean(Info.CanTrade); // Allow trading
            Message.AppendInt32(0); // Nothing else has ever been logged
            Message.AppendInt32(Info.CategoryId);
            Message.AppendStringWithBreak(string.Empty); // Nothing else has ever been logged
            Message.AppendInt32(Info.Tags.Count);

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

            Message.AppendInt32(Info.Icon.BackgroundImageId);
            Message.AppendInt32(Info.Icon.OverlayImageId);
            Message.AppendInt32(Info.Icon.Objects.Count);

            foreach (KeyValuePair<int, int> Object in Info.Icon.Objects)
            {
                Message.AppendInt32(Object.Key);
                Message.AppendInt32(Object.Value);
            }

            Message.AppendBoolean(Info.AllowPets);
            Message.AppendBoolean(true); // Always
            Message.AppendBoolean(CheckEntry); // stuff
            Message.AppendBoolean(false); // Always
            return Message;
        }
        public static ServerMessage Compose(RoomInfo Info, RoomInstance Instance)
        {
            ReadOnlyCollection<string> Tags = Info.Tags;
            RoomEvent Event = (Instance == null ? null : Instance.Event);

            ServerMessage Message = new ServerMessage(OpcodesOut.MODERATION_ROOM_INFO);
            Message.AppendUInt32(Info.Id);
            Message.AppendInt32(Info.CurrentUsers);
            Message.AppendBoolean(Instance == null ? false : (Instance.GetActorByReferenceId(Info.OwnerId) != null));
            Message.AppendUInt32(Info.OwnerId);
            Message.AppendStringWithBreak(Info.OwnerName);
            Message.AppendUInt32(Info.Id);
            Message.AppendStringWithBreak(Info.Name);
            Message.AppendStringWithBreak(Info.Description);
            Message.AppendInt32(Tags.Count);

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

            Message.AppendBoolean(Event != null);

            if (Event != null)
            {
                List<string> EventTags = Event.Tags;

                Message.AppendStringWithBreak(Event.Name);
                Message.AppendStringWithBreak(Event.Description);
                Message.AppendInt32(EventTags.Count);

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

            return Message;
        }
        public static void SerializeRoom(ServerMessage Message, RoomInfo Info, RoomEvent EventData = null)
        {
            bool ShowingEvent = (EventData != null);

            Message.AppendUInt32(Info.Id);                                                  // Actual priv room ID
            Message.AppendBoolean(ShowingEvent);                                         // Unknown
            Message.AppendStringWithBreak(ShowingEvent ? EventData.Name : Info.Name);                                       // Name
            Message.AppendStringWithBreak(Info.OwnerName);                                  // Descr
            Message.AppendInt32((int)Info.AccessType);                                      // Room state
            Message.AppendInt32(Info.CurrentUsers);           // Users now
            Message.AppendInt32(Info.MaxUsers);                                             // Users max
            Message.AppendStringWithBreak(ShowingEvent ? EventData.Description : Info.Description);                                // Descr
            Message.AppendInt32(0);                                                         // Unknown
            Message.AppendBoolean(Info.CanTrade);                                                   // Enable trade
            Message.AppendInt32(Info.Score);                                                // Score
            Message.AppendInt32(ShowingEvent? EventData.CategoryId : Info.CategoryId);                                           // Category
            Message.AppendStringWithBreak(ShowingEvent ? EventData.TimeStartedString : string.Empty);                                              // Unknown, seems no effect
            Message.AppendInt32(Info.Tags.Count);                                           // Tag count

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

            Message.AppendInt32(Info.Icon.BackgroundImageId);                               // Icon bg
            Message.AppendInt32(Info.Icon.OverlayImageId);                                  // Icon overlay
            Message.AppendInt32(Info.Icon.Objects.Count);                           // Icon fg count

            foreach (KeyValuePair<int, int> Data in Info.Icon.Objects)
            {
                Message.AppendInt32(Data.Key);
                Message.AppendInt32(Data.Value);
            }

            Message.AppendInt32(0);                                                         // Added in R63; unknown. Seems to have no effect.
            Message.AppendInt32(1);                                                         // Eof message, unknown
        }
Beispiel #7
0
        public RoomInstance(uint InstanceId, RoomInfo Info, RoomModel Model)
        {
            mActorSyncRoot = new object();
            mItemSyncRoot = new object();

            mInstanceId = InstanceId;
            mInfo = Info;
            mActors = new Dictionary<uint, RoomActor>();
            mCachedModel = Model;
            mRelativeHeightmap = string.Empty;
            mActorIdGenerator = 1;
            mActorIdGeneratorSyncLock = new object();
            mTileStates = new TileState[mCachedModel.Heightmap.SizeX, mCachedModel.Heightmap.SizeY];
            mUsersWithRights = new List<uint>();
            mBannedUsers = new Dictionary<uint, double>();
            mItems = new Dictionary<uint, Item>();
            mStaticObjects = new List<StaticObject>();
            mItemLimitCache = new Dictionary<ItemBehavior, int>();
            mUserGrid = new List<RoomActor>[mCachedModel.Heightmap.SizeX, mCachedModel.Heightmap.SizeY];
            mMusicController = new RoomMusicController();
            mTemporaryStickieRights = new Dictionary<uint, uint>();
            mTradeManager = new TradeManager();
            mRollerItems = new List<Item>[mCachedModel.Heightmap.SizeX, mCachedModel.Heightmap.SizeY];
            mWiredManager = new WiredManager(this);

            foreach (Bot Bot in BotManager.GenerateBotInstancesForRoom(RoomId))
            {
                AddBotToRoom(Bot);
            }

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                // Items
                MySqlClient.SetParameter("id", RoomId);
                DataTable ItemTable = MySqlClient.ExecuteQueryTable("SELECT * FROM items WHERE room_id = @id");

                foreach (DataRow Row in ItemTable.Rows)
                {
                    Item Item = ItemFactory.CreateFromDatabaseRow(Row, mWiredManager);

                    if (Item.PendingExpiration && Item.ExpireTimeLeft <= 0)
                    {
                        Item.RemovePermanently(MySqlClient);
                        continue;
                    }

                    if (Item.InSoundManager)
                    {
                        continue;
                    }

                    mItems.Add(Item.Id, Item);
                    IncrecementFurniLimitCache(Item.Definition.Behavior);

                    ItemEventDispatcher.InvokeItemEventHandler(null, Item, this, ItemEventType.InstanceLoaded);
                }

                // Static objects
                MySqlClient.SetParameter("id", RoomId);
                DataTable StaticObjectTable = MySqlClient.ExecuteQueryTable("SELECT id,name,position,height,rotation,is_seat FROM static_objects WHERE room_id = @id");

                foreach (DataRow Row in StaticObjectTable.Rows)
                {
                    mStaticObjects.Add(new StaticObject((uint)Row["id"], (string)Row["name"], Vector2.FromString((string)Row["position"]),
                        (int)Row["height"], (int)Row["rotation"], (Row["is_seat"].ToString() == "1")));
                }

                // Rights
                MySqlClient.SetParameter("id", RoomId);
                DataTable RightsTable = MySqlClient.ExecuteQueryTable("SELECT user_id FROM room_rights WHERE room_id = @id");

                foreach (DataRow Row in RightsTable.Rows)
                {
                    mUsersWithRights.Add((uint)Row["user_id"]);
                }

                // Pets
                MySqlClient.SetParameter("id", RoomId);
                DataTable PetsTable = MySqlClient.ExecuteQueryTable("SELECT * FROM pets WHERE room_id = @id");

                foreach (DataRow Row in PetsTable.Rows)
                {
                    Pet PetData = PetFactory.GetPetFromDatabaseRow(Row);

                    AddBotToRoom(BotManager.CreateNewInstance(BotManager.GetHandlerDefinitionForPetType(PetData.Type),
                        RoomId, Vector3.FromString(Row["room_pos"].ToString()), PetData));
                }
            }

            RegenerateRelativeHeightmap();

            mUpdater = new Timer(new TimerCallback(PerformUpdate), null, TimeSpan.FromMilliseconds(500), TimeSpan.FromMilliseconds(500));
        }
Beispiel #8
0
        public void Dispose()
        {
            if (!mUnloaded)
            {
                Unload();
            }

            mUpdater.Dispose();
            mUpdater = null;
            mInfo = null;
        }