RegionCombinerLargeLandChannel.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Reflection;
  30. using log4net;
  31. using OpenMetaverse;
  32. using OpenSim.Framework;
  33. using OpenSim.Region.Framework.Interfaces;
  34. using OpenSim.Region.CoreModules.World.Land;
  35. namespace OpenSim.Region.RegionCombinerModule
  36. {
  37. public class RegionCombinerLargeLandChannel : ILandChannel
  38. {
  39. // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  40. private RegionData RegData;
  41. private ILandChannel RootRegionLandChannel;
  42. private readonly List<RegionData> RegionConnections;
  43. #region ILandChannel Members
  44. public RegionCombinerLargeLandChannel(RegionData regData, ILandChannel rootRegionLandChannel,
  45. List<RegionData> regionConnections)
  46. {
  47. RegData = regData;
  48. RootRegionLandChannel = rootRegionLandChannel;
  49. RegionConnections = regionConnections;
  50. }
  51. public List<ILandObject> ParcelsNearPoint(Vector3 position)
  52. {
  53. //m_log.DebugFormat("[LANDPARCELNEARPOINT]: {0}>", position);
  54. return RootRegionLandChannel.ParcelsNearPoint(position - RegData.Offset);
  55. }
  56. public List<ILandObject> AllParcels()
  57. {
  58. return RootRegionLandChannel.AllParcels();
  59. }
  60. public void Clear(bool setupDefaultParcel)
  61. {
  62. RootRegionLandChannel.Clear(setupDefaultParcel);
  63. }
  64. public ILandObject GetLandObject(Vector3 position)
  65. {
  66. return GetLandObject(position.X, position.Y);
  67. }
  68. public ILandObject GetLandObject(int x, int y)
  69. {
  70. return GetLandObject((float)x, (float)y);
  71. // m_log.DebugFormat("[BIGLANDTESTINT]: <{0},{1}>", x, y);
  72. //
  73. // if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize)
  74. // {
  75. // return RootRegionLandChannel.GetLandObject(x, y);
  76. // }
  77. // else
  78. // {
  79. // int offsetX = (x / (int)Constants.RegionSize);
  80. // int offsetY = (y / (int)Constants.RegionSize);
  81. // offsetX *= (int)Constants.RegionSize;
  82. // offsetY *= (int)Constants.RegionSize;
  83. //
  84. // foreach (RegionData regionData in RegionConnections)
  85. // {
  86. // if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY)
  87. // {
  88. // m_log.DebugFormat(
  89. // "[REGION COMBINER LARGE LAND CHANNEL]: Found region {0} at offset {1},{2}",
  90. // regionData.RegionScene.Name, offsetX, offsetY);
  91. //
  92. // return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY);
  93. // }
  94. // }
  95. // //ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene);
  96. // //obj.LandData.Name = "NO LAND";
  97. // //return obj;
  98. // }
  99. //
  100. // m_log.DebugFormat("[REGION COMBINER LARGE LAND CHANNEL]: No region found at {0},{1}, returning null", x, y);
  101. //
  102. // return null;
  103. }
  104. public ILandObject GetLandObject(int localID)
  105. {
  106. // XXX: Possibly should be looking in every land channel, not just the root.
  107. return RootRegionLandChannel.GetLandObject(localID);
  108. }
  109. public ILandObject GetLandObject(float x, float y)
  110. {
  111. // m_log.DebugFormat("[BIGLANDTESTFLOAT]: <{0},{1}>", x, y);
  112. if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize)
  113. {
  114. return RootRegionLandChannel.GetLandObject(x, y);
  115. }
  116. else
  117. {
  118. int offsetX = (int)(x/(int) Constants.RegionSize);
  119. int offsetY = (int)(y/(int) Constants.RegionSize);
  120. offsetX *= (int) Constants.RegionSize;
  121. offsetY *= (int) Constants.RegionSize;
  122. foreach (RegionData regionData in RegionConnections)
  123. {
  124. if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY)
  125. {
  126. // m_log.DebugFormat(
  127. // "[REGION COMBINER LARGE LAND CHANNEL]: Found region {0} at offset {1},{2}",
  128. // regionData.RegionScene.Name, offsetX, offsetY);
  129. return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY);
  130. }
  131. }
  132. // ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene);
  133. // obj.LandData.Name = "NO LAND";
  134. // return obj;
  135. }
  136. // m_log.DebugFormat("[REGION COMBINER LARGE LAND CHANNEL]: No region found at {0},{1}, returning null", x, y);
  137. return null;
  138. }
  139. public bool IsForcefulBansAllowed()
  140. {
  141. return RootRegionLandChannel.IsForcefulBansAllowed();
  142. }
  143. public void UpdateLandObject(int localID, LandData data)
  144. {
  145. RootRegionLandChannel.UpdateLandObject(localID, data);
  146. }
  147. public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
  148. {
  149. RootRegionLandChannel.Join(start_x, start_y, end_x, end_y, attempting_user_id);
  150. }
  151. public void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
  152. {
  153. RootRegionLandChannel.Subdivide(start_x, start_y, end_x, end_y, attempting_user_id);
  154. }
  155. public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
  156. {
  157. RootRegionLandChannel.ReturnObjectsInParcel(localID, returnType, agentIDs, taskIDs, remoteClient);
  158. }
  159. public void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel)
  160. {
  161. RootRegionLandChannel.setParcelObjectMaxOverride(overrideDel);
  162. }
  163. public void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel)
  164. {
  165. RootRegionLandChannel.setSimulatorObjectMaxOverride(overrideDel);
  166. }
  167. public void SetParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime)
  168. {
  169. RootRegionLandChannel.SetParcelOtherCleanTime(remoteClient, localID, otherCleanTime);
  170. }
  171. public void sendClientInitialLandInfo(IClientAPI remoteClient) { }
  172. #endregion
  173. }
  174. }