Fix mantis #6170 - Check if first argument of PRIM_TEXT is string or key

Signed-off-by: UbitUmarov <ajlduarte@sapo.pt>
This commit is contained in:
Kevin Cozens
2023-03-14 14:16:06 -04:00
committed by UbitUmarov
parent c9281979c0
commit e40fe91966

View File

@@ -2276,7 +2276,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!pbs.SculptEntry && (pbs.PathCurve == (byte)Extrusion.Straight || pbs.PathCurve == (byte)Extrusion.Flexible)) if (!pbs.SculptEntry && (pbs.PathCurve == (byte)Extrusion.Straight || pbs.PathCurve == (byte)Extrusion.Flexible))
{ {
if(flexi) if(flexi)
{ {
pbs.PathCurve = (byte)Extrusion.Flexible; pbs.PathCurve = (byte)Extrusion.Flexible;
if(!sog.IsPhantom) if(!sog.IsPhantom)
{ {
@@ -2477,7 +2477,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
Primitive.TextureEntry tex = part.Shape.Textures; Primitive.TextureEntry tex = part.Shape.Textures;
int nsides = GetNumberOfSides(part); int nsides = GetNumberOfSides(part);
if (face >= 0 && face < nsides) if (face >= 0 && face < nsides)
{ {
@@ -2773,7 +2773,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
SceneObjectGroup grp = part.ParentGroup; SceneObjectGroup grp = part.ParentGroup;
if (grp == null || grp.IsDeleted || grp.inTransit) if (grp == null || grp.IsDeleted || grp.inTransit)
return; return;
LSL_Vector currentPos = GetPartLocalPos(part); LSL_Vector currentPos = GetPartLocalPos(part);
LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos, adjust); LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos, adjust);
@@ -3152,7 +3152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if(soundID.IsZero()) if(soundID.IsZero())
return; return;
// send the sound, once, to all clients in range // send the sound, once, to all clients in range
m_SoundModule.SendSound(m_host.UUID, soundID, volume, false, 0, false, false); m_SoundModule.SendSound(m_host.UUID, soundID, volume, false, 0, false, false);
} }
@@ -3165,12 +3165,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
SceneObjectPart sop; SceneObjectPart sop;
if (linknumber == ScriptBaseClass.LINK_THIS) if (linknumber == ScriptBaseClass.LINK_THIS)
sop = m_host; sop = m_host;
else if (linknumber < 0) else if (linknumber < 0)
return; return;
else if (linknumber < 2) else if (linknumber < 2)
sop = m_host.ParentGroup.RootPart; sop = m_host.ParentGroup.RootPart;
else else
sop = m_host.ParentGroup.GetLinkNumPart(linknumber); sop = m_host.ParentGroup.GetLinkNumPart(linknumber);
if(sop == null) if(sop == null)
@@ -3180,7 +3180,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (soundID.IsZero()) if (soundID.IsZero())
return; return;
// send the sound, once, to all clients in range // send the sound, once, to all clients in range
m_SoundModule.SendSound(sop.UUID, soundID, volume, false, 0, false, false); m_SoundModule.SendSound(sop.UUID, soundID, volume, false, 0, false, false);
} }
@@ -3978,7 +3978,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
message = (message.Length > 1024) ? message.Substring(0, 1024) : message, message = (message.Length > 1024) ? message.Substring(0, 1024) : message,
binaryBucket = Util.StringToBytes256("{0}/{1}/{2}/{3}", m_regionName, (int)pos.X, (int)pos.Y, (int)pos.Z) binaryBucket = Util.StringToBytes256("{0}/{1}/{2}/{3}", m_regionName, (int)pos.X, (int)pos.Y, (int)pos.Z)
}; };
m_TransferModule?.SendInstantMessage(msg, delegate(bool success) {}); m_TransferModule?.SendInstantMessage(msg, delegate(bool success) {});
ScriptSleep(m_sleepMsOnInstantMessage); ScriptSleep(m_sleepMsOnInstantMessage);
} }
@@ -5770,7 +5770,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
if(key.IsZero()) if(key.IsZero())
return id; return id;
SceneObjectPart obj = World.GetSceneObjectPart(key); SceneObjectPart obj = World.GetSceneObjectPart(key);
return (obj == null) ? id : obj.OwnerID.ToString(); return (obj == null) ? id : obj.OwnerID.ToString();
} }
@@ -5933,7 +5933,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// a string, a key as string and a string that by coincidence // a string, a key as string and a string that by coincidence
// is a string, so we're going to leave that up to the // is a string, so we're going to leave that up to the
// LSL_Vector constructor. // LSL_Vector constructor.
if(item is LSL_Vector) if(item is LSL_Vector)
return (LSL_Vector) item; return (LSL_Vector) item;
if (item is LSL_String || item is string) // xengine sees string if (item is LSL_String || item is string) // xengine sees string
@@ -5958,7 +5958,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// a string, a key as string and a string that by coincidence // a string, a key as string and a string that by coincidence
// is a string, so we're going to leave that up to the // is a string, so we're going to leave that up to the
// LSL_Rotation constructor. // LSL_Rotation constructor.
if (item.GetType() == typeof(LSL_Rotation)) if (item.GetType() == typeof(LSL_Rotation))
return (LSL_Rotation)item; return (LSL_Rotation)item;
@@ -6521,7 +6521,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// Remove as they are done /// Remove as they are done
/// </summary> /// </summary>
static readonly UUID busyAnimation = new UUID("efcf670c-2d18-8128-973a-034ebc806b67"); static readonly UUID busyAnimation = new UUID("efcf670c-2d18-8128-973a-034ebc806b67");
public LSL_Integer llGetAgentInfo(LSL_Key id) public LSL_Integer llGetAgentInfo(LSL_Key id)
{ {
@@ -8311,7 +8311,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_String llSHA256String(LSL_String input) public LSL_String llSHA256String(LSL_String input)
{ {
// Create a SHA256 // Create a SHA256
using (SHA256 sha256Hash = SHA256.Create()) using (SHA256 sha256Hash = SHA256.Create())
{ {
// ComputeHash - returns byte array // ComputeHash - returns byte array
@@ -10155,14 +10155,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Vector primTextColor; LSL_Vector primTextColor;
LSL_Float primTextAlpha; LSL_Float primTextAlpha;
try object o = rules.Data[idx];
{ if (o is LSL_Types.LSLString || o is LSL_Types.key)
primText = rules.GetLSLStringItem(idx++); primText = rules.GetLSLStringItem(idx++);
} else
catch(InvalidCastException)
{ {
Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TEXT: arg #{1} - parameter 2 must be string", rulesParsed, idx - idxStart - 1)); //throw new InvalidCastException(string.Format("Error running rule #{0} -> PRIM_TEXT: arg #{1} - parameter 2 must be string", rulesParsed, idx - idxStart - 1));
return new LSL_List(); Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TEXT: arg #{1} - parameter 2 must be string", rulesParsed, idx - idxStart - 1));
return new LSL_List();
} }
try try
{ {
@@ -10378,7 +10378,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Error(originFunc, string.Format("Error running rule #{0} -> PRIM_ALPHA_MODE: arg #{1} - must be 0 to 255", rulesParsed, idx - idxStart - 1)); Error(originFunc, string.Format("Error running rule #{0} -> PRIM_ALPHA_MODE: arg #{1} - must be 0 to 255", rulesParsed, idx - idxStart - 1));
return new LSL_List(); return new LSL_List();
} }
materialChanged |= SetMaterialAlphaMode(part, face, materialAlphaMode, materialMaskCutoff); materialChanged |= SetMaterialAlphaMode(part, face, materialAlphaMode, materialMaskCutoff);
break; break;
@@ -10442,7 +10442,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Error(originFunc, string.Format("Error running rule #{0} -> PRIM_NORMAL: arg #{1} - must be float", rulesParsed, idx - idxStart - 1)); Error(originFunc, string.Format("Error running rule #{0} -> PRIM_NORMAL: arg #{1} - must be float", rulesParsed, idx - idxStart - 1));
return new LSL_List(); return new LSL_List();
} }
float repeatX = (float)Util.Clamp(mnrepeat.x,-100.0, 100.0); float repeatX = (float)Util.Clamp(mnrepeat.x,-100.0, 100.0);
float repeatY = (float)Util.Clamp(mnrepeat.y,-100.0, 100.0); float repeatY = (float)Util.Clamp(mnrepeat.y,-100.0, 100.0);
float offsetX = (float)Util.Clamp(mnoffset.x, 0, 1.0); float offsetX = (float)Util.Clamp(mnoffset.x, 0, 1.0);
@@ -10544,7 +10544,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SPECULAR: arg #{1} - must be integer", rulesParsed, idx - idxStart - 1)); Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SPECULAR: arg #{1} - must be integer", rulesParsed, idx - idxStart - 1));
return new LSL_List(); return new LSL_List();
} }
float srepeatX = (float)Util.Clamp(msrepeat.x, -100.0, 100.0); float srepeatX = (float)Util.Clamp(msrepeat.x, -100.0, 100.0);
float srepeatY = (float)Util.Clamp(msrepeat.y, -100.0, 100.0); float srepeatY = (float)Util.Clamp(msrepeat.y, -100.0, 100.0);
float soffsetX = (float)Util.Clamp(msoffset.x, -1.0, 1.0); float soffsetX = (float)Util.Clamp(msoffset.x, -1.0, 1.0);
@@ -10686,8 +10686,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
if(m_materialsModule == null) if(m_materialsModule == null)
return false; return false;
int nsides = part.GetNumberOfSides(); int nsides = part.GetNumberOfSides();
if(face == ScriptBaseClass.ALL_SIDES) if(face == ScriptBaseClass.ALL_SIDES)
{ {
@@ -10741,8 +10741,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
if(m_materialsModule == null) if(m_materialsModule == null)
return false; return false;
int nsides = part.GetNumberOfSides(); int nsides = part.GetNumberOfSides();
if(face == ScriptBaseClass.ALL_SIDES) if(face == ScriptBaseClass.ALL_SIDES)
{ {
@@ -10806,8 +10806,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
if(m_materialsModule == null) if(m_materialsModule == null)
return false; return false;
int nsides = part.GetNumberOfSides(); int nsides = part.GetNumberOfSides();
if(face == ScriptBaseClass.ALL_SIDES) if(face == ScriptBaseClass.ALL_SIDES)
{ {
@@ -12896,7 +12896,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
try try
{ {
if (m_regionName.Equals(simulator)) if (m_regionName.Equals(simulator))
{ {
string lreply = String.Empty; string lreply = String.Empty;
@@ -17886,7 +17886,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_List(); return new LSL_List();
char first = ((string)json)[0]; char first = ((string)json)[0];
if(first != '[' && first !='{') if(first != '[' && first !='{')
{ {
// we already have a single element // we already have a single element
LSL_List l = new LSL_List(); LSL_List l = new LSL_List();
@@ -17920,7 +17920,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_List retl = new LSL_List(); LSL_List retl = new LSL_List();
if(elem == null) if(elem == null)
retl.Add((LSL_String)ScriptBaseClass.JSON_NULL); retl.Add((LSL_String)ScriptBaseClass.JSON_NULL);
LitJson.JsonType elemType = elem.GetJsonType(); LitJson.JsonType elemType = elem.GetJsonType();
switch (elemType) switch (elemType)
{ {
@@ -18041,7 +18041,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return "\"Inf\""; return "\"Inf\"";
if(double.IsNaN(float_val)) if(double.IsNaN(float_val))
return "\"NaN\""; return "\"NaN\"";
return ((LSL_Float)float_val).ToString(); return ((LSL_Float)float_val).ToString();
} }
if (o is LSL_Integer || o is int) if (o is LSL_Integer || o is int)
@@ -18269,7 +18269,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
newData.SetJsonType(LitJson.JsonType.Array); newData.SetJsonType(LitJson.JsonType.Array);
newData.Add(JsonBuildRestOfSpec(specifiers, level + 1, val)); newData.Add(JsonBuildRestOfSpec(specifiers, level + 1, val));
return newData; return newData;
} }
} }
else else
{ {