Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

bulletsim
Diva Canto 2011-05-14 12:57:34 -07:00
commit 082a9ecd31
11 changed files with 103 additions and 86 deletions

View File

@ -35,8 +35,8 @@ namespace OpenSim.Framework
public interface ILandObject
{
int GetParcelMaxPrimCount(ILandObject thisObject);
int GetSimulatorMaxPrimCount(ILandObject thisObject);
int GetParcelMaxPrimCount();
int GetSimulatorMaxPrimCount();
int GetPrimsFree();
LandData LandData { get; set; }

View File

@ -347,12 +347,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
landData.Add(parcel);
}
if (!m_merge)
m_scene.LandChannel.Clear(false);
if (!m_merge)
{
bool setupDefaultParcel = (landData.Count == 0);
m_scene.LandChannel.Clear(setupDefaultParcel);
}
m_scene.EventManager.TriggerIncomingLandDataFromStorage(landData);
m_log.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count);
m_log.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count);
}
/// <summary>

View File

@ -313,6 +313,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
Assert.That(loadedSoundAsset, Is.Not.Null, "loaded sound asset was null");
Assert.That(loadedSoundAsset.Data, Is.EqualTo(soundData), "saved and loaded sound data do not match");
Assert.Greater(m_scene.LandChannel.AllParcels().Count, 0, "incorrect number of parcels");
// Temporary
Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod());
}

View File

@ -520,8 +520,12 @@ namespace OpenSim.Region.CoreModules.World.Land
}
}
/// <summary>
/// Like handleEventManagerOnSignificantClientMovement, but called with an AgentUpdate regardless of distance.
/// </summary>
/// <param name="avatar"></param>
public void EventManagerOnClientMovement(ScenePresence avatar)
//Like handleEventManagerOnSignificantClientMovement, but called with an AgentUpdate regardless of distance.
//
{
ILandObject over = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
if (over != null)
@ -534,7 +538,6 @@ namespace OpenSim.Region.CoreModules.World.Land
}
}
public void ClientOnParcelAccessListRequest(UUID agentID, UUID sessionID, uint flags, int sequenceID,
int landLocalID, IClientAPI remote_client)
{
@ -668,14 +671,14 @@ namespace OpenSim.Region.CoreModules.World.Land
//m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID);
m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID);
}
m_landList.Clear();
ResetSimLandObjects();
if (setupDefaultParcel)
CreateDefaultParcel();
}
ResetSimLandObjects();
if (setupDefaultParcel)
CreateDefaultParcel();
}
private void performFinalLandJoin(ILandObject master, ILandObject slave)
@ -1391,8 +1394,11 @@ namespace OpenSim.Region.CoreModules.World.Land
public void EventManagerOnNoLandDataFromStorage()
{
ResetSimLandObjects();
CreateDefaultParcel();
lock (m_landList)
{
ResetSimLandObjects();
CreateDefaultParcel();
}
}
#endregion

View File

@ -67,7 +67,7 @@ namespace OpenSim.Region.CoreModules.World.Land
public int GetPrimsFree()
{
m_scene.EventManager.TriggerParcelPrimCountUpdate();
int free = GetSimulatorMaxPrimCount(this) - m_landData.SimwidePrims;
int free = GetSimulatorMaxPrimCount() - m_landData.SimwidePrims;
return free;
}
@ -181,11 +181,11 @@ namespace OpenSim.Region.CoreModules.World.Land
overrideSimulatorMaxPrimCount = overrideDel;
}
public int GetParcelMaxPrimCount(ILandObject thisObject)
public int GetParcelMaxPrimCount()
{
if (overrideParcelMaxPrimCount != null)
{
return overrideParcelMaxPrimCount(thisObject);
return overrideParcelMaxPrimCount(this);
}
else
{
@ -197,11 +197,12 @@ namespace OpenSim.Region.CoreModules.World.Land
return parcelMax;
}
}
public int GetSimulatorMaxPrimCount(ILandObject thisObject)
public int GetSimulatorMaxPrimCount()
{
if (overrideSimulatorMaxPrimCount != null)
{
return overrideSimulatorMaxPrimCount(thisObject);
return overrideSimulatorMaxPrimCount(this);
}
else
{
@ -244,8 +245,8 @@ namespace OpenSim.Region.CoreModules.World.Land
remote_client.SendLandProperties(seq_id,
snap_selection, request_result, this,
(float)m_scene.RegionInfo.RegionSettings.ObjectBonus,
GetParcelMaxPrimCount(this),
GetSimulatorMaxPrimCount(this), regionFlags);
GetParcelMaxPrimCount(),
GetSimulatorMaxPrimCount(), regionFlags);
}
public void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client)

View File

@ -70,14 +70,14 @@ namespace OpenSim.Region.CoreModules.World.Region
false, "region restart bluebox",
"region restart bluebox <message> <delta seconds>+",
"Schedule a region restart",
"Schedule a region restart after a given number of seconds. If one delta is given then the region is restarted in delta seconds time. A time to restart is sent to users in the region as a transient notice. If multiple deltas are given then a notice is sent when we reach each delta.",
"Schedule a region restart after a given number of seconds. If one delta is given then the region is restarted in delta seconds time. A time to restart is sent to users in the region as a dismissable bluebox notice. If multiple deltas are given then a notice is sent when we reach each delta.",
HandleRegionRestart);
MainConsole.Instance.Commands.AddCommand("RestartModule",
false, "region restart notice",
"region restart notice <message> <delta seconds>+",
"Schedule a region restart",
"Schedule a region restart after a given number of seconds. If one delta is given then the region is restarted in delta seconds time. A time to restart is sent to users in the region as a dismissable bluebox notice. If multiple deltas are given then a notice is sent when we reach each delta.",
"Schedule a region restart after a given number of seconds. If one delta is given then the region is restarted in delta seconds time. A time to restart is sent to users in the region as a transient notice. If multiple deltas are given then a notice is sent when we reach each delta.",
HandleRegionRestart);
MainConsole.Instance.Commands.AddCommand("RestartModule",

View File

@ -924,9 +924,9 @@ namespace OpenSim.Region.Framework.Scenes
uint callbackID, string description, string name,
sbyte invType, sbyte type, UUID olditemID)
{
m_log.DebugFormat(
"[AGENT INVENTORY]: Received request from {0} to create inventory item link {1} in folder {2} pointing to {3}",
remoteClient.Name, name, folderID, olditemID);
// m_log.DebugFormat(
// "[AGENT INVENTORY]: Received request from {0} to create inventory item link {1} in folder {2} pointing to {3}",
// remoteClient.Name, name, folderID, olditemID);
if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
return;
@ -934,20 +934,25 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence presence;
if (TryGetScenePresence(remoteClient.AgentId, out presence))
{
bool linkAlreadyExists = false;
List<InventoryItemBase> existingItems = InventoryService.GetFolderItems(remoteClient.AgentId, folderID);
foreach (InventoryItemBase item in existingItems)
if (item.AssetID == olditemID)
linkAlreadyExists = true;
if (linkAlreadyExists)
{
m_log.WarnFormat(
"[AGENT INVENTORY]: Ignoring request from {0} to create item link {1} in folder {2} pointing to {3} since a link already exists",
remoteClient.Name, name, folderID, olditemID);
return;
}
// Disabled the check for duplicate links.
//
// When outfits are being adjusted, the viewer rapidly sends delete link messages followed by
// create links. However, since these are handled asynchronously, the deletes do not complete before
// the creates are handled. Therefore, we cannot enforce a duplicate link check.
// InventoryItemBase existingLink = null;
// List<InventoryItemBase> existingItems = InventoryService.GetFolderItems(remoteClient.AgentId, folderID);
// foreach (InventoryItemBase item in existingItems)
// if (item.AssetID == olditemID)
// existingLink = item;
//
// if (existingLink != null)
// {
// m_log.WarnFormat(
// "[AGENT INVENTORY]: Ignoring request from {0} to create item link {1} in folder {2} pointing to {3} since a link named {4} with id {5} already exists",
// remoteClient.Name, name, folderID, olditemID, existingLink.Name, existingLink.ID);
//
// return;
// }
AssetBase asset = new AssetBase();
asset.FullID = olditemID;
@ -975,7 +980,11 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="itemID"></param>
private void RemoveInventoryItem(IClientAPI remoteClient, List<UUID> itemIDs)
{
//m_log.Debug("[SCENE INVENTORY]: user " + remoteClient.AgentId);
// m_log.DebugFormat(
// "[AGENT INVENTORY]: Removing inventory items {0} for {1}",
// string.Join(",", itemIDs.ConvertAll<string>(uuid => uuid.ToString()).ToArray()),
// remoteClient.Name);
InventoryService.DeleteItems(remoteClient.AgentId, itemIDs);
}

View File

@ -76,22 +76,24 @@ namespace OpenSim.Region.OptionalModules
public void AddRegion(Scene scene)
{
if(!m_enabled)
if (!m_enabled)
{
return;
}
scene.Permissions.OnRezObject += CanRezObject;
scene.Permissions.OnObjectEntry += CanObjectEnter;
scene.Permissions.OnDuplicateObject += CanDuplicateObject;
m_log.DebugFormat("[PRIM LIMITS]: Region {0} added", scene.RegionInfo.RegionName);
}
public void RemoveRegion(Scene scene)
{
if(m_enabled)
if (m_enabled)
{
return;
}
scene.Permissions.OnRezObject -= CanRezObject;
scene.Permissions.OnObjectEntry -= CanObjectEnter;
scene.Permissions.OnDuplicateObject -= CanDuplicateObject;
@ -104,13 +106,11 @@ namespace OpenSim.Region.OptionalModules
private bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition, Scene scene)
{
// This may be a little long winded and can probably be optomized
int usedPrims = scene.LandChannel.GetLandObject(objectPosition.X,objectPosition.Y).PrimCounts.Total;
LandData landData = scene.LandChannel.GetLandObject(objectPosition.X,objectPosition.Y).LandData;
int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) *
(float)scene.RegionInfo.ObjectCapacity * (float)scene.RegionInfo.RegionSettings.ObjectBonus);
ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
int usedPrims = lo.PrimCounts.Total;
int simulatorCapacity = lo.GetSimulatorMaxPrimCount();
if(objectCount + usedPrims > simulatorCapacity)
if (objectCount + usedPrims > simulatorCapacity)
{
m_dialogModule.SendAlertToUser(owner, "Unable to rez object because the parcel is too full");
return false;
@ -118,7 +118,7 @@ namespace OpenSim.Region.OptionalModules
return true;
}
//OnMoveObject
private bool CanObjectEnter(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene)
{
SceneObjectPart obj = scene.GetSceneObjectPart(objectID);
@ -126,11 +126,9 @@ namespace OpenSim.Region.OptionalModules
int objectCount = obj.ParentGroup.PrimCount;
ILandObject oldParcel = scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
ILandObject newParcel = scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y);
int usedPrims=newParcel.PrimCounts.Total;
LandData landData = newParcel.LandData;
int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) *
(float)scene.RegionInfo.ObjectCapacity * (float)scene.RegionInfo.RegionSettings.ObjectBonus);
int usedPrims = newParcel.PrimCounts.Total;
int simulatorCapacity = newParcel.GetSimulatorMaxPrimCount();
// The prim hasn't crossed a region boundry so we don't need to worry
// about prim counts here
@ -138,36 +136,39 @@ namespace OpenSim.Region.OptionalModules
{
return true;
}
// Prim counts are determined by the location of the root prim. if we're
// moving a child prim, just let it pass
if(!obj.IsRoot)
{
return true;
}
// Add Special Case here for temporary prims
// TODO: Add Special Case here for temporary prims
if(objectCount + usedPrims > simulatorCapacity)
{
m_dialogModule.SendAlertToUser(obj.OwnerID, "Unable to move object because the destination parcel is too full");
return false;
}
return true;
}
//OnDuplicateObject
private bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition)
{
// This may be a little long winded and can probably be optomized
int usedPrims = scene.LandChannel.GetLandObject(objectPosition.X,objectPosition.Y).PrimCounts.Total;
LandData landData = scene.LandChannel.GetLandObject(objectPosition.X,objectPosition.Y).LandData;
int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) *
(float)scene.RegionInfo.ObjectCapacity * (float)scene.RegionInfo.RegionSettings.ObjectBonus);
ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
int usedPrims = lo.PrimCounts.Total;
int simulatorCapacity = lo.GetSimulatorMaxPrimCount();
if(objectCount + usedPrims > simulatorCapacity)
{
m_dialogModule.SendAlertToUser(owner, "Unable to duplicate object because the parcel is too full");
return false;
}
return true;
}
}
}
}

View File

@ -9908,31 +9908,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llGetParcelMaxPrims(LSL_Vector pos, int sim_wide)
{
m_host.AddScriptLPS(1);
// Alondria: This currently just is utilizing the normal grid's 0.22 prims/m2 calculation
// Which probably will be irrelevent in OpenSim....
LandData land = World.GetLandData((float)pos.x, (float)pos.y);
float bonusfactor = (float)World.RegionInfo.RegionSettings.ObjectBonus;
ILandObject lo = World.LandChannel.GetLandObject((float)pos.x, (float)pos.y);
if (land == null)
{
if (lo == null)
return 0;
}
if (sim_wide != 0)
{
decimal v = land.SimwideArea * (decimal)(0.22) * (decimal)bonusfactor;
return (int)v;
}
return lo.GetSimulatorMaxPrimCount();
else
{
decimal v = land.Area * (decimal)(0.22) * (decimal)bonusfactor;
return (int)v;
}
return lo.GetParcelMaxPrimCount();
}
public LSL_List llGetParcelDetails(LSL_Vector pos, LSL_List param)

View File

@ -30,6 +30,7 @@ using System.Collections;
using System.IO;
using System.Net;
using System.Reflection;
using System.Security;
using System.Text;
using log4net;
using Nini.Config;
@ -143,7 +144,7 @@ namespace OpenSim.Server.Handlers.Grid
sb.Append("<gridinfo>\n");
foreach (string k in _info.Keys)
{
sb.AppendFormat("<{0}>{1}</{0}>\n", k, _info[k]);
sb.AppendFormat("<{0}>{1}</{0}>\n", k, SecurityElement.Escape(_info[k].ToString()));
}
sb.Append("</gridinfo>\n");

View File

@ -40,10 +40,12 @@ namespace OpenSim.Tests.Common.Mock
public class TestLandChannel : ILandChannel
{
private Scene m_scene;
private List<ILandObject> m_parcels;
public TestLandChannel(Scene scene)
{
m_scene = scene;
m_parcels = new List<ILandObject>();
}
public List<ILandObject> ParcelsNearPoint(Vector3 position)
@ -53,12 +55,19 @@ namespace OpenSim.Tests.Common.Mock
public List<ILandObject> AllParcels()
{
return new List<ILandObject>();
return m_parcels;
}
public void Clear(bool setupDefaultParcel)
{
// Intentionally blank since we don't save any parcel data in the test channel
m_parcels.Clear();
if (setupDefaultParcel)
{
ILandObject obj = new LandObject(UUID.Zero, false, m_scene);
obj.LandData.Name = "Your Parcel";
m_parcels.Add(obj);
}
}
protected ILandObject GetNoLand()