From 48f8b884c33ba5f5b7991d1047f4f2f988eb7415 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 11 May 2013 07:15:09 -0700 Subject: [PATCH] Handle SetHome properly --- .../World/Land/LandManagementModule.cs | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 693de1dff4..c295f3a078 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -74,6 +74,8 @@ namespace OpenSim.Region.CoreModules.World.Land protected IUserManagement m_userManager; protected IPrimCountModule m_primCountModule; + protected IDialogModule m_Dialog; + protected IGroupsModule m_Groups; // Minimum for parcels to work is 64m even if we don't actually use them. #pragma warning disable 0429 @@ -153,6 +155,8 @@ namespace OpenSim.Region.CoreModules.World.Land { m_userManager = m_scene.RequestModuleInterface(); m_primCountModule = m_scene.RequestModuleInterface(); + m_Dialog = m_scene.RequestModuleInterface(); + m_Groups = m_scene.RequestModuleInterface(); } public void RemoveRegion(Scene scene) @@ -212,6 +216,7 @@ namespace OpenSim.Region.CoreModules.World.Land client.OnPreAgentUpdate += ClientOnPreAgentUpdate; client.OnParcelEjectUser += ClientOnParcelEjectUser; client.OnParcelFreezeUser += ClientOnParcelFreezeUser; + client.OnSetStartLocationRequest += ClientOnSetHome; EntityBase presenceEntity; @@ -1823,6 +1828,60 @@ namespace OpenSim.Region.CoreModules.World.Land } } + /// + /// Sets the Home Point. The LoginService uses this to know where to put a user when they log-in + /// + /// + /// + /// + /// + /// + public virtual void ClientOnSetHome(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) + { + m_log.DebugFormat("[XXX]: SetHome"); + // Let's find the parcel in question + ILandObject land = landChannel.GetLandObject(position); + if (land == null || m_scene.GridUserService == null) + { + m_Dialog.SendAlertToUser(remoteClient, "Set Home request Failed."); + return; + } + + // Can the user set home here? + bool canSetHome = false; + // (a) land owners can set home + if (remoteClient.AgentId == land.LandData.OwnerID) + canSetHome = true; + // (b) members of land-owned group in roles that can set home + if (land.LandData.IsGroupOwned && m_Groups != null) + { + ulong gpowers = remoteClient.GetGroupPowers(land.LandData.GroupID); + m_log.DebugFormat("[XXX]: GroupPowers 0x{0:x16}", gpowers); + if ((gpowers & (ulong)GroupPowers.AllowSetHome) == 1) + canSetHome = true; + } + // (c) parcels with telehubs can be the home of anyone + if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero) + { + // If the telehub in this parcel? + SceneObjectGroup telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject); + if (telehub != null && land.ContainsPoint((int)telehub.AbsolutePosition.X, (int)telehub.AbsolutePosition.Y)) + canSetHome = true; + } + + if (canSetHome) + { + if (m_scene.GridUserService != null && m_scene.GridUserService.SetHome(remoteClient.AgentId.ToString(), land.RegionUUID, position, lookAt)) + // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. + m_Dialog.SendAlertToUser(remoteClient, "Home position set."); + else + m_Dialog.SendAlertToUser(remoteClient, "Set Home request Failed."); + } + else + m_Dialog.SendAlertToUser(remoteClient, "You are not allowed to set your home location in this parcel."); + } + + protected void InstallInterfaces() { Command clearCommand