Example #1
0
        public AdminRoomUserMessageArgs(GameClient session)
        {
            this.session = session;
            this.RoomUser = null;
            this.allowsExecution = false;
            this.Room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(session.GetHabbo().CurrentRoomId);

            if (Room != null)
            {
                this.allowsExecution = Room.CheckRights(session, true);
                this.RoomUser = Room.GetRoomUserManager().GetRoomUserByHabbo(session.GetHabbo().Id);
            }

            if (Room == null || RoomUser == null || !allowsExecution)
                allowsExecution = false;
        }
Example #2
0
        public void GenerateMaps(bool checkLines = true)
        {
            int MaxX = 0;
            int MaxY = 0;

            if (checkLines)
            {
                Item[] items = this.room.GetRoomItemHandler().GetFloor.ToArray();
                foreach (Item item in items.ToList())
                {
                    if (item == null)
                    {
                        continue;
                    }

                    foreach (ThreeDCoord Point in item.GetAffectedTiles.Values)
                    {
                        if (item.GetX > Model.MapSizeX && Point.X > MaxX)
                        {
                            MaxX = Point.X;
                        }
                        if (item.GetY > Model.MapSizeY && Point.Y > MaxY)
                        {
                            MaxY = Point.Y;
                        }
                    }
                }

                Array.Clear(items, 0, items.Length);
                items = null;
            }

            if (MaxY > (Model.MapSizeY - 1) || MaxX > (Model.MapSizeX - 1))
            {
                if (MaxX < Model.MapSizeX)
                {
                    MaxX = Model.MapSizeX;
                }
                if (MaxY < Model.MapSizeY)
                {
                    MaxY = Model.MapSizeY;
                }

                Model.SetMapsize(MaxX + 1, MaxY + 1);
            }

            this.CoordinatedItems.Clear();
            this.GameMap       = new byte[this.Model.MapSizeX, this.Model.MapSizeY];
            this.mUserOnMap    = new byte[this.Model.MapSizeX, this.Model.MapSizeY];
            this.mSquareTaking = new byte[this.Model.MapSizeX, this.Model.MapSizeY];
            this.ItemHeightMap = new double[this.Model.MapSizeX, this.Model.MapSizeY];
            this.EffectMap     = new byte[this.Model.MapSizeX, this.Model.MapSizeY];

            for (int line = 0; line < this.Model.MapSizeY; ++line)
            {
                for (int chr = 0; chr < this.Model.MapSizeX; ++chr)
                {
                    this.GameMap[chr, line]   = 0;
                    this.EffectMap[chr, line] = 0;

                    //if (chr == this.Model.DoorX && line == this.Model.DoorY)
                    //this.GameMap[chr, line] = 3;
                    //else
                    if (this.Model.SqState[chr, line] == SquareState.OPEN)
                    {
                        this.GameMap[chr, line] = 1;
                    }
                }
            }

            foreach (Item Item in room.GetRoomItemHandler().GetFloor.ToArray())
            {
                if (!AddItemToMap(Item))
                {
                    continue;
                }
            }

            foreach (RoomUser user in room.GetRoomUserManager().GetUserList().ToList())
            {
                if (this.ValidTile(user.X, user.Y))
                {
                    this.mUserOnMap[user.X, user.Y] = 1;
                }
            }
        }
Example #3
0
File: Room.cs Project: BjkGkh/R106
        internal bool SaveHeightmap(Room room, string heightmap, int doorx, int doory, int doordir, int wallheight)
        {
            string doorZ = "";
            string lineSeparator = ((char)0x2028).ToString();
            string paragraphSeparator = ((char)0x2029).ToString();

            heightmap = heightmap.Replace("\r\n", "<k>").Replace("\n", "<k>").Replace("\r", "<k>").Replace(lineSeparator, "<k>").Replace(paragraphSeparator, "<k>");

            string[] rows = System.Text.RegularExpressions.Regex.Split(heightmap, "<k>");

            int doorlocation = 0;

            try
            {
                int d = doorx;
                int f = doory;
                if (rows[f][d++] != 'x')
                {
                    doorlocation = 2;
                    doorZ = rows[doory][doorx].ToString();
                }
                else if (rows[f++][d] != 'x')
                {
                    doorlocation = 4;
                    doorZ = rows[doory][doorx].ToString();
                }
                else
                    return false;
            }
            catch
            {
                return false;
            }

            doorZ = fixDoorZ(doorZ);

            if (doorZ == "-1")
                return false;

            double doorzn = Convert.ToDouble(doorZ);

            heightmap = heightmap.Replace("z", doorZ);

            if (heightmap.EndsWith("<k>"))
                heightmap = heightmap.Remove(heightmap.Length - 3);

            heightmap = heightmap.Replace("<k>", "\r\n");

            RoomModel Custom = ButterflyEnvironment.GetGame().GetRoomManager().GetModel("custom", room.Id);

            RoomModel model = new RoomModel(doorx, doory, doorzn, doordir, heightmap, "", false, "");

            if (Custom == null)
            {
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("INSERT INTO room_models_customs SET `modeldata` = @heightmap,`doorx`=@x,`doory`=@y,`height`=@dir,`wallheight`= @wallh, `roomid` = @roomid;");
                    dbClient.addParameter("roomid", room.Id);
                    dbClient.addParameter("heightmap", heightmap);
                    dbClient.addParameter("x", doorx);
                    dbClient.addParameter("y", doory);
                    dbClient.addParameter("dir", doordir);
                    dbClient.addParameter("wallh", wallheight);
                    dbClient.runQuery();

                    dbClient.runFastQuery("UPDATE rooms SET model_name = 'custom' WHERE id = " + this.Id + " LIMIT 1");
                }
            }
            else
            {
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("UPDATE room_models_customs SET `modeldata` = @heightmap,`doorx` = @x, `doory` = @y,`height` = @dir, `wallheight` = @wallheight WHERE roomid = @rid LIMIT 1;");
                    dbClient.addParameter("rid", room.Id);
                    dbClient.addParameter("heightmap", heightmap);
                    dbClient.addParameter("x", doorx);
                    dbClient.addParameter("y", doory);
                    dbClient.addParameter("dir", doordir);
                    dbClient.addParameter("wallheight", wallheight);
                    dbClient.runQuery();
                }
            }

            List<GameClient> gamclients = new List<GameClient>();

            foreach (RoomUser user in room.GetRoomUserManager().UserList.Values)
            {
                if (user != null && user.GetClient() != null && user.GetClient().GetMessageHandler() != null)
                {
                    if (!gamclients.Contains(user.GetClient()))
                        gamclients.Add(user.GetClient());
                }
            }

            ButterflyEnvironment.GetGame().GetRoomManager().UnloadRoom(this);

            room.RoomData.ModelName = "custom";
            room.RoomData.Model = null;

            gamclients.Clear();
            return true;
        }