aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
-rw-r--r--OpenSim/Region/Environment/Modules/ChatModule.cs134
-rw-r--r--OpenSim/Region/Environment/Modules/InstantMessageModule.cs9
2 files changed, 51 insertions, 92 deletions
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs
index ef46224..081e7ac 100644
--- a/OpenSim/Region/Environment/Modules/ChatModule.cs
+++ b/OpenSim/Region/Environment/Modules/ChatModule.cs
@@ -110,6 +110,43 @@ namespace OpenSim.Region.Environment.Modules
110 client.OnChatFromViewer += SimChat; 110 client.OnChatFromViewer += SimChat;
111 } 111 }
112 112
113 private void TrySendChatMessage(ScenePresence presence, LLVector3 fromPos, LLVector3 regionPos,
114 LLUUID fromAgentID, string fromName, ChatTypeEnum type, string message)
115 {
116 if (!presence.IsChildAgent)
117 {
118 LLVector3 fromRegionPos = fromPos + regionPos;
119 LLVector3 toRegionPos = presence.AbsolutePosition + regionPos;
120 int dis = Math.Abs((int) Util.GetDistanceTo(toRegionPos, fromRegionPos));
121
122 switch (type)
123 {
124 case ChatTypeEnum.Whisper:
125 if (dis < m_whisperdistance)
126 {
127 // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
128 presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID);
129 }
130 break;
131 case ChatTypeEnum.Say:
132 if (dis < m_saydistance)
133 {
134 presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID);
135 }
136 break;
137 case ChatTypeEnum.Shout:
138 if (dis < m_shoutdistance)
139 {
140 presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID);
141 }
142 break;
143 case ChatTypeEnum.Broadcast:
144 presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID);
145 break;
146 }
147 }
148 }
149
113 public void SimChat(Object sender, ChatFromViewerArgs e) 150 public void SimChat(Object sender, ChatFromViewerArgs e)
114 { 151 {
115 ScenePresence avatar = null; 152 ScenePresence avatar = null;
@@ -123,12 +160,10 @@ namespace OpenSim.Region.Environment.Modules
123 160
124 // Filled in since it's easier than rewriting right now. 161 // Filled in since it's easier than rewriting right now.
125 LLVector3 fromPos = e.Position; 162 LLVector3 fromPos = e.Position;
126 LLVector3 fromRegionPos = e.Position + 163 LLVector3 regionPos = new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, 0);
127 new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, 164
128 0);
129 string fromName = e.From; 165 string fromName = e.From;
130 string message = e.Message; 166 string message = e.Message;
131 byte type = (byte) e.Type;
132 LLUUID fromAgentID = LLUUID.Zero; 167 LLUUID fromAgentID = LLUUID.Zero;
133 168
134 if (e.Sender != null) 169 if (e.Sender != null)
@@ -139,32 +174,11 @@ namespace OpenSim.Region.Environment.Modules
139 if (avatar != null) 174 if (avatar != null)
140 { 175 {
141 fromPos = avatar.AbsolutePosition; 176 fromPos = avatar.AbsolutePosition;
142 fromRegionPos = fromPos + 177 regionPos = new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, 0);
143 new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, 0);
144 fromName = avatar.Firstname + " " + avatar.Lastname; 178 fromName = avatar.Firstname + " " + avatar.Lastname;
145 fromAgentID = e.Sender.AgentId; 179 fromAgentID = e.Sender.AgentId;
146 } 180 }
147 181
148 string typeName;
149 switch (e.Type)
150 {
151 case ChatTypeEnum.Broadcast:
152 typeName = "broadcasts";
153 break;
154 case ChatTypeEnum.Say:
155 typeName = "says";
156 break;
157 case ChatTypeEnum.Shout:
158 typeName = "shouts";
159 break;
160 case ChatTypeEnum.Whisper:
161 typeName = "whispers";
162 break;
163 default:
164 typeName = "unknown";
165 break;
166 }
167
168 if (e.Message.Length > 0) 182 if (e.Message.Length > 0)
169 { 183 {
170 if (m_irc.Connected) 184 if (m_irc.Connected)
@@ -174,69 +188,13 @@ namespace OpenSim.Region.Environment.Modules
174 188
175 if (e.Channel == 0) 189 if (e.Channel == 0)
176 { 190 {
177 foreach (Scene m_scene in m_scenes) 191 foreach (Scene s in m_scenes)
178 { 192 {
179 m_scene.ForEachScenePresence(delegate(ScenePresence presence) 193 s.ForEachScenePresence(delegate(ScenePresence presence)
180 { 194 {
181 if (!presence.IsChildAgent) 195 TrySendChatMessage(presence, fromPos, regionPos,
182 { 196 fromAgentID, fromName, e.Type, message);
183 int dis = -100000; 197 });
184
185 LLVector3 avatarRegionPos = presence.AbsolutePosition +
186 new LLVector3(
187 scene.RegionInfo.RegionLocX * 256,
188 scene.RegionInfo.RegionLocY * 256,
189 0);
190 dis =
191 Math.Abs((int) Util.GetDistanceTo(avatarRegionPos, fromRegionPos));
192
193 switch (e.Type)
194 {
195 case ChatTypeEnum.Whisper:
196 if (dis < m_whisperdistance)
197 {
198 //should change so the message is sent through the avatar rather than direct to the ClientView
199 presence.ControllingClient.SendChatMessage(message,
200 type,
201 fromPos,
202 fromName,
203 fromAgentID);
204 }
205 break;
206 case ChatTypeEnum.Say:
207 if (dis < m_saydistance)
208 {
209 //Console.WriteLine("sending chat");
210 presence.ControllingClient.SendChatMessage(message,
211 type,
212 fromPos,
213 fromName,
214 fromAgentID);
215 }
216 break;
217 case ChatTypeEnum.Shout:
218 if (dis < m_shoutdistance)
219 {
220 presence.ControllingClient.SendChatMessage(message,
221 type,
222 fromPos,
223 fromName,
224 fromAgentID);
225 }
226 break;
227
228 case ChatTypeEnum.Broadcast:
229 presence.ControllingClient.SendChatMessage(message,
230 type,
231 fromPos,
232 fromName,
233 fromAgentID);
234 break;
235 default:
236 break;
237 }
238 }
239 });
240 } 198 }
241 } 199 }
242 } 200 }
diff --git a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs
index 23dd0d9..cf6a94d 100644
--- a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs
+++ b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs
@@ -65,12 +65,12 @@ namespace OpenSim.Region.Environment.Modules
65 LLUUID imSessionID, uint timestamp, string fromAgentName, 65 LLUUID imSessionID, uint timestamp, string fromAgentName,
66 string message, byte dialog) 66 string message, byte dialog)
67 { 67 {
68 foreach (Scene m_scene in m_scenes) 68 foreach (Scene scene in m_scenes)
69 { 69 {
70 if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) 70 if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence)
71 { 71 {
72 // Local Message 72 // Local message
73 ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID]; 73 ScenePresence user = (ScenePresence) scene.Entities[toAgentID];
74 if (!user.IsChildAgent) 74 if (!user.IsChildAgent)
75 { 75 {
76 user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, 76 user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message,
@@ -83,6 +83,7 @@ namespace OpenSim.Region.Environment.Modules
83 } 83 }
84 84
85 // Still here, try send via Grid 85 // Still here, try send via Grid
86 // TODO
86 } 87 }
87 88
88 public void PostInitialise() 89 public void PostInitialise()