public RoomInstance(uint InstanceId, RoomInfo Info, RoomModel Model) { mActorSyncRoot = new object(); mItemSyncRoot = new object(); mInstanceId = InstanceId; mInfo = Info; mActors = new Dictionary <uint, RoomActor>(); mCachedModel = Model; mRelativeHeightmap = string.Empty; mActorIdGenerator = 1; mActorIdGeneratorSyncLock = new object(); mTileStates = new TileState[mCachedModel.Heightmap.SizeX, mCachedModel.Heightmap.SizeY]; mUsersWithRights = new List <uint>(); mBannedUsers = new Dictionary <uint, double>(); mItems = new Dictionary <uint, Item>(); mStaticObjects = new List <StaticObject>(); mItemLimitCache = new Dictionary <ItemBehavior, int>(); mUserGrid = new List <RoomActor> [mCachedModel.Heightmap.SizeX, mCachedModel.Heightmap.SizeY]; mMusicController = new RoomMusicController(); mTemporaryStickieRights = new Dictionary <uint, uint>(); mTradeManager = new TradeManager(); mRollerItems = new List <Item> [mCachedModel.Heightmap.SizeX, mCachedModel.Heightmap.SizeY]; mWiredManager = new WiredManager(this); foreach (Bot Bot in BotManager.GenerateBotInstancesForRoom(RoomId)) { AddBotToRoom(Bot); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { // Items MySqlClient.SetParameter("id", RoomId); DataTable ItemTable = MySqlClient.ExecuteQueryTable("SELECT * FROM items WHERE room_id = @id"); foreach (DataRow Row in ItemTable.Rows) { Item Item = ItemFactory.CreateFromDatabaseRow(Row, mWiredManager); if (Item.PendingExpiration && Item.ExpireTimeLeft <= 0) { Item.RemovePermanently(MySqlClient); continue; } if (Item.InSoundManager) { continue; } mItems.Add(Item.Id, Item); IncrecementFurniLimitCache(Item.Definition.Behavior); ItemEventDispatcher.InvokeItemEventHandler(null, Item, this, ItemEventType.InstanceLoaded); } // Static objects MySqlClient.SetParameter("id", RoomId); DataTable StaticObjectTable = MySqlClient.ExecuteQueryTable("SELECT id,name,position,height,rotation,is_seat FROM static_objects WHERE room_id = @id"); foreach (DataRow Row in StaticObjectTable.Rows) { mStaticObjects.Add(new StaticObject((uint)Row["id"], (string)Row["name"], Vector2.FromString((string)Row["position"]), (int)Row["height"], (int)Row["rotation"], (Row["is_seat"].ToString() == "1"))); } // Rights MySqlClient.SetParameter("id", RoomId); DataTable RightsTable = MySqlClient.ExecuteQueryTable("SELECT user_id FROM room_rights WHERE room_id = @id"); foreach (DataRow Row in RightsTable.Rows) { mUsersWithRights.Add((uint)Row["user_id"]); } // Pets MySqlClient.SetParameter("id", RoomId); DataTable PetsTable = MySqlClient.ExecuteQueryTable("SELECT * FROM pets WHERE room_id = @id"); foreach (DataRow Row in PetsTable.Rows) { Pet PetData = PetFactory.GetPetFromDatabaseRow(Row); AddBotToRoom(BotManager.CreateNewInstance(BotManager.GetHandlerDefinitionForPetType(PetData.Type), RoomId, Vector3.FromString(Row["room_pos"].ToString()), PetData)); } } RegenerateRelativeHeightmap(); mUpdater = new Timer(new TimerCallback(PerformUpdate), null, TimeSpan.FromMilliseconds(500), TimeSpan.FromMilliseconds(500)); }