aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs196
1 files changed, 96 insertions, 100 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d8478a2..05a6f13 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -49,6 +49,7 @@ using OpenSim.Region.Framework.Scenes.Serialization;
49using OpenSim.Region.Physics.Manager; 49using OpenSim.Region.Physics.Manager;
50using Timer=System.Timers.Timer; 50using Timer=System.Timers.Timer;
51using TPFlags = OpenSim.Framework.Constants.TeleportFlags; 51using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
52using GridRegion = OpenSim.Services.Interfaces.GridRegion;
52 53
53namespace OpenSim.Region.Framework.Scenes 54namespace OpenSim.Region.Framework.Scenes
54{ 55{
@@ -193,6 +194,26 @@ namespace OpenSim.Region.Framework.Scenes
193 } 194 }
194 } 195 }
195 196
197 protected IGridService m_GridService = null;
198
199 public IGridService GridService
200 {
201 get
202 {
203 if (m_GridService == null)
204 {
205 m_GridService = RequestModuleInterface<IGridService>();
206
207 if (m_GridService == null)
208 {
209 throw new Exception("No IGridService available. This could happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. Please also check that you have the correct version of your inventory service dll. Sometimes old versions of this dll will still exist. Do a clean checkout and re-create the opensim.ini from the opensim.ini.example.");
210 }
211 }
212
213 return m_GridService;
214 }
215 }
216
196 protected IXMLRPC m_xmlrpcModule; 217 protected IXMLRPC m_xmlrpcModule;
197 protected IWorldComm m_worldCommModule; 218 protected IWorldComm m_worldCommModule;
198 protected IAvatarFactory m_AvatarFactory; 219 protected IAvatarFactory m_AvatarFactory;
@@ -566,10 +587,7 @@ namespace OpenSim.Region.Framework.Scenes
566 } 587 }
567 588
568 /// <summary> 589 /// <summary>
569 /// Another region is up. Gets called from Grid Comms: 590 /// Another region is up.
570 /// (OGS1 -> LocalBackEnd -> RegionListened -> SceneCommunicationService)
571 /// We have to tell all our ScenePresences about it, and add it to the
572 /// neighbor list.
573 /// 591 ///
574 /// We only add it to the neighbor list if it's within 1 region from here. 592 /// We only add it to the neighbor list if it's within 1 region from here.
575 /// Agents may have draw distance values that cross two regions though, so 593 /// Agents may have draw distance values that cross two regions though, so
@@ -578,47 +596,30 @@ namespace OpenSim.Region.Framework.Scenes
578 /// </summary> 596 /// </summary>
579 /// <param name="otherRegion">RegionInfo handle for the new region.</param> 597 /// <param name="otherRegion">RegionInfo handle for the new region.</param>
580 /// <returns>True after all operations complete, throws exceptions otherwise.</returns> 598 /// <returns>True after all operations complete, throws exceptions otherwise.</returns>
581 public override bool OtherRegionUp(RegionInfo otherRegion) 599 public override void OtherRegionUp(GridRegion otherRegion)
582 { 600 {
583 m_log.InfoFormat("[SCENE]: Region {0} up in coords {1}-{2}", otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); 601 uint xcell = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize);
602 uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize);
603 m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}",
604 RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell);
584 605
585 if (RegionInfo.RegionHandle != otherRegion.RegionHandle) 606 if (RegionInfo.RegionHandle != otherRegion.RegionHandle)
586 { 607 {
587 for (int i = 0; i < m_neighbours.Count; i++)
588 {
589 // The purpose of this loop is to re-update the known neighbors
590 // when another region comes up on top of another one.
591 // The latest region in that location ends up in the
592 // 'known neighbors list'
593 // Additionally, the commFailTF property gets reset to false.
594 if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle)
595 {
596 lock (m_neighbours)
597 {
598 m_neighbours[i] = otherRegion;
599
600 }
601 }
602 }
603
604 // If the value isn't in the neighbours, add it.
605 // If the RegionInfo isn't exact but is for the same XY World location,
606 // then the above loop will fix that.
607
608 if (!(CheckNeighborRegion(otherRegion)))
609 {
610 lock (m_neighbours)
611 {
612 m_neighbours.Add(otherRegion);
613 //m_log.Info("[UP]: " + otherRegion.RegionHandle.ToString());
614 }
615 }
616 608
617 // If these are cast to INT because long + negative values + abs returns invalid data 609 // If these are cast to INT because long + negative values + abs returns invalid data
618 int resultX = Math.Abs((int)otherRegion.RegionLocX - (int)RegionInfo.RegionLocX); 610 int resultX = Math.Abs((int)xcell - (int)RegionInfo.RegionLocX);
619 int resultY = Math.Abs((int)otherRegion.RegionLocY - (int)RegionInfo.RegionLocY); 611 int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY);
620 if (resultX <= 1 && resultY <= 1) 612 if (resultX <= 1 && resultY <= 1)
621 { 613 {
614 // Let the grid service module know, so this can be cached
615 m_eventManager.TriggerOnRegionUp(otherRegion);
616
617 RegionInfo regInfo = new RegionInfo(xcell, ycell, otherRegion.InternalEndPoint, otherRegion.ExternalHostName);
618 regInfo.RegionID = otherRegion.RegionID;
619 regInfo.RegionName = otherRegion.RegionName;
620 regInfo.ScopeID = otherRegion.ScopeID;
621 regInfo.ExternalHostName = otherRegion.ExternalHostName;
622
622 try 623 try
623 { 624 {
624 ForEachScenePresence(delegate(ScenePresence agent) 625 ForEachScenePresence(delegate(ScenePresence agent)
@@ -632,7 +633,7 @@ namespace OpenSim.Region.Framework.Scenes
632 List<ulong> old = new List<ulong>(); 633 List<ulong> old = new List<ulong>();
633 old.Add(otherRegion.RegionHandle); 634 old.Add(otherRegion.RegionHandle);
634 agent.DropOldNeighbours(old); 635 agent.DropOldNeighbours(old);
635 InformClientOfNeighbor(agent, otherRegion); 636 InformClientOfNeighbor(agent, regInfo);
636 } 637 }
637 } 638 }
638 ); 639 );
@@ -643,6 +644,7 @@ namespace OpenSim.Region.Framework.Scenes
643 // This shouldn't happen too often anymore. 644 // This shouldn't happen too often anymore.
644 m_log.Error("[SCENE]: Couldn't inform client of regionup because we got a null reference exception"); 645 m_log.Error("[SCENE]: Couldn't inform client of regionup because we got a null reference exception");
645 } 646 }
647
646 } 648 }
647 else 649 else
648 { 650 {
@@ -651,7 +653,6 @@ namespace OpenSim.Region.Framework.Scenes
651 otherRegion.RegionLocY.ToString() + ")"); 653 otherRegion.RegionLocY.ToString() + ")");
652 } 654 }
653 } 655 }
654 return true;
655 } 656 }
656 657
657 public void AddNeighborRegion(RegionInfo region) 658 public void AddNeighborRegion(RegionInfo region)
@@ -683,9 +684,10 @@ namespace OpenSim.Region.Framework.Scenes
683 } 684 }
684 685
685 // Alias IncomingHelloNeighbour OtherRegionUp, for now 686 // Alias IncomingHelloNeighbour OtherRegionUp, for now
686 public bool IncomingHelloNeighbour(RegionInfo neighbour) 687 public GridRegion IncomingHelloNeighbour(RegionInfo neighbour)
687 { 688 {
688 return OtherRegionUp(neighbour); 689 OtherRegionUp(new GridRegion(neighbour));
690 return new GridRegion(RegionInfo);
689 } 691 }
690 692
691 /// <summary> 693 /// <summary>
@@ -994,7 +996,7 @@ namespace OpenSim.Region.Framework.Scenes
994 996
995 // Loop it 997 // Loop it
996 if (m_frame == Int32.MaxValue) 998 if (m_frame == Int32.MaxValue)
997 m_frame = 0; 999 m_frame = 0;
998 1000
999 otherMS = Environment.TickCount; 1001 otherMS = Environment.TickCount;
1000 // run through all entities looking for updates (slow) 1002 // run through all entities looking for updates (slow)
@@ -1336,24 +1338,31 @@ namespace OpenSim.Region.Framework.Scenes
1336 RegisterCommsEvents(); 1338 RegisterCommsEvents();
1337 1339
1338 // These two 'commands' *must be* next to each other or sim rebooting fails. 1340 // These two 'commands' *must be* next to each other or sim rebooting fails.
1339 m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo); 1341 //m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo);
1342
1343 GridRegion region = new GridRegion(RegionInfo);
1344 bool success = GridService.RegisterRegion(RegionInfo.ScopeID, region);
1345 if (!success)
1346 throw new Exception("Can't register with grid");
1347
1348 m_sceneGridService.SetScene(this);
1340 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); 1349 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
1341 1350
1342 Dictionary<string, string> dGridSettings = m_sceneGridService.GetGridSettings(); 1351 //Dictionary<string, string> dGridSettings = m_sceneGridService.GetGridSettings();
1343 1352
1344 if (dGridSettings.ContainsKey("allow_forceful_banlines")) 1353 //if (dGridSettings.ContainsKey("allow_forceful_banlines"))
1345 { 1354 //{
1346 if (dGridSettings["allow_forceful_banlines"] != "TRUE") 1355 // if (dGridSettings["allow_forceful_banlines"] != "TRUE")
1347 { 1356 // {
1348 m_log.Info("[GRID]: Grid is disabling forceful parcel banlists"); 1357 // m_log.Info("[GRID]: Grid is disabling forceful parcel banlists");
1349 EventManager.TriggerSetAllowForcefulBan(false); 1358 // EventManager.TriggerSetAllowForcefulBan(false);
1350 } 1359 // }
1351 else 1360 // else
1352 { 1361 // {
1353 m_log.Info("[GRID]: Grid is allowing forceful parcel banlists"); 1362 // m_log.Info("[GRID]: Grid is allowing forceful parcel banlists");
1354 EventManager.TriggerSetAllowForcefulBan(true); 1363 // EventManager.TriggerSetAllowForcefulBan(true);
1355 } 1364 // }
1356 } 1365 //}
1357 } 1366 }
1358 1367
1359 /// <summary> 1368 /// <summary>
@@ -2014,12 +2023,12 @@ namespace OpenSim.Region.Framework.Scenes
2014 return true; 2023 return true;
2015 } 2024 }
2016 break; 2025 break;
2017 case Cardinals.W: 2026 case Cardinals.W:
2018 foreach (Border b in WestBorders) 2027 foreach (Border b in WestBorders)
2019 { 2028 {
2020 if (b.TestCross(position)) 2029 if (b.TestCross(position))
2021 return true; 2030 return true;
2022 } 2031 }
2023 break; 2032 break;
2024 } 2033 }
2025 } 2034 }
@@ -2717,10 +2726,12 @@ namespace OpenSim.Region.Framework.Scenes
2717 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); 2726 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId);
2718 if (UserProfile != null) 2727 if (UserProfile != null)
2719 { 2728 {
2720 RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegionID); 2729 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
2721 if (regionInfo == null) 2730 if (regionInfo == null)
2722 { 2731 {
2723 regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); 2732 uint x = 0, y = 0;
2733 Utils.LongToUInts(UserProfile.HomeRegion, out x, out y);
2734 regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
2724 if (regionInfo != null) // home region can be away temporarily, too 2735 if (regionInfo != null) // home region can be away temporarily, too
2725 { 2736 {
2726 UserProfile.HomeRegionID = regionInfo.RegionID; 2737 UserProfile.HomeRegionID = regionInfo.RegionID;
@@ -3074,7 +3085,7 @@ namespace OpenSim.Region.Framework.Scenes
3074 m_sceneGridService.OnExpectUser += HandleNewUserConnection; 3085 m_sceneGridService.OnExpectUser += HandleNewUserConnection;
3075 m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing; 3086 m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing;
3076 m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent; 3087 m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent;
3077 m_sceneGridService.OnRegionUp += OtherRegionUp; 3088 //m_eventManager.OnRegionUp += OtherRegionUp;
3078 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3089 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3079 m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup; 3090 m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup;
3080 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3091 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
@@ -3102,7 +3113,7 @@ namespace OpenSim.Region.Framework.Scenes
3102 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3113 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3103 m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup; 3114 m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup;
3104 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3115 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3105 m_sceneGridService.OnRegionUp -= OtherRegionUp; 3116 //m_eventManager.OnRegionUp -= OtherRegionUp;
3106 m_sceneGridService.OnExpectUser -= HandleNewUserConnection; 3117 m_sceneGridService.OnExpectUser -= HandleNewUserConnection;
3107 m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; 3118 m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing;
3108 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; 3119 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent;
@@ -3111,7 +3122,11 @@ namespace OpenSim.Region.Framework.Scenes
3111 if (m_interregionCommsIn != null) 3122 if (m_interregionCommsIn != null)
3112 m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3123 m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3113 3124
3125 // this does nothing; should be removed
3114 m_sceneGridService.Close(); 3126 m_sceneGridService.Close();
3127
3128 if (!GridService.DeregisterRegion(m_regInfo.RegionID))
3129 m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName);
3115 } 3130 }
3116 3131
3117 /// <summary> 3132 /// <summary>
@@ -3255,7 +3270,7 @@ namespace OpenSim.Region.Framework.Scenes
3255 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3270 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3256 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3271 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3257 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); 3272 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName);
3258 return false; 3273 return false;
3259 } 3274 }
3260 } 3275 }
3261 3276
@@ -3404,7 +3419,7 @@ namespace OpenSim.Region.Framework.Scenes
3404 /// We've got an update about an agent that sees into this region, 3419 /// We've got an update about an agent that sees into this region,
3405 /// send it to ScenePresence for processing It's the full data. 3420 /// send it to ScenePresence for processing It's the full data.
3406 /// </summary> 3421 /// </summary>
3407 /// <param name="cAgentData">Agent that contains all of the relevant things about an agent. 3422 /// <param name="cAgentData">Agent that contains all of the relevant things about an agent.
3408 /// Appearance, animations, position, etc.</param> 3423 /// Appearance, animations, position, etc.</param>
3409 /// <returns>true if we handled it.</returns> 3424 /// <returns>true if we handled it.</returns>
3410 public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) 3425 public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData)
@@ -3557,30 +3572,6 @@ namespace OpenSim.Region.Framework.Scenes
3557 } 3572 }
3558 3573
3559 /// <summary> 3574 /// <summary>
3560 /// Requests information about this region from gridcomms
3561 /// </summary>
3562 /// <param name="regionHandle"></param>
3563 /// <returns></returns>
3564 public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
3565 {
3566 return m_sceneGridService.RequestNeighbouringRegionInfo(regionHandle);
3567 }
3568
3569 /// <summary>
3570 /// Requests textures for map from minimum region to maximum region in world cordinates
3571 /// </summary>
3572 /// <param name="remoteClient"></param>
3573 /// <param name="minX"></param>
3574 /// <param name="minY"></param>
3575 /// <param name="maxX"></param>
3576 /// <param name="maxY"></param>
3577 public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
3578 {
3579 m_log.DebugFormat("[MAPBLOCK]: {0}-{1}, {2}-{3}", minX, minY, maxX, maxY);
3580 m_sceneGridService.RequestMapBlocks(remoteClient, minX, minY, maxX, maxY);
3581 }
3582
3583 /// <summary>
3584 /// Tries to teleport agent to other region. 3575 /// Tries to teleport agent to other region.
3585 /// </summary> 3576 /// </summary>
3586 /// <param name="remoteClient"></param> 3577 /// <param name="remoteClient"></param>
@@ -3591,7 +3582,7 @@ namespace OpenSim.Region.Framework.Scenes
3591 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, 3582 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
3592 Vector3 lookat, uint teleportFlags) 3583 Vector3 lookat, uint teleportFlags)
3593 { 3584 {
3594 RegionInfo regionInfo = m_sceneGridService.RequestClosestRegion(regionName); 3585 GridRegion regionInfo = GridService.GetRegionByName(UUID.Zero, regionName);
3595 if (regionInfo == null) 3586 if (regionInfo == null)
3596 { 3587 {
3597 // can't find the region: Tell viewer and abort 3588 // can't find the region: Tell viewer and abort
@@ -3680,7 +3671,7 @@ namespace OpenSim.Region.Framework.Scenes
3680 /// <param name="position"></param> 3671 /// <param name="position"></param>
3681 public void RequestTeleportLandmark(IClientAPI remoteClient, UUID regionID, Vector3 position) 3672 public void RequestTeleportLandmark(IClientAPI remoteClient, UUID regionID, Vector3 position)
3682 { 3673 {
3683 RegionInfo info = CommsManager.GridService.RequestNeighbourInfo(regionID); 3674 GridRegion info = GridService.GetRegionByUUID(UUID.Zero, regionID);
3684 3675
3685 if (info == null) 3676 if (info == null)
3686 { 3677 {
@@ -3864,10 +3855,6 @@ namespace OpenSim.Region.Framework.Scenes
3864 return LandChannel.GetLandObject((int)x, (int)y).landData; 3855 return LandChannel.GetLandObject((int)x, (int)y).landData;
3865 } 3856 }
3866 3857
3867 public RegionInfo RequestClosestRegion(string name)
3868 {
3869 return m_sceneGridService.RequestClosestRegion(name);
3870 }
3871 3858
3872 #endregion 3859 #endregion
3873 3860
@@ -4154,6 +4141,11 @@ namespace OpenSim.Region.Framework.Scenes
4154 m_sceneGraph.ForEachClient(action); 4141 m_sceneGraph.ForEachClient(action);
4155 } 4142 }
4156 4143
4144 public void ForEachSOG(Action<SceneObjectGroup> action)
4145 {
4146 m_sceneGraph.ForEachSOG(action);
4147 }
4148
4157 /// <summary> 4149 /// <summary>
4158 /// Returns a list of the entities in the scene. This is a new list so operations perform on the list itself 4150 /// Returns a list of the entities in the scene. This is a new list so operations perform on the list itself
4159 /// will not affect the original list of objects in the scene. 4151 /// will not affect the original list of objects in the scene.
@@ -4178,14 +4170,18 @@ namespace OpenSim.Region.Framework.Scenes
4178 4170
4179 public void RegionHandleRequest(IClientAPI client, UUID regionID) 4171 public void RegionHandleRequest(IClientAPI client, UUID regionID)
4180 { 4172 {
4181 RegionInfo info; 4173 ulong handle = 0;
4182 if (regionID == RegionInfo.RegionID) 4174 if (regionID == RegionInfo.RegionID)
4183 info = RegionInfo; 4175 handle = RegionInfo.RegionHandle;
4184 else 4176 else
4185 info = CommsManager.GridService.RequestNeighbourInfo(regionID); 4177 {
4178 GridRegion r = GridService.GetRegionByUUID(UUID.Zero, regionID);
4179 if (r != null)
4180 handle = r.RegionHandle;
4181 }
4186 4182
4187 if (info != null) 4183 if (handle != 0)
4188 client.SendRegionHandle(regionID, info.RegionHandle); 4184 client.SendRegionHandle(regionID, handle);
4189 } 4185 }
4190 4186
4191 public void TerrainUnAcked(IClientAPI client, int patchX, int patchY) 4187 public void TerrainUnAcked(IClientAPI client, int patchX, int patchY)