aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorAdam Frisby2008-04-23 11:53:16 +0000
committerAdam Frisby2008-04-23 11:53:16 +0000
commit163d254bb917d8e3fac6a86724fa908e35fc02c8 (patch)
tree172976b603ca7305efe1c2feda1df02b1fe615e6 /OpenSim
parent* Applying Mantis #1020 (Animations) - Thanks Melanie. (diff)
downloadopensim-SC_OLD-163d254bb917d8e3fac6a86724fa908e35fc02c8.zip
opensim-SC_OLD-163d254bb917d8e3fac6a86724fa908e35fc02c8.tar.gz
opensim-SC_OLD-163d254bb917d8e3fac6a86724fa908e35fc02c8.tar.bz2
opensim-SC_OLD-163d254bb917d8e3fac6a86724fa908e35fc02c8.tar.xz
* Applying Mantis #1021 (llStartAnimation/llStopAnimation) - Thanks Melanie!
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/TaskInventoryItem.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs229
3 files changed, 216 insertions, 17 deletions
diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs
index 5453eb3..1eff696 100644
--- a/OpenSim/Framework/TaskInventoryItem.cs
+++ b/OpenSim/Framework/TaskInventoryItem.cs
@@ -214,6 +214,8 @@ namespace OpenSim.Framework
214 public string Name = String.Empty; 214 public string Name = String.Empty;
215 public string Description = String.Empty; 215 public string Description = String.Empty;
216 public uint CreationDate = 0; 216 public uint CreationDate = 0;
217 public LLUUID PermsGranter;
218 public int PermsMask;
217 219
218 public LLUUID ParentPartID = LLUUID.Zero; 220 public LLUUID ParentPartID = LLUUID.Zero;
219 221
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 40a9fcf..48ca582 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -103,7 +103,7 @@ namespace OpenSim.Region.Environment.Scenes
103 private PhysicsVector m_lastRotationalVelocity = PhysicsVector.Zero; 103 private PhysicsVector m_lastRotationalVelocity = PhysicsVector.Zero;
104 private Vector3 m_sitTargetPosition = new Vector3(0, 0, 0); 104 private Vector3 m_sitTargetPosition = new Vector3(0, 0, 0);
105 private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1); 105 private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1);
106 private LLUUID m_sitTargetAvatar = LLUUID.Zero; 106 public LLUUID m_sitTargetAvatar = LLUUID.Zero;
107 107
108 #region Permissions 108 #region Permissions
109 109
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index f4a3bd3..a8eb824 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -118,6 +118,51 @@ namespace OpenSim.Region.ScriptEngine.Common
118 return World.GetCommander(name); 118 return World.GetCommander(name);
119 } 119 }
120 120
121 private LLUUID InventorySelf()
122 {
123 LLUUID invItemID=new LLUUID();
124
125 foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
126 {
127 if(inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
128 {
129 invItemID=inv.Key;
130 break;
131 }
132 }
133
134 return invItemID;
135 }
136
137 private LLUUID InventoryKey(string name, int type)
138 {
139 m_host.AddScriptLPS(1);
140 foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
141 {
142 if(inv.Value.Name == name)
143 {
144 if(inv.Value.Type != type)
145 return LLUUID.Zero;
146
147 return inv.Value.AssetID.ToString();
148 }
149 }
150 return LLUUID.Zero;
151 }
152
153 private LLUUID InventoryKey(string name)
154 {
155 m_host.AddScriptLPS(1);
156 foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
157 {
158 if(inv.Value.Name == name)
159 {
160 return inv.Value.AssetID.ToString();
161 }
162 }
163 return LLUUID.Zero;
164 }
165
121 //These are the implementations of the various ll-functions used by the LSL scripts. 166 //These are the implementations of the various ll-functions used by the LSL scripts.
122 //starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07 167 //starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07
123 public double llSin(double f) 168 public double llSin(double f)
@@ -890,12 +935,23 @@ namespace OpenSim.Region.ScriptEngine.Common
890 public void llSetTexture(string texture, int face) 935 public void llSetTexture(string texture, int face)
891 { 936 {
892 m_host.AddScriptLPS(1); 937 m_host.AddScriptLPS(1);
938
939 LLUUID textureID=new LLUUID();
940
941 if(!LLUUID.TryParse(texture, out textureID))
942 {
943 textureID=InventoryKey(texture, (int)AssetType.Texture);
944 }
945
946 if(textureID == LLUUID.Zero)
947 return;
948
893 LLObject.TextureEntry tex = m_host.Shape.Textures; 949 LLObject.TextureEntry tex = m_host.Shape.Textures;
894 950
895 if (face > -1) 951 if (face > -1)
896 { 952 {
897 LLObject.TextureEntryFace texface = tex.CreateFace((uint)face); 953 LLObject.TextureEntryFace texface = tex.CreateFace((uint)face);
898 texface.TextureID = new LLUUID(texture); 954 texface.TextureID = textureID;
899 tex.FaceTextures[face] = texface; 955 tex.FaceTextures[face] = texface;
900 m_host.UpdateTexture(tex); 956 m_host.UpdateTexture(tex);
901 return; 957 return;
@@ -906,10 +962,10 @@ namespace OpenSim.Region.ScriptEngine.Common
906 { 962 {
907 if (tex.FaceTextures[i] != null) 963 if (tex.FaceTextures[i] != null)
908 { 964 {
909 tex.FaceTextures[i].TextureID = new LLUUID(texture); 965 tex.FaceTextures[i].TextureID = textureID;
910 } 966 }
911 } 967 }
912 tex.DefaultTexture.TextureID = new LLUUID(texture); 968 tex.DefaultTexture.TextureID = textureID;
913 m_host.UpdateTexture(tex); 969 m_host.UpdateTexture(tex);
914 return; 970 return;
915 } 971 }
@@ -1781,13 +1837,58 @@ namespace OpenSim.Region.ScriptEngine.Common
1781 public void llStartAnimation(string anim) 1837 public void llStartAnimation(string anim)
1782 { 1838 {
1783 m_host.AddScriptLPS(1); 1839 m_host.AddScriptLPS(1);
1784 NotImplemented("llStartAnimation"); 1840
1841 LLUUID invItemID=InventorySelf();
1842 if(invItemID == LLUUID.Zero)
1843 return;
1844
1845 if(m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero)
1846 return;
1847
1848 if((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
1849 {
1850 // Do NOT try to parse LLUUID, animations cannot be triggered by ID
1851 LLUUID animID=InventoryKey(anim, (int)AssetType.Animation);
1852 if(animID == LLUUID.Zero)
1853 return;
1854
1855 if (World.m_innerScene.ScenePresences.ContainsKey(m_host.TaskInventory[invItemID].PermsGranter))
1856 {
1857 ScenePresence presence = World.m_innerScene.ScenePresences[m_host.TaskInventory[invItemID].PermsGranter];
1858 presence.AddAnimation(animID);
1859 }
1860 }
1785 } 1861 }
1786 1862
1787 public void llStopAnimation(string anim) 1863 public void llStopAnimation(string anim)
1788 { 1864 {
1789 m_host.AddScriptLPS(1); 1865 m_host.AddScriptLPS(1);
1790 NotImplemented("llStopAnimation"); 1866
1867 LLUUID invItemID=InventorySelf();
1868 if(invItemID == LLUUID.Zero)
1869 return;
1870
1871 if(m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero)
1872 return;
1873
1874 if((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
1875 {
1876 LLUUID animID = new LLUUID();
1877
1878 if(!LLUUID.TryParse(anim, out animID))
1879 {
1880 animID=InventoryKey(anim);
1881 }
1882
1883 if(animID == LLUUID.Zero)
1884 return;
1885
1886 if (World.m_innerScene.ScenePresences.ContainsKey(m_host.TaskInventory[invItemID].PermsGranter))
1887 {
1888 ScenePresence presence = World.m_innerScene.ScenePresences[m_host.TaskInventory[invItemID].PermsGranter];
1889 presence.RemoveAnimation(animID);
1890 }
1891 }
1791 } 1892 }
1792 1893
1793 public void llPointAt() 1894 public void llPointAt()
@@ -1826,21 +1927,108 @@ namespace OpenSim.Region.ScriptEngine.Common
1826 1927
1827 public void llRequestPermissions(string agent, int perm) 1928 public void llRequestPermissions(string agent, int perm)
1828 { 1929 {
1930 LLUUID agentID=new LLUUID();
1931
1932 if(!LLUUID.TryParse(agent, out agentID))
1933 return;
1934
1935 LLUUID invItemID=InventorySelf();
1936
1937 if(invItemID == LLUUID.Zero)
1938 return; // Not in a prim? How??
1939
1940 if(agentID == LLUUID.Zero || perm == 0) // Releasing permissions
1941 {
1942 m_host.TaskInventory[invItemID].PermsGranter=LLUUID.Zero;
1943 m_host.TaskInventory[invItemID].PermsMask=0;
1944
1945 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
1946 m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {(int)0});
1947
1948 return;
1949 }
1950
1829 m_host.AddScriptLPS(1); 1951 m_host.AddScriptLPS(1);
1830 NotImplemented("llRequestPermissions"); 1952
1953 // Cannot combine debit with anything else since the new debit perms dialog has been introduced.
1954 if((perm & BuiltIn_Commands_BaseClass.PERMISSION_DEBIT) != 0 &&
1955 perm != BuiltIn_Commands_BaseClass.PERMISSION_DEBIT)
1956 perm &= ~BuiltIn_Commands_BaseClass.PERMISSION_DEBIT;// Silently ignore debit request
1957
1958 bool attachment=false; // Attachments not implemented yet. TODO: reflect real attachemnt state
1959
1960 if(attachment && agent == m_host.OwnerID)
1961 {
1962 // When attached, certain permissions are implicit if requested from owner
1963 int implicitPerms = BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS |
1964 BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION |
1965 BuiltIn_Commands_BaseClass.PERMISSION_ATTACH;
1966
1967 if((perm & (~implicitPerms)) == 0) // Requested only implicit perms
1968 {
1969 m_host.TaskInventory[invItemID].PermsGranter=agentID;
1970 m_host.TaskInventory[invItemID].PermsMask=perm;
1971
1972 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
1973 m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {(int)perm});
1974
1975 return;
1976 }
1977 }
1978 else if(m_host.m_sitTargetAvatar == agentID) // Sitting avatar
1979 {
1980 // When agent is sitting, certain permissions are implicit if requested from sitting agent
1981 int implicitPerms = BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION |
1982 BuiltIn_Commands_BaseClass.PERMISSION_TRACK_CAMERA;
1983
1984 if((perm & (~implicitPerms)) == 0) // Requested only implicit perms
1985 {
1986 m_host.TaskInventory[invItemID].PermsGranter=agentID;
1987 m_host.TaskInventory[invItemID].PermsMask=perm;
1988
1989 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
1990 m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {(int)perm});
1991
1992 return;
1993 }
1994 }
1995
1996 // TODO: Implement perms dialog sending
1997
1998 // Refuse perms for now
1999 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
2000 m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {(int)0});
2001
2002 NotImplemented("llRequestPermissions");
1831 } 2003 }
1832 2004
1833 public string llGetPermissionsKey() 2005 public string llGetPermissionsKey()
1834 { 2006 {
1835 m_host.AddScriptLPS(1); 2007 m_host.AddScriptLPS(1);
1836 NotImplemented("llGetPermissionsKey"); 2008
1837 return String.Empty; 2009 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
2010 {
2011 if(item.Type == 10 && item.ItemID == m_itemID)
2012 {
2013 return item.PermsGranter.ToString();
2014 }
2015 }
2016
2017 return LLUUID.Zero.ToString();
1838 } 2018 }
1839 2019
1840 public int llGetPermissions() 2020 public int llGetPermissions()
1841 { 2021 {
1842 m_host.AddScriptLPS(1); 2022 m_host.AddScriptLPS(1);
1843 NotImplemented("llGetPermissions"); 2023
2024 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
2025 {
2026 if(item.Type == 10 && item.ItemID == m_itemID)
2027 {
2028 return item.PermsMask;
2029 }
2030 }
2031
1844 return 0; 2032 return 0;
1845 } 2033 }
1846 2034
@@ -2292,14 +2480,23 @@ namespace OpenSim.Region.ScriptEngine.Common
2292 2480
2293 case (int)BuiltIn_Commands_BaseClass.LINK_THIS: 2481 case (int)BuiltIn_Commands_BaseClass.LINK_THIS:
2294 2482
2295 Object[] respObjThis = new object[] 2483 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
2296 { 2484 {
2297 m_host.LinkNum + 1, num, msg, id 2485 if (item.Type == 10)
2298 }; 2486 {
2487 partItemID = item.ItemID;
2299 2488
2300 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 2489 object[] resobj = new object[]
2301 m_localID, m_itemID, "link_message", EventQueueManager.llDetectNull, respObjThis 2490 {
2302 ); 2491 m_host.LinkNum + 1, num, msg, id
2492 };
2493
2494 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
2495 m_localID, partItemID, "link_message", EventQueueManager.llDetectNull, resobj
2496 );
2497
2498 }
2499 }
2303 2500
2304 break; 2501 break;
2305 2502