diff options
author | Dr Scofield | 2008-10-21 13:34:43 +0000 |
---|---|---|
committer | Dr Scofield | 2008-10-21 13:34:43 +0000 |
commit | 4218744a26ed096c0f0096a4ff1b627ca27aadf5 (patch) | |
tree | 51184ccdc00514c520ee2bfd8d33fe3a9ee58414 /OpenSim/Region/Environment/Modules/Avatar | |
parent | fixes #2445 & #2449. interim fix that will make listeners work (diff) | |
download | opensim-SC-4218744a26ed096c0f0096a4ff1b627ca27aadf5.zip opensim-SC-4218744a26ed096c0f0096a4ff1b627ca27aadf5.tar.gz opensim-SC-4218744a26ed096c0f0096a4ff1b627ca27aadf5.tar.bz2 opensim-SC-4218744a26ed096c0f0096a4ff1b627ca27aadf5.tar.xz |
fixing real cause of #2445 & #2449: Position was <0, 0, 0> for
OSChatMessage coming from client.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs | 84 |
1 files changed, 31 insertions, 53 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs index 5ee07ff..df42f07 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs | |||
@@ -114,55 +114,43 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
114 | client.OnChatFromClient += OnChatFromClient; | 114 | client.OnChatFromClient += OnChatFromClient; |
115 | } | 115 | } |
116 | 116 | ||
117 | public virtual void OnChatFromClient(Object sender, OSChatMessage e) | 117 | protected OSChatMessage FixPositionOfChatMessage(OSChatMessage c) |
118 | { | 118 | { |
119 | ScenePresence avatar; | ||
120 | Scene scene = (Scene)c.Scene; | ||
121 | if ((avatar = scene.GetScenePresence(c.Sender.AgentId)) != null) | ||
122 | c.Position = avatar.AbsolutePosition; | ||
123 | |||
124 | return c; | ||
125 | } | ||
126 | |||
127 | public virtual void OnChatFromClient(Object sender, OSChatMessage c) | ||
128 | { | ||
129 | c = FixPositionOfChatMessage(c); | ||
130 | |||
119 | // redistribute to interested subscribers | 131 | // redistribute to interested subscribers |
120 | Scene scene = (Scene)e.Scene; | 132 | Scene scene = (Scene)c.Scene; |
121 | scene.EventManager.TriggerOnChatFromClient(sender, e); | 133 | scene.EventManager.TriggerOnChatFromClient(sender, c); |
122 | 134 | ||
123 | // early return if not on public or debug channel | 135 | // early return if not on public or debug channel |
124 | if (e.Channel != 0 && e.Channel != DEBUG_CHANNEL) return; | 136 | if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return; |
125 | 137 | ||
126 | // sanity check: | 138 | // sanity check: |
127 | if (e.Sender == null) | 139 | if (c.Sender == null) |
128 | { | 140 | { |
129 | m_log.ErrorFormat("[CHAT] OnChatFromClient from {0} has empty Sender field!", sender); | 141 | m_log.ErrorFormat("[CHAT] OnChatFromClient from {0} has empty Sender field!", sender); |
130 | return; | 142 | return; |
131 | } | 143 | } |
132 | 144 | ||
133 | // string message = e.Message; | 145 | DeliverChatToAvatars(ChatSourceType.Agent, c); |
134 | // if (e.Channel == DEBUG_CHANNEL) e.Type = ChatTypeEnum.DebugChannel; | ||
135 | |||
136 | // ScenePresence avatar = scene.GetScenePresence(e.Sender.AgentId); | ||
137 | // Vector3 fromPos = avatar.AbsolutePosition; | ||
138 | // Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, | ||
139 | // scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); | ||
140 | // string fromName = avatar.Firstname + " " + avatar.Lastname; | ||
141 | // UUID fromID = e.Sender.AgentId; | ||
142 | |||
143 | // DeliverChatToAvatars(fromPos, regionPos, fromID, fromName, e.Type, ChatSourceType.Agent, message); | ||
144 | DeliverChatToAvatars(ChatSourceType.Agent, e); | ||
145 | } | 146 | } |
146 | 147 | ||
147 | public virtual void OnChatFromWorld(Object sender, OSChatMessage e) | 148 | public virtual void OnChatFromWorld(Object sender, OSChatMessage c) |
148 | { | 149 | { |
149 | // early return if not on public or debug channel | 150 | // early return if not on public or debug channel |
150 | if (e.Channel != 0 && e.Channel != DEBUG_CHANNEL) return; | 151 | if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return; |
151 | |||
152 | // // Filled in since it's easier than rewriting right now. | ||
153 | // Vector3 fromPos = e.Position; | ||
154 | // Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, | ||
155 | // scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); | ||
156 | 152 | ||
157 | // string fromName = e.From; | 153 | DeliverChatToAvatars(ChatSourceType.Object, c); |
158 | // string message = e.Message; | ||
159 | // UUID fromID = e.SenderUUID; | ||
160 | |||
161 | // if (e.Channel == DEBUG_CHANNEL) | ||
162 | // e.Type = ChatTypeEnum.DebugChannel; | ||
163 | |||
164 | // DeliverChatToAvatars(fromPos, regionPos, fromID, fromName, e.Type, ChatSourceType.Object, message); | ||
165 | DeliverChatToAvatars(ChatSourceType.Object, e); | ||
166 | } | 154 | } |
167 | 155 | ||
168 | protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) | 156 | protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) |
@@ -188,7 +176,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
188 | } | 176 | } |
189 | ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId); | 177 | ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId); |
190 | fromPos = avatar.AbsolutePosition; | 178 | fromPos = avatar.AbsolutePosition; |
191 | fromName = avatar.Firstname + " " + avatar.Lastname; | 179 | fromName = avatar.Name; |
192 | fromID = c.Sender.AgentId; | 180 | fromID = c.Sender.AgentId; |
193 | 181 | ||
194 | break; | 182 | break; |
@@ -203,6 +191,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
203 | if (message.Length >= 1000) // libomv limit | 191 | if (message.Length >= 1000) // libomv limit |
204 | message = message.Substring(0, 1000); | 192 | message = message.Substring(0, 1000); |
205 | 193 | ||
194 | // m_log.DebugFormat("[CHAT] DCTA: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, c.Type, sourceType); | ||
195 | |||
206 | foreach (Scene s in m_scenes) | 196 | foreach (Scene s in m_scenes) |
207 | { | 197 | { |
208 | s.ForEachScenePresence(delegate(ScenePresence presence) | 198 | s.ForEachScenePresence(delegate(ScenePresence presence) |
@@ -213,24 +203,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
213 | } | 203 | } |
214 | } | 204 | } |
215 | 205 | ||
216 | // protected virtual void DeliverChatToAvatars(Vector3 pos, Vector3 regionPos, UUID uuid, string name, | ||
217 | // ChatTypeEnum chatType, ChatSourceType sourceType, string message) | ||
218 | // { | ||
219 | // // iterate over message | ||
220 | // if (message.Length >= 1000) // libomv limit | ||
221 | // message = message.Substring(0, 1000); | ||
222 | |||
223 | // foreach (Scene s in m_scenes) | ||
224 | // { | ||
225 | // s.ForEachScenePresence(delegate(ScenePresence presence) | ||
226 | // { | ||
227 | // TrySendChatMessage(presence, pos, regionPos, uuid, name, | ||
228 | // chatType, message, sourceType); | ||
229 | // }); | ||
230 | // } | ||
231 | // } | ||
232 | |||
233 | 206 | ||
207 | static private Vector3 CenterOfRegion = new Vector3(128, 128, 30); | ||
234 | public virtual void OnChatBroadcast(Object sender, OSChatMessage c) | 208 | public virtual void OnChatBroadcast(Object sender, OSChatMessage c) |
235 | { | 209 | { |
236 | // unless the chat to be broadcast is of type Region, we | 210 | // unless the chat to be broadcast is of type Region, we |
@@ -249,16 +223,20 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
249 | 223 | ||
250 | // broadcast chat works by redistributing every incoming chat | 224 | // broadcast chat works by redistributing every incoming chat |
251 | // message to each avatar in the scene. | 225 | // message to each avatar in the scene. |
252 | Vector3 pos = new Vector3(128, 128, 30); | 226 | string fromName = c.From; |
253 | 227 | ||
254 | UUID fromID = UUID.Zero; | 228 | UUID fromID = UUID.Zero; |
255 | ChatSourceType sourceType = ChatSourceType.Object; | 229 | ChatSourceType sourceType = ChatSourceType.Object; |
256 | if (null != c.Sender) | 230 | if (null != c.Sender) |
257 | { | 231 | { |
232 | ScenePresence avatar = (c.Scene as Scene).GetScenePresence(c.Sender.AgentId); | ||
258 | fromID = c.Sender.AgentId; | 233 | fromID = c.Sender.AgentId; |
234 | fromName = avatar.Name; | ||
259 | sourceType = ChatSourceType.Agent; | 235 | sourceType = ChatSourceType.Agent; |
260 | } | 236 | } |
261 | 237 | ||
238 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); | ||
239 | |||
262 | ((Scene)c.Scene).ForEachScenePresence( | 240 | ((Scene)c.Scene).ForEachScenePresence( |
263 | delegate(ScenePresence presence) | 241 | delegate(ScenePresence presence) |
264 | { | 242 | { |
@@ -274,7 +252,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
274 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) | 252 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) |
275 | return; | 253 | return; |
276 | 254 | ||
277 | client.SendChatMessage(c.Message, (byte)cType, pos, c.From, fromID, | 255 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, |
278 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | 256 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); |
279 | }); | 257 | }); |
280 | } | 258 | } |