mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +08:00
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
This commit is contained in:
@@ -71,6 +71,7 @@ using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
|
||||
using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
|
||||
using System.Reflection;
|
||||
using Timer = System.Timers.Timer;
|
||||
using System.Linq;
|
||||
using PermissionMask = OpenSim.Framework.PermissionMask;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
@@ -96,8 +97,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
/// <summary>
|
||||
/// Used for script sleeps when we are using co-operative script termination.
|
||||
/// </summary>
|
||||
/// <remarks>null if co-operative script termination is not active</remarks>
|
||||
WaitHandle m_coopSleepHandle;
|
||||
/// <remarks>null if co-operative script termination is not active</remarks>
|
||||
WaitHandle m_coopSleepHandle;
|
||||
|
||||
/// <summary>
|
||||
/// The item that hosts this script
|
||||
@@ -150,6 +151,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{"TURNLEFT", "Turning Left"},
|
||||
{"TURNRIGHT", "Turning Right"}
|
||||
};
|
||||
//An array of HTTP/1.1 headers that are not allowed to be used
|
||||
//as custom headers by llHTTPRequest.
|
||||
private string[] HttpStandardHeaders =
|
||||
{
|
||||
"Accept", "Accept-Charset", "Accept-Encoding", "Accept-Language",
|
||||
"Accept-Ranges", "Age", "Allow", "Authorization", "Cache-Control",
|
||||
"Connection", "Content-Encoding", "Content-Language",
|
||||
"Content-Length", "Content-Location", "Content-MD5",
|
||||
"Content-Range", "Content-Type", "Date", "ETag", "Expect",
|
||||
"Expires", "From", "Host", "If-Match", "If-Modified-Since",
|
||||
"If-None-Match", "If-Range", "If-Unmodified-Since", "Last-Modified",
|
||||
"Location", "Max-Forwards", "Pragma", "Proxy-Authenticate",
|
||||
"Proxy-Authorization", "Range", "Referer", "Retry-After", "Server",
|
||||
"TE", "Trailer", "Transfer-Encoding", "Upgrade", "User-Agent",
|
||||
"Vary", "Via", "Warning", "WWW-Authenticate"
|
||||
};
|
||||
|
||||
public void Initialize(
|
||||
IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle)
|
||||
@@ -391,7 +408,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
/// If the linkset has more than one entity and a linknum greater than zero but equal to or less than the number
|
||||
/// of entities, then the entity which corresponds to that linknum is returned.
|
||||
/// Otherwise, if a positive linknum is given which is greater than the number of entities in the linkset, then
|
||||
/// null is returned.
|
||||
/// null is returned.
|
||||
/// </param>
|
||||
public ISceneEntity GetLinkEntity(int linknum)
|
||||
{
|
||||
@@ -1750,7 +1767,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
if (tex.FaceTextures[i] != null)
|
||||
{
|
||||
tex.FaceTextures[i].Shiny = sval;
|
||||
tex.FaceTextures[i].Bump = bump;;
|
||||
tex.FaceTextures[i].Bump = bump;
|
||||
}
|
||||
tex.DefaultTexture.Shiny = sval;
|
||||
tex.DefaultTexture.Bump = bump;
|
||||
@@ -1873,7 +1890,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
|
||||
tex.DefaultTexture.RGBA = texcolor;
|
||||
}
|
||||
|
||||
|
||||
part.UpdateTextureEntry(tex.GetBytes());
|
||||
return;
|
||||
}
|
||||
@@ -1996,7 +2013,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
rgb.x = texcolor.R;
|
||||
rgb.y = texcolor.G;
|
||||
rgb.z = texcolor.B;
|
||||
|
||||
|
||||
return rgb;
|
||||
}
|
||||
else
|
||||
@@ -2038,12 +2055,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
UUID textureID = new UUID();
|
||||
|
||||
textureID = ScriptUtils.GetAssetIdFromItemName(m_host, texture, (int)AssetType.Texture);
|
||||
if (textureID == UUID.Zero)
|
||||
{
|
||||
if (!UUID.TryParse(texture, out textureID))
|
||||
return;
|
||||
}
|
||||
textureID = ScriptUtils.GetAssetIdFromItemName(m_host, texture, (int)AssetType.Texture);
|
||||
if (textureID == UUID.Zero)
|
||||
{
|
||||
if (!UUID.TryParse(texture, out textureID))
|
||||
return;
|
||||
}
|
||||
|
||||
Primitive.TextureEntry tex = part.Shape.Textures;
|
||||
|
||||
@@ -2249,7 +2266,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
// IF YOU GET REGION CROSSINGS WORKING WITH THIS FUNCTION, REPLACE THE WORKAROUND.
|
||||
//
|
||||
// This workaround is to prevent silent failure of this function.
|
||||
// According to the specification on the SL Wiki, providing a position outside of the
|
||||
// According to the specification on the SL Wiki, providing a position outside of the
|
||||
if (pos.x < 0 || pos.x > Constants.RegionSize || pos.y < 0 || pos.y > Constants.RegionSize)
|
||||
{
|
||||
return 0;
|
||||
@@ -2484,7 +2501,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
return llGetRootRotation();
|
||||
}
|
||||
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
Quaternion q = m_host.GetWorldRotation();
|
||||
|
||||
@@ -3317,7 +3334,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
if (!UUID.TryParse(id, out objectID))
|
||||
objectID = UUID.Zero;
|
||||
|
||||
|
||||
if (objectID == UUID.Zero && name == "")
|
||||
return;
|
||||
|
||||
@@ -3527,19 +3544,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid;
|
||||
|
||||
Vector3 pos = m_host.AbsolutePosition;
|
||||
msg.binaryBucket
|
||||
msg.binaryBucket
|
||||
= Util.StringToBytes256(
|
||||
"{0}/{1}/{2}/{3}",
|
||||
World.RegionInfo.RegionName,
|
||||
(int)Math.Floor(pos.X),
|
||||
(int)Math.Floor(pos.Y),
|
||||
"{0}/{1}/{2}/{3}",
|
||||
World.RegionInfo.RegionName,
|
||||
(int)Math.Floor(pos.X),
|
||||
(int)Math.Floor(pos.Y),
|
||||
(int)Math.Floor(pos.Z));
|
||||
|
||||
if (m_TransferModule != null)
|
||||
{
|
||||
m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
|
||||
}
|
||||
|
||||
|
||||
ScriptSleep(2000);
|
||||
}
|
||||
|
||||
@@ -3664,7 +3681,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
public void llRotLookAt(LSL_Rotation target, double strength, double damping)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
|
||||
// Per discussion with Melanie, for non-physical objects llLookAt appears to simply
|
||||
// set the rotation of the object, copy that behavior
|
||||
PhysicsActor pa = m_host.PhysActor;
|
||||
@@ -5458,7 +5475,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
// SL spits out an empty string for types other than key & string
|
||||
// At the time of patching, LSL_Key is currently LSL_String,
|
||||
// so the OR check may be a little redundant, but it's being done
|
||||
// for completion and should LSL_Key ever be implemented
|
||||
// for completion and should LSL_Key ever be implemented
|
||||
// as it's own struct
|
||||
else if (!(src.Data[index] is LSL_String ||
|
||||
src.Data[index] is LSL_Key ||
|
||||
@@ -5595,8 +5612,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
return string.Join(", ",
|
||||
(new List<object>(src.Data)).ConvertAll<string>(o =>
|
||||
return string.Join(", ",
|
||||
(new List<object>(src.Data)).ConvertAll<string>(o =>
|
||||
{
|
||||
return o.ToString();
|
||||
}).ToArray());
|
||||
@@ -6700,7 +6717,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
SetParticleSystem(m_host, rules);
|
||||
}
|
||||
|
||||
private void SetParticleSystem(SceneObjectPart part, LSL_List rules)
|
||||
private void SetParticleSystem(SceneObjectPart part, LSL_List rules)
|
||||
{
|
||||
if (rules.Length == 0)
|
||||
{
|
||||
@@ -6937,7 +6954,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
m_host.OwnerID, m_host.Name, destID,
|
||||
(byte)InstantMessageDialog.TaskInventoryOffered,
|
||||
false, string.Format("'{0}'", category),
|
||||
// We won't go so far as to add a SLURL, but this is the format used by LL as of 2012-10-06
|
||||
// We won't go so far as to add a SLURL, but this is the format used by LL as of 2012-10-06
|
||||
// false, string.Format("'{0}' ( http://slurl.com/secondlife/{1}/{2}/{3}/{4} )", category, World.Name, (int)pos.X, (int)pos.Y, (int)pos.Z),
|
||||
folderID, false, pos,
|
||||
bucket, false);
|
||||
@@ -7056,12 +7073,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
public LSL_String llAvatarOnLinkSitTarget(int linknum)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
if(linknum == ScriptBaseClass.LINK_SET ||
|
||||
if(linknum == ScriptBaseClass.LINK_SET ||
|
||||
linknum == ScriptBaseClass.LINK_ALL_CHILDREN ||
|
||||
linknum == ScriptBaseClass.LINK_ALL_OTHERS) return UUID.Zero.ToString();
|
||||
|
||||
|
||||
List<SceneObjectPart> parts = GetLinkParts(linknum);
|
||||
if (parts.Count == 0) return UUID.Zero.ToString();
|
||||
if (parts.Count == 0) return UUID.Zero.ToString();
|
||||
return parts[0].SitTargetAvatar.ToString();
|
||||
}
|
||||
|
||||
@@ -7451,7 +7468,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
hollow = 0.70f;
|
||||
}
|
||||
}
|
||||
// Otherwise, hollow is limited to 95%.
|
||||
// Otherwise, hollow is limited to 95%.
|
||||
else
|
||||
{
|
||||
if (hollow > 0.95f)
|
||||
@@ -8906,16 +8923,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
res.Add(new LSL_Vector(Shape.PathTaperX / 100.0, Shape.PathTaperY / 100.0, 0));
|
||||
|
||||
// float revolutions
|
||||
res.Add(new LSL_Float(Math.Round(Shape.PathRevolutions * 0.015d, 2, MidpointRounding.AwayFromZero)) + 1.0d);
|
||||
res.Add(new LSL_Float(Math.Round(Shape.PathRevolutions * 0.015d, 2, MidpointRounding.AwayFromZero)) + 1.0d);
|
||||
// Slightly inaccurate, because an unsigned byte is being used to represent
|
||||
// the entire range of floating-point values from 1.0 through 4.0 (which is how
|
||||
// the entire range of floating-point values from 1.0 through 4.0 (which is how
|
||||
// SL does it).
|
||||
//
|
||||
// Using these formulas to store and retrieve PathRevolutions, it is not
|
||||
// possible to use all values between 1.00 and 4.00. For instance, you can't
|
||||
// Using these formulas to store and retrieve PathRevolutions, it is not
|
||||
// possible to use all values between 1.00 and 4.00. For instance, you can't
|
||||
// represent 1.10. You can represent 1.09 and 1.11, but not 1.10. So, if you
|
||||
// use llSetPrimitiveParams to set revolutions to 1.10 and then retreive them
|
||||
// with llGetPrimitiveParams, you'll retrieve 1.09. You can also see a similar
|
||||
// with llGetPrimitiveParams, you'll retrieve 1.09. You can also see a similar
|
||||
// behavior in the viewer as you cannot set 1.10. The viewer jumps to 1.11.
|
||||
// In SL, llSetPrimitveParams and llGetPrimitiveParams can set and get a value
|
||||
// such as 1.10. So, SL must store and retreive the actual user input rather
|
||||
@@ -9199,7 +9216,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
case (int)ScriptBaseClass.PRIM_DESC:
|
||||
res.Add(new LSL_String(part.Description));
|
||||
break;
|
||||
case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
|
||||
case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
|
||||
res.Add(new LSL_Rotation(part.RotationOffset));
|
||||
break;
|
||||
|
||||
@@ -11127,9 +11144,60 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
IHttpRequestModule httpScriptMod =
|
||||
m_ScriptEngine.World.RequestModuleInterface<IHttpRequestModule>();
|
||||
List<string> param = new List<string>();
|
||||
foreach (object o in parameters.Data)
|
||||
bool ok;
|
||||
Int32 flag;
|
||||
|
||||
for (int i = 0; i < parameters.Data.Length; i += 2)
|
||||
{
|
||||
param.Add(o.ToString());
|
||||
ok = Int32.TryParse(parameters.Data[i].ToString(), out flag);
|
||||
if (!ok || flag < 0 ||
|
||||
flag > (int)HttpRequestConstants.HTTP_PRAGMA_NO_CACHE)
|
||||
{
|
||||
throw new ScriptException("Parameter " + i.ToString() + " is an invalid flag");
|
||||
}
|
||||
|
||||
param.Add(parameters.Data[i].ToString()); //Add parameter flag
|
||||
|
||||
if (flag != (int)HttpRequestConstants.HTTP_CUSTOM_HEADER)
|
||||
{
|
||||
param.Add(parameters.Data[i+1].ToString()); //Add parameter value
|
||||
}
|
||||
else
|
||||
{
|
||||
//Parameters are in pairs and custom header takes
|
||||
//arguments in pairs so adjust for header marker.
|
||||
++i;
|
||||
|
||||
//Maximum of 8 headers are allowed based on the
|
||||
//Second Life documentation for llHTTPRequest.
|
||||
for (int count = 1; count <= 8; ++count)
|
||||
{
|
||||
//Enough parameters remaining for (another) header?
|
||||
if (parameters.Data.Length - i < 2)
|
||||
{
|
||||
//There must be at least one name/value pair for custom header
|
||||
if (count == 1)
|
||||
throw new ScriptException("Missing name/value for custom header at parameter " + i.ToString());
|
||||
break;
|
||||
}
|
||||
|
||||
if (HttpStandardHeaders.Contains(parameters.Data[i].ToString(), StringComparer.OrdinalIgnoreCase))
|
||||
throw new ScriptException("Name is invalid as a custom header at parameter " + i.ToString());
|
||||
|
||||
param.Add(parameters.Data[i].ToString());
|
||||
param.Add(parameters.Data[i+1].ToString());
|
||||
|
||||
//Have we reached the end of the list of headers?
|
||||
//End is marked by a string with a single digit.
|
||||
if (i+2 >= parameters.Data.Length ||
|
||||
Char.IsDigit(parameters.Data[i].ToString()[0]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 position = m_host.AbsolutePosition;
|
||||
@@ -11295,12 +11363,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
public LSL_Integer llGetParcelPrimCount(LSL_Vector pos, int category, int sim_wide)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
|
||||
ILandObject lo = World.LandChannel.GetLandObject((float)pos.x, (float)pos.y);
|
||||
|
||||
if (lo == null)
|
||||
return 0;
|
||||
|
||||
|
||||
IPrimCounts pc = lo.PrimCounts;
|
||||
|
||||
if (sim_wide != ScriptBaseClass.FALSE)
|
||||
@@ -11330,7 +11398,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
else if (category == ScriptBaseClass.PARCEL_COUNT_TEMP)
|
||||
return 0; // counts not implemented yet
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -11691,7 +11759,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new LSL_List();
|
||||
}
|
||||
|
||||
@@ -12071,7 +12139,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
// Vector3 bc = group.AbsolutePosition - rayEnd;
|
||||
|
||||
double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / Vector3.Distance(rayStart, rayEnd));
|
||||
|
||||
|
||||
// Too far off ray, don't bother
|
||||
if (d > radius)
|
||||
return;
|
||||
@@ -12434,7 +12502,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
else
|
||||
{
|
||||
ScenePresence sp = World.GetScenePresence(result.ConsumerID);
|
||||
/// It it a boy? a girl?
|
||||
/// It it a boy? a girl?
|
||||
if (sp != null)
|
||||
itemID = sp.UUID;
|
||||
}
|
||||
|
||||
@@ -356,6 +356,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
public const int HTTP_MIMETYPE = 1;
|
||||
public const int HTTP_BODY_MAXLENGTH = 2;
|
||||
public const int HTTP_VERIFY_CERT = 3;
|
||||
public const int HTTP_VERBOSE_THROTTLE = 4;
|
||||
public const int HTTP_CUSTOM_HEADER = 5;
|
||||
public const int HTTP_PRAGMA_NO_CACHE = 6;
|
||||
|
||||
public const int PRIM_MATERIAL = 2;
|
||||
public const int PRIM_PHYSICS = 3;
|
||||
@@ -636,7 +639,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
public const int TOUCH_INVALID_FACE = -1;
|
||||
public static readonly vector TOUCH_INVALID_TEXCOORD = new vector(-1.0, -1.0, 0.0);
|
||||
public static readonly vector TOUCH_INVALID_VECTOR = ZERO_VECTOR;
|
||||
|
||||
|
||||
// constants for llGetPrimMediaParams/llSetPrimMediaParams
|
||||
public const int PRIM_MEDIA_ALT_IMAGE_ENABLE = 0;
|
||||
public const int PRIM_MEDIA_CONTROLS = 1;
|
||||
@@ -653,10 +656,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
public const int PRIM_MEDIA_WHITELIST = 12;
|
||||
public const int PRIM_MEDIA_PERMS_INTERACT = 13;
|
||||
public const int PRIM_MEDIA_PERMS_CONTROL = 14;
|
||||
|
||||
|
||||
public const int PRIM_MEDIA_CONTROLS_STANDARD = 0;
|
||||
public const int PRIM_MEDIA_CONTROLS_MINI = 1;
|
||||
|
||||
|
||||
public const int PRIM_MEDIA_PERM_NONE = 0;
|
||||
public const int PRIM_MEDIA_PERM_OWNER = 1;
|
||||
public const int PRIM_MEDIA_PERM_GROUP = 2;
|
||||
@@ -689,7 +692,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
public const string TEXTURE_PLYWOOD = "89556747-24cb-43ed-920b-47caed15465f";
|
||||
public const string TEXTURE_TRANSPARENT = "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903";
|
||||
public const string TEXTURE_MEDIA = "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361";
|
||||
|
||||
|
||||
// Constants for osGetRegionStats
|
||||
public const int STATS_TIME_DILATION = 0;
|
||||
public const int STATS_SIM_FPS = 1;
|
||||
@@ -742,7 +745,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
public static readonly LSLInteger RC_GET_ROOT_KEY = 2;
|
||||
public static readonly LSLInteger RC_GET_LINK_NUM = 4;
|
||||
|
||||
public static readonly LSLInteger RCERR_UNKNOWN = -1;
|
||||
public static readonly LSLInteger RCERR_UNKNOWN = -1;
|
||||
public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2;
|
||||
public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = -3;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user