aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.World/World.PacketHandlers.cs
diff options
context:
space:
mode:
authorMW2007-05-26 14:55:17 +0000
committerMW2007-05-26 14:55:17 +0000
commit06387d0344b8fa84b790a9dd910fda8a0a1128bb (patch)
treefaf19abd4c940e6c6fddf805beaee47b9b175e32 /OpenSim/OpenSim.World/World.PacketHandlers.cs
parentDie WebFrontEnd, Die Grid class! (diff)
downloadopensim-SC-06387d0344b8fa84b790a9dd910fda8a0a1128bb.zip
opensim-SC-06387d0344b8fa84b790a9dd910fda8a0a1128bb.tar.gz
opensim-SC-06387d0344b8fa84b790a9dd910fda8a0a1128bb.tar.bz2
opensim-SC-06387d0344b8fa84b790a9dd910fda8a0a1128bb.tar.xz
Goodbye World
Diffstat (limited to 'OpenSim/OpenSim.World/World.PacketHandlers.cs')
-rw-r--r--OpenSim/OpenSim.World/World.PacketHandlers.cs261
1 files changed, 261 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.World/World.PacketHandlers.cs b/OpenSim/OpenSim.World/World.PacketHandlers.cs
new file mode 100644
index 0000000..ee5a23a
--- /dev/null
+++ b/OpenSim/OpenSim.World/World.PacketHandlers.cs
@@ -0,0 +1,261 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6using OpenSim.Physics.Manager;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Framework.Types;
9using OpenSim.Framework.Terrain;
10using OpenSim.Framework.Inventory;
11using OpenSim.Framework.Utilities;
12using OpenSim.Assets;
13
14namespace OpenSim.world
15{
16 public partial class World
17 {
18 public void ModifyTerrain(byte action, float north, float west)
19 {
20 switch (action)
21 {
22 case 1:
23 // raise terrain
24 Terrain.raise(north, west, 10.0, 0.001);
25 RegenerateTerrain(true, (int)north, (int)west);
26 break;
27 case 2:
28 //lower terrain
29 Terrain.lower(north, west, 10.0, 0.001);
30 RegenerateTerrain(true, (int)north, (int)west);
31 break;
32 }
33 return;
34 }
35
36 public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
37 {
38 foreach (ClientView client in m_clientThreads.Values)
39 {
40 // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
41 int dis = (int)client.ClientAvatar.Pos.GetDistanceTo(fromPos);
42
43 switch (type)
44 {
45 case 0: // Whisper
46 if ((dis < 10) && (dis > -10))
47 {
48 //should change so the message is sent through the avatar rather than direct to the ClientView
49 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
50 }
51 break;
52 case 1: // Say
53 if ((dis < 30) && (dis > -30))
54 {
55 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
56 }
57 break;
58 case 2: // Shout
59 if ((dis < 100) && (dis > -100))
60 {
61 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
62 }
63 break;
64
65 case 0xff: // Broadcast
66 client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
67 break;
68 }
69
70 }
71 }
72
73 public void RezObject(AssetBase primAsset, LLVector3 pos)
74 {
75 PrimData primd = new PrimData(primAsset.Data);
76 Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
77 nPrim.CreateFromStorage(primd, pos, this._primCount, true);
78 this.Entities.Add(nPrim.uuid, nPrim);
79 this._primCount++;
80 }
81
82 public void DeRezObject(Packet packet, ClientView simClient)
83 {
84 DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet;
85
86 //Needs to delete object from physics at a later date
87 if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
88 {
89 //currently following code not used (or don't know of any case of destination being zero
90
91 }
92 else
93 {
94 foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
95 {
96 Entity selectedEnt = null;
97 //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
98 foreach (Entity ent in this.Entities.Values)
99 {
100 if (ent.localid == Data.ObjectLocalID)
101 {
102 AssetBase primAsset = new AssetBase();
103 primAsset.FullID = LLUUID.Random();//DeRezPacket.AgentBlock.TransactionID.Combine(LLUUID.Zero); //should be combining with securesessionid
104 primAsset.InvType = 6;
105 primAsset.Type = 6;
106 primAsset.Name = "Prim";
107 primAsset.Description = "";
108 primAsset.Data = ((Primitive)ent).GetByteArray();
109 this._assetCache.AddAsset(primAsset);
110 this._inventoryCache.AddNewInventoryItem(simClient, DeRezPacket.AgentBlock.DestinationID, primAsset);
111 selectedEnt = ent;
112 break;
113 }
114 }
115 if (selectedEnt != null)
116 {
117 this.localStorage.RemovePrim(selectedEnt.uuid);
118 KillObjectPacket kill = new KillObjectPacket();
119 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
120 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
121 kill.ObjectData[0].ID = selectedEnt.localid;
122 foreach (ClientView client in m_clientThreads.Values)
123 {
124 client.OutPacket(kill);
125 }
126 lock (Entities)
127 {
128 Entities.Remove(selectedEnt.uuid);
129 }
130 }
131 }
132 }
133
134 }
135
136 public void SendAvatarsToClient(ClientView remoteClient)
137 {
138 foreach (ClientView client in m_clientThreads.Values)
139 {
140 if (client.AgentID != remoteClient.AgentID)
141 {
142 // ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket();
143 // RemoteClient.OutPacket(objupdate);
144 client.ClientAvatar.SendUpdateToOtherClient(remoteClient.ClientAvatar);
145 client.ClientAvatar.SendAppearanceToOtherAgent(remoteClient.ClientAvatar);
146 }
147 }
148 }
149
150 public void LinkObjects(uint parentPrim, List<uint> childPrims)
151 {
152 Primitive parentprim = null;
153 foreach (Entity ent in Entities.Values)
154 {
155 if (ent.localid == parentPrim)
156 {
157 parentprim = (OpenSim.world.Primitive)ent;
158
159 }
160 }
161
162 for (int i = 0; i < childPrims.Count; i++)
163 {
164 uint childId = childPrims[i];
165 foreach (Entity ent in Entities.Values)
166 {
167 if (ent.localid == childId)
168 {
169 ((OpenSim.world.Primitive)ent).MakeParent(parentprim);
170 }
171 }
172 }
173
174 }
175
176 public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock)
177 {
178 foreach (Entity ent in Entities.Values)
179 {
180 if (ent.localid == primLocalID)
181 {
182 ((OpenSim.world.Primitive)ent).UpdateShape(shapeBlock);
183 break;
184 }
185 }
186 }
187
188 public void SelectPrim(uint primLocalID, ClientView remoteClient)
189 {
190 foreach (Entity ent in Entities.Values)
191 {
192 if (ent.localid == primLocalID)
193 {
194 ((OpenSim.world.Primitive)ent).GetProperites(remoteClient);
195 break;
196 }
197 }
198 }
199
200 public void UpdatePrimFlags(uint localID, Packet packet, ClientView remoteClient)
201 {
202 foreach (Entity ent in Entities.Values)
203 {
204 if (ent.localid == localID)
205 {
206 ((OpenSim.world.Primitive)ent).UpdateObjectFlags((ObjectFlagUpdatePacket) packet);
207 break;
208 }
209 }
210 }
211
212 public void UpdatePrimTexture(uint localID, byte[] texture, ClientView remoteClient)
213 {
214 foreach (Entity ent in Entities.Values)
215 {
216 if (ent.localid == localID)
217 {
218 ((OpenSim.world.Primitive)ent).UpdateTexture(texture);
219 break;
220 }
221 }
222 }
223
224 public void UpdatePrimPosition(uint localID, LLVector3 pos, ClientView remoteClient)
225 {
226 foreach (Entity ent in Entities.Values)
227 {
228 if (ent.localid == localID)
229 {
230 ((OpenSim.world.Primitive)ent).UpdatePosition(pos);
231 break;
232 }
233 }
234 }
235
236 public void UpdatePrimRotation(uint localID, LLQuaternion rot, ClientView remoteClient)
237 {
238 foreach (Entity ent in Entities.Values)
239 {
240 if (ent.localid == localID)
241 {
242 ent.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
243 ((OpenSim.world.Primitive)ent).UpdateFlag = true;
244 break;
245 }
246 }
247 }
248
249 public void UpdatePrimScale(uint localID, LLVector3 scale, ClientView remoteClient)
250 {
251 foreach (Entity ent in Entities.Values)
252 {
253 if (ent.localid == localID)
254 {
255 ((OpenSim.world.Primitive)ent).Scale = scale;
256 break;
257 }
258 }
259 }
260 }
261}