Beispiel #1
0
 public GameItemHandler(Room room)
 {
     this.room = room;
     this.rnd = new Random();
     this.banzaiPyramids = new QueuedDictionary<uint, RoomItem>();
     this.banzaiTeleports = new QueuedDictionary<uint, RoomItem>();
 }
Beispiel #2
0
 internal void Init(UInt32 pBaseId, Int32 pRoomUserId, UInt32 pRoomId, RoomUser user, Room room)
 {
     this.BaseId = pBaseId;
     this.RoomUserId = pRoomUserId;
     this.RoomId = pRoomId;
     this.roomUser = user;
     this.room = room;
 }
Beispiel #3
0
 internal void Destroy()
 {
     if (banzaiTeleports != null)
         banzaiTeleports.Destroy();
     if (banzaiPyramids != null)
         banzaiPyramids.Clear();
     banzaiPyramids = null;
     banzaiTeleports = null;
     room = null;
     rnd = null;
 }
Beispiel #4
0
        internal static UInt32 GetLinkedTele(UInt32 TeleId, Room pRoom)
        {
            using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT tele_two_id FROM tele_links WHERE tele_one_id = " + TeleId);
                DataRow Row = dbClient.getRow();

                if (Row == null)
                {
                    return 0;
                }

                return Convert.ToUInt32(Row[0]);
            }
        }
Beispiel #5
0
        public Gamemap(Room room)
        {
            this.room = room;
            this.DiagonalEnabled = true;
            this.mStaticModel = SilverwaveEnvironment.GetGame().GetRoomManager().GetModel(room.ModelName);
            if (mStaticModel == null)
                throw new Exception("No modeldata found for roomID " + room.RoomId);
            this.mDynamicModel = new DynamicRoomModel(this.mStaticModel);

            this.mCoordinatedItems = new Hashtable();

            this.gotPublicPool = room.RoomData.Model.gotPublicPool;
            this.mGameMap = new byte[Model.MapSizeX, Model.MapSizeY];
            this.mItemHeightMap = new double[Model.MapSizeX, Model.MapSizeY];
            userMap = new Hashtable();
        }
Beispiel #6
0
        public RoomUserManager(Room room)
        {
            //this.RoomUserCounter = 0;
            this.room = room;
            this.userlist = new QueuedDictionary<int, RoomUser>(new EventHandler(OnUserAdd), null, new EventHandler(onRemove), null);
            this.pets = new Hashtable();
            this.bots = new Hashtable();
            this.usersByUsername = new Hashtable();
            this.usersByUserID = new Hashtable();
            this.primaryPrivateUserID = 0;
            this.secondaryPrivateUserID = 0;
            this.ToRemove = new List<RoomUser>(room.UsersMax);

            this.petCount = 0;
            this.userCount = 0;
        }
Beispiel #7
0
        internal static UInt32 GetTeleRoomId(UInt32 TeleId, Room pRoom)
        {
            if (pRoom.GetRoomItemHandler().GetItem(TeleId) != null)
                return pRoom.RoomId;

            using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT room_id FROM items WHERE id = " + TeleId + " LIMIT 1");
                DataRow Row = dbClient.getRow();

                if (Row == null)
                {
                    return 0;
                }

                return Convert.ToUInt32(Row[0]);
            }
        }
Beispiel #8
0
        public RoomItemHandling(Room room)
        {
            this.room = room;

            this.mRemovedItems = new Hashtable();
            this.mMovedItems = new Hashtable();
            this.mAddedItems = new Hashtable();
            this.mRollers = new QueuedDictionary<uint,RoomItem>();

            this.mWallItems = new QueuedDictionary<uint, RoomItem>();
            this.mFloorItems = new QueuedDictionary<uint, RoomItem>();
            this.roomItemUpdateQueue = new Queue();
            this.mGotRollers = false;
            this.mRoolerCycle = 0;
            this.mRollerSpeed = 4;
            this.HopperCount = 0;

            rollerItemsMoved = new List<uint>();
            rollerUsersMoved = new List<uint>();
            rollerMessages = new List<ServerMessage>();
        }
Beispiel #9
0
        internal static bool IsTeleLinked(UInt32 TeleId, Room pRoom)
        {
            uint LinkId = GetLinkedTele(TeleId, pRoom);

            if (LinkId == 0)
            {
                return false;
            }

            RoomItem item = pRoom.GetRoomItemHandler().GetItem(LinkId);
            if (item != null && item.GetBaseItem().InteractionType == Silverwave.HabboHotel.Items.InteractionType.teleport)
                return true;

            uint RoomId = GetTeleRoomId(LinkId, pRoom);

            if (RoomId == 0)
            {
                return false;
            }

            return true;
        }
Beispiel #10
0
        internal void PrepareRoomForUser(uint Id, string Password)
        {
            ClearRoomLoading();

            QueuedServerMessage response = new QueuedServerMessage(Session.GetConnection());
            if (Session == null)
                return;

            if (SilverwaveEnvironment.ShutdownStarted)
            {
                Session.SendNotif(LanguageLocale.GetValue("shutdown.alert"));
                return;
            }

            if (Session.GetHabbo().InRoom)
            {
                Room OldRoom = SilverwaveEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

                if (OldRoom != null)
                {
                    if (OldRoom.GetRoomUserManager() != null)
                        OldRoom.GetRoomUserManager().RemoveUserFromRoom(Session, false, false);
                }
            }

            Room Room = SilverwaveEnvironment.GetGame().GetRoomManager().LoadRoom(Id);
            if (Room == null)
                return;

            if (Room.UserCount >= Room.UsersMax && !Session.GetHabbo().HasFuse("fuse_enter_full_rooms"))
            {
                if (Session.GetHabbo().Id != Room.OwnerId)
                {
                    // This rom is full!!

                    ServerMessage msg = new ServerMessage(Outgoing.RoomErrorToEnter);
                    msg.AppendInt32(1);
                    //Session.SendMessage(msg);
                    ServerMessage msg2 = new ServerMessage(Outgoing.OutOfRoom);
                    Session.SendMessage(msg2);
                    return;
                }
            }

            if (Room == null || Session == null || Session.GetHabbo() == null)
                return;

            if (Session.GetHabbo().IsTeleporting && Session.GetHabbo().TeleportingRoomID != Id)
                return;

            Session.GetHabbo().LoadingRoom = Id;
            CurrentLoadingRoom = Room;

            if (!Session.GetHabbo().HasFuse("fuse_enter_any_room") && Room.UserIsBanned(Session.GetHabbo().Id))
            {
                if (Room.HasBanExpired(Session.GetHabbo().Id))
                {
                    Room.RemoveBan(Session.GetHabbo().Id);
                }
                else
                {
                    // You are banned of this room!

                    // C`PA
                    // Response.Init(Outgoing.RoomErrorToEnter);
                    //Response.AppendInt32(4);
                    //response.appendResponse(GetResponse());
                    Session.SendNotif("You are banned from this room");
                    Response.Init(Outgoing.OutOfRoom);
                    response.appendResponse(GetResponse());

                    response.sendResponse();
                    return;
                }
            }

            Response.Init(Outgoing.PrepareRoomForUsers);
            response.appendResponse(GetResponse());

            if (!Session.GetHabbo().HasFuse("fuse_enter_any_room") && !Room.CheckRights(Session, true, true) && !Session.GetHabbo().IsTeleporting && !Session.GetHabbo().IsHopping)
            {
                if (Room.State == 1)
                {
                    if (Room.UserCount == 0)
                    {
                        Response.Init(Outgoing.DoorBellNoPerson);
                        response.appendResponse(GetResponse());
                    }
                    else
                    {
                        Response.Init(Outgoing.Doorbell);
                        Response.AppendString("");
                        response.appendResponse(GetResponse());

                        ServerMessage RingMessage = new ServerMessage(Outgoing.Doorbell);
                        RingMessage.AppendString(Session.GetHabbo().Username);
                        Room.SendMessageToUsersWithRights(RingMessage);
                    }

                    response.sendResponse();

                    return;
                }
                else if (Room.State == 2)
                {
                    if (Password.ToLower() != Room.Password.ToLower())
                    {
                        Response.Init(Outgoing.OutOfRoom);
                        response.appendResponse(GetResponse());

                        response.sendResponse();
                        return;
                    }
                }
            }

            Session.GetHabbo().LoadingChecksPassed = true;

            response.addBytes(LoadRoomForUser().getPacket);
            //LoadRoomForUser();
            response.sendResponse();
            using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                dbClient.runFastQuery("INSERT INTO user_roomvisits (user_id,room_id,entry_timestamp,exit_timestamp,hour,minute) VALUES ('" + Session.GetHabbo().Id + "','" + Id + "','" + SilverwaveEnvironment.GetUnixTimestamp() + "','0','" + DateTime.Now.Hour + "','" + DateTime.Now.Minute + "');" +
                    "UPDATE user_stats SET RoomVisits = RoomVisits + 1 WHERE id = " + Session.GetHabbo().Id);
        }
Beispiel #11
0
 internal ServerMessage RoomFloorAndWallComposer(Room room)
 {
     //Habbo owner = SilverwaveEnvironment.getHabboForId((uint)room.OwnerId);
     //if (owner.GetSubscriptionManager().HasSubscription)
     {
         ServerMessage m = new ServerMessage(Outgoing.RoomFloorAndWallComposer);
         m.AppendBoolean(room.Hidewall == 1);
         m.AppendInt32(room.WallThickness);
         m.AppendInt32(room.FloorThickness);
         return m;
     }
 }
Beispiel #12
0
        internal void UnloadRoom(Room Room)
        {
            if (Room == null)
            {
                return;
            }
            System.Text.StringBuilder formattedTags = new System.Text.StringBuilder();

            for (int i = 0; i < Room.TagCount; i++)
            {
                if (i > 0)
                {
                    formattedTags.Append(",");
                }
                formattedTags.Append(Room.Tags[i]);
            }
            string formattedState = "open";

            if (Room.State == 1)
                formattedState = "locked";
            else if (Room.State > 1)
                formattedState = "password";

            using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("UPDATE rooms SET caption = @caption, description = @description, password = @password, category = " + Room.Category + ", state = '" + formattedState + "', tags = @tags, users_max = " + Room.UsersMax + ", allow_pets = '" + Room.AllowPets + "', allow_pets_eat = '" + Room.AllowPetsEating + "', allow_walkthrough = '" + Room.AllowWalkthrough +
                    "', allow_hidewall = '" + Room.Hidewall + "', floorthick = " + Room.FloorThickness + ", wallthick = " + Room.WallThickness + ", mute_settings='" + Room.WhoCanMute + "', kick_settings='" + Room.WhoCanKick + 
                    "',ban_settings='" + Room.WhoCanBan + "', chat_type = @chat_t,chat_balloon = @chat_b,chat_speed = @chat_s,chat_max_distance = @chat_m,chat_flood_protection = @chat_f WHERE id = " + Room.RoomId);
                dbClient.addParameter("caption", Room.Name);
                dbClient.addParameter("description", Room.Description);
                dbClient.addParameter("password", Room.Password);
                dbClient.addParameter("tags", formattedTags.ToString());
                dbClient.addParameter("chat_t", Room.ChatType);
                dbClient.addParameter("chat_b", Room.ChatBalloon);
                dbClient.addParameter("chat_s", Room.ChatSpeed);
                dbClient.addParameter("chat_m", Room.ChatMaxDistance);
                dbClient.addParameter("chat_f", Room.ChatFloodProtection);
                dbClient.runQuery();
            }

            lock (roomsToRemoveQueue.SyncRoot)
            {
                roomsToRemoveQueue.Enqueue(Room.RoomId);
            }

            foreach (RoomUser User in Room.GetRoomUserManager().UserList.Values)
            {
                if (User.IsPet)
                {
                    using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        dbClient.setQuery("UPDATE bots SET x=@x, y=@y, z=@z WHERE id=@id LIMIT 1;");
                        dbClient.addParameter("x", User.X);
                        dbClient.addParameter("y", User.Y);
                        dbClient.addParameter("z", User.Z);
                        dbClient.addParameter("id", User.PetData.PetId);
                        dbClient.runQuery();
                    }
                }
                else if (User.IsBot)
                {
                    using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        dbClient.setQuery("UPDATE bots SET x=@x, y=@y, z=@z, name=@name, motto=@motto, look=@look,"+
                            " rotation=@rotation, dance=@dance WHERE id=@id LIMIT 1;");
                        dbClient.addParameter("name", User.BotData.Name);
                        dbClient.addParameter("motto", User.BotData.Motto);
                        dbClient.addParameter("look", User.BotData.Look);
                        dbClient.addParameter("rotation", User.BotData.Rot);
                        dbClient.addParameter("dance", User.BotData.DanceId);
                        dbClient.addParameter("x", User.X);
                        dbClient.addParameter("y", User.Y);
                        dbClient.addParameter("z", User.Z);
                        dbClient.addParameter("id", User.BotData.BotId);
                        dbClient.runQuery();
                    }
                }
                Room.GetRoomUserManager().RemoveRoomUser(User);    
            }
            
            foreach (Chatlog Chat in Room.RoomChat)
            {
                    Chat.Save(Room.RoomId);
            }
            foreach (Chatlog Chat in Room.Added)
            {
                    Chat.Save(Room.RoomId);
            }

            Room.Destroy();

           Logging.WriteLine("[RoomMgr] Unloaded room: \"" + Room.Name + "\" (ID: " + Room.RoomId + ")");
        }
Beispiel #13
0
        internal void OnRoomUserAdd()
        {
            if (Session == null || GetResponse() == null)
                return;
            QueuedServerMessage response = new QueuedServerMessage(Session.GetConnection());

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

            if (CurrentLoadingRoom == null || CurrentLoadingRoom.GetRoomUserManager() == null || CurrentLoadingRoom.GetRoomUserManager().UserList == null)
                return;

            foreach (RoomUser User in CurrentLoadingRoom.GetRoomUserManager().UserList.Values)
            {
                if (User == null || User.IsSpectator)
                    continue;

                UsersToDisplay.Add(User);
            }

            Response.Init(Outgoing.SetRoomUser);
            Response.AppendInt32(UsersToDisplay.Count);

            foreach (RoomUser User in UsersToDisplay)
            {
                User.Serialize(Response, CurrentLoadingRoom.GetGameMap().gotPublicPool);
            }
            response.appendResponse(GetResponse());

            response.appendResponse(RoomFloorAndWallComposer(CurrentLoadingRoom));

            response.appendResponse(GetResponse());

            Response.Init(Outgoing.ValidRoom);
            Response.AppendBoolean(true);
            Response.AppendInt32(CurrentLoadingRoom.RoomId);
            Response.AppendBoolean(CurrentLoadingRoom.CheckRights(Session, true));
            response.appendResponse(GetResponse());

            //DataTable Table;
            //using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
            //{
            //dbClient.setQuery("SELECT user_id FROM room_rights WHERE room_id=" + CurrentLoadingRoom.RoomData.Id);
            //Table = dbClient.getTable();
            //}

            /*GetResponse().Init(Outgoing.GetPowerList);
            GetResponse().AppendUInt(CurrentLoadingRoom.RoomData.Id);
            GetResponse().AppendInt32(Table.Rows.Count);
            foreach (DataRow i in Table.Rows)
            {
                Habbo xUser = SilverwaveEnvironment.getHabboForId((uint)i[0]);
                GetResponse().AppendUInt(xUser.Id);
                GetResponse().AppendString(xUser.Username);
            }
            //response.appendResponse(GetResponse());*/

            foreach (uint i in CurrentLoadingRoom.UsersWithRights)
            {
                Habbo xUser = SilverwaveEnvironment.getHabboForId(i);
                if (xUser != null)
                {
                    GetResponse().Init(Outgoing.GivePowers);
                    GetResponse().AppendInt32(CurrentLoadingRoom.RoomId);
                    GetResponse().AppendInt32(xUser.Id);
                    GetResponse().AppendString(xUser.Username);
                    response.appendResponse(GetResponse());
                }

            }
            ServerMessage Updates = CurrentLoadingRoom.GetRoomUserManager().SerializeStatusUpdates(true);

            if (Updates != null)
                response.appendResponse(Updates);

            if (CurrentLoadingRoom.Event != null)
            {
                SilverwaveEnvironment.GetGame().GetRoomEvents().SerializeEventInfo(CurrentLoadingRoom.RoomId);
            }

            foreach (RoomUser User in CurrentLoadingRoom.GetRoomUserManager().UserList.Values)
            {
                if (User == null || User.IsSpectator)
                    continue;
                if (User.IsBot)
                {
                    if (User.BotData.DanceId > 0)
                    {
                        Response.Init(Outgoing.Dance);
                        Response.AppendInt32(User.VirtualId);
                        Response.AppendInt32(User.BotData.DanceId);
                        response.appendResponse(GetResponse());
                    }
                }
                else
                {

                    if (User.IsDancing)
                    {
                        Response.Init(Outgoing.Dance);
                        Response.AppendInt32(User.VirtualId);
                        Response.AppendInt32(User.DanceId);
                        response.appendResponse(GetResponse());
                    }
                }
                if (User.IsAsleep)
                {
                    response.appendResponse(new SleepComposer(User, true));
                }

                if (User.CarryItemID > 0 && User.CarryTimer > 0)
                {
                    Response.Init(Outgoing.ApplyCarryItem);
                    Response.AppendInt32(User.VirtualId);
                    Response.AppendInt32(User.CarryTimer);
                    response.appendResponse(GetResponse());
                }

                if (!User.IsBot)
                {
                    try
                    {
                        if (User != null && User.GetClient() != null && User.GetClient().GetHabbo() != null)
                        {
                            if (User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent() != null && User.CurrentEffect >= 1)
                            {
                                Response.Init(Outgoing.ApplyEffects);
                                Response.AppendInt32(User.VirtualId);
                                Response.AppendInt32(User.CurrentEffect);
                                Response.AppendInt32(0);
                                response.appendResponse(GetResponse());
                            }
                            ServerMessage RoomUpdate = new ServerMessage(Outgoing.UpdateUserInformation);
                            RoomUpdate.AppendInt32(User.VirtualId);
                            RoomUpdate.AppendString(User.GetClient().GetHabbo().Look);
                            RoomUpdate.AppendString(User.GetClient().GetHabbo().Gender.ToLower());
                            RoomUpdate.AppendString(User.GetClient().GetHabbo().Motto);
                            RoomUpdate.AppendInt32(User.GetClient().GetHabbo().AchievementPoints);
                            if (CurrentLoadingRoom != null)
                                CurrentLoadingRoom.SendMessage(RoomUpdate);
                        }
                    }
                    catch (Exception e) { Logging.HandleException(e, "Rooms.SendRoomData3"); }
                }

            }

            response.sendResponse();
            CurrentLoadingRoom = null;
        }
Beispiel #14
0
        internal void Fill(Room Room)
        {
            this.Id = Room.RoomId;
            this.Name = Room.Name;
            this.Description = Room.Description;
            this.Type = Room.Type;
            this.Owner = Room.Owner;
            this.Category = Room.Category;
            this.State = Room.State;
            this.UsersNow = Room.UsersNow;
            this.UsersMax = Room.UsersMax;
            this.ModelName = Room.ModelName;
            this.Score = Room.Score;

            this.Tags = new List<string>();
            foreach (string tag in Room.Tags.ToArray())
                this.Tags.Add(tag);
            this.AllowPets = Room.AllowPets;
            this.AllowPetsEating = Room.AllowPetsEating;
            this.AllowWalkthrough = Room.AllowWalkthrough;
            this.Hidewall = Room.Hidewall;
            this.Password = Room.Password;
            this.Wallpaper = Room.Wallpaper;
            this.Floor = Room.Floor;
            this.Landscape = Room.Landscape;
            this.FloorThickness = Room.FloorThickness;
            this.WallThickness = Room.WallThickness;
            this.Group = Room.Group;
            this.Event = Room.Event;
            this.GameId = Room.GameId;
            this.ChatType = Room.ChatType;
            this.ChatBalloon = Room.ChatBalloon;
            this.ChatSpeed = Room.ChatSpeed;
            this.ChatMaxDistance = Room.ChatMaxDistance;
            this.ChatFloodProtection = Room.ChatFloodProtection;
            this.WhoCanMute = Room.WhoCanMute;
            this.WhoCanKick = Room.WhoCanKick;
            this.WhoCanBan = Room.WhoCanBan;
            this.RoomChat = Room.RoomChat;
            mModel = SilverwaveEnvironment.GetGame().GetRoomManager().GetModel(ModelName);
        }
Beispiel #15
0
        internal Room LoadRoom(UInt32 Id)
        {
            if (IsRoomLoaded(Id))
            {
                return GetRoom(Id);
            }

            RoomData Data = GenerateRoomData(Id);

            if (Data == null)
                return null;

            Room Room = new Room(Data);

            //Room Room = new Room(Data.Id, Data.Name, Data.Description, Data.Type, Data.Owner, Data.Category, Data.State,
            //    Data.UsersMax, Data.ModelName, Data.CCTs, Data.Score, Data.Tags, Data.AllowPets, Data.AllowPetsEating,
            //    Data.AllowWalkthrough, Data.Hidewall, Data.Icon, Data.Password, Data.Wallpaper, Data.Floor, Data.Landscape, Data, Data.AllowRightsOverride);

            lock (roomsToAddQueue.SyncRoot)
            {
                roomsToAddQueue.Enqueue(Room);
            }


            Room.InitBots();
            Room.InitPets();
            //Logging.WriteLine("[RoomMgr] Loaded room: \"" + Room.Name + "\" (ID: " + Id + ")");

            return Room;
        }
Beispiel #16
0
 internal void BroadcastCurrentSongData(Room Instance)
 {
     if (mSong != null)
         Instance.SendMessage(JukeboxComposer.ComposePlayingComposer(mSong.SongData.Id, mSongQueuePosition, 0));
     else
         Instance.SendMessage(JukeboxComposer.ComposePlayingComposer(0, 0, 0));
 }
Beispiel #17
0
        internal void SerializeGroupInfo(Group Group, ServerMessage Response, GameClient Session, Room Room, bool NewWindow = false)
        {
            DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            DateTime Time = origin.AddSeconds(Group.CreateTime);
            Response.Init(Outgoing.SerializeGroupInfo);
            Response.AppendInt32(Group.Id);
            Response.AppendBoolean(true);
            Response.AppendInt32(Group.State); // Type (0 = 50k users, 1 = Request, 2 = blocked, 3 = ?, 4 = ?..
            Response.AppendString(Group.Name);
            Response.AppendString(Group.Description);
            Response.AppendString(Group.Badge);
            Response.AppendInt32(Group.RoomId);
            Response.AppendString((SilverwaveEnvironment.GetGame().GetRoomManager().GenerateRoomData(Group.RoomId) == null) ? "No room found.." : SilverwaveEnvironment.GetGame().GetRoomManager().GenerateRoomData(Group.RoomId).Name); // room name
            Response.AppendInt32((Group.CreatorId == Session.GetHabbo().Id) ? 3 : (Group.Requests.Contains(Session.GetHabbo().Id)) ? 2 : (Group.Members.ContainsKey(Session.GetHabbo().Id)) ? 1 : 0); //Member
            Response.AppendInt32(Group.Members.Count); // Members
            Response.AppendBoolean(Session.GetHabbo().FavouriteGroup == Group.Id);
            Response.AppendString(Time.Day + "-" + Time.Month + "-" + Time.Year);
            Response.AppendBoolean(Group.CreatorId == Session.GetHabbo().Id);
            Response.AppendBoolean((Group.Admins.ContainsKey(Session.GetHabbo().Id)));
            Response.AppendString((SilverwaveEnvironment.getHabboForId(Group.CreatorId) == null) ? "" : SilverwaveEnvironment.getHabboForId(Group.CreatorId).Username);
            Response.AppendBoolean(NewWindow); // Show group info
            Response.AppendBoolean(Group.AdminOnlyDeco == 0); // Any user can place furni in home room
            Response.AppendInt32(Group.Requests.Count); // Pending users
            Response.AppendBoolean(true);
            if (Room != null)
                Room.SendMessage(Response);
            else if (Session != null)
                Session.SendMessage(Response);

            /*if (Session.GetHabbo().Id == Group.CreatorId)
                SerializeGroupInfo(Group, Response, Session, false);*/
        }
Beispiel #18
0
        internal void Destroy()
        {
            mFloorItems.Clear();
            mWallItems.Clear();
            mRemovedItems.Clear();
            mMovedItems.Clear();
            mAddedItems.Clear();
            roomItemUpdateQueue.Clear();

            room = null;
            mFloorItems = null;
            mWallItems = null;
            mRemovedItems = null;
            mMovedItems = null;
            mAddedItems = null;
            mWallItems = null;
            roomItemUpdateQueue = null;
        }
Beispiel #19
0
        /*
        internal void OpenPresent()
        {
            Room Room = SilverwaveEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

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

            uint ItemId = Request.PopWiredUInt();
            RoomItem Present = Room.GetRoomItemHandler().GetItem(ItemId);
            if (Present == null)
            {
                return;
            }

            if (SilverwaveEnvironment.GetDBConfig().DBData["gifts_enabled"] != "1")
            {
                Session.SendNotif("The hotel managers have disabled gifting");
                return;
            }

            DataRow Data = null;

            using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT base_id,amount,extra_data FROM user_presents WHERE item_id = " + Present.Id + "");
                Data = dbClient.getRow();
            }

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

            Item BaseItem = SilverwaveEnvironment.GetGame().GetItemManager().GetItem(Convert.ToUInt32(Data["base_id"]));
            if (BaseItem == null)
            {
                Room.GetRoomItemHandler().RemoveFurniture(Session, Present.Id);
                return;
            }

            uint PurchaserId = (uint)int.Parse(Present.ExtraData.Split(';')[0]);
            Habbo Purchaser = SilverwaveEnvironment.getHabboForId(PurchaserId);
            Response.Init(Outgoing.UpdateFloorItemExtraData);
            Response.AppendString(ItemId.ToString());
            Response.AppendInt32(1);
            Response.AppendInt32(6);
            Response.AppendString("EXTRA_PARAM");
            Response.AppendString("");
            Response.AppendString("MESSAGE");
            Response.AppendString(Present.ExtraData.Split(';')[1].Split((char)5)[0]);
            Response.AppendString("PURCHASER_NAME");
            Response.AppendString(Purchaser.Username);
            Response.AppendString("PURCHASER_FIGURE");
            Response.AppendString(Purchaser.Look);
            Response.AppendString("PRODUCT_CODE");
            Response.AppendString("A1 KUMIANKKA");
            Response.AppendString("state");
            Response.AppendString("1");
            Room.SendMessage(Response);

            Present.ReqUpdate(5, true);

            Thread thread = new Thread(() => FinishOpenGift(BaseItem, Present, Room, Data));
            thread.Start();
        }*/
        private void FinishOpenGift(Item BaseItem, RoomItem Present, Room Room, DataRow Data)
        {
            Thread.Sleep(3000);
            try
            {
                if (BaseItem == null || Present == null || Room == null || Data == null)
                    return;
                if (BaseItem.Type.ToString().ToLower().Equals("s") && BaseItem.InteractionType != InteractionType.teleport)
                {
                    Room.GetRoomItemHandler().RemoveFurniture(Session, Present.Id);

                    using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        dbClient.runFastQuery("DELETE FROM items WHERE id=" + Present.Id + " LIMIT 1;");
                        dbClient.setQuery("UPDATE items SET extra_data = @Edata WHERE id = " + Present.Id + " LIMIT 1");
                        dbClient.addParameter("edata", Data["extra_data"]);
                        dbClient.runQuery();
                        dbClient.runFastQuery("DELETE FROM user_presents WHERE item_id = " + Present.Id + " LIMIT 1");
                    }

                    string type = Present.GetBaseItem().Type.ToString().ToLower();
                    string ExtraData = Present.ExtraData;
                    Present.BaseItem = Convert.ToUInt32(Data["base_id"]);
                    Present.refreshItem();
                    Present.ExtraData = "";
                    if ((int)Data["amount"] == 1)
                    {
                        if (!Room.GetRoomItemHandler().SetFloorItem(Session, Present, Present.GetX, Present.GetY, Present.Rot, true, false, true))
                        {
                            SilverwaveEnvironment.GetGame().GetCatalog().DeliverItems(Session, BaseItem, (int)Data["amount"], (String)Data["extra_data"], 0, 0);
                            Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
                        }
                    }
                    else
                    {
                        SilverwaveEnvironment.GetGame().GetCatalog().DeliverItems(Session, BaseItem, (int)Data["amount"], (String)Data["extra_data"], 0, 0);
                        Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
                    }

                    Response.Init(Outgoing.OpenGift);
                    Response.AppendString(BaseItem.Type.ToString());
                    Response.AppendInt32(BaseItem.SpriteId);
                    Response.AppendString(BaseItem.Name);
                    Response.AppendInt32(Present.Id);
                    Response.AppendString(type);
                    Response.AppendBoolean(false);
                    Response.AppendString(ExtraData);
                    //SendResponse();
                }
                else
                {
                    Room.GetRoomItemHandler().RemoveFurniture(Session, Present.Id);
                    using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        dbClient.runFastQuery("DELETE FROM items WHERE id=" + Present.Id + " LIMIT 1;");
                        dbClient.runFastQuery("DELETE FROM user_presents WHERE item_id = " + Present.Id);
                    }
                    Session.GetMessageHandler().GetResponse().Init(Outgoing.SendPurchaseAlert);
                    Session.GetMessageHandler().GetResponse().AppendInt32(1); // items
                    int Type = 2;
                    if (BaseItem.Type.ToString().ToLower().Equals("s"))
                    {
                        if (BaseItem.InteractionType == InteractionType.pet)
                            Type = 3;
                        else
                            Type = 1;
                    }
                    Session.GetMessageHandler().GetResponse().AppendInt32(Type);
                    List<UserItem> items = SilverwaveEnvironment.GetGame().GetCatalog().DeliverItems(Session, BaseItem, (int)Data["amount"], (String)Data["extra_data"], 0, 0);
                    Session.GetMessageHandler().GetResponse().AppendInt32(items.Count);
                    foreach (UserItem u in items)
                        Session.GetMessageHandler().GetResponse().AppendInt32(u.Id);
                    Session.GetMessageHandler().SendResponse();
                    Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
                }
            }
            catch { }
        }
Beispiel #20
0
 internal ServerMessage SerializeRoomChatOption(Room room)
 {
     ServerMessage m = new ServerMessage(Outgoing.RoomChatOptionsComposer);
     m.AppendInt32(room.ChatType);  //ChatMode, ChatSize, ChatSpeed, HearingDistance, ExtraFlood is the order.
     m.AppendInt32(room.ChatBalloon);
     m.AppendInt32(room.ChatSpeed);
     m.AppendInt32(room.ChatMaxDistance);
     m.AppendInt32(room.ChatFloodProtection);
     return m;
 }
Beispiel #21
0
        internal void Destroy()
        {
            userMap.Clear();
            mDynamicModel.Destroy();
            mCoordinatedItems.Clear();

            Array.Clear(mGameMap, 0, mGameMap.Length);
            Array.Clear(mUserItemEffect, 0, mUserItemEffect.Length);
            Array.Clear(mItemHeightMap, 0, mItemHeightMap.Length);

            userMap = null;
            mGameMap = null;
            mUserItemEffect = null;
            mItemHeightMap = null;
            mCoordinatedItems = null;
            mDynamicModel = null;
            room = null;
            mStaticModel = null;
        }
Beispiel #22
0
 internal void Destroy()
 {
     room = null;
     usersByUsername.Clear();
     usersByUsername = null;
     usersByUserID.Clear();
     usersByUserID = null;
     OnUserEnter = null;
     pets.Clear();
     bots.Clear();
     pets = null;
     bots = null;
     userlist.Destroy();
     userlist = null;
 }
Beispiel #23
0
        //ill debug it, second,
        internal void SerializeRoomInformation(Room Room, bool show)
        {
            GetResponse().Init(Outgoing.RoomData);
            GetResponse().AppendBoolean(show);
            GetResponse().AppendInt32(Room.RoomId);
            GetResponse().AppendString(Room.Name);
            GetResponse().AppendBoolean(Room.Type == "private");
            GetResponse().AppendInt32(Room.OwnerId);
            GetResponse().AppendString(Room.Owner);
            GetResponse().AppendInt32(Room.State);
            GetResponse().AppendInt32(Room.UsersNow);
            GetResponse().AppendInt32(Room.UsersMax);
            GetResponse().AppendString(Room.Description);
            GetResponse().AppendInt32(0); //unused, let be 0
            GetResponse().AppendInt32(Room.CanTradeInRoom ? 2 : 0);
            GetResponse().AppendInt32(Room.Score);
            GetResponse().AppendInt32(0); // visible for rank > x
            GetResponse().AppendInt32(Room.Category);
            if (Room.GroupId > 0)
            {
                GetResponse().AppendInt32(Room.Group.Id);
                GetResponse().AppendString(Room.Group.Name);
                GetResponse().AppendString(Room.Group.Badge);
                Response.AppendString("");
            }
            else
            {
                GetResponse().AppendInt32(0);
                GetResponse().AppendString("");
                GetResponse().AppendString("");
                GetResponse().AppendString("");
            }
            GetResponse().AppendInt32(Room.TagCount);
            foreach (string Tag in Room.Tags.ToArray())
            {
                GetResponse().AppendString(Tag);
            }
            //GUESTROOM THUMBNAIL^?  disabled
            GetResponse().AppendInt32(0); //
            GetResponse().AppendInt32(0); //
            GetResponse().AppendInt32(0);
            //GetResponse().AppendInt32(0); loop
            //GUESROOM THUBNAILS ^
            GetResponse().AppendBoolean(Room.AllowPets == 1);
            GetResponse().AppendBoolean(Room.AllowPetsEating == 1);
            GetResponse().AppendString("");  // EVENT related stuff
            GetResponse().AppendString("");  // EVENT related stuff
            GetResponse().AppendInt32(0); // EVENT Time Left, in minutes
            GetResponse().AppendBoolean(!(Room.RoomId == this.Session.GetHabbo().CurrentRoomId)); //forwarding
            GetResponse().AppendBoolean(false);
            GetResponse().AppendBoolean(false);
            GetResponse().AppendBoolean(false);
            GetResponse().AppendInt32(Room.WhoCanMute); // who can mute
            GetResponse().AppendInt32(Room.WhoCanKick); // who can kick
            GetResponse().AppendInt32(Room.WhoCanBan); // who can ban
            GetResponse().AppendBoolean(Room.CheckRights(Session, true));
            GetResponse().AppendInt32(Room.ChatType);  //ChatMode, ChatSize, ChatSpeed, HearingDistance, ExtraFlood is the order.
            GetResponse().AppendInt32(Room.ChatBalloon);
            GetResponse().AppendInt32(Room.ChatSpeed);
            GetResponse().AppendInt32(Room.ChatMaxDistance);
            GetResponse().AppendInt32(Room.ChatFloodProtection);
            SendResponse();

            if (Room.Group == null)
            {

                DataTable Table;
                using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT user_id FROM room_rights WHERE room_id=" + Room.RoomId);
                    Table = dbClient.getTable();
                }

                Response.Init(Outgoing.LoadRoomRightsList);
                GetResponse().AppendInt32(Room.RoomData.Id);
                GetResponse().AppendInt32(Table.Rows.Count);
                foreach (DataRow i in Table.Rows)
                {
                    Habbo xUser = SilverwaveEnvironment.getHabboForId((uint)i[0]);
                    if (xUser != null)
                    {
                        GetResponse().AppendInt32(xUser.Id);
                        GetResponse().AppendString(xUser.Username);
                    }
                }
                SendResponse();
            }
        }
Beispiel #24
0
 internal void UpdateUser(GameClient client)
 {
     this.client = client;
     if (client != null && client.GetHabbo() != null)
         currentRoom = client.GetHabbo().CurrentRoom;
 }
Beispiel #25
0
        internal bool SaveHeightmap(Room room, string heightmap)
        {
            int doorX = 0;
            int doorY = 0;
            int doorDir = 0;
            string doorZ = "";
            string lineSeparator = ((char)0x2028).ToString();
            string paragraphSeparator = ((char)0x2029).ToString();
            string or_heightmap = heightmap;
            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 i = 0;
            int j = 0;
            foreach (string row in rows)
            {
                foreach (char teken in row)
                {
                    if (teken == 'z')
                    {
                        doorX = j;
                        doorY = i;
                    }
                    j++;
                }
                i++;
                j = 0;
            }

            //Calculate the door direction and grab that tile height.
            try
            {
                if (rows[doorY][doorX++] != 'x') //0
                {
                    doorDir = 2;
                    doorZ = rows[doorY][doorX++].ToString();
                }
                else if (rows[doorY++][doorX] != 'x')
                {
                    doorDir = 4;
                    doorZ = rows[doorY++][doorX].ToString();
                }
                else
                    return false;
            }
            catch
            {
                return false;
            }

            using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
            {
                doorZ = fixDoorZ(doorZ);
                if (doorZ == "-1")
                {
                    return false;
                }

                heightmap = heightmap.Replace("z", doorZ);
                if (heightmap.EndsWith("<k>"))
                {
                    heightmap = heightmap.Remove(heightmap.Length - 3);
                }
                heightmap = heightmap.Replace("<k>", "\r\n");
                //Console.WriteLine("ID: " + room.Id + ", doorX: " + doorX + ", doorY:" + doorY + ", doorZ:" + doorZ + ", doorDir:" + doorDir);

                //Insert the room in the room_models table
                try
                {
                    dbClient.setQuery("REPLACE INTO room_models VALUES (@id, @doorX, @doorY, @doorZ, @doorDir, @heightmap, '', '0', '')");
                    dbClient.addParameter("id", room.Id);
                    dbClient.addParameter("doorX", (doorX - 3 >= 0 ? doorX - 3 : 0));
                    dbClient.addParameter("doorY", doorY);
                    dbClient.addParameter("doorZ", doorZ);
                    dbClient.addParameter("doorDir", doorDir);
                    dbClient.addParameter("heightmap", heightmap);
                    dbClient.runQuery();
                    dbClient.runFastQuery("UPDATE rooms SET model_name = " + room.Id + " WHERE id = " + room.Id + " LIMIT 1");
                }
                catch (Exception e)
                {
                    Logging.LogMessage(e.ToString());
                    return false;
                }

                SilverwaveEnvironment.GetGame().GetRoomManager().LoadModels(dbClient);
                room.ReloadSettings(true);
                return true;
            }
        }
Beispiel #26
0
        public void Update(Room Instance)
        {
            if (mIsPlaying && (mSong == null || (TimePlaying >= (mSong.SongData.LengthSeconds + 1))))
            {
                if (mPlaylist.Count == 0)
                {
                    Stop();

                    mRoomOutputItem.ExtraData = "0";
                    mRoomOutputItem.UpdateState();
                }
                else
                {
                    SetNextSong();
                }

                mBroadcastNeeded = true;
            }

            if (mBroadcastNeeded)
            {
                BroadcastCurrentSongData(Instance);
                mBroadcastNeeded = false;
            }
        }