From 4cbf0444df4b4c0eb3616e19279203e5f17a939b Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 1 Aug 2009 14:26:00 +0000 Subject: [PATCH] * Tweak the caps manager so that the NPCAvatar works again. --- .../World/Land/LandManagementModule.cs | 5 ++- .../Scenes/SceneCommunicationService.cs | 40 +++++++++++++++---- .../Region/Framework/Scenes/ScenePresence.cs | 13 +++++- .../OptionalModules/World/NPC/NPCAvatar.cs | 3 +- .../OptionalModules/World/NPC/NPCModule.cs | 4 +- 5 files changed, 52 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index e385ae0dd0..4deb36e6d1 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -581,7 +581,10 @@ namespace OpenSim.Region.CoreModules.World.Land } lock (m_landIDList) { - return m_landList[m_landIDList[x / 4, y / 4]]; + if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4])) + return m_landList[m_landIDList[x / 4, y / 4]]; + else + return null; } } diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 665354497c..4f2b6ecd30 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -360,15 +360,33 @@ namespace OpenSim.Region.Framework.Scenes } // we're going to be using the above code once neighbour cache is correct. Currently it doesn't appear to be // So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/ - neighbours = + if (m_regionInfo != null) + { + neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); + } + else + { + m_log.Debug("[ENABLENEIGHBOURCHILDAGENTS]: m_regionInfo was null in EnableNeighbourChildAgents, is this a NPC?"); + } + /// We need to find the difference between the new regions where there are no child agents /// and the regions where there are already child agents. We only send notification to the former. List neighbourHandles = NeighbourHandles(neighbours); // on this region neighbourHandles.Add(avatar.Scene.RegionInfo.RegionHandle); // add this region too - List previousRegionNeighbourHandles - = new List(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID).Keys); + List previousRegionNeighbourHandles ; + + if (avatar.Scene.CapsModule != null) + { + previousRegionNeighbourHandles = + new List(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID).Keys); + } + else + { + previousRegionNeighbourHandles = new List(); + } + List newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles); List oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles); @@ -381,8 +399,12 @@ namespace OpenSim.Region.Framework.Scenes avatar.DropOldNeighbours(oldRegions); /// Collect as many seeds as possible - Dictionary seeds - = new Dictionary(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID)); + Dictionary seeds; + if (avatar.Scene.CapsModule != null) + seeds + = new Dictionary(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID)); + else + seeds = new Dictionary(); //m_log.Debug(" !!! No. of seeds: " + seeds.Count); if (!seeds.ContainsKey(avatar.Scene.RegionInfo.RegionHandle)) @@ -419,8 +441,12 @@ namespace OpenSim.Region.Framework.Scenes { a.ChildrenCapSeeds = new Dictionary(seeds); } - // These two are the same thing! - avatar.Scene.CapsModule.SetChildrenSeed(avatar.UUID, seeds); + + if (avatar.Scene.CapsModule != null) + { + // These two are the same thing! + avatar.Scene.CapsModule.SetChildrenSeed(avatar.UUID, seeds); + } avatar.KnownRegions = seeds; //avatar.Scene.DumpChildrenSeeds(avatar.UUID); //avatar.DumpKnownRegions(); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6850312ab8..fa1fd89dad 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -538,7 +538,13 @@ namespace OpenSim.Region.Framework.Scenes public void AdjustKnownSeeds() { - Dictionary seeds = Scene.CapsModule.GetChildrenSeeds(UUID); + Dictionary seeds; + + if (Scene.CapsModule != null) + seeds = Scene.CapsModule.GetChildrenSeeds(UUID); + else + seeds = new Dictionary(); + List old = new List(); foreach (ulong handle in seeds.Keys) { @@ -552,7 +558,10 @@ namespace OpenSim.Region.Framework.Scenes } } DropOldNeighbours(old); - Scene.CapsModule.SetChildrenSeed(UUID, seeds); + + if (Scene.CapsModule != null) + Scene.CapsModule.SetChildrenSeed(UUID, seeds); + KnownRegions = seeds; //m_log.Debug(" ++++++++++AFTER+++++++++++++ "); //DumpKnownRegions(); diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 2102db9094..4a8ba8c958 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -1044,7 +1044,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC public bool AddGenericPacketHandler(string MethodName, GenericMessage handler) { - throw new NotImplementedException(); + //throw new NotImplementedException(); + return false; } public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name) diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 8b45788c89..8c9717caa2 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -42,8 +42,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC // { // NPCAvatar testAvatar = new NPCAvatar("Jack", "NPC", new Vector3(128, 128, 40), scene); // NPCAvatar testAvatar2 = new NPCAvatar("Jill", "NPC", new Vector3(136, 128, 40), scene); - // scene.AddNewClient(testAvatar, false); - // scene.AddNewClient(testAvatar2, false); + // scene.AddNewClient(testAvatar); + // scene.AddNewClient(testAvatar2); // } }