diff options
author | MW | 2007-04-04 18:26:33 +0000 |
---|---|---|
committer | MW | 2007-04-04 18:26:33 +0000 |
commit | d3766d0aef46c53b9e92afa77ffaa33817c7a04a (patch) | |
tree | 6e93d5ac3a70e38ce68d2694f0e0fbec68633e6c /OpenSim.RegionServer | |
parent | Split Avatar class into three partial classes (hopefully will make it easier ... (diff) | |
download | opensim-SC-d3766d0aef46c53b9e92afa77ffaa33817c7a04a.zip opensim-SC-d3766d0aef46c53b9e92afa77ffaa33817c7a04a.tar.gz opensim-SC-d3766d0aef46c53b9e92afa77ffaa33817c7a04a.tar.bz2 opensim-SC-d3766d0aef46c53b9e92afa77ffaa33817c7a04a.tar.xz |
Deleted OpenSim.Config/SimConfigDb4o, as it hasn't been used for a while now.
Split World class into two partial classes
Diffstat (limited to '')
-rw-r--r-- | OpenSim.RegionServer/OpenSim.RegionServer.csproj | 3 | ||||
-rw-r--r-- | OpenSim.RegionServer/OpenSim.RegionServer.dll.build | 1 | ||||
-rw-r--r-- | OpenSim.RegionServer/SimClient.cs | 7 | ||||
-rw-r--r-- | OpenSim.RegionServer/world/World.cs | 224 | ||||
-rw-r--r-- | OpenSim.RegionServer/world/WorldPacketHandlers.cs | 200 |
5 files changed, 237 insertions, 198 deletions
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj index cee91f8..73f523a 100644 --- a/OpenSim.RegionServer/OpenSim.RegionServer.csproj +++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj | |||
@@ -190,6 +190,9 @@ | |||
190 | <Compile Include="world\World.cs"> | 190 | <Compile Include="world\World.cs"> |
191 | <SubType>Code</SubType> | 191 | <SubType>Code</SubType> |
192 | </Compile> | 192 | </Compile> |
193 | <Compile Include="world\WorldPacketHandlers.cs"> | ||
194 | <SubType>Code</SubType> | ||
195 | </Compile> | ||
193 | <Compile Include="world\scripting\IScript.cs"> | 196 | <Compile Include="world\scripting\IScript.cs"> |
194 | <SubType>Code</SubType> | 197 | <SubType>Code</SubType> |
195 | </Compile> | 198 | </Compile> |
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build index c0289e7..7488a3e 100644 --- a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build +++ b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build | |||
@@ -37,6 +37,7 @@ | |||
37 | <include name="world/ScriptEngine.cs" /> | 37 | <include name="world/ScriptEngine.cs" /> |
38 | <include name="world/SurfacePatch.cs" /> | 38 | <include name="world/SurfacePatch.cs" /> |
39 | <include name="world/World.cs" /> | 39 | <include name="world/World.cs" /> |
40 | <include name="world/WorldPacketHandlers.cs" /> | ||
40 | <include name="world/scripting/IScript.cs" /> | 41 | <include name="world/scripting/IScript.cs" /> |
41 | <include name="world/scripting/IScriptContext.cs" /> | 42 | <include name="world/scripting/IScriptContext.cs" /> |
42 | <include name="world/scripting/IScriptEntity.cs" /> | 43 | <include name="world/scripting/IScriptEntity.cs" /> |
diff --git a/OpenSim.RegionServer/SimClient.cs b/OpenSim.RegionServer/SimClient.cs index 1564238..770573a 100644 --- a/OpenSim.RegionServer/SimClient.cs +++ b/OpenSim.RegionServer/SimClient.cs | |||
@@ -813,12 +813,13 @@ namespace OpenSim | |||
813 | } | 813 | } |
814 | 814 | ||
815 | m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode); | 815 | m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode); |
816 | lock (m_world.Entities) | 816 | /*lock (m_world.Entities) |
817 | { | 817 | { |
818 | m_world.Entities.Remove(this.AgentID); | 818 | m_world.Entities.Remove(this.AgentID); |
819 | } | 819 | }*/ |
820 | m_world.RemoveViewerAgent(this); | ||
820 | //need to do other cleaning up here too | 821 | //need to do other cleaning up here too |
821 | m_clientThreads.Remove(this.CircuitCode); //this.userEP); | 822 | m_clientThreads.Remove(this.CircuitCode); |
822 | m_application.RemoveClientCircuit(this.CircuitCode); | 823 | m_application.RemoveClientCircuit(this.CircuitCode); |
823 | this.ClientThread.Abort(); | 824 | this.ClientThread.Abort(); |
824 | return true; | 825 | return true; |
diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs index 4661a90..5e4a3d3 100644 --- a/OpenSim.RegionServer/world/World.cs +++ b/OpenSim.RegionServer/world/World.cs | |||
@@ -17,7 +17,7 @@ using OpenSim.RegionServer.world.scripting.Scripts; | |||
17 | 17 | ||
18 | namespace OpenSim.world | 18 | namespace OpenSim.world |
19 | { | 19 | { |
20 | public class World : ILocalStorageReceiver | 20 | public partial class World : ILocalStorageReceiver |
21 | { | 21 | { |
22 | public object LockPhysicsEngine = new object(); | 22 | public object LockPhysicsEngine = new object(); |
23 | public Dictionary<libsecondlife.LLUUID, Entity> Entities; | 23 | public Dictionary<libsecondlife.LLUUID, Entity> Entities; |
@@ -86,10 +86,10 @@ namespace OpenSim.world | |||
86 | 86 | ||
87 | if (this.m_scripts.TryGetValue(substring, out scriptFactory)) | 87 | if (this.m_scripts.TryGetValue(substring, out scriptFactory)) |
88 | { | 88 | { |
89 | //Console.WriteLine("added script"); | 89 | //Console.WriteLine("added script"); |
90 | this.AddScript(entity, scriptFactory()); | 90 | this.AddScript(entity, scriptFactory()); |
91 | } | 91 | } |
92 | 92 | ||
93 | } | 93 | } |
94 | 94 | ||
95 | public InventoryCache InventoryCache | 95 | public InventoryCache InventoryCache |
@@ -208,7 +208,6 @@ namespace OpenSim.world | |||
208 | 208 | ||
209 | public void RegenerateTerrain(float[] newMap) | 209 | public void RegenerateTerrain(float[] newMap) |
210 | { | 210 | { |
211 | |||
212 | this.LandMap = newMap; | 211 | this.LandMap = newMap; |
213 | lock (this.LockPhysicsEngine) | 212 | lock (this.LockPhysicsEngine) |
214 | { | 213 | { |
@@ -309,8 +308,8 @@ namespace OpenSim.world | |||
309 | 308 | ||
310 | Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches); | 309 | Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches); |
311 | RemoteClient.OutPacket(layerpack); | 310 | RemoteClient.OutPacket(layerpack); |
312 | |||
313 | } | 311 | } |
312 | |||
314 | public void GetInitialPrims(SimClient RemoteClient) | 313 | public void GetInitialPrims(SimClient RemoteClient) |
315 | { | 314 | { |
316 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | 315 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) |
@@ -323,19 +322,38 @@ namespace OpenSim.world | |||
323 | } | 322 | } |
324 | } | 323 | } |
325 | 324 | ||
326 | public void AddViewerAgent(SimClient AgentClient) | 325 | public void AddViewerAgent(SimClient agentClient) |
327 | { | 326 | { |
328 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); | 327 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); |
329 | Avatar NewAvatar = new Avatar(AgentClient, this, m_regionName, m_clientThreads, m_regionHandle); | 328 | Avatar newAvatar = new Avatar(agentClient, this, m_regionName, m_clientThreads, m_regionHandle); |
330 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); | 329 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); |
331 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); | 330 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); |
332 | NewAvatar.SendRegionHandshake(this); | 331 | newAvatar.SendRegionHandshake(this); |
333 | PhysicsVector pVec = new PhysicsVector(NewAvatar.Pos.X, NewAvatar.Pos.Y, NewAvatar.Pos.Z); | 332 | PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z); |
334 | lock (this.LockPhysicsEngine) | 333 | lock (this.LockPhysicsEngine) |
335 | { | 334 | { |
336 | NewAvatar.PhysActor = this.phyScene.AddAvatar(pVec); | 335 | newAvatar.PhysActor = this.phyScene.AddAvatar(pVec); |
336 | } | ||
337 | lock (Entities) | ||
338 | { | ||
339 | this.Entities.Add(agentClient.AgentID, newAvatar); | ||
340 | } | ||
341 | lock (Avatars) | ||
342 | { | ||
343 | this.Avatars.Add(agentClient.AgentID, newAvatar); | ||
344 | } | ||
345 | } | ||
346 | |||
347 | public void RemoveViewerAgent(SimClient agentClient) | ||
348 | { | ||
349 | lock (Entities) | ||
350 | { | ||
351 | Entities.Remove(agentClient.AgentID); | ||
352 | } | ||
353 | lock (Avatars) | ||
354 | { | ||
355 | Avatars.Remove(agentClient.AgentID); | ||
337 | } | 356 | } |
338 | this.Entities.Add(AgentClient.AgentID, NewAvatar); | ||
339 | } | 357 | } |
340 | 358 | ||
341 | public void AddNewPrim(ObjectAddPacket addPacket, SimClient AgentClient) | 359 | public void AddNewPrim(ObjectAddPacket addPacket, SimClient AgentClient) |
@@ -357,94 +375,6 @@ namespace OpenSim.world | |||
357 | this._primCount++; | 375 | this._primCount++; |
358 | } | 376 | } |
359 | 377 | ||
360 | public bool DeRezObject(SimClient simClient, Packet packet) | ||
361 | { | ||
362 | DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet; | ||
363 | // Console.WriteLine(DeRezPacket); | ||
364 | //Needs to delete object from physics at a later date | ||
365 | if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) | ||
366 | { | ||
367 | libsecondlife.LLUUID[] DeRezEnts; | ||
368 | DeRezEnts = new libsecondlife.LLUUID[DeRezPacket.ObjectData.Length]; | ||
369 | int i = 0; | ||
370 | foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) | ||
371 | { | ||
372 | |||
373 | //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); | ||
374 | foreach (Entity ent in this.Entities.Values) | ||
375 | { | ||
376 | if (ent.localid == Data.ObjectLocalID) | ||
377 | { | ||
378 | DeRezEnts[i++] = ent.uuid; | ||
379 | this.localStorage.RemovePrim(ent.uuid); | ||
380 | KillObjectPacket kill = new KillObjectPacket(); | ||
381 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | ||
382 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | ||
383 | kill.ObjectData[0].ID = ent.localid; | ||
384 | foreach (SimClient client in m_clientThreads.Values) | ||
385 | { | ||
386 | client.OutPacket(kill); | ||
387 | } | ||
388 | //Uncommenting this means an old UUID will be re-used, thus crashing the asset server | ||
389 | //Uncomment when prim/object UUIDs are random or such | ||
390 | //2007-03-22 - Randomskk | ||
391 | //this._primCount--; | ||
392 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Deleted UUID " + ent.uuid); | ||
393 | } | ||
394 | } | ||
395 | } | ||
396 | foreach (libsecondlife.LLUUID uuid in DeRezEnts) | ||
397 | { | ||
398 | lock (Entities) | ||
399 | { | ||
400 | Entities.Remove(uuid); | ||
401 | } | ||
402 | } | ||
403 | } | ||
404 | else | ||
405 | { | ||
406 | foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) | ||
407 | { | ||
408 | Entity selectedEnt = null; | ||
409 | //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); | ||
410 | foreach (Entity ent in this.Entities.Values) | ||
411 | { | ||
412 | if (ent.localid == Data.ObjectLocalID) | ||
413 | { | ||
414 | AssetBase primAsset = new AssetBase(); | ||
415 | primAsset.FullID = LLUUID.Random();//DeRezPacket.AgentBlock.TransactionID.Combine(LLUUID.Zero); //should be combining with securesessionid | ||
416 | primAsset.InvType = 6; | ||
417 | primAsset.Type = 6; | ||
418 | primAsset.Name = "Prim"; | ||
419 | primAsset.Description = ""; | ||
420 | primAsset.Data = ((Primitive)ent).GetByteArray(); | ||
421 | this._assetCache.AddAsset(primAsset); | ||
422 | this._inventoryCache.AddNewInventoryItem(simClient, DeRezPacket.AgentBlock.DestinationID, primAsset); | ||
423 | selectedEnt = ent; | ||
424 | break; | ||
425 | } | ||
426 | } | ||
427 | if (selectedEnt != null) | ||
428 | { | ||
429 | this.localStorage.RemovePrim(selectedEnt.uuid); | ||
430 | KillObjectPacket kill = new KillObjectPacket(); | ||
431 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | ||
432 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | ||
433 | kill.ObjectData[0].ID = selectedEnt.localid; | ||
434 | foreach (SimClient client in m_clientThreads.Values) | ||
435 | { | ||
436 | client.OutPacket(kill); | ||
437 | } | ||
438 | lock (Entities) | ||
439 | { | ||
440 | Entities.Remove(selectedEnt.uuid); | ||
441 | } | ||
442 | } | ||
443 | } | ||
444 | } | ||
445 | return true; | ||
446 | } | ||
447 | |||
448 | public bool Backup() | 378 | public bool Backup() |
449 | { | 379 | { |
450 | 380 | ||
@@ -456,100 +386,6 @@ namespace OpenSim.world | |||
456 | return true; | 386 | return true; |
457 | } | 387 | } |
458 | 388 | ||
459 | #region Packet Handlers | ||
460 | public bool ModifyTerrain(SimClient simClient, Packet packet) | ||
461 | { | ||
462 | ModifyLandPacket modify = (ModifyLandPacket)packet; | ||
463 | |||
464 | switch (modify.ModifyBlock.Action) | ||
465 | { | ||
466 | case 1: | ||
467 | // raise terrain | ||
468 | if (modify.ParcelData.Length > 0) | ||
469 | { | ||
470 | int mody = (int)modify.ParcelData[0].North; | ||
471 | int modx = (int)modify.ParcelData[0].West; | ||
472 | lock (LandMap) | ||
473 | { | ||
474 | LandMap[(mody * 256) + modx - 1] += 0.05f; | ||
475 | LandMap[(mody * 256) + modx] += 0.1f; | ||
476 | LandMap[(mody * 256) + modx + 1] += 0.05f; | ||
477 | LandMap[((mody + 1) * 256) + modx] += 0.05f; | ||
478 | LandMap[((mody - 1) * 256) + modx] += 0.05f; | ||
479 | } | ||
480 | RegenerateTerrain(true, modx, mody); | ||
481 | } | ||
482 | break; | ||
483 | case 2: | ||
484 | //lower terrain | ||
485 | if (modify.ParcelData.Length > 0) | ||
486 | { | ||
487 | int mody = (int)modify.ParcelData[0].North; | ||
488 | int modx = (int)modify.ParcelData[0].West; | ||
489 | lock (LandMap) | ||
490 | { | ||
491 | LandMap[(mody * 256) + modx - 1] -= 0.05f; | ||
492 | LandMap[(mody * 256) + modx] -= 0.1f; | ||
493 | LandMap[(mody * 256) + modx + 1] -= 0.05f; | ||
494 | LandMap[((mody + 1) * 256) + modx] -= 0.05f; | ||
495 | LandMap[((mody - 1) * 256) + modx] -= 0.05f; | ||
496 | } | ||
497 | RegenerateTerrain(true, modx, mody); | ||
498 | } | ||
499 | break; | ||
500 | } | ||
501 | return true; | ||
502 | } | ||
503 | |||
504 | public bool SimChat(SimClient simClient, Packet packet) | ||
505 | { | ||
506 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
507 | ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)packet; | ||
508 | if (Helpers.FieldToString(inchatpack.ChatData.Message) == "") | ||
509 | { | ||
510 | //empty message so don't bother with it | ||
511 | return true; | ||
512 | } | ||
513 | |||
514 | libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); | ||
515 | reply.ChatData.Audible = 1; | ||
516 | reply.ChatData.Message = inchatpack.ChatData.Message; | ||
517 | reply.ChatData.ChatType = 1; | ||
518 | reply.ChatData.SourceType = 1; | ||
519 | reply.ChatData.Position = simClient.ClientAvatar.Pos; | ||
520 | reply.ChatData.FromName = enc.GetBytes(simClient.ClientAvatar.firstname + " " + simClient.ClientAvatar.lastname + "\0"); | ||
521 | reply.ChatData.OwnerID = simClient.AgentID; | ||
522 | reply.ChatData.SourceID = simClient.AgentID; | ||
523 | foreach (SimClient client in m_clientThreads.Values) | ||
524 | { | ||
525 | client.OutPacket(reply); | ||
526 | } | ||
527 | return true; | ||
528 | } | ||
529 | |||
530 | public bool RezObject(SimClient simClient, Packet packet) | ||
531 | { | ||
532 | RezObjectPacket rezPacket = (RezObjectPacket)packet; | ||
533 | AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID); | ||
534 | if (inven != null) | ||
535 | { | ||
536 | if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID)) | ||
537 | { | ||
538 | AssetBase asset = this._assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID); | ||
539 | if (asset != null) | ||
540 | { | ||
541 | PrimData primd = new PrimData(asset.Data); | ||
542 | Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this); | ||
543 | nPrim.CreateFromStorage(primd, rezPacket.RezData.RayEnd, this._primCount, true); | ||
544 | this.Entities.Add(nPrim.uuid, nPrim); | ||
545 | this._primCount++; | ||
546 | this._inventoryCache.DeleteInventoryItem(simClient, rezPacket.InventoryData.ItemID); | ||
547 | } | ||
548 | } | ||
549 | } | ||
550 | return true; | ||
551 | } | ||
552 | |||
553 | public void SetDefaultScripts() | 389 | public void SetDefaultScripts() |
554 | { | 390 | { |
555 | this.m_scripts.Add("FollowRandomAvatar", delegate() | 391 | this.m_scripts.Add("FollowRandomAvatar", delegate() |
@@ -558,7 +394,5 @@ namespace OpenSim.world | |||
558 | }); | 394 | }); |
559 | } | 395 | } |
560 | 396 | ||
561 | |||
562 | #endregion | ||
563 | } | 397 | } |
564 | } | 398 | } |
diff --git a/OpenSim.RegionServer/world/WorldPacketHandlers.cs b/OpenSim.RegionServer/world/WorldPacketHandlers.cs new file mode 100644 index 0000000..a155ffe --- /dev/null +++ b/OpenSim.RegionServer/world/WorldPacketHandlers.cs | |||
@@ -0,0 +1,200 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using libsecondlife; | ||
5 | using libsecondlife.Packets; | ||
6 | using OpenSim.Physics.Manager; | ||
7 | using OpenSim.Framework.Interfaces; | ||
8 | using OpenSim.Framework.Assets; | ||
9 | using OpenSim.Framework.Terrain; | ||
10 | using OpenSim.Framework.Inventory; | ||
11 | using OpenSim.Assets; | ||
12 | |||
13 | namespace OpenSim.world | ||
14 | { | ||
15 | partial class World | ||
16 | { | ||
17 | public bool ModifyTerrain(SimClient simClient, Packet packet) | ||
18 | { | ||
19 | ModifyLandPacket modify = (ModifyLandPacket)packet; | ||
20 | |||
21 | switch (modify.ModifyBlock.Action) | ||
22 | { | ||
23 | case 1: | ||
24 | // raise terrain | ||
25 | if (modify.ParcelData.Length > 0) | ||
26 | { | ||
27 | int mody = (int)modify.ParcelData[0].North; | ||
28 | int modx = (int)modify.ParcelData[0].West; | ||
29 | lock (LandMap) | ||
30 | { | ||
31 | LandMap[(mody * 256) + modx - 1] += 0.05f; | ||
32 | LandMap[(mody * 256) + modx] += 0.1f; | ||
33 | LandMap[(mody * 256) + modx + 1] += 0.05f; | ||
34 | LandMap[((mody + 1) * 256) + modx] += 0.05f; | ||
35 | LandMap[((mody - 1) * 256) + modx] += 0.05f; | ||
36 | } | ||
37 | RegenerateTerrain(true, modx, mody); | ||
38 | } | ||
39 | break; | ||
40 | case 2: | ||
41 | //lower terrain | ||
42 | if (modify.ParcelData.Length > 0) | ||
43 | { | ||
44 | int mody = (int)modify.ParcelData[0].North; | ||
45 | int modx = (int)modify.ParcelData[0].West; | ||
46 | lock (LandMap) | ||
47 | { | ||
48 | LandMap[(mody * 256) + modx - 1] -= 0.05f; | ||
49 | LandMap[(mody * 256) + modx] -= 0.1f; | ||
50 | LandMap[(mody * 256) + modx + 1] -= 0.05f; | ||
51 | LandMap[((mody + 1) * 256) + modx] -= 0.05f; | ||
52 | LandMap[((mody - 1) * 256) + modx] -= 0.05f; | ||
53 | } | ||
54 | RegenerateTerrain(true, modx, mody); | ||
55 | } | ||
56 | break; | ||
57 | } | ||
58 | return true; | ||
59 | } | ||
60 | |||
61 | public bool SimChat(SimClient simClient, Packet packet) | ||
62 | { | ||
63 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
64 | ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)packet; | ||
65 | if (Helpers.FieldToString(inchatpack.ChatData.Message) == "") | ||
66 | { | ||
67 | //empty message so don't bother with it | ||
68 | return true; | ||
69 | } | ||
70 | |||
71 | libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); | ||
72 | reply.ChatData.Audible = 1; | ||
73 | reply.ChatData.Message = inchatpack.ChatData.Message; | ||
74 | reply.ChatData.ChatType = 1; | ||
75 | reply.ChatData.SourceType = 1; | ||
76 | reply.ChatData.Position = simClient.ClientAvatar.Pos; | ||
77 | reply.ChatData.FromName = enc.GetBytes(simClient.ClientAvatar.firstname + " " + simClient.ClientAvatar.lastname + "\0"); | ||
78 | reply.ChatData.OwnerID = simClient.AgentID; | ||
79 | reply.ChatData.SourceID = simClient.AgentID; | ||
80 | foreach (SimClient client in m_clientThreads.Values) | ||
81 | { | ||
82 | client.OutPacket(reply); | ||
83 | } | ||
84 | return true; | ||
85 | } | ||
86 | |||
87 | public bool RezObject(SimClient simClient, Packet packet) | ||
88 | { | ||
89 | RezObjectPacket rezPacket = (RezObjectPacket)packet; | ||
90 | AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID); | ||
91 | if (inven != null) | ||
92 | { | ||
93 | if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID)) | ||
94 | { | ||
95 | AssetBase asset = this._assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID); | ||
96 | if (asset != null) | ||
97 | { | ||
98 | PrimData primd = new PrimData(asset.Data); | ||
99 | Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this); | ||
100 | nPrim.CreateFromStorage(primd, rezPacket.RezData.RayEnd, this._primCount, true); | ||
101 | this.Entities.Add(nPrim.uuid, nPrim); | ||
102 | this._primCount++; | ||
103 | this._inventoryCache.DeleteInventoryItem(simClient, rezPacket.InventoryData.ItemID); | ||
104 | } | ||
105 | } | ||
106 | } | ||
107 | return true; | ||
108 | } | ||
109 | |||
110 | public bool DeRezObject(SimClient simClient, Packet packet) | ||
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 (SimClient 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.WriteLine("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 (SimClient 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 | return true; | ||
197 | } | ||
198 | |||
199 | } | ||
200 | } | ||