aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Land
diff options
context:
space:
mode:
authorAdam Frisby2008-05-06 04:56:48 +0000
committerAdam Frisby2008-05-06 04:56:48 +0000
commit31cd162d34ab03284186484924e434a1187942cf (patch)
tree0edad805100caebd12d3bb103bef42503b92de57 /OpenSim/Region/Environment/Modules/World/Land
parent* Committing a bunch of work for control snatching. Not done yet. No visib... (diff)
downloadopensim-SC-31cd162d34ab03284186484924e434a1187942cf.zip
opensim-SC-31cd162d34ab03284186484924e434a1187942cf.tar.gz
opensim-SC-31cd162d34ab03284186484924e434a1187942cf.tar.bz2
opensim-SC-31cd162d34ab03284186484924e434a1187942cf.tar.xz
* Cleaning up code, making it conform to OpenSim standards.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Land')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs334
-rw-r--r--OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs4
-rw-r--r--OpenSim/Region/Environment/Modules/World/Land/LandObject.cs8
3 files changed, 159 insertions, 187 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs b/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs
index 4454c38..02558a9 100644
--- a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs
+++ b/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs
@@ -44,8 +44,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
44 //Land types set with flags in ParcelOverlay. 44 //Land types set with flags in ParcelOverlay.
45 //Only one of these can be used. 45 //Only one of these can be used.
46 public const float BAN_LINE_SAFETY_HIEGHT = 100; 46 public const float BAN_LINE_SAFETY_HIEGHT = 100;
47 public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte) 128; //Equals 10000000 47 public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = 128; //Equals 10000000
48 public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte) 64; //Equals 01000000 48 public const byte LAND_FLAG_PROPERTY_BORDER_WEST = 64; //Equals 01000000
49 49
50 //RequestResults (I think these are right, they seem to work): 50 //RequestResults (I think these are right, they seem to work):
51 public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land 51 public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land
@@ -55,31 +55,41 @@ namespace OpenSim.Region.Environment.Modules.World.Land
55 public const int LAND_SELECT_OBJECTS_GROUP = 4; 55 public const int LAND_SELECT_OBJECTS_GROUP = 4;
56 public const int LAND_SELECT_OBJECTS_OTHER = 8; 56 public const int LAND_SELECT_OBJECTS_OTHER = 8;
57 public const int LAND_SELECT_OBJECTS_OWNER = 2; 57 public const int LAND_SELECT_OBJECTS_OWNER = 2;
58 public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte) 5; //Equals 00000101 58 public const byte LAND_TYPE_IS_BEING_AUCTIONED = 5; //Equals 00000101
59 public const byte LAND_TYPE_IS_FOR_SALE = (byte) 4; //Equals 00000100 59 public const byte LAND_TYPE_IS_FOR_SALE = 4; //Equals 00000100
60 public const byte LAND_TYPE_OWNED_BY_GROUP = (byte) 2; //Equals 00000010 60 public const byte LAND_TYPE_OWNED_BY_GROUP = 2; //Equals 00000010
61 public const byte LAND_TYPE_OWNED_BY_OTHER = (byte) 1; //Equals 00000001 61 public const byte LAND_TYPE_OWNED_BY_OTHER = 1; //Equals 00000001
62 public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte) 3; //Equals 00000011 62 public const byte LAND_TYPE_OWNED_BY_REQUESTER = 3; //Equals 00000011
63 public const byte LAND_TYPE_PUBLIC = (byte) 0; //Equals 00000000 63 public const byte LAND_TYPE_PUBLIC = 0; //Equals 00000000
64 64
65 //These are other constants. Yay! 65 //These are other constants. Yay!
66 public const int START_LAND_LOCAL_ID = 1; 66 public const int START_LAND_LOCAL_ID = 1;
67 67
68 #endregion 68 #endregion
69 69
70 private int[,] landIDList = new int[64,64]; 70 private readonly int[,] landIDList = new int[64,64];
71 private Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>(); 71 private readonly Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>();
72 72
73 private bool landPrimCountTainted = false; 73 private bool landPrimCountTainted;
74 private int lastLandLocalID = START_LAND_LOCAL_ID - 1; 74 private int lastLandLocalID = START_LAND_LOCAL_ID - 1;
75 75
76 private bool m_allowedForcefulBans = true; 76 private bool m_allowedForcefulBans = true;
77 private Scene m_scene; 77 private readonly Scene m_scene;
78 78
79 public LandChannel(Scene scene) 79 public LandChannel(Scene scene)
80 { 80 {
81 m_scene = scene; 81 m_scene = scene;
82 landIDList.Initialize(); 82 landIDList.Initialize();
83
84 m_scene.EventManager.OnNewPresence += handleNewPresence;
85 }
86
87 private void handleNewPresence(ScenePresence avatar)
88 {
89 if (avatar.IsChildAgent)
90 {
91 avatar.OnSignificantClientMovement += handleSignificantClientMovement;
92 }
83 } 93 }
84 94
85 #region Land Object From Storage Functions 95 #region Land Object From Storage Functions
@@ -109,19 +119,19 @@ namespace OpenSim.Region.Environment.Modules.World.Land
109 ILandObject new_land = new LandObject(data.ownerID, data.isGroupOwned, m_scene); 119 ILandObject new_land = new LandObject(data.ownerID, data.isGroupOwned, m_scene);
110 new_land.landData = data.Copy(); 120 new_land.landData = data.Copy();
111 new_land.setLandBitmapFromByteArray(); 121 new_land.setLandBitmapFromByteArray();
112 addLandObject(new_land); 122 AddLandObject(new_land);
113 } 123 }
114 124
115 public void NoLandDataFromStorage() 125 public void NoLandDataFromStorage()
116 { 126 {
117 resetSimLandObjects(); 127 ResetSimLandObjects();
118 } 128 }
119 129
120 #endregion 130 #endregion
121 131
122 #region Parcel Add/Remove/Get/Create 132 #region Parcel Add/Remove/Get/Create
123 133
124 public void updateLandObject(int local_id, LandData newData) 134 public void UpdateLandObject(int local_id, LandData newData)
125 { 135 {
126 if (landList.ContainsKey(local_id)) 136 if (landList.ContainsKey(local_id))
127 { 137 {
@@ -133,10 +143,10 @@ namespace OpenSim.Region.Environment.Modules.World.Land
133 /// <summary> 143 /// <summary>
134 /// Get the land object at the specified point 144 /// Get the land object at the specified point
135 /// </summary> 145 /// </summary>
136 /// <param name="x">Value between 0 - 256 on the x axis of the point</param> 146 /// <param name="x_float">Value between 0 - 256 on the x axis of the point</param>
137 /// <param name="y">Value between 0 - 256 on the y axis of the point</param> 147 /// <param name="y_float">Value between 0 - 256 on the y axis of the point</param>
138 /// <returns>Land object at the point supplied</returns> 148 /// <returns>Land object at the point supplied</returns>
139 public ILandObject getLandObject(float x_float, float y_float) 149 public ILandObject GetLandObject(float x_float, float y_float)
140 { 150 {
141 int x; 151 int x;
142 int y; 152 int y;
@@ -155,13 +165,10 @@ namespace OpenSim.Region.Environment.Modules.World.Land
155 { 165 {
156 return null; 166 return null;
157 } 167 }
158 else 168 return landList[landIDList[x, y]];
159 {
160 return landList[landIDList[x, y]];
161 }
162 } 169 }
163 170
164 public ILandObject getLandObject(int x, int y) 171 public ILandObject GetLandObject(int x, int y)
165 { 172 {
166 if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0) 173 if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0)
167 { 174 {
@@ -169,17 +176,14 @@ namespace OpenSim.Region.Environment.Modules.World.Land
169 // they happen every time at border crossings 176 // they happen every time at border crossings
170 throw new Exception("Error: Parcel not found at point " + x + ", " + y); 177 throw new Exception("Error: Parcel not found at point " + x + ", " + y);
171 } 178 }
172 else 179 return landList[landIDList[x / 4, y / 4]];
173 {
174 return landList[landIDList[x / 4, y / 4]];
175 }
176 } 180 }
177 181
178 /// <summary> 182 /// <summary>
179 /// Creates a basic Parcel object without an owner (a zeroed key) 183 /// Creates a basic Parcel object without an owner (a zeroed key)
180 /// </summary> 184 /// </summary>
181 /// <returns></returns> 185 /// <returns></returns>
182 public ILandObject createBaseLand() 186 public ILandObject CreateBaseLand()
183 { 187 {
184 return new LandObject(LLUUID.Zero, false, m_scene); 188 return new LandObject(LLUUID.Zero, false, m_scene);
185 } 189 }
@@ -188,17 +192,18 @@ namespace OpenSim.Region.Environment.Modules.World.Land
188 /// Adds a land object to the stored list and adds them to the landIDList to what they own 192 /// Adds a land object to the stored list and adds them to the landIDList to what they own
189 /// </summary> 193 /// </summary>
190 /// <param name="new_land">The land object being added</param> 194 /// <param name="new_land">The land object being added</param>
191 public ILandObject addLandObject(ILandObject new_land) 195 public ILandObject AddLandObject(ILandObject new_land)
192 { 196 {
193 lastLandLocalID++; 197 lastLandLocalID++;
194 new_land.landData.localID = lastLandLocalID; 198 new_land.landData.localID = lastLandLocalID;
195 landList.Add(lastLandLocalID, (LandObject) new_land.Copy()); 199 landList.Add(lastLandLocalID, new_land.Copy());
196 200
197 201
198 bool[,] landBitmap = new_land.getLandBitmap(); 202 bool[,] landBitmap = new_land.getLandBitmap();
199 int x, y; 203 int x;
200 for (x = 0; x < 64; x++) 204 for (x = 0; x < 64; x++)
201 { 205 {
206 int y;
202 for (y = 0; y < 64; y++) 207 for (y = 0; y < 64; y++)
203 { 208 {
204 if (landBitmap[x, y]) 209 if (landBitmap[x, y])
@@ -218,9 +223,10 @@ namespace OpenSim.Region.Environment.Modules.World.Land
218 /// <param name="local_id">Land.localID of the peice of land to remove.</param> 223 /// <param name="local_id">Land.localID of the peice of land to remove.</param>
219 public void removeLandObject(int local_id) 224 public void removeLandObject(int local_id)
220 { 225 {
221 int x, y; 226 int x;
222 for (x = 0; x < 64; x++) 227 for (x = 0; x < 64; x++)
223 { 228 {
229 int y;
224 for (y = 0; y < 64; y++) 230 for (y = 0; y < 64; y++)
225 { 231 {
226 if (landIDList[x, y] == local_id) 232 if (landIDList[x, y] == local_id)
@@ -237,10 +243,11 @@ namespace OpenSim.Region.Environment.Modules.World.Land
237 243
238 private void performFinalLandJoin(ILandObject master, ILandObject slave) 244 private void performFinalLandJoin(ILandObject master, ILandObject slave)
239 { 245 {
240 int x, y; 246 int x;
241 bool[,] landBitmapSlave = slave.getLandBitmap(); 247 bool[,] landBitmapSlave = slave.getLandBitmap();
242 for (x = 0; x < 64; x++) 248 for (x = 0; x < 64; x++)
243 { 249 {
250 int y;
244 for (y = 0; y < 64; y++) 251 for (y = 0; y < 64; y++)
245 { 252 {
246 if (landBitmapSlave[x, y]) 253 if (landBitmapSlave[x, y])
@@ -251,10 +258,10 @@ namespace OpenSim.Region.Environment.Modules.World.Land
251 } 258 }
252 259
253 removeLandObject(slave.landData.localID); 260 removeLandObject(slave.landData.localID);
254 updateLandObject(master.landData.localID, master.landData); 261 UpdateLandObject(master.landData.localID, master.landData);
255 } 262 }
256 263
257 public ILandObject getLandObject(int parcelLocalID) 264 public ILandObject GetLandObject(int parcelLocalID)
258 { 265 {
259 lock (landList) 266 lock (landList)
260 { 267 {
@@ -270,7 +277,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
270 277
271 #region Parcel Modification 278 #region Parcel Modification
272 279
273 public void resetAllLandPrimCounts() 280 public void ResetAllLandPrimCounts()
274 { 281 {
275 foreach (LandObject p in landList.Values) 282 foreach (LandObject p in landList.Values)
276 { 283 {
@@ -278,27 +285,27 @@ namespace OpenSim.Region.Environment.Modules.World.Land
278 } 285 }
279 } 286 }
280 287
281 public void setPrimsTainted() 288 public void SetPrimsTainted()
282 { 289 {
283 landPrimCountTainted = true; 290 landPrimCountTainted = true;
284 } 291 }
285 292
286 public bool isLandPrimCountTainted() 293 public bool IsLandPrimCountTainted()
287 { 294 {
288 return landPrimCountTainted; 295 return landPrimCountTainted;
289 } 296 }
290 297
291 public void addPrimToLandPrimCounts(SceneObjectGroup obj) 298 public void AddPrimToLandPrimCounts(SceneObjectGroup obj)
292 { 299 {
293 LLVector3 position = obj.AbsolutePosition; 300 LLVector3 position = obj.AbsolutePosition;
294 ILandObject landUnderPrim = getLandObject(position.X, position.Y); 301 ILandObject landUnderPrim = GetLandObject(position.X, position.Y);
295 if (landUnderPrim != null) 302 if (landUnderPrim != null)
296 { 303 {
297 landUnderPrim.addPrimToCount(obj); 304 landUnderPrim.addPrimToCount(obj);
298 } 305 }
299 } 306 }
300 307
301 public void removePrimFromLandPrimCounts(SceneObjectGroup obj) 308 public void RemovePrimFromLandPrimCounts(SceneObjectGroup obj)
302 { 309 {
303 foreach (LandObject p in landList.Values) 310 foreach (LandObject p in landList.Values)
304 { 311 {
@@ -306,7 +313,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
306 } 313 }
307 } 314 }
308 315
309 public void finalizeLandPrimCountUpdate() 316 public void FinalizeLandPrimCountUpdate()
310 { 317 {
311 //Get Simwide prim count for owner 318 //Get Simwide prim count for owner
312 Dictionary<LLUUID, List<LandObject>> landOwnersAndParcels = new Dictionary<LLUUID, List<LandObject>>(); 319 Dictionary<LLUUID, List<LandObject>> landOwnersAndParcels = new Dictionary<LLUUID, List<LandObject>>();
@@ -343,7 +350,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
343 } 350 }
344 } 351 }
345 352
346 public void updateLandPrimCounts() 353 public void UpdateLandPrimCounts()
347 { 354 {
348 foreach (EntityBase obj in m_scene.Entities.Values) 355 foreach (EntityBase obj in m_scene.Entities.Values)
349 { 356 {
@@ -354,11 +361,11 @@ namespace OpenSim.Region.Environment.Modules.World.Land
354 } 361 }
355 } 362 }
356 363
357 public void performParcelPrimCountUpdate() 364 public void PerformParcelPrimCountUpdate()
358 { 365 {
359 resetAllLandPrimCounts(); 366 ResetAllLandPrimCounts();
360 m_scene.EventManager.TriggerParcelPrimCountUpdate(); 367 m_scene.EventManager.TriggerParcelPrimCountUpdate();
361 finalizeLandPrimCountUpdate(); 368 FinalizeLandPrimCountUpdate();
362 landPrimCountTainted = false; 369 landPrimCountTainted = false;
363 } 370 }
364 371
@@ -371,47 +378,42 @@ namespace OpenSim.Region.Environment.Modules.World.Land
371 /// <param name="end_y">North Point</param> 378 /// <param name="end_y">North Point</param>
372 /// <param name="attempting_user_id">LLUUID of user who is trying to subdivide</param> 379 /// <param name="attempting_user_id">LLUUID of user who is trying to subdivide</param>
373 /// <returns>Returns true if successful</returns> 380 /// <returns>Returns true if successful</returns>
374 private bool subdivide(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) 381 private void subdivide(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id)
375 { 382 {
376 //First, lets loop through the points and make sure they are all in the same peice of land 383 //First, lets loop through the points and make sure they are all in the same peice of land
377 //Get the land object at start 384 //Get the land object at start
378 ILandObject startLandObject = null; 385
379 try 386 ILandObject startLandObject = GetLandObject(start_x, start_y);
380 { 387
381 startLandObject = getLandObject(start_x, start_y); 388 if (startLandObject == null) return;
382 }
383 catch (Exception)
384 {
385 //m_log.Error("[LAND]: " + "Unable to get land object for subdivision at x: " + start_x + " y:" + start_y);
386 }
387 if (startLandObject == null) return false; //No such land object at the beginning
388 389
389 //Loop through the points 390 //Loop through the points
390 try 391 try
391 { 392 {
392 int totalX = end_x - start_x; 393 int totalX = end_x - start_x;
393 int totalY = end_y - start_y; 394 int totalY = end_y - start_y;
394 int x, y; 395 int y;
395 for (y = 0; y < totalY; y++) 396 for (y = 0; y < totalY; y++)
396 { 397 {
398 int x;
397 for (x = 0; x < totalX; x++) 399 for (x = 0; x < totalX; x++)
398 { 400 {
399 ILandObject tempLandObject = getLandObject(start_x + x, start_y + y); 401 ILandObject tempLandObject = GetLandObject(start_x + x, start_y + y);
400 if (tempLandObject == null) return false; //No such land object at that point 402 if (tempLandObject == null) return;
401 if (tempLandObject != startLandObject) return false; //Subdividing over 2 land objects; no-no 403 if (tempLandObject != startLandObject) return;
402 } 404 }
403 } 405 }
404 } 406 }
405 catch (Exception) 407 catch (Exception)
406 { 408 {
407 return false; //Exception. For now, lets skip subdivision 409 return;
408 } 410 }
409 411
410 //If we are still here, then they are subdividing within one piece of land 412 //If we are still here, then they are subdividing within one piece of land
411 //Check owner 413 //Check owner
412 if (startLandObject.landData.ownerID != attempting_user_id) 414 if (startLandObject.landData.ownerID != attempting_user_id)
413 { 415 {
414 return false; //They cant do this! 416 return;
415 } 417 }
416 418
417 //Lets create a new land object with bitmap activated at that point (keeping the old land objects info) 419 //Lets create a new land object with bitmap activated at that point (keeping the old land objects info)
@@ -427,15 +429,15 @@ namespace OpenSim.Region.Environment.Modules.World.Land
427 newLand.modifyLandBitmapSquare(startLandObject.getLandBitmap(), start_x, start_y, end_x, end_y, false)); 429 newLand.modifyLandBitmapSquare(startLandObject.getLandBitmap(), start_x, start_y, end_x, end_y, false));
428 landList[startLandObjectIndex].forceUpdateLandInfo(); 430 landList[startLandObjectIndex].forceUpdateLandInfo();
429 431
430 setPrimsTainted(); 432 SetPrimsTainted();
431 433
432 //Now add the new land object 434 //Now add the new land object
433 ILandObject result = addLandObject(newLand); 435 ILandObject result = AddLandObject(newLand);
434 updateLandObject(startLandObject.landData.localID, startLandObject.landData); 436 UpdateLandObject(startLandObject.landData.localID, startLandObject.landData);
435 result.sendLandUpdateToAvatarsOverMe(); 437 result.sendLandUpdateToAvatarsOverMe();
436 438
437 439
438 return true; 440 return;
439 } 441 }
440 442
441 /// <summary> 443 /// <summary>
@@ -447,27 +449,20 @@ namespace OpenSim.Region.Environment.Modules.World.Land
447 /// <param name="end_y">y value in second peice of land</param> 449 /// <param name="end_y">y value in second peice of land</param>
448 /// <param name="attempting_user_id">LLUUID of the avatar trying to join the land objects</param> 450 /// <param name="attempting_user_id">LLUUID of the avatar trying to join the land objects</param>
449 /// <returns>Returns true if successful</returns> 451 /// <returns>Returns true if successful</returns>
450 private bool join(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) 452 private void join(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id)
451 { 453 {
452 end_x -= 4; 454 end_x -= 4;
453 end_y -= 4; 455 end_y -= 4;
454 456
455 List<ILandObject> selectedLandObjects = new List<ILandObject>(); 457 List<ILandObject> selectedLandObjects = new List<ILandObject>();
456 int stepXSelected = 0; 458 int stepYSelected;
457 int stepYSelected = 0;
458 for (stepYSelected = start_y; stepYSelected <= end_y; stepYSelected += 4) 459 for (stepYSelected = start_y; stepYSelected <= end_y; stepYSelected += 4)
459 { 460 {
461 int stepXSelected;
460 for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4) 462 for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4)
461 { 463 {
462 ILandObject p = null; 464 ILandObject p = GetLandObject(stepXSelected, stepYSelected);
463 try 465
464 {
465 p = getLandObject(stepXSelected, stepYSelected);
466 }
467 catch (Exception)
468 {
469 //m_log.Error("[LAND]: " + "Unable to get land object for subdivision at x: " + stepXSelected + " y:" + stepYSelected);
470 }
471 if (p != null) 466 if (p != null)
472 { 467 {
473 if (!selectedLandObjects.Contains(p)) 468 if (!selectedLandObjects.Contains(p))
@@ -483,17 +478,17 @@ namespace OpenSim.Region.Environment.Modules.World.Land
483 478
484 if (selectedLandObjects.Count < 1) 479 if (selectedLandObjects.Count < 1)
485 { 480 {
486 return false; //Only one piece of land selected 481 return;
487 } 482 }
488 if (masterLandObject.landData.ownerID != attempting_user_id) 483 if (masterLandObject.landData.ownerID != attempting_user_id)
489 { 484 {
490 return false; //Not the same owner 485 return;
491 } 486 }
492 foreach (ILandObject p in selectedLandObjects) 487 foreach (ILandObject p in selectedLandObjects)
493 { 488 {
494 if (p.landData.ownerID != masterLandObject.landData.ownerID) 489 if (p.landData.ownerID != masterLandObject.landData.ownerID)
495 { 490 {
496 return false; //Over multiple users. TODO: make this just ignore this piece of land? 491 return;
497 } 492 }
498 } 493 }
499 foreach (ILandObject slaveLandObject in selectedLandObjects) 494 foreach (ILandObject slaveLandObject in selectedLandObjects)
@@ -504,11 +499,11 @@ namespace OpenSim.Region.Environment.Modules.World.Land
504 } 499 }
505 500
506 501
507 setPrimsTainted(); 502 SetPrimsTainted();
508 503
509 masterLandObject.sendLandUpdateToAvatarsOverMe(); 504 masterLandObject.sendLandUpdateToAvatarsOverMe();
510 505
511 return true; 506 return;
512 } 507 }
513 508
514 #endregion 509 #endregion
@@ -519,30 +514,24 @@ namespace OpenSim.Region.Environment.Modules.World.Land
519 /// Where we send the ParcelOverlay packet to the client 514 /// Where we send the ParcelOverlay packet to the client
520 /// </summary> 515 /// </summary>
521 /// <param name="remote_client">The object representing the client</param> 516 /// <param name="remote_client">The object representing the client</param>
522 public void sendParcelOverlay(IClientAPI remote_client) 517 public void SendParcelOverlay(IClientAPI remote_client)
523 { 518 {
524 const int LAND_BLOCKS_PER_PACKET = 1024; 519 const int LAND_BLOCKS_PER_PACKET = 1024;
525 int x, y = 0; 520
526 byte[] byteArray = new byte[LAND_BLOCKS_PER_PACKET]; 521 byte[] byteArray = new byte[LAND_BLOCKS_PER_PACKET];
527 int byteArrayCount = 0; 522 int byteArrayCount = 0;
528 int sequenceID = 0; 523 int sequenceID = 0;
529 ParcelOverlayPacket packet; 524 ParcelOverlayPacket packet;
530 525
526 int y;
531 for (y = 0; y < 64; y++) 527 for (y = 0; y < 64; y++)
532 { 528 {
529 int x;
533 for (x = 0; x < 64; x++) 530 for (x = 0; x < 64; x++)
534 { 531 {
535 byte tempByte = (byte) 0; //This represents the byte for the current 4x4 532 byte tempByte = 0; //This represents the byte for the current 4x4
536 ILandObject currentParcelBlock = null;
537 533
538 try 534 ILandObject currentParcelBlock = GetLandObject(x * 4, y * 4);
539 {
540 currentParcelBlock = getLandObject(x * 4, y * 4);
541 }
542 catch (Exception)
543 {
544 //m_log.Warn("[LAND]: " + "unable to get land at x: " + (x * 4) + " y: " + (y * 4));
545 }
546 535
547 536
548 if (currentParcelBlock != null) 537 if (currentParcelBlock != null)
@@ -572,53 +561,47 @@ namespace OpenSim.Region.Environment.Modules.World.Land
572 561
573 562
574 //Now for border control 563 //Now for border control
575 try 564
565 ILandObject westParcel = null;
566 ILandObject southParcel = null;
567 if (x > 0)
568 {
569 westParcel = GetLandObject((x - 1) * 4, y * 4);
570 }
571 if (y > 0)
572 {
573 southParcel = GetLandObject(x * 4, (y - 1) * 4);
574 }
575
576 if (x == 0)
577 {
578 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST);
579 }
580 else if (westParcel != null && westParcel != currentParcelBlock)
581 {
582 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST);
583 }
584
585 if (y == 0)
576 { 586 {
577 ILandObject westParcel = null; 587 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH);
578 ILandObject southParcel = null;
579 if (x > 0)
580 {
581 westParcel = getLandObject((x - 1) * 4, y * 4);
582 }
583 if (y > 0)
584 {
585 southParcel = getLandObject(x * 4, (y - 1) * 4);
586 }
587
588 if (x == 0)
589 {
590 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST);
591 }
592 else if (westParcel != null && westParcel != currentParcelBlock)
593 {
594 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST);
595 }
596
597 if (y == 0)
598 {
599 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH);
600 }
601 else if (southParcel != null && southParcel != currentParcelBlock)
602 {
603 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH);
604 }
605
606 byteArray[byteArrayCount] = tempByte;
607 byteArrayCount++;
608 if (byteArrayCount >= LAND_BLOCKS_PER_PACKET)
609 {
610 byteArrayCount = 0;
611 packet = (ParcelOverlayPacket) PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
612 packet.ParcelData.Data = byteArray;
613 packet.ParcelData.SequenceID = sequenceID;
614 remote_client.OutPacket((Packet) packet, ThrottleOutPacketType.Task);
615 sequenceID++;
616 byteArray = new byte[LAND_BLOCKS_PER_PACKET];
617 }
618 } 588 }
619 catch (Exception) 589 else if (southParcel != null && southParcel != currentParcelBlock)
620 { 590 {
621 //m_log.Debug("[LAND]: Skipped Land checks because avatar is out of bounds: " + e.Message); 591 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH);
592 }
593
594 byteArray[byteArrayCount] = tempByte;
595 byteArrayCount++;
596 if (byteArrayCount >= LAND_BLOCKS_PER_PACKET)
597 {
598 byteArrayCount = 0;
599 packet = (ParcelOverlayPacket) PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
600 packet.ParcelData.Data = byteArray;
601 packet.ParcelData.SequenceID = sequenceID;
602 remote_client.OutPacket(packet, ThrottleOutPacketType.Task);
603 sequenceID++;
604 byteArray = new byte[LAND_BLOCKS_PER_PACKET];
622 } 605 }
623 } 606 }
624 } 607 }
@@ -630,22 +613,17 @@ namespace OpenSim.Region.Environment.Modules.World.Land
630 { 613 {
631 //Get the land objects within the bounds 614 //Get the land objects within the bounds
632 List<ILandObject> temp = new List<ILandObject>(); 615 List<ILandObject> temp = new List<ILandObject>();
633 int x, y, i; 616 int x;
617 int i;
634 int inc_x = end_x - start_x; 618 int inc_x = end_x - start_x;
635 int inc_y = end_y - start_y; 619 int inc_y = end_y - start_y;
636 for (x = 0; x < inc_x; x++) 620 for (x = 0; x < inc_x; x++)
637 { 621 {
622 int y;
638 for (y = 0; y < inc_y; y++) 623 for (y = 0; y < inc_y; y++)
639 { 624 {
640 ILandObject currentParcel = null; 625 ILandObject currentParcel = GetLandObject(start_x + x, start_y + y);
641 try 626
642 {
643 currentParcel = getLandObject(start_x + x, start_y + y);
644 }
645 catch (Exception)
646 {
647 //m_log.Warn("[LAND]: " + "unable to get land at x: " + (start_x + x) + " y: " + (start_y + y));
648 }
649 if (currentParcel != null) 627 if (currentParcel != null)
650 { 628 {
651 if (!temp.Contains(currentParcel)) 629 if (!temp.Contains(currentParcel))
@@ -669,7 +647,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
669 } 647 }
670 648
671 649
672 sendParcelOverlay(remote_client); 650 SendParcelOverlay(remote_client);
673 } 651 }
674 652
675 public void handleParcelPropertiesUpdateRequest(LandUpdateArgs args, int localID, IClientAPI remote_client) 653 public void handleParcelPropertiesUpdateRequest(LandUpdateArgs args, int localID, IClientAPI remote_client)
@@ -704,7 +682,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
704 682
705 #region ILandChannel Members 683 #region ILandChannel Members
706 684
707 public bool allowedForcefulBans 685 public bool AllowedForcefulBans
708 { 686 {
709 get { return m_allowedForcefulBans; } 687 get { return m_allowedForcefulBans; }
710 set { m_allowedForcefulBans = value; } 688 set { m_allowedForcefulBans = value; }
@@ -713,7 +691,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
713 /// <summary> 691 /// <summary>
714 /// Resets the sim to the default land object (full sim piece of land owned by the default user) 692 /// Resets the sim to the default land object (full sim piece of land owned by the default user)
715 /// </summary> 693 /// </summary>
716 public void resetSimLandObjects() 694 public void ResetSimLandObjects()
717 { 695 {
718 //Remove all the land objects in the sim and add a blank, full sim land object set to public 696 //Remove all the land objects in the sim and add a blank, full sim land object set to public
719 landList.Clear(); 697 landList.Clear();
@@ -725,18 +703,19 @@ namespace OpenSim.Region.Environment.Modules.World.Land
725 fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize)); 703 fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize));
726 fullSimParcel.landData.ownerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; 704 fullSimParcel.landData.ownerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
727 705
728 addLandObject(fullSimParcel); 706 AddLandObject(fullSimParcel);
729 } 707 }
730 708
731 public List<ILandObject> parcelsNearPoint(LLVector3 position) 709 public List<ILandObject> ParcelsNearPoint(LLVector3 position)
732 { 710 {
733 List<ILandObject> parcelsNear = new List<ILandObject>(); 711 List<ILandObject> parcelsNear = new List<ILandObject>();
734 int x, y; 712 int x;
735 for (x = -4; x <= 4; x += 4) 713 for (x = -4; x <= 4; x += 4)
736 { 714 {
715 int y;
737 for (y = -4; y <= 4; y += 4) 716 for (y = -4; y <= 4; y += 4)
738 { 717 {
739 ILandObject check = getLandObject(position.X + x, position.Y + y); 718 ILandObject check = GetLandObject(position.X + x, position.Y + y);
740 if (check != null) 719 if (check != null)
741 { 720 {
742 if (!parcelsNear.Contains(check)) 721 if (!parcelsNear.Contains(check))
@@ -750,9 +729,9 @@ namespace OpenSim.Region.Environment.Modules.World.Land
750 return parcelsNear; 729 return parcelsNear;
751 } 730 }
752 731
753 public void sendYouAreBannedNotice(ScenePresence avatar) 732 public void SendYouAreBannedNotice(ScenePresence avatar)
754 { 733 {
755 if (allowedForcefulBans) 734 if (AllowedForcefulBans)
756 { 735 {
757 avatar.ControllingClient.SendAlertMessage( 736 avatar.ControllingClient.SendAlertMessage(
758 "You are not allowed on this parcel because you are banned. Please go away. <3 OpenSim Developers"); 737 "You are not allowed on this parcel because you are banned. Please go away. <3 OpenSim Developers");
@@ -780,7 +759,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
780 { 759 {
781 if (parcelAvatarIsEntering.isBannedFromLand(avatar.UUID)) 760 if (parcelAvatarIsEntering.isBannedFromLand(avatar.UUID))
782 { 761 {
783 sendYouAreBannedNotice(avatar); 762 SendYouAreBannedNotice(avatar);
784 } 763 }
785 else if (parcelAvatarIsEntering.isRestrictedFromLand(avatar.UUID)) 764 else if (parcelAvatarIsEntering.isRestrictedFromLand(avatar.UUID))
786 { 765 {
@@ -800,14 +779,14 @@ namespace OpenSim.Region.Environment.Modules.World.Land
800 } 779 }
801 } 780 }
802 781
803 public void sendOutNearestBanLine(IClientAPI avatar) 782 public void SendOutNearestBanLine(IClientAPI avatar)
804 { 783 {
805 List<ScenePresence> avatars = m_scene.GetAvatars(); 784 List<ScenePresence> avatars = m_scene.GetAvatars();
806 foreach (ScenePresence presence in avatars) 785 foreach (ScenePresence presence in avatars)
807 { 786 {
808 if (presence.UUID == avatar.AgentId) 787 if (presence.UUID == avatar.AgentId)
809 { 788 {
810 List<ILandObject> checkLandParcels = parcelsNearPoint(presence.AbsolutePosition); 789 List<ILandObject> checkLandParcels = ParcelsNearPoint(presence.AbsolutePosition);
811 foreach (ILandObject checkBan in checkLandParcels) 790 foreach (ILandObject checkBan in checkLandParcels)
812 { 791 {
813 if (checkBan.isBannedFromLand(avatar.AgentId)) 792 if (checkBan.isBannedFromLand(avatar.AgentId))
@@ -815,7 +794,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
815 checkBan.sendLandProperties(-30000, false, (int) ParcelManager.ParcelResult.Single, avatar); 794 checkBan.sendLandProperties(-30000, false, (int) ParcelManager.ParcelResult.Single, avatar);
816 return; //Only send one 795 return; //Only send one
817 } 796 }
818 else if (checkBan.isRestrictedFromLand(avatar.AgentId)) 797 if (checkBan.isRestrictedFromLand(avatar.AgentId))
819 { 798 {
820 checkBan.sendLandProperties(-40000, false, (int) ParcelManager.ParcelResult.Single, avatar); 799 checkBan.sendLandProperties(-40000, false, (int) ParcelManager.ParcelResult.Single, avatar);
821 return; //Only send one 800 return; //Only send one
@@ -826,18 +805,11 @@ namespace OpenSim.Region.Environment.Modules.World.Land
826 } 805 }
827 } 806 }
828 807
829 public void sendLandUpdate(ScenePresence avatar, bool force) 808 public void SendLandUpdate(ScenePresence avatar, bool force)
830 { 809 {
831 ILandObject over = null; 810 ILandObject over = GetLandObject((int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
832 try 811 (int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
833 { 812
834 over = getLandObject((int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
835 (int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
836 }
837 catch (Exception)
838 {
839 //m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatar.AbsolutePosition.X) + " y: " + Math.Round(avatar.AbsolutePosition.Y));
840 }
841 813
842 if (over != null) 814 if (over != null)
843 { 815 {
@@ -864,9 +836,9 @@ namespace OpenSim.Region.Environment.Modules.World.Land
864 } 836 }
865 } 837 }
866 838
867 public void sendLandUpdate(ScenePresence avatar) 839 public void SendLandUpdate(ScenePresence avatar)
868 { 840 {
869 sendLandUpdate(avatar, false); 841 SendLandUpdate(avatar, false);
870 } 842 }
871 843
872 public void handleSignificantClientMovement(IClientAPI remote_client) 844 public void handleSignificantClientMovement(IClientAPI remote_client)
@@ -875,9 +847,9 @@ namespace OpenSim.Region.Environment.Modules.World.Land
875 847
876 if (clientAvatar != null) 848 if (clientAvatar != null)
877 { 849 {
878 sendLandUpdate(clientAvatar); 850 SendLandUpdate(clientAvatar);
879 sendOutNearestBanLine(remote_client); 851 SendOutNearestBanLine(remote_client);
880 ILandObject parcel = getLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); 852 ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y);
881 if (parcel != null) 853 if (parcel != null)
882 { 854 {
883 if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && 855 if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT &&
@@ -893,7 +865,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
893 else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && 865 else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT &&
894 parcel.isBannedFromLand(clientAvatar.UUID)) 866 parcel.isBannedFromLand(clientAvatar.UUID))
895 { 867 {
896 sendYouAreBannedNotice(clientAvatar); 868 SendYouAreBannedNotice(clientAvatar);
897 } 869 }
898 } 870 }
899 } 871 }
@@ -902,7 +874,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
902 public void handleAnyClientMovement(ScenePresence avatar) 874 public void handleAnyClientMovement(ScenePresence avatar)
903 //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance. 875 //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance.
904 { 876 {
905 ILandObject over = getLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 877 ILandObject over = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
906 if (over != null) 878 if (over != null)
907 { 879 {
908 if (!over.isBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= BAN_LINE_SAFETY_HIEGHT) 880 if (!over.isBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= BAN_LINE_SAFETY_HIEGHT)
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs
index f891332..5e65608 100644
--- a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs
@@ -44,8 +44,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
44 m_scene = scene; 44 m_scene = scene;
45 landChannel = new LandChannel(scene); 45 landChannel = new LandChannel(scene);
46 46
47 m_scene.EventManager.OnParcelPrimCountAdd += landChannel.addPrimToLandPrimCounts; 47 m_scene.EventManager.OnParcelPrimCountAdd += landChannel.AddPrimToLandPrimCounts;
48 m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts; 48 m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.UpdateLandPrimCounts;
49 m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel); 49 m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel);
50 m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(landChannel.handleAnyClientMovement); 50 m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(landChannel.handleAnyClientMovement);
51 m_scene.EventManager.OnValidateLandBuy += landChannel.handleLandValidationRequest; 51 m_scene.EventManager.OnValidateLandBuy += landChannel.handleLandValidationRequest;
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
index 891e1db..88bc4e6 100644
--- a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
+++ b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
@@ -150,7 +150,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
150 newData.userLocation = args.UserLocation; 150 newData.userLocation = args.UserLocation;
151 newData.userLookAt = args.UserLookAt; 151 newData.userLookAt = args.UserLookAt;
152 152
153 m_scene.LandChannel.updateLandObject(landData.localID, newData); 153 m_scene.LandChannel.UpdateLandObject(landData.localID, newData);
154 154
155 sendLandUpdateToAvatarsOverMe(); 155 sendLandUpdateToAvatarsOverMe();
156 } 156 }
@@ -168,7 +168,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
168 newData.salePrice = 0; 168 newData.salePrice = 0;
169 newData.authBuyerID = LLUUID.Zero; 169 newData.authBuyerID = LLUUID.Zero;
170 newData.landFlags &= ~(uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects); 170 newData.landFlags &= ~(uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects);
171 m_scene.LandChannel.updateLandObject(landData.localID, newData); 171 m_scene.LandChannel.UpdateLandObject(landData.localID, newData);
172 172
173 sendLandUpdateToAvatarsOverMe(); 173 sendLandUpdateToAvatarsOverMe();
174 } 174 }
@@ -234,7 +234,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
234 try 234 try
235 { 235 {
236 over = 236 over =
237 m_scene.LandChannel.getLandObject((int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.X))), 237 m_scene.LandChannel.GetLandObject((int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.X))),
238 (int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.Y)))); 238 (int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.Y))));
239 } 239 }
240 catch (Exception) 240 catch (Exception)
@@ -332,7 +332,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
332 } 332 }
333 } 333 }
334 334
335 m_scene.LandChannel.updateLandObject(landData.localID, newData); 335 m_scene.LandChannel.UpdateLandObject(landData.localID, newData);
336 } 336 }
337 337
338 #endregion 338 #endregion