diff options
author | Teravus Ovares | 2008-04-20 04:19:44 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-04-20 04:19:44 +0000 |
commit | 3358d70c5b174b2b9ac1216e9e43497279982805 (patch) | |
tree | 3b6684a1d58912962eeda8a6b5fd1fc69ae2d00d /OpenSim/Region/Environment | |
parent | * Added experimental "svn load <revision>" command to allow you to load a reg... (diff) | |
download | opensim-SC-3358d70c5b174b2b9ac1216e9e43497279982805.zip opensim-SC-3358d70c5b174b2b9ac1216e9e43497279982805.tar.gz opensim-SC-3358d70c5b174b2b9ac1216e9e43497279982805.tar.bz2 opensim-SC-3358d70c5b174b2b9ac1216e9e43497279982805.tar.xz |
* Updates LSL2CS converter
* All objects are not touchable by default now
* When a script listens for one of the touch events in the state, an object becomes touchable.
* All LSL scripts report which events they consume now
** This uses semi-complicated Regex to discover the events, stick them in a dictionary, and then write a method call into each script state's state_entry() event.
** Tedd may figure out a better way to do this in the future. For now, this works for LSL.
Diffstat (limited to 'OpenSim/Region/Environment')
4 files changed, 149 insertions, 3 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs index 3f14fff..495b604 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -51,6 +51,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
51 | if (part != null) | 51 | if (part != null) |
52 | { | 52 | { |
53 | part.StartScript(itemID); | 53 | part.StartScript(itemID); |
54 | |||
54 | } | 55 | } |
55 | else | 56 | else |
56 | { | 57 | { |
@@ -119,6 +120,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
119 | if (part != null) | 120 | if (part != null) |
120 | { | 121 | { |
121 | part.StopScript(itemID); | 122 | part.StopScript(itemID); |
123 | RemoveScriptEvents(itemID); | ||
122 | } | 124 | } |
123 | else | 125 | else |
124 | { | 126 | { |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 1f38e4f..7abaaee 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | |||
@@ -41,6 +41,40 @@ using OpenSim.Region.Physics.Manager; | |||
41 | 41 | ||
42 | namespace OpenSim.Region.Environment.Scenes | 42 | namespace OpenSim.Region.Environment.Scenes |
43 | { | 43 | { |
44 | |||
45 | [Flags] | ||
46 | public enum scriptEvents : int | ||
47 | { | ||
48 | None = 0, | ||
49 | attach = 1, | ||
50 | collision = 15, | ||
51 | collision_end = 32, | ||
52 | collision_start = 64, | ||
53 | control = 128, | ||
54 | dataserver = 256, | ||
55 | email = 512, | ||
56 | http_response = 1024, | ||
57 | land_collision = 2048, | ||
58 | land_collision_end = 4096, | ||
59 | land_collision_start = 8192, | ||
60 | link_message = 16384, | ||
61 | listen = 32768, | ||
62 | money = 65536, | ||
63 | moving_end = 131072, | ||
64 | moving_start = 262144, | ||
65 | not_at_rot_target = 524288, | ||
66 | not_at_target = 1048576, | ||
67 | remote_data = 8388608, | ||
68 | run_time_permissions = 268435456, | ||
69 | state_entry = 1073741824, | ||
70 | state_exit = 2, | ||
71 | timer = 4, | ||
72 | touch = 8, | ||
73 | touch_end = 536870912, | ||
74 | touch_start = 2097152, | ||
75 | object_rez = 4194304 | ||
76 | } | ||
77 | |||
44 | public delegate void PrimCountTaintedDelegate(); | 78 | public delegate void PrimCountTaintedDelegate(); |
45 | 79 | ||
46 | public partial class SceneObjectGroup : EntityBase | 80 | public partial class SceneObjectGroup : EntityBase |
@@ -67,6 +101,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
67 | private LLVector3 lastPhysGroupPos; | 101 | private LLVector3 lastPhysGroupPos; |
68 | private LLQuaternion lastPhysGroupRot; | 102 | private LLQuaternion lastPhysGroupRot; |
69 | 103 | ||
104 | private Dictionary<LLUUID, scriptEvents> m_scriptEvents = new Dictionary<LLUUID, scriptEvents>(); | ||
105 | private scriptEvents m_aggregateScriptEvents = scriptEvents.None; | ||
106 | |||
70 | #region Properties | 107 | #region Properties |
71 | 108 | ||
72 | /// <summary> | 109 | /// <summary> |
@@ -2042,6 +2079,104 @@ namespace OpenSim.Region.Environment.Scenes | |||
2042 | d.AddActiveScripts(count); | 2079 | d.AddActiveScripts(count); |
2043 | } | 2080 | } |
2044 | 2081 | ||
2082 | public void RemoveScriptEvents(LLUUID scriptid) | ||
2083 | { | ||
2084 | lock (m_scriptEvents) | ||
2085 | { | ||
2086 | if (m_scriptEvents.ContainsKey(scriptid)) | ||
2087 | { | ||
2088 | scriptEvents oldparts = scriptEvents.None; | ||
2089 | oldparts = (scriptEvents)m_scriptEvents[scriptid]; | ||
2090 | |||
2091 | // remove values from aggregated script events | ||
2092 | m_aggregateScriptEvents &= ~oldparts; | ||
2093 | m_scriptEvents.Remove(scriptid); | ||
2094 | } | ||
2095 | |||
2096 | } | ||
2097 | aggregateScriptEvents(); | ||
2098 | } | ||
2099 | |||
2100 | public void SetScriptEvents(LLUUID scriptid, int events) | ||
2101 | { | ||
2102 | |||
2103 | scriptEvents oldparts = scriptEvents.None; | ||
2104 | lock (m_scriptEvents) | ||
2105 | { | ||
2106 | if (m_scriptEvents.ContainsKey(scriptid)) | ||
2107 | { | ||
2108 | oldparts = (scriptEvents)m_scriptEvents[scriptid]; | ||
2109 | |||
2110 | // remove values from aggregated script events | ||
2111 | m_aggregateScriptEvents &= ~oldparts; | ||
2112 | m_scriptEvents[scriptid] = (scriptEvents)events; | ||
2113 | } | ||
2114 | else | ||
2115 | { | ||
2116 | m_scriptEvents.Add(scriptid, (scriptEvents)events); | ||
2117 | } | ||
2118 | |||
2119 | } | ||
2120 | |||
2121 | aggregateScriptEvents(); | ||
2122 | } | ||
2123 | public void aggregateScriptEvents() | ||
2124 | { | ||
2125 | // Aggregate script events | ||
2126 | lock (m_scriptEvents) | ||
2127 | { | ||
2128 | foreach (scriptEvents s in m_scriptEvents.Values) | ||
2129 | { | ||
2130 | m_aggregateScriptEvents |= s; | ||
2131 | } | ||
2132 | } | ||
2133 | uint objectflagupdate = m_rootPart.ObjectFlags; | ||
2134 | |||
2135 | if ( | ||
2136 | ((m_aggregateScriptEvents & scriptEvents.touch) != 0) || | ||
2137 | ((m_aggregateScriptEvents & scriptEvents.touch_end) != 0) || | ||
2138 | ((m_aggregateScriptEvents & scriptEvents.touch_start) != 0) | ||
2139 | ) | ||
2140 | { | ||
2141 | objectflagupdate |= (uint)LLObject.ObjectFlags.Touch; | ||
2142 | } | ||
2143 | else | ||
2144 | { | ||
2145 | objectflagupdate &= ~(uint)LLObject.ObjectFlags.Touch; | ||
2146 | } | ||
2147 | |||
2148 | if ((m_aggregateScriptEvents & scriptEvents.money) != 0) | ||
2149 | { | ||
2150 | objectflagupdate |= (uint)LLObject.ObjectFlags.Money; | ||
2151 | } | ||
2152 | else | ||
2153 | { | ||
2154 | objectflagupdate &= ~(uint)LLObject.ObjectFlags.Money; | ||
2155 | } | ||
2156 | |||
2157 | if ( | ||
2158 | ((m_aggregateScriptEvents & scriptEvents.collision) != 0) || | ||
2159 | ((m_aggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
2160 | ((m_aggregateScriptEvents & scriptEvents.collision_start) != 0) | ||
2161 | ) | ||
2162 | { | ||
2163 | // subscribe to physics updates. | ||
2164 | } | ||
2165 | else | ||
2166 | { | ||
2167 | // unsubscribe to physics updates. | ||
2168 | } | ||
2169 | lock (m_parts) | ||
2170 | { | ||
2171 | foreach (SceneObjectPart part in m_parts.Values) | ||
2172 | { | ||
2173 | part.ObjectFlags = objectflagupdate; | ||
2174 | } | ||
2175 | } | ||
2176 | ScheduleGroupForFullUpdate(); | ||
2177 | |||
2178 | } | ||
2179 | |||
2045 | public override void SetText(string text, Vector3 color, double alpha) | 2180 | public override void SetText(string text, Vector3 color, double alpha) |
2046 | { | 2181 | { |
2047 | Color = Color.FromArgb(0xff - (int) (alpha*0xff), | 2182 | Color = Color.FromArgb(0xff - (int) (alpha*0xff), |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs index 16da516..8ce71c4 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs | |||
@@ -147,6 +147,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
147 | if (10 == item.Type) | 147 | if (10 == item.Type) |
148 | { | 148 | { |
149 | StopScript(item.ItemID); | 149 | StopScript(item.ItemID); |
150 | m_parentGroup.RemoveScriptEvents(item.ItemID); | ||
150 | } | 151 | } |
151 | } | 152 | } |
152 | } | 153 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index b42375f..61d10c9 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -83,6 +83,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
83 | SCALE = 0x40 | 83 | SCALE = 0x40 |
84 | } | 84 | } |
85 | 85 | ||
86 | |||
86 | [Serializable] | 87 | [Serializable] |
87 | public partial class SceneObjectPart : IScriptHost, ISerializable | 88 | public partial class SceneObjectPart : IScriptHost, ISerializable |
88 | { | 89 | { |
@@ -729,8 +730,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
729 | m_folderID = LLUUID.Random(); | 730 | m_folderID = LLUUID.Random(); |
730 | 731 | ||
731 | Flags = 0; | 732 | Flags = 0; |
732 | Flags |= LLObject.ObjectFlags.Touch | | 733 | Flags |= LLObject.ObjectFlags.AllowInventoryDrop | |
733 | LLObject.ObjectFlags.AllowInventoryDrop | | ||
734 | LLObject.ObjectFlags.CreateSelected; | 734 | LLObject.ObjectFlags.CreateSelected; |
735 | 735 | ||
736 | 736 | ||
@@ -774,7 +774,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
774 | 774 | ||
775 | // Since we don't store script state, this is only a 'temporary' objectflag now | 775 | // Since we don't store script state, this is only a 'temporary' objectflag now |
776 | // If the object is scripted, the script will get loaded and this will be set again | 776 | // If the object is scripted, the script will get loaded and this will be set again |
777 | ObjectFlags &= ~(uint)LLObject.ObjectFlags.Scripted; | 777 | ObjectFlags &= ~(uint)(LLObject.ObjectFlags.Scripted | LLObject.ObjectFlags.Touch); |
778 | 778 | ||
779 | TrimPermissions(); | 779 | TrimPermissions(); |
780 | // ApplyPhysics(); | 780 | // ApplyPhysics(); |
@@ -2312,6 +2312,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
2312 | SetText( text ); | 2312 | SetText( text ); |
2313 | } | 2313 | } |
2314 | 2314 | ||
2315 | public void setScriptEvents(LLUUID scriptID, int events) | ||
2316 | { | ||
2317 | if (m_parentGroup != null) | ||
2318 | { | ||
2319 | m_parentGroup.SetScriptEvents(scriptID, events); | ||
2320 | } | ||
2321 | } | ||
2322 | |||
2315 | protected SceneObjectPart(SerializationInfo info, StreamingContext context) | 2323 | protected SceneObjectPart(SerializationInfo info, StreamingContext context) |
2316 | { | 2324 | { |
2317 | //System.Console.WriteLine("SceneObjectPart Deserialize BGN"); | 2325 | //System.Console.WriteLine("SceneObjectPart Deserialize BGN"); |