diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs index 81e30c933d..350996835c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs @@ -94,14 +94,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public string cmDetectedCountry(int number) { m_host.AddScriptLPS(1); + if(!m_CMFunctionsEnabled) + return String.Empty; + if(World.UserAccountService == null) + return String.Empty; DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number); if (detectedParams == null) return String.Empty; - return detectedParams.Country; + UUID key = detectedParams.Key; + if(key == UUID.Zero) + return String.Empty; + UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, key); + return account.UserCountry; } public string cmGetAgentCountry(LSL_Key key) { + if(! m_CMFunctionsEnabled) + return ""; + if(World.UserAccountService == null) + return String.Empty; if (!World.Permissions.IsGod(m_host.OwnerID)) return String.Empty; diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs index e44a106404..d30a1c4e03 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs @@ -121,7 +121,6 @@ namespace OpenSim.Region.ScriptEngine.Shared Type = 0; Velocity = new LSL_Types.Vector3(); initializeSurfaceTouch(); - Country = String.Empty; } public UUID Key; @@ -153,8 +152,6 @@ namespace OpenSim.Region.ScriptEngine.Shared private int touchFace; public int TouchFace { get { return touchFace; } } - public string Country; - // This can be done in two places including the constructor // so be carefull what gets added here private void initializeSurfaceTouch() @@ -202,9 +199,6 @@ namespace OpenSim.Region.ScriptEngine.Shared return; Name = presence.Firstname + " " + presence.Lastname; - UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, Key); - if (account != null) - Country = account.UserCountry; Owner = Key; Position = new LSL_Types.Vector3(presence.AbsolutePosition);