simplify DeliverChatToAvatars(..) ( hopefully not breaking it )

LSLKeyTest
UbitUmarov 2015-11-24 17:28:05 +00:00
parent a0c3297b37
commit 6d5b405168
1 changed files with 66 additions and 77 deletions

View File

@ -206,7 +206,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
UUID fromID = UUID.Zero; UUID fromID = UUID.Zero;
UUID ownerID = UUID.Zero; UUID ownerID = UUID.Zero;
string message = c.Message; string message = c.Message;
IScene scene = c.Scene; Scene scene = c.Scene as Scene;
UUID destination = c.Destination; UUID destination = c.Destination;
Vector3 fromPos = c.Position; Vector3 fromPos = c.Position;
Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0); Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0);
@ -217,47 +217,48 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel; if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel;
if(!m_scenes.Contains(scene))
{
m_log.WarnFormat("[CHAT]: message from unkown scene {0} ignored",
scene.RegionInfo.RegionName);
return;
}
switch (sourceType) switch (sourceType)
{ {
case ChatSourceType.Agent: case ChatSourceType.Agent:
if (!(scene is Scene)) ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
{ fromPos = avatar.AbsolutePosition;
m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}", fromName = avatar.Name;
scene.RegionInfo.RegionName, c.Sender.AgentId); fromID = c.Sender.AgentId;
return; if (avatar.GodLevel >= 200)
} { // let gods speak to outside or things may get confusing
ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId); fromNamePrefix = m_adminPrefix;
fromPos = avatar.AbsolutePosition; checkParcelHide = false;
fromName = avatar.Name; }
fromID = c.Sender.AgentId; else
if (avatar.GodLevel >= 200)
{ // let gods speak to outside or things may get confusing
fromNamePrefix = m_adminPrefix;
checkParcelHide = false;
}
else
{
checkParcelHide = true;
}
destination = UUID.Zero; // Avatars cant "SayTo"
ownerID = c.Sender.AgentId;
hidePos = fromPos;
break;
case ChatSourceType.Object:
fromID = c.SenderUUID;
if (c.SenderObject != null && c.SenderObject is SceneObjectPart)
{
ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
if (((SceneObjectPart)c.SenderObject).ParentGroup.IsAttachment)
{ {
checkParcelHide = true; checkParcelHide = true;
hidePos = ((SceneObjectPart)c.SenderObject).ParentGroup.AbsolutePosition;
} }
} destination = UUID.Zero; // Avatars cant "SayTo"
break; ownerID = c.Sender.AgentId;
hidePos = fromPos;
break;
case ChatSourceType.Object:
fromID = c.SenderUUID;
if (c.SenderObject != null && c.SenderObject is SceneObjectPart)
{
ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
if (((SceneObjectPart)c.SenderObject).ParentGroup.IsAttachment)
{
checkParcelHide = true;
hidePos = ((SceneObjectPart)c.SenderObject).ParentGroup.AbsolutePosition;
}
}
break;
} }
// TODO: iterate over message // TODO: iterate over message
@ -275,7 +276,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
checkParcelHide = false; checkParcelHide = false;
if (c.Type < ChatTypeEnum.DebugChannel && destination == UUID.Zero) if (c.Type < ChatTypeEnum.DebugChannel && destination == UUID.Zero)
{ {
ILandObject srcland = (scene as Scene).LandChannel.GetLandObject(hidePos.X, hidePos.Y); ILandObject srcland = scene.LandChannel.GetLandObject(hidePos.X, hidePos.Y);
if (srcland != null && !srcland.LandData.SeeAVs) if (srcland != null && !srcland.LandData.SeeAVs)
{ {
sourceParcelID = srcland.LandData.GlobalID; sourceParcelID = srcland.LandData.GlobalID;
@ -284,54 +285,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
} }
} }
foreach (Scene s in m_scenes) scene.ForEachScenePresence(
{ delegate(ScenePresence presence)
// This should use ForEachClient, but clients don't have a position. {
// If camera is moved into client, then camera position can be used if (destination != UUID.Zero && presence.UUID != destination)
// MT: No, it can't, as chat is heard from the avatar position, not return;
// the camera position.
s.ForEachScenePresence( if(presence.IsChildAgent)
delegate(ScenePresence presence)
{
if (receiverIDs.Contains(presence.UUID))
return; // already sent to this presence
if (destination != UUID.Zero && presence.UUID != destination)
return;
ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
if (Presencecheck != null)
{ {
// This will pass all chat from objects. Not if(checkParcelHide)
// perfect, but it will do. For now. Better return;
// than the prior behavior of muting all if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
// objects on a parcel with access restrictions ownerID, fromNamePrefix + fromName, c.Type,
if (checkParcelHide) message, sourceType, (destination != UUID.Zero)))
{ receiverIDs.Add(presence.UUID);
if (sourceParcelID != Presencecheck.LandData.GlobalID && presence.GodLevel < 200) return;
return;
}
if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
{
if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
ownerID, fromNamePrefix + fromName, c.Type,
message, sourceType, (destination != UUID.Zero)))
receiverIDs.Add(presence.UUID);
}
} }
else if(!checkParcelHide && (presence.IsChildAgent))
ILandObject Presencecheck = scene.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
if (Presencecheck != null)
{
if (checkParcelHide)
{
if (sourceParcelID != Presencecheck.LandData.GlobalID && presence.GodLevel < 200)
return;
}
if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
{ {
if (TrySendChatMessage(presence, fromPos, regionPos, fromID, if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
ownerID, fromNamePrefix + fromName, c.Type, ownerID, fromNamePrefix + fromName, c.Type,
message, sourceType, (destination != UUID.Zero))) message, sourceType, (destination != UUID.Zero)))
receiverIDs.Add(presence.UUID); receiverIDs.Add(presence.UUID);
} }
} }
); });
}
(scene as Scene).EventManager.TriggerOnChatToClients( scene.EventManager.TriggerOnChatToClients(
fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
} }