diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
index 3da4130765..00344ecc5a 100644
--- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
+++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
@@ -108,6 +108,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// key of sender (object or avatar)
/// msg to sent
void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg);
+ void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg, Vector3 sourcePosition);
///
/// Delivers the message to a specified object in the region.
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 374741bdbe..a486e896f3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -99,6 +99,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected SceneObjectPart m_host;
protected UUID RegionScopeID = UUID.Zero;
+ protected string m_regionName = String.Empty;
///
/// The item that hosts this script
///
@@ -261,30 +262,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
private string m_lsl_shard = "OpenSim";
private string m_lsl_user_agent = string.Empty;
- private static readonly Dictionary MovementAnimationsForLSL =
- new Dictionary {
- {"CROUCH", "Crouching"},
- {"CROUCHWALK", "CrouchWalking"},
- {"FALLDOWN", "Falling Down"},
- {"FLY", "Flying"},
- {"FLYSLOW", "FlyingSlow"},
- {"HOVER", "Hovering"},
- {"HOVER_UP", "Hovering Up"},
- {"HOVER_DOWN", "Hovering Down"},
- {"JUMP", "Jumping"},
- {"LAND", "Landing"},
- {"PREJUMP", "PreJumping"},
- {"RUN", "Running"},
- {"SIT","Sitting"},
- {"SITGROUND","Sitting on Ground"},
- {"STAND", "Standing"},
- {"STANDUP", "Standing Up"},
- {"STRIDE","Striding"},
- {"SOFT_LAND", "Soft Landing"},
- {"TURNLEFT", "Turning Left"},
- {"TURNRIGHT", "Turning Right"},
- {"WALK", "Walking"}
- };
+ private static readonly Dictionary MovementAnimationsForLSL = new Dictionary(StringComparer.InvariantCultureIgnoreCase)
+ {
+ {"CROUCH", "Crouching"},
+ {"CROUCHWALK", "CrouchWalking"},
+ {"FALLDOWN", "Falling Down"},
+ {"FLY", "Flying"},
+ {"FLYSLOW", "FlyingSlow"},
+ {"HOVER", "Hovering"},
+ {"HOVER_UP", "Hovering Up"},
+ {"HOVER_DOWN", "Hovering Down"},
+ {"JUMP", "Jumping"},
+ {"LAND", "Landing"},
+ {"PREJUMP", "PreJumping"},
+ {"RUN", "Running"},
+ {"SIT","Sitting"},
+ {"SITGROUND","Sitting on Ground"},
+ {"STAND", "Standing"},
+ {"STANDUP", "Standing Up"},
+ {"STRIDE","Striding"},
+ {"SOFT_LAND", "Soft Landing"},
+ {"TURNLEFT", "Turning Left"},
+ {"TURNRIGHT", "Turning Right"},
+ {"WALK", "Walking"}
+ };
//llHTTPRequest custom headers use control
// true means fatal error,
@@ -381,8 +382,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
"referer", "trailer", "transfer-encoding", "via", "authorization"
};
- public void Initialize(
- IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item)
+ public void Initialize(IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item)
{
m_lastSayShoutCheck = DateTime.UtcNow;
@@ -393,8 +393,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LoadConfig();
- m_TransferModule =
- m_ScriptEngine.World.RequestModuleInterface();
+ m_TransferModule = m_ScriptEngine.World.RequestModuleInterface();
m_UrlModule = m_ScriptEngine.World.RequestModuleInterface();
m_SoundModule = m_ScriptEngine.World.RequestModuleInterface();
m_materialsModule = m_ScriptEngine.World.RequestModuleInterface();
@@ -405,8 +404,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_AsyncCommands = new AsyncCommandManager(m_ScriptEngine);
m_userAccountService = World.UserAccountService;
if(World.RegionInfo != null)
+ {
RegionScopeID = World.RegionInfo.ScopeID;
-
+ m_regionName = World.RegionInfo.RegionName;
+ }
}
///
@@ -1217,17 +1218,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llWhisper(int channelID, string text)
{
-
- if (text.Length > 1023)
- text = text.Substring(0, 1023);
-
byte[] binText = Utils.StringToBytesNoTerm(text, 1023);
World.SimChat(binText,
ChatTypeEnum.Whisper, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false);
IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface();
if (wComm != null)
- wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, Util.UTF8.GetString(binText));
+ wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, Util.UTF8.GetString(binText), m_host.AbsolutePosition);
}
private void CheckSayShoutTime()
@@ -1272,7 +1269,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface();
if (wComm != null)
- wComm.DeliverMessage(ChatTypeEnum.Say, channelID, m_host.Name, m_host.UUID, Util.UTF8.GetString(binText));
+ wComm.DeliverMessage(ChatTypeEnum.Say, channelID, m_host.Name, m_host.UUID, Util.UTF8.GetString(binText), m_host.AbsolutePosition);
}
}
@@ -1293,7 +1290,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface();
if (wComm != null)
- wComm.DeliverMessage(ChatTypeEnum.Shout, channelID, m_host.Name, m_host.UUID, Util.UTF8.GetString(binText));
+ wComm.DeliverMessage(ChatTypeEnum.Shout, channelID, m_host.Name, m_host.UUID, Util.UTF8.GetString(binText), m_host.AbsolutePosition);
}
public void llRegionSay(int channelID, string text)
@@ -1320,18 +1317,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llRegionSayTo(string target, int channel, string msg)
{
- if (msg.Length > 1023)
- msg = msg.Substring(0, 1023);
-
-
if (channel == ScriptBaseClass.DEBUG_CHANNEL)
return;
- UUID.TryParse(target, out UUID TargetID);
+ if(UUID.TryParse(target, out UUID TargetID) && TargetID.IsNotZero())
+ {
+ IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface();
+ if (wComm != null)
+ {
+ if (msg.Length > 1023)
+ msg = msg.Substring(0, 1023);
- IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface();
- if (wComm != null)
- wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg);
+ wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg);
+ }
+ }
}
public LSL_Integer llListen(int channelID, string name, string ID, string msg)
@@ -2008,7 +2007,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Primitive.TextureEntry tex = part.Shape.Textures;
MappingType textype;
textype = MappingType.Default;
- if (style == (int)ScriptBaseClass.PRIM_TEXGEN_PLANAR)
+ if (style == ScriptBaseClass.PRIM_TEXGEN_PLANAR)
textype = MappingType.Planar;
int nsides = GetNumberOfSides(part);
@@ -3907,62 +3906,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return m_host.OwnerID.ToString();
}
- public void llInstantMessage(string user, string message)
+ public void llInstantMessage(string userKey, string message)
{
- if (!UUID.TryParse(user, out UUID result) || result.IsZero())
+ if (m_TransferModule == null || String.IsNullOrEmpty(message))
+ return;
+
+ if (!UUID.TryParse(userKey, out UUID userID) || userID.IsZero())
{
Error("llInstantMessage","An invalid key was passed to llInstantMessage");
ScriptSleep(2000);
return;
}
- // We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
- // InstantMessageModule.OnInstantMessage searches through a list of scenes for a client matching the toAgent,
- // but I don't think we have a list of scenes available from here.
- // (We also don't want to duplicate the code in OnInstantMessage if we can avoid it.)
-
- // user is a UUID
-
- // TODO: figure out values for client, fromSession, and imSessionID
- // client.SendInstantMessage(m_host.UUID, fromSession, message, user, imSessionID, m_host.Name, AgentManager.InstantMessageDialog.MessageFromAgent, (uint)Util.UnixTimeSinceEpoch());
- UUID friendTransactionID = UUID.Random();
-
- //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
-
+ Vector3 pos = m_host.AbsolutePosition;
GridInstantMessage msg = new GridInstantMessage
{
- fromAgentID = new Guid(m_host.OwnerID.ToString()), // fromAgentID.Guid;
- toAgentID = new Guid(user), // toAgentID.Guid;
- imSessionID = new Guid(m_host.UUID.ToString()), // This is the item we're mucking with here
+ fromAgentID = m_host.OwnerID.Guid,
+ toAgentID = userID.Guid,
+ imSessionID = m_host.UUID.Guid, // This is the item we're mucking with here
timestamp = (uint)Util.UnixTimeSinceEpoch(),
- fromAgentName = m_host.Name//client.FirstName + " " + client.LastName;// fromAgentName;
+ fromAgentName = m_host.Name, //client.FirstName + " " + client.LastName;// fromAgentName;
+ dialog = 19, // MessageFromObject
+ fromGroup = false,
+ offline = 0,
+ ParentEstateID = World.RegionInfo.EstateSettings.EstateID,
+ Position = pos,
+ RegionID = World.RegionInfo.RegionID.Guid,
+ 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)
};
-
- if (message != null && message.Length > 1024)
- msg.message = message.Substring(0, 1024);
- else
- msg.message = message;
- msg.dialog = (byte)19; // MessageFromObject
- msg.fromGroup = false;// fromGroup;
- msg.offline = (byte)0; //offline;
- msg.ParentEstateID = World.RegionInfo.EstateSettings.EstateID;
- msg.Position = new Vector3(m_host.AbsolutePosition);
- msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid;
-
- Vector3 pos = m_host.AbsolutePosition;
- msg.binaryBucket
- = Util.StringToBytes256(
- "{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) {});
- }
-
+
+ m_TransferModule?.SendInstantMessage(msg, delegate(bool success) {});
ScriptSleep(m_sleepMsOnInstantMessage);
}
@@ -4789,17 +4763,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llGiveInventory(LSL_Key destination, LSL_String inventory)
{
-
- UUID destId = UUID.Zero;
-
- if (!UUID.TryParse(destination, out destId))
+ if (!UUID.TryParse(destination, out UUID destId))
{
Error("llGiveInventory", "Can't parse destination key '" + destination + "'");
return;
}
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory);
-
if (item == null)
{
Error("llGiveInventory", "Can't find inventory object '" + inventory + "'");
@@ -4849,19 +4819,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.OwnerID, m_host.Name, destId,
(byte)InstantMessageDialog.TaskInventoryOffered,
m_host.OwnerID.Equals(m_host.GroupID), "'"+item.Name+"'. ("+m_host.Name+" is located at "+
- World.RegionInfo.RegionName+" "+ m_host.AbsolutePosition.ToString() + ")",
+ m_regionName + " "+ m_host.AbsolutePosition.ToString() + ")",
agentItem.ID, true, m_host.AbsolutePosition,
bucket, true);
if (World.TryGetScenePresence(destId, out ScenePresence sp))
- {
sp.ControllingClient.SendInstantMessage(msg);
- }
else
- {
- if (m_TransferModule != null)
- m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
- }
+ m_TransferModule?.SendInstantMessage(msg, delegate(bool success) {});
//This delay should only occur when giving inventory to avatars.
ScriptSleep(m_sleepMsOnGiveInventory);
@@ -5166,7 +5131,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (assetID.IsZero())
{
if(string.IsNullOrEmpty(destination))
- World.RequestTeleportLocation(sp.ControllingClient, World.RegionInfo.RegionName, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation);
+ World.RequestTeleportLocation(sp.ControllingClient, m_regionName, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation);
else
World.RequestTeleportLocation(sp.ControllingClient, destination, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation);
return;
@@ -6481,8 +6446,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llGetAgentInfo(LSL_Key id)
{
- UUID key = new UUID();
- if (!UUID.TryParse(id, out key))
+ if (!UUID.TryParse(id, out UUID key))
{
return 0;
}
@@ -7201,7 +7165,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_String llGetRegionName()
{
- return World.RegionInfo.RegionName;
+ return m_regionName;
}
public LSL_Float llGetRegionTimeDilation()
@@ -12827,7 +12791,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
try
{
- if (World.RegionInfo.RegionName == simulator)
+ if (m_regionName.Equals(simulator))
{
string lreply = String.Empty;
RegionInfo rinfo = World.RegionInfo;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index 0f83d930b4..10941b8fec 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -113,7 +113,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true);
IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface();
- wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
+ wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message, m_host.AbsolutePosition);
}
///