aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/Simulator/World.PacketHandlers.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/OpenSim.RegionServer/Simulator/World.PacketHandlers.cs449
1 files changed, 0 insertions, 449 deletions
diff --git a/OpenSim/OpenSim.RegionServer/Simulator/World.PacketHandlers.cs b/OpenSim/OpenSim.RegionServer/Simulator/World.PacketHandlers.cs
deleted file mode 100644
index 2c5a05f..0000000
--- a/OpenSim/OpenSim.RegionServer/Simulator/World.PacketHandlers.cs
+++ /dev/null
@@ -1,449 +0,0 @@
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 System.Text;
31using libsecondlife;
32using libsecondlife.Packets;
33using OpenSim.Physics.Manager;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types;
36using OpenSim.Framework.Terrain;
37using OpenSim.Framework.Inventory;
38using OpenSim.Framework.Utilities;
39using OpenSim.RegionServer.Assets;
40using OpenSim.RegionServer.Client;
41
42namespace OpenSim.RegionServer.Simulator
43{
44 public partial class World
45 {
46 public void ModifyTerrain(byte action, float north, float west)
47 {
48 switch (action)
49 {
50 case 1:
51 // raise terrain
52 Terrain.raise(north, west, 10.0, 0.001);
53 RegenerateTerrain(true, (int)north, (int)west);
54 break;
55 case 2:
56 //lower terrain
57 Terrain.lower(north, west, 10.0, 0.001);
58 RegenerateTerrain(true, (int)north, (int)west);
59 break;
60 }
61 return;
62 }
63
64 public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
65 {
66 foreach (ClientView client in m_clientThreads.Values)
67 {
68 // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
69 int dis = (int)client.ClientAvatar.Pos.GetDistanceTo(fromPos);
70
71 switch (type)
72 {
73 case 0: // Whisper
74 if ((dis < 10) && (dis > -10))
75 {
76 //should change so the message is sent through the avatar rather than direct to the ClientView
77 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
78 }
79 break;
80 case 1: // Say
81 if ((dis < 30) && (dis > -30))
82 {
83 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
84 }
85 break;
86 case 2: // Shout
87 if ((dis < 100) && (dis > -100))
88 {
89 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
90 }
91 break;
92
93 case 0xff: // Broadcast
94 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
95 break;
96 }
97
98 }
99 }
100
101 public void RezObject(AssetBase primAsset, LLVector3 pos)
102 {
103 PrimData primd = new PrimData(primAsset.Data);
104 Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
105 nPrim.CreateFromStorage(primd, pos, this._primCount, true);
106 this.Entities.Add(nPrim.uuid, nPrim);
107 this._primCount++;
108 }
109
110 public void DeRezObject(Packet packet, ClientView simClient)
111 {
112 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet;
113
114 //Needs to delete object from physics at a later date
115 if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
116 {
117 //currently following code not used (or don't know of any case of destination being zero
118 libsecondlife.LLUUID[] DeRezEnts;
119 DeRezEnts = new libsecondlife.LLUUID[DeRezPacket.ObjectData.Length];
120 int i = 0;
121 foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
122 {
123
124 //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
125 foreach (Entity ent in this.Entities.Values)
126 {
127 if (ent.localid == Data.ObjectLocalID)
128 {
129 DeRezEnts[i++] = ent.uuid;
130 this.localStorage.RemovePrim(ent.uuid);
131 KillObjectPacket kill = new KillObjectPacket();
132 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
133 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
134 kill.ObjectData[0].ID = ent.localid;
135 foreach (ClientView client in m_clientThreads.Values)
136 {
137 client.OutPacket(kill);
138 }
139 //Uncommenting this means an old UUID will be re-used, thus crashing the asset server
140 //Uncomment when prim/object UUIDs are random or such
141 //2007-03-22 - Randomskk
142 //this._primCount--;
143 OpenSim.Framework.Console.MainConsole.Instance.Verbose("Deleted UUID " + ent.uuid);
144 }
145 }
146 }
147 foreach (libsecondlife.LLUUID uuid in DeRezEnts)
148 {
149 lock (Entities)
150 {
151 Entities.Remove(uuid);
152 }
153 }
154 }
155 else
156 {
157 foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
158 {
159 Entity selectedEnt = null;
160 //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
161 foreach (Entity ent in this.Entities.Values)
162 {
163 if (ent.localid == Data.ObjectLocalID)
164 {
165 AssetBase primAsset = new AssetBase();
166 primAsset.FullID = LLUUID.Random();//DeRezPacket.AgentBlock.TransactionID.Combine(LLUUID.Zero); //should be combining with securesessionid
167 primAsset.InvType = 6;
168 primAsset.Type = 6;
169 primAsset.Name = "Prim";
170 primAsset.Description = "";
171 primAsset.Data = ((Primitive)ent).GetByteArray();
172 this._assetCache.AddAsset(primAsset);
173 this._inventoryCache.AddNewInventoryItem(simClient, DeRezPacket.AgentBlock.DestinationID, primAsset);
174 selectedEnt = ent;
175 break;
176 }
177 }
178 if (selectedEnt != null)
179 {
180 this.localStorage.RemovePrim(selectedEnt.uuid);
181 KillObjectPacket kill = new KillObjectPacket();
182 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
183 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
184 kill.ObjectData[0].ID = selectedEnt.localid;
185 foreach (ClientView client in m_clientThreads.Values)
186 {
187 client.OutPacket(kill);
188 }
189 lock (Entities)
190 {
191 Entities.Remove(selectedEnt.uuid);
192 }
193 }
194 }
195 }
196
197 }
198
199 public void SendAvatarsToClient(ClientView remoteClient)
200 {
201 foreach (ClientView client in m_clientThreads.Values)
202 {
203 if (client.AgentID != remoteClient.AgentID)
204 {
205 // ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket();
206 // RemoteClient.OutPacket(objupdate);
207 client.ClientAvatar.SendUpdateToOtherClient(remoteClient.ClientAvatar);
208 client.ClientAvatar.SendAppearanceToOtherAgent(remoteClient.ClientAvatar);
209 }
210 }
211 }
212
213 public void LinkObjects(uint parentPrim, List<uint> childPrims)
214 {
215 Primitive parentprim = null;
216 foreach (Entity ent in Entities.Values)
217 {
218 if (ent.localid == parentPrim)
219 {
220 parentprim = (OpenSim.RegionServer.Simulator.Primitive)ent;
221
222 }
223 }
224
225 for (int i = 0; i < childPrims.Count; i++)
226 {
227 uint childId = childPrims[i];
228 foreach (Entity ent in Entities.Values)
229 {
230 if (ent.localid == childId)
231 {
232 ((OpenSim.RegionServer.Simulator.Primitive)ent).MakeParent(parentprim);
233 }
234 }
235 }
236
237 }
238
239 public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock)
240 {
241 foreach (Entity ent in Entities.Values)
242 {
243 if (ent.localid == primLocalID)
244 {
245 ((OpenSim.RegionServer.Simulator.Primitive)ent).UpdateShape(shapeBlock);
246 break;
247 }
248 }
249 }
250
251 public void SelectPrim(uint primLocalID, ClientView remoteClient)
252 {
253 foreach (Entity ent in Entities.Values)
254 {
255 if (ent.localid == primLocalID)
256 {
257 ((OpenSim.RegionServer.Simulator.Primitive)ent).GetProperites(remoteClient);
258 break;
259 }
260 }
261 }
262
263 public void UpdatePrimFlags(uint localID, Packet packet, ClientView remoteClient)
264 {
265 foreach (Entity ent in Entities.Values)
266 {
267 if (ent.localid == localID)
268 {
269 ((OpenSim.RegionServer.Simulator.Primitive)ent).UpdateObjectFlags((ObjectFlagUpdatePacket) packet);
270 break;
271 }
272 }
273 }
274
275 public void UpdatePrimTexture(uint localID, byte[] texture, ClientView remoteClient)
276 {
277 foreach (Entity ent in Entities.Values)
278 {
279 if (ent.localid == localID)
280 {
281 ((OpenSim.RegionServer.Simulator.Primitive)ent).UpdateTexture(texture);
282 break;
283 }
284 }
285 }
286
287 public void UpdatePrimPosition(uint localID, LLVector3 pos, ClientView remoteClient)
288 {
289 foreach (Entity ent in Entities.Values)
290 {
291 if (ent.localid == localID)
292 {
293 ((OpenSim.RegionServer.Simulator.Primitive)ent).UpdatePosition(pos);
294 break;
295 }
296 }
297 }
298
299 public void UpdatePrimRotation(uint localID, LLQuaternion rot, ClientView remoteClient)
300 {
301 foreach (Entity ent in Entities.Values)
302 {
303 if (ent.localid == localID)
304 {
305 ent.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
306 ((OpenSim.RegionServer.Simulator.Primitive)ent).UpdateFlag = true;
307 break;
308 }
309 }
310 }
311
312 public void UpdatePrimScale(uint localID, LLVector3 scale, ClientView remoteClient)
313 {
314 foreach (Entity ent in Entities.Values)
315 {
316 if (ent.localid == localID)
317 {
318 ((OpenSim.RegionServer.Simulator.Primitive)ent).Scale = scale;
319 break;
320 }
321 }
322 }
323 #region Parcel Packet Handlers
324 void ParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, ClientView remote_client)
325 {
326 //Get the parcels within the bounds
327 List<OpenSim.RegionServer.Simulator.Parcel> temp = new List<OpenSim.RegionServer.Simulator.Parcel>();
328 int x, y, i;
329 int inc_x = end_x - start_x;
330 int inc_y = end_y - start_y;
331 for(x = 0; x < inc_x; x++)
332 {
333 for(y = 0; y < inc_y; y++)
334 {
335 OpenSim.RegionServer.Simulator.Parcel currentParcel = parcelManager.getParcel(start_x + x, start_y + y);
336 if(!temp.Contains(currentParcel))
337 {
338 currentParcel.
339 forceUpdateParcelInfo();
340 temp.Add(currentParcel);
341 }
342 }
343 }
344
345 int requestResult = OpenSim.RegionServer.Simulator.ParcelManager.PARCEL_RESULT_ONE_PARCEL;
346 if (temp.Count > 1)
347 {
348 requestResult = OpenSim.RegionServer.Simulator.ParcelManager.PARCEL_RESULT_MULTIPLE_PARCELS;
349 }
350
351 for (i = 0; i < temp.Count; i++)
352 {
353 temp[i].sendParcelProperties(sequence_id, snap_selection, requestResult, remote_client);
354 }
355
356
357 parcelManager.sendParcelOverlay(remote_client);
358 }
359
360 void ParcelDivideRequest(int west, int south, int east, int north, ClientView remote_client)
361 {
362 parcelManager.subdivide(west, south, east, north, remote_client.AgentID);
363 }
364 void ParcelJoinRequest(int west, int south, int east, int north, ClientView remote_client)
365 {
366 parcelManager.join(west, south, east, north, remote_client.AgentID);
367 }
368 void ParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, ClientView remote_client)
369 {
370 if (parcelManager.parcelList.ContainsKey(packet.ParcelData.LocalID))
371 {
372 parcelManager.parcelList[packet.ParcelData.LocalID].updateParcelProperties(packet, remote_client);
373 }
374 }
375 #endregion
376
377 /*
378 public void RequestMapBlock(ClientView simClient, int minX, int minY, int maxX, int maxY)
379 {
380 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
381 if (((m_regInfo.RegionLocX > minX) && (m_regInfo.RegionLocX < maxX)) && ((m_regInfo.RegionLocY > minY) && (m_regInfo.RegionLocY < maxY)))
382 {
383 MapBlockReplyPacket mapReply = new MapBlockReplyPacket();
384 mapReply.AgentData.AgentID = simClient.AgentID;
385 mapReply.AgentData.Flags = 0;
386 mapReply.Data = new MapBlockReplyPacket.DataBlock[1];
387 mapReply.Data[0] = new MapBlockReplyPacket.DataBlock();
388 mapReply.Data[0].MapImageID = new LLUUID("00000000-0000-0000-9999-000000000007");
389 mapReply.Data[0].X = (ushort)m_regInfo.RegionLocX;
390 mapReply.Data[0].Y = (ushort)m_regInfo.RegionLocY;
391 mapReply.Data[0].WaterHeight = (byte)m_regInfo.RegionWaterHeight;
392 mapReply.Data[0].Name = _enc.GetBytes(this.m_regionName);
393 mapReply.Data[0].RegionFlags = 72458694;
394 mapReply.Data[0].Access = 13;
395 mapReply.Data[0].Agents = 1; //should send number of clients connected
396 simClient.OutPacket(mapReply);
397 }
398 }
399 public bool RezObjectHandler(ClientView simClient, Packet packet)
400 {
401 RezObjectPacket rezPacket = (RezObjectPacket)packet;
402 AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID);
403 if (inven != null)
404 {
405 if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID))
406 {
407 AssetBase asset = this._assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID);
408 if (asset != null)
409 {
410 PrimData primd = new PrimData(asset.Data);
411 Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
412 nPrim.CreateFromStorage(primd, rezPacket.RezData.RayEnd, this._primCount, true);
413 this.Entities.Add(nPrim.uuid, nPrim);
414 this._primCount++;
415 this._inventoryCache.DeleteInventoryItem(simClient, rezPacket.InventoryData.ItemID);
416 }
417 }
418 }
419 return true;
420 }
421 public bool ModifyTerrain(ClientView simClient, Packet packet)
422 {
423 ModifyLandPacket modify = (ModifyLandPacket)packet;
424
425 switch (modify.ModifyBlock.Action)
426 {
427 case 1:
428 // raise terrain
429 if (modify.ParcelData.Length > 0)
430 {
431 Terrain.raise(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1);
432 RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West);
433 }
434 break;
435 case 2:
436 //lower terrain
437 if (modify.ParcelData.Length > 0)
438 {
439 Terrain.lower(modify.ParcelData[0].North, modify.ParcelData[0].West, 10.0, 0.1);
440 RegenerateTerrain(true, (int)modify.ParcelData[0].North, (int)modify.ParcelData[0].West);
441 }
442 break;
443 }
444 return true;
445 }
446 */
447
448 }
449}