aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common
diff options
context:
space:
mode:
authorMelanie Thielker2008-09-24 13:18:06 +0000
committerMelanie Thielker2008-09-24 13:18:06 +0000
commitfb7a29a5efe70a334ccbf6e82e9ee6e7d481beef (patch)
tree599bf798dae443a82a64f6554694ddbcc845ba98 /OpenSim/Region/ScriptEngine/Common
parentFrom: alan webb (alan_webb@us.ibm.com) (diff)
downloadopensim-SC_OLD-fb7a29a5efe70a334ccbf6e82e9ee6e7d481beef.zip
opensim-SC_OLD-fb7a29a5efe70a334ccbf6e82e9ee6e7d481beef.tar.gz
opensim-SC_OLD-fb7a29a5efe70a334ccbf6e82e9ee6e7d481beef.tar.bz2
opensim-SC_OLD-fb7a29a5efe70a334ccbf6e82e9ee6e7d481beef.tar.xz
Rename lots of stuff in DNE to reduce source code differences in the
LSL implementation files. Rename lots of stuff in XEngine for the same reason. Move methods between interfaces. Just refactor stuff.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs590
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs42
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs8
3 files changed, 360 insertions, 280 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index de7ca08..72a4322 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -68,9 +68,9 @@ namespace OpenSim.Region.ScriptEngine.Common
68 internal uint m_localID; 68 internal uint m_localID;
69 internal UUID m_itemID; 69 internal UUID m_itemID;
70 internal bool throwErrorOnNotImplemented = true; 70 internal bool throwErrorOnNotImplemented = true;
71 internal float m_delayFactor = 1.0f; 71 internal float m_ScriptDelayFactor = 1.0f;
72 internal float m_distanceFactor = 1.0f; 72 internal float m_ScriptDistanceFactor = 1.0f;
73 73 internal AsyncCommandManager AsyncCommands = null;
74 74
75 public LSL_BuiltIn_Commands(ScriptEngineBase.ScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 75 public LSL_BuiltIn_Commands(ScriptEngineBase.ScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
76 { 76 {
@@ -79,6 +79,7 @@ namespace OpenSim.Region.ScriptEngine.Common
79 m_localID = localID; 79 m_localID = localID;
80 m_itemID = itemID; 80 m_itemID = itemID;
81 81
82 AsyncCommands = m_ScriptEngine.m_ASYNCLSLCommandManager;
82 //m_log.Info(ScriptEngineName, "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]"); 83 //m_log.Info(ScriptEngineName, "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]");
83 84
84 85
@@ -86,8 +87,8 @@ namespace OpenSim.Region.ScriptEngine.Common
86 if (config.Configs["LL-Functions"] == null) 87 if (config.Configs["LL-Functions"] == null)
87 config.AddConfig("LL-Functions"); 88 config.AddConfig("LL-Functions");
88 89
89 m_delayFactor = config.Configs["LL-Functions"].GetFloat("ScriptDelayFactor", 1.0f); 90 m_ScriptDelayFactor = config.Configs["LL-Functions"].GetFloat("ScriptDelayFactor", 1.0f);
90 m_distanceFactor = config.Configs["LL-Functions"].GetFloat("ScriptDistanceLimitFactor", 1.0f); 91 m_ScriptDistanceFactor = config.Configs["LL-Functions"].GetFloat("ScriptDistanceLimitFactor", 1.0f);
91 92
92 } 93 }
93 94
@@ -97,7 +98,7 @@ namespace OpenSim.Region.ScriptEngine.Common
97 98
98 protected void ScriptSleep(int delay) 99 protected void ScriptSleep(int delay)
99 { 100 {
100 delay = (int)((float)delay * m_delayFactor); 101 delay = (int)((float)delay * m_ScriptDelayFactor);
101 if (delay == 0) 102 if (delay == 0)
102 return; 103 return;
103 System.Threading.Thread.Sleep(delay); 104 System.Threading.Thread.Sleep(delay);
@@ -281,7 +282,6 @@ namespace OpenSim.Region.ScriptEngine.Common
281 } 282 }
282 283
283 //These are the implementations of the various ll-functions used by the LSL scripts. 284 //These are the implementations of the various ll-functions used by the LSL scripts.
284 //starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07
285 public LSL_Float llSin(double f) 285 public LSL_Float llSin(double f)
286 { 286 {
287 m_host.AddScriptLPS(1); 287 m_host.AddScriptLPS(1);
@@ -710,7 +710,7 @@ namespace OpenSim.Region.ScriptEngine.Common
710 UUID keyID = UUID.Zero; 710 UUID keyID = UUID.Zero;
711 UUID.TryParse(id, out keyID); 711 UUID.TryParse(id, out keyID);
712 712
713 m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host); 713 AsyncCommands.SensorRepeatPlugin.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host);
714 } 714 }
715 715
716 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) 716 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate)
@@ -719,13 +719,13 @@ namespace OpenSim.Region.ScriptEngine.Common
719 UUID keyID = UUID.Zero; 719 UUID keyID = UUID.Zero;
720 UUID.TryParse(id, out keyID); 720 UUID.TryParse(id, out keyID);
721 721
722 m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host); 722 AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host);
723 } 723 }
724 724
725 public void llSensorRemove() 725 public void llSensorRemove()
726 { 726 {
727 m_host.AddScriptLPS(1); 727 m_host.AddScriptLPS(1);
728 m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.UnSetSenseRepeaterEvents(m_localID, m_itemID); 728 AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_localID, m_itemID);
729 } 729 }
730 730
731 public string resolveName(UUID objecUUID) 731 public string resolveName(UUID objecUUID)
@@ -759,7 +759,7 @@ namespace OpenSim.Region.ScriptEngine.Common
759 public LSL_String llDetectedName(int number) 759 public LSL_String llDetectedName(int number)
760 { 760 {
761 m_host.AddScriptLPS(1); 761 m_host.AddScriptLPS(1);
762 LSL_List SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.GetSensorList(m_localID, m_itemID); 762 LSL_List SenseList = AsyncCommands.SensorRepeatPlugin.GetSensorList(m_localID, m_itemID);
763 if (SenseList != null) 763 if (SenseList != null)
764 { 764 {
765 if ((number >= 0) && (number < SenseList.Length)) 765 if ((number >= 0) && (number < SenseList.Length))
@@ -799,7 +799,7 @@ namespace OpenSim.Region.ScriptEngine.Common
799 799
800 public UUID uuidDetectedKey(int number) 800 public UUID uuidDetectedKey(int number)
801 { 801 {
802 LSL_List SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.GetSensorList(m_localID, m_itemID); 802 LSL_List SenseList = AsyncCommands.SensorRepeatPlugin.GetSensorList(m_localID, m_itemID);
803 if (SenseList != null) 803 if (SenseList != null)
804 { 804 {
805 if ((number >= 0) && (number < SenseList.Length)) 805 if ((number >= 0) && (number < SenseList.Length))
@@ -836,7 +836,7 @@ namespace OpenSim.Region.ScriptEngine.Common
836 836
837 public EntityBase entityDetectedKey(int number) 837 public EntityBase entityDetectedKey(int number)
838 { 838 {
839 LSL_List SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.GetSensorList(m_localID, m_itemID); 839 LSL_List SenseList = AsyncCommands.SensorRepeatPlugin.GetSensorList(m_localID, m_itemID);
840 if (SenseList != null) 840 if (SenseList != null)
841 { 841 {
842 if ((number >= 0) && (number < SenseList.Length)) 842 if ((number >= 0) && (number < SenseList.Length))
@@ -1809,9 +1809,9 @@ namespace OpenSim.Region.ScriptEngine.Common
1809 { 1809 {
1810 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) 1810 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
1811 LSL_Vector currentPos = llGetLocalPos(); 1811 LSL_Vector currentPos = llGetLocalPos();
1812 if (llVecDist(currentPos, targetPos) > 10.0f * m_distanceFactor) 1812 if (llVecDist(currentPos, targetPos) > 10.0f * m_ScriptDistanceFactor)
1813 { 1813 {
1814 targetPos = currentPos + m_distanceFactor * 10.0f * llVecNorm(targetPos - currentPos); 1814 targetPos = currentPos + m_ScriptDistanceFactor * 10.0f * llVecNorm(targetPos - currentPos);
1815 } 1815 }
1816 1816
1817 if (part.ParentID != 0) 1817 if (part.ParentID != 0)
@@ -2440,17 +2440,13 @@ namespace OpenSim.Region.ScriptEngine.Common
2440 public void llRezAtRoot(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) 2440 public void llRezAtRoot(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param)
2441 { 2441 {
2442 m_host.AddScriptLPS(1); 2442 m_host.AddScriptLPS(1);
2443
2443 if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) 2444 if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s))
2444 return; 2445 return;
2445 bool found = false;
2446
2447 float dist = (float)llVecDist(llGetPos(), pos); 2446 float dist = (float)llVecDist(llGetPos(), pos);
2448 if (dist > m_distanceFactor * 10.0f)
2449 return;
2450 2447
2451 // Instead of using return;, I'm using continue; because in our TaskInventory implementation 2448 if (dist > m_ScriptDistanceFactor * 10.0f)
2452 // it's possible to have two items with the same task inventory name. 2449 return;
2453 // this is an easter egg of sorts.
2454 2450
2455 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 2451 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
2456 { 2452 {
@@ -2460,7 +2456,7 @@ namespace OpenSim.Region.ScriptEngine.Common
2460 if (inv.Value.InvType != (int)InventoryType.Object) 2456 if (inv.Value.InvType != (int)InventoryType.Object)
2461 { 2457 {
2462 llSay(0, "Unable to create requested object. Object is missing from database."); 2458 llSay(0, "Unable to create requested object. Object is missing from database.");
2463 continue; 2459 return;
2464 } 2460 }
2465 2461
2466 Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); 2462 Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
@@ -2525,7 +2521,7 @@ namespace OpenSim.Region.ScriptEngine.Common
2525 { 2521 {
2526 m_host.AddScriptLPS(1); 2522 m_host.AddScriptLPS(1);
2527 // Setting timer repeat 2523 // Setting timer repeat
2528 m_ScriptEngine.m_ASYNCLSLCommandManager.m_Timer.SetTimerEvent(m_localID, m_itemID, sec); 2524 AsyncCommands.TimerPlugin.SetTimerEvent(m_localID, m_itemID, sec);
2529 } 2525 }
2530 2526
2531 public void llSleep(double sec) 2527 public void llSleep(double sec)
@@ -2686,7 +2682,26 @@ namespace OpenSim.Region.ScriptEngine.Common
2686 public void llGetNextEmail(string address, string subject) 2682 public void llGetNextEmail(string address, string subject)
2687 { 2683 {
2688 m_host.AddScriptLPS(1); 2684 m_host.AddScriptLPS(1);
2689 NotImplemented("llGetNextEmail"); 2685 IEmailModule emailModule = m_ScriptEngine.World.RequestModuleInterface<IEmailModule>();
2686 if (emailModule == null)
2687 return;
2688 Email email;
2689
2690 email = emailModule.GetNextEmail(m_host.UUID, address, subject);
2691
2692 if (email == null)
2693 return;
2694
2695 m_ScriptEngine.PostObjectEvent(m_host.LocalId,
2696 new EventParams("email",
2697 new Object[] {
2698 new LSL_String(email.time),
2699 new LSL_String(email.sender),
2700 new LSL_String(email.subject),
2701 new LSL_String(email.message),
2702 new LSL_Integer(email.numLeft)},
2703 new DetectParams[0]));
2704
2690 } 2705 }
2691 2706
2692 public LSL_String llGetKey() 2707 public LSL_String llGetKey()
@@ -3015,96 +3030,10 @@ namespace OpenSim.Region.ScriptEngine.Common
3015 3030
3016 public void llSetLinkColor(int linknumber, LSL_Vector color, int face) 3031 public void llSetLinkColor(int linknumber, LSL_Vector color, int face)
3017 { 3032 {
3018 m_host.AddScriptLPS(1); 3033 List<SceneObjectPart> parts = GetLinkParts(linknumber);
3019 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknumber); 3034
3020 if (linknumber > -1) 3035 foreach (SceneObjectPart part in parts)
3021 { 3036 SetColor(part, color, face);
3022 Primitive.TextureEntry tex = part.Shape.Textures;
3023 Color4 texcolor;
3024 if (face > -1)
3025 {
3026 texcolor = tex.CreateFace((uint)face).RGBA;
3027 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
3028 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
3029 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
3030 tex.FaceTextures[face].RGBA = texcolor;
3031 part.UpdateTexture(tex);
3032 return;
3033 }
3034 else if (face == -1)
3035 {
3036 texcolor = tex.DefaultTexture.RGBA;
3037 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
3038 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
3039 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
3040 tex.DefaultTexture.RGBA = texcolor;
3041 for (uint i = 0; i < 32; i++)
3042 {
3043 if (tex.FaceTextures[i] != null)
3044 {
3045 texcolor = tex.FaceTextures[i].RGBA;
3046 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
3047 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
3048 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
3049 tex.FaceTextures[i].RGBA = texcolor;
3050 }
3051 }
3052 texcolor = tex.DefaultTexture.RGBA;
3053 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
3054 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
3055 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
3056 tex.DefaultTexture.RGBA = texcolor;
3057 part.UpdateTexture(tex);
3058 return;
3059 }
3060 return;
3061 }
3062 else if (linknumber == -1)
3063 {
3064 int num = m_host.ParentGroup.PrimCount;
3065 for (int w = 0; w < num; w++)
3066 {
3067 linknumber = w;
3068 part = m_host.ParentGroup.GetLinkNumPart(linknumber);
3069 Primitive.TextureEntry tex = part.Shape.Textures;
3070 Color4 texcolor;
3071 if (face > -1)
3072 {
3073 texcolor = tex.CreateFace((uint)face).RGBA;
3074 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
3075 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
3076 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
3077 tex.FaceTextures[face].RGBA = texcolor;
3078 part.UpdateTexture(tex);
3079 }
3080 else if (face == -1)
3081 {
3082 texcolor = tex.DefaultTexture.RGBA;
3083 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
3084 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
3085 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
3086 tex.DefaultTexture.RGBA = texcolor;
3087 for (uint i = 0; i < 32; i++)
3088 {
3089 if (tex.FaceTextures[i] != null)
3090 {
3091 texcolor = tex.FaceTextures[i].RGBA;
3092 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
3093 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
3094 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
3095 tex.FaceTextures[i].RGBA = texcolor;
3096 }
3097 }
3098 texcolor = tex.DefaultTexture.RGBA;
3099 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
3100 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
3101 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
3102 tex.DefaultTexture.RGBA = texcolor;
3103 part.UpdateTexture(tex);
3104 }
3105 }
3106 return;
3107 }
3108 } 3037 }
3109 3038
3110 public void llCreateLink(string target, int parent) 3039 public void llCreateLink(string target, int parent)
@@ -3129,10 +3058,11 @@ namespace OpenSim.Region.ScriptEngine.Common
3129 parentPrim = targetPart.ParentGroup; 3058 parentPrim = targetPart.ParentGroup;
3130 childPrim = m_host.ParentGroup; 3059 childPrim = m_host.ParentGroup;
3131 } 3060 }
3132 byte uf = childPrim.RootPart.UpdateFlag; 3061// byte uf = childPrim.RootPart.UpdateFlag;
3133 childPrim.RootPart.UpdateFlag = 0; 3062 childPrim.RootPart.UpdateFlag = 0;
3134 parentPrim.LinkToGroup(childPrim); 3063 parentPrim.LinkToGroup(childPrim);
3135 childPrim.RootPart.UpdateFlag = uf; 3064// if (uf != (Byte)0)
3065// parent.RootPart.UpdateFlag = uf;
3136 } 3066 }
3137 parentPrim.TriggerScriptChangedEvent(Changed.LINK); 3067 parentPrim.TriggerScriptChangedEvent(Changed.LINK);
3138 parentPrim.RootPart.AddFlag(PrimFlags.CreateSelected); 3068 parentPrim.RootPart.AddFlag(PrimFlags.CreateSelected);
@@ -3423,24 +3353,25 @@ namespace OpenSim.Region.ScriptEngine.Common
3423 3353
3424 switch (data) 3354 switch (data)
3425 { 3355 {
3426 case ScriptBaseClass.DATA_ONLINE: // DATA_ONLINE (0|1) 3356 case 1: // DATA_ONLINE (0|1)
3357 // TODO: implement fetching of this information
3427 if (userProfile.CurrentAgent.AgentOnline) 3358 if (userProfile.CurrentAgent.AgentOnline)
3428 reply = "1"; 3359 reply = "1";
3429 else 3360 else
3430 reply = "0"; 3361 reply = "0";
3431 break; 3362 break;
3432 case ScriptBaseClass.DATA_NAME: // DATA_NAME (First Last) 3363 case 2: // DATA_NAME (First Last)
3433 reply = userProfile.FirstName + " " + userProfile.SurName; 3364 reply = userProfile.FirstName + " " + userProfile.SurName;
3434 break; 3365 break;
3435 case ScriptBaseClass.DATA_BORN: // DATA_BORN (YYYY-MM-DD) 3366 case 3: // DATA_BORN (YYYY-MM-DD)
3436 DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); 3367 DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0);
3437 born = born.AddSeconds(userProfile.Created); 3368 born = born.AddSeconds(userProfile.Created);
3438 reply = born.ToString("yyyy-MM-dd"); 3369 reply = born.ToString("yyyy-MM-dd");
3439 break; 3370 break;
3440 case ScriptBaseClass.DATA_RATING: // DATA_RATING (0,0,0,0,0,0) 3371 case 4: // DATA_RATING (0,0,0,0,0,0)
3441 reply = "0,0,0,0,0,0"; 3372 reply = "0,0,0,0,0,0";
3442 break; 3373 break;
3443 case ScriptBaseClass.DATA_PAYINFO: // DATA_PAYINFO (0|1|2|3) 3374 case 8: // DATA_PAYINFO (0|1|2|3)
3444 reply = "0"; 3375 reply = "0";
3445 break; 3376 break;
3446 default: 3377 default:
@@ -3449,11 +3380,12 @@ namespace OpenSim.Region.ScriptEngine.Common
3449 3380
3450 UUID rq = UUID.Random(); 3381 UUID rq = UUID.Random();
3451 3382
3452 UUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.m_Dataserver.RegisterRequest( 3383 UUID tid = AsyncCommands.
3453 m_localID, m_itemID, rq.ToString()); 3384 DataserverPlugin.RegisterRequest(m_localID,
3385 m_itemID, rq.ToString());
3454 3386
3455 m_ScriptEngine.m_ASYNCLSLCommandManager. 3387 AsyncCommands.
3456 m_Dataserver.DataserverReply(rq.ToString(), reply); 3388 DataserverPlugin.DataserverReply(rq.ToString(), reply);
3457 3389
3458 // ScriptSleep(100); 3390 // ScriptSleep(100);
3459 return tid.ToString(); 3391 return tid.ToString();
@@ -3467,8 +3399,9 @@ namespace OpenSim.Region.ScriptEngine.Common
3467 { 3399 {
3468 if (item.Type == 3 && item.Name == name) 3400 if (item.Type == 3 && item.Name == name)
3469 { 3401 {
3470 UUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.m_Dataserver.RegisterRequest( 3402 UUID tid = AsyncCommands.
3471 m_localID, m_itemID, item.AssetID.ToString()); 3403 DataserverPlugin.RegisterRequest(m_localID,
3404 m_itemID, item.AssetID.ToString());
3472 3405
3473 Vector3 region = new Vector3( 3406 Vector3 region = new Vector3(
3474 World.RegionInfo.RegionLocX * Constants.RegionSize, 3407 World.RegionInfo.RegionLocX * Constants.RegionSize,
@@ -3485,8 +3418,8 @@ namespace OpenSim.Region.ScriptEngine.Common
3485 region = lm.Position + new Vector3(rx, ry, 0) - region; 3418 region = lm.Position + new Vector3(rx, ry, 0) - region;
3486 3419
3487 string reply = region.ToString(); 3420 string reply = region.ToString();
3488 m_ScriptEngine.m_ASYNCLSLCommandManager. 3421 AsyncCommands.
3489 m_Dataserver.DataserverReply(i.ToString(), 3422 DataserverPlugin.DataserverReply(i.ToString(),
3490 reply); 3423 reply);
3491 }, false); 3424 }, false);
3492 3425
@@ -3563,7 +3496,7 @@ namespace OpenSim.Region.ScriptEngine.Common
3563 3496
3564 m_host.AddScriptLPS(1); 3497 m_host.AddScriptLPS(1);
3565 3498
3566 uint partLocalID; 3499 // uint partLocalID;
3567 UUID partItemID; 3500 UUID partItemID;
3568 3501
3569 switch ((int)linknum) 3502 switch ((int)linknum)
@@ -3577,7 +3510,7 @@ namespace OpenSim.Region.ScriptEngine.Common
3577 { 3510 {
3578 if (item.Type == 10) 3511 if (item.Type == 10)
3579 { 3512 {
3580 partLocalID = part.LocalId; 3513 // partLocalID = part.LocalId;
3581 partItemID = item.ItemID; 3514 partItemID = item.ItemID;
3582 3515
3583 object[] resobj = new object[] 3516 object[] resobj = new object[]
@@ -4151,7 +4084,7 @@ namespace OpenSim.Region.ScriptEngine.Common
4151 } 4084 }
4152 catch (KeyNotFoundException) 4085 catch (KeyNotFoundException)
4153 { 4086 {
4154 return id; // The Object/Agent is not in the region so just return the key 4087 return id; // The Object/Agent not in the region so just return the key
4155 } 4088 }
4156 } 4089 }
4157 else 4090 else
@@ -4219,26 +4152,6 @@ namespace OpenSim.Region.ScriptEngine.Common
4219 } 4152 }
4220 } 4153 }
4221 4154
4222 public double osList2Double(LSL_List src, int index)
4223 {
4224 m_host.AddScriptLPS(1);
4225 if (index < 0)
4226 {
4227 index = src.Length + index;
4228 }
4229 if (index >= src.Length)
4230 {
4231 return 0.0;
4232 }
4233 if (src.Data[index] is LSL_Integer)
4234 return Convert.ToDouble(((LSL_Integer) src.Data[index]).value);
4235 else if (src.Data[index] is LSL_Float)
4236 return Convert.ToDouble(((LSL_Float) src.Data[index]).value);
4237 else if (src.Data[index] is LSL_String)
4238 return Convert.ToDouble(((LSL_String) src.Data[index]).m_string);
4239 return Convert.ToDouble(src.Data[index]);
4240 }
4241
4242 public LSL_Float llList2Float(LSL_List src, int index) 4155 public LSL_Float llList2Float(LSL_List src, int index)
4243 { 4156 {
4244 m_host.AddScriptLPS(1); 4157 m_host.AddScriptLPS(1);
@@ -4810,10 +4723,10 @@ namespace OpenSim.Region.ScriptEngine.Common
4810 { 4723 {
4811 m_host.AddScriptLPS(1); 4724 m_host.AddScriptLPS(1);
4812 Primitive.TextureAnimation pTexAnim = new Primitive.TextureAnimation(); 4725 Primitive.TextureAnimation pTexAnim = new Primitive.TextureAnimation();
4813 pTexAnim.Flags =(Primitive.TextureAnimMode)mode; 4726 pTexAnim.Flags = (Primitive.TextureAnimMode)mode;
4814 4727
4815 //ALL_SIDES 4728 //ALL_SIDES
4816 if (face == -1) 4729 if (face == ScriptBaseClass.ALL_SIDES)
4817 face = 255; 4730 face = 255;
4818 4731
4819 pTexAnim.Face = (uint)face; 4732 pTexAnim.Face = (uint)face;
@@ -5176,98 +5089,92 @@ namespace OpenSim.Region.ScriptEngine.Common
5176 switch ((int)rules.Data[i]) 5089 switch ((int)rules.Data[i])
5177 { 5090 {
5178 case (int)ScriptBaseClass.PSYS_PART_FLAGS: 5091 case (int)ScriptBaseClass.PSYS_PART_FLAGS:
5179 prules.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)((uint)Convert.ToInt32(rules.Data[i + 1].ToString())); 5092 prules.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)(uint)rules.GetLSLIntegerItem(i + 1);
5180 break; 5093 break;
5181 5094
5182 case (int)ScriptBaseClass.PSYS_PART_START_COLOR: 5095 case (int)ScriptBaseClass.PSYS_PART_START_COLOR:
5183 tempv = (LSL_Vector)rules.Data[i + 1]; 5096 tempv = rules.GetVector3Item(i + 1);
5184 prules.PartStartColor.R = (float)tempv.x; 5097 prules.PartStartColor.R = (float)tempv.x;
5185 prules.PartStartColor.G = (float)tempv.y; 5098 prules.PartStartColor.G = (float)tempv.y;
5186 prules.PartStartColor.B = (float)tempv.z; 5099 prules.PartStartColor.B = (float)tempv.z;
5187 break; 5100 break;
5188 5101
5189 case (int)ScriptBaseClass.PSYS_PART_START_ALPHA: 5102 case (int)ScriptBaseClass.PSYS_PART_START_ALPHA:
5190 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 5103 tempf = (float)rules.GetLSLFloatItem(i + 1);
5191 prules.PartStartColor.A = (float)tempf; 5104 prules.PartStartColor.A = tempf;
5192 break; 5105 break;
5193 5106
5194 case (int)ScriptBaseClass.PSYS_PART_END_COLOR: 5107 case (int)ScriptBaseClass.PSYS_PART_END_COLOR:
5195 tempv = (LSL_Vector)rules.Data[i + 1]; 5108 tempv = rules.GetVector3Item(i + 1);
5196 //prules.PartEndColor = new Color4(tempv.x,tempv.y,tempv.z,1);
5197
5198 prules.PartEndColor.R = (float)tempv.x; 5109 prules.PartEndColor.R = (float)tempv.x;
5199 prules.PartEndColor.G = (float)tempv.y; 5110 prules.PartEndColor.G = (float)tempv.y;
5200 prules.PartEndColor.B = (float)tempv.z; 5111 prules.PartEndColor.B = (float)tempv.z;
5201 break; 5112 break;
5202 5113
5203 case (int)ScriptBaseClass.PSYS_PART_END_ALPHA: 5114 case (int)ScriptBaseClass.PSYS_PART_END_ALPHA:
5204 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 5115 tempf = (float)rules.GetLSLFloatItem(i + 1);
5205 prules.PartEndColor.A = (float)tempf; 5116 prules.PartEndColor.A = tempf;
5206 break; 5117 break;
5207 5118
5208 case (int)ScriptBaseClass.PSYS_PART_START_SCALE: 5119 case (int)ScriptBaseClass.PSYS_PART_START_SCALE:
5209 tempv = (LSL_Vector)rules.Data[i + 1]; 5120 tempv = rules.GetVector3Item(i + 1);
5210 prules.PartStartScaleX = (float)tempv.x; 5121 prules.PartStartScaleX = (float)tempv.x;
5211 prules.PartStartScaleY = (float)tempv.y; 5122 prules.PartStartScaleY = (float)tempv.y;
5212 break; 5123 break;
5213 5124
5214 case (int)ScriptBaseClass.PSYS_PART_END_SCALE: 5125 case (int)ScriptBaseClass.PSYS_PART_END_SCALE:
5215 tempv = (LSL_Vector)rules.Data[i + 1]; 5126 tempv = rules.GetVector3Item(i + 1);
5216 prules.PartEndScaleX = (float)tempv.x; 5127 prules.PartEndScaleX = (float)tempv.x;
5217 prules.PartEndScaleY = (float)tempv.y; 5128 prules.PartEndScaleY = (float)tempv.y;
5218 break; 5129 break;
5219 5130
5220 case (int)ScriptBaseClass.PSYS_PART_MAX_AGE: 5131 case (int)ScriptBaseClass.PSYS_PART_MAX_AGE:
5221 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 5132 tempf = (float)rules.GetLSLFloatItem(i + 1);
5222 prules.PartMaxAge = (float)tempf; 5133 prules.PartMaxAge = tempf;
5223 break; 5134 break;
5224 5135
5225 case (int)ScriptBaseClass.PSYS_SRC_ACCEL: 5136 case (int)ScriptBaseClass.PSYS_SRC_ACCEL:
5226 tempv = (LSL_Vector)rules.Data[i + 1]; 5137 tempv = rules.GetVector3Item(i + 1);
5227 prules.PartAcceleration.X = (float)tempv.x; 5138 prules.PartAcceleration.X = (float)tempv.x;
5228 prules.PartAcceleration.Y = (float)tempv.y; 5139 prules.PartAcceleration.Y = (float)tempv.y;
5229 prules.PartAcceleration.Z = (float)tempv.z; 5140 prules.PartAcceleration.Z = (float)tempv.z;
5230 break; 5141 break;
5231 5142
5232 case (int)ScriptBaseClass.PSYS_SRC_PATTERN: 5143 case (int)ScriptBaseClass.PSYS_SRC_PATTERN:
5233 int tmpi = int.Parse(rules.Data[i + 1].ToString()); 5144 int tmpi = (int)rules.GetLSLIntegerItem(i + 1);
5234 prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; 5145 prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi;
5235 break; 5146 break;
5236 5147
5237 // Xantor 20080503
5238 // Wiki: PSYS_SRC_TEXTURE string inventory item name or key of the particle texture
5239 // "" = default texture.
5240 // 20080530 Updated to remove code duplication
5241 case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: 5148 case (int)ScriptBaseClass.PSYS_SRC_TEXTURE:
5242 prules.Texture = KeyOrName(rules.Data[i + 1].ToString()); 5149 prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1));
5243 break; 5150 break;
5244 5151
5245 case (int)ScriptBaseClass.PSYS_SRC_BURST_RATE: 5152 case (int)ScriptBaseClass.PSYS_SRC_BURST_RATE:
5246 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 5153 tempf = (float)rules.GetLSLFloatItem(i + 1);
5247 prules.BurstRate = (float)tempf; 5154 prules.BurstRate = (float)tempf;
5248 break; 5155 break;
5249 5156
5250 case (int)ScriptBaseClass.PSYS_SRC_BURST_PART_COUNT: 5157 case (int)ScriptBaseClass.PSYS_SRC_BURST_PART_COUNT:
5251 prules.BurstPartCount = (byte)Convert.ToByte(rules.Data[i + 1].ToString()); 5158 prules.BurstPartCount = (byte)(int)rules.GetLSLIntegerItem(i + 1);
5252 break; 5159 break;
5253 5160
5254 case (int)ScriptBaseClass.PSYS_SRC_BURST_RADIUS: 5161 case (int)ScriptBaseClass.PSYS_SRC_BURST_RADIUS:
5255 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 5162 tempf = (float)rules.GetLSLFloatItem(i + 1);
5256 prules.BurstRadius = (float)tempf; 5163 prules.BurstRadius = (float)tempf;
5257 break; 5164 break;
5258 5165
5259 case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MIN: 5166 case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MIN:
5260 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 5167 tempf = (float)rules.GetLSLFloatItem(i + 1);
5261 prules.BurstSpeedMin = (float)tempf; 5168 prules.BurstSpeedMin = (float)tempf;
5262 break; 5169 break;
5263 5170
5264 case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MAX: 5171 case (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MAX:
5265 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 5172 tempf = (float)rules.GetLSLFloatItem(i + 1);
5266 prules.BurstSpeedMax = (float)tempf; 5173 prules.BurstSpeedMax = (float)tempf;
5267 break; 5174 break;
5268 5175
5269 case (int)ScriptBaseClass.PSYS_SRC_MAX_AGE: 5176 case (int)ScriptBaseClass.PSYS_SRC_MAX_AGE:
5270 tempf = Convert.ToSingle(rules.Data[i + 1].ToString()); 5177 tempf = (float)rules.GetLSLFloatItem(i + 1);
5271 prules.MaxAge = (float)tempf; 5178 prules.MaxAge = (float)tempf;
5272 break; 5179 break;
5273 5180
@@ -6009,26 +5916,26 @@ namespace OpenSim.Region.ScriptEngine.Common
6009 5916
6010 public void llSetPrimitiveParams(LSL_List rules) 5917 public void llSetPrimitiveParams(LSL_List rules)
6011 { 5918 {
6012 llSetLinkPrimitiveParams(m_host.LinkNum, rules); 5919 SetPrimParams(m_host, rules);
6013 } 5920 }
6014 5921
6015 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) 5922 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules)
6016 { 5923 {
6017 m_host.AddScriptLPS(1); 5924 m_host.AddScriptLPS(1);
6018 5925
6019 if (m_host.ParentGroup == null) 5926 List<SceneObjectPart> parts = GetLinkParts(linknumber);
6020 return;
6021 5927
6022 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknumber); 5928 foreach (SceneObjectPart part in parts)
6023 5929 SetPrimParams(part, rules);
6024 if (part == null) 5930 }
6025 return;
6026 5931
5932 private void SetPrimParams(SceneObjectPart part, LSL_List rules)
5933 {
6027 int idx = 0; 5934 int idx = 0;
6028 5935
6029 while (idx < rules.Length) 5936 while (idx < rules.Length)
6030 { 5937 {
6031 int code = Convert.ToInt32(rules.Data[idx++]); 5938 int code = rules.GetLSLIntegerItem(idx++);
6032 5939
6033 int remain = rules.Length - idx; 5940 int remain = rules.Length - idx;
6034 5941
@@ -6041,7 +5948,7 @@ namespace OpenSim.Region.ScriptEngine.Common
6041 if (remain < 1) 5948 if (remain < 1)
6042 return; 5949 return;
6043 5950
6044 v=new LSL_Vector(rules.Data[idx++].ToString()); 5951 v=rules.GetVector3Item(idx++);
6045 SetPos(part, v); 5952 SetPos(part, v);
6046 5953
6047 break; 5954 break;
@@ -6049,7 +5956,7 @@ namespace OpenSim.Region.ScriptEngine.Common
6049 if (remain < 1) 5956 if (remain < 1)
6050 return; 5957 return;
6051 5958
6052 v=new LSL_Vector(rules.Data[idx++].ToString()); 5959 v=rules.GetVector3Item(idx++);
6053 SetScale(part, v); 5960 SetScale(part, v);
6054 5961
6055 break; 5962 break;
@@ -6057,7 +5964,7 @@ namespace OpenSim.Region.ScriptEngine.Common
6057 if (remain < 1) 5964 if (remain < 1)
6058 return; 5965 return;
6059 5966
6060 LSL_Rotation q = new LSL_Rotation(rules.Data[idx++].ToString()); 5967 LSL_Rotation q = rules.GetQuaternionItem(idx++);
6061 SetRot(part, q); 5968 SetRot(part, q);
6062 5969
6063 break; 5970 break;
@@ -6066,7 +5973,7 @@ namespace OpenSim.Region.ScriptEngine.Common
6066 if (remain < 3) 5973 if (remain < 3)
6067 return; 5974 return;
6068 5975
6069 code = Convert.ToInt32(rules.Data[idx++]); 5976 code = (int)rules.GetLSLIntegerItem(idx++);
6070 5977
6071 remain = rules.Length - idx; 5978 remain = rules.Length - idx;
6072 float hollow; 5979 float hollow;
@@ -7317,10 +7224,10 @@ namespace OpenSim.Region.ScriptEngine.Common
7317 { 7224 {
7318 m_host.AddScriptLPS(1); 7225 m_host.AddScriptLPS(1);
7319 IConfigSource config = new IniConfigSource(Application.iniFilePath); 7226 IConfigSource config = new IniConfigSource(Application.iniFilePath);
7320 if (config.Configs["LL-Functions"] == null) 7227 if (config.Configs["XEngine"] == null)
7321 config.AddConfig("LL-Functions"); 7228 config.AddConfig("XEngine");
7322 7229
7323 if (config.Configs["LL-Functions"].GetBoolean("AllowGodFunctions", false)) 7230 if (config.Configs["XEngine"].GetBoolean("AllowGodFunctions", false))
7324 { 7231 {
7325 if (World.ExternalChecks.ExternalChecksCanRunConsoleCommand(m_host.OwnerID)) 7232 if (World.ExternalChecks.ExternalChecksCanRunConsoleCommand(m_host.OwnerID))
7326 { 7233 {
@@ -7458,11 +7365,11 @@ namespace OpenSim.Region.ScriptEngine.Common
7458 } 7365 }
7459 UUID rq = UUID.Random(); 7366 UUID rq = UUID.Random();
7460 7367
7461 UUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager. 7368 UUID tid = AsyncCommands.
7462 m_Dataserver.RegisterRequest(m_localID, m_itemID, rq.ToString()); 7369 DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString());
7463 7370
7464 m_ScriptEngine.m_ASYNCLSLCommandManager. 7371 AsyncCommands.
7465 m_Dataserver.DataserverReply(rq.ToString(), reply); 7372 DataserverPlugin.DataserverReply(rq.ToString(), reply);
7466 7373
7467 // ScriptSleep(1000); 7374 // ScriptSleep(1000);
7468 return tid.ToString(); 7375 return tid.ToString();
@@ -8424,122 +8331,261 @@ namespace OpenSim.Region.ScriptEngine.Common
8424 throw new Exception("LSL Runtime Error: " + msg); 8331 throw new Exception("LSL Runtime Error: " + msg);
8425 } 8332 }
8426 8333
8334 public delegate void AssetRequestCallback(UUID assetID, AssetBase asset);
8335 private void WithNotecard(UUID assetID, AssetRequestCallback cb)
8336 {
8337 World.AssetCache.GetAsset(assetID, delegate(UUID i, AssetBase a) { cb(i, a); }, false);
8338 }
8339
8427 public LSL_String llGetNumberOfNotecardLines(string name) 8340 public LSL_String llGetNumberOfNotecardLines(string name)
8428 { 8341 {
8429 m_host.AddScriptLPS(1); 8342 m_host.AddScriptLPS(1);
8430 8343
8431 String[] notecardLines = GetNotecardLines(name); 8344 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
8432 if (!String.IsNullOrEmpty(notecardLines[0]))
8433 { 8345 {
8434 UUID rq = UUID.Random(); 8346 if (item.Type == 7 && item.Name == name)
8435 8347 {
8436 UUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.m_Dataserver.RegisterRequest( 8348 UUID tid = AsyncCommands.
8437 m_localID, m_itemID, rq.ToString()); 8349 DataserverPlugin.RegisterRequest(m_localID,
8438 8350 m_itemID, item.AssetID.ToString());
8439 m_ScriptEngine.m_ASYNCLSLCommandManager. 8351 if (NotecardCache.IsCached(item.AssetID))
8440 m_Dataserver.DataserverReply(rq.ToString(), notecardLines.Length.ToString()); 8352 {
8353 AsyncCommands.
8354 DataserverPlugin.DataserverReply(item.AssetID.ToString(),
8355 NotecardCache.GetLines(item.AssetID).ToString());
8356 // ScriptSleep(100);
8441 return tid.ToString(); 8357 return tid.ToString();
8442 } 8358 }
8443 else 8359 WithNotecard(item.AssetID, delegate (UUID id, AssetBase a)
8444 { 8360 {
8445 return UUID.Zero.ToString(); 8361 System.Text.ASCIIEncoding enc =
8362 new System.Text.ASCIIEncoding();
8363 string data = enc.GetString(a.Data);
8364 //Console.WriteLine(data);
8365 NotecardCache.Cache(id, data);
8366 AsyncCommands.
8367 DataserverPlugin.DataserverReply(id.ToString(),
8368 NotecardCache.GetLines(id).ToString());
8369 });
8370 // ScriptSleep(100);
8371 return tid.ToString();
8446 } 8372 }
8373 }
8374 // if we got to here, we didn't find the notecard the script was asking for
8375 // => complain loudly, as specified by the LSL docs
8376 ShoutError("Notecard '" + name + "' could not be found.");
8377
8447 // ScriptSleep(100); 8378 // ScriptSleep(100);
8379 return UUID.Zero.ToString();
8448 } 8380 }
8449 8381
8450 public LSL_String llGetNotecardLine(string name, int line) 8382 public LSL_String llGetNotecardLine(string name, int line)
8451 { 8383 {
8452 m_host.AddScriptLPS(1); 8384 m_host.AddScriptLPS(1);
8453 8385
8454 String[] notecardLines = GetNotecardLines(name); 8386 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
8455
8456 // line index starts at zero
8457 if ((!String.IsNullOrEmpty(notecardLines[0])) &&
8458 (line >= 0))
8459 { 8387 {
8460 if (line < notecardLines.Length) 8388 if (item.Type == 7 && item.Name == name)
8461 { 8389 {
8462 // ScriptSleep(100); 8390 UUID tid = AsyncCommands.
8463 UUID rq = UUID.Random(); 8391 DataserverPlugin.RegisterRequest(m_localID,
8464 8392 m_itemID, item.AssetID.ToString());
8465 UUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.m_Dataserver.RegisterRequest(
8466 m_localID, m_itemID, rq.ToString());
8467 8393
8468 m_ScriptEngine.m_ASYNCLSLCommandManager. 8394 if (NotecardCache.IsCached(item.AssetID))
8469 m_Dataserver.DataserverReply(rq.ToString(), notecardLines[line]);
8470 return tid.ToString();
8471 }
8472 else
8473 { 8395 {
8396 AsyncCommands.
8397 DataserverPlugin.DataserverReply(item.AssetID.ToString(),
8398 NotecardCache.GetLine(item.AssetID, line));
8474 // ScriptSleep(100); 8399 // ScriptSleep(100);
8475 UUID rq = UUID.Random(); 8400 return tid.ToString();
8401 }
8476 8402
8477 UUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.m_Dataserver.RegisterRequest( 8403 WithNotecard(item.AssetID, delegate (UUID id, AssetBase a)
8478 m_localID, m_itemID, rq.ToString()); 8404 {
8405 System.Text.ASCIIEncoding enc =
8406 new System.Text.ASCIIEncoding();
8407 string data = enc.GetString(a.Data);
8408 //Console.WriteLine(data);
8409 NotecardCache.Cache(id, data);
8410 AsyncCommands.
8411 DataserverPlugin.DataserverReply(id.ToString(),
8412 NotecardCache.GetLine(id, line));
8413 });
8479 8414
8480 m_ScriptEngine.m_ASYNCLSLCommandManager. 8415 // ScriptSleep(100);
8481 m_Dataserver.DataserverReply(rq.ToString(), ScriptBaseClass.EOF);
8482 return tid.ToString(); 8416 return tid.ToString();
8483 } 8417 }
8484 } 8418 }
8485 else 8419
8486 { 8420 // if we got to here, we didn't find the notecard the script was asking for
8421 // => complain loudly, as specified by the LSL docs
8422 ShoutError("Notecard '" + name + "' could not be found.");
8423
8487 // ScriptSleep(100); 8424 // ScriptSleep(100);
8488 return UUID.Zero.ToString(); 8425 return UUID.Zero.ToString();
8489 } 8426 }
8427
8428 }
8429
8430 public class NotecardCache
8431 {
8432 private class Notecard
8433 {
8434 public string[] text;
8435 public DateTime lastRef;
8490 } 8436 }
8491 8437
8492 private String[] GetNotecardLines(string name) 8438 private static Dictionary<UUID, Notecard> m_Notecards =
8439 new Dictionary<UUID, Notecard>();
8440
8441 public static void Cache(UUID assetID, string text)
8493 { 8442 {
8494 // bool found = false; 8443 CacheCheck();
8495 int notecardIndex = 0;
8496 String[] notecardLines = { "0" };
8497 notecardLines[0] = String.Empty;
8498 8444
8499 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 8445 lock (m_Notecards)
8500 { 8446 {
8501 if ((inv.Value.Name == name) && (inv.Value.InvType == (int)InventoryType.Notecard)) 8447 if (m_Notecards.ContainsKey(assetID))
8448 return;
8449
8450 Notecard nc = new Notecard();
8451 nc.lastRef = DateTime.Now;
8452 nc.text = ParseText(text.Replace("\r", "").Split('\n'));
8453 m_Notecards[assetID] = nc;
8454 }
8455 }
8456
8457 private static string[] ParseText(string[] input)
8458 {
8459 int idx = 0;
8460 int level = 0;
8461 List<string> output = new List<string>();
8462 string[] words;
8463
8464 while (idx < input.Length)
8465 {
8466 if (input[idx] == "{")
8502 { 8467 {
8503 // OK, it has the right name and it is a notecard 8468 level++;
8504 // so get the asset that contains the notecard raw data 8469 idx++;
8505 // and convert it into a string 8470 continue;
8506 AssetBase notecardAsset = World.AssetCache.GetAsset(inv.Value.AssetID, false); 8471 }
8507 String dataString = System.Text.Encoding.ASCII.GetString(notecardAsset.Data);
8508 8472
8509 if (!String.IsNullOrEmpty(dataString)) 8473 if (input[idx]== "}")
8510 { 8474 {
8511 // good, we have the notecard data as a string 8475 level--;
8512 // now parse the text lines using the Linden Text delimiters 8476 idx++;
8513 notecardIndex = dataString.IndexOf("}\nText length "); 8477 continue;
8514 if (notecardIndex > 0) 8478 }
8479
8480 switch (level)
8515 { 8481 {
8516 notecardIndex = notecardIndex + 2; //get past delimiter 8482 case 0:
8517 notecardIndex = dataString.IndexOf("\n", notecardIndex); 8483 words = input[idx].Split(' '); // Linden text ver
8518 if (notecardIndex > 0) 8484 // Notecards are created *really* empty. Treat that as "no text" (just like after saving an empty notecard)
8485 if (words.Length < 3)
8486 return new String[0];
8487
8488 int version = int.Parse(words[3]);
8489 if (version != 2)
8490 return new String[0];
8491 break;
8492 case 1:
8493 words = input[idx].Split(' ');
8494 if (words[0] == "LLEmbeddedItems")
8495 break;
8496 if (words[0] == "Text")
8519 { 8497 {
8520 // Finally got to the first line of the notecard 8498 int len = int.Parse(words[2]);
8521 // now find the end of the notecard text delimited by }<LF> 8499 idx++;
8522 // parse the lines, delimited by <LF> 8500
8523 notecardIndex = dataString.IndexOf("\n", notecardIndex); 8501 int count = -1;
8524 notecardIndex++; // get past delimiter 8502
8525 8503 while (count < len)
8526 int notecardLength = dataString.Length - notecardIndex - 3; 8504 {
8527 8505 // int l = input[idx].Length;
8528 // create new string to parse that only consists of the actual lines in the asset 8506 string ln = input[idx];
8529 Char[] notecardCharArray = dataString.ToCharArray(notecardIndex, notecardLength); 8507
8530 String notecardString = new String(notecardCharArray); 8508 int need = len-count-1;
8531 8509 if (ln.Length > need)
8532 // split the lines of the notecard into separate strings 8510 ln = ln.Substring(0, need);
8533 char[] delimChar = { '\n' }; 8511
8534 notecardLines = notecardString.Split(delimChar); 8512 output.Add(ln);
8535 return notecardLines; 8513 count += ln.Length + 1;
8514 idx++;
8536 } 8515 }
8516
8517 return output.ToArray();
8537 } 8518 }
8519 break;
8520 case 2:
8521 words = input[idx].Split(' '); // count
8522 if (words[0] == "count")
8523 {
8524 int c = int.Parse(words[1]);
8525 if (c > 0)
8526 return new String[0];
8527 break;
8538 } 8528 }
8529 break;
8539 } 8530 }
8531 idx++;
8540 } 8532 }
8541 return notecardLines; 8533 return output.ToArray();
8542 } 8534 }
8543 8535
8536 public static bool IsCached(UUID assetID)
8537 {
8538 lock (m_Notecards)
8539 {
8540 return m_Notecards.ContainsKey(assetID);
8541 }
8542 }
8543
8544 public static int GetLines(UUID assetID)
8545 {
8546 if (!IsCached(assetID))
8547 return -1;
8548
8549 lock (m_Notecards)
8550 {
8551 m_Notecards[assetID].lastRef = DateTime.Now;
8552 return m_Notecards[assetID].text.Length;
8553 }
8554 }
8555
8556 public static string GetLine(UUID assetID, int line)
8557 {
8558 if (line < 0)
8559 return "";
8560
8561 string data;
8562
8563 if (!IsCached(assetID))
8564 return "";
8565
8566 lock (m_Notecards)
8567 {
8568 m_Notecards[assetID].lastRef = DateTime.Now;
8569
8570 if (line >= m_Notecards[assetID].text.Length)
8571 return "\n\n\n";
8572
8573 data = m_Notecards[assetID].text[line];
8574 if (data.Length > 255)
8575 data = data.Substring(0, 255);
8576
8577 return data;
8578 }
8579 }
8580
8581 public static void CacheCheck()
8582 {
8583 foreach (UUID key in new List<UUID>(m_Notecards.Keys))
8584 {
8585 Notecard nc = m_Notecards[key];
8586 if (nc.lastRef.AddSeconds(30) < DateTime.Now)
8587 m_Notecards.Remove(key);
8588 }
8589 }
8544 } 8590 }
8545} 8591}
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs
index ee86500..5fa6010 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandManager.cs
@@ -45,12 +45,42 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
45 45
46 public ScriptEngine m_ScriptEngine; 46 public ScriptEngine m_ScriptEngine;
47 47
48 public Timer m_Timer; 48 private Timer m_Timer;
49 public HttpRequest m_HttpRequest; 49 private HttpRequest m_HttpRequest;
50 public Listener m_Listener; 50 private Listener m_Listener;
51 public SensorRepeat m_SensorRepeat; 51 private SensorRepeat m_SensorRepeat;
52 public XmlRequest m_XmlRequest; 52 private XmlRequest m_XmlRequest;
53 public Dataserver m_Dataserver; 53 private Dataserver m_Dataserver;
54
55 public Dataserver DataserverPlugin
56 {
57 get { return m_Dataserver; }
58 }
59
60 public Timer TimerPlugin
61 {
62 get { return m_Timer; }
63 }
64
65 public HttpRequest HttpRequestPlugin
66 {
67 get { return m_HttpRequest; }
68 }
69
70 public Listener ListenerPlugin
71 {
72 get { return m_Listener; }
73 }
74
75 public SensorRepeat SensorRepeatPlugin
76 {
77 get { return m_SensorRepeat; }
78 }
79
80 public XmlRequest XmlRequestPlugin
81 {
82 get { return m_XmlRequest; }
83 }
54 84
55 public AsyncCommandManager(ScriptEngine _ScriptEngine) 85 public AsyncCommandManager(ScriptEngine _ScriptEngine)
56 { 86 {
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
index 01af0af..c972683 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
@@ -48,7 +48,11 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 public static List<ScriptEngine> ScriptEngines = new List<ScriptEngine>(); 50 public static List<ScriptEngine> ScriptEngines = new List<ScriptEngine>();
51 public Scene World; 51 private Scene m_Scene;
52 public Scene World
53 {
54 get { return m_Scene; }
55 }
52 public EventManager m_EventManager; // Handles and queues incoming events from OpenSim 56 public EventManager m_EventManager; // Handles and queues incoming events from OpenSim
53 public EventQueueManager m_EventQueueManager; // Executes events, handles script threads 57 public EventQueueManager m_EventQueueManager; // Executes events, handles script threads
54 public ScriptManager m_ScriptManager; // Load, unload and execute scripts 58 public ScriptManager m_ScriptManager; // Load, unload and execute scripts
@@ -94,7 +98,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
94 98
95 public void InitializeEngine(Scene Sceneworld, IConfigSource config, bool HookUpToServer, ScriptManager newScriptManager) 99 public void InitializeEngine(Scene Sceneworld, IConfigSource config, bool HookUpToServer, ScriptManager newScriptManager)
96 { 100 {
97 World = Sceneworld; 101 m_Scene = Sceneworld;
98 ConfigSource = config; 102 ConfigSource = config;
99 m_hookUpToServer = HookUpToServer; 103 m_hookUpToServer = HookUpToServer;
100 104