aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorlbsa712009-03-12 10:50:59 +0000
committerlbsa712009-03-12 10:50:59 +0000
commit33f511ee4b5b4e1f8fe4fbb47d3b5b51e1d0104a (patch)
treeeb1bb1db8b93b4038d8f12d4d7abee2e5071b9fe /OpenSim/Framework
parentMove ArchiveConstants to OpenSim.Framework.Archive (diff)
downloadopensim-SC_OLD-33f511ee4b5b4e1f8fe4fbb47d3b5b51e1d0104a.zip
opensim-SC_OLD-33f511ee4b5b4e1f8fe4fbb47d3b5b51e1d0104a.tar.gz
opensim-SC_OLD-33f511ee4b5b4e1f8fe4fbb47d3b5b51e1d0104a.tar.bz2
opensim-SC_OLD-33f511ee4b5b4e1f8fe4fbb47d3b5b51e1d0104a.tar.xz
* Another stab at refactoring up the CustomiseResponse function. Two fixes:
* Sometimes, null is a valid return value to indicate 'none found'. doh. * Sometimes, the Grid server does not send simURI - this you need to reconstruct yourself. Euw. (I believe) this solves mantis issue #3287
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Communications/LoginService.cs156
-rw-r--r--OpenSim/Framework/RegionInfo.cs3
2 files changed, 149 insertions, 10 deletions
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs
index 36d7280..278ea43 100644
--- a/OpenSim/Framework/Communications/LoginService.cs
+++ b/OpenSim/Framework/Communications/LoginService.cs
@@ -78,15 +78,6 @@ namespace OpenSim.Framework.Communications
78 } 78 }
79 79
80 /// <summary> 80 /// <summary>
81 /// Customises the login response and fills in missing values. This method also tells the login region to
82 /// expect a client connection.
83 /// </summary>
84 /// <param name="response">The existing response</param>
85 /// <param name="theUser">The user profile</param>
86 /// <returns>true on success, false if the region was not successfully told to expect a user connection</returns>
87 public abstract bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest);
88
89 /// <summary>
90 /// If the user is already logged in, try to notify the region that the user they've got is dead. 81 /// If the user is already logged in, try to notify the region that the user they've got is dead.
91 /// </summary> 82 /// </summary>
92 /// <param name="theUser"></param> 83 /// <param name="theUser"></param>
@@ -872,5 +863,152 @@ namespace OpenSim.Framework.Communications
872 m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key); 863 m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key);
873 } 864 }
874 } 865 }
866
867 /// <summary>
868 /// Customises the login response and fills in missing values. This method also tells the login region to
869 /// expect a client connection.
870 /// </summary>
871 /// <param name="response">The existing response</param>
872 /// <param name="theUser">The user profile</param>
873 /// <param name="startLocationRequest">The requested start location</param>
874 /// <returns>true on success, false if the region was not successfully told to expect a user connection</returns>
875 public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest)
876 {
877 // add active gestures to login-response
878 AddActiveGestures(response, theUser);
879
880 // HomeLocation
881 RegionInfo homeInfo = null;
882
883 // use the homeRegionID if it is stored already. If not, use the regionHandle as before
884 UUID homeRegionId = theUser.HomeRegionID;
885 ulong homeRegionHandle = theUser.HomeRegion;
886 if (homeRegionId != UUID.Zero)
887 {
888 homeInfo = GetRegionInfo(homeRegionId);
889 }
890 else
891 {
892 homeInfo = GetRegionInfo(homeRegionHandle);
893 }
894
895 if (homeInfo != null)
896 {
897 response.Home =
898 string.Format(
899 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
900 (homeInfo.RegionLocX * Constants.RegionSize),
901 (homeInfo.RegionLocY * Constants.RegionSize),
902 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
903 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
904 }
905 else
906 {
907 m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY);
908 // Emergency mode: Home-region isn't available, so we can't request the region info.
909 // Use the stored home regionHandle instead.
910 // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again
911 ulong regionX = homeRegionHandle >> 32;
912 ulong regionY = homeRegionHandle & 0xffffffff;
913 response.Home =
914 string.Format(
915 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
916 regionX, regionY,
917 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
918 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
919
920 m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}",
921 theUser.FirstName, theUser.SurName,
922 regionX, regionY);
923 }
924
925 // StartLocation
926 RegionInfo regionInfo = null;
927 if (startLocationRequest == "home")
928 {
929 regionInfo = homeInfo;
930 theUser.CurrentAgent.Position = theUser.HomeLocation;
931 response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]";
932 }
933 else if (startLocationRequest == "last")
934 {
935 UUID lastRegion = theUser.CurrentAgent.Region;
936 regionInfo = GetRegionInfo(lastRegion);
937 response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]";
938 }
939 else
940 {
941 Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$");
942 Match uriMatch = reURI.Match(startLocationRequest);
943 if (uriMatch == null)
944 {
945 m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest);
946 }
947 else
948 {
949 string region = uriMatch.Groups["region"].ToString();
950 regionInfo = RequestClosestRegion(region);
951 if (regionInfo == null)
952 {
953 m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region);
954 }
955 else
956 {
957 theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value),
958 float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value));
959 }
960 }
961 response.LookAt = "[r0,r1,r0]";
962 // can be: last, home, safe, url
963 response.StartLocation = "url";
964 }
965
966 if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response)))
967 {
968 return true;
969 }
970
971 // StartLocation not available, send him to a nearby region instead
972 // regionInfo = m_gridService.RequestClosestRegion("");
973 //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName);
974
975 // Send him to default region instead
976 ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) |
977 ((ulong)m_defaultHomeY * Constants.RegionSize);
978
979 if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle))
980 {
981 m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region");
982 return false;
983 }
984
985 m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead");
986 regionInfo = GetRegionInfo(defaultHandle);
987
988 if( regionInfo == null )
989 {
990 m_log.ErrorFormat("[LOGIN]: No default region available. Aborting.");
991 return false;
992 }
993
994 // Customise the response
995 //response.Home =
996 // string.Format(
997 // "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
998 // (SimInfo.regionLocX * Constants.RegionSize),
999 // (SimInfo.regionLocY*Constants.RegionSize),
1000 // theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
1001 // theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
1002 theUser.CurrentAgent.Position = new Vector3(128, 128, 0);
1003 response.StartLocation = "safe";
1004
1005 return PrepareLoginToRegion(regionInfo, theUser, response);
1006 }
1007
1008 protected abstract RegionInfo RequestClosestRegion(string region);
1009 protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle);
1010 protected abstract RegionInfo GetRegionInfo(UUID homeRegionId);
1011 protected abstract void AddActiveGestures(LoginResponse response, UserProfileData theUser);
1012 protected abstract bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response);
875 } 1013 }
876} 1014}
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index c958c68..202b587 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -676,7 +676,7 @@ namespace OpenSim.Framework
676 proxyUrl = args["proxy_url"].AsString(); 676 proxyUrl = args["proxy_url"].AsString();
677 } 677 }
678 678
679 public static RegionInfo Create(UUID regionID, string regionName, uint regX, uint regY, string externalHostName, uint httpPort, uint simPort, uint remotingPort) 679 public static RegionInfo Create(UUID regionID, string regionName, uint regX, uint regY, string externalHostName, uint httpPort, uint simPort, uint remotingPort, string serverURI)
680 { 680 {
681 RegionInfo regionInfo; 681 RegionInfo regionInfo;
682 IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(externalHostName), (int)simPort); 682 IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(externalHostName), (int)simPort);
@@ -686,6 +686,7 @@ namespace OpenSim.Framework
686 regionInfo.HttpPort = httpPort; 686 regionInfo.HttpPort = httpPort;
687 regionInfo.RegionID = regionID; 687 regionInfo.RegionID = regionID;
688 regionInfo.RegionName = regionName; 688 regionInfo.RegionName = regionName;
689 regionInfo.ServerURI = serverURI;
689 return regionInfo; 690 return regionInfo;
690 } 691 }
691 } 692 }