refactored ChatModule a bit.

misc cleanup and code convention fixes.
afrisby
Jeff Ames 2007-12-10 02:29:42 +00:00
parent e595f82489
commit e278d07220
7 changed files with 74 additions and 105 deletions

View File

@ -50,10 +50,12 @@ namespace OpenSim.Framework
Whisper = 0,
Say = 1,
Shout = 2,
// 3 is an obsolete version of Say
StartTyping = 4,
StopTyping = 5,
Broadcast = 0xFF
} ;
}
public enum ThrottleOutPacketType : int
{
Resend = 0,
@ -135,6 +137,9 @@ namespace OpenSim.Framework
set { m_sender = value; }
}
/// <summary>
///
/// </summary>
public IScene Scene
{
get { return m_scene; }
@ -153,18 +158,27 @@ namespace OpenSim.Framework
private sbyte m_discardLevel;
private uint m_packetNumber;
/// <summary>
///
/// </summary>
public uint PacketNumber
{
get { return m_packetNumber; }
set { m_packetNumber = value; }
}
/// <summary>
///
/// </summary>
public sbyte DiscardLevel
{
get { return m_discardLevel; }
set { m_discardLevel = value; }
}
/// <summary>
///
/// </summary>
public LLUUID RequestedAssetID
{
get { return m_requestedAssetID; }
@ -176,6 +190,9 @@ namespace OpenSim.Framework
{
private List<Wearable> m_nowWearing = new List<Wearable>();
/// <summary>
///
/// </summary>
public List<Wearable> NowWearing
{
get { return m_nowWearing; }
@ -269,6 +286,7 @@ namespace OpenSim.Framework
public delegate void AgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset);
public delegate void AgentSit(IClientAPI remoteClient, LLUUID agentID);
public delegate void AvatarPickerRequest(IClientAPI remoteClient, LLUUID agentdata, LLUUID queryID, string UserQuery);
public delegate void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 grapPos, IClientAPI remoteClient);
@ -340,7 +358,6 @@ namespace OpenSim.Framework
public delegate void ObjectPermissions(IClientAPI remoteClinet, LLUUID AgentID, LLUUID SessionID, List<ObjectPermissionsPacket.ObjectDataBlock> permChanges);
public interface IClientAPI
{
event ImprovedInstantMessage OnInstantMessage;

View File

@ -587,7 +587,6 @@ namespace OpenSim.Region.ClientStack
/// <summary>
///
/// </summary>
/// <remarks>TODO</remarks>
/// <param name="message"></param>
/// <param name="target"></param>
public void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent,

View File

@ -110,6 +110,43 @@ namespace OpenSim.Region.Environment.Modules
client.OnChatFromViewer += SimChat;
}
private void TrySendChatMessage(ScenePresence presence, LLVector3 fromPos, LLVector3 regionPos,
LLUUID fromAgentID, string fromName, ChatTypeEnum type, string message)
{
if (!presence.IsChildAgent)
{
LLVector3 fromRegionPos = fromPos + regionPos;
LLVector3 toRegionPos = presence.AbsolutePosition + regionPos;
int dis = Math.Abs((int) Util.GetDistanceTo(toRegionPos, fromRegionPos));
switch (type)
{
case ChatTypeEnum.Whisper:
if (dis < m_whisperdistance)
{
// TODO: should change so the message is sent through the avatar rather than direct to the ClientView
presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID);
}
break;
case ChatTypeEnum.Say:
if (dis < m_saydistance)
{
presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID);
}
break;
case ChatTypeEnum.Shout:
if (dis < m_shoutdistance)
{
presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID);
}
break;
case ChatTypeEnum.Broadcast:
presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID);
break;
}
}
}
public void SimChat(Object sender, ChatFromViewerArgs e)
{
ScenePresence avatar = null;
@ -123,12 +160,10 @@ namespace OpenSim.Region.Environment.Modules
// Filled in since it's easier than rewriting right now.
LLVector3 fromPos = e.Position;
LLVector3 fromRegionPos = e.Position +
new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256,
0);
LLVector3 regionPos = new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, 0);
string fromName = e.From;
string message = e.Message;
byte type = (byte) e.Type;
LLUUID fromAgentID = LLUUID.Zero;
if (e.Sender != null)
@ -139,32 +174,11 @@ namespace OpenSim.Region.Environment.Modules
if (avatar != null)
{
fromPos = avatar.AbsolutePosition;
fromRegionPos = fromPos +
new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, 0);
regionPos = new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, 0);
fromName = avatar.Firstname + " " + avatar.Lastname;
fromAgentID = e.Sender.AgentId;
}
string typeName;
switch (e.Type)
{
case ChatTypeEnum.Broadcast:
typeName = "broadcasts";
break;
case ChatTypeEnum.Say:
typeName = "says";
break;
case ChatTypeEnum.Shout:
typeName = "shouts";
break;
case ChatTypeEnum.Whisper:
typeName = "whispers";
break;
default:
typeName = "unknown";
break;
}
if (e.Message.Length > 0)
{
if (m_irc.Connected)
@ -174,69 +188,13 @@ namespace OpenSim.Region.Environment.Modules
if (e.Channel == 0)
{
foreach (Scene m_scene in m_scenes)
foreach (Scene s in m_scenes)
{
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
{
if (!presence.IsChildAgent)
{
int dis = -100000;
LLVector3 avatarRegionPos = presence.AbsolutePosition +
new LLVector3(
scene.RegionInfo.RegionLocX * 256,
scene.RegionInfo.RegionLocY * 256,
0);
dis =
Math.Abs((int) Util.GetDistanceTo(avatarRegionPos, fromRegionPos));
switch (e.Type)
{
case ChatTypeEnum.Whisper:
if (dis < m_whisperdistance)
{
//should change so the message is sent through the avatar rather than direct to the ClientView
presence.ControllingClient.SendChatMessage(message,
type,
fromPos,
fromName,
fromAgentID);
}
break;
case ChatTypeEnum.Say:
if (dis < m_saydistance)
{
//Console.WriteLine("sending chat");
presence.ControllingClient.SendChatMessage(message,
type,
fromPos,
fromName,
fromAgentID);
}
break;
case ChatTypeEnum.Shout:
if (dis < m_shoutdistance)
{
presence.ControllingClient.SendChatMessage(message,
type,
fromPos,
fromName,
fromAgentID);
}
break;
case ChatTypeEnum.Broadcast:
presence.ControllingClient.SendChatMessage(message,
type,
fromPos,
fromName,
fromAgentID);
break;
default:
break;
}
}
});
s.ForEachScenePresence(delegate(ScenePresence presence)
{
TrySendChatMessage(presence, fromPos, regionPos,
fromAgentID, fromName, e.Type, message);
});
}
}
}

View File

@ -65,12 +65,12 @@ namespace OpenSim.Region.Environment.Modules
LLUUID imSessionID, uint timestamp, string fromAgentName,
string message, byte dialog)
{
foreach (Scene m_scene in m_scenes)
foreach (Scene scene in m_scenes)
{
if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence)
{
// Local Message
ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
// Local message
ScenePresence user = (ScenePresence) scene.Entities[toAgentID];
if (!user.IsChildAgent)
{
user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message,
@ -83,6 +83,7 @@ namespace OpenSim.Region.Environment.Modules
}
// Still here, try send via Grid
// TODO
}
public void PostInitialise()

View File

@ -156,10 +156,10 @@ namespace OpenSim.Region.Environment.Scenes
}
}
}
public void ProcessAvatarPickerRequest(IClientAPI client, LLUUID avatarID, LLUUID RequestID, string query)
{
//EventManager.TriggerAvatarPickerRequest();
List<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>();
AvatarResponses = CommsManager.GenerateAgentPickerRequestResponse(RequestID, query);
@ -167,7 +167,7 @@ namespace OpenSim.Region.Environment.Scenes
AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket();
AvatarPickerReplyPacket.DataBlock[] searchData = new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count];
AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();
agentData.AgentID = avatarID;
agentData.QueryID = RequestID;
replyPacket.AgentData = agentData;

View File

@ -68,7 +68,7 @@ namespace OpenSim.Region.Environment.Scenes
public Int32 CreationDate;
public uint ParentID = 0;
// Main grid has default permissions as follows
// Main grid has default permissions as follows
//
public uint OwnerMask = FULL_MASK_PERMISSIONS_OWNER;
public uint NextOwnerMask = OBJNEXT_OWNER;
@ -85,7 +85,6 @@ namespace OpenSim.Region.Environment.Scenes
[XmlIgnore]
public uint TimeStampLastActivity = 0; // Will be used for AutoReturn
/// <summary>
/// Only used internally to schedule client updates
/// </summary>

View File

@ -59,7 +59,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
private LLUUID m_itemID;
private bool throwErrorOnNotImplemented = true;
public LSL_BuiltIn_Commands(ScriptEngine ScriptEngine, SceneObjectPart host, uint localID, LLUUID itemID)
{
m_ScriptEngine = ScriptEngine;
@ -67,11 +66,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
m_localID = localID;
m_itemID = itemID;
//MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]");
}
private string m_state = "default";
public string State()
@ -95,7 +92,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
return lease;
}
public Scene World
{
get { return m_ScriptEngine.World; }
@ -1022,7 +1018,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
m_host.SetText(text, av3, alpha);
}
public double llWater(LSL_Types.Vector3 offset)
{
NotImplemented("llWater");
@ -2300,4 +2295,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
throw new NotImplementedException("Command not implemented: " + Command);
}
}
}
}