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/ScriptEngine | |
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/ScriptEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 102 |
1 files changed, 49 insertions, 53 deletions
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) |