From ccfddd1775fe2786ad54b7bbfe528e7eb65170b1 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 27 Mar 2007 19:12:55 +0000 Subject: * Continued refactoring away OpenSimRoot - now it's down to the final 2. --- OpenSim.RegionServer/world/Avatar.cs | 39 ++++++++++++++++++++------------- OpenSim.RegionServer/world/Primitive.cs | 27 ++++++++++++++--------- OpenSim.RegionServer/world/World.cs | 33 ++++++++++++++++++---------- 3 files changed, 63 insertions(+), 36 deletions(-) (limited to 'OpenSim.RegionServer/world') diff --git a/OpenSim.RegionServer/world/Avatar.cs b/OpenSim.RegionServer/world/Avatar.cs index 75f2cff..2ae9992 100644 --- a/OpenSim.RegionServer/world/Avatar.cs +++ b/OpenSim.RegionServer/world/Avatar.cs @@ -30,14 +30,23 @@ namespace OpenSim.world private byte[] visualParams; private AvatarWearable[] Wearables; private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); + private World m_world; + private ulong m_regionHandle; + private Dictionary m_clientThreads; + private string m_regionName; - public Avatar(SimClient TheClient) + public Avatar(SimClient TheClient, World world, string regionName, Dictionary clientThreads, ulong regionHandle) { + m_world = world; + m_clientThreads = clientThreads; + m_regionName = regionName; + m_regionHandle = regionHandle; + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); ControllingClient = TheClient; - localid = 8880000 + (OpenSimRoot.Instance.LocalWorld._localNumber++); + localid = 8880000 + (m_world._localNumber++); position = new LLVector3(100.0f, 100.0f, 30.0f); - position.Z = OpenSimRoot.Instance.LocalWorld.LandMap[(int)position.Y * 256 + (int)position.X] + 1; + position.Z = m_world.LandMap[(int)position.Y * 256 + (int)position.X] + 1; visualParams = new byte[218]; for (int i = 0; i < 218; i++) { @@ -52,7 +61,7 @@ namespace OpenSim.world this.Wearables[0].ItemID = LLUUID.Random(); this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); - + } public PhysicsActor PhysActor @@ -96,11 +105,11 @@ namespace OpenSim.world //use CreateTerseBlock() ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); - terse.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; // FIXME + terse.RegionData.RegionHandle = m_regionHandle; // FIXME terse.RegionData.TimeDilation = 64096; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; terse.ObjectData[0] = terseBlock; - foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + foreach (SimClient client in m_clientThreads.Values) { client.OutPacket(terse); } @@ -119,11 +128,11 @@ namespace OpenSim.world //It has been a while since last update was sent so lets send one. ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); - terse.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; // FIXME + terse.RegionData.RegionHandle = m_regionHandle; // FIXME terse.RegionData.TimeDilation = 64096; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; terse.ObjectData[0] = terseBlock; - foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + foreach (SimClient client in m_clientThreads.Values) { client.OutPacket(terse); } @@ -172,7 +181,7 @@ namespace OpenSim.world AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); mov.AgentData.SessionID = this.ControllingClient.SessionID; mov.AgentData.AgentID = this.ControllingClient.AgentID; - mov.Data.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; + mov.Data.RegionHandle = m_regionHandle; // TODO - dynamicalise this stuff mov.Data.Timestamp = 1172750370; mov.Data.Position = new LLVector3(100f, 100f, 23f); @@ -187,7 +196,7 @@ namespace OpenSim.world System.Text.Encoding _enc = System.Text.Encoding.ASCII; //send a objectupdate packet with information about the clients avatar ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; + objupdate.RegionData.RegionHandle = m_regionHandle; objupdate.RegionData.TimeDilation = 64096; objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; @@ -202,9 +211,9 @@ namespace OpenSim.world byte[] pb = pos2.GetBytes(); Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); - OpenSimRoot.Instance.LocalWorld._localNumber++; + m_world._localNumber++; - foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + foreach (SimClient client in m_clientThreads.Values) { client.OutPacket(objupdate); if (client.AgentID != ControllingClient.AgentID) @@ -241,7 +250,7 @@ namespace OpenSim.world System.Text.Encoding _enc = System.Text.Encoding.ASCII; //send a objectupdate packet with information about the clients avatar ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; + objupdate.RegionData.RegionHandle = m_regionHandle; objupdate.RegionData.TimeDilation = 64096; objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; @@ -293,7 +302,7 @@ namespace OpenSim.world this.visualParams[i] = appear.VisualParam[i].ParamValue; } - foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + foreach (SimClient client in m_clientThreads.Values) { if (client.AgentID != ControllingClient.AgentID) { @@ -490,7 +499,7 @@ namespace OpenSim.world handshake.RegionInfo.SimAccess = 13; handshake.RegionInfo.WaterHeight = 20; handshake.RegionInfo.RegionFlags = 72458694; - handshake.RegionInfo.SimName = _enc.GetBytes(OpenSimRoot.Instance.Cfg.RegionName + "\0"); + handshake.RegionInfo.SimName = _enc.GetBytes(m_regionName + "\0"); handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000"); handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); diff --git a/OpenSim.RegionServer/world/Primitive.cs b/OpenSim.RegionServer/world/Primitive.cs index 6ff66a3..a185f0b 100644 --- a/OpenSim.RegionServer/world/Primitive.cs +++ b/OpenSim.RegionServer/world/Primitive.cs @@ -22,6 +22,9 @@ namespace OpenSim.world private PhysicsActor _physActor; private bool physicsEnabled = false; private bool physicstest = false; //just added for testing + private Dictionary m_clientThreads; + private ulong m_regionHandle; + private World m_world; public bool PhysicsEnabled { @@ -65,10 +68,14 @@ namespace OpenSim.world } } - public Primitive() + public Primitive(Dictionary clientThreads, ulong regionHandle, World world) { mesh_cutbegin = 0.0f; mesh_cutend = 1.0f; + + m_clientThreads = clientThreads; + m_regionHandle = regionHandle; + m_world = world; } public override Mesh getMesh() @@ -99,7 +106,7 @@ namespace OpenSim.world { if (this.newPrimFlag) { - foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + foreach (SimClient client in m_clientThreads.Values) { client.OutPacket(OurPacket); } @@ -108,11 +115,11 @@ namespace OpenSim.world else if (this.updateFlag) { ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); - terse.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; // FIXME + terse.RegionData.RegionHandle = m_regionHandle; // FIXME terse.RegionData.TimeDilation = 64096; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; terse.ObjectData[0] = this.CreateImprovedBlock(); - foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + foreach (SimClient client in m_clientThreads.Values) { client.OutPacket(terse); } @@ -120,7 +127,7 @@ namespace OpenSim.world } else if (this.dirtyFlag) { - foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + foreach (SimClient client in m_clientThreads.Values) { UpdateClient(client); } @@ -131,11 +138,11 @@ namespace OpenSim.world if (this._physActor != null && this.physicsEnabled) { ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); - terse.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; // FIXME + terse.RegionData.RegionHandle = m_regionHandle; // FIXME terse.RegionData.TimeDilation = 64096; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; terse.ObjectData[0] = this.CreateImprovedBlock(); - foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + foreach (SimClient client in m_clientThreads.Values) { client.OutPacket(terse); } @@ -255,7 +262,7 @@ namespace OpenSim.world public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID) { ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; + objupdate.RegionData.RegionHandle = m_regionHandle; objupdate.RegionData.TimeDilation = 64096; objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; @@ -323,7 +330,7 @@ namespace OpenSim.world { //need to clean this up as it shares a lot of code with CreateFromPacket() ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); - objupdate.RegionData.RegionHandle = OpenSimRoot.Instance.Cfg.RegionHandle; + objupdate.RegionData.RegionHandle = m_regionHandle; objupdate.RegionData.TimeDilation = 64096; objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; @@ -480,7 +487,7 @@ namespace OpenSim.world this.primData.LocalID = this.localid; this.primData.Position = this.position; this.primData.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z, this.rotation.w); - OpenSimRoot.Instance.LocalWorld.localStorage.StorePrim(this.primData); + m_world.localStorage.StorePrim(this.primData); } } diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs index e6d8921..7605f9e 100644 --- a/OpenSim.RegionServer/world/World.cs +++ b/OpenSim.RegionServer/world/World.cs @@ -25,10 +25,21 @@ namespace OpenSim.world private Random Rand = new Random(); private uint _primCount = 702000; private int storageCount; + private Dictionary m_clientThreads; + private ulong m_regionHandle; + private World m_world; + private string m_regionName; + private SimConfig m_cfg; - public World() + public World(Dictionary clientThreads, ulong regionHandle, World world, string regionName, SimConfig cfg) { - OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance"); + m_clientThreads = clientThreads; + m_regionHandle = regionHandle; + m_world = world; + m_regionName = regionName; + m_cfg = cfg; + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance"); Entities = new Dictionary(); OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating LandMap"); @@ -115,9 +126,9 @@ namespace OpenSim.world HeightmapGenHills hills = new HeightmapGenHills(); this.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false); this.phyScene.SetTerrain(this.LandMap); - OpenSimRoot.Instance.Cfg.SaveMap(this.LandMap); + m_cfg.SaveMap(this.LandMap); - foreach(SimClient client in OpenSimRoot.Instance.ClientThreads.Values) { + foreach(SimClient client in m_clientThreads.Values) { this.SendLayerData(client); } } @@ -134,7 +145,7 @@ namespace OpenSim.world _primCount = prim.LocalID + 1; } OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Reloading prim (localId "+ prim.LocalID+ " ) from storage"); - Primitive nPrim = new Primitive(); + Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, m_world); nPrim.CreateFromStorage(prim); this.Entities.Add(nPrim.uuid, nPrim); } @@ -175,7 +186,7 @@ namespace OpenSim.world public void AddViewerAgent(SimClient AgentClient) { OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); - Avatar NewAvatar = new Avatar(AgentClient); + Avatar NewAvatar = new Avatar(AgentClient, m_world, m_regionName, m_clientThreads, m_regionHandle ); OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); NewAvatar.SendRegionHandshake(this); @@ -187,7 +198,7 @@ namespace OpenSim.world public void AddNewPrim(ObjectAddPacket addPacket, SimClient AgentClient) { OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim"); - Primitive prim = new Primitive(); + Primitive prim = new Primitive(m_clientThreads, m_regionHandle, m_world ); prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount); PhysicsVector pVec = new PhysicsVector(prim.position.X, prim.position.Y, prim.position.Z); PhysicsVector pSize = new PhysicsVector( 0.255f, 0.255f, 0.255f); @@ -210,7 +221,7 @@ namespace OpenSim.world foreach( DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData ) { //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); - foreach (Entity ent in OpenSimRoot.Instance.LocalWorld.Entities.Values) + foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == Data.ObjectLocalID) { @@ -220,7 +231,7 @@ namespace OpenSim.world kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); kill.ObjectData[0].ID = ent.localid; - foreach (SimClient client in OpenSimRoot.Instance.ClientThreads.Values) + foreach (SimClient client in m_clientThreads.Values) { client.OutPacket(kill); } @@ -234,9 +245,9 @@ namespace OpenSim.world } foreach( libsecondlife.LLUUID uuid in DeRezEnts ) { - lock (OpenSimRoot.Instance.LocalWorld.Entities) + lock (m_world.Entities) { - OpenSimRoot.Instance.LocalWorld.Entities.Remove(uuid); + m_world.Entities.Remove(uuid); } } -- cgit v1.1