aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs817
1 files changed, 0 insertions, 817 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs
deleted file mode 100644
index 7b2d229..0000000
--- a/OpenSim/Region/ScriptEngine/Common/OSSL_BuilIn_Commands.cs
+++ /dev/null
@@ -1,817 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections;
29using OpenMetaverse;
30using Nini.Config;
31using OpenSim.Framework.Console;
32using OpenSim.Region.Environment.Interfaces;
33using OpenSim.Region.Environment.Scenes;
34using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
35using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
36//using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL;
37using OpenSim.Region.ScriptEngine.Shared;
38
39namespace OpenSim.Region.ScriptEngine.Common
40{
41 public class OSSL_BuilIn_Commands : LSL_BuiltIn_Commands, OSSL_BuilIn_Commands_Interface
42 {
43 internal ScriptEngineBase.ScriptEngine m_ScriptEngineDirect;
44
45 public OSSL_BuilIn_Commands(ScriptEngineBase.ScriptEngine scriptEngine, SceneObjectPart host, uint localID,
46 UUID itemID)
47 : base(scriptEngine, host, localID, itemID)
48 {
49 m_ScriptEngineDirect = scriptEngine;
50 Prim = new OSSLPrim(this);
51 }
52
53 public OSSLPrim Prim;
54
55 [Serializable]
56 public class OSSLPrim
57 {
58 internal OSSL_BuilIn_Commands OSSL;
59 public OSSLPrim(OSSL_BuilIn_Commands bc)
60 {
61 OSSL = bc;
62 Position = new OSSLPrim_Position(this);
63 Rotation = new OSSLPrim_Rotation(this);
64 }
65
66 public OSSLPrim_Position Position;
67 public OSSLPrim_Rotation Rotation;
68 //public LSL_Types.Vector3 Position
69 //{
70 // get { return OSSL.llGetPos(); }
71 // set { OSSL.llSetPos(value); }
72 //}
73 //public LSL_Types.Quaternion Rotation
74 //{
75 // get { return OSSL.llGetRot(); }
76 // set { OSSL.llSetRot(value); }
77 //}
78 private TextStruct _text;
79 public TextStruct Text
80 {
81 get { return _text; }
82 set
83 {
84 _text = value;
85 OSSL.llSetText(_text.Text, _text.color, _text.alpha);
86 }
87 }
88
89 [Serializable]
90 public struct TextStruct
91 {
92 public string Text;
93 public LSL_Types.Vector3 color;
94 public double alpha;
95 }
96 }
97
98 [Serializable]
99 public class OSSLPrim_Position
100 {
101 private OSSLPrim prim;
102 private LSL_Types.Vector3 Position;
103 public OSSLPrim_Position(OSSLPrim _prim)
104 {
105 prim = _prim;
106 }
107 private void Load()
108 {
109 Position = prim.OSSL.llGetPos();
110 }
111 private void Save()
112 {
113 if (Position.x > 255)
114 Position.x = 255;
115 if (Position.x < 0)
116 Position.x = 0;
117 if (Position.y > 255)
118 Position.y = 255;
119 if (Position.y < 0)
120 Position.y = 0;
121 if (Position.z > 768)
122 Position.z = 768;
123 if (Position.z < 0)
124 Position.z = 0;
125 prim.OSSL.llSetPos(Position);
126 }
127
128 public double x
129 {
130 get
131 {
132 Load();
133 return Position.x;
134 }
135 set
136 {
137 Load();
138 Position.x = value;
139 Save();
140 }
141 }
142 public double y
143 {
144 get
145 {
146 Load();
147 return Position.y;
148 }
149 set
150 {
151 Load();
152 Position.y = value;
153 Save();
154 }
155 }
156 public double z
157 {
158 get
159 {
160 Load();
161 return Position.z;
162 }
163 set
164 {
165 Load();
166 Position.z = value;
167 Save();
168 }
169 }
170 }
171
172 [Serializable]
173 public class OSSLPrim_Rotation
174 {
175 private OSSLPrim prim;
176 private LSL_Types.Quaternion Rotation;
177 public OSSLPrim_Rotation(OSSLPrim _prim)
178 {
179 prim = _prim;
180 }
181 private void Load()
182 {
183 Rotation = prim.OSSL.llGetRot();
184 }
185 private void Save()
186 {
187 prim.OSSL.llSetRot(Rotation);
188 }
189
190 public double x
191 {
192 get
193 {
194 Load();
195 return Rotation.x;
196 }
197 set
198 {
199 Load();
200 Rotation.x = value;
201 Save();
202 }
203 }
204 public double y
205 {
206 get
207 {
208 Load();
209 return Rotation.y;
210 }
211 set
212 {
213 Load();
214 Rotation.y = value;
215 Save();
216 }
217 }
218 public double z
219 {
220 get
221 {
222 Load();
223 return Rotation.z;
224 }
225 set
226 {
227 Load();
228 Rotation.z = value;
229 Save();
230 }
231 }
232 public double s
233 {
234 get
235 {
236 Load();
237 return Rotation.s;
238 }
239 set
240 {
241 Load();
242 Rotation.s = value;
243 Save();
244 }
245 }
246 }
247 //public struct OSSLPrim_Rotation
248 //{
249 // public double X;
250 // public double Y;
251 // public double Z;
252 // public double R;
253 //}
254
255
256 //
257 // OpenSim functions
258 //
259
260 public int osTerrainSetHeight(int x, int y, double val)
261 {
262 m_host.AddScriptLPS(1);
263 if (x > 255 || x < 0 || y > 255 || y < 0)
264 LSLError("osTerrainSetHeight: Coordinate out of bounds");
265
266 if (World.ExternalChecks.ExternalChecksCanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0)))
267 {
268 World.Heightmap[x, y] = val;
269 return 1;
270 }
271 else
272 {
273 return 0;
274 }
275 }
276
277 public double osTerrainGetHeight(int x, int y)
278 {
279 m_host.AddScriptLPS(1);
280 if (x > 255 || x < 0 || y > 255 || y < 0)
281 LSLError("osTerrainGetHeight: Coordinate out of bounds");
282
283 return World.Heightmap[x, y];
284 }
285
286 public int osRegionRestart(double seconds)
287 {
288 m_host.AddScriptLPS(1);
289 if (World.ExternalChecks.ExternalChecksCanIssueEstateCommand(m_host.OwnerID, false))
290 {
291 World.Restart((float)seconds);
292 return 1;
293 }
294 else
295 {
296 return 0;
297 }
298 }
299
300 public void osRegionNotice(string msg)
301 {
302 m_host.AddScriptLPS(1);
303 World.SendGeneralAlert(msg);
304 }
305
306 public void osSetRot(UUID target, Quaternion rotation)
307 {
308 m_host.AddScriptLPS(1);
309 if (World.Entities.ContainsKey(target))
310 {
311 World.Entities[target].Rotation = rotation;
312 }
313 else
314 {
315 LSLError("osSetRot: Invalid target");
316 }
317 }
318
319 public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
320 int timer)
321 {
322 m_host.AddScriptLPS(1);
323 if (dynamicID == String.Empty)
324 {
325 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
326 UUID createdTexture =
327 textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url,
328 extraParams, timer);
329 return createdTexture.ToString();
330 }
331 else
332 {
333 //TODO update existing dynamic textures
334 }
335
336 return UUID.Zero.ToString();
337 }
338
339 public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
340 int timer, int alpha)
341 {
342 m_host.AddScriptLPS(1);
343 if (dynamicID == String.Empty)
344 {
345 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
346 UUID createdTexture =
347 textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url,
348 extraParams, timer, true, (byte) alpha);
349 return createdTexture.ToString();
350 }
351 else
352 {
353 //TODO update existing dynamic textures
354 }
355
356 return UUID.Zero.ToString();
357 }
358
359 public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams,
360 int timer)
361 {
362 m_host.AddScriptLPS(1);
363 if (dynamicID == String.Empty)
364 {
365 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
366 if (textureManager != null)
367 {
368 if (extraParams == String.Empty)
369 {
370 extraParams = "256";
371 }
372 UUID createdTexture =
373 textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data,
374 extraParams, timer);
375 return createdTexture.ToString();
376 }
377 }
378 else
379 {
380 //TODO update existing dynamic textures
381 }
382
383 return UUID.Zero.ToString();
384 }
385
386 public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
387 int timer, int alpha)
388 {
389 m_host.AddScriptLPS(1);
390 if (dynamicID == String.Empty)
391 {
392 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
393 if (textureManager != null)
394 {
395 if (extraParams == String.Empty)
396 {
397 extraParams = "256";
398 }
399 UUID createdTexture =
400 textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data,
401 extraParams, timer, true, (byte) alpha);
402 return createdTexture.ToString();
403 }
404 }
405 else
406 {
407 //TODO update existing dynamic textures
408 }
409
410 return UUID.Zero.ToString();
411 }
412
413 public bool osConsoleCommand(string command)
414 {
415 m_host.AddScriptLPS(1);
416 IConfigSource config = new IniConfigSource(Application.iniFilePath);
417 if (config.Configs["LL-Functions"] == null)
418 config.AddConfig("LL-Functions");
419
420 if (config.Configs["LL-Functions"].GetBoolean("AllowosConsoleCommand", false))
421 {
422 if (World.ExternalChecks.ExternalChecksCanRunConsoleCommand(m_host.OwnerID))
423 {
424 MainConsole.Instance.RunCommand(command);
425 return true;
426 }
427 return false;
428 }
429 return false;
430 }
431 public void osSetPrimFloatOnWater(int floatYN)
432 {
433 m_host.AddScriptLPS(1);
434 if (m_host.ParentGroup != null)
435 {
436 if (m_host.ParentGroup.RootPart != null)
437 {
438 m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN);
439 }
440 }
441 }
442
443 // Teleport functions
444 public void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
445 {
446 m_host.AddScriptLPS(1);
447 UUID agentId = new UUID();
448 if (UUID.TryParse(agent, out agentId))
449 {
450 ScenePresence presence = World.GetScenePresence(agentId);
451 if (presence != null)
452 {
453 // agent must be over owners land to avoid abuse
454 if (m_host.OwnerID == World.GetLandOwner(presence.AbsolutePosition.X, presence.AbsolutePosition.Y))
455 {
456 World.RequestTeleportLocation(presence.ControllingClient, regionName,
457 new Vector3((float)position.x, (float)position.y, (float)position.z),
458 new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation);
459 // ScriptSleep(5000);
460
461 }
462 }
463 }
464 }
465
466 public void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
467 {
468 osTeleportAgent(agent, World.RegionInfo.RegionName, position, lookat);
469 }
470
471 // Adam's super super custom animation functions
472 public void osAvatarPlayAnimation(string avatar, string animation)
473 {
474 m_host.AddScriptLPS(1);
475 if (World.Entities.ContainsKey(avatar) && World.Entities[avatar] is ScenePresence)
476 {
477 ScenePresence target = (ScenePresence)World.Entities[avatar];
478 target.AddAnimation(avatar);
479 }
480 }
481
482 public void osAvatarStopAnimation(string avatar, string animation)
483 {
484 m_host.AddScriptLPS(1);
485 if (World.Entities.ContainsKey(avatar) && World.Entities[avatar] is ScenePresence)
486 {
487 ScenePresence target = (ScenePresence)World.Entities[avatar];
488 target.RemoveAnimation(animation);
489 }
490 }
491
492 //Texture draw functions
493 public string osMovePen(string drawList, int x, int y)
494 {
495 m_host.AddScriptLPS(1);
496 drawList += "MoveTo " + x + "," + y + ";";
497 return drawList;
498 }
499
500 public string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
501 {
502 m_host.AddScriptLPS(1);
503 drawList += "MoveTo "+ startX+","+ startY +"; LineTo "+endX +","+endY +"; ";
504 return drawList;
505 }
506
507 public string osDrawLine(string drawList, int endX, int endY)
508 {
509 m_host.AddScriptLPS(1);
510 drawList += "LineTo " + endX + "," + endY + "; ";
511 return drawList;
512 }
513
514 public string osDrawText(string drawList, string text)
515 {
516 m_host.AddScriptLPS(1);
517 drawList += "Text " + text + "; ";
518 return drawList;
519 }
520
521 public string osDrawEllipse(string drawList, int width, int height)
522 {
523 m_host.AddScriptLPS(1);
524 drawList += "Ellipse " + width + "," + height + "; ";
525 return drawList;
526 }
527
528 public string osDrawRectangle(string drawList, int width, int height)
529 {
530 m_host.AddScriptLPS(1);
531 drawList += "Rectangle " + width + "," + height + "; ";
532 return drawList;
533 }
534
535 public string osDrawFilledRectangle(string drawList, int width, int height)
536 {
537 m_host.AddScriptLPS(1);
538 drawList += "FillRectangle " + width + "," + height + "; ";
539 return drawList;
540 }
541
542 public string osSetFontSize(string drawList, int fontSize)
543 {
544 m_host.AddScriptLPS(1);
545 drawList += "FontSize "+ fontSize +"; ";
546 return drawList;
547 }
548
549 public string osSetPenSize(string drawList, int penSize)
550 {
551 m_host.AddScriptLPS(1);
552 drawList += "PenSize " + penSize + "; ";
553 return drawList;
554 }
555
556 public string osSetPenColour(string drawList, string colour)
557 {
558 m_host.AddScriptLPS(1);
559 drawList += "PenColour " + colour + "; ";
560 return drawList;
561 }
562
563 public string osDrawImage(string drawList, int width, int height, string imageUrl)
564 {
565 m_host.AddScriptLPS(1);
566 drawList +="Image " +width + "," + height+ ","+ imageUrl +"; " ;
567 return drawList;
568 }
569
570 public void osSetStateEvents(int events)
571 {
572 m_host.SetScriptEvents(m_itemID, events);
573 }
574
575 public void osOpenRemoteDataChannel(string channel)
576 {
577 m_host.AddScriptLPS(1);
578 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
579 if (xmlrpcMod.IsEnabled())
580 {
581 UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, new UUID(channel));
582 object[] resobj = new object[] { new LSL_Types.LSLInteger(1), new LSL_Types.LSLString(channelID.ToString()), new LSL_Types.LSLString(UUID.Zero.ToString()), new LSL_Types.LSLString(String.Empty), new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(String.Empty) };
583 m_ScriptEngineDirect.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "remote_data", new DetectParams[0], resobj);
584 }
585 }
586
587 public void osSetParcelMediaURL(string url)
588 {
589 m_host.AddScriptLPS(1);
590 UUID landowner = World.GetLandOwner(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
591
592 if (landowner == UUID.Zero)
593 {
594 return;
595 }
596
597 if (landowner != m_host.ObjectOwner)
598 {
599 return;
600 }
601
602 World.SetLandMediaURL(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, url);
603 }
604
605 public string osGetScriptEngineName()
606 {
607 m_host.AddScriptLPS(1);
608
609 int scriptEngineNameIndex = 0;
610
611 if (!String.IsNullOrEmpty(m_ScriptEngineDirect.ScriptEngineName))
612 {
613 // parse off the "ScriptEngine."
614 scriptEngineNameIndex = m_ScriptEngineDirect.ScriptEngineName.IndexOf(".", scriptEngineNameIndex);
615 scriptEngineNameIndex++; // get past delimiter
616
617 int scriptEngineNameLength = m_ScriptEngineDirect.ScriptEngineName.Length - scriptEngineNameIndex;
618
619 // create char array then a string that is only the script engine name
620 Char[] scriptEngineNameCharArray = m_ScriptEngineDirect.ScriptEngineName.ToCharArray(scriptEngineNameIndex, scriptEngineNameLength);
621 String scriptEngineName = new String(scriptEngineNameCharArray);
622
623 return scriptEngineName;
624 }
625 else
626 {
627 return String.Empty;
628 }
629 }
630
631 //for testing purposes only
632 public void osSetParcelMediaTime(double time)
633 {
634 World.ParcelMediaSetTime((float)time);
635 }
636
637 public Hashtable osParseJSON(string JSON)
638 {
639 m_host.AddScriptLPS(1);
640
641 // see http://www.json.org/ for more details on JSON
642
643 string currentKey=null;
644 Stack objectStack = new Stack(); // objects in JSON can be nested so we need to keep a track of this
645 Hashtable jsondata = new Hashtable(); // the hashtable to be returned
646
647 try
648 {
649
650 // iterate through the serialised stream of tokens and store at the right depth in the hashtable
651 // the top level hashtable may contain more nested hashtables within it each containing an objects representation
652 for (int i=0;i<JSON.Length; i++)
653 {
654
655 // Console.WriteLine(""+JSON[i]);
656 switch (JSON[i])
657 {
658 case '{':
659 // create hashtable and add it to the stack or array if we are populating one, we can have a lot of nested objects in JSON
660
661 Hashtable currentObject = new Hashtable();
662 if (objectStack.Count==0) // the stack should only be empty for the first outer object
663 {
664
665 objectStack.Push(jsondata);
666 }
667 else if (objectStack.Peek().ToString()=="System.Collections.ArrayList")
668 {
669 // add it to the parent array
670 ((ArrayList)objectStack.Peek()).Add(currentObject);
671 objectStack.Push(currentObject);
672 }
673 else
674 {
675 // add it to the parent hashtable
676 ((Hashtable)objectStack.Peek()).Add(currentKey,currentObject);
677 objectStack.Push(currentObject);
678 }
679
680 // clear the key
681 currentKey=null;
682 break;
683 case '}':
684 // pop the hashtable off the stack
685 objectStack.Pop();
686 break;
687 case '"':// string boundary
688
689 string tokenValue="";
690 i++; // move to next char
691
692 // just loop through until the next quote mark storing the string
693 while (JSON[i]!='"')
694 {
695 tokenValue+=JSON[i++];
696 }
697
698 // ok we've got a string, if we've got an array on the top of the stack then we store it
699 if (objectStack.Peek().ToString()=="System.Collections.ArrayList")
700 {
701 ((ArrayList)objectStack.Peek()).Add(tokenValue);
702 }
703 else if (currentKey==null) // no key stored and its not an array this must be a key so store it
704 {
705 currentKey = tokenValue;
706 }
707 else
708 {
709 // we have a key so lets store this value
710 ((Hashtable)objectStack.Peek()).Add(currentKey,tokenValue);
711 // now lets clear the key, we're done with it and moving on
712 currentKey=null;
713 }
714
715 break;
716 case ':':// key : value separator
717 // just ignore
718 break;
719 case ' ':// spaces
720 // just ignore
721 break;
722 case '[': // array start
723 ArrayList currentArray = new ArrayList();
724
725 if (objectStack.Peek().ToString()=="System.Collections.ArrayList")
726 {
727 ((ArrayList)objectStack.Peek()).Add(currentArray);
728 }
729 else
730 {
731 ((Hashtable)objectStack.Peek()).Add(currentKey,currentArray);
732 // clear the key
733 currentKey=null;
734 }
735 objectStack.Push(currentArray);
736
737 break;
738 case ',':// seperator
739 // just ignore
740 break;
741 case ']'://Array end
742 // pop the array off the stack
743 objectStack.Pop();
744 break;
745 case 't': // we've found a character start not in quotes, it must be a boolean true
746
747 if (objectStack.Peek().ToString()=="System.Collections.ArrayList")
748 {
749 ((ArrayList)objectStack.Peek()).Add(true);
750 }
751 else
752 {
753 ((Hashtable)objectStack.Peek()).Add(currentKey,true);
754 }
755
756 //advance the counter to the letter 'e'
757 i = i+3;
758 break;
759 case 'f': // we've found a character start not in quotes, it must be a boolean false
760
761 if (objectStack.Peek().ToString()=="System.Collections.ArrayList")
762 {
763 ((ArrayList)objectStack.Peek()).Add(false);
764 }
765 else
766 {
767 ((Hashtable)objectStack.Peek()).Add(currentKey,false);
768 }
769 //advance the counter to the letter 'e'
770 i = i+4;
771 break;
772
773 default:
774 // ok here we're catching all numeric types int,double,long we might want to spit these up mr accurately
775 // but for now we'll just do them as strings
776
777 string numberValue="";
778
779 // just loop through until the next known marker quote mark storing the string
780 while (JSON[i] != '"' && JSON[i] != ',' && JSON[i] != ']' && JSON[i] != '}' && JSON[i] != ' ')
781 {
782 numberValue+=""+JSON[i++];
783 }
784
785 i--; // we want to process this caracter that marked the end of this string in the main loop
786
787 // ok we've got a string, if we've got an array on the top of the stack then we store it
788 if (objectStack.Peek().ToString()=="System.Collections.ArrayList")
789 {
790 ((ArrayList)objectStack.Peek()).Add(numberValue);
791 }
792 else
793 {
794 // we have a key so lets store this value
795 ((Hashtable)objectStack.Peek()).Add(currentKey,numberValue);
796 // now lets clear the key, we're done with it and moving on
797 currentKey=null;
798 }
799
800 break;
801 }
802 }
803 }
804 catch(Exception)
805 {
806 LSLError("osParseJSON: The JSON string is not valid " + JSON);
807 }
808
809 return jsondata;
810 }
811
812 internal void LSLError(string msg)
813 {
814 throw new Exception("LSL Runtime Error: " + msg);
815 }
816 }
817}