diff options
author | Dr Scofield | 2008-09-30 16:14:09 +0000 |
---|---|---|
committer | Dr Scofield | 2008-09-30 16:14:09 +0000 |
commit | 63b2e3575ae7aa765f22a35b23784ae98af8527a (patch) | |
tree | 5d8a9a6972fd0103040d09a35a9c7cea13bd8c05 /OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs | |
parent | And one more. lThat should make all scripts start for everyone (diff) | |
download | opensim-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/ChatModule.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs | 109 |
1 files changed, 60 insertions, 49 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 | ||