From cb21caae777341b7b4af724e86b9a82b9b827c43 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 14 May 2017 01:44:04 +0100 Subject: fix some issue on parcels loading and make parcels dwell show something. Resolution is 2.5min aprox. --- .../Region/CoreModules/World/Land/DwellModule.cs | 26 +++++++++++--- .../CoreModules/World/Land/LandManagementModule.cs | 16 ++------- .../Region/CoreModules/World/Land/LandObject.cs | 40 ++++++++++++++++++++-- 3 files changed, 61 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/CoreModules/World/Land') diff --git a/OpenSim/Region/CoreModules/World/Land/DwellModule.cs b/OpenSim/Region/CoreModules/World/Land/DwellModule.cs index 5f1eab2..55a341e 100644 --- a/OpenSim/Region/CoreModules/World/Land/DwellModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/DwellModule.cs @@ -53,7 +53,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.World.Land { [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DefaultDwellModule")] - public class DefaultDwellModule : IDwellModule, INonSharedRegionModule + public class DefaultDwellModule : INonSharedRegionModule, IDwellModule { private Scene m_scene; private IConfigSource m_Config; @@ -88,16 +88,21 @@ namespace OpenSim.Region.CoreModules.World.Land return; m_scene = scene; - - m_scene.EventManager.OnNewClient += OnNewClient; + m_scene.RegisterModuleInterface(this); } public void RegionLoaded(Scene scene) { + if (!m_Enabled) + return; + m_scene.EventManager.OnNewClient += OnNewClient; } public void RemoveRegion(Scene scene) { + if (!m_Enabled) + return; + m_scene.EventManager.OnNewClient -= OnNewClient; } public void Close() @@ -115,15 +120,26 @@ namespace OpenSim.Region.CoreModules.World.Land if (parcel == null) return; - client.SendParcelDwellReply(localID, parcel.LandData.GlobalID, parcel.LandData.Dwell); + LandData land = parcel.LandData; + if(land!= null) + client.SendParcelDwellReply(localID, land.GlobalID, land.Dwell); } + public int GetDwell(UUID parcelID) { ILandObject parcel = m_scene.LandChannel.GetLandObject(parcelID); if (parcel != null && parcel.LandData != null) - return (int)parcel.LandData.Dwell; + return (int)(parcel.LandData.Dwell + 0.5f); + return 0; + } + + public int GetDwell(LandData land) + { + if (land != null) + return (int)(land.Dwell + 0.5f); return 0; } + } } diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index e1f2975..ce982a2 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -439,15 +439,6 @@ namespace OpenSim.Region.CoreModules.World.Land if (parcelAvatarIsEntering != null && avatar.currentParcelUUID != parcelAvatarIsEntering.LandData.GlobalID) { - if(!avatar.IsNPC && avatar.currentParcelUUID != UUID.Zero) - { - ILandObject last = GetLandObject(avatar.currentParcelUUID); - if(last != null) - { - - } - } - SendLandUpdate(avatar, parcelAvatarIsEntering); avatar.currentParcelUUID = parcelAvatarIsEntering.LandData.GlobalID; EnforceBans(parcelAvatarIsEntering, avatar); @@ -602,10 +593,8 @@ namespace OpenSim.Region.CoreModules.World.Land /// The land object being added. /// Will return null if this overlaps with an existing parcel that has not had its bitmap adjusted. /// - public ILandObject AddLandObject(ILandObject land) + public ILandObject AddLandObject(ILandObject new_land) { - ILandObject new_land = land.Copy(); - // Only now can we add the prim counts to the land object - we rely on the global ID which is generated // as a random UUID inside LandData initialization if (m_primCountModule != null) @@ -1621,8 +1610,7 @@ namespace OpenSim.Region.CoreModules.World.Land private void IncomingLandObjectFromStorage(LandData data) { - ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); - new_land.LandData = data.Copy(); + ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene, data); new_land.SetLandBitmapFromByteArray(); AddLandObject(new_land); diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 2b5cb31..cb54184 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -270,7 +270,7 @@ namespace OpenSim.Region.CoreModules.World.Land m_scene = scene; } - public LandObject(UUID owner_id, bool is_group_owned, Scene scene) + public LandObject(UUID owner_id, bool is_group_owned, Scene scene, LandData data = null) { m_scene = scene; if (m_scene == null) @@ -278,12 +278,17 @@ namespace OpenSim.Region.CoreModules.World.Land else LandBitmap = new bool[m_scene.RegionInfo.RegionSizeX / landUnit, m_scene.RegionInfo.RegionSizeY / landUnit]; - LandData = new LandData(); + if(data == null) + LandData = new LandData(); + else + LandData = data; + LandData.OwnerID = owner_id; if (is_group_owned) LandData.GroupID = owner_id; else LandData.GroupID = UUID.Zero; + LandData.IsGroupOwned = is_group_owned; m_scene.EventManager.OnFrame += OnFrame; @@ -1812,6 +1817,37 @@ namespace OpenSim.Region.CoreModules.World.Land ExpireAccessList(); m_expiryCounter = 0; } + + // need to update dwell here bc landdata has no parent info + if(LandData != null) + { + double now = Util.GetTimeStampMS(); + double elapsed = now - LandData.LastDwellTimeMS; + if(elapsed > 150000) //2.5 minutes resolution / throttle + { + float dwell = LandData.Dwell; + double cur = dwell * 60000.0; + double decay = 1.5e-8 * cur * elapsed; + cur -= decay; + if(cur < 0) + cur = 0; + + UUID lgid = LandData.GlobalID; + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) + { + if(sp.IsNPC || sp.IsLoggingIn || sp.IsDeleted || sp.currentParcelUUID != lgid) + return; + cur += (now - sp.ParcelDwellTickMS); + sp.ParcelDwellTickMS = now; + }); + + float newdwell = (float)(cur * 1.666666666667e-5); + LandData.Dwell = newdwell; + + if(Math.Abs(newdwell - dwell) > 1.0) + m_scene.EventManager.TriggerLandObjectAdded(this); + } + } } private void ExpireAccessList() -- cgit v1.1