diff options
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/LandObject.cs | 2090 |
1 files changed, 1045 insertions, 1045 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index fcd993c..9e9934e 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -1,1045 +1,1045 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSimulator Project nor the | 12 | * * Neither the name of the OpenSimulator Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
36 | 36 | ||
37 | namespace OpenSim.Region.CoreModules.World.Land | 37 | namespace OpenSim.Region.CoreModules.World.Land |
38 | { | 38 | { |
39 | /// <summary> | 39 | /// <summary> |
40 | /// Keeps track of a specific piece of land's information | 40 | /// Keeps track of a specific piece of land's information |
41 | /// </summary> | 41 | /// </summary> |
42 | public class LandObject : ILandObject | 42 | public class LandObject : ILandObject |
43 | { | 43 | { |
44 | #region Member Variables | 44 | #region Member Variables |
45 | 45 | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | #pragma warning disable 0429 | 47 | #pragma warning disable 0429 |
48 | private const int landArrayMax = ((int)((int)Constants.RegionSize / 4) >= 64) ? (int)((int)Constants.RegionSize / 4) : 64; | 48 | private const int landArrayMax = ((int)((int)Constants.RegionSize / 4) >= 64) ? (int)((int)Constants.RegionSize / 4) : 64; |
49 | #pragma warning restore 0429 | 49 | #pragma warning restore 0429 |
50 | private bool[,] m_landBitmap = new bool[landArrayMax,landArrayMax]; | 50 | private bool[,] m_landBitmap = new bool[landArrayMax,landArrayMax]; |
51 | 51 | ||
52 | private int m_lastSeqId = 0; | 52 | private int m_lastSeqId = 0; |
53 | 53 | ||
54 | protected LandData m_landData = new LandData(); | 54 | protected LandData m_landData = new LandData(); |
55 | protected Scene m_scene; | 55 | protected Scene m_scene; |
56 | protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); | 56 | protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); |
57 | 57 | ||
58 | public bool[,] LandBitmap | 58 | public bool[,] LandBitmap |
59 | { | 59 | { |
60 | get { return m_landBitmap; } | 60 | get { return m_landBitmap; } |
61 | set { m_landBitmap = value; } | 61 | set { m_landBitmap = value; } |
62 | } | 62 | } |
63 | 63 | ||
64 | #endregion | 64 | #endregion |
65 | 65 | ||
66 | #region ILandObject Members | 66 | #region ILandObject Members |
67 | 67 | ||
68 | public LandData LandData | 68 | public LandData LandData |
69 | { | 69 | { |
70 | get { return m_landData; } | 70 | get { return m_landData; } |
71 | 71 | ||
72 | set { m_landData = value; } | 72 | set { m_landData = value; } |
73 | } | 73 | } |
74 | 74 | ||
75 | public UUID RegionUUID | 75 | public UUID RegionUUID |
76 | { | 76 | { |
77 | get { return m_scene.RegionInfo.RegionID; } | 77 | get { return m_scene.RegionInfo.RegionID; } |
78 | } | 78 | } |
79 | 79 | ||
80 | #region Constructors | 80 | #region Constructors |
81 | 81 | ||
82 | public LandObject(UUID owner_id, bool is_group_owned, Scene scene) | 82 | public LandObject(UUID owner_id, bool is_group_owned, Scene scene) |
83 | { | 83 | { |
84 | m_scene = scene; | 84 | m_scene = scene; |
85 | LandData.OwnerID = owner_id; | 85 | LandData.OwnerID = owner_id; |
86 | if (is_group_owned) | 86 | if (is_group_owned) |
87 | LandData.GroupID = owner_id; | 87 | LandData.GroupID = owner_id; |
88 | else | 88 | else |
89 | LandData.GroupID = UUID.Zero; | 89 | LandData.GroupID = UUID.Zero; |
90 | LandData.IsGroupOwned = is_group_owned; | 90 | LandData.IsGroupOwned = is_group_owned; |
91 | } | 91 | } |
92 | 92 | ||
93 | #endregion | 93 | #endregion |
94 | 94 | ||
95 | #region Member Functions | 95 | #region Member Functions |
96 | 96 | ||
97 | #region General Functions | 97 | #region General Functions |
98 | 98 | ||
99 | /// <summary> | 99 | /// <summary> |
100 | /// Checks to see if this land object contains a point | 100 | /// Checks to see if this land object contains a point |
101 | /// </summary> | 101 | /// </summary> |
102 | /// <param name="x"></param> | 102 | /// <param name="x"></param> |
103 | /// <param name="y"></param> | 103 | /// <param name="y"></param> |
104 | /// <returns>Returns true if the piece of land contains the specified point</returns> | 104 | /// <returns>Returns true if the piece of land contains the specified point</returns> |
105 | public bool ContainsPoint(int x, int y) | 105 | public bool ContainsPoint(int x, int y) |
106 | { | 106 | { |
107 | if (x >= 0 && y >= 0 && x <= Constants.RegionSize && y <= Constants.RegionSize) | 107 | if (x >= 0 && y >= 0 && x <= Constants.RegionSize && y <= Constants.RegionSize) |
108 | { | 108 | { |
109 | return (LandBitmap[x / 4, y / 4] == true); | 109 | return (LandBitmap[x / 4, y / 4] == true); |
110 | } | 110 | } |
111 | else | 111 | else |
112 | { | 112 | { |
113 | return false; | 113 | return false; |
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | public ILandObject Copy() | 117 | public ILandObject Copy() |
118 | { | 118 | { |
119 | ILandObject newLand = new LandObject(LandData.OwnerID, LandData.IsGroupOwned, m_scene); | 119 | ILandObject newLand = new LandObject(LandData.OwnerID, LandData.IsGroupOwned, m_scene); |
120 | 120 | ||
121 | //Place all new variables here! | 121 | //Place all new variables here! |
122 | newLand.LandBitmap = (bool[,]) (LandBitmap.Clone()); | 122 | newLand.LandBitmap = (bool[,]) (LandBitmap.Clone()); |
123 | newLand.LandData = LandData.Copy(); | 123 | newLand.LandData = LandData.Copy(); |
124 | 124 | ||
125 | return newLand; | 125 | return newLand; |
126 | } | 126 | } |
127 | 127 | ||
128 | static overrideParcelMaxPrimCountDelegate overrideParcelMaxPrimCount; | 128 | static overrideParcelMaxPrimCountDelegate overrideParcelMaxPrimCount; |
129 | static overrideSimulatorMaxPrimCountDelegate overrideSimulatorMaxPrimCount; | 129 | static overrideSimulatorMaxPrimCountDelegate overrideSimulatorMaxPrimCount; |
130 | 130 | ||
131 | public void SetParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel) | 131 | public void SetParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel) |
132 | { | 132 | { |
133 | overrideParcelMaxPrimCount = overrideDel; | 133 | overrideParcelMaxPrimCount = overrideDel; |
134 | } | 134 | } |
135 | public void SetSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel) | 135 | public void SetSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel) |
136 | { | 136 | { |
137 | overrideSimulatorMaxPrimCount = overrideDel; | 137 | overrideSimulatorMaxPrimCount = overrideDel; |
138 | } | 138 | } |
139 | 139 | ||
140 | public int GetParcelMaxPrimCount(ILandObject thisObject) | 140 | public int GetParcelMaxPrimCount(ILandObject thisObject) |
141 | { | 141 | { |
142 | if (overrideParcelMaxPrimCount != null) | 142 | if (overrideParcelMaxPrimCount != null) |
143 | { | 143 | { |
144 | return overrideParcelMaxPrimCount(thisObject); | 144 | return overrideParcelMaxPrimCount(thisObject); |
145 | } | 145 | } |
146 | else | 146 | else |
147 | { | 147 | { |
148 | // Normal Calculations | 148 | // Normal Calculations |
149 | return (int)Math.Round(((float)LandData.Area / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus); | 149 | return (int)Math.Round(((float)LandData.Area / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus); |
150 | } | 150 | } |
151 | } | 151 | } |
152 | public int GetSimulatorMaxPrimCount(ILandObject thisObject) | 152 | public int GetSimulatorMaxPrimCount(ILandObject thisObject) |
153 | { | 153 | { |
154 | if (overrideSimulatorMaxPrimCount != null) | 154 | if (overrideSimulatorMaxPrimCount != null) |
155 | { | 155 | { |
156 | return overrideSimulatorMaxPrimCount(thisObject); | 156 | return overrideSimulatorMaxPrimCount(thisObject); |
157 | } | 157 | } |
158 | else | 158 | else |
159 | { | 159 | { |
160 | //Normal Calculations | 160 | //Normal Calculations |
161 | return m_scene.RegionInfo.ObjectCapacity; | 161 | return m_scene.RegionInfo.ObjectCapacity; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | #endregion | 164 | #endregion |
165 | 165 | ||
166 | #region Packet Request Handling | 166 | #region Packet Request Handling |
167 | 167 | ||
168 | public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client) | 168 | public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client) |
169 | { | 169 | { |
170 | IEstateModule estateModule = m_scene.RequestModuleInterface<IEstateModule>(); | 170 | IEstateModule estateModule = m_scene.RequestModuleInterface<IEstateModule>(); |
171 | uint regionFlags = 336723974 & ~((uint)(RegionFlags.AllowLandmark | RegionFlags.AllowSetHome)); | 171 | uint regionFlags = 336723974 & ~((uint)(RegionFlags.AllowLandmark | RegionFlags.AllowSetHome)); |
172 | if (estateModule != null) | 172 | if (estateModule != null) |
173 | regionFlags = estateModule.GetRegionFlags(); | 173 | regionFlags = estateModule.GetRegionFlags(); |
174 | 174 | ||
175 | // In a perfect world, this would have worked. | 175 | // In a perfect world, this would have worked. |
176 | // | 176 | // |
177 | // if ((landData.Flags & (uint)ParcelFlags.AllowLandmark) != 0) | 177 | // if ((landData.Flags & (uint)ParcelFlags.AllowLandmark) != 0) |
178 | // regionFlags |= (uint)RegionFlags.AllowLandmark; | 178 | // regionFlags |= (uint)RegionFlags.AllowLandmark; |
179 | // if (landData.OwnerID == remote_client.AgentId) | 179 | // if (landData.OwnerID == remote_client.AgentId) |
180 | // regionFlags |= (uint)RegionFlags.AllowSetHome; | 180 | // regionFlags |= (uint)RegionFlags.AllowSetHome; |
181 | 181 | ||
182 | int seq_id; | 182 | int seq_id; |
183 | if (snap_selection && (sequence_id == 0)) | 183 | if (snap_selection && (sequence_id == 0)) |
184 | { | 184 | { |
185 | seq_id = m_lastSeqId; | 185 | seq_id = m_lastSeqId; |
186 | } | 186 | } |
187 | else | 187 | else |
188 | { | 188 | { |
189 | seq_id = sequence_id; | 189 | seq_id = sequence_id; |
190 | m_lastSeqId = seq_id; | 190 | m_lastSeqId = seq_id; |
191 | } | 191 | } |
192 | 192 | ||
193 | remote_client.SendLandProperties(seq_id, | 193 | remote_client.SendLandProperties(seq_id, |
194 | snap_selection, request_result, LandData, | 194 | snap_selection, request_result, LandData, |
195 | (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, | 195 | (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, |
196 | GetParcelMaxPrimCount(this), | 196 | GetParcelMaxPrimCount(this), |
197 | GetSimulatorMaxPrimCount(this), regionFlags); | 197 | GetSimulatorMaxPrimCount(this), regionFlags); |
198 | } | 198 | } |
199 | 199 | ||
200 | public void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client) | 200 | public void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client) |
201 | { | 201 | { |
202 | if (m_scene.Permissions.CanEditParcel(remote_client.AgentId,this)) | 202 | if (m_scene.Permissions.CanEditParcel(remote_client.AgentId,this)) |
203 | { | 203 | { |
204 | //Needs later group support | 204 | //Needs later group support |
205 | bool snap_selection = false; | 205 | bool snap_selection = false; |
206 | LandData newData = LandData.Copy(); | 206 | LandData newData = LandData.Copy(); |
207 | 207 | ||
208 | if (args.AuthBuyerID != newData.AuthBuyerID || args.SalePrice != newData.SalePrice) | 208 | if (args.AuthBuyerID != newData.AuthBuyerID || args.SalePrice != newData.SalePrice) |
209 | { | 209 | { |
210 | if (m_scene.Permissions.CanSellParcel(remote_client.AgentId, this)) | 210 | if (m_scene.Permissions.CanSellParcel(remote_client.AgentId, this)) |
211 | { | 211 | { |
212 | newData.AuthBuyerID = args.AuthBuyerID; | 212 | newData.AuthBuyerID = args.AuthBuyerID; |
213 | newData.SalePrice = args.SalePrice; | 213 | newData.SalePrice = args.SalePrice; |
214 | snap_selection = true; | 214 | snap_selection = true; |
215 | } | 215 | } |
216 | } | 216 | } |
217 | newData.Category = args.Category; | 217 | newData.Category = args.Category; |
218 | newData.Description = args.Desc; | 218 | newData.Description = args.Desc; |
219 | newData.GroupID = args.GroupID; | 219 | newData.GroupID = args.GroupID; |
220 | newData.LandingType = args.LandingType; | 220 | newData.LandingType = args.LandingType; |
221 | newData.MediaAutoScale = args.MediaAutoScale; | 221 | newData.MediaAutoScale = args.MediaAutoScale; |
222 | newData.MediaID = args.MediaID; | 222 | newData.MediaID = args.MediaID; |
223 | newData.MediaURL = args.MediaURL; | 223 | newData.MediaURL = args.MediaURL; |
224 | newData.MusicURL = args.MusicURL; | 224 | newData.MusicURL = args.MusicURL; |
225 | newData.Name = args.Name; | 225 | newData.Name = args.Name; |
226 | newData.Flags = args.ParcelFlags; | 226 | newData.Flags = args.ParcelFlags; |
227 | newData.PassHours = args.PassHours; | 227 | newData.PassHours = args.PassHours; |
228 | newData.PassPrice = args.PassPrice; | 228 | newData.PassPrice = args.PassPrice; |
229 | newData.SnapshotID = args.SnapshotID; | 229 | newData.SnapshotID = args.SnapshotID; |
230 | newData.UserLocation = args.UserLocation; | 230 | newData.UserLocation = args.UserLocation; |
231 | newData.UserLookAt = args.UserLookAt; | 231 | newData.UserLookAt = args.UserLookAt; |
232 | 232 | ||
233 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); | 233 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); |
234 | 234 | ||
235 | SendLandUpdateToAvatarsOverMe(snap_selection); | 235 | SendLandUpdateToAvatarsOverMe(snap_selection); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | public void UpdateLandSold(UUID avatarID, UUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area) | 239 | public void UpdateLandSold(UUID avatarID, UUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area) |
240 | { | 240 | { |
241 | LandData newData = LandData.Copy(); | 241 | LandData newData = LandData.Copy(); |
242 | newData.OwnerID = avatarID; | 242 | newData.OwnerID = avatarID; |
243 | newData.GroupID = groupID; | 243 | newData.GroupID = groupID; |
244 | newData.IsGroupOwned = groupOwned; | 244 | newData.IsGroupOwned = groupOwned; |
245 | //newData.auctionID = AuctionID; | 245 | //newData.auctionID = AuctionID; |
246 | newData.ClaimDate = Util.UnixTimeSinceEpoch(); | 246 | newData.ClaimDate = Util.UnixTimeSinceEpoch(); |
247 | newData.ClaimPrice = claimprice; | 247 | newData.ClaimPrice = claimprice; |
248 | newData.SalePrice = 0; | 248 | newData.SalePrice = 0; |
249 | newData.AuthBuyerID = UUID.Zero; | 249 | newData.AuthBuyerID = UUID.Zero; |
250 | newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory); | 250 | newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory); |
251 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); | 251 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); |
252 | 252 | ||
253 | SendLandUpdateToAvatarsOverMe(true); | 253 | SendLandUpdateToAvatarsOverMe(true); |
254 | } | 254 | } |
255 | 255 | ||
256 | public void DeedToGroup(UUID groupID) | 256 | public void DeedToGroup(UUID groupID) |
257 | { | 257 | { |
258 | LandData newData = LandData.Copy(); | 258 | LandData newData = LandData.Copy(); |
259 | newData.OwnerID = groupID; | 259 | newData.OwnerID = groupID; |
260 | newData.GroupID = groupID; | 260 | newData.GroupID = groupID; |
261 | newData.IsGroupOwned = true; | 261 | newData.IsGroupOwned = true; |
262 | 262 | ||
263 | // Reset show in directory flag on deed | 263 | // Reset show in directory flag on deed |
264 | newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory); | 264 | newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory); |
265 | 265 | ||
266 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); | 266 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); |
267 | 267 | ||
268 | SendLandUpdateToAvatarsOverMe(true); | 268 | SendLandUpdateToAvatarsOverMe(true); |
269 | } | 269 | } |
270 | 270 | ||
271 | public bool IsEitherBannedOrRestricted(UUID avatar) | 271 | public bool IsEitherBannedOrRestricted(UUID avatar) |
272 | { | 272 | { |
273 | if (IsBannedFromLand(avatar)) | 273 | if (IsBannedFromLand(avatar)) |
274 | { | 274 | { |
275 | return true; | 275 | return true; |
276 | } | 276 | } |
277 | else if (IsRestrictedFromLand(avatar)) | 277 | else if (IsRestrictedFromLand(avatar)) |
278 | { | 278 | { |
279 | return true; | 279 | return true; |
280 | } | 280 | } |
281 | return false; | 281 | return false; |
282 | } | 282 | } |
283 | 283 | ||
284 | public bool HasGroupAccess(UUID avatar) | 284 | public bool HasGroupAccess(UUID avatar) |
285 | { | 285 | { |
286 | if ((LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup) | 286 | if ((LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup) |
287 | { | 287 | { |
288 | IGroupsModule groupsModule = | 288 | IGroupsModule groupsModule = |
289 | m_scene.RequestModuleInterface<IGroupsModule>(); | 289 | m_scene.RequestModuleInterface<IGroupsModule>(); |
290 | 290 | ||
291 | List<UUID> agentGroups = new List<UUID>(); | 291 | List<UUID> agentGroups = new List<UUID>(); |
292 | if (groupsModule != null) | 292 | if (groupsModule != null) |
293 | { | 293 | { |
294 | GroupMembershipData[] GroupMembership = | 294 | GroupMembershipData[] GroupMembership = |
295 | groupsModule.GetMembershipData(avatar); | 295 | groupsModule.GetMembershipData(avatar); |
296 | 296 | ||
297 | if (GroupMembership != null) | 297 | if (GroupMembership != null) |
298 | { | 298 | { |
299 | for (int i = 0; i < GroupMembership.Length; i++) | 299 | for (int i = 0; i < GroupMembership.Length; i++) |
300 | { | 300 | { |
301 | if (LandData.GroupID == GroupMembership[i].GroupID) | 301 | if (LandData.GroupID == GroupMembership[i].GroupID) |
302 | { | 302 | { |
303 | return true; | 303 | return true; |
304 | } | 304 | } |
305 | } | 305 | } |
306 | } | 306 | } |
307 | } | 307 | } |
308 | } | 308 | } |
309 | return false; | 309 | return false; |
310 | } | 310 | } |
311 | 311 | ||
312 | public bool IsBannedFromLand(UUID avatar) | 312 | public bool IsBannedFromLand(UUID avatar) |
313 | { | 313 | { |
314 | if (m_scene.Permissions.IsAdministrator(avatar)) | 314 | if (m_scene.Permissions.IsAdministrator(avatar)) |
315 | return false; | 315 | return false; |
316 | 316 | ||
317 | if ((LandData.Flags & (uint) ParcelFlags.UseBanList) > 0) | 317 | if ((LandData.Flags & (uint) ParcelFlags.UseBanList) > 0) |
318 | { | 318 | { |
319 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | 319 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); |
320 | entry.AgentID = avatar; | 320 | entry.AgentID = avatar; |
321 | entry.Flags = AccessList.Ban; | 321 | entry.Flags = AccessList.Ban; |
322 | entry.Time = new DateTime(); | 322 | entry.Time = new DateTime(); |
323 | //See if they are on the list, but make sure the owner isn't banned | 323 | //See if they are on the list, but make sure the owner isn't banned |
324 | if (LandData.ParcelAccessList.Contains(entry) && LandData.OwnerID != avatar) | 324 | if (LandData.ParcelAccessList.Contains(entry) && LandData.OwnerID != avatar) |
325 | { | 325 | { |
326 | //They are banned, so lets send them a notice about this parcel | 326 | //They are banned, so lets send them a notice about this parcel |
327 | return true; | 327 | return true; |
328 | } | 328 | } |
329 | } | 329 | } |
330 | return false; | 330 | return false; |
331 | } | 331 | } |
332 | 332 | ||
333 | public bool IsRestrictedFromLand(UUID avatar) | 333 | public bool IsRestrictedFromLand(UUID avatar) |
334 | { | 334 | { |
335 | if (m_scene.Permissions.IsAdministrator(avatar)) | 335 | if (m_scene.Permissions.IsAdministrator(avatar)) |
336 | return false; | 336 | return false; |
337 | 337 | ||
338 | if ((LandData.Flags & (uint) ParcelFlags.UseAccessList) > 0) | 338 | if ((LandData.Flags & (uint) ParcelFlags.UseAccessList) > 0) |
339 | { | 339 | { |
340 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | 340 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); |
341 | entry.AgentID = avatar; | 341 | entry.AgentID = avatar; |
342 | entry.Flags = AccessList.Access; | 342 | entry.Flags = AccessList.Access; |
343 | entry.Time = new DateTime(); | 343 | entry.Time = new DateTime(); |
344 | 344 | ||
345 | //If they are not on the access list and are not the owner | 345 | //If they are not on the access list and are not the owner |
346 | if (!LandData.ParcelAccessList.Contains(entry) && LandData.OwnerID != avatar) | 346 | if (!LandData.ParcelAccessList.Contains(entry) && LandData.OwnerID != avatar) |
347 | { | 347 | { |
348 | if (!HasGroupAccess(avatar)) | 348 | if (!HasGroupAccess(avatar)) |
349 | { | 349 | { |
350 | //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel | 350 | //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel |
351 | return true; | 351 | return true; |
352 | } | 352 | } |
353 | } | 353 | } |
354 | } | 354 | } |
355 | 355 | ||
356 | return false; | 356 | return false; |
357 | } | 357 | } |
358 | 358 | ||
359 | public void SendLandUpdateToClient(IClientAPI remote_client) | 359 | public void SendLandUpdateToClient(IClientAPI remote_client) |
360 | { | 360 | { |
361 | SendLandProperties(0, false, 0, remote_client); | 361 | SendLandProperties(0, false, 0, remote_client); |
362 | } | 362 | } |
363 | 363 | ||
364 | public void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client) | 364 | public void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client) |
365 | { | 365 | { |
366 | SendLandProperties(0, snap_selection, 0, remote_client); | 366 | SendLandProperties(0, snap_selection, 0, remote_client); |
367 | } | 367 | } |
368 | 368 | ||
369 | public void SendLandUpdateToAvatarsOverMe() | 369 | public void SendLandUpdateToAvatarsOverMe() |
370 | { | 370 | { |
371 | SendLandUpdateToAvatarsOverMe(false); | 371 | SendLandUpdateToAvatarsOverMe(false); |
372 | } | 372 | } |
373 | 373 | ||
374 | public void SendLandUpdateToAvatarsOverMe(bool snap_selection) | 374 | public void SendLandUpdateToAvatarsOverMe(bool snap_selection) |
375 | { | 375 | { |
376 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) | 376 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) |
377 | { | 377 | { |
378 | if (avatar.IsChildAgent) | 378 | if (avatar.IsChildAgent) |
379 | return; | 379 | return; |
380 | 380 | ||
381 | ILandObject over = null; | 381 | ILandObject over = null; |
382 | try | 382 | try |
383 | { | 383 | { |
384 | over = | 384 | over = |
385 | m_scene.LandChannel.GetLandObject(Util.Clamp<int>((int)Math.Round(avatar.AbsolutePosition.X), 0, ((int)Constants.RegionSize - 1)), | 385 | m_scene.LandChannel.GetLandObject(Util.Clamp<int>((int)Math.Round(avatar.AbsolutePosition.X), 0, ((int)Constants.RegionSize - 1)), |
386 | Util.Clamp<int>((int)Math.Round(avatar.AbsolutePosition.Y), 0, ((int)Constants.RegionSize - 1))); | 386 | Util.Clamp<int>((int)Math.Round(avatar.AbsolutePosition.Y), 0, ((int)Constants.RegionSize - 1))); |
387 | } | 387 | } |
388 | catch (Exception) | 388 | catch (Exception) |
389 | { | 389 | { |
390 | m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatar.AbsolutePosition.X) + " y: " + | 390 | m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatar.AbsolutePosition.X) + " y: " + |
391 | Math.Round(avatar.AbsolutePosition.Y)); | 391 | Math.Round(avatar.AbsolutePosition.Y)); |
392 | } | 392 | } |
393 | 393 | ||
394 | if (over != null) | 394 | if (over != null) |
395 | { | 395 | { |
396 | if (over.LandData.LocalID == LandData.LocalID) | 396 | if (over.LandData.LocalID == LandData.LocalID) |
397 | { | 397 | { |
398 | if (((over.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0) && | 398 | if (((over.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0) && |
399 | m_scene.RegionInfo.RegionSettings.AllowDamage) | 399 | m_scene.RegionInfo.RegionSettings.AllowDamage) |
400 | avatar.Invulnerable = false; | 400 | avatar.Invulnerable = false; |
401 | else | 401 | else |
402 | avatar.Invulnerable = true; | 402 | avatar.Invulnerable = true; |
403 | 403 | ||
404 | SendLandUpdateToClient(snap_selection, avatar.ControllingClient); | 404 | SendLandUpdateToClient(snap_selection, avatar.ControllingClient); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | }); | 407 | }); |
408 | } | 408 | } |
409 | 409 | ||
410 | #endregion | 410 | #endregion |
411 | 411 | ||
412 | #region AccessList Functions | 412 | #region AccessList Functions |
413 | 413 | ||
414 | public List<UUID> CreateAccessListArrayByFlag(AccessList flag) | 414 | public List<UUID> CreateAccessListArrayByFlag(AccessList flag) |
415 | { | 415 | { |
416 | List<UUID> list = new List<UUID>(); | 416 | List<UUID> list = new List<UUID>(); |
417 | foreach (ParcelManager.ParcelAccessEntry entry in LandData.ParcelAccessList) | 417 | foreach (ParcelManager.ParcelAccessEntry entry in LandData.ParcelAccessList) |
418 | { | 418 | { |
419 | if (entry.Flags == flag) | 419 | if (entry.Flags == flag) |
420 | { | 420 | { |
421 | list.Add(entry.AgentID); | 421 | list.Add(entry.AgentID); |
422 | } | 422 | } |
423 | } | 423 | } |
424 | if (list.Count == 0) | 424 | if (list.Count == 0) |
425 | { | 425 | { |
426 | list.Add(UUID.Zero); | 426 | list.Add(UUID.Zero); |
427 | } | 427 | } |
428 | 428 | ||
429 | return list; | 429 | return list; |
430 | } | 430 | } |
431 | 431 | ||
432 | public void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID, | 432 | public void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID, |
433 | IClientAPI remote_client) | 433 | IClientAPI remote_client) |
434 | { | 434 | { |
435 | 435 | ||
436 | if (flags == (uint) AccessList.Access || flags == (uint) AccessList.Both) | 436 | if (flags == (uint) AccessList.Access || flags == (uint) AccessList.Both) |
437 | { | 437 | { |
438 | List<UUID> avatars = CreateAccessListArrayByFlag(AccessList.Access); | 438 | List<UUID> avatars = CreateAccessListArrayByFlag(AccessList.Access); |
439 | remote_client.SendLandAccessListData(avatars,(uint) AccessList.Access,LandData.LocalID); | 439 | remote_client.SendLandAccessListData(avatars,(uint) AccessList.Access,LandData.LocalID); |
440 | } | 440 | } |
441 | 441 | ||
442 | if (flags == (uint) AccessList.Ban || flags == (uint) AccessList.Both) | 442 | if (flags == (uint) AccessList.Ban || flags == (uint) AccessList.Both) |
443 | { | 443 | { |
444 | List<UUID> avatars = CreateAccessListArrayByFlag(AccessList.Ban); | 444 | List<UUID> avatars = CreateAccessListArrayByFlag(AccessList.Ban); |
445 | remote_client.SendLandAccessListData(avatars, (uint)AccessList.Ban, LandData.LocalID); | 445 | remote_client.SendLandAccessListData(avatars, (uint)AccessList.Ban, LandData.LocalID); |
446 | } | 446 | } |
447 | } | 447 | } |
448 | 448 | ||
449 | public void UpdateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client) | 449 | public void UpdateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client) |
450 | { | 450 | { |
451 | LandData newData = LandData.Copy(); | 451 | LandData newData = LandData.Copy(); |
452 | 452 | ||
453 | if (entries.Count == 1 && entries[0].AgentID == UUID.Zero) | 453 | if (entries.Count == 1 && entries[0].AgentID == UUID.Zero) |
454 | { | 454 | { |
455 | entries.Clear(); | 455 | entries.Clear(); |
456 | } | 456 | } |
457 | 457 | ||
458 | List<ParcelManager.ParcelAccessEntry> toRemove = new List<ParcelManager.ParcelAccessEntry>(); | 458 | List<ParcelManager.ParcelAccessEntry> toRemove = new List<ParcelManager.ParcelAccessEntry>(); |
459 | foreach (ParcelManager.ParcelAccessEntry entry in newData.ParcelAccessList) | 459 | foreach (ParcelManager.ParcelAccessEntry entry in newData.ParcelAccessList) |
460 | { | 460 | { |
461 | if (entry.Flags == (AccessList)flags) | 461 | if (entry.Flags == (AccessList)flags) |
462 | { | 462 | { |
463 | toRemove.Add(entry); | 463 | toRemove.Add(entry); |
464 | } | 464 | } |
465 | } | 465 | } |
466 | 466 | ||
467 | foreach (ParcelManager.ParcelAccessEntry entry in toRemove) | 467 | foreach (ParcelManager.ParcelAccessEntry entry in toRemove) |
468 | { | 468 | { |
469 | newData.ParcelAccessList.Remove(entry); | 469 | newData.ParcelAccessList.Remove(entry); |
470 | } | 470 | } |
471 | foreach (ParcelManager.ParcelAccessEntry entry in entries) | 471 | foreach (ParcelManager.ParcelAccessEntry entry in entries) |
472 | { | 472 | { |
473 | ParcelManager.ParcelAccessEntry temp = new ParcelManager.ParcelAccessEntry(); | 473 | ParcelManager.ParcelAccessEntry temp = new ParcelManager.ParcelAccessEntry(); |
474 | temp.AgentID = entry.AgentID; | 474 | temp.AgentID = entry.AgentID; |
475 | temp.Time = new DateTime(); //Pointless? Yes. | 475 | temp.Time = new DateTime(); //Pointless? Yes. |
476 | temp.Flags = (AccessList)flags; | 476 | temp.Flags = (AccessList)flags; |
477 | 477 | ||
478 | if (!newData.ParcelAccessList.Contains(temp)) | 478 | if (!newData.ParcelAccessList.Contains(temp)) |
479 | { | 479 | { |
480 | newData.ParcelAccessList.Add(temp); | 480 | newData.ParcelAccessList.Add(temp); |
481 | } | 481 | } |
482 | } | 482 | } |
483 | 483 | ||
484 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); | 484 | m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); |
485 | } | 485 | } |
486 | 486 | ||
487 | #endregion | 487 | #endregion |
488 | 488 | ||
489 | #region Update Functions | 489 | #region Update Functions |
490 | 490 | ||
491 | public void UpdateLandBitmapByteArray() | 491 | public void UpdateLandBitmapByteArray() |
492 | { | 492 | { |
493 | LandData.Bitmap = ConvertLandBitmapToBytes(); | 493 | LandData.Bitmap = ConvertLandBitmapToBytes(); |
494 | } | 494 | } |
495 | 495 | ||
496 | /// <summary> | 496 | /// <summary> |
497 | /// Update all settings in land such as area, bitmap byte array, etc | 497 | /// Update all settings in land such as area, bitmap byte array, etc |
498 | /// </summary> | 498 | /// </summary> |
499 | public void ForceUpdateLandInfo() | 499 | public void ForceUpdateLandInfo() |
500 | { | 500 | { |
501 | UpdateAABBAndAreaValues(); | 501 | UpdateAABBAndAreaValues(); |
502 | UpdateLandBitmapByteArray(); | 502 | UpdateLandBitmapByteArray(); |
503 | } | 503 | } |
504 | 504 | ||
505 | public void SetLandBitmapFromByteArray() | 505 | public void SetLandBitmapFromByteArray() |
506 | { | 506 | { |
507 | LandBitmap = ConvertBytesToLandBitmap(); | 507 | LandBitmap = ConvertBytesToLandBitmap(); |
508 | } | 508 | } |
509 | 509 | ||
510 | /// <summary> | 510 | /// <summary> |
511 | /// Updates the AABBMin and AABBMax values after area/shape modification of the land object | 511 | /// Updates the AABBMin and AABBMax values after area/shape modification of the land object |
512 | /// </summary> | 512 | /// </summary> |
513 | private void UpdateAABBAndAreaValues() | 513 | private void UpdateAABBAndAreaValues() |
514 | { | 514 | { |
515 | int min_x = 64; | 515 | int min_x = 64; |
516 | int min_y = 64; | 516 | int min_y = 64; |
517 | int max_x = 0; | 517 | int max_x = 0; |
518 | int max_y = 0; | 518 | int max_y = 0; |
519 | int tempArea = 0; | 519 | int tempArea = 0; |
520 | int x, y; | 520 | int x, y; |
521 | for (x = 0; x < 64; x++) | 521 | for (x = 0; x < 64; x++) |
522 | { | 522 | { |
523 | for (y = 0; y < 64; y++) | 523 | for (y = 0; y < 64; y++) |
524 | { | 524 | { |
525 | if (LandBitmap[x, y] == true) | 525 | if (LandBitmap[x, y] == true) |
526 | { | 526 | { |
527 | if (min_x > x) min_x = x; | 527 | if (min_x > x) min_x = x; |
528 | if (min_y > y) min_y = y; | 528 | if (min_y > y) min_y = y; |
529 | if (max_x < x) max_x = x; | 529 | if (max_x < x) max_x = x; |
530 | if (max_y < y) max_y = y; | 530 | if (max_y < y) max_y = y; |
531 | tempArea += 16; //16sqm peice of land | 531 | tempArea += 16; //16sqm peice of land |
532 | } | 532 | } |
533 | } | 533 | } |
534 | } | 534 | } |
535 | int tx = min_x * 4; | 535 | int tx = min_x * 4; |
536 | if (tx > ((int)Constants.RegionSize - 1)) | 536 | if (tx > ((int)Constants.RegionSize - 1)) |
537 | tx = ((int)Constants.RegionSize - 1); | 537 | tx = ((int)Constants.RegionSize - 1); |
538 | int ty = min_y * 4; | 538 | int ty = min_y * 4; |
539 | if (ty > ((int)Constants.RegionSize - 1)) | 539 | if (ty > ((int)Constants.RegionSize - 1)) |
540 | ty = ((int)Constants.RegionSize - 1); | 540 | ty = ((int)Constants.RegionSize - 1); |
541 | LandData.AABBMin = | 541 | LandData.AABBMin = |
542 | new Vector3((float) (min_x * 4), (float) (min_y * 4), | 542 | new Vector3((float) (min_x * 4), (float) (min_y * 4), |
543 | (float) m_scene.Heightmap[tx, ty]); | 543 | (float) m_scene.Heightmap[tx, ty]); |
544 | 544 | ||
545 | tx = max_x * 4; | 545 | tx = max_x * 4; |
546 | if (tx > ((int)Constants.RegionSize - 1)) | 546 | if (tx > ((int)Constants.RegionSize - 1)) |
547 | tx = ((int)Constants.RegionSize - 1); | 547 | tx = ((int)Constants.RegionSize - 1); |
548 | ty = max_y * 4; | 548 | ty = max_y * 4; |
549 | if (ty > ((int)Constants.RegionSize - 1)) | 549 | if (ty > ((int)Constants.RegionSize - 1)) |
550 | ty = ((int)Constants.RegionSize - 1); | 550 | ty = ((int)Constants.RegionSize - 1); |
551 | LandData.AABBMax = | 551 | LandData.AABBMax = |
552 | new Vector3((float) (max_x * 4), (float) (max_y * 4), | 552 | new Vector3((float) (max_x * 4), (float) (max_y * 4), |
553 | (float) m_scene.Heightmap[tx, ty]); | 553 | (float) m_scene.Heightmap[tx, ty]); |
554 | LandData.Area = tempArea; | 554 | LandData.Area = tempArea; |
555 | } | 555 | } |
556 | 556 | ||
557 | #endregion | 557 | #endregion |
558 | 558 | ||
559 | #region Land Bitmap Functions | 559 | #region Land Bitmap Functions |
560 | 560 | ||
561 | /// <summary> | 561 | /// <summary> |
562 | /// Sets the land's bitmap manually | 562 | /// Sets the land's bitmap manually |
563 | /// </summary> | 563 | /// </summary> |
564 | /// <param name="bitmap">64x64 block representing where this land is on a map</param> | 564 | /// <param name="bitmap">64x64 block representing where this land is on a map</param> |
565 | public void SetLandBitmap(bool[,] bitmap) | 565 | public void SetLandBitmap(bool[,] bitmap) |
566 | { | 566 | { |
567 | if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2) | 567 | if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2) |
568 | { | 568 | { |
569 | //Throw an exception - The bitmap is not 64x64 | 569 | //Throw an exception - The bitmap is not 64x64 |
570 | //throw new Exception("Error: Invalid Parcel Bitmap"); | 570 | //throw new Exception("Error: Invalid Parcel Bitmap"); |
571 | } | 571 | } |
572 | else | 572 | else |
573 | { | 573 | { |
574 | //Valid: Lets set it | 574 | //Valid: Lets set it |
575 | LandBitmap = bitmap; | 575 | LandBitmap = bitmap; |
576 | ForceUpdateLandInfo(); | 576 | ForceUpdateLandInfo(); |
577 | } | 577 | } |
578 | } | 578 | } |
579 | 579 | ||
580 | /// <summary> | 580 | /// <summary> |
581 | /// Gets the land's bitmap manually | 581 | /// Gets the land's bitmap manually |
582 | /// </summary> | 582 | /// </summary> |
583 | /// <returns></returns> | 583 | /// <returns></returns> |
584 | public bool[,] GetLandBitmap() | 584 | public bool[,] GetLandBitmap() |
585 | { | 585 | { |
586 | return LandBitmap; | 586 | return LandBitmap; |
587 | } | 587 | } |
588 | 588 | ||
589 | /// <summary> | 589 | /// <summary> |
590 | /// Full sim land object creation | 590 | /// Full sim land object creation |
591 | /// </summary> | 591 | /// </summary> |
592 | /// <returns></returns> | 592 | /// <returns></returns> |
593 | public bool[,] BasicFullRegionLandBitmap() | 593 | public bool[,] BasicFullRegionLandBitmap() |
594 | { | 594 | { |
595 | return GetSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize); | 595 | return GetSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize); |
596 | } | 596 | } |
597 | 597 | ||
598 | /// <summary> | 598 | /// <summary> |
599 | /// Used to modify the bitmap between the x and y points. Points use 64 scale | 599 | /// Used to modify the bitmap between the x and y points. Points use 64 scale |
600 | /// </summary> | 600 | /// </summary> |
601 | /// <param name="start_x"></param> | 601 | /// <param name="start_x"></param> |
602 | /// <param name="start_y"></param> | 602 | /// <param name="start_y"></param> |
603 | /// <param name="end_x"></param> | 603 | /// <param name="end_x"></param> |
604 | /// <param name="end_y"></param> | 604 | /// <param name="end_y"></param> |
605 | /// <returns></returns> | 605 | /// <returns></returns> |
606 | public bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y) | 606 | public bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y) |
607 | { | 607 | { |
608 | bool[,] tempBitmap = new bool[64,64]; | 608 | bool[,] tempBitmap = new bool[64,64]; |
609 | tempBitmap.Initialize(); | 609 | tempBitmap.Initialize(); |
610 | 610 | ||
611 | tempBitmap = ModifyLandBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true); | 611 | tempBitmap = ModifyLandBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true); |
612 | return tempBitmap; | 612 | return tempBitmap; |
613 | } | 613 | } |
614 | 614 | ||
615 | /// <summary> | 615 | /// <summary> |
616 | /// Change a land bitmap at within a square and set those points to a specific value | 616 | /// Change a land bitmap at within a square and set those points to a specific value |
617 | /// </summary> | 617 | /// </summary> |
618 | /// <param name="land_bitmap"></param> | 618 | /// <param name="land_bitmap"></param> |
619 | /// <param name="start_x"></param> | 619 | /// <param name="start_x"></param> |
620 | /// <param name="start_y"></param> | 620 | /// <param name="start_y"></param> |
621 | /// <param name="end_x"></param> | 621 | /// <param name="end_x"></param> |
622 | /// <param name="end_y"></param> | 622 | /// <param name="end_y"></param> |
623 | /// <param name="set_value"></param> | 623 | /// <param name="set_value"></param> |
624 | /// <returns></returns> | 624 | /// <returns></returns> |
625 | public bool[,] ModifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, | 625 | public bool[,] ModifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, |
626 | bool set_value) | 626 | bool set_value) |
627 | { | 627 | { |
628 | if (land_bitmap.GetLength(0) != 64 || land_bitmap.GetLength(1) != 64 || land_bitmap.Rank != 2) | 628 | if (land_bitmap.GetLength(0) != 64 || land_bitmap.GetLength(1) != 64 || land_bitmap.Rank != 2) |
629 | { | 629 | { |
630 | //Throw an exception - The bitmap is not 64x64 | 630 | //Throw an exception - The bitmap is not 64x64 |
631 | //throw new Exception("Error: Invalid Parcel Bitmap in modifyLandBitmapSquare()"); | 631 | //throw new Exception("Error: Invalid Parcel Bitmap in modifyLandBitmapSquare()"); |
632 | } | 632 | } |
633 | 633 | ||
634 | int x, y; | 634 | int x, y; |
635 | for (y = 0; y < 64; y++) | 635 | for (y = 0; y < 64; y++) |
636 | { | 636 | { |
637 | for (x = 0; x < 64; x++) | 637 | for (x = 0; x < 64; x++) |
638 | { | 638 | { |
639 | if (x >= start_x / 4 && x < end_x / 4 | 639 | if (x >= start_x / 4 && x < end_x / 4 |
640 | && y >= start_y / 4 && y < end_y / 4) | 640 | && y >= start_y / 4 && y < end_y / 4) |
641 | { | 641 | { |
642 | land_bitmap[x, y] = set_value; | 642 | land_bitmap[x, y] = set_value; |
643 | } | 643 | } |
644 | } | 644 | } |
645 | } | 645 | } |
646 | return land_bitmap; | 646 | return land_bitmap; |
647 | } | 647 | } |
648 | 648 | ||
649 | /// <summary> | 649 | /// <summary> |
650 | /// Join the true values of 2 bitmaps together | 650 | /// Join the true values of 2 bitmaps together |
651 | /// </summary> | 651 | /// </summary> |
652 | /// <param name="bitmap_base"></param> | 652 | /// <param name="bitmap_base"></param> |
653 | /// <param name="bitmap_add"></param> | 653 | /// <param name="bitmap_add"></param> |
654 | /// <returns></returns> | 654 | /// <returns></returns> |
655 | public bool[,] MergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add) | 655 | public bool[,] MergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add) |
656 | { | 656 | { |
657 | if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2) | 657 | if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2) |
658 | { | 658 | { |
659 | //Throw an exception - The bitmap is not 64x64 | 659 | //Throw an exception - The bitmap is not 64x64 |
660 | throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeLandBitmaps"); | 660 | throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeLandBitmaps"); |
661 | } | 661 | } |
662 | if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2) | 662 | if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2) |
663 | { | 663 | { |
664 | //Throw an exception - The bitmap is not 64x64 | 664 | //Throw an exception - The bitmap is not 64x64 |
665 | throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeLandBitmaps"); | 665 | throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeLandBitmaps"); |
666 | } | 666 | } |
667 | 667 | ||
668 | int x, y; | 668 | int x, y; |
669 | for (y = 0; y < 64; y++) | 669 | for (y = 0; y < 64; y++) |
670 | { | 670 | { |
671 | for (x = 0; x < 64; x++) | 671 | for (x = 0; x < 64; x++) |
672 | { | 672 | { |
673 | if (bitmap_add[x, y]) | 673 | if (bitmap_add[x, y]) |
674 | { | 674 | { |
675 | bitmap_base[x, y] = true; | 675 | bitmap_base[x, y] = true; |
676 | } | 676 | } |
677 | } | 677 | } |
678 | } | 678 | } |
679 | return bitmap_base; | 679 | return bitmap_base; |
680 | } | 680 | } |
681 | 681 | ||
682 | /// <summary> | 682 | /// <summary> |
683 | /// Converts the land bitmap to a packet friendly byte array | 683 | /// Converts the land bitmap to a packet friendly byte array |
684 | /// </summary> | 684 | /// </summary> |
685 | /// <returns></returns> | 685 | /// <returns></returns> |
686 | private byte[] ConvertLandBitmapToBytes() | 686 | private byte[] ConvertLandBitmapToBytes() |
687 | { | 687 | { |
688 | byte[] tempConvertArr = new byte[512]; | 688 | byte[] tempConvertArr = new byte[512]; |
689 | byte tempByte = 0; | 689 | byte tempByte = 0; |
690 | int x, y, i, byteNum = 0; | 690 | int x, y, i, byteNum = 0; |
691 | i = 0; | 691 | i = 0; |
692 | for (y = 0; y < 64; y++) | 692 | for (y = 0; y < 64; y++) |
693 | { | 693 | { |
694 | for (x = 0; x < 64; x++) | 694 | for (x = 0; x < 64; x++) |
695 | { | 695 | { |
696 | tempByte = Convert.ToByte(tempByte | Convert.ToByte(LandBitmap[x, y]) << (i++ % 8)); | 696 | tempByte = Convert.ToByte(tempByte | Convert.ToByte(LandBitmap[x, y]) << (i++ % 8)); |
697 | if (i % 8 == 0) | 697 | if (i % 8 == 0) |
698 | { | 698 | { |
699 | tempConvertArr[byteNum] = tempByte; | 699 | tempConvertArr[byteNum] = tempByte; |
700 | tempByte = (byte) 0; | 700 | tempByte = (byte) 0; |
701 | i = 0; | 701 | i = 0; |
702 | byteNum++; | 702 | byteNum++; |
703 | } | 703 | } |
704 | } | 704 | } |
705 | } | 705 | } |
706 | return tempConvertArr; | 706 | return tempConvertArr; |
707 | } | 707 | } |
708 | 708 | ||
709 | private bool[,] ConvertBytesToLandBitmap() | 709 | private bool[,] ConvertBytesToLandBitmap() |
710 | { | 710 | { |
711 | bool[,] tempConvertMap = new bool[landArrayMax, landArrayMax]; | 711 | bool[,] tempConvertMap = new bool[landArrayMax, landArrayMax]; |
712 | tempConvertMap.Initialize(); | 712 | tempConvertMap.Initialize(); |
713 | byte tempByte = 0; | 713 | byte tempByte = 0; |
714 | int x = 0, y = 0, i = 0, bitNum = 0; | 714 | int x = 0, y = 0, i = 0, bitNum = 0; |
715 | for (i = 0; i < 512; i++) | 715 | for (i = 0; i < 512; i++) |
716 | { | 716 | { |
717 | tempByte = LandData.Bitmap[i]; | 717 | tempByte = LandData.Bitmap[i]; |
718 | for (bitNum = 0; bitNum < 8; bitNum++) | 718 | for (bitNum = 0; bitNum < 8; bitNum++) |
719 | { | 719 | { |
720 | bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1); | 720 | bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1); |
721 | tempConvertMap[x, y] = bit; | 721 | tempConvertMap[x, y] = bit; |
722 | x++; | 722 | x++; |
723 | if (x > 63) | 723 | if (x > 63) |
724 | { | 724 | { |
725 | x = 0; | 725 | x = 0; |
726 | y++; | 726 | y++; |
727 | } | 727 | } |
728 | } | 728 | } |
729 | } | 729 | } |
730 | return tempConvertMap; | 730 | return tempConvertMap; |
731 | } | 731 | } |
732 | 732 | ||
733 | #endregion | 733 | #endregion |
734 | 734 | ||
735 | #region Object Select and Object Owner Listing | 735 | #region Object Select and Object Owner Listing |
736 | 736 | ||
737 | public void SendForceObjectSelect(int local_id, int request_type, List<UUID> returnIDs, IClientAPI remote_client) | 737 | public void SendForceObjectSelect(int local_id, int request_type, List<UUID> returnIDs, IClientAPI remote_client) |
738 | { | 738 | { |
739 | if (m_scene.Permissions.CanEditParcel(remote_client.AgentId, this)) | 739 | if (m_scene.Permissions.CanEditParcel(remote_client.AgentId, this)) |
740 | { | 740 | { |
741 | List<uint> resultLocalIDs = new List<uint>(); | 741 | List<uint> resultLocalIDs = new List<uint>(); |
742 | try | 742 | try |
743 | { | 743 | { |
744 | lock (primsOverMe) | 744 | lock (primsOverMe) |
745 | { | 745 | { |
746 | foreach (SceneObjectGroup obj in primsOverMe) | 746 | foreach (SceneObjectGroup obj in primsOverMe) |
747 | { | 747 | { |
748 | if (obj.LocalId > 0) | 748 | if (obj.LocalId > 0) |
749 | { | 749 | { |
750 | if (request_type == LandChannel.LAND_SELECT_OBJECTS_OWNER && obj.OwnerID == LandData.OwnerID) | 750 | if (request_type == LandChannel.LAND_SELECT_OBJECTS_OWNER && obj.OwnerID == LandData.OwnerID) |
751 | { | 751 | { |
752 | resultLocalIDs.Add(obj.LocalId); | 752 | resultLocalIDs.Add(obj.LocalId); |
753 | } | 753 | } |
754 | else if (request_type == LandChannel.LAND_SELECT_OBJECTS_GROUP && obj.GroupID == LandData.GroupID && LandData.GroupID != UUID.Zero) | 754 | else if (request_type == LandChannel.LAND_SELECT_OBJECTS_GROUP && obj.GroupID == LandData.GroupID && LandData.GroupID != UUID.Zero) |
755 | { | 755 | { |
756 | resultLocalIDs.Add(obj.LocalId); | 756 | resultLocalIDs.Add(obj.LocalId); |
757 | } | 757 | } |
758 | else if (request_type == LandChannel.LAND_SELECT_OBJECTS_OTHER && | 758 | else if (request_type == LandChannel.LAND_SELECT_OBJECTS_OTHER && |
759 | obj.OwnerID != remote_client.AgentId) | 759 | obj.OwnerID != remote_client.AgentId) |
760 | { | 760 | { |
761 | resultLocalIDs.Add(obj.LocalId); | 761 | resultLocalIDs.Add(obj.LocalId); |
762 | } | 762 | } |
763 | else if (request_type == (int)ObjectReturnType.List && returnIDs.Contains(obj.OwnerID)) | 763 | else if (request_type == (int)ObjectReturnType.List && returnIDs.Contains(obj.OwnerID)) |
764 | { | 764 | { |
765 | resultLocalIDs.Add(obj.LocalId); | 765 | resultLocalIDs.Add(obj.LocalId); |
766 | } | 766 | } |
767 | } | 767 | } |
768 | } | 768 | } |
769 | } | 769 | } |
770 | } catch (InvalidOperationException) | 770 | } catch (InvalidOperationException) |
771 | { | 771 | { |
772 | m_log.Error("[LAND]: Unable to force select the parcel objects. Arr."); | 772 | m_log.Error("[LAND]: Unable to force select the parcel objects. Arr."); |
773 | } | 773 | } |
774 | 774 | ||
775 | remote_client.SendForceClientSelectObjects(resultLocalIDs); | 775 | remote_client.SendForceClientSelectObjects(resultLocalIDs); |
776 | } | 776 | } |
777 | } | 777 | } |
778 | 778 | ||
779 | /// <summary> | 779 | /// <summary> |
780 | /// Notify the parcel owner each avatar that owns prims situated on their land. This notification includes | 780 | /// Notify the parcel owner each avatar that owns prims situated on their land. This notification includes |
781 | /// aggreagete details such as the number of prims. | 781 | /// aggreagete details such as the number of prims. |
782 | /// | 782 | /// |
783 | /// </summary> | 783 | /// </summary> |
784 | /// <param name="remote_client"> | 784 | /// <param name="remote_client"> |
785 | /// A <see cref="IClientAPI"/> | 785 | /// A <see cref="IClientAPI"/> |
786 | /// </param> | 786 | /// </param> |
787 | public void SendLandObjectOwners(IClientAPI remote_client) | 787 | public void SendLandObjectOwners(IClientAPI remote_client) |
788 | { | 788 | { |
789 | if (m_scene.Permissions.CanEditParcel(remote_client.AgentId, this)) | 789 | if (m_scene.Permissions.CanEditParcel(remote_client.AgentId, this)) |
790 | { | 790 | { |
791 | Dictionary<UUID, int> primCount = new Dictionary<UUID, int>(); | 791 | Dictionary<UUID, int> primCount = new Dictionary<UUID, int>(); |
792 | List<UUID> groups = new List<UUID>(); | 792 | List<UUID> groups = new List<UUID>(); |
793 | 793 | ||
794 | lock (primsOverMe) | 794 | lock (primsOverMe) |
795 | { | 795 | { |
796 | try | 796 | try |
797 | { | 797 | { |
798 | 798 | ||
799 | foreach (SceneObjectGroup obj in primsOverMe) | 799 | foreach (SceneObjectGroup obj in primsOverMe) |
800 | { | 800 | { |
801 | try | 801 | try |
802 | { | 802 | { |
803 | if (!primCount.ContainsKey(obj.OwnerID)) | 803 | if (!primCount.ContainsKey(obj.OwnerID)) |
804 | { | 804 | { |
805 | primCount.Add(obj.OwnerID, 0); | 805 | primCount.Add(obj.OwnerID, 0); |
806 | } | 806 | } |
807 | } | 807 | } |
808 | catch (NullReferenceException) | 808 | catch (NullReferenceException) |
809 | { | 809 | { |
810 | m_log.Info("[LAND]: " + "Got Null Reference when searching land owners from the parcel panel"); | 810 | m_log.Info("[LAND]: " + "Got Null Reference when searching land owners from the parcel panel"); |
811 | } | 811 | } |
812 | try | 812 | try |
813 | { | 813 | { |
814 | primCount[obj.OwnerID] += obj.PrimCount; | 814 | primCount[obj.OwnerID] += obj.PrimCount; |
815 | } | 815 | } |
816 | catch (KeyNotFoundException) | 816 | catch (KeyNotFoundException) |
817 | { | 817 | { |
818 | m_log.Error("[LAND]: Unable to match a prim with it's owner."); | 818 | m_log.Error("[LAND]: Unable to match a prim with it's owner."); |
819 | } | 819 | } |
820 | if (obj.OwnerID == obj.GroupID && (!groups.Contains(obj.OwnerID))) | 820 | if (obj.OwnerID == obj.GroupID && (!groups.Contains(obj.OwnerID))) |
821 | groups.Add(obj.OwnerID); | 821 | groups.Add(obj.OwnerID); |
822 | } | 822 | } |
823 | } | 823 | } |
824 | catch (InvalidOperationException) | 824 | catch (InvalidOperationException) |
825 | { | 825 | { |
826 | m_log.Error("[LAND]: Unable to Enumerate Land object arr."); | 826 | m_log.Error("[LAND]: Unable to Enumerate Land object arr."); |
827 | } | 827 | } |
828 | } | 828 | } |
829 | 829 | ||
830 | remote_client.SendLandObjectOwners(LandData, groups, primCount); | 830 | remote_client.SendLandObjectOwners(LandData, groups, primCount); |
831 | } | 831 | } |
832 | } | 832 | } |
833 | 833 | ||
834 | public Dictionary<UUID, int> GetLandObjectOwners() | 834 | public Dictionary<UUID, int> GetLandObjectOwners() |
835 | { | 835 | { |
836 | Dictionary<UUID, int> ownersAndCount = new Dictionary<UUID, int>(); | 836 | Dictionary<UUID, int> ownersAndCount = new Dictionary<UUID, int>(); |
837 | lock (primsOverMe) | 837 | lock (primsOverMe) |
838 | { | 838 | { |
839 | try | 839 | try |
840 | { | 840 | { |
841 | 841 | ||
842 | foreach (SceneObjectGroup obj in primsOverMe) | 842 | foreach (SceneObjectGroup obj in primsOverMe) |
843 | { | 843 | { |
844 | if (!ownersAndCount.ContainsKey(obj.OwnerID)) | 844 | if (!ownersAndCount.ContainsKey(obj.OwnerID)) |
845 | { | 845 | { |
846 | ownersAndCount.Add(obj.OwnerID, 0); | 846 | ownersAndCount.Add(obj.OwnerID, 0); |
847 | } | 847 | } |
848 | ownersAndCount[obj.OwnerID] += obj.PrimCount; | 848 | ownersAndCount[obj.OwnerID] += obj.PrimCount; |
849 | } | 849 | } |
850 | } | 850 | } |
851 | catch (InvalidOperationException) | 851 | catch (InvalidOperationException) |
852 | { | 852 | { |
853 | m_log.Error("[LAND]: Unable to enumerate land owners. arr."); | 853 | m_log.Error("[LAND]: Unable to enumerate land owners. arr."); |
854 | } | 854 | } |
855 | 855 | ||
856 | } | 856 | } |
857 | return ownersAndCount; | 857 | return ownersAndCount; |
858 | } | 858 | } |
859 | 859 | ||
860 | #endregion | 860 | #endregion |
861 | 861 | ||
862 | #region Object Returning | 862 | #region Object Returning |
863 | 863 | ||
864 | public void ReturnObject(SceneObjectGroup obj) | 864 | public void ReturnObject(SceneObjectGroup obj) |
865 | { | 865 | { |
866 | SceneObjectGroup[] objs = new SceneObjectGroup[1]; | 866 | SceneObjectGroup[] objs = new SceneObjectGroup[1]; |
867 | objs[0] = obj; | 867 | objs[0] = obj; |
868 | m_scene.returnObjects(objs, obj.OwnerID); | 868 | m_scene.returnObjects(objs, obj.OwnerID); |
869 | } | 869 | } |
870 | 870 | ||
871 | public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client) | 871 | public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client) |
872 | { | 872 | { |
873 | Dictionary<UUID,List<SceneObjectGroup>> returns = | 873 | Dictionary<UUID,List<SceneObjectGroup>> returns = |
874 | new Dictionary<UUID,List<SceneObjectGroup>>(); | 874 | new Dictionary<UUID,List<SceneObjectGroup>>(); |
875 | 875 | ||
876 | lock (primsOverMe) | 876 | lock (primsOverMe) |
877 | { | 877 | { |
878 | if (type == (uint)ObjectReturnType.Owner) | 878 | if (type == (uint)ObjectReturnType.Owner) |
879 | { | 879 | { |
880 | foreach (SceneObjectGroup obj in primsOverMe) | 880 | foreach (SceneObjectGroup obj in primsOverMe) |
881 | { | 881 | { |
882 | if (obj.OwnerID == m_landData.OwnerID) | 882 | if (obj.OwnerID == m_landData.OwnerID) |
883 | { | 883 | { |
884 | if (!returns.ContainsKey(obj.OwnerID)) | 884 | if (!returns.ContainsKey(obj.OwnerID)) |
885 | returns[obj.OwnerID] = | 885 | returns[obj.OwnerID] = |
886 | new List<SceneObjectGroup>(); | 886 | new List<SceneObjectGroup>(); |
887 | returns[obj.OwnerID].Add(obj); | 887 | returns[obj.OwnerID].Add(obj); |
888 | } | 888 | } |
889 | } | 889 | } |
890 | } | 890 | } |
891 | else if (type == (uint)ObjectReturnType.Group && m_landData.GroupID != UUID.Zero) | 891 | else if (type == (uint)ObjectReturnType.Group && m_landData.GroupID != UUID.Zero) |
892 | { | 892 | { |
893 | foreach (SceneObjectGroup obj in primsOverMe) | 893 | foreach (SceneObjectGroup obj in primsOverMe) |
894 | { | 894 | { |
895 | if (obj.GroupID == m_landData.GroupID) | 895 | if (obj.GroupID == m_landData.GroupID) |
896 | { | 896 | { |
897 | if (!returns.ContainsKey(obj.OwnerID)) | 897 | if (!returns.ContainsKey(obj.OwnerID)) |
898 | returns[obj.OwnerID] = | 898 | returns[obj.OwnerID] = |
899 | new List<SceneObjectGroup>(); | 899 | new List<SceneObjectGroup>(); |
900 | returns[obj.OwnerID].Add(obj); | 900 | returns[obj.OwnerID].Add(obj); |
901 | } | 901 | } |
902 | } | 902 | } |
903 | } | 903 | } |
904 | else if (type == (uint)ObjectReturnType.Other) | 904 | else if (type == (uint)ObjectReturnType.Other) |
905 | { | 905 | { |
906 | foreach (SceneObjectGroup obj in primsOverMe) | 906 | foreach (SceneObjectGroup obj in primsOverMe) |
907 | { | 907 | { |
908 | if (obj.OwnerID != m_landData.OwnerID && | 908 | if (obj.OwnerID != m_landData.OwnerID && |
909 | (obj.GroupID != m_landData.GroupID || | 909 | (obj.GroupID != m_landData.GroupID || |
910 | m_landData.GroupID == UUID.Zero)) | 910 | m_landData.GroupID == UUID.Zero)) |
911 | { | 911 | { |
912 | if (!returns.ContainsKey(obj.OwnerID)) | 912 | if (!returns.ContainsKey(obj.OwnerID)) |
913 | returns[obj.OwnerID] = | 913 | returns[obj.OwnerID] = |
914 | new List<SceneObjectGroup>(); | 914 | new List<SceneObjectGroup>(); |
915 | returns[obj.OwnerID].Add(obj); | 915 | returns[obj.OwnerID].Add(obj); |
916 | } | 916 | } |
917 | } | 917 | } |
918 | } | 918 | } |
919 | else if (type == (uint)ObjectReturnType.List) | 919 | else if (type == (uint)ObjectReturnType.List) |
920 | { | 920 | { |
921 | List<UUID> ownerlist = new List<UUID>(owners); | 921 | List<UUID> ownerlist = new List<UUID>(owners); |
922 | 922 | ||
923 | foreach (SceneObjectGroup obj in primsOverMe) | 923 | foreach (SceneObjectGroup obj in primsOverMe) |
924 | { | 924 | { |
925 | if (ownerlist.Contains(obj.OwnerID)) | 925 | if (ownerlist.Contains(obj.OwnerID)) |
926 | { | 926 | { |
927 | if (!returns.ContainsKey(obj.OwnerID)) | 927 | if (!returns.ContainsKey(obj.OwnerID)) |
928 | returns[obj.OwnerID] = | 928 | returns[obj.OwnerID] = |
929 | new List<SceneObjectGroup>(); | 929 | new List<SceneObjectGroup>(); |
930 | returns[obj.OwnerID].Add(obj); | 930 | returns[obj.OwnerID].Add(obj); |
931 | } | 931 | } |
932 | } | 932 | } |
933 | } | 933 | } |
934 | } | 934 | } |
935 | 935 | ||
936 | foreach (List<SceneObjectGroup> ol in returns.Values) | 936 | foreach (List<SceneObjectGroup> ol in returns.Values) |
937 | { | 937 | { |
938 | if (m_scene.Permissions.CanReturnObjects(this, remote_client.AgentId, ol)) | 938 | if (m_scene.Permissions.CanReturnObjects(this, remote_client.AgentId, ol)) |
939 | m_scene.returnObjects(ol.ToArray(), remote_client.AgentId); | 939 | m_scene.returnObjects(ol.ToArray(), remote_client.AgentId); |
940 | } | 940 | } |
941 | } | 941 | } |
942 | 942 | ||
943 | #endregion | 943 | #endregion |
944 | 944 | ||
945 | #region Object Adding/Removing from Parcel | 945 | #region Object Adding/Removing from Parcel |
946 | 946 | ||
947 | public void ResetLandPrimCounts() | 947 | public void ResetLandPrimCounts() |
948 | { | 948 | { |
949 | LandData.GroupPrims = 0; | 949 | LandData.GroupPrims = 0; |
950 | LandData.OwnerPrims = 0; | 950 | LandData.OwnerPrims = 0; |
951 | LandData.OtherPrims = 0; | 951 | LandData.OtherPrims = 0; |
952 | LandData.SelectedPrims = 0; | 952 | LandData.SelectedPrims = 0; |
953 | 953 | ||
954 | 954 | ||
955 | lock (primsOverMe) | 955 | lock (primsOverMe) |
956 | primsOverMe.Clear(); | 956 | primsOverMe.Clear(); |
957 | } | 957 | } |
958 | 958 | ||
959 | public void AddPrimToCount(SceneObjectGroup obj) | 959 | public void AddPrimToCount(SceneObjectGroup obj) |
960 | { | 960 | { |
961 | 961 | ||
962 | UUID prim_owner = obj.OwnerID; | 962 | UUID prim_owner = obj.OwnerID; |
963 | int prim_count = obj.PrimCount; | 963 | int prim_count = obj.PrimCount; |
964 | 964 | ||
965 | if (obj.IsSelected) | 965 | if (obj.IsSelected) |
966 | { | 966 | { |
967 | LandData.SelectedPrims += prim_count; | 967 | LandData.SelectedPrims += prim_count; |
968 | } | 968 | } |
969 | else | 969 | else |
970 | { | 970 | { |
971 | if (prim_owner == LandData.OwnerID) | 971 | if (prim_owner == LandData.OwnerID) |
972 | { | 972 | { |
973 | LandData.OwnerPrims += prim_count; | 973 | LandData.OwnerPrims += prim_count; |
974 | } | 974 | } |
975 | else if ((obj.GroupID == LandData.GroupID || | 975 | else if ((obj.GroupID == LandData.GroupID || |
976 | prim_owner == LandData.GroupID) && | 976 | prim_owner == LandData.GroupID) && |
977 | LandData.GroupID != UUID.Zero) | 977 | LandData.GroupID != UUID.Zero) |
978 | { | 978 | { |
979 | LandData.GroupPrims += prim_count; | 979 | LandData.GroupPrims += prim_count; |
980 | } | 980 | } |
981 | else | 981 | else |
982 | { | 982 | { |
983 | LandData.OtherPrims += prim_count; | 983 | LandData.OtherPrims += prim_count; |
984 | } | 984 | } |
985 | } | 985 | } |
986 | 986 | ||
987 | lock (primsOverMe) | 987 | lock (primsOverMe) |
988 | primsOverMe.Add(obj); | 988 | primsOverMe.Add(obj); |
989 | } | 989 | } |
990 | 990 | ||
991 | public void RemovePrimFromCount(SceneObjectGroup obj) | 991 | public void RemovePrimFromCount(SceneObjectGroup obj) |
992 | { | 992 | { |
993 | lock (primsOverMe) | 993 | lock (primsOverMe) |
994 | { | 994 | { |
995 | if (primsOverMe.Contains(obj)) | 995 | if (primsOverMe.Contains(obj)) |
996 | { | 996 | { |
997 | UUID prim_owner = obj.OwnerID; | 997 | UUID prim_owner = obj.OwnerID; |
998 | int prim_count = obj.PrimCount; | 998 | int prim_count = obj.PrimCount; |
999 | 999 | ||
1000 | if (prim_owner == LandData.OwnerID) | 1000 | if (prim_owner == LandData.OwnerID) |
1001 | { | 1001 | { |
1002 | LandData.OwnerPrims -= prim_count; | 1002 | LandData.OwnerPrims -= prim_count; |
1003 | } | 1003 | } |
1004 | else if (obj.GroupID == LandData.GroupID || | 1004 | else if (obj.GroupID == LandData.GroupID || |
1005 | prim_owner == LandData.GroupID) | 1005 | prim_owner == LandData.GroupID) |
1006 | { | 1006 | { |
1007 | LandData.GroupPrims -= prim_count; | 1007 | LandData.GroupPrims -= prim_count; |
1008 | } | 1008 | } |
1009 | else | 1009 | else |
1010 | { | 1010 | { |
1011 | LandData.OtherPrims -= prim_count; | 1011 | LandData.OtherPrims -= prim_count; |
1012 | } | 1012 | } |
1013 | 1013 | ||
1014 | primsOverMe.Remove(obj); | 1014 | primsOverMe.Remove(obj); |
1015 | } | 1015 | } |
1016 | } | 1016 | } |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | #endregion | 1019 | #endregion |
1020 | 1020 | ||
1021 | #endregion | 1021 | #endregion |
1022 | 1022 | ||
1023 | #endregion | 1023 | #endregion |
1024 | 1024 | ||
1025 | /// <summary> | 1025 | /// <summary> |
1026 | /// Set the media url for this land parcel | 1026 | /// Set the media url for this land parcel |
1027 | /// </summary> | 1027 | /// </summary> |
1028 | /// <param name="url"></param> | 1028 | /// <param name="url"></param> |
1029 | public void SetMediaUrl(string url) | 1029 | public void SetMediaUrl(string url) |
1030 | { | 1030 | { |
1031 | LandData.MediaURL = url; | 1031 | LandData.MediaURL = url; |
1032 | SendLandUpdateToAvatarsOverMe(); | 1032 | SendLandUpdateToAvatarsOverMe(); |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | /// <summary> | 1035 | /// <summary> |
1036 | /// Set the music url for this land parcel | 1036 | /// Set the music url for this land parcel |
1037 | /// </summary> | 1037 | /// </summary> |
1038 | /// <param name="url"></param> | 1038 | /// <param name="url"></param> |
1039 | public void SetMusicUrl(string url) | 1039 | public void SetMusicUrl(string url) |
1040 | { | 1040 | { |
1041 | LandData.MusicURL = url; | 1041 | LandData.MusicURL = url; |
1042 | SendLandUpdateToAvatarsOverMe(); | 1042 | SendLandUpdateToAvatarsOverMe(); |
1043 | } | 1043 | } |
1044 | } | 1044 | } |
1045 | } | 1045 | } |