예제 #1
0
        /// <summary>
        /// 380 - "E|"
        /// </summary>
        private void SetFrontPageListening()
        {
            Response.Initialize(450); // "GB"
            using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
            {
                DataTable DataQuery = dbClient.ReadDataTable("SELECT * FROM public_rooms ORDER BY style ASC");

                Response.AppendInt32(DataQuery.Rows.Count);
                foreach (System.Data.DataRow Row in DataQuery.Rows)
                {
                    Response.AppendInt32((int)Row["id"]);
                    Response.AppendString((string)Row["frontpagetext"]);
                    Response.AppendString((string)Row["desc"]);
                    Response.AppendInt32((int)Row["style"]);
                    Response.AppendString((string)Row["frontpagetext"]);
                    Response.AppendString(string.Empty);
                    Response.AppendInt32((int)Row["hidden"]);
                    Response.AppendInt32((int)Row["in_room"]);
                    Response.AppendInt32((int)Row["type"]);
                    Response.AppendString((string)Row["model"]);
                    Response.AppendInt32((int)Row["id"]);
                    Response.AppendInt32(0);
                    Response.AppendString((string)Row["ccts"]);
                    Response.AppendInt32((int)Row["max_in"]);
                    Response.AppendInt32((int)Row["id"]);
                }
                SendResponse();
            }
        }
예제 #2
0
        public cataloguePages()
        {
            //Initalize the "cataPages" List.
            cataPages = new List <cataloguePages>();

            //Run the queries and define them/put them into cache.
            using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
            {
                foreach (DataRow row in dbClient.ReadDataTable("SELECT * FROM catalogue_pages;").Rows)
                {
                    cataPages.Add(new cataloguePages(
                                      Convert.ToInt32(row["indexid"]),
                                      Convert.ToString(row["style_layout"]),
                                      Convert.ToString(row["img_header"]),
                                      Convert.ToString(row["img_side"]),
                                      Convert.ToString(row["label_text"]),
                                      Convert.ToString(row["label_description"]),
                                      Convert.ToString(row["label_moredetails"]),
                                      Convert.ToString(row["header_else"]),
                                      Convert.ToString(row["content_else"])));
                }
            }

            //Console.WriteLine("Initializing Catalogue Page(s).");
            //Console.WriteLine("Successfully cached [ " + cataPages.Count + " ] pages.\n");
        }
예제 #3
0
 public void reload_bots()
 {
     if (Session.GetHabbo().HasFuse("fuse_admin") || Session.GetHabbo().HasFuse("fuse_sysadmin"))
     {
         AleedaEnvironment.GetCache().GetRoomBots().Reload();
     }
 }
예제 #4
0
        private void WisperHandler()
        {
            string mMessage   = Request.PopFixedString();
            string TargetUser = mMessage.Split(' ')[0];

            mMessage = mMessage.Substring(TargetUser.Length + 1);

            try
            {
                uint       SessionId = AleedaEnvironment.GetHabboHotel().GetHabbos().GetHabbo(TargetUser).ID;
                GameClient mUser     = AleedaEnvironment.GetHabboHotel().GetClients().GetClientOfHabbo(SessionId);

                ServerMessage Message = new ServerMessage(25); // "@Y"
                Message.AppendInt32(Client.GetHabbo().UnitId);
                Message.AppendString(mMessage);
                Message.AppendBoolean(true);
                mUser.GetConnection().SendMessage(Message);


                Response.Initialize(25); // "@Y"
                Response.AppendInt32(Client.GetHabbo().UnitId);
                Response.AppendString(mMessage);
                Response.AppendBoolean(true);
                SendResponse();
            }
            catch
            {
                Response.Initialize(25); // "@Y"
                Response.AppendInt32(Client.GetHabbo().UnitId);
                Response.AppendString(mMessage);
                Response.AppendBoolean(true);
                SendRoom();
            }
        }
예제 #5
0
        public static void BootUp()
        {
            Privileges = new Dictionary <string, bool>();

            using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
            {
                DataTable BootTable = null;

                BootTable = dbClient.ReadDataTable("SELECT field, enabled FROM server_config");

                if (BootTable != null)
                {
                    foreach (DataRow BootRows in BootTable.Rows)
                    {
                        if ((int)BootRows["enabled"] == 0)
                        {
                            Privilege.Privileges.Add((string)BootRows["field"], true);
                        }
                        else
                        {
                            Privilege.Privileges.Add((string)BootRows["field"], false);
                        }
                    }
                }
            }

            //Console.WriteLine("Initializing System Hotel Privileges.");
            //Console.WriteLine("Successfully cached [ " + Privileges.Count + " ] privileges.\n");
        }
예제 #6
0
        public static UserInventory Parse(DataRow row, bool b)
        {
            UserInventory details = new UserInventory();

            try
            {
                if (!b)
                {
                    details.mID      = (int)row["id"];
                    details.mName    = (string)row["name"];
                    details.spriteID = (int)row["sprite_id"];
                    details.mType    = (string)row["type"];
                }
                else if (b)
                {
                    details.mID     = (int)row["id"];
                    details.petname = (string)row["petname"];
                    details.race    = (int)row["race"];
                    details.colour  = (string)row["color"];
                }
                return(details);
            }
            catch (Exception ex)
            {
                AleedaEnvironment.GetLog().WriteUnhandledExceptionError("UserInventory.Parse", ex);
            }

            return(null);
        }
예제 #7
0
파일: Rooms.cs 프로젝트: YuupOnline/Aleeda
        /// <summary>
        /// 390 - "FF"
        /// </summary>
        private void GetRoomEntryDataMessageComposer()
        {
            try
            {
                Client.GetHabbo().X = Client.GetHabbo().Functions().GetModelX();
                Client.GetHabbo().Y = Client.GetHabbo().Functions().GetModelY();
            }
            catch
            {
                Client.GetHabbo().X = 0;
                Client.GetHabbo().Y = 0;
            }

            using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
            {
                string map;
                try
                {
                    map = dbClient.ReadString("SELECT heightmap FROM room_models WHERE id = '" + Client.GetHabbo().FlatModel + "'");
                }
                catch
                {
                    map = "";
                }
                Response.Initialize(31); // "@_"
                Response.AppendString(map.Replace("/", "\r"));
                SendResponse();

                Response.Initialize(470); // "GV"
                Response.AppendString(map.Replace("/", "\r"));
                SendResponse();

                CatalogIndexMessageEvent();
            }
        }
예제 #8
0
파일: Rooms.cs 프로젝트: YuupOnline/Aleeda
        private void GetRoomSettingsMessageComposer()
        {
            PrivateRooms mRoom = AleedaEnvironment.GetCache().GetPrivateRooms().getRoom(Client.GetHabbo().RoomId);

            if (mRoom == null)
            {
                return;
            }

            Response.Initialize(465); // "GQ"
            Response.AppendInt32(mRoom.ID);
            Response.AppendString(mRoom.Name);
            Response.AppendString(mRoom.Description);
            Response.AppendInt32(mRoom.Status);
            Response.AppendInt32(mRoom.Category);
            Response.AppendInt32(mRoom.MaxVisitors);
            Response.AppendInt32(25);
            Response.AppendInt32(AleedaEnvironment.GetCache().GetPrivateRooms().GetTagCount(mRoom.ID)); //TAG count
            AleedaEnvironment.GetCache().GetPrivateRooms().AppendTags(Response, mRoom.ID);
            AleedaEnvironment.GetCache().GetPrivateRooms().SerializeUsersWithRights(Response, mRoom.ID);
            Response.AppendInt32(AleedaEnvironment.GetCache().GetPrivateRooms().RoomWithRightsCount(mRoom.ID));
            Response.AppendInt32(mRoom.PetsAllowed);        // allows pets in room - pet system lacking, so always off
            Response.AppendBoolean(mRoom.PetsEatOtherFood); // allows pets to eat your food - pet system lacking, so always off
            Response.AppendBoolean(true);
            Response.AppendBoolean(false);                  //hidewalls
            Response.AppendInt32(0);
            Response.AppendInt32(0);
            SendResponse();
        }
예제 #9
0
 public void Serialize(ServerMessage message)
 {
     message.AppendUInt32(mID);
     message.AppendString(mUsername);
     message.AppendBoolean(true);
     using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
     {
         DataTable isOnlineQuery = dbClient.ReadDataTable("SELECT * FROM users WHERE username = '******'");
         foreach (DataRow isOnline in isOnlineQuery.Rows)
         {
             if ((int)isOnline["online"] == 0)
             {
                 message.AppendBoolean(false);
             }
             else
             {
                 message.AppendBoolean(true);
             }
         }
     }
     message.AppendBoolean(false);
     message.AppendString(mFigure);
     message.AppendBoolean(false);
     message.AppendString(mMotto);
     message.AppendString("1-1-2011");
     message.AppendString("");
     message.AppendString("");
     //message.AppendString("");
 }
예제 #10
0
 public static int OnlineCount()
 {
     using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
     {
         return(dbClient.ReadDataTable("SELECT * FROM users WHERE online = '1'").Rows.Count);
     }
 }
예제 #11
0
        public CatalogueIndex()
        {
            //Initalize the "cataPages" List.
            cataIndex = new List <CatalogueIndex>();

            //Run the queries and define them/put them into cache.
            using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
            {
                foreach (DataRow row in dbClient.ReadDataTable("SELECT * FROM catalogue_categories;").Rows)
                {
                    cataIndex.Add(new CatalogueIndex(
                                      Convert.ToInt32(row["indexid"]),
                                      Convert.ToInt32(row["pageid"]),
                                      Convert.ToInt32(row["minrank"]),
                                      Convert.ToInt32(row["icon"]),
                                      Convert.ToInt32(row["colour"]),
                                      Convert.ToString(row["indexname"]), true, 0));
                }
                foreach (DataRow row in dbClient.ReadDataTable("SELECT * FROM catalogue_pages;").Rows)
                {
                    cataIndex.Add(new CatalogueIndex(
                                      Convert.ToInt32(row["indexid"]), 0,
                                      Convert.ToInt32(row["minrank"]),
                                      Convert.ToInt32(row["style_icon"]), 0,
                                      Convert.ToString(row["displayname"]), false,
                                      Convert.ToInt32(row["in_category"])));
                }
            }
        }
예제 #12
0
        public static ServerMessage PlaceFurni(GameClient Session, int id, int x, int y, int rot, DatabaseClient dbClient)
        {
            List <UserInventory> mInventoryItem = AleedaEnvironment.GetHabboHotel().GetRoomUser().GetUserInventory(Session.GetHabbo().ID, false, Session.GetHabbo().ItemUsingID);

            foreach (UserInventory mItem in mInventoryItem)
            {
                dbClient.AddParamWithValue("id", Session.GetHabbo().RoomId);
                dbClient.AddParamWithValue("x", x);
                dbClient.AddParamWithValue("y", y);
                dbClient.AddParamWithValue("rotation", rot);
                dbClient.AddParamWithValue("sID", mItem.SpriteID);
                dbClient.ExecuteQuery("INSERT INTO room_items (`id`, `mID`, `x_axis`, `y_axis`, `rotation`, `sprite_id`, `trigger`, `isWallItem`) VALUES ('" + id + "', @id, @x, @y, @rotation, @sID, 1, 0);");

                ServerMessage Message = new ServerMessage(93);
                Message.AppendInt32(id);
                Message.AppendInt32(mItem.SpriteID);
                Message.AppendInt32(x);
                Message.AppendInt32(y);
                Message.AppendInt32(rot);
                Message.AppendString("0.0");
                Message.AppendInt32(1);
                Message.AppendString("" + 1);
                Message.AppendInt32(-1);
                return(Message);
            }
            return(null);
        }
예제 #13
0
        public void add_tag()
        {
            if (Session.GetHabbo().HasFuse("fuse_admin") || Session.GetHabbo().HasFuse("fuse_sysadmin") || Session.GetHabbo().HasFuse("fuse_mod") || RoomUser.CalculateRights(Session.GetHabbo().RoomId, Session.GetHabbo().ID))
            {
                int    Length          = args[0].Length + 1;
                string Tag             = command.Substring(Length);
                string CurrentTags     = "";
                int    CurrentTagCount = 0;

                using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
                {
                    CurrentTags = dbClient.ReadString("SELECT tags FROM private_rooms WHERE id = '" + Session.GetHabbo().RoomId + "'");

                    foreach (string tag in CurrentTags.Split(','))
                    {
                        ++CurrentTagCount;
                    }

                    if (CurrentTagCount != 4)
                    {
                        CurrentTags = Tag + "," + CurrentTags;

                        dbClient.AddParamWithValue("tag", CurrentTags);
                        dbClient.ExecuteQuery("UPDATE private_rooms SET tags = @tag WHERE id = '" + Session.GetHabbo().RoomId + "'");
                    }
                    //Set the variable
                    AleedaEnvironment.GetCache().GetPrivateRooms().getRoom(Session.GetHabbo().RoomId).Tags = CurrentTags;

                    ServerMessage msg = new ServerMessage(139); // "BK"
                    msg.Append("Added more tags!. ( " + Tag + " )");
                    Session.GetMessageHandler().SendRoom(msg);
                }
            }
        }
예제 #14
0
        public void remove_tag()
        {
            if (Session.GetHabbo().HasFuse("fuse_admin") || Session.GetHabbo().HasFuse("fuse_sysadmin") || Session.GetHabbo().HasFuse("fuse_mod") || RoomUser.CalculateRights(Session.GetHabbo().RoomId, Session.GetHabbo().ID))
            {
                int    Length = args[0].Length + 1;
                string Tag    = command.Substring(Length);

                using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
                {
                    string CurrentTags = dbClient.ReadString("SELECT tags FROM private_rooms WHERE id = '" + Session.GetHabbo().RoomId + "'");

                    CurrentTags = CurrentTags.Replace(Tag + ",", "");

                    dbClient.AddParamWithValue("tag", CurrentTags);
                    dbClient.ExecuteQuery("UPDATE private_rooms SET tags = @tag WHERE id = '" + Session.GetHabbo().RoomId + "'");

                    //Set the variable
                    AleedaEnvironment.GetCache().GetPrivateRooms().getRoom(Session.GetHabbo().RoomId).Tags = CurrentTags;

                    ServerMessage msg = new ServerMessage(139); // "BK"
                    msg.Append("Removed the tag ( " + Tag + " )");
                    Session.GetMessageHandler().SendRoom(msg);
                }
            }
        }
예제 #15
0
        /// <summary>
        /// 33 - "@a"
        /// </summary>
        private void SendMsg()
        {
            uint   buddyID = Request.PopWiredUInt32();
            string sText   = Request.PopFixedString();

            // Buddy in list?
            if (Client.GetMessenger().GetBuddy(buddyID) != null)
            {
                // Buddy online?
                GameClient buddyClient = AleedaEnvironment.GetHabboHotel().GetClients().GetClientOfHabbo(buddyID);
                if (buddyClient == null)
                {
                    Response.Initialize(261); // "DE"
                    Response.AppendInt32(5);  // Error code
                    Response.AppendUInt32(Client.GetHabbo().ID);
                    SendResponse();
                }
                else
                {
                    ServerMessage notify = new ServerMessage(134); // "BF"
                    notify.AppendUInt32(Client.GetHabbo().ID);
                    notify.AppendString(sText);
                    buddyClient.GetConnection().SendMessage(notify);
                }
            }
        }
예제 #16
0
        public void AddItem(int furniId, int spriteId, string FurnitureType)
        {
            string FurnitureName = "";

            List <Aleeda.HabboHotel.Catalog.CataProducts> cItem = AleedaEnvironment.GetHabboHotel().GetCatalog().CataProductsBySpriteID(spriteId);

            {
                foreach (Catalog.CataProducts cataItem in cItem)
                {
                    FurnitureName = cataItem.CCTName;
                }
            }

            using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
            {
                dbClient.ExecuteQuery("INSERT INTO user_inventory (userid, sprite_id, type, name) VALUES ('" + mID + "','" + spriteId + "','" + FurnitureType + "','" + FurnitureName + "')");

                dbClient.ExecuteQuery("DELETE FROM room_items WHERE id = '" + furniId + "'");
            }

            GetClient().GetMessageHandler().GetResponse().Initialize(101);
            GetClient().GetMessageHandler().SendResponse();

            /*GetClient().GetMessageHandler().GetResponse().Initialize(832);
             * GetClient().GetMessageHandler().GetResponse().AppendBoolean(true);
             * if (FurnitureType == "s")
             *  GetClient().GetMessageHandler().GetResponse().AppendInt32(1);
             * else
             *  GetClient().GetMessageHandler().GetResponse().AppendInt32(2);
             * GetClient().GetMessageHandler().GetResponse().AppendInt32(1); // total count of furnis
             * GetClient().GetMessageHandler().GetResponse().AppendInt32(furniId); // id of furni purchased on inventory
             * GetClient().GetMessageHandler().SendResponse();*/
        }
예제 #17
0
        public ServerMessage SerializeHighestRoomRating()
        {
            ServerMessage Response = new ServerMessage();

            Response.Initialize(451); // "GC"
            Response.AppendString("HQA");
            Response.AppendInt32(HighScoreRoomCount());
            foreach (PrivateRooms mRoom in privateRooms)
            {
                if (mRoom.Rating > 0)
                {
                    Response.AppendInt32(mRoom.ID);
                    Response.AppendBoolean(true);
                    Response.AppendString(mRoom.Name);
                    Response.AppendString(AleedaEnvironment.GetHabboHotel().GetHabbos().GetHabbo((uint)mRoom.OwnerID).Username);
                    Response.AppendInt32(mRoom.Status);
                    Response.AppendInt32(UsersInRoomCount(mRoom.ID));
                    Response.AppendInt32(mRoom.MaxVisitors);
                    Response.AppendString(mRoom.Description);
                    Response.AppendInt32(mRoom.Category);
                    Response.AppendBoolean(false);
                    Response.AppendBoolean(true); //Trading set on by default.
                    Response.AppendInt32(mRoom.Rating);
                    Response.AppendInt32(mRoom.Category);
                    Response.AppendString("N/A");
                    Response.AppendInt32(GetTagCount(mRoom.ID)); //TAG count
                    AppendTags(Response, mRoom.ID);
                    Response.Append(mRoom.Thumbnail);
                    Response.AppendBoolean(true);
                }
            }
            return(Response);
        }
예제 #18
0
 public int RoomWithRightsCount(int id)
 {
     using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
     {
         return(dbClient.ReadDataTable("SELECT * FROM room_rights WHERE roomid = '" + id + "'").Rows.Count);
     }
 }
예제 #19
0
        public int GetModelY()
        {
            //Clear the byte queue.
            Bytes.Clear();

            string mStartingPosition;

            using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
            {
                dbClient.AddParamWithValue("model", Session.GetHabbo().FlatModel);
                mStartingPosition = dbClient.ReadString("SELECT door FROM room_models WHERE id = @model");
            }

            Encoding enc = Encoding.ASCII;

            //Gets the bytes from 'Door'
            byte[] myByteArray = enc.GetBytes(mStartingPosition);

            this.Bytes = new Queue <byte>(myByteArray);

            //Get rid of the X, aka garbage - no longer needed
            PopInt();

            /*if (mStartingPosition == "" || mStartingPosition == null)
             *  return 0;
             * else*/
            return(PopInt());
        }
예제 #20
0
파일: Rooms.cs 프로젝트: YuupOnline/Aleeda
        private void GetGuestRoomMessageComposer()
        {
            PrivateRooms mRoom = AleedaEnvironment.GetCache().GetPrivateRooms().getRoom(Client.GetHabbo().RoomId);

            if (mRoom == null)
            {
                return;
            }

            Response.Initialize(454); // "GF"
            Response.AppendInt32(0);
            Response.AppendInt32(mRoom.ID);
            Response.AppendBoolean(true);
            Response.AppendString(mRoom.Name);
            Response.AppendString(AleedaEnvironment.GetHabboHotel().GetHabbos().GetHabbo((uint)mRoom.OwnerID).Username);
            Response.AppendInt32(mRoom.Status);
            Response.AppendInt32(AleedaEnvironment.GetCache().GetPrivateRooms().UsersInRoomCount(mRoom.ID));
            Response.AppendInt32(mRoom.MaxVisitors);
            Response.AppendString(mRoom.Description);
            Response.AppendBoolean(true);
            Response.AppendBoolean(true); //Trading set on by default.
            Response.AppendInt32(mRoom.Rating);
            Response.AppendInt32(mRoom.Category);
            Response.AppendString("");
            Response.AppendInt32(AleedaEnvironment.GetCache().GetPrivateRooms().GetTagCount(mRoom.ID)); //TAG count
            AleedaEnvironment.GetCache().GetPrivateRooms().AppendTags(Response, mRoom.ID);
            //Response.Append(mRoom.Thumbnail);
            SendResponse();
        }
예제 #21
0
        /// <summary>
        /// Closes the connections of database clients that have been inactive for too long. Connections can be opened again when needed.
        /// </summary>
        private void MonitorClientsLoop()
        {
            while (true)
            {
                try
                {
                    lock (this)
                    {
                        DateTime dtNow = DateTime.Now;
                        for (int i = 0; i < mClients.Length; i++)
                        {
                            if (mClients[i].State != ConnectionState.Closed)
                            {
                                if (mClients[i].Inactivity >= 60) // Not used in the last %x% seconds
                                {
                                    mClients[i].Disconnect();     // Temporarily close connection

                                    //LimeEnvironment.GetLog().WriteInformation("Disconnected database client #" + mClients[i].Handle);
                                }
                            }
                        }
                    }

                    Thread.Sleep(10000); // 10 seconds
                }
                catch (ThreadAbortException) { } // Nothing special
                catch (Exception ex)
                {
                    AleedaEnvironment.GetLog().WriteError(ex.Message);
                }
            }
        }
예제 #22
0
        public List <UserInventory> GetUserInventory(uint userid, bool b, int id)
        {
            List <UserInventory> rDetails = new List <UserInventory>();

            using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
            {
                if (b == true)
                {
                    dbClient.AddParamWithValue("@userid", userid);
                    foreach (DataRow row in dbClient.ReadDataTable("SELECT * FROM user_inventory WHERE userid = @userid").Rows)
                    {
                        UserInventory details = UserInventory.Parse(row, false);
                        if (details != null)
                        {
                            rDetails.Add(details);
                        }
                    }
                }
                else if (b == false)
                {
                    dbClient.AddParamWithValue("@id", id);
                    foreach (DataRow row in dbClient.ReadDataTable("SELECT * FROM user_inventory WHERE id = @id").Rows)
                    {
                        UserInventory details = UserInventory.Parse(row, false);
                        if (details != null)
                        {
                            rDetails.Add(details);
                        }
                    }
                }
            }
            return(rDetails);
        }
예제 #23
0
파일: Rooms.cs 프로젝트: YuupOnline/Aleeda
        private void AnswerDoorbell()
        {
            string Name = Request.PopFixedString();

            byte[] Result = Request.ReadBytes(1);

            GameClient sClient = AleedaEnvironment.GetHabboHotel().GetClients().GetClientOfHabbo(Name);

            if (Client == null)
            {
                return;
            }

            Boolean Accepted = (Result[0] == Convert.ToByte(65));

            Console.WriteLine(Accepted);

            if (Accepted)
            {
                sClient.GetMessageHandler().GetResponse().Initialize(41);
                sClient.GetMessageHandler().SendResponse();
            }
            else
            {
                sClient.GetMessageHandler().GetResponse().Initialize(131);
                sClient.GetMessageHandler().SendResponse();
            }
        }
예제 #24
0
        public static bool CalculateRights(int RoomID, uint usernameid)
        {
            using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
            {
                bool CheckRights = dbClient.ReadBoolean("SELECT * FROM room_rights WHERE user = '******' AND roomid = '" + RoomID + "'");
                bool CheckOwner  = dbClient.ReadBoolean("SELECT * FROM private_rooms WHERE ownerid = '" + usernameid + "' AND id = '" + RoomID + "'");

                if (CheckRights && !CheckOwner)
                {
                    return(true);
                }
                else if (!CheckRights && CheckOwner)
                {
                    return(true);
                }
                else if (CheckRights && CheckOwner)
                {
                    return(true);
                }
                else if (!CheckRights && !CheckOwner)
                {
                    return(false);
                }
                else
                {
                    return(false);
                }
            }
        }
예제 #25
0
파일: Rooms.cs 프로젝트: YuupOnline/Aleeda
        private void SaveRoomIcon()
        {
            //Remove crap
            Request.PopWiredInt32();

            string Background = Request.PopEncodeInt32();
            string TopLayer   = Request.PopEncodeInt32();

            //Save the thumbnail
            AleedaEnvironment.GetCache().GetPrivateRooms().getRoom(Client.GetHabbo().RoomId).Thumbnail = Background + TopLayer + "HH";

            GetResponse().Initialize(457);
            GetResponse().AppendInt32(Client.GetHabbo().RoomId);
            GetResponse().AppendBoolean(true);
            SendResponse();

            GetResponse().Initialize(456);
            GetResponse().AppendInt32(Client.GetHabbo().RoomId);
            SendResponse();

            using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
            {
                dbClient.ExecuteQuery("UPDATE private_rooms SET thumbnail = '" + Background + TopLayer + "HH' WHERE id = '" + Client.GetHabbo().RoomId + "'");
            }
        }
예제 #26
0
        public static bool RequestToMove(GameClient Client, int NewX, int NewY)
        {
            bool CanMove   = false;
            int  UserCount = AleedaEnvironment.GetCache().GetPrivateRooms().UsersInRoomCount(Client.GetHabbo().RoomId);

            if (UserCount == 1)
            {
                CanMove = true;
            }
            else
            {
                foreach (GameClient mClient in ClientMessageHandler.mRoomList)
                {
                    if (mClient.GetHabbo().Username != Client.GetHabbo().Username&&
                        mClient.GetHabbo().RoomId == Client.GetHabbo().RoomId)
                    {
                        if (mClient.GetHabbo().X != Client.GetHabbo().ReqX&& mClient.GetHabbo().Y != Client.GetHabbo().ReqY)
                        {
                            Client.GetHabbo().X = NewX;
                            Client.GetHabbo().Y = NewY;
                            CanMove = true;
                        }
                    }
                }
            }
            return(CanMove);
        }
예제 #27
0
파일: Rooms.cs 프로젝트: YuupOnline/Aleeda
        private void TriggerItem()
        {
            if (RoomUser.CalculateRights(Client.GetHabbo().RoomId, Client.GetHabbo().ID))
            {
                int furniID = Request.PopWiredInt32();

                FloorItems mFloor = AleedaEnvironment.GetCache().GetFloorItems().getItem(furniID);
                WallItems  mWall  = AleedaEnvironment.GetCache().GetWallItems().getItem(furniID);

                if (mFloor == null)
                {
                    Response.Initialize(85); // "AU"
                    Response.AppendString(mWall.ID + "");
                    Response.AppendInt32(mWall.SpriteID);
                    Response.AppendString(mWall.Wall);
                    if (mWall.Trigger == 0)
                    {
                        Response.Append(1);
                        Update.UpdateFurniTrigger(furniID, 1);

                        //Set the trigger
                        AleedaEnvironment.GetCache().GetWallItems().getItem(mWall.ID).Trigger = 1;
                    }
                    else
                    {
                        Response.Append(0);
                        Update.UpdateFurniTrigger(furniID, 0);

                        //Set the trigger
                        AleedaEnvironment.GetCache().GetWallItems().getItem(mWall.ID).Trigger = 0;
                    }
                    SendRoom();
                }
                else if (mWall == null)
                {
                    Response.Initialize(88); // "AX"
                    Response.Append(furniID);
                    Response.AppendChar(2);
                    if (mFloor.Trigger == 0)
                    {
                        Response.Append(1);
                        Update.UpdateFurniTrigger(furniID, 1);

                        //Set the trigger
                        AleedaEnvironment.GetCache().GetFloorItems().getItem(mFloor.ID).Trigger = 1;
                    }
                    else
                    {
                        Response.Append(0);
                        Update.UpdateFurniTrigger(furniID, 0);

                        //Set the trigger
                        AleedaEnvironment.GetCache().GetFloorItems().getItem(mFloor.ID).Trigger = 0;
                    }
                    Response.AppendChar(2);
                    SendRoom();
                }
            }
        }
예제 #28
0
 public static string GetStartingPosition(string model)
 {
     using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient())
     {
         dbClient.AddParamWithValue("model", model);
         return(dbClient.ReadString("SELECT starting_pos FROM room_models WHERE id = @model"));
     }
 }
예제 #29
0
        /// <summary>
        /// Handles a given amount of data in a given byte array, by attempting to parse messages from the received data and process them in the message handler.
        /// </summary>
        /// <param name="Data">The byte array with the data to process.</param>
        /// <param name="numBytesToProcess">The actual amount of bytes in the byte array to process.</param>
        public void HandleConnectionData(ref byte[] data)
        {
            // Gameclient protocol or policyrequest?
            if (data[0] != 64)
            {
                //AleedaEnvironment.GetLog().WriteInformation("Client " + mID + " sent non-gameclient message: " + AleedaEnvironment.GetDefaultTextEncoding().GetString(data));

                string xmlPolicy =
                    "<?xml version=\"1.0\"?>\r\n" +
                    "<!DOCTYPE cross-domain-policy SYSTEM \"/xml/dtds/cross-domain-policy.dtd\">\r\n" +
                    "<cross-domain-policy>\r\n" +
                    "<allow-access-from domain=\"*\" to-ports=\"1-31111\" />\r\n" +
                    "</cross-domain-policy>\x0";

                //AleedaEnvironment.GetLog().WriteInformation("Client " + mID + ": sending XML cross domain policy file: " + xmlPolicy);
                mConnection.SendData(xmlPolicy);

                mMessageHandler.GetResponse().Initialize(1); // "@A"
                mMessageHandler.GetResponse().Append("ION/Deltar");
                mMessageHandler.SendResponse();
            }
            else
            {
                int pos = 0;
                while (pos < data.Length)
                {
                    try
                    {
                        // Total length of message (without this): 3 Base64 bytes
                        int messageLength = Base64Encoding.DecodeInt32(new byte[] { data[pos++], data[pos++], data[pos++] });

                        // ID of message: 2 Base64 bytes
                        uint messageID = Base64Encoding.DecodeUInt32(new byte[] { data[pos++], data[pos++] });

                        // Data of message: (messageLength - 2) bytes
                        byte[] Content = new byte[messageLength - 2];
                        for (int i = 0; i < Content.Length; i++)
                        {
                            Content[i] = data[pos++];
                        }

                        // Create message object
                        ClientMessage message = new ClientMessage(messageID, Content);

                        // Handle message object
                        mMessageHandler.HandleRequest(message);
                    }
                    catch (IndexOutOfRangeException) // Bad formatting!
                    {
                        AleedaEnvironment.GetHabboHotel().GetClients().StopClient(mID);
                    }
                    catch (Exception ex)
                    {
                        AleedaEnvironment.GetLog().WriteUnhandledExceptionError("GameClient.HandleConnectionData", ex);
                    }
                }
            }
        }
예제 #30
0
        public void SerializeStatus(bool IsPrivate, int mRoomId, ServerMessage fuseMessage)
        {
            if (IsPrivate)
            {
                int UsersInRoom = 0;

                UsersInRoom = GetPrivateRooms().UsersInRoomCount(mRoomId);
                int BotCount = GetRoomBots().RoomBotCounts(mRoomId);

                UsersInRoom = BotCount += UsersInRoom;

                fuseMessage.AppendInt32(BotCount += UsersInRoom);
                foreach (GameClient Session in ClientMessageHandler.mRoomList)
                {
                    if (Session.GetHabbo().RoomId == mRoomId)
                    {
                        fuseMessage.AppendInt32(Session.GetHabbo().UnitId);
                        fuseMessage.AppendInt32(Session.GetHabbo().X);
                        fuseMessage.AppendInt32(Session.GetHabbo().Y);
                        fuseMessage.AppendString("0.0");
                        fuseMessage.AppendInt32(Session.GetHabbo().UserRotation);
                        fuseMessage.AppendInt32(Session.GetHabbo().UserRotation);
                        fuseMessage.AppendString("/flatctrl useradmin//");
                    }
                }

                if (GetRoomBots().RoomBotCounts(mRoomId) != 0)
                {
                    //Do room bots
                    AleedaEnvironment.GetCache().GetRoomBots().LoadStatus(mRoomId, fuseMessage);
                }
            }
            else
            {
                int i = 0;
                foreach (GameClient Session in ClientMessageHandler.mRoomList)
                {
                    if (Session.GetHabbo().pRoomId == mRoomId)
                    {
                        ++i;
                    }
                }
                fuseMessage.AppendInt32(i);
                foreach (GameClient Session in ClientMessageHandler.mRoomList)
                {
                    if (Session.GetHabbo().RoomId == mRoomId)
                    {
                        fuseMessage.AppendInt32(Session.GetHabbo().UnitId);
                        fuseMessage.AppendInt32(Session.GetHabbo().X);
                        fuseMessage.AppendInt32(Session.GetHabbo().Y);
                        fuseMessage.AppendString("0.0");
                        fuseMessage.AppendInt32(Session.GetHabbo().UserRotation);
                        fuseMessage.AppendInt32(Session.GetHabbo().UserRotation);
                        fuseMessage.AppendString("/flatctrl useradmin//");
                    }
                }
            }
        }