LandChannel.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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.Collections.Generic;
  28. using System.Runtime.CompilerServices;
  29. using OpenMetaverse;
  30. using OpenSim.Framework;
  31. using OpenSim.Region.Framework.Interfaces;
  32. using OpenSim.Region.Framework.Scenes;
  33. namespace OpenSim.Region.CoreModules.World.Land
  34. {
  35. public class LandChannel : ILandChannel
  36. {
  37. #region Constants
  38. //Land types set with flags in ParcelOverlay.
  39. //Only one of these can be used.
  40. //RequestResults (I think these are right, they seem to work):
  41. public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land
  42. public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land
  43. //ParcelSelectObjects
  44. public const int LAND_SELECT_OBJECTS_OWNER = 2;
  45. public const int LAND_SELECT_OBJECTS_GROUP = 4;
  46. public const int LAND_SELECT_OBJECTS_OTHER = 8;
  47. public const byte LAND_TYPE_PUBLIC = 0; //Equals 00000000
  48. // types 1 to 7 are exclusive
  49. public const byte LAND_TYPE_OWNED_BY_OTHER = 1; //Equals 00000001
  50. public const byte LAND_TYPE_OWNED_BY_GROUP = 2; //Equals 00000010
  51. public const byte LAND_TYPE_OWNED_BY_REQUESTER = 3; //Equals 00000011
  52. public const byte LAND_TYPE_IS_FOR_SALE = 4; //Equals 00000100
  53. public const byte LAND_TYPE_IS_BEING_AUCTIONED = 5; //Equals 00000101
  54. public const byte LAND_TYPE_unused6 = 6;
  55. public const byte LAND_TYPE_unused7 = 7;
  56. // next are flags
  57. public const byte LAND_FLAG_unused8 = 0x08; // this may become excluside in future
  58. public const byte LAND_FLAG_HIDEAVATARS = 0x10;
  59. public const byte LAND_FLAG_LOCALSOUND = 0x20;
  60. public const byte LAND_FLAG_PROPERTY_BORDER_WEST = 0x40; //Equals 01000000
  61. public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = 0x80; //Equals 10000000
  62. //These are other constants. Yay!
  63. public const int START_LAND_LOCAL_ID = 1;
  64. #endregion
  65. private readonly LandManagementModule m_landManagementModule;
  66. private float m_BanLineSafeHeight = 100.0f;
  67. public float BanLineSafeHeight
  68. {
  69. get
  70. {
  71. return m_BanLineSafeHeight;
  72. }
  73. private set
  74. {
  75. if (value >= 20f && value <= 5000f)
  76. m_BanLineSafeHeight = value;
  77. else
  78. m_BanLineSafeHeight = 100.0f;
  79. }
  80. }
  81. public LandChannel(Scene scene, LandManagementModule landManagementMod)
  82. {
  83. m_landManagementModule = landManagementMod;
  84. if(landManagementMod is not null)
  85. m_BanLineSafeHeight = landManagementMod.BanLineSafeHeight;
  86. }
  87. #region ILandChannel Members
  88. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  89. public ILandObject GetLandObject(float x_float, float y_float)
  90. {
  91. return m_landManagementModule?.GetLandObject(x_float, y_float);
  92. }
  93. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  94. public ILandObject GetLandObject(int localID)
  95. {
  96. return m_landManagementModule?.GetLandObject(localID);
  97. }
  98. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  99. public ILandObject GetLandObject(UUID GlobalID)
  100. {
  101. return m_landManagementModule?.GetLandObject(GlobalID);
  102. }
  103. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  104. public ILandObject GetLandObject(Vector3 position)
  105. {
  106. return GetLandObject(position.X, position.Y);
  107. }
  108. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  109. public ILandObject GetLandObject(int x, int y)
  110. {
  111. return m_landManagementModule?.GetLandObject(x, y);
  112. }
  113. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  114. public ILandObject GetLandObjectClippedXY(float x, float y)
  115. {
  116. return m_landManagementModule?.GetLandObjectClippedXY(x, y);
  117. }
  118. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  119. public List<ILandObject> AllParcels()
  120. {
  121. return m_landManagementModule is not null ? m_landManagementModule.AllParcels() : new List<ILandObject>();
  122. }
  123. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  124. public void Clear(bool setupDefaultParcel)
  125. {
  126. m_landManagementModule?.Clear(setupDefaultParcel);
  127. }
  128. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  129. public List<ILandObject> ParcelsNearPoint(Vector3 position)
  130. {
  131. return m_landManagementModule is not null ? m_landManagementModule.ParcelsNearPoint(position) : new List<ILandObject>();
  132. }
  133. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  134. public bool IsForcefulBansAllowed()
  135. {
  136. return m_landManagementModule is not null && m_landManagementModule.AllowedForcefulBans;
  137. }
  138. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  139. public void UpdateLandObject(int localID, LandData data)
  140. {
  141. m_landManagementModule?.UpdateLandObject(localID, data);
  142. }
  143. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  144. public void SendParcelsOverlay(IClientAPI client)
  145. {
  146. m_landManagementModule?.SendParcelOverlay(client);
  147. }
  148. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  149. public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
  150. {
  151. m_landManagementModule?.Join(start_x, start_y, end_x, end_y, attempting_user_id);
  152. }
  153. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  154. public void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
  155. {
  156. m_landManagementModule?.Subdivide(start_x, start_y, end_x, end_y, attempting_user_id);
  157. }
  158. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  159. public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
  160. {
  161. m_landManagementModule?.ReturnObjectsInParcel(localID, returnType, agentIDs, taskIDs, remoteClient);
  162. }
  163. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  164. public void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel)
  165. {
  166. m_landManagementModule?.setParcelObjectMaxOverride(overrideDel);
  167. }
  168. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  169. public void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel)
  170. {
  171. m_landManagementModule?.setSimulatorObjectMaxOverride(overrideDel);
  172. }
  173. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  174. public void SetParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime)
  175. {
  176. m_landManagementModule?.SetParcelOtherCleanTime(remoteClient, localID, otherCleanTime);
  177. }
  178. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  179. public void sendClientInitialLandInfo(IClientAPI remoteClient, bool overlay)
  180. {
  181. m_landManagementModule?.sendClientInitialLandInfo(remoteClient, overlay);
  182. }
  183. public void ClearAllEnvironments()
  184. {
  185. List<ILandObject> parcels = AllParcels();
  186. for(int i=0; i< parcels.Count; ++i)
  187. parcels[i].StoreEnvironment(null);
  188. }
  189. #endregion
  190. }
  191. }