NullRegionData.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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;
  29. using System.Collections.Generic;
  30. using OpenMetaverse;
  31. using OpenSim.Framework;
  32. using OpenSim.Data;
  33. namespace OpenSim.Data.Null
  34. {
  35. public class NullRegionData : IRegionData
  36. {
  37. Dictionary<UUID, RegionData> m_regionData = new Dictionary<UUID, RegionData>();
  38. public NullRegionData(string connectionString, string realm)
  39. {
  40. //Console.WriteLine("[XXX] NullRegionData constructor");
  41. }
  42. public List<RegionData> Get(string regionName, UUID scopeID)
  43. {
  44. List<RegionData> ret = new List<RegionData>();
  45. foreach (RegionData r in m_regionData.Values)
  46. {
  47. if (regionName.Contains("%"))
  48. {
  49. if (r.RegionName.Contains(regionName.Replace("%", "")))
  50. ret.Add(r);
  51. }
  52. else
  53. {
  54. if (r.RegionName == regionName)
  55. ret.Add(r);
  56. }
  57. }
  58. if (ret.Count > 0)
  59. return ret;
  60. return null;
  61. }
  62. public RegionData Get(int posX, int posY, UUID scopeID)
  63. {
  64. List<RegionData> ret = new List<RegionData>();
  65. foreach (RegionData r in m_regionData.Values)
  66. {
  67. if (r.posX == posX && r.posY == posY)
  68. ret.Add(r);
  69. }
  70. if (ret.Count > 0)
  71. return ret[0];
  72. return null;
  73. }
  74. public RegionData Get(UUID regionID, UUID scopeID)
  75. {
  76. if (m_regionData.ContainsKey(regionID))
  77. return m_regionData[regionID];
  78. return null;
  79. }
  80. public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID)
  81. {
  82. List<RegionData> ret = new List<RegionData>();
  83. foreach (RegionData r in m_regionData.Values)
  84. {
  85. if (r.posX >= startX && r.posX <= endX && r.posY >= startY && r.posY <= endY)
  86. ret.Add(r);
  87. }
  88. return ret;
  89. }
  90. public bool Store(RegionData data)
  91. {
  92. m_regionData[data.RegionID] = data;
  93. return true;
  94. }
  95. public bool SetDataItem(UUID regionID, string item, string value)
  96. {
  97. if (!m_regionData.ContainsKey(regionID))
  98. return false;
  99. m_regionData[regionID].Data[item] = value;
  100. return true;
  101. }
  102. public bool Delete(UUID regionID)
  103. {
  104. if (!m_regionData.ContainsKey(regionID))
  105. return false;
  106. m_regionData.Remove(regionID);
  107. return true;
  108. }
  109. }
  110. }