diff options
author | UbitUmarov | 2017-06-26 00:18:46 +0100 |
---|---|---|
committer | UbitUmarov | 2017-06-26 00:18:46 +0100 |
commit | 041854234429800d6ca10c4987c5d99185552fd6 (patch) | |
tree | 7073a059733da39c9e4f5d85f59f3d5b8ae78bbc /OpenSim/Region | |
parent | change Backup calls overlap control code (diff) | |
download | opensim-SC-041854234429800d6ca10c4987c5d99185552fd6.zip opensim-SC-041854234429800d6ca10c4987c5d99185552fd6.tar.gz opensim-SC-041854234429800d6ca10c4987c5d99185552fd6.tar.bz2 opensim-SC-041854234429800d6ca10c4987c5d99185552fd6.tar.xz |
some shortcuts on local osTeleport, reduce its time penalty, do it with script thread
Diffstat (limited to 'OpenSim/Region')
-rwxr-xr-x | OpenSim/Region/Framework/Scenes/Scene.cs | 44 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 102 |
2 files changed, 79 insertions, 67 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 09b209e..5e8487d 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -4824,16 +4824,34 @@ Label_GroupsDone: | |||
4824 | public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, | 4824 | public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, |
4825 | Vector3 lookat, uint teleportFlags) | 4825 | Vector3 lookat, uint teleportFlags) |
4826 | { | 4826 | { |
4827 | GridRegion region = GridService.GetRegionByName(RegionInfo.ScopeID, regionName); | 4827 | if (EntityTransferModule == null) |
4828 | { | ||
4829 | m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); | ||
4830 | return; | ||
4831 | } | ||
4832 | |||
4833 | ScenePresence sp = GetScenePresence(remoteClient.AgentId); | ||
4834 | if (sp == null || sp.IsDeleted || sp.IsInTransit) | ||
4835 | return; | ||
4828 | 4836 | ||
4829 | if (region == null) | 4837 | ulong regionHandle = 0; |
4838 | if(regionName == RegionInfo.RegionName) | ||
4839 | regionHandle = RegionInfo.RegionHandle; | ||
4840 | else | ||
4841 | { | ||
4842 | GridRegion region = GridService.GetRegionByName(RegionInfo.ScopeID, regionName); | ||
4843 | if (region != null) | ||
4844 | regionHandle = region.RegionHandle; | ||
4845 | } | ||
4846 | |||
4847 | if(regionHandle == 0) | ||
4830 | { | 4848 | { |
4831 | // can't find the region: Tell viewer and abort | 4849 | // can't find the region: Tell viewer and abort |
4832 | remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found."); | 4850 | remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found."); |
4833 | return; | 4851 | return; |
4834 | } | 4852 | } |
4835 | 4853 | ||
4836 | RequestTeleportLocation(remoteClient, region.RegionHandle, position, lookat, teleportFlags); | 4854 | EntityTransferModule.Teleport(sp, regionHandle, position, lookat, teleportFlags); |
4837 | } | 4855 | } |
4838 | 4856 | ||
4839 | /// <summary> | 4857 | /// <summary> |
@@ -4847,19 +4865,17 @@ Label_GroupsDone: | |||
4847 | public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, | 4865 | public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, |
4848 | Vector3 lookAt, uint teleportFlags) | 4866 | Vector3 lookAt, uint teleportFlags) |
4849 | { | 4867 | { |
4850 | ScenePresence sp = GetScenePresence(remoteClient.AgentId); | 4868 | if (EntityTransferModule == null) |
4851 | if (sp != null) | ||
4852 | { | 4869 | { |
4853 | if (EntityTransferModule != null) | 4870 | m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); |
4854 | { | 4871 | return; |
4855 | EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); | ||
4856 | } | ||
4857 | else | ||
4858 | { | ||
4859 | m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); | ||
4860 | sp.ControllingClient.SendTeleportFailed("Unable to perform teleports on this simulator."); | ||
4861 | } | ||
4862 | } | 4872 | } |
4873 | |||
4874 | ScenePresence sp = GetScenePresence(remoteClient.AgentId); | ||
4875 | if (sp == null || sp.IsDeleted || sp.IsInTransit) | ||
4876 | return; | ||
4877 | |||
4878 | EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); | ||
4863 | } | 4879 | } |
4864 | 4880 | ||
4865 | public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying) | 4881 | public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index dee195a..5339fc3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -859,41 +859,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
859 | // | 859 | // |
860 | CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent"); | 860 | CheckThreatLevel(ThreatLevel.Severe, "osTeleportAgent"); |
861 | 861 | ||
862 | TeleportAgent(agent, regionName, position, lookat, false); | 862 | TeleportAgent(agent, regionName, position, lookat); |
863 | } | 863 | } |
864 | 864 | ||
865 | private void TeleportAgent(string agent, string regionName, | 865 | private void TeleportAgent(string agent, string regionName, |
866 | LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions) | 866 | LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) |
867 | { | 867 | { |
868 | m_host.AddScriptLPS(1); | 868 | m_host.AddScriptLPS(1); |
869 | UUID agentId = new UUID(); | 869 | if(String.IsNullOrWhiteSpace(regionName)) |
870 | return; | ||
871 | |||
872 | UUID agentId; | ||
870 | if (UUID.TryParse(agent, out agentId)) | 873 | if (UUID.TryParse(agent, out agentId)) |
871 | { | 874 | { |
872 | ScenePresence presence = World.GetScenePresence(agentId); | 875 | ScenePresence presence = World.GetScenePresence(agentId); |
873 | if (presence != null) | 876 | if (presence == null || presence.IsDeleted || presence.IsInTransit) |
874 | { | 877 | return; |
875 | // For osTeleportAgent, agent must be over owners land to avoid abuse | ||
876 | // For osTeleportOwner, this restriction isn't necessary | ||
877 | |||
878 | // commented out because its redundant and uneeded please remove eventually. | ||
879 | // if (relaxRestrictions || | ||
880 | // m_host.OwnerID | ||
881 | // == World.LandChannel.GetLandObject( | ||
882 | // presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | ||
883 | // { | ||
884 | |||
885 | // We will launch the teleport on a new thread so that when the script threads are terminated | ||
886 | // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. | ||
887 | Util.FireAndForget( | ||
888 | o => World.RequestTeleportLocation( | ||
889 | presence.ControllingClient, regionName, position, | ||
890 | lookat, (uint)TPFlags.ViaLocation), | ||
891 | null, "OSSL_Api.TeleportAgentByRegionCoords"); | ||
892 | |||
893 | ScriptSleep(5000); | ||
894 | |||
895 | // } | ||
896 | 878 | ||
879 | if(regionName == World.RegionInfo.RegionName) | ||
880 | { | ||
881 | // should be faster than going to threadpool | ||
882 | World.RequestTeleportLocation(presence.ControllingClient, regionName, position, | ||
883 | lookat, (uint)TPFlags.ViaLocation); | ||
884 | ScriptSleep(500); | ||
885 | } | ||
886 | else | ||
887 | { | ||
888 | // We will launch the teleport on a new thread so that when the script threads are terminated | ||
889 | // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. | ||
890 | Util.FireAndForget( | ||
891 | o => World.RequestTeleportLocation( | ||
892 | presence.ControllingClient, regionName, position, | ||
893 | lookat, (uint)TPFlags.ViaLocation), | ||
894 | null, "OSSL_Api.TeleportAgentByRegionCoords"); | ||
895 | ScriptSleep(5000); | ||
897 | } | 896 | } |
898 | } | 897 | } |
899 | } | 898 | } |
@@ -913,41 +912,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
913 | ulong regionHandle = Util.RegionGridLocToHandle((uint)regionGridX, (uint)regionGridY); | 912 | ulong regionHandle = Util.RegionGridLocToHandle((uint)regionGridX, (uint)regionGridY); |
914 | 913 | ||
915 | m_host.AddScriptLPS(1); | 914 | m_host.AddScriptLPS(1); |
916 | UUID agentId = new UUID(); | 915 | UUID agentId; |
917 | if (UUID.TryParse(agent, out agentId)) | 916 | if (UUID.TryParse(agent, out agentId)) |
918 | { | 917 | { |
919 | ScenePresence presence = World.GetScenePresence(agentId); | 918 | ScenePresence presence = World.GetScenePresence(agentId); |
920 | if (presence != null) | 919 | if (presence == null || presence.IsDeleted || presence.IsInTransit) |
921 | { | 920 | return; |
922 | // For osTeleportAgent, agent must be over owners land to avoid abuse | ||
923 | // For osTeleportOwner, this restriction isn't necessary | ||
924 | |||
925 | // commented out because its redundant and uneeded please remove eventually. | ||
926 | // if (relaxRestrictions || | ||
927 | // m_host.OwnerID | ||
928 | // == World.LandChannel.GetLandObject( | ||
929 | // presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | ||
930 | // { | ||
931 | |||
932 | // We will launch the teleport on a new thread so that when the script threads are terminated | ||
933 | // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. | ||
934 | Util.FireAndForget( | ||
935 | o => World.RequestTeleportLocation( | ||
936 | presence.ControllingClient, regionHandle, | ||
937 | position, lookat, (uint)TPFlags.ViaLocation), | ||
938 | null, "OSSL_Api.TeleportAgentByRegionName"); | ||
939 | |||
940 | ScriptSleep(5000); | ||
941 | 921 | ||
942 | // } | 922 | Util.FireAndForget( |
923 | o => World.RequestTeleportLocation( | ||
924 | presence.ControllingClient, regionHandle, | ||
925 | position, lookat, (uint)TPFlags.ViaLocation), | ||
926 | null, "OSSL_Api.TeleportAgentByRegionName"); | ||
943 | 927 | ||
944 | } | 928 | ScriptSleep(5000); |
945 | } | 929 | } |
946 | } | 930 | } |
947 | 931 | ||
948 | public void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) | 932 | public void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) |
949 | { | 933 | { |
950 | osTeleportAgent(agent, World.RegionInfo.RegionName, position, lookat); | 934 | m_host.AddScriptLPS(1); |
935 | |||
936 | UUID agentId; | ||
937 | if (UUID.TryParse(agent, out agentId)) | ||
938 | { | ||
939 | ScenePresence presence = World.GetScenePresence(agentId); | ||
940 | if (presence == null || presence.IsDeleted || presence.IsInTransit) | ||
941 | return; | ||
942 | |||
943 | World.RequestTeleportLocation(presence.ControllingClient, World.RegionInfo.RegionName, position, | ||
944 | lookat, (uint)TPFlags.ViaLocation); | ||
945 | ScriptSleep(500); | ||
946 | } | ||
951 | } | 947 | } |
952 | 948 | ||
953 | public void osTeleportOwner(string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) | 949 | public void osTeleportOwner(string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) |
@@ -955,12 +951,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
955 | // Threat level None because this is what can already be done with the World Map in the viewer | 951 | // Threat level None because this is what can already be done with the World Map in the viewer |
956 | CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); | 952 | CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); |
957 | 953 | ||
958 | TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat, true); | 954 | TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat); |
959 | } | 955 | } |
960 | 956 | ||
961 | public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) | 957 | public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) |
962 | { | 958 | { |
963 | osTeleportOwner(World.RegionInfo.RegionName, position, lookat); | 959 | osTeleportAgent(m_host.OwnerID.ToString(), position, lookat); |
964 | } | 960 | } |
965 | 961 | ||
966 | public void osTeleportOwner(int regionGridX, int regionGridY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) | 962 | public void osTeleportOwner(int regionGridX, int regionGridY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) |