fix some issue on parcels loading and make parcels dwell show something. Resolution is 2.5min aprox.

0.9.0-post-fixes
UbitUmarov 2017-05-14 01:44:04 +01:00
parent 25ca8695f3
commit cb21caae77
7 changed files with 74 additions and 26 deletions

View File

@ -97,7 +97,9 @@ namespace OpenSim.Framework
private bool _mediaLoop = false;
private bool _obscureMusic = false;
private bool _obscureMedia = false;
private float _dwell = 0;
private float m_dwell = 0;
public double LastDwellTimeMS;
public bool SeeAVs { get; set; }
public bool AnyAVSounds { get; set; }
@ -111,11 +113,12 @@ namespace OpenSim.Framework
{
get
{
return _dwell;
return m_dwell;
}
set
{
_dwell = value;
m_dwell = value;
LastDwellTimeMS = Util.GetTimeStampMS();
}
}
@ -735,6 +738,7 @@ namespace OpenSim.Framework
SeeAVs = true;
AnyAVSounds = true;
GroupAVSounds = true;
LastDwellTimeMS = Util.GetTimeStampMS();
}
/// <summary>
@ -784,7 +788,7 @@ namespace OpenSim.Framework
landData._obscureMedia = _obscureMedia;
landData._simwideArea = _simwideArea;
landData._simwidePrims = _simwidePrims;
landData._dwell = _dwell;
landData.m_dwell = m_dwell;
landData.SeeAVs = SeeAVs;
landData.AnyAVSounds = AnyAVSounds;
landData.GroupAVSounds = GroupAVSounds;

View File

@ -3114,7 +3114,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
float dwell = 0.0f;
IDwellModule dwellModule = m_scene.RequestModuleInterface<IDwellModule>();
if (dwellModule != null)
dwell = dwellModule.GetDwell(land.GlobalID);
dwell = dwellModule.GetDwell(land);
ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply);
reply.AgentData.AgentID = m_agentId;
reply.Data.ParcelID = parcelID;

View File

@ -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<IDwellModule>(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;
}
}
}

View File

@ -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.
/// </param>
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);

View File

@ -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()

View File

@ -33,5 +33,6 @@ namespace OpenSim.Region.Framework.Interfaces
public interface IDwellModule
{
int GetDwell(UUID parcelID);
int GetDwell(LandData land);
}
}

View File

@ -170,6 +170,7 @@ namespace OpenSim.Region.Framework.Scenes
private bool m_previusParcelHide = false;
private bool m_currentParcelHide = false;
private object parcelLock = new Object();
public double ParcelDwellTickMS;
public UUID currentParcelUUID
{
@ -182,6 +183,7 @@ namespace OpenSim.Region.Framework.Scenes
bool checksame = true;
if (value != m_currentParcelUUID)
{
ParcelDwellTickMS = Util.GetTimeStampMS();
m_previusParcelHide = m_currentParcelHide;
m_previusParcelUUID = m_currentParcelUUID;
checksame = false;
@ -2141,6 +2143,7 @@ namespace OpenSim.Region.Framework.Scenes
m_previusParcelUUID = UUID.Zero;
m_currentParcelHide = false;
m_currentParcelUUID = UUID.Zero;
ParcelDwellTickMS = Util.GetTimeStampMS();
if(!IsNPC)
{