예제 #1
0
        public void Execute(GameClient Session, Room Room, RoomUser UserRoom, string[] Params)
        {
            if (Params.Length != 2)
            {
                return;
            }

            string Cmd = Params[1];

            if (string.IsNullOrEmpty(Cmd))
            {
                return;
            }

            switch (Cmd)
            {
            case "text":
            case "texte":
            case "locale":
            {
                ButterflyEnvironment.GetLanguageManager().InitLocalValues();
                break;
            }

            case "autogame":
            {
                ButterflyEnvironment.GetGame().GetAnimationManager().ForceDisabled = !ButterflyEnvironment.GetGame().GetAnimationManager().ForceDisabled;
                if (!ButterflyEnvironment.GetGame().GetAnimationManager().ForceDisabled)
                {
                    UserRoom.SendWhisperChat(ButterflyEnvironment.GetLanguageManager().TryGetValue("cmd.autogame.false", Session.Langue));
                }
                else
                {
                    UserRoom.SendWhisperChat(ButterflyEnvironment.GetLanguageManager().TryGetValue("cmd.autogame.true", Session.Langue));
                }

                break;
            }

            case "rpitems":
            {
                ButterflyEnvironment.GetGame().GetRoleplayManager().GetItemManager().Init();
                break;
            }

            case "rpweapon":
            {
                ButterflyEnvironment.GetGame().GetRoleplayManager().GetWeaponManager().Init();
                break;
            }

            case "rpenemy":
            {
                ButterflyEnvironment.GetGame().GetRoleplayManager().GetEnemyManager().Init();
                break;
            }

            case "cmd":
            case "commands":
            {
                ButterflyEnvironment.GetGame().GetChatManager().GetCommands().Init();
                break;
            }

            case "role":
            {
                ButterflyEnvironment.GetGame().GetRoleManager().Init();
                break;
            }

            case "effet":
            {
                ButterflyEnvironment.GetGame().GetEffectsInventoryManager().Init();
                break;
            }

            case "rp":
            case "roleplay":
            {
                ButterflyEnvironment.GetGame().GetRoleplayManager().Init();
                break;
            }

            case "catalogue":
            case "cata":
            {
                ButterflyEnvironment.GetGame().GetCatalog().Init(ButterflyEnvironment.GetGame().GetItemManager());
                ButterflyEnvironment.GetGame().GetClientManager().SendMessage(new CatalogUpdatedComposer());
                break;
            }

            case "navigateur":
            case "navi":
            {
                ButterflyEnvironment.GetGame().GetNavigator().Init();
                break;
            }

            case "filter":
            case "filtre":
            {
                ButterflyEnvironment.GetGame().GetChatManager().GetFilter().Init();
                break;
            }

            case "items":
            {
                ButterflyEnvironment.GetGame().GetItemManager().Init();
                break;
            }

            case "model":
                ButterflyEnvironment.GetGame().GetRoomManager().LoadModels();
                break;

            case "mutant":
            case "figure":
            {
                ButterflyEnvironment.GetFigureManager().Init();
                break;
            }

            case "notiftop":
            {
                ButterflyEnvironment.GetGame().GetNotifTopManager().Init();
                break;
            }

            default:
            {
                UserRoom.SendWhisperChat(ButterflyEnvironment.GetLanguageManager().TryGetValue("cmd.notfound", Session.Langue));
                return;
            }
            }
            UserRoom.SendWhisperChat(ButterflyEnvironment.GetLanguageManager().TryGetValue("cmd.refresh", Session.Langue));
        }
예제 #2
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            Room room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (room == null || !room.CheckRights(Session, true))
            {
                return;
            }
            Item userItem = Session.GetHabbo().GetInventoryComponent().GetItem(Packet.PopInt());

            if (userItem == null)
            {
                return;
            }

            string DecorationKey = string.Empty;

            switch (userItem.GetBaseItem().InteractionType)
            {
            case InteractionType.FLOOR:
                DecorationKey = "floor";
                break;

            case InteractionType.WALLPAPER:
                DecorationKey = "wallpaper";
                break;

            case InteractionType.LANDSCAPE:
                DecorationKey = "landscape";
                break;

            default:
                return;
            }

            switch (DecorationKey)
            {
            case "floor":
                room.RoomData.Floor = userItem.ExtraData;
                ButterflyEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.FURNI_DECORATION_FLOOR, 0);
                break;

            case "wallpaper":
                room.RoomData.Wallpaper = userItem.ExtraData;
                ButterflyEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.FURNI_DECORATION_WALL, 0);
                break;

            case "landscape":
                room.RoomData.Landscape = userItem.ExtraData;
                break;
            }

            using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                queryreactor.SetQuery("UPDATE `rooms` SET " + DecorationKey + " = @extradata WHERE `id` = '" + room.Id + "' LIMIT 1");
                queryreactor.AddParameter("extradata", userItem.ExtraData);
                queryreactor.RunQuery();

                queryreactor.RunQuery("DELETE FROM items WHERE id = " + userItem.Id);
            }
            Session.GetHabbo().GetInventoryComponent().RemoveItem(userItem.Id);
            ServerPacket Message = new ServerPacket(ServerPacketHeader.RoomPropertyMessageComposer);

            Message.WriteString(DecorationKey);
            Message.WriteString(userItem.ExtraData);
            room.SendPacket(Message);
        }
예제 #3
0
 public void Parse(GameClient Session, ClientPacket Packet)
 {
     Session.SendPacket(new CatalogIndexComposer(Session, ButterflyEnvironment.GetGame().GetCatalog().GetPages()));//, Sub));
     Session.SendPacket(new CatalogItemDiscountComposer());
     Session.SendPacket(new BCBorrowedItemsComposer());
 }
예제 #4
0
        private void OnUserAdd(object sender, EventArgs args)
        {
            try
            {
                KeyValuePair <int, RoomUser> userPair = (KeyValuePair <int, RoomUser>)sender;
                RoomUser user = userPair.Value;

                if (user == null || user.GetClient() == null || user.GetClient().GetHabbo() == null)
                {
                    return;
                }

                GameClient session = user.GetClient();

                if (session == null || session.GetHabbo() == null)
                {
                    return;
                }

                if (userCount >= room.UsersMax && user.GetClient().GetHabbo().Rank < 4)
                {
                    ServerMessage msg = new ServerMessage(33);
                    msg.AppendInt32(4008);
                    session.SendMessage(msg);
                    return;
                }

                if (session.GetHabbo() != null && session.GetHabbo().userGroup != null)
                {
                    Group group = session.GetHabbo().userGroup;
                    if (!room.groups.ContainsKey(group.groupID))
                    {
                        room.groups.Add(group.groupID, group);
                    }
                }

                if (!user.IsSpectator)
                {
                    DynamicRoomModel Model = room.GetGameMap().Model;
                    if (room.IsPublic && session.SetDoorPos)
                    {
                        user.SetPos(session.newDoorPos.X, session.newDoorPos.Y, room.GetGameMap().StaticModel.SqFloorHeight[session.newDoorPos.X, session.newDoorPos.Y]);
                        user.SetRot(Model.DoorOrientation, false);
                        session.SetDoorPos = false;
                    }
                    else
                    {
                        user.SetPos(Model.DoorX, Model.DoorY, Model.DoorZ);
                        user.SetRot(Model.DoorOrientation, false);
                    }

                    if (room.CheckRights(session, true))
                    {
                        user.AddStatus("flatcrtl", "useradmin");
                    }
                    else if (room.CheckRights(session))
                    {
                        user.AddStatus("flatcrtl", "");
                    }
                    user.CurrentItemEffect = ItemEffectType.None;

                    //UpdateUserEffect(User, User.X, User.Y);

                    if (!user.IsBot && user.GetClient().GetHabbo().IsTeleporting)
                    {
                        RoomItem Item = room.GetRoomItemHandler().GetItem(user.GetClient().GetHabbo().TeleporterId);

                        if (Item != null)
                        {
                            user.SetPos(Item.GetX, Item.GetY, Item.GetZ);
                            user.SetRot(Item.Rot, false);

                            Item.InteractingUser2 = session.GetHabbo().Id;
                            Item.ExtraData        = "2";
                            Item.UpdateState(false, true);
                        }
                    }

                    user.GetClient().GetHabbo().IsTeleporting = false;
                    user.GetClient().GetHabbo().TeleporterId  = 0;

                    ServerMessage EnterMessage = new ServerMessage(28);
                    EnterMessage.AppendInt32(1);
                    user.Serialize(EnterMessage, room.GetGameMap().gotPublicPool);
                    room.SendMessage(EnterMessage);


                    if (room.Owner != session.GetHabbo().Username&& !room.IsPublic)
                    {
                        ButterflyEnvironment.GetGame().GetQuestManager().ProgressUserQuest(user.GetClient(), HabboHotel.Quests.QuestType.SOCIAL_VISIT);
                    }
                }

                if (session.GetHabbo().GetMessenger() != null)
                {
                    session.GetHabbo().GetMessenger().OnStatusChanged(true);
                }


                if (!user.IsSpectator)
                {
                    foreach (RoomUser roomUser in UserList.Values)
                    {
                        if (!user.IsBot)
                        {
                            continue;
                        }

                        roomUser.BotAI.OnUserEnterRoom(user);
                    }
                }

                user.GetClient().GetMessageHandler().OnRoomUserAdd();

                if (OnUserEnter != null)
                {
                    OnUserEnter(user, null);
                }

                if (room.GotMusicController())
                {
                    room.GetRoomMusicController().OnNewUserEnter(user);
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException(e.ToString());
            }
        }
예제 #5
0
        internal bool tryLogin(string AuthTicket)
        {
            try
            {
                string   ip        = GetConnection().getIp();
                byte     errorCode = 0;
                UserData userData  = UserDataFactory.GetUserData(AuthTicket, ip, out errorCode);
                if (errorCode == 1)
                {
                    SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso"));
                    return(false);
                }
                else if (errorCode == 2)
                {
                    SendNotifWithScroll(LanguageLocale.GetValue("login.loggedin"));
                    return(false);
                }


                if (Program.LicHandeler != null && ButterflyEnvironment.GetGame().GetClientManager().ClientCount > Program.LicHandeler.AmountOfSlots)
                {
                    Program.LicHandeler.ReportFullServer();
                    SendBanMessage(LanguageLocale.GetValue("server.full"));
                    return(false);
                }
                ButterflyEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username);
                this.Habbo = userData.user;
                userData.user.LoadData(userData);

                if (userData.user.Username == null)
                {
                    SendBanMessage("You have no username.");
                    return(false);
                }
                string banReason = ButterflyEnvironment.GetGame().GetBanManager().GetBanReason(userData.user.Username, ip);
                if (!string.IsNullOrEmpty(banReason))
                {
                    SendBanMessage(banReason);
                    return(false);
                }

                userData.user.Init(this, userData);

                QueuedServerMessage response = new QueuedServerMessage(Connection);

                userData.user.SerializeQuests(ref response);

                List <string> Rights = ButterflyEnvironment.GetGame().GetRoleManager().GetRightsForHabbo(userData.user);

                ServerMessage appendingResponse = new ServerMessage(2);
                appendingResponse.Init(2);
                appendingResponse.AppendInt32(Rights.Count);

                foreach (string Right in Rights)
                {
                    appendingResponse.AppendStringWithBreak(Right);
                }

                response.appendResponse(appendingResponse);

                if (userData.user.HasFuse("fuse_mod"))
                {
                    response.appendResponse(ButterflyEnvironment.GetGame().GetModerationTool().SerializeTool());
                    ButterflyEnvironment.GetGame().GetModerationTool().SerializeOpenTickets(ref response, userData.userID);
                }

                response.appendResponse(userData.user.GetAvatarEffectsInventoryComponent().Serialize());

                appendingResponse.Init(290);
                appendingResponse.AppendBoolean(true);
                appendingResponse.AppendBoolean(false);
                response.appendResponse(appendingResponse);

                appendingResponse.Init(3);
                response.appendResponse(appendingResponse);

                appendingResponse.Init(517);
                appendingResponse.AppendBoolean(true);
                response.appendResponse(appendingResponse);

                //if (PixelManager.NeedsUpdate(this))
                //    PixelManager.GivePixels(this);

                if (ButterflyEnvironment.GetGame().GetClientManager().pixelsOnLogin > 0)
                {
                    PixelManager.GivePixels(this, ButterflyEnvironment.GetGame().GetClientManager().pixelsOnLogin);
                }

                if (ButterflyEnvironment.GetGame().GetClientManager().creditsOnLogin > 0)
                {
                    userData.user.Credits += ButterflyEnvironment.GetGame().GetClientManager().creditsOnLogin;
                    userData.user.UpdateCreditsBalance();
                }

                if (userData.user.HomeRoom > 0)
                {
                    appendingResponse.Init(455);
                    appendingResponse.AppendUInt(userData.user.HomeRoom);
                    response.appendResponse(appendingResponse);
                }

                appendingResponse.Init(458);
                appendingResponse.AppendInt32(30);
                appendingResponse.AppendInt32(userData.user.FavoriteRooms.Count);

                foreach (uint Id in userData.user.FavoriteRooms.ToArray())
                {
                    appendingResponse.AppendUInt(Id);
                }

                response.appendResponse(appendingResponse);

                if (userData.user.HasFuse("fuse_use_club_badge") && !userData.user.GetBadgeComponent().HasBadge("ACH_BasicClub1"))
                {
                    userData.user.GetBadgeComponent().GiveBadge("ACH_BasicClub1", true);
                }
                else if (!userData.user.HasFuse("fuse_use_club_badge") && userData.user.GetBadgeComponent().HasBadge("ACH_BasicClub1"))
                {
                    userData.user.GetBadgeComponent().RemoveBadge("ACH_BasicClub1");
                }


                if (!userData.user.GetBadgeComponent().HasBadge("Z63"))
                {
                    userData.user.GetBadgeComponent().GiveBadge("Z63", true);
                }

                appendingResponse.Init(2);
                appendingResponse.AppendInt32(0);

                if (userData.user.HasFuse("fuse_use_vip_outfits")) // VIP
                {
                    appendingResponse.AppendInt32(2);
                }
                else if (userData.user.HasFuse("fuse_furni_chooser")) // HC
                {
                    appendingResponse.AppendInt32(1);
                }
                else
                {
                    appendingResponse.AppendInt32(0);
                }

                appendingResponse.AppendInt32(0);
                response.appendResponse(appendingResponse);

                appendingResponse.Init(2);
                appendingResponse.AppendInt32(Rights.Count);

                foreach (string Right in Rights)
                {
                    appendingResponse.AppendStringWithBreak(Right);
                }

                response.appendResponse(appendingResponse);

                if (LanguageLocale.welcomeAlertEnabled)
                {
                    ServerMessage alert = new ServerMessage(810);
                    alert.AppendUInt(1);
                    alert.AppendStringWithBreak(LanguageLocale.welcomeAlert);
                    response.appendResponse(alert);
                }

                response.sendResponse();
                Logging.WriteLine("[" + Habbo.Username + "] logged in");

                return(true);
            }
            catch (UserDataNotFoundException e)
            {
                SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso") + "extra data: " + e.ToString());
            }
            catch (Exception e)
            {
                //Logging.LogCriticalException("Invalid Dario bug duing user login: "******"Login error: " + e.ToString());
                SendNotifWithScroll("Login error: " + e.ToString());
            }
            return(false);
        }
예제 #6
0
파일: Room.cs 프로젝트: EmuZoneDEV/HBBO-EMU
        public void ProcessRoom(object pCallback)
        {
            try
            {
                this.isCycling = true;
                if (this.Disposed)
                {
                    return;
                }

                try
                {
                    int idleCount = 0;

                    this.GetRoomUserManager().OnCycle(ref idleCount);

                    this.GetRoomItemHandler().OnCycle();

                    this.RpCycleHour();

                    this.GetProjectileManager().OnCycle();

                    if (idleCount > 0)
                    {
                        this.IdleTime++;
                    }
                    else
                    {
                        this.IdleTime = 0;
                    }

                    if (!this.mCycleEnded)
                    {
                        if (this.IdleTime >= 60)
                        {
                            ButterflyEnvironment.GetGame().GetRoomManager().UnloadRoom(this);
                            this.mIsIdle = false;
                            return;
                        }
                        else
                        {
                            this.GetRoomUserManager().SerializeStatusUpdates();
                        }
                    }

                    if (this.GetGameItemHandler() != null)
                    {
                        this.GetGameItemHandler().OnCycle();
                    }

                    if (this.GetWiredHandler() != null)
                    {
                        this.GetWiredHandler().OnCycle();
                    }

                    if (this.GotJanken())
                    {
                        this.GetJanken().OnCycle();
                    }

                    if (this.SaveTimer < ((5 * 60) * 2))
                    {
                        this.SaveTimer++;
                    }
                    else
                    {
                        this.SaveTimer = 0;
                        using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            this.GetRoomItemHandler().SaveFurniture(queryreactor);
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.OnRoomCrash(ex);
                }
            }
            catch (Exception ex)
            {
                isCycling = false;
                Logging.LogCriticalException("Sub crash in room cycle: " + (ex).ToString());
            }
            finally
            {
                isCycling = false;
            }
        }
예제 #7
0
 internal static Game getGame()
 {
     return(ButterflyEnvironment.GetGame());
 }
예제 #8
0
파일: Quests.cs 프로젝트: nightwolf93/Bfly
 public void OpenQuests()
 {
     ButterflyEnvironment.GetGame().GetQuestManager().GetList(Session, Request);
 }
예제 #9
0
        public void Parse(WebClient Session, ClientPacket Packet)
        {
            if (Session == null)
            {
                return;
            }

            GameClient Client = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(Session.UserId);

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

            if (!Client.GetHabbo().HasFuse("fuse_wibbotool"))
            {
                return;
            }

            bool   EventAlert = Packet.PopBoolean();
            string Message    = Packet.PopString();
            string Url        = Packet.PopString();

            if (string.IsNullOrWhiteSpace(Message) || Message.Length > 1000 || Message.Length < 20)
            {
                return;
            }

            Message = Message.Replace("<", "&lt;").Replace(">", "&gt;");

            Message = new Regex(@"\[b\](.*?)\[\/b\]").Replace(Message, "<b>$1</b>");
            Message = new Regex(@"\[i\](.*?)\[\/i\]").Replace(Message, "<i>$1</i>");
            Message = new Regex(@"\[u\](.*?)\[\/u\]").Replace(Message, "<u>$1</u>");

            if (!string.IsNullOrWhiteSpace(Url))
            {
                ButterflyEnvironment.GetGame().GetModerationTool().LogStaffEntry(Client.GetHabbo().Id, Client.GetHabbo().Username, 0, string.Empty, "hal", string.Format("WbTool hal: {0} : {1}", Url, Message));

                if (!Url.StartsWith("https://wibbo.org") && !Url.StartsWith("https://www.facebook.com/WibboHotelFR") && !Url.StartsWith("https://twitter.com/WibboOrg") && !Url.StartsWith("https://instagram.com/wibboorg"))
                {
                    return;
                }

                ButterflyEnvironment.GetGame().GetClientWebManager().SendMessage(new NotifAlertComposer("annonce", "Message de communication", Message, "Allez voir !", 0, Url), Session.Langue);
                return;
            }

            if (EventAlert)
            {
                if (Client.GetHabbo().CurrentRoom == null)
                {
                    return;
                }

                ButterflyEnvironment.GetGame().GetModerationTool().LogStaffEntry(Client.GetHabbo().Id, Client.GetHabbo().Username, Client.GetHabbo().CurrentRoom.Id, string.Empty, "eventha", string.Format("WbTool eventha: {0}", Message));
                if (Client.Antipub(Message, "<eventalert>"))
                {
                    return;
                }

                if (!ButterflyEnvironment.GetGame().GetAnimationManager().AllowAnimation())
                {
                    return;
                }

                //ButterflyEnvironment.GetGame().GetClientManager().SendSuperNotif("Message des Staffs", AlertMessage, "game_promo_small", "event:navigator/goto/" + Client.GetHabbo().CurrentRoom.Id, "Je veux y accéder!", true, true);
                ButterflyEnvironment.GetGame().GetClientWebManager().SendMessage(new NotifAlertComposer("game_promo_small", "Message d'animation", Message, "Je veux y jouer !", Client.GetHabbo().CurrentRoom.Id, ""), Session.Langue);

                Client.GetHabbo().CurrentRoom.CloseFullRoom = true;
            }
            else
            {
                ButterflyEnvironment.GetGame().GetModerationTool().LogStaffEntry(Client.GetHabbo().Id, Client.GetHabbo().Username, 0, string.Empty, "ha", string.Format("WbTool ha: {0}", Message));
                if (Client.Antipub(Message, "<alert>"))
                {
                    return;
                }

                //ServerPacket message = new ServerPacket(ServerPacketHeader.BroadcastMessageAlertMessageComposer);
                //message.WriteString(ButterflyEnvironment.GetLanguageManager().TryGetValue("hotelallert.notice", Client.Langue) + "\r\n" + Message);// + "\r\n- " + Client.GetHabbo().Username);
                //ButterflyEnvironment.GetGame().GetClientManager().SendMessage(message);
                ButterflyEnvironment.GetGame().GetClientWebManager().SendMessage(new NotifAlertComposer("staff", "Message des Staffs", Message, "Compris !", 0, ""), Session.Langue);
            }
        }
예제 #10
0
파일: Quests.cs 프로젝트: nightwolf93/Bfly
 public void StopQuest()
 {
     ButterflyEnvironment.GetGame().GetQuestManager().CancelQuest(Session, Request);
 }
예제 #11
0
파일: Quests.cs 프로젝트: nightwolf93/Bfly
 public void GetCurrentQuest()
 {
     ButterflyEnvironment.GetGame().GetQuestManager().GetCurrentQuest(Session, Request);
 }
예제 #12
0
파일: Quests.cs 프로젝트: nightwolf93/Bfly
 public void StartQuest()
 {
     ButterflyEnvironment.GetGame().GetQuestManager().ActivateQuest(Session, Request);
 }
예제 #13
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            int  PresentId = Packet.PopInt();
            Item Present   = Room.GetRoomItemHandler().GetItem(PresentId);

            if (Present == null)
            {
                return;
            }

            if (!Room.CheckRights(Session, true))
            {
                return;
            }

            if (Present.GetBaseItem().InteractionType == InteractionType.GIFT)
            {
                DataRow Data = null;
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT `base_id`,`extra_data` FROM `user_presents` WHERE `item_id` = @presentId LIMIT 1");
                    dbClient.AddParameter("presentId", Present.Id);
                    Data = dbClient.GetRow();
                }

                if (Data == null)
                {
                    Room.GetRoomItemHandler().RemoveFurniture(null, Present.Id);

                    using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.RunQuery("DELETE items, items_limited FROM items LEFT JOIN items_limited ON (items_limited.item_id = items.id) WHERE items.id = '" + Present.Id + "'");
                        dbClient.RunQuery("DELETE FROM `user_presents` WHERE `item_id` = '" + Present.Id + "' LIMIT 1");
                    }

                    Session.GetHabbo().GetInventoryComponent().RemoveItem(Present.Id);
                    return;
                }

                ItemData BaseItem = null;
                if (!ButterflyEnvironment.GetGame().GetItemManager().GetItem(Convert.ToInt32(Data["base_id"]), out BaseItem))
                {
                    Room.GetRoomItemHandler().RemoveFurniture(null, Present.Id);

                    using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.RunQuery("DELETE items, items_limited FROM items LEFT JOIN items_limited ON (items_limited.item_id = items.id) WHERE items.id = '" + Present.Id + "'");
                        dbClient.RunQuery("DELETE FROM `user_presents` WHERE `item_id` = '" + Present.Id + "' LIMIT 1");
                    }

                    Session.GetHabbo().GetInventoryComponent().RemoveItem(Present.Id);
                    return;
                }

                FinishOpenGift(Session, BaseItem, Present, Room, Data);
            }
            else if (Present.GetBaseItem().InteractionType == InteractionType.EXTRABOX)
            {
                ItemExtrabox.OpenExtrabox(Session, Present, Room);
            }
            else if (Present.GetBaseItem().InteractionType == InteractionType.LEGENDBOX)
            {
                ItemExtrabox.OpenLegendBox(Session, Present, Room);
            }
            else if (Present.GetBaseItem().InteractionType == InteractionType.BADGEBOX)
            {
                ItemExtrabox.OpenBadgeBox(Session, Present, Room);
            }
        }
예제 #14
0
파일: Session.cs 프로젝트: nightwolf93/Bfly
        private void BytesReceived(IAsyncResult pIar)
        {
            try
            {
                int BytesReceived = mSock.EndReceive(pIar);
                try
                {
                    byte[] ReceivedData = new byte[BytesReceived];
                    Array.Copy(mDataBuffer, ReceivedData, BytesReceived);
                    string[] Packets = System.Text.Encoding.Default.GetString(mDataBuffer, 0, BytesReceived).Split('|');
                    foreach (string Packet in Packets)
                    {
                        if (string.IsNullOrEmpty(Packet))
                        {
                            continue;
                        }
                        string[] Data = Packet.Split(':');
                        if (Data[0].Length == 0)
                        {
                            Close();
                            return;
                        }

                        switch (Data[0])
                        {
                        /*
                         *
                         *
                         */
                        case "auth":
                        {
                            if (Data[1] == "bitch")
                            {
                                Logging.WriteLine(mIP + " -> Reached session");
                                SendData("authok");
                                SessionManagement.RegisterSession(this);
                                Authorizated = true;

                                DatabaseStats.totalQueries   = 0;
                                DatabaseStats.totalQueryTime = 0;
                            }
                            else
                            {
                                Close();
                            }
                            break;
                        }

                        case "upda":
                        {
                            if (!Authorizated)
                            {
                                Close();
                            }
                            else
                            {
                                int Rate;
                                if (mDisconnections == 0)
                                {
                                    Rate = 0;
                                }
                                else if (mDisconnections == 0 && mDisconnectionErrors > 0)
                                {
                                    Rate = mDisconnectionErrors;
                                }
                                else
                                {
                                    Rate = mDisconnectionErrors / mDisconnections;
                                }
                                mDisconnections      = 0;
                                mDisconnectionErrors = 0;

                                int    totalQueries   = DatabaseStats.totalQueries;
                                double totalQueryTime = DatabaseStats.totalQueryTime;

                                DatabaseStats.totalQueries   = 0;
                                DatabaseStats.totalQueryTime = 0;

                                int rate = 0;

                                if (totalQueryTime != 0 && totalQueries != 0)
                                {
                                    rate = (int)(totalQueryTime / totalQueries);
                                }

                                if (count == 0)
                                {
                                    queryspersecond = totalQueries;
                                    count++;
                                }
                                else
                                {
                                    count = 0;
                                }

                                //
                                SendData("data:onlinecount=" + (ButterflyEnvironment.GetGame().GetClientManager().ClientCount) + ",roomloadcount=" + ButterflyEnvironment.GetGame().GetRoomManager().LoadedRoomsCount + ",disconnectionrate=" + Rate + ",qurate=" + rate + ",qps=" + queryspersecond);
                            }
                            break;
                        }
                        }
                    }
                    ContinueListening();
                }
                catch
                {
                    Close();
                }
            }
            catch
            {
                Close();
            }
        }
예제 #15
0
파일: Habbo.cs 프로젝트: nightwolf93/Bfly
 private GameClient GetClient()
 {
     return(ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(Id));
 }
예제 #16
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room;

            if (!ButterflyEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room))
            {
                return;
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabboId(Session.GetHabbo().Id);

            if (User == null)
            {
                return;
            }

            int  PetId = Packet.PopInt();
            bool Type  = Packet.PopBoolean();

            RoomUser Pet = null;

            if (!Room.GetRoomUserManager().TryGetPet(PetId, out Pet))
            {
                return;
            }

            if (Pet.PetData == null || Pet.PetData.Type != 13)
            {
                return;
            }

            if (!Pet.PetData.AnyoneCanRide && Pet.PetData.OwnerId != User.UserId)
            {
                return;
            }

            if (Math.Abs(User.X - Pet.X) >= 2 || Math.Abs(User.Y - Pet.Y) >= 2)
            {
                User.MoveTo(Pet.X, Pet.Y);
                return;
            }

            if (Type && !User.RidingHorse)
            {
                if (Pet.RidingHorse)
                {
                    string Speechtxt = ButterflyEnvironment.GetLanguageManager().TryGetValue("pet.alreadymounted", Session.Langue);
                    Pet.OnChat(Speechtxt, 0, false);
                }
                else if (User.RidingHorse)
                {
                    return;
                }
                else
                {
                    if (Pet._statusses.Count > 0)
                    {
                        Pet._statusses.Clear();
                    }

                    int NewX2 = Pet.X;
                    int NewY2 = Pet.Y;
                    Room.SendPacket(Room.GetRoomItemHandler().UpdateUserOnRoller(User, new Point(NewX2, NewY2), 0, Room.GetGameMap().SqAbsoluteHeight(NewX2, NewY2) + 1));
                    Room.SendPacket(Room.GetRoomItemHandler().UpdateUserOnRoller(Pet, new Point(NewX2, NewY2), 0, Room.GetGameMap().SqAbsoluteHeight(NewX2, NewY2)));

                    User.MoveTo(NewX2, NewY2);

                    User.RidingHorse = true;
                    Pet.RidingHorse  = true;
                    Pet.HorseID      = User.VirtualId;
                    User.HorseID     = Pet.VirtualId;

                    if (Pet.PetData.Saddle == 9)
                    {
                        User.ApplyEffect(77);
                    }
                    else
                    {
                        User.ApplyEffect(103);
                    }

                    User.RotBody = Pet.RotBody;
                    User.RotHead = Pet.RotHead;

                    User.UpdateNeeded = true;
                    Pet.UpdateNeeded  = true;
                }
            }
            else
            {
                if (User.VirtualId == Pet.HorseID)
                {
                    Pet._statusses.Remove("sit");
                    Pet._statusses.Remove("lay");
                    Pet._statusses.Remove("snf");
                    Pet._statusses.Remove("eat");
                    Pet._statusses.Remove("ded");
                    Pet._statusses.Remove("jmp");
                    User.RidingHorse = false;
                    User.HorseID     = 0;
                    Pet.RidingHorse  = false;
                    Pet.HorseID      = 0;
                    User.MoveTo(new Point(User.X + 1, User.Y + 1));
                    User.ApplyEffect(-1);
                    User.UpdateNeeded = true;
                    Pet.UpdateNeeded  = true;
                }
            }

            Room.SendPacket(new PetHorseFigureInformationComposer(Pet));
        }
예제 #17
0
        public void Parse(WebClient Session, ClientPacket Packet)
        {
            int ItemId   = Packet.PopInt();
            int UseCount = Packet.PopInt();

            GameClient Client = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(Session.UserId);

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

            Room Room = Client.GetHabbo().CurrentRoom;

            if (Room == null || !Room.RpRoom)
            {
                return;
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabboId(Client.GetHabbo().Id);

            if (User == null)
            {
                return;
            }

            if (User.Freeze)
            {
                return;
            }

            RolePlayer Rp = User.Roleplayer;

            if (Rp == null || Rp.Dead || Rp.SendPrison || Rp.TradeId > 0)
            {
                return;
            }

            if (Rp.AggroTimer > 0)
            {
                User.SendWhisperChat(string.Format(ButterflyEnvironment.GetLanguageManager().TryGetValue("rp.useitem.notallowed", Client.Langue), Math.Round((double)Rp.AggroTimer / 2)));
                return;
            }

            RPItem RpItem = ButterflyEnvironment.GetGame().GetRoleplayManager().GetItemManager().GetItem(ItemId);

            if (RpItem == null)
            {
                return;
            }

            RolePlayInventoryItem RpItemInventory = Rp.GetInventoryItem(ItemId);

            if (RpItemInventory == null || RpItemInventory.Count <= 0 || RpItem.Type == "none")
            {
                return;
            }

            if (UseCount <= 0 || RpItem.UseType != 2)
            {
                UseCount = 1;
            }

            if (UseCount > RpItemInventory.Count)
            {
                UseCount = RpItemInventory.Count;
            }


            if (User.FreezeEndCounter <= 1)
            {
                User.Freeze           = true;
                User.FreezeEndCounter = 1;
            }

            if (RpItem.Id == 75)
            {
                Rp.AddInventoryItem(45, UseCount);
            }

            switch (RpItem.Type)
            {
            case "openpage":
            {
                User.GetClient().SendPacket(new NuxAlertComposer("habbopages/roleplay/" + RpItem.Value));
                break;
            }

            case "openguide":
            {
                User.GetClient().SendPacket(new NuxAlertComposer("habbopages/westworld/westworld"));
                break;
            }

            case "hit":
            {
                Rp.Hit(User, RpItem.Value * UseCount, Room, false, true, false);
                Rp.RemoveInventoryItem(RpItem.Id, UseCount);
                break;
            }

            case "enable":
            {
                User.ApplyEffect(RpItem.Value);
                break;
            }

            case "showtime":
            {
                User.SendWhisperChat("Il est " + Room.RpHour + " heures et " + Room.RpMinute + " minutes");
                break;
            }

            case "money":
            {
                Rp.Money += RpItem.Value * UseCount;
                Rp.RemoveInventoryItem(RpItem.Id, UseCount);
                Rp.SendUpdate();
                break;
            }

            case "munition":
            {
                Rp.AddMunition(RpItem.Value * UseCount);
                Rp.RemoveInventoryItem(RpItem.Id, UseCount);
                Rp.SendUpdate();
                break;
            }

            case "energytired":
            {
                User.ApplyEffect(4, true);
                User.TimerResetEffect = 2;

                Rp.AddEnergy(RpItem.Value * UseCount);
                Rp.Hit(User, RpItem.Value * UseCount, Room, false, true, false);
                Rp.SendUpdate();
                Rp.RemoveInventoryItem(RpItem.Id, UseCount);

                User.OnChat("*Consomme " + Char.ToLowerInvariant(RpItem.Title[0]) + RpItem.Title.Substring(1) + "*");
                break;
            }

            case "healthtired":
            {
                User.ApplyEffect(4, true);
                User.TimerResetEffect = 2;

                Rp.RemoveEnergy(RpItem.Value * UseCount);
                Rp.AddHealth(RpItem.Value * UseCount);
                Rp.SendUpdate();
                Rp.RemoveInventoryItem(RpItem.Id, UseCount);

                User.OnChat("*Consomme " + Char.ToLowerInvariant(RpItem.Title[0]) + RpItem.Title.Substring(1) + "*");
                break;
            }

            case "healthenergy":
            {
                User.ApplyEffect(4, true);
                User.TimerResetEffect = 2;

                Rp.AddEnergy(RpItem.Value * UseCount);
                Rp.AddHealth(RpItem.Value * UseCount);
                Rp.SendUpdate();
                Rp.RemoveInventoryItem(RpItem.Id, UseCount);

                User.OnChat("*Consomme " + Char.ToLowerInvariant(RpItem.Title[0]) + RpItem.Title.Substring(1) + "*");
                break;
            }

            case "energy":
            {
                User.ApplyEffect(4, true);
                User.TimerResetEffect = 2;

                Rp.AddEnergy(RpItem.Value * UseCount);
                Rp.SendUpdate();
                Rp.RemoveInventoryItem(RpItem.Id, UseCount);

                User.OnChat("*Consomme " + Char.ToLowerInvariant(RpItem.Title[0]) + RpItem.Title.Substring(1) + "*");
                break;
            }

            case "health":
            {
                User.ApplyEffect(737, true);
                User.TimerResetEffect = 4;

                Rp.AddHealth(RpItem.Value * UseCount);
                Rp.SendUpdate();
                Rp.RemoveInventoryItem(RpItem.Id, UseCount);

                User.OnChat("*Consomme " + Char.ToLowerInvariant(RpItem.Title[0]) + RpItem.Title.Substring(1) + "*");
                break;
            }

            case "weapon_cac":
            {
                if (Rp.WeaponCac.Id == RpItem.Value)
                {
                    break;
                }
                Rp.WeaponCac = ButterflyEnvironment.GetGame().GetRoleplayManager().GetWeaponManager().GetWeaponCac(RpItem.Value);
                User.SendWhisperChat(ButterflyEnvironment.GetLanguageManager().TryGetValue("rp.changearmecac", Client.Langue));
                break;
            }

            case "weapon_far":
            {
                if (Rp.WeaponGun.Id == RpItem.Value)
                {
                    break;
                }
                Rp.WeaponGun = ButterflyEnvironment.GetGame().GetRoleplayManager().GetWeaponManager().GetWeaponGun(RpItem.Value);
                User.SendWhisperChat(ButterflyEnvironment.GetLanguageManager().TryGetValue("rp.changearmefar", Client.Langue));
                break;
            }
            }
        }
예제 #18
0
 public void Execute(GameClient Session, Room Room, RoomUser UserRoom, string[] Params)
 {
     Session.SendHugeNotif(ButterflyEnvironment.GetGame().GetChatManager().GetCommands().GetCommandList(Session));
 }
예제 #19
0
        internal static void InvokeCommand(string inputData)
        {
            if (string.IsNullOrEmpty(inputData) && Logging.DisabledState)
            {
                return;
            }

            Console.WriteLine();

            if (Logging.DisabledState == false)
            {
                Logging.DisabledState = true;
                Console.WriteLine("Console writing disabled. Waiting for user input.");
                return;
            }

            try
            {
                #region Command parsing
                string[] parameters = inputData.Split(' ');

                switch (parameters[0])
                {
                case "roomload":
                {
                    if (parameters.Length <= 2)
                    {
                        Console.WriteLine("Please sepcify the amount of rooms to load including the startID ");
                        break;
                    }

                    uint rooms   = uint.Parse(parameters[1]);
                    uint startID = uint.Parse(parameters[2]);

                    for (uint i = startID; i < startID + rooms; i++)
                    {
                        getGame().GetRoomManager().LoadRoom(i);
                    }

                    Console.WriteLine(string.Format("{0} rooms loaded", rooms));

                    break;
                }

                case "loadrooms":
                {
                    uint       rooms  = uint.Parse(parameters[1]);
                    RoomLoader loader = new RoomLoader(rooms);
                    Console.WriteLine("Starting loading " + rooms + " rooms");
                    break;
                }

                case "systemmute":
                {
                    ButterflyEnvironment.SystemMute = !ButterflyEnvironment.SystemMute;
                    if (ButterflyEnvironment.SystemMute)
                    {
                        Console.WriteLine("Mute started");
                    }
                    else
                    {
                        Console.WriteLine("Mute ended");
                    }

                    break;
                }

                case "stop":
                case "shutdown":
                {
                    Logging.LogMessage("Server exiting at " + DateTime.Now);
                    Logging.DisablePrimaryWriting(true);
                    Console.WriteLine("The server is saving users furniture, rooms, etc. WAIT FOR THE SERVER TO CLOSE, DO NOT EXIT THE PROCESS IN TASK MANAGER!!");

                    ButterflyEnvironment.PreformShutDown(true);
                    break;
                }

                case "flush":
                {
                    if (parameters.Length < 2)
                    {
                        Console.WriteLine("You need to specify a parameter within your command. Type help for more information");
                    }
                    else
                    {
                        switch (parameters[1])
                        {
                        case "database":
                        {
                            ButterflyEnvironment.GetDatabaseManager().destroy();
                            Console.WriteLine("Closed old connections");
                            break;
                        }

                        case "settings":
                        {
                            if (parameters.Length < 3)
                            {
                                Console.WriteLine("You need to specify a parameter within your command. Type help for more information");
                            }
                            else
                            {
                                switch (parameters[2])
                                {
                                case "catalog":
                                {
                                    Console.WriteLine("Flushing catalog settings");

                                    using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                                    {
                                        getGame().GetCatalog().Initialize(dbClient);
                                    }
                                    getGame().GetCatalog().InitCache();
                                    getGame().GetClientManager().QueueBroadcaseMessage(new ServerMessage(441));

                                    Console.WriteLine("Catalog flushed");

                                    break;
                                }


                                case "modeldata":
                                {
                                    Console.WriteLine("Flushing modeldata");
                                    using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                                    {
                                        getGame().GetRoomManager().LoadModels(dbClient);
                                        getGame().GetRoomManager().InitRoomLinks(dbClient);
                                    }
                                    Console.WriteLine("Models flushed");

                                    break;
                                }

                                case "bans":
                                {
                                    Console.WriteLine("Flushing bans");
                                    using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                                    {
                                        getGame().GetBanManager().LoadBans(dbClient);
                                    }
                                    Console.WriteLine("Bans flushed");

                                    break;
                                }

                                case "commands":
                                {
                                    Console.WriteLine("Flushing commands");
                                    ChatCommandRegister.Init();
                                    PetCommandHandeler.Init();
                                    PetLocale.Init();
                                    Console.WriteLine("Commands flushed");

                                    break;
                                }

                                case "language":
                                {
                                    Console.WriteLine("Flushing language files");
                                    LanguageLocale.Init();
                                    Console.WriteLine("Language files flushed");

                                    break;
                                }
                                }
                            }
                            break;
                        }

                        //case "users":
                        //    {
                        //        Console.WriteLine("Flushing users...");
                        //        Console.WriteLine(getGame().GetClientManager().flushUsers() + " users flushed");
                        //        break;
                        //    }

                        //case "connections":
                        //    {
                        //        Console.WriteLine("Flushing connections...");
                        //        Console.WriteLine(getGame().GetClientManager().flushConnections() + " connections flushed");
                        //        break;
                        //    }

                        case "ddosprotection":
                        {
                            //Console.WriteLine("Flushing anti-ddos...");
                            //TcpAuthorization.Flush();
                            //Console.WriteLine("Anti-ddos flushed");
                            break;
                        }

                        case "console":
                        {
                            Console.Clear();
                            break;
                        }

                        case "toilet":
                        {
                            Console.WriteLine("Flushing toilet...");
                            Console.WriteLine("*SPLOUSH*");
                            Console.WriteLine("Toilet flushed");
                            break;
                        }

                        case "memory":
                        {
                            GC.Collect();
                            Console.WriteLine("Memory flushed");

                            break;
                        }

                        default:
                        {
                            unknownCommand(inputData);
                            break;
                        }
                        }
                    }

                    break;
                }

                case "view":
                {
                    if (parameters.Length < 2)
                    {
                        Console.WriteLine("You need to specify a parameter within your command. Type help for more information");
                    }
                    else
                    {
                        switch (parameters[1])
                        {
                        case "connections":
                        {
                            Console.WriteLine("Connection count: " + getGame().GetClientManager().connectionCount);
                            break;
                        }

                        case "users":
                        {
                            Console.WriteLine("User count: " + getGame().GetClientManager().ClientCount);
                            break;
                        }

                        case "rooms":
                        {
                            Console.WriteLine("Loaded room count: " + getGame().GetRoomManager().LoadedRoomsCount);
                            break;
                        }

                        //case "dbconnections":
                        //    {
                        //        Console.WriteLine("Database connection: " + ButterflyEnvironment.GetDatabaseManager().getOpenConnectionCount());
                        //        break;
                        //    }

                        case "console":
                        {
                            Console.WriteLine("Press ENTER for disabling console writing");
                            Logging.DisabledState = false;
                            break;
                        }

                        default:
                        {
                            unknownCommand(inputData);
                            break;
                        }
                        }
                    }
                    break;
                }

                case "alert":
                {
                    string Notice = inputData.Substring(6);

                    ServerMessage HotelAlert = new ServerMessage(810);
                    HotelAlert.AppendUInt(1);
                    HotelAlert.AppendStringWithBreak(LanguageLocale.GetValue("console.noticefromadmin") +
                                                     Notice);
                    getGame().GetClientManager().QueueBroadcaseMessage(HotelAlert);
                    Console.WriteLine("[" + Notice + "] sent");


                    //ButterflyEnvironment.messagingBot.SendMassMessage(new PublicMessage(string.Format("[@CONSOLE] => [{0}]", Notice)), true);

                    break;
                }

                //case "ddos":
                //case "setddosprotection":
                //    {
                //        if (parameters.Length < 2)
                //            Console.WriteLine("You need to specify a parameter within your command. Type help for more information");
                //        else
                //        {
                //            TcpAuthorization.Enabled = (parameters[1] == "true");
                //            if (TcpAuthorization.Enabled)
                //                Console.WriteLine("DDOS protection enabled");
                //            else
                //                Console.WriteLine("DDOS protection disabled");
                //        }

                //        break;
                //    }

                case "version":
                {
                    Console.WriteLine(ButterflyEnvironment.PrettyVersion);
                    break;
                }

                case "help":
                {
                    Console.WriteLine("shutdown - shuts down the server");
                    Console.WriteLine("flush");
                    Console.WriteLine("     settings");
                    Console.WriteLine("          catalog - flushes catalog");
                    Console.WriteLine("          modeldata - flushes modeldata");
                    Console.WriteLine("          bans - flushes bans");
                    Console.WriteLine("     users - disconnects everyone that does not got a user");
                    Console.WriteLine("     connections - closes all server connectinons");
                    Console.WriteLine("     rooms - unloads all rooms");
                    Console.WriteLine("     ddosprotection - flushes ddos protection");
                    Console.WriteLine("     console - clears console");
                    Console.WriteLine("     toilet - flushes the toilet");
                    Console.WriteLine("     cache - flushes the cache");
                    Console.WriteLine("     commands - flushes the commands");
                    Console.WriteLine("view");
                    Console.WriteLine(" ^^  connections - views connections");
                    Console.WriteLine("     users - views users");
                    Console.WriteLine("     rooms - views rooms");
                    Console.WriteLine("     dbconnections - views active database connections");
                    Console.WriteLine("     console - views server output (Press enter to disable)");
                    Console.WriteLine("          Note: Parameter stat shows sumary instead of list");
                    Console.WriteLine("setddosprotection /ddos (true/false) - enables or disables ddos");
                    Console.WriteLine("alert (message) - sends alert to everyone online");
                    Console.WriteLine("help - shows commandlist");
                    Console.WriteLine("runquery - runs a query");
                    Console.WriteLine("diagdump - dumps data to file for diagnostic");
                    Console.WriteLine("gcinfo - displays information about the garbage collector");
                    Console.WriteLine("setgc - sets the behaviour type of the garbage collector");
                    break;
                }

                case "runquery":
                {
                    string query = inputData.Substring(9);
                    using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        dbClient.runFastQuery(query);
                    }

                    break;
                }

                case "diagdump":
                {
                    DateTime      now     = DateTime.Now;
                    StringBuilder builder = new StringBuilder();
                    Console.WriteLine();
                    Console.WriteLine("============== SYSTEM DIAGNOSTICS DUMP ==============");
                    Console.WriteLine("Starting diagnostic dump at " + now.ToString());
                    Console.WriteLine();


                    builder.AppendLine("============== SYSTEM DIAGNOSTICS DUMP ==============");
                    builder.AppendLine("Starting diagnostic dump at " + now.ToString());
                    builder.AppendLine();

                    DateTime Now      = DateTime.Now;
                    TimeSpan TimeUsed = Now - ButterflyEnvironment.ServerStarted;

                    string uptime = "Server uptime: " + TimeUsed.Days + " day(s), " + TimeUsed.Hours + " hour(s) and " + TimeUsed.Minutes + " minute(s)";
                    string tcp    = "Active TCP connections: " + ButterflyEnvironment.GetGame().GetClientManager().ClientCount;
                    string room   = "Active rooms: " + ButterflyEnvironment.GetGame().GetRoomManager().LoadedRoomsCount;
                    Console.WriteLine(uptime);
                    Console.WriteLine(tcp);
                    Console.WriteLine(room);

                    builder.AppendLine(uptime);
                    builder.AppendLine(tcp);
                    builder.AppendLine(room);

                    Console.WriteLine();
                    builder.AppendLine();

                    Console.WriteLine("=== DATABASE STATUS ===");
                    builder.AppendLine("=== DATABASE STATUS ===");

                    builder.AppendLine();
                    Console.WriteLine();

                    Console.WriteLine();
                    Console.WriteLine("=== GAME LOOP STATUS ===");
                    builder.AppendLine();
                    builder.AppendLine("=== GAME LOOP STATUS ===");

                    string gameLoopStatus = "Game loop status: " + ButterflyEnvironment.GetGame().GameLoopStatus;
                    Console.WriteLine(gameLoopStatus);
                    builder.AppendLine(gameLoopStatus);
                    Console.WriteLine();
                    Console.WriteLine();

                    Console.WriteLine("Writing dumpfile...");
                    FileStream errWriter = new System.IO.FileStream(@"Logs\dump" + now.ToString().Replace(':', '.').Replace(" ", string.Empty).Replace("\\", ".") + ".txt", System.IO.FileMode.Append, System.IO.FileAccess.Write);
                    byte[]     Msg       = ASCIIEncoding.ASCII.GetBytes(builder.ToString());
                    errWriter.Write(Msg, 0, Msg.Length);
                    errWriter.Dispose();
                    Console.WriteLine("Done!");
                    break;
                }

                case "gcinfo":
                {
                    Console.WriteLine("Mode: " + System.Runtime.GCSettings.LatencyMode.ToString());
                    Console.WriteLine("Enabled: " + System.Runtime.GCSettings.IsServerGC);

                    break;
                }

                case "setgc":
                {
                    switch (parameters[1].ToLower())
                    {
                    default:
                    case "interactive":
                    {
                        GCSettings.LatencyMode = GCLatencyMode.Interactive;
                        break;
                    }

                    case "batch":
                    {
                        GCSettings.LatencyMode = GCLatencyMode.Batch;
                        break;
                    }

                    case "lowlatency":
                    {
                        GCSettings.LatencyMode = GCLatencyMode.LowLatency;
                        break;
                    }
                    }

                    Console.WriteLine("Latency mode set to: " + GCSettings.LatencyMode);
                    break;
                }

                case "packetdiag":
                {
                    ButterflyEnvironment.diagPackets = !ButterflyEnvironment.diagPackets;
                    if (ButterflyEnvironment.diagPackets)
                    {
                        Console.WriteLine("Packet diagnostic enabled");
                    }
                    else
                    {
                        Console.WriteLine("Packet diagnostic disabled");
                    }
                    break;
                }

                case "settimeout":
                {
                    int timeout = int.Parse(parameters[1]);
                    ButterflyEnvironment.timeout = timeout;
                    Console.WriteLine("Packet timeout set to " + timeout + "ms");
                    break;
                }

                case "trigmodule":
                {
                    switch (parameters[1].ToLower())
                    {
                    case "send":
                    {
                        if (ConnectionInformation.disableSend = !ConnectionInformation.disableSend)
                        {
                            Console.WriteLine("Data sending disabled");
                        }
                        else
                        {
                            Console.WriteLine("Data sending enabled");
                        }
                        break;
                    }

                    case "receive":
                    {
                        if (ConnectionInformation.disableReceive = !ConnectionInformation.disableReceive)
                        {
                            Console.WriteLine("Data receiving disabled");
                        }
                        else
                        {
                            Console.WriteLine("Data receiving enabled");
                        }
                        break;
                    }

                    case "roomcycle":
                    {
                        if (RoomManager.roomCyclingEnabled = !RoomManager.roomCyclingEnabled)
                        {
                            Console.WriteLine("Room cycling enabled");
                        }
                        else
                        {
                            Console.WriteLine("Room cycling disabled");
                        }

                        break;
                    }

                    case "gamecycle":
                    {
                        if (Game.gameLoopEnabled = !Game.gameLoopEnabled)
                        {
                            Console.WriteLine("Game loop started");
                        }
                        else
                        {
                            Console.WriteLine("Game loop stopped");
                        }

                        break;
                    }

                    case "db":
                    {
                        if (DatabaseManager.dbEnabled = !DatabaseManager.dbEnabled)
                        {
                            Console.WriteLine("Db enabled");
                        }
                        else
                        {
                            Console.WriteLine("Db stopped");
                        }

                        break;
                    }

                    default:
                    {
                        Console.WriteLine("Unknown module");
                        break;
                    }
                    }

                    break;
                }

                default:
                {
                    unknownCommand(inputData);
                    break;
                }
                }
                #endregion
            }
            catch (Exception e)
            {
                Console.WriteLine("Error in command [" + inputData + "]: " + e.ToString());
            }

            Console.WriteLine();
        }
예제 #20
0
        public void LoadFurniture(int RoomId = 0)
        {
            if (RoomId == 0)
            {
                this._floorItems.Clear();
                this._wallItems.Clear();
            }

            using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                queryreactor.SetQuery("SELECT items.id, items.user_id, items.room_id, items.base_item, items.extra_data, items.x, items.y, items.z, items.rot, items.wall_pos, items_limited.limited_number, items_limited.limited_stack FROM items LEFT JOIN items_limited ON (items_limited.item_id = items.id) WHERE items.room_id = @roomid");
                queryreactor.AddParameter("roomid", (RoomId == 0) ? this.GetRoom.Id : RoomId);

                int    itemID;
                int    UserId;
                int    baseID;
                string ExtraData;
                int    x;
                int    y;
                double z;
                sbyte  n;
                string wallposs;
                int    Limited;
                int    LimitedTo;
                string wallCoord;

                foreach (DataRow dataRow in queryreactor.GetTable().Rows)
                {
                    itemID    = Convert.ToInt32(dataRow[0]);
                    UserId    = Convert.ToInt32(dataRow[1]);
                    baseID    = Convert.ToInt32(dataRow[3]);
                    ExtraData = !DBNull.Value.Equals(dataRow[4]) ? (string)dataRow[4] : string.Empty;
                    x         = Convert.ToInt32(dataRow[5]);
                    y         = Convert.ToInt32(dataRow[6]);
                    z         = Convert.ToDouble(dataRow[7]);
                    n         = Convert.ToSByte(dataRow[8]);
                    wallposs  = !DBNull.Value.Equals(dataRow[9]) ? (string)(dataRow[9]) : string.Empty;
                    Limited   = !DBNull.Value.Equals(dataRow[10]) ? Convert.ToInt32(dataRow[10]) : 0;
                    LimitedTo = !DBNull.Value.Equals(dataRow[11]) ? Convert.ToInt32(dataRow[11]) : 0;

                    ItemData Data = null;
                    ButterflyEnvironment.GetGame().GetItemManager().GetItem(baseID, out Data);

                    if (Data == null)
                    {
                        continue;
                    }

                    if (Data.Type.ToString() == "i")
                    {
                        if (string.IsNullOrEmpty(wallposs))
                        {
                            wallCoord = "w=0,0 l=0,0 l";
                        }
                        else
                        {
                            wallCoord = wallposs;//WallPositionCheck(":" + wallposs.Split(':')[1]);
                        }
                        Item roomItem = new Item(itemID, this.GetRoom.Id, baseID, ExtraData, Limited, LimitedTo, 0, 0, 0.0, 0, wallCoord, this.GetRoom);
                        if (!this._wallItems.ContainsKey(itemID))
                        {
                            this._wallItems.TryAdd(itemID, roomItem);
                        }

                        if (roomItem.GetBaseItem().InteractionType == InteractionType.MOODLIGHT)
                        {
                            if (this.GetRoom.MoodlightData == null)
                            {
                                this.GetRoom.MoodlightData = new MoodlightData(roomItem.Id);
                            }
                        }
                    }
                    else //Is flooritem
                    {
                        Item roomItem = new Item(itemID, this.GetRoom.Id, baseID, ExtraData, Limited, LimitedTo, x, y, (double)z, n, "", this.GetRoom);

                        if (!this._floorItems.ContainsKey(itemID))
                        {
                            this._floorItems.TryAdd(itemID, roomItem);
                        }
                    }
                }

                if (RoomId == 0)
                {
                    foreach (Item Item in _floorItems.Values)
                    {
                        if (WiredUtillity.TypeIsWired(Item.GetBaseItem().InteractionType))
                        {
                            WiredLoader.LoadWiredItem(Item, this.GetRoom, queryreactor);
                        }
                    }
                }
            }
        }
예제 #21
0
        internal void OnCycle(ref int idleCount)
        {
            ToRemove.Clear();
            int userCounter = 0;

            foreach (RoomUser User in UserList.Values)
            {
                if (!isValid(User))
                {
                    if (User.GetClient() != null)
                    {
                        RemoveUserFromRoom(User.GetClient(), false, false);
                    }
                    else
                    {
                        RemoveRoomUser(User);
                    }
                }

                bool updated = false;
                User.IdleTime++;

                if (!User.IsAsleep && User.IdleTime >= 600)
                {
                    User.IsAsleep = true;

                    ServerMessage FallAsleep = new ServerMessage(486);
                    FallAsleep.AppendInt32(User.VirtualId);
                    FallAsleep.AppendBoolean(true);
                    room.SendMessage(FallAsleep);
                }

                if (User.NeedsAutokick && !ToRemove.Contains(User))
                {
                    ToRemove.Add(User);
                    continue;
                }

                if (User.CarryItemID > 0)
                {
                    User.CarryTimer--;
                    if (User.CarryTimer <= 0)
                    {
                        User.CarryItem(0);
                    }
                }

                if (room.GotFreeze())
                {
                    room.GetFreeze().CycleUser(User);
                }

                if (User.isFlying)
                {
                    User.OnFly();
                }

                if (User.SetStep)
                {
                    if (room.GetGameMap().CanWalk(User.SetX, User.SetY, User.AllowOverride))
                    {
                        room.GetGameMap().UpdateUserMovement(new Point(User.Coordinate.X, User.Coordinate.Y), new Point(User.SetX, User.SetY), User);
                        List <RoomItem> items = room.GetGameMap().GetCoordinatedItems(new Point(User.X, User.Y));

                        User.X = User.SetX;
                        User.Y = User.SetY;
                        User.Z = User.SetZ;
                        if (User.isFlying)
                        {
                            User.Z += 4 + 0.5 * Math.Sin(0.7 * User.flyk);
                        }

                        foreach (RoomItem item in items)
                        {
                            item.UserWalksOffFurni(User);
                        }

                        if (User.X == room.GetGameMap().Model.DoorX&& User.Y == room.GetGameMap().Model.DoorY&& !ToRemove.Contains(User) && !User.IsBot)
                        {
                            ToRemove.Add(User);
                            continue;
                        }

                        if (room.IsPublic)
                        {
                            room.GetGameMap().HandleRoomLinks(User);
                        }

                        UpdateUserStatus(User, true);
                    }
                    User.SetStep = false;
                }

                if (User.IsWalking && !User.Freezed)
                {
                    Gamemap     map   = room.GetGameMap();
                    SquarePoint Point = DreamPathfinder.GetNextStep(User.X, User.Y, User.GoalX, User.GoalY, map.GameMap, map.ItemHeightMap,
                                                                    map.Model.MapSizeX, map.Model.MapSizeY, User.AllowOverride, map.DiagonalEnabled);

                    if (Point.X == User.X && Point.Y == User.Y) //No path found, or reached goal (:
                    {
                        User.IsWalking = false;
                        User.RemoveStatus("mv");

                        UpdateUserStatus(User, false);
                    }
                    else
                    {
                        int nextX = Point.X;
                        int nextY = Point.Y;

                        User.RemoveStatus("mv");

                        double nextZ = room.GetGameMap().SqAbsoluteHeight(nextX, nextY);

                        User.Statusses.Remove("lay");
                        User.Statusses.Remove("sit");
                        if (!User.isFlying)
                        {
                            User.AddStatus("mv", nextX + "," + nextY + "," + TextHandling.GetString(nextZ));
                        }
                        else
                        {
                            User.AddStatus("mv", nextX + "," + nextY + "," + TextHandling.GetString(nextZ + 4 + (0.5 * Math.Sin(0.7 * User.flyk))));
                        }

                        int newRot = Rotation.Calculate(User.X, User.Y, nextX, nextY, User.moonwalkEnabled);

                        User.RotBody = newRot;
                        User.RotHead = newRot;

                        User.SetStep = true;
                        User.SetX    = nextX;
                        User.SetY    = nextY;
                        User.SetZ    = nextZ;

                        UpdateUserEffect(User, User.SetX, User.SetY);
                        updated = true;



                        room.GetGameMap().GameMap[User.X, User.Y] = User.SqState;       // REstore the old one
                        User.SqState = room.GetGameMap().GameMap[User.SetX, User.SetY]; //Backup the new one

                        if (!room.AllowWalkthrough)
                        {
                            room.GetGameMap().GameMap[nextX, nextY] = 0;
                        }
                    }

                    User.UpdateNeeded = true;
                }
                else
                {
                    if (User.Statusses.ContainsKey("mv"))
                    {
                        User.RemoveStatus("mv");
                        User.UpdateNeeded = true;
                    }
                }


                if (User.IsBot)
                {
                    User.BotAI.OnTimerTick();
                }
                else
                {
                    userCounter++;
                }

                if (!updated)
                {
                    UpdateUserEffect(User, User.X, User.Y);
                }
            }

            if (userCounter == 0)
            {
                idleCount++;
            }


            foreach (RoomUser toRemove in ToRemove)
            {
                GameClient client = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(toRemove.HabboId);
                if (client != null)
                {
                    RemoveUserFromRoom(client, true, false);
                    client.CurrentRoomUserID = -1;
                }
                else
                {
                    RemoveRoomUser(toRemove);
                }
            }

            if (userCount != userCounter)
            {
                UpdateUserCount(userCounter);
            }
        }
예제 #22
0
        private bool EndTrade(RPTroc Troc)
        {
            RolePlayerManager RPManager = ButterflyEnvironment.GetGame().GetRoleplayManager().GetRolePlay(Troc.RPId);

            if (RPManager == null)
            {
                return(false);
            }

            RolePlayer PlayerOne = RPManager.GetPlayer(Troc.UserOne.UserId);

            if (PlayerOne == null)
            {
                return(false);
            }

            RolePlayer PlayerTwo = RPManager.GetPlayer(Troc.UserTwo.UserId);

            if (PlayerTwo == null)
            {
                return(false);
            }

            foreach (KeyValuePair <int, int> entry in Troc.UserOne.ItemIds)
            {
                RolePlayInventoryItem Item = PlayerOne.GetInventoryItem(entry.Key);
                if (Item == null)
                {
                    return(false);
                }
                if (Item.Count < entry.Value)
                {
                    return(false);
                }
            }
            foreach (KeyValuePair <int, int> entry in Troc.UserTwo.ItemIds)
            {
                RolePlayInventoryItem Item = PlayerTwo.GetInventoryItem(entry.Key);
                if (Item == null)
                {
                    return(false);
                }
                if (Item.Count < entry.Value)
                {
                    return(false);
                }
            }

            foreach (KeyValuePair <int, int> entry in Troc.UserOne.ItemIds)
            {
                RolePlayInventoryItem Item = PlayerOne.GetInventoryItem(entry.Key);
                if (Item == null)
                {
                    return(false);
                }

                PlayerOne.RemoveInventoryItem(entry.Key, entry.Value);
                PlayerTwo.AddInventoryItem(entry.Key, entry.Value);
            }

            foreach (KeyValuePair <int, int> entry in Troc.UserTwo.ItemIds)
            {
                PlayerTwo.RemoveInventoryItem(entry.Key, entry.Value);
                PlayerOne.AddInventoryItem(entry.Key, entry.Value);
            }

            return(true);
        }
예제 #23
0
        internal void RemoveUserFromRoom(GameClient Session, Boolean NotifyClient, Boolean NotifyKick)
        {
            try
            {
                if (Session == null)
                {
                    return;
                }

                if (Session.GetHabbo() == null)
                {
                    return;
                }


                Session.GetHabbo().GetAvatarEffectsInventoryComponent().OnRoomExit();

                if (NotifyClient)
                {
                    if (NotifyKick)
                    {
                        Session.GetMessageHandler().GetResponse().Init(33);
                        Session.GetMessageHandler().GetResponse().AppendInt32(4008);
                        Session.GetMessageHandler().SendResponse();
                    }

                    Session.GetMessageHandler().GetResponse().Init(18);
                    Session.GetMessageHandler().SendResponse();
                }

                RoomUser User = GetRoomUserByHabbo(Session.GetHabbo().Id);


                if (User != null)
                {
                    RemoveRoomUser(User);


                    if (Session.GetHabbo() != null)
                    {
                        if (!User.IsSpectator)
                        {
                            if (User.CurrentItemEffect != ItemEffectType.None)
                            {
                                User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().CurrentEffect = -1;
                            }
                            //UserMatrix[User.X, User.Y] = false;

                            if (Session.GetHabbo() != null)
                            {
                                if (room.HasActiveTrade(Session.GetHabbo().Id))
                                {
                                    room.TryStopTrade(Session.GetHabbo().Id);
                                }

                                if (Session.GetHabbo().Username == room.Owner)
                                {
                                    if (room.HasOngoingEvent)
                                    {
                                        room.Event = new RoomEvent(0, null, null, 0, new List <string>());

                                        ServerMessage Message = new ServerMessage(370);
                                        Message.AppendStringWithBreak("-1");
                                        room.SendMessage(Message);

                                        ButterflyEnvironment.GetGame().GetRoomManager().GetEventManager().QueueRemoveEvent(room.RoomData, room.Event.Category);
                                    }
                                }
                                Session.GetHabbo().CurrentRoomId = 0;

                                if (Session.GetHabbo().GetMessenger() != null)
                                {
                                    Session.GetHabbo().GetMessenger().OnStatusChanged(true);
                                }
                            }

                            //DateTime Start = DateTime.Now;
                            //using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                            //{
                            //    //TimeSpan TimeUsed1 = DateTime.Now - Start;
                            //    //Logging.LogThreadException("Time used on sys part 2: " + TimeUsed1.Seconds + "s, " + TimeUsed1.Milliseconds + "ms", "");

                            //    //if (Session.GetHabbo() != null)
                            //    //    dbClient.runFastQuery("UPDATE user_roomvisits SET exit_timestamp = '" + ButterflyEnvironment.GetUnixTimestamp() + "' WHERE room_id = '" + this.Id + "' AND user_id = '" + Id + "' ORDER BY exit_timestamp DESC LIMIT 1");
                            //    //dbClient.runFastQuery("UPDATE rooms SET users_now = " + UsersNow + " WHERE id = " + Id);
                            //    //dbClient.runFastQuery("REPLACE INTO room_active VALUES (" + RoomId + ", " + UsersNow + ")");
                            //    dbClient.runFastQuery("UPDATE room_active SET active_users = " + UsersNow);
                            //}
                        }
                    }

                    usersByUserID.Remove(User.userID);
                    if (Session.GetHabbo() != null)
                    {
                        usersByUsername.Remove(Session.GetHabbo().Username.ToLower());
                    }

                    User.Dispose();
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException("Error during removing user from room:" + e.ToString());
            }
        }
예제 #24
0
 public void Parse(GameClient Session, ClientPacket Packet)
 {
     ButterflyEnvironment.GetGame().GetQuestManager().ActivateQuest(Session, Packet);
 }
예제 #25
0
 internal void GetCatalogIndex()
 {
     Session.SendMessage(ButterflyEnvironment.GetGame().GetCatalog().GetIndexMessageForRank(Session.GetHabbo().Rank));
 }
 public void Parse(GameClient Session, ClientPacket Packet)
 {
     Session.SendPacket(new GroupFurniConfigComposer(ButterflyEnvironment.GetGame().GetGroupManager().GetGroupsForUser(Session.GetHabbo().MyGroups)));
 }
예제 #27
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            ICollection <SearchResultList> Categories = ButterflyEnvironment.GetGame().GetNavigator().GetFlatCategories();

            Session.SendPacket(new UserFlatCatsComposer(Categories, Session.GetHabbo().Rank));
        }
예제 #28
0
파일: Habbo.cs 프로젝트: nightwolf93/Bfly
 internal void SerializeQuests(ref QueuedServerMessage response)
 {
     ButterflyEnvironment.GetGame().GetQuestManager().GetList(mClient, null);
 }
예제 #29
0
        internal void processCommand(String data)
        {
            String header = data.Split(Convert.ToChar(1))[0];
            String param  = data.Split(Convert.ToChar(1))[1];

            Logging.WriteLine("[MUSConnection.ProcessCommand]: " + data);

            GameClient Client = null;

            switch (header.ToLower())
            {
            case "updatecredits":
            {
                if (param == "ALL")
                {
                    //   ButterflyEnvironment.GetGame().GetClientManager().GetClient()
                }
                else
                {
                    Client = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(uint.Parse(param));

                    if (Client == null)
                    {
                        return;
                    }

                    DataRow newCredits;

                    using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        dbClient.setQuery("SELECT credits FROM users WHERE id = @userid");
                        dbClient.addParameter("userid", (int)Client.GetHabbo().Id);
                        newCredits = dbClient.getRow();
                    }

                    Client.GetHabbo().Credits = (int)newCredits["credits"];
                    Client.GetHabbo().UpdateCreditsBalance();
                }

                break;
            }

            case "signout":
            {
                ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(uint.Parse(param)).Disconnect();
                break;
            }

            case "ha":
            {
                //String extradata = data.Split(Convert.ToChar(1))[2];

                ServerMessage HotelAlert = new ServerMessage(810);
                HotelAlert.AppendUInt(1);
                HotelAlert.AppendStringWithBreak(LanguageLocale.GetValue("hotelallert.notice") + "\r\n" +
                                                 param + "\r\n");

                /*if (extradata.Contains("://"))
                 * {
                 *  Console.WriteLine("TEST");
                 *  HotelAlert.AppendStringWithBreak(extradata);
                 * }*/

                ButterflyEnvironment.GetGame().GetClientManager().QueueBroadcaseMessage(HotelAlert);
                break;
            }

            case "useralert":
            {
                String     extradata    = data.Split(Convert.ToChar(1))[2];
                String     url          = extradata.Split(Convert.ToChar(1))[0];
                GameClient TargetClient = null;
                TargetClient = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(param);

                if (TargetClient == null)
                {
                    return;
                }
                if (url.Contains("://"))
                {
                    extradata = extradata + Convert.ToChar(2) + url;
                }
                TargetClient.SendNotif(extradata);
                break;
            }

            default:
            {
                Logging.WriteLine("Unrecognized MUS packet: " + data);
                break;
            }
            }
        }
예제 #30
0
        internal void Fill(DataRow Row)
        {
            this.Id          = Convert.ToUInt32(Row["id"]);
            this.Name        = (string)Row["caption"];
            this.Description = (string)Row["description"];
            this.Type        = (string)Row["roomtype"];
            this.Owner       = (string)Row["owner"];

            switch (Row["state"].ToString().ToLower())
            {
            case "open":

                this.State = 0;
                break;

            case "password":

                this.State = 2;
                break;

            case "locked":
            default:

                this.State = 1;
                break;
            }

            this.Category = (int)Row["category"];
            if (!string.IsNullOrEmpty(Row["active_users"].ToString()))
            {
                this.UsersNow = (int)Row["active_users"];
            }
            else
            {
                this.UsersNow = 0;
            }
            this.UsersMax            = (int)Row["users_max"];
            this.ModelName           = (string)Row["model_name"];
            this.CCTs                = (string)Row["public_ccts"];
            this.Score               = (int)Row["score"];
            this.Tags                = new List <string>();
            this.AllowPets           = ButterflyEnvironment.EnumToBool(Row["allow_pets"].ToString());
            this.AllowPetsEating     = ButterflyEnvironment.EnumToBool(Row["allow_pets_eat"].ToString());
            this.AllowWalkthrough    = ButterflyEnvironment.EnumToBool(Row["allow_walkthrough"].ToString());
            this.AllowRightsOverride = ButterflyEnvironment.EnumToBool(Row["allow_rightsoverride"].ToString());
            this.Hidewall            = ButterflyEnvironment.EnumToBool(Row["allow_hidewall"].ToString());
            this.Password            = (string)Row["password"];
            this.Wallpaper           = (string)Row["wallpaper"];
            this.Floor               = (string)Row["floor"];
            this.Landscape           = (string)Row["landscape"];
            this.FloorThickness      = (int)Row["floorthickness"];
            this.WallThickness       = (int)Row["wallthickness"];
            //this.Event = null;

            Dictionary <int, int> IconItems = new Dictionary <int, int>();

            if (!string.IsNullOrEmpty(Row["icon_items"].ToString()))
            {
                foreach (string Bit in Row["icon_items"].ToString().Split('|'))
                {
                    if (string.IsNullOrEmpty(Bit))
                    {
                        continue;
                    }

                    string[] tBit = Bit.Replace('.', ',').Split(',');

                    int a = 0;
                    int b = 0;

                    int.TryParse(tBit[0], out a);
                    if (tBit.Length > 1)
                    {
                        int.TryParse(tBit[1], out b);
                    }

                    try
                    {
                        if (!IconItems.ContainsKey(a))
                        {
                            IconItems.Add(a, b);
                        }
                    }
                    catch (Exception e)
                    {
                        Logging.LogException("Exception: " + e.ToString() + "[" + Bit + "]");
                    }
                }
            }

            this.myIcon = new RoomIcon((int)Row["icon_bg"], (int)Row["icon_fg"], IconItems);

            foreach (string Tag in Row["tags"].ToString().Split(','))
            {
                this.Tags.Add(Tag);
            }

            mModel = ButterflyEnvironment.GetGame().GetRoomManager().GetModel(ModelName, Id);
        }