コード例 #1
0
ファイル: DreamPathfinder.cs プロジェクト: BjkGkh/R106
        private static SquarePoint GetClosetSqare(SquareInformation pInfo, HeightInfo Height, double currentHeight, Gamemap map, bool pOverride)
        {
            double Closest = pInfo.Point.GetDistance;

            SquarePoint ClosestPoint = pInfo.Point;
            double InfoOnSqare = Height.GetState(pInfo.Point.X, pInfo.Point.Y, currentHeight);

            for (int i = 0; i < 8; i++)
            {
                SquarePoint Position = pInfo.Pos(i);
                if (!Position.InUse)
                    continue;

                double h = Height.GetState(Position.X, Position.Y, currentHeight);
                if (Position.CanWalk(h) && (!map.SquareOccupied(Position.X, Position.Y, h) || pOverride))
                {
                    if (h - InfoOnSqare < 3) //<3
                    {
                        double Distance = Position.GetDistance;
                        if (Closest > Distance)
                        {
                            Closest = Distance;
                            ClosestPoint = Position;
                        }
                    }
                }
            }
            return ClosestPoint;
        }
コード例 #2
0
 public bool SetFloorItem(Item Item, int newX, int newY, double newZ)
 {
     this.GetRoom.GetGameMap().RemoveFromMap(Item);
     Item.SetState(newX, newY, newZ, Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, Item.Rotation));
     this.UpdateItem(Item);
     this.GetRoom.GetGameMap().AddItemToMap(Item);
     return(true);
 }
コード例 #3
0
        internal bool SetFloorItem(RoomItem Item, int newX, int newY, Double newZ)
        {
            room.GetGameMap().RemoveFromMap(Item);
            Item.SetState(newX, newY, newZ, Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, Item.Rot));

            UpdateItem(Item);
            room.GetGameMap().AddItemToMap(Item);

            return(true);
        }
コード例 #4
0
ファイル: DreamPathfinder.cs プロジェクト: BjkGkh/R106
        internal static SquarePoint GetNextStep(int pUserX, int pUserY, double pUserZ,
            int pUserTargetX, int pUserTargetY,
            byte[,] pGameMap, Stackmap pHeight, short[,] pHeightmap,
            int MaxX, int MaxY,
            bool pUserOverride, bool pDiagonal, Gamemap gamemap)
        {
            ModelInfo MapInfo = new ModelInfo(MaxX, MaxY, pGameMap);
            SquarePoint TargetPoint = new SquarePoint(pUserTargetX, pUserTargetY, pUserZ, pUserTargetX, pUserTargetY, MapInfo.GetState(pUserTargetX, pUserTargetY), pUserOverride, pHeight);
            if (pUserX == pUserTargetX && pUserY == pUserTargetY)
                return TargetPoint;

            SquareInformation SquareOnUser = new SquareInformation(pUserX, pUserY, pUserZ, TargetPoint, MapInfo, pUserOverride, pDiagonal, pHeight);

            return GetClosetSqare(SquareOnUser, new HeightInfo(MaxX, MaxY, pHeight, pHeightmap), pUserZ, gamemap, pUserOverride);
        }
コード例 #5
0
ファイル: Room.cs プロジェクト: EmuZoneDEV/HBBO-EMU
        public Room(RoomData Data)
        {
            RolePlayerManager RPManager = ButterflyEnvironment.GetGame().GetRoleplayManager().GetRolePlay(Data.OwnerId);

            if (RPManager != null)
            {
                this.RpRoom            = true;
                this.Pvp               = true;
                this.RpCycleHourEffect = true;
                this.RpTimeSpeed       = false;
                this.RpHour            = -1;
            }

            this.SaveTimer          = 0;
            this.Disposed           = false;
            this.Bans               = new Dictionary <int, double>();
            this.Mutes              = new Dictionary <int, double>();
            this.ActiveTrades       = new List <Trade>();
            this.mCycleEnded        = false;
            this.HeightMapLoaded    = false;
            this.RoomData           = Data;
            this.EveryoneGotRights  = Data.AllowRightsOverride;
            this.IdleTime           = 0;
            this.RoomMuted          = false;
            this.PushPullAllowed    = true;
            this.RoomIngameChat     = false;
            this.gamemap            = new Gamemap(this);
            this.roomItemHandling   = new RoomItemHandling(this);
            this.roomUserManager    = new RoomUserManager(this);
            this.wiredHandler       = new WiredHandler(this);
            this.projecctileManager = new ProjectileManager(this);
            this.chatMessageManager = new ChatMessageManager();
            this.chatMessageManager.LoadRoomChatlogs(this.Id);
            this.LoadRights();
            this.GetRoomItemHandler().LoadFurniture();
            if (this.RoomData.OwnerName == "WibboGame")
            {
                this.GetRoomItemHandler().LoadFurniture(5400713);
            }

            this.GetGameMap().GenerateMaps();
            this.LoadBots();
            this.InitPets();
            this.lastTimerReset = DateTime.Now;
        }
コード例 #6
0
ファイル: RoomModel.cs プロジェクト: fuding/Coolmemes
        public ServerMessage SerializeHeightmap(Gamemap map)
        {
            ServerMessage Message = new ServerMessage(Outgoing.HeightMapMessageParser);

            Message.AppendInt32(MapSizeX);
            Message.AppendInt32(MapSizeX * MapSizeY);
            for (int y = 0; y < MapSizeY; y++)
            {
                for (int x = 0; x < MapSizeX; x++)
                {
                    if (SqState[x, y] != SquareState.BLOCKED || (DoorX == x && DoorY == y))
                    {
                        Message.AppendShort((int)(map.SqAbsoluteHeightGameMap(x, y) * 256));
                    }
                    else
                    {
                        Message.AppendShort(0x4000);
                    }
                }
            }

            return(Message);
        }
コード例 #7
0
ファイル: DynamicRoomModel.cs プロジェクト: BjkGkh/R106
        internal ServerMessage GetHeightmap(Gamemap map)
        {
            if (!HeightmapSerialized)
            {
                SerializedHeightmap = SerializeHeightmap();
                HeightmapSerialized = true;
            }

            return SerializedHeightmap;
        }
コード例 #8
0
 internal void FixGameMap()
 {
     gamemap = new Gamemap(this);
     // GetGameMap().GenerateMaps();
 }
コード例 #9
0
        private void Initialize(RoomData RoomData)
        {
            this.Id = RoomData.Id;

            this.mDisposed         = false;
            this.RoomMuted         = false;
            this.muteSignalEnabled = false;

            this.Bans               = new Dictionary <UInt32, double>();
            this.Mutes              = new Dictionary <UInt32, MuteUser>();
            this.FilterWords        = new List <string>();
            this.chatMessageManager = new ChatMessageManager();
            this.lastTimerReset     = DateTime.Now;
            this.IsRoomLoaded       = false;

            this.mCycleEnded     = false;
            this.HeightMapLoaded = false;

            this.mRoomData = RoomData;

            this.roomMessages     = new Queue();
            this.chatMessageQueue = new Queue();

            this.roomMessages           = new Queue();
            this.roomAlerts             = new Queue();
            this.roomBadge              = new Queue();
            this.roomDiamonds           = new Queue();
            this.roomCredits            = new Queue();
            this.roomPiruletas          = new Queue();
            this.roomKick               = new Queue();
            this.roomServerMessages     = new Queue();
            this.roomChatServerMessages = new Queue();

            this.groupAddQueue    = new Queue();
            this.groupRemoveQueue = new Queue();
            this.groupsOnRoom     = new Dictionary <uint, int>();

            this.roomUserFloorItems = new Dictionary <uint, uint>();
            this.roomUserWallItems  = new Dictionary <uint, uint>();

            this.gamemap          = new Gamemap(this);
            this.roomUserManager  = new RoomUserManager(this);
            this.roomItemHandling = new RoomItemHandling(this);
            this.wiredHandler     = new WiredHandler(this);
            this.games            = new GameManager(this);

            this.roomPoll = new RoomQuestionary();
            if (!this.roomPoll.LoadQuestionary(this.Id))
            {
                this.roomPoll = null;
            }

            this.LoadFilterWords();
            this.LoadRights();
            this.GetRoomItemHandler().LoadFurniture();
            this.GetGameMap().GenerateMaps();
            this.GetRoomUserManager().OnUserUpdateStatus(); // Update Bots State.
            this.LoadMusic();

            if (this.RoomData.State != 3)
            {
                OtanixEnvironment.GetGame().GetRoomManager().QueueActiveRoomAdd(mRoomData);
            }
        }
コード例 #10
0
        private void Dispose()
        {
            if (!mDisposed)
            {
                try
                {
                    mDisposed   = true;
                    mCycleEnded = true;
                    OtanixEnvironment.GetGame().GetRoomManager().QueueActiveRoomRemove(mRoomData);

                    using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        GetRoomItemHandler().SaveFurniture(dbClient);
                        saveBots();
                    }

                    WorkRoomServerMessageThread();
                    WorkRoomChatServerMessageThread();

                    ClearMute();
                    UsersWithRights.Clear();
                    Bans.Clear();

                    foreach (var item in GetRoomItemHandler().mFloorItems.Values)
                    {
                        item.Destroy();
                    }

                    foreach (var item in GetRoomItemHandler().mWallItems.Values)
                    {
                        item.Destroy();
                    }

                    roomUserManager.Destroy();
                    roomUserManager = null;

                    chatMessageManager.Destroy();
                    chatMessageManager = null;

                    roomItemHandling.Destroy();
                    roomItemHandling = null;

                    if (GetGameManager() != null)
                    {
                        GetGameManager().Destroy();
                        games = null;
                    }

                    if (GotSoccer())
                    {
                        GetSoccer().Destroy();
                        soccer = null;
                    }

                    if (GotWired())
                    {
                        GetWiredHandler().Destroy();
                        wiredHandler = null;
                    }

                    if (GotMusicController())
                    {
                        GetRoomMusicController().Destroy();
                        musicController = null;
                    }

                    if (GetGameMap() != null)
                    {
                        GetGameMap().Destroy();
                        gamemap = null;
                    }
                }
                catch (Exception e)
                {
                    Logging.LogCriticalException("Unload of room " + e);
                }
            }
        }
コード例 #11
0
ファイル: RoomUserManager.cs プロジェクト: nightwolf93/Bfly
        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);
            }
        }
コード例 #12
0
        public bool SetFloorItem(GameClient Session, Item Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage)
        {
            bool NeedsReAdd = false;

            if (!newItem)
            {
                NeedsReAdd = this.GetRoom.GetGameMap().RemoveFromMap(Item);
            }

            Dictionary <int, ThreeDCoord> affectedTiles = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot);

            foreach (ThreeDCoord threeDcoord in affectedTiles.Values)
            {
                if (!this.GetRoom.GetGameMap().ValidTile(threeDcoord.X, threeDcoord.Y) || (this.GetRoom.GetGameMap().SquareHasUsers(threeDcoord.X, threeDcoord.Y) && !Item.GetBaseItem().IsSeat&& Item.GetBaseItem().InteractionType != InteractionType.bed) || this.GetRoom.GetGameMap().Model.SqState[threeDcoord.X, threeDcoord.Y] != SquareState.OPEN)
                {
                    if (NeedsReAdd)
                    {
                        this.UpdateItem(Item);
                        this.GetRoom.GetGameMap().AddToMap(Item);
                    }
                    return(false);
                }
            }

            double pZ = (double)this.GetRoom.GetGameMap().Model.SqFloorHeight[newX, newY];

            List <Item> ItemsAffected = new List <Item>();
            List <Item> ItemsComplete = new List <Item>();

            foreach (ThreeDCoord threeDcoord in affectedTiles.Values)
            {
                List <Item> Temp = this.GetRoom.GetGameMap().GetCoordinatedItems(new Point(threeDcoord.X, threeDcoord.Y));
                if (Temp != null)
                {
                    ItemsAffected.AddRange(Temp);
                }
            }
            //ItemsComplete.AddRange(ItemsOnTile);
            ItemsComplete.AddRange(ItemsAffected);


            bool   ConstruitMode   = false;
            bool   ConstruitZMode  = false;
            double ConstruitHeigth = 1.0;
            bool   PileMagic       = false;

            if (Item.GetBaseItem().InteractionType == InteractionType.pilemagic)
            {
                PileMagic = true;
            }

            if (Session != null && Session.GetHabbo() != null && Session.GetHabbo().CurrentRoom != null)
            {
                RoomUser User_room = Session.GetHabbo().CurrentRoom.GetRoomUserManager().GetRoomUserByHabboId(Session.GetHabbo().Id);
                if (User_room != null)
                {
                    ConstruitMode   = User_room.ConstruitMode;
                    ConstruitZMode  = User_room.ConstruitZMode;
                    ConstruitHeigth = User_room.ConstruitHeigth;
                }
            }

            if (Item.Rotation != newRot && Item.GetX == newX && Item.GetY == newY && !ConstruitZMode)
            {
                pZ = Item.GetZ;
            }

            if (ConstruitZMode)
            {
                pZ = pZ + ConstruitHeigth;
            }
            else
            {
                foreach (Item roomItem in ItemsComplete)
                {
                    if (roomItem.GetBaseItem().InteractionType == InteractionType.pilemagic)
                    {
                        pZ        = roomItem.GetZ;
                        PileMagic = true;
                        break;
                    }
                    if (roomItem.Id != Item.Id && roomItem.TotalHeight > pZ)
                    {
                        if (ConstruitMode)
                        {
                            pZ = roomItem.GetZ + ConstruitHeigth;
                        }
                        else
                        {
                            pZ = roomItem.TotalHeight;
                        }
                    }
                }
            }

            if (!OnRoller)
            {
                foreach (Item roomItem in ItemsComplete)
                {
                    if (roomItem != null && roomItem.Id != Item.Id && (roomItem.GetBaseItem() != null && (!roomItem.GetBaseItem().Stackable&& !ConstruitMode && !PileMagic && !ConstruitZMode)))
                    {
                        if (NeedsReAdd)
                        {
                            this.UpdateItem(Item);
                            this.GetRoom.GetGameMap().AddToMap(Item);
                        }
                        return(false);
                    }
                }
            }

            if (newRot != 1 && newRot != 2 && newRot != 3 && newRot != 4 && newRot != 5 && newRot != 6 && newRot != 7 && newRot != 8)
            {
                newRot = 0;
            }

            List <RoomUser> userForSquare = new List <RoomUser>();

            foreach (ThreeDCoord threeDcoord in Item.GetAffectedTiles.Values)
            {
                userForSquare.AddRange(this.GetRoom.GetGameMap().GetRoomUsers(new Point(threeDcoord.X, threeDcoord.Y)));
            }

            Item.Rotation = newRot;
            Item.SetState(newX, newY, pZ, affectedTiles);

            if (!OnRoller && Session != null)
            {
                Item.Interactor.OnPlace(Session, Item);
            }

            if (newItem)
            {
                if (this._floorItems.ContainsKey(Item.Id))
                {
                    if (Session != null)
                    {
                        Session.SendNotification(ButterflyEnvironment.GetLanguageManager().TryGetValue("room.itemplaced", Session.Langue));
                    }
                    return(true);
                }
                else
                {
                    if (Item.IsFloorItem && !this._floorItems.ContainsKey(Item.Id))
                    {
                        this._floorItems.TryAdd(Item.Id, Item);
                    }
                    else if (Item.IsWallItem && !this._wallItems.ContainsKey(Item.Id))
                    {
                        this._wallItems.TryAdd(Item.Id, Item);
                    }

                    this.UpdateItem(Item);
                    if (sendMessage)
                    {
                        this.GetRoom.SendPacket(new ObjectAddComposer(Item, this.GetRoom.RoomData.OwnerName, this.GetRoom.RoomData.OwnerId));
                    }
                }
            }
            else
            {
                this.UpdateItem(Item);
                if (!OnRoller && sendMessage)
                {
                    GetRoom.SendPacket(new ObjectUpdateComposer(Item, GetRoom.RoomData.OwnerId));
                }
            }

            this.GetRoom.GetGameMap().AddToMap(Item);


            foreach (ThreeDCoord threeDcoord in Item.GetAffectedTiles.Values)
            {
                userForSquare.AddRange(this.GetRoom.GetGameMap().GetRoomUsers(new Point(threeDcoord.X, threeDcoord.Y)));
            }

            foreach (RoomUser User in userForSquare)
            {
                if (User == null)
                {
                    continue;
                }
                if (User.IsWalking)
                {
                    continue;
                }

                this.GetRoom.GetRoomUserManager().UpdateUserStatus(User, false);
            }

            return(true);
        }
コード例 #13
0
ファイル: Room.cs プロジェクト: habb0/Bfly
        private void Initialize(UInt32 Id, string Name, string Description, string Type, string Owner, int Category,
            int State, int UsersMax, string ModelName, string CCTs, int Score, List<string> pTags, bool AllowPets,
            bool AllowPetsEating, bool AllowWalkthrough, bool Hidewall, RoomIcon Icon, string Password, string Wallpaper, string Floor,
            string Landscape, RoomData RoomData, bool RightOverride, int walltickness, int floorthickness)
        {
            this.mDisposed = false;
            this.Id = Id;
            this.Name = Name;
            this.Description = Description;
            this.Owner = Owner;
            this.Category = Category;
            this.Type = Type;
            this.State = State;
            this.UsersNow = 0;
            this.UsersMax = UsersMax;
            this.ModelName = ModelName;
            this.CCTs = CCTs;
            this.Score = Score;

            tagCount = 0;
            this.Tags = new ArrayList();
            foreach (string tag in pTags)
            {
                tagCount++;
                Tags.Add(tag);
            }

            this.AllowPets = AllowPets;
            this.AllowPetsEating = AllowPetsEating;
            this.AllowWalkthrough = AllowWalkthrough;
            this.Hidewall = Hidewall;

            this.myIcon = Icon;
            this.Password = Password;
            this.Bans = new Dictionary<UInt32, double>();
            this.Wallpaper = Wallpaper;
            this.Floor = Floor;
            this.Landscape = Landscape;
            this.chatMessageManager = new ChatMessageManager();
            this.groups = new QueuedDictionary<int, Group>();
            this.ActiveTrades = new ArrayList();

            this.mCycleEnded = false;

            this.mRoomData = RoomData;
            this.EveryoneGotRights = RightOverride;

            this.roomMessages = new Queue();
            this.chatMessageQueue = new Queue();
            this.rnd = new Random();

            this.roomMessages = new Queue();
            this.roomAlerts = new Queue();
            this.roomBadge = new Queue();
            this.roomKick = new Queue();
            this.roomServerMessages = new Queue();
            this.IdleTime = 0;
            this.RoomMuted = false;
            this.WallThickness = walltickness;
            this.FloorThickness = floorthickness;

            this.gamemap = new Gamemap(this);
            this.roomItemHandling = new RoomItemHandling(this);
            this.roomUserManager = new RoomUserManager(this);
            this.wiredHandler = new WiredHandler(this);

            LoadRights();
            GetRoomItemHandler().LoadFurniture();
            wiredHandler.LoadWired();
            GetGameMap().GenerateMaps();
            LoadMusic();
            //LoadBots();
            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (dbClient.dbType == Database_Manager.Database.DatabaseType.MySQL)
                {
                    dbClient.runFastQuery("REPLACE INTO room_active VALUES (" + Id + ",1)");
                }
                else
                {
                    dbClient.runFastQuery("IF EXISTS (SELECT roomid FROM room_active WHERE roomid = " + Id + ") " +
                                            "UPDATE room_active SET active_users = 1 WHERE roomid = " + Id + " " +
                                            "ELSE " +
                                            "INSERT INTO room_active VALUES (" + Id + ",1)");
                }
            }

            ButterflyEnvironment.GetGame().GetRoomManager().QueueActiveRoomAdd(mRoomData);
        }
コード例 #14
0
        internal bool SetFloorItem(GameClient Session, RoomItem Item, int newX, int newY, int newRot, bool newItem, bool OnRoller, bool sendMessage, bool updateRoomUserStatuses)
        {
            bool NeedsReAdd = false;

            if (!newItem)
            {
                NeedsReAdd = room.GetGameMap().RemoveFromMap(Item);
            }
            Dictionary <int, ThreeDCoord> AffectedTiles = Gamemap.GetAffectedTiles(Item.GetBaseItem().Length, Item.GetBaseItem().Width, newX, newY, newRot);

            if (!room.GetGameMap().ValidTile(newX, newY) || room.GetGameMap().SquareHasUsers(newX, newY))
            {
                if (NeedsReAdd)
                {
                    AddItem(Item);
                    room.GetGameMap().AddToMap(Item);
                }
                return(false);
            }

            foreach (ThreeDCoord Tile in AffectedTiles.Values)
            {
                if (!room.GetGameMap().ValidTile(Tile.X, Tile.Y) || room.GetGameMap().SquareHasUsers(Tile.X, Tile.Y))
                {
                    if (NeedsReAdd)
                    {
                        AddItem(Item);
                        room.GetGameMap().AddToMap(Item);
                    }
                    return(false);
                }
            }

            // Start calculating new Z coordinate
            Double newZ = room.GetGameMap().Model.SqFloorHeight[newX, newY];

            if (!OnRoller)
            {
                // Is the item trying to stack on itself!?
                //if (Item.Rot == newRot && Item.GetX == newX && Item.GetY == newY && Item.GetZ != newZ)
                //{
                //    if (NeedsReAdd)
                //        AddItem(Item);
                //    return false;
                //}

                // Make sure this tile is open and there are no users here
                if (room.GetGameMap().Model.SqState[newX, newY] != SquareState.OPEN)
                {
                    if (NeedsReAdd)
                    {
                        AddItem(Item);
                        room.GetGameMap().AddToMap(Item);
                    }
                    return(false);
                }

                foreach (ThreeDCoord Tile in AffectedTiles.Values)
                {
                    if (room.GetGameMap().Model.SqState[Tile.X, Tile.Y] != SquareState.OPEN)
                    {
                        if (NeedsReAdd)
                        {
                            AddItem(Item);
                            room.GetGameMap().AddToMap(Item);
                        }
                        return(false);
                    }
                }

                // And that we have no users
                if (!Item.GetBaseItem().IsSeat&& !Item.IsRoller)
                {
                    foreach (ThreeDCoord Tile in AffectedTiles.Values)
                    {
                        if (room.GetGameMap().GetRoomUsers(new Point(Tile.X, Tile.Y)).Count > 0)
                        {
                            if (NeedsReAdd)
                            {
                                AddItem(Item);
                                room.GetGameMap().AddToMap(Item);
                            }
                            return(false);
                        }
                    }
                }
            }

            // Find affected objects
            List <RoomItem> ItemsOnTile   = GetFurniObjects(newX, newY);
            List <RoomItem> ItemsAffected = new List <RoomItem>();
            List <RoomItem> ItemsComplete = new List <RoomItem>();

            foreach (ThreeDCoord Tile in AffectedTiles.Values)
            {
                List <RoomItem> Temp = GetFurniObjects(Tile.X, Tile.Y);

                if (Temp != null)
                {
                    ItemsAffected.AddRange(Temp);
                }
            }


            ItemsComplete.AddRange(ItemsOnTile);
            ItemsComplete.AddRange(ItemsAffected);

            if (!OnRoller)
            {
                // Check for items in the stack that do not allow stacking on top of them
                foreach (RoomItem I in ItemsComplete)
                {
                    if (I == null)
                    {
                        continue;
                    }

                    if (I.Id == Item.Id)
                    {
                        continue;
                    }

                    if (I.GetBaseItem() == null)
                    {
                        continue;
                    }

                    if (!I.GetBaseItem().Stackable)
                    {
                        if (NeedsReAdd)
                        {
                            AddItem(Item);
                            room.GetGameMap().AddToMap(Item);
                        }
                        return(false);
                    }
                }
            }

            //if (!Item.IsRoller)
            {
                // If this is a rotating action, maintain item at current height
                if (Item.Rot != newRot && Item.GetX == newX && Item.GetY == newY)
                {
                    newZ = Item.GetZ;
                }

                // Are there any higher objects in the stack!?
                foreach (RoomItem I in ItemsComplete)
                {
                    if (I.Id == Item.Id)
                    {
                        continue; // cannot stack on self
                    }

                    if (I.TotalHeight > newZ)
                    {
                        newZ = I.TotalHeight;
                    }
                }
            }

            // Verify the rotation is correct
            if (newRot != 0 && newRot != 2 && newRot != 4 && newRot != 6 && newRot != 8)
            {
                newRot = 0;
            }

            //Item.GetX = newX;
            //Item.GetY = newY;
            //Item.GetZ = newZ;


            Item.Rot = newRot;
            int oldX = Item.GetX;
            int oldY = Item.GetY;

            Item.SetState(newX, newY, newZ, AffectedTiles);

            if (!OnRoller && Session != null)
            {
                Item.Interactor.OnPlace(Session, Item);
            }


            if (newItem)
            {
                if (mFloorItems.ContainsKey(Item.Id))
                {
                    if (Session != null)
                    {
                        Session.SendNotif(LanguageLocale.GetValue("room.itemplaced"));
                    }

                    //Remove from map!!!
                    return(true);
                }

                //using (DatabaseClient dbClient = ButterflyEnvironment.GetDatabase().GetClient())
                //{
                //    dbClient.addParameter("extra_data", Item.ExtraData);
                //    dbClient.runFastQuery("INSERT INTO room_items (id,room_id,base_item,extra_data,x,y,z,rot,wall_pos) VALUES ('" + Item.Id + "','" + RoomId + "','" + Item.BaseItem + "',@extra_data,'" + Item.GetX + "','" + Item.GetY + "','" + Item.GetZ + "','" + Item.Rot + "','')");
                //}
                //if (mRemovedItems.ContainsKey(Item.Id))
                //    mRemovedItems.Remove(Item.Id);
                //if (mAddedItems.ContainsKey(Item.Id))
                //    return false;

                //mAddedItems.Add(Item.Id, Item);

                if (Item.IsFloorItem && !mFloorItems.ContainsKey(Item.Id))
                {
                    mFloorItems.Add(Item.Id, Item);
                }
                else if (Item.IsWallItem && !mWallItems.ContainsKey(Item.Id))
                {
                    mWallItems.Add(Item.Id, Item);
                }

                AddItem(Item);

                if (sendMessage)
                {
                    ServerMessage Message = new ServerMessage(93);
                    Item.Serialize(Message);
                    room.SendMessage(Message);
                }
            }
            else
            {
                //using (DatabaseClient dbClient = ButterflyEnvironment.GetDatabase().GetClient())
                //{
                //    dbClient.runFastQuery("UPDATE room_items SET x = '" + Item.GetX + "', y = '" + Item.GetY + "', z = '" + Item.GetZ + "', rot = '" + Item.Rot + "', wall_pos = '' WHERE id = '" + Item.Id + "' LIMIT 1");
                //}
                UpdateItem(Item);

                if (!OnRoller && sendMessage)
                {
                    ServerMessage Message = new ServerMessage(95);
                    Item.Serialize(Message);
                    room.SendMessage(Message);
                }
            }

            if (!newItem)
            {
                room.GetWiredHandler().RemoveWiredItem(new System.Drawing.Point(oldX, oldY));

                if (WiredHandler.TypeIsWire(Item.GetBaseItem().InteractionType))
                {
                    room.GetWiredHandler().AddWire(Item, new System.Drawing.Point(newX, newY), newRot, Item.GetBaseItem().InteractionType);
                }
            }
            else
            {
                if (WiredHandler.TypeIsWire(Item.GetBaseItem().InteractionType))
                {
                    room.GetWiredHandler().AddWire(Item, Item.Coordinate, newRot, Item.GetBaseItem().InteractionType);
                }
            }

            //GenerateMaps(false);
            room.GetGameMap().AddToMap(Item);

            if (updateRoomUserStatuses)
            {
                room.GetRoomUserManager().UpdateUserStatusses();
            }

            return(true);
        }
コード例 #15
0
        private void Initialize(UInt32 Id, string Name, string Description, string Type, string Owner, int Category,
                                int State, int UsersMax, string ModelName, string CCTs, int Score, List <string> pTags, bool AllowPets,
                                bool AllowPetsEating, bool AllowWalkthrough, bool Hidewall, RoomIcon Icon, string Password, string Wallpaper, string Floor,
                                string Landscape, RoomData RoomData, bool RightOverride, int walltickness, int floorthickness)
        {
            this.mDisposed   = false;
            this.Id          = Id;
            this.Name        = Name;
            this.Description = Description;
            this.Owner       = Owner;
            this.Category    = Category;
            this.Type        = Type;
            this.State       = State;
            this.UsersNow    = 0;
            this.UsersMax    = UsersMax;
            this.ModelName   = ModelName;
            this.CCTs        = CCTs;
            this.Score       = Score;

            tagCount  = 0;
            this.Tags = new ArrayList();
            foreach (string tag in pTags)
            {
                tagCount++;
                Tags.Add(tag);
            }

            this.AllowPets        = AllowPets;
            this.AllowPetsEating  = AllowPetsEating;
            this.AllowWalkthrough = AllowWalkthrough;
            this.Hidewall         = Hidewall;


            this.myIcon             = Icon;
            this.Password           = Password;
            this.Bans               = new Dictionary <UInt32, double>();
            this.Wallpaper          = Wallpaper;
            this.Floor              = Floor;
            this.Landscape          = Landscape;
            this.chatMessageManager = new ChatMessageManager();
            this.groups             = new QueuedDictionary <int, Group>();
            this.ActiveTrades       = new ArrayList();


            this.mCycleEnded = false;

            this.mRoomData         = RoomData;
            this.EveryoneGotRights = RightOverride;

            this.roomMessages     = new Queue();
            this.chatMessageQueue = new Queue();
            this.rnd = new Random();

            this.roomMessages       = new Queue();
            this.roomAlerts         = new Queue();
            this.roomBadge          = new Queue();
            this.roomKick           = new Queue();
            this.roomServerMessages = new Queue();
            this.IdleTime           = 0;
            this.RoomMuted          = false;
            this.WallThickness      = walltickness;
            this.FloorThickness     = floorthickness;

            this.gamemap          = new Gamemap(this);
            this.roomItemHandling = new RoomItemHandling(this);
            this.roomUserManager  = new RoomUserManager(this);
            this.wiredHandler     = new WiredHandler(this);

            LoadRights();
            GetRoomItemHandler().LoadFurniture();
            wiredHandler.LoadWired();
            GetGameMap().GenerateMaps();
            LoadMusic();
            //LoadBots();
            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (dbClient.dbType == Database_Manager.Database.DatabaseType.MySQL)
                {
                    dbClient.runFastQuery("REPLACE INTO room_active VALUES (" + Id + ",1)");
                }
                else
                {
                    dbClient.runFastQuery("IF EXISTS (SELECT roomid FROM room_active WHERE roomid = " + Id + ") " +
                                          "UPDATE room_active SET active_users = 1 WHERE roomid = " + Id + " " +
                                          "ELSE " +
                                          "INSERT INTO room_active VALUES (" + Id + ",1)");
                }
            }

            ButterflyEnvironment.GetGame().GetRoomManager().QueueActiveRoomAdd(mRoomData);
        }
コード例 #16
0
        internal void MoveTo(int pX, int pY)
        {
            // Comando developer activado?
            if (DeveloperCommand.CheckDeveloper(this, pX, pY, GetRoom()))
            {
                return;
            }

            bool    guildGateUser = false;
            Gamemap roomGameMap   = GetRoom().GetGameMap();

            Point square = new Point(pX, pY);

            if (roomGameMap.guildGates.ContainsKey(square))
            {
                uint     GuildId = 0;
                string[] strArr  = roomGameMap.guildGates[square].GroupData.Split(';');
                if (strArr.Length < 2)
                {
                    return;
                }

                uint.TryParse(strArr[1], out GuildId);

                if (GuildId > 0)
                {
                    if (!IsBot)
                    {
                        if (GetClient().GetHabbo().MyGroups.Contains(GuildId))
                        {
                            guildGateUser = true;
                        }
                    }
                }
            }

            // Si hay un usuario o un item, evitamos crear un nuevo path.
            if (!GetRoom().GetGameMap().tileIsWalkable(pX, pY, true, false, guildGateUser) && !AllowOverride && walkingToPet == null)
            {
                return;
            }

            if (ByteToItemEffectEnum.Parse(GetRoom().GetGameMap().EffectMap[pX, pY]) == ItemEffectType.HorseJump)
            {
                return;
            }

            if (isKicking)
            {
                return;
            }

            Unidle();

            if (TeleportEnabled)
            {
                if (IsWalking)
                {
                    GetRoom().GetGameMap().RemoveUserFromMap(this, new Point(SetX, SetY));
                    ClearMovement(true);
                }

                GetRoom().SendMessage(GetRoom().GetRoomItemHandler().UpdateUserOnRoller(this, new Point(pX, pY), 0));
                GetRoom().GetRoomUserManager().UpdateUserStatus(this, false);
                return;
            }

            IsWalking        = true;
            GoalX            = pX;
            GoalY            = pY;
            PathRecalcNeeded = true;
            throwBallAtGoal  = false;
            // GetRoom().GetRoomUserManager().UpdateUsersPath = true;
        }