HGScene.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * Copyright (c) 2008, Contributors. All rights reserved.
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * * Redistributions of source code must retain the above copyright notice,
  9. * this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. * * Neither the name of the Organizations nor the names of Individual
  14. * Contributors may be used to endorse or promote products derived from
  15. * this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  20. * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  21. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  22. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  23. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  25. * OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *
  27. */
  28. using System;
  29. using System.Collections.Generic;
  30. using OpenMetaverse;
  31. using OpenSim.Framework;
  32. using OpenSim.Framework.Communications.Cache;
  33. using OpenSim.Region.Environment;
  34. using OpenSim.Region.Environment.Scenes;
  35. using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
  36. namespace OpenSim.Region.Environment.Scenes.Hypergrid
  37. {
  38. public partial class HGScene : Scene
  39. {
  40. /// <summary>
  41. /// Teleport an avatar to their home region
  42. /// </summary>
  43. /// <param name="agentId"></param>
  44. /// <param name="client"></param>
  45. public override void TeleportClientHome(UUID agentId, IClientAPI client)
  46. {
  47. m_log.Debug("[HGScene]: TeleportClientHome " + client.FirstName + " " + client.LastName);
  48. CachedUserInfo uinfo = CommsManager.UserProfileCacheService.GetUserDetails(agentId);
  49. if (uinfo != null)
  50. {
  51. UserProfileData UserProfile = uinfo.UserProfile;
  52. if (UserProfile != null)
  53. {
  54. RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion);
  55. //if (regionInfo != null)
  56. //{
  57. // UserProfile.HomeRegionID = regionInfo.RegionID;
  58. // //CommsManager.UserService.UpdateUserProfile(UserProfile);
  59. //}
  60. if (regionInfo == null)
  61. {
  62. // can't find the Home region: Tell viewer and abort
  63. client.SendTeleportFailed("Your home-region could not be found.");
  64. return;
  65. }
  66. RequestTeleportLocation(
  67. client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt,
  68. (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome));
  69. }
  70. }
  71. else
  72. client.SendTeleportFailed("Sorry! I lost your home-region information.");
  73. }
  74. }
  75. }