Merge branch 'master' into careminster-presence-refactor

avinationmerge
Melanie 2011-02-24 02:37:21 +00:00
commit 9be1d2aef1
9 changed files with 115 additions and 34 deletions

View File

@ -51,27 +51,55 @@ namespace OpenSim.Data.Null
//Console.WriteLine("[XXX] NullRegionData constructor"); //Console.WriteLine("[XXX] NullRegionData constructor");
} }
private delegate bool Matcher(string value);
public List<RegionData> Get(string regionName, UUID scopeID) public List<RegionData> Get(string regionName, UUID scopeID)
{ {
if (Instance != this) if (Instance != this)
return Instance.Get(regionName, scopeID); return Instance.Get(regionName, scopeID);
string cleanName = regionName.ToLower();
// Handle SQL wildcards
const string wildcard = "%";
bool wildcardPrefix = false;
bool wildcardSuffix = false;
if (cleanName.Equals(wildcard))
{
wildcardPrefix = wildcardSuffix = true;
cleanName = string.Empty;
}
else
{
if (cleanName.StartsWith(wildcard))
{
wildcardPrefix = true;
cleanName = cleanName.Substring(1);
}
if (regionName.EndsWith(wildcard))
{
wildcardSuffix = true;
cleanName = cleanName.Remove(cleanName.Length - 1);
}
}
Matcher queryMatch;
if (wildcardPrefix && wildcardSuffix)
queryMatch = delegate(string s) { return s.Contains(cleanName); };
else if (wildcardSuffix)
queryMatch = delegate(string s) { return s.StartsWith(cleanName); };
else if (wildcardPrefix)
queryMatch = delegate(string s) { return s.EndsWith(cleanName); };
else
queryMatch = delegate(string s) { return s.Equals(cleanName); };
// Find region data
List<RegionData> ret = new List<RegionData>(); List<RegionData> ret = new List<RegionData>();
foreach (RegionData r in m_regionData.Values) foreach (RegionData r in m_regionData.Values)
{ {
if (regionName.Contains("%")) m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanName, r.RegionName.ToLower());
{ if (queryMatch(r.RegionName.ToLower()))
string cleanname = regionName.Replace("%", "");
m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanname.ToLower(), r.RegionName.ToLower());
if (r.RegionName.ToLower().Contains(cleanname.ToLower()))
ret.Add(r); ret.Add(r);
}
else
{
if (r.RegionName.ToLower() == regionName.ToLower())
ret.Add(r);
}
} }
if (ret.Count > 0) if (ret.Count > 0)

View File

@ -471,10 +471,17 @@ namespace OpenSim.Framework
/// <param name="oldy">Old region y-coord</param> /// <param name="oldy">Old region y-coord</param>
/// <param name="newy">New region y-coord</param> /// <param name="newy">New region y-coord</param>
/// <returns></returns> /// <returns></returns>
public static bool IsOutsideView(uint oldx, uint newx, uint oldy, uint newy) public static bool IsOutsideView(float drawdist, uint oldx, uint newx, uint oldy, uint newy)
{ {
// Eventually this will be a function of the draw distance / camera position too. int dd = (int)((drawdist + Constants.RegionSize - 1) / Constants.RegionSize);
return (((int)Math.Abs((int)(oldx - newx)) > 1) || ((int)Math.Abs((int)(oldy - newy)) > 1));
int startX = (int)oldx - dd;
int startY = (int)oldy - dd;
int endX = (int)oldx + dd;
int endY = (int)oldy + dd;
return (newx < startX || endX < newx || newy < startY || endY < newy);
} }
public static string FieldToString(byte[] bytes) public static string FieldToString(byte[] bytes)

View File

@ -319,7 +319,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
agentCircuit.Id0 = currentAgentCircuit.Id0; agentCircuit.Id0 = currentAgentCircuit.Id0;
} }
if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY))
{ {
// brand new agent, let's create a new caps seed // brand new agent, let's create a new caps seed
agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
@ -337,7 +337,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// OK, it got this agent. Let's close some child agents // OK, it got this agent. Let's close some child agents
sp.CloseChildAgents(newRegionX, newRegionY); sp.CloseChildAgents(newRegionX, newRegionY);
IClientIPEndpoint ipepClient; IClientIPEndpoint ipepClient;
if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY))
{ {
//sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
#region IP Translation for NAT #region IP Translation for NAT
@ -448,7 +448,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) if (NeedsClosing(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
{ {
Thread.Sleep(5000); Thread.Sleep(5000);
sp.Close(); sp.Close();
@ -522,14 +522,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
return region; return region;
} }
protected virtual bool NeedsNewAgent(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY)
{ {
return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY);
} }
protected virtual bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) protected virtual bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg)
{ {
return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY);
} }
protected virtual bool IsOutsideRegion(Scene s, Vector3 pos) protected virtual bool IsOutsideRegion(Scene s, Vector3 pos)
@ -1072,7 +1072,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
if (m_regionInfo != null) if (m_regionInfo != null)
{ {
neighbours = RequestNeighbours(sp.Scene, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); neighbours = RequestNeighbours(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
} }
else else
{ {
@ -1298,8 +1298,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
/// <param name="pRegionLocX"></param> /// <param name="pRegionLocX"></param>
/// <param name="pRegionLocY"></param> /// <param name="pRegionLocY"></param>
/// <returns></returns> /// <returns></returns>
protected List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY) protected List<GridRegion> RequestNeighbours(ScenePresence avatar, uint pRegionLocX, uint pRegionLocY)
{ {
Scene pScene = avatar.Scene;
RegionInfo m_regionInfo = pScene.RegionInfo; RegionInfo m_regionInfo = pScene.RegionInfo;
Border[] northBorders = pScene.NorthBorders.ToArray(); Border[] northBorders = pScene.NorthBorders.ToArray();
@ -1307,10 +1308,24 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
Border[] eastBorders = pScene.EastBorders.ToArray(); Border[] eastBorders = pScene.EastBorders.ToArray();
Border[] westBorders = pScene.WestBorders.ToArray(); Border[] westBorders = pScene.WestBorders.ToArray();
// Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. // Leaving this as a "megaregions" computation vs "non-megaregions" computation; it isn't
// clear what should be done with a "far view" given that megaregions already extended the
// view to include everything in the megaregion
if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
{ {
return pScene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID); int dd = avatar.DrawDistance < Constants.RegionSize ? (int)Constants.RegionSize : (int)avatar.DrawDistance;
int startX = (int)pRegionLocX * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2);
int startY = (int)pRegionLocY * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2);
int endX = (int)pRegionLocX * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2);
int endY = (int)pRegionLocY * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2);
List<GridRegion> neighbours =
avatar.Scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
return neighbours;
} }
else else
{ {

View File

@ -130,9 +130,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
return region; return region;
} }
protected override bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) protected override bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg)
{ {
if (base.NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
return true; return true;
int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID);

View File

@ -604,6 +604,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
{ {
m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 1"); m_log.Debug("[InventoryAccessModule]: Inventory object has UUID.Zero! Position 1");
} }
item.Owner = remoteClient.AgentId;
AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString());

View File

@ -83,6 +83,13 @@ namespace OpenSim.Region.Framework.Scenes
public bool m_useFlySlow; public bool m_useFlySlow;
public bool m_usePreJump; public bool m_usePreJump;
public bool m_seeIntoRegionFromNeighbor; public bool m_seeIntoRegionFromNeighbor;
protected float m_defaultDrawDistance = 255.0f;
public float DefaultDrawDistance
{
get { return m_defaultDrawDistance; }
}
// TODO: need to figure out how allow client agents but deny // TODO: need to figure out how allow client agents but deny
// root agents when ACL denies access to root agent // root agents when ACL denies access to root agent
public bool m_strictAccessControl = true; public bool m_strictAccessControl = true;
@ -649,6 +656,8 @@ namespace OpenSim.Region.Framework.Scenes
// //
IConfig startupConfig = m_config.Configs["Startup"]; IConfig startupConfig = m_config.Configs["Startup"];
m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance);
//Animation states //Animation states
m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
// TODO: Change default to true once the feature is supported // TODO: Change default to true once the feature is supported

View File

@ -690,7 +690,7 @@ namespace OpenSim.Region.Framework.Scenes
Utils.LongToUInts(handle, out x, out y); Utils.LongToUInts(handle, out x, out y);
x = x / Constants.RegionSize; x = x / Constants.RegionSize;
y = y / Constants.RegionSize; y = y / Constants.RegionSize;
if (Util.IsOutsideView(x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY))
{ {
old.Add(handle); old.Add(handle);
} }
@ -764,6 +764,7 @@ namespace OpenSim.Region.Framework.Scenes
private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this()
{ {
m_DrawDistance = world.DefaultDrawDistance;
m_rootRegionHandle = reginfo.RegionHandle; m_rootRegionHandle = reginfo.RegionHandle;
m_controllingClient = client; m_controllingClient = client;
m_firstname = m_controllingClient.FirstName; m_firstname = m_controllingClient.FirstName;
@ -1429,7 +1430,11 @@ namespace OpenSim.Region.Framework.Scenes
m_CameraUpAxis = agentData.CameraUpAxis; m_CameraUpAxis = agentData.CameraUpAxis;
// The Agent's Draw distance setting // The Agent's Draw distance setting
m_DrawDistance = agentData.Far; // When we get to the point of re-computing neighbors everytime this
// changes, then start using the agent's drawdistance rather than the
// region's draw distance.
// m_DrawDistance = agentData.Far;
m_DrawDistance = Scene.DefaultDrawDistance;
// Check if Client has camera in 'follow cam' or 'build' mode. // Check if Client has camera in 'follow cam' or 'build' mode.
Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation);
@ -3289,7 +3294,7 @@ namespace OpenSim.Region.Framework.Scenes
//m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
//m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
if (Util.IsOutsideView(x, newRegionX, y, newRegionY)) if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY))
{ {
byebyeRegions.Add(handle); byebyeRegions.Add(handle);
} }
@ -3365,7 +3370,12 @@ namespace OpenSim.Region.Framework.Scenes
Vector3 offset = new Vector3(shiftx, shifty, 0f); Vector3 offset = new Vector3(shiftx, shifty, 0f);
m_DrawDistance = cAgentData.Far; // When we get to the point of re-computing neighbors everytime this
// changes, then start using the agent's drawdistance rather than the
// region's draw distance.
// m_DrawDistance = cAgentData.Far;
m_DrawDistance = Scene.DefaultDrawDistance;
if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!!
m_pos = cAgentData.Position + offset; m_pos = cAgentData.Position + offset;
@ -3516,7 +3526,11 @@ namespace OpenSim.Region.Framework.Scenes
m_CameraLeftAxis = cAgent.LeftAxis; m_CameraLeftAxis = cAgent.LeftAxis;
m_CameraUpAxis = cAgent.UpAxis; m_CameraUpAxis = cAgent.UpAxis;
m_DrawDistance = cAgent.Far; // When we get to the point of re-computing neighbors everytime this
// changes, then start using the agent's drawdistance rather than the
// region's draw distance.
// m_DrawDistance = cAgent.Far;
m_DrawDistance = Scene.DefaultDrawDistance;
if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0)
ControllingClient.SetChildAgentThrottle(cAgent.Throttles); ControllingClient.SetChildAgentThrottle(cAgent.Throttles);

View File

@ -115,15 +115,15 @@ namespace OpenSim.Server.Handlers.Grid
case "get_region_flags": case "get_region_flags":
return GetRegionFlags(request); return GetRegionFlags(request);
} }
m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method); m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method);
} }
catch (Exception e) catch (Exception e)
{ {
m_log.DebugFormat("[GRID HANDLER]: Exception {0}", e); m_log.ErrorFormat("[GRID HANDLER]: Exception {0} {1}", e.Message, e.StackTrace);
} }
return FailureResult(); return FailureResult();
} }
#region Method-specific handlers #region Method-specific handlers

View File

@ -94,6 +94,13 @@
; Warning! Don't use this with regions that have existing content!, This will likely break them ; Warning! Don't use this with regions that have existing content!, This will likely break them
CombineContiguousRegions = false CombineContiguousRegions = false
; Extend the region's draw distance; 255m is the default which includes
; one neighbor on each side of the current region, 767m would go three
; neighbors on each side for a total of 49 regions in view. Warning, unless
; all the regions have the same drawdistance, you will end up with strange
; effects because the agents that get closed may be inconsistent.
; DefaultDrawDistance = 255.0
; If you have only one region in an instance, or to avoid the many bugs ; If you have only one region in an instance, or to avoid the many bugs
; that you can trigger in modules by restarting a region, set this to ; that you can trigger in modules by restarting a region, set this to
; true to make the entire instance exit instead of restarting the region. ; true to make the entire instance exit instead of restarting the region.