Exemple #1
0
        /// <summary>
        /// This sets the estateID for the region if the estate password is set right
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void OnChatFromClient(object sender, OSChatMessage e)
        {
            //For Estate Password
            EstateChange Change = null;

            if (ChannelDirectory.TryGetValue(e.Sender.AgentId, out Change))
            {
                //Check whether the channel is right
                if (Change.Channel == e.Channel)
                {
                    ((IClientAPI)sender).OnChatFromClient -= OnChatFromClient;
                    ChannelDirectory.Remove(e.Sender.AgentId);
                    IWorldComm comm = ((Scene)((IClientAPI)sender).Scene).RequestModuleInterface <IWorldComm>();
                    //Unblock the channel now that we have the password
                    comm.RemoveBlockedChannel(Change.Channel);

                    string Password = Util.Md5Hash(e.Message);
                    //Try to switch estates
                    bool changed = DataManager.DataManager.RequestPlugin <IEstateConnector>().LinkRegion(((Scene)((IClientAPI)sender).Scene).RegionInfo.RegionID, (int)Change.EstateID, Password);
                    if (!changed)
                    {
                        //Revert it, it didn't work
                        ((Scene)((IClientAPI)sender).Scene).RegionInfo.EstateSettings.EstateID = Change.OldEstateID;
                        ((IClientAPI)sender).SendAgentAlertMessage("Unable to connect to the given estate.", false);
                    }
                    else
                    {
                        ((Scene)((IClientAPI)sender).Scene).RegionInfo.EstateSettings.EstateID = Change.EstateID;
                        ((Scene)((IClientAPI)sender).Scene).RegionInfo.EstateSettings.Save();
                        ((IClientAPI)sender).SendAgentAlertMessage("Estate Updated.", false);
                    }
                    //Tell the clients to update all references to the new settings
                    foreach (IScenePresence sp in ((IClientAPI)sender).Scene.GetScenePresences())
                    {
                        HandleRegionInfoRequest(sp.ControllingClient, ((Scene)((IClientAPI)sender).Scene));
                    }
                }
            }
        }