From 016a648a3097b452f63b82af533e92c549ce0ca6 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 4 Sep 2009 20:19:34 -0400 Subject: * Fixes various quirks rezzing in virtual regions. * Breaks up the Client event registrations in Scene into methods of similar event types. The generic event registration registers all of the event types. *Created symmetrical Un-Registration methods. * Made the Registration and Unregistration methods public * Hooks The events required for creating new prim and rezzing new prim into the proper scene. --- .../CoreModules/World/Land/RegionCombinerModule.cs | 248 ++++++++++++++----- OpenSim/Region/Framework/Scenes/Scene.cs | 268 ++++++++++++++++++--- 2 files changed, 434 insertions(+), 82 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs index 5c5f164..91d736b 100644 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs @@ -32,6 +32,7 @@ using log4net; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Framework.Client; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -71,6 +72,18 @@ namespace OpenSim.Region.CoreModules.World.Land public void AddRegion(Scene scene) { + + + } + + public void RemoveRegion(Scene scene) + { + + + } + + public void RegionLoaded(Scene scene) + { if (!enabledYN) return; @@ -295,8 +308,8 @@ namespace OpenSim.Region.CoreModules.World.Land m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", conn.RegionScene.RegionInfo.RegionName, regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); - - + + scene.BordersLocked = true; conn.RegionScene.BordersLocked = true; @@ -325,9 +338,11 @@ namespace OpenSim.Region.CoreModules.World.Land // scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); - + conn.RegionScene.BordersLocked = false; scene.BordersLocked = false; + if (conn.ClientEventForwarder != null) + conn.ClientEventForwarder.AddSceneToEventForwarding(scene); connectedYN = true; break; } @@ -367,7 +382,7 @@ namespace OpenSim.Region.CoreModules.World.Land m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", conn.RegionScene.RegionInfo.RegionName, regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); - conn.RegionScene.PhysicsScene.Combine(null,Vector3.Zero,extents); + conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); lock (conn.RegionScene.NorthBorders) @@ -386,7 +401,8 @@ namespace OpenSim.Region.CoreModules.World.Land scene.BordersLocked = false; conn.RegionScene.BordersLocked = false; - + if (conn.ClientEventForwarder != null) + conn.ClientEventForwarder.AddSceneToEventForwarding(scene); connectedYN = true; break; } @@ -424,52 +440,52 @@ namespace OpenSim.Region.CoreModules.World.Land m_log.DebugFormat("Scene: {0} to the NorthEast of Scene{1} Offset: {2}. Extents:{3}", conn.RegionScene.RegionInfo.RegionName, regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); - + conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); lock (conn.RegionScene.NorthBorders) - if (conn.RegionScene.NorthBorders.Count == 1)// && 2) - { - //compound border - // already locked above - conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; + if (conn.RegionScene.NorthBorders.Count == 1)// && 2) + { + //compound border + // already locked above + conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; - lock (conn.RegionScene.EastBorders) - conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; - lock (conn.RegionScene.WestBorders) - conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock (conn.RegionScene.EastBorders) + conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock (conn.RegionScene.WestBorders) + conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; - - } + + } lock (scene.SouthBorders) scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south - + lock (conn.RegionScene.EastBorders) - if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) - { + if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) + { - conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; - lock (conn.RegionScene.NorthBorders) - conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; - lock (conn.RegionScene.SouthBorders) - conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; + conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; + lock (conn.RegionScene.NorthBorders) + conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock (conn.RegionScene.SouthBorders) + conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; - - } + + } lock (scene.WestBorders) scene.WestBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport West -/* - else - { - conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; - conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; - conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; - scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south - } -*/ - + /* + else + { + conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; + conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; + conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; + scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south + } + */ + // Reset Terrain.. since terrain normally loads first. //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); @@ -478,6 +494,9 @@ namespace OpenSim.Region.CoreModules.World.Land scene.BordersLocked = false; conn.RegionScene.BordersLocked = false; + if (conn.ClientEventForwarder != null) + conn.ClientEventForwarder.AddSceneToEventForwarding(scene); + connectedYN = true; //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); @@ -495,7 +514,7 @@ namespace OpenSim.Region.CoreModules.World.Land rdata.RegionScene = scene; regionConnections.RegionLandChannel = scene.LandChannel; - RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata,scene.LandChannel,regionConnections.ConnectedRegions); + RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, regionConnections.ConnectedRegions); scene.LandChannel = lnd; lock (m_regions) { @@ -504,24 +523,14 @@ namespace OpenSim.Region.CoreModules.World.Land ForwardPermissionRequests(regionConnections, r.RegionScene); } } - - m_regions.Add(scene.RegionInfo.originRegionID,regionConnections); + + regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections); + + m_regions.Add(scene.RegionInfo.originRegionID, regionConnections); } - + } AdjustLargeRegionBounds(); - - } - - public void RemoveRegion(Scene scene) - { - - - } - - public void RegionLoaded(Scene scene) - { - } public void PostInitialise() @@ -733,6 +742,7 @@ namespace OpenSim.Region.CoreModules.World.Land public int YEnd; public List ConnectedRegions; public RegionCombinerPermissionModule PermissionModule; + public RegionCombinerClientEventForwarder ClientEventForwarder; public void UpdateExtents(Vector3 extents) { XEnd = (int)extents.X; @@ -790,7 +800,7 @@ namespace OpenSim.Region.CoreModules.World.Land else { int offsetX = (x / (int)Constants.RegionSize); - int offsetY = (x / (int)Constants.RegionSize); + int offsetY = (y / (int)Constants.RegionSize); offsetX *= (int)Constants.RegionSize; offsetY *= (int)Constants.RegionSize; @@ -823,7 +833,7 @@ namespace OpenSim.Region.CoreModules.World.Land else { int offsetX = (int)(x/(int) Constants.RegionSize); - int offsetY = (int)(x/(int) Constants.RegionSize); + int offsetY = (int)(y/(int) Constants.RegionSize); offsetX *= (int) Constants.RegionSize; offsetY *= (int) Constants.RegionSize; @@ -886,6 +896,7 @@ namespace OpenSim.Region.CoreModules.World.Land m_rootScene = RootScene; } + #region Permission Override public bool BypassPermissions() { return m_rootScene.Permissions.BypassPermissions(); @@ -1110,5 +1121,132 @@ namespace OpenSim.Region.CoreModules.World.Land { return m_rootScene.Permissions.CanUseObjectReturn(landdata, type, client, retlist); } + #endregion + } + + public class RegionCombinerClientEventForwarder + { + private Scene m_rootScene; + private Dictionary m_virtScene = new Dictionary(); + private Dictionary m_forwarders = new Dictionary(); + public RegionCombinerClientEventForwarder(RegionConnections rootScene) + { + m_rootScene = rootScene.RegionScene; + + + } + + public void AddSceneToEventForwarding( Scene virtualScene ) + { + lock (m_virtScene) + { + if (m_virtScene.ContainsKey(virtualScene.RegionInfo.originRegionID)) + { + m_virtScene[virtualScene.RegionInfo.originRegionID] = virtualScene; + } + else + { + m_virtScene.Add(virtualScene.RegionInfo.originRegionID, virtualScene); + } + } + + lock (m_forwarders) + { + // TODO: Fix this to unregister if this happens + if (m_forwarders.ContainsKey(virtualScene.RegionInfo.originRegionID)) + m_forwarders.Remove(virtualScene.RegionInfo.originRegionID); + + RegionCombinerModuleIndividualForwarder forwarder = + new RegionCombinerModuleIndividualForwarder(m_rootScene, virtualScene); + m_forwarders.Add(virtualScene.RegionInfo.originRegionID, forwarder); + + virtualScene.EventManager.OnNewClient += forwarder.ClientConnect; + virtualScene.EventManager.OnClientClosed += forwarder.ClientClosed; + } + } + + public void RemoveSceneFromEventForwarding (Scene virtualScene) + { + lock (m_forwarders) + { + RegionCombinerModuleIndividualForwarder forwarder = m_forwarders[virtualScene.RegionInfo.originRegionID]; + virtualScene.EventManager.OnNewClient -= forwarder.ClientConnect; + virtualScene.EventManager.OnClientClosed -= forwarder.ClientClosed; + m_forwarders.Remove(virtualScene.RegionInfo.originRegionID); + } + lock (m_virtScene) + { + if (m_virtScene.ContainsKey(virtualScene.RegionInfo.originRegionID)) + { + m_virtScene.Remove(virtualScene.RegionInfo.originRegionID); + } + } + } + } + + public class RegionCombinerModuleIndividualForwarder + { + private Scene m_rootScene; + private Scene m_virtScene; + public RegionCombinerModuleIndividualForwarder(Scene rootScene, Scene virtScene) + { + m_rootScene = rootScene; + m_virtScene = virtScene; + } + + public void ClientConnect(IClientAPI client) + { + + m_virtScene.UnSubscribeToClientPrimEvents(client); + m_virtScene.UnSubscribeToClientPrimRezEvents(client); + m_virtScene.UnSubscribeToClientInventoryEvents(client); + m_virtScene.UnSubscribeToClientAttachmentEvents(client); + m_virtScene.UnSubscribeToClientTeleportEvents(client); + m_virtScene.UnSubscribeToClientScriptEvents(client); + m_virtScene.UnSubscribeToClientGodEvents(client); + m_virtScene.UnSubscribeToClientNetworkEvents(client); + + m_rootScene.SubscribeToClientPrimEvents(client); + client.OnAddPrim += LocalAddNewPrim; + client.OnRezObject += LocalRezObject; + m_rootScene.SubscribeToClientInventoryEvents(client); + m_rootScene.SubscribeToClientAttachmentEvents(client); + m_rootScene.SubscribeToClientTeleportEvents(client); + m_rootScene.SubscribeToClientScriptEvents(client); + m_rootScene.SubscribeToClientGodEvents(client); + m_rootScene.SubscribeToClientNetworkEvents(client); + } + public void ClientClosed(UUID clientid, Scene scene) + { + + } + + + private void LocalRezObject(IClientAPI remoteclient, UUID itemid, Vector3 rayend, Vector3 raystart, UUID raytargetid, byte bypassraycast, bool rayendisintersection, bool rezselected, bool removeitem, UUID fromtaskid) + { + int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX; + int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY; + rayend.X += differenceX * (int)Constants.RegionSize; + rayend.Y += differenceY * (int)Constants.RegionSize; + raystart.X += differenceX * (int)Constants.RegionSize; + raystart.Y += differenceY * (int)Constants.RegionSize; + + m_rootScene.RezObject(remoteclient, itemid, rayend, raystart, raytargetid, bypassraycast, + rayendisintersection, rezselected, removeitem, fromtaskid); + + } + + private void LocalAddNewPrim(UUID ownerid, UUID groupid, Vector3 rayend, Quaternion rot, PrimitiveBaseShape shape, byte bypassraycast, Vector3 raystart, UUID raytargetid, byte rayendisintersection) + { + int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX; + int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY; + rayend.X += differenceX * (int)Constants.RegionSize; + rayend.Y += differenceY * (int)Constants.RegionSize; + raystart.X += differenceX * (int)Constants.RegionSize; + raystart.Y += differenceY * (int)Constants.RegionSize; + m_rootScene.AddNewPrim(ownerid, groupid, rayend, rot, shape, bypassraycast, raystart, raytargetid, + rayendisintersection); + + } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 1d0da4c..c25ae10 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2365,14 +2365,40 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerOnNewClient(client); } + + /// /// Register for events from the client /// /// The IClientAPI of the connected client - protected virtual void SubscribeToClientEvents(IClientAPI client) + public virtual void SubscribeToClientEvents(IClientAPI client) + { + SubscribeToClientTerrainEvents(client); + SubscribeToClientPrimEvents(client); + SubscribeToClientPrimRezEvents(client); + SubscribeToClientInventoryEvents(client); + SubscribeToClientAttachmentEvents(client); + SubscribeToClientTeleportEvents(client); + SubscribeToClientScriptEvents(client); + SubscribeToClientParcelEvents(client); + SubscribeToClientGridEvents(client); + SubscribeToClientGodEvents(client); + + SubscribeToClientNetworkEvents(client); + + + // EventManager.TriggerOnNewClient(client); + } + + public virtual void SubscribeToClientTerrainEvents(IClientAPI client) { client.OnRegionHandShakeReply += SendLayerData; - client.OnAddPrim += AddNewPrim; + client.OnUnackedTerrain += TerrainUnAcked; + } + + public virtual void SubscribeToClientPrimEvents(IClientAPI client) + { + client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimPosition; client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimRotation; @@ -2384,8 +2410,6 @@ namespace OpenSim.Region.Framework.Scenes client.OnUpdateExtraParams += m_sceneGraph.UpdateExtraParam; client.OnUpdatePrimShape += m_sceneGraph.UpdatePrimShape; client.OnUpdatePrimTexture += m_sceneGraph.UpdatePrimTexture; - client.OnTeleportLocationRequest += RequestTeleportLocation; - client.OnTeleportLandmarkRequest += RequestTeleportLandmark; client.OnObjectRequest += RequestPrim; client.OnObjectSelect += SelectPrim; client.OnObjectDeselect += DeselectPrim; @@ -2393,15 +2417,7 @@ namespace OpenSim.Region.Framework.Scenes client.OnSpinStart += m_sceneGraph.SpinStart; client.OnSpinUpdate += m_sceneGraph.SpinObject; client.OnDeRezObject += DeRezObject; - client.OnRezObject += RezObject; - client.OnRezSingleAttachmentFromInv += RezSingleAttachment; - client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments; - client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv; - client.OnObjectAttach += m_sceneGraph.AttachObject; - client.OnObjectDetach += m_sceneGraph.DetachObject; - client.OnObjectDrop += m_sceneGraph.DropObject; - client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; - client.OnObjectDescription += m_sceneGraph.PrimDescription; + client.OnObjectName += m_sceneGraph.PrimName; client.OnObjectClickAction += m_sceneGraph.PrimClickAction; client.OnObjectMaterial += m_sceneGraph.PrimMaterial; @@ -2412,7 +2428,24 @@ namespace OpenSim.Region.Framework.Scenes client.OnUpdatePrimFlags += m_sceneGraph.UpdatePrimFlags; client.OnRequestObjectPropertiesFamily += m_sceneGraph.RequestObjectPropertiesFamily; client.OnObjectPermissions += HandleObjectPermissionsUpdate; + client.OnGrabObject += ProcessObjectGrab; + client.OnDeGrabObject += ProcessObjectDeGrab; + client.OnUndo += m_sceneGraph.HandleUndo; + client.OnObjectDescription += m_sceneGraph.PrimDescription; + client.OnObjectDrop += m_sceneGraph.DropObject; + client.OnObjectSaleInfo += ObjectSaleInfo; + client.OnObjectIncludeInSearch += m_sceneGraph.MakeObjectSearchable; + client.OnObjectOwner += ObjectOwner; + } + + public virtual void SubscribeToClientPrimRezEvents(IClientAPI client) + { + client.OnAddPrim += AddNewPrim; + client.OnRezObject += RezObject; + } + public virtual void SubscribeToClientInventoryEvents(IClientAPI client) + { client.OnCreateNewInventoryItem += CreateNewInventoryItem; client.OnCreateNewInventoryFolder += HandleCreateInventoryFolder; client.OnUpdateInventoryFolder += HandleUpdateInventoryFolder; @@ -2430,36 +2463,217 @@ namespace OpenSim.Region.Framework.Scenes client.OnRemoveTaskItem += RemoveTaskInventory; client.OnUpdateTaskInventory += UpdateTaskInventory; client.OnMoveTaskItem += ClientMoveTaskInventoryItem; + } - client.OnGrabObject += ProcessObjectGrab; - client.OnDeGrabObject += ProcessObjectDeGrab; - client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; - client.OnParcelBuy += ProcessParcelBuy; - client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; - client.OnObjectIncludeInSearch += m_sceneGraph.MakeObjectSearchable; + public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) + { + client.OnRezSingleAttachmentFromInv += RezSingleAttachment; + client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments; + client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv; + client.OnObjectAttach += m_sceneGraph.AttachObject; + client.OnObjectDetach += m_sceneGraph.DetachObject; + } + + public virtual void SubscribeToClientTeleportEvents(IClientAPI client) + { + client.OnTeleportLocationRequest += RequestTeleportLocation; + client.OnTeleportLandmarkRequest += RequestTeleportLandmark; client.OnTeleportHomeRequest += TeleportClientHome; - client.OnSetStartLocationRequest += SetHomeRezPoint; - client.OnUndo += m_sceneGraph.HandleUndo; - client.OnObjectGroupRequest += m_sceneGraph.HandleObjectGroupUpdate; - client.OnParcelReturnObjectsRequest += LandChannel.ReturnObjectsInParcel; - client.OnParcelSetOtherCleanTime += LandChannel.SetParcelOtherCleanTime; - client.OnObjectSaleInfo += ObjectSaleInfo; + } + + public virtual void SubscribeToClientScriptEvents(IClientAPI client) + { client.OnScriptReset += ProcessScriptReset; client.OnGetScriptRunning += GetScriptRunning; client.OnSetScriptRunning += SetScriptRunning; + } + + public virtual void SubscribeToClientParcelEvents(IClientAPI client) + { + client.OnObjectGroupRequest += m_sceneGraph.HandleObjectGroupUpdate; + client.OnParcelReturnObjectsRequest += LandChannel.ReturnObjectsInParcel; + client.OnParcelSetOtherCleanTime += LandChannel.SetParcelOtherCleanTime; + client.OnParcelBuy += ProcessParcelBuy; + } + + public virtual void SubscribeToClientGridEvents(IClientAPI client) + { + client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; + client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; + client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; + client.OnSetStartLocationRequest += SetHomeRezPoint; client.OnRegionHandleRequest += RegionHandleRequest; - client.OnUnackedTerrain += TerrainUnAcked; - client.OnObjectOwner += ObjectOwner; + } + public virtual void SubscribeToClientGodEvents(IClientAPI client) + { IGodsModule godsModule = RequestModuleInterface(); client.OnGodKickUser += godsModule.KickUser; client.OnRequestGodlikePowers += godsModule.RequestGodlikePowers; + } + public virtual void SubscribeToClientNetworkEvents(IClientAPI client) + { client.OnNetworkStatsUpdate += StatsReporter.AddPacketsStats; + } + + protected virtual void UnsubscribeToClientEvents(IClientAPI client) + { + + } + + /// + /// Register for events from the client + /// + /// The IClientAPI of the connected client + public virtual void UnSubscribeToClientEvents(IClientAPI client) + { + UnSubscribeToClientTerrainEvents(client); + UnSubscribeToClientPrimEvents(client); + UnSubscribeToClientPrimRezEvents(client); + UnSubscribeToClientInventoryEvents(client); + UnSubscribeToClientAttachmentEvents(client); + UnSubscribeToClientTeleportEvents(client); + UnSubscribeToClientScriptEvents(client); + UnSubscribeToClientParcelEvents(client); + UnSubscribeToClientGridEvents(client); + UnSubscribeToClientGodEvents(client); + + UnSubscribeToClientNetworkEvents(client); + // EventManager.TriggerOnNewClient(client); } + public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client) + { + client.OnRegionHandShakeReply -= SendLayerData; + client.OnUnackedTerrain -= TerrainUnAcked; + } + + public virtual void UnSubscribeToClientPrimEvents(IClientAPI client) + { + client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimPosition; + client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; + client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimRotation; + client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimRotation; + client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; + client.OnUpdatePrimSingleRotationPosition -= m_sceneGraph.UpdatePrimSingleRotationPosition; + client.OnUpdatePrimScale -= m_sceneGraph.UpdatePrimScale; + client.OnUpdatePrimGroupScale -= m_sceneGraph.UpdatePrimGroupScale; + client.OnUpdateExtraParams -= m_sceneGraph.UpdateExtraParam; + client.OnUpdatePrimShape -= m_sceneGraph.UpdatePrimShape; + client.OnUpdatePrimTexture -= m_sceneGraph.UpdatePrimTexture; + client.OnObjectRequest -= RequestPrim; + client.OnObjectSelect -= SelectPrim; + client.OnObjectDeselect -= DeselectPrim; + client.OnGrabUpdate -= m_sceneGraph.MoveObject; + client.OnSpinStart -= m_sceneGraph.SpinStart; + client.OnSpinUpdate -= m_sceneGraph.SpinObject; + client.OnDeRezObject -= DeRezObject; + client.OnObjectName -= m_sceneGraph.PrimName; + client.OnObjectClickAction -= m_sceneGraph.PrimClickAction; + client.OnObjectMaterial -= m_sceneGraph.PrimMaterial; + client.OnLinkObjects -= m_sceneGraph.LinkObjects; + client.OnDelinkObjects -= m_sceneGraph.DelinkObjects; + client.OnObjectDuplicate -= m_sceneGraph.DuplicateObject; + client.OnObjectDuplicateOnRay -= doObjectDuplicateOnRay; + client.OnUpdatePrimFlags -= m_sceneGraph.UpdatePrimFlags; + client.OnRequestObjectPropertiesFamily -= m_sceneGraph.RequestObjectPropertiesFamily; + client.OnObjectPermissions -= HandleObjectPermissionsUpdate; + client.OnGrabObject -= ProcessObjectGrab; + client.OnDeGrabObject -= ProcessObjectDeGrab; + client.OnUndo -= m_sceneGraph.HandleUndo; + client.OnObjectDescription -= m_sceneGraph.PrimDescription; + client.OnObjectDrop -= m_sceneGraph.DropObject; + client.OnObjectSaleInfo -= ObjectSaleInfo; + client.OnObjectIncludeInSearch -= m_sceneGraph.MakeObjectSearchable; + client.OnObjectOwner -= ObjectOwner; + } + + public virtual void UnSubscribeToClientPrimRezEvents(IClientAPI client) + { + client.OnAddPrim -= AddNewPrim; + client.OnRezObject -= RezObject; + } + + + public virtual void UnSubscribeToClientInventoryEvents(IClientAPI client) + { + client.OnCreateNewInventoryItem -= CreateNewInventoryItem; + client.OnCreateNewInventoryFolder -= HandleCreateInventoryFolder; + client.OnUpdateInventoryFolder -= HandleUpdateInventoryFolder; + client.OnMoveInventoryFolder -= HandleMoveInventoryFolder; // 2; //!! + client.OnFetchInventoryDescendents -= HandleFetchInventoryDescendents; + client.OnPurgeInventoryDescendents -= HandlePurgeInventoryDescendents; // 2; //!! + client.OnFetchInventory -= HandleFetchInventory; + client.OnUpdateInventoryItem -= UpdateInventoryItemAsset; + client.OnCopyInventoryItem -= CopyInventoryItem; + client.OnMoveInventoryItem -= MoveInventoryItem; + client.OnRemoveInventoryItem -= RemoveInventoryItem; + client.OnRemoveInventoryFolder -= RemoveInventoryFolder; + client.OnRezScript -= RezScript; + client.OnRequestTaskInventory -= RequestTaskInventory; + client.OnRemoveTaskItem -= RemoveTaskInventory; + client.OnUpdateTaskInventory -= UpdateTaskInventory; + client.OnMoveTaskItem -= ClientMoveTaskInventoryItem; + } + + public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) + { + client.OnRezSingleAttachmentFromInv -= RezSingleAttachment; + client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments; + client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv; + client.OnObjectAttach -= m_sceneGraph.AttachObject; + client.OnObjectDetach -= m_sceneGraph.DetachObject; + } + + public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) + { + client.OnTeleportLocationRequest -= RequestTeleportLocation; + client.OnTeleportLandmarkRequest -= RequestTeleportLandmark; + client.OnTeleportHomeRequest -= TeleportClientHome; + } + + public virtual void UnSubscribeToClientScriptEvents(IClientAPI client) + { + client.OnScriptReset -= ProcessScriptReset; + client.OnGetScriptRunning -= GetScriptRunning; + client.OnSetScriptRunning -= SetScriptRunning; + } + + public virtual void UnSubscribeToClientParcelEvents(IClientAPI client) + { + client.OnObjectGroupRequest -= m_sceneGraph.HandleObjectGroupUpdate; + client.OnParcelReturnObjectsRequest -= LandChannel.ReturnObjectsInParcel; + client.OnParcelSetOtherCleanTime -= LandChannel.SetParcelOtherCleanTime; + client.OnParcelBuy -= ProcessParcelBuy; + } + + public virtual void UnSubscribeToClientGridEvents(IClientAPI client) + { + client.OnNameFromUUIDRequest -= CommsManager.HandleUUIDNameRequest; + client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; + client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest; + client.OnSetStartLocationRequest -= SetHomeRezPoint; + client.OnRegionHandleRequest -= RegionHandleRequest; + } + + public virtual void UnSubscribeToClientGodEvents(IClientAPI client) + { + IGodsModule godsModule = RequestModuleInterface(); + client.OnGodKickUser -= godsModule.KickUser; + client.OnRequestGodlikePowers -= godsModule.RequestGodlikePowers; + } + + public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client) + { + client.OnNetworkStatsUpdate -= StatsReporter.AddPacketsStats; + } + + + + /// /// Teleport an avatar to their home region /// -- cgit v1.1 From c48ec978179ade68cf816e3134e11ddde71f8bfc Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 4 Sep 2009 22:30:30 -0700 Subject: Fixed some long-standing issues with appearance in HG1. --- .../Hypergrid/HGCommunicationsGridMode.cs | 2 +- .../Hypergrid/HGCommunicationsStandalone.cs | 2 +- .../Communications/Hypergrid/HGUserDataPlugin.cs | 72 ++++++++++++++++++++++ .../Communications/Hypergrid/HGUserServices.cs | 2 +- .../Communications/OGS1/OGS1UserDataPlugin.cs | 10 ++- .../Hypergrid/HGStandaloneLoginModule.cs | 62 +++++++++++++++++++ .../Scenes/Hypergrid/HGScene.Inventory.cs | 36 +++++------ 7 files changed, 162 insertions(+), 24 deletions(-) create mode 100644 OpenSim/Region/Communications/Hypergrid/HGUserDataPlugin.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs index 381070e..80f2e79 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs @@ -59,7 +59,7 @@ namespace OpenSim.Region.Communications.Hypergrid HGUserServices userServices = new HGUserServices(this); // This plugin arrangement could eventually be configurable rather than hardcoded here. userServices.AddPlugin(new TemporaryUserProfilePlugin()); - userServices.AddPlugin(new OGS1UserDataPlugin(this)); + userServices.AddPlugin(new HGUserDataPlugin(this, userServices)); m_userService = userServices; m_messageService = userServices; diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs index 568437d..e4e12d4 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs @@ -57,7 +57,7 @@ namespace OpenSim.Region.Communications.Hypergrid HGUserServices hgUserService = new HGUserServices(this, localUserService); // This plugin arrangement could eventually be configurable rather than hardcoded here. hgUserService.AddPlugin(new TemporaryUserProfilePlugin()); - hgUserService.AddPlugin(new OGS1UserDataPlugin(this)); + hgUserService.AddPlugin(new HGUserDataPlugin(this, hgUserService)); m_userService = hgUserService; m_userAdminService = hgUserService; diff --git a/OpenSim/Region/Communications/Hypergrid/HGUserDataPlugin.cs b/OpenSim/Region/Communications/Hypergrid/HGUserDataPlugin.cs new file mode 100644 index 0000000..4b8fc26 --- /dev/null +++ b/OpenSim/Region/Communications/Hypergrid/HGUserDataPlugin.cs @@ -0,0 +1,72 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Net; +using System.Reflection; +using System.Text.RegularExpressions; +using System.Xml.Serialization; +using log4net; +using Nwc.XmlRpc; +using OpenMetaverse; +using OpenSim.Data; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Clients; +using OpenSim.Region.Communications.OGS1; + +namespace OpenSim.Region.Communications.Hypergrid +{ + public class HGUserDataPlugin : OGS1UserDataPlugin + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + HGUserServices m_UserServices; + + public HGUserDataPlugin() + { + } + + public HGUserDataPlugin(CommunicationsManager commsManager, HGUserServices userServices) + { + m_log.DebugFormat("[HG USER SERVICES]: {0} initialized", Name); + m_commsManager = commsManager; + m_UserServices = userServices; + } + + protected override string GetUserServerURL(UUID userID) + { + string url = string.Empty; + if (m_UserServices.IsForeignUser(userID, out url)) + return url; + return m_commsManager.NetworkServersInfo.UserURL; + } + + } +} diff --git a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs index 68a9076..aaa1c78 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs @@ -311,7 +311,7 @@ namespace OpenSim.Region.Communications.Hypergrid return m_commsManager.NetworkServersInfo.UserURL; } - private bool IsForeignUser(UUID userID, out string userServerURL) + public bool IsForeignUser(UUID userID, out string userServerURL) { userServerURL = string.Empty; CachedUserInfo uinfo = m_commsManager.UserProfileCacheService.GetUserDetails(userID); diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs b/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs index 9f234be..92e6ae3 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs @@ -48,6 +48,10 @@ namespace OpenSim.Region.Communications.OGS1 protected CommunicationsManager m_commsManager; + public OGS1UserDataPlugin() + { + } + public OGS1UserDataPlugin(CommunicationsManager commsManager) { m_log.DebugFormat("[OGS1 USER SERVICES]: {0} initialized", Name); @@ -603,7 +607,7 @@ namespace OpenSim.Region.Communications.OGS1 { if ((string)respData["returnString"] == "TRUE") { - + m_log.DebugFormat("[OGS1 USER SERVICES]: Updated user appearance in {0}", GetUserServerURL(user)); } else { @@ -622,8 +626,8 @@ namespace OpenSim.Region.Communications.OGS1 } catch (WebException e) { - m_log.Warn("[OGS1 USER SERVICES]: Error when trying to update Avatar's appearance: " + - e.Message); + m_log.WarnFormat("[OGS1 USER SERVICES]: Error when trying to update Avatar's appearance in {0}: {1}", + GetUserServerURL(user), e.Message); // Return Empty list (no friends) } } diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs index a5894c6..613dbe9 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs @@ -34,6 +34,7 @@ using System.Text.RegularExpressions; using log4net; using Nini.Config; using OpenMetaverse; +using Nwc.XmlRpc; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Services; @@ -115,6 +116,8 @@ namespace OpenSim.Region.CoreModules.Hypergrid httpServer.AddXmlRPCHandler("hg_login", m_loginService.XmlRpcLoginMethod); httpServer.AddXmlRPCHandler("check_auth_session", m_loginService.XmlRPCCheckAuthSession, false); + httpServer.AddXmlRPCHandler("get_avatar_appearance", XmlRPCGetAvatarAppearance); + httpServer.AddXmlRPCHandler("update_avatar_appearance", XmlRPCUpdateAvatarAppearance); } } @@ -256,5 +259,64 @@ namespace OpenSim.Region.CoreModules.Hypergrid scene = null; return false; } + + public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request, IPEndPoint remoteClient) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + AvatarAppearance appearance; + Hashtable responseData; + if (requestData.Contains("owner")) + { + appearance = m_firstScene.CommsManager.AvatarService.GetUserAppearance(new UUID((string)requestData["owner"])); + if (appearance == null) + { + responseData = new Hashtable(); + responseData["error_type"] = "no appearance"; + responseData["error_desc"] = "There was no appearance found for this avatar"; + } + else + { + responseData = appearance.ToHashTable(); + } + } + else + { + responseData = new Hashtable(); + responseData["error_type"] = "unknown_avatar"; + responseData["error_desc"] = "The avatar appearance requested is not in the database"; + } + + response.Value = responseData; + return response; + } + + public XmlRpcResponse XmlRPCUpdateAvatarAppearance(XmlRpcRequest request, IPEndPoint remoteClient) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable responseData; + if (requestData.Contains("owner")) + { + AvatarAppearance appearance = new AvatarAppearance(requestData); + + // TODO: Sometime in the future we may have a database layer that is capable of updating appearance when + // the TextureEntry is null. When that happens, this check can be removed + if (appearance.Texture != null) + m_firstScene.CommsManager.AvatarService.UpdateUserAppearance(new UUID((string)requestData["owner"]), appearance); + + responseData = new Hashtable(); + responseData["returnString"] = "TRUE"; + } + else + { + responseData = new Hashtable(); + responseData["error_type"] = "unknown_avatar"; + responseData["error_desc"] = "The avatar appearance requested is not in the database"; + } + response.Value = responseData; + return response; + } } + } diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs index dd6928f..8fe3565 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs @@ -113,26 +113,26 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) { - //m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); - - if (fromTaskID.Equals(UUID.Zero)) + m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); + + //if (fromTaskID.Equals(UUID.Zero)) + //{ + InventoryItemBase item = new InventoryItemBase(itemID); + item.Owner = remoteClient.AgentId; + item = InventoryService.GetItem(item); + //if (item == null) + //{ // Fetch the item + // item = new InventoryItemBase(); + // item.Owner = remoteClient.AgentId; + // item.ID = itemID; + // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo); + //} + if (item != null) { - InventoryItemBase item = new InventoryItemBase(itemID); - item.Owner = remoteClient.AgentId; - item = InventoryService.GetItem(item); - //if (item == null) - //{ // Fetch the item - // item = new InventoryItemBase(); - // item.Owner = remoteClient.AgentId; - // item.ID = itemID; - // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo); - //} - if (item != null) - { - m_assMapper.Get(item.AssetID, remoteClient.AgentId); - - } + m_assMapper.Get(item.AssetID, remoteClient.AgentId); + } + //} // OK, we're done fetching. Pass it up to the default RezObject return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, -- cgit v1.1 From 855fb58c9650086122b76c586c4a4a408343143f Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Sat, 5 Sep 2009 02:58:35 -0400 Subject: * Moves ScenePresence SendCourseLocations to a delegate and provide a method to replace the delegate * RegionCombinerModule replaces this delegate and distributes the CoarseLocationUpdates through the client connection in the region where the user would be if it was a separate region. * Fixes Mini Map display on combined regions. --- .../CoreModules/World/Land/RegionCombinerModule.cs | 171 ++++++++++++++++++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 23 +++ 2 files changed, 188 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs index 91d736b..9da869c 100644 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs @@ -514,7 +514,8 @@ namespace OpenSim.Region.CoreModules.World.Land rdata.RegionScene = scene; regionConnections.RegionLandChannel = scene.LandChannel; - RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, regionConnections.ConnectedRegions); + RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, + regionConnections.ConnectedRegions); scene.LandChannel = lnd; lock (m_regions) { @@ -525,19 +526,164 @@ namespace OpenSim.Region.CoreModules.World.Land } regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections); - + scene.EventManager.OnNewPresence += SetCourseLocationDelegate; m_regions.Add(scene.RegionInfo.originRegionID, regionConnections); + } } AdjustLargeRegionBounds(); } + private void SetCourseLocationDelegate(ScenePresence presence) + { + presence.SetSendCourseLocationMethod(SendCourseLocationUpdates); + } + + private void SendCourseLocationUpdates(UUID sceneId, ScenePresence presence) + { + RegionConnections connectiondata = null; + lock (m_regions) + { + if (m_regions.ContainsKey(sceneId)) + connectiondata = m_regions[sceneId]; + else + return; + } + + List avatars = connectiondata.RegionScene.GetAvatars(); + List CoarseLocations = new List(); + List AvatarUUIDs = new List(); + for (int i = 0; i < avatars.Count; i++) + { + if (avatars[i].UUID != presence.UUID) + { + if (avatars[i].ParentID != 0) + { + // sitting avatar + SceneObjectPart sop = connectiondata.RegionScene.GetSceneObjectPart(avatars[i].ParentID); + if (sop != null) + { + CoarseLocations.Add(sop.AbsolutePosition + avatars[i].AbsolutePosition); + AvatarUUIDs.Add(avatars[i].UUID); + } + else + { + // we can't find the parent.. ! arg! + CoarseLocations.Add(avatars[i].AbsolutePosition); + AvatarUUIDs.Add(avatars[i].UUID); + } + } + else + { + CoarseLocations.Add(avatars[i].AbsolutePosition); + AvatarUUIDs.Add(avatars[i].UUID); + } + } + } + DistributeCourseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence); + } + + private void DistributeCourseLocationUpdates(List locations, List uuids, + RegionConnections connectiondata, ScenePresence rootPresence) + { + RegionData[] rdata = connectiondata.ConnectedRegions.ToArray(); + List clients = new List(); + Dictionary updates = new Dictionary(); + + + // Root Region entry + RegionCourseLocationStruct rootupdatedata = new RegionCourseLocationStruct(); + rootupdatedata.Locations = new List(); + rootupdatedata.Uuids = new List(); + rootupdatedata.Offset = Vector2.Zero; + + rootupdatedata.UserAPI = rootPresence.ControllingClient; + + if (rootupdatedata.UserAPI != null) + updates.Add(Vector2.Zero, rootupdatedata); + + //Each Region needs an entry or we will end up with dead minimap dots + foreach (RegionData regiondata in rdata) + { + Vector2 offset = new Vector2(regiondata.Offset.X, regiondata.Offset.Y); + RegionCourseLocationStruct updatedata = new RegionCourseLocationStruct(); + updatedata.Locations = new List(); + updatedata.Uuids = new List(); + updatedata.Offset = offset; + + if (offset == Vector2.Zero) + updatedata.UserAPI = rootPresence.ControllingClient; + else + updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata); + + if (updatedata.UserAPI != null) + updates.Add(offset, updatedata); + } + + // go over the locations and assign them to an IClientAPI + for (int i = 0; i < locations.Count;i++ ) + //{locations[i]/(int) Constants.RegionSize; + { + Vector3 pPosition = new Vector3((int)locations[i].X / (int)Constants.RegionSize, + (int)locations[i].Y / (int)Constants.RegionSize, locations[i].Z); + Vector2 offset = new Vector2(pPosition.X*(int) Constants.RegionSize, + pPosition.Y*(int) Constants.RegionSize); + + if (!updates.ContainsKey(offset)) + { + // This shouldn't happen + RegionCourseLocationStruct updatedata = new RegionCourseLocationStruct(); + updatedata.Locations = new List(); + updatedata.Uuids = new List(); + updatedata.Offset = offset; + + if (offset == Vector2.Zero) + updatedata.UserAPI = rootPresence.ControllingClient; + else + updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata); + + updates.Add(offset,updatedata); + + } + + updates[offset].Locations.Add(locations[i]); + updates[offset].Uuids.Add(uuids[i]); + + } + + // Send out the CoarseLocationupdates from their respective client connection based on where the avatar is + foreach (Vector2 offset in updates.Keys) + { + if (updates[offset].UserAPI != null) + { + updates[offset].UserAPI.SendCoarseLocationUpdate(updates[offset].Uuids,updates[offset].Locations); + } + } + + } + + private IClientAPI LocateUsersChildAgentIClientAPI(Vector2 offset, UUID uUID, RegionData[] rdata) + { + IClientAPI returnclient = null; + foreach (RegionData r in rdata) + { + if (r.Offset.X == offset.X && r.Offset.Y == offset.Y) + { + return r.RegionScene.SceneGraph.GetControllingClient(uUID); + } + } + + return returnclient; + } + public void PostInitialise() { } + + public void UnCombineRegion(RegionData rdata) { lock (m_regions) @@ -758,6 +904,13 @@ namespace OpenSim.Region.CoreModules.World.Land public Vector3 Offset; } + struct RegionCourseLocationStruct + { + public List Locations; + public List Uuids; + public IClientAPI UserAPI; + public Vector2 Offset; + } public class RegionCombinerLargeLandChannel : ILandChannel { @@ -769,7 +922,8 @@ namespace OpenSim.Region.CoreModules.World.Land #region ILandChannel Members - public RegionCombinerLargeLandChannel(RegionData regData, ILandChannel rootRegionLandChannel,List regionConnections) + public RegionCombinerLargeLandChannel(RegionData regData, ILandChannel rootRegionLandChannel, + List regionConnections) { RegData = regData; RootRegionLandChannel = rootRegionLandChannel; @@ -1128,7 +1282,8 @@ namespace OpenSim.Region.CoreModules.World.Land { private Scene m_rootScene; private Dictionary m_virtScene = new Dictionary(); - private Dictionary m_forwarders = new Dictionary(); + private Dictionary m_forwarders = new Dictionary(); public RegionCombinerClientEventForwarder(RegionConnections rootScene) { m_rootScene = rootScene.RegionScene; @@ -1222,7 +1377,9 @@ namespace OpenSim.Region.CoreModules.World.Land } - private void LocalRezObject(IClientAPI remoteclient, UUID itemid, Vector3 rayend, Vector3 raystart, UUID raytargetid, byte bypassraycast, bool rayendisintersection, bool rezselected, bool removeitem, UUID fromtaskid) + private void LocalRezObject(IClientAPI remoteclient, UUID itemid, Vector3 rayend, Vector3 raystart, + UUID raytargetid, byte bypassraycast, bool rayendisintersection, bool rezselected, bool removeitem, + UUID fromtaskid) { int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX; int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY; @@ -1236,7 +1393,9 @@ namespace OpenSim.Region.CoreModules.World.Land } - private void LocalAddNewPrim(UUID ownerid, UUID groupid, Vector3 rayend, Quaternion rot, PrimitiveBaseShape shape, byte bypassraycast, Vector3 raystart, UUID raytargetid, byte rayendisintersection) + private void LocalAddNewPrim(UUID ownerid, UUID groupid, Vector3 rayend, Quaternion rot, + PrimitiveBaseShape shape, byte bypassraycast, Vector3 raystart, UUID raytargetid, + byte rayendisintersection) { int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX; int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 857dc11..1024857 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -62,6 +62,8 @@ namespace OpenSim.Region.Framework.Scenes public ScriptControlled eventControls; } + public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence); + public class ScenePresence : EntityBase { // ~ScenePresence() @@ -87,12 +89,15 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 lastKnownAllowedPosition; public bool sentMessageAboutRestrictedParcelFlyingDown; + + private bool m_updateflag; private byte m_movementflag; private readonly List m_forcesList = new List(); private short m_updateCount; private uint m_requestedSitTargetID; private UUID m_requestedSitTargetUUID = UUID.Zero; + private SendCourseLocationsMethod m_sendCourseLocationsMethod; private bool m_startAnimationSet; @@ -616,6 +621,7 @@ namespace OpenSim.Region.Framework.Scenes private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) { + m_sendCourseLocationsMethod = SendCoarseLocationsDefault; CreateSceneViewer(); m_regionHandle = reginfo.RegionHandle; m_controllingClient = client; @@ -2458,6 +2464,21 @@ namespace OpenSim.Region.Framework.Scenes public void SendCoarseLocations() { + SendCourseLocationsMethod d = m_sendCourseLocationsMethod; + if (d != null) + { + d.Invoke(m_scene.RegionInfo.originRegionID, this); + } + } + + public void SetSendCourseLocationMethod(SendCourseLocationsMethod d) + { + if (d != null) + m_sendCourseLocationsMethod = d; + } + + public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p) + { m_perfMonMS = Environment.TickCount; List CoarseLocations = new List(); @@ -3302,6 +3323,7 @@ namespace OpenSim.Region.Framework.Scenes { Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); DefaultTexture = textu.GetBytes(); + } public class NewForce @@ -3431,6 +3453,7 @@ namespace OpenSim.Region.Framework.Scenes Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); DefaultTexture = textu.GetBytes(); } + m_sendCourseLocationsMethod = SendCoarseLocationsDefault; CreateSceneViewer(); } -- cgit v1.1 From 7d9d8eb90f1aae353e6e0a649875a9506892a6cc Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 5 Sep 2009 16:56:33 -0700 Subject: This should get rid of the infinite loop upon looking up users/agents by UUID in grid mode. Grr. --- OpenSim/Region/Communications/Hypergrid/HGUserServices.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs index aaa1c78..f1a56ef 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs @@ -313,7 +313,7 @@ namespace OpenSim.Region.Communications.Hypergrid public bool IsForeignUser(UUID userID, out string userServerURL) { - userServerURL = string.Empty; + userServerURL = m_commsManager.NetworkServersInfo.UserURL; CachedUserInfo uinfo = m_commsManager.UserProfileCacheService.GetUserDetails(userID); if (uinfo != null) { -- cgit v1.1 From babe392709a7f7a65540485a641916d6e0194b5d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 5 Sep 2009 17:16:43 -0700 Subject: uh-hum. It might help if I remembered to save the file. --- OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs b/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs index 92e6ae3..ec8512a 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs @@ -112,7 +112,7 @@ namespace OpenSim.Region.Communications.OGS1 parameters.Add(param); XmlRpcRequest req = new XmlRpcRequest("get_agent_by_uuid", parameters); - XmlRpcResponse resp = req.Send(GetUserServerURL(userId), 6000); + XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 6000); Hashtable respData = (Hashtable)resp.Value; if (respData.Contains("error_type")) { -- cgit v1.1 From 2a8f66b221e93fb2d693c1c273c2dee85439f835 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 6 Sep 2009 04:28:42 +0100 Subject: Revising the user account data interfaces. No user functionality yet --- OpenSim/Data/IUserAccountData.cs | 55 +++++++ OpenSim/Data/MySQL/MySQLUserAccountData.cs | 180 +++++++++++++++++++++ OpenSim/Data/MySQL/Resources/008_UserStore.sql | 5 + .../User/LocalUserServiceConnector.cs | 6 +- .../User/RemoteUserServiceConnector.cs | 4 +- .../Connectors/User/UserServiceConnector.cs | 145 ++--------------- OpenSim/Services/Interfaces/IUserService.cs | 35 ++-- OpenSim/Services/UserService/UserService.cs | 14 +- 8 files changed, 275 insertions(+), 169 deletions(-) create mode 100644 OpenSim/Data/IUserAccountData.cs create mode 100644 OpenSim/Data/MySQL/MySQLUserAccountData.cs create mode 100644 OpenSim/Data/MySQL/Resources/008_UserStore.sql (limited to 'OpenSim') diff --git a/OpenSim/Data/IUserAccountData.cs b/OpenSim/Data/IUserAccountData.cs new file mode 100644 index 0000000..6bec188 --- /dev/null +++ b/OpenSim/Data/IUserAccountData.cs @@ -0,0 +1,55 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Framework; + +namespace OpenSim.Data +{ + public class UserAccountData + { + public UUID PrincipalID; + public UUID ScopeID; + public Dictionary Data; + } + + /// + /// An interface for connecting to the authentication datastore + /// + public interface IUserAccountData + { + UserAccountData Get(UUID principalID, UUID ScopeID); + + List Query(UUID principalID, UUID ScopeID, string query); + + bool Store(UserAccountData data); + + bool SetDataItem(UUID principalID, string item, string value); + } +} diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs new file mode 100644 index 0000000..39d60ca --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -0,0 +1,180 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using OpenMetaverse; +using OpenSim.Framework; +using MySql.Data.MySqlClient; + +namespace OpenSim.Data.MySQL +{ + public class MySqlUserAccountData : MySqlFramework, IUserAccountData + { + private string m_Realm; + private List m_ColumnNames = null; + private int m_LastExpire = 0; + + public MySqlUserAccountData(string connectionString, string realm) + : base(connectionString) + { + m_Realm = realm; + + Migration m = new Migration(m_Connection, GetType().Assembly, "UserStore"); + m.Update(); + } + + public List Query(UUID principalID, UUID scopeID, string query) + { + return null; + } + + public UserAccountData Get(UUID principalID, UUID scopeID) + { + UserAccountData ret = new UserAccountData(); + ret.Data = new Dictionary(); + + string command = "select * from `"+m_Realm+"` where UUID = ?principalID"; + if (scopeID != UUID.Zero) + command += " and ScopeID = ?scopeID"; + + MySqlCommand cmd = new MySqlCommand(command); + + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + + IDataReader result = ExecuteReader(cmd); + + if (result.Read()) + { + ret.PrincipalID = principalID; + UUID scope; + UUID.TryParse(result["ScopeID"].ToString(), out scope); + ret.ScopeID = scope; + + if (m_ColumnNames == null) + { + m_ColumnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } + + foreach (string s in m_ColumnNames) + { + if (s == "UUID") + continue; + if (s == "ScopeID") + continue; + + ret.Data[s] = result[s].ToString(); + } + + result.Close(); + CloseReaderCommand(cmd); + + return ret; + } + + result.Close(); + CloseReaderCommand(cmd); + + return null; + } + + public bool Store(UserAccountData data) + { + if (data.Data.ContainsKey("UUID")) + data.Data.Remove("UUID"); + if (data.Data.ContainsKey("ScopeID")) + data.Data.Remove("ScopeID"); + + string[] fields = new List(data.Data.Keys).ToArray(); + + MySqlCommand cmd = new MySqlCommand(); + + string update = "update `"+m_Realm+"` set "; + bool first = true; + foreach (string field in fields) + { + if (!first) + update += ", "; + update += "`" + field + "` = ?"+field; + + first = false; + + cmd.Parameters.AddWithValue("?"+field, data.Data[field]); + } + + update += " where UUID = ?principalID"; + + if (data.ScopeID != UUID.Zero) + update += " and ScopeID = ?scopeID"; + + cmd.CommandText = update; + cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); + + if (ExecuteNonQuery(cmd) < 1) + { + string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + + String.Join("`, `", fields) + + "`) values ( ?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; + + cmd.CommandText = insert; + + if (ExecuteNonQuery(cmd) < 1) + { + cmd.Dispose(); + return false; + } + } + + cmd.Dispose(); + + return true; + } + + public bool SetDataItem(UUID principalID, string item, string value) + { + MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + + "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); + + + cmd.Parameters.AddWithValue("?"+item, value); + cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); + + if (ExecuteNonQuery(cmd) > 0) + return true; + + return false; + } + } +} diff --git a/OpenSim/Data/MySQL/Resources/008_UserStore.sql b/OpenSim/Data/MySQL/Resources/008_UserStore.sql new file mode 100644 index 0000000..4500bd5 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/008_UserStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE users add scopeID char(36) not null default '00000000-0000-0000-0000-000000000000'; + +COMMIT; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs index fcd0304..cca5bb4 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs @@ -42,7 +42,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - private IUserAccountDataService m_UserService; + private IUserAccountService m_UserService; private bool m_Enabled = false; @@ -82,7 +82,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User Object[] args = new Object[] { source }; m_UserService = - ServerUtils.LoadPlugin(serviceDll, + ServerUtils.LoadPlugin(serviceDll, args); if (m_UserService == null) @@ -113,7 +113,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User if (!m_Enabled) return; - scene.RegisterModuleInterface(m_UserService); + scene.RegisterModuleInterface(m_UserService); } public void RemoveRegion(Scene scene) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs index a2b854b..cef9129 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs @@ -37,7 +37,7 @@ using OpenSim.Services.Connectors; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User { public class RemoteUserServicesConnector : UserServicesConnector, - ISharedRegionModule, IUserAccountDataService + ISharedRegionModule, IUserAccountService { private static readonly ILog m_log = LogManager.GetLogger( @@ -96,7 +96,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User if (!m_Enabled) return; - scene.RegisterModuleInterface(this); + scene.RegisterModuleInterface(this); } public void RemoveRegion(Scene scene) diff --git a/OpenSim/Services/Connectors/User/UserServiceConnector.cs b/OpenSim/Services/Connectors/User/UserServiceConnector.cs index fb03844..d418938 100644 --- a/OpenSim/Services/Connectors/User/UserServiceConnector.cs +++ b/OpenSim/Services/Connectors/User/UserServiceConnector.cs @@ -39,7 +39,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class UserServicesConnector : IUserAccountDataService + public class UserServicesConnector : IUserAccountService { private static readonly ILog m_log = LogManager.GetLogger( @@ -81,153 +81,34 @@ namespace OpenSim.Services.Connectors m_ServerURI = serviceURI; } - public UserAccountData GetUserAccountData(UUID scopeID, string firstName, string lastName) + public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) { - string uri = m_ServerURI + "/users/"; - UserAccountData data = new UserAccountData(); - data.FirstName = firstName; - data.LastName = lastName; - data.ScopeID = scopeID; - data.UserID = UUID.Zero; - - try - { - data = SynchronousRestObjectRequester. - MakeRequest("POST", uri, data); - } - catch (Exception e) - { - m_log.WarnFormat("[USER CONNECTOR]: Unable to send request to user server. Reason: {1}", e.Message); - return null; - } - - if (data.UserID == UUID.Zero) - return null; - - return data; + return null; } - public UserAccountData GetUserAccountData(UUID scopeID, UUID userID) + public UserAccount GetUserAccount(UUID scopeID, UUID userID) { - string uri = m_ServerURI + "/users/"; - UserAccountData data = new UserAccountData(); - data.FirstName = String.Empty; - data.LastName = String.Empty; - data.ScopeID = scopeID; - data.UserID = userID; - - try - { - data = SynchronousRestObjectRequester. - MakeRequest("POST", uri, data); - } - catch (Exception e) - { - m_log.WarnFormat("[USER CONNECTOR]: Unable to send request to user server. Reason: {1}", e.Message); - return null; - } - - if (data.UserID == UUID.Zero) - return null; - - return data; + return null; } - public bool SetHomePosition(UserAccountData data, UUID regionID, UUID regionSecret) + public bool SetHomePosition(UserAccount data, UUID regionID, UUID regionSecret) { - string uri = m_ServerURI + "/user/"; - bool result = false; - - UserAccountDataMessage msg = new UserAccountDataMessage(); - - msg.Data = data; - msg.RegionID = regionID; - msg.RegionSecret = regionSecret; - - try - { - result = SynchronousRestObjectRequester. - MakeRequest("POST", uri, msg); - } - catch (Exception e) - { - m_log.WarnFormat("[USER CONNECTOR]: Unable to send request to user server. Reason: {1}", e.Message); - return false; - } - - return result; + return false; } - public bool SetUserAccountData(UserAccountData data, UUID principalID, UUID sessionID) + public bool SetUserAccount(UserAccount data, UUID principalID, string token) { - string uri = m_ServerURI + "/user/"; - bool result = false; - - UserAccountDataMessage msg = new UserAccountDataMessage(); - - msg.Data = data; - msg.PrincipalID = principalID; - msg.SessionID = sessionID; - - try - { - result = SynchronousRestObjectRequester. - MakeRequest("POST", uri, msg); - } - catch (Exception e) - { - m_log.WarnFormat("[USER CONNECTOR]: Unable to send request to user server. Reason: {1}", e.Message); - return false; - } - - return result; + return false; } - public bool CreateUserAccountData(UserAccountData data, UUID principalID, UUID sessionID) + public bool CreateUserAccount(UserAccount data, UUID principalID, string token) { - string uri = m_ServerURI + "/newuser/"; - bool result = false; - - UserAccountDataMessage msg = new UserAccountDataMessage(); - - msg.Data = data; - msg.PrincipalID = principalID; - msg.SessionID = sessionID; - - try - { - result = SynchronousRestObjectRequester. - MakeRequest("POST", uri, msg); - } - catch (Exception e) - { - m_log.WarnFormat("[USER CONNECTOR]: Unable to send request to user server. Reason: {1}", e.Message); - return false; - } - - return result; + return false; } - public List GetUserAccountData(UUID scopeID, string query) + public List GetUserAccount(UUID scopeID, string query) { - string uri = m_ServerURI + "/userlist/"; - UserAccountData data = new UserAccountData(); - data.FirstName = query; - data.ScopeID = scopeID; - List result; - - try - { - result = SynchronousRestObjectRequester. - MakeRequest>("POST", uri, data); - } - catch (Exception e) - { - m_log.WarnFormat("[USER CONNECTOR]: Unable to send request to user server. Reason: {1}", e.Message); - return null; - } - - return result; + return null; } } } diff --git a/OpenSim/Services/Interfaces/IUserService.cs b/OpenSim/Services/Interfaces/IUserService.cs index 35254a1..92bd8ef 100644 --- a/OpenSim/Services/Interfaces/IUserService.cs +++ b/OpenSim/Services/Interfaces/IUserService.cs @@ -30,13 +30,13 @@ using OpenMetaverse; namespace OpenSim.Services.Interfaces { - public class UserAccountData + public class UserAccount { - public UserAccountData() + public UserAccount() { } - public UserAccountData(UUID userID, UUID homeRegionID, float homePositionX, + public UserAccount(UUID userID, UUID homeRegionID, float homePositionX, float homePositionY, float homePositionZ, float homeLookAtX, float homeLookAtY, float homeLookAtZ) { @@ -78,41 +78,26 @@ namespace OpenSim.Services.Interfaces }; - public class UserAccountDataMessage + public interface IUserAccountService { - public UserAccountData Data; - - // Set to the region's ID and secret when updating home location - // - public UUID RegionID; - public UUID RegionSecret; - - // Set to the auth info of the user requesting creation/update - // - public UUID PrincipalID; - public UUID SessionID; - }; - - public interface IUserAccountDataService - { - UserAccountData GetUserAccountData(UUID scopeID, UUID userID); - UserAccountData GetUserAccountData(UUID scopeID, string FirstName, string LastName); + UserAccount GetUserAccount(UUID scopeID, UUID userID); + UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName); // Returns the list of avatars that matches both the search // criterion and the scope ID passed // - List GetUserAccountData(UUID scopeID, string query); + List GetUserAccount(UUID scopeID, string query); // This will set only the home region portion of the data! // Can't be used to set god level, flags, type or change the name! // - bool SetHomePosition(UserAccountData data, UUID RegionID, UUID RegionSecret); + bool SetHomePosition(UserAccount data, UUID RegionID, UUID RegionSecret); // Update all updatable fields // - bool SetUserAccountData(UserAccountData data, UUID PrincipalID, UUID SessionID); + bool SetUserAccount(UserAccount data, UUID PrincipalID, string token); // Creates a user data record - bool CreateUserAccountData(UserAccountData data, UUID PrincipalID, UUID SessionID); + bool CreateUserAccount(UserAccount data, UUID PrincipalID, string token); } } diff --git a/OpenSim/Services/UserService/UserService.cs b/OpenSim/Services/UserService/UserService.cs index 78793657..e8b9fc3 100644 --- a/OpenSim/Services/UserService/UserService.cs +++ b/OpenSim/Services/UserService/UserService.cs @@ -35,39 +35,39 @@ using OpenMetaverse; namespace OpenSim.Services.UserAccountService { - public class UserAccountService : UserAccountServiceBase, IUserAccountDataService + public class UserAccountService : UserAccountServiceBase, IUserAccountService { public UserAccountService(IConfigSource config) : base(config) { } - public UserAccountData GetUserAccountData(UUID scopeID, string firstName, + public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) { return null; } - public UserAccountData GetUserAccountData(UUID scopeID, UUID userID) + public UserAccount GetUserAccount(UUID scopeID, UUID userID) { return null; } - public bool SetHomePosition(UserAccountData data, UUID regionID, UUID regionSecret) + public bool SetHomePosition(UserAccount data, UUID regionID, UUID regionSecret) { return false; } - public bool SetUserAccountData(UserAccountData data, UUID principalID, UUID sessionID) + public bool SetUserAccount(UserAccount data, UUID principalID, string token) { return false; } - public bool CreateUserAccountData(UserAccountData data, UUID principalID, UUID sessionID) + public bool CreateUserAccount(UserAccount data, UUID principalID, string token) { return false; } - public List GetUserAccountData(UUID scopeID, + public List GetUserAccount(UUID scopeID, string query) { return null; -- cgit v1.1 From bb1d4d23c4703cde5c3f7f7d2d123a8abaac3cfa Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 6 Sep 2009 04:44:08 +0100 Subject: Change the loader to actually load the user service data module --- OpenSim/Services/UserService/UserServiceBase.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/UserService/UserServiceBase.cs b/OpenSim/Services/UserService/UserServiceBase.cs index c982c1a..fea8b01 100644 --- a/OpenSim/Services/UserService/UserServiceBase.cs +++ b/OpenSim/Services/UserService/UserServiceBase.cs @@ -36,7 +36,7 @@ namespace OpenSim.Services.UserAccountService { public class UserAccountServiceBase: ServiceBase { - protected IUserDataPlugin m_Database = null; + protected IUserAccountData m_Database = null; public UserAccountServiceBase(IConfigSource config) : base(config) { @@ -53,12 +53,12 @@ namespace OpenSim.Services.UserAccountService string connString = userConfig.GetString("ConnectionString", String.Empty); - m_Database = LoadPlugin(dllName); + string realm = userConfig.GetString("Realm", "users"); + + m_Database = LoadPlugin(dllName, new Object[] {connString, realm}); if (m_Database == null) throw new Exception("Could not find a storage interface in the given module"); - - m_Database.Initialise(connString); } } } -- cgit v1.1 From 25313c21053edf4cb44fc00d82b7c5456640c1ce Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 6 Sep 2009 21:52:11 +1000 Subject: * Debugging why region loading is occurring so slowly on a setup with 64 regions in a Regions.ini (took 38 minutes on my test box) --- OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs | 10 ++++++++++ .../RegionLoader/Filesystem/RegionLoaderFileSystem.cs | 1 + 2 files changed, 11 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index dff4d48..6fd3d30 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs @@ -94,14 +94,24 @@ namespace OpenSim.ApplicationPlugins.LoadRegions regionLoader = new RegionLoaderWebServer(); } + m_log.Info("[LOADREGIONSPLUGIN]: Loading region configurations..."); + regionLoader.SetIniConfigSource(m_openSim.ConfigSource.Source); RegionInfo[] regionsToLoad = regionLoader.LoadRegions(); + m_log.Info("[LOADREGIONSPLUGIN]: Loading specific shared modules..."); + m_log.Info("[LOADREGIONSPLUGIN]: DynamicTextureModule..."); m_openSim.ModuleLoader.LoadDefaultSharedModule(new DynamicTextureModule()); + m_log.Info("[LOADREGIONSPLUGIN]: InstantMessageModule..."); m_openSim.ModuleLoader.LoadDefaultSharedModule(new InstantMessageModule()); + m_log.Info("[LOADREGIONSPLUGIN]: LoadImageURLModule..."); m_openSim.ModuleLoader.LoadDefaultSharedModule(new LoadImageURLModule()); + m_log.Info("[LOADREGIONSPLUGIN]: XMLRPCModule..."); m_openSim.ModuleLoader.LoadDefaultSharedModule(new XMLRPCModule()); + m_log.Info("[LOADREGIONSPLUGIN]: AssetTransactionModule..."); m_openSim.ModuleLoader.LoadDefaultSharedModule(new AssetTransactionModule()); + m_log.Info("[LOADREGIONSPLUGIN]: Done."); + if (!CheckRegionsForSanity(regionsToLoad)) { m_log.Error("[LOADREGIONS]: Halting startup due to conflicts in region configurations"); diff --git a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs index 44f44fe..42f3934 100644 --- a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs +++ b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs @@ -78,6 +78,7 @@ namespace OpenSim.Framework.RegionLoader.Filesystem foreach (IConfig config in source.Configs) { + m_log.Info("[REGIONLOADERFILESYSTEM]: Creating RegionInfo for " + config.Name); RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource, config.Name); regionInfos.Add(regionInfo); i++; -- cgit v1.1 From 5e4b7be7120b60a133338ea98ef4e7effd321e76 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 6 Sep 2009 21:53:03 +1000 Subject: * Typo in previous commit. --- OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs index 42f3934..63e09ae 100644 --- a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs +++ b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs @@ -78,7 +78,7 @@ namespace OpenSim.Framework.RegionLoader.Filesystem foreach (IConfig config in source.Configs) { - m_log.Info("[REGIONLOADERFILESYSTEM]: Creating RegionInfo for " + config.Name); + //m_log.Info("[REGIONLOADERFILESYSTEM]: Creating RegionInfo for " + config.Name); RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource, config.Name); regionInfos.Add(regionInfo); i++; -- cgit v1.1 From dcebbc3f1b27cf01ae28cb522c5180c195729823 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 6 Sep 2009 15:55:14 +0100 Subject: Remove the encryption from the IAuthenticationService interface. That is too high up for that type of stuff. It needs to be at the connector/handler level --- OpenSim/Region/Framework/Scenes/Scene.cs | 30 ++++++++++++++++-- .../AuthenticationServiceBase.cs | 15 --------- .../PasswordAuthenticationService.cs | 5 --- .../WebkeyAuthenticationService.cs | 5 --- .../Services/Interfaces/IAuthenticationService.cs | 36 ---------------------- 5 files changed, 27 insertions(+), 64 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c25ae10..8cd77f8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -220,7 +220,7 @@ namespace OpenSim.Region.Framework.Scenes private bool m_scripts_enabled = true; private string m_defaultScriptEngine; private int m_LastLogin = 0; - private Thread HeartbeatThread; + private Thread HeartbeatThread = null; private volatile bool shuttingdown = false; private int m_lastUpdate = Environment.TickCount; @@ -876,6 +876,13 @@ namespace OpenSim.Region.Framework.Scenes //m_heartbeatTimer.Enabled = true; //m_heartbeatTimer.Interval = (int)(m_timespan * 1000); //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); + if (HeartbeatThread != null) + { + ThreadTracker.Remove(HeartbeatThread); + HeartbeatThread.Abort(); + HeartbeatThread = null; + } + m_lastUpdate = Environment.TickCount; HeartbeatThread = new Thread(new ParameterizedThreadStart(Heartbeat)); HeartbeatThread.SetApartmentState(ApartmentState.MTA); HeartbeatThread.Name = string.Format("Heartbeat for region {0}", RegionInfo.RegionName); @@ -912,9 +919,15 @@ namespace OpenSim.Region.Framework.Scenes /// private void Heartbeat(object sender) { - Update(); + try + { + Update(); - m_lastUpdate = Environment.TickCount; + m_lastUpdate = Environment.TickCount; + } + catch (ThreadAbortException) + { + } } /// @@ -2307,6 +2320,7 @@ namespace OpenSim.Region.Framework.Scenes /// public override void AddNewClient(IClientAPI client) { + CheckHeartbeat(); SubscribeToClientEvents(client); ScenePresence presence; @@ -2831,6 +2845,7 @@ namespace OpenSim.Region.Framework.Scenes /// protected virtual ScenePresence CreateAndAddScenePresence(IClientAPI client) { + CheckHeartbeat(); AvatarAppearance appearance = null; GetAvatarAppearance(client, out appearance); @@ -2873,6 +2888,7 @@ namespace OpenSim.Region.Framework.Scenes /// public override void RemoveClient(UUID agentID) { + CheckHeartbeat(); bool childagentYN = false; ScenePresence avatar = GetScenePresence(agentID); if (avatar != null) @@ -4374,6 +4390,8 @@ namespace OpenSim.Region.Framework.Scenes else return health; + CheckHeartbeat(); + return health; } @@ -4559,5 +4577,11 @@ namespace OpenSim.Region.Framework.Scenes return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; } + + private void CheckHeartbeat() + { + if (System.Environment.TickCount - m_lastUpdate > 2000) + StartTimer(); + } } } diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs index 2ed177c..8904461 100644 --- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs +++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs @@ -90,31 +90,16 @@ namespace OpenSim.Services.AuthenticationService throw new Exception("Could not find a storage interface in the given module"); } - public virtual byte[] GetPublicKey() - { - return new byte[0]; - } - public bool Verify(UUID principalID, string token, int lifetime) { return m_Database.CheckToken(principalID, token, lifetime); } - public bool VerifyEncrypted(byte[] cyphertext, byte[] key) - { - return false; - } - public virtual bool Release(UUID principalID, string token) { return m_Database.CheckToken(principalID, token, 0); } - public virtual bool ReleaseEncrypted(byte[] cyphertext, byte[] key) - { - return false; - } - protected string GetToken(UUID principalID, int lifetime) { UUID token = UUID.Random(); diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs index 7fdbbf6..6c99b66 100644 --- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs @@ -76,10 +76,5 @@ namespace OpenSim.Services.AuthenticationService return String.Empty; } - - public byte[] AuthenticateEncrypted(byte[] cyphertext, byte[] key) - { - return new byte[0]; - } } } diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs index 0118c91..8831c8a 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs @@ -56,10 +56,5 @@ namespace OpenSim.Services.AuthenticationService { return String.Empty; } - - public byte[] AuthenticateEncrypted(byte[] cyphertext, byte[] key) - { - return new byte[0]; - } } } diff --git a/OpenSim/Services/Interfaces/IAuthenticationService.cs b/OpenSim/Services/Interfaces/IAuthenticationService.cs index b448a14..9225773 100644 --- a/OpenSim/Services/Interfaces/IAuthenticationService.cs +++ b/OpenSim/Services/Interfaces/IAuthenticationService.cs @@ -39,39 +39,12 @@ namespace OpenSim.Services.Interfaces public interface IAuthenticationService { ////////////////////////////////////////////////////// - // PKI Zone! - // - // HG2 authentication works by using a cryptographic - // exchange. - // This method must provide a public key, the other - // crypto methods must understand hoow to deal with - // messages encrypted to it. - // - // If the public key is of zero length, you will - // get NO encryption and NO security. - // - // For non-HG installations, this is not relevant - // - // Implementors who are not using PKI can treat the - // cyphertext as a string and provide a zero-length - // key. Encryptionless implementations will not - // interoperate with implementations using encryption. - // If one side uses encryption, both must do so. - // - byte[] GetPublicKey(); - - ////////////////////////////////////////////////////// // Authentication // // These methods will return a token, which can be used to access // various services. // - // The encrypted versions take the received cyphertext and - // the public key of the peer, which the connector must have - // obtained using a remote GetPublicKey call. - // string Authenticate(UUID principalID, string password, int lifetime); - byte[] AuthenticateEncrypted(byte[] cyphertext, byte[] key); ////////////////////////////////////////////////////// // Verification @@ -81,12 +54,7 @@ namespace OpenSim.Services.Interfaces // Tokens expire after 30 minutes and can be refreshed by // re-verifying. // - // If encrypted authentication was used, encrypted verification - // must be used to refresh. Unencrypted verification is still - // performed, but doesn't refresh token lifetime. - // bool Verify(UUID principalID, string token, int lifetime); - bool VerifyEncrypted(byte[] cyphertext, byte[] key); ////////////////////////////////////////////////////// // Teardown @@ -95,11 +63,7 @@ namespace OpenSim.Services.Interfaces // invalidates it and it can not subsequently be used // or refreshed. // - // Tokens created by encrypted authentication must - // be returned by encrypted release calls; - // bool Release(UUID principalID, string token); - bool ReleaseEncrypted(byte[] cyphertext, byte[] key); ////////////////////////////////////////////////////// // Grid -- cgit v1.1 From 998624544c5120676e3048990ef74956210be959 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 6 Sep 2009 16:14:45 +0100 Subject: Addendum to last commit. With the last commit, some other code that should have been in this commit slipped in. If the last heartbeat is more than 2 seconds ago, kill that thread and start a new one. Untested. his commit adds support to let the first heartbeat complete unconditionally, since it is almost always longer. --- OpenSim/Region/Framework/Scenes/Scene.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 8cd77f8..8f3ba97 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -225,6 +225,7 @@ namespace OpenSim.Region.Framework.Scenes private int m_lastUpdate = Environment.TickCount; private int m_maxPrimsPerFrame = 200; + private bool m_firstHeartbeat = true; private object m_deleting_scene_object = new object(); @@ -924,6 +925,7 @@ namespace OpenSim.Region.Framework.Scenes Update(); m_lastUpdate = Environment.TickCount; + m_firstHeartbeat = false; } catch (ThreadAbortException) { @@ -4580,6 +4582,9 @@ namespace OpenSim.Region.Framework.Scenes private void CheckHeartbeat() { + if (m_firstHeartbeat) + return; + if (System.Environment.TickCount - m_lastUpdate > 2000) StartTimer(); } -- cgit v1.1 From 511bddc8bc5783919a8135b69ddd6c974fbcf1f7 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Sun, 6 Sep 2009 16:15:06 -0400 Subject: * Moves another Legacy avatar inbounds check to Border --- OpenSim/Region/Framework/Scenes/Scene.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c25ae10..278091f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3140,11 +3140,17 @@ namespace OpenSim.Region.Framework.Scenes if (!agent.child) { - if (agent.startpos.X > (int)Constants.RegionSize - 1) - agent.startpos.X = (int)Constants.RegionSize - 1; + if (TestBorderCross(agent.startpos,Cardinals.E)) + { + Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.E); + agent.startpos.X = crossedBorder.BorderLine.Z - 1; + } - if (agent.startpos.Y > (int)Constants.RegionSize - 1) - agent.startpos.Y = (int)Constants.RegionSize - 1; + if (TestBorderCross(agent.startpos, Cardinals.N)) + { + Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.N); + agent.startpos.Y = crossedBorder.BorderLine.Z - 1; + } // Honor parcel landing type and position. ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); -- cgit v1.1 From a6e2e94345ae3d153f945dd79f3221630015d826 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 6 Sep 2009 23:05:06 +0100 Subject: Thank you, StrawberryFride, for a hit-and-run patch to add authentication and user services to MSSQL --- OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs | 222 +++++++++++++++++++++++++ OpenSim/Data/MSSQL/MSSQLUserAccountData.cs | 186 +++++++++++++++++++++ OpenSim/Data/MSSQL/Resources/011_UserStore.sql | 5 + 3 files changed, 413 insertions(+) create mode 100644 OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs create mode 100644 OpenSim/Data/MSSQL/MSSQLUserAccountData.cs create mode 100644 OpenSim/Data/MSSQL/Resources/011_UserStore.sql (limited to 'OpenSim') diff --git a/OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs b/OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs new file mode 100644 index 0000000..78fc22c --- /dev/null +++ b/OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs @@ -0,0 +1,222 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using OpenMetaverse; +using OpenSim.Framework; +using System.Data.SqlClient; +using System.Reflection; +using System.Text; + +namespace OpenSim.Data.MSSQL +{ + public class MSSQLAuthenticationData : IAuthenticationData + { + private string m_Realm; + private List m_ColumnNames = null; + private int m_LastExpire = 0; + private string m_ConnectionString; + + public MSSQLAuthenticationData(string connectionString, string realm) + { + m_Realm = realm; + m_ConnectionString = connectionString; + using (SqlConnection conn = new SqlConnection(m_ConnectionString)) + { + conn.Open(); + Migration m = new Migration(conn, GetType().Assembly, "AuthStore"); + m.Update(); + } + } + + public AuthenticationData Get(UUID principalID) + { + AuthenticationData ret = new AuthenticationData(); + ret.Data = new Dictionary(); + + string sql = string.Format("select * from '{0}' where UUID = @principalID", m_Realm); + + using (SqlConnection conn = new SqlConnection(m_ConnectionString)) + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + cmd.Parameters.AddWithValue("@principalID", principalID.ToString()); + conn.Open(); + using (SqlDataReader result = cmd.ExecuteReader()) + { + if (result.Read()) + { + ret.PrincipalID = principalID; + + if (m_ColumnNames == null) + { + m_ColumnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } + + foreach (string s in m_ColumnNames) + { + if (s == "UUID") + continue; + + ret.Data[s] = result[s].ToString(); + } + return ret; + } + } + } + return null; + } + + public bool Store(AuthenticationData data) + { + if (data.Data.ContainsKey("UUID")) + data.Data.Remove("UUID"); + + string[] fields = new List(data.Data.Keys).ToArray(); + StringBuilder updateBuilder = new StringBuilder(); + + using (SqlConnection conn = new SqlConnection(m_ConnectionString)) + using (SqlCommand cmd = new SqlCommand()) + { + updateBuilder.AppendFormat("update '{0}' set ", m_Realm); + + bool first = true; + foreach (string field in fields) + { + if (!first) + updateBuilder.Append(", "); + updateBuilder.AppendFormat("'{0}' = @{0}",field); + + first = false; + + cmd.Parameters.AddWithValue("@" + field, data.Data[field]); + } + + updateBuilder.Append(" where UUID = @principalID"); + + cmd.CommandText = updateBuilder.ToString(); + cmd.Connection = conn; + + cmd.Parameters.AddWithValue("@principalID", data.PrincipalID.ToString()); + conn.Open(); + if (cmd.ExecuteNonQuery() < 1) + { + StringBuilder insertBuilder = new StringBuilder(); + + insertBuilder.AppendFormat("insert into '{0}' ('UUID', '", m_Realm); + insertBuilder.Append(String.Join("', '", fields)); + insertBuilder.Append("') values ( @principalID, @"); + insertBuilder.Append(String.Join(", @", fields)); + insertBuilder.Append(")"); + + cmd.CommandText = insertBuilder.ToString(); + + if (cmd.ExecuteNonQuery() < 1) + { + return false; + } + } + } + return true; + } + + public bool SetDataItem(UUID principalID, string item, string value) + { + string sql = string.Format("update '{0}' set '{1}' = @{1} where UUID = @UUID", m_Realm, item); + using (SqlConnection conn = new SqlConnection(m_ConnectionString)) + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + cmd.Parameters.AddWithValue("@" + item, value); + cmd.Parameters.AddWithValue("@UUID", principalID.ToString()); + conn.Open(); + if (cmd.ExecuteNonQuery() > 0) + return true; + } + return false; + } + + public bool SetToken(UUID principalID, string token, int lifetime) + { + if (System.Environment.TickCount - m_LastExpire > 30000) + DoExpire(); + string sql = "insert into tokens (UUID, token, validity) values (@principalID, @token, date_add(now(), interval @lifetime minute))"; + using (SqlConnection conn = new SqlConnection(m_ConnectionString)) + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + cmd.Parameters.AddWithValue("@principalID", principalID.ToString()); + cmd.Parameters.AddWithValue("@token", token); + cmd.Parameters.AddWithValue("@lifetime", lifetime.ToString()); + conn.Open(); + + if (cmd.ExecuteNonQuery() > 0) + { + return true; + } + } + return false; + } + + public bool CheckToken(UUID principalID, string token, int lifetime) + { + if (System.Environment.TickCount - m_LastExpire > 30000) + DoExpire(); + string sql = "update tokens set validity = date_add(now(), interval @lifetime minute) where UUID = @principalID and token = @token and validity > now()"; + using (SqlConnection conn = new SqlConnection(m_ConnectionString)) + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + cmd.Parameters.AddWithValue("@principalID", principalID.ToString()); + cmd.Parameters.AddWithValue("@token", token); + cmd.Parameters.AddWithValue("@lifetime", lifetime.ToString()); + conn.Open(); + + if (cmd.ExecuteNonQuery() > 0) + { + return true; + } + } + return false; + } + + private void DoExpire() + { + string sql = "delete from tokens where validity < now()"; + using (SqlConnection conn = new SqlConnection(m_ConnectionString)) + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + conn.Open(); + cmd.ExecuteNonQuery(); + } + m_LastExpire = System.Environment.TickCount; + } + } +} diff --git a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs new file mode 100644 index 0000000..1520888 --- /dev/null +++ b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs @@ -0,0 +1,186 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using OpenMetaverse; +using OpenSim.Framework; +using System.Data.SqlClient; +using System.Text; + +namespace OpenSim.Data.MSSQL +{ + public class MSSQLUserAccountData : IUserAccountData + { + private string m_Realm; + private List m_ColumnNames = null; + private int m_LastExpire = 0; + private string m_ConnectionString; + + public MSSQLUserAccountData(string connectionString, string realm) + { + m_Realm = realm; + m_ConnectionString = connectionString; + using (SqlConnection conn = new SqlConnection(m_ConnectionString)) + { + conn.Open(); + Migration m = new Migration(conn, GetType().Assembly, "UserStore"); + m.Update(); + } + } + + public List Query(UUID principalID, UUID scopeID, string query) + { + return null; + } + + public UserAccountData Get(UUID principalID, UUID scopeID) + { + UserAccountData ret = new UserAccountData(); + ret.Data = new Dictionary(); + + string sql = string.Format("select * from '{0}' where UUID = @principalID", m_Realm); + if (scopeID != UUID.Zero) + sql += " and ScopeID = @scopeID"; + + using (SqlConnection conn = new SqlConnection(m_ConnectionString)) + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + + cmd.Parameters.AddWithValue("@principalID", principalID); + cmd.Parameters.AddWithValue("@scopeID", scopeID); + conn.Open(); + using (SqlDataReader result = cmd.ExecuteReader()) + { + if (result.Read()) + { + ret.PrincipalID = principalID; + UUID scope; + UUID.TryParse(result["ScopeID"].ToString(), out scope); + ret.ScopeID = scope; + + if (m_ColumnNames == null) + { + m_ColumnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } + + foreach (string s in m_ColumnNames) + { + if (s == "UUID") + continue; + if (s == "ScopeID") + continue; + + ret.Data[s] = result[s].ToString(); + } + return ret; + } + } + } + return null; + } + + public bool Store(UserAccountData data) + { + if (data.Data.ContainsKey("UUID")) + data.Data.Remove("UUID"); + if (data.Data.ContainsKey("ScopeID")) + data.Data.Remove("ScopeID"); + + string[] fields = new List(data.Data.Keys).ToArray(); + + using (SqlConnection conn = new SqlConnection(m_ConnectionString)) + using (SqlCommand cmd = new SqlCommand()) + { + StringBuilder updateBuilder = new StringBuilder(); + updateBuilder.AppendFormat("update '{0}' set ", m_Realm); + bool first = true; + foreach (string field in fields) + { + if (!first) + updateBuilder.Append(", "); + updateBuilder.AppendFormat("'{0}' = @{0}", field); + + first = false; + + cmd.Parameters.AddWithValue("@" + field, data.Data[field]); + } + + updateBuilder.Append(" where UUID = @principalID"); + + if (data.ScopeID != UUID.Zero) + updateBuilder.Append(" and ScopeID = @scopeID"); + + cmd.CommandText = updateBuilder.ToString(); + cmd.Connection = conn; + cmd.Parameters.AddWithValue("@principalID", data.PrincipalID); + cmd.Parameters.AddWithValue("@scopeID", data.ScopeID); + conn.Open(); + + if (cmd.ExecuteNonQuery() < 1) + { + StringBuilder insertBuilder = new StringBuilder(); + insertBuilder.AppendFormat("insert into '{0}' ('UUID', 'ScopeID', '", m_Realm); + insertBuilder.Append(String.Join("', '", fields)); + insertBuilder.Append("') values ( @principalID, @scopeID, @"); + insertBuilder.Append(String.Join(", @", fields)); + insertBuilder.Append(")"); + + cmd.CommandText = insertBuilder.ToString(); + + if (cmd.ExecuteNonQuery() < 1) + { + return false; + } + } + } + return true; + } + + public bool SetDataItem(UUID principalID, string item, string value) + { + string sql = string.Format("update '{0}' set '{1}' = @{1} where UUID = @UUID", m_Realm, item); + using (SqlConnection conn = new SqlConnection(m_ConnectionString)) + using (SqlCommand cmd = new SqlCommand(sql, conn)) + { + cmd.Parameters.AddWithValue("@" + item, value); + cmd.Parameters.AddWithValue("@UUID", principalID); + conn.Open(); + + if (cmd.ExecuteNonQuery() > 0) + return true; + } + return false; + } + } +} diff --git a/OpenSim/Data/MSSQL/Resources/011_UserStore.sql b/OpenSim/Data/MSSQL/Resources/011_UserStore.sql new file mode 100644 index 0000000..5aa064f --- /dev/null +++ b/OpenSim/Data/MSSQL/Resources/011_UserStore.sql @@ -0,0 +1,5 @@ +BEGIN TRANSACTION + +ALTER TABLE users ADD scopeID uniqueidentifier not null default '00000000-0000-0000-0000-000000000000' + +COMMIT -- cgit v1.1 From c4edefd9a0982e5b9c205a39c858d50abc677240 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Sun, 6 Sep 2009 21:26:59 -0400 Subject: minor: organizational * Move the neighbor region lookup to another method from where it was before in EnableNeighbourChildAgents. --- .../Framework/Scenes/SceneCommunicationService.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index c6b3f30..08563d0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -407,6 +407,24 @@ namespace OpenSim.Region.Framework.Scenes //blah.Port = region.RemotingPort; } + public List RequestNeighbors(Scene pScene, uint pRegionLocX, uint pRegionLocY) + { + Border[] northBorders = pScene.NorthBorders.ToArray(); + Border[] southBorders = pScene.SouthBorders.ToArray(); + Border[] eastBorders = pScene.EastBorders.ToArray(); + Border[] westBorders = pScene.WestBorders.ToArray(); + + // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. + if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) + { + return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); + } + else + { + return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); + } + } + /// /// This informs all neighboring regions about agent "avatar". /// Calls an asynchronous method to do so.. so it doesn't lag the sim. @@ -429,7 +447,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_regionInfo != null) { neighbours = - m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); + RequestNeighbors(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); } else { -- cgit v1.1 From 326c3ee14fb294796ff3b908f17da1021d321e3b Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Mon, 7 Sep 2009 12:57:30 -0400 Subject: * Enables Child Agents for all virtual regions in the region and their neighbors. There still may be issues with crossing into the mentioned neighbors of the virtual regions. This makes regions larger then 512x512 (3 virtual regions) display fully to clients. * Uses a grid request multiple times, so the more regions are in the instance, the longer logging in takes. Consider this temporary until there's a RegionInfo request similar to the MapItem Request. --- .../Framework/Scenes/SceneCommunicationService.cs | 58 +++++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 08563d0..0827672 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -367,6 +367,7 @@ namespace OpenSim.Region.Framework.Scenes string reason = String.Empty; //bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a); + bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason); if (regionAccepted && newAgent) @@ -384,7 +385,7 @@ namespace OpenSim.Region.Framework.Scenes eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID); eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath); - m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}", + m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}", capsPath, avatar.UUID, avatar.Scene.RegionInfo.RegionName); } else @@ -394,7 +395,9 @@ namespace OpenSim.Region.Framework.Scenes } m_log.Info("[INTERGRID]: Completed inform client about neighbour " + endPoint.ToString()); + } + } public void RequestNeighbors(RegionInfo region) @@ -421,7 +424,48 @@ namespace OpenSim.Region.Framework.Scenes } else { - return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); + Vector2 extent = Vector2.Zero; + for (int i=0;i extent.X) ? eastBorders[i].BorderLine.Z : extent.X; + } + for (int i=0;i extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; + } + + List neighbourList = new List(); + + // Loss of fraction on purpose + extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; + extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; + + int startX = (int) pRegionLocX - 1; + int startY = (int) pRegionLocY - 1; + + int endX = (int) pRegionLocX + (int)extent.X + 1; + int endY = (int) pRegionLocY + (int)extent.Y + 1; + + for (int i=startX;i