diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rwxr-xr-x | OpenSim/Region/Framework/Scenes/Scene.cs | 211 |
1 files changed, 147 insertions, 64 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2137b42..715ae5c 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -540,6 +540,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
540 | private Timer m_mapGenerationTimer = new Timer(); | 540 | private Timer m_mapGenerationTimer = new Timer(); |
541 | private bool m_generateMaptiles; | 541 | private bool m_generateMaptiles; |
542 | 542 | ||
543 | protected int m_lastHealth = -1; | ||
544 | protected int m_lastUsers = -1; | ||
545 | |||
543 | #endregion Fields | 546 | #endregion Fields |
544 | 547 | ||
545 | #region Properties | 548 | #region Properties |
@@ -805,6 +808,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
805 | private float m_minReprioritizationDistance = 32f; | 808 | private float m_minReprioritizationDistance = 32f; |
806 | public bool ObjectsCullingByDistance = false; | 809 | public bool ObjectsCullingByDistance = false; |
807 | 810 | ||
811 | private ExpiringCache<UUID, UUID> TeleportTargetsCoolDown = new ExpiringCache<UUID, UUID>(); | ||
812 | |||
808 | public AgentCircuitManager AuthenticateHandler | 813 | public AgentCircuitManager AuthenticateHandler |
809 | { | 814 | { |
810 | get { return m_authenticateHandler; } | 815 | get { return m_authenticateHandler; } |
@@ -1212,6 +1217,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
1212 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; | 1217 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; |
1213 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 1218 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
1214 | 1219 | ||
1220 | IConfig restartConfig = config.Configs["RestartModule"]; | ||
1221 | if (restartConfig != null) | ||
1222 | { | ||
1223 | string markerPath = restartConfig.GetString("MarkerPath", String.Empty); | ||
1224 | |||
1225 | if (markerPath != String.Empty) | ||
1226 | { | ||
1227 | string path = Path.Combine(markerPath, RegionInfo.RegionID.ToString() + ".started"); | ||
1228 | try | ||
1229 | { | ||
1230 | string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); | ||
1231 | FileStream fs = File.Create(path); | ||
1232 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | ||
1233 | Byte[] buf = enc.GetBytes(pidstring); | ||
1234 | fs.Write(buf, 0, buf.Length); | ||
1235 | fs.Close(); | ||
1236 | } | ||
1237 | catch (Exception) | ||
1238 | { | ||
1239 | } | ||
1240 | } | ||
1241 | } | ||
1242 | |||
1243 | StartTimerWatchdog(); | ||
1215 | } | 1244 | } |
1216 | 1245 | ||
1217 | public Scene(RegionInfo regInfo) | 1246 | public Scene(RegionInfo regInfo) |
@@ -1482,6 +1511,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1482 | return; | 1511 | return; |
1483 | } | 1512 | } |
1484 | 1513 | ||
1514 | IEtcdModule etcd = RequestModuleInterface<IEtcdModule>(); | ||
1515 | if (etcd != null) | ||
1516 | { | ||
1517 | etcd.Delete("Health"); | ||
1518 | etcd.Delete("HealthFlags"); | ||
1519 | etcd.Delete("RootAgents"); | ||
1520 | } | ||
1521 | |||
1485 | m_log.InfoFormat("[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName); | 1522 | m_log.InfoFormat("[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName); |
1486 | 1523 | ||
1487 | 1524 | ||
@@ -1520,6 +1557,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1520 | m_log.Debug("[SCENE]: Persisting changed objects"); | 1557 | m_log.Debug("[SCENE]: Persisting changed objects"); |
1521 | Backup(true); | 1558 | Backup(true); |
1522 | 1559 | ||
1560 | m_log.Debug("[SCENE]: Closing scene"); | ||
1561 | |||
1523 | m_sceneGraph.Close(); | 1562 | m_sceneGraph.Close(); |
1524 | 1563 | ||
1525 | base.Close(); | 1564 | base.Close(); |
@@ -2351,6 +2390,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2351 | EventManager.TriggerOnSceneObjectLoaded(group); | 2390 | EventManager.TriggerOnSceneObjectLoaded(group); |
2352 | SceneObjectPart rootPart = group.GetPart(group.UUID); | 2391 | SceneObjectPart rootPart = group.GetPart(group.UUID); |
2353 | rootPart.Flags &= ~PrimFlags.Scripted; | 2392 | rootPart.Flags &= ~PrimFlags.Scripted; |
2393 | group.AggregateDeepPerms(); | ||
2354 | rootPart.TrimPermissions(); | 2394 | rootPart.TrimPermissions(); |
2355 | 2395 | ||
2356 | // Don't do this here - it will get done later on when sculpt data is loaded. | 2396 | // Don't do this here - it will get done later on when sculpt data is loaded. |
@@ -2603,8 +2643,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2603 | { | 2643 | { |
2604 | // Otherwise, use this default creation code; | 2644 | // Otherwise, use this default creation code; |
2605 | sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape); | 2645 | sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape); |
2606 | AddNewSceneObject(sceneObject, true); | ||
2607 | sceneObject.SetGroup(groupID, null); | 2646 | sceneObject.SetGroup(groupID, null); |
2647 | AddNewSceneObject(sceneObject, true); | ||
2608 | 2648 | ||
2609 | if (AgentPreferencesService != null) // This will override the brave new full perm world! | 2649 | if (AgentPreferencesService != null) // This will override the brave new full perm world! |
2610 | { | 2650 | { |
@@ -2622,6 +2662,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2622 | if (UserManagementModule != null) | 2662 | if (UserManagementModule != null) |
2623 | sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID); | 2663 | sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID); |
2624 | 2664 | ||
2665 | sceneObject.AggregateDeepPerms(); | ||
2625 | sceneObject.ScheduleGroupForFullUpdate(); | 2666 | sceneObject.ScheduleGroupForFullUpdate(); |
2626 | 2667 | ||
2627 | return sceneObject; | 2668 | return sceneObject; |
@@ -2768,7 +2809,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2768 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2809 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2769 | if (sog != null && !sog.IsAttachment) | 2810 | if (sog != null && !sog.IsAttachment) |
2770 | { | 2811 | { |
2771 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | 2812 | if (!exceptNoCopy || ((sog.EffectiveOwnerPerms & (uint)PermissionMask.Copy) != 0)) |
2772 | { | 2813 | { |
2773 | DeleteSceneObject((SceneObjectGroup)e, false); | 2814 | DeleteSceneObject((SceneObjectGroup)e, false); |
2774 | } | 2815 | } |
@@ -2782,7 +2823,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2782 | } | 2823 | } |
2783 | if (toReturn.Count > 0) | 2824 | if (toReturn.Count > 0) |
2784 | { | 2825 | { |
2785 | returnObjects(toReturn.ToArray(), UUID.Zero); | 2826 | returnObjects(toReturn.ToArray(), null); |
2786 | } | 2827 | } |
2787 | } | 2828 | } |
2788 | 2829 | ||
@@ -2944,15 +2985,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2944 | // Return 'true' if position inside region. | 2985 | // Return 'true' if position inside region. |
2945 | public bool PositionIsInCurrentRegion(Vector3 pos) | 2986 | public bool PositionIsInCurrentRegion(Vector3 pos) |
2946 | { | 2987 | { |
2947 | bool ret = false; | 2988 | float t = pos.X; |
2948 | int xx = (int)Math.Floor(pos.X); | 2989 | if (t < 0 || t >= RegionInfo.RegionSizeX) |
2949 | int yy = (int)Math.Floor(pos.Y); | ||
2950 | if (xx < 0 || yy < 0) | ||
2951 | return false; | 2990 | return false; |
2952 | 2991 | ||
2953 | if (xx < RegionInfo.RegionSizeX && yy < RegionInfo.RegionSizeY ) | 2992 | t = pos.Y; |
2954 | ret = true; | 2993 | if (t < 0 || t >= RegionInfo.RegionSizeY) |
2955 | return ret; | 2994 | return false; |
2995 | |||
2996 | return true; | ||
2956 | } | 2997 | } |
2957 | 2998 | ||
2958 | /// <summary> | 2999 | /// <summary> |
@@ -3603,7 +3644,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3603 | /// <param name="GroupID">Group of new object</param> | 3644 | /// <param name="GroupID">Group of new object</param> |
3604 | public void DuplicateObject(uint originalPrim, Vector3 offset, uint flags, UUID AgentID, UUID GroupID) | 3645 | public void DuplicateObject(uint originalPrim, Vector3 offset, uint flags, UUID AgentID, UUID GroupID) |
3605 | { | 3646 | { |
3606 | SceneObjectGroup copy = SceneGraph.DuplicateObject(originalPrim, offset, flags, AgentID, GroupID, Quaternion.Identity); | 3647 | bool createSelected = (flags & (uint)PrimFlags.CreateSelected) != 0; |
3648 | SceneObjectGroup copy = SceneGraph.DuplicateObject(originalPrim, offset, AgentID, | ||
3649 | GroupID, Quaternion.Identity, createSelected); | ||
3607 | if (copy != null) | 3650 | if (copy != null) |
3608 | EventManager.TriggerObjectAddedToScene(copy); | 3651 | EventManager.TriggerObjectAddedToScene(copy); |
3609 | } | 3652 | } |
@@ -3633,6 +3676,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3633 | SceneObjectPart target = GetSceneObjectPart(localID); | 3676 | SceneObjectPart target = GetSceneObjectPart(localID); |
3634 | SceneObjectPart target2 = GetSceneObjectPart(RayTargetObj); | 3677 | SceneObjectPart target2 = GetSceneObjectPart(RayTargetObj); |
3635 | 3678 | ||
3679 | bool createSelected = (dupeFlags & (uint)PrimFlags.CreateSelected) != 0; | ||
3680 | |||
3636 | if (target != null && target2 != null) | 3681 | if (target != null && target2 != null) |
3637 | { | 3682 | { |
3638 | Vector3 direction = Vector3.Normalize(RayEnd - RayStart); | 3683 | Vector3 direction = Vector3.Normalize(RayEnd - RayStart); |
@@ -3674,13 +3719,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3674 | Quaternion worldRot = target2.GetWorldRotation(); | 3719 | Quaternion worldRot = target2.GetWorldRotation(); |
3675 | 3720 | ||
3676 | // SceneObjectGroup obj = m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, worldRot); | 3721 | // SceneObjectGroup obj = m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, worldRot); |
3677 | copy = m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, worldRot); | 3722 | copy = m_sceneGraph.DuplicateObject(localID, pos, AgentID, GroupID, worldRot, createSelected); |
3678 | //obj.Rotation = worldRot; | 3723 | //obj.Rotation = worldRot; |
3679 | //obj.UpdateGroupRotationR(worldRot); | 3724 | //obj.UpdateGroupRotationR(worldRot); |
3680 | } | 3725 | } |
3681 | else | 3726 | else |
3682 | { | 3727 | { |
3683 | copy = m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, Quaternion.Identity); | 3728 | copy = m_sceneGraph.DuplicateObject(localID, pos, AgentID, GroupID, Quaternion.Identity, createSelected); |
3684 | } | 3729 | } |
3685 | 3730 | ||
3686 | if (copy != null) | 3731 | if (copy != null) |
@@ -3983,7 +4028,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3983 | 4028 | ||
3984 | if (!LoginsEnabled) | 4029 | if (!LoginsEnabled) |
3985 | { | 4030 | { |
3986 | reason = "Logins Disabled"; | 4031 | reason = "Logins to this region are disabled"; |
3987 | return false; | 4032 | return false; |
3988 | } | 4033 | } |
3989 | 4034 | ||
@@ -5077,65 +5122,59 @@ Label_GroupsDone: | |||
5077 | #endregion | 5122 | #endregion |
5078 | 5123 | ||
5079 | #region Script Engine | 5124 | #region Script Engine |
5080 | 5125 | public bool LSLScriptDanger(SceneObjectPart part, Vector3 pos) | |
5081 | private bool ScriptDanger(SceneObjectPart part, Vector3 pos) | ||
5082 | { | 5126 | { |
5127 | |||
5083 | ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y); | 5128 | ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y); |
5084 | if (part != null) | 5129 | if (parcel == null) |
5085 | { | 5130 | return true; |
5086 | if (parcel != null) | 5131 | |
5087 | { | 5132 | LandData ldata = parcel.LandData; |
5088 | if ((parcel.LandData.Flags & (uint)ParcelFlags.AllowOtherScripts) != 0) | 5133 | if (ldata == null) |
5089 | { | 5134 | return true; |
5090 | return true; | 5135 | |
5091 | } | 5136 | uint landflags = ldata.Flags; |
5092 | else if ((part.OwnerID == parcel.LandData.OwnerID) || Permissions.IsGod(part.OwnerID)) | 5137 | |
5093 | { | 5138 | uint mask = (uint)(ParcelFlags.CreateObjects | ParcelFlags.AllowAPrimitiveEntry); |
5094 | return true; | 5139 | if((landflags & mask) != mask) |
5095 | } | 5140 | return true; |
5096 | else if (((parcel.LandData.Flags & (uint)ParcelFlags.AllowGroupScripts) != 0) | 5141 | |
5097 | && (parcel.LandData.GroupID != UUID.Zero) && (parcel.LandData.GroupID == part.GroupID)) | 5142 | if((landflags & (uint)ParcelFlags.AllowOtherScripts) != 0) |
5098 | { | 5143 | return false; |
5099 | return true; | ||
5100 | } | ||
5101 | else | ||
5102 | { | ||
5103 | return false; | ||
5104 | } | ||
5105 | } | ||
5106 | else | ||
5107 | { | ||
5108 | 5144 | ||
5109 | if (pos.X > 0f && pos.X < RegionInfo.RegionSizeX && pos.Y > 0f && pos.Y < RegionInfo.RegionSizeY) | 5145 | if(part == null) |
5110 | { | 5146 | return true; |
5111 | // The only time parcel != null when an object is inside a region is when | 5147 | if(part.GroupID == ldata.GroupID && (landflags & (uint)ParcelFlags.AllowGroupScripts) != 0) |
5112 | // there is nothing behind the landchannel. IE, no land plugin loaded. | ||
5113 | return true; | ||
5114 | } | ||
5115 | else | ||
5116 | { | ||
5117 | // The object is outside of this region. Stop piping events to it. | ||
5118 | return false; | ||
5119 | } | ||
5120 | } | ||
5121 | } | ||
5122 | else | ||
5123 | { | ||
5124 | return false; | 5148 | return false; |
5125 | } | 5149 | |
5150 | return true; | ||
5126 | } | 5151 | } |
5127 | 5152 | ||
5128 | public bool ScriptDanger(uint localID, Vector3 pos) | 5153 | private bool ScriptDanger(SceneObjectPart part, Vector3 pos) |
5129 | { | 5154 | { |
5130 | SceneObjectPart part = GetSceneObjectPart(localID); | 5155 | if (part == null) |
5131 | if (part != null) | 5156 | return false; |
5157 | |||
5158 | ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y); | ||
5159 | if (parcel != null) | ||
5132 | { | 5160 | { |
5133 | return ScriptDanger(part, pos); | 5161 | if ((parcel.LandData.Flags & (uint)ParcelFlags.AllowOtherScripts) != 0) |
5162 | return true; | ||
5163 | |||
5164 | if ((part.OwnerID == parcel.LandData.OwnerID) || Permissions.IsGod(part.OwnerID)) | ||
5165 | return true; | ||
5166 | |||
5167 | if (((parcel.LandData.Flags & (uint)ParcelFlags.AllowGroupScripts) != 0) | ||
5168 | && (parcel.LandData.GroupID != UUID.Zero) && (parcel.LandData.GroupID == part.GroupID)) | ||
5169 | return true; | ||
5134 | } | 5170 | } |
5135 | else | 5171 | else |
5136 | { | 5172 | { |
5137 | return false; | 5173 | if (pos.X > 0f && pos.X < RegionInfo.RegionSizeX && pos.Y > 0f && pos.Y < RegionInfo.RegionSizeY) |
5174 | return true; | ||
5138 | } | 5175 | } |
5176 | |||
5177 | return false; | ||
5139 | } | 5178 | } |
5140 | 5179 | ||
5141 | public bool PipeEventsForScript(uint localID) | 5180 | public bool PipeEventsForScript(uint localID) |
@@ -5512,23 +5551,24 @@ Label_GroupsDone: | |||
5512 | return 0; | 5551 | return 0; |
5513 | } | 5552 | } |
5514 | 5553 | ||
5515 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 5554 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 2000) |
5516 | { | 5555 | { |
5517 | health+=1; | 5556 | health+=1; |
5518 | flags |= 1; | 5557 | flags |= 1; |
5519 | } | 5558 | } |
5520 | 5559 | ||
5521 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | 5560 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 2000) |
5522 | { | 5561 | { |
5523 | health+=1; | 5562 | health+=1; |
5524 | flags |= 2; | 5563 | flags |= 2; |
5525 | } | 5564 | } |
5526 | 5565 | ||
5527 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | 5566 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 2000) |
5528 | { | 5567 | { |
5529 | health+=1; | 5568 | health+=1; |
5530 | flags |= 4; | 5569 | flags |= 4; |
5531 | } | 5570 | } |
5571 | /* | ||
5532 | else | 5572 | else |
5533 | { | 5573 | { |
5534 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | 5574 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; |
@@ -5541,6 +5581,7 @@ proc.WaitForExit(); | |||
5541 | Thread.Sleep(1000); | 5581 | Thread.Sleep(1000); |
5542 | Environment.Exit(1); | 5582 | Environment.Exit(1); |
5543 | } | 5583 | } |
5584 | */ | ||
5544 | 5585 | ||
5545 | if (flags != 7) | 5586 | if (flags != 7) |
5546 | return health; | 5587 | return health; |
@@ -6305,6 +6346,32 @@ Environment.Exit(1); | |||
6305 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | 6346 | public void TimerWatchdog(object sender, ElapsedEventArgs e) |
6306 | { | 6347 | { |
6307 | CheckHeartbeat(); | 6348 | CheckHeartbeat(); |
6349 | |||
6350 | IEtcdModule etcd = RequestModuleInterface<IEtcdModule>(); | ||
6351 | int flags; | ||
6352 | string message; | ||
6353 | if (etcd != null) | ||
6354 | { | ||
6355 | int health = GetHealth(out flags, out message); | ||
6356 | if (health != m_lastHealth) | ||
6357 | { | ||
6358 | m_lastHealth = health; | ||
6359 | |||
6360 | etcd.Store("Health", health.ToString(), 300000); | ||
6361 | etcd.Store("HealthFlags", flags.ToString(), 300000); | ||
6362 | } | ||
6363 | |||
6364 | int roots = 0; | ||
6365 | foreach (ScenePresence sp in GetScenePresences()) | ||
6366 | if (!sp.IsChildAgent && !sp.IsNPC) | ||
6367 | roots++; | ||
6368 | |||
6369 | if (m_lastUsers != roots) | ||
6370 | { | ||
6371 | m_lastUsers = roots; | ||
6372 | etcd.Store("RootAgents", roots.ToString(), 300000); | ||
6373 | } | ||
6374 | } | ||
6308 | } | 6375 | } |
6309 | 6376 | ||
6310 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 6377 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
@@ -6461,5 +6528,21 @@ Environment.Exit(1); | |||
6461 | 6528 | ||
6462 | m_eventManager.TriggerExtraSettingChanged(this, name, String.Empty); | 6529 | m_eventManager.TriggerExtraSettingChanged(this, name, String.Empty); |
6463 | } | 6530 | } |
6531 | |||
6532 | public bool InTeleportTargetsCoolDown(UUID sourceID, UUID targetID, double timeout) | ||
6533 | { | ||
6534 | lock(TeleportTargetsCoolDown) | ||
6535 | { | ||
6536 | UUID lastSource = UUID.Zero; | ||
6537 | TeleportTargetsCoolDown.TryGetValue(targetID, out lastSource); | ||
6538 | if(lastSource == UUID.Zero) | ||
6539 | { | ||
6540 | TeleportTargetsCoolDown.Add(targetID, sourceID, timeout); | ||
6541 | return false; | ||
6542 | } | ||
6543 | TeleportTargetsCoolDown.AddOrUpdate(targetID, sourceID, timeout); | ||
6544 | return lastSource == sourceID; | ||
6545 | } | ||
6546 | } | ||
6464 | } | 6547 | } |
6465 | } | 6548 | } |