diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 204 |
1 files changed, 145 insertions, 59 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index b2c8dfd..2b6f80b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -606,7 +606,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
606 | 606 | ||
607 | if (m_storageManager.EstateDataStore != null) | 607 | if (m_storageManager.EstateDataStore != null) |
608 | { | 608 | { |
609 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID); | 609 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); |
610 | if (m_regInfo.EstateSettings.EstateID == 0) // No record at all | ||
611 | { | ||
612 | MainConsole.Instance.Output("Your region is not part of an estate."); | ||
613 | while (true) | ||
614 | { | ||
615 | string response = MainConsole.Instance.CmdPrompt("Do you wish to join an existing estate?", "no", new List<string>() {"yes", "no"}); | ||
616 | if (response == "no") | ||
617 | { | ||
618 | // Create a new estate | ||
619 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, true); | ||
620 | |||
621 | m_regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", m_regInfo.EstateSettings.EstateName); | ||
622 | m_regInfo.EstateSettings.Save(); | ||
623 | break; | ||
624 | } | ||
625 | else | ||
626 | { | ||
627 | response = MainConsole.Instance.CmdPrompt("Estate name to join", "None"); | ||
628 | if (response == "None") | ||
629 | continue; | ||
630 | |||
631 | List<int> estateIDs = m_storageManager.EstateDataStore.GetEstates(response); | ||
632 | if (estateIDs.Count < 1) | ||
633 | { | ||
634 | MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); | ||
635 | continue; | ||
636 | } | ||
637 | |||
638 | int estateID = estateIDs[0]; | ||
639 | |||
640 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(estateID); | ||
641 | |||
642 | if (m_storageManager.EstateDataStore.LinkRegion(m_regInfo.RegionID, estateID)) | ||
643 | break; | ||
644 | |||
645 | MainConsole.Instance.Output("Joining the estate failed. Please try again."); | ||
646 | } | ||
647 | } | ||
648 | } | ||
610 | } | 649 | } |
611 | 650 | ||
612 | //Bind Storage Manager functions to some land manager functions for this scene | 651 | //Bind Storage Manager functions to some land manager functions for this scene |
@@ -1229,6 +1268,84 @@ namespace OpenSim.Region.Framework.Scenes | |||
1229 | m_dialogModule = RequestModuleInterface<IDialogModule>(); | 1268 | m_dialogModule = RequestModuleInterface<IDialogModule>(); |
1230 | m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); | 1269 | m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); |
1231 | m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); | 1270 | m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); |
1271 | |||
1272 | // Shoving this in here for now, because we have the needed | ||
1273 | // interfaces at this point | ||
1274 | // | ||
1275 | // TODO: Find a better place for this | ||
1276 | // | ||
1277 | while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) | ||
1278 | { | ||
1279 | MainConsole.Instance.Output("The current estate has no owner set."); | ||
1280 | string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test"); | ||
1281 | string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User"); | ||
1282 | |||
1283 | UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last); | ||
1284 | |||
1285 | if (account == null) | ||
1286 | { | ||
1287 | // Create a new account | ||
1288 | account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty); | ||
1289 | if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) | ||
1290 | { | ||
1291 | account.ServiceURLs = new Dictionary<string, object>(); | ||
1292 | account.ServiceURLs["HomeURI"] = string.Empty; | ||
1293 | account.ServiceURLs["GatekeeperURI"] = string.Empty; | ||
1294 | account.ServiceURLs["InventoryServerURI"] = string.Empty; | ||
1295 | account.ServiceURLs["AssetServerURI"] = string.Empty; | ||
1296 | } | ||
1297 | |||
1298 | if (UserAccountService.StoreUserAccount(account)) | ||
1299 | { | ||
1300 | string password = MainConsole.Instance.PasswdPrompt("Password"); | ||
1301 | string email = MainConsole.Instance.CmdPrompt("Email", ""); | ||
1302 | |||
1303 | account.Email = email; | ||
1304 | UserAccountService.StoreUserAccount(account); | ||
1305 | |||
1306 | bool success = false; | ||
1307 | success = AuthenticationService.SetPassword(account.PrincipalID, password); | ||
1308 | if (!success) | ||
1309 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.", | ||
1310 | first, last); | ||
1311 | |||
1312 | GridRegion home = null; | ||
1313 | if (GridService != null) | ||
1314 | { | ||
1315 | List<GridRegion> defaultRegions = GridService.GetDefaultRegions(UUID.Zero); | ||
1316 | if (defaultRegions != null && defaultRegions.Count >= 1) | ||
1317 | home = defaultRegions[0]; | ||
1318 | |||
1319 | if (PresenceService != null && home != null) | ||
1320 | PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); | ||
1321 | else | ||
1322 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", | ||
1323 | first, last); | ||
1324 | |||
1325 | } | ||
1326 | else | ||
1327 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.", | ||
1328 | first, last); | ||
1329 | |||
1330 | if (InventoryService != null) | ||
1331 | success = InventoryService.CreateUserInventory(account.PrincipalID); | ||
1332 | if (!success) | ||
1333 | m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", | ||
1334 | first, last); | ||
1335 | |||
1336 | |||
1337 | m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last); | ||
1338 | |||
1339 | m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; | ||
1340 | m_regInfo.EstateSettings.Save(); | ||
1341 | } | ||
1342 | } | ||
1343 | else | ||
1344 | { | ||
1345 | m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; | ||
1346 | m_regInfo.EstateSettings.Save(); | ||
1347 | } | ||
1348 | } | ||
1232 | } | 1349 | } |
1233 | 1350 | ||
1234 | #endregion | 1351 | #endregion |
@@ -3296,7 +3413,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3296 | } | 3413 | } |
3297 | } | 3414 | } |
3298 | 3415 | ||
3299 | ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID); | 3416 | ScenePresence sp = GetScenePresence(agent.AgentID); |
3300 | if (sp != null) | 3417 | if (sp != null) |
3301 | { | 3418 | { |
3302 | m_log.DebugFormat( | 3419 | m_log.DebugFormat( |
@@ -3594,8 +3711,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3594 | /// <param name="message">message to display to the user. Reason for being logged off</param> | 3711 | /// <param name="message">message to display to the user. Reason for being logged off</param> |
3595 | public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) | 3712 | public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) |
3596 | { | 3713 | { |
3597 | ScenePresence loggingOffUser = null; | 3714 | ScenePresence loggingOffUser = GetScenePresence(AvatarID); |
3598 | loggingOffUser = GetScenePresence(AvatarID); | ||
3599 | if (loggingOffUser != null) | 3715 | if (loggingOffUser != null) |
3600 | { | 3716 | { |
3601 | UUID localRegionSecret = UUID.Zero; | 3717 | UUID localRegionSecret = UUID.Zero; |
@@ -3631,8 +3747,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3631 | /// <param name="isFlying"></param> | 3747 | /// <param name="isFlying"></param> |
3632 | public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) | 3748 | public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) |
3633 | { | 3749 | { |
3634 | ScenePresence presence; | 3750 | ScenePresence presence = GetScenePresence(agentID); |
3635 | if(m_sceneGraph.TryGetAvatar(agentID, out presence)) | 3751 | if(presence != null) |
3636 | { | 3752 | { |
3637 | try | 3753 | try |
3638 | { | 3754 | { |
@@ -3806,8 +3922,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3806 | public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, | 3922 | public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, |
3807 | Vector3 lookAt, uint teleportFlags) | 3923 | Vector3 lookAt, uint teleportFlags) |
3808 | { | 3924 | { |
3809 | ScenePresence sp; | 3925 | ScenePresence sp = GetScenePresence(remoteClient.AgentId); |
3810 | if(m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp)) | 3926 | if (sp != null) |
3811 | { | 3927 | { |
3812 | uint regionX = m_regInfo.RegionLocX; | 3928 | uint regionX = m_regInfo.RegionLocX; |
3813 | uint regionY = m_regInfo.RegionLocY; | 3929 | uint regionY = m_regInfo.RegionLocY; |
@@ -3985,17 +4101,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
3985 | m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", | 4101 | m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", |
3986 | "Agent ID", "Session ID", "Circuit", "IP", "World"); | 4102 | "Agent ID", "Session ID", "Circuit", "IP", "World"); |
3987 | 4103 | ||
3988 | foreach (ScenePresence scenePresence in GetAvatars()) | 4104 | ForEachScenePresence(delegate(ScenePresence sp) |
3989 | { | 4105 | { |
3990 | m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", | 4106 | m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", |
3991 | scenePresence.Firstname, | 4107 | sp.Firstname, |
3992 | scenePresence.Lastname, | 4108 | sp.Lastname, |
3993 | scenePresence.UUID, | 4109 | sp.UUID, |
3994 | scenePresence.ControllingClient.AgentId, | 4110 | sp.ControllingClient.AgentId, |
3995 | "Unknown", | 4111 | "Unknown", |
3996 | "Unknown", | 4112 | "Unknown", |
3997 | RegionInfo.RegionName); | 4113 | RegionInfo.RegionName); |
3998 | } | 4114 | }); |
3999 | 4115 | ||
4000 | break; | 4116 | break; |
4001 | } | 4117 | } |
@@ -4161,72 +4277,42 @@ namespace OpenSim.Region.Framework.Scenes | |||
4161 | m_sceneGraph.RemovePhysicalPrim(num); | 4277 | m_sceneGraph.RemovePhysicalPrim(num); |
4162 | } | 4278 | } |
4163 | 4279 | ||
4164 | //The idea is to have a group of method that return a list of avatars meeting some requirement | 4280 | public int GetRootAgentCount() |
4165 | // ie it could be all m_scenePresences within a certain range of the calling prim/avatar. | ||
4166 | // | ||
4167 | // GetAvatars returns a new list of all root agent presences in the scene | ||
4168 | // GetScenePresences returns a new list of all presences in the scene or a filter may be passed. | ||
4169 | // GetScenePresence returns the presence with matching UUID or first/last name. | ||
4170 | // ForEachScenePresence requests the Scene to run a delegate function against all presences. | ||
4171 | |||
4172 | /// <summary> | ||
4173 | /// Return a list of all avatars in this region. | ||
4174 | /// This list is a new object, so it can be iterated over without locking. | ||
4175 | /// </summary> | ||
4176 | /// <returns></returns> | ||
4177 | public List<ScenePresence> GetAvatars() | ||
4178 | { | 4281 | { |
4179 | return m_sceneGraph.GetAvatars(); | 4282 | return m_sceneGraph.GetRootAgentCount(); |
4180 | } | 4283 | } |
4181 | 4284 | ||
4182 | /// <summary> | 4285 | public int GetChildAgentCount() |
4183 | /// Return a list of all ScenePresences in this region. This returns child agents as well as root agents. | ||
4184 | /// This list is a new object, so it can be iterated over without locking. | ||
4185 | /// </summary> | ||
4186 | /// <returns></returns> | ||
4187 | public List<ScenePresence> GetScenePresences() | ||
4188 | { | 4286 | { |
4189 | return m_sceneGraph.GetScenePresences(); | 4287 | return m_sceneGraph.GetChildAgentCount(); |
4190 | } | 4288 | } |
4191 | 4289 | ||
4192 | /// <summary> | 4290 | /// <summary> |
4193 | /// Request a filtered list of ScenePresences in this region. | 4291 | /// Request a scene presence by UUID. Fast, indexed lookup. |
4194 | /// This list is a new object, so it can be iterated over without locking. | ||
4195 | /// </summary> | 4292 | /// </summary> |
4196 | /// <param name="filter"></param> | 4293 | /// <param name="agentID"></param> |
4197 | /// <returns></returns> | 4294 | /// <returns>null if the presence was not found</returns> |
4198 | public List<ScenePresence> GetScenePresences(FilterAvatarList filter) | 4295 | public ScenePresence GetScenePresence(UUID agentID) |
4199 | { | ||
4200 | return m_sceneGraph.GetScenePresences(filter); | ||
4201 | } | ||
4202 | |||
4203 | /// <summary> | ||
4204 | /// Request a scene presence by UUID | ||
4205 | /// </summary> | ||
4206 | /// <param name="avatarID"></param> | ||
4207 | /// <returns></returns> | ||
4208 | public ScenePresence GetScenePresence(UUID avatarID) | ||
4209 | { | 4296 | { |
4210 | return m_sceneGraph.GetScenePresence(avatarID); | 4297 | return m_sceneGraph.GetScenePresence(agentID); |
4211 | } | 4298 | } |
4212 | 4299 | ||
4213 | /// <summary> | 4300 | /// <summary> |
4214 | /// Request the ScenePresence in this region by first/last name. | 4301 | /// Request the scene presence by name. |
4215 | /// Should normally only be a single match, but first is always returned | ||
4216 | /// </summary> | 4302 | /// </summary> |
4217 | /// <param name="firstName"></param> | 4303 | /// <param name="firstName"></param> |
4218 | /// <param name="lastName"></param> | 4304 | /// <param name="lastName"></param> |
4219 | /// <returns></returns> | 4305 | /// <returns>null if the presence was not found</returns> |
4220 | public ScenePresence GetScenePresence(string firstName, string lastName) | 4306 | public ScenePresence GetScenePresence(string firstName, string lastName) |
4221 | { | 4307 | { |
4222 | return m_sceneGraph.GetScenePresence(firstName, lastName); | 4308 | return m_sceneGraph.GetScenePresence(firstName, lastName); |
4223 | } | 4309 | } |
4224 | 4310 | ||
4225 | /// <summary> | 4311 | /// <summary> |
4226 | /// Request the ScenePresence in this region by localID. | 4312 | /// Request the scene presence by localID. |
4227 | /// </summary> | 4313 | /// </summary> |
4228 | /// <param name="localID"></param> | 4314 | /// <param name="localID"></param> |
4229 | /// <returns></returns> | 4315 | /// <returns>null if the presence was not found</returns> |
4230 | public ScenePresence GetScenePresence(uint localID) | 4316 | public ScenePresence GetScenePresence(uint localID) |
4231 | { | 4317 | { |
4232 | return m_sceneGraph.GetScenePresence(localID); | 4318 | return m_sceneGraph.GetScenePresence(localID); |
@@ -4318,9 +4404,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4318 | return m_sceneGraph.GetGroupByPrim(localID); | 4404 | return m_sceneGraph.GetGroupByPrim(localID); |
4319 | } | 4405 | } |
4320 | 4406 | ||
4321 | public override bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) | 4407 | public override bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) |
4322 | { | 4408 | { |
4323 | return m_sceneGraph.TryGetAvatar(avatarId, out avatar); | 4409 | return m_sceneGraph.TryGetScenePresence(avatarId, out avatar); |
4324 | } | 4410 | } |
4325 | 4411 | ||
4326 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) | 4412 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) |