From 04f8d0e45dae6b773e49532e4cd31ee290f9a677 Mon Sep 17 00:00:00 2001 From: Makopoppo Date: Thu, 7 Jul 2011 23:36:41 +0900 Subject: Made some LSL_Constant or LS_Constant raw int values --- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 461b473..0839ab4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -1741,8 +1741,13 @@ namespace OpenSim.Region.ScriptEngine.Shared public override bool Equals(Object o) { - if (!(o is LSLInteger)) - return false; + if (!(o is LSLInteger)) { + if(o is int) { + return value == (int)o; + } else { + return false; + } + } return value == ((LSLInteger)o).value; } -- cgit v1.1 From b983f38e2abc4ee28a572c680ba267138064ed5c Mon Sep 17 00:00:00 2001 From: Makopoppo Date: Thu, 7 Jul 2011 23:38:22 +0900 Subject: lsGetWindlightScene() returns raw int value, which makes unable to compare to another value with llListFindList() --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index 645566e..80daf5b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs @@ -130,7 +130,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api int idx = 0; while (idx < rules.Length) { - uint rule = (uint)rules.GetLSLIntegerItem(idx); + LSL_Integer ruleInt = rules.GetLSLIntegerItem(idx); + uint rule = (uint)ruleInt; LSL_List toadd = new LSL_List(); switch (rule) @@ -247,7 +248,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (toadd.Length > 0) { - values.Add(rule); + values.Add(ruleInt); values.Add(toadd.Data[0]); } idx++; -- cgit v1.1 From 52c3671aa07c5d4c91908a8e1b15b76e96cc49c0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 9 Jul 2011 01:17:35 +0100 Subject: fix formatting issues from last patch --- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 0839ab4..e0a4014 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -1741,13 +1741,18 @@ namespace OpenSim.Region.ScriptEngine.Shared public override bool Equals(Object o) { - if (!(o is LSLInteger)) { - if(o is int) { + if (!(o is LSLInteger)) + { + if (o is int) + { return value == (int)o; - } else { + } + else + { return false; } } + return value == ((LSLInteger)o).value; } -- cgit v1.1 From f680c134955b3179265ec197c935ed86b397b6ad Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 9 Jul 2011 01:24:30 +0100 Subject: Fix osMatchString() so that it reports all instance of pattern matches, not just the first one. This is a slight adaptation of the patch in http://opensimulator.org/mantis/view.php?id=4568 which doesn't apply directly since the underlying code was changed by earlier makopoppo patches. Thanks makopoppo! --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index b3f90e2..b710229 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1909,8 +1909,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api }; return NotecardCache.GetLines(assetID); - - } public string osAvatarName2Key(string firstname, string lastname) @@ -2024,7 +2022,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Find matches beginning at start position Regex matcher = new Regex(pattern); Match match = matcher.Match(src, start); - if (match.Success) + while (match.Success) { foreach (System.Text.RegularExpressions.Group g in match.Groups) { @@ -2034,6 +2032,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api result.Add(new LSL_Integer(g.Index)); } } + + match = match.NextMatch(); } return result; -- cgit v1.1 From df586c9d2502523395b53d48ddd7dda8832c7a08 Mon Sep 17 00:00:00 2001 From: Makopoppo Date: Tue, 5 Jul 2011 22:19:26 +0900 Subject: Raw int numbers (ex.LSL Constants) are displayed like "1.000000" when type cast to string --- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index e0a4014..bf66b12 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -1396,6 +1396,12 @@ namespace OpenSim.Region.ScriptEngine.Shared string s = String.Format(Culture.FormatProvider, "{0:0.000000}", f.value); m_string=s; } + + public LSLString(int i) + { + string s = String.Format("{0}", i); + m_string = s; + } public LSLString(LSLInteger i) { @@ -1469,6 +1475,11 @@ namespace OpenSim.Region.ScriptEngine.Shared { return new LSLString(d); } + + static public explicit operator LSLString(int i) + { + return new LSLString(i); + } public static explicit operator LSLString(LSLFloat f) { -- cgit v1.1 From 6963b8b046f8a236d5a6e75a0fed81103d807c21 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 9 Jul 2011 01:28:27 +0100 Subject: refactor: Get LSLString(LSLInteger i) constructor to now call LSLString(int i) structure to remove code duplication. --- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index bf66b12..d848b2a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -1379,7 +1379,9 @@ namespace OpenSim.Region.ScriptEngine.Shared public struct LSLString { public string m_string; + #region Constructors + public LSLString(string s) { m_string = s; @@ -1387,14 +1389,14 @@ namespace OpenSim.Region.ScriptEngine.Shared public LSLString(double d) { - string s=String.Format(Culture.FormatProvider, "{0:0.000000}", d); - m_string=s; + string s = String.Format(Culture.FormatProvider, "{0:0.000000}", d); + m_string = s; } public LSLString(LSLFloat f) { string s = String.Format(Culture.FormatProvider, "{0:0.000000}", f.value); - m_string=s; + m_string = s; } public LSLString(int i) @@ -1403,12 +1405,8 @@ namespace OpenSim.Region.ScriptEngine.Shared m_string = s; } - public LSLString(LSLInteger i) - { - string s = String.Format("{0}", i); - m_string = s; - } - + public LSLString(LSLInteger i) : this(i.value) {} + #endregion #region Operators -- cgit v1.1 From 3e456163dd284fa04ab17465041a1a27f7b632b9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 12 Jul 2011 22:13:15 +0100 Subject: Port implementation of llCastRay() from Aurora. I haven't been able to test this since the viewer won't parse the llCastRay() function. Maybe some activation cap is missing. Could wait until it is activated by default in the viewer. --- .../Shared/Api/Implementation/LSL_Api.cs | 166 +++++++++++++++++++-- .../ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 5 +- .../Shared/Api/Runtime/LSL_Constants.cs | 16 ++ 3 files changed, 172 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index fd6d64c..c8bce60 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -10309,51 +10309,191 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return rq.ToString(); } + public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) + { + m_host.AddScriptLPS(1); + + Vector3 dir = new Vector3((float)(end-start).x, (float)(end-start).y, (float)(end-start).z); + Vector3 startvector = new Vector3((float)start.x, (float)start.y, (float)start.z); + Vector3 endvector = new Vector3((float)end.x, (float)end.y, (float)end.z); + + int count = 0; +// int detectPhantom = 0; + int dataFlags = 0; + int rejectTypes = 0; + + for (int i = 0; i < options.Length; i += 2) + { + if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_MAX_HITS) + { + count = options.GetLSLIntegerItem(i + 1); + } +// else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DETECT_PHANTOM) +// { +// detectPhantom = options.GetLSLIntegerItem(i + 1); +// } + else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DATA_FLAGS) + { + dataFlags = options.GetLSLIntegerItem(i + 1); + } + else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_REJECT_TYPES) + { + rejectTypes = options.GetLSLIntegerItem(i + 1); + } + } + + LSL_List list = new LSL_List(); + List results = World.PhysicsScene.RaycastWorld(startvector, dir, dir.Length(), count); + + double distance = Util.GetDistanceTo(startvector, endvector); + + if (distance == 0) + distance = 0.001; + + Vector3 posToCheck = startvector; + ITerrainChannel channel = World.RequestModuleInterface(); + + bool checkTerrain = !((rejectTypes & ScriptBaseClass.RC_REJECT_LAND) == ScriptBaseClass.RC_REJECT_LAND); + bool checkAgents = !((rejectTypes & ScriptBaseClass.RC_REJECT_AGENTS) == ScriptBaseClass.RC_REJECT_AGENTS); + bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL); + bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); + + for (float i = 0; i <= distance; i += 0.1f) + { + posToCheck = startvector + (dir * (i / (float)distance)); + + if (checkTerrain && channel[(int)(posToCheck.X + startvector.X), (int)(posToCheck.Y + startvector.Y)] < posToCheck.Z) + { + ContactResult result = new ContactResult(); + result.ConsumerID = 0; + result.Depth = 0; + result.Normal = Vector3.Zero; + result.Pos = posToCheck; + results.Add(result); + checkTerrain = false; + } + + if (checkAgents) + { + World.ForEachScenePresence(delegate(ScenePresence sp) + { + if (sp.AbsolutePosition.ApproxEquals(posToCheck, sp.PhysicsActor.Size.X)) + { + ContactResult result = new ContactResult (); + result.ConsumerID = sp.LocalId; + result.Depth = 0; + result.Normal = Vector3.Zero; + result.Pos = posToCheck; + results.Add(result); + } + }); + } + } + + int refcount = 0; + foreach (ContactResult result in results) + { + if ((rejectTypes & ScriptBaseClass.RC_REJECT_LAND) + == ScriptBaseClass.RC_REJECT_LAND && result.ConsumerID == 0) + continue; + + ISceneEntity entity = World.GetSceneObjectPart(result.ConsumerID); + + if (entity == null && (rejectTypes & ScriptBaseClass.RC_REJECT_AGENTS) != ScriptBaseClass.RC_REJECT_AGENTS) + entity = World.GetScenePresence(result.ConsumerID); //Only check if we should be looking for agents + + if (entity == null) + { + list.Add(UUID.Zero); + + if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM) + list.Add(0); + + list.Add(result.Pos); + + if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL) + list.Add(result.Normal); + + continue; //Can't find it, so add UUID.Zero + } + + /*if (detectPhantom == 0 && intersection.obj is ISceneChildEntity && + ((ISceneChildEntity)intersection.obj).PhysActor == null) + continue;*/ //Can't do this ATM, physics engine knows only of non phantom objects + + if (entity is SceneObjectPart) + { + if (((SceneObjectPart)entity).PhysActor != null && ((SceneObjectPart)entity).PhysActor.IsPhysical) + { + if (!checkPhysical) + continue; + } + else + { + if (!checkNonPhysical) + continue; + } + } + + refcount++; + if ((dataFlags & ScriptBaseClass.RC_GET_ROOT_KEY) == ScriptBaseClass.RC_GET_ROOT_KEY && entity is SceneObjectPart) + list.Add(((SceneObjectPart)entity).ParentGroup.UUID); + else + list.Add(entity.UUID); + + if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM) + { + if (entity is SceneObjectPart) + list.Add(((SceneObjectPart)entity).LinkNum); + else + list.Add(0); + } + + list.Add(result.Pos); + + if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL) + list.Add(result.Normal); + } + + list.Add(refcount); //The status code, either the # of contacts, RCERR_SIM_PERF_LOW, or RCERR_CAST_TIME_EXCEEDED + + return list; + } + #region Not Implemented // // Listing the unimplemented lsl functions here, please move // them from this region as they are completed // - public void llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) - { - m_host.AddScriptLPS(1); - NotImplemented("llCastRay"); - - } public void llGetEnv(LSL_String name) { m_host.AddScriptLPS(1); NotImplemented("llGetEnv"); - } public void llGetSPMaxMemory() { m_host.AddScriptLPS(1); NotImplemented("llGetSPMaxMemory"); - } public void llGetUsedMemory() { m_host.AddScriptLPS(1); NotImplemented("llGetUsedMemory"); - } - public void llRegionSayTo( LSL_Key target, LSL_Integer channel, LSL_String msg ) + public void llRegionSayTo(LSL_Key target, LSL_Integer channel, LSL_String msg) { m_host.AddScriptLPS(1); NotImplemented("llRegionSayTo"); - } - public void llScriptProfiler( LSL_Integer flags ) + public void llScriptProfiler(LSL_Integer flags) { m_host.AddScriptLPS(1); NotImplemented("llScriptProfiler"); - } public void llSetSoundQueueing(int queue) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 654ea81..27f9c84 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -60,6 +60,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_String llBase64ToString(string str); void llBreakAllLinks(); void llBreakLink(int linknum); + LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options); LSL_Integer llCeil(double f); void llClearCameraParams(); LSL_Integer llClearPrimMedia(LSL_Integer face); @@ -404,7 +405,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_String llXorBase64StringsCorrect(string str1, string str2); void print(string str); - void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); - LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); + void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); + LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 9377cda..3f90788 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -593,5 +593,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; + + public static readonly LSLInteger RC_REJECT_TYPES = 2; + public static readonly LSLInteger RC_DATA_FLAGS = 4; + public static readonly LSLInteger RC_MAX_HITS = 8; + public static readonly LSLInteger RC_DETECT_PHANTOM = 16; + + public static readonly LSLInteger RC_REJECT_AGENTS = 2; + public static readonly LSLInteger RC_REJECT_PHYSICAL = 4; + public static readonly LSLInteger RC_REJECT_NONPHYSICAL = 8; + public static readonly LSLInteger RC_REJECT_LAND = 16; + + public static readonly LSLInteger RC_GET_NORMAL = 2; + public static readonly LSLInteger RC_GET_ROOT_KEY = 4; + public static readonly LSLInteger RC_GET_LINK_NUM = 8; + + public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 1; } } -- cgit v1.1 From 0ee7a5ee81437f7fb81814b1694c00cb5a206bda Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 15 Jul 2011 23:36:32 +0100 Subject: If object is an attachment, make llGetVel() return the avatar's speed rather than the object's own zero speed. As per http://opensimulator.org/mantis/view.php?id=5575 --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c8bce60..7759b0a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2214,7 +2214,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetVel() { m_host.AddScriptLPS(1); - return new LSL_Vector(m_host.Velocity.X, m_host.Velocity.Y, m_host.Velocity.Z); + + Vector3 vel; + + if (m_host.IsAttachment) + { + ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.AttachedAvatar); + vel = avatar.Velocity; + } + else + { + vel = m_host.Velocity; + } + + return new LSL_Vector(vel.X, vel.Y, vel.Z); } public LSL_Vector llGetAccel() @@ -10021,8 +10034,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; } } + return ret; } + SceneObjectPart obj = World.GetSceneObjectPart(key); if (obj != null) { -- cgit v1.1 From 7247ca16447e962d0f8281e0ed4f163ea4e06b96 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 16 Jul 2011 00:08:11 +0100 Subject: use constants in llGetObjectDetails() rather than magic numbers --- .../Shared/Api/Implementation/LSL_Api.cs | 43 +++++++++++----------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 7759b0a..26969a5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2523,10 +2523,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// negative (indicating end-relative) and may be inverted, /// i.e. end < start. /// - public LSL_String llDeleteSubString(string src, int start, int end) { - m_host.AddScriptLPS(1); // Normalize indices (if negative). @@ -2606,10 +2604,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// which case it is end-relative. The index may exceed either /// string bound, with the result being a concatenation. /// - public LSL_String llInsertString(string dest, int index, string src) { - m_host.AddScriptLPS(1); // Normalize indices (if negative). @@ -9996,6 +9992,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_List llGetObjectDetails(string id, LSL_List args) { m_host.AddScriptLPS(1); + LSL_List ret = new LSL_List(); UUID key = new UUID(); if (UUID.TryParse(id, out key)) @@ -10006,30 +10003,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { foreach (object o in args.Data) { - switch (o.ToString()) + switch (int.Parse(o.ToString())) { - case "1": + case ScriptBaseClass.OBJECT_NAME: ret.Add(new LSL_String(av.Firstname + " " + av.Lastname)); break; - case "2": + case ScriptBaseClass.OBJECT_DESC: ret.Add(new LSL_String("")); break; - case "3": + case ScriptBaseClass.OBJECT_POS: ret.Add(new LSL_Vector((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z)); break; - case "4": + case ScriptBaseClass.OBJECT_ROT: ret.Add(new LSL_Rotation((double)av.Rotation.X, (double)av.Rotation.Y, (double)av.Rotation.Z, (double)av.Rotation.W)); break; - case "5": + case ScriptBaseClass.OBJECT_VELOCITY: ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z)); break; - case "6": + case ScriptBaseClass.OBJECT_OWNER: ret.Add(new LSL_String(id)); break; - case "7": + case ScriptBaseClass.OBJECT_GROUP: ret.Add(new LSL_String(UUID.Zero.ToString())); break; - case "8": + case ScriptBaseClass.OBJECT_CREATOR: ret.Add(new LSL_String(UUID.Zero.ToString())); break; } @@ -10043,37 +10040,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { foreach (object o in args.Data) { - switch (o.ToString()) + switch (int.Parse(o.ToString())) { - case "1": + case ScriptBaseClass.OBJECT_NAME: ret.Add(new LSL_String(obj.Name)); break; - case "2": + case ScriptBaseClass.OBJECT_DESC: ret.Add(new LSL_String(obj.Description)); break; - case "3": + case ScriptBaseClass.OBJECT_POS: ret.Add(new LSL_Vector(obj.AbsolutePosition.X, obj.AbsolutePosition.Y, obj.AbsolutePosition.Z)); break; - case "4": + case ScriptBaseClass.OBJECT_ROT: ret.Add(new LSL_Rotation(obj.RotationOffset.X, obj.RotationOffset.Y, obj.RotationOffset.Z, obj.RotationOffset.W)); break; - case "5": + case ScriptBaseClass.OBJECT_VELOCITY: ret.Add(new LSL_Vector(obj.Velocity.X, obj.Velocity.Y, obj.Velocity.Z)); break; - case "6": + case ScriptBaseClass.OBJECT_OWNER: ret.Add(new LSL_String(obj.OwnerID.ToString())); break; - case "7": + case ScriptBaseClass.OBJECT_GROUP: ret.Add(new LSL_String(obj.GroupID.ToString())); break; - case "8": + case ScriptBaseClass.OBJECT_CREATOR: ret.Add(new LSL_String(obj.CreatorID.ToString())); break; } } + return ret; } } + return new LSL_List(); } -- cgit v1.1 From 61d49d4f63eafa68d0b63877029da3475d977263 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Aug 2011 23:20:36 +0100 Subject: rename NPC.Autopilot to NPC.MoveToTarget internally. Add method doc to INPCModule --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index b710229..8093502 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2110,7 +2110,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (module != null) { Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); - module.Autopilot(new UUID(npc.m_string), World, pos); + module.MoveToTarget(new UUID(npc.m_string), World, pos); } } -- cgit v1.1 From c6c91e6599de6d4402ec0258da03cc975147da90 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 6 Aug 2011 00:13:08 +0100 Subject: refactor: Fold most SOP.ScriptSet* methods back into script code. Simplify. --- .../Shared/Api/Implementation/LSL_Api.cs | 27 ++++++---------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 26969a5..7c21ba9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1204,10 +1204,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if ((status & ScriptBaseClass.STATUS_PHANTOM) == ScriptBaseClass.STATUS_PHANTOM) { - if (value != 0) - m_host.ScriptSetPhantomStatus(true); - else - m_host.ScriptSetPhantomStatus(false); + if (m_host.ParentGroup != null) + m_host.ParentGroup.ScriptSetPhantomStatus(value != 0); } if ((status & ScriptBaseClass.STATUS_CAST_SHADOWS) == ScriptBaseClass.STATUS_CAST_SHADOWS) @@ -6446,9 +6444,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_host.ParentGroup != null) { if (!m_host.ParentGroup.IsDeleted) - { - m_host.ParentGroup.RootPart.ScriptSetVolumeDetect(detect!=0); - } + m_host.ParentGroup.ScriptSetVolumeDetect(detect != 0); } } @@ -6456,7 +6452,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// This is a depecated function so this just replicates the result of /// invoking it in SL /// - public void llRemoteLoadScript(string target, string name, int running, int start_param) { m_host.AddScriptLPS(1); @@ -7254,14 +7249,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; string ph = rules.Data[idx++].ToString(); - bool phantom; - if (ph.Equals("1")) - phantom = true; - else - phantom = false; + if (m_host.ParentGroup != null) + m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); - part.ScriptSetPhantomStatus(phantom); break; case (int)ScriptBaseClass.PRIM_PHYSICS: @@ -7282,14 +7273,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (remain < 1) return; string temp = rules.Data[idx++].ToString(); - bool tempOnRez; - if (temp.Equals("1")) - tempOnRez = true; - else - tempOnRez = false; + if (m_host.ParentGroup != null) + m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); - part.ScriptSetTemporaryStatus(tempOnRez); break; case (int)ScriptBaseClass.PRIM_TEXGEN: -- cgit v1.1 From bda1a4be4567181df6c18ce6e059ca8982bc5fa1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 6 Aug 2011 00:26:37 +0100 Subject: rename test SceneSetupHelpers -> SceneHelpers for consistency --- OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index 80b60a4..3f37ec7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs @@ -57,8 +57,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests IConfig config = initConfigSource.AddConfig("XEngine"); config.Set("Enabled", "true"); - Scene scene = SceneSetupHelpers.SetupScene(); - SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); + Scene scene = SceneHelpers.SetupScene(); + SceneObjectPart part = SceneHelpers.AddSceneObject(scene); XEngine.XEngine engine = new XEngine.XEngine(); engine.Initialise(initConfigSource); -- cgit v1.1 From 78d8ce3816cde8702cfd4f5d198e2c69aff0a7be Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 8 Aug 2011 23:22:47 +0100 Subject: refactor: split out generic parts of osMakeNotecard() into a separate. Add method doc. Other minor tidies. --- .../Shared/Api/Implementation/OSSL_Api.cs | 157 +++++++++++++-------- 1 file changed, 99 insertions(+), 58 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 8093502..32ad21f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -348,20 +348,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api System.Threading.Thread.Sleep(delay); } - // - // OpenSim functions - // public LSL_Integer osSetTerrainHeight(int x, int y, double val) { CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight"); return SetTerrainHeight(x, y, val); } + public LSL_Integer osTerrainSetHeight(int x, int y, double val) { CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight"); OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight"); return SetTerrainHeight(x, y, val); } + private LSL_Integer SetTerrainHeight(int x, int y, double val) { m_host.AddScriptLPS(1); @@ -384,12 +383,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.None, "osGetTerrainHeight"); return GetTerrainHeight(x, y); } + public LSL_Float osTerrainGetHeight(int x, int y) { CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight"); OSSLDeprecated("osTerrainGetHeight", "osGetTerrainHeight"); return GetTerrainHeight(x, y); } + private LSL_Float GetTerrainHeight(int x, int y) { m_host.AddScriptLPS(1); @@ -1021,6 +1022,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api drawList += "PenColor " + color + "; "; return drawList; } + // Deprecated public string osSetPenColour(string drawList, string colour) { @@ -1182,11 +1184,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api OSSLDeprecated("osSunGetParam", "osGetSunParam"); return GetSunParam(param); } + public double osGetSunParam(string param) { CheckThreatLevel(ThreatLevel.None, "osGetSunParam"); return GetSunParam(param); } + private double GetSunParam(string param) { m_host.AddScriptLPS(1); @@ -1208,11 +1212,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api OSSLDeprecated("osSunSetParam", "osSetSunParam"); SetSunParam(param, value); } + public void osSetSunParam(string param, double value) { CheckThreatLevel(ThreatLevel.None, "osSetSunParam"); SetSunParam(param, value); } + private void SetSunParam(string param, double value) { m_host.AddScriptLPS(1); @@ -1222,10 +1228,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { module.SetSunParameter(param, value); } - } - public string osWindActiveModelPluginName() { CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName"); @@ -1304,12 +1308,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api OSSLDeprecated(functionName, "osSetParcelDetails"); SetParcelDetails(pos, rules, functionName); } + public void osSetParcelDetails(LSL_Vector pos, LSL_List rules) { const string functionName = "osSetParcelDetails"; CheckThreatLevel(ThreatLevel.High, functionName); SetParcelDetails(pos, rules, functionName); } + private void SetParcelDetails(LSL_Vector pos, LSL_List rules, string functionName) { m_host.AddScriptLPS(1); @@ -1429,8 +1435,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID); else OSSLError("osSetParcelSIPAddress: No voice module enabled for this land"); - - } public string osGetScriptEngineName() @@ -1683,8 +1687,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return jsondata; } - // send a message to to object identified by the given UUID, a script in the object must implement the dataserver function - // the dataserver function is passed the ID of the calling function and a string message + /// + /// Send a message to to object identified by the given UUID + /// + /// + /// A script in the object must implement the dataserver function + /// the dataserver function is passed the ID of the calling function and a string message + /// + /// + /// public void osMessageObject(LSL_Key objectUUID, string message) { CheckThreatLevel(ThreatLevel.Low, "osMessageObject"); @@ -1699,24 +1710,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api "dataserver", resobj, new DetectParams[0])); } - - // This needs ThreatLevel high. It is an excellent griefer tool, - // In a loop, it can cause asset bloat and DOS levels of asset - // writes. - // + /// + /// Write a notecard directly to the prim's inventory. + /// + /// + /// This needs ThreatLevel high. It is an excellent griefer tool, + /// In a loop, it can cause asset bloat and DOS levels of asset + /// writes. + /// + /// The name of the notecard to write. + /// The contents of the notecard. public void osMakeNotecard(string notecardName, LSL_Types.list contents) { CheckThreatLevel(ThreatLevel.High, "osMakeNotecard"); m_host.AddScriptLPS(1); + StringBuilder notecardData = new StringBuilder(); + + for (int i = 0; i < contents.Length; i++) + notecardData.Append((string)(contents.GetLSLStringItem(i) + "\n")); + + SaveNotecard(notecardName, notecardData.ToString()); + } + + protected void SaveNotecard(string notecardName, string notecardData) + { // Create new asset AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString()); asset.Description = "Script Generated Notecard"; - string notecardData = String.Empty; - - for (int i = 0; i < contents.Length; i++) { - notecardData += contents.GetLSLStringItem(i) + "\n"; - } int textLength = notecardData.Length; notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " @@ -1726,7 +1747,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api World.AssetService.Store(asset); // Create Task Entry - TaskInventoryItem taskItem=new TaskInventoryItem(); + TaskInventoryItem taskItem = new TaskInventoryItem(); taskItem.ResetIDs(m_host.UUID); taskItem.ParentID = m_host.UUID; @@ -1751,13 +1772,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.Inventory.AddInventoryItem(taskItem, false); } - - /*Instead of using the LSL Dataserver event to pull notecard data, - this will simply read the requested line and return its data as a string. - - Warning - due to the synchronous method this function uses to fetch assets, its use - may be dangerous and unreliable while running in grid mode. - */ + /// + /// Directly get an entire notecard at once. + /// + /// + /// Instead of using the LSL Dataserver event to pull notecard data + /// this will simply read the entire notecard and return its data as a string. + /// + /// Warning - due to the synchronous method this function uses to fetch assets, its use + /// may be dangerous and unreliable while running in grid mode. + /// + /// Name of the notecard or its asset id + /// The line number to read. The first line is line 0 + /// Notecard line public string osGetNotecardLine(string name, int line) { CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine"); @@ -1799,17 +1826,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api }; return NotecardCache.GetLine(assetID, line, 255); - - } - /*Instead of using the LSL Dataserver event to pull notecard data line by line, - this will simply read the entire notecard and return its data as a string. - - Warning - due to the synchronous method this function uses to fetch assets, its use - may be dangerous and unreliable while running in grid mode. - */ - + /// + /// Get an entire notecard at once. + /// + /// + /// Instead of using the LSL Dataserver event to pull notecard data line by line, + /// this will simply read the entire notecard and return its data as a string. + /// + /// Warning - due to the synchronous method this function uses to fetch assets, its use + /// may be dangerous and unreliable while running in grid mode. + /// + /// Name of the notecard or its asset id + /// Notecard text public string osGetNotecard(string name) { CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard"); @@ -1857,17 +1887,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } return NotecardData; - - } - /*Instead of using the LSL Dataserver event to pull notecard data, - this will simply read the number of note card lines and return this data as an integer. - - Warning - due to the synchronous method this function uses to fetch assets, its use - may be dangerous and unreliable while running in grid mode. - */ - + /// + /// Get the number of lines in the given notecard. + /// + /// + /// Instead of using the LSL Dataserver event to pull notecard data, + /// this will simply read the number of note card lines and return this data as an integer. + /// + /// Warning - due to the synchronous method this function uses to fetch assets, its use + /// may be dangerous and unreliable while running in grid mode. + /// + /// Name of the notecard or its asset id + /// public int osGetNumberOfNotecardLines(string name) { CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines"); @@ -1947,15 +1980,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { return ""; } - } + /// + /// Get the nickname of this grid, as set in the [GridInfo] config section. + /// + /// /// Threat level is Moderate because intentional abuse, for instance /// scripts that are written to be malicious only on one grid, /// for instance in a HG scenario, are a distinct possibility. - /// - /// Use value from the config file and return it. - /// + /// + /// public string osGetGridNick() { CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); @@ -2063,12 +2098,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return World.RegionInfo.RegionSettings.LoadedCreationID; } - // Threat level is 'Low' because certain users could possibly be tricked into - // dropping an unverified script into one of their own objects, which could - // then gather the physical construction details of the object and transmit it - // to an unscrupulous third party, thus permitting unauthorized duplication of - // the object's form. - // + /// + /// Get the primitive parameters of a linked prim. + /// + /// + /// Threat level is 'Low' because certain users could possibly be tricked into + /// dropping an unverified script into one of their own objects, which could + /// then gather the physical construction details of the object and transmit it + /// to an unscrupulous third party, thus permitting unauthorized duplication of + /// the object's form. + /// + /// + /// + /// public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) { CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams"); @@ -2344,10 +2386,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api obj.Shape.ProjectionFocus = (float)focus; obj.Shape.ProjectionAmbiance = (float)amb; - obj.ParentGroup.HasGroupChanged = true; obj.ScheduleFullUpdate(); - } /// @@ -2372,6 +2412,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } }); + return result; } @@ -2391,4 +2432,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); } } -} +} \ No newline at end of file -- cgit v1.1 From 3e16a0fbdd9477f24a93e0e70311bfca7995e339 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 9 Aug 2011 00:12:41 +0100 Subject: factor out common notecard caching code from 3 methods. --- .../Shared/Api/Implementation/OSSL_Api.cs | 167 +++++++++------------ 1 file changed, 74 insertions(+), 93 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 32ad21f..154179c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1733,7 +1733,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api SaveNotecard(notecardName, notecardData.ToString()); } - protected void SaveNotecard(string notecardName, string notecardData) + /// + /// Save a notecard to prim inventory. + /// + /// + /// + /// Prim inventory item created. + protected TaskInventoryItem SaveNotecard(string notecardName, string notecardData) { // Create new asset AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString()); @@ -1770,6 +1776,66 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api taskItem.AssetID = asset.FullID; m_host.Inventory.AddInventoryItem(taskItem, false); + + return taskItem; + } + + /// + /// Load the notecard data found at the given prim inventory item name or asset uuid. + /// + /// + /// The text loaded. Null if no notecard was found. + protected string LoadNotecard(string notecardNameOrUuid) + { + UUID assetID = CacheNotecard(notecardNameOrUuid); + StringBuilder notecardData = new StringBuilder(); + + for (int count = 0; count < NotecardCache.GetLines(assetID); count++) + notecardData.Append(NotecardCache.GetLine(assetID, count, 255) + "\n"); + + return notecardData.ToString(); + } + + /// + /// Cache a notecard's contents. + /// + /// + /// + /// The asset id of the notecard, which is used for retrieving the cached data. + /// UUID.Zero if no asset could be found. + /// + protected UUID CacheNotecard(string notecardNameOrUuid) + { + UUID assetID = UUID.Zero; + StringBuilder notecardData = new StringBuilder(); + + if (!UUID.TryParse(notecardNameOrUuid, out assetID)) + { + foreach (TaskInventoryItem item in m_host.TaskInventory.Values) + { + if (item.Type == 7 && item.Name == notecardNameOrUuid) + { + assetID = item.AssetID; + } + } + } + + if (assetID == UUID.Zero) + return UUID.Zero; + + if (!NotecardCache.IsCached(assetID)) + { + AssetBase a = World.AssetService.Get(assetID.ToString()); + + if (a == null) + return UUID.Zero; + + System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); + string data = enc.GetString(a.Data); + NotecardCache.Cache(assetID, data); + }; + + return assetID; } /// @@ -1790,18 +1856,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine"); m_host.AddScriptLPS(1); - UUID assetID = UUID.Zero; - - if (!UUID.TryParse(name, out assetID)) - { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) - { - if (item.Type == 7 && item.Name == name) - { - assetID = item.AssetID; - } - } - } + UUID assetID = CacheNotecard(name); if (assetID == UUID.Zero) { @@ -1809,22 +1864,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return "ERROR!"; } - if (!NotecardCache.IsCached(assetID)) - { - AssetBase a = World.AssetService.Get(assetID.ToString()); - if (a != null) - { - System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); - string data = enc.GetString(a.Data); - NotecardCache.Cache(assetID, data); - } - else - { - OSSLShoutError("Notecard '" + name + "' could not be found."); - return "ERROR!"; - } - }; - return NotecardCache.GetLine(assetID, line, 255); } @@ -1845,48 +1884,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard"); m_host.AddScriptLPS(1); - UUID assetID = UUID.Zero; - string NotecardData = ""; - - if (!UUID.TryParse(name, out assetID)) - { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) - { - if (item.Type == 7 && item.Name == name) - { - assetID = item.AssetID; - } - } - } + string text = LoadNotecard(name); - if (assetID == UUID.Zero) + if (text == null) { OSSLShoutError("Notecard '" + name + "' could not be found."); return "ERROR!"; } - - if (!NotecardCache.IsCached(assetID)) - { - AssetBase a = World.AssetService.Get(assetID.ToString()); - if (a != null) - { - System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); - string data = enc.GetString(a.Data); - NotecardCache.Cache(assetID, data); - } - else - { - OSSLShoutError("Notecard '" + name + "' could not be found."); - return "ERROR!"; - } - }; - - for (int count = 0; count < NotecardCache.GetLines(assetID); count++) + else { - NotecardData += NotecardCache.GetLine(assetID, count, 255) + "\n"; + return text; } - - return NotecardData; } /// @@ -1906,18 +1914,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines"); m_host.AddScriptLPS(1); - UUID assetID = UUID.Zero; - - if (!UUID.TryParse(name, out assetID)) - { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) - { - if (item.Type == 7 && item.Name == name) - { - assetID = item.AssetID; - } - } - } + UUID assetID = CacheNotecard(name); if (assetID == UUID.Zero) { @@ -1925,22 +1922,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return -1; } - if (!NotecardCache.IsCached(assetID)) - { - AssetBase a = World.AssetService.Get(assetID.ToString()); - if (a != null) - { - System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); - string data = enc.GetString(a.Data); - NotecardCache.Cache(assetID, data); - } - else - { - OSSLShoutError("Notecard '" + name + "' could not be found."); - return -1; - } - }; - return NotecardCache.GetLines(assetID); } @@ -2412,7 +2393,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } }); - + return result; } -- cgit v1.1 From e869eeb0bfc48c769f680970f99e4c67dd5a1a70 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 9 Aug 2011 03:51:34 +0100 Subject: Implement first draft functions for saving and loading NPC appearance from storage. This works by serializing and deserializing NPC AvatarAppearance to a notecard in the prim inventory and making the required baked textures permanent. By using notecards, we avoid lots of awkward, technical and user-unfriendly issues concerning retaining asset references and creating a new asset type. Notecards also allow different appearances to be swapped and manipulated easily. This also allows stored NPC appearances to work transparently with OARs/IARs since the UUID scan will pick up and store the necessary references from the notecard text. This works in my basic test but is not at all ready for user use or bug reporting yet. --- .../Shared/Api/Implementation/LSL_Api.cs | 33 +++++-- .../Shared/Api/Implementation/OSSL_Api.cs | 104 ++++++++++++++++++--- .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 10 ++ 4 files changed, 130 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 7c21ba9..86ee28a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -10565,9 +10565,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - public static string GetLine(UUID assetID, int line, int maxLength) + /// + /// Get a notecard line. + /// + /// + /// Lines start at index 0 + /// + public static string GetLine(UUID assetID, int lineNumber) { - if (line < 0) + if (lineNumber < 0) return ""; string data; @@ -10579,17 +10585,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_Notecards[assetID].lastRef = DateTime.Now; - if (line >= m_Notecards[assetID].text.Length) + if (lineNumber >= m_Notecards[assetID].text.Length) return "\n\n\n"; - data = m_Notecards[assetID].text[line]; - if (data.Length > maxLength) - data = data.Substring(0, maxLength); + data = m_Notecards[assetID].text[lineNumber]; return data; } } + /// + /// Get a notecard line. + /// + /// + /// Lines start at index 0 + /// Maximum length of the returned line. Longer lines will be truncated + /// + public static string GetLine(UUID assetID, int lineNumber, int maxLength) + { + string line = GetLine(assetID, lineNumber); + + if (line.Length > maxLength) + line = line.Substring(0, maxLength); + + return line; + } + public static void CacheCheck() { foreach (UUID key in new List(m_Notecards.Keys)) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 154179c..07b36de 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -28,11 +28,16 @@ using System; using System.Collections; using System.Collections.Generic; +using System.IO; +using System.Reflection; using System.Runtime.Remoting.Lifetime; using System.Text; using System.Net; using System.Threading; +using System.Xml; +using log4net; using OpenMetaverse; +using OpenMetaverse.StructuredData; using Nini.Config; using OpenSim; using OpenSim.Framework; @@ -119,6 +124,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api [Serializable] public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + internal IScriptEngine m_ScriptEngine; internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there internal SceneObjectPart m_host; @@ -1730,26 +1737,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api for (int i = 0; i < contents.Length; i++) notecardData.Append((string)(contents.GetLSLStringItem(i) + "\n")); - SaveNotecard(notecardName, notecardData.ToString()); + SaveNotecard(notecardName, "Script generated notecard", notecardData.ToString(), false); } /// /// Save a notecard to prim inventory. /// - /// + /// + /// Description of notecard /// + /// + /// If true, then if an item exists with the same name, it is replaced. + /// If false, then a new item is created witha slightly different name (e.g. name 1) + /// /// Prim inventory item created. - protected TaskInventoryItem SaveNotecard(string notecardName, string notecardData) + protected TaskInventoryItem SaveNotecard(string name, string description, string data, bool forceSameName) { // Create new asset - AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString()); - asset.Description = "Script Generated Notecard"; + AssetBase asset = new AssetBase(UUID.Random(), name, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString()); + asset.Description = description; - int textLength = notecardData.Length; - notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " - + textLength.ToString() + "\n" + notecardData + "}\n"; + int textLength = data.Length; + data + = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " + + textLength.ToString() + "\n" + data + "}\n"; - asset.Data = Util.UTF8.GetBytes(notecardData); + asset.Data = Util.UTF8.GetBytes(data); World.AssetService.Store(asset); // Create Task Entry @@ -1775,7 +1788,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api taskItem.PermsMask = 0; taskItem.AssetID = asset.FullID; - m_host.Inventory.AddInventoryItem(taskItem, false); + if (forceSameName) + m_host.Inventory.AddInventoryItemExclusive(taskItem, false); + else + m_host.Inventory.AddInventoryItem(taskItem, false); return taskItem; } @@ -1791,7 +1807,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api StringBuilder notecardData = new StringBuilder(); for (int count = 0; count < NotecardCache.GetLines(assetID); count++) - notecardData.Append(NotecardCache.GetLine(assetID, count, 255) + "\n"); + { + string line = NotecardCache.GetLine(assetID, count) + "\n"; + +// m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line); + + notecardData.Append(line); + } return notecardData.ToString(); } @@ -1807,7 +1829,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected UUID CacheNotecard(string notecardNameOrUuid) { UUID assetID = UUID.Zero; - StringBuilder notecardData = new StringBuilder(); if (!UUID.TryParse(notecardNameOrUuid, out assetID)) { @@ -1864,7 +1885,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return "ERROR!"; } - return NotecardCache.GetLine(assetID, line, 255); + return NotecardCache.GetLine(assetID, line); } /// @@ -2122,9 +2143,66 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new LSL_Key(x.ToString()); } + return new LSL_Key(UUID.Zero.ToString()); } + public LSL_Key osNpcSaveAppearance(string avatar, string notecardName) + { + CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance"); + + INPCModule npcModule = World.RequestModuleInterface(); + IAvatarFactory appearanceModule = World.RequestModuleInterface(); + + if (npcModule != null && appearanceModule != null) + { + UUID avatarId = UUID.Zero; + if (!UUID.TryParse(avatar, out avatarId)) + return new LSL_Key(UUID.Zero.ToString()); + + if (!npcModule.IsNPC(avatarId, m_host.ParentGroup.Scene)) + return new LSL_Key(UUID.Zero.ToString()); + + appearanceModule.SaveBakedTextures(avatarId); + ScenePresence sp = m_host.ParentGroup.Scene.GetScenePresence(avatarId); + OSDMap appearancePacked = sp.Appearance.Pack(); + + TaskInventoryItem item + = SaveNotecard(notecardName, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true); + + return new LSL_Key(item.AssetID.ToString()); + } + + return new LSL_Key(UUID.Zero.ToString()); + } + + public void osNpcLoadAppearance(string avatar, string notecardNameOrUuid) + { + CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance"); + + INPCModule npcModule = World.RequestModuleInterface(); + + if (npcModule != null) + { + UUID avatarId = UUID.Zero; + if (!UUID.TryParse(avatar, out avatarId)) + return; + + if (!npcModule.IsNPC(avatarId, m_host.ParentGroup.Scene)) + return; + + string appearanceSerialized = LoadNotecard(notecardNameOrUuid); + OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); +// OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized); +// Console.WriteLine("appearanceSerialized {0}", appearanceSerialized); +// Console.WriteLine("a.Type {0}, a.ToString() {1}", a.Type, a); + AvatarAppearance appearance = new AvatarAppearance(); + appearance.Unpack(appearanceOsd); + + npcModule.SetNPCAppearance(avatarId, appearance, m_host.ParentGroup.Scene); + } + } + public void osNpcMoveTo(LSL_Key npc, LSL_Vector position) { CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 19352f0..868af27 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -170,6 +170,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces key osNpcCreate(string user, string name, vector position, key cloneFrom); + LSL_Key osNpcSaveAppearance(string avatar, string notecardName); + void osNpcLoadAppearance(string avatar, string notecardNameOrUuid); void osNpcMoveTo(key npc, vector position); void osNpcSay(key npc, string message); void osNpcRemove(key npc); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 7c59098..959b5d5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -483,6 +483,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom); } + public key osNpcSaveAppearance(string avatar, string notecardName) + { + return m_OSSL_Functions.osNpcSaveAppearance(avatar, notecardName); + } + + public void osNpcLoadAppearance(string avatar, string notecardNameOrUuid) + { + m_OSSL_Functions.osNpcLoadAppearance(avatar, notecardNameOrUuid); + } + public void osNpcMoveTo(key npc, vector position) { m_OSSL_Functions.osNpcMoveTo(npc, position); -- cgit v1.1 From 795c8e6c22d4174d942ad56e70a0acbe507e2ec7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 9 Aug 2011 22:05:47 +0100 Subject: Add osOwnerSaveAppearance() to help with setting up NPC appearances. Not yet ready for user use. Adds regression test. --- .../Shared/Api/Implementation/OSSL_Api.cs | 51 ++++++++-- .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 + .../Shared/Tests/OSSL_ApiAppearanceTest.cs | 105 +++++++++++++++++++++ 4 files changed, 153 insertions(+), 10 deletions(-) create mode 100644 OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 07b36de..a05c623 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2147,14 +2147,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new LSL_Key(UUID.Zero.ToString()); } + /// + /// Save the current appearance of the NPC permanently to the named notecard. + /// + /// + /// The name of the notecard to which to save the appearance. + /// The asset ID of the notecard saved. public LSL_Key osNpcSaveAppearance(string avatar, string notecardName) { CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance"); INPCModule npcModule = World.RequestModuleInterface(); - IAvatarFactory appearanceModule = World.RequestModuleInterface(); - if (npcModule != null && appearanceModule != null) + if (npcModule != null) { UUID avatarId = UUID.Zero; if (!UUID.TryParse(avatar, out avatarId)) @@ -2163,14 +2168,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!npcModule.IsNPC(avatarId, m_host.ParentGroup.Scene)) return new LSL_Key(UUID.Zero.ToString()); - appearanceModule.SaveBakedTextures(avatarId); - ScenePresence sp = m_host.ParentGroup.Scene.GetScenePresence(avatarId); - OSDMap appearancePacked = sp.Appearance.Pack(); - - TaskInventoryItem item - = SaveNotecard(notecardName, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true); - - return new LSL_Key(item.AssetID.ToString()); + return SaveAppearanceToNotecard(avatarId, notecardName); } return new LSL_Key(UUID.Zero.ToString()); @@ -2236,6 +2234,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api module.DeleteNPC(new UUID(npc.m_string), World); } } + + /// + /// Save the current appearance of the script owner permanently to the named notecard. + /// + /// The name of the notecard to which to save the appearance. + /// The asset ID of the notecard saved. + public LSL_Key osOwnerSaveAppearance(string notecardName) + { + CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance"); + + return SaveAppearanceToNotecard(m_host.OwnerID, notecardName); + } + + protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecardName) + { + IAvatarFactory appearanceModule = World.RequestModuleInterface(); + + if (appearanceModule != null) + { + appearanceModule.SaveBakedTextures(m_host.OwnerID); + ScenePresence sp = m_host.ParentGroup.Scene.GetScenePresence(m_host.OwnerID); + OSDMap appearancePacked = sp.Appearance.Pack(); + + TaskInventoryItem item + = SaveNotecard(notecardName, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true); + + return new LSL_Key(item.AssetID.ToString()); + } + else + { + return new LSL_Key(UUID.Zero.ToString()); + } + } /// /// Get current region's map texture UUID diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 868af27..92473ae 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -176,6 +176,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osNpcSay(key npc, string message); void osNpcRemove(key npc); + LSL_Key osOwnerSaveAppearance(string notecardName); + key osGetMapTexture(); key osGetRegionMapTexture(string regionName); LSL_List osGetRegionStats(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 959b5d5..4b21c88 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -508,6 +508,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osNpcRemove(npc); } + public LSL_Key osOwnerSaveAppearance(string notecardName) + { + return m_OSSL_Functions.osOwnerSaveAppearance(notecardName); + } + public OSSLPrim Prim; [Serializable] diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs new file mode 100644 index 0000000..fc8b551 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs @@ -0,0 +1,105 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; +using Nini.Config; +using NUnit.Framework; +using OpenMetaverse; +using OpenMetaverse.Assets; +using OpenMetaverse.StructuredData; +using OpenSim.Framework; +using OpenSim.Region.CoreModules.Avatar.AvatarFactory; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.ScriptEngine.Shared; +using OpenSim.Region.ScriptEngine.Shared.Api; +using OpenSim.Services.Interfaces; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Region.ScriptEngine.Shared.Tests +{ + /// + /// Tests for OSSL_Api + /// + [TestFixture] + public class OSSL_ApiAppearanceTest + { + [Test] + public void TestOsOwnerSaveAppearance() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + IConfigSource initConfigSource = new IniConfigSource(); + IConfig config = initConfigSource.AddConfig("XEngine"); + config.Set("Enabled", "true"); + config.Set("AllowOSFunctions", "true"); + config.Set("OSFunctionThreatLevel", "Severe"); + + UUID userId = TestHelpers.ParseTail(0x1); + float newHeight = 1.9f; + + Scene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, new AvatarFactoryModule()); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); + sp.Appearance.AvatarHeight = newHeight; + SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); + SceneObjectPart part = so.RootPart; + scene.AddSceneObject(so); + + XEngine.XEngine engine = new XEngine.XEngine(); + engine.Initialise(initConfigSource); + engine.AddRegion(scene); + + OSSL_Api osslApi = new OSSL_Api(); + osslApi.Initialize(engine, part, part.LocalId, part.UUID); + + string notecardName = "appearanceNc"; + + osslApi.osOwnerSaveAppearance(notecardName); + + IList items = part.Inventory.GetInventoryItems(notecardName); + Assert.That(items.Count, Is.EqualTo(1)); + + TaskInventoryItem ncItem = items[0]; + Assert.That(ncItem.Name, Is.EqualTo(notecardName)); + + AssetBase ncAsset = scene.AssetService.Get(ncItem.AssetID.ToString()); + Assert.That(ncAsset, Is.Not.Null); + + AssetNotecard anc = new AssetNotecard(UUID.Zero, ncAsset.Data); + anc.Decode(); + OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(anc.BodyText); + AvatarAppearance savedAppearance = new AvatarAppearance(); + savedAppearance.Unpack(appearanceOsd); + + Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight)); + } + } +} \ No newline at end of file -- cgit v1.1 From 195c1dc9b8b8511980d9a607a242b24a5a91da17 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 10 Aug 2011 00:26:38 +0100 Subject: implement osNpcStopMoveTo() to cancel any current move target --- .../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 9 +++++++++ OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++ 3 files changed, 15 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index a05c623..9c32029 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2213,6 +2213,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + public void osNpcStopMoveTo(LSL_Key npc) + { + CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); + + INPCModule module = World.RequestModuleInterface(); + if (module != null) + module.StopMoveToTarget(new UUID(npc.m_string), World); + } + public void osNpcSay(LSL_Key npc, string message) { CheckThreatLevel(ThreatLevel.High, "osNpcSay"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 92473ae..ab0097a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -173,6 +173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Key osNpcSaveAppearance(string avatar, string notecardName); void osNpcLoadAppearance(string avatar, string notecardNameOrUuid); void osNpcMoveTo(key npc, vector position); + void osNpcStopMoveTo(LSL_Key npc); void osNpcSay(key npc, string message); void osNpcRemove(key npc); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 4b21c88..a7843dd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -498,6 +498,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osNpcMoveTo(npc, position); } + public void osNpcStopMoveTo(LSL_Key npc) + { + m_OSSL_Functions.osNpcStopMoveTo(npc); + } + public void osNpcSay(key npc, string message) { m_OSSL_Functions.osNpcSay(npc, message); -- cgit v1.1 From 5d6c9644faf6aeac38410af9cff97adfef88d7aa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 10 Aug 2011 01:47:37 +0100 Subject: early code to allow scripts to force npcs not to fly when moving to target this is to allow walking on prims. it will be up to the script writer to be sure that there is a continuous path. currently implemented in osNpcMoveToTarget(), but none of this is final. --- .../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 14 +++++++++++++- .../Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + .../Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++ 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 9c32029..63c882d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2209,7 +2209,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (module != null) { Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); - module.MoveToTarget(new UUID(npc.m_string), World, pos); + module.MoveToTarget(new UUID(npc.m_string), World, pos, false); + } + } + + public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector position, int noFly) + { + CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget"); + + INPCModule module = World.RequestModuleInterface(); + if (module != null) + { + Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); + module.MoveToTarget(new UUID(npc.m_string), World, pos, noFly != 0); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index ab0097a..56be9d9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -173,6 +173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Key osNpcSaveAppearance(string avatar, string notecardName); void osNpcLoadAppearance(string avatar, string notecardNameOrUuid); void osNpcMoveTo(key npc, vector position); + void osNpcMoveToTarget(key npc, vector position, int noFly); void osNpcStopMoveTo(LSL_Key npc); void osNpcSay(key npc, string message); void osNpcRemove(key npc); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index a7843dd..c745e5c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -498,6 +498,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osNpcMoveTo(npc, position); } + public void osNpcMoveToTarget(key npc, vector position, int noFly) + { + m_OSSL_Functions.osNpcMoveToTarget(npc, position, noFly); + } + public void osNpcStopMoveTo(LSL_Key npc) { m_OSSL_Functions.osNpcStopMoveTo(npc); -- cgit v1.1 From fb92678b83dca1c1f64cc91f3ac887170408a455 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 10 Aug 2011 22:34:42 +0100 Subject: fly and no fly constants for osNpcMoveToTarget() --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 63c882d..9b5d8d9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2220,7 +2220,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api INPCModule module = World.RequestModuleInterface(); if (module != null) { - Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); + Vector3 pos = new Vector3((float)position.x, (float)position.y, (float)position.z); module.MoveToTarget(new UUID(npc.m_string), World, pos, noFly != 0); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 3f90788..9ed894c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -591,6 +591,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int STATS_ACTIVE_SCRIPTS = 19; public const int STATS_SCRIPT_LPS = 20; + // Constants for osNpc* functions + public const int OS_NPC_FLY = 0; + public const int OS_NPC_NO_FLY = 1; + public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; -- cgit v1.1 From 7f499ff3f386d57bcd81ebb3f58f110011100604 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 10 Aug 2011 23:56:19 +0100 Subject: Add a OS_NPC_LAND_AT_TARGET option to osMoveToTarget() Default for this function is now not to automatically land. This allows better control by scripts when an avatar is going to be landing on a prim rather than the ground. Stopping the avatar involves faking a collision, to avoid the pid controller making it overshoot. A better approach would be to gradually slow the avatar as we near the target --- .../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 11 ++++++++--- .../Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 9b5d8d9..f83304b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2209,11 +2209,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (module != null) { Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); - module.MoveToTarget(new UUID(npc.m_string), World, pos, false); + module.MoveToTarget(new UUID(npc.m_string), World, pos, false, true); } } - public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector position, int noFly) + public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector position, int moveParams) { CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget"); @@ -2221,7 +2221,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (module != null) { Vector3 pos = new Vector3((float)position.x, (float)position.y, (float)position.z); - module.MoveToTarget(new UUID(npc.m_string), World, pos, noFly != 0); + module.MoveToTarget( + new UUID(npc.m_string), + World, + pos, + (moveParams & ScriptBaseClass.OS_NPC_NO_FLY) != 0, + (moveParams & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 9ed894c..e82c281 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -594,6 +594,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase // Constants for osNpc* functions public const int OS_NPC_FLY = 0; public const int OS_NPC_NO_FLY = 1; + public const int OS_NPC_LAND_AT_TARGET = 2; public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; -- cgit v1.1 From 4402851b086e7faf0d441d2ae0d5f6a3e1ea04b8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 01:56:42 +0100 Subject: Get NPCs to revert to the correct 'resting' animation (e.g. stand or hover) after finishing their movement. This also fixes judder after an avatar has finished "go here"/autopilot movement in a viewer. This meant reseting the SP.AgentControlFlags since the Animator uses these to determine the correct default animation. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index f83304b..71fc15f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -870,7 +870,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ScenePresence target = (ScenePresence)World.Entities[avatarID]; if (target != null) { - UUID animID=UUID.Zero; + UUID animID = UUID.Zero; lock (m_host.TaskInventory) { foreach (KeyValuePair inv in m_host.TaskInventory) -- cgit v1.1 From ee22569c9262277467df9a4b15674a1472fa0b71 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 02:19:13 +0100 Subject: only accept npc UUIDs to osNpc* functions, not names (except for create) --- .../Shared/Api/Implementation/OSSL_Api.cs | 26 +++++++++------------- .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 6 ++--- .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 12 +++++----- 3 files changed, 20 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 71fc15f..91ac3b7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2153,7 +2153,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// /// The name of the notecard to which to save the appearance. /// The asset ID of the notecard saved. - public LSL_Key osNpcSaveAppearance(string avatar, string notecardName) + public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecardName) { CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance"); @@ -2161,20 +2161,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (npcModule != null) { - UUID avatarId = UUID.Zero; - if (!UUID.TryParse(avatar, out avatarId)) - return new LSL_Key(UUID.Zero.ToString()); + UUID npcId = new UUID(npc.m_string); - if (!npcModule.IsNPC(avatarId, m_host.ParentGroup.Scene)) + if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) return new LSL_Key(UUID.Zero.ToString()); - return SaveAppearanceToNotecard(avatarId, notecardName); + return SaveAppearanceToNotecard(npcId, notecardName); } return new LSL_Key(UUID.Zero.ToString()); } - public void osNpcLoadAppearance(string avatar, string notecardNameOrUuid) + public void osNpcLoadAppearance(LSL_Key npc, string notecardNameOrUuid) { CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance"); @@ -2182,11 +2180,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (npcModule != null) { - UUID avatarId = UUID.Zero; - if (!UUID.TryParse(avatar, out avatarId)) - return; + UUID npcId = new UUID(npc.m_string); - if (!npcModule.IsNPC(avatarId, m_host.ParentGroup.Scene)) + if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) return; string appearanceSerialized = LoadNotecard(notecardNameOrUuid); @@ -2197,7 +2193,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api AvatarAppearance appearance = new AvatarAppearance(); appearance.Unpack(appearanceOsd); - npcModule.SetNPCAppearance(avatarId, appearance, m_host.ParentGroup.Scene); + npcModule.SetNPCAppearance(npcId, appearance, m_host.ParentGroup.Scene); } } @@ -2213,7 +2209,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector position, int moveParams) + public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector position, int options) { CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget"); @@ -2225,8 +2221,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api new UUID(npc.m_string), World, pos, - (moveParams & ScriptBaseClass.OS_NPC_NO_FLY) != 0, - (moveParams & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0); + (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, + (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 56be9d9..f4a618b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -170,10 +170,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces key osNpcCreate(string user, string name, vector position, key cloneFrom); - LSL_Key osNpcSaveAppearance(string avatar, string notecardName); - void osNpcLoadAppearance(string avatar, string notecardNameOrUuid); + LSL_Key osNpcSaveAppearance(key npc, string notecardName); + void osNpcLoadAppearance(key npc, string notecardNameOrUuid); void osNpcMoveTo(key npc, vector position); - void osNpcMoveToTarget(key npc, vector position, int noFly); + void osNpcMoveToTarget(key npc, vector position, int options); void osNpcStopMoveTo(LSL_Key npc); void osNpcSay(key npc, string message); void osNpcRemove(key npc); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index c745e5c..84d61f4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -483,14 +483,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom); } - public key osNpcSaveAppearance(string avatar, string notecardName) + public key osNpcSaveAppearance(key npc, string notecardName) { - return m_OSSL_Functions.osNpcSaveAppearance(avatar, notecardName); + return m_OSSL_Functions.osNpcSaveAppearance(npc, notecardName); } - public void osNpcLoadAppearance(string avatar, string notecardNameOrUuid) + public void osNpcLoadAppearance(key npc, string notecardNameOrUuid) { - m_OSSL_Functions.osNpcLoadAppearance(avatar, notecardNameOrUuid); + m_OSSL_Functions.osNpcLoadAppearance(npc, notecardNameOrUuid); } public void osNpcMoveTo(key npc, vector position) @@ -498,9 +498,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osNpcMoveTo(npc, position); } - public void osNpcMoveToTarget(key npc, vector position, int noFly) + public void osNpcMoveToTarget(key npc, vector position, int options) { - m_OSSL_Functions.osNpcMoveToTarget(npc, position, noFly); + m_OSSL_Functions.osNpcMoveToTarget(npc, position, options); } public void osNpcStopMoveTo(LSL_Key npc) -- cgit v1.1 From 83ca5a101d5578282ba0fd7177fcb618f70d3cc9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 20:56:18 +0100 Subject: Split out to-be-common setup stuff from TestOsOwnerSaveAppearance() --- .../Shared/Tests/OSSL_ApiAppearanceTest.cs | 48 +++++++++++++++------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs index fc8b551..2218a1f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs @@ -50,35 +50,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [TestFixture] public class OSSL_ApiAppearanceTest { - [Test] - public void TestOsOwnerSaveAppearance() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); + protected Scene m_scene; + protected XEngine.XEngine m_engine; + [SetUp] + public void SetUp() + { IConfigSource initConfigSource = new IniConfigSource(); IConfig config = initConfigSource.AddConfig("XEngine"); config.Set("Enabled", "true"); config.Set("AllowOSFunctions", "true"); config.Set("OSFunctionThreatLevel", "Severe"); + m_scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(m_scene, new AvatarFactoryModule()); + + m_engine = new XEngine.XEngine(); + m_engine.Initialise(initConfigSource); + m_engine.AddRegion(m_scene); + } + + /// + /// Test creation of an NPC where the appearance data comes from a notecard + /// +// [Test] +// public void TestOsNpcCreateFromNotecard() +// { +// TestHelpers.InMethod(); +//// log4net.Config.XmlConfigurator.Configure(); +// } + + [Test] + public void TestOsOwnerSaveAppearance() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + UUID userId = TestHelpers.ParseTail(0x1); float newHeight = 1.9f; - Scene scene = SceneHelpers.SetupScene(); - SceneHelpers.SetupSceneModules(scene, new AvatarFactoryModule()); - ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); + ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); sp.Appearance.AvatarHeight = newHeight; SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); SceneObjectPart part = so.RootPart; - scene.AddSceneObject(so); - - XEngine.XEngine engine = new XEngine.XEngine(); - engine.Initialise(initConfigSource); - engine.AddRegion(scene); + m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); - osslApi.Initialize(engine, part, part.LocalId, part.UUID); + osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); string notecardName = "appearanceNc"; @@ -90,7 +108,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests TaskInventoryItem ncItem = items[0]; Assert.That(ncItem.Name, Is.EqualTo(notecardName)); - AssetBase ncAsset = scene.AssetService.Get(ncItem.AssetID.ToString()); + AssetBase ncAsset = m_scene.AssetService.Get(ncItem.AssetID.ToString()); Assert.That(ncAsset, Is.Not.Null); AssetNotecard anc = new AssetNotecard(UUID.Zero, ncAsset.Data); -- cgit v1.1 From 50945dd56029a1280c581ea9b29213ab0e162a0a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 21:43:26 +0100 Subject: add regression test for osNpcCreate when cloning an in-region avatar --- .../Shared/Api/Implementation/OSSL_Api.cs | 6 +- .../Shared/Tests/OSSL_ApiAppearanceTest.cs | 79 ++++++++++++++++++++-- 2 files changed, 77 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 91ac3b7..b18aa3b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2135,11 +2135,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api INPCModule module = World.RequestModuleInterface(); if (module != null) { + ScenePresence clonePresence = World.GetScenePresence(new UUID(cloneFrom.m_string)); + if (clonePresence == null) + return new LSL_Key(UUID.Zero.ToString()); + UUID x = module.CreateNPC(firstname, lastname, new Vector3((float) position.x, (float) position.y, (float) position.z), World, - new UUID(cloneFrom)); + clonePresence.Appearance); return new LSL_Key(x.ToString()); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs index 2218a1f..7f778d7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs @@ -27,7 +27,9 @@ using System; using System.Collections.Generic; +using System.Reflection; using System.Text; +using log4net; using Nini.Config; using NUnit.Framework; using OpenMetaverse; @@ -35,6 +37,7 @@ using OpenMetaverse.Assets; using OpenMetaverse.StructuredData; using OpenSim.Framework; using OpenSim.Region.CoreModules.Avatar.AvatarFactory; +using OpenSim.Region.OptionalModules.World.NPC; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared.Api; @@ -61,9 +64,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests config.Set("Enabled", "true"); config.Set("AllowOSFunctions", "true"); config.Set("OSFunctionThreatLevel", "Severe"); + config = initConfigSource.AddConfig("NPC"); + config.Set("Enabled", "true"); m_scene = SceneHelpers.SetupScene(); - SceneHelpers.SetupSceneModules(m_scene, new AvatarFactoryModule()); + SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); m_engine = new XEngine.XEngine(); m_engine.Initialise(initConfigSource); @@ -73,12 +78,72 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests /// /// Test creation of an NPC where the appearance data comes from a notecard /// -// [Test] -// public void TestOsNpcCreateFromNotecard() -// { -// TestHelpers.InMethod(); -//// log4net.Config.XmlConfigurator.Configure(); -// } + //[Test] + public void TestOsNpcCreateFromNotecard() + { + TestHelpers.InMethod(); + log4net.Config.XmlConfigurator.Configure(); + + // Store an avatar with a different height from default in a notecard. + UUID userId = TestHelpers.ParseTail(0x1); + float newHeight = 1.9f; + + ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); + sp.Appearance.AvatarHeight = newHeight; + SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); + SceneObjectPart part = so.RootPart; + m_scene.AddSceneObject(so); + + OSSL_Api osslApi = new OSSL_Api(); + osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); + + string notecardName = "appearanceNc"; + osslApi.osOwnerSaveAppearance(notecardName); + + // Try creating a bot using the appearance in the notecard. + string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName); + Assert.That(npcRaw, Is.Not.Null); + + UUID npcId = new UUID(npcRaw); + ScenePresence npc = m_scene.GetScenePresence(npcId); + Assert.That(npc, Is.Not.Null); + Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight)); + } + + /// + /// Test creation of an NPC where the appearance data comes from an avatar already in the region. + /// + [Test] + public void TestOsNpcCreateFromAvatar() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + // Store an avatar with a different height from default in a notecard. + UUID userId = TestHelpers.ParseTail(0x1); + float newHeight = 1.9f; + + ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); + sp.Appearance.AvatarHeight = newHeight; + SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); + SceneObjectPart part = so.RootPart; + m_scene.AddSceneObject(so); + + OSSL_Api osslApi = new OSSL_Api(); + osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); + + string notecardName = "appearanceNc"; + osslApi.osOwnerSaveAppearance(notecardName); + + // Try creating a bot using the existing avatar's appearance + string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), sp.UUID.ToString()); + Assert.That(npcRaw, Is.Not.Null); + + UUID npcId = new UUID(npcRaw); + ScenePresence npc = m_scene.GetScenePresence(npcId); + Assert.That(npc, Is.Not.Null); + Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight)); + } [Test] public void TestOsOwnerSaveAppearance() -- cgit v1.1 From b1ae930c6b8e7d985e2c148a4e18a59ac880dcbd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 22:26:47 +0100 Subject: Implement osAgentSaveAppearance() to save the appearance of an avatar in the region to a notecard This is separate from osOwnerSaveAppearance() so that owner saves can be allowed without allowing arbitrary avatar saves --- .../Shared/Api/Implementation/OSSL_Api.cs | 35 +++++++++++++++--- .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 +- .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++ .../Shared/Tests/OSSL_ApiAppearanceTest.cs | 41 ++++++++++++++++++++++ 4 files changed, 78 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index b18aa3b..939602a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2165,7 +2165,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (npcModule != null) { - UUID npcId = new UUID(npc.m_string); + UUID npcId; + if (!UUID.TryParse(npc.m_string, out npcId)) + return new LSL_Key(UUID.Zero.ToString()); if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) return new LSL_Key(UUID.Zero.ToString()); @@ -2273,14 +2275,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return SaveAppearanceToNotecard(m_host.OwnerID, notecardName); } - protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecardName) + public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecardName) + { + CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance"); + + return SaveAppearanceToNotecard(avatarId, notecardName); + } + + protected LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecardName) { IAvatarFactory appearanceModule = World.RequestModuleInterface(); if (appearanceModule != null) { - appearanceModule.SaveBakedTextures(m_host.OwnerID); - ScenePresence sp = m_host.ParentGroup.Scene.GetScenePresence(m_host.OwnerID); + appearanceModule.SaveBakedTextures(sp.UUID); OSDMap appearancePacked = sp.Appearance.Pack(); TaskInventoryItem item @@ -2293,6 +2301,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new LSL_Key(UUID.Zero.ToString()); } } + + protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecardName) + { + ScenePresence sp = World.GetScenePresence(avatarId); + + if (sp == null || sp.IsChildAgent) + return new LSL_Key(UUID.Zero.ToString()); + + return SaveAppearanceToNotecard(sp, notecardName); + } + + protected LSL_Key SaveAppearanceToNotecard(LSL_Key rawAvatarId, string notecardName) + { + UUID avatarId; + if (!UUID.TryParse(rawAvatarId, out avatarId)) + return new LSL_Key(UUID.Zero.ToString()); + + return SaveAppearanceToNotecard(avatarId, notecardName); + } /// /// Get current region's map texture UUID diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index f4a618b..88e1f15 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -168,7 +168,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); - key osNpcCreate(string user, string name, vector position, key cloneFrom); LSL_Key osNpcSaveAppearance(key npc, string notecardName); void osNpcLoadAppearance(key npc, string notecardNameOrUuid); @@ -179,6 +178,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osNpcRemove(key npc); LSL_Key osOwnerSaveAppearance(string notecardName); + LSL_Key osAgentSaveAppearance(key agentId, string notecardName); key osGetMapTexture(); key osGetRegionMapTexture(string regionName); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 84d61f4..4701736 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -523,6 +523,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osOwnerSaveAppearance(notecardName); } + public LSL_Key osAgentSaveAppearance(LSL_Key agentId, string notecardName) + { + return m_OSSL_Functions.osAgentSaveAppearance(agentId, notecardName); + } + public OSSLPrim Prim; [Serializable] diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs index 7f778d7..85cf507 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs @@ -184,5 +184,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight)); } + + [Test] + public void TestOsAgentSaveAppearance() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID ownerId = TestHelpers.ParseTail(0x1); + UUID nonOwnerId = TestHelpers.ParseTail(0x2); + float newHeight = 1.9f; + + ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, nonOwnerId); + sp.Appearance.AvatarHeight = newHeight; + SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId); + SceneObjectPart part = so.RootPart; + m_scene.AddSceneObject(so); + + OSSL_Api osslApi = new OSSL_Api(); + osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); + + string notecardName = "appearanceNc"; + + osslApi.osAgentSaveAppearance(new LSL_Types.LSLString(nonOwnerId.ToString()), notecardName); + + IList items = part.Inventory.GetInventoryItems(notecardName); + Assert.That(items.Count, Is.EqualTo(1)); + + TaskInventoryItem ncItem = items[0]; + Assert.That(ncItem.Name, Is.EqualTo(notecardName)); + + AssetBase ncAsset = m_scene.AssetService.Get(ncItem.AssetID.ToString()); + Assert.That(ncAsset, Is.Not.Null); + + AssetNotecard anc = new AssetNotecard(UUID.Zero, ncAsset.Data); + anc.Decode(); + OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(anc.BodyText); + AvatarAppearance savedAppearance = new AvatarAppearance(); + savedAppearance.Unpack(appearanceOsd); + + Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight)); + } } } \ No newline at end of file -- cgit v1.1 From a21e98ae1a3e2f570cc119e020d4d4ea111e0ad2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 23:28:14 +0100 Subject: implement osNpcGetRot() and osNpcSetRot() Rotation works if done around the z axis. Anything else leads to random results. --- .../Shared/Api/Implementation/LSL_Api.cs | 3 +- .../Shared/Api/Implementation/OSSL_Api.cs | 57 ++++++++++++++++++++-- .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 10 ++++ 4 files changed, 67 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 86ee28a..8a281d4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -369,7 +369,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } // convert a LSL_Rotation to a Quaternion - protected Quaternion Rot2Quaternion(LSL_Rotation r) + public static Quaternion Rot2Quaternion(LSL_Rotation r) { Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); q.Normalize(); @@ -2061,6 +2061,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { return llGetRootRotation(); } + m_host.AddScriptLPS(1); Quaternion q = m_host.GetWorldRotation(); return new LSL_Rotation(q.X, q.Y, q.Z, q.W); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 939602a..1874826 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2186,9 +2186,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (npcModule != null) { - UUID npcId = new UUID(npc.m_string); - - if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) + UUID npcId; + if (!UUID.TryParse(npc.m_string, out npcId)) return; string appearanceSerialized = LoadNotecard(notecardNameOrUuid); @@ -2210,8 +2209,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api INPCModule module = World.RequestModuleInterface(); if (module != null) { + UUID npcId; + if (!UUID.TryParse(npc.m_string, out npcId)) + return; + Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); - module.MoveToTarget(new UUID(npc.m_string), World, pos, false, true); + module.MoveToTarget(npcId, World, pos, false, true); } } @@ -2222,6 +2225,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api INPCModule module = World.RequestModuleInterface(); if (module != null) { + UUID npcId; + if (!UUID.TryParse(npc.m_string, out npcId)) + return; + Vector3 pos = new Vector3((float)position.x, (float)position.y, (float)position.z); module.MoveToTarget( new UUID(npc.m_string), @@ -2232,6 +2239,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + public LSL_Rotation osNpcGetRot(LSL_Key npc) + { + CheckThreatLevel(ThreatLevel.High, "osNpcGetRot"); + + INPCModule npcModule = World.RequestModuleInterface(); + if (npcModule != null) + { + UUID npcId; + if (!UUID.TryParse(npc.m_string, out npcId)) + return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); + + if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) + return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); + + ScenePresence sp = World.GetScenePresence(npcId); + Quaternion rot = sp.Rotation; + + return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); + } + + return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); + } + + public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation) + { + CheckThreatLevel(ThreatLevel.High, "osNpcSetRot"); + + INPCModule npcModule = World.RequestModuleInterface(); + if (npcModule != null) + { + UUID npcId; + if (!UUID.TryParse(npc.m_string, out npcId)) + return; + + if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) + return; + + ScenePresence sp = World.GetScenePresence(npcId); + sp.Rotation = LSL_Api.Rot2Quaternion(rotation); + } + } + public void osNpcStopMoveTo(LSL_Key npc) { CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 88e1f15..7c08e84 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -173,6 +173,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osNpcLoadAppearance(key npc, string notecardNameOrUuid); void osNpcMoveTo(key npc, vector position); void osNpcMoveToTarget(key npc, vector position, int options); + rotation osNpcGetRot(key npc); + void osNpcSetRot(LSL_Key npc, rotation rot); void osNpcStopMoveTo(LSL_Key npc); void osNpcSay(key npc, string message); void osNpcRemove(key npc); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 4701736..e8e5f52 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -503,6 +503,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osNpcMoveToTarget(npc, position, options); } + public rotation osNpcGetRot(key npc) + { + return m_OSSL_Functions.osNpcGetRot(npc); + } + + public void osNpcSetRot(key npc, rotation rot) + { + m_OSSL_Functions.osNpcSetRot(npc, rot); + } + public void osNpcStopMoveTo(LSL_Key npc) { m_OSSL_Functions.osNpcStopMoveTo(npc); -- cgit v1.1 From d23d37d2aa7c5a3d9c6ec1726aef7941d5e52519 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 23:36:22 +0100 Subject: implement osNpcGetPos() --- .../Shared/Api/Implementation/OSSL_Api.cs | 21 +++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++ 3 files changed, 27 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 1874826..b1066b5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2202,6 +2202,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + public LSL_Vector osNpcGetPos(LSL_Key npc) + { + CheckThreatLevel(ThreatLevel.High, "osNpcGetPos"); + + INPCModule npcModule = World.RequestModuleInterface(); + if (npcModule != null) + { + UUID npcId; + if (!UUID.TryParse(npc.m_string, out npcId)) + return new LSL_Vector(0, 0, 0); + + if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) + return new LSL_Vector(0, 0, 0); + + Vector3 pos = World.GetScenePresence(npcId).AbsolutePosition; + return new LSL_Vector(pos.X, pos.Y, pos.Z); + } + + return new LSL_Vector(0, 0, 0); + } + public void osNpcMoveTo(LSL_Key npc, LSL_Vector position) { CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 7c08e84..9f0d07c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -171,6 +171,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces key osNpcCreate(string user, string name, vector position, key cloneFrom); LSL_Key osNpcSaveAppearance(key npc, string notecardName); void osNpcLoadAppearance(key npc, string notecardNameOrUuid); + vector osNpcGetPos(key npc); void osNpcMoveTo(key npc, vector position); void osNpcMoveToTarget(key npc, vector position, int options); rotation osNpcGetRot(key npc); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index e8e5f52..3ccb3f1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -493,6 +493,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osNpcLoadAppearance(npc, notecardNameOrUuid); } + public vector osNpcGetPos(LSL_Key npc) + { + return m_OSSL_Functions.osNpcGetPos(npc); + } + public void osNpcMoveTo(key npc, vector position) { m_OSSL_Functions.osNpcMoveTo(npc, position); -- cgit v1.1 From 0a1bbc27d26a430c53e84e22b7aad0df2f1f4a09 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 12 Aug 2011 00:14:06 +0100 Subject: Allow the osNpcCreate() function to accept a notecard name or asset for initial appearance --- .../Shared/Api/Implementation/OSSL_Api.cs | 28 ++++++++++++++++++---- .../Shared/Tests/OSSL_ApiAppearanceTest.cs | 4 ++-- 2 files changed, 26 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index b1066b5..90c4636 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2130,20 +2130,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom) { CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); - //QueueUserWorkItem INPCModule module = World.RequestModuleInterface(); if (module != null) { - ScenePresence clonePresence = World.GetScenePresence(new UUID(cloneFrom.m_string)); - if (clonePresence == null) + AvatarAppearance appearance = null; + + UUID cloneId; + if (UUID.TryParse(cloneFrom, out cloneId)) + { + ScenePresence clonePresence = World.GetScenePresence(new UUID(cloneFrom.m_string)); + if (clonePresence != null) + appearance = clonePresence.Appearance; + } + + if (appearance == null) + { + string appearanceSerialized = LoadNotecard(cloneFrom.m_string); + + if (appearanceSerialized != null) + { + OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); + appearance = new AvatarAppearance(); + appearance.Unpack(appearanceOsd); + } + } + + if (appearance == null) return new LSL_Key(UUID.Zero.ToString()); UUID x = module.CreateNPC(firstname, lastname, new Vector3((float) position.x, (float) position.y, (float) position.z), World, - clonePresence.Appearance); + appearance); return new LSL_Key(x.ToString()); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs index 85cf507..7573dff 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs @@ -78,11 +78,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests /// /// Test creation of an NPC where the appearance data comes from a notecard /// - //[Test] + [Test] public void TestOsNpcCreateFromNotecard() { TestHelpers.InMethod(); - log4net.Config.XmlConfigurator.Configure(); +// log4net.Config.XmlConfigurator.Configure(); // Store an avatar with a different height from default in a notecard. UUID userId = TestHelpers.ParseTail(0x1); -- cgit v1.1 From aebd46a4348cf55d25eaa56325940a0f33d8b8fe Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 12 Aug 2011 01:32:49 +0100 Subject: rename osNpcStopMoveTo() to osNpcStopMoveToTarget() --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 2 +- OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 +- OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 90c4636..07473e5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2322,7 +2322,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - public void osNpcStopMoveTo(LSL_Key npc) + public void osNpcStopMoveToTarget(LSL_Key npc) { CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 9f0d07c..2ba68ff 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -176,7 +176,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osNpcMoveToTarget(key npc, vector position, int options); rotation osNpcGetRot(key npc); void osNpcSetRot(LSL_Key npc, rotation rot); - void osNpcStopMoveTo(LSL_Key npc); + void osNpcStopMoveToTarget(LSL_Key npc); void osNpcSay(key npc, string message); void osNpcRemove(key npc); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 3ccb3f1..140501c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -518,9 +518,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osNpcSetRot(npc, rot); } - public void osNpcStopMoveTo(LSL_Key npc) + public void osNpcStopMoveToTarget(LSL_Key npc) { - m_OSSL_Functions.osNpcStopMoveTo(npc); + m_OSSL_Functions.osNpcStopMoveToTarget(npc); } public void osNpcSay(key npc, string message) -- cgit v1.1 From 16ac5413ddb57ac347addebc82d425364a083637 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 12 Aug 2011 01:52:12 +0100 Subject: rename position parameter in osNpcMoveToTarget to target --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 4 ++-- OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 +- OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 07473e5..2e28907 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2259,7 +2259,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector position, int options) + public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options) { CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget"); @@ -2270,7 +2270,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(npc.m_string, out npcId)) return; - Vector3 pos = new Vector3((float)position.x, (float)position.y, (float)position.z); + Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z); module.MoveToTarget( new UUID(npc.m_string), World, diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 2ba68ff..1f3454f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -173,7 +173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osNpcLoadAppearance(key npc, string notecardNameOrUuid); vector osNpcGetPos(key npc); void osNpcMoveTo(key npc, vector position); - void osNpcMoveToTarget(key npc, vector position, int options); + void osNpcMoveToTarget(key npc, vector target, int options); rotation osNpcGetRot(key npc); void osNpcSetRot(LSL_Key npc, rotation rot); void osNpcStopMoveToTarget(LSL_Key npc); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 140501c..13cf7fa 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -503,9 +503,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osNpcMoveTo(npc, position); } - public void osNpcMoveToTarget(key npc, vector position, int options) + public void osNpcMoveToTarget(key npc, vector target, int options) { - m_OSSL_Functions.osNpcMoveToTarget(npc, position, options); + m_OSSL_Functions.osNpcMoveToTarget(npc, target, options); } public rotation osNpcGetRot(key npc) -- cgit v1.1 From 76e0afe83f012e451a66a145c50e79c1bd047f37 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 12 Aug 2011 02:46:44 +0100 Subject: tidy up some OSSL NPC parameter names --- .../Shared/Api/Implementation/OSSL_Api.cs | 42 +++++++++++----------- .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 10 +++--- .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 16 ++++----- 3 files changed, 34 insertions(+), 34 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 2e28907..d791885 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2127,7 +2127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return retVal; } - public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom) + public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard) { CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); @@ -2136,17 +2136,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { AvatarAppearance appearance = null; - UUID cloneId; - if (UUID.TryParse(cloneFrom, out cloneId)) + UUID id; + if (UUID.TryParse(notecard, out id)) { - ScenePresence clonePresence = World.GetScenePresence(new UUID(cloneFrom.m_string)); + ScenePresence clonePresence = World.GetScenePresence(id); if (clonePresence != null) appearance = clonePresence.Appearance; } if (appearance == null) { - string appearanceSerialized = LoadNotecard(cloneFrom.m_string); + string appearanceSerialized = LoadNotecard(notecard); if (appearanceSerialized != null) { @@ -2175,9 +2175,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// Save the current appearance of the NPC permanently to the named notecard. /// /// - /// The name of the notecard to which to save the appearance. + /// The name of the notecard to which to save the appearance. /// The asset ID of the notecard saved. - public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecardName) + public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard) { CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance"); @@ -2192,13 +2192,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) return new LSL_Key(UUID.Zero.ToString()); - return SaveAppearanceToNotecard(npcId, notecardName); + return SaveAppearanceToNotecard(npcId, notecard); } return new LSL_Key(UUID.Zero.ToString()); } - public void osNpcLoadAppearance(LSL_Key npc, string notecardNameOrUuid) + public void osNpcLoadAppearance(LSL_Key npc, string notecard) { CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance"); @@ -2210,7 +2210,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(npc.m_string, out npcId)) return; - string appearanceSerialized = LoadNotecard(notecardNameOrUuid); + string appearanceSerialized = LoadNotecard(notecard); OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); // OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized); // Console.WriteLine("appearanceSerialized {0}", appearanceSerialized); @@ -2356,23 +2356,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// /// Save the current appearance of the script owner permanently to the named notecard. /// - /// The name of the notecard to which to save the appearance. + /// The name of the notecard to which to save the appearance. /// The asset ID of the notecard saved. - public LSL_Key osOwnerSaveAppearance(string notecardName) + public LSL_Key osOwnerSaveAppearance(string notecard) { CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance"); - return SaveAppearanceToNotecard(m_host.OwnerID, notecardName); + return SaveAppearanceToNotecard(m_host.OwnerID, notecard); } - public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecardName) + public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard) { CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance"); - return SaveAppearanceToNotecard(avatarId, notecardName); + return SaveAppearanceToNotecard(avatarId, notecard); } - protected LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecardName) + protected LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecard) { IAvatarFactory appearanceModule = World.RequestModuleInterface(); @@ -2382,7 +2382,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api OSDMap appearancePacked = sp.Appearance.Pack(); TaskInventoryItem item - = SaveNotecard(notecardName, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true); + = SaveNotecard(notecard, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true); return new LSL_Key(item.AssetID.ToString()); } @@ -2392,23 +2392,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecardName) + protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecard) { ScenePresence sp = World.GetScenePresence(avatarId); if (sp == null || sp.IsChildAgent) return new LSL_Key(UUID.Zero.ToString()); - return SaveAppearanceToNotecard(sp, notecardName); + return SaveAppearanceToNotecard(sp, notecard); } - protected LSL_Key SaveAppearanceToNotecard(LSL_Key rawAvatarId, string notecardName) + protected LSL_Key SaveAppearanceToNotecard(LSL_Key rawAvatarId, string notecard) { UUID avatarId; if (!UUID.TryParse(rawAvatarId, out avatarId)) return new LSL_Key(UUID.Zero.ToString()); - return SaveAppearanceToNotecard(avatarId, notecardName); + return SaveAppearanceToNotecard(avatarId, notecard); } /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 1f3454f..87cfe1a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -168,9 +168,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); - key osNpcCreate(string user, string name, vector position, key cloneFrom); - LSL_Key osNpcSaveAppearance(key npc, string notecardName); - void osNpcLoadAppearance(key npc, string notecardNameOrUuid); + key osNpcCreate(string user, string name, vector position, string notecard); + LSL_Key osNpcSaveAppearance(key npc, string notecard); + void osNpcLoadAppearance(key npc, string notecard); vector osNpcGetPos(key npc); void osNpcMoveTo(key npc, vector position); void osNpcMoveToTarget(key npc, vector target, int options); @@ -180,8 +180,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osNpcSay(key npc, string message); void osNpcRemove(key npc); - LSL_Key osOwnerSaveAppearance(string notecardName); - LSL_Key osAgentSaveAppearance(key agentId, string notecardName); + LSL_Key osOwnerSaveAppearance(string notecard); + LSL_Key osAgentSaveAppearance(key agentId, string notecard); key osGetMapTexture(); key osGetRegionMapTexture(string regionName); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 13cf7fa..bbc8cc6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -483,14 +483,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom); } - public key osNpcSaveAppearance(key npc, string notecardName) + public key osNpcSaveAppearance(key npc, string notecard) { - return m_OSSL_Functions.osNpcSaveAppearance(npc, notecardName); + return m_OSSL_Functions.osNpcSaveAppearance(npc, notecard); } - public void osNpcLoadAppearance(key npc, string notecardNameOrUuid) + public void osNpcLoadAppearance(key npc, string notecard) { - m_OSSL_Functions.osNpcLoadAppearance(npc, notecardNameOrUuid); + m_OSSL_Functions.osNpcLoadAppearance(npc, notecard); } public vector osNpcGetPos(LSL_Key npc) @@ -533,14 +533,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osNpcRemove(npc); } - public LSL_Key osOwnerSaveAppearance(string notecardName) + public LSL_Key osOwnerSaveAppearance(string notecard) { - return m_OSSL_Functions.osOwnerSaveAppearance(notecardName); + return m_OSSL_Functions.osOwnerSaveAppearance(notecard); } - public LSL_Key osAgentSaveAppearance(LSL_Key agentId, string notecardName) + public LSL_Key osAgentSaveAppearance(LSL_Key agentId, string notecard) { - return m_OSSL_Functions.osAgentSaveAppearance(agentId, notecardName); + return m_OSSL_Functions.osAgentSaveAppearance(agentId, notecard); } public OSSLPrim Prim; -- cgit v1.1 From b80dfb6572438cb583e95884c0f607342f0c88d4 Mon Sep 17 00:00:00 2001 From: Micheil Merlin Date: Fri, 12 Aug 2011 21:09:01 -0500 Subject: llGetPrimitiveParams fix prim hollow/hole shape value --- .../Shared/Api/Implementation/LSL_Api.cs | 6 +- .../ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 175 +++++++++++++++++++++ 2 files changed, 178 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 8a281d4..c84afee 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7650,7 +7650,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case ScriptBaseClass.PRIM_TYPE_BOX: case ScriptBaseClass.PRIM_TYPE_CYLINDER: case ScriptBaseClass.PRIM_TYPE_PRISM: - res.Add(new LSL_Integer(Shape.ProfileCurve)); + res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble. res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0)); res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0)); res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); @@ -7659,7 +7659,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case ScriptBaseClass.PRIM_TYPE_SPHERE: - res.Add(new LSL_Integer(Shape.ProfileCurve)); + res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble. res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0)); res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); @@ -7675,7 +7675,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case ScriptBaseClass.PRIM_TYPE_TUBE: case ScriptBaseClass.PRIM_TYPE_TORUS: // holeshape - res.Add(new LSL_Integer(Shape.ProfileCurve)); + res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble. // cut res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index 3f37ec7..623c82d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs @@ -27,11 +27,13 @@ using System.Collections.Generic; using NUnit.Framework; +using OpenSim.Framework; using OpenSim.Tests.Common; using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.Framework.Scenes; using Nini.Config; using OpenSim.Region.ScriptEngine.Shared.Api; +using OpenSim.Region.ScriptEngine.Shared.ScriptBase; using OpenMetaverse; using System; using OpenSim.Tests.Common.Mock; @@ -47,6 +49,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; + private const double FLOAT_ACCURACY = 0.00005d; private LSL_Api m_lslApi; [SetUp] @@ -166,6 +169,178 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests } [Test] + // llSetPrimitiveParams and llGetPrimitiveParams test. + public void TestllSetPrimitiveParams() + { + // Create Prim1. + Scene scene = SceneHelpers.SetupScene(); + string obj1Name = "Prim1"; + UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); + SceneObjectPart part1 = + new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, + Vector3.Zero, Quaternion.Identity, + Vector3.Zero) { Name = obj1Name, UUID = objUuid }; + Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True); + + // Test a sphere. + CheckllSetPrimitiveParams( + "test 1", // Prim test identification string + new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size + ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type + ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type + new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut + 0.80d, // Prim hollow + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist + new LSL_Types.Vector3(0.32d, 0.76d, 0.0d)); // Prim dimple + + // Test a prism. + CheckllSetPrimitiveParams( + "test 2", // Prim test identification string + new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size + ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type + ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type + new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut + 0.90d, // Prim hollow + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist + new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); // Prim shear + + // Test a box. + CheckllSetPrimitiveParams( + "test 3", // Prim test identification string + new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size + ScriptBaseClass.PRIM_TYPE_BOX, // Prim type + ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type + new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut + 0.90d, // Prim hollow + new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist + new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); // Prim shear + + // Test a tube. + CheckllSetPrimitiveParams( + "test 4", // Prim test identification string + new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size + ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type + ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type + new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut + 0.00d, // Prim hollow + new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist + new LSL_Types.Vector3(1.0d, 0.5d, 0.0d), // Prim hole size + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear + new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut + new LSL_Types.Vector3(-1.0d, 1.0d, 0.0d), // Prim taper + 1.0d, // Prim revolutions + 1.0d, // Prim radius + 0.0d); // Prim skew + } + + // Set prim params for a box, cylinder or prism and check results. + public void CheckllSetPrimitiveParams(string primTest, + LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, + double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear) + { + // Set the prim params. + m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, + ScriptBaseClass.PRIM_TYPE, primType, primHoleType, + primCut, primHollow, primTwist, primTaper, primShear)); + + // Get params for prim to validate settings. + LSL_Types.list primParams = + m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); + + // Validate settings. + CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); + Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), + "TestllSetPrimitiveParams " + primTest + " prim type check fail"); + Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), + "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); + CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); + Assert.AreEqual(primHollow, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, + "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); + CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); + CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 6), primTest + " prim taper"); + CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear"); + } + + // Set prim params for a sphere and check results. + public void CheckllSetPrimitiveParams(string primTest, + LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, + double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple) + { + // Set the prim params. + m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, + ScriptBaseClass.PRIM_TYPE, primType, primHoleType, + primCut, primHollow, primTwist, primDimple)); + + // Get params for prim to validate settings. + LSL_Types.list primParams = + m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); + + // Validate settings. + CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); + Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), + "TestllSetPrimitiveParams " + primTest + " prim type check fail"); + Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), + "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); + CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); + Assert.AreEqual(primHollow, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, + "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); + CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); + CheckllSetPrimitiveParamsVector(primDimple, m_lslApi.llList2Vector(primParams, 6), primTest + " prim dimple"); + } + + // Set prim params for a torus, tube or ring and check results. + public void CheckllSetPrimitiveParams(string primTest, + LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, + double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize, + LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper, + double primRev, double primRadius, double primSkew) + { + // Set the prim params. + m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, + ScriptBaseClass.PRIM_TYPE, primType, primHoleType, + primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut, + primTaper, primRev, primRadius, primSkew)); + + // Get params for prim to validate settings. + LSL_Types.list primParams = + m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); + + // Valdate settings. + CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); + Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), + "TestllSetPrimitiveParams " + primTest + " prim type check fail"); + Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), + "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); + CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); + Assert.AreEqual(primHollow, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, + "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); + CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); + CheckllSetPrimitiveParamsVector(primHoleSize, m_lslApi.llList2Vector(primParams, 6), primTest + " prim hole size"); + CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear"); + CheckllSetPrimitiveParamsVector(primProfCut, m_lslApi.llList2Vector(primParams, 8), primTest + " prim profile cut"); + CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 9), primTest + " prim taper"); + Assert.AreEqual(primRev, m_lslApi.llList2Float(primParams, 10), FLOAT_ACCURACY, + "TestllSetPrimitiveParams " + primTest + " prim revolution fail"); + Assert.AreEqual(primRadius, m_lslApi.llList2Float(primParams, 11), FLOAT_ACCURACY, + "TestllSetPrimitiveParams " + primTest + " prim radius fail"); + Assert.AreEqual(primSkew, m_lslApi.llList2Float(primParams, 12), FLOAT_ACCURACY, + "TestllSetPrimitiveParams " + primTest + " prim skew fail"); + } + + public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg) + { + // Check each vector component against expected result. + Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY, + "TestllSetPrimitiveParams " + msg + " vector check fail on x component"); + Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY, + "TestllSetPrimitiveParams " + msg + " vector check fail on y component"); + Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY, + "TestllSetPrimitiveParams " + msg + " vector check fail on z component"); + } + + [Test] // llVecNorm test. public void TestllVecNorm() { -- cgit v1.1 From 2787207aa287a60a3c7c06fad66d406180033ae2 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Fri, 19 Aug 2011 18:47:21 -0400 Subject: Add llRegionSayTo llRegionSayTo(key target, integer channel, string messasge) Allows messages to be sent region-wide to a particular prim. --- .../Shared/Api/Implementation/LSL_Api.cs | 27 +++++++++++++++++----- .../ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 1 + .../ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 5 ++++ 3 files changed, 27 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c84afee..25d7ad9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -843,6 +843,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api wComm.DeliverMessage(ChatTypeEnum.Region, channelID, m_host.Name, m_host.UUID, text); } + public void llRegionSayTo(string target, int channel, string msg) + { + if (channel == 0) + { + LSLError("Cannot use llRegionSay() on channel 0"); + return; + } + + if (msg.Length > 1023) + msg = msg.Substring(0, 1023); + + m_host.AddScriptLPS(1); + + UUID TargetID; + UUID.TryParse(target, out TargetID); + + IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); + if (wComm != null) + wComm.DeliverMessageTo(TargetID, channel, m_host.Name, m_host.UUID, msg); + } + public LSL_Integer llListen(int channelID, string name, string ID, string msg) { m_host.AddScriptLPS(1); @@ -10486,12 +10507,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api NotImplemented("llGetUsedMemory"); } - public void llRegionSayTo(LSL_Key target, LSL_Integer channel, LSL_String msg) - { - m_host.AddScriptLPS(1); - NotImplemented("llRegionSayTo"); - } - public void llScriptProfiler(LSL_Integer flags) { m_host.AddScriptLPS(1); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 27f9c84..4d7d60d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -271,6 +271,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void llPushObject(string target, LSL_Vector impulse, LSL_Vector ang_impulse, int local); void llRefreshPrimURL(); void llRegionSay(int channelID, string text); + void llRegionSayTo(string target, int channelID, string text); void llReleaseCamera(string avatar); void llReleaseControls(); void llReleaseURL(string url); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 303d75e..96e46fd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -1199,6 +1199,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llRegionSay(channelID, text); } + public void llRegionSayTo(string key, int channelID, string text) + { + m_LSL_Functions.llRegionSayTo(key, channelID, text); + } + public void llReleaseCamera(string avatar) { m_LSL_Functions.llReleaseCamera(avatar); -- cgit v1.1 From 5e231acdce7a006a4d88a205044d9862f7d4dda8 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sat, 20 Aug 2011 12:36:35 -0400 Subject: Add avatar and attachments to llRegionSay llRegionSay will now message avatars on chan 0 and will message attachments on the avatar that listen on channels other than 0. This behavior is consistant with the LL implementation as tested on regions in Agni with one exception: this implementation does not include issue: https://jira.secondlife.com/browse/SCR-66? --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 25d7ad9..db45354 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -845,11 +845,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRegionSayTo(string target, int channel, string msg) { - if (channel == 0) - { - LSLError("Cannot use llRegionSay() on channel 0"); - return; - } + string error = String.Empty; if (msg.Length > 1023) msg = msg.Substring(0, 1023); @@ -861,7 +857,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); if (wComm != null) - wComm.DeliverMessageTo(TargetID, channel, m_host.Name, m_host.UUID, msg); + if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) + LSLError(error); } public LSL_Integer llListen(int channelID, string name, string ID, string msg) -- cgit v1.1 From db91044593fc2592c7abb21034aeea8965febbd7 Mon Sep 17 00:00:00 2001 From: Snoopy Pfeffer Date: Mon, 22 Aug 2011 14:51:43 +0200 Subject: Thanks Neil Canham for fixing bulk inventory updates, no sending BulkInventoryUpdate after accepting inventory items. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index db45354..ef67a0c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3927,7 +3927,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api GridInstantMessage msg = new GridInstantMessage(World, m_host.UUID, m_host.Name+", an object owned by "+ resolveName(m_host.OwnerID)+",", destId, - (byte)InstantMessageDialog.InventoryOffered, + (byte)InstantMessageDialog.TaskInventoryOffered, false, objName+"\n"+m_host.Name+" is located at "+ World.RegionInfo.RegionName+" "+ m_host.AbsolutePosition.ToString(), -- cgit v1.1 From ce011d7e446e8f05247fc4ed7e0af5a94afbb074 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Tue, 23 Aug 2011 10:52:12 -0700 Subject: Protect a check for default texture entry when setting alpha values. Apparently if all faces have their own textures then the default texture is null --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ef67a0c..24be7d4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1619,9 +1619,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api tex.FaceTextures[i].RGBA = texcolor; } } - texcolor = tex.DefaultTexture.RGBA; - texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); - tex.DefaultTexture.RGBA = texcolor; + + // In some cases, the default texture can be null, eg when every face + // has a unique texture + if (tex.DefaultTexture != null) + { + texcolor = tex.DefaultTexture.RGBA; + texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); + tex.DefaultTexture.RGBA = texcolor; + } + part.UpdateTexture(tex); return; } -- cgit v1.1 From 97b207240ee79abfec08d2dfaa9385211eb305c8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Aug 2011 22:05:22 +0100 Subject: rename AttachmentsModule.ShowDetachInUserInventory() to DetachSingleAttachmentToInv() for consistency and to reflect it's actual behaviour --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 24be7d4..ffa0e24 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3031,7 +3031,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; if (attachmentsModule != null) - attachmentsModule.ShowDetachInUserInventory(itemID, presence.ControllingClient); + attachmentsModule.DetachSingleAttachmentToInv(itemID, presence.ControllingClient); } public void llTakeCamera(string avatar) -- cgit v1.1 From cf3ffe5bb4c6a8bea9599b6143c2f7793500c984 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 20:49:23 +0100 Subject: Fix llAttachToAvatar() Apart from one obvious bug, this was failing because attempting to serialize the script from inside the script (as part of saving the attachment as an inventory asset) was triggering an extremely long delay. So we now don't do this. The state will be serialized anyway when the avatar normally logs out. The worst that can happen is that if the client/server crashes, the attachment scripts start without previous state. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ffa0e24..d340ef2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2964,8 +2964,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) - return; +// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) +// return; TaskInventoryItem item; -- cgit v1.1 From cf42fcd978601a315ac1eb9599ab169f14fc9a8d Mon Sep 17 00:00:00 2001 From: Micheil Merlin Date: Wed, 24 Aug 2011 20:21:51 -0500 Subject: llSetPrimitiveParams correct prim hollow for cases where limit should be 70%. Signed-off-by: BlueWall --- .../Shared/Api/Implementation/LSL_Api.cs | 87 ++++++++++++---------- .../ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 75 ++++++++++++++++--- 2 files changed, 111 insertions(+), 51 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d340ef2..a690e3b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -6608,7 +6608,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return Util.SHA1Hash(src).ToLower(); } - protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) + protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) { ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); @@ -6619,7 +6619,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { holeshape = (int)ScriptBaseClass.PRIM_HOLE_DEFAULT; } - shapeBlock.ProfileCurve = (byte)holeshape; + shapeBlock.PathCurve = pathcurve; + shapeBlock.ProfileCurve = (byte)holeshape; // Set the hole shape. + shapeBlock.ProfileCurve += profileshape; // Add in the profile shape. if (cut.x < 0f) { cut.x = 0f; @@ -6651,9 +6653,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { hollow = 0f; } - if (hollow > 0.95) + // If the prim is a Cylinder, Prism, Sphere, Torus or Ring (or not a + // Box or Tube) and the hole shape is a square, hollow is limited to + // a max of 70%. The viewer performs its own check on this value but + // we need to do it here also so llGetPrimitiveParams can have access + // to the correct value. + if (profileshape != (byte)ProfileCurve.Square && + holeshape == (int)ScriptBaseClass.PRIM_HOLE_SQUARE) { - hollow = 0.95f; + if (hollow > 0.70f) + { + hollow = 0.70f; + } + } + // Otherwise, hollow is limited to 95%. + else + { + if (hollow > 0.95f) + { + hollow = 0.95f; + } } shapeBlock.ProfileHollow = (ushort)(50000 * hollow); if (twist.x < -1.0f) @@ -6677,20 +6696,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api shapeBlock.ObjectLocalID = part.LocalId; - // retain pathcurve - shapeBlock.PathCurve = part.Shape.PathCurve; - part.Shape.SculptEntry = false; return shapeBlock; } - protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) + // Prim type box, cylinder and prism. + protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte profileshape, byte pathcurve) { ObjectShapePacket.ObjectDataBlock shapeBlock; - shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); - - shapeBlock.ProfileCurve += fudge; + shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); if (taper_b.x < 0f) { @@ -6733,18 +6748,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api part.UpdateShape(shapeBlock); } - protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) + // Prim type sphere. + protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) { ObjectShapePacket.ObjectDataBlock shapeBlock; - shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); + shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); // profile/path swapped for a sphere shapeBlock.PathBegin = shapeBlock.ProfileBegin; shapeBlock.PathEnd = shapeBlock.ProfileEnd; - shapeBlock.ProfileCurve += fudge; - shapeBlock.PathScaleX = 100; shapeBlock.PathScaleY = 100; @@ -6775,13 +6789,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api part.UpdateShape(shapeBlock); } - protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte fudge) + // Prim type torus, tube and ring. + protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte profileshape, byte pathcurve) { ObjectShapePacket.ObjectDataBlock shapeBlock; - shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); - - shapeBlock.ProfileCurve += fudge; + shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); // profile/path swapped for a torrus, tube, ring shapeBlock.PathBegin = shapeBlock.ProfileBegin; @@ -6901,7 +6914,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api part.UpdateShape(shapeBlock); } - protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) + // Prim type sculpt. + protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) { ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); UUID sculptId; @@ -6914,6 +6928,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (sculptId == UUID.Zero) return; + shapeBlock.PathCurve = pathcurve; shapeBlock.ObjectLocalID = part.LocalId; shapeBlock.PathScaleX = 100; shapeBlock.PathScaleY = 150; @@ -6927,9 +6942,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; } - // retain pathcurve - shapeBlock.PathCurve = part.Shape.PathCurve; - part.Shape.SetSculptProperties((byte)type, sculptId); part.Shape.SculptEntry = true; part.UpdateShape(shapeBlock); @@ -7053,8 +7065,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api taper_b = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); - part.Shape.PathCurve = (byte)Extrusion.Straight; - SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 1); + SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, + (byte)ProfileShape.Square, (byte)Extrusion.Straight); break; case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: @@ -7067,9 +7079,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api twist = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); - part.Shape.ProfileShape = ProfileShape.Circle; - part.Shape.PathCurve = (byte)Extrusion.Straight; - SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 0); + SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, + (byte)ProfileShape.Circle, (byte)Extrusion.Straight); break; case (int)ScriptBaseClass.PRIM_TYPE_PRISM: @@ -7082,8 +7093,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api twist = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); - part.Shape.PathCurve = (byte)Extrusion.Straight; - SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 3); + SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, + (byte)ProfileShape.EquilateralTriangle, (byte)Extrusion.Straight); break; case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: @@ -7095,8 +7106,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); // dimple - part.Shape.PathCurve = (byte)Extrusion.Curve1; - SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, 5); + SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, + (byte)ProfileShape.HalfCircle, (byte)Extrusion.Curve1); break; case (int)ScriptBaseClass.PRIM_TYPE_TORUS: @@ -7114,9 +7125,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api revolutions = (float)rules.GetLSLFloatItem(idx++); radiusoffset = (float)rules.GetLSLFloatItem(idx++); skew = (float)rules.GetLSLFloatItem(idx++); - part.Shape.PathCurve = (byte)Extrusion.Curve1; SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, - revolutions, radiusoffset, skew, 0); + revolutions, radiusoffset, skew, (byte)ProfileShape.Circle, (byte)Extrusion.Curve1); break; case (int)ScriptBaseClass.PRIM_TYPE_TUBE: @@ -7134,9 +7144,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api revolutions = (float)rules.GetLSLFloatItem(idx++); radiusoffset = (float)rules.GetLSLFloatItem(idx++); skew = (float)rules.GetLSLFloatItem(idx++); - part.Shape.PathCurve = (byte)Extrusion.Curve1; SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, - revolutions, radiusoffset, skew, 1); + revolutions, radiusoffset, skew, (byte)ProfileShape.Square, (byte)Extrusion.Curve1); break; case (int)ScriptBaseClass.PRIM_TYPE_RING: @@ -7154,9 +7163,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api revolutions = (float)rules.GetLSLFloatItem(idx++); radiusoffset = (float)rules.GetLSLFloatItem(idx++); skew = (float)rules.GetLSLFloatItem(idx++); - part.Shape.PathCurve = (byte)Extrusion.Curve1; SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, - revolutions, radiusoffset, skew, 3); + revolutions, radiusoffset, skew, (byte)ProfileShape.EquilateralTriangle, (byte)Extrusion.Curve1); break; case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: @@ -7165,8 +7173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api string map = rules.Data[idx++].ToString(); face = (int)rules.GetLSLIntegerItem(idx++); // type - part.Shape.PathCurve = (byte)Extrusion.Curve1; - SetPrimitiveShapeParams(part, map, face); + SetPrimitiveShapeParams(part, map, face, (byte)Extrusion.Curve1); break; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index 623c82d..8cd1e84 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs @@ -182,6 +182,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Vector3.Zero) { Name = obj1Name, UUID = objUuid }; Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True); + // Note that prim hollow check is passed with the other prim params in order to allow the + // specification of a different check value from the prim param. A cylinder, prism, sphere, + // torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below + // specifies a value of 95% and checks to see if 70% was properly returned. + // Test a sphere. CheckllSetPrimitiveParams( "test 1", // Prim test identification string @@ -191,7 +196,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut 0.80d, // Prim hollow new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist - new LSL_Types.Vector3(0.32d, 0.76d, 0.0d)); // Prim dimple + new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple + 0.80d); // Prim hollow check // Test a prism. CheckllSetPrimitiveParams( @@ -203,7 +209,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests 0.90d, // Prim hollow new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper - new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); // Prim shear + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear + 0.90d); // Prim hollow check // Test a box. CheckllSetPrimitiveParams( @@ -212,10 +219,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests ScriptBaseClass.PRIM_TYPE_BOX, // Prim type ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut - 0.90d, // Prim hollow + 0.95d, // Prim hollow new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper - new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); // Prim shear + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear + 0.95d); // Prim hollow check // Test a tube. CheckllSetPrimitiveParams( @@ -232,13 +240,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests new LSL_Types.Vector3(-1.0d, 1.0d, 0.0d), // Prim taper 1.0d, // Prim revolutions 1.0d, // Prim radius - 0.0d); // Prim skew + 0.0d, // Prim skew + 0.00d); // Prim hollow check + + // Test a prism. + CheckllSetPrimitiveParams( + "test 5", // Prim test identification string + new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size + ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type + ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type + new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut + 0.95d, // Prim hollow + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist + new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear + 0.70d); // Prim hollow check + + // Test a sculpted prim. + CheckllSetPrimitiveParams( + "test 6", // Prim test identification string + new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size + ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type + "be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map + ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type } // Set prim params for a box, cylinder or prism and check results. public void CheckllSetPrimitiveParams(string primTest, LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, - double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear) + double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear, + double primHollowCheck) { // Set the prim params. m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, @@ -256,7 +287,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); - Assert.AreEqual(primHollow, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, + Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 6), primTest + " prim taper"); @@ -266,7 +297,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Set prim params for a sphere and check results. public void CheckllSetPrimitiveParams(string primTest, LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, - double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple) + double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, double primHollowCheck) { // Set the prim params. m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, @@ -284,7 +315,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); - Assert.AreEqual(primHollow, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, + Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); CheckllSetPrimitiveParamsVector(primDimple, m_lslApi.llList2Vector(primParams, 6), primTest + " prim dimple"); @@ -295,7 +326,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize, LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper, - double primRev, double primRadius, double primSkew) + double primRev, double primRadius, double primSkew, double primHollowCheck) { // Set the prim params. m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, @@ -314,7 +345,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); - Assert.AreEqual(primHollow, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, + Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); CheckllSetPrimitiveParamsVector(primHoleSize, m_lslApi.llList2Vector(primParams, 6), primTest + " prim hole size"); @@ -329,6 +360,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests "TestllSetPrimitiveParams " + primTest + " prim skew fail"); } + // Set prim params for a sculpted prim and check results. + public void CheckllSetPrimitiveParams(string primTest, + LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType) + { + // Set the prim params. + m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, + ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType)); + + // Get params for prim to validate settings. + LSL_Types.list primParams = + m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); + + // Validate settings. + CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); + Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), + "TestllSetPrimitiveParams " + primTest + " prim type check fail"); + Assert.AreEqual(primMap, (string)m_lslApi.llList2String(primParams, 2), + "TestllSetPrimitiveParams " + primTest + " prim map check fail"); + Assert.AreEqual(primSculptType, m_lslApi.llList2Integer(primParams, 3), + "TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail"); + } + public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg) { // Check each vector component against expected result. -- cgit v1.1 From 15a514fcbc8f7447fc3a5997b6bbc2fe35974c9a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 23:06:41 +0100 Subject: refactor: simplify SOP.AttachedAvatar into SOG.AttachedAvatar This does a tiny bit to reduce code complexity, memory requirement and the cpu time of pointlessly setting this field to the same value in every SOP --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 8 ++++---- .../Shared/Api/Implementation/Plugins/SensorRepeat.cs | 4 ++-- OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a690e3b..81f1f38 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2099,7 +2099,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { if (part.ParentGroup.RootPart.AttachmentPoint != 0) { - ScenePresence avatar = World.GetScenePresence(part.AttachedAvatar); + ScenePresence avatar = World.GetScenePresence(part.ParentGroup.AttachedAvatar); if (avatar != null) { if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) @@ -2243,7 +2243,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_host.IsAttachment) { - ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.AttachedAvatar); + ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); vel = avatar.Velocity; } else @@ -3388,7 +3388,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); - if (m_host.ParentGroup.IsAttachment && (UUID)agent == m_host.ParentGroup.RootPart.AttachedAvatar) + if (m_host.ParentGroup.IsAttachment && (UUID)agent == m_host.ParentGroup.AttachedAvatar) { // When attached, certain permissions are implicit if requested from owner int implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | @@ -7460,7 +7460,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Quaternion q; if (m_host.ParentGroup.RootPart.AttachmentPoint != 0) { - ScenePresence avatar = World.GetScenePresence(m_host.AttachedAvatar); + ScenePresence avatar = World.GetScenePresence(m_host.ParentGroup.AttachedAvatar); if (avatar != null) if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) q = avatar.CameraRotation; // Mouselook diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index e53a61a..bf74760 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -308,7 +308,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins // In attachments, the sensor cone always orients with the // avatar rotation. This may include a nonzero elevation if // in mouselook. - ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); + ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); q = avatar.Rotation; } LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); @@ -428,7 +428,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins // In attachments, the sensor cone always orients with the // avatar rotation. This may include a nonzero elevation if // in mouselook. - ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); + ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); q = avatar.Rotation; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 783791f..ef9b2ac 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -233,7 +233,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance m_MaxScriptQueue = maxScriptQueue; m_stateSource = stateSource; m_postOnRez = postOnRez; - m_AttachedAvatar = part.AttachedAvatar; + m_AttachedAvatar = part.ParentGroup.AttachedAvatar; m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; if (part != null) -- cgit v1.1 From 33a894f3d2cc95a7a512b86f39f3c6a6afabb015 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 27 Aug 2011 00:15:21 +0100 Subject: refactor: move SOP.IsAttachment and AttachmentPoint up into SOG to avoid pointless duplication of identical values --- .../Shared/Api/Implementation/LSL_Api.cs | 20 ++++++++++---------- .../Api/Implementation/Plugins/SensorRepeat.cs | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 81f1f38..a7f08d9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1965,7 +1965,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (part.ParentGroup.RootPart == part) { - if ((targetPos.z < ground) && disable_underground_movement && m_host.AttachmentPoint == 0) + if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) targetPos.z = ground; SceneObjectGroup parent = part.ParentGroup; LSL_Vector real_vec = SetPosAdjust(currentPos, targetPos); @@ -2097,7 +2097,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Quaternion q; if (part.LinkNum == 0 || part.LinkNum == 1) // unlinked or root prim { - if (part.ParentGroup.RootPart.AttachmentPoint != 0) + if (part.ParentGroup.AttachmentPoint != 0) { ScenePresence avatar = World.GetScenePresence(part.ParentGroup.AttachedAvatar); if (avatar != null) @@ -2241,7 +2241,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Vector3 vel; - if (m_host.IsAttachment) + if (m_host.ParentGroup.IsAttachment) { ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); vel = avatar.Velocity; @@ -2997,7 +2997,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) + if (m_host.ParentGroup.AttachmentPoint == 0) return; TaskInventoryItem item; @@ -3587,7 +3587,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api SceneObjectPart targetPart = World.GetSceneObjectPart((UUID)targetID); - if (targetPart.ParentGroup.RootPart.AttachmentPoint != 0) + if (targetPart.ParentGroup.AttachmentPoint != 0) return; // Fail silently if attached SceneObjectGroup parentPrim = null, childPrim = null; @@ -3640,7 +3640,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api SceneObjectGroup parentPrim = m_host.ParentGroup; - if (parentPrim.RootPart.AttachmentPoint != 0) + if (parentPrim.AttachmentPoint != 0) return; // Fail silently if attached SceneObjectPart childPrim = null; @@ -3710,7 +3710,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); SceneObjectGroup parentPrim = m_host.ParentGroup; - if (parentPrim.RootPart.AttachmentPoint != 0) + if (parentPrim.AttachmentPoint != 0) return; // Fail silently if attached List parts = new List(parentPrim.Parts); @@ -4349,7 +4349,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; // Object not pushable. Not an attachment and has no physics component - if (!pusheeob.IsAttachment && pusheeob.PhysActor == null) + if (!pusheeob.ParentGroup.IsAttachment && pusheeob.PhysActor == null) return; PusheePos = pusheeob.AbsolutePosition; @@ -5857,7 +5857,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetAttached() { m_host.AddScriptLPS(1); - return m_host.ParentGroup.RootPart.AttachmentPoint; + return m_host.ParentGroup.AttachmentPoint; } public LSL_Integer llGetFreeMemory() @@ -7458,7 +7458,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); Quaternion q; - if (m_host.ParentGroup.RootPart.AttachmentPoint != 0) + if (m_host.ParentGroup.AttachmentPoint != 0) { ScenePresence avatar = World.GetScenePresence(m_host.ParentGroup.AttachedAvatar); if (avatar != null) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index bf74760..4ac7f8b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -303,7 +303,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins float dz; Quaternion q = SensePoint.RotationOffset; - if (SensePoint.ParentGroup.RootPart.IsAttachment) + if (SensePoint.ParentGroup.IsAttachment) { // In attachments, the sensor cone always orients with the // avatar rotation. This may include a nonzero elevation if @@ -352,7 +352,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins objtype = 0; part = ((SceneObjectGroup)ent).RootPart; - if (part.AttachmentPoint != 0) // Attached so ignore + if (part.ParentGroup.AttachmentPoint != 0) // Attached so ignore continue; if (part.Inventory.ContainsScripts()) @@ -423,7 +423,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins Vector3 fromRegionPos = SensePoint.AbsolutePosition; Quaternion q = SensePoint.RotationOffset; - if (SensePoint.ParentGroup.RootPart.IsAttachment) + if (SensePoint.ParentGroup.IsAttachment) { // In attachments, the sensor cone always orients with the // avatar rotation. This may include a nonzero elevation if @@ -435,7 +435,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); - bool attached = (SensePoint.AttachmentPoint != 0); + bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0); Vector3 toRegionPos; double dis; -- cgit v1.1 From 095b3e5756bb3160b30c9c5670ba008fa13d2e66 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Sep 2011 01:22:28 +0100 Subject: Remove pointless cluttering SOP.ParentGroup != null checks. The only times when ParentGroup might be null is during regression tests (which might not be a valid thing) and when scene objects are being constructed from the database. At all other times it's not possible for a SOP not to have a SOG parent. --- .../Shared/Api/Implementation/LSL_Api.cs | 157 ++++++++------------- .../Shared/Api/Implementation/OSSL_Api.cs | 10 +- OpenSim/Region/ScriptEngine/Shared/Helpers.cs | 2 +- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 4 +- 4 files changed, 61 insertions(+), 112 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a7f08d9..dff7269 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -234,35 +234,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api switch (linkType) { case ScriptBaseClass.LINK_SET: - if (m_host.ParentGroup != null) - { - return new List(m_host.ParentGroup.Parts); - } - return ret; + return new List(m_host.ParentGroup.Parts); case ScriptBaseClass.LINK_ROOT: - if (m_host.ParentGroup != null) - { - ret = new List(); - ret.Add(m_host.ParentGroup.RootPart); - return ret; - } + ret = new List(); + ret.Add(m_host.ParentGroup.RootPart); return ret; case ScriptBaseClass.LINK_ALL_OTHERS: - if (m_host.ParentGroup == null) - return new List(); - ret = new List(m_host.ParentGroup.Parts); if (ret.Contains(m_host)) ret.Remove(m_host); + return ret; case ScriptBaseClass.LINK_ALL_CHILDREN: - if (m_host.ParentGroup == null) - return new List(); - ret = new List(m_host.ParentGroup.Parts); if (ret.Contains(m_host.ParentGroup.RootPart)) @@ -273,15 +260,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return ret; default: - if (linkType < 0 || m_host.ParentGroup == null) + if (linkType < 0) return new List(); + SceneObjectPart target = m_host.ParentGroup.GetLinkNumPart(linkType); if (target == null) return new List(); ret = new List(); ret.Add(target); return ret; - } } @@ -1199,8 +1186,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (value != 0) { SceneObjectGroup group = m_host.ParentGroup; - if (group == null) - return; bool allow = true; foreach (SceneObjectPart part in group.Parts) @@ -1214,16 +1199,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!allow) return; + m_host.ScriptSetPhysicsStatus(true); } else + { m_host.ScriptSetPhysicsStatus(false); + } } if ((status & ScriptBaseClass.STATUS_PHANTOM) == ScriptBaseClass.STATUS_PHANTOM) { - if (m_host.ParentGroup != null) - m_host.ParentGroup.ScriptSetPhantomStatus(value != 0); + m_host.ParentGroup.ScriptSetPhantomStatus(value != 0); } if ((status & ScriptBaseClass.STATUS_CAST_SHADOWS) == ScriptBaseClass.STATUS_CAST_SHADOWS) @@ -1365,8 +1352,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected void SetScale(SceneObjectPart part, LSL_Vector scale) { // TODO: this needs to trigger a persistance save as well - if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) + if (part == null || part.ParentGroup.IsDeleted) return; + if (scale.x < 0.01) scale.x = 0.01; if (scale.y < 0.01) @@ -1409,7 +1397,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); m_host.ClickAction = (byte)action; - if (m_host.ParentGroup != null) m_host.ParentGroup.HasGroupChanged = true; + m_host.ParentGroup.HasGroupChanged = true; m_host.ScheduleFullUpdate(); return; } @@ -2033,14 +2021,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api else { // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. - SceneObjectGroup group = m_host.ParentGroup; - if (group != null) // a bit paranoid, maybe + SceneObjectPart rootPart = m_host.ParentGroup.RootPart; + if (rootPart != null) // better safe than sorry { - SceneObjectPart rootPart = group.RootPart; - if (rootPart != null) // again, better safe than sorry - { - SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); - } + SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); } } @@ -2128,15 +2112,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - if (m_host.ParentGroup != null) + if (!m_host.ParentGroup.IsDeleted) { - if (!m_host.ParentGroup.IsDeleted) - { - if (local != 0) - force *= llGetRot(); + if (local != 0) + force *= llGetRot(); - m_host.ParentGroup.RootPart.SetForce(new Vector3((float)force.x, (float)force.y, (float)force.z)); - } + m_host.ParentGroup.RootPart.SetForce(new Vector3((float)force.x, (float)force.y, (float)force.z)); } } @@ -2146,15 +2127,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); - if (m_host.ParentGroup != null) + if (!m_host.ParentGroup.IsDeleted) { - if (!m_host.ParentGroup.IsDeleted) - { - Vector3 tmpForce = m_host.ParentGroup.RootPart.GetForce(); - force.x = tmpForce.X; - force.y = tmpForce.Y; - force.z = tmpForce.Z; - } + Vector3 tmpForce = m_host.ParentGroup.RootPart.GetForce(); + force.x = tmpForce.X; + force.y = tmpForce.Y; + force.z = tmpForce.Z; } return force; @@ -3163,12 +3141,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetBuoyancy(double buoyancy) { m_host.AddScriptLPS(1); - if (m_host.ParentGroup != null) + + if (!m_host.ParentGroup.IsDeleted) { - if (!m_host.ParentGroup.IsDeleted) - { - m_host.ParentGroup.RootPart.SetBuoyancy((float)buoyancy); - } + m_host.ParentGroup.RootPart.SetBuoyancy((float)buoyancy); } } @@ -6238,12 +6214,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetVehicleType(int type) { m_host.AddScriptLPS(1); - if (m_host.ParentGroup != null) + + if (!m_host.ParentGroup.IsDeleted) { - if (!m_host.ParentGroup.IsDeleted) - { - m_host.ParentGroup.RootPart.SetVehicleType(type); - } + m_host.ParentGroup.RootPart.SetVehicleType(type); } } @@ -6253,12 +6227,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - if (m_host.ParentGroup != null) + if (!m_host.ParentGroup.IsDeleted) { - if (!m_host.ParentGroup.IsDeleted) - { - m_host.ParentGroup.RootPart.SetVehicleFloatParam(param, (float)value); - } + m_host.ParentGroup.RootPart.SetVehicleFloatParam(param, (float)value); } } @@ -6267,13 +6238,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetVehicleVectorParam(int param, LSL_Vector vec) { m_host.AddScriptLPS(1); - if (m_host.ParentGroup != null) + + if (!m_host.ParentGroup.IsDeleted) { - if (!m_host.ParentGroup.IsDeleted) - { - m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, - new Vector3((float)vec.x, (float)vec.y, (float)vec.z)); - } + m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, + new Vector3((float)vec.x, (float)vec.y, (float)vec.z)); } } @@ -6282,37 +6251,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetVehicleRotationParam(int param, LSL_Rotation rot) { m_host.AddScriptLPS(1); - if (m_host.ParentGroup != null) + + if (!m_host.ParentGroup.IsDeleted) { - if (!m_host.ParentGroup.IsDeleted) - { - m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, - Rot2Quaternion(rot)); - } + m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, Rot2Quaternion(rot)); } } public void llSetVehicleFlags(int flags) { m_host.AddScriptLPS(1); - if (m_host.ParentGroup != null) + + if (!m_host.ParentGroup.IsDeleted) { - if (!m_host.ParentGroup.IsDeleted) - { - m_host.ParentGroup.RootPart.SetVehicleFlags(flags, false); - } + m_host.ParentGroup.RootPart.SetVehicleFlags(flags, false); } } public void llRemoveVehicleFlags(int flags) { m_host.AddScriptLPS(1); - if (m_host.ParentGroup != null) + + if (!m_host.ParentGroup.IsDeleted) { - if (!m_host.ParentGroup.IsDeleted) - { - m_host.ParentGroup.RootPart.SetVehicleFlags(flags, true); - } + m_host.ParentGroup.RootPart.SetVehicleFlags(flags, true); } } @@ -6467,11 +6429,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llVolumeDetect(int detect) { m_host.AddScriptLPS(1); - if (m_host.ParentGroup != null) - { - if (!m_host.ParentGroup.IsDeleted) - m_host.ParentGroup.ScriptSetVolumeDetect(detect != 0); - } + + if (!m_host.ParentGroup.IsDeleted) + m_host.ParentGroup.ScriptSetVolumeDetect(detect != 0); } /// @@ -7022,14 +6982,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api else { // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. - SceneObjectGroup group = part.ParentGroup; - if (group != null) // a bit paranoid, maybe + SceneObjectPart rootPart = part.ParentGroup.RootPart; + if (rootPart != null) // better safe than sorry { - SceneObjectPart rootPart = group.RootPart; - if (rootPart != null) // again, better safe than sorry - { - SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); - } + SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); } } @@ -7278,13 +7234,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_PHANTOM: - if (remain < 1) + if (remain < 1) return; string ph = rules.Data[idx++].ToString(); - - if (m_host.ParentGroup != null) - m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); + m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); break; @@ -7307,8 +7261,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; string temp = rules.Data[idx++].ToString(); - if (m_host.ParentGroup != null) - m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); + m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); break; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index d791885..7f3d84d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -672,13 +672,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.VeryLow, "osSetPrimFloatOnWater"); m_host.AddScriptLPS(1); - if (m_host.ParentGroup != null) - { - if (m_host.ParentGroup.RootPart != null) - { - m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN); - } - } + + if (m_host.ParentGroup.RootPart != null) + m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN); } // Teleport functions diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs index 3575889..8cebb4a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs @@ -197,7 +197,7 @@ namespace OpenSim.Region.ScriptEngine.Shared return; } - part=part.ParentGroup.RootPart; // We detect objects only + part = part.ParentGroup.RootPart; // We detect objects only LinkNum = 0; // Not relevant diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index ef9b2ac..6e9f3ec 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -766,13 +766,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) { m_InSelfDelete = true; - if (part != null && part.ParentGroup != null) + if (part != null) m_Engine.World.DeleteSceneObject(part.ParentGroup, false); } else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) { m_InSelfDelete = true; - if (part != null && part.ParentGroup != null) + if (part != null) part.Inventory.RemoveInventoryItem(m_ItemID); } } -- cgit v1.1 From 63bf71023772ea9c54687c5006fcf6649eb1139f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Sep 2011 01:37:35 +0100 Subject: Fix issue with llGetTorque() where it would only ever return a zero vector. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index dff7269..8d95546 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2202,7 +2202,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetTorque() { m_host.AddScriptLPS(1); - Vector3 torque = m_host.GetTorque(); + Vector3 torque = m_host.ParentGroup.GetTorque(); return new LSL_Vector(torque.X,torque.Y,torque.Z); } -- cgit v1.1 From 7eca929686bd2db1cb42f5c9740fd1d186cdc8b1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Sep 2011 02:09:41 +0100 Subject: Eliminate pointless checks of SOG.RootPart != null It's never possible for SOG to have no RootPart, except in the first few picosends of the big bang when it's pulled from region persistence or deserialized --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 7 +------ OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 3 +-- 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 8d95546..2fd98f6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2767,8 +2767,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // If either of these are null, then there was an unknown error. if (new_group == null) continue; - if (new_group.RootPart == null) - continue; // objects rezzed with this method are die_at_edge by default. new_group.RootPart.SetDieAtEdge(true); @@ -6983,10 +6981,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. SceneObjectPart rootPart = part.ParentGroup.RootPart; - if (rootPart != null) // better safe than sorry - { - SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); - } + SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); } break; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 7f3d84d..3ddd79b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -673,8 +673,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); - if (m_host.ParentGroup.RootPart != null) - m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN); + m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN); } // Teleport functions -- cgit v1.1 From c491cdcb952ba50b84a2ba710bb3771421cc61f2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Sep 2011 02:18:31 +0100 Subject: refactor: use SOG register target waypoints and rots directly instead of calling through the SOP, which doesn't make conceptual sense anyway. --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 2fd98f6..88e884d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2141,25 +2141,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llTarget(LSL_Vector position, double range) { m_host.AddScriptLPS(1); - return m_host.registerTargetWaypoint(new Vector3((float)position.x, (float)position.y, (float)position.z), (float)range); + return m_host.ParentGroup.registerTargetWaypoint( + new Vector3((float)position.x, (float)position.y, (float)position.z), (float)range); } public void llTargetRemove(int number) { m_host.AddScriptLPS(1); - m_host.unregisterTargetWaypoint(number); + m_host.ParentGroup.unregisterTargetWaypoint(number); } public LSL_Integer llRotTarget(LSL_Rotation rot, double error) { m_host.AddScriptLPS(1); - return m_host.registerRotTargetWaypoint(new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), (float)error); + return m_host.ParentGroup.registerRotTargetWaypoint( + new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), (float)error); } public void llRotTargetRemove(int number) { m_host.AddScriptLPS(1); - m_host.unregisterRotTargetWaypoint(number); + m_host.ParentGroup.unregisterRotTargetWaypoint(number); } public void llMoveToTarget(LSL_Vector target, double tau) -- cgit v1.1