diff options
author | Justin Clark-Casey (justincc) | 2010-03-04 20:08:25 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-03-04 20:08:25 +0000 |
commit | e07548d703798bfd661c1ab89cc3b48c936d0a77 (patch) | |
tree | 90f23640fda71f2b74a181df9cadf56cdabc4b41 | |
parent | compiler warnings revealed that public PlaySoundSlavePrims properties were ch... (diff) | |
download | opensim-SC-e07548d703798bfd661c1ab89cc3b48c936d0a77.zip opensim-SC-e07548d703798bfd661c1ab89cc3b48c936d0a77.tar.gz opensim-SC-e07548d703798bfd661c1ab89cc3b48c936d0a77.tar.bz2 opensim-SC-e07548d703798bfd661c1ab89cc3b48c936d0a77.tar.xz |
move linden notecard parsing from LSL_Api.cs to SLUtil so that region modules can use it
-rw-r--r-- | OpenSim/Framework/SLUtil.cs | 99 | ||||
-rw-r--r-- | OpenSim/Region/Application/ConfigurationLoader.cs | 19 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/EventManager.cs | 30 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 1 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 83 |
5 files changed, 123 insertions, 109 deletions
diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index 9d5c30a..ff5f8b9 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/OpenSim/Framework/SLUtil.cs | |||
@@ -1,4 +1,5 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | ||
2 | using OpenMetaverse; | 3 | using OpenMetaverse; |
3 | 4 | ||
4 | namespace OpenSim.Framework | 5 | namespace OpenSim.Framework |
@@ -181,5 +182,101 @@ namespace OpenSim.Framework | |||
181 | } | 182 | } |
182 | 183 | ||
183 | #endregion SL / file extension / content-type conversions | 184 | #endregion SL / file extension / content-type conversions |
185 | |||
186 | /// <summary> | ||
187 | /// Parse a notecard in Linden format to a string of ordinary text. | ||
188 | /// </summary> | ||
189 | /// <param name="rawInput"></param> | ||
190 | /// <returns></returns> | ||
191 | public static string ParseNotecardToString(string rawInput) | ||
192 | { | ||
193 | return string.Join("\n", ParseNotecardToList(rawInput).ToArray()); | ||
194 | } | ||
195 | |||
196 | /// <summary> | ||
197 | /// Parse a notecard in Linden format to a list of ordinary lines. | ||
198 | /// </summary> | ||
199 | /// <param name="rawInput"></param> | ||
200 | /// <returns></returns> | ||
201 | public static List<string> ParseNotecardToList(string rawInput) | ||
202 | { | ||
203 | string[] input = rawInput.Replace("\r", "").Split('\n'); | ||
204 | int idx = 0; | ||
205 | int level = 0; | ||
206 | List<string> output = new List<string>(); | ||
207 | string[] words; | ||
208 | |||
209 | while (idx < input.Length) | ||
210 | { | ||
211 | if (input[idx] == "{") | ||
212 | { | ||
213 | level++; | ||
214 | idx++; | ||
215 | continue; | ||
216 | } | ||
217 | |||
218 | if (input[idx]== "}") | ||
219 | { | ||
220 | level--; | ||
221 | idx++; | ||
222 | continue; | ||
223 | } | ||
224 | |||
225 | switch (level) | ||
226 | { | ||
227 | case 0: | ||
228 | words = input[idx].Split(' '); // Linden text ver | ||
229 | // Notecards are created *really* empty. Treat that as "no text" (just like after saving an empty notecard) | ||
230 | if (words.Length < 3) | ||
231 | return output; | ||
232 | |||
233 | int version = int.Parse(words[3]); | ||
234 | if (version != 2) | ||
235 | return output; | ||
236 | break; | ||
237 | case 1: | ||
238 | words = input[idx].Split(' '); | ||
239 | if (words[0] == "LLEmbeddedItems") | ||
240 | break; | ||
241 | if (words[0] == "Text") | ||
242 | { | ||
243 | int len = int.Parse(words[2]); | ||
244 | idx++; | ||
245 | |||
246 | int count = -1; | ||
247 | |||
248 | while (count < len) | ||
249 | { | ||
250 | // int l = input[idx].Length; | ||
251 | string ln = input[idx]; | ||
252 | |||
253 | int need = len-count-1; | ||
254 | if (ln.Length > need) | ||
255 | ln = ln.Substring(0, need); | ||
256 | |||
257 | output.Add(ln); | ||
258 | count += ln.Length + 1; | ||
259 | idx++; | ||
260 | } | ||
261 | |||
262 | return output; | ||
263 | } | ||
264 | break; | ||
265 | case 2: | ||
266 | words = input[idx].Split(' '); // count | ||
267 | if (words[0] == "count") | ||
268 | { | ||
269 | int c = int.Parse(words[1]); | ||
270 | if (c > 0) | ||
271 | return output; | ||
272 | break; | ||
273 | } | ||
274 | break; | ||
275 | } | ||
276 | idx++; | ||
277 | } | ||
278 | |||
279 | return output; | ||
280 | } | ||
184 | } | 281 | } |
185 | } | 282 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs index 655c5ca..8f19417 100644 --- a/OpenSim/Region/Application/ConfigurationLoader.cs +++ b/OpenSim/Region/Application/ConfigurationLoader.cs | |||
@@ -164,12 +164,12 @@ namespace OpenSim | |||
164 | m_config.Source = new IniConfigSource(); | 164 | m_config.Source = new IniConfigSource(); |
165 | m_config.Source.Merge(DefaultConfig()); | 165 | m_config.Source.Merge(DefaultConfig()); |
166 | 166 | ||
167 | m_log.Info("[CONFIG] Reading configuration settings"); | 167 | m_log.Info("[CONFIG]: Reading configuration settings"); |
168 | 168 | ||
169 | if (sources.Count == 0) | 169 | if (sources.Count == 0) |
170 | { | 170 | { |
171 | m_log.FatalFormat("[CONFIG] Could not load any configuration"); | 171 | m_log.FatalFormat("[CONFIG]: Could not load any configuration"); |
172 | m_log.FatalFormat("[CONFIG] Did you copy the OpenSim.ini.example file to OpenSim.ini?"); | 172 | m_log.FatalFormat("[CONFIG]: Did you copy the OpenSim.ini.example file to OpenSim.ini?"); |
173 | Environment.Exit(1); | 173 | Environment.Exit(1); |
174 | } | 174 | } |
175 | 175 | ||
@@ -182,8 +182,8 @@ namespace OpenSim | |||
182 | 182 | ||
183 | if (!iniFileExists) | 183 | if (!iniFileExists) |
184 | { | 184 | { |
185 | m_log.FatalFormat("[CONFIG] Could not load any configuration"); | 185 | m_log.FatalFormat("[CONFIG]: Could not load any configuration"); |
186 | m_log.FatalFormat("[CONFIG] Configuration exists, but there was an error loading it!"); | 186 | m_log.FatalFormat("[CONFIG]: Configuration exists, but there was an error loading it!"); |
187 | Environment.Exit(1); | 187 | Environment.Exit(1); |
188 | } | 188 | } |
189 | 189 | ||
@@ -257,20 +257,17 @@ namespace OpenSim | |||
257 | 257 | ||
258 | if (!IsUri(iniPath)) | 258 | if (!IsUri(iniPath)) |
259 | { | 259 | { |
260 | m_log.InfoFormat("[CONFIG] Reading configuration file {0}", | 260 | m_log.InfoFormat("[CONFIG]: Reading configuration file {0}", Path.GetFullPath(iniPath)); |
261 | Path.GetFullPath(iniPath)); | ||
262 | 261 | ||
263 | m_config.Source.Merge(new IniConfigSource(iniPath)); | 262 | m_config.Source.Merge(new IniConfigSource(iniPath)); |
264 | success = true; | 263 | success = true; |
265 | } | 264 | } |
266 | else | 265 | else |
267 | { | 266 | { |
268 | m_log.InfoFormat("[CONFIG] {0} is a http:// URI, fetching ...", | 267 | m_log.InfoFormat("[CONFIG]: {0} is a http:// URI, fetching ...", iniPath); |
269 | iniPath); | ||
270 | 268 | ||
271 | // The ini file path is a http URI | 269 | // The ini file path is a http URI |
272 | // Try to read it | 270 | // Try to read it |
273 | // | ||
274 | try | 271 | try |
275 | { | 272 | { |
276 | XmlReader r = XmlReader.Create(iniPath); | 273 | XmlReader r = XmlReader.Create(iniPath); |
@@ -281,7 +278,7 @@ namespace OpenSim | |||
281 | } | 278 | } |
282 | catch (Exception e) | 279 | catch (Exception e) |
283 | { | 280 | { |
284 | m_log.FatalFormat("[CONFIG] Exception reading config from URI {0}\n" + e.ToString(), iniPath); | 281 | m_log.FatalFormat("[CONFIG]: Exception reading config from URI {0}\n" + e.ToString(), iniPath); |
285 | Environment.Exit(1); | 282 | Environment.Exit(1); |
286 | } | 283 | } |
287 | } | 284 | } |
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index ac04462..f0d346f 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -110,21 +110,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
110 | public event OnSetRootAgentSceneDelegate OnSetRootAgentScene; | 110 | public event OnSetRootAgentSceneDelegate OnSetRootAgentScene; |
111 | 111 | ||
112 | /// <summary> | 112 | /// <summary> |
113 | /// Called when an object is touched/grabbed. | 113 | /// Fired when an object is touched/grabbed. |
114 | /// </summary> | 114 | /// </summary> |
115 | /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of | 115 | /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of |
116 | /// the root part. | 116 | /// the root part. |
117 | public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs); | ||
118 | public event ObjectGrabDelegate OnObjectGrab; | 117 | public event ObjectGrabDelegate OnObjectGrab; |
118 | public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs); | ||
119 | 119 | ||
120 | public event ObjectGrabDelegate OnObjectGrabbing; | 120 | public event ObjectGrabDelegate OnObjectGrabbing; |
121 | public event ObjectDeGrabDelegate OnObjectDeGrab; | 121 | public event ObjectDeGrabDelegate OnObjectDeGrab; |
122 | public event ScriptResetDelegate OnScriptReset; | 122 | public event ScriptResetDelegate OnScriptReset; |
123 | 123 | ||
124 | public event OnPermissionErrorDelegate OnPermissionError; | 124 | public event OnPermissionErrorDelegate OnPermissionError; |
125 | 125 | ||
126 | public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource); | 126 | /// <summary> |
127 | /// Fired when a new script is created. | ||
128 | /// </summary> | ||
127 | public event NewRezScript OnRezScript; | 129 | public event NewRezScript OnRezScript; |
130 | public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource); | ||
128 | 131 | ||
129 | public delegate void RemoveScript(uint localID, UUID itemID); | 132 | public delegate void RemoveScript(uint localID, UUID itemID); |
130 | public event RemoveScript OnRemoveScript; | 133 | public event RemoveScript OnRemoveScript; |
@@ -166,38 +169,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
166 | 169 | ||
167 | public delegate void ClientClosed(UUID clientID, Scene scene); | 170 | public delegate void ClientClosed(UUID clientID, Scene scene); |
168 | 171 | ||
169 | public event ClientClosed OnClientClosed; | 172 | public event ClientClosed OnClientClosed; |
170 | |||
171 | public delegate void ScriptChangedEvent(uint localID, uint change); | ||
172 | 173 | ||
174 | /// <summary> | ||
175 | /// This is fired when a scene object property that a script might be interested in (such as color, scale or | ||
176 | /// inventory) changes. Only enough information is sent for the LSL changed event | ||
177 | /// (see http://lslwiki.net/lslwiki/wakka.php?wakka=changed) | ||
178 | /// </summary> | ||
173 | public event ScriptChangedEvent OnScriptChangedEvent; | 179 | public event ScriptChangedEvent OnScriptChangedEvent; |
180 | public delegate void ScriptChangedEvent(uint localID, uint change); | ||
174 | 181 | ||
175 | public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed); | 182 | public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed); |
176 | |||
177 | public event ScriptControlEvent OnScriptControlEvent; | 183 | public event ScriptControlEvent OnScriptControlEvent; |
178 | 184 | ||
179 | public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos); | 185 | public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos); |
180 | |||
181 | public event ScriptAtTargetEvent OnScriptAtTargetEvent; | 186 | public event ScriptAtTargetEvent OnScriptAtTargetEvent; |
182 | 187 | ||
183 | public delegate void ScriptNotAtTargetEvent(uint localID); | 188 | public delegate void ScriptNotAtTargetEvent(uint localID); |
184 | |||
185 | public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent; | 189 | public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent; |
186 | 190 | ||
187 | public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot); | 191 | public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot); |
188 | |||
189 | public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent; | 192 | public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent; |
190 | 193 | ||
191 | public delegate void ScriptNotAtRotTargetEvent(uint localID); | 194 | public delegate void ScriptNotAtRotTargetEvent(uint localID); |
192 | |||
193 | public event ScriptNotAtRotTargetEvent OnScriptNotAtRotTargetEvent; | 195 | public event ScriptNotAtRotTargetEvent OnScriptNotAtRotTargetEvent; |
194 | 196 | ||
195 | public delegate void ScriptColliding(uint localID, ColliderArgs colliders); | 197 | public delegate void ScriptColliding(uint localID, ColliderArgs colliders); |
196 | |||
197 | public event ScriptColliding OnScriptColliderStart; | 198 | public event ScriptColliding OnScriptColliderStart; |
198 | public event ScriptColliding OnScriptColliding; | 199 | public event ScriptColliding OnScriptColliding; |
199 | public event ScriptColliding OnScriptCollidingEnd; | 200 | public event ScriptColliding OnScriptCollidingEnd; |
200 | |||
201 | public event ScriptColliding OnScriptLandColliderStart; | 201 | public event ScriptColliding OnScriptLandColliderStart; |
202 | public event ScriptColliding OnScriptLandColliding; | 202 | public event ScriptColliding OnScriptLandColliding; |
203 | public event ScriptColliding OnScriptLandColliderEnd; | 203 | public event ScriptColliding OnScriptLandColliderEnd; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 04e3221..77bf6fe 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -637,7 +637,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
637 | m_items[item.ItemID] = item; | 637 | m_items[item.ItemID] = item; |
638 | m_inventorySerial++; | 638 | m_inventorySerial++; |
639 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 639 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
640 | |||
641 | HasInventoryChanged = true; | 640 | HasInventoryChanged = true; |
642 | m_part.ParentGroup.HasGroupChanged = true; | 641 | m_part.ParentGroup.HasGroupChanged = true; |
643 | 642 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index dc4249c..974f91b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -9705,90 +9705,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9705 | 9705 | ||
9706 | Notecard nc = new Notecard(); | 9706 | Notecard nc = new Notecard(); |
9707 | nc.lastRef = DateTime.Now; | 9707 | nc.lastRef = DateTime.Now; |
9708 | nc.text = ParseText(text.Replace("\r", "").Split('\n')); | 9708 | nc.text = SLUtil.ParseNotecardToList(text).ToArray(); |
9709 | m_Notecards[assetID] = nc; | 9709 | m_Notecards[assetID] = nc; |
9710 | } | 9710 | } |
9711 | } | 9711 | } |
9712 | 9712 | ||
9713 | protected static string[] ParseText(string[] input) | ||
9714 | { | ||
9715 | int idx = 0; | ||
9716 | int level = 0; | ||
9717 | List<string> output = new List<string>(); | ||
9718 | string[] words; | ||
9719 | |||
9720 | while (idx < input.Length) | ||
9721 | { | ||
9722 | if (input[idx] == "{") | ||
9723 | { | ||
9724 | level++; | ||
9725 | idx++; | ||
9726 | continue; | ||
9727 | } | ||
9728 | |||
9729 | if (input[idx]== "}") | ||
9730 | { | ||
9731 | level--; | ||
9732 | idx++; | ||
9733 | continue; | ||
9734 | } | ||
9735 | |||
9736 | switch (level) | ||
9737 | { | ||
9738 | case 0: | ||
9739 | words = input[idx].Split(' '); // Linden text ver | ||
9740 | // Notecards are created *really* empty. Treat that as "no text" (just like after saving an empty notecard) | ||
9741 | if (words.Length < 3) | ||
9742 | return new String[0]; | ||
9743 | |||
9744 | int version = int.Parse(words[3]); | ||
9745 | if (version != 2) | ||
9746 | return new String[0]; | ||
9747 | break; | ||
9748 | case 1: | ||
9749 | words = input[idx].Split(' '); | ||
9750 | if (words[0] == "LLEmbeddedItems") | ||
9751 | break; | ||
9752 | if (words[0] == "Text") | ||
9753 | { | ||
9754 | int len = int.Parse(words[2]); | ||
9755 | idx++; | ||
9756 | |||
9757 | int count = -1; | ||
9758 | |||
9759 | while (count < len) | ||
9760 | { | ||
9761 | // int l = input[idx].Length; | ||
9762 | string ln = input[idx]; | ||
9763 | |||
9764 | int need = len-count-1; | ||
9765 | if (ln.Length > need) | ||
9766 | ln = ln.Substring(0, need); | ||
9767 | |||
9768 | output.Add(ln); | ||
9769 | count += ln.Length + 1; | ||
9770 | idx++; | ||
9771 | } | ||
9772 | |||
9773 | return output.ToArray(); | ||
9774 | } | ||
9775 | break; | ||
9776 | case 2: | ||
9777 | words = input[idx].Split(' '); // count | ||
9778 | if (words[0] == "count") | ||
9779 | { | ||
9780 | int c = int.Parse(words[1]); | ||
9781 | if (c > 0) | ||
9782 | return new String[0]; | ||
9783 | break; | ||
9784 | } | ||
9785 | break; | ||
9786 | } | ||
9787 | idx++; | ||
9788 | } | ||
9789 | return output.ToArray(); | ||
9790 | } | ||
9791 | |||
9792 | public static bool IsCached(UUID assetID) | 9713 | public static bool IsCached(UUID assetID) |
9793 | { | 9714 | { |
9794 | lock (m_Notecards) | 9715 | lock (m_Notecards) |
@@ -9844,4 +9765,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9844 | } | 9765 | } |
9845 | } | 9766 | } |
9846 | } | 9767 | } |
9847 | } | 9768 | } \ No newline at end of file |