aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs101
1 files changed, 62 insertions, 39 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs
index 9730b02..e12588c 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs
@@ -65,6 +65,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
65 m_scenes.Add(scene); 65 m_scenes.Add(scene);
66 scene.EventManager.OnNewClient += NewClient; 66 scene.EventManager.OnNewClient += NewClient;
67 scene.EventManager.OnChatFromWorld += SimChat; 67 scene.EventManager.OnChatFromWorld += SimChat;
68 scene.EventManager.OnChatBroadcast += SimBroadcast;
68 } 69 }
69 70
70 // 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
@@ -104,8 +105,34 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
104 #endregion 105 #endregion
105 106
106 #region ISimChat Members 107 #region ISimChat Members
108 public void SimBroadcast(Object sender, ChatFromViewerArgs c)
109 {
110 // We only want to relay stuff on channel 0
111 if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return;
112
113 if (c.Channel == DEBUG_CHANNEL)
114 c.Type = ChatTypeEnum.DebugChannel;
115
116 // chat works by redistributing every incoming chat
117 // message to each avatar in the scene
118 LLVector3 pos = new LLVector3(128, 128, 30);
119 ((Scene)c.Scene).ForEachScenePresence(delegate(ScenePresence presence)
120 {
121 if (!presence.IsChildAgent) return;
122
123 presence.ControllingClient.SendChatMessage(c.Message,
124 1, //255,
125 pos, c.From, LLUUID.Zero,
126 c.Channel == DEBUG_CHANNEL? (byte)ChatSourceType.Object : (byte)ChatSourceType.Agent,
127 (byte)ChatAudibleLevel.Fully);
128 });
129 }
130
107 public void SimChat(Object sender, ChatFromViewerArgs e) 131 public void SimChat(Object sender, ChatFromViewerArgs e)
108 { 132 {
133 // early return if not on public or debug channel
134 if (e.Channel != 0 && e.Channel != DEBUG_CHANNEL) return;
135
109 ScenePresence avatar = null; 136 ScenePresence avatar = null;
110 Scene scene = (Scene) e.Scene; 137 Scene scene = (Scene) e.Scene;
111 138
@@ -136,32 +163,28 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
136 fromAgentID = e.Sender.AgentId; 163 fromAgentID = e.Sender.AgentId;
137 } 164 }
138 165
139 // We only want to relay stuff on channel 0 166 if (e.Channel == DEBUG_CHANNEL)
140 if (e.Channel == 0 || e.Channel == DEBUG_CHANNEL) 167 e.Type = ChatTypeEnum.DebugChannel;
141 {
142 if (e.Channel == DEBUG_CHANNEL)
143 e.Type = ChatTypeEnum.DebugChannel;
144 168
145 // chat works by redistributing every incoming chat 169 // chat works by redistributing every incoming chat
146 // message to each avatar in the scene 170 // message to each avatar in the scene
147 foreach (Scene s in m_scenes) 171 foreach (Scene s in m_scenes)
148 { 172 {
149 s.ForEachScenePresence(delegate(ScenePresence presence) 173 s.ForEachScenePresence(delegate(ScenePresence presence)
174 {
175 if (e.Channel == DEBUG_CHANNEL)
150 { 176 {
151 if (e.Channel == DEBUG_CHANNEL) 177 TrySendChatMessage(presence, fromPos, regionPos,
152 { 178 fromAgentID, fromName, e.Type,
153 TrySendChatMessage(presence, fromPos, regionPos, 179 message, ChatSourceType.Object);
154 fromAgentID, fromName, e.Type, 180 }
155 message, ChatSourceType.Object); 181 else
156 } 182 {
157 else 183 TrySendChatMessage(presence, fromPos, regionPos,
158 { 184 fromAgentID, fromName, e.Type,
159 TrySendChatMessage(presence, fromPos, regionPos, 185 message, ChatSourceType.Agent);
160 fromAgentID, fromName, e.Type, 186 }
161 message, ChatSourceType.Agent); 187 });
162 }
163 });
164 }
165 } 188 }
166 } 189 }
167 190
@@ -183,23 +206,23 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
183 LLUUID fromAgentID, string fromName, ChatTypeEnum type, 206 LLUUID fromAgentID, string fromName, ChatTypeEnum type,
184 string message, ChatSourceType src) 207 string message, ChatSourceType src)
185 { 208 {
186 if (!presence.IsChildAgent) 209 // don't send stuff to child agents
210 if (presence.IsChildAgent) return;
211
212 LLVector3 fromRegionPos = fromPos + regionPos;
213 LLVector3 toRegionPos = presence.AbsolutePosition + regionPos;
214 int dis = Math.Abs((int) Util.GetDistanceTo(toRegionPos, fromRegionPos));
215
216 if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
217 type == ChatTypeEnum.Say && dis > m_saydistance ||
218 type == ChatTypeEnum.Shout && dis > m_shoutdistance)
187 { 219 {
188 LLVector3 fromRegionPos = fromPos + regionPos; 220 return;
189 LLVector3 toRegionPos = presence.AbsolutePosition + regionPos;
190 int dis = Math.Abs((int) Util.GetDistanceTo(toRegionPos, fromRegionPos));
191
192 if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
193 type == ChatTypeEnum.Say && dis > m_saydistance ||
194 type == ChatTypeEnum.Shout && dis > m_shoutdistance)
195 {
196 return;
197 }
198
199 // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
200 presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName,
201 fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully);
202 } 221 }
222
223 // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
224 presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName,
225 fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully);
203 } 226 }
204 } 227 }
205} \ No newline at end of file 228} \ No newline at end of file