diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 1341533..457ee33 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -50,6 +50,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
50 | { | 50 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 52 | ||
53 | /// <summary> | ||
54 | /// The maximum distance, in standard region units (256m) that an agent is allowed to transfer. | ||
55 | /// </summary> | ||
56 | private int m_MaxTransferDistance = 4095; | ||
57 | public int MaxTransferDistance | ||
58 | { | ||
59 | get { return m_MaxTransferDistance; } | ||
60 | set { m_MaxTransferDistance = value; } | ||
61 | } | ||
62 | |||
63 | |||
53 | protected bool m_Enabled = false; | 64 | protected bool m_Enabled = false; |
54 | protected Scene m_aScene; | 65 | protected Scene m_aScene; |
55 | protected List<Scene> m_Scenes = new List<Scene>(); | 66 | protected List<Scene> m_Scenes = new List<Scene>(); |
@@ -78,13 +89,26 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
78 | string name = moduleConfig.GetString("EntityTransferModule", ""); | 89 | string name = moduleConfig.GetString("EntityTransferModule", ""); |
79 | if (name == Name) | 90 | if (name == Name) |
80 | { | 91 | { |
81 | m_agentsInTransit = new List<UUID>(); | 92 | InitialiseCommon(source); |
82 | m_Enabled = true; | 93 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} enabled.", Name); |
83 | m_log.InfoFormat("[ENTITY TRANSFER MODULE]: {0} enabled.", Name); | ||
84 | } | 94 | } |
85 | } | 95 | } |
86 | } | 96 | } |
87 | 97 | ||
98 | /// <summary> | ||
99 | /// Initialize config common for this module and any descendents. | ||
100 | /// </summary> | ||
101 | /// <param name="source"></param> | ||
102 | protected virtual void InitialiseCommon(IConfigSource source) | ||
103 | { | ||
104 | IConfig transferConfig = source.Configs["EntityTransfer"]; | ||
105 | if (transferConfig != null) | ||
106 | MaxTransferDistance = transferConfig.GetInt("max_distance", 4095); | ||
107 | |||
108 | m_agentsInTransit = new List<UUID>(); | ||
109 | m_Enabled = true; | ||
110 | } | ||
111 | |||
88 | public virtual void PostInitialise() | 112 | public virtual void PostInitialise() |
89 | { | 113 | { |
90 | } | 114 | } |
@@ -114,7 +138,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
114 | return; | 138 | return; |
115 | } | 139 | } |
116 | 140 | ||
117 | |||
118 | public virtual void RemoveRegion(Scene scene) | 141 | public virtual void RemoveRegion(Scene scene) |
119 | { | 142 | { |
120 | if (!m_Enabled) | 143 | if (!m_Enabled) |
@@ -129,7 +152,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
129 | { | 152 | { |
130 | if (!m_Enabled) | 153 | if (!m_Enabled) |
131 | return; | 154 | return; |
132 | |||
133 | } | 155 | } |
134 | 156 | ||
135 | #endregion | 157 | #endregion |
@@ -204,8 +226,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
204 | sp.ControllingClient.SendTeleportFailed("Problem at destination"); | 226 | sp.ControllingClient.SendTeleportFailed("Problem at destination"); |
205 | return; | 227 | return; |
206 | } | 228 | } |
207 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} {2}@{3}", | 229 | |
208 | finalDestination.RegionLocX / Constants.RegionSize, finalDestination.RegionLocY / Constants.RegionSize, finalDestination.RegionID, finalDestination.ServerURI); | 230 | uint curX = 0, curY = 0; |
231 | Utils.LongToUInts(sp.Scene.RegionInfo.RegionHandle, out curX, out curY); | ||
232 | int curCellX = (int)(curX / Constants.RegionSize); | ||
233 | int curCellY = (int)(curY / Constants.RegionSize); | ||
234 | int destCellX = (int)(finalDestination.RegionLocX / Constants.RegionSize); | ||
235 | int destCellY = (int)(finalDestination.RegionLocY / Constants.RegionSize); | ||
236 | |||
237 | // m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Source co-ords are x={0} y={1}", curRegionX, curRegionY); | ||
238 | // | ||
239 | // m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final dest is x={0} y={1} {2}@{3}", | ||
240 | // destRegionX, destRegionY, finalDestination.RegionID, finalDestination.ServerURI); | ||
209 | 241 | ||
210 | // Check that these are not the same coordinates | 242 | // Check that these are not the same coordinates |
211 | if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX && | 243 | if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX && |
@@ -216,6 +248,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
216 | return; | 248 | return; |
217 | } | 249 | } |
218 | 250 | ||
251 | if (Math.Abs(curCellX - destCellX) > MaxTransferDistance || Math.Abs(curCellY - destCellY) > MaxTransferDistance) | ||
252 | { | ||
253 | sp.ControllingClient.SendTeleportFailed( | ||
254 | string.Format( | ||
255 | "Can't teleport to {0} ({1},{2}) from {3} ({4},{5}), destination is more than {6} regions way", | ||
256 | finalDestination.RegionName, destCellX, destCellY, | ||
257 | sp.Scene.RegionInfo.RegionName, curCellX, curCellY, | ||
258 | MaxTransferDistance)); | ||
259 | |||
260 | return; | ||
261 | } | ||
262 | |||
219 | // | 263 | // |
220 | // This is it | 264 | // This is it |
221 | // | 265 | // |