aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Addons/Groups/GroupsModule.cs24
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs10
-rw-r--r--OpenSim/Framework/ChildAgentDataUpdate.cs34
-rw-r--r--OpenSim/Framework/PermissionsUtil.cs19
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs13
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs12
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs46
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs13
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs43
-rw-r--r--OpenSim/Region/Framework/Scenes/GodController.cs222
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs42
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs257
-rw-r--r--OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs2
-rwxr-xr-xOpenSim/Region/ScriptEngine/XEngine/XEngine.cs60
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs1
22 files changed, 479 insertions, 353 deletions
diff --git a/OpenSim/Addons/Groups/GroupsModule.cs b/OpenSim/Addons/Groups/GroupsModule.cs
index aa5105e..0e3a172 100644
--- a/OpenSim/Addons/Groups/GroupsModule.cs
+++ b/OpenSim/Addons/Groups/GroupsModule.cs
@@ -781,8 +781,8 @@ namespace OpenSim.Groups
781 781
782 if (groupID != UUID.Zero) 782 if (groupID != UUID.Zero)
783 { 783 {
784 if (money != null) 784 if (money != null && money.GroupCreationCharge > 0)
785 money.ApplyCharge(remoteClient.AgentId, money.GroupCreationCharge, MoneyTransactionType.GroupCreate); 785 money.ApplyCharge(remoteClient.AgentId, money.GroupCreationCharge, MoneyTransactionType.GroupCreate, name);
786 786
787 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully"); 787 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully");
788 788
@@ -979,10 +979,28 @@ namespace OpenSim.Groups
979 { 979 {
980 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 980 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
981 981
982 GroupRecord groupRecord = GetGroupRecord(groupID);
983 IMoneyModule money = remoteClient.Scene.RequestModuleInterface<IMoneyModule>();
984
985 // Should check to see if there's an outstanding invitation
986
987 if (money != null && groupRecord.MembershipFee > 0)
988 {
989 // Does the agent have the funds to cover the group join fee?
990 if (!money.AmountCovered(remoteClient.AgentId, groupRecord.MembershipFee))
991 {
992 remoteClient.SendAlertMessage("Insufficient funds to join the group.");
993 remoteClient.SendJoinGroupReply(groupID, false);
994 return;
995 }
996 }
997
982 string reason = string.Empty; 998 string reason = string.Empty;
983 // Should check to see if OpenEnrollment, or if there's an outstanding invitation 999
984 if (m_groupData.AddAgentToGroup(GetRequestingAgentIDStr(remoteClient), GetRequestingAgentIDStr(remoteClient), groupID, UUID.Zero, string.Empty, out reason)) 1000 if (m_groupData.AddAgentToGroup(GetRequestingAgentIDStr(remoteClient), GetRequestingAgentIDStr(remoteClient), groupID, UUID.Zero, string.Empty, out reason))
985 { 1001 {
1002 if (money != null && groupRecord.MembershipFee > 0)
1003 money.ApplyCharge(remoteClient.AgentId, groupRecord.MembershipFee, MoneyTransactionType.GroupJoin, groupRecord.GroupName);
986 1004
987 remoteClient.SendJoinGroupReply(groupID, true); 1005 remoteClient.SendJoinGroupReply(groupID, true);
988 1006
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index a5c9fb4..597b439 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -3053,11 +3053,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
3053 { 3053 {
3054 if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) 3054 if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
3055 { 3055 {
3056 uint perms = item.CurrentPermissions; 3056 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
3057 PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms); 3057 item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
3058 item.CurrentPermissions = perms; 3058 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
3059 item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
3060 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
3061 item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
3059 } 3062 }
3060
3061 item.CurrentPermissions &= item.NextPermissions; 3063 item.CurrentPermissions &= item.NextPermissions;
3062 item.BasePermissions &= item.NextPermissions; 3064 item.BasePermissions &= item.NextPermissions;
3063 item.EveryOnePermissions &= item.NextPermissions; 3065 item.EveryOnePermissions &= item.NextPermissions;
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index b9d64b1..d6d8dde 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -90,7 +90,7 @@ namespace OpenSim.Framework
90 public Vector3 LeftAxis; 90 public Vector3 LeftAxis;
91 public Vector3 UpAxis; 91 public Vector3 UpAxis;
92 //public int GodLevel; 92 //public int GodLevel;
93 public OSD GodData = new OSDMap(); 93 public OSD GodData = null;
94 public bool ChangedGrid; 94 public bool ChangedGrid;
95 95
96 // This probably shouldn't be here 96 // This probably shouldn't be here
@@ -119,12 +119,15 @@ namespace OpenSim.Framework
119 args["far"] = OSD.FromReal(Far); 119 args["far"] = OSD.FromReal(Far);
120 args["changed_grid"] = OSD.FromBoolean(ChangedGrid); 120 args["changed_grid"] = OSD.FromBoolean(ChangedGrid);
121 //args["god_level"] = OSD.FromString(GodLevel.ToString()); 121 //args["god_level"] = OSD.FromString(GodLevel.ToString());
122 args["god_data"] = GodData; 122 if(GodData != null)
123 OSDMap g = (OSDMap)GodData; 123 {
124 // Set legacy value 124 args["god_data"] = GodData;
125 // TODO: remove after 0.9 is superseded 125 OSDMap g = (OSDMap)GodData;
126 if (g.ContainsKey("ViewerUiIsGod")) 126 // Set legacy value
127 args["god_level"] = g["ViewerUiIsGod"].AsBoolean() ? 200 : 0;; 127 // TODO: remove after 0.9 is superseded
128 if (g.ContainsKey("ViewerUiIsGod"))
129 args["god_level"] = g["ViewerUiIsGod"].AsBoolean() ? 200 : 0;
130 }
128 131
129 if ((Throttles != null) && (Throttles.Length > 0)) 132 if ((Throttles != null) && (Throttles.Length > 0))
130 args["throttles"] = OSD.FromBinary(Throttles); 133 args["throttles"] = OSD.FromBinary(Throttles);
@@ -185,7 +188,7 @@ namespace OpenSim.Framework
185 188
186 //if (args["god_level"] != null) 189 //if (args["god_level"] != null)
187 // Int32.TryParse(args["god_level"].AsString(), out GodLevel); 190 // Int32.TryParse(args["god_level"].AsString(), out GodLevel);
188 if (args["god_data"] != null) 191 if (args.ContainsKey("god_data") && args["god_data"] != null)
189 GodData = args["god_data"]; 192 GodData = args["god_data"];
190 193
191 if (args["far"] != null) 194 if (args["far"] != null)
@@ -362,7 +365,7 @@ namespace OpenSim.Framework
362 public Quaternion BodyRotation; 365 public Quaternion BodyRotation;
363 public uint ControlFlags; 366 public uint ControlFlags;
364 public float EnergyLevel; 367 public float EnergyLevel;
365 public OSD GodData = new OSDMap(); 368 public OSD GodData = null;
366 //public Byte GodLevel; 369 //public Byte GodLevel;
367 public bool AlwaysRun; 370 public bool AlwaysRun;
368 public UUID PreyAgent; 371 public UUID PreyAgent;
@@ -438,10 +441,13 @@ namespace OpenSim.Framework
438 441
439 args["energy_level"] = OSD.FromReal(EnergyLevel); 442 args["energy_level"] = OSD.FromReal(EnergyLevel);
440 //args["god_level"] = OSD.FromString(GodLevel.ToString()); 443 //args["god_level"] = OSD.FromString(GodLevel.ToString());
441 args["god_data"] = GodData; 444 if(GodData != null)
442 OSDMap g = (OSDMap)GodData; 445 {
443 if (g.ContainsKey("ViewerUiIsGod")) 446 args["god_data"] = GodData;
444 args["god_level"] = g["ViewerUiIsGod"].AsBoolean() ? 200 : 0;; 447 OSDMap g = (OSDMap)GodData;
448 if (g.ContainsKey("ViewerUiIsGod"))
449 args["god_level"] = g["ViewerUiIsGod"].AsBoolean() ? 200 : 0;;
450 }
445 args["always_run"] = OSD.FromBoolean(AlwaysRun); 451 args["always_run"] = OSD.FromBoolean(AlwaysRun);
446 args["prey_agent"] = OSD.FromUUID(PreyAgent); 452 args["prey_agent"] = OSD.FromUUID(PreyAgent);
447 args["agent_access"] = OSD.FromString(AgentAccess.ToString()); 453 args["agent_access"] = OSD.FromString(AgentAccess.ToString());
@@ -622,7 +628,7 @@ namespace OpenSim.Framework
622 //if (args["god_level"] != null) 628 //if (args["god_level"] != null)
623 // Byte.TryParse(args["god_level"].AsString(), out GodLevel); 629 // Byte.TryParse(args["god_level"].AsString(), out GodLevel);
624 630
625 if (args["god_data"] != null) 631 if (args.ContainsKey("god_data") && args["god_data"] != null)
626 GodData = args["god_data"]; 632 GodData = args["god_data"];
627 633
628 if (args["always_run"] != null) 634 if (args["always_run"] != null)
diff --git a/OpenSim/Framework/PermissionsUtil.cs b/OpenSim/Framework/PermissionsUtil.cs
index 5d3186d..3dce04d 100644
--- a/OpenSim/Framework/PermissionsUtil.cs
+++ b/OpenSim/Framework/PermissionsUtil.cs
@@ -64,24 +64,5 @@ namespace OpenSim.Framework
64 str = "."; 64 str = ".";
65 return str; 65 return str;
66 } 66 }
67
68 /// <summary>
69 /// Applies an object's folded permissions to its regular permissions.
70 /// </summary>
71 /// <param name="foldedPerms">The folded permissions. Only the lowest 7 bits are examined.</param>
72 /// <param name="mainPerms">The permissions variable to modify.</param>
73 public static void ApplyFoldedPermissions(uint foldedPerms, ref uint mainPerms)
74 {
75// if ((foldedPerms & 7) == 0)
76// return; // assume that if the folded permissions are 0 then this means that they weren't actually recorded
77
78 if ((foldedPerms & ((uint)PermissionMask.Copy >> 13)) == 0)
79 mainPerms &= ~(uint)PermissionMask.Copy;
80 if ((foldedPerms & ((uint)PermissionMask.Transfer >> 13)) == 0)
81 mainPerms &= ~(uint)PermissionMask.Transfer;
82 if ((foldedPerms & ((uint)PermissionMask.Modify >> 13)) == 0)
83 mainPerms &= ~(uint)PermissionMask.Modify;
84 }
85
86 } 67 }
87} 68}
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
index cecef0d..f733972 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
@@ -185,7 +185,13 @@ namespace OpenSim.Region.ClientStack.Linden
185 m_log.DebugFormat("[GetMeshModule] Closing"); 185 m_log.DebugFormat("[GetMeshModule] Closing");
186 foreach (Thread t in m_workerThreads) 186 foreach (Thread t in m_workerThreads)
187 Watchdog.AbortThread(t.ManagedThreadId); 187 Watchdog.AbortThread(t.ManagedThreadId);
188 m_queue.Clear(); 188 // This will fail on region shutdown. Its harmless.
189 // Prevent red ink.
190 try
191 {
192 m_queue.Clear();
193 }
194 catch {}
189 } 195 }
190 } 196 }
191 197
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index f4a8a6b..8b8ac20 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -1118,7 +1118,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1118 1118
1119 SceneObjectGroup objatt; 1119 SceneObjectGroup objatt;
1120 1120
1121 UUID rezGroupID = sp.ControllingClient.ActiveGroupId; 1121 UUID rezGroupID;
1122
1123 // This will fail if the user aborts login. sp will exist
1124 // but ControllintClient will be null.
1125 try
1126 {
1127 rezGroupID = sp.ControllingClient.ActiveGroupId;
1128 }
1129 catch
1130 {
1131 return null;
1132 }
1122 1133
1123 if (itemID != UUID.Zero) 1134 if (itemID != UUID.Zero)
1124 objatt = m_invAccessModule.RezObject(sp.ControllingClient, 1135 objatt = m_invAccessModule.RezObject(sp.ControllingClient,
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 7980de3..35b48d9 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -369,6 +369,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
369 369
370 public virtual bool SendFriendsOnlineIfNeeded(IClientAPI client) 370 public virtual bool SendFriendsOnlineIfNeeded(IClientAPI client)
371 { 371 {
372 if (client == null)
373 return false;
374
372 UUID agentID = client.AgentId; 375 UUID agentID = client.AgentId;
373 376
374 // Check if the online friends list is needed 377 // Check if the online friends list is needed
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
index b7ae298..8116b3c 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
@@ -194,14 +194,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
194 int godlevel = 200; 194 int godlevel = 200;
195 // update level so higher gods can kick lower ones 195 // update level so higher gods can kick lower ones
196 ScenePresence god = m_scene.GetScenePresence(godID); 196 ScenePresence god = m_scene.GetScenePresence(godID);
197 if(god != null && god.GodController.GodLevel > godlevel) 197 if(god != null && god.GodController.EffectiveLevel > godlevel)
198 godlevel = god.GodController.GodLevel; 198 godlevel = god.GodController.EffectiveLevel;
199 199
200 if(agentID == ALL_AGENTS) 200 if(agentID == ALL_AGENTS)
201 { 201 {
202 m_scene.ForEachRootScenePresence(delegate(ScenePresence p) 202 m_scene.ForEachRootScenePresence(delegate(ScenePresence p)
203 { 203 {
204 if (p.UUID != godID && godlevel > p.GodController.GodLevel) 204 if (p.UUID != godID && godlevel > p.GodController.EffectiveLevel)
205 doKickmodes(godID, p, kickflags, reason); 205 doKickmodes(godID, p, kickflags, reason);
206 }); 206 });
207 return; 207 return;
@@ -224,7 +224,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
224 return; 224 return;
225 } 225 }
226 226
227 if (godlevel <= sp.GodController.GodLevel) // no god wars 227 if (godlevel <= sp.GodController.EffectiveLevel) // no god wars
228 return; 228 return;
229 229
230 if(sp.UUID == godID) 230 if(sp.UUID == godID)
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index d0e5d86..6dc982b 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -1999,8 +1999,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1999 1999
2000 IClientAPI spClient = sp.ControllingClient; 2000 IClientAPI spClient = sp.ControllingClient;
2001 2001
2002 if (!seeds.ContainsKey(currentRegionHandler)) 2002 // This will fail if the user aborts login
2003 seeds.Add(currentRegionHandler, spClient.RequestClientInfo().CapsPath); 2003 try
2004 {
2005 if (!seeds.ContainsKey(currentRegionHandler))
2006 seeds.Add(currentRegionHandler, spClient.RequestClientInfo().CapsPath);
2007 }
2008 catch
2009 {
2010 return;
2011 }
2004 2012
2005 AgentCircuitData currentAgentCircuit = 2013 AgentCircuitData currentAgentCircuit =
2006 spScene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); 2014 spScene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index f89e446..95e7456 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -322,7 +322,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
322 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 322 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
323 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) 323 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
324 { 324 {
325 m_log.DebugFormat("[HGScene]: RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); 325 //m_log.DebugFormat("[HGScene]: RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID);
326 326
327 //if (fromTaskID.Equals(UUID.Zero)) 327 //if (fromTaskID.Equals(UUID.Zero))
328 //{ 328 //{
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index fcf373b..0104823 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -532,17 +532,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
532 } 532 }
533 else 533 else
534 { 534 {
535 AddPermissions(item, objlist[0], objlist, remoteClient);
536
535 item.CreationDate = Util.UnixTimeSinceEpoch(); 537 item.CreationDate = Util.UnixTimeSinceEpoch();
536 item.Description = asset.Description; 538 item.Description = asset.Description;
537 item.Name = asset.Name; 539 item.Name = asset.Name;
538 item.AssetType = asset.Type; 540 item.AssetType = asset.Type;
539 541
540 //preserve perms on return
541 if(DeRezAction.Return == action)
542 AddPermissions(item, objlist[0], objlist, null);
543 else
544 AddPermissions(item, objlist[0], objlist, remoteClient);
545
546 m_Scene.AddInventoryItem(item); 542 m_Scene.AddInventoryItem(item);
547 543
548 if (remoteClient != null && item.Owner == remoteClient.AgentId) 544 if (remoteClient != null && item.Owner == remoteClient.AgentId)
@@ -599,15 +595,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
599 } 595 }
600 effectivePerms |= (uint)PermissionMask.Move; 596 effectivePerms |= (uint)PermissionMask.Move;
601 597
602 //PermissionsUtil.LogPermissions(item.Name, "Before AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions);
603
604 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) 598 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
605 { 599 {
606 // Changing ownership, so apply the "Next Owner" permissions to all of the
607 // inventory item's permissions.
608
609 uint perms = effectivePerms; 600 uint perms = effectivePerms;
610 PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms); 601 uint nextPerms = (perms & 7) << 13;
602 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
603 perms &= ~(uint)PermissionMask.Copy;
604 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
605 perms &= ~(uint)PermissionMask.Transfer;
606 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
607 perms &= ~(uint)PermissionMask.Modify;
611 608
612 item.BasePermissions = perms & so.RootPart.NextOwnerMask; 609 item.BasePermissions = perms & so.RootPart.NextOwnerMask;
613 item.CurrentPermissions = item.BasePermissions; 610 item.CurrentPermissions = item.BasePermissions;
@@ -620,13 +617,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
620 } 617 }
621 else 618 else
622 { 619 {
623 // Not changing ownership.
624 // In this case we apply the permissions in the object's items ONLY to the inventory
625 // item's "Next Owner" permissions, but NOT to its "Current", "Base", etc. permissions.
626 // E.g., if the object contains a No-Transfer item then the item's "Next Owner"
627 // permissions are also No-Transfer.
628 PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref allObjectsNextOwnerPerms);
629
630 item.BasePermissions = effectivePerms; 620 item.BasePermissions = effectivePerms;
631 item.CurrentPermissions = effectivePerms; 621 item.CurrentPermissions = effectivePerms;
632 item.NextPermissions = so.RootPart.NextOwnerMask & effectivePerms; 622 item.NextPermissions = so.RootPart.NextOwnerMask & effectivePerms;
@@ -640,10 +630,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
640 (uint)PermissionMask.Move | 630 (uint)PermissionMask.Move |
641 (uint)PermissionMask.Export | 631 (uint)PermissionMask.Export |
642 7); // Preserve folded permissions 632 7); // Preserve folded permissions
643 } 633 }
644 634
645 //PermissionsUtil.LogPermissions(item.Name, "After AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions);
646
647 return item; 635 return item;
648 } 636 }
649 637
@@ -1153,6 +1141,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1153 part.OwnerID = item.Owner; 1141 part.OwnerID = item.Owner;
1154 part.RezzerID = item.Owner; 1142 part.RezzerID = item.Owner;
1155 part.Inventory.ChangeInventoryOwner(item.Owner); 1143 part.Inventory.ChangeInventoryOwner(item.Owner);
1144
1145 // This applies the base mask from the item as the next
1146 // permissions for the object. This is correct because the
1147 // giver's base mask was masked by the giver's next owner
1148 // mask, so the base mask equals the original next owner mask.
1149 part.NextOwnerMask = item.BasePermissions;
1156 } 1150 }
1157 1151
1158 so.ApplyNextOwnerPermissions(); 1152 so.ApplyNextOwnerPermissions();
@@ -1164,10 +1158,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1164 { 1158 {
1165 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) 1159 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
1166 { 1160 {
1167 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) 1161 part.EveryoneMask = item.EveryOnePermissions & part.BaseMask;
1168 part.EveryoneMask = item.EveryOnePermissions & part.BaseMask; 1162 part.NextOwnerMask = item.NextPermissions & part.BaseMask;
1169 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
1170 part.NextOwnerMask = item.NextPermissions & part.BaseMask;
1171 } 1163 }
1172 } 1164 }
1173 } 1165 }
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 3a8d6b7..0122f47 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -1818,13 +1818,20 @@ namespace OpenSim.Region.CoreModules.World.Land
1818 uint wx; 1818 uint wx;
1819 uint wy; 1819 uint wy;
1820 Util.RegionHandleToWorldLoc(regionHandle, out wx, out wy); 1820 Util.RegionHandleToWorldLoc(regionHandle, out wx, out wy);
1821 wx += x;
1822 wy += y;
1823 GridRegion info = m_scene.GridService.GetRegionByPosition(scope, (int)wx, (int)wy); 1821 GridRegion info = m_scene.GridService.GetRegionByPosition(scope, (int)wx, (int)wy);
1824 if(info != null) 1822 if(info != null)
1825 { 1823 {
1826 wx -= (uint)info.RegionLocX; 1824 wx -= (uint)info.RegionLocX;
1827 wy -= (uint)info.RegionLocY; 1825 wy -= (uint)info.RegionLocY;
1826 wx += x;
1827 wy += y;
1828 // Firestorm devs have no ideia how to do handlers math
1829 // on all cases
1830 if(wx > info.RegionSizeX || wy > info.RegionSizeY)
1831 {
1832 wx = x;
1833 wy = y;
1834 }
1828 parcelID = Util.BuildFakeParcelID(info.RegionHandle, wx, wy); 1835 parcelID = Util.BuildFakeParcelID(info.RegionHandle, wx, wy);
1829 } 1836 }
1830 } 1837 }
@@ -1845,8 +1852,6 @@ namespace OpenSim.Region.CoreModules.World.Land
1845 parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y); 1852 parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y);
1846 } 1853 }
1847 } 1854 }
1848
1849
1850 } 1855 }
1851 } 1856 }
1852 catch (LLSD.LLSDParseException e) 1857 catch (LLSD.LLSDParseException e)
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index b7f01be..2837358 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -211,7 +211,13 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
211 item.InvType = (int)InventoryType.Object; 211 item.InvType = (int)InventoryType.Object;
212 item.Folder = categoryID; 212 item.Folder = categoryID;
213 213
214 PermissionsUtil.ApplyFoldedPermissions(perms, ref perms); 214 uint nextPerms=(perms & 7) << 13;
215 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
216 perms &= ~(uint)PermissionMask.Copy;
217 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
218 perms &= ~(uint)PermissionMask.Transfer;
219 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
220 perms &= ~(uint)PermissionMask.Modify;
215 221
216 item.BasePermissions = perms & part.NextOwnerMask; 222 item.BasePermissions = perms & part.NextOwnerMask;
217 item.CurrentPermissions = perms & part.NextOwnerMask; 223 item.CurrentPermissions = perms & part.NextOwnerMask;
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 02d0e02..75d90f3 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -99,7 +99,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions
99 private bool m_allowGridGods = false; 99 private bool m_allowGridGods = false;
100 private bool m_RegionOwnerIsGod = false; 100 private bool m_RegionOwnerIsGod = false;
101 private bool m_RegionManagerIsGod = false; 101 private bool m_RegionManagerIsGod = false;
102 private bool m_ParcelOwnerIsGod = false; 102 private bool m_forceGridGodsOnly;
103 private bool m_forceGodModeAlwaysOn;
104 private bool m_allowGodActionsWithoutGodMode;
103 105
104 private bool m_SimpleBuildPermissions = false; 106 private bool m_SimpleBuildPermissions = false;
105 107
@@ -168,21 +170,27 @@ namespace OpenSim.Region.CoreModules.World.Permissions
168 170
169 m_Enabled = true; 171 m_Enabled = true;
170 172
171 m_allowGridGods = Util.GetConfigVarFromSections<bool>(config, "allow_grid_gods", 173 string[] sections = new string[] { "Startup", "Permissions" };
172 new string[] { "Startup", "Permissions" }, false); 174
173 m_bypassPermissions = !Util.GetConfigVarFromSections<bool>(config, "serverside_object_permissions", 175 m_allowGridGods = Util.GetConfigVarFromSections<bool>(config, "allow_grid_gods", sections, false);
174 new string[] { "Startup", "Permissions" }, true); 176 m_bypassPermissions = !Util.GetConfigVarFromSections<bool>(config, "serverside_object_permissions", sections, true);
175 m_propagatePermissions = Util.GetConfigVarFromSections<bool>(config, "propagate_permissions", 177 m_propagatePermissions = Util.GetConfigVarFromSections<bool>(config, "propagate_permissions", sections, true);
176 new string[] { "Startup", "Permissions" }, true); 178
177 m_RegionOwnerIsGod = Util.GetConfigVarFromSections<bool>(config, "region_owner_is_god", 179 m_forceGridGodsOnly = Util.GetConfigVarFromSections<bool>(config, "force_grid_gods_only", sections, false);
178 new string[] { "Startup", "Permissions" }, true); 180 if(!m_forceGridGodsOnly)
179 m_RegionManagerIsGod = Util.GetConfigVarFromSections<bool>(config, "region_manager_is_god", 181 {
180 new string[] { "Startup", "Permissions" }, false); 182 m_RegionOwnerIsGod = Util.GetConfigVarFromSections<bool>(config, "region_owner_is_god",sections, true);
181 m_ParcelOwnerIsGod = Util.GetConfigVarFromSections<bool>(config, "parcel_owner_is_god", 183 m_RegionManagerIsGod = Util.GetConfigVarFromSections<bool>(config, "region_manager_is_god",sections, false);
182 new string[] { "Startup", "Permissions" }, false); 184 }
183 185 else
184 m_SimpleBuildPermissions = Util.GetConfigVarFromSections<bool>(config, "simple_build_permissions", 186 m_allowGridGods = true;
185 new string[] { "Startup", "Permissions" }, false); 187
188 m_forceGodModeAlwaysOn = Util.GetConfigVarFromSections<bool>(config, "automatic_gods", sections, false);
189 m_allowGodActionsWithoutGodMode = Util.GetConfigVarFromSections<bool>(config, "implicit_gods", sections, false);
190 if(m_allowGodActionsWithoutGodMode)
191 m_forceGodModeAlwaysOn = false;
192
193 m_SimpleBuildPermissions = Util.GetConfigVarFromSections<bool>(config, "simple_build_permissions",sections, false);
186 194
187 m_allowedScriptCreators 195 m_allowedScriptCreators
188 = ParseUserSetConfigSetting(config, "allowed_script_creators", m_allowedScriptCreators); 196 = ParseUserSetConfigSetting(config, "allowed_script_creators", m_allowedScriptCreators);
@@ -718,6 +726,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
718 if (IsAdministrator(user)) 726 if (IsAdministrator(user))
719 return PermissionClass.Owner; 727 return PermissionClass.Owner;
720 728
729/* to review later
721 // Users should be able to edit what is over their land. 730 // Users should be able to edit what is over their land.
722 Vector3 taskPos = obj.AbsolutePosition; 731 Vector3 taskPos = obj.AbsolutePosition;
723 ILandObject parcel = m_scene.LandChannel.GetLandObject(taskPos.X, taskPos.Y); 732 ILandObject parcel = m_scene.LandChannel.GetLandObject(taskPos.X, taskPos.Y);
@@ -727,7 +736,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
727 if (!IsAdministrator(objectOwner)) 736 if (!IsAdministrator(objectOwner))
728 return PermissionClass.Owner; 737 return PermissionClass.Owner;
729 } 738 }
730 739*/
731 // Group permissions 740 // Group permissions
732 if ((obj.GroupID != UUID.Zero) && IsGroupMember(obj.GroupID, user, 0)) 741 if ((obj.GroupID != UUID.Zero) && IsGroupMember(obj.GroupID, user, 0))
733 return PermissionClass.Group; 742 return PermissionClass.Group;
diff --git a/OpenSim/Region/Framework/Scenes/GodController.cs b/OpenSim/Region/Framework/Scenes/GodController.cs
index 5763e03..8035760 100644
--- a/OpenSim/Region/Framework/Scenes/GodController.cs
+++ b/OpenSim/Region/Framework/Scenes/GodController.cs
@@ -47,23 +47,35 @@ namespace OpenSim.Region.Framework.Scenes
47{ 47{
48 public class GodController 48 public class GodController
49 { 49 {
50 public enum ImplicitGodLevels : int
51 {
52 EstateManager = 210, // estate manager implicit god level
53 RegionOwner = 220 // region owner implicit god level should be >= than estate
54 }
55
50 ScenePresence m_scenePresence; 56 ScenePresence m_scenePresence;
51 Scene m_scene; 57 Scene m_scene;
52 protected bool m_allowGridGods; 58 protected bool m_allowGridGods;
59 protected bool m_forceGridGodsOnly;
53 protected bool m_regionOwnerIsGod; 60 protected bool m_regionOwnerIsGod;
54 protected bool m_regionManagerIsGod; 61 protected bool m_regionManagerIsGod;
55 protected bool m_parcelOwnerIsGod;
56 protected bool m_forceGodModeAlwaysOn; 62 protected bool m_forceGodModeAlwaysOn;
57 protected bool m_allowGodActionsWithoutGodMode; 63 protected bool m_allowGodActionsWithoutGodMode;
58 64
59 protected bool m_viewerUiIsGod = false;
60
61 protected int m_userLevel = 0; 65 protected int m_userLevel = 0;
62 66 // the god level from local or grid user rights
63 public GodController(Scene scene, ScenePresence sp) 67 protected int m_rightsGodLevel = 0;
68 // the level seen by viewers
69 protected int m_godlevel = 0;
70 // new level that can be fixed or equal to godlevel, acording to options
71 protected int m_effectivegodlevel = 0;
72 protected int m_lastLevelToViewer = 0;
73
74 public GodController(Scene scene, ScenePresence sp, int userlevel)
64 { 75 {
65 m_scene = scene; 76 m_scene = scene;
66 m_scenePresence = sp; 77 m_scenePresence = sp;
78 m_userLevel = userlevel;
67 79
68 IConfigSource config = scene.Config; 80 IConfigSource config = scene.Config;
69 81
@@ -76,21 +88,27 @@ namespace OpenSim.Region.Framework.Scenes
76 Util.GetConfigVarFromSections<bool>(config, 88 Util.GetConfigVarFromSections<bool>(config,
77 "allow_grid_gods", sections, false); 89 "allow_grid_gods", sections, false);
78 90
79 // The owner of a region is a god in his region only. 91 // If grid gods are active, dont allow any other gods
80 m_regionOwnerIsGod = 92 m_forceGridGodsOnly =
81 Util.GetConfigVarFromSections<bool>(config, 93 Util.GetConfigVarFromSections<bool>(config,
82 "region_owner_is_god", sections, true); 94 "force_grid_gods_only", sections, false);
83 95
84 // Region managers are gods in the regions they manage. 96 if(!m_forceGridGodsOnly)
85 m_regionManagerIsGod = 97 {
98 // The owner of a region is a god in his region only.
99 m_regionOwnerIsGod =
86 Util.GetConfigVarFromSections<bool>(config, 100 Util.GetConfigVarFromSections<bool>(config,
87 "region_manager_is_god", sections, false); 101 "region_owner_is_god", sections, true);
88 102
89 // Parcel owners are gods in their own parcels only. 103 // Region managers are gods in the regions they manage.
90 m_parcelOwnerIsGod = 104 m_regionManagerIsGod =
91 Util.GetConfigVarFromSections<bool>(config, 105 Util.GetConfigVarFromSections<bool>(config,
92 "parcel_owner_is_god", sections, false); 106 "region_manager_is_god", sections, false);
93 107
108 }
109 else
110 m_allowGridGods = true; // reduce potencial user mistakes
111
94 // God mode should be turned on in the viewer whenever 112 // God mode should be turned on in the viewer whenever
95 // the user has god rights somewhere. They may choose 113 // the user has god rights somewhere. They may choose
96 // to turn it off again, though. 114 // to turn it off again, though.
@@ -105,78 +123,121 @@ namespace OpenSim.Region.Framework.Scenes
105 Util.GetConfigVarFromSections<bool>(config, 123 Util.GetConfigVarFromSections<bool>(config,
106 "implicit_gods", sections, false); 124 "implicit_gods", sections, false);
107 125
126 m_rightsGodLevel = CalcRightsGodLevel();
127
128 if(m_allowGodActionsWithoutGodMode)
129 {
130 m_effectivegodlevel = m_rightsGodLevel;
131
132 m_forceGodModeAlwaysOn = false;
133 }
134
135 else if(m_forceGodModeAlwaysOn)
136 {
137 m_godlevel = m_rightsGodLevel;
138 m_effectivegodlevel = m_rightsGodLevel;
139 }
140
141 m_scenePresence.isGod = (m_effectivegodlevel >= 200);
142 m_scenePresence.isLegacyGod = (m_godlevel >= 200);
108 } 143 }
109 144
110 protected bool CanBeGod() 145 // calculates god level at sp creation from local and grid user god rights
146 // for now this is assumed static until user leaves region.
147 // later estate and gride level updates may update this
148 protected int CalcRightsGodLevel()
111 { 149 {
112 bool canBeGod = false; 150 int level = 0;
151 if (m_allowGridGods && m_userLevel >= 200)
152 level = m_userLevel;
113 153
114 if (m_allowGridGods && m_userLevel > 0) 154 if(m_forceGridGodsOnly || level >= (int)ImplicitGodLevels.RegionOwner)
115 canBeGod = true; 155 return level;
116 156
117 if (m_regionOwnerIsGod && m_scene.RegionInfo.EstateSettings.IsEstateOwner(m_scenePresence.UUID)) 157 if (m_regionOwnerIsGod && m_scene.RegionInfo.EstateSettings.IsEstateOwner(m_scenePresence.UUID))
118 canBeGod = true; 158 level = (int)ImplicitGodLevels.RegionOwner;
119 159
120 if (m_regionManagerIsGod && m_scene.Permissions.IsEstateManager(m_scenePresence.UUID)) 160 if(level >= (int)ImplicitGodLevels.EstateManager)
121 canBeGod = true; 161 return level;
122 162
123 if (!canBeGod && m_parcelOwnerIsGod) // Skip expensive check if we're already god! 163 if (m_regionManagerIsGod && m_scene.Permissions.IsEstateManager(m_scenePresence.UUID))
124 { 164 level = (int)ImplicitGodLevels.EstateManager;
125 Vector3 pos = m_scenePresence.AbsolutePosition;
126 ILandObject parcel = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
127 if (parcel != null && parcel.LandData.OwnerID == m_scenePresence.UUID)
128 canBeGod = true;
129 }
130 165
131 return canBeGod; 166 return level;
132 } 167 }
133 168
134 protected void SyncViewerState() 169 protected bool CanBeGod()
135 { 170 {
136 bool canBeGod = CanBeGod(); 171 return m_rightsGodLevel >= 200;
172 }
137 173
138 bool shoudBeGod = m_forceGodModeAlwaysOn ? canBeGod : (m_viewerUiIsGod && canBeGod); 174 protected void UpdateGodLevels(bool viewerState)
175 {
176 if(!CanBeGod())
177 {
178 m_godlevel = 0;
179 m_effectivegodlevel = 0;
180 m_scenePresence.isGod = false;
181 m_scenePresence.isLegacyGod = false;
182 return;
183 }
139 184
140 int godLevel = m_allowGridGods ? m_userLevel : 200; 185 // legacy some are controled by viewer, others are static
141 if (!shoudBeGod) 186 if(m_allowGodActionsWithoutGodMode)
142 godLevel = 0; 187 {
188 if(viewerState)
189 m_godlevel = m_rightsGodLevel;
190 else
191 m_godlevel = 0;
143 192
144 if (m_viewerUiIsGod != shoudBeGod) 193 m_effectivegodlevel = m_rightsGodLevel;
194 }
195 else
145 { 196 {
146 m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)godLevel); 197 // new all change with viewer
147 m_viewerUiIsGod = shoudBeGod; 198 if(viewerState)
199 {
200 m_godlevel = m_rightsGodLevel;
201 m_effectivegodlevel = m_rightsGodLevel;
202 }
203 else
204 {
205 m_godlevel = 0;
206 m_effectivegodlevel = 0;
207 }
148 } 208 }
209 m_scenePresence.isGod = (m_effectivegodlevel >= 200);
210 m_scenePresence.isLegacyGod = (m_godlevel >= 200);
149 } 211 }
150 212
151 public bool RequestGodMode(bool god) 213 public void SyncViewerState()
152 { 214 {
153 if (!god) 215 if(m_lastLevelToViewer == m_godlevel)
154 { 216 return;
155 if (m_viewerUiIsGod)
156 m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, 0);
157 217
158 m_viewerUiIsGod = false; 218 m_lastLevelToViewer = m_godlevel;
159 219
160 return true; 220 if(m_scenePresence.IsChildAgent)
161 } 221 return;
162 222
163 if (!CanBeGod()) 223 m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)m_godlevel);
164 return false; 224 }
165
166 int godLevel = m_allowGridGods ? m_userLevel : 200;
167
168 if (!m_viewerUiIsGod)
169 m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)godLevel);
170 225
171 m_viewerUiIsGod = true; 226 public void RequestGodMode(bool god)
227 {
228 UpdateGodLevels(god);
172 229
173 return true; 230 if(m_lastLevelToViewer != m_godlevel)
231 {
232 m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)m_godlevel);
233 m_lastLevelToViewer = m_godlevel;
234 }
174 } 235 }
175 236
176 public OSD State() 237 public OSD State()
177 { 238 {
178 OSDMap godMap = new OSDMap(2); 239 OSDMap godMap = new OSDMap(2);
179 240 bool m_viewerUiIsGod = m_godlevel >= 200;
180 godMap.Add("ViewerUiIsGod", OSD.FromBoolean(m_viewerUiIsGod)); 241 godMap.Add("ViewerUiIsGod", OSD.FromBoolean(m_viewerUiIsGod));
181 242
182 return godMap; 243 return godMap;
@@ -184,45 +245,42 @@ namespace OpenSim.Region.Framework.Scenes
184 245
185 public void SetState(OSD state) 246 public void SetState(OSD state)
186 { 247 {
187 OSDMap s = (OSDMap)state; 248 bool newstate = false;
188 249 if(m_forceGodModeAlwaysOn)
189 if (s.ContainsKey("ViewerUiIsGod")) 250 newstate = true;
190 m_viewerUiIsGod = s["ViewerUiIsGod"].AsBoolean(); 251 else
252 {
253 if(state != null)
254 {
255 OSDMap s = (OSDMap)state;
256
257 if (s.ContainsKey("ViewerUiIsGod"))
258 newstate = s["ViewerUiIsGod"].AsBoolean();
259 m_lastLevelToViewer = m_godlevel; // we are not changing viewer level by default
260 }
261 }
262 UpdateGodLevels(newstate);
263 }
191 264
192 SyncViewerState(); 265 public void HasMovedAway()
266 {
267 m_lastLevelToViewer = 0;
193 } 268 }
194 269
195 public int UserLevel 270 public int UserLevel
196 { 271 {
197 get { return m_userLevel; } 272 get { return m_userLevel; }
198 set { m_userLevel = UserLevel; } 273 set { m_userLevel = value; }
199 } 274 }
200 275
201 public int GodLevel 276 public int GodLevel
202 { 277 {
203 get 278 get { return m_godlevel; }
204 {
205 int godLevel = m_allowGridGods ? m_userLevel : 200;
206 if (!m_viewerUiIsGod)
207 godLevel = 0;
208
209 return godLevel;
210 }
211 } 279 }
212 280
213 public int EffectiveLevel 281 public int EffectiveLevel
214 { 282 {
215 get 283 get { return m_effectivegodlevel; }
216 {
217 int godLevel = m_allowGridGods ? m_userLevel : 200;
218 if (m_viewerUiIsGod)
219 return godLevel;
220
221 if (m_allowGodActionsWithoutGodMode && CanBeGod())
222 return godLevel;
223
224 return 0;
225 }
226 } 284 }
227 } 285 }
228} 286}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index e3ccf96..cb06540 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -627,6 +627,7 @@ namespace OpenSim.Region.Framework.Scenes
627 itemCopy.AssetType = item.AssetType; 627 itemCopy.AssetType = item.AssetType;
628 itemCopy.InvType = item.InvType; 628 itemCopy.InvType = item.InvType;
629 itemCopy.Folder = recipientFolderId; 629 itemCopy.Folder = recipientFolderId;
630 itemCopy.Flags = item.Flags;
630 631
631 if (Permissions.PropagatePermissions() && recipient != senderId) 632 if (Permissions.PropagatePermissions() && recipient != senderId)
632 { 633 {
@@ -643,7 +644,7 @@ namespace OpenSim.Region.Framework.Scenes
643 // 644 //
644 // Transfer 645 // Transfer
645 // Copy 646 // Copy
646 // Modufy 647 // Modify
647 uint permsMask = ~ ((uint)PermissionMask.Copy | 648 uint permsMask = ~ ((uint)PermissionMask.Copy |
648 (uint)PermissionMask.Transfer | 649 (uint)PermissionMask.Transfer |
649 (uint)PermissionMask.Modify); 650 (uint)PermissionMask.Modify);
@@ -681,13 +682,17 @@ namespace OpenSim.Region.Framework.Scenes
681 // a mask 682 // a mask
682 if (item.InvType == (int)InventoryType.Object) 683 if (item.InvType == (int)InventoryType.Object)
683 { 684 {
685 // Create a safe mask for the current perms
686 uint foldedPerms = (item.CurrentPermissions & 7) << 13;
687 foldedPerms |= permsMask;
688
684 bool isRootMod = (item.CurrentPermissions & 689 bool isRootMod = (item.CurrentPermissions &
685 (uint)PermissionMask.Modify) != 0 ? 690 (uint)PermissionMask.Modify) != 0 ?
686 true : false; 691 true : false;
687 692
688 // Mask the owner perms to the folded perms 693 // Mask the owner perms to the folded perms
689 PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref ownerPerms); 694 ownerPerms &= foldedPerms;
690 PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref basePerms); 695 basePerms &= foldedPerms;
691 696
692 // If the root was mod, let the mask reflect that 697 // If the root was mod, let the mask reflect that
693 // We also need to adjust the base here, because 698 // We also need to adjust the base here, because
@@ -714,6 +719,10 @@ namespace OpenSim.Region.Framework.Scenes
714 itemCopy.BasePermissions = basePerms; 719 itemCopy.BasePermissions = basePerms;
715 itemCopy.CurrentPermissions = ownerPerms; 720 itemCopy.CurrentPermissions = ownerPerms;
716 itemCopy.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; 721 itemCopy.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
722 // Need to clear the other inventory slam options.
723 // That is so we can handle the case where the recipient
724 // changes the bits in inventory before rezzing
725 itemCopy.Flags &= ~(uint)(InventoryItemFlags.ObjectOverwriteBase | InventoryItemFlags.ObjectOverwriteOwner | InventoryItemFlags.ObjectOverwriteGroup | InventoryItemFlags.ObjectOverwriteEveryone | InventoryItemFlags.ObjectOverwriteNextOwner);
717 726
718 itemCopy.NextPermissions = item.NextPermissions; 727 itemCopy.NextPermissions = item.NextPermissions;
719 728
@@ -763,9 +772,8 @@ namespace OpenSim.Region.Framework.Scenes
763 772
764 itemCopy.GroupID = UUID.Zero; 773 itemCopy.GroupID = UUID.Zero;
765 itemCopy.GroupOwned = false; 774 itemCopy.GroupOwned = false;
766 itemCopy.Flags = item.Flags; 775 itemCopy.SalePrice = 0; //item.SalePrice;
767 itemCopy.SalePrice = item.SalePrice; 776 itemCopy.SaleType = 0; //item.SaleType;
768 itemCopy.SaleType = item.SaleType;
769 777
770 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); 778 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
771 if (invAccess != null) 779 if (invAccess != null)
@@ -1240,26 +1248,18 @@ namespace OpenSim.Region.Framework.Scenes
1240 { 1248 {
1241 agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); 1249 agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
1242 if (taskItem.InvType == (int)InventoryType.Object) 1250 if (taskItem.InvType == (int)InventoryType.Object)
1243 { 1251 agentItem.CurrentPermissions = agentItem.BasePermissions & (((taskItem.CurrentPermissions & 7) << 13) | (taskItem.CurrentPermissions & (uint)PermissionMask.Move));
1244 // Bake the new base permissions from folded permissions 1252 else
1245 // The folded perms are in the lowest 3 bits of the current perms 1253 agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions;
1246 // We use base permissions here to avoid baking the "Locked" status
1247 // into the item as it is passed.
1248 uint perms = taskItem.BasePermissions & taskItem.NextPermissions;
1249 PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms);
1250 // Avoid the "lock trap" - move must always be enabled but the above may remove it
1251 // Add it back here.
1252 agentItem.BasePermissions = perms | (uint)PermissionMask.Move;
1253 // Newly given items cannot be "locked" on rez. Make sure by
1254 // setting current equal to base.
1255 }
1256 1254
1257 agentItem.CurrentPermissions = agentItem.BasePermissions; 1255 agentItem.CurrentPermissions = agentItem.BasePermissions;
1258 1256
1259 agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; 1257 agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
1258 agentItem.Flags &= ~(uint)(InventoryItemFlags.ObjectOverwriteBase | InventoryItemFlags.ObjectOverwriteOwner | InventoryItemFlags.ObjectOverwriteGroup | InventoryItemFlags.ObjectOverwriteEveryone | InventoryItemFlags.ObjectOverwriteNextOwner);
1260 agentItem.NextPermissions = taskItem.NextPermissions; 1259 agentItem.NextPermissions = taskItem.NextPermissions;
1261 agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); 1260 agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move);
1262 agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions; 1261 // Group permissions make no sense here
1262 agentItem.GroupPermissions = 0;
1263 } 1263 }
1264 else 1264 else
1265 { 1265 {
@@ -1267,7 +1267,7 @@ namespace OpenSim.Region.Framework.Scenes
1267 agentItem.CurrentPermissions = taskItem.CurrentPermissions; 1267 agentItem.CurrentPermissions = taskItem.CurrentPermissions;
1268 agentItem.NextPermissions = taskItem.NextPermissions; 1268 agentItem.NextPermissions = taskItem.NextPermissions;
1269 agentItem.EveryOnePermissions = taskItem.EveryonePermissions; 1269 agentItem.EveryOnePermissions = taskItem.EveryonePermissions;
1270 agentItem.GroupPermissions = taskItem.GroupPermissions; 1270 agentItem.GroupPermissions = 0;
1271 } 1271 }
1272 1272
1273 message = null; 1273 message = null;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index b97cceb..99be06b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -5242,6 +5242,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
5242 BaseMask &= NextOwnerMask | (uint)PermissionMask.Export; 5242 BaseMask &= NextOwnerMask | (uint)PermissionMask.Export;
5243 OwnerMask &= NextOwnerMask; 5243 OwnerMask &= NextOwnerMask;
5244 EveryoneMask &= NextOwnerMask | (uint)PermissionMask.Export; 5244 EveryoneMask &= NextOwnerMask | (uint)PermissionMask.Export;
5245 GroupMask = 0; // Giving an object zaps group permissions
5245 5246
5246 Inventory.ApplyNextOwnerPermissions(); 5247 Inventory.ApplyNextOwnerPermissions();
5247 } 5248 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index a50f162..6557003 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -1358,6 +1358,10 @@ namespace OpenSim.Region.Framework.Scenes
1358 { 1358 {
1359 if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) 1359 if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
1360 { 1360 {
1361// m_log.DebugFormat (
1362// "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}",
1363// item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions);
1364
1361 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) 1365 if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
1362 item.CurrentPermissions &= ~(uint)PermissionMask.Copy; 1366 item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
1363 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) 1367 if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 339f1b1..dbca68b 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -92,6 +92,14 @@ namespace OpenSim.Region.Framework.Scenes
92 92
93 public bool isNPC { get; private set; } 93 public bool isNPC { get; private set; }
94 94
95 // simple yes or no isGOD from god level >= 200
96 // should only be set by GodController
97 // we have two to suport legacy behaviour
98 // isLegacyGod was controlled by viewer in older versions
99 // isGod may now be also controled by viewer acording to options
100 public bool isLegacyGod { get; set; }
101 public bool isGod { get; set; }
102
95 private PresenceType m_presenceType; 103 private PresenceType m_presenceType;
96 public PresenceType PresenceType { 104 public PresenceType PresenceType {
97 get {return m_presenceType;} 105 get {return m_presenceType;}
@@ -155,7 +163,7 @@ namespace OpenSim.Region.Framework.Scenes
155 public static readonly float MOVEMENT = .25f; 163 public static readonly float MOVEMENT = .25f;
156 public static readonly float SIGNIFICANT_MOVEMENT = 16.0f; 164 public static readonly float SIGNIFICANT_MOVEMENT = 16.0f;
157 public static readonly float CHILDUPDATES_MOVEMENT = 100.0f; 165 public static readonly float CHILDUPDATES_MOVEMENT = 100.0f;
158 public static readonly float CHILDUPDATES_TIME = 10000f; // min time between child updates (ms) 166 public static readonly float CHILDUPDATES_TIME = 2000f; // min time between child updates (ms)
159 167
160 private UUID m_previusParcelUUID = UUID.Zero; 168 private UUID m_previusParcelUUID = UUID.Zero;
161 private UUID m_currentParcelUUID = UUID.Zero; 169 private UUID m_currentParcelUUID = UUID.Zero;
@@ -186,7 +194,7 @@ namespace OpenSim.Region.Framework.Scenes
186 m_currentParcelHide = true; 194 m_currentParcelHide = true;
187 195
188 if (m_previusParcelUUID != UUID.Zero || checksame) 196 if (m_previusParcelUUID != UUID.Zero || checksame)
189 ParcelCrossCheck(m_currentParcelUUID,m_previusParcelUUID,m_currentParcelHide, m_previusParcelHide, oldhide,checksame); 197 ParcelCrossCheck(m_currentParcelUUID, m_previusParcelUUID, m_currentParcelHide, m_previusParcelHide, oldhide,checksame);
190 } 198 }
191 } 199 }
192 } 200 }
@@ -267,8 +275,6 @@ namespace OpenSim.Region.Framework.Scenes
267 private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; 275 private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO;
268 private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; 276 private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO;
269 private bool MouseDown = false; 277 private bool MouseDown = false;
270// private SceneObjectGroup proxyObjectGroup;
271 //private SceneObjectPart proxyObjectPart = null;
272 public Vector3 lastKnownAllowedPosition; 278 public Vector3 lastKnownAllowedPosition;
273 public bool sentMessageAboutRestrictedParcelFlyingDown; 279 public bool sentMessageAboutRestrictedParcelFlyingDown;
274 public Vector4 CollisionPlane = Vector4.UnitW; 280 public Vector4 CollisionPlane = Vector4.UnitW;
@@ -281,9 +287,6 @@ namespace OpenSim.Region.Framework.Scenes
281 287
282 private bool m_followCamAuto = false; 288 private bool m_followCamAuto = false;
283 289
284// private object m_forceToApplyLock = new object();
285// private bool m_forceToApplyValid;
286// private Vector3 m_forceToApply;
287 private int m_userFlags; 290 private int m_userFlags;
288 public int UserFlags 291 public int UserFlags
289 { 292 {
@@ -304,9 +307,6 @@ namespace OpenSim.Region.Framework.Scenes
304 set { PhysicsActor.IsColliding = value; } 307 set { PhysicsActor.IsColliding = value; }
305 } 308 }
306 309
307// private int m_lastColCount = -1; //KF: Look for Collision chnages
308// private int m_updateCount = 0; //KF: Update Anims for a while
309// private static readonly int UPDATE_COUNT = 10; // how many frames to update for
310 private List<uint> m_lastColliders = new List<uint>(); 310 private List<uint> m_lastColliders = new List<uint>();
311 311
312 private TeleportFlags m_teleportFlags; 312 private TeleportFlags m_teleportFlags;
@@ -332,8 +332,10 @@ namespace OpenSim.Region.Framework.Scenes
332 332
333 private float m_sitAvatarHeight = 2.0f; 333 private float m_sitAvatarHeight = 2.0f;
334 334
335 private bool childUpdatesBusy = false; 335 private bool m_childUpdatesBusy = false;
336 private int lastChildUpdatesTime; 336 private int m_lastChildUpdatesTime;
337 private int m_lastChildAgentUpdateGodLevel;
338 private float m_lastChildAgentUpdateDrawDistance;
337 private Vector3 m_lastChildAgentUpdatePosition; 339 private Vector3 m_lastChildAgentUpdatePosition;
338// private Vector3 m_lastChildAgentUpdateCamPosition; 340// private Vector3 m_lastChildAgentUpdateCamPosition;
339 341
@@ -348,8 +350,6 @@ namespace OpenSim.Region.Framework.Scenes
348 private float m_healRate = 1f; 350 private float m_healRate = 1f;
349 private float m_healRatePerFrame = 0.05f; 351 private float m_healRatePerFrame = 0.05f;
350 352
351// protected ulong crossingFromRegion;
352
353 private readonly Vector3[] Dir_Vectors = new Vector3[12]; 353 private readonly Vector3[] Dir_Vectors = new Vector3[12];
354 354
355 protected int m_reprioritizationLastTime; 355 protected int m_reprioritizationLastTime;
@@ -372,10 +372,7 @@ namespace OpenSim.Region.Framework.Scenes
372 private const int NumMovementsBetweenRayCast = 5; 372 private const int NumMovementsBetweenRayCast = 5;
373 373
374 private bool CameraConstraintActive; 374 private bool CameraConstraintActive;
375 //private int m_moveToPositionStateStatus;
376 //*****************************************************
377 375
378 //private bool m_collisionEventFlag = false;
379 private object m_collisionEventLock = new Object(); 376 private object m_collisionEventLock = new Object();
380 377
381 private int m_movementAnimationUpdateCounter = 0; 378 private int m_movementAnimationUpdateCounter = 0;
@@ -529,7 +526,6 @@ namespace OpenSim.Region.Framework.Scenes
529 private bool m_doingCamRayCast = false; 526 private bool m_doingCamRayCast = false;
530 527
531 public Vector3 CameraPosition { get; set; } 528 public Vector3 CameraPosition { get; set; }
532
533 public Quaternion CameraRotation { get; private set; } 529 public Quaternion CameraRotation { get; private set; }
534 530
535 // Use these three vectors to figure out what the agent is looking at 531 // Use these three vectors to figure out what the agent is looking at
@@ -589,7 +585,6 @@ namespace OpenSim.Region.Framework.Scenes
589 public bool AllowMovement { get; set; } 585 public bool AllowMovement { get; set; }
590 586
591 private bool m_setAlwaysRun; 587 private bool m_setAlwaysRun;
592
593 public bool SetAlwaysRun 588 public bool SetAlwaysRun
594 { 589 {
595 get 590 get
@@ -613,7 +608,6 @@ namespace OpenSim.Region.Framework.Scenes
613 } 608 }
614 } 609 }
615 610
616
617 public byte State { get; set; } 611 public byte State { get; set; }
618 612
619 private AgentManager.ControlFlags m_AgentControlFlags; 613 private AgentManager.ControlFlags m_AgentControlFlags;
@@ -935,27 +929,7 @@ namespace OpenSim.Region.Framework.Scenes
935 seeds = Scene.CapsModule.GetChildrenSeeds(UUID); 929 seeds = Scene.CapsModule.GetChildrenSeeds(UUID);
936 else 930 else
937 seeds = new Dictionary<ulong, string>(); 931 seeds = new Dictionary<ulong, string>();
938
939/* we can't do this anymore
940 List<ulong> old = new List<ulong>();
941 foreach (ulong handle in seeds.Keys)
942 {
943 uint x, y;
944 Util.RegionHandleToRegionLoc(handle, out x, out y);
945// if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY,))
946 {
947 old.Add(handle);
948 }
949 }
950
951 DropOldNeighbours(old);
952
953 if (Scene.CapsModule != null)
954 Scene.CapsModule.SetChildrenSeed(UUID, seeds);
955*/
956 KnownRegions = seeds; 932 KnownRegions = seeds;
957 //m_log.Debug(" ++++++++++AFTER+++++++++++++ ");
958 //DumpKnownRegions();
959 } 933 }
960 934
961 public void DumpKnownRegions() 935 public void DumpKnownRegions()
@@ -1045,8 +1019,6 @@ namespace OpenSim.Region.Framework.Scenes
1045 public ScenePresence( 1019 public ScenePresence(
1046 IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type) 1020 IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type)
1047 { 1021 {
1048 GodController = new GodController(world, this);
1049
1050 m_scene = world; 1022 m_scene = world;
1051 AttachmentsSyncLock = new Object(); 1023 AttachmentsSyncLock = new Object();
1052 AllowMovement = true; 1024 AllowMovement = true;
@@ -1072,8 +1044,11 @@ namespace OpenSim.Region.Framework.Scenes
1072 else 1044 else
1073 m_userFlags = 0; 1045 m_userFlags = 0;
1074 1046
1047 int userlevel = 0;
1075 if (account != null) 1048 if (account != null)
1076 GodController.UserLevel = account.UserLevel; 1049 userlevel = account.UserLevel;
1050
1051 GodController = new GodController(world, this, userlevel);
1077 1052
1078 // IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); 1053 // IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
1079 // if (gm != null) 1054 // if (gm != null)
@@ -1087,7 +1062,7 @@ namespace OpenSim.Region.Framework.Scenes
1087 m_reprioritizationLastDrawDistance = DrawDistance; 1062 m_reprioritizationLastDrawDistance = DrawDistance;
1088 1063
1089 // disable updates workjobs for now 1064 // disable updates workjobs for now
1090 childUpdatesBusy = true; 1065 m_childUpdatesBusy = true;
1091 m_reprioritizationBusy = true; 1066 m_reprioritizationBusy = true;
1092 1067
1093 AdjustKnownSeeds(); 1068 AdjustKnownSeeds();
@@ -1289,7 +1264,7 @@ namespace OpenSim.Region.Framework.Scenes
1289 IsLoggingIn = false; 1264 IsLoggingIn = false;
1290 } 1265 }
1291 1266
1292 IsChildAgent = false; 1267 IsChildAgent = false;
1293 } 1268 }
1294 1269
1295 m_log.DebugFormat("[MakeRootAgent] out lock: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 1270 m_log.DebugFormat("[MakeRootAgent] out lock: {0}ms", Util.EnvironmentTickCountSubtract(ts));
@@ -1299,7 +1274,6 @@ namespace OpenSim.Region.Framework.Scenes
1299 // Should not be needed if we are not trying to tell this region to close 1274 // Should not be needed if we are not trying to tell this region to close
1300 // DoNotCloseAfterTeleport = false; 1275 // DoNotCloseAfterTeleport = false;
1301 1276
1302
1303 RegionHandle = m_scene.RegionInfo.RegionHandle; 1277 RegionHandle = m_scene.RegionInfo.RegionHandle;
1304 1278
1305 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); 1279 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene);
@@ -1442,7 +1416,6 @@ namespace OpenSim.Region.Framework.Scenes
1442 } 1416 }
1443 } 1417 }
1444 1418
1445
1446 m_log.DebugFormat("[MakeRootAgent] position and physical: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 1419 m_log.DebugFormat("[MakeRootAgent] position and physical: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1447 m_scene.SwapRootAgentCount(false); 1420 m_scene.SwapRootAgentCount(false);
1448 1421
@@ -1777,17 +1750,14 @@ namespace OpenSim.Region.Framework.Scenes
1777 1750
1778 if (m_AngularVelocity.Z > 0) 1751 if (m_AngularVelocity.Z > 0)
1779 { 1752 {
1780
1781 float leftOverToMin = m_AngularVelocity.Z - rollMinRadians; 1753 float leftOverToMin = m_AngularVelocity.Z - rollMinRadians;
1782 if (amount > leftOverToMin) 1754 if (amount > leftOverToMin)
1783 return -leftOverToMin; 1755 return -leftOverToMin;
1784 else 1756 else
1785 return -amount; 1757 return -amount;
1786
1787 } 1758 }
1788 else 1759 else
1789 { 1760 {
1790
1791 float leftOverToMin = -m_AngularVelocity.Z - rollMinRadians; 1761 float leftOverToMin = -m_AngularVelocity.Z - rollMinRadians;
1792 if (amount > leftOverToMin) 1762 if (amount > leftOverToMin)
1793 return leftOverToMin; 1763 return leftOverToMin;
@@ -1796,8 +1766,6 @@ namespace OpenSim.Region.Framework.Scenes
1796 } 1766 }
1797 } 1767 }
1798 1768
1799
1800
1801 // neighbouring regions we have enabled a child agent in 1769 // neighbouring regions we have enabled a child agent in
1802 // holds the seed cap for the child agent in that region 1770 // holds the seed cap for the child agent in that region
1803 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); 1771 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>();
@@ -1810,7 +1778,6 @@ namespace OpenSim.Region.Framework.Scenes
1810 1778
1811 private Dictionary<ulong, spRegionSizeInfo> m_knownChildRegionsSizeInfo = new Dictionary<ulong, spRegionSizeInfo>(); 1779 private Dictionary<ulong, spRegionSizeInfo> m_knownChildRegionsSizeInfo = new Dictionary<ulong, spRegionSizeInfo>();
1812 1780
1813
1814 public void AddNeighbourRegionSizeInfo(GridRegion region) 1781 public void AddNeighbourRegionSizeInfo(GridRegion region)
1815 { 1782 {
1816 lock (m_knownChildRegions) 1783 lock (m_knownChildRegions)
@@ -1941,7 +1908,6 @@ namespace OpenSim.Region.Framework.Scenes
1941 lock (m_originRegionIDAccessLock) 1908 lock (m_originRegionIDAccessLock)
1942 originID = m_originRegionID; 1909 originID = m_originRegionID;
1943 1910
1944
1945 while (originID.Equals(UUID.Zero) && count-- > 0) 1911 while (originID.Equals(UUID.Zero) && count-- > 0)
1946 { 1912 {
1947 lock (m_originRegionIDAccessLock) 1913 lock (m_originRegionIDAccessLock)
@@ -2063,13 +2029,11 @@ namespace OpenSim.Region.Framework.Scenes
2063 m_log.DebugFormat("[CompleteMovement]: Missing COF for {0} is {1}", client.AgentId, COF); 2029 m_log.DebugFormat("[CompleteMovement]: Missing COF for {0} is {1}", client.AgentId, COF);
2064 } 2030 }
2065 2031
2066
2067 // Tell the client that we're totally ready 2032 // Tell the client that we're totally ready
2068 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); 2033 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
2069 2034
2070 m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 2035 m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2071 2036
2072
2073 if (!string.IsNullOrEmpty(m_callbackURI)) 2037 if (!string.IsNullOrEmpty(m_callbackURI))
2074 { 2038 {
2075 // We cannot sleep here since this would hold up the inbound packet processing thread, as 2039 // We cannot sleep here since this would hold up the inbound packet processing thread, as
@@ -2098,7 +2062,6 @@ namespace OpenSim.Region.Framework.Scenes
2098// client.Name, client.AgentId, m_scene.RegionInfo.RegionName); 2062// client.Name, client.AgentId, m_scene.RegionInfo.RegionName);
2099// } 2063// }
2100 2064
2101
2102 m_log.DebugFormat("[CompleteMovement] ReleaseAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 2065 m_log.DebugFormat("[CompleteMovement] ReleaseAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2103 2066
2104 if(m_teleportFlags > 0) 2067 if(m_teleportFlags > 0)
@@ -2118,17 +2081,19 @@ namespace OpenSim.Region.Framework.Scenes
2118 m_log.DebugFormat("[CompleteMovement] HG"); 2081 m_log.DebugFormat("[CompleteMovement] HG");
2119 } 2082 }
2120 2083
2121 if(!IsChildAgent && !isNPC)
2122
2123// start sending terrain patchs
2124 if (!gotCrossUpdate && !isNPC)
2125 Scene.SendLayerData(ControllingClient);
2126
2127 m_previusParcelHide = false; 2084 m_previusParcelHide = false;
2128 m_previusParcelUUID = UUID.Zero; 2085 m_previusParcelUUID = UUID.Zero;
2129 m_currentParcelHide = false; 2086 m_currentParcelHide = false;
2130 m_currentParcelUUID = UUID.Zero; 2087 m_currentParcelUUID = UUID.Zero;
2131 2088
2089 if(!isNPC)
2090 {
2091 GodController.SyncViewerState();
2092
2093 // start sending terrain patchs
2094 if (!gotCrossUpdate)
2095 Scene.SendLayerData(ControllingClient);
2096 }
2132 // send initial land overlay and parcel 2097 // send initial land overlay and parcel
2133 ILandChannel landch = m_scene.LandChannel; 2098 ILandChannel landch = m_scene.LandChannel;
2134 if (landch != null) 2099 if (landch != null)
@@ -2177,7 +2142,6 @@ namespace OpenSim.Region.Framework.Scenes
2177 if (haveAnims) 2142 if (haveAnims)
2178 SendAnimPackToAgent(this, animIDs, animseqs, animsobjs); 2143 SendAnimPackToAgent(this, animIDs, animseqs, animsobjs);
2179 2144
2180
2181 // we should be able to receive updates, etc 2145 // we should be able to receive updates, etc
2182 // so release them 2146 // so release them
2183 m_inTransit = false; 2147 m_inTransit = false;
@@ -2192,7 +2156,7 @@ namespace OpenSim.Region.Framework.Scenes
2192 if (p == this) 2156 if (p == this)
2193 continue; 2157 continue;
2194 2158
2195 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) 2159 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod)
2196 continue; 2160 continue;
2197 2161
2198 SendAppearanceToAgentNF(p); 2162 SendAppearanceToAgentNF(p);
@@ -2242,7 +2206,7 @@ namespace OpenSim.Region.Framework.Scenes
2242 continue; 2206 continue;
2243 } 2207 }
2244 2208
2245 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) 2209 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod)
2246 continue; 2210 continue;
2247 2211
2248 SendAttachmentsToAgentNF(p); 2212 SendAttachmentsToAgentNF(p);
@@ -2259,10 +2223,13 @@ namespace OpenSim.Region.Framework.Scenes
2259 { 2223 {
2260 m_agentTransfer.EnableChildAgents(this); 2224 m_agentTransfer.EnableChildAgents(this);
2261 } 2225 }
2262 // let updates be sent, with some delay
2263 lastChildUpdatesTime = Util.EnvironmentTickCount() + 10000;
2264 childUpdatesBusy = false; // allow them
2265 } 2226 }
2227 // let updates be sent, with some delay
2228 m_lastChildUpdatesTime = Util.EnvironmentTickCount() + 10000;
2229 m_lastChildAgentUpdateGodLevel = GodController.GodLevel;
2230 m_lastChildAgentUpdateDrawDistance = DrawDistance;
2231 m_lastChildAgentUpdatePosition = AbsolutePosition;
2232 m_childUpdatesBusy = false; // allow them
2266 } 2233 }
2267 2234
2268 m_log.DebugFormat("[CompleteMovement] openChildAgents: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 2235 m_log.DebugFormat("[CompleteMovement] openChildAgents: {0}ms", Util.EnvironmentTickCountSubtract(ts));
@@ -2292,7 +2259,6 @@ namespace OpenSim.Region.Framework.Scenes
2292 m_log.DebugFormat("[CompleteMovement] friendsModule: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 2259 m_log.DebugFormat("[CompleteMovement] friendsModule: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2293 2260
2294 } 2261 }
2295
2296 } 2262 }
2297 finally 2263 finally
2298 { 2264 {
@@ -2301,14 +2267,7 @@ namespace OpenSim.Region.Framework.Scenes
2301 crossingFlags = 0; 2267 crossingFlags = 0;
2302 m_inTransit = false; 2268 m_inTransit = false;
2303 } 2269 }
2304 // if hide force a check 2270
2305 // if (!IsChildAgent && newhide)
2306 // {
2307 // ParcelLoginCheck(m_currentParcelUUID);
2308 // m_currentParcelHide = newhide;
2309 // }
2310
2311
2312 m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; 2271 m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd;
2313 2272
2314 m_log.DebugFormat("[CompleteMovement] end: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 2273 m_log.DebugFormat("[CompleteMovement] end: {0}ms", Util.EnvironmentTickCountSubtract(ts));
@@ -3220,7 +3179,6 @@ namespace OpenSim.Region.Framework.Scenes
3220 if (part == null) 3179 if (part == null)
3221 return; 3180 return;
3222 3181
3223
3224 if (PhysicsActor != null) 3182 if (PhysicsActor != null)
3225 m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; 3183 m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f;
3226 3184
@@ -3249,7 +3207,6 @@ namespace OpenSim.Region.Framework.Scenes
3249 3207
3250 if (canSit) 3208 if (canSit)
3251 { 3209 {
3252
3253 if (PhysicsActor != null) 3210 if (PhysicsActor != null)
3254 { 3211 {
3255 // We can remove the physicsActor until they stand up. 3212 // We can remove the physicsActor until they stand up.
@@ -3360,7 +3317,6 @@ namespace OpenSim.Region.Framework.Scenes
3360 return false; 3317 return false;
3361 } 3318 }
3362 3319
3363
3364 private bool CanEnterLandPosition(Vector3 testPos) 3320 private bool CanEnterLandPosition(Vector3 testPos)
3365 { 3321 {
3366 ILandObject land = m_scene.LandChannel.GetLandObject(testPos.X, testPos.Y); 3322 ILandObject land = m_scene.LandChannel.GetLandObject(testPos.X, testPos.Y);
@@ -3440,7 +3396,6 @@ namespace OpenSim.Region.Framework.Scenes
3440 ControllingClient.SendSitResponse( 3396 ControllingClient.SendSitResponse(
3441 part.ParentGroup.UUID, offset, Orientation, true, cameraAtOffset, cameraEyeOffset, forceMouselook); 3397 part.ParentGroup.UUID, offset, Orientation, true, cameraAtOffset, cameraEyeOffset, forceMouselook);
3442 3398
3443
3444 SendAvatarDataToAllAgents(); 3399 SendAvatarDataToAllAgents();
3445 3400
3446 if (status == 3) 3401 if (status == 3)
@@ -3650,8 +3605,6 @@ namespace OpenSim.Region.Framework.Scenes
3650 Animator.avnChangeAnim(animID, addRemove, sendPack); 3605 Animator.avnChangeAnim(animID, addRemove, sendPack);
3651 } 3606 }
3652 3607
3653
3654
3655 /// <summary> 3608 /// <summary>
3656 /// Rotate the avatar to the given rotation and apply a movement in the given relative vector 3609 /// Rotate the avatar to the given rotation and apply a movement in the given relative vector
3657 /// </summary> 3610 /// </summary>
@@ -3858,7 +3811,7 @@ namespace OpenSim.Region.Framework.Scenes
3858 if (!remoteClient.IsActive) 3811 if (!remoteClient.IsActive)
3859 return; 3812 return;
3860 3813
3861 if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && p.GodController.GodLevel < 200) 3814 if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && !p.isLegacyGod)
3862 return; 3815 return;
3863 3816
3864 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); 3817 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity);
@@ -3968,7 +3921,7 @@ namespace OpenSim.Region.Framework.Scenes
3968 // get the avatar, then a kill if can't see it 3921 // get the avatar, then a kill if can't see it
3969 p.SendInitialAvatarDataToAgent(this); 3922 p.SendInitialAvatarDataToAgent(this);
3970 3923
3971 if (p.ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && GodController.GodLevel < 200) 3924 if (p.ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !isLegacyGod)
3972 return; 3925 return;
3973 3926
3974 p.SendAppearanceToAgentNF(this); 3927 p.SendAppearanceToAgentNF(this);
@@ -4016,7 +3969,7 @@ namespace OpenSim.Region.Framework.Scenes
4016 foreach (ScenePresence p in presences) 3969 foreach (ScenePresence p in presences)
4017 { 3970 {
4018 p.ControllingClient.SendAvatarDataImmediate(this); 3971 p.ControllingClient.SendAvatarDataImmediate(this);
4019 if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) 3972 if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod)
4020 // either just kill the object 3973 // either just kill the object
4021 // p.ControllingClient.SendKillObject(new List<uint> {LocalId}); 3974 // p.ControllingClient.SendKillObject(new List<uint> {LocalId});
4022 // or also attachments viewer may still know about 3975 // or also attachments viewer may still know about
@@ -4029,7 +3982,7 @@ namespace OpenSim.Region.Framework.Scenes
4029 public void SendInitialAvatarDataToAgent(ScenePresence p) 3982 public void SendInitialAvatarDataToAgent(ScenePresence p)
4030 { 3983 {
4031 p.ControllingClient.SendAvatarDataImmediate(this); 3984 p.ControllingClient.SendAvatarDataImmediate(this);
4032 if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) 3985 if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod)
4033 // either just kill the object 3986 // either just kill the object
4034 // p.ControllingClient.SendKillObject(new List<uint> {LocalId}); 3987 // p.ControllingClient.SendKillObject(new List<uint> {LocalId});
4035 // or also attachments viewer may still know about 3988 // or also attachments viewer may still know about
@@ -4043,7 +3996,7 @@ namespace OpenSim.Region.Framework.Scenes
4043 public void SendAvatarDataToAgent(ScenePresence avatar) 3996 public void SendAvatarDataToAgent(ScenePresence avatar)
4044 { 3997 {
4045 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID); 3998 //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID);
4046 if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodController.GodLevel < 200) 3999 if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && !avatar.isLegacyGod)
4047 return; 4000 return;
4048 avatar.ControllingClient.SendAvatarDataImmediate(this); 4001 avatar.ControllingClient.SendAvatarDataImmediate(this);
4049 } 4002 }
@@ -4088,7 +4041,7 @@ namespace OpenSim.Region.Framework.Scenes
4088 { 4041 {
4089 // m_log.DebugFormat( 4042 // m_log.DebugFormat(
4090 // "[SCENE PRESENCE]: Sending appearance data from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); 4043 // "[SCENE PRESENCE]: Sending appearance data from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID);
4091 if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodController.GodLevel < 200) 4044 if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && !avatar.isLegacyGod)
4092 return; 4045 return;
4093 SendAppearanceToAgentNF(avatar); 4046 SendAppearanceToAgentNF(avatar);
4094 } 4047 }
@@ -4104,7 +4057,7 @@ namespace OpenSim.Region.Framework.Scenes
4104 if (IsChildAgent || Animator == null) 4057 if (IsChildAgent || Animator == null)
4105 return; 4058 return;
4106 4059
4107 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) 4060 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod)
4108 return; 4061 return;
4109 4062
4110 Animator.SendAnimPackToClient(p.ControllingClient); 4063 Animator.SendAnimPackToClient(p.ControllingClient);
@@ -4115,7 +4068,7 @@ namespace OpenSim.Region.Framework.Scenes
4115 if (IsChildAgent) 4068 if (IsChildAgent)
4116 return; 4069 return;
4117 4070
4118 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) 4071 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod)
4119 return; 4072 return;
4120 4073
4121 p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs); 4074 p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs);
@@ -4140,7 +4093,7 @@ namespace OpenSim.Region.Framework.Scenes
4140 4093
4141 m_scene.ForEachScenePresence(delegate(ScenePresence p) 4094 m_scene.ForEachScenePresence(delegate(ScenePresence p)
4142 { 4095 {
4143 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) 4096 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod)
4144 return; 4097 return;
4145 p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs); 4098 p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs);
4146 }); 4099 });
@@ -4175,7 +4128,7 @@ namespace OpenSim.Region.Framework.Scenes
4175 if(DrawDistance > minregionSize && m_reprioritizationLastDrawDistance > minregionSize) 4128 if(DrawDistance > minregionSize && m_reprioritizationLastDrawDistance > minregionSize)
4176 byDrawdistance = false; 4129 byDrawdistance = false;
4177 else 4130 else
4178 byDrawdistance = (Math.Abs(DrawDistance-m_reprioritizationLastDrawDistance) > 0.5f * limit); 4131 byDrawdistance = (Math.Abs(DrawDistance - m_reprioritizationLastDrawDistance) > 0.5f * limit);
4179 } 4132 }
4180 4133
4181 int tdiff = Util.EnvironmentTickCountSubtract(m_reprioritizationLastTime); 4134 int tdiff = Util.EnvironmentTickCountSubtract(m_reprioritizationLastTime);
@@ -4224,7 +4177,7 @@ namespace OpenSim.Region.Framework.Scenes
4224 // updates priority recalc 4177 // updates priority recalc
4225 checkRePrioritization(); 4178 checkRePrioritization();
4226 4179
4227 if(childUpdatesBusy) 4180 if(m_childUpdatesBusy)
4228 return; 4181 return;
4229 4182
4230 //possible KnownRegionHandles always contains current region and this check is not needed 4183 //possible KnownRegionHandles always contains current region and this check is not needed
@@ -4234,37 +4187,52 @@ namespace OpenSim.Region.Framework.Scenes
4234 4187
4235 if(KnownRegionHandles.Count > minhandles) 4188 if(KnownRegionHandles.Count > minhandles)
4236 { 4189 {
4237 int tdiff = Util.EnvironmentTickCountSubtract(lastChildUpdatesTime); 4190 int tdiff = Util.EnvironmentTickCountSubtract(m_lastChildUpdatesTime);
4238 if(tdiff > CHILDUPDATES_TIME) 4191 if(tdiff < CHILDUPDATES_TIME)
4192 return;
4193
4194 bool doUpdate = false;
4195 if(m_lastChildAgentUpdateGodLevel != GodController.GodLevel)
4196 doUpdate = true;
4197
4198 if(!doUpdate && Math.Abs(DrawDistance - m_lastChildAgentUpdateDrawDistance) > 32.0f)
4199 doUpdate = true;
4200
4201 if(!doUpdate)
4239 { 4202 {
4240 diff = pos - m_lastChildAgentUpdatePosition; 4203 diff = pos - m_lastChildAgentUpdatePosition;
4241 if (diff.LengthSquared() > CHILDUPDATES_MOVEMENT) 4204 if (diff.LengthSquared() > CHILDUPDATES_MOVEMENT)
4242 { 4205 doUpdate = true;
4243 childUpdatesBusy = true; 4206 }
4244 m_lastChildAgentUpdatePosition = pos; 4207
4208 if(doUpdate)
4209 {
4210 m_childUpdatesBusy = true;
4211 m_lastChildAgentUpdatePosition = pos;
4212 m_lastChildAgentUpdateGodLevel = GodController.GodLevel;
4213 m_lastChildAgentUpdateDrawDistance = DrawDistance;
4245// m_lastChildAgentUpdateCamPosition = CameraPosition; 4214// m_lastChildAgentUpdateCamPosition = CameraPosition;
4246 4215
4247 AgentPosition agentpos = new AgentPosition(); 4216 AgentPosition agentpos = new AgentPosition();
4248 agentpos.AgentID = new UUID(UUID.Guid); 4217 agentpos.AgentID = new UUID(UUID.Guid);
4249 agentpos.SessionID = ControllingClient.SessionId; 4218 agentpos.SessionID = ControllingClient.SessionId;
4250 agentpos.Size = Appearance.AvatarSize; 4219 agentpos.Size = Appearance.AvatarSize;
4251 agentpos.Center = CameraPosition; 4220 agentpos.Center = CameraPosition;
4252 agentpos.Far = DrawDistance; 4221 agentpos.Far = DrawDistance;
4253 agentpos.Position = AbsolutePosition; 4222 agentpos.Position = AbsolutePosition;
4254 agentpos.Velocity = Velocity; 4223 agentpos.Velocity = Velocity;
4255 agentpos.RegionHandle = RegionHandle; 4224 agentpos.RegionHandle = RegionHandle;
4256 agentpos.GodData = GodController.State(); 4225 agentpos.GodData = GodController.State();
4257 agentpos.Throttles = ControllingClient.GetThrottlesPacked(1); 4226 agentpos.Throttles = ControllingClient.GetThrottlesPacked(1);
4258 4227
4259 // Let's get this out of the update loop 4228 // Let's get this out of the update loop
4260 Util.FireAndForget( 4229 Util.FireAndForget(
4261 o => 4230 o =>
4262 { 4231 {
4263 m_scene.SendOutChildAgentUpdates(agentpos, this); 4232 m_scene.SendOutChildAgentUpdates(agentpos, this);
4264 lastChildUpdatesTime = Util.EnvironmentTickCount(); 4233 m_lastChildUpdatesTime = Util.EnvironmentTickCount();
4265 childUpdatesBusy = false; 4234 m_childUpdatesBusy = false;
4266 }, null, "ScenePresence.SendOutChildAgentUpdates"); 4235 }, null, "ScenePresence.SendOutChildAgentUpdates");
4267 }
4268 } 4236 }
4269 } 4237 }
4270 } 4238 }
@@ -4505,9 +4473,10 @@ namespace OpenSim.Region.Framework.Scenes
4505 if (isNPC) 4473 if (isNPC)
4506 return; 4474 return;
4507 4475
4508 bool success = GodController.RequestGodMode(godStatus); 4476 bool wasgod = isLegacyGod;
4509 if (success && godStatus) 4477 GodController.RequestGodMode(godStatus);
4510 parcelGodCheck(m_currentParcelUUID, GodController.GodLevel >= 200); 4478 if (wasgod != isLegacyGod)
4479 parcelGodCheck(m_currentParcelUUID);
4511 } 4480 }
4512 4481
4513 #region Child Agent Updates 4482 #region Child Agent Updates
@@ -4606,6 +4575,7 @@ namespace OpenSim.Region.Framework.Scenes
4606 cAgent.UpAxis = CameraUpAxis; 4575 cAgent.UpAxis = CameraUpAxis;
4607 4576
4608 cAgent.Far = DrawDistance; 4577 cAgent.Far = DrawDistance;
4578 cAgent.GodData = GodController.State();
4609 4579
4610 // Throttles 4580 // Throttles
4611 cAgent.Throttles = ControllingClient.GetThrottlesPacked(1); 4581 cAgent.Throttles = ControllingClient.GetThrottlesPacked(1);
@@ -4686,7 +4656,6 @@ namespace OpenSim.Region.Framework.Scenes
4686 Quaternion camRot = Util.Axes2Rot(CameraAtAxis, CameraLeftAxis, CameraUpAxis); 4656 Quaternion camRot = Util.Axes2Rot(CameraAtAxis, CameraLeftAxis, CameraUpAxis);
4687 CameraRotation = camRot; 4657 CameraRotation = camRot;
4688 4658
4689
4690 ParentUUID = cAgent.ParentPart; 4659 ParentUUID = cAgent.ParentPart;
4691 PrevSitOffset = cAgent.SitOffset; 4660 PrevSitOffset = cAgent.SitOffset;
4692 4661
@@ -4872,7 +4841,6 @@ namespace OpenSim.Region.Framework.Scenes
4872 ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); 4841 ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true);
4873 } 4842 }
4874 4843
4875
4876 /// <summary> 4844 /// <summary>
4877 /// Event called by the physics plugin to tell the avatar about a collision. 4845 /// Event called by the physics plugin to tell the avatar about a collision.
4878 /// </summary> 4846 /// </summary>
@@ -4941,7 +4909,7 @@ namespace OpenSim.Region.Framework.Scenes
4941 RaiseCollisionScriptEvents(coldata); 4909 RaiseCollisionScriptEvents(coldata);
4942 4910
4943 // Gods do not take damage and Invulnerable is set depending on parcel/region flags 4911 // Gods do not take damage and Invulnerable is set depending on parcel/region flags
4944 if (Invulnerable || GodController.GodLevel > 0) 4912 if (Invulnerable || isLegacyGod)
4945 return; 4913 return;
4946 4914
4947 // The following may be better in the ICombatModule 4915 // The following may be better in the ICombatModule
@@ -5226,7 +5194,7 @@ namespace OpenSim.Region.Framework.Scenes
5226 if (p != this && sog.HasPrivateAttachmentPoint) 5194 if (p != this && sog.HasPrivateAttachmentPoint)
5227 return; 5195 return;
5228 5196
5229 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) 5197 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod)
5230 return; 5198 return;
5231 5199
5232 SendTerseUpdateToAgentNF(p); 5200 SendTerseUpdateToAgentNF(p);
@@ -5340,7 +5308,7 @@ namespace OpenSim.Region.Framework.Scenes
5340 if (p == this) 5308 if (p == this)
5341 continue; 5309 continue;
5342 5310
5343 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) 5311 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod)
5344 continue; 5312 continue;
5345 5313
5346 p.ControllingClient.SendEntityUpdate(rootpart, rootflag); 5314 p.ControllingClient.SendEntityUpdate(rootpart, rootflag);
@@ -5392,14 +5360,13 @@ namespace OpenSim.Region.Framework.Scenes
5392 if (sog.HasPrivateAttachmentPoint) 5360 if (sog.HasPrivateAttachmentPoint)
5393 return; 5361 return;
5394 5362
5395
5396 List<ScenePresence> allPresences = m_scene.GetScenePresences(); 5363 List<ScenePresence> allPresences = m_scene.GetScenePresences();
5397 foreach (ScenePresence p in allPresences) 5364 foreach (ScenePresence p in allPresences)
5398 { 5365 {
5399 if (p == this) 5366 if (p == this)
5400 continue; 5367 continue;
5401 5368
5402 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) 5369 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod)
5403 continue; 5370 continue;
5404 5371
5405 p.ControllingClient.SendEntityUpdate(rootpart, flag); 5372 p.ControllingClient.SendEntityUpdate(rootpart, flag);
@@ -5449,7 +5416,7 @@ namespace OpenSim.Region.Framework.Scenes
5449 if (p == this) 5416 if (p == this)
5450 continue; 5417 continue;
5451 5418
5452 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) 5419 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod)
5453 continue; 5420 continue;
5454 5421
5455 p.ControllingClient.SendEntityUpdate(part, flag); 5422 p.ControllingClient.SendEntityUpdate(part, flag);
@@ -5490,7 +5457,7 @@ namespace OpenSim.Region.Framework.Scenes
5490 { 5457 {
5491 if (p == this) 5458 if (p == this)
5492 continue; 5459 continue;
5493 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) 5460 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod)
5494 continue; 5461 continue;
5495 5462
5496 p.ControllingClient.SendEntityUpdate(part, flag); 5463 p.ControllingClient.SendEntityUpdate(part, flag);
@@ -6128,7 +6095,7 @@ namespace OpenSim.Region.Framework.Scenes
6128 // the TP point. This behaviour mimics agni. 6095 // the TP point. This behaviour mimics agni.
6129 if (land.LandData.LandingType == (byte)LandingType.LandingPoint && 6096 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
6130 land.LandData.UserLocation != Vector3.Zero && 6097 land.LandData.UserLocation != Vector3.Zero &&
6131 GodController.GodLevel < 200 && 6098 !isLegacyGod &&
6132 ((land.LandData.OwnerID != m_uuid && 6099 ((land.LandData.OwnerID != m_uuid &&
6133 !m_scene.Permissions.IsGod(m_uuid) && 6100 !m_scene.Permissions.IsGod(m_uuid) &&
6134 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || 6101 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
@@ -6153,7 +6120,7 @@ namespace OpenSim.Region.Framework.Scenes
6153 string reason; 6120 string reason;
6154 6121
6155 // dont mess with gods 6122 // dont mess with gods
6156 if(GodController.GodLevel >= 200 || m_scene.Permissions.IsGod(m_uuid)) 6123 if(isLegacyGod || m_scene.Permissions.IsGod(m_uuid))
6157 return true; 6124 return true;
6158 6125
6159 // respect region owner and managers 6126 // respect region owner and managers
@@ -6439,7 +6406,7 @@ namespace OpenSim.Region.Framework.Scenes
6439 6406
6440 } 6407 }
6441 6408
6442 private void parcelGodCheck(UUID currentParcelID, bool isGod) 6409 private void parcelGodCheck(UUID currentParcelID)
6443 { 6410 {
6444 List<ScenePresence> allpresences = m_scene.GetScenePresences(); 6411 List<ScenePresence> allpresences = m_scene.GetScenePresences();
6445 6412
@@ -6450,7 +6417,7 @@ namespace OpenSim.Region.Framework.Scenes
6450 6417
6451 if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID) 6418 if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID)
6452 { 6419 {
6453 if (isGod) 6420 if (isLegacyGod)
6454 p.SendViewTo(this); 6421 p.SendViewTo(this);
6455 else 6422 else
6456 p.SendKillTo(this); 6423 p.SendKillTo(this);
@@ -6459,7 +6426,7 @@ namespace OpenSim.Region.Framework.Scenes
6459 } 6426 }
6460 6427
6461 private void ParcelCrossCheck(UUID currentParcelID,UUID previusParcelID, 6428 private void ParcelCrossCheck(UUID currentParcelID,UUID previusParcelID,
6462 bool currentParcelHide, bool previusParcelHide, bool oldhide,bool check) 6429 bool currentParcelHide, bool previusParcelHide, bool oldhide, bool check)
6463 { 6430 {
6464 List<ScenePresence> killsToSendto = new List<ScenePresence>(); 6431 List<ScenePresence> killsToSendto = new List<ScenePresence>();
6465 List<ScenePresence> killsToSendme = new List<ScenePresence>(); 6432 List<ScenePresence> killsToSendme = new List<ScenePresence>();
@@ -6501,7 +6468,7 @@ namespace OpenSim.Region.Framework.Scenes
6501 continue; 6468 continue;
6502 6469
6503 // those not on parcel dont see me 6470 // those not on parcel dont see me
6504 if (currentParcelID != p.currentParcelUUID && p.GodController.GodLevel < 200) 6471 if (currentParcelID != p.currentParcelUUID && !p.isLegacyGod)
6505 { 6472 {
6506 killsToSendto.Add(p); // they dont see me 6473 killsToSendto.Add(p); // they dont see me
6507 } 6474 }
@@ -6527,9 +6494,9 @@ namespace OpenSim.Region.Framework.Scenes
6527 // only those on previus parcel need receive kills 6494 // only those on previus parcel need receive kills
6528 if (previusParcelID == p.currentParcelUUID) 6495 if (previusParcelID == p.currentParcelUUID)
6529 { 6496 {
6530 if(p.GodController.GodLevel < 200) 6497 if(!p.isLegacyGod)
6531 killsToSendto.Add(p); // they dont see me 6498 killsToSendto.Add(p); // they dont see me
6532 if(GodController.GodLevel < 200) 6499 if(!isLegacyGod)
6533 killsToSendme.Add(p); // i dont see them 6500 killsToSendme.Add(p); // i dont see them
6534 } 6501 }
6535 // only those on new parcel need see 6502 // only those on new parcel need see
@@ -6551,7 +6518,7 @@ namespace OpenSim.Region.Framework.Scenes
6551 continue; 6518 continue;
6552 6519
6553 // those not on new parcel dont see me 6520 // those not on new parcel dont see me
6554 if (currentParcelID != p.currentParcelUUID && p.GodController.GodLevel < 200) 6521 if (currentParcelID != p.currentParcelUUID && !p.isLegacyGod)
6555 { 6522 {
6556 killsToSendto.Add(p); // they dont see me 6523 killsToSendto.Add(p); // they dont see me
6557 } 6524 }
@@ -6577,7 +6544,7 @@ namespace OpenSim.Region.Framework.Scenes
6577 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) 6544 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
6578 continue; 6545 continue;
6579 // only those old parcel need kills 6546 // only those old parcel need kills
6580 if (previusParcelID == p.currentParcelUUID && GodController.GodLevel < 200) 6547 if (previusParcelID == p.currentParcelUUID && !isLegacyGod)
6581 { 6548 {
6582 killsToSendme.Add(p); // i dont see them 6549 killsToSendme.Add(p); // i dont see them
6583 } 6550 }
@@ -6634,13 +6601,12 @@ namespace OpenSim.Region.Framework.Scenes
6634 6601
6635 public void HasMovedAway(bool nearRegion) 6602 public void HasMovedAway(bool nearRegion)
6636 { 6603 {
6637
6638 if (nearRegion) 6604 if (nearRegion)
6639 { 6605 {
6640 if (Scene.AttachmentsModule != null) 6606 if (Scene.AttachmentsModule != null)
6641 Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); 6607 Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true);
6642 6608
6643 if (!ParcelHideThisAvatar || GodController.GodLevel >= 200) 6609 if (!ParcelHideThisAvatar || isLegacyGod)
6644 return; 6610 return;
6645 6611
6646 List<ScenePresence> allpresences = m_scene.GetScenePresences(); 6612 List<ScenePresence> allpresences = m_scene.GetScenePresences();
@@ -6657,6 +6623,7 @@ namespace OpenSim.Region.Framework.Scenes
6657 } 6623 }
6658 else 6624 else
6659 { 6625 {
6626 GodController.HasMovedAway();
6660 List<ScenePresence> allpresences = m_scene.GetScenePresences(); 6627 List<ScenePresence> allpresences = m_scene.GetScenePresences();
6661 foreach (ScenePresence p in allpresences) 6628 foreach (ScenePresence p in allpresences)
6662 { 6629 {
diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs
index e76e8f2..ed44a5a 100644
--- a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs
+++ b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs
@@ -134,7 +134,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
134 } 134 }
135 else 135 else
136 { 136 {
137 using (FileStream fs = File.Open(dialogData.XmlName + ".xml", FileMode.Open)) 137 using (FileStream fs = File.Open(dialogData.XmlName + ".xml", FileMode.Open, FileAccess.Read))
138 { 138 {
139 using (StreamReader sr = new StreamReader(fs)) 139 using (StreamReader sr = new StreamReader(fs))
140 xml = sr.ReadToEnd().Replace("\n", ""); 140 xml = sr.ReadToEnd().Replace("\n", "");
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index cd5308d..0ccc683 100755
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -182,7 +182,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
182 182
183 private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); 183 private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue();
184 IWorkItemResult m_CurrentCompile = null; 184 IWorkItemResult m_CurrentCompile = null;
185 private Dictionary<UUID, int> m_CompileDict = new Dictionary<UUID, int>(); 185 private Dictionary<UUID, ScriptCompileInfo> m_CompileDict = new Dictionary<UUID, ScriptCompileInfo>();
186 186
187 private ScriptEngineConsoleCommands m_consoleCommands; 187 private ScriptEngineConsoleCommands m_consoleCommands;
188 188
@@ -236,6 +236,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
236 get { return m_ConfigSource; } 236 get { return m_ConfigSource; }
237 } 237 }
238 238
239 private class ScriptCompileInfo
240 {
241 public List<EventParams> eventList = new List<EventParams>();
242 }
243
239 /// <summary> 244 /// <summary>
240 /// Event fired after the script engine has finished removing a script. 245 /// Event fired after the script engine has finished removing a script.
241 /// </summary> 246 /// </summary>
@@ -1009,7 +1014,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1009 { 1014 {
1010 lock (m_CompileDict) 1015 lock (m_CompileDict)
1011 { 1016 {
1012 m_CompileDict[itemID] = 0; 1017// m_log.DebugFormat("[XENGINE]: Set compile dict for {0}", itemID);
1018 m_CompileDict[itemID] = new ScriptCompileInfo();
1013 } 1019 }
1014 1020
1015 DoOnRezScript(parms); 1021 DoOnRezScript(parms);
@@ -1017,7 +1023,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1017 else 1023 else
1018 { 1024 {
1019 lock (m_CompileDict) 1025 lock (m_CompileDict)
1020 m_CompileDict[itemID] = 0; 1026 m_CompileDict[itemID] = new ScriptCompileInfo();
1027// m_log.DebugFormat("[XENGINE]: Set compile dict for {0} delayed", itemID);
1021 1028
1022 // This must occur after the m_CompileDict so that an existing compile thread cannot hit the check 1029 // This must occur after the m_CompileDict so that an existing compile thread cannot hit the check
1023 // in DoOnRezScript() before m_CompileDict has been updated. 1030 // in DoOnRezScript() before m_CompileDict has been updated.
@@ -1135,7 +1142,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1135 { 1142 {
1136 if (!m_CompileDict.ContainsKey(itemID)) 1143 if (!m_CompileDict.ContainsKey(itemID))
1137 return false; 1144 return false;
1138 m_CompileDict.Remove(itemID);
1139 } 1145 }
1140 1146
1141 // Get the asset ID of the script, so we can check if we 1147 // Get the asset ID of the script, so we can check if we
@@ -1150,6 +1156,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1150 m_log.ErrorFormat("[Script]: SceneObjectPart with localID {0} unavailable. Script NOT started.", localID); 1156 m_log.ErrorFormat("[Script]: SceneObjectPart with localID {0} unavailable. Script NOT started.", localID);
1151 m_ScriptErrorMessage += "SceneObjectPart unavailable. Script NOT started.\n"; 1157 m_ScriptErrorMessage += "SceneObjectPart unavailable. Script NOT started.\n";
1152 m_ScriptFailCount++; 1158 m_ScriptFailCount++;
1159 lock (m_CompileDict)
1160 m_CompileDict.Remove(itemID);
1153 return false; 1161 return false;
1154 } 1162 }
1155 1163
@@ -1158,6 +1166,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1158 { 1166 {
1159 m_ScriptErrorMessage += "Can't find script inventory item.\n"; 1167 m_ScriptErrorMessage += "Can't find script inventory item.\n";
1160 m_ScriptFailCount++; 1168 m_ScriptFailCount++;
1169 lock (m_CompileDict)
1170 m_CompileDict.Remove(itemID);
1161 return false; 1171 return false;
1162 } 1172 }
1163 1173
@@ -1275,6 +1285,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1275 // e.Message.ToString()); 1285 // e.Message.ToString());
1276 // } 1286 // }
1277 1287
1288 lock (m_CompileDict)
1289 m_CompileDict.Remove(itemID);
1278 return false; 1290 return false;
1279 } 1291 }
1280 } 1292 }
@@ -1345,6 +1357,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1345 { 1357 {
1346 m_AddingAssemblies[assemblyPath]--; 1358 m_AddingAssemblies[assemblyPath]--;
1347 } 1359 }
1360 lock (m_CompileDict)
1361 m_CompileDict.Remove(itemID);
1348 return false; 1362 return false;
1349 } 1363 }
1350 } 1364 }
@@ -1402,6 +1416,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1402 assemblyName.FullName, World.Name), 1416 assemblyName.FullName, World.Name),
1403 e2); 1417 e2);
1404 1418
1419 lock (m_CompileDict)
1420 m_CompileDict.Remove(itemID);
1405 return false; 1421 return false;
1406 } 1422 }
1407 1423
@@ -1451,6 +1467,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1451 assemblyName.FullName, World.Name), 1467 assemblyName.FullName, World.Name),
1452 e2); 1468 e2);
1453 1469
1470 lock (m_CompileDict)
1471 m_CompileDict.Remove(itemID);
1454 return false; 1472 return false;
1455 } 1473 }
1456 1474
@@ -1478,7 +1496,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1478 1496
1479 if(!instance.Load(scriptObj, coopSleepHandle, assemblyPath, 1497 if(!instance.Load(scriptObj, coopSleepHandle, assemblyPath,
1480 Path.Combine(ScriptEnginePath, World.RegionInfo.RegionID.ToString()), stateSource, coopTerminationForThisScript)) 1498 Path.Combine(ScriptEnginePath, World.RegionInfo.RegionID.ToString()), stateSource, coopTerminationForThisScript))
1481 return false; 1499 {
1500 lock (m_CompileDict)
1501 m_CompileDict.Remove(itemID);
1502 return false;
1503 }
1482 1504
1483// if (DebugLevel >= 1) 1505// if (DebugLevel >= 1)
1484// m_log.DebugFormat( 1506// m_log.DebugFormat(
@@ -1518,7 +1540,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1518 } 1540 }
1519 1541
1520 if (instance != null) 1542 if (instance != null)
1543 {
1521 instance.Init(); 1544 instance.Init();
1545 lock (m_CompileDict)
1546 {
1547 foreach (EventParams pp in m_CompileDict[itemID].eventList)
1548 instance.PostEvent(pp);
1549 }
1550 }
1551 lock (m_CompileDict)
1552 m_CompileDict.Remove(itemID);
1522 1553
1523 bool runIt; 1554 bool runIt;
1524 if (m_runFlags.TryGetValue(itemID, out runIt)) 1555 if (m_runFlags.TryGetValue(itemID, out runIt))
@@ -1742,6 +1773,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1742 instance.PostEvent(p); 1773 instance.PostEvent(p);
1743 result = true; 1774 result = true;
1744 } 1775 }
1776 else
1777 {
1778 lock (m_CompileDict)
1779 {
1780 if (m_CompileDict.ContainsKey(itemID))
1781 {
1782 m_CompileDict[itemID].eventList.Add(p);
1783 result = true;
1784 }
1785 }
1786 }
1745 } 1787 }
1746 } 1788 }
1747 1789
@@ -1763,6 +1805,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1763 instance.PostEvent(p); 1805 instance.PostEvent(p);
1764 return true; 1806 return true;
1765 } 1807 }
1808 lock (m_CompileDict)
1809 {
1810 if (m_CompileDict.ContainsKey(itemID))
1811 {
1812 m_CompileDict[itemID].eventList.Add(p);
1813 return true;
1814 }
1815 }
1766 return false; 1816 return false;
1767 } 1817 }
1768 1818
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index 7120aeb..f6b003a 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -947,7 +947,6 @@ namespace OpenSim.Services.UserAccountService
947 if (item.InvType == (int)InventoryType.Object) 947 if (item.InvType == (int)InventoryType.Object)
948 { 948 {
949 uint perms = item.CurrentPermissions; 949 uint perms = item.CurrentPermissions;
950 PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms);
951 item.CurrentPermissions = perms; 950 item.CurrentPermissions = perms;
952 } 951 }
953 952