diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim.RegionServer/world/World.cs | 122 |
1 files changed, 103 insertions, 19 deletions
diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs index 446d37c..82e8b8d 100644 --- a/OpenSim.RegionServer/world/World.cs +++ b/OpenSim.RegionServer/world/World.cs | |||
@@ -9,6 +9,8 @@ using OpenSim.Physics.Manager; | |||
9 | using OpenSim.Framework.Interfaces; | 9 | using OpenSim.Framework.Interfaces; |
10 | using OpenSim.Framework.Assets; | 10 | using OpenSim.Framework.Assets; |
11 | using OpenSim.Framework.Terrain; | 11 | using OpenSim.Framework.Terrain; |
12 | using OpenSim.Framework.Inventory; | ||
13 | using OpenSim.Assets; | ||
12 | 14 | ||
13 | namespace OpenSim.world | 15 | namespace OpenSim.world |
14 | { | 16 | { |
@@ -30,6 +32,8 @@ namespace OpenSim.world | |||
30 | private ulong m_regionHandle; | 32 | private ulong m_regionHandle; |
31 | private string m_regionName; | 33 | private string m_regionName; |
32 | private SimConfig m_cfg; | 34 | private SimConfig m_cfg; |
35 | private InventoryCache _inventoryCache; | ||
36 | private AssetCache _assetCache; | ||
33 | 37 | ||
34 | public World(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, string regionName, SimConfig cfg) | 38 | public World(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, string regionName, SimConfig cfg) |
35 | { | 39 | { |
@@ -50,6 +54,21 @@ namespace OpenSim.world | |||
50 | Avatar.LoadAnims(); | 54 | Avatar.LoadAnims(); |
51 | } | 55 | } |
52 | 56 | ||
57 | public InventoryCache InventoryCache | ||
58 | { | ||
59 | set | ||
60 | { | ||
61 | this._inventoryCache = value; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | public AssetCache AssetCache | ||
66 | { | ||
67 | set | ||
68 | { | ||
69 | this._assetCache = value; | ||
70 | } | ||
71 | } | ||
53 | public PhysicsScene PhysScene | 72 | public PhysicsScene PhysScene |
54 | { | 73 | { |
55 | set | 74 | set |
@@ -291,44 +310,109 @@ namespace OpenSim.world | |||
291 | 310 | ||
292 | public void DeRezObject(DeRezObjectPacket DeRezPacket, SimClient AgentClient) | 311 | public void DeRezObject(DeRezObjectPacket DeRezPacket, SimClient AgentClient) |
293 | { | 312 | { |
313 | // Console.WriteLine(DeRezPacket); | ||
294 | //Needs to delete object from physics at a later date | 314 | //Needs to delete object from physics at a later date |
315 | if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) | ||
316 | { | ||
317 | libsecondlife.LLUUID[] DeRezEnts; | ||
318 | DeRezEnts = new libsecondlife.LLUUID[DeRezPacket.ObjectData.Length]; | ||
319 | int i = 0; | ||
320 | foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) | ||
321 | { | ||
295 | 322 | ||
296 | libsecondlife.LLUUID[] DeRezEnts; | 323 | //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); |
297 | DeRezEnts = new libsecondlife.LLUUID[DeRezPacket.ObjectData.Length]; | 324 | foreach (Entity ent in this.Entities.Values) |
298 | int i = 0; | 325 | { |
299 | foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) | 326 | if (ent.localid == Data.ObjectLocalID) |
327 | { | ||
328 | DeRezEnts[i++] = ent.uuid; | ||
329 | this.localStorage.RemovePrim(ent.uuid); | ||
330 | KillObjectPacket kill = new KillObjectPacket(); | ||
331 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | ||
332 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | ||
333 | kill.ObjectData[0].ID = ent.localid; | ||
334 | foreach (SimClient client in m_clientThreads.Values) | ||
335 | { | ||
336 | client.OutPacket(kill); | ||
337 | } | ||
338 | //Uncommenting this means an old UUID will be re-used, thus crashing the asset server | ||
339 | //Uncomment when prim/object UUIDs are random or such | ||
340 | //2007-03-22 - Randomskk | ||
341 | //this._primCount--; | ||
342 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Deleted UUID " + ent.uuid); | ||
343 | } | ||
344 | } | ||
345 | } | ||
346 | foreach (libsecondlife.LLUUID uuid in DeRezEnts) | ||
347 | { | ||
348 | lock (Entities) | ||
349 | { | ||
350 | Entities.Remove(uuid); | ||
351 | } | ||
352 | } | ||
353 | } | ||
354 | else | ||
300 | { | 355 | { |
301 | //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); | 356 | foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) |
302 | foreach (Entity ent in this.Entities.Values) | ||
303 | { | 357 | { |
304 | if (ent.localid == Data.ObjectLocalID) | 358 | Entity selectedEnt = null; |
359 | //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); | ||
360 | foreach (Entity ent in this.Entities.Values) | ||
361 | { | ||
362 | if (ent.localid == Data.ObjectLocalID) | ||
363 | { | ||
364 | AssetBase primAsset = new AssetBase(); | ||
365 | primAsset.FullID = LLUUID.Random();//DeRezPacket.AgentBlock.TransactionID.Combine(LLUUID.Zero); //should be combining with securesessionid | ||
366 | primAsset.InvType = 6; | ||
367 | primAsset.Type = 6; | ||
368 | primAsset.Name = "Prim"; | ||
369 | primAsset.Description = ""; | ||
370 | primAsset.Data = ((Primitive)ent).GetByteArray(); | ||
371 | this._assetCache.AddAsset(primAsset); | ||
372 | this._inventoryCache.AddNewInventoryItem(AgentClient, DeRezPacket.AgentBlock.DestinationID, primAsset); | ||
373 | selectedEnt = ent; | ||
374 | break; | ||
375 | } | ||
376 | } | ||
377 | if (selectedEnt != null) | ||
305 | { | 378 | { |
306 | DeRezEnts[i++] = ent.uuid; | 379 | this.localStorage.RemovePrim(selectedEnt.uuid); |
307 | this.localStorage.RemovePrim(ent.uuid); | ||
308 | KillObjectPacket kill = new KillObjectPacket(); | 380 | KillObjectPacket kill = new KillObjectPacket(); |
309 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | 381 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; |
310 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | 382 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); |
311 | kill.ObjectData[0].ID = ent.localid; | 383 | kill.ObjectData[0].ID = selectedEnt.localid; |
312 | foreach (SimClient client in m_clientThreads.Values) | 384 | foreach (SimClient client in m_clientThreads.Values) |
313 | { | 385 | { |
314 | client.OutPacket(kill); | 386 | client.OutPacket(kill); |
315 | } | 387 | } |
316 | //Uncommenting this means an old UUID will be re-used, thus crashing the asset server | 388 | lock (Entities) |
317 | //Uncomment when prim/object UUIDs are random or such | 389 | { |
318 | //2007-03-22 - Randomskk | 390 | Entities.Remove(selectedEnt.uuid); |
319 | //this._primCount--; | 391 | } |
320 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Deleted UUID " + ent.uuid); | ||
321 | } | 392 | } |
322 | } | 393 | } |
323 | } | 394 | } |
324 | foreach (libsecondlife.LLUUID uuid in DeRezEnts) | 395 | } |
396 | |||
397 | public void RezObject(SimClient remoteClient, RezObjectPacket packet) | ||
398 | { | ||
399 | AgentInventory inven =this._inventoryCache.GetAgentsInventory(remoteClient.AgentID); | ||
400 | if(inven != null) | ||
325 | { | 401 | { |
326 | lock (Entities) | 402 | if (inven.InventoryItems.ContainsKey(packet.InventoryData.ItemID)) |
327 | { | 403 | { |
328 | Entities.Remove(uuid); | 404 | AssetBase asset = this._assetCache.GetAsset(inven.InventoryItems[packet.InventoryData.ItemID].AssetID); |
405 | if (asset != null) | ||
406 | { | ||
407 | PrimData primd = new PrimData(asset.Data); | ||
408 | Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this); | ||
409 | nPrim.CreateFromStorage(primd, packet.RezData.RayEnd, this._primCount, true); | ||
410 | this.Entities.Add(nPrim.uuid, nPrim); | ||
411 | this._primCount++; | ||
412 | this._inventoryCache.DeleteInventoryItem(remoteClient, packet.InventoryData.ItemID); | ||
413 | } | ||
329 | } | 414 | } |
330 | } | 415 | } |
331 | |||
332 | } | 416 | } |
333 | 417 | ||
334 | public bool Backup() | 418 | public bool Backup() |