* Fixed a dangling event hook that I added.

* Added a Non-finite avatar position reset.    This will either handle the <0,0,0> avatar gracefully, or send the avatar to 127,127,127 if that also doesn't work.  ( I've only been able to reproduce this error once on my development workstation )
0.6.0-stable
Teravus Ovares 2008-05-30 11:25:21 +00:00
parent 0462510956
commit 334d05db05
4 changed files with 116 additions and 6 deletions

View File

@ -183,6 +183,7 @@ namespace OpenSim.Region.Environment.Modules.World.Estate
// Time of day / fixed sun // Time of day / fixed sun
m_scene.RegionInfo.EstateSettings.useFixedSun = UseFixedSun; m_scene.RegionInfo.EstateSettings.useFixedSun = UseFixedSun;
m_scene.RegionInfo.EstateSettings.sunHour = SunHour; m_scene.RegionInfo.EstateSettings.sunHour = SunHour;
m_scene.EventManager.TriggerEstateToolsTimeUpdate(m_scene.RegionInfo.RegionHandle, UseFixedSun, UseFixedSun, SunHour);
//m_log.Debug("[ESTATE]: UFS: " + UseFixedSun.ToString()); //m_log.Debug("[ESTATE]: UFS: " + UseFixedSun.ToString());
//m_log.Debug("[ESTATE]: SunHour: " + SunHour.ToString()); //m_log.Debug("[ESTATE]: SunHour: " + SunHour.ToString());
sendRegionInfoPacketToAll(); sendRegionInfoPacketToAll();

View File

@ -94,7 +94,8 @@ namespace OpenSim.Region.Environment.Modules
private LLVector3 Position = new LLVector3(0,0,0); private LLVector3 Position = new LLVector3(0,0,0);
private LLVector3 Velocity = new LLVector3(0,0,0); private LLVector3 Velocity = new LLVector3(0,0,0);
private LLQuaternion Tilt = new LLQuaternion(1,0,0,0); private LLQuaternion Tilt = new LLQuaternion(1,0,0,0);
private float LindenEstateHour = 6f; //private float LindenEstateHour = 6f;
private long LindenHourOffset = 0;
private bool sunFixed = false; private bool sunFixed = false;
private long estateTicksOffset = 0; private long estateTicksOffset = 0;
@ -104,13 +105,14 @@ namespace OpenSim.Region.Environment.Modules
private ulong CurrentTime private ulong CurrentTime
{ {
get { get {
//m_log.Debug("[LH]: " + LindenHourOffset.ToString());
return (ulong)(((System.DateTime.Now.Ticks) - TicksToEpoch + TicksOffset)/10000000); return (ulong)(((System.DateTime.Now.Ticks) - TicksToEpoch + TicksOffset + LindenHourOffset)/10000000);
} }
} }
private float GetLindenEstateHourFromCurrentTime() private float GetLindenEstateHourFromCurrentTime()
{ {
float ticksleftover = ((float)((ulong)(((System.DateTime.Now.Ticks) - TicksToEpoch + TicksOffset) / 10000000))) % ((float)SecondsPerSunCycle); float ticksleftover = ((float)CurrentTime) % ((float)SecondsPerSunCycle);
//m_log.Debug("[TICKS]: " + ticksleftover.ToString()); //m_log.Debug("[TICKS]: " + ticksleftover.ToString());
float hour = (24 * (ticksleftover / SecondsPerSunCycle)) + 6; float hour = (24 * (ticksleftover / SecondsPerSunCycle)) + 6;
//m_log.Debug("[LINDENHOUR]: " + hour.ToString()); //m_log.Debug("[LINDENHOUR]: " + hour.ToString());
@ -120,6 +122,33 @@ namespace OpenSim.Region.Environment.Modules
return hour; return hour;
} }
private void SetTimeByLindenHour(float LindenHour)
{
if (LindenHour - 6 == 0)
{
LindenHourOffset = 0;
return;
}
//TimeZone local = TimeZone.CurrentTimeZone;
//TicksOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks;
float ticksleftover = ((float)(((long)(CurrentTime * 10000000) - (long)LindenHourOffset)/ 10000000) % ((float)SecondsPerSunCycle));
float hour = (24 * (ticksleftover / SecondsPerSunCycle));
float offsethours = 0;
if (LindenHour - 6 > hour)
{
offsethours = hour + ((LindenHour-6) - hour);
}
else
{
offsethours = hour - (hour - (LindenHour - 6));
}
//m_log.Debug("[OFFSET]: " + hour + " - " + LindenHour + " - " + offsethours.ToString());
//LindenHourOffset = (long)((float)offsethours * (-14400000));
//m_log.Debug("[SUN]: Using " + CurrentTime.ToString());
}
// Called immediately after the module is loaded for a given region // Called immediately after the module is loaded for a given region
// i.e. Immediately after instance creation. // i.e. Immediately after instance creation.
@ -203,6 +232,7 @@ namespace OpenSim.Region.Environment.Modules
scene.EventManager.OnMakeChildAgent += MakeChildAgent; scene.EventManager.OnMakeChildAgent += MakeChildAgent;
scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
scene.EventManager.OnClientClosed += ClientLoggedOut; scene.EventManager.OnClientClosed += ClientLoggedOut;
scene.EventManager.OnEstateToolsTimeUpdate += EstateToolsTimeUpdate;
ready = true; ready = true;
@ -226,8 +256,9 @@ namespace OpenSim.Region.Environment.Modules
m_scene.EventManager.OnFrame -= SunUpdate; m_scene.EventManager.OnFrame -= SunUpdate;
// m_scene.EventManager.OnNewClient -= SunToClient; // m_scene.EventManager.OnNewClient -= SunToClient;
m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent; m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent;
m_scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
m_scene.EventManager.OnClientClosed += ClientLoggedOut; m_scene.EventManager.OnClientClosed -= ClientLoggedOut;
m_scene.EventManager.OnEstateToolsTimeUpdate -= EstateToolsTimeUpdate;
} }
public string Name public string Name
@ -273,7 +304,21 @@ namespace OpenSim.Region.Environment.Modules
m_scene.RegionInfo.EstateSettings.sunPosition = Position; m_scene.RegionInfo.EstateSettings.sunPosition = Position;
m_scene.RegionInfo.EstateSettings.sunHour = GetLindenEstateHourFromCurrentTime(); m_scene.RegionInfo.EstateSettings.sunHour = GetLindenEstateHourFromCurrentTime();
} }
public void ForceSunUpdateToAllClients()
{
GenSunPos(); // Generate shared values once
List<ScenePresence> avatars = m_scene.GetAvatars();
foreach (ScenePresence avatar in avatars)
{
if (!avatar.IsChildAgent)
avatar.ControllingClient.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition);
}
// set estate settings for region access to sun position
m_scene.RegionInfo.EstateSettings.sunPosition = Position;
m_scene.RegionInfo.EstateSettings.sunHour = GetLindenEstateHourFromCurrentTime();
}
/// <summary> /// <summary>
/// Calculate the sun's orbital position and its velocity. /// Calculate the sun's orbital position and its velocity.
/// </summary> /// </summary>
@ -370,5 +415,20 @@ namespace OpenSim.Region.Environment.Modules
} }
} }
} }
public void EstateToolsTimeUpdate(ulong regionHandle, bool FixedTime, bool useEstateTime, float LindenHour)
{
if (m_scene.RegionInfo.RegionHandle == regionHandle)
{
SetTimeByLindenHour(LindenHour);
//if (useEstateTime)
//LindenHourOffset = 0;
//ForceSunUpdateToAllClients();
//ready = true;// !FixedTime;
}
}
} }
} }

View File

@ -180,6 +180,8 @@ namespace OpenSim.Region.Environment.Scenes
public event ScriptTimerEvent OnScriptTimerEvent; public event ScriptTimerEvent OnScriptTimerEvent;
public delegate void EstateToolsTimeUpdate(ulong regionHandle, bool FixedTime, bool EstateSun, float LindenHour);
public event EstateToolsTimeUpdate OnEstateToolsTimeUpdate;
public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj); public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj);
public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene; public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene;
@ -346,6 +348,7 @@ namespace OpenSim.Region.Environment.Scenes
private ParcelPrimCountTainted handlerParcelPrimCountTainted = null; private ParcelPrimCountTainted handlerParcelPrimCountTainted = null;
private ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = null; private ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = null;
private ScriptTimerEvent handlerScriptTimerEvent = null; private ScriptTimerEvent handlerScriptTimerEvent = null;
private EstateToolsTimeUpdate handlerEstateToolsTimeUpdate = null;
public void TriggerOnScriptChangedEvent(uint localID, uint change) public void TriggerOnScriptChangedEvent(uint localID, uint change)
{ {
@ -798,5 +801,14 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
public void TriggerEstateToolsTimeUpdate(ulong regionHandle, bool FixedTime, bool useEstateTime, float LindenHour)
{
handlerEstateToolsTimeUpdate = OnEstateToolsTimeUpdate;
if (handlerEstateToolsTimeUpdate != null)
{
handlerEstateToolsTimeUpdate(regionHandle, FixedTime, useEstateTime, LindenHour);
}
}
} }
} }

View File

@ -90,6 +90,9 @@ namespace OpenSim.Region.Environment.Scenes
private short m_updateCount = 0; private short m_updateCount = 0;
private uint m_requestedSitTargetID = 0; private uint m_requestedSitTargetID = 0;
private LLVector3 m_requestedSitOffset = new LLVector3(); private LLVector3 m_requestedSitOffset = new LLVector3();
private LLVector3 m_LastFinitePos = new LLVector3();
private float m_sitAvatarHeight = 2.0f; private float m_sitAvatarHeight = 2.0f;
private float m_godlevel = 0; private float m_godlevel = 0;
@ -750,6 +753,40 @@ namespace OpenSim.Region.Environment.Scenes
// Must check for standing up even when PhysicsActor is null, // Must check for standing up even when PhysicsActor is null,
// since sitting currently removes avatar from physical scene // since sitting currently removes avatar from physical scene
//m_log.Debug("agentPos:" + AbsolutePosition.ToString());
// This is irritating. Really.
if (!AbsolutePosition.IsFinite())
{
RemoveFromPhysicalScene();
m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error# 9999902");
m_pos = m_LastFinitePos;
if (!m_pos.IsFinite())
{
m_pos.X = 127f;
m_pos.Y = 127f;
m_pos.Z = 127f;
m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error# 9999903");
}
AddToPhysicalScene();
}
else
{
m_LastFinitePos = m_pos;
}
//m_physicsActor.AddForce(new PhysicsVector(999999999, 99999999, 999999999999999), true);
//ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
//if (land != null)
//{
//if (land.landData.landingType == (byte)1 && land.landData.userLocation != LLVector3.Zero)
//{
// agent.startpos = land.landData.userLocation;
//}
//}
m_perfMonMS = System.Environment.TickCount; m_perfMonMS = System.Environment.TickCount;