From 567f4c51f85e61205c8b1caaab207bc6f979f04f Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 2 Feb 2012 01:52:17 +0000 Subject: [PATCH 1/7] Improve reliability of script state saving by covering various saving and loading scenarios which resulted in loss of continuity on item ids --- OpenSim/Framework/TaskInventoryItem.cs | 11 ++++++++ .../Scenes/SceneObjectPartInventory.cs | 26 ++++++++++++------- .../Serialization/SceneObjectSerializer.cs | 5 +--- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs index ba2a306c4e..d4bbbfb7c9 100644 --- a/OpenSim/Framework/TaskInventoryItem.cs +++ b/OpenSim/Framework/TaskInventoryItem.cs @@ -65,6 +65,7 @@ namespace OpenSim.Framework private int _permsMask; private int _type = 0; private UUID _oldID; + private UUID _loadedID = UUID.Zero; private bool _ownerChanged = false; @@ -231,6 +232,15 @@ namespace OpenSim.Framework } } + public UUID LoadedItemID { + get { + return _loadedID; + } + set { + _loadedID = value; + } + } + public UUID LastOwnerID { get { return _lastOwnerID; @@ -347,6 +357,7 @@ namespace OpenSim.Framework /// The new part ID to which this item belongs public void ResetIDs(UUID partID) { + LoadedItemID = OldItemID; OldItemID = ItemID; ItemID = UUID.Random(); ParentPartID = partID; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index daddb90684..0c36dcd686 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -307,14 +307,15 @@ namespace OpenSim.Region.Framework.Scenes else { if (m_part.ParentGroup.m_savedScriptState != null) - RestoreSavedScriptState(item.OldItemID, item.ItemID); + item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); lock (m_items) { + m_items[item.ItemID].OldItemID = item.OldItemID; m_items[item.ItemID].PermsMask = 0; m_items[item.ItemID].PermsGranter = UUID.Zero; } - + string script = Utils.BytesToString(asset.Data); m_part.ParentGroup.Scene.EventManager.TriggerRezScript( m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); @@ -324,17 +325,20 @@ namespace OpenSim.Region.Framework.Scenes } } - private void RestoreSavedScriptState(UUID oldID, UUID newID) + private UUID RestoreSavedScriptState(UUID loadedID, UUID oldID, UUID newID) { IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); if (engines.Length == 0) // No engine at all - return; + return oldID; - if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) + UUID stateID = oldID; + if (!m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) + stateID = loadedID; + if (m_part.ParentGroup.m_savedScriptState.ContainsKey(stateID)) { XmlDocument doc = new XmlDocument(); - doc.LoadXml(m_part.ParentGroup.m_savedScriptState[oldID]); + doc.LoadXml(m_part.ParentGroup.m_savedScriptState[stateID]); ////////// CRUFT WARNING /////////////////////////////////// // @@ -351,7 +355,7 @@ namespace OpenSim.Region.Framework.Scenes XmlElement rootN = newDoc.CreateElement("", "State", ""); XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", ""); - uuidA.Value = oldID.ToString(); + uuidA.Value = stateID.ToString(); rootN.Attributes.Append(uuidA); XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", ""); engineA.Value = "XEngine"; @@ -365,20 +369,22 @@ namespace OpenSim.Region.Framework.Scenes // This created document has only the minimun data // necessary for XEngine to parse it successfully - m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml; + m_part.ParentGroup.m_savedScriptState[stateID] = newDoc.OuterXml; } foreach (IScriptModule e in engines) { if (e != null) { - if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID])) + if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[stateID])) break; } } - m_part.ParentGroup.m_savedScriptState.Remove(oldID); + m_part.ParentGroup.m_savedScriptState.Remove(stateID); } + + return stateID; } /// diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 3a08271c4f..b54fcb757e 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -794,10 +794,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader) { - Util.ReadUUID(reader, "OldItemID"); - // On deserialization, the old item id MUST BE UUID.Zero!!!!! - // Setting this to the saved value will BREAK script persistence! - // item.OldItemID = Util.ReadUUID(reader, "OldItemID"); + item.OldItemID = Util.ReadUUID(reader, "OldItemID"); } private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader) From dbf6381e3485ca63108f13f232be0b9cbfd6290d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 2 Feb 2012 08:39:23 -0800 Subject: [PATCH 2/7] OpenID: server connector had a copy-and-paste error that made identity queries fail. --- OpenSim/Server/Handlers/Authentication/OpenIdServerConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Server/Handlers/Authentication/OpenIdServerConnector.cs b/OpenSim/Server/Handlers/Authentication/OpenIdServerConnector.cs index a0a92edc32..6464399f93 100644 --- a/OpenSim/Server/Handlers/Authentication/OpenIdServerConnector.cs +++ b/OpenSim/Server/Handlers/Authentication/OpenIdServerConnector.cs @@ -63,7 +63,7 @@ namespace OpenSim.Server.Handlers.Authentication Object[] args = new Object[] { config }; m_AuthenticationService = ServerUtils.LoadPlugin(authService, args); - m_UserAccountService = ServerUtils.LoadPlugin(authService, args); + m_UserAccountService = ServerUtils.LoadPlugin(userService, args); // Handler for OpenID user identity pages server.AddStreamHandler(new OpenIdStreamHandler("GET", "/users/", m_UserAccountService, m_AuthenticationService)); From 17df4185ce09f7fb911dc72e1974231a1ff14a12 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 2 Feb 2012 18:42:27 +0000 Subject: [PATCH 3/7] Add stress tests for simple object add of 100 prim objects. Add time taken to output (this is unreliable). --- OpenSim/Tests/Torture/ObjectTortureTests.cs | 51 +++++++++++++++------ 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/OpenSim/Tests/Torture/ObjectTortureTests.cs b/OpenSim/Tests/Torture/ObjectTortureTests.cs index cdbaa66c63..b9764d767d 100644 --- a/OpenSim/Tests/Torture/ObjectTortureTests.cs +++ b/OpenSim/Tests/Torture/ObjectTortureTests.cs @@ -59,33 +59,60 @@ namespace OpenSim.Tests.Torture // } [Test] - public void Test0001TenThousandObjects() + public void Test0001_10K_1PrimObjects() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - TestAddObjects(10000); + TestAddObjects(1, 10000); } [Test] - public void Test0002OneHundredThousandObjects() + public void Test0002_100K_1PrimObjects() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - TestAddObjects(100000); + TestAddObjects(1, 100000); } [Test] - public void Test0003TwoHundredThousandObjects() + public void Test0003_200K_1PrimObjects() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - TestAddObjects(200000); + TestAddObjects(1, 200000); } - private void TestAddObjects(int objectsToAdd) + [Test] + public void Test0011_100_100PrimObjects() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + TestAddObjects(100, 100); + } + + [Test] + public void Test0012_1K_100PrimObjects() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + TestAddObjects(100, 1000); + } + + [Test] + public void Test0013_2K_100PrimObjects() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + TestAddObjects(100, 2000); + } + + private void TestAddObjects(int primsInEachObject, int objectsToAdd) { UUID ownerId = new UUID("F0000000-0000-0000-0000-000000000000"); @@ -98,7 +125,7 @@ namespace OpenSim.Tests.Torture for (int i = 1; i <= objectsToAdd; i++) { - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId, "part_", i); + SceneObjectGroup so = SceneHelpers.CreateSceneObject(primsInEachObject, ownerId, "part_", i); Assert.That(scene.AddNewSceneObject(so, false), Is.True, string.Format("Object {0} was not created", i)); } @@ -114,13 +141,9 @@ namespace OpenSim.Tests.Torture string.Format("Object {0} could not be retrieved", i)); } -// Console.WriteLine( -// "Took {0}ms, {1}MB to create {2} single prim scene objects", -// elapsed.Milliseconds, processGcAlloc / 1024 / 1024, objectsToAdd); - Console.WriteLine( - "Took {0}MB to create {1} single prim scene objects", - processGcAlloc / 1024 / 1024, objectsToAdd); + "Took {0}ms, {1}MB to create {2} objects each containing {3} prim(s)", + Math.Round(elapsed.TotalMilliseconds), processGcAlloc / 1024 / 1024, objectsToAdd, primsInEachObject); } } } \ No newline at end of file From 264c83aec4151a93647c14e317067d8646f38680 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 2 Feb 2012 22:48:36 +0000 Subject: [PATCH 4/7] Add llGetLinkNumberOfSides to LSL_Stub and ILSL_Api It already existed in LSL_Api but it also needs to exist in these two other places for a script to be able to see it. Hopefully resolves http://opensimulator.org/mantis/view.php?id=5489 --- OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 3 ++- OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index b66537f544..6106a653b5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -138,7 +138,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Key llGetLinkKey(int linknum); LSL_String llGetLinkName(int linknum); LSL_Integer llGetLinkNumber(); - LSL_List llGetLinkPrimitiveParams(int linknum, LSL_List rules); + LSL_Integer llGetLinkNumberOfSides(int link); + LSL_List llGetLinkPrimitiveParams(int linknum, LSL_List rules); LSL_Integer llGetListEntryType(LSL_List src, int index); LSL_Integer llGetListLength(LSL_List src); LSL_Vector llGetLocalPos(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 840d3a4ec6..d1a5e2f585 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -539,6 +539,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetLinkNumber(); } + public LSL_Integer llGetLinkNumberOfSides(int link) + { + return m_LSL_Functions.llGetLinkNumber(); + } + public LSL_Integer llGetListEntryType(LSL_List src, int index) { return m_LSL_Functions.llGetListEntryType(src, index); From 54d473e2000643d083e51a09ca31b1cd54de363b Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 2 Feb 2012 23:35:16 +0000 Subject: [PATCH 5/7] D'oh - we want to call llGetLinkNumberOfSides() in the LSL_Stub, not llGetLinkNumber(). --- OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index d1a5e2f585..83550a5933 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -541,7 +541,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public LSL_Integer llGetLinkNumberOfSides(int link) { - return m_LSL_Functions.llGetLinkNumber(); + return m_LSL_Functions.llGetLinkNumberOfSides(link); } public LSL_Integer llGetListEntryType(LSL_List src, int index) From 447a66d66005c5ec54a786d1d0a532738729251c Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 2 Feb 2012 23:40:56 +0000 Subject: [PATCH 6/7] Replace ParcelAccessEntry with a new struct, LandAccessEntry, which more accurately reflects the data sent by the viewer. Add times bans and the expiration of timed bans. Warning: Contains a Migration (and nuts) --- OpenSim/Data/MSSQL/MSSQLSimulationData.cs | 12 +-- OpenSim/Data/MySQL/MySQLSimulationData.cs | 17 ++-- .../MySQL/Resources/RegionStore.migrations | 6 ++ OpenSim/Data/SQLite/SQLiteSimulationData.cs | 12 +-- OpenSim/Framework/IClientAPI.cs | 4 +- OpenSim/Framework/ILandObject.cs | 4 +- OpenSim/Framework/LandData.cs | 19 ++-- .../External/LandDataSerializer.cs | 12 ++- .../Tests/LandDataSerializerTests.cs | 12 +-- .../ClientStack/Linden/UDP/LLClientView.cs | 14 +-- .../World/Land/LandManagementModule.cs | 4 +- .../CoreModules/World/Land/LandObject.cs | 84 +++++++++++----- .../Server/IRCClientView.cs | 2 +- .../OptionalModules/World/NPC/NPCAvatar.cs | 2 +- .../Shared/Api/Implementation/LSL_Api.cs | 99 +++++++++++++------ OpenSim/Tests/Common/Mock/TestClient.cs | 2 +- 16 files changed, 197 insertions(+), 108 deletions(-) diff --git a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs index bb59bba927..be60d4cf65 100644 --- a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs +++ b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs @@ -681,7 +681,7 @@ VALUES using (SqlCommand cmd = new SqlCommand(sql, conn)) { conn.Open(); - foreach (ParcelManager.ParcelAccessEntry parcelAccessEntry in parcel.LandData.ParcelAccessList) + foreach (LandAccessEntry parcelAccessEntry in parcel.LandData.ParcelAccessList) { cmd.Parameters.AddRange(CreateLandAccessParameters(parcelAccessEntry, parcel.RegionUUID)); @@ -1453,7 +1453,7 @@ VALUES _Log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); } - newData.ParcelAccessList = new List(); + newData.ParcelAccessList = new List(); return newData; } @@ -1463,12 +1463,12 @@ VALUES /// /// datarecord with landaccess data /// - private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataRecord row) + private static LandAccessEntry BuildLandAccessData(IDataRecord row) { - ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + LandAccessEntry entry = new LandAccessEntry(); entry.AgentID = new UUID((Guid)row["AccessUUID"]); entry.Flags = (AccessList)Convert.ToInt32(row["Flags"]); - entry.Time = new DateTime(); + entry.Expires = 0; return entry; } @@ -1851,7 +1851,7 @@ VALUES /// parcel access entry. /// parcel ID. /// - private SqlParameter[] CreateLandAccessParameters(ParcelManager.ParcelAccessEntry parcelAccessEntry, UUID parcelID) + private SqlParameter[] CreateLandAccessParameters(LandAccessEntry parcelAccessEntry, UUID parcelID) { List parameters = new List(); diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 3123edfe7b..32751468a0 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -700,10 +700,10 @@ namespace OpenSim.Data.MySQL cmd.Parameters.Clear(); cmd.CommandText = "insert into landaccesslist (LandUUID, " + - "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " + - "?Flags)"; + "AccessUUID, Flags, Expires) values (?LandUUID, ?AccessUUID, " + + "?Flags, ?Expires)"; - foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList) + foreach (LandAccessEntry entry in parcel.LandData.ParcelAccessList) { FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID); ExecuteNonQuery(cmd); @@ -1377,7 +1377,7 @@ namespace OpenSim.Data.MySQL newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]); newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]); - newData.ParcelAccessList = new List(); + newData.ParcelAccessList = new List(); return newData; } @@ -1387,12 +1387,12 @@ namespace OpenSim.Data.MySQL /// /// /// - private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataReader row) + private static LandAccessEntry BuildLandAccessData(IDataReader row) { - ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + LandAccessEntry entry = new LandAccessEntry(); entry.AgentID = DBGuid.FromDB(row["AccessUUID"]); entry.Flags = (AccessList) Convert.ToInt32(row["Flags"]); - entry.Time = new DateTime(); + entry.Expires = Convert.ToInt32(row["Expires"]); return entry; } @@ -1697,11 +1697,12 @@ namespace OpenSim.Data.MySQL /// /// /// - private static void FillLandAccessCommand(MySqlCommand cmd, ParcelManager.ParcelAccessEntry entry, UUID parcelID) + private static void FillLandAccessCommand(MySqlCommand cmd, LandAccessEntry entry, UUID parcelID) { cmd.Parameters.AddWithValue("LandUUID", parcelID.ToString()); cmd.Parameters.AddWithValue("AccessUUID", entry.AgentID.ToString()); cmd.Parameters.AddWithValue("Flags", entry.Flags); + cmd.Parameters.AddWithValue("Expires", entry.Expires.ToString()); } /// diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index f9b5737c78..642e3b7517 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -863,3 +863,9 @@ BEGIN; ALTER TABLE `regionsettings` ADD COLUMN `parcel_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; COMMIT; +:VERSION 41 #---------------- Timed bans/access + +BEGIN; +ALTER TABLE `landaccesslist` ADD COLUMN `Expires` INTEGER NOT NULL DEFAULT 0; +COMMIT; + diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs index 5618772a41..2d06f82ad8 100644 --- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs +++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs @@ -759,7 +759,7 @@ namespace OpenSim.Data.SQLite landaccesslist.Rows.Remove(rowsToDelete[iter]); } rowsToDelete.Clear(); - foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList) + foreach (LandAccessEntry entry in parcel.LandData.ParcelAccessList) { DataRow newAccessRow = landaccesslist.NewRow(); fillLandAccessRow(newAccessRow, entry, parcel.LandData.GlobalID); @@ -1456,7 +1456,7 @@ namespace OpenSim.Data.SQLite newData.UserLocation = Vector3.Zero; newData.UserLookAt = Vector3.Zero; } - newData.ParcelAccessList = new List(); + newData.ParcelAccessList = new List(); UUID authBuyerID = UUID.Zero; UUID.TryParse((string)row["AuthbuyerID"], out authBuyerID); @@ -1519,12 +1519,12 @@ namespace OpenSim.Data.SQLite /// /// /// - private static ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) + private static LandAccessEntry buildLandAccessData(DataRow row) { - ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + LandAccessEntry entry = new LandAccessEntry(); entry.AgentID = new UUID((string) row["AccessUUID"]); entry.Flags = (AccessList) row["Flags"]; - entry.Time = new DateTime(); + entry.Expires = 0; return entry; } @@ -1787,7 +1787,7 @@ namespace OpenSim.Data.SQLite /// /// /// - private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, UUID parcelID) + private static void fillLandAccessRow(DataRow row, LandAccessEntry entry, UUID parcelID) { row["LandUUID"] = parcelID.ToString(); row["AccessUUID"] = entry.AgentID.ToString(); diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 1326fe9dd6..dd3e6567ec 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -177,7 +177,7 @@ namespace OpenSim.Framework public delegate void ParcelAccessListUpdateRequest(UUID agentID, uint flags, int landLocalID, UUID transactionID, int sequenceID, - int sections, List entries, + int sections, List entries, IClientAPI remote_client); public delegate void ParcelPropertiesRequest( @@ -1251,7 +1251,7 @@ namespace OpenSim.Framework float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags); - void SendLandAccessListData(List avatars, uint accessFlag, int localLandID); + void SendLandAccessListData(List accessList, uint accessFlag, int localLandID); void SendForceClientSelectObjects(List objectIDs); void SendCameraConstraint(Vector4 ConstraintPlane); void SendLandObjectOwners(LandData land, List groups, Dictionary ownersAndCount); diff --git a/OpenSim/Framework/ILandObject.cs b/OpenSim/Framework/ILandObject.cs index f75a9908c9..dd73b3fe01 100644 --- a/OpenSim/Framework/ILandObject.cs +++ b/OpenSim/Framework/ILandObject.cs @@ -73,9 +73,9 @@ namespace OpenSim.Framework bool IsRestrictedFromLand(UUID avatar); void SendLandUpdateToClient(IClientAPI remote_client); void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client); - List CreateAccessListArrayByFlag(AccessList flag); + List CreateAccessListArrayByFlag(AccessList flag); void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID, IClientAPI remote_client); - void UpdateAccessList(uint flags, UUID transactionID, int sequenceID, int sections, List entries, IClientAPI remote_client); + void UpdateAccessList(uint flags, UUID transactionID, int sequenceID, int sections, List entries, IClientAPI remote_client); void UpdateLandBitmapByteArray(); void SetLandBitmapFromByteArray(); bool[,] GetLandBitmap(); diff --git a/OpenSim/Framework/LandData.cs b/OpenSim/Framework/LandData.cs index c107143a6c..58a80efe75 100644 --- a/OpenSim/Framework/LandData.cs +++ b/OpenSim/Framework/LandData.cs @@ -34,6 +34,13 @@ using OpenMetaverse; namespace OpenSim.Framework { + public struct LandAccessEntry + { + public UUID AgentID; + public int Expires; + public AccessList Flags; + } + /// /// Details of a Parcel of land /// @@ -73,7 +80,7 @@ namespace OpenSim.Framework private string _mediaURL = String.Empty; private string _musicURL = String.Empty; private UUID _ownerID = UUID.Zero; - private List _parcelAccessList = new List(); + private List _parcelAccessList = new List(); private float _passHours = 0; private int _passPrice = 0; private int _salePrice = 0; //Unemeplemented. Parcels price. @@ -450,7 +457,7 @@ namespace OpenSim.Framework /// /// List of access data for the parcel. User data, some bitflags, and a time /// - public List ParcelAccessList { + public List ParcelAccessList { get { return _parcelAccessList; } @@ -638,12 +645,12 @@ namespace OpenSim.Framework landData._simwidePrims = _simwidePrims; landData._parcelAccessList.Clear(); - foreach (ParcelManager.ParcelAccessEntry entry in _parcelAccessList) + foreach (LandAccessEntry entry in _parcelAccessList) { - ParcelManager.ParcelAccessEntry newEntry = new ParcelManager.ParcelAccessEntry(); + LandAccessEntry newEntry = new LandAccessEntry(); newEntry.AgentID = entry.AgentID; newEntry.Flags = entry.Flags; - newEntry.Time = entry.Time; + newEntry.Expires = entry.Expires; landData._parcelAccessList.Add(newEntry); } @@ -668,4 +675,4 @@ namespace OpenSim.Framework return land; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs index fc0387b76c..c61b9e8ecc 100644 --- a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs +++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs @@ -90,7 +90,7 @@ namespace OpenSim.Framework.Serialization.External landData.MusicURL = xtr.ReadElementString("MusicURL"); landData.OwnerID = UUID.Parse( xtr.ReadElementString("OwnerID")); - landData.ParcelAccessList = new List(); + landData.ParcelAccessList = new List(); xtr.Read(); if (xtr.Name != "ParcelAccessList") throw new XmlException(String.Format("Expected \"ParcelAccessList\" element but got \"{0}\"", xtr.Name)); @@ -99,11 +99,13 @@ namespace OpenSim.Framework.Serialization.External { while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement) { - ParcelManager.ParcelAccessEntry pae = new ParcelManager.ParcelAccessEntry(); + LandAccessEntry pae = new LandAccessEntry(); xtr.ReadStartElement("ParcelAccessEntry"); pae.AgentID = UUID.Parse( xtr.ReadElementString("AgentID")); - pae.Time = Convert.ToDateTime( xtr.ReadElementString("Time")); + // We really don't care about temp vs perm here and this + // would break on old oars. Assume all bans are perm + pae.Expires = 0; // Convert.ToUint( xtr.ReadElementString("Time")); pae.Flags = (AccessList)Convert.ToUInt32( xtr.ReadElementString("AccessList")); xtr.ReadEndElement(); @@ -162,11 +164,11 @@ namespace OpenSim.Framework.Serialization.External xtw.WriteElementString("OwnerID", landData.OwnerID.ToString()); xtw.WriteStartElement("ParcelAccessList"); - foreach (ParcelManager.ParcelAccessEntry pal in landData.ParcelAccessList) + foreach (LandAccessEntry pal in landData.ParcelAccessList) { xtw.WriteStartElement("ParcelAccessEntry"); xtw.WriteElementString("AgentID", pal.AgentID.ToString()); - xtw.WriteElementString("Time", pal.Time.ToString("s")); + xtw.WriteElementString("Time", pal.Expires.ToString()); xtw.WriteElementString("AccessList", Convert.ToString((uint)pal.Flags)); xtw.WriteEndElement(); } diff --git a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs index c69c89dc0a..3607ce8e42 100644 --- a/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs +++ b/OpenSim/Framework/Serialization/Tests/LandDataSerializerTests.cs @@ -42,7 +42,7 @@ namespace OpenSim.Framework.Serialization.Tests private LandData landWithParcelAccessList; private static string preSerialized = "\n\n 128\n 0\n 00000000-0000-0000-0000-000000000000\n 10\n 0\n 0\n 54ff9641-dd40-4a2c-b1f1-47dd3af24e50\n d740204e-bbbf-44aa-949d-02c7d739f6a5\n False\n AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n land data to test LandDataSerializer\n 536870944\n 2\n LandDataSerializerTest Land\n 0\n 0\n 1\n d4452578-2f25-4b97-a81b-819af559cfd7\n http://videos.opensimulator.org/bumblebee.mp4\n \n 1b8eedf9-6d15-448b-8015-24286f1756bf\n \n 0\n 0\n 0\n 00000000-0000-0000-0000-000000000000\n <0, 0, 0>\n <0, 0, 0>\n 0\n 0\n"; - private static string preSerializedWithParcelAccessList = "\n\n 128\n 0\n 00000000-0000-0000-0000-000000000000\n 10\n 0\n 0\n 54ff9641-dd40-4a2c-b1f1-47dd3af24e50\n d740204e-bbbf-44aa-949d-02c7d739f6a5\n False\n AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n land data to test LandDataSerializer\n 536870944\n 2\n LandDataSerializerTest Land\n 0\n 0\n 1\n d4452578-2f25-4b97-a81b-819af559cfd7\n http://videos.opensimulator.org/bumblebee.mp4\n \n 1b8eedf9-6d15-448b-8015-24286f1756bf\n \n \n 62d65d45-c91a-4f77-862c-46557d978b6c\n \n 2\n \n \n ec2a8d18-2378-4fe0-8b68-2a31b57c481e\n \n 1\n \n \n 0\n 0\n 0\n 00000000-0000-0000-0000-000000000000\n <0, 0, 0>\n <0, 0, 0>\n 0\n 0\n"; + private static string preSerializedWithParcelAccessList = "\n\n 128\n 0\n 00000000-0000-0000-0000-000000000000\n 10\n 0\n 0\n 54ff9641-dd40-4a2c-b1f1-47dd3af24e50\n d740204e-bbbf-44aa-949d-02c7d739f6a5\n False\n AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n land data to test LandDataSerializer\n 536870944\n 2\n LandDataSerializerTest Land\n 0\n 0\n 1\n d4452578-2f25-4b97-a81b-819af559cfd7\n http://videos.opensimulator.org/bumblebee.mp4\n \n 1b8eedf9-6d15-448b-8015-24286f1756bf\n \n \n 62d65d45-c91a-4f77-862c-46557d978b6c\n \n 2\n \n \n ec2a8d18-2378-4fe0-8b68-2a31b57c481e\n \n 1\n \n \n 0\n 0\n 0\n 00000000-0000-0000-0000-000000000000\n <0, 0, 0>\n <0, 0, 0>\n 0\n 0\n"; [SetUp] public void setup() @@ -73,16 +73,16 @@ namespace OpenSim.Framework.Serialization.Tests this.landWithParcelAccessList = this.land.Copy(); this.landWithParcelAccessList.ParcelAccessList.Clear(); - ParcelManager.ParcelAccessEntry pae0 = new ParcelManager.ParcelAccessEntry(); + LandAccessEntry pae0 = new LandAccessEntry(); pae0.AgentID = new UUID("62d65d45-c91a-4f77-862c-46557d978b6c"); pae0.Flags = AccessList.Ban; - pae0.Time = new DateTime(2009, 10, 01); + pae0.Expires = 0; this.landWithParcelAccessList.ParcelAccessList.Add(pae0); - ParcelManager.ParcelAccessEntry pae1 = new ParcelManager.ParcelAccessEntry(); + LandAccessEntry pae1 = new LandAccessEntry(); pae1.AgentID = new UUID("ec2a8d18-2378-4fe0-8b68-2a31b57c481e"); pae1.Flags = AccessList.Access; - pae1.Time = new DateTime(2010, 10, 20); + pae1.Expires = 0; this.landWithParcelAccessList.ParcelAccessList.Add(pae1); } @@ -128,4 +128,4 @@ namespace OpenSim.Framework.Serialization.Tests "Reified LandData.Name != original LandData.Name (pre-serialized with parcel access list)"); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index a7bf06d7a2..cdd4957b79 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -4623,7 +4623,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - public void SendLandAccessListData(List avatars, uint accessFlag, int localLandID) + public void SendLandAccessListData(List accessList, uint accessFlag, int localLandID) { ParcelAccessListReplyPacket replyPacket = (ParcelAccessListReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply); replyPacket.Data.AgentID = AgentId; @@ -4632,12 +4632,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP replyPacket.Data.SequenceID = 0; List list = new List(); - foreach (UUID avatar in avatars) + foreach (LandAccessEntry entry in accessList) { ParcelAccessListReplyPacket.ListBlock block = new ParcelAccessListReplyPacket.ListBlock(); block.Flags = accessFlag; - block.ID = avatar; - block.Time = 0; + block.ID = entry.AgentID; + block.Time = entry.Expires; list.Add(block); } @@ -8577,13 +8577,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - List entries = new List(); + List entries = new List(); foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List) { - ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + LandAccessEntry entry = new LandAccessEntry(); entry.AgentID = block.ID; entry.Flags = (AccessList)block.Flags; - entry.Time = Util.ToDateTime(block.Time); + entry.Expires = block.Time; entries.Add(entry); } diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 94bba83bfb..1c503aa8c3 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -550,7 +550,7 @@ namespace OpenSim.Region.CoreModules.World.Land public void ClientOnParcelAccessListUpdateRequest(UUID agentID, uint flags, int landLocalID, UUID transactionID, int sequenceID, - int sections, List entries, + int sections, List entries, IClientAPI remote_client) { // Flags is the list to update, it can mean either the ban or @@ -1712,4 +1712,4 @@ namespace OpenSim.Region.CoreModules.World.Land MainConsole.Instance.Output(report.ToString()); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 79b13c3779..3b4336f108 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -418,13 +418,21 @@ namespace OpenSim.Region.CoreModules.World.Land public bool IsBannedFromLand(UUID avatar) { - if (m_scene.Permissions.CanEditParcelProperties(avatar, this, 0)) + ExpireAccessList(); + + if (m_scene.Permissions.IsAdministrator(avatar)) + return false; + + if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar)) + return false; + + if (avatar == LandData.OwnerID) return false; if ((LandData.Flags & (uint) ParcelFlags.UseBanList) > 0) { if (LandData.ParcelAccessList.FindIndex( - delegate(ParcelManager.ParcelAccessEntry e) + delegate(LandAccessEntry e) { if (e.AgentID == avatar && e.Flags == AccessList.Ban) return true; @@ -439,13 +447,21 @@ namespace OpenSim.Region.CoreModules.World.Land public bool IsRestrictedFromLand(UUID avatar) { - if (m_scene.Permissions.CanEditParcelProperties(avatar, this, 0)) + ExpireAccessList(); + + if (m_scene.Permissions.IsAdministrator(avatar)) + return false; + + if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar)) + return false; + + if (avatar == LandData.OwnerID) return false; if ((LandData.Flags & (uint) ParcelFlags.UseAccessList) > 0) { if (LandData.ParcelAccessList.FindIndex( - delegate(ParcelManager.ParcelAccessEntry e) + delegate(LandAccessEntry e) { if (e.AgentID == avatar && e.Flags == AccessList.Access) return true; @@ -511,19 +527,24 @@ namespace OpenSim.Region.CoreModules.World.Land #region AccessList Functions - public List CreateAccessListArrayByFlag(AccessList flag) + public List CreateAccessListArrayByFlag(AccessList flag) { - List list = new List(); - foreach (ParcelManager.ParcelAccessEntry entry in LandData.ParcelAccessList) + ExpireAccessList(); + + List list = new List(); + foreach (LandAccessEntry entry in LandData.ParcelAccessList) { if (entry.Flags == flag) - { - list.Add(entry.AgentID); - } + list.Add(entry); } if (list.Count == 0) { - list.Add(UUID.Zero); + LandAccessEntry e = new LandAccessEntry(); + e.AgentID = UUID.Zero; + e.Flags = 0; + e.Expires = 0; + + list.Add(e); } return list; @@ -535,20 +556,20 @@ namespace OpenSim.Region.CoreModules.World.Land if (flags == (uint) AccessList.Access || flags == (uint) AccessList.Both) { - List avatars = CreateAccessListArrayByFlag(AccessList.Access); - remote_client.SendLandAccessListData(avatars,(uint) AccessList.Access,LandData.LocalID); + List accessEntries = CreateAccessListArrayByFlag(AccessList.Access); + remote_client.SendLandAccessListData(accessEntries,(uint) AccessList.Access,LandData.LocalID); } if (flags == (uint) AccessList.Ban || flags == (uint) AccessList.Both) { - List avatars = CreateAccessListArrayByFlag(AccessList.Ban); - remote_client.SendLandAccessListData(avatars, (uint)AccessList.Ban, LandData.LocalID); + List accessEntries = CreateAccessListArrayByFlag(AccessList.Ban); + remote_client.SendLandAccessListData(accessEntries, (uint)AccessList.Ban, LandData.LocalID); } } public void UpdateAccessList(uint flags, UUID transactionID, int sequenceID, int sections, - List entries, + List entries, IClientAPI remote_client) { LandData newData = LandData.Copy(); @@ -558,16 +579,16 @@ namespace OpenSim.Region.CoreModules.World.Land { m_listTransactions[flags] = transactionID; - List toRemove = - new List(); + List toRemove = + new List(); - foreach (ParcelManager.ParcelAccessEntry entry in newData.ParcelAccessList) + foreach (LandAccessEntry entry in newData.ParcelAccessList) { if (entry.Flags == (AccessList)flags) toRemove.Add(entry); } - foreach (ParcelManager.ParcelAccessEntry entry in toRemove) + foreach (LandAccessEntry entry in toRemove) { newData.ParcelAccessList.Remove(entry); } @@ -582,13 +603,13 @@ namespace OpenSim.Region.CoreModules.World.Land } } - foreach (ParcelManager.ParcelAccessEntry entry in entries) + foreach (LandAccessEntry entry in entries) { - ParcelManager.ParcelAccessEntry temp = - new ParcelManager.ParcelAccessEntry(); + LandAccessEntry temp = + new LandAccessEntry(); temp.AgentID = entry.AgentID; - temp.Time = entry.Time; + temp.Expires = entry.Expires; temp.Flags = (AccessList)flags; newData.ParcelAccessList.Add(temp); @@ -1105,5 +1126,20 @@ namespace OpenSim.Region.CoreModules.World.Land } #endregion + + private void ExpireAccessList() + { + List delete = new List(); + + foreach (LandAccessEntry entry in LandData.ParcelAccessList) + { + if (entry.Expires != 0 && entry.Expires < Util.UnixTimeSinceEpoch()) + delete.Add(entry); + } + foreach (LandAccessEntry entry in delete) + LandData.ParcelAccessList.Remove(entry); + + m_scene.EventManager.TriggerLandObjectUpdated((uint)LandData.LocalID, this); + } } } diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index bbf3729114..11f927c0ee 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1253,7 +1253,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server } - public void SendLandAccessListData(List avatars, uint accessFlag, int localLandID) + public void SendLandAccessListData(List accessList, uint accessFlag, int localLandID) { } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 6d40a92e2e..81bf9ed3cb 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -940,7 +940,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor,int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) { } - public void SendLandAccessListData(List avatars, uint accessFlag, int localLandID) + public void SendLandAccessListData(List accessList, uint accessFlag, int localLandID) { } public void SendForceClientSelectObjects(List objectIDs) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 67dee021c8..0bdd84ad08 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5714,16 +5714,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llEjectFromLand(string pest) { m_host.AddScriptLPS(1); - UUID agentId = new UUID(); - if (UUID.TryParse(pest, out agentId)) + UUID agentID = new UUID(); + if (UUID.TryParse(pest, out agentID)) { - ScenePresence presence = World.GetScenePresence(agentId); + ScenePresence presence = World.GetScenePresence(agentID); if (presence != null) { // agent must be over the owners land - if (m_host.OwnerID == World.LandChannel.GetLandObject( - presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) - World.TeleportClientHome(agentId, presence.ControllingClient); + ILandObject land = World.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); + if (land == null) + return; + + if (m_host.OwnerID == land.LandData.OwnerID) + { + World.TeleportClientHome(agentID, presence.ControllingClient); + } } } ScriptSleep(5000); @@ -6408,24 +6413,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); UUID key; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); - if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageAllowed)) + if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) { - ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + int expires = 0; + if (hours != 0) + expires = Util.UnixTimeSinceEpoch() + (int)(3600.0 * hours); + if (UUID.TryParse(avatar, out key)) { - if (land.LandData.ParcelAccessList.FindIndex( - delegate(ParcelManager.ParcelAccessEntry e) + int idx = land.LandData.ParcelAccessList.FindIndex( + delegate(LandAccessEntry e) { if (e.AgentID == key && e.Flags == AccessList.Access) return true; return false; - }) == -1) - { - entry.AgentID = key; - entry.Flags = AccessList.Access; - entry.Time = DateTime.Now.AddHours(hours); - land.LandData.ParcelAccessList.Add(entry); - } + }); + + if (idx != -1 && (land.LandData.ParcelAccessList[idx].Expires == 0 || (expires != 0 && expires < land.LandData.ParcelAccessList[idx].Expires))) + return; + + if (idx != -1) + land.LandData.ParcelAccessList.RemoveAt(idx); + + LandAccessEntry entry = new LandAccessEntry(); + + entry.AgentID = key; + entry.Flags = AccessList.Access; + entry.Expires = expires; + + land.LandData.ParcelAccessList.Add(entry); + + World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); } } ScriptSleep(100); @@ -9679,22 +9697,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) { - ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + int expires = 0; + if (hours != 0) + expires = Util.UnixTimeSinceEpoch() + (int)(3600.0 * hours); + if (UUID.TryParse(avatar, out key)) { - if (land.LandData.ParcelAccessList.FindIndex( - delegate(ParcelManager.ParcelAccessEntry e) + int idx = land.LandData.ParcelAccessList.FindIndex( + delegate(LandAccessEntry e) { if (e.AgentID == key && e.Flags == AccessList.Ban) return true; return false; - }) == -1) - { - entry.AgentID = key; - entry.Flags = AccessList.Ban; - entry.Time = DateTime.Now.AddHours(hours); - land.LandData.ParcelAccessList.Add(entry); - } + }); + + if (idx != -1 && (land.LandData.ParcelAccessList[idx].Expires == 0 || (expires != 0 && expires < land.LandData.ParcelAccessList[idx].Expires))) + return; + + if (idx != -1) + land.LandData.ParcelAccessList.RemoveAt(idx); + + LandAccessEntry entry = new LandAccessEntry(); + + entry.AgentID = key; + entry.Flags = AccessList.Ban; + entry.Expires = expires; + + land.LandData.ParcelAccessList.Add(entry); + + World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); } } ScriptSleep(100); @@ -9710,7 +9741,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (UUID.TryParse(avatar, out key)) { int idx = land.LandData.ParcelAccessList.FindIndex( - delegate(ParcelManager.ParcelAccessEntry e) + delegate(LandAccessEntry e) { if (e.AgentID == key && e.Flags == AccessList.Access) return true; @@ -9718,7 +9749,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api }); if (idx != -1) + { land.LandData.ParcelAccessList.RemoveAt(idx); + World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); + } } } ScriptSleep(100); @@ -9734,7 +9768,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (UUID.TryParse(avatar, out key)) { int idx = land.LandData.ParcelAccessList.FindIndex( - delegate(ParcelManager.ParcelAccessEntry e) + delegate(LandAccessEntry e) { if (e.AgentID == key && e.Flags == AccessList.Ban) return true; @@ -9742,7 +9776,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api }); if (idx != -1) + { land.LandData.ParcelAccessList.RemoveAt(idx); + World.EventManager.TriggerLandObjectUpdated((uint)land.LandData.LocalID, land); + } } } ScriptSleep(100); @@ -9997,7 +10034,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).LandData; if (land.OwnerID == m_host.OwnerID) { - foreach (ParcelManager.ParcelAccessEntry entry in land.ParcelAccessList) + foreach (LandAccessEntry entry in land.ParcelAccessList) { if (entry.Flags == AccessList.Ban) { @@ -10014,7 +10051,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).LandData; if (land.OwnerID == m_host.OwnerID) { - foreach (ParcelManager.ParcelAccessEntry entry in land.ParcelAccessList) + foreach (LandAccessEntry entry in land.ParcelAccessList) { if (entry.Flags == AccessList.Access) { diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index ab89fe02b4..4d3d257f65 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -980,7 +980,7 @@ namespace OpenSim.Tests.Common.Mock { } - public void SendLandAccessListData(List avatars, uint accessFlag, int localLandID) + public void SendLandAccessListData(List accessList, uint accessFlag, int localLandID) { } From 574c24020284bf52349b9dd42c77ef90eae68500 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 3 Feb 2012 00:05:36 +0000 Subject: [PATCH 7/7] Fix test failure --- OpenSim/Framework/Serialization/External/LandDataSerializer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs index c61b9e8ecc..3ae9a8ee9a 100644 --- a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs +++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs @@ -105,6 +105,7 @@ namespace OpenSim.Framework.Serialization.External pae.AgentID = UUID.Parse( xtr.ReadElementString("AgentID")); // We really don't care about temp vs perm here and this // would break on old oars. Assume all bans are perm + xtr.ReadElementString("Time"); pae.Expires = 0; // Convert.ToUint( xtr.ReadElementString("Time")); pae.Flags = (AccessList)Convert.ToUInt32( xtr.ReadElementString("AccessList")); xtr.ReadEndElement();