aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.World/World.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/OpenSim.World/World.cs')
-rw-r--r--OpenSim/OpenSim.World/World.cs110
1 files changed, 41 insertions, 69 deletions
diff --git a/OpenSim/OpenSim.World/World.cs b/OpenSim/OpenSim.World/World.cs
index d840d10..2580761 100644
--- a/OpenSim/OpenSim.World/World.cs
+++ b/OpenSim/OpenSim.World/World.cs
@@ -6,13 +6,11 @@ using System.Text;
6using System.Reflection; 6using System.Reflection;
7using System.IO; 7using System.IO;
8using System.Threading; 8using System.Threading;
9using System.Timers;
9using OpenSim.Physics.Manager; 10using OpenSim.Physics.Manager;
10using OpenSim.Framework.Interfaces; 11using OpenSim.Framework.Interfaces;
11using OpenSim.Framework.Types; 12using OpenSim.Framework.Types;
12using OpenSim.Framework.Terrain;
13using OpenSim.Framework.Inventory; 13using OpenSim.Framework.Inventory;
14using OpenSim.Assets;
15//using OpenSim.world.scripting;
16using OpenSim.RegionServer.world.scripting; 14using OpenSim.RegionServer.world.scripting;
17using OpenSim.Terrain; 15using OpenSim.Terrain;
18 16
@@ -20,6 +18,7 @@ namespace OpenSim.world
20{ 18{
21 public partial class World : WorldBase, ILocalStorageReceiver, IScriptAPI 19 public partial class World : WorldBase, ILocalStorageReceiver, IScriptAPI
22 { 20 {
21 protected System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer();
23 public object LockPhysicsEngine = new object(); 22 public object LockPhysicsEngine = new object();
24 public Dictionary<libsecondlife.LLUUID, Avatar> Avatars; 23 public Dictionary<libsecondlife.LLUUID, Avatar> Avatars;
25 public Dictionary<libsecondlife.LLUUID, Primitive> Prims; 24 public Dictionary<libsecondlife.LLUUID, Primitive> Prims;
@@ -57,15 +56,16 @@ namespace OpenSim.world
57 /// <param name="clientThreads">Dictionary to contain client threads</param> 56 /// <param name="clientThreads">Dictionary to contain client threads</param>
58 /// <param name="regionHandle">Region Handle for this region</param> 57 /// <param name="regionHandle">Region Handle for this region</param>
59 /// <param name="regionName">Region Name for this region</param> 58 /// <param name="regionName">Region Name for this region</param>
60 public World(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regInfo, ulong regionHandle, string regionName) 59 public World(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regInfo)
61 { 60 {
62 try 61 try
63 { 62 {
64 updateLock = new Mutex(false); 63 updateLock = new Mutex(false);
65 m_clientThreads = clientThreads; 64 m_clientThreads = clientThreads;
66 m_regionHandle = regionHandle;
67 m_regionName = regionName;
68 m_regInfo = regInfo; 65 m_regInfo = regInfo;
66 m_regionHandle = m_regInfo.RegionHandle;
67 m_regionName = m_regInfo.RegionName;
68 this.m_datastore = m_regInfo.DataStore;
69 69
70 m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>(); 70 m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>();
71 m_scripts = new Dictionary<string, ScriptFactory>(); 71 m_scripts = new Dictionary<string, ScriptFactory>();
@@ -85,6 +85,8 @@ namespace OpenSim.world
85 Avatar.LoadAnims(); 85 Avatar.LoadAnims();
86 this.SetDefaultScripts(); 86 this.SetDefaultScripts();
87 this.LoadScriptEngines(); 87 this.LoadScriptEngines();
88
89
88 } 90 }
89 catch (Exception e) 91 catch (Exception e)
90 { 92 {
@@ -93,6 +95,13 @@ namespace OpenSim.world
93 } 95 }
94 #endregion 96 #endregion
95 97
98 public void StartTimer()
99 {
100 m_heartbeatTimer.Enabled = true;
101 m_heartbeatTimer.Interval = 100;
102 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
103 }
104
96 #region Script Methods 105 #region Script Methods
97 /// <summary> 106 /// <summary>
98 /// Loads a new script into the specified entity 107 /// Loads a new script into the specified entity
@@ -167,6 +176,18 @@ namespace OpenSim.world
167 #endregion 176 #endregion
168 177
169 #region Update Methods 178 #region Update Methods
179
180
181 /// <summary>
182 /// Performs per-frame updates regularly
183 /// </summary>
184 /// <param name="sender"></param>
185 /// <param name="e"></param>
186 void Heartbeat(object sender, System.EventArgs e)
187 {
188 this.Update();
189 }
190
170 /// <summary> 191 /// <summary>
171 /// Performs per-frame updates on the world, this should be the central world loop 192 /// Performs per-frame updates on the world, this should be the central world loop
172 /// </summary> 193 /// </summary>
@@ -327,7 +348,7 @@ namespace OpenSim.world
327 } 348 }
328 this.localStorage.SaveMap(this.Terrain.getHeights1D()); 349 this.localStorage.SaveMap(this.Terrain.getHeights1D());
329 350
330 foreach (ClientView client in m_clientThreads.Values) 351 foreach (IClientAPI client in m_clientThreads.Values)
331 { 352 {
332 this.SendLayerData(client); 353 this.SendLayerData(client);
333 } 354 }
@@ -358,7 +379,7 @@ namespace OpenSim.world
358 } 379 }
359 this.localStorage.SaveMap(this.Terrain.getHeights1D()); 380 this.localStorage.SaveMap(this.Terrain.getHeights1D());
360 381
361 foreach (ClientView client in m_clientThreads.Values) 382 foreach (IClientAPI client in m_clientThreads.Values)
362 { 383 {
363 this.SendLayerData(client); 384 this.SendLayerData(client);
364 } 385 }
@@ -388,7 +409,7 @@ namespace OpenSim.world
388 { 409 {
389 /* Dont save here, rely on tainting system instead */ 410 /* Dont save here, rely on tainting system instead */
390 411
391 foreach (ClientView client in m_clientThreads.Values) 412 foreach (IClientAPI client in m_clientThreads.Values)
392 { 413 {
393 this.SendLayerData(pointx, pointy, client); 414 this.SendLayerData(pointx, pointy, client);
394 } 415 }
@@ -436,23 +457,9 @@ namespace OpenSim.world
436 /// Sends prims to a client 457 /// Sends prims to a client
437 /// </summary> 458 /// </summary>
438 /// <param name="RemoteClient">Client to send to</param> 459 /// <param name="RemoteClient">Client to send to</param>
439 public void GetInitialPrims(ClientView RemoteClient) 460 public void GetInitialPrims(IClientAPI RemoteClient)
440 { 461 {
441 try 462
442 {
443 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
444 {
445 if (Entities[UUID] is Primitive)
446 {
447 Primitive primitive = Entities[UUID] as Primitive;
448 primitive.UpdateClient(RemoteClient);
449 }
450 }
451 }
452 catch (Exception e)
453 {
454 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: GetInitialPrims() - Failed with exception " + e.ToString());
455 }
456 } 463 }
457 464
458 /// <summary> 465 /// <summary>
@@ -477,67 +484,32 @@ namespace OpenSim.world
477 /// <param name="prim">The object to load</param> 484 /// <param name="prim">The object to load</param>
478 public void PrimFromStorage(PrimData prim) 485 public void PrimFromStorage(PrimData prim)
479 { 486 {
480 try 487
481 {
482 if (prim.LocalID >= this._primCount)
483 {
484 _primCount = prim.LocalID + 1;
485 }
486 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: PrimFromStorage() - Reloading prim (localId " + prim.LocalID + " ) from storage");
487 Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
488 nPrim.CreateFromStorage(prim);
489 this.Entities.Add(nPrim.uuid, nPrim);
490 }
491 catch (Exception e)
492 {
493 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: PrimFromStorage() - Failed with exception " + e.ToString());
494 }
495 } 488 }
496 489
497 public void AddNewPrim(Packet addPacket, ClientView agentClient) 490 public void AddNewPrim(Packet addPacket, IClientAPI agentClient)
498 { 491 {
499 AddNewPrim((ObjectAddPacket)addPacket, agentClient.AgentID); 492 AddNewPrim((ObjectAddPacket)addPacket, agentClient.AgentId);
500 } 493 }
501 494
502 public void AddNewPrim(ObjectAddPacket addPacket, LLUUID ownerID) 495 public void AddNewPrim(ObjectAddPacket addPacket, LLUUID ownerID)
503 { 496 {
504 try 497
505 {
506 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: AddNewPrim() - Creating new prim");
507 Primitive prim = new Primitive(m_clientThreads, m_regionHandle, this);
508 prim.CreateFromPacket(addPacket, ownerID, this._primCount);
509 PhysicsVector pVec = new PhysicsVector(prim.Pos.X, prim.Pos.Y, prim.Pos.Z);
510 PhysicsVector pSize = new PhysicsVector(0.255f, 0.255f, 0.255f);
511 if (OpenSim.world.Avatar.PhysicsEngineFlying)
512 {
513 lock (this.LockPhysicsEngine)
514 {
515 prim.PhysActor = this.phyScene.AddPrim(pVec, pSize);
516 }
517 }
518
519 this.Entities.Add(prim.uuid, prim);
520 this._primCount++;
521 }
522 catch (Exception e)
523 {
524 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: AddNewPrim() - Failed with exception " + e.ToString());
525 }
526 } 498 }
527 499
528 #endregion 500 #endregion
529 501
530 #region Add/Remove Avatar Methods 502 #region Add/Remove Avatar Methods
531 503
532 public override Avatar AddViewerAgent(ClientView agentClient) 504 public override bool AddNewAvatar(IClientAPI agentClient, bool child)
533 { 505 {
534 Avatar newAvatar = null; 506
535 return newAvatar; 507 return false;
536 } 508 }
537 509
538 public override void RemoveViewerAgent(ClientView agentClient) 510 public override bool RemoveAvatar(LLUUID agentID)
539 { 511 {
540 512 return false;
541 } 513 }
542 #endregion 514 #endregion
543 515