1
0

TerrainChannel.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  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.IO;
  29. using System.Text;
  30. using System.Reflection;
  31. using System.Xml;
  32. using System.Xml.Serialization;
  33. using OpenSim.Data;
  34. using OpenSim.Framework;
  35. using OpenSim.Region.Framework.Interfaces;
  36. using OpenMetaverse;
  37. using log4net;
  38. namespace OpenSim.Region.Framework.Scenes
  39. {
  40. /// <summary>
  41. /// A new version of the old Channel class, simplified
  42. /// </summary>
  43. public class TerrainChannel : ITerrainChannel
  44. {
  45. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  46. private static string LogHeader = "[TERRAIN CHANNEL]";
  47. protected TerrainData m_terrainData;
  48. public int Width { get { return m_terrainData.SizeX; } } // X dimension
  49. // Unfortunately, for historical reasons, in this module 'Width' is X and 'Height' is Y
  50. public int Height { get { return m_terrainData.SizeY; } } // Y dimension
  51. public int Altitude { get { return m_terrainData.SizeZ; } } // Y dimension
  52. // Default, not-often-used builder
  53. public TerrainChannel()
  54. {
  55. m_terrainData = new TerrainData((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight);
  56. FlatLand();
  57. // PinHeadIsland();
  58. }
  59. // Create terrain of given size
  60. public TerrainChannel(int pX, int pY)
  61. {
  62. m_terrainData = new TerrainData(pX, pY, (int)Constants.RegionHeight);
  63. }
  64. // Create terrain of specified size and initialize with specified terrain.
  65. // TODO: join this with the terrain initializers.
  66. public TerrainChannel(String type, int pX, int pY, int pZ)
  67. {
  68. m_terrainData = new TerrainData(pX, pY, pZ);
  69. if (type.Equals("flat"))
  70. FlatLand();
  71. else
  72. PinHeadIsland();
  73. }
  74. // Create channel passed a heightmap and expected dimensions of the region.
  75. // The heightmap might not fit the passed size so accomodations must be made.
  76. public TerrainChannel(double[,] pM, int pSizeX, int pSizeY, int pAltitude)
  77. {
  78. int hmSizeX = pM.GetLength(0);
  79. int hmSizeY = pM.GetLength(1);
  80. m_terrainData = new TerrainData(pSizeX, pSizeY, pAltitude);
  81. for (int xx = 0; xx < pSizeX; xx++)
  82. for (int yy = 0; yy < pSizeY; yy++)
  83. if (xx > hmSizeX || yy > hmSizeY)
  84. m_terrainData[xx, yy] = TerrainData.DefaultTerrainHeight;
  85. else
  86. m_terrainData[xx, yy] = (float)pM[xx, yy];
  87. }
  88. public TerrainChannel(TerrainData pTerrData)
  89. {
  90. m_terrainData = pTerrData;
  91. }
  92. #region ITerrainChannel Members
  93. // ITerrainChannel.MakeCopy()
  94. public ITerrainChannel MakeCopy()
  95. {
  96. return this.Copy();
  97. }
  98. // ITerrainChannel.GetTerrainData()
  99. public TerrainData GetTerrainData()
  100. {
  101. return m_terrainData;
  102. }
  103. // This one dimensional version is ordered so height = map[y*sizeX+x];
  104. public float[] GetFloatsSerialised()
  105. {
  106. return m_terrainData.GetFloatsSerialized();
  107. }
  108. // ITerrainChannel.GetDoubles()
  109. public double[,] GetDoubles()
  110. {
  111. double[,] heights = new double[Width, Height];
  112. int idx = 0; // index into serialized array
  113. for (int ii = 0; ii < Width; ii++)
  114. {
  115. for (int jj = 0; jj < Height; jj++)
  116. {
  117. heights[ii, jj] = (double)m_terrainData[ii, jj];
  118. idx++;
  119. }
  120. }
  121. return heights;
  122. }
  123. // ITerrainChannel.this[x,y]
  124. public float this[int x, int y]
  125. {
  126. get {
  127. if (x < 0 || x >= Width || y < 0 || y >= Height)
  128. return 0;
  129. return m_terrainData[x, y];
  130. }
  131. set
  132. {
  133. if (Double.IsNaN(value) || Double.IsInfinity(value))
  134. return;
  135. m_terrainData[x, y] = (float)value;
  136. }
  137. }
  138. // ITerrainChannel.GetHieghtAtXYZ(x, y, z)
  139. public float GetHeightAtXYZ(float x, float y, float z)
  140. {
  141. if (x < 0 || x >= Width || y < 0 || y >= Height)
  142. return 0;
  143. return m_terrainData[(int)x, (int)y];
  144. }
  145. // ITerrainChannel.Tainted()
  146. public bool Tainted(int x, int y)
  147. {
  148. return m_terrainData.IsTaintedAt(x, y);
  149. }
  150. // ITerrainChannel.SaveToXmlString()
  151. public string SaveToXmlString()
  152. {
  153. XmlWriterSettings settings = new XmlWriterSettings();
  154. settings.Encoding = Util.UTF8;
  155. using (StringWriter sw = new StringWriter())
  156. {
  157. using (XmlWriter writer = XmlWriter.Create(sw, settings))
  158. {
  159. WriteXml(writer);
  160. }
  161. string output = sw.ToString();
  162. return output;
  163. }
  164. }
  165. // ITerrainChannel.LoadFromXmlString()
  166. public void LoadFromXmlString(string data)
  167. {
  168. using(StringReader sr = new StringReader(data))
  169. {
  170. using(XmlTextReader reader = new XmlTextReader(sr))
  171. ReadXml(reader);
  172. }
  173. }
  174. // ITerrainChannel.Merge
  175. public void Merge(ITerrainChannel newTerrain, Vector3 displacement, float radianRotation, Vector2 rotationDisplacement)
  176. {
  177. m_log.DebugFormat("{0} Merge. inSize=<{1},{2}>, disp={3}, rot={4}, rotDisp={5}, outSize=<{6},{7}>", LogHeader,
  178. newTerrain.Width, newTerrain.Height,
  179. displacement, radianRotation, rotationDisplacement,
  180. m_terrainData.SizeX, m_terrainData.SizeY);
  181. for (int xx = 0; xx < newTerrain.Width; xx++)
  182. {
  183. for (int yy = 0; yy < newTerrain.Height; yy++)
  184. {
  185. int dispX = (int)displacement.X;
  186. int dispY = (int)displacement.Y;
  187. float newHeight = (float)newTerrain[xx, yy] + displacement.Z;
  188. if (radianRotation == 0)
  189. {
  190. // If no rotation, place the new height in the specified location
  191. dispX += xx;
  192. dispY += yy;
  193. if (dispX >= 0 && dispX < m_terrainData.SizeX && dispY >= 0 && dispY < m_terrainData.SizeY)
  194. {
  195. m_terrainData[dispX, dispY] = newHeight;
  196. }
  197. }
  198. else
  199. {
  200. // If rotating, we have to smooth the result because the conversion
  201. // to ints will mean heightmap entries will not get changed
  202. // First compute the rotation location for the new height.
  203. dispX += (int)(rotationDisplacement.X
  204. + ((float)xx - rotationDisplacement.X) * Math.Cos(radianRotation)
  205. - ((float)yy - rotationDisplacement.Y) * Math.Sin(radianRotation) );
  206. dispY += (int)(rotationDisplacement.Y
  207. + ((float)xx - rotationDisplacement.X) * Math.Sin(radianRotation)
  208. + ((float)yy - rotationDisplacement.Y) * Math.Cos(radianRotation) );
  209. if (dispX >= 0 && dispX < m_terrainData.SizeX && dispY >= 0 && dispY < m_terrainData.SizeY)
  210. {
  211. float oldHeight = m_terrainData[dispX, dispY];
  212. // Smooth the heights around this location if the old height is far from this one
  213. for (int sxx = dispX - 2; sxx < dispX + 2; sxx++)
  214. {
  215. for (int syy = dispY - 2; syy < dispY + 2; syy++)
  216. {
  217. if (sxx >= 0 && sxx < m_terrainData.SizeX && syy >= 0 && syy < m_terrainData.SizeY)
  218. {
  219. if (sxx == dispX && syy == dispY)
  220. {
  221. // Set height for the exact rotated point
  222. m_terrainData[dispX, dispY] = newHeight;
  223. }
  224. else
  225. {
  226. if (Math.Abs(m_terrainData[sxx, syy] - newHeight) > 1f)
  227. {
  228. // If the adjacent height is far off, force it to this height
  229. m_terrainData[sxx, syy] = newHeight;
  230. }
  231. }
  232. }
  233. }
  234. }
  235. }
  236. if (dispX >= 0 && dispX < m_terrainData.SizeX && dispY >= 0 && dispY < m_terrainData.SizeY)
  237. {
  238. m_terrainData[dispX, dispY] = (float)newTerrain[xx, yy];
  239. }
  240. }
  241. }
  242. }
  243. }
  244. /// <summary>
  245. /// A new version of terrain merge that processes the terrain in a specific order and corrects the problems with rotated terrains
  246. /// having 'holes' in that need to be smoothed. The correct way to rotate something is to iterate over the target, taking data from
  247. /// the source, not the other way around. This ensures that the target has no holes in it.
  248. /// The processing order of an incoming terrain is:
  249. /// 1. Apply rotation
  250. /// 2. Apply bounding rectangle
  251. /// 3. Apply displacement
  252. /// rotationCenter is no longer needed and has been discarded.
  253. /// </summary>
  254. /// <param name="newTerrain"></param>
  255. /// <param name="displacement">&lt;x, y, z&gt;</param>
  256. /// <param name="rotationDegrees"></param>
  257. /// <param name="boundingOrigin">&lt;x, y&gt;</param>
  258. /// <param name="boundingSize">&lt;x, y&gt;</param>
  259. public void MergeWithBounding(ITerrainChannel newTerrain, Vector3 displacement, float rotationDegrees, Vector2 boundingOrigin, Vector2 boundingSize)
  260. {
  261. m_log.DebugFormat("{0} MergeWithBounding: inSize=<{1},{2}>, rot={3}, boundingOrigin={4}, boundingSize={5}, disp={6}, outSize=<{7},{8}>",
  262. LogHeader, newTerrain.Width, newTerrain.Height, rotationDegrees, boundingOrigin.ToString(),
  263. boundingSize.ToString(), displacement, m_terrainData.SizeX, m_terrainData.SizeY);
  264. // get the size of the incoming terrain
  265. int baseX = newTerrain.Width;
  266. int baseY = newTerrain.Height;
  267. // create an intermediate terrain map that is 25% bigger on each side that we can work with to handle rotation
  268. int offsetX = baseX / 4; // the original origin will now be at these coordinates so now we can have imaginary negative coordinates ;)
  269. int offsetY = baseY / 4;
  270. int tmpX = baseX + baseX / 2;
  271. int tmpY = baseY + baseY / 2;
  272. int centreX = tmpX / 2;
  273. int centreY = tmpY / 2;
  274. TerrainData terrain_tmp = new TerrainData(tmpX, tmpY, (int)Constants.RegionHeight);
  275. for (int xx = 0; xx < tmpX; xx++)
  276. for (int yy = 0; yy < tmpY; yy++)
  277. terrain_tmp[xx, yy] = -65535f; //use this height like an 'alpha' mask channel
  278. double radianRotation = Math.PI * rotationDegrees / 180f;
  279. double cosR = Math.Cos(radianRotation);
  280. double sinR = Math.Sin(radianRotation);
  281. if (rotationDegrees < 0f) rotationDegrees += 360f; //-90=270 -180=180 -270=90
  282. // So first we apply the rotation to the incoming terrain, storing the result in terrain_tmp
  283. // We special case orthogonal rotations for accuracy because even using double precision math, Math.Cos(90 degrees) is never fully 0
  284. // and we can never rotate around a centre 'pixel' because the 'bitmap' size is always even
  285. int x, y, sx, sy;
  286. for (y = 0; y <= tmpY; y++)
  287. {
  288. for (x = 0; x <= tmpX; x++)
  289. {
  290. if (rotationDegrees == 0f)
  291. {
  292. sx = x - offsetX;
  293. sy = y - offsetY;
  294. }
  295. else if (rotationDegrees == 90f)
  296. {
  297. sx = y - offsetX;
  298. sy = tmpY - 1 - x - offsetY;
  299. }
  300. else if (rotationDegrees == 180f)
  301. {
  302. sx = tmpX - 1 - x - offsetX;
  303. sy = tmpY - 1 - y - offsetY;
  304. }
  305. else if (rotationDegrees == 270f)
  306. {
  307. sx = tmpX - 1 - y - offsetX;
  308. sy = x - offsetY;
  309. }
  310. else
  311. {
  312. // arbitary rotation: hmmm should I be using (centreX - 0.5) and (centreY - 0.5) and round cosR and sinR to say only 5 decimal places?
  313. sx = centreX + (int)Math.Round((((double)x - centreX) * cosR) + (((double)y - centreY) * sinR)) - offsetX;
  314. sy = centreY + (int)Math.Round((((double)y - centreY) * cosR) - (((double)x - centreX) * sinR)) - offsetY;
  315. }
  316. if (sx >= 0 && sx < baseX && sy >= 0 && sy < baseY)
  317. {
  318. try
  319. {
  320. terrain_tmp[x, y] = (float)newTerrain[sx, sy];
  321. }
  322. catch (Exception) //just in case we've still not taken care of every way the arrays might go out of bounds! ;)
  323. {
  324. m_log.DebugFormat("{0} MergeWithBounding - Rotate: Out of Bounds sx={1} sy={2} dx={3} dy={4}", sx, sy, x, y);
  325. }
  326. }
  327. }
  328. }
  329. // We could also incorporate the next steps, bounding-rectangle and displacement in the loop above, but it's simpler to visualise if done separately
  330. // and will also make it much easier when later I want the option for maybe a circular or oval bounding shape too ;).
  331. int newX = m_terrainData.SizeX;
  332. int newY = m_terrainData.SizeY;
  333. // displacement is relative to <0,0> in the destination region and defines where the origin of the data selected by the bounding-rectangle is placed
  334. int dispX = (int)Math.Floor(displacement.X);
  335. int dispY = (int)Math.Floor(displacement.Y);
  336. // startX/Y and endX/Y are coordinates in bitmap_tmp
  337. int startX = (int)Math.Floor(boundingOrigin.X) + offsetX;
  338. if (startX > tmpX) startX = tmpX;
  339. if (startX < 0) startX = 0;
  340. int startY = (int)Math.Floor(boundingOrigin.Y) + offsetY;
  341. if (startY > tmpY) startY = tmpY;
  342. if (startY < 0) startY = 0;
  343. int endX = (int)Math.Floor(boundingOrigin.X + boundingSize.X) + offsetX;
  344. if (endX > tmpX) endX = tmpX;
  345. if (endX < 0) endX = 0;
  346. int endY = (int)Math.Floor(boundingOrigin.Y + boundingSize.Y) + offsetY;
  347. if (endY > tmpY) endY = tmpY;
  348. if (endY < 0) endY = 0;
  349. //m_log.DebugFormat("{0} MergeWithBounding: inSize=<{1},{2}>, disp=<{3},{4}> rot={5}, offset=<{6},{7}>, boundingStart=<{8},{9}>, boundingEnd=<{10},{11}>, cosR={12}, sinR={13}, outSize=<{14},{15}>", LogHeader,
  350. // baseX, baseY, dispX, dispY, radianRotation, offsetX, offsetY, startX, startY, endX, endY, cosR, sinR, newX, newY);
  351. int dx, dy;
  352. for (y = startY; y < endY; y++)
  353. {
  354. for (x = startX; x < endX; x++)
  355. {
  356. dx = x - startX + dispX;
  357. dy = y - startY + dispY;
  358. if (dx >= 0 && dx < newX && dy >= 0 && dy < newY)
  359. {
  360. try
  361. {
  362. float newHeight = (float)terrain_tmp[x, y]; //use 'alpha' mask
  363. if (newHeight != -65535f) m_terrainData[dx, dy] = newHeight + displacement.Z;
  364. }
  365. catch (Exception) //just in case we've still not taken care of every way the arrays might go out of bounds! ;)
  366. {
  367. m_log.DebugFormat("{0} MergeWithBounding - Bound & Displace: Out of Bounds sx={1} sy={2} dx={3} dy={4}", x, y, dx, dy);
  368. }
  369. }
  370. }
  371. }
  372. }
  373. #endregion
  374. public TerrainChannel Copy()
  375. {
  376. TerrainChannel copy = new TerrainChannel();
  377. copy.m_terrainData = m_terrainData.Clone();
  378. return copy;
  379. }
  380. private void WriteXml(XmlWriter writer)
  381. {
  382. if (Width == Constants.RegionSize && Height == Constants.RegionSize)
  383. {
  384. // Downward compatibility for legacy region terrain maps.
  385. // If region is exactly legacy size, return the old format XML.
  386. writer.WriteStartElement(String.Empty, "TerrainMap", String.Empty);
  387. ToXml(writer);
  388. writer.WriteEndElement();
  389. }
  390. else
  391. {
  392. // New format XML that includes width and length.
  393. writer.WriteStartElement(String.Empty, "TerrainMap2", String.Empty);
  394. ToXml2(writer);
  395. writer.WriteEndElement();
  396. }
  397. }
  398. private void ReadXml(XmlReader reader)
  399. {
  400. // Check the first element. If legacy element, use the legacy reader.
  401. if (reader.IsStartElement("TerrainMap"))
  402. {
  403. reader.ReadStartElement("TerrainMap");
  404. FromXml(reader);
  405. }
  406. else
  407. {
  408. reader.ReadStartElement("TerrainMap2");
  409. FromXml2(reader);
  410. }
  411. }
  412. // Write legacy terrain map. Presumed to be 256x256 of data encoded as floats in a byte array.
  413. private void ToXml(XmlWriter xmlWriter)
  414. {
  415. float[] mapData = GetFloatsSerialised();
  416. byte[] buffer = new byte[mapData.Length * 4];
  417. for (int i = 0; i < mapData.Length; i++)
  418. {
  419. byte[] value = BitConverter.GetBytes(mapData[i]);
  420. Array.Copy(value, 0, buffer, (i * 4), 4);
  421. }
  422. XmlSerializer serializer = new XmlSerializer(typeof(byte[]));
  423. serializer.Serialize(xmlWriter, buffer);
  424. }
  425. // Read legacy terrain map. Presumed to be 256x256 of data encoded as floats in a byte array.
  426. private void FromXml(XmlReader xmlReader)
  427. {
  428. XmlSerializer serializer = new XmlSerializer(typeof(byte[]));
  429. byte[] dataArray = (byte[])serializer.Deserialize(xmlReader);
  430. int index = 0;
  431. m_terrainData = new TerrainData(Height, Width, (int)Constants.RegionHeight);
  432. for (int y = 0; y < Height; y++)
  433. {
  434. for (int x = 0; x < Width; x++)
  435. {
  436. float value;
  437. value = BitConverter.ToSingle(dataArray, index);
  438. index += 4;
  439. this[x, y] = value;
  440. }
  441. }
  442. }
  443. private class TerrainChannelXMLPackage
  444. {
  445. public int Version;
  446. public int SizeX;
  447. public int SizeY;
  448. public int SizeZ;
  449. public float CompressionFactor;
  450. public float[] Map;
  451. public TerrainChannelXMLPackage(int pX, int pY, int pZ, float pCompressionFactor, float[] pMap)
  452. {
  453. Version = 1;
  454. SizeX = pX;
  455. SizeY = pY;
  456. SizeZ = pZ;
  457. CompressionFactor = pCompressionFactor;
  458. Map = pMap;
  459. }
  460. }
  461. // New terrain serialization format that includes the width and length.
  462. private void ToXml2(XmlWriter xmlWriter)
  463. {
  464. TerrainChannelXMLPackage package = new TerrainChannelXMLPackage(Width, Height, Altitude, m_terrainData.CompressionFactor,
  465. m_terrainData.GetCompressedMap());
  466. XmlSerializer serializer = new XmlSerializer(typeof(TerrainChannelXMLPackage));
  467. serializer.Serialize(xmlWriter, package);
  468. }
  469. // New terrain serialization format that includes the width and length.
  470. private void FromXml2(XmlReader xmlReader)
  471. {
  472. XmlSerializer serializer = new XmlSerializer(typeof(TerrainChannelXMLPackage));
  473. TerrainChannelXMLPackage package = (TerrainChannelXMLPackage)serializer.Deserialize(xmlReader);
  474. m_terrainData = new TerrainData(package.Map, package.CompressionFactor, package.SizeX, package.SizeY, package.SizeZ);
  475. }
  476. // Fill the heightmap with the center bump terrain
  477. private void PinHeadIsland()
  478. {
  479. float cx = m_terrainData.SizeX * 0.5f;
  480. float cy = m_terrainData.SizeY * 0.5f;
  481. float h, b;
  482. for (int x = 0; x < Width; x++)
  483. {
  484. for (int y = 0; y < Height; y++)
  485. {
  486. h = 25 * TerrainUtil.SphericalFactor(x - cx, y - cy, 50);
  487. b = 10 * TerrainUtil.SphericalFactor(x - cx, y - cy, 100);
  488. if (h < b)
  489. h = b;
  490. m_terrainData[x, y] = h;
  491. }
  492. }
  493. }
  494. private void FlatLand()
  495. {
  496. m_terrainData.ClearLand();
  497. }
  498. }
  499. }