aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-09-16 17:48:57 +0000
committerJustin Clarke Casey2008-09-16 17:48:57 +0000
commitc6dfc99f22efb5d8644819e38c8e6f59cf59768f (patch)
treeeeb5ae7603bedc5a566f4bd5ba5a3f97749ebdcf /OpenSim/Region
parent* Add Y. Nitta to OpenSim contributors (diff)
downloadopensim-SC-c6dfc99f22efb5d8644819e38c8e6f59cf59768f.zip
opensim-SC-c6dfc99f22efb5d8644819e38c8e6f59cf59768f.tar.gz
opensim-SC-c6dfc99f22efb5d8644819e38c8e6f59cf59768f.tar.bz2
opensim-SC-c6dfc99f22efb5d8644819e38c8e6f59cf59768f.tar.xz
* Apply http://opensimulator.org/mantis/view.php?id=2203
* Implementation of LSL llBreakLink and llBreakAllLinks * Thanks Y. Nitta!
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs69
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs70
2 files changed, 135 insertions, 4 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index 76b88bc..a74f304 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -2986,13 +2986,78 @@ namespace OpenSim.Region.ScriptEngine.Common
2986 public void llBreakLink(int linknum) 2986 public void llBreakLink(int linknum)
2987 { 2987 {
2988 m_host.AddScriptLPS(1); 2988 m_host.AddScriptLPS(1);
2989 NotImplemented("llBreakLink"); 2989 UUID invItemID = InventorySelf();
2990 if ((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_CHANGE_LINKS) == 0)
2991 {
2992 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
2993 return;
2994 }
2995 if (linknum < BuiltIn_Commands_BaseClass.LINK_THIS)
2996 return;
2997 SceneObjectGroup parentPrim = m_host.ParentGroup;
2998 SceneObjectPart childPrim = null;
2999 switch(linknum)
3000 {
3001 case BuiltIn_Commands_BaseClass.LINK_ROOT:
3002 break;
3003 case BuiltIn_Commands_BaseClass.LINK_SET:
3004 case BuiltIn_Commands_BaseClass.LINK_ALL_OTHERS:
3005 case BuiltIn_Commands_BaseClass.LINK_ALL_CHILDREN:
3006 case BuiltIn_Commands_BaseClass.LINK_THIS:
3007 foreach(SceneObjectPart part in parentPrim.Children.Values)
3008 {
3009 if (part.UUID != m_host.UUID)
3010 {
3011 childPrim = part;
3012 break;
3013 }
3014 }
3015 break;
3016 default:
3017 childPrim = parentPrim.GetLinkNumPart(linknum);
3018 if (childPrim.UUID == m_host.UUID)
3019 childPrim = null;
3020 break;
3021 }
3022 if (linknum == BuiltIn_Commands_BaseClass.LINK_ROOT)
3023 {
3024 // Restructuring Multiple Prims.
3025 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values);
3026 parts.Remove(parentPrim.RootPart);
3027 foreach (SceneObjectPart part in parts)
3028 {
3029 parentPrim.DelinkFromGroup(part.LocalId, true);
3030 }
3031 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
3032 if (parts.Count > 0) {
3033 SceneObjectPart newRoot = parts[0];
3034 parts.Remove(newRoot);
3035 foreach (SceneObjectPart part in parts)
3036 {
3037 part.UpdateFlag = 0;
3038 newRoot.ParentGroup.LinkToGroup(part.ParentGroup);
3039 }
3040 }
3041 }
3042 else
3043 {
3044 if (childPrim == null)
3045 return;
3046 parentPrim.DelinkFromGroup(childPrim.LocalId, true);
3047 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
3048 }
2990 } 3049 }
2991 3050
2992 public void llBreakAllLinks() 3051 public void llBreakAllLinks()
2993 { 3052 {
2994 m_host.AddScriptLPS(1); 3053 m_host.AddScriptLPS(1);
2995 NotImplemented("llBreakAllLinks"); 3054 SceneObjectGroup parentPrim = m_host.ParentGroup;
3055 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values);
3056 parts.Remove(parentPrim.RootPart);
3057 foreach (SceneObjectPart part in parts) {
3058 parentPrim.DelinkFromGroup(part.LocalId, true);
3059 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
3060 }
2996 } 3061 }
2997 3062
2998 public string llGetLinkKey(int linknum) 3063 public string llGetLinkKey(int linknum)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index d5fc9a6..249b4dd 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2830,13 +2830,79 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2830 public void llBreakLink(int linknum) 2830 public void llBreakLink(int linknum)
2831 { 2831 {
2832 m_host.AddScriptLPS(1); 2832 m_host.AddScriptLPS(1);
2833 NotImplemented("llBreakLink"); 2833 UUID invItemID = InventorySelf();
2834 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0)
2835 {
2836 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
2837 return;
2838 }
2839 if (linknum < ScriptBaseClass.LINK_THIS)
2840 return;
2841 SceneObjectGroup parentPrim = m_host.ParentGroup;
2842 SceneObjectPart childPrim = null;
2843 switch(linknum)
2844 {
2845 case ScriptBaseClass.LINK_ROOT:
2846 break;
2847 case ScriptBaseClass.LINK_SET:
2848 case ScriptBaseClass.LINK_ALL_OTHERS:
2849 case ScriptBaseClass.LINK_ALL_CHILDREN:
2850 case ScriptBaseClass.LINK_THIS:
2851 foreach(SceneObjectPart part in parentPrim.Children.Values)
2852 {
2853 if (part.UUID != m_host.UUID)
2854 {
2855 childPrim = part;
2856 break;
2857 }
2858 }
2859 break;
2860 default:
2861 childPrim = parentPrim.GetLinkNumPart(linknum);
2862 if (childPrim.UUID == m_host.UUID)
2863 childPrim = null;
2864 break;
2865 }
2866 if (linknum == ScriptBaseClass.LINK_ROOT)
2867 {
2868 // Restructuring Multiple Prims.
2869 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values);
2870 parts.Remove(parentPrim.RootPart);
2871 foreach (SceneObjectPart part in parts)
2872 {
2873 parentPrim.DelinkFromGroup(part.LocalId, true);
2874 }
2875 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
2876 if (parts.Count > 0) {
2877 SceneObjectPart newRoot = parts[0];
2878 parts.Remove(newRoot);
2879 foreach (SceneObjectPart part in parts)
2880 {
2881 part.UpdateFlag = 0;
2882 newRoot.ParentGroup.LinkToGroup(part.ParentGroup);
2883 }
2884 }
2885 }
2886 else
2887 {
2888 if (childPrim == null)
2889 return;
2890 parentPrim.DelinkFromGroup(childPrim.LocalId, true);
2891 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
2892 }
2834 } 2893 }
2835 2894
2836 public void llBreakAllLinks() 2895 public void llBreakAllLinks()
2837 { 2896 {
2838 m_host.AddScriptLPS(1); 2897 m_host.AddScriptLPS(1);
2839 NotImplemented("llBreakAllLinks"); 2898 SceneObjectGroup parentPrim = m_host.ParentGroup;
2899 List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Children.Values);
2900 parts.Remove(parentPrim.RootPart);
2901 foreach (SceneObjectPart part in parts)
2902 {
2903 parentPrim.DelinkFromGroup(part.LocalId, true);
2904 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
2905 }
2840 } 2906 }
2841 2907
2842 public LSL_Types.LSLString llGetLinkKey(int linknum) 2908 public LSL_Types.LSLString llGetLinkKey(int linknum)