示例#1
0
        public static bool TryGetData(int roomId, out RoomData data)
        {
            if (Program.GameContext.GetRoomManager().TryGetRoom(roomId, out var room))
            {
                data = room;
                return(true);
            }

            using (var dbClient = Program.DatabaseManager.GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `rooms`.*, `users`.`username` FROM `rooms` INNER JOIN `users` ON `users`.`id` = `rooms`.`owner` WHERE `rooms`.`id` = @id LIMIT 1");
                dbClient.AddParameter("id", roomId);
                var row = dbClient.GetRow();

                if (row != null)
                {
                    RoomModel model = null;
                    if (!Program.GameContext.GetRoomManager().TryGetModel(Convert.ToString(row["model_name"]), out model))
                    {
                        data = null;
                        return(false);
                    }

                    // TODO: Revise this?
                    var username = !string.IsNullOrEmpty(Convert.ToString(row["username"])) ? Convert.ToString(row["username"]) : "Habboon";

                    data = new RoomData(Convert.ToInt32(row["id"]), Convert.ToString(row["caption"]), Convert.ToString(row["model_name"]), username, Convert.ToInt32(row["owner"]),
                                        Convert.ToString(row["password"]), Convert.ToInt32(row["score"]), Convert.ToString(row["roomtype"]), Convert.ToString(row["state"]), Convert.ToInt32(row["users_now"]),
                                        Convert.ToInt32(row["users_max"]), Convert.ToInt32(row["category"]), Convert.ToString(row["description"]), Convert.ToString(row["tags"]), Convert.ToString(row["floor"]),
                                        Convert.ToString(row["landscape"]), Convert.ToInt32(row["allow_pets"]), Convert.ToInt32(row["allow_pets_eat"]), Convert.ToInt32(row["room_blocking_disabled"]), Convert.ToInt32(row["allow_hidewall"]),
                                        Convert.ToInt32(row["wallthick"]), Convert.ToInt32(row["floorthick"]), Convert.ToString(row["wallpaper"]), Convert.ToInt32(row["mute_settings"]), Convert.ToInt32(row["ban_settings"]),
                                        Convert.ToInt32(row["kick_settings"]), Convert.ToInt32(row["chat_mode"]), Convert.ToInt32(row["chat_size"]), Convert.ToInt32(row["chat_speed"]), Convert.ToInt32(row["chat_extra_flood"]),
                                        Convert.ToInt32(row["chat_hearing_distance"]), Convert.ToInt32(row["trade_settings"]), Convert.ToString(row["push_enabled"]) == "1", Convert.ToString(row["pull_enabled"]) == "1",
                                        Convert.ToString(row["spush_enabled"]) == "1", Convert.ToString(row["spull_enabled"]) == "1", Convert.ToString(row["enables_enabled"]) == "1", Convert.ToString(row["respect_notifications_enabled"]) == "1",
                                        Convert.ToString(row["pet_morphs_allowed"]) == "1", Convert.ToInt32(row["group_id"]), Convert.ToInt32(row["sale_price"]), Convert.ToString(row["lay_enabled"]) == "1", model);
                    return(true);
                }
            }

            data = null;
            return(false);
        }
示例#2
0
        public bool TryGetModel(string id, out RoomModel model)
        {
            if (_roomModels.ContainsKey(id))
            {
                model = _roomModels[id];
                return(true);
            }

            if (LoadModel(id))
            {
                if (TryGetModel(id, out var customModel))
                {
                    model = customModel;
                    return(true);
                }
            }

            model = null;
            return(false);
        }
示例#3
0
        public RoomData CreateRoom(Player session, string name, string description, int category, int maxVisitors, int tradeSettings, RoomModel model, string wallpaper = "0.0", string floor = "0.0", string landscape = "0.0", int wallthick = 0, int floorthick = 0)
        {
            if (name.Length < 3)
            {
                session.SendNotification(Program.LanguageManager.TryGetValue("room.creation.name.too_short"));
                return(null);
            }

            var roomId = 0;

            using (var dbClient = Program.DatabaseManager.GetQueryReactor())
            {
                dbClient.SetQuery("INSERT INTO `rooms` (`roomtype`,`caption`,`description`,`owner`,`model_name`,`category`,`users_max`,`trade_settings`) VALUES ('private',@caption,@description,@UserId,@model,@category,@usersmax,@tradesettings)");
                dbClient.AddParameter("caption", name);
                dbClient.AddParameter("description", description);
                dbClient.AddParameter("UserId", session.GetHabbo().Id);
                dbClient.AddParameter("model", model.Id);
                dbClient.AddParameter("category", category);
                dbClient.AddParameter("usersmax", maxVisitors);
                dbClient.AddParameter("tradesettings", tradeSettings);

                roomId = Convert.ToInt32(dbClient.InsertQuery());
            }

            var data = new RoomData(roomId, name, model.Id, session.GetHabbo().Username, session.GetHabbo().Id, "", 0, "public", "open", 0, maxVisitors, category, description, string.Empty,
                                    floor, landscape, 1, 1, 0, 0, wallthick, floorthick, wallpaper, 1, 1, 1, 1, 1, 1, 1, 8, tradeSettings, true, true, true, true, true, true, true, 0, 0, true, model);

            return(data);
        }
示例#4
0
        public DynamicRoomModel(RoomModel model)
        {
            staticModel = model;
            DoorX       = staticModel.DoorX;
            DoorY       = staticModel.DoorY;
            DoorZ       = staticModel.DoorZ;

            DoorOrientation = staticModel.DoorOrientation;
            Heightmap       = staticModel.Heightmap;

            MapSizeX = staticModel.MapSizeX;
            MapSizeY = staticModel.MapSizeY;
            ClubOnly = staticModel.ClubOnly;

            _relativeHeightmap = string.Empty;

            SqState       = new SquareState[MapSizeX, MapSizeY];
            SqFloorHeight = new short[MapSizeX, MapSizeY];
            SqSeatRot     = new byte[MapSizeX, MapSizeY];

            for (var y = 0; y < MapSizeY; y++)
            {
                for (var x = 0; x < MapSizeX; x++)
                {
                    if (x > staticModel.MapSizeX - 1 || y > staticModel.MapSizeY - 1)
                    {
                        SqState[x, y] = SquareState.Blocked;
                    }
                    else
                    {
                        SqState[x, y]       = staticModel.SqState[x, y];
                        SqFloorHeight[x, y] = staticModel.SqFloorHeight[x, y];
                        SqSeatRot[x, y]     = staticModel.SqSeatRot[x, y];
                    }
                }
            }

            var FloorMap = new StringBuilder();

            for (var y = 0; y < MapSizeY; y++)
            {
                for (var x = 0; x < MapSizeX; x++)
                {
                    if (x == DoorX && y == DoorY)
                    {
                        FloorMap.Append(DoorZ > 9 ? ((char)(87 + DoorZ)).ToString() : DoorZ.ToString());
                        continue;
                    }

                    if (SqState[x, y] == SquareState.Blocked)
                    {
                        FloorMap.Append('x');
                        continue;
                    }

                    double height = SqFloorHeight[x, y];
                    var    val    = height > 9 ? ((char)(87 + height)).ToString() : height.ToString();
                    FloorMap.Append(val);
                }
                FloorMap.Append(Convert.ToChar(13));
            }

            _relativeHeightmap = FloorMap.ToString();
        }
示例#5
0
        public RoomData(int id, string caption, string modelName, string ownerName, int ownerId, string password, int score, string type, string access, int usersNow, int usersMax, int category, string description,
            string tags, string floor, string landscape, int allowPets, int allowPetsEating, int roomBlockingEnabled, int hidewall, int wallThickness, int floorThickness, string wallpaper, int muteSettings,
            int banSettings, int kickSettings, int chatMode, int chatSize, int chatSpeed, int extraFlood, int chatDistance, int tradeSettings, bool pushEnabled, bool pullEnabled, bool superPushEnabled,
            bool superPullEnabled, bool enablesEnabled, bool respectedNotificationsEnabled, bool petMorphsAllowed, int groupId, int salePrice, bool layEnabled, RoomModel model)
        {
            Id = id;
            Name = caption;
            ModelName = modelName;
            OwnerName = ownerName;
            OwnerId = ownerId;
            Password = password;
            Score = score;
            Type = type;
            Access = RoomAccessUtility.ToRoomAccess(access);
            UsersNow = usersNow;
            UsersMax = usersMax;
            Category = category;
            Description = description;

            Tags = new List<string>();
            foreach (var Tag in tags.Split(','))
            {
                Tags.Add(Tag);
            }

            Floor = floor;
            Landscape = landscape;
            AllowPets = allowPets;
            AllowPetsEating = allowPetsEating;
            RoomBlockingEnabled = roomBlockingEnabled;
            Hidewall = hidewall;
            WallThickness = wallThickness;
            FloorThickness = floorThickness;
            Wallpaper = wallpaper;
            WhoCanMute = muteSettings;
            WhoCanBan = banSettings;
            WhoCanKick = kickSettings;
            ChatMode = chatMode;
            ChatSize = chatSize;
            ChatSpeed = chatSpeed;
            ExtraFlood = extraFlood;
            ChatDistance = chatDistance;
            TradeSettings = tradeSettings;
            PushEnabled = pushEnabled;
            PullEnabled = pullEnabled;
            SuperPushEnabled = superPushEnabled;
            SuperPullEnabled = superPullEnabled;
            EnablesEnabled = enablesEnabled;
            RespectNotificationsEnabled = respectedNotificationsEnabled;
            PetMorphsAllowed = petMorphsAllowed;
            SalePrice = salePrice;
            ReverseRollers = false;
            LayEnabled = layEnabled;

            if (groupId > 0)
            {
                Program.GameContext.GetGroupManager().TryGetGroup(groupId, out _group);
            }

            LoadPromotions();

            Model = model;
        }