fix line ending mixing. Probably should put some
wiki descriptions up on line endings so we don't keep ending up in this place.afrisby
parent
f6279beafb
commit
61397a3410
|
@ -1,223 +1,223 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace OpenSim.Framework.PolicyManager
|
namespace OpenSim.Framework.PolicyManager
|
||||||
{
|
{
|
||||||
#region ACL Core Class
|
#region ACL Core Class
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Access Control List Engine
|
/// Access Control List Engine
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ACL
|
public class ACL
|
||||||
{
|
{
|
||||||
Dictionary<string, Role> Roles = new Dictionary<string, Role>();
|
Dictionary<string, Role> Roles = new Dictionary<string, Role>();
|
||||||
Dictionary<string, Resource> Resources = new Dictionary<string, Resource>();
|
Dictionary<string, Resource> Resources = new Dictionary<string, Resource>();
|
||||||
|
|
||||||
public ACL AddRole(Role role)
|
public ACL AddRole(Role role)
|
||||||
{
|
{
|
||||||
if (Roles.ContainsKey(role.Name))
|
if (Roles.ContainsKey(role.Name))
|
||||||
throw new AlreadyContainsRoleException(role);
|
throw new AlreadyContainsRoleException(role);
|
||||||
|
|
||||||
Roles.Add(role.Name, role);
|
Roles.Add(role.Name, role);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ACL AddResource(Resource resource)
|
public ACL AddResource(Resource resource)
|
||||||
{
|
{
|
||||||
Resources.Add(resource.Name, resource);
|
Resources.Add(resource.Name, resource);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Permission HasPermission(string role, string resource)
|
public Permission HasPermission(string role, string resource)
|
||||||
{
|
{
|
||||||
if (!Roles.ContainsKey(role))
|
if (!Roles.ContainsKey(role))
|
||||||
throw new KeyNotFoundException();
|
throw new KeyNotFoundException();
|
||||||
|
|
||||||
if (!Resources.ContainsKey(resource))
|
if (!Resources.ContainsKey(resource))
|
||||||
throw new KeyNotFoundException();
|
throw new KeyNotFoundException();
|
||||||
|
|
||||||
return Roles[role].RequestPermission(resource);
|
return Roles[role].RequestPermission(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ACL GrantPermission(string role, string resource)
|
public ACL GrantPermission(string role, string resource)
|
||||||
{
|
{
|
||||||
if (!Roles.ContainsKey(role))
|
if (!Roles.ContainsKey(role))
|
||||||
throw new KeyNotFoundException();
|
throw new KeyNotFoundException();
|
||||||
|
|
||||||
if (!Resources.ContainsKey(resource))
|
if (!Resources.ContainsKey(resource))
|
||||||
throw new KeyNotFoundException();
|
throw new KeyNotFoundException();
|
||||||
|
|
||||||
Roles[role].GivePermission(resource, Permission.Allow);
|
Roles[role].GivePermission(resource, Permission.Allow);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ACL DenyPermission(string role, string resource)
|
public ACL DenyPermission(string role, string resource)
|
||||||
{
|
{
|
||||||
if (!Roles.ContainsKey(role))
|
if (!Roles.ContainsKey(role))
|
||||||
throw new KeyNotFoundException();
|
throw new KeyNotFoundException();
|
||||||
|
|
||||||
if (!Resources.ContainsKey(resource))
|
if (!Resources.ContainsKey(resource))
|
||||||
throw new KeyNotFoundException();
|
throw new KeyNotFoundException();
|
||||||
|
|
||||||
Roles[role].GivePermission(resource, Permission.Deny);
|
Roles[role].GivePermission(resource, Permission.Deny);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ACL ResetPermission(string role, string resource)
|
public ACL ResetPermission(string role, string resource)
|
||||||
{
|
{
|
||||||
if (!Roles.ContainsKey(role))
|
if (!Roles.ContainsKey(role))
|
||||||
throw new KeyNotFoundException();
|
throw new KeyNotFoundException();
|
||||||
|
|
||||||
if (!Resources.ContainsKey(resource))
|
if (!Resources.ContainsKey(resource))
|
||||||
throw new KeyNotFoundException();
|
throw new KeyNotFoundException();
|
||||||
|
|
||||||
Roles[role].GivePermission(resource, Permission.None);
|
Roles[role].GivePermission(resource, Permission.None);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Exceptions
|
#region Exceptions
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Thrown when an ACL attempts to add a duplicate role.
|
/// Thrown when an ACL attempts to add a duplicate role.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AlreadyContainsRoleException : Exception
|
public class AlreadyContainsRoleException : Exception
|
||||||
{
|
{
|
||||||
protected Role m_role;
|
protected Role m_role;
|
||||||
|
|
||||||
public Role ErrorRole
|
public Role ErrorRole
|
||||||
{
|
{
|
||||||
get { return m_role; }
|
get { return m_role; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlreadyContainsRoleException(Role role)
|
public AlreadyContainsRoleException(Role role)
|
||||||
{
|
{
|
||||||
m_role = role;
|
m_role = role;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return "This ACL already contains a role called '" + m_role.Name + "'.";
|
return "This ACL already contains a role called '" + m_role.Name + "'.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Roles and Resources
|
#region Roles and Resources
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Does this Role have permission to access a specified Resource?
|
/// Does this Role have permission to access a specified Resource?
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum Permission { Deny, None, Allow };
|
public enum Permission { Deny, None, Allow };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A role class, for use with Users or Groups
|
/// A role class, for use with Users or Groups
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Role
|
public class Role
|
||||||
{
|
{
|
||||||
private string m_name;
|
private string m_name;
|
||||||
private Role[] m_parents;
|
private Role[] m_parents;
|
||||||
private Dictionary<string, Permission> m_resources = new Dictionary<string, Permission>();
|
private Dictionary<string, Permission> m_resources = new Dictionary<string, Permission>();
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return m_name; }
|
get { return m_name; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Permission RequestPermission(string resource)
|
public Permission RequestPermission(string resource)
|
||||||
{
|
{
|
||||||
return RequestPermission(resource, Permission.None);
|
return RequestPermission(resource, Permission.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Permission RequestPermission(string resource, Permission current)
|
public Permission RequestPermission(string resource, Permission current)
|
||||||
{
|
{
|
||||||
// Deny permissions always override any others
|
// Deny permissions always override any others
|
||||||
if (current == Permission.Deny)
|
if (current == Permission.Deny)
|
||||||
return current;
|
return current;
|
||||||
|
|
||||||
Permission temp = Permission.None;
|
Permission temp = Permission.None;
|
||||||
|
|
||||||
// Pickup non-None permissions
|
// Pickup non-None permissions
|
||||||
if (m_resources.ContainsKey(resource) && m_resources[resource] != Permission.None)
|
if (m_resources.ContainsKey(resource) && m_resources[resource] != Permission.None)
|
||||||
temp = m_resources[resource];
|
temp = m_resources[resource];
|
||||||
|
|
||||||
if (m_parents != null)
|
if (m_parents != null)
|
||||||
{
|
{
|
||||||
foreach (Role parent in m_parents)
|
foreach (Role parent in m_parents)
|
||||||
{
|
{
|
||||||
temp = parent.RequestPermission(resource, temp);
|
temp = parent.RequestPermission(resource, temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GivePermission(string resource, Permission perm)
|
public void GivePermission(string resource, Permission perm)
|
||||||
{
|
{
|
||||||
m_resources[resource] = perm;
|
m_resources[resource] = perm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Role(string name)
|
public Role(string name)
|
||||||
{
|
{
|
||||||
m_name = name;
|
m_name = name;
|
||||||
m_parents = null;
|
m_parents = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Role(string name, Role[] parents)
|
public Role(string name, Role[] parents)
|
||||||
{
|
{
|
||||||
m_name = name;
|
m_name = name;
|
||||||
m_parents = parents;
|
m_parents = parents;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Resource
|
public class Resource
|
||||||
{
|
{
|
||||||
private string m_name;
|
private string m_name;
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return m_name; }
|
get { return m_name; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Resource(string name)
|
public Resource(string name)
|
||||||
{
|
{
|
||||||
m_name = name;
|
m_name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Tests
|
#region Tests
|
||||||
|
|
||||||
class ACLTester
|
class ACLTester
|
||||||
{
|
{
|
||||||
public ACLTester()
|
public ACLTester()
|
||||||
{
|
{
|
||||||
ACL acl = new ACL();
|
ACL acl = new ACL();
|
||||||
|
|
||||||
Role Guests = new Role("Guests");
|
Role Guests = new Role("Guests");
|
||||||
acl.AddRole(Guests);
|
acl.AddRole(Guests);
|
||||||
|
|
||||||
Role[] parents = new Role[0];
|
Role[] parents = new Role[0];
|
||||||
parents[0] = Guests;
|
parents[0] = Guests;
|
||||||
|
|
||||||
Role JoeGuest = new Role("JoeGuest", parents);
|
Role JoeGuest = new Role("JoeGuest", parents);
|
||||||
acl.AddRole(JoeGuest);
|
acl.AddRole(JoeGuest);
|
||||||
|
|
||||||
Resource CanBuild = new Resource("CanBuild");
|
Resource CanBuild = new Resource("CanBuild");
|
||||||
acl.AddResource(CanBuild);
|
acl.AddResource(CanBuild);
|
||||||
|
|
||||||
|
|
||||||
acl.GrantPermission("Guests", "CanBuild");
|
acl.GrantPermission("Guests", "CanBuild");
|
||||||
|
|
||||||
acl.HasPermission("JoeGuest", "CanBuild");
|
acl.HasPermission("JoeGuest", "CanBuild");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,18 +41,18 @@ using OpenSim.Region.Environment.Scenes;
|
||||||
namespace OpenSim.Region.Environment.Modules
|
namespace OpenSim.Region.Environment.Modules
|
||||||
{
|
{
|
||||||
public class ChatModule : IRegionModule, ISimChat
|
public class ChatModule : IRegionModule, ISimChat
|
||||||
{
|
{
|
||||||
private List<Scene> m_scenes = new List<Scene>();
|
private List<Scene> m_scenes = new List<Scene>();
|
||||||
private LogBase m_log;
|
private LogBase m_log;
|
||||||
|
|
||||||
private string m_server = null;
|
private string m_server = null;
|
||||||
private int m_port = 6668;
|
private int m_port = 6668;
|
||||||
private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
|
private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
|
||||||
private string m_nick = null;
|
private string m_nick = null;
|
||||||
private string m_channel = null;
|
private string m_channel = null;
|
||||||
|
|
||||||
private int m_whisperdistance = 10;
|
private int m_whisperdistance = 10;
|
||||||
private int m_saydistance = 30;
|
private int m_saydistance = 30;
|
||||||
private int m_shoutdistance = 100;
|
private int m_shoutdistance = 100;
|
||||||
|
|
||||||
private NetworkStream m_stream;
|
private NetworkStream m_stream;
|
||||||
|
@ -71,8 +71,8 @@ namespace OpenSim.Region.Environment.Modules
|
||||||
m_nick = "OSimBot" + Util.RandomClass.Next(1, 99);
|
m_nick = "OSimBot" + Util.RandomClass.Next(1, 99);
|
||||||
m_irc = null;
|
m_irc = null;
|
||||||
m_ircWriter = null;
|
m_ircWriter = null;
|
||||||
m_ircReader = null;
|
m_ircReader = null;
|
||||||
|
|
||||||
m_log = OpenSim.Framework.Console.MainLog.Instance;
|
m_log = OpenSim.Framework.Console.MainLog.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,17 +89,17 @@ namespace OpenSim.Region.Environment.Modules
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Console.WriteLine("No IRC config information, skipping IRC bridge configuration");
|
Console.WriteLine("No IRC config information, skipping IRC bridge configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance");
|
m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance");
|
||||||
m_saydistance = config.Configs["Chat"].GetInt("say_distance");
|
m_saydistance = config.Configs["Chat"].GetInt("say_distance");
|
||||||
m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance");
|
m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance");
|
||||||
|
|
||||||
if (!m_scenes.Contains(scene))
|
if (!m_scenes.Contains(scene))
|
||||||
{
|
{
|
||||||
m_scenes.Add(scene);
|
m_scenes.Add(scene);
|
||||||
scene.EventManager.OnNewClient += NewClient;
|
scene.EventManager.OnNewClient += NewClient;
|
||||||
scene.RegisterModuleInterface<ISimChat>(this);
|
scene.RegisterModuleInterface<ISimChat>(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,18 +177,18 @@ namespace OpenSim.Region.Environment.Modules
|
||||||
Console.WriteLine(inputLine);
|
Console.WriteLine(inputLine);
|
||||||
if (inputLine.Contains(m_channel))
|
if (inputLine.Contains(m_channel))
|
||||||
{
|
{
|
||||||
string mess = inputLine.Substring(inputLine.IndexOf(m_channel));
|
string mess = inputLine.Substring(inputLine.IndexOf(m_channel));
|
||||||
foreach (Scene m_scene in m_scenes)
|
foreach (Scene m_scene in m_scenes)
|
||||||
{
|
{
|
||||||
m_scene.Broadcast(delegate(IClientAPI client)
|
m_scene.Broadcast(delegate(IClientAPI client)
|
||||||
{
|
{
|
||||||
client.SendChatMessage(
|
client.SendChatMessage(
|
||||||
Helpers.StringToField(mess), 255, pos, "IRC:",
|
Helpers.StringToField(mess), 255, pos, "IRC:",
|
||||||
LLUUID.Zero);
|
LLUUID.Zero);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Thread.Sleep(50);
|
Thread.Sleep(50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||||
scene = m_scenes[0];
|
scene = m_scenes[0];
|
||||||
|
|
||||||
// Filled in since it's easier than rewriting right now.
|
// Filled in since it's easier than rewriting right now.
|
||||||
LLVector3 fromPos = e.Position;
|
LLVector3 fromPos = e.Position;
|
||||||
LLVector3 fromRegionPos = e.Position + new LLVector3(e.Scene.RegionInfo.RegionLocX * 256, e.Scene.RegionInfo.RegionLocY * 256, 0);
|
LLVector3 fromRegionPos = e.Position + new LLVector3(e.Scene.RegionInfo.RegionLocX * 256, e.Scene.RegionInfo.RegionLocY * 256, 0);
|
||||||
string fromName = e.From;
|
string fromName = e.From;
|
||||||
string message = e.Message;
|
string message = e.Message;
|
||||||
|
@ -217,108 +217,108 @@ namespace OpenSim.Region.Environment.Modules
|
||||||
|
|
||||||
if (avatar != null)
|
if (avatar != null)
|
||||||
{
|
{
|
||||||
fromPos = avatar.AbsolutePosition;
|
fromPos = avatar.AbsolutePosition;
|
||||||
fromRegionPos = fromPos + new LLVector3(e.Scene.RegionInfo.RegionLocX * 256, e.Scene.RegionInfo.RegionLocY * 256, 0);
|
fromRegionPos = fromPos + new LLVector3(e.Scene.RegionInfo.RegionLocX * 256, e.Scene.RegionInfo.RegionLocY * 256, 0);
|
||||||
fromName = avatar.Firstname + " " + avatar.Lastname;
|
fromName = avatar.Firstname + " " + avatar.Lastname;
|
||||||
fromAgentID = e.Sender.AgentId;
|
fromAgentID = e.Sender.AgentId;
|
||||||
avatar = null;
|
avatar = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
string typeName;
|
string typeName;
|
||||||
switch (e.Type)
|
switch (e.Type)
|
||||||
{
|
{
|
||||||
case ChatTypeEnum.Broadcast:
|
case ChatTypeEnum.Broadcast:
|
||||||
typeName = "broadcasts";
|
typeName = "broadcasts";
|
||||||
break;
|
break;
|
||||||
case ChatTypeEnum.Say:
|
case ChatTypeEnum.Say:
|
||||||
typeName = "says";
|
typeName = "says";
|
||||||
break;
|
break;
|
||||||
case ChatTypeEnum.Shout:
|
case ChatTypeEnum.Shout:
|
||||||
typeName = "shouts";
|
typeName = "shouts";
|
||||||
break;
|
break;
|
||||||
case ChatTypeEnum.Whisper:
|
case ChatTypeEnum.Whisper:
|
||||||
typeName = "whispers";
|
typeName = "whispers";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
typeName = "unknown";
|
typeName = "unknown";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.Verbose("CHAT", fromName + " (" + e.Channel + " @ " + scene.RegionInfo.RegionName + ") " + typeName + ": " + e.Message);
|
m_log.Verbose("CHAT", fromName + " (" + e.Channel + " @ " + scene.RegionInfo.RegionName + ") " + typeName + ": " + e.Message);
|
||||||
|
|
||||||
if (connected)
|
if (connected)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + " in " + scene.RegionInfo.RegionName + ">: " +
|
m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + " in " + scene.RegionInfo.RegionName + ">: " +
|
||||||
e.Message);
|
e.Message);
|
||||||
m_ircWriter.Flush();
|
m_ircWriter.Flush();
|
||||||
}
|
}
|
||||||
catch (IOException)
|
catch (IOException)
|
||||||
{
|
{
|
||||||
m_log.Error("IRC","Disconnected from IRC server.");
|
m_log.Error("IRC","Disconnected from IRC server.");
|
||||||
listener.Abort();
|
listener.Abort();
|
||||||
pingSender.Abort();
|
pingSender.Abort();
|
||||||
connected = false;
|
connected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.Channel == 0)
|
||||||
|
{
|
||||||
|
foreach (Scene m_scene in m_scenes)
|
||||||
|
{
|
||||||
|
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
|
||||||
|
{
|
||||||
|
int dis = -100000;
|
||||||
|
|
||||||
|
LLVector3 avatarRegionPos = presence.AbsolutePosition + new LLVector3(scene.RegionInfo.RegionLocX * 256, scene.RegionInfo.RegionLocY * 256, 0);
|
||||||
|
dis = Math.Abs((int)avatarRegionPos.GetDistanceTo(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;
|
||||||
|
default:
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (e.Channel == 0)
|
|
||||||
{
|
|
||||||
foreach (Scene m_scene in m_scenes)
|
|
||||||
{
|
|
||||||
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
|
|
||||||
{
|
|
||||||
int dis = -100000;
|
|
||||||
|
|
||||||
LLVector3 avatarRegionPos = presence.AbsolutePosition + new LLVector3(scene.RegionInfo.RegionLocX * 256, scene.RegionInfo.RegionLocY * 256, 0);
|
|
||||||
dis = Math.Abs((int)avatarRegionPos.GetDistanceTo(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;
|
|
||||||
default:
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using OpenSim.Region.Environment.LandManagement;
|
using OpenSim.Region.Environment.LandManagement;
|
||||||
using OpenSim.Region.Environment.Scenes;
|
using OpenSim.Region.Environment.Scenes;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment
|
namespace OpenSim.Region.Environment
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue