aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/Chat
diff options
context:
space:
mode:
authorDr Scofield2008-09-30 16:14:09 +0000
committerDr Scofield2008-09-30 16:14:09 +0000
commit63b2e3575ae7aa765f22a35b23784ae98af8527a (patch)
tree5d8a9a6972fd0103040d09a35a9c7cea13bd8c05 /OpenSim/Region/Environment/Modules/Avatar/Chat
parentAnd one more. lThat should make all scripts start for everyone (diff)
downloadopensim-SC_OLD-63b2e3575ae7aa765f22a35b23784ae98af8527a.zip
opensim-SC_OLD-63b2e3575ae7aa765f22a35b23784ae98af8527a.tar.gz
opensim-SC_OLD-63b2e3575ae7aa765f22a35b23784ae98af8527a.tar.bz2
opensim-SC_OLD-63b2e3575ae7aa765f22a35b23784ae98af8527a.tar.xz
- a couple of minor code cleanups in RestInventoryServices
- cleanups and more comments in ChatModule and IRCBridgeModule - adding Name support in ScenePresence
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Chat')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs109
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs19
2 files changed, 70 insertions, 58 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs
index 6a7b622..606ce7e 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs
@@ -63,9 +63,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
63 if (!m_scenes.Contains(scene)) 63 if (!m_scenes.Contains(scene))
64 { 64 {
65 m_scenes.Add(scene); 65 m_scenes.Add(scene);
66 scene.EventManager.OnNewClient += NewClient; 66 scene.EventManager.OnNewClient += OnNewClient;
67 scene.EventManager.OnChatFromWorld += SimChat; 67 scene.EventManager.OnChatFromWorld += OnSimChat;
68 scene.EventManager.OnChatBroadcast += SimBroadcast; 68 scene.EventManager.OnChatBroadcast += OnSimBroadcast;
69 } 69 }
70 70
71 // wrap this in a try block so that defaults will work if 71 // wrap this in a try block so that defaults will work if
@@ -105,7 +105,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
105 #endregion 105 #endregion
106 106
107 #region ISimChat Members 107 #region ISimChat Members
108 public void SimBroadcast(Object sender, OSChatMessage c) 108 public void OnSimBroadcast(Object sender, OSChatMessage c)
109 { 109 {
110 // We only want to relay stuff on channel 0 and on the debug channel 110 // We only want to relay stuff on channel 0 and on the debug channel
111 if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return; 111 if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return;
@@ -116,34 +116,44 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
116 if (c.Message.Length > 1100) 116 if (c.Message.Length > 1100)
117 c.Message = c.Message.Substring(0, 1000); 117 c.Message = c.Message.Substring(0, 1000);
118 118
119 // chat works by redistributing every incoming chat 119 // broadcast chat works by redistributing every incoming chat
120 // message to each avatar in the scene 120 // message to each avatar in the scene.
121 Vector3 pos = new Vector3(128, 128, 30); 121 Vector3 pos = new Vector3(128, 128, 30);
122 ((Scene)c.Scene).ForEachScenePresence(delegate(ScenePresence presence) 122 ((Scene)c.Scene).ForEachScenePresence(
123 { 123 delegate(ScenePresence presence)
124 if (presence.IsChildAgent) return; 124 {
125 125 // ignore chat from child agents
126 IClientAPI client = presence.ControllingClient; 126 if (presence.IsChildAgent) return;
127 127
128 if ((c.Type == ChatTypeEnum.Owner) && 128 IClientAPI client = presence.ControllingClient;
129 (null != c.SenderObject) && 129
130 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) 130 // don't forward SayOwner chat from objects to
131 return; 131 // non-owner agents
132 132 if ((c.Type == ChatTypeEnum.Owner) &&
133 if (null == c.SenderObject) 133 (null != c.SenderObject) &&
134 client.SendChatMessage(c.Message, (byte)c.Type, 134 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
135 pos, c.From, UUID.Zero, 135 return;
136 (byte)ChatSourceType.Agent, 136
137 (byte)ChatAudibleLevel.Fully); 137 if (null == c.SenderObject)
138 else 138 {
139 client.SendChatMessage(c.Message, (byte)c.Type, 139 // chat from agent (avatar)
140 pos, c.From, UUID.Zero, 140 client.SendChatMessage(c.Message, (byte)c.Type,
141 (byte)ChatSourceType.Object, 141 pos, c.From, UUID.Zero,
142 (byte)ChatAudibleLevel.Fully); 142 (byte)ChatSourceType.Agent,
143 }); 143 (byte)ChatAudibleLevel.Fully);
144 }
145 else
146 {
147 // chat from object
148 client.SendChatMessage(c.Message, (byte)c.Type,
149 pos, c.From, UUID.Zero,
150 (byte)ChatSourceType.Object,
151 (byte)ChatAudibleLevel.Fully);
152 }
153 });
144 } 154 }
145 155
146 public void SimChat(Object sender, OSChatMessage e) 156 public void OnSimChat(Object sender, OSChatMessage e)
147 { 157 {
148 // early return if not on public or debug channel 158 // early return if not on public or debug channel
149 if (e.Channel != 0 && e.Channel != DEBUG_CHANNEL) return; 159 if (e.Channel != 0 && e.Channel != DEBUG_CHANNEL) return;
@@ -176,7 +186,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
176 { 186 {
177 fromPos = avatar.AbsolutePosition; 187 fromPos = avatar.AbsolutePosition;
178 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, 188 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize,
179 scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); 189 scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
180 fromName = avatar.Firstname + " " + avatar.Lastname; 190 fromName = avatar.Firstname + " " + avatar.Lastname;
181 fromID = e.Sender.AgentId; 191 fromID = e.Sender.AgentId;
182 } 192 }
@@ -188,31 +198,32 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
188 // message to each avatar in the scene 198 // message to each avatar in the scene
189 foreach (Scene s in m_scenes) 199 foreach (Scene s in m_scenes)
190 { 200 {
191 s.ForEachScenePresence(delegate(ScenePresence presence) 201 s.ForEachScenePresence(
192 { 202 delegate(ScenePresence presence)
193 if (e.Channel == DEBUG_CHANNEL) 203 {
194 { 204 if (e.Channel == DEBUG_CHANNEL)
195 TrySendChatMessage(presence, fromPos, regionPos, 205 {
196 fromID, fromName, e.Type, 206 TrySendChatMessage(presence, fromPos, regionPos,
197 message, ChatSourceType.Object); 207 fromID, fromName, e.Type,
198 } 208 message, ChatSourceType.Object);
199 else 209 }
200 { 210 else
201 TrySendChatMessage(presence, fromPos, regionPos, 211 {
202 fromID, fromName, e.Type, 212 TrySendChatMessage(presence, fromPos, regionPos,
203 message, ChatSourceType.Agent); 213 fromID, fromName, e.Type,
204 } 214 message, ChatSourceType.Agent);
205 }); 215 }
216 });
206 } 217 }
207 } 218 }
208 219
209 #endregion 220 #endregion
210 221
211 public void NewClient(IClientAPI client) 222 public void OnNewClient(IClientAPI client)
212 { 223 {
213 try 224 try
214 { 225 {
215 client.OnChatFromViewer += SimChat; 226 client.OnChatFromViewer += OnSimChat;
216 } 227 }
217 catch (Exception ex) 228 catch (Exception ex)
218 { 229 {
@@ -229,8 +240,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
229 240
230 Vector3 fromRegionPos = fromPos + regionPos; 241 Vector3 fromRegionPos = fromPos + regionPos;
231 Vector3 toRegionPos = presence.AbsolutePosition + 242 Vector3 toRegionPos = presence.AbsolutePosition +
232 new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize, 243 new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize,
233 presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); 244 presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
234 245
235 int dis = Math.Abs((int) Util.GetDistanceTo(toRegionPos, fromRegionPos)); 246 int dis = Math.Abs((int) Util.GetDistanceTo(toRegionPos, fromRegionPos));
236 247
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs
index 8fe5080..215c8d9 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs
@@ -92,8 +92,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
92 if (!m_scenes.Contains(scene)) 92 if (!m_scenes.Contains(scene))
93 { 93 {
94 m_scenes.Add(scene); 94 m_scenes.Add(scene);
95 scene.EventManager.OnNewClient += NewClient; 95 scene.EventManager.OnNewClient += OnNewClient;
96 scene.EventManager.OnChatFromWorld += SimChat; 96 scene.EventManager.OnChatFromWorld += OnSimChat;
97 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; 97 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
98 scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; 98 scene.EventManager.OnMakeChildAgent += OnMakeChildAgent;
99 } 99 }
@@ -171,7 +171,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
171 171
172 #region ISimChat Members 172 #region ISimChat Members
173 173
174 public void SimChat(Object sender, OSChatMessage e) 174 public void OnSimChat(Object sender, OSChatMessage e)
175 { 175 {
176 // We only want to relay stuff on channel 0 176 // We only want to relay stuff on channel 0
177 if (e.Channel != 0) return; 177 if (e.Channel != 0) return;
@@ -233,15 +233,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
233 233
234 #endregion 234 #endregion
235 235
236 public void NewClient(IClientAPI client) 236 public void OnNewClient(IClientAPI client)
237 { 237 {
238 try 238 try
239 { 239 {
240 string clientName = String.Format("{0} {1}", client.FirstName, client.LastName); 240 string clientName = String.Format("{0} {1}", client.FirstName, client.LastName);
241 241
242 client.OnChatFromViewer += SimChat; 242 client.OnChatFromViewer += OnSimChat;
243 client.OnLogout += ClientLoggedOut; 243 client.OnLogout += OnClientLoggedOut;
244 client.OnConnectionClosed += ClientLoggedOut; 244 client.OnConnectionClosed += OnClientLoggedOut;
245 245
246 if (clientName != m_last_new_user) 246 if (clientName != m_last_new_user)
247 { 247 {
@@ -295,7 +295,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
295 } 295 }
296 296
297 297
298 public void ClientLoggedOut(IClientAPI client) 298 public void OnClientLoggedOut(IClientAPI client)
299 { 299 {
300 lock (m_syncLogout) 300 lock (m_syncLogout)
301 { 301 {
@@ -614,10 +614,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
614 } 614 }
615 } 615 }
616 616
617 static private Vector3 pos = new Vector3(128, 128, 20);
617 public void ListenerRun() 618 public void ListenerRun()
618 { 619 {
619 string inputLine; 620 string inputLine;
620 Vector3 pos = new Vector3(128, 128, 20); 621
621 while (m_enabled) 622 while (m_enabled)
622 { 623 {
623 try 624 try