diff options
Start of a redesign of SimClient (now renamed ClientView)/World/Avatar/Prim , switching to a event based system (World/Avatar register as event handlers). It is possible that I've broke something with this commit but it doesn't matter as I'll just hide and no one will find me.
Diffstat (limited to 'OpenSim.RegionServer/SimClient.ProcessPackets.cs')
-rw-r--r-- | OpenSim.RegionServer/SimClient.ProcessPackets.cs | 419 |
1 files changed, 0 insertions, 419 deletions
diff --git a/OpenSim.RegionServer/SimClient.ProcessPackets.cs b/OpenSim.RegionServer/SimClient.ProcessPackets.cs deleted file mode 100644 index c9592c2..0000000 --- a/OpenSim.RegionServer/SimClient.ProcessPackets.cs +++ /dev/null | |||
@@ -1,419 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using libsecondlife; | ||
5 | using libsecondlife.Packets; | ||
6 | using Nwc.XmlRpc; | ||
7 | using System.Net; | ||
8 | using System.Net.Sockets; | ||
9 | using System.IO; | ||
10 | using System.Threading; | ||
11 | using System.Timers; | ||
12 | using OpenSim.Framework.Interfaces; | ||
13 | using OpenSim.Framework.Types; | ||
14 | using OpenSim.Framework.Inventory; | ||
15 | using OpenSim.Framework.Utilities; | ||
16 | using OpenSim.world; | ||
17 | using OpenSim.Assets; | ||
18 | |||
19 | namespace OpenSim | ||
20 | { | ||
21 | public partial class SimClient | ||
22 | { | ||
23 | protected virtual void ProcessInPacket(Packet Pack) | ||
24 | { | ||
25 | ack_pack(Pack); | ||
26 | if (debug) | ||
27 | { | ||
28 | if (Pack.Type != PacketType.AgentUpdate) | ||
29 | { | ||
30 | Console.WriteLine(Pack.Type.ToString()); | ||
31 | } | ||
32 | } | ||
33 | |||
34 | if (this.ProcessPacketMethod(Pack)) | ||
35 | { | ||
36 | //there is a handler registered that handled this packet type | ||
37 | return; | ||
38 | } | ||
39 | else | ||
40 | { | ||
41 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
42 | |||
43 | switch (Pack.Type) | ||
44 | { | ||
45 | case PacketType.CompleteAgentMovement: | ||
46 | if (this.m_child) this.UpgradeClient(); | ||
47 | ClientAvatar.CompleteMovement(m_world); | ||
48 | ClientAvatar.SendInitialPosition(); | ||
49 | this.EnableNeighbours(); | ||
50 | break; | ||
51 | case PacketType.RegionHandshakeReply: | ||
52 | m_world.SendLayerData(this); | ||
53 | break; | ||
54 | case PacketType.AgentWearablesRequest: | ||
55 | ClientAvatar.SendInitialAppearance(); | ||
56 | foreach (SimClient client in m_clientThreads.Values) | ||
57 | { | ||
58 | if (client.AgentID != this.AgentID) | ||
59 | { | ||
60 | ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket(); | ||
61 | this.OutPacket(objupdate); | ||
62 | client.ClientAvatar.SendAppearanceToOtherAgent(this); | ||
63 | } | ||
64 | } | ||
65 | m_world.GetInitialPrims(this); | ||
66 | break; | ||
67 | case PacketType.AgentIsNowWearing: | ||
68 | AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack; | ||
69 | //Console.WriteLine(Pack.ToString()); | ||
70 | break; | ||
71 | case PacketType.AgentSetAppearance: | ||
72 | AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; | ||
73 | // Console.WriteLine(appear.ToString()); | ||
74 | this.ClientAvatar.SetAppearance(appear); | ||
75 | break; | ||
76 | case PacketType.ObjectAdd: | ||
77 | m_world.AddNewPrim((ObjectAddPacket)Pack, this); | ||
78 | break; | ||
79 | case PacketType.ObjectLink: | ||
80 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, Pack.ToString()); | ||
81 | ObjectLinkPacket link = (ObjectLinkPacket)Pack; | ||
82 | uint parentprimid = 0; | ||
83 | OpenSim.world.Primitive parentprim = null; | ||
84 | if (link.ObjectData.Length > 1) | ||
85 | { | ||
86 | parentprimid = link.ObjectData[0].ObjectLocalID; | ||
87 | foreach (Entity ent in m_world.Entities.Values) | ||
88 | { | ||
89 | if (ent.localid == parentprimid) | ||
90 | { | ||
91 | parentprim = (OpenSim.world.Primitive)ent; | ||
92 | |||
93 | } | ||
94 | } | ||
95 | for (int i = 1; i < link.ObjectData.Length; i++) | ||
96 | { | ||
97 | foreach (Entity ent in m_world.Entities.Values) | ||
98 | { | ||
99 | if (ent.localid == link.ObjectData[i].ObjectLocalID) | ||
100 | { | ||
101 | ((OpenSim.world.Primitive)ent).MakeParent(parentprim); | ||
102 | } | ||
103 | } | ||
104 | } | ||
105 | } | ||
106 | break; | ||
107 | case PacketType.ObjectScale: | ||
108 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, Pack.ToString()); | ||
109 | break; | ||
110 | case PacketType.ObjectShape: | ||
111 | ObjectShapePacket shape = (ObjectShapePacket)Pack; | ||
112 | for (int i = 0; i < shape.ObjectData.Length; i++) | ||
113 | { | ||
114 | foreach (Entity ent in m_world.Entities.Values) | ||
115 | { | ||
116 | if (ent.localid == shape.ObjectData[i].ObjectLocalID) | ||
117 | { | ||
118 | ((OpenSim.world.Primitive)ent).UpdateShape(shape.ObjectData[i]); | ||
119 | } | ||
120 | } | ||
121 | } | ||
122 | break; | ||
123 | case PacketType.RequestImage: | ||
124 | RequestImagePacket imageRequest = (RequestImagePacket)Pack; | ||
125 | for (int i = 0; i < imageRequest.RequestImage.Length; i++) | ||
126 | { | ||
127 | m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image); | ||
128 | } | ||
129 | break; | ||
130 | case PacketType.TransferRequest: | ||
131 | //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); | ||
132 | TransferRequestPacket transfer = (TransferRequestPacket)Pack; | ||
133 | m_assetCache.AddAssetRequest(this, transfer); | ||
134 | break; | ||
135 | case PacketType.AgentUpdate: | ||
136 | ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack); | ||
137 | break; | ||
138 | case PacketType.ObjectImage: | ||
139 | ObjectImagePacket imagePack = (ObjectImagePacket)Pack; | ||
140 | for (int i = 0; i < imagePack.ObjectData.Length; i++) | ||
141 | { | ||
142 | foreach (Entity ent in m_world.Entities.Values) | ||
143 | { | ||
144 | if (ent.localid == imagePack.ObjectData[i].ObjectLocalID) | ||
145 | { | ||
146 | ((OpenSim.world.Primitive)ent).UpdateTexture(imagePack.ObjectData[i].TextureEntry); | ||
147 | } | ||
148 | } | ||
149 | } | ||
150 | break; | ||
151 | case PacketType.ObjectFlagUpdate: | ||
152 | ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; | ||
153 | foreach (Entity ent in m_world.Entities.Values) | ||
154 | { | ||
155 | if (ent.localid == flags.AgentData.ObjectLocalID) | ||
156 | { | ||
157 | ((OpenSim.world.Primitive)ent).UpdateObjectFlags(flags); | ||
158 | } | ||
159 | } | ||
160 | break; | ||
161 | case PacketType.AssetUploadRequest: | ||
162 | AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; | ||
163 | this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); | ||
164 | break; | ||
165 | case PacketType.RequestXfer: | ||
166 | //Console.WriteLine(Pack.ToString()); | ||
167 | break; | ||
168 | case PacketType.SendXferPacket: | ||
169 | this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack); | ||
170 | break; | ||
171 | case PacketType.CreateInventoryFolder: | ||
172 | CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; | ||
173 | m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID); | ||
174 | //Console.WriteLine(Pack.ToString()); | ||
175 | break; | ||
176 | case PacketType.CreateInventoryItem: | ||
177 | //Console.WriteLine(Pack.ToString()); | ||
178 | CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; | ||
179 | if (createItem.InventoryBlock.TransactionID != LLUUID.Zero) | ||
180 | { | ||
181 | this.UploadAssets.CreateInventoryItem(createItem); | ||
182 | } | ||
183 | else | ||
184 | { | ||
185 | // Console.Write(Pack.ToString()); | ||
186 | this.CreateInventoryItem(createItem); | ||
187 | } | ||
188 | break; | ||
189 | case PacketType.FetchInventory: | ||
190 | //Console.WriteLine("fetch item packet"); | ||
191 | FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack; | ||
192 | m_inventoryCache.FetchInventory(this, FetchInventory); | ||
193 | break; | ||
194 | case PacketType.FetchInventoryDescendents: | ||
195 | FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; | ||
196 | m_inventoryCache.FetchInventoryDescendents(this, Fetch); | ||
197 | break; | ||
198 | case PacketType.UpdateInventoryItem: | ||
199 | UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack; | ||
200 | //Console.WriteLine(Pack.ToString()); | ||
201 | for (int i = 0; i < update.InventoryData.Length; i++) | ||
202 | { | ||
203 | if (update.InventoryData[i].TransactionID != LLUUID.Zero) | ||
204 | { | ||
205 | AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID)); | ||
206 | if (asset != null) | ||
207 | { | ||
208 | // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache"); | ||
209 | m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); | ||
210 | } | ||
211 | else | ||
212 | { | ||
213 | asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID); | ||
214 | if (asset != null) | ||
215 | { | ||
216 | //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache"); | ||
217 | m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); | ||
218 | } | ||
219 | else | ||
220 | { | ||
221 | //Console.WriteLine("trying to update inventory item, but asset is null"); | ||
222 | } | ||
223 | } | ||
224 | } | ||
225 | else | ||
226 | { | ||
227 | m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ; | ||
228 | } | ||
229 | } | ||
230 | break; | ||
231 | case PacketType.ViewerEffect: | ||
232 | ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; | ||
233 | foreach (SimClient client in m_clientThreads.Values) | ||
234 | { | ||
235 | if (client.AgentID != this.AgentID) | ||
236 | { | ||
237 | viewer.AgentData.AgentID = client.AgentID; | ||
238 | viewer.AgentData.SessionID = client.SessionID; | ||
239 | client.OutPacket(viewer); | ||
240 | } | ||
241 | } | ||
242 | break; | ||
243 | case PacketType.RequestTaskInventory: | ||
244 | // Console.WriteLine(Pack.ToString()); | ||
245 | RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; | ||
246 | ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket(); | ||
247 | bool foundent = false; | ||
248 | foreach (Entity ent in m_world.Entities.Values) | ||
249 | { | ||
250 | if (ent.localid == requesttask.InventoryData.LocalID) | ||
251 | { | ||
252 | replytask.InventoryData.TaskID = ent.uuid; | ||
253 | replytask.InventoryData.Serial = 0; | ||
254 | replytask.InventoryData.Filename = new byte[0]; | ||
255 | foundent = true; | ||
256 | } | ||
257 | } | ||
258 | if (foundent) | ||
259 | { | ||
260 | this.OutPacket(replytask); | ||
261 | } | ||
262 | break; | ||
263 | case PacketType.UpdateTaskInventory: | ||
264 | // Console.WriteLine(Pack.ToString()); | ||
265 | UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; | ||
266 | AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID); | ||
267 | if (myinventory != null) | ||
268 | { | ||
269 | if (updatetask.UpdateData.Key == 0) | ||
270 | { | ||
271 | if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null) | ||
272 | { | ||
273 | if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7) | ||
274 | { | ||
275 | LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID; | ||
276 | AssetBase assBase = this.m_assetCache.GetAsset(noteaid); | ||
277 | if (assBase != null) | ||
278 | { | ||
279 | foreach (Entity ent in m_world.Entities.Values) | ||
280 | { | ||
281 | if (ent.localid == updatetask.UpdateData.LocalID) | ||
282 | { | ||
283 | if (ent is OpenSim.world.Primitive) | ||
284 | { | ||
285 | this.m_world.AddScript(ent, Util.FieldToString(assBase.Data)); | ||
286 | } | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | } | ||
291 | } | ||
292 | } | ||
293 | } | ||
294 | break; | ||
295 | case PacketType.AgentAnimation: | ||
296 | if (!m_child) | ||
297 | { | ||
298 | AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; | ||
299 | for (int i = 0; i < AgentAni.AnimationList.Length; i++) | ||
300 | { | ||
301 | if (AgentAni.AnimationList[i].StartAnim) | ||
302 | { | ||
303 | ClientAvatar.current_anim = AgentAni.AnimationList[i].AnimID; | ||
304 | ClientAvatar.anim_seq = 1; | ||
305 | ClientAvatar.SendAnimPack(); | ||
306 | } | ||
307 | } | ||
308 | } | ||
309 | break; | ||
310 | case PacketType.ObjectSelect: | ||
311 | ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; | ||
312 | for (int i = 0; i < incomingselect.ObjectData.Length; i++) | ||
313 | { | ||
314 | foreach (Entity ent in m_world.Entities.Values) | ||
315 | { | ||
316 | if (ent.localid == incomingselect.ObjectData[i].ObjectLocalID) | ||
317 | { | ||
318 | ((OpenSim.world.Primitive)ent).GetProperites(this); | ||
319 | break; | ||
320 | } | ||
321 | } | ||
322 | } | ||
323 | break; | ||
324 | case PacketType.MapLayerRequest: | ||
325 | this.RequestMapLayer(); | ||
326 | break; | ||
327 | case PacketType.MapBlockRequest: | ||
328 | MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack; | ||
329 | |||
330 | this.RequestMapBlocks(MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); | ||
331 | break; | ||
332 | |||
333 | case PacketType.TeleportLandmarkRequest: | ||
334 | TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; | ||
335 | |||
336 | TeleportStartPacket tpStart = new TeleportStartPacket(); | ||
337 | tpStart.Info.TeleportFlags = 8; // tp via lm | ||
338 | this.OutPacket(tpStart); | ||
339 | |||
340 | TeleportProgressPacket tpProgress = new TeleportProgressPacket(); | ||
341 | tpProgress.Info.Message = (new System.Text.ASCIIEncoding()).GetBytes("sending_landmark"); | ||
342 | tpProgress.Info.TeleportFlags = 8; | ||
343 | tpProgress.AgentData.AgentID = tpReq.Info.AgentID; | ||
344 | this.OutPacket(tpProgress); | ||
345 | |||
346 | // Fetch landmark | ||
347 | LLUUID lmid = tpReq.Info.LandmarkID; | ||
348 | AssetBase lma = this.m_assetCache.GetAsset(lmid); | ||
349 | if (lma != null) | ||
350 | { | ||
351 | AssetLandmark lm = new AssetLandmark(lma); | ||
352 | |||
353 | if (lm.RegionID == m_regionData.SimUUID) | ||
354 | { | ||
355 | TeleportLocalPacket tpLocal = new TeleportLocalPacket(); | ||
356 | |||
357 | tpLocal.Info.AgentID = tpReq.Info.AgentID; | ||
358 | tpLocal.Info.TeleportFlags = 8; // Teleport via landmark | ||
359 | tpLocal.Info.LocationID = 2; | ||
360 | tpLocal.Info.Position = lm.Position; | ||
361 | OutPacket(tpLocal); | ||
362 | } | ||
363 | else | ||
364 | { | ||
365 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | ||
366 | tpCancel.Info.AgentID = tpReq.Info.AgentID; | ||
367 | tpCancel.Info.SessionID = tpReq.Info.SessionID; | ||
368 | OutPacket(tpCancel); | ||
369 | } | ||
370 | } | ||
371 | else | ||
372 | { | ||
373 | Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented"); | ||
374 | |||
375 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | ||
376 | tpCancel.Info.AgentID = tpReq.Info.AgentID; | ||
377 | tpCancel.Info.SessionID = tpReq.Info.SessionID; | ||
378 | OutPacket(tpCancel); | ||
379 | } | ||
380 | break; | ||
381 | |||
382 | case PacketType.TeleportLocationRequest: | ||
383 | TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; | ||
384 | Console.WriteLine(tpLocReq.ToString()); | ||
385 | |||
386 | tpStart = new TeleportStartPacket(); | ||
387 | tpStart.Info.TeleportFlags = 16; // Teleport via location | ||
388 | Console.WriteLine(tpStart.ToString()); | ||
389 | OutPacket(tpStart); | ||
390 | |||
391 | if (m_regionData.RegionHandle != tpLocReq.Info.RegionHandle) | ||
392 | { | ||
393 | /* m_gridServer.getRegion(tpLocReq.Info.RegionHandle); */ | ||
394 | Console.WriteLine("Inter-sim teleport not yet implemented"); | ||
395 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | ||
396 | tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID; | ||
397 | tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID; | ||
398 | |||
399 | OutPacket(tpCancel); | ||
400 | } | ||
401 | else | ||
402 | { | ||
403 | Console.WriteLine("Local teleport"); | ||
404 | TeleportLocalPacket tpLocal = new TeleportLocalPacket(); | ||
405 | tpLocal.Info.AgentID = tpLocReq.AgentData.AgentID; | ||
406 | tpLocal.Info.TeleportFlags = tpStart.Info.TeleportFlags; | ||
407 | tpLocal.Info.LocationID = 2; | ||
408 | tpLocal.Info.LookAt = tpLocReq.Info.LookAt; | ||
409 | tpLocal.Info.Position = tpLocReq.Info.Position; | ||
410 | OutPacket(tpLocal); | ||
411 | |||
412 | } | ||
413 | |||
414 | break; | ||
415 | } | ||
416 | } | ||
417 | } | ||
418 | } | ||
419 | } | ||