aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/world/World.cs
diff options
context:
space:
mode:
authorMW2007-04-04 18:26:33 +0000
committerMW2007-04-04 18:26:33 +0000
commitd3766d0aef46c53b9e92afa77ffaa33817c7a04a (patch)
tree6e93d5ac3a70e38ce68d2694f0e0fbec68633e6c /OpenSim.RegionServer/world/World.cs
parentSplit Avatar class into three partial classes (hopefully will make it easier ... (diff)
downloadopensim-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 'OpenSim.RegionServer/world/World.cs')
-rw-r--r--OpenSim.RegionServer/world/World.cs224
1 files changed, 29 insertions, 195 deletions
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
18namespace OpenSim.world 18namespace 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}