From f41379549773531b2886b64aaacf57c954a64610 Mon Sep 17 00:00:00 2001 From: MW Date: Mon, 25 Jun 2007 16:01:30 +0000 Subject: updated prebuild.xml. Added some more events to IClientAPI (OnGrapObject , OnGrapUpdate, OnDeGrapObject). --- OpenSim/OpenSim.Region/Caps.cs | 28 +++++-- OpenSim/OpenSim.Region/EstateManager.cs | 3 +- OpenSim/OpenSim.Region/Scenes/Primitive.cs | 45 +++++++++++- .../OpenSim.Region/Scenes/Scene.PacketHandlers.cs | 17 ++++- OpenSim/OpenSim.Region/Scenes/Scene.cs | 85 ++-------------------- OpenSim/OpenSim.Region/Scenes/SceneBase.cs | 71 ++++++++++++++++-- OpenSim/OpenSim.Region/Scenes/ScenePresence.cs | 44 +++++++---- 7 files changed, 185 insertions(+), 108 deletions(-) (limited to 'OpenSim/OpenSim.Region') diff --git a/OpenSim/OpenSim.Region/Caps.cs b/OpenSim/OpenSim.Region/Caps.cs index 9cb921b..88799a0 100644 --- a/OpenSim/OpenSim.Region/Caps.cs +++ b/OpenSim/OpenSim.Region/Caps.cs @@ -27,6 +27,7 @@ namespace OpenSim.Region private LLUUID agentID; private AssetCache assetCache; private int eventQueueCount = 1; + private Queue CapsEventQueue = new Queue(); public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent) { @@ -77,7 +78,7 @@ namespace OpenSim.Region capURLS += "MapLayerhttp://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + mapLayerPath + ""; capURLS += "NewFileAgentInventoryhttp://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + newInventory + ""; //capURLS += "RequestTextureDownloadhttp://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + requestTexture + ""; - // capURLS += "EventQueueGethttp://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + eventQueue + ""; + //capURLS += "EventQueueGethttp://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + eventQueue + ""; return capURLS; } @@ -122,9 +123,26 @@ namespace OpenSim.Region public string ProcessEventQueue(string request, string path, string param) { - // Console.WriteLine("event queue request " + request); + // Console.WriteLine("event queue request " + request); string res = ""; - res = this.CreateEmptyEventResponse(); + int timer = 0; + + /*while ((timer < 200) || (this.CapsEventQueue.Count < 1)) + { + timer++; + }*/ + if (this.CapsEventQueue.Count > 0) + { + lock (this.CapsEventQueue) + { + string item = CapsEventQueue.Dequeue(); + res = item; + } + } + else + { + res = this.CreateEmptyEventResponse(); + } return res; } @@ -141,6 +159,7 @@ namespace OpenSim.Region res += ""; res += ""; eventQueueCount++; + this.CapsEventQueue.Enqueue(res); return res; } @@ -176,7 +195,7 @@ namespace OpenSim.Region public void UploadHandler(LLUUID assetID, LLUUID inventoryItem, byte[] data) { - // Console.WriteLine("upload handler called"); + Console.WriteLine("upload handler called"); AssetBase asset; asset = new AssetBase(); asset.FullID = assetID; @@ -185,7 +204,6 @@ namespace OpenSim.Region asset.Name = "UploadedTexture" + Util.RandomClass.Next(1, 1000).ToString("000"); asset.Data = data; this.assetCache.AddAsset(asset); - } public class AssetUploader diff --git a/OpenSim/OpenSim.Region/EstateManager.cs b/OpenSim/OpenSim.Region/EstateManager.cs index fbcab33..dcb5564 100644 --- a/OpenSim/OpenSim.Region/EstateManager.cs +++ b/OpenSim/OpenSim.Region/EstateManager.cs @@ -265,6 +265,7 @@ namespace OpenSim.Region public void sendRegionInfoPacket(IClientAPI remote_client) { + Encoding _enc = System.Text.Encoding.ASCII; AgentCircuitData circuitData = remote_client.RequestClientInfo(); @@ -281,7 +282,7 @@ namespace OpenSim.Region regionInfoPacket.RegionInfo.RedirectGridY = m_regInfo.estateSettings.redirectGridY; regionInfoPacket.RegionInfo.RegionFlags = (uint)m_regInfo.estateSettings.regionFlags; regionInfoPacket.RegionInfo.SimAccess = (byte)m_regInfo.estateSettings.simAccess; - regionInfoPacket.RegionInfo.SimName = Helpers.StringToField(m_regInfo.RegionName); + regionInfoPacket.RegionInfo.SimName = _enc.GetBytes( m_regInfo.RegionName); regionInfoPacket.RegionInfo.SunHour = m_regInfo.estateSettings.sunHour; regionInfoPacket.RegionInfo.TerrainLowerLimit = m_regInfo.estateSettings.terrainLowerLimit; regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_regInfo.estateSettings.terrainRaiseLimit; diff --git a/OpenSim/OpenSim.Region/Scenes/Primitive.cs b/OpenSim/OpenSim.Region/Scenes/Primitive.cs index 62f401c..b0bfd1e 100644 --- a/OpenSim/OpenSim.Region/Scenes/Primitive.cs +++ b/OpenSim/OpenSim.Region/Scenes/Primitive.cs @@ -47,6 +47,7 @@ namespace OpenSim.Region.Scenes private const uint FULL_MASK_PERMISSIONS = 2147483647; private bool physicsEnabled = false; private byte updateFlag = 0; + private uint flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128; private Dictionary inventoryItems; @@ -411,7 +412,7 @@ namespace OpenSim.Region.Scenes lPos = this.Pos; } - remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.primData, lPos, new LLUUID("00000000-0000-0000-9999-000000000005")); + remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.primData, lPos, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags); } /// @@ -434,7 +435,7 @@ namespace OpenSim.Region.Scenes { LLVector3 lPos; Axiom.MathLib.Quaternion lRot; - if (this._physActor != null && this.physicsEnabled) + if (this._physActor != null && this.physicsEnabled) //is this needed ? doesn't the property fields do this for us? { PhysicsVector pPos = this._physActor.Position; lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); @@ -445,6 +446,8 @@ namespace OpenSim.Region.Scenes lPos = this.Pos; lRot = this.rotation; } + LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w); + RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot); } /// @@ -534,6 +537,44 @@ namespace OpenSim.Region.Scenes { } + + public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) + { + Console.WriteLine("moving prim to new location " + pos.X + " , " + pos.Y + " , " + pos.Z); + this.Pos = pos; + this.SendTerseUpdateToALLClients(); + } + + public void GetProperites(IClientAPI client) + { + //needs changing + ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); + proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; + proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); + proper.ObjectData[0].ItemID = LLUUID.Zero; + proper.ObjectData[0].CreationDate = (ulong)primData.CreationDate; + proper.ObjectData[0].CreatorID = primData.OwnerID; + proper.ObjectData[0].FolderID = LLUUID.Zero; + proper.ObjectData[0].FromTaskID = LLUUID.Zero; + proper.ObjectData[0].GroupID = LLUUID.Zero; + proper.ObjectData[0].InventorySerial = 0; + proper.ObjectData[0].LastOwnerID = LLUUID.Zero; + proper.ObjectData[0].ObjectID = this.uuid; + proper.ObjectData[0].OwnerID = primData.OwnerID; + proper.ObjectData[0].TouchName = new byte[0]; + proper.ObjectData[0].TextureID = new byte[0]; + proper.ObjectData[0].SitName = new byte[0]; + proper.ObjectData[0].Name = new byte[0]; + proper.ObjectData[0].Description = new byte[0]; + proper.ObjectData[0].OwnerMask = primData.OwnerMask; + proper.ObjectData[0].NextOwnerMask = primData.NextOwnerMask; + proper.ObjectData[0].GroupMask = primData.GroupMask; + proper.ObjectData[0].EveryoneMask = primData.EveryoneMask; + proper.ObjectData[0].BaseMask = primData.BaseMask; + + client.OutPacket(proper); + + } #endregion diff --git a/OpenSim/OpenSim.Region/Scenes/Scene.PacketHandlers.cs b/OpenSim/OpenSim.Region/Scenes/Scene.PacketHandlers.cs index 01e38d5..d1a2717 100644 --- a/OpenSim/OpenSim.Region/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/OpenSim.Region/Scenes/Scene.PacketHandlers.cs @@ -214,7 +214,22 @@ namespace OpenSim.Region.Scenes /// public void SelectPrim(uint primLocalID, IClientAPI remoteClient) { - + foreach (Entity ent in Entities.Values) + { + if (ent.LocalId == primLocalID) + { + ((OpenSim.Region.Scenes.Primitive)ent).GetProperites(remoteClient); + break; + } + } + } + + public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) + { + if (this.Entities.ContainsKey(objectID)) + { + ((Primitive)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient); + } } /// diff --git a/OpenSim/OpenSim.Region/Scenes/Scene.cs b/OpenSim/OpenSim.Region/Scenes/Scene.cs index 62edc4b..426dd50 100644 --- a/OpenSim/OpenSim.Region/Scenes/Scene.cs +++ b/OpenSim/OpenSim.Region/Scenes/Scene.cs @@ -57,19 +57,18 @@ namespace OpenSim.Region.Scenes protected Dictionary Prims; private PhysicsScene phyScene; private float timeStep = 0.1f; - public ILocalStorage localStorage; private Random Rand = new Random(); private uint _primCount = 702000; private int storageCount; private Dictionary m_scriptHandlers; private Dictionary m_scripts; private Mutex updateLock; - public string m_datastore; + protected AuthenticateSessionsBase authenticateHandler; protected RegionCommsListener regionCommsHost; protected CommunicationsManager commsManager; - protected List capsHandlers = new List(); + protected Dictionary capsHandlers = new Dictionary(); protected BaseHttpServer httpListener; public ParcelManager parcelManager; @@ -127,7 +126,6 @@ namespace OpenSim.Region.Scenes Prims = new Dictionary(); OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs - creating LandMap"); - TerrainManager = new TerrainManager(new SecondLife()); Terrain = new TerrainEngine(); ScenePresence.LoadAnims(); @@ -271,53 +269,6 @@ namespace OpenSim.Region.Scenes } #endregion - #region Setup Methods - /// - /// Loads a new storage subsystem from a named library - /// - /// Storage Library - /// Successful or not - public bool LoadStorageDLL(string dllName) - { - try - { - Assembly pluginAssembly = Assembly.LoadFrom(dllName); - ILocalStorage store = null; - - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("ILocalStorage", true); - - if (typeInterface != null) - { - ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - store = plug; - - store.Initialise(this.m_datastore); - break; - } - - typeInterface = null; - } - } - } - pluginAssembly = null; - this.localStorage = store; - return (store == null); - } - catch (Exception e) - { - OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: LoadStorageDLL() - Failed with exception " + e.ToString()); - return false; - } - } - - #endregion - #region Regenerate Terrain /// @@ -558,6 +509,8 @@ namespace OpenSim.Region.Scenes remoteClient.OnUpdatePrimPosition += this.UpdatePrimPosition; remoteClient.OnRequestMapBlocks += this.RequestMapBlocks; remoteClient.OnTeleportLocationRequest += this.RequestTeleportLocation; + //remoteClient.OnObjectSelect += this.SelectPrim; + remoteClient.OnGrapUpdate += this.MoveObject; /* remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest); remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest); @@ -680,22 +633,6 @@ namespace OpenSim.Region.Scenes } #endregion - #region ShutDown - /// - /// Tidy before shutdown - /// - public override void Close() - { - try - { - this.localStorage.ShutDown(); - } - catch (Exception e) - { - OpenSim.Framework.Console.MainLog.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "World.cs: Close() - Failed with exception " + e.ToString()); - } - } - #endregion #region RegionCommsHost @@ -729,7 +666,7 @@ namespace OpenSim.Region.Scenes //Console.WriteLine("new user, so creating caps handler for it"); Caps cap = new Caps(this.assetCache, httpListener, this.m_regInfo.CommsIPListenAddr, 9000, agent.CapsPath, agent.AgentID); cap.RegisterHandlers(); - this.capsHandlers.Add(cap); + this.capsHandlers.Add(agent.AgentID, cap); } this.authenticateHandler.AddNewCircuit(agent.circuitcode, agent); } @@ -767,6 +704,7 @@ namespace OpenSim.Region.Scenes agent.child = true; this.commsManager.InterRegion.InformRegionOfChildAgent(neighbours[i].RegionHandle, agent); remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr), (ushort)neighbours[i].CommsIPListenPort); + //this.capsHandlers[remoteClient.AgentId].CreateEstablishAgentComms("", System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr) + ":" + neighbours[i].CommsIPListenPort); } } } @@ -845,16 +783,5 @@ namespace OpenSim.Region.Scenes } #endregion - - /// - /// - /// - /// - /// - /// - public override void SendLayerData(int px, int py, IClientAPI RemoteClient) - { - RemoteClient.SendLayerData(px, py, Terrain.getHeights1D()); - } } } diff --git a/OpenSim/OpenSim.Region/Scenes/SceneBase.cs b/OpenSim/OpenSim.Region/Scenes/SceneBase.cs index e650127..4dbd374 100644 --- a/OpenSim/OpenSim.Region/Scenes/SceneBase.cs +++ b/OpenSim/OpenSim.Region/Scenes/SceneBase.cs @@ -51,8 +51,11 @@ namespace OpenSim.Region.Scenes protected string m_regionName; protected RegionInfo m_regInfo; - public TerrainEngine Terrain; //TODO: Replace TerrainManager with this. - protected libsecondlife.TerrainManager TerrainManager; // To be referenced via TerrainEngine + public TerrainEngine Terrain; + + public string m_datastore; + public ILocalStorage localStorage; + protected object m_syncRoot = new object(); private uint m_nextLocalId = 8880000; protected AssetCache assetCache; @@ -71,6 +74,51 @@ namespace OpenSim.Region.Scenes /// Loads the World heightmap /// public abstract void LoadWorldMap(); + + /// + /// Loads a new storage subsystem from a named library + /// + /// Storage Library + /// Successful or not + public bool LoadStorageDLL(string dllName) + { + try + { + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + ILocalStorage store = null; + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("ILocalStorage", true); + + if (typeInterface != null) + { + ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + store = plug; + + store.Initialise(this.m_datastore); + break; + } + + typeInterface = null; + } + } + } + pluginAssembly = null; + this.localStorage = store; + return (store == null); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainLog.Instance.Warn("World.cs: LoadStorageDLL() - Failed with exception " + e.ToString()); + return false; + } + } + /// /// Send the region heightmap to the client @@ -87,7 +135,10 @@ namespace OpenSim.Region.Scenes /// Patch coordinate (x) 0..16 /// Patch coordinate (y) 0..16 /// The client to send to - public abstract void SendLayerData(int px, int py, IClientAPI RemoteClient); + public virtual void SendLayerData(int px, int py, IClientAPI RemoteClient) + { + RemoteClient.SendLayerData(px, py, Terrain.getHeights1D()); + } #endregion @@ -114,7 +165,7 @@ namespace OpenSim.Region.Scenes /// public virtual RegionInfo RegionInfo { - get { return null; } + get { return this.m_regInfo; } } public object SyncRoot @@ -131,7 +182,17 @@ namespace OpenSim.Region.Scenes /// /// Tidy before shutdown /// - public abstract void Close(); + public virtual void Close() + { + try + { + this.localStorage.ShutDown(); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainLog.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "World.cs: Close() - Failed with exception " + e.ToString()); + } + } #endregion diff --git a/OpenSim/OpenSim.Region/Scenes/ScenePresence.cs b/OpenSim/OpenSim.Region/Scenes/ScenePresence.cs index e2e30b9..ffec3e5 100644 --- a/OpenSim/OpenSim.Region/Scenes/ScenePresence.cs +++ b/OpenSim/OpenSim.Region/Scenes/ScenePresence.cs @@ -223,26 +223,23 @@ namespace OpenSim.Region.Scenes Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); if (((movementflag & 1) == 0) || (q != this.bodyRot)) { - //we should add a new force to the list - // but for now we will deal with velocities - NewForce newVelocity = new NewForce(); Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0); - Axiom.MathLib.Vector3 direc = q * v3; - direc.Normalize(); - - //work out velocity for sim physics system - direc = direc * ((0.03f) * 128f); - if (this._physActor.Flying) - direc *= 4; - - newVelocity.X = direc.x; - newVelocity.Y = direc.y; - newVelocity.Z = direc.z; - this.forcesList.Add(newVelocity); + this.AddNewMovement(v3, q); movementflag = 1; this.bodyRot = q; } } + else if ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG) != 0) + { + Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); + if (((movementflag & 2) == 0) || (q != this.bodyRot)) + { + Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(-1, 0, 0); + this.AddNewMovement(v3, q); + movementflag = 2; + this.bodyRot = q; + } + } else { if ((movementflag) != 0) @@ -257,6 +254,23 @@ namespace OpenSim.Region.Scenes } } + + protected void AddNewMovement(Axiom.MathLib.Vector3 vec, Axiom.MathLib.Quaternion rotation) + { + NewForce newVelocity = new NewForce(); + Axiom.MathLib.Vector3 direc = rotation * vec; + direc.Normalize(); + + direc = direc * ((0.03f) * 128f); + if (this._physActor.Flying) + direc *= 4; + + newVelocity.X = direc.x; + newVelocity.Y = direc.y; + newVelocity.Z = direc.z; + this.forcesList.Add(newVelocity); + } + #endregion #region Overridden Methods -- cgit v1.1