simplify DeliverChatToAvatars(..) ( hopefully not breaking it )
parent
a0c3297b37
commit
6d5b405168
|
@ -206,7 +206,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
|||
UUID fromID = UUID.Zero;
|
||||
UUID ownerID = UUID.Zero;
|
||||
string message = c.Message;
|
||||
IScene scene = c.Scene;
|
||||
Scene scene = c.Scene as Scene;
|
||||
UUID destination = c.Destination;
|
||||
Vector3 fromPos = c.Position;
|
||||
Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0);
|
||||
|
@ -217,15 +217,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
|||
|
||||
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)
|
||||
{
|
||||
case ChatSourceType.Agent:
|
||||
if (!(scene is Scene))
|
||||
{
|
||||
m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}",
|
||||
scene.RegionInfo.RegionName, c.Sender.AgentId);
|
||||
return;
|
||||
}
|
||||
ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
|
||||
fromPos = avatar.AbsolutePosition;
|
||||
fromName = avatar.Name;
|
||||
|
@ -275,7 +276,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
|||
checkParcelHide = false;
|
||||
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)
|
||||
{
|
||||
sourceParcelID = srcland.LandData.GlobalID;
|
||||
|
@ -284,29 +285,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
|||
}
|
||||
}
|
||||
|
||||
foreach (Scene s in m_scenes)
|
||||
{
|
||||
// This should use ForEachClient, but clients don't have a position.
|
||||
// If camera is moved into client, then camera position can be used
|
||||
// MT: No, it can't, as chat is heard from the avatar position, not
|
||||
// the camera position.
|
||||
|
||||
s.ForEachScenePresence(
|
||||
scene.ForEachScenePresence(
|
||||
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(presence.IsChildAgent)
|
||||
{
|
||||
if(checkParcelHide)
|
||||
return;
|
||||
if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
|
||||
ownerID, fromNamePrefix + fromName, c.Type,
|
||||
message, sourceType, (destination != UUID.Zero)))
|
||||
receiverIDs.Add(presence.UUID);
|
||||
return;
|
||||
}
|
||||
|
||||
ILandObject Presencecheck = scene.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
|
||||
if (Presencecheck != null)
|
||||
{
|
||||
// This will pass all chat from objects. Not
|
||||
// perfect, but it will do. For now. Better
|
||||
// than the prior behavior of muting all
|
||||
// objects on a parcel with access restrictions
|
||||
if (checkParcelHide)
|
||||
{
|
||||
if (sourceParcelID != Presencecheck.LandData.GlobalID && presence.GodLevel < 200)
|
||||
|
@ -320,18 +318,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
|||
receiverIDs.Add(presence.UUID);
|
||||
}
|
||||
}
|
||||
else if(!checkParcelHide && (presence.IsChildAgent))
|
||||
{
|
||||
if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
|
||||
ownerID, fromNamePrefix + fromName, c.Type,
|
||||
message, sourceType, (destination != UUID.Zero)))
|
||||
receiverIDs.Add(presence.UUID);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
(scene as Scene).EventManager.TriggerOnChatToClients(
|
||||
scene.EventManager.TriggerOnChatToClients(
|
||||
fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue