aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs570
1 files changed, 570 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
new file mode 100644
index 0000000..69eaa75
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
@@ -0,0 +1,570 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using libsecondlife;
31using libsecondlife.Packets;
32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework.Types;
34
35namespace OpenSim.Region.Environment.Scenes
36{
37 public partial class Scene
38 {
39 /// <summary>
40 /// Modifies terrain using the specified information
41 /// </summary>
42 /// <param name="height">The height at which the user started modifying the terrain</param>
43 /// <param name="seconds">The number of seconds the modify button was pressed</param>
44 /// <param name="brushsize">The size of the brush used</param>
45 /// <param name="action">The action to be performed</param>
46 /// <param name="north">Distance from the north border where the cursor is located</param>
47 /// <param name="west">Distance from the west border where the cursor is located</param>
48 public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west)
49 {
50 // Shiny.
51 double size = (double)(1 << brushsize);
52
53 switch (action)
54 {
55 case 0:
56 // flatten terrain
57 Terrain.flatten(north, west, size, (double)seconds / 100.0);
58 RegenerateTerrain(true, (int)north, (int)west);
59 break;
60 case 1:
61 // raise terrain
62 Terrain.raise(north, west, size, (double)seconds / 100.0);
63 RegenerateTerrain(true, (int)north, (int)west);
64 break;
65 case 2:
66 //lower terrain
67 Terrain.lower(north, west, size, (double)seconds / 100.0);
68 RegenerateTerrain(true, (int)north, (int)west);
69 break;
70 case 3:
71 // smooth terrain
72 Terrain.smooth(north, west, size, (double)seconds / 100.0);
73 RegenerateTerrain(true, (int)north, (int)west);
74 break;
75 case 4:
76 // noise
77 Terrain.noise(north, west, size, (double)seconds / 100.0);
78 RegenerateTerrain(true, (int)north, (int)west);
79 break;
80 case 5:
81 // revert
82 Terrain.revert(north, west, size, (double)seconds / 100.0);
83 RegenerateTerrain(true, (int)north, (int)west);
84 break;
85
86 // CLIENT EXTENSIONS GO HERE
87 case 128:
88 // erode-thermal
89 break;
90 case 129:
91 // erode-aerobic
92 break;
93 case 130:
94 // erode-hydraulic
95 break;
96 }
97 return;
98 }
99
100 /// <summary>
101 ///
102 /// </summary>
103 /// <remarks>Inefficient. TODO: Fixme</remarks>
104 /// <param name="fromAgentID"></param>
105 /// <param name="toAgentID"></param>
106 /// <param name="timestamp"></param>
107 /// <param name="fromAgentName"></param>
108 /// <param name="message"></param>
109 public void InstantMessage(LLUUID fromAgentID, LLUUID toAgentID, uint timestamp, string fromAgentName, string message)
110 {
111 if (this.Avatars.ContainsKey(toAgentID))
112 {
113 if (this.Avatars.ContainsKey(fromAgentID))
114 {
115 // Local sim message
116 ScenePresence avatar = this.Avatars[fromAgentID];
117 avatar.ControllingClient.SendInstantMessage(message, toAgentID);
118 }
119 else
120 {
121 // Message came from a user outside the sim, ignore?
122 }
123 }
124 else
125 {
126 // Grid message
127 }
128 }
129
130 /// <summary>
131 ///
132 /// </summary>
133 /// <param name="message"></param>
134 /// <param name="type"></param>
135 /// <param name="fromPos"></param>
136 /// <param name="fromName"></param>
137 /// <param name="fromAgentID"></param>
138 public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
139 {
140 // Console.WriteLine("Chat message");
141 ScenePresence avatar = null;
142
143 m_clientManager.ForEachClient(delegate(IClientAPI client)
144 {
145 int dis = -1000;
146 if (this.Avatars.ContainsKey(client.AgentId))
147 {
148 avatar = this.Avatars[client.AgentId];
149 // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
150 dis = (int) avatar.Pos.GetDistanceTo(fromPos);
151 //Console.WriteLine("found avatar at " +dis);
152 }
153
154 switch (type)
155 {
156 case 0: // Whisper
157 if ((dis < 10) && (dis > -10))
158 {
159 //should change so the message is sent through the avatar rather than direct to the ClientView
160 client.SendChatMessage(message, type, fromPos, fromName,
161 fromAgentID);
162 }
163 break;
164 case 1: // Say
165 if ((dis < 30) && (dis > -30))
166 {
167 //Console.WriteLine("sending chat");
168 client.SendChatMessage(message, type, fromPos, fromName,
169 fromAgentID);
170 }
171 break;
172 case 2: // Shout
173 if ((dis < 100) && (dis > -100))
174 {
175 client.SendChatMessage(message, type, fromPos, fromName,
176 fromAgentID);
177 }
178 break;
179
180 case 0xff: // Broadcast
181 client.SendChatMessage(message, type, fromPos, fromName,
182 fromAgentID);
183 break;
184 }
185 });
186 }
187
188 /// <summary>
189 ///
190 /// </summary>
191 /// <param name="primAsset"></param>
192 /// <param name="pos"></param>
193 public void RezObject(AssetBase primAsset, LLVector3 pos)
194 {
195
196 }
197
198 /// <summary>
199 ///
200 /// </summary>
201 /// <param name="packet"></param>
202 /// <param name="simClient"></param>
203 public void DeRezObject(Packet packet, IClientAPI simClient)
204 {
205
206 }
207
208 /// <summary>
209 ///
210 /// </summary>
211 /// <param name="remoteClient"></param>
212 public void SendAvatarsToClient(IClientAPI remoteClient)
213 {
214
215 }
216
217 /// <summary>
218 ///
219 /// </summary>
220 /// <param name="originalPrim"></param>
221 /// <param name="offset"></param>
222 /// <param name="flags"></param>
223 public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags)
224 {
225 SceneObject originPrim = null;
226 foreach (EntityBase ent in Entities.Values)
227 {
228 if (ent is SceneObject)
229 {
230 if (((SceneObject)ent).rootLocalID == originalPrim)
231 {
232 originPrim = (SceneObject)ent;
233 break;
234 }
235 }
236 }
237
238 if (originPrim != null)
239 {
240 //SceneObject copy = originPrim.Copy();
241
242 }
243 else
244 {
245 OpenSim.Framework.Console.MainLog.Instance.Warn("Attempted to duplicate nonexistant prim");
246 }
247
248 }
249
250 /// <summary>
251 ///
252 /// </summary>
253 /// <param name="parentPrim"></param>
254 /// <param name="childPrims"></param>
255 public void LinkObjects(uint parentPrim, List<uint> childPrims)
256 {
257 SceneObject parenPrim = null;
258 foreach (EntityBase ent in Entities.Values)
259 {
260 if (ent is SceneObject)
261 {
262 if (((SceneObject)ent).rootLocalID == parentPrim)
263 {
264 parenPrim = (SceneObject)ent;
265 break;
266 }
267 }
268 }
269
270 List<SceneObject> children = new List<SceneObject>();
271 if (parenPrim != null)
272 {
273 for (int i = 0; i < childPrims.Count; i++)
274 {
275 foreach (EntityBase ent in Entities.Values)
276 {
277 if (ent is SceneObject)
278 {
279 if (((SceneObject)ent).rootLocalID == childPrims[i])
280 {
281 children.Add((SceneObject)ent);
282 }
283 }
284 }
285 }
286 }
287
288 foreach (SceneObject sceneObj in children)
289 {
290 parenPrim.AddNewChildPrims(sceneObj);
291 }
292 }
293
294 /// <summary>
295 ///
296 /// </summary>
297 /// <param name="primLocalID"></param>
298 /// <param name="shapeBlock"></param>
299 public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock)
300 {
301 Primitive prim = null;
302 foreach (EntityBase ent in Entities.Values)
303 {
304 if (ent is SceneObject)
305 {
306 prim = ((SceneObject)ent).HasChildPrim(primLocalID);
307 if (prim != null)
308 {
309 prim.UpdateShape(shapeBlock);
310 break;
311 }
312 }
313 }
314 }
315
316 /// <summary>
317 ///
318 /// </summary>
319 /// <param name="primLocalID"></param>
320 /// <param name="remoteClient"></param>
321 public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
322 {
323 foreach (EntityBase ent in Entities.Values)
324 {
325 if (ent is SceneObject)
326 {
327 if (((SceneObject)ent).rootLocalID == primLocalID)
328 {
329 ((SceneObject)ent).GetProperites(remoteClient);
330 break;
331 }
332 }
333 }
334 }
335
336 /// <summary>
337 ///
338 /// </summary>
339 /// <param name="primLocalID"></param>
340 /// <param name="description"></param>
341 public void PrimDescription(uint primLocalID, string description)
342 {
343 Primitive prim = null;
344 foreach (EntityBase ent in Entities.Values)
345 {
346 if (ent is SceneObject)
347 {
348 prim = ((SceneObject)ent).HasChildPrim(primLocalID);
349 if (prim != null)
350 {
351 prim.Description = description;
352 break;
353 }
354 }
355 }
356 }
357
358 /// <summary>
359 ///
360 /// </summary>
361 /// <param name="primLocalID"></param>
362 /// <param name="description"></param>
363 public void PrimName(uint primLocalID, string name)
364 {
365 Primitive prim = null;
366 foreach (EntityBase ent in Entities.Values)
367 {
368 if (ent is SceneObject)
369 {
370 prim = ((SceneObject)ent).HasChildPrim(primLocalID);
371 if (prim != null)
372 {
373 prim.Name = name;
374 break;
375 }
376 }
377 }
378 }
379
380 public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
381 {
382 Primitive prim = null;
383 foreach (EntityBase ent in Entities.Values)
384 {
385 if (ent is SceneObject)
386 {
387 prim = ((SceneObject)ent).HasChildPrim(objectID);
388 if (prim != null)
389 {
390 ((SceneObject)ent).GrapMovement(offset, pos, remoteClient);
391 break;
392 }
393 }
394 }
395 /*
396 if (this.Entities.ContainsKey(objectID))
397 {
398 if (this.Entities[objectID] is SceneObject)
399 {
400 ((SceneObject)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient);
401 }
402 }*/
403 }
404
405 /// <summary>
406 ///
407 /// </summary>
408 /// <param name="localID"></param>
409 /// <param name="packet"></param>
410 /// <param name="remoteClient"></param>
411 public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient)
412 {
413
414 }
415
416 /// <summary>
417 ///
418 /// </summary>
419 /// <param name="localID"></param>
420 /// <param name="texture"></param>
421 /// <param name="remoteClient"></param>
422 public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient)
423 {
424
425 }
426
427 /// <summary>
428 ///
429 /// </summary>
430 /// <param name="localID"></param>
431 /// <param name="pos"></param>
432 /// <param name="remoteClient"></param>
433 public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient)
434 {
435 Primitive prim = null;
436 foreach (EntityBase ent in Entities.Values)
437 {
438 if (ent is SceneObject)
439 {
440 prim = ((SceneObject)ent).HasChildPrim(localID);
441 if (prim != null)
442 {
443 prim.UpdateGroupPosition(pos);
444 break;
445 }
446 }
447 }
448 }
449
450 public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient)
451 {
452 Primitive prim = null;
453 foreach (EntityBase ent in Entities.Values)
454 {
455 if (ent is SceneObject)
456 {
457 prim = ((SceneObject)ent).HasChildPrim(localID);
458 if (prim != null)
459 {
460 prim.UpdateSinglePosition(pos);
461 break;
462 }
463 }
464 }
465 }
466
467 /// <summary>
468 ///
469 /// </summary>
470 /// <param name="localID"></param>
471 /// <param name="pos"></param>
472 /// <param name="rot"></param>
473 /// <param name="remoteClient"></param>
474 public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient)
475 {
476 Primitive prim = null;
477 foreach (EntityBase ent in Entities.Values)
478 {
479 if (ent is SceneObject)
480 {
481 prim = ((SceneObject)ent).HasChildPrim(localID);
482 if (prim != null)
483 {
484 prim.UpdateGroupMouseRotation( pos, rot);
485 break;
486 }
487 }
488 }
489 }
490
491 /// <summary>
492 ///
493 /// </summary>
494 /// <param name="localID"></param>
495 /// <param name="rot"></param>
496 /// <param name="remoteClient"></param>
497 public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient)
498 {
499 Primitive prim = null;
500 foreach (EntityBase ent in Entities.Values)
501 {
502 if (ent is SceneObject)
503 {
504 prim = ((SceneObject)ent).HasChildPrim(localID);
505 if (prim != null)
506 {
507 prim.UpdateGroupRotation(rot);
508 break;
509 }
510 }
511 }
512 }
513
514 /// <summary>
515 ///
516 /// </summary>
517 /// <param name="localID"></param>
518 /// <param name="rot"></param>
519 /// <param name="remoteClient"></param>
520 public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient)
521 {
522 //Console.WriteLine("trying to update single prim rotation");
523 Primitive prim = null;
524 foreach (EntityBase ent in Entities.Values)
525 {
526 if (ent is SceneObject)
527 {
528 prim = ((SceneObject)ent).HasChildPrim(localID);
529 if (prim != null)
530 {
531 prim.UpdateSingleRotation(rot);
532 break;
533 }
534 }
535 }
536 }
537
538 /// <summary>
539 ///
540 /// </summary>
541 /// <param name="localID"></param>
542 /// <param name="scale"></param>
543 /// <param name="remoteClient"></param>
544 public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient)
545 {
546 Primitive prim = null;
547 foreach (EntityBase ent in Entities.Values)
548 {
549 if (ent is SceneObject)
550 {
551 prim = ((SceneObject)ent).HasChildPrim(localID);
552 if (prim != null)
553 {
554 prim.ResizeGoup(scale);
555 break;
556 }
557 }
558 }
559 }
560
561 /// <summary>
562 /// Sends prims to a client
563 /// </summary>
564 /// <param name="RemoteClient">Client to send to</param>
565 public void GetInitialPrims(IClientAPI RemoteClient)
566 {
567
568 }
569 }
570}