diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World')
10 files changed, 346 insertions, 371 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs b/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs index cbea07a..efc5234 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs | |||
@@ -43,61 +43,45 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
43 | 43 | ||
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 byte LAND_TYPE_PUBLIC = (byte)0; //Equals 00000000 | 46 | public const float BAN_LINE_SAFETY_HIEGHT = 100; |
47 | public const byte LAND_TYPE_OWNED_BY_OTHER = (byte)1; //Equals 00000001 | 47 | public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte) 128; //Equals 10000000 |
48 | public const byte LAND_TYPE_OWNED_BY_GROUP = (byte)2; //Equals 00000010 | 48 | public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte) 64; //Equals 01000000 |
49 | public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte)3; //Equals 00000011 | ||
50 | public const byte LAND_TYPE_IS_FOR_SALE = (byte)4; //Equals 00000100 | ||
51 | public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte)5; //Equals 00000101 | ||
52 | |||
53 | //Flags that when set, a border on the given side will be placed | ||
54 | //NOTE: North and East is assumable by the west and south sides (if land to east has a west border, then I have an east border; etc) | ||
55 | //This took forever to figure out -- jeesh. /blame LL for even having to send these | ||
56 | public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte)64; //Equals 01000000 | ||
57 | public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte)128; //Equals 10000000 | ||
58 | 49 | ||
59 | //RequestResults (I think these are right, they seem to work): | 50 | //RequestResults (I think these are right, they seem to work): |
60 | public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land | ||
61 | 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 |
52 | public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land | ||
62 | 53 | ||
63 | //ParcelSelectObjects | 54 | //ParcelSelectObjects |
64 | public const int LAND_SELECT_OBJECTS_OWNER = 2; | ||
65 | public const int LAND_SELECT_OBJECTS_GROUP = 4; | 55 | public const int LAND_SELECT_OBJECTS_GROUP = 4; |
66 | 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; | ||
58 | public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte) 5; //Equals 00000101 | ||
59 | public const byte LAND_TYPE_IS_FOR_SALE = (byte) 4; //Equals 00000100 | ||
60 | public const byte LAND_TYPE_OWNED_BY_GROUP = (byte) 2; //Equals 00000010 | ||
61 | public const byte LAND_TYPE_OWNED_BY_OTHER = (byte) 1; //Equals 00000001 | ||
62 | public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte) 3; //Equals 00000011 | ||
63 | public const byte LAND_TYPE_PUBLIC = (byte) 0; //Equals 00000000 | ||
67 | 64 | ||
68 | //These are other constants. Yay! | 65 | //These are other constants. Yay! |
69 | public const int START_LAND_LOCAL_ID = 1; | 66 | public const int START_LAND_LOCAL_ID = 1; |
70 | 67 | ||
71 | public const float BAN_LINE_SAFETY_HIEGHT = 100; | ||
72 | |||
73 | #endregion | 68 | #endregion |
74 | 69 | ||
75 | private Scene m_scene; | 70 | private int[,] landIDList = new int[64,64]; |
76 | |||
77 | private Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>(); | 71 | private Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>(); |
78 | private int lastLandLocalID = START_LAND_LOCAL_ID - 1; | ||
79 | private int[,] landIDList = new int[64, 64]; | ||
80 | 72 | ||
81 | private bool landPrimCountTainted = false; | 73 | private bool landPrimCountTainted = false; |
74 | private int lastLandLocalID = START_LAND_LOCAL_ID - 1; | ||
82 | 75 | ||
83 | private bool m_allowedForcefulBans = true; | 76 | private bool m_allowedForcefulBans = true; |
84 | public bool allowedForcefulBans | 77 | private Scene m_scene; |
85 | { | ||
86 | get | ||
87 | { | ||
88 | return m_allowedForcefulBans; | ||
89 | } | ||
90 | set | ||
91 | { | ||
92 | m_allowedForcefulBans = value; | ||
93 | } | ||
94 | } | ||
95 | 78 | ||
96 | public LandChannel(Scene scene) | 79 | public LandChannel(Scene scene) |
97 | { | 80 | { |
98 | m_scene = scene; | 81 | m_scene = scene; |
99 | landIDList.Initialize(); | 82 | landIDList.Initialize(); |
100 | } | 83 | } |
84 | |||
101 | #region Land Object From Storage Functions | 85 | #region Land Object From Storage Functions |
102 | 86 | ||
103 | public void IncomingLandObjectsFromStorage(List<LandData> data) | 87 | public void IncomingLandObjectsFromStorage(List<LandData> data) |
@@ -133,10 +117,64 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
133 | resetSimLandObjects(); | 117 | resetSimLandObjects(); |
134 | } | 118 | } |
135 | 119 | ||
136 | #endregion | 120 | #endregion |
137 | 121 | ||
138 | #region Parcel Add/Remove/Get/Create | 122 | #region Parcel Add/Remove/Get/Create |
139 | 123 | ||
124 | public void updateLandObject(int local_id, LandData newData) | ||
125 | { | ||
126 | if (landList.ContainsKey(local_id)) | ||
127 | { | ||
128 | landList[local_id].landData = newData.Copy(); | ||
129 | m_scene.EventManager.TriggerLandObjectUpdated((uint) local_id, landList[local_id]); | ||
130 | } | ||
131 | } | ||
132 | |||
133 | /// <summary> | ||
134 | /// Get the land object at the specified point | ||
135 | /// </summary> | ||
136 | /// <param name="x">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> | ||
138 | /// <returns>Land object at the point supplied</returns> | ||
139 | public ILandObject getLandObject(float x_float, float y_float) | ||
140 | { | ||
141 | int x; | ||
142 | int y; | ||
143 | |||
144 | try | ||
145 | { | ||
146 | x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / Convert.ToDouble(4.0))); | ||
147 | y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / Convert.ToDouble(4.0))); | ||
148 | } | ||
149 | catch (OverflowException) | ||
150 | { | ||
151 | return null; | ||
152 | } | ||
153 | |||
154 | if (x >= 64 || y >= 64 || x < 0 || y < 0) | ||
155 | { | ||
156 | return null; | ||
157 | } | ||
158 | else | ||
159 | { | ||
160 | return landList[landIDList[x, y]]; | ||
161 | } | ||
162 | } | ||
163 | |||
164 | public ILandObject getLandObject(int x, int y) | ||
165 | { | ||
166 | if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0) | ||
167 | { | ||
168 | // These exceptions here will cause a lot of complaints from the users specifically because | ||
169 | // they happen every time at border crossings | ||
170 | throw new Exception("Error: Parcel not found at point " + x + ", " + y); | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | return landList[landIDList[x / 4, y / 4]]; | ||
175 | } | ||
176 | } | ||
177 | |||
140 | /// <summary> | 178 | /// <summary> |
141 | /// Creates a basic Parcel object without an owner (a zeroed key) | 179 | /// Creates a basic Parcel object without an owner (a zeroed key) |
142 | /// </summary> | 180 | /// </summary> |
@@ -154,7 +192,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
154 | { | 192 | { |
155 | lastLandLocalID++; | 193 | lastLandLocalID++; |
156 | new_land.landData.localID = lastLandLocalID; | 194 | new_land.landData.localID = lastLandLocalID; |
157 | landList.Add(lastLandLocalID, (LandObject)new_land.Copy()); | 195 | landList.Add(lastLandLocalID, (LandObject) new_land.Copy()); |
158 | 196 | ||
159 | 197 | ||
160 | bool[,] landBitmap = new_land.getLandBitmap(); | 198 | bool[,] landBitmap = new_land.getLandBitmap(); |
@@ -197,15 +235,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
197 | landList.Remove(local_id); | 235 | landList.Remove(local_id); |
198 | } | 236 | } |
199 | 237 | ||
200 | public void updateLandObject(int local_id, LandData newData) | ||
201 | { | ||
202 | if (landList.ContainsKey(local_id)) | ||
203 | { | ||
204 | landList[local_id].landData = newData.Copy(); | ||
205 | m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landList[local_id]); | ||
206 | } | ||
207 | } | ||
208 | |||
209 | private void performFinalLandJoin(ILandObject master, ILandObject slave) | 238 | private void performFinalLandJoin(ILandObject master, ILandObject slave) |
210 | { | 239 | { |
211 | int x, y; | 240 | int x, y; |
@@ -225,66 +254,113 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
225 | updateLandObject(master.landData.localID, master.landData); | 254 | updateLandObject(master.landData.localID, master.landData); |
226 | } | 255 | } |
227 | 256 | ||
228 | /// <summary> | 257 | public ILandObject getLandObject(int parcelLocalID) |
229 | /// Get the land object at the specified point | ||
230 | /// </summary> | ||
231 | /// <param name="x">Value between 0 - 256 on the x axis of the point</param> | ||
232 | /// <param name="y">Value between 0 - 256 on the y axis of the point</param> | ||
233 | /// <returns>Land object at the point supplied</returns> | ||
234 | public ILandObject getLandObject(float x_float, float y_float) | ||
235 | { | 258 | { |
236 | int x; | 259 | lock (landList) |
237 | int y; | ||
238 | |||
239 | try | ||
240 | { | 260 | { |
241 | x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / Convert.ToDouble(4.0))); | 261 | if (landList.ContainsKey(parcelLocalID)) |
242 | y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / Convert.ToDouble(4.0))); | 262 | { |
263 | return landList[parcelLocalID]; | ||
264 | } | ||
243 | } | 265 | } |
244 | catch (OverflowException) | 266 | return null; |
267 | } | ||
268 | |||
269 | #endregion | ||
270 | |||
271 | #region Parcel Modification | ||
272 | |||
273 | public void resetAllLandPrimCounts() | ||
274 | { | ||
275 | foreach (LandObject p in landList.Values) | ||
245 | { | 276 | { |
246 | return null; | 277 | p.resetLandPrimCounts(); |
247 | } | 278 | } |
279 | } | ||
248 | 280 | ||
249 | if (x >= 64 || y >= 64 || x < 0 || y < 0) | 281 | public void setPrimsTainted() |
282 | { | ||
283 | landPrimCountTainted = true; | ||
284 | } | ||
285 | |||
286 | public bool isLandPrimCountTainted() | ||
287 | { | ||
288 | return landPrimCountTainted; | ||
289 | } | ||
290 | |||
291 | public void addPrimToLandPrimCounts(SceneObjectGroup obj) | ||
292 | { | ||
293 | LLVector3 position = obj.AbsolutePosition; | ||
294 | ILandObject landUnderPrim = getLandObject(position.X, position.Y); | ||
295 | if (landUnderPrim != null) | ||
250 | { | 296 | { |
251 | return null; | 297 | landUnderPrim.addPrimToCount(obj); |
252 | } | 298 | } |
253 | else | 299 | } |
300 | |||
301 | public void removePrimFromLandPrimCounts(SceneObjectGroup obj) | ||
302 | { | ||
303 | foreach (LandObject p in landList.Values) | ||
254 | { | 304 | { |
255 | return landList[landIDList[x, y]]; | 305 | p.removePrimFromCount(obj); |
256 | } | 306 | } |
257 | } | 307 | } |
258 | 308 | ||
259 | public ILandObject getLandObject(int parcelLocalID) | 309 | public void finalizeLandPrimCountUpdate() |
260 | { | 310 | { |
261 | lock (landList) | 311 | //Get Simwide prim count for owner |
312 | Dictionary<LLUUID, List<LandObject>> landOwnersAndParcels = new Dictionary<LLUUID, List<LandObject>>(); | ||
313 | foreach (LandObject p in landList.Values) | ||
262 | { | 314 | { |
263 | if (landList.ContainsKey(parcelLocalID)) | 315 | if (!landOwnersAndParcels.ContainsKey(p.landData.ownerID)) |
264 | { | 316 | { |
265 | return landList[parcelLocalID]; | 317 | List<LandObject> tempList = new List<LandObject>(); |
318 | tempList.Add(p); | ||
319 | landOwnersAndParcels.Add(p.landData.ownerID, tempList); | ||
320 | } | ||
321 | else | ||
322 | { | ||
323 | landOwnersAndParcels[p.landData.ownerID].Add(p); | ||
266 | } | 324 | } |
267 | } | 325 | } |
268 | return null; | ||
269 | } | ||
270 | 326 | ||
271 | public ILandObject getLandObject(int x, int y) | 327 | foreach (LLUUID owner in landOwnersAndParcels.Keys) |
272 | { | ||
273 | if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0) | ||
274 | { | 328 | { |
275 | // These exceptions here will cause a lot of complaints from the users specifically because | 329 | int simArea = 0; |
276 | // they happen every time at border crossings | 330 | int simPrims = 0; |
277 | throw new Exception("Error: Parcel not found at point " + x + ", " + y); | 331 | foreach (LandObject p in landOwnersAndParcels[owner]) |
332 | { | ||
333 | simArea += p.landData.area; | ||
334 | simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims + | ||
335 | p.landData.selectedPrims; | ||
336 | } | ||
337 | |||
338 | foreach (LandObject p in landOwnersAndParcels[owner]) | ||
339 | { | ||
340 | p.landData.simwideArea = simArea; | ||
341 | p.landData.simwidePrims = simPrims; | ||
342 | } | ||
278 | } | 343 | } |
279 | else | 344 | } |
345 | |||
346 | public void updateLandPrimCounts() | ||
347 | { | ||
348 | foreach (EntityBase obj in m_scene.Entities.Values) | ||
280 | { | 349 | { |
281 | return landList[landIDList[x / 4, y / 4]]; | 350 | if (obj is SceneObjectGroup) |
351 | { | ||
352 | m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj); | ||
353 | } | ||
282 | } | 354 | } |
283 | } | 355 | } |
284 | 356 | ||
285 | #endregion | 357 | public void performParcelPrimCountUpdate() |
286 | 358 | { | |
287 | #region Parcel Modification | 359 | resetAllLandPrimCounts(); |
360 | m_scene.EventManager.TriggerParcelPrimCountUpdate(); | ||
361 | finalizeLandPrimCountUpdate(); | ||
362 | landPrimCountTainted = false; | ||
363 | } | ||
288 | 364 | ||
289 | /// <summary> | 365 | /// <summary> |
290 | /// Subdivides a piece of land | 366 | /// Subdivides a piece of land |
@@ -435,97 +511,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
435 | return true; | 511 | return true; |
436 | } | 512 | } |
437 | 513 | ||
438 | public void resetAllLandPrimCounts() | ||
439 | { | ||
440 | foreach (LandObject p in landList.Values) | ||
441 | { | ||
442 | p.resetLandPrimCounts(); | ||
443 | } | ||
444 | } | ||
445 | |||
446 | public void setPrimsTainted() | ||
447 | { | ||
448 | landPrimCountTainted = true; | ||
449 | } | ||
450 | |||
451 | public bool isLandPrimCountTainted() | ||
452 | { | ||
453 | return landPrimCountTainted; | ||
454 | } | ||
455 | |||
456 | public void addPrimToLandPrimCounts(SceneObjectGroup obj) | ||
457 | { | ||
458 | LLVector3 position = obj.AbsolutePosition; | ||
459 | ILandObject landUnderPrim = getLandObject(position.X, position.Y); | ||
460 | if (landUnderPrim != null) | ||
461 | { | ||
462 | landUnderPrim.addPrimToCount(obj); | ||
463 | } | ||
464 | } | ||
465 | |||
466 | public void removePrimFromLandPrimCounts(SceneObjectGroup obj) | ||
467 | { | ||
468 | foreach (LandObject p in landList.Values) | ||
469 | { | ||
470 | p.removePrimFromCount(obj); | ||
471 | } | ||
472 | } | ||
473 | |||
474 | public void finalizeLandPrimCountUpdate() | ||
475 | { | ||
476 | //Get Simwide prim count for owner | ||
477 | Dictionary<LLUUID, List<LandObject>> landOwnersAndParcels = new Dictionary<LLUUID, List<LandObject>>(); | ||
478 | foreach (LandObject p in landList.Values) | ||
479 | { | ||
480 | if (!landOwnersAndParcels.ContainsKey(p.landData.ownerID)) | ||
481 | { | ||
482 | List<LandObject> tempList = new List<LandObject>(); | ||
483 | tempList.Add(p); | ||
484 | landOwnersAndParcels.Add(p.landData.ownerID, tempList); | ||
485 | } | ||
486 | else | ||
487 | { | ||
488 | landOwnersAndParcels[p.landData.ownerID].Add(p); | ||
489 | } | ||
490 | } | ||
491 | |||
492 | foreach (LLUUID owner in landOwnersAndParcels.Keys) | ||
493 | { | ||
494 | int simArea = 0; | ||
495 | int simPrims = 0; | ||
496 | foreach (LandObject p in landOwnersAndParcels[owner]) | ||
497 | { | ||
498 | simArea += p.landData.area; | ||
499 | simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims + | ||
500 | p.landData.selectedPrims; | ||
501 | } | ||
502 | |||
503 | foreach (LandObject p in landOwnersAndParcels[owner]) | ||
504 | { | ||
505 | p.landData.simwideArea = simArea; | ||
506 | p.landData.simwidePrims = simPrims; | ||
507 | } | ||
508 | } | ||
509 | } | ||
510 | |||
511 | public void updateLandPrimCounts() | ||
512 | { | ||
513 | foreach (EntityBase obj in m_scene.Entities.Values) | ||
514 | { | ||
515 | if (obj is SceneObjectGroup) | ||
516 | { | ||
517 | m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup)obj); | ||
518 | } | ||
519 | } | ||
520 | } | ||
521 | |||
522 | public void performParcelPrimCountUpdate() | ||
523 | { | ||
524 | resetAllLandPrimCounts(); | ||
525 | m_scene.EventManager.TriggerParcelPrimCountUpdate(); | ||
526 | finalizeLandPrimCountUpdate(); | ||
527 | landPrimCountTainted = false; | ||
528 | } | ||
529 | #endregion | 514 | #endregion |
530 | 515 | ||
531 | #region Parcel Updating | 516 | #region Parcel Updating |
@@ -547,7 +532,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
547 | { | 532 | { |
548 | for (x = 0; x < 64; x++) | 533 | for (x = 0; x < 64; x++) |
549 | { | 534 | { |
550 | byte tempByte = (byte)0; //This represents the byte for the current 4x4 | 535 | byte tempByte = (byte) 0; //This represents the byte for the current 4x4 |
551 | ILandObject currentParcelBlock = null; | 536 | ILandObject currentParcelBlock = null; |
552 | 537 | ||
553 | try | 538 | try |
@@ -623,10 +608,10 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
623 | if (byteArrayCount >= LAND_BLOCKS_PER_PACKET) | 608 | if (byteArrayCount >= LAND_BLOCKS_PER_PACKET) |
624 | { | 609 | { |
625 | byteArrayCount = 0; | 610 | byteArrayCount = 0; |
626 | packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay); | 611 | packet = (ParcelOverlayPacket) PacketPool.Instance.GetPacket(PacketType.ParcelOverlay); |
627 | packet.ParcelData.Data = byteArray; | 612 | packet.ParcelData.Data = byteArray; |
628 | packet.ParcelData.SequenceID = sequenceID; | 613 | packet.ParcelData.SequenceID = sequenceID; |
629 | remote_client.OutPacket((Packet)packet, ThrottleOutPacketType.Task); | 614 | remote_client.OutPacket((Packet) packet, ThrottleOutPacketType.Task); |
630 | sequenceID++; | 615 | sequenceID++; |
631 | byteArray = new byte[LAND_BLOCKS_PER_PACKET]; | 616 | byteArray = new byte[LAND_BLOCKS_PER_PACKET]; |
632 | } | 617 | } |
@@ -652,7 +637,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
652 | { | 637 | { |
653 | for (y = 0; y < inc_y; y++) | 638 | for (y = 0; y < inc_y; y++) |
654 | { | 639 | { |
655 | |||
656 | ILandObject currentParcel = null; | 640 | ILandObject currentParcel = null; |
657 | try | 641 | try |
658 | { | 642 | { |
@@ -693,7 +677,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
693 | if (landList.ContainsKey(packet.ParcelData.LocalID)) | 677 | if (landList.ContainsKey(packet.ParcelData.LocalID)) |
694 | { | 678 | { |
695 | landList[packet.ParcelData.LocalID].updateLandProperties(packet, remote_client); | 679 | landList[packet.ParcelData.LocalID].updateLandProperties(packet, remote_client); |
696 | |||
697 | } | 680 | } |
698 | } | 681 | } |
699 | 682 | ||
@@ -719,6 +702,14 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
719 | 702 | ||
720 | #endregion | 703 | #endregion |
721 | 704 | ||
705 | #region ILandChannel Members | ||
706 | |||
707 | public bool allowedForcefulBans | ||
708 | { | ||
709 | get { return m_allowedForcefulBans; } | ||
710 | set { m_allowedForcefulBans = value; } | ||
711 | } | ||
712 | |||
722 | /// <summary> | 713 | /// <summary> |
723 | /// Resets the sim to the default land object (full sim piece of land owned by the default user) | 714 | /// Resets the sim to the default land object (full sim piece of land owned by the default user) |
724 | /// </summary> | 715 | /// </summary> |
@@ -731,7 +722,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
731 | 722 | ||
732 | ILandObject fullSimParcel = new LandObject(LLUUID.Zero, false, m_scene); | 723 | ILandObject fullSimParcel = new LandObject(LLUUID.Zero, false, m_scene); |
733 | 724 | ||
734 | fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); | 725 | fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize)); |
735 | fullSimParcel.landData.ownerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; | 726 | fullSimParcel.landData.ownerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; |
736 | 727 | ||
737 | addLandObject(fullSimParcel); | 728 | addLandObject(fullSimParcel); |
@@ -816,18 +807,17 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
816 | { | 807 | { |
817 | if (presence.UUID == avatar.AgentId) | 808 | if (presence.UUID == avatar.AgentId) |
818 | { | 809 | { |
819 | |||
820 | List<ILandObject> checkLandParcels = parcelsNearPoint(presence.AbsolutePosition); | 810 | List<ILandObject> checkLandParcels = parcelsNearPoint(presence.AbsolutePosition); |
821 | foreach (ILandObject checkBan in checkLandParcels) | 811 | foreach (ILandObject checkBan in checkLandParcels) |
822 | { | 812 | { |
823 | if (checkBan.isBannedFromLand(avatar.AgentId)) | 813 | if (checkBan.isBannedFromLand(avatar.AgentId)) |
824 | { | 814 | { |
825 | checkBan.sendLandProperties(-30000, false, (int)ParcelManager.ParcelResult.Single, avatar); | 815 | checkBan.sendLandProperties(-30000, false, (int) ParcelManager.ParcelResult.Single, avatar); |
826 | return; //Only send one | 816 | return; //Only send one |
827 | } | 817 | } |
828 | else if (checkBan.isRestrictedFromLand(avatar.AgentId)) | 818 | else if (checkBan.isRestrictedFromLand(avatar.AgentId)) |
829 | { | 819 | { |
830 | checkBan.sendLandProperties(-40000, false, (int)ParcelManager.ParcelResult.Single, avatar); | 820 | checkBan.sendLandProperties(-40000, false, (int) ParcelManager.ParcelResult.Single, avatar); |
831 | return; //Only send one | 821 | return; //Only send one |
832 | } | 822 | } |
833 | } | 823 | } |
@@ -841,8 +831,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
841 | ILandObject over = null; | 831 | ILandObject over = null; |
842 | try | 832 | try |
843 | { | 833 | { |
844 | over = getLandObject((int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), | 834 | over = getLandObject((int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), |
845 | (int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); | 835 | (int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); |
846 | } | 836 | } |
847 | catch (Exception) | 837 | catch (Exception) |
848 | { | 838 | { |
@@ -873,11 +863,12 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
873 | } | 863 | } |
874 | } | 864 | } |
875 | } | 865 | } |
866 | |||
876 | public void sendLandUpdate(ScenePresence avatar) | 867 | public void sendLandUpdate(ScenePresence avatar) |
877 | { | 868 | { |
878 | sendLandUpdate(avatar, false); | 869 | sendLandUpdate(avatar, false); |
879 | |||
880 | } | 870 | } |
871 | |||
881 | public void handleSignificantClientMovement(IClientAPI remote_client) | 872 | public void handleSignificantClientMovement(IClientAPI remote_client) |
882 | { | 873 | { |
883 | ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId); | 874 | ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId); |
@@ -949,6 +940,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
949 | } | 940 | } |
950 | } | 941 | } |
951 | 942 | ||
943 | #endregion | ||
944 | |||
952 | // If the economy has been validated by the economy module, | 945 | // If the economy has been validated by the economy module, |
953 | // and land has been validated as well, this method transfers | 946 | // and land has been validated as well, this method transfers |
954 | // the land ownership | 947 | // the land ownership |
@@ -961,7 +954,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
961 | { | 954 | { |
962 | if (landList.ContainsKey(e.parcelLocalID)) | 955 | if (landList.ContainsKey(e.parcelLocalID)) |
963 | { | 956 | { |
964 | landList[e.parcelLocalID].updateLandSold(e.agentId, e.groupId, e.groupOwned, (uint)e.transactionID, e.parcelPrice, e.parcelArea); | 957 | landList[e.parcelLocalID].updateLandSold(e.agentId, e.groupId, e.groupOwned, (uint) e.transactionID, e.parcelPrice, e.parcelArea); |
965 | return; | 958 | return; |
966 | } | 959 | } |
967 | } | 960 | } |
@@ -989,17 +982,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
989 | LLUUID AuthorizedID = lob.landData.authBuyerID; | 982 | LLUUID AuthorizedID = lob.landData.authBuyerID; |
990 | int saleprice = lob.landData.salePrice; | 983 | int saleprice = lob.landData.salePrice; |
991 | LLUUID pOwnerID = lob.landData.ownerID; | 984 | LLUUID pOwnerID = lob.landData.ownerID; |
992 | 985 | ||
993 | bool landforsale = ((lob.landData.landFlags & (uint)(Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects)) != 0); | 986 | bool landforsale = ((lob.landData.landFlags & |
987 | (uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects)) != 0); | ||
994 | if ((AuthorizedID == LLUUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice && landforsale) | 988 | if ((AuthorizedID == LLUUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice && landforsale) |
995 | { | 989 | { |
996 | lock (e) | 990 | lock (e) |
997 | { | 991 | { |
998 | e.parcelOwnerID = pOwnerID; | 992 | e.parcelOwnerID = pOwnerID; |
999 | e.landValidated = true; | 993 | e.landValidated = true; |
1000 | |||
1001 | } | 994 | } |
1002 | |||
1003 | } | 995 | } |
1004 | } | 996 | } |
1005 | } | 997 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs index c5ffdca..3f09bd5 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs | |||
@@ -27,7 +27,6 @@ | |||
27 | 27 | ||
28 | using Nini.Config; | 28 | using Nini.Config; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | using OpenSim.Region.Environment.Modules.World.Land; | ||
31 | using OpenSim.Region.Environment.Scenes; | 30 | using OpenSim.Region.Environment.Scenes; |
32 | 31 | ||
33 | namespace OpenSim.Region.Environment.Modules.World.Land | 32 | namespace OpenSim.Region.Environment.Modules.World.Land |
@@ -43,7 +42,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
43 | { | 42 | { |
44 | m_scene = scene; | 43 | m_scene = scene; |
45 | landChannel = new LandChannel(scene); | 44 | landChannel = new LandChannel(scene); |
46 | 45 | ||
47 | m_scene.EventManager.OnParcelPrimCountAdd += landChannel.addPrimToLandPrimCounts; | 46 | m_scene.EventManager.OnParcelPrimCountAdd += landChannel.addPrimToLandPrimCounts; |
48 | m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts; | 47 | m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts; |
49 | m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel); | 48 | m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel); |
@@ -53,18 +52,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
53 | 52 | ||
54 | lock (m_scene) | 53 | lock (m_scene) |
55 | { | 54 | { |
56 | m_scene.LandChannel = (ILandChannel)landChannel; | 55 | m_scene.LandChannel = (ILandChannel) landChannel; |
57 | } | 56 | } |
58 | } | 57 | } |
59 | 58 | ||
60 | public void PostInitialise() | 59 | public void PostInitialise() |
61 | { | 60 | { |
62 | |||
63 | } | 61 | } |
64 | 62 | ||
65 | public void Close() | 63 | public void Close() |
66 | { | 64 | { |
67 | |||
68 | } | 65 | } |
69 | 66 | ||
70 | public string Name | 67 | public string Name |
@@ -77,10 +74,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
77 | get { return false; } | 74 | get { return false; } |
78 | } | 75 | } |
79 | 76 | ||
80 | |||
81 | |||
82 | |||
83 | |||
84 | #endregion | 77 | #endregion |
85 | } | 78 | } |
86 | } \ No newline at end of file | 79 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs index 693c55d..368e113 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs | |||
@@ -33,7 +33,6 @@ using libsecondlife.Packets; | |||
33 | using log4net; | 33 | using log4net; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Region.Environment.Interfaces; | 35 | using OpenSim.Region.Environment.Interfaces; |
36 | using OpenSim.Region.Environment.Modules.World.Land; | ||
37 | using OpenSim.Region.Environment.Scenes; | 36 | using OpenSim.Region.Environment.Scenes; |
38 | 37 | ||
39 | namespace OpenSim.Region.Environment.Modules.World.Land | 38 | namespace OpenSim.Region.Environment.Modules.World.Land |
@@ -46,23 +45,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
46 | #region Member Variables | 45 | #region Member Variables |
47 | 46 | ||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | private bool[,] m_landBitmap = new bool[64,64]; | ||
49 | 49 | ||
50 | protected LandData m_landData = new LandData(); | 50 | protected LandData m_landData = new LandData(); |
51 | protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); | ||
52 | protected Scene m_scene; | 51 | protected Scene m_scene; |
53 | 52 | protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); | |
54 | private bool[,] m_landBitmap = new bool[64,64]; | ||
55 | 53 | ||
56 | public bool[,] landBitmap | 54 | public bool[,] landBitmap |
57 | { | 55 | { |
58 | get | 56 | get { return m_landBitmap; } |
59 | { | 57 | set { m_landBitmap = value; } |
60 | return m_landBitmap; | ||
61 | } | ||
62 | set | ||
63 | { | ||
64 | m_landBitmap = value; | ||
65 | } | ||
66 | } | 58 | } |
67 | 59 | ||
68 | #endregion | 60 | #endregion |
@@ -71,25 +63,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
71 | 63 | ||
72 | public LandData landData | 64 | public LandData landData |
73 | { | 65 | { |
74 | get | 66 | get { return m_landData; } |
75 | { | ||
76 | return m_landData; | ||
77 | } | ||
78 | 67 | ||
79 | set | 68 | set { m_landData = value; } |
80 | { | ||
81 | m_landData = value; | ||
82 | } | ||
83 | } | 69 | } |
84 | 70 | ||
85 | public LLUUID regionUUID | 71 | public LLUUID regionUUID |
86 | { | 72 | { |
87 | get { return m_scene.RegionInfo.RegionID; } | 73 | get { return m_scene.RegionInfo.RegionID; } |
88 | } | 74 | } |
89 | 75 | ||
90 | #endregion | ||
91 | |||
92 | |||
93 | #region Constructors | 76 | #region Constructors |
94 | 77 | ||
95 | public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene) | 78 | public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene) |
@@ -115,7 +98,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
115 | { | 98 | { |
116 | if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize) | 99 | if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize) |
117 | { | 100 | { |
118 | return (landBitmap[x/4, y/4] == true); | 101 | return (landBitmap[x / 4, y / 4] == true); |
119 | } | 102 | } |
120 | else | 103 | else |
121 | { | 104 | { |
@@ -149,7 +132,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
149 | { | 132 | { |
150 | ParcelPropertiesPacket updatePacket = (ParcelPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ParcelProperties); | 133 | ParcelPropertiesPacket updatePacket = (ParcelPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ParcelProperties); |
151 | // TODO: don't create new blocks if recycling an old packet | 134 | // TODO: don't create new blocks if recycling an old packet |
152 | 135 | ||
153 | updatePacket.ParcelData.AABBMax = landData.AABBMax; | 136 | updatePacket.ParcelData.AABBMax = landData.AABBMax; |
154 | updatePacket.ParcelData.AABBMin = landData.AABBMin; | 137 | updatePacket.ParcelData.AABBMin = landData.AABBMin; |
155 | updatePacket.ParcelData.Area = landData.area; | 138 | updatePacket.ParcelData.Area = landData.area; |
@@ -171,7 +154,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
171 | { | 154 | { |
172 | updatePacket.ParcelData.MaxPrims = | 155 | updatePacket.ParcelData.MaxPrims = |
173 | Convert.ToInt32( | 156 | Convert.ToInt32( |
174 | Math.Round((Convert.ToDecimal(landData.area)/Convert.ToDecimal(65536))*m_scene.objectCapacity* | 157 | Math.Round((Convert.ToDecimal(landData.area) / Convert.ToDecimal(65536)) * m_scene.objectCapacity * |
175 | Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor))); | 158 | Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor))); |
176 | } | 159 | } |
177 | else | 160 | else |
@@ -193,7 +176,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
193 | updatePacket.ParcelData.PassHours = landData.passHours; | 176 | updatePacket.ParcelData.PassHours = landData.passHours; |
194 | updatePacket.ParcelData.PassPrice = landData.passPrice; | 177 | updatePacket.ParcelData.PassPrice = landData.passPrice; |
195 | updatePacket.ParcelData.PublicCount = 0; //unemplemented | 178 | updatePacket.ParcelData.PublicCount = 0; //unemplemented |
196 | 179 | ||
197 | uint regionFlags = (uint) m_scene.RegionInfo.EstateSettings.regionFlags; | 180 | uint regionFlags = (uint) m_scene.RegionInfo.EstateSettings.regionFlags; |
198 | updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint) Simulator.RegionFlags.DenyAnonymous) > | 181 | updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint) Simulator.RegionFlags.DenyAnonymous) > |
199 | 0); | 182 | 0); |
@@ -255,12 +238,13 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
255 | newData.snapshotID = packet.ParcelData.SnapshotID; | 238 | newData.snapshotID = packet.ParcelData.SnapshotID; |
256 | newData.userLocation = packet.ParcelData.UserLocation; | 239 | newData.userLocation = packet.ParcelData.UserLocation; |
257 | newData.userLookAt = packet.ParcelData.UserLookAt; | 240 | newData.userLookAt = packet.ParcelData.UserLookAt; |
258 | 241 | ||
259 | m_scene.LandChannel.updateLandObject(landData.localID, newData); | 242 | m_scene.LandChannel.updateLandObject(landData.localID, newData); |
260 | 243 | ||
261 | sendLandUpdateToAvatarsOverMe(); | 244 | sendLandUpdateToAvatarsOverMe(); |
262 | } | 245 | } |
263 | } | 246 | } |
247 | |||
264 | public void updateLandSold(LLUUID avatarID, LLUUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area) | 248 | public void updateLandSold(LLUUID avatarID, LLUUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area) |
265 | { | 249 | { |
266 | LandData newData = landData.Copy(); | 250 | LandData newData = landData.Copy(); |
@@ -272,7 +256,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
272 | newData.claimPrice = claimprice; | 256 | newData.claimPrice = claimprice; |
273 | newData.salePrice = 0; | 257 | newData.salePrice = 0; |
274 | newData.authBuyerID = LLUUID.Zero; | 258 | newData.authBuyerID = LLUUID.Zero; |
275 | newData.landFlags &= ~(uint)(Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects); | 259 | newData.landFlags &= ~(uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects); |
276 | m_scene.LandChannel.updateLandObject(landData.localID, newData); | 260 | m_scene.LandChannel.updateLandObject(landData.localID, newData); |
277 | 261 | ||
278 | sendLandUpdateToAvatarsOverMe(); | 262 | sendLandUpdateToAvatarsOverMe(); |
@@ -339,12 +323,13 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
339 | try | 323 | try |
340 | { | 324 | { |
341 | over = | 325 | over = |
342 | m_scene.LandChannel.getLandObject((int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.X))), | 326 | m_scene.LandChannel.getLandObject((int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.X))), |
343 | (int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.Y)))); | 327 | (int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.Y)))); |
344 | } | 328 | } |
345 | catch (Exception) | 329 | catch (Exception) |
346 | { | 330 | { |
347 | m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + Math.Round(avatars[i].AbsolutePosition.Y)); | 331 | m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + |
332 | Math.Round(avatars[i].AbsolutePosition.Y)); | ||
348 | } | 333 | } |
349 | 334 | ||
350 | if (over != null) | 335 | if (over != null) |
@@ -463,6 +448,25 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
463 | 448 | ||
464 | #region Update Functions | 449 | #region Update Functions |
465 | 450 | ||
451 | public void updateLandBitmapByteArray() | ||
452 | { | ||
453 | landData.landBitmapByteArray = convertLandBitmapToBytes(); | ||
454 | } | ||
455 | |||
456 | /// <summary> | ||
457 | /// Update all settings in land such as area, bitmap byte array, etc | ||
458 | /// </summary> | ||
459 | public void forceUpdateLandInfo() | ||
460 | { | ||
461 | updateAABBAndAreaValues(); | ||
462 | updateLandBitmapByteArray(); | ||
463 | } | ||
464 | |||
465 | public void setLandBitmapFromByteArray() | ||
466 | { | ||
467 | landBitmap = convertBytesToLandBitmap(); | ||
468 | } | ||
469 | |||
466 | /// <summary> | 470 | /// <summary> |
467 | /// Updates the AABBMin and AABBMax values after area/shape modification of the land object | 471 | /// Updates the AABBMin and AABBMax values after area/shape modification of the land object |
468 | /// </summary> | 472 | /// </summary> |
@@ -495,8 +499,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
495 | if (ty > 255) | 499 | if (ty > 255) |
496 | ty = 255; | 500 | ty = 255; |
497 | landData.AABBMin = | 501 | landData.AABBMin = |
498 | new LLVector3((float)(min_x * 4), (float)(min_y * 4), | 502 | new LLVector3((float) (min_x * 4), (float) (min_y * 4), |
499 | (float)m_scene.Heightmap[tx, ty]); | 503 | (float) m_scene.Heightmap[tx, ty]); |
500 | 504 | ||
501 | tx = max_x * 4; | 505 | tx = max_x * 4; |
502 | if (tx > 255) | 506 | if (tx > 255) |
@@ -505,30 +509,11 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
505 | if (ty > 255) | 509 | if (ty > 255) |
506 | ty = 255; | 510 | ty = 255; |
507 | landData.AABBMax = | 511 | landData.AABBMax = |
508 | new LLVector3((float)(max_x * 4), (float)(max_y * 4), | 512 | new LLVector3((float) (max_x * 4), (float) (max_y * 4), |
509 | (float)m_scene.Heightmap[tx, ty]); | 513 | (float) m_scene.Heightmap[tx, ty]); |
510 | landData.area = tempArea; | 514 | landData.area = tempArea; |
511 | } | 515 | } |
512 | 516 | ||
513 | public void updateLandBitmapByteArray() | ||
514 | { | ||
515 | landData.landBitmapByteArray = convertLandBitmapToBytes(); | ||
516 | } | ||
517 | |||
518 | /// <summary> | ||
519 | /// Update all settings in land such as area, bitmap byte array, etc | ||
520 | /// </summary> | ||
521 | public void forceUpdateLandInfo() | ||
522 | { | ||
523 | updateAABBAndAreaValues(); | ||
524 | updateLandBitmapByteArray(); | ||
525 | } | ||
526 | |||
527 | public void setLandBitmapFromByteArray() | ||
528 | { | ||
529 | landBitmap = convertBytesToLandBitmap(); | ||
530 | } | ||
531 | |||
532 | #endregion | 517 | #endregion |
533 | 518 | ||
534 | #region Land Bitmap Functions | 519 | #region Land Bitmap Functions |
@@ -562,63 +547,12 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
562 | } | 547 | } |
563 | 548 | ||
564 | /// <summary> | 549 | /// <summary> |
565 | /// Converts the land bitmap to a packet friendly byte array | ||
566 | /// </summary> | ||
567 | /// <returns></returns> | ||
568 | private byte[] convertLandBitmapToBytes() | ||
569 | { | ||
570 | byte[] tempConvertArr = new byte[512]; | ||
571 | byte tempByte = 0; | ||
572 | int x, y, i, byteNum = 0; | ||
573 | i = 0; | ||
574 | for (y = 0; y < 64; y++) | ||
575 | { | ||
576 | for (x = 0; x < 64; x++) | ||
577 | { | ||
578 | tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++%8)); | ||
579 | if (i%8 == 0) | ||
580 | { | ||
581 | tempConvertArr[byteNum] = tempByte; | ||
582 | tempByte = (byte) 0; | ||
583 | i = 0; | ||
584 | byteNum++; | ||
585 | } | ||
586 | } | ||
587 | } | ||
588 | return tempConvertArr; | ||
589 | } | ||
590 | |||
591 | private bool[,] convertBytesToLandBitmap() | ||
592 | { | ||
593 | bool[,] tempConvertMap = new bool[64,64]; | ||
594 | tempConvertMap.Initialize(); | ||
595 | byte tempByte = 0; | ||
596 | int x = 0, y = 0, i = 0, bitNum = 0; | ||
597 | for (i = 0; i < 512; i++) | ||
598 | { | ||
599 | tempByte = landData.landBitmapByteArray[i]; | ||
600 | for (bitNum = 0; bitNum < 8; bitNum++) | ||
601 | { | ||
602 | bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1); | ||
603 | tempConvertMap[x, y] = bit; | ||
604 | x++; | ||
605 | if (x > 63) | ||
606 | { | ||
607 | x = 0; | ||
608 | y++; | ||
609 | } | ||
610 | } | ||
611 | } | ||
612 | return tempConvertMap; | ||
613 | } | ||
614 | |||
615 | /// <summary> | ||
616 | /// Full sim land object creation | 550 | /// Full sim land object creation |
617 | /// </summary> | 551 | /// </summary> |
618 | /// <returns></returns> | 552 | /// <returns></returns> |
619 | public bool[,] basicFullRegionLandBitmap() | 553 | public bool[,] basicFullRegionLandBitmap() |
620 | { | 554 | { |
621 | return getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize); | 555 | return getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize); |
622 | } | 556 | } |
623 | 557 | ||
624 | /// <summary> | 558 | /// <summary> |
@@ -662,8 +596,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
662 | { | 596 | { |
663 | for (x = 0; x < 64; x++) | 597 | for (x = 0; x < 64; x++) |
664 | { | 598 | { |
665 | if (x >= start_x/4 && x < end_x/4 | 599 | if (x >= start_x / 4 && x < end_x / 4 |
666 | && y >= start_y/4 && y < end_y/4) | 600 | && y >= start_y / 4 && y < end_y / 4) |
667 | { | 601 | { |
668 | land_bitmap[x, y] = set_value; | 602 | land_bitmap[x, y] = set_value; |
669 | } | 603 | } |
@@ -705,6 +639,57 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
705 | return bitmap_base; | 639 | return bitmap_base; |
706 | } | 640 | } |
707 | 641 | ||
642 | /// <summary> | ||
643 | /// Converts the land bitmap to a packet friendly byte array | ||
644 | /// </summary> | ||
645 | /// <returns></returns> | ||
646 | private byte[] convertLandBitmapToBytes() | ||
647 | { | ||
648 | byte[] tempConvertArr = new byte[512]; | ||
649 | byte tempByte = 0; | ||
650 | int x, y, i, byteNum = 0; | ||
651 | i = 0; | ||
652 | for (y = 0; y < 64; y++) | ||
653 | { | ||
654 | for (x = 0; x < 64; x++) | ||
655 | { | ||
656 | tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++ % 8)); | ||
657 | if (i % 8 == 0) | ||
658 | { | ||
659 | tempConvertArr[byteNum] = tempByte; | ||
660 | tempByte = (byte) 0; | ||
661 | i = 0; | ||
662 | byteNum++; | ||
663 | } | ||
664 | } | ||
665 | } | ||
666 | return tempConvertArr; | ||
667 | } | ||
668 | |||
669 | private bool[,] convertBytesToLandBitmap() | ||
670 | { | ||
671 | bool[,] tempConvertMap = new bool[64,64]; | ||
672 | tempConvertMap.Initialize(); | ||
673 | byte tempByte = 0; | ||
674 | int x = 0, y = 0, i = 0, bitNum = 0; | ||
675 | for (i = 0; i < 512; i++) | ||
676 | { | ||
677 | tempByte = landData.landBitmapByteArray[i]; | ||
678 | for (bitNum = 0; bitNum < 8; bitNum++) | ||
679 | { | ||
680 | bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1); | ||
681 | tempConvertMap[x, y] = bit; | ||
682 | x++; | ||
683 | if (x > 63) | ||
684 | { | ||
685 | x = 0; | ||
686 | y++; | ||
687 | } | ||
688 | } | ||
689 | } | ||
690 | return tempConvertMap; | ||
691 | } | ||
692 | |||
708 | #endregion | 693 | #endregion |
709 | 694 | ||
710 | #region Object Select and Object Owner Listing | 695 | #region Object Select and Object Owner Listing |
@@ -781,7 +766,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
781 | public void sendLandObjectOwners(IClientAPI remote_client) | 766 | public void sendLandObjectOwners(IClientAPI remote_client) |
782 | { | 767 | { |
783 | Dictionary<LLUUID, int> primCount = new Dictionary<LLUUID, int>(); | 768 | Dictionary<LLUUID, int> primCount = new Dictionary<LLUUID, int>(); |
784 | ParcelObjectOwnersReplyPacket pack | 769 | ParcelObjectOwnersReplyPacket pack |
785 | = (ParcelObjectOwnersReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply); | 770 | = (ParcelObjectOwnersReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply); |
786 | // TODO: don't create new blocks if recycling an old packet | 771 | // TODO: don't create new blocks if recycling an old packet |
787 | 772 | ||
@@ -807,21 +792,21 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
807 | m_log.Error("[LAND]: Unable to match a prim with it's owner."); | 792 | m_log.Error("[LAND]: Unable to match a prim with it's owner."); |
808 | } | 793 | } |
809 | } | 794 | } |
810 | 795 | ||
811 | int notifyCount = primCount.Count; | 796 | int notifyCount = primCount.Count; |
812 | 797 | ||
813 | if (notifyCount > 0) | 798 | if (notifyCount > 0) |
814 | { | 799 | { |
815 | if (notifyCount > 32) | 800 | if (notifyCount > 32) |
816 | { | 801 | { |
817 | m_log.InfoFormat( | 802 | m_log.InfoFormat( |
818 | "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}" | 803 | "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}" |
819 | + " - a developer might want to investigate whether this is a hard limit", 32); | 804 | + " - a developer might want to investigate whether this is a hard limit", 32); |
820 | 805 | ||
821 | notifyCount = 32; | 806 | notifyCount = 32; |
822 | } | 807 | } |
823 | 808 | ||
824 | ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock | 809 | ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock |
825 | = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount]; | 810 | = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount]; |
826 | 811 | ||
827 | int num = 0; | 812 | int num = 0; |
@@ -834,16 +819,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
834 | dataBlock[num].OwnerID = owner; | 819 | dataBlock[num].OwnerID = owner; |
835 | 820 | ||
836 | num++; | 821 | num++; |
837 | 822 | ||
838 | if (num >= notifyCount) | 823 | if (num >= notifyCount) |
839 | { | 824 | { |
840 | break; | 825 | break; |
841 | } | 826 | } |
842 | } | 827 | } |
843 | 828 | ||
844 | pack.Data = dataBlock; | 829 | pack.Data = dataBlock; |
845 | } | 830 | } |
846 | 831 | ||
847 | remote_client.OutPacket(pack, ThrottleOutPacketType.Task); | 832 | remote_client.OutPacket(pack, ThrottleOutPacketType.Task); |
848 | } | 833 | } |
849 | 834 | ||
@@ -937,7 +922,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land | |||
937 | #endregion | 922 | #endregion |
938 | 923 | ||
939 | #endregion | 924 | #endregion |
940 | |||
941 | 925 | ||
926 | #endregion | ||
942 | } | 927 | } |
943 | } \ No newline at end of file | 928 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs index c14ae57..ef90fd4 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs | |||
@@ -110,6 +110,7 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser | |||
110 | private static void CreateCompressedXmlFile(MemoryStream xmlStream, string fileName) | 110 | private static void CreateCompressedXmlFile(MemoryStream xmlStream, string fileName) |
111 | { | 111 | { |
112 | #region GZip Compressed Version | 112 | #region GZip Compressed Version |
113 | |||
113 | FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create); | 114 | FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create); |
114 | MemoryStream gzipMSStream = new MemoryStream(); | 115 | MemoryStream gzipMSStream = new MemoryStream(); |
115 | GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress); | 116 | GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress); |
@@ -117,6 +118,7 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser | |||
117 | gzipMSStream.WriteTo(objectsFileCompressed); | 118 | gzipMSStream.WriteTo(objectsFileCompressed); |
118 | objectsFileCompressed.Flush(); | 119 | objectsFileCompressed.Flush(); |
119 | objectsFileCompressed.Close(); | 120 | objectsFileCompressed.Close(); |
121 | |||
120 | #endregion | 122 | #endregion |
121 | } | 123 | } |
122 | } | 124 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs index a465a60..a12118e 100644 --- a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs | |||
@@ -39,15 +39,17 @@ namespace OpenSim.Region.Environment.Modules | |||
39 | { | 39 | { |
40 | //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 40 | //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
41 | 41 | ||
42 | private const double m_real_day = 24.0; | ||
43 | private const int m_default_frame = 100; | 42 | private const int m_default_frame = 100; |
44 | private int m_frame_mod; | 43 | private const double m_real_day = 24.0; |
45 | private double m_day_length; | 44 | private double m_day_length; |
46 | private int m_dilation; | 45 | private int m_dilation; |
47 | private int m_frame; | 46 | private int m_frame; |
48 | private long m_start; | 47 | private int m_frame_mod; |
49 | 48 | ||
50 | private Scene m_scene; | 49 | private Scene m_scene; |
50 | private long m_start; | ||
51 | |||
52 | #region IRegionModule Members | ||
51 | 53 | ||
52 | public void Initialise(Scene scene, IConfigSource config) | 54 | public void Initialise(Scene scene, IConfigSource config) |
53 | { | 55 | { |
@@ -66,7 +68,7 @@ namespace OpenSim.Region.Environment.Modules | |||
66 | m_frame_mod = m_default_frame; | 68 | m_frame_mod = m_default_frame; |
67 | } | 69 | } |
68 | 70 | ||
69 | m_dilation = (int) (m_real_day/m_day_length); | 71 | m_dilation = (int) (m_real_day / m_day_length); |
70 | m_scene = scene; | 72 | m_scene = scene; |
71 | scene.EventManager.OnFrame += SunUpdate; | 73 | scene.EventManager.OnFrame += SunUpdate; |
72 | scene.EventManager.OnNewClient += SunToClient; | 74 | scene.EventManager.OnNewClient += SunToClient; |
@@ -90,6 +92,8 @@ namespace OpenSim.Region.Environment.Modules | |||
90 | get { return false; } | 92 | get { return false; } |
91 | } | 93 | } |
92 | 94 | ||
95 | #endregion | ||
96 | |||
93 | public void SunToClient(IClientAPI client) | 97 | public void SunToClient(IClientAPI client) |
94 | { | 98 | { |
95 | client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); | 99 | client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); |
@@ -121,15 +125,15 @@ namespace OpenSim.Region.Environment.Modules | |||
121 | // ticks don't get out of hand | 125 | // ticks don't get out of hand |
122 | private double HourOfTheDay() | 126 | private double HourOfTheDay() |
123 | { | 127 | { |
124 | long m_addticks = (DateTime.Now.Ticks - m_start)*m_dilation; | 128 | long m_addticks = (DateTime.Now.Ticks - m_start) * m_dilation; |
125 | DateTime dt = new DateTime(m_start + m_addticks); | 129 | DateTime dt = new DateTime(m_start + m_addticks); |
126 | return (double) dt.Hour + ((double) dt.Minute/60.0); | 130 | return (double) dt.Hour + ((double) dt.Minute / 60.0); |
127 | } | 131 | } |
128 | 132 | ||
129 | private LLVector3 SunPos(double hour) | 133 | private LLVector3 SunPos(double hour) |
130 | { | 134 | { |
131 | // now we have our radian position | 135 | // now we have our radian position |
132 | double rad = (hour/m_real_day)*2*Math.PI - (Math.PI/2.0); | 136 | double rad = (hour / m_real_day) * 2 * Math.PI - (Math.PI / 2.0); |
133 | double z = Math.Sin(rad); | 137 | double z = Math.Sin(rad); |
134 | double x = Math.Cos(rad); | 138 | double x = Math.Cos(rad); |
135 | return new LLVector3((float) x, 0f, (float) z); | 139 | return new LLVector3((float) x, 0f, (float) z); |
@@ -192,4 +196,4 @@ namespace OpenSim.Region.Environment.Modules | |||
192 | // // OutPacket(viewertime); | 196 | // // OutPacket(viewertime); |
193 | // } | 197 | // } |
194 | } | 198 | } |
195 | } | 199 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs index 1dd923a..9c2fedc 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs | |||
@@ -27,7 +27,6 @@ | |||
27 | using System.Drawing; | 27 | using System.Drawing; |
28 | using System.Drawing.Imaging; | 28 | using System.Drawing.Imaging; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders; | ||
31 | 30 | ||
32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
33 | { | 32 | { |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs index 07072be..2925c7d 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs | |||
@@ -27,7 +27,6 @@ | |||
27 | using System.Drawing; | 27 | using System.Drawing; |
28 | using System.Drawing.Imaging; | 28 | using System.Drawing.Imaging; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders; | ||
31 | 30 | ||
32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
33 | { | 32 | { |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs index d206763..3a137ae 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs | |||
@@ -27,7 +27,6 @@ | |||
27 | using System.Drawing; | 27 | using System.Drawing; |
28 | using System.Drawing.Imaging; | 28 | using System.Drawing.Imaging; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders; | ||
31 | 30 | ||
32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 31 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
33 | { | 32 | { |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs index cf85aa4..09c3117 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs | |||
@@ -35,7 +35,6 @@ using Nini.Config; | |||
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Region.Environment.Interfaces; | 36 | using OpenSim.Region.Environment.Interfaces; |
37 | using OpenSim.Region.Environment.Modules.Framework; | 37 | using OpenSim.Region.Environment.Modules.Framework; |
38 | using OpenSim.Region.Environment.Modules.World.Terrain; | ||
39 | using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders; | 38 | using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders; |
40 | using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes; | 39 | using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes; |
41 | using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; | 40 | using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; |
@@ -79,9 +78,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain | |||
79 | private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects = | 78 | private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects = |
80 | new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>(); | 79 | new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>(); |
81 | 80 | ||
82 | private Dictionary<Location, ITerrainChannel> m_channels; | ||
83 | |||
84 | private ITerrainChannel m_channel; | 81 | private ITerrainChannel m_channel; |
82 | private Dictionary<Location, ITerrainChannel> m_channels; | ||
85 | private Dictionary<string, ITerrainEffect> m_plugineffects; | 83 | private Dictionary<string, ITerrainEffect> m_plugineffects; |
86 | private ITerrainChannel m_revert; | 84 | private ITerrainChannel m_revert; |
87 | private Scene m_scene; | 85 | private Scene m_scene; |
@@ -252,7 +250,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain | |||
252 | { | 250 | { |
253 | m_plugineffects.Add(pluginType.Name, terEffect); | 251 | m_plugineffects.Add(pluginType.Name, terEffect); |
254 | m_log.Info("E ... " + pluginType.Name); | 252 | m_log.Info("E ... " + pluginType.Name); |
255 | } else | 253 | } |
254 | else | ||
256 | { | 255 | { |
257 | m_log.Warn("E ... " + pluginType.Name + " (Already added)"); | 256 | m_log.Warn("E ... " + pluginType.Name + " (Already added)"); |
258 | } | 257 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs index ce93060..f144444 100644 --- a/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs +++ b/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs | |||
@@ -44,13 +44,14 @@ namespace OpenSim.Region.Environment.Modules | |||
44 | /// </summary> | 44 | /// </summary> |
45 | public class TreePopulatorModule : IRegionModule | 45 | public class TreePopulatorModule : IRegionModule |
46 | { | 46 | { |
47 | private Scene m_scene; | ||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 48 | private Scene m_scene; | |
50 | private List<LLUUID> m_trees; | ||
51 | 49 | ||
52 | public double m_tree_density = 50.0; // Aim for this many per region | 50 | public double m_tree_density = 50.0; // Aim for this many per region |
53 | public double m_tree_updates = 1000.0; // MS between updates | 51 | public double m_tree_updates = 1000.0; // MS between updates |
52 | private List<LLUUID> m_trees; | ||
53 | |||
54 | #region IRegionModule Members | ||
54 | 55 | ||
55 | public void Initialise(Scene scene, IConfigSource config) | 56 | public void Initialise(Scene scene, IConfigSource config) |
56 | { | 57 | { |
@@ -59,7 +60,8 @@ namespace OpenSim.Region.Environment.Modules | |||
59 | m_tree_density = config.Configs["Trees"].GetDouble("tree_density", m_tree_density); | 60 | m_tree_density = config.Configs["Trees"].GetDouble("tree_density", m_tree_density); |
60 | } | 61 | } |
61 | catch (Exception) | 62 | catch (Exception) |
62 | { } | 63 | { |
64 | } | ||
63 | 65 | ||
64 | m_trees = new List<LLUUID>(); | 66 | m_trees = new List<LLUUID>(); |
65 | m_scene = scene; | 67 | m_scene = scene; |
@@ -72,7 +74,27 @@ namespace OpenSim.Region.Environment.Modules | |||
72 | m_log.Debug("[TREES]: Initialised tree module"); | 74 | m_log.Debug("[TREES]: Initialised tree module"); |
73 | } | 75 | } |
74 | 76 | ||
75 | void EventManager_OnPluginConsole(string[] args) | 77 | public void PostInitialise() |
78 | { | ||
79 | } | ||
80 | |||
81 | public void Close() | ||
82 | { | ||
83 | } | ||
84 | |||
85 | public string Name | ||
86 | { | ||
87 | get { return "TreePopulatorModule"; } | ||
88 | } | ||
89 | |||
90 | public bool IsSharedModule | ||
91 | { | ||
92 | get { return false; } | ||
93 | } | ||
94 | |||
95 | #endregion | ||
96 | |||
97 | private void EventManager_OnPluginConsole(string[] args) | ||
76 | { | 98 | { |
77 | if (args[0] == "tree") | 99 | if (args[0] == "tree") |
78 | { | 100 | { |
@@ -81,13 +103,13 @@ namespace OpenSim.Region.Environment.Modules | |||
81 | } | 103 | } |
82 | } | 104 | } |
83 | 105 | ||
84 | void growTrees() | 106 | private void growTrees() |
85 | { | 107 | { |
86 | foreach (LLUUID tree in m_trees) | 108 | foreach (LLUUID tree in m_trees) |
87 | { | 109 | { |
88 | if (m_scene.Entities.ContainsKey(tree)) | 110 | if (m_scene.Entities.ContainsKey(tree)) |
89 | { | 111 | { |
90 | SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; | 112 | SceneObjectPart s_tree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart; |
91 | 113 | ||
92 | // 100 seconds to grow 1m | 114 | // 100 seconds to grow 1m |
93 | s_tree.Scale += new LLVector3(0.1f, 0.1f, 0.1f); | 115 | s_tree.Scale += new LLVector3(0.1f, 0.1f, 0.1f); |
@@ -101,13 +123,13 @@ namespace OpenSim.Region.Environment.Modules | |||
101 | } | 123 | } |
102 | } | 124 | } |
103 | 125 | ||
104 | void seedTrees() | 126 | private void seedTrees() |
105 | { | 127 | { |
106 | foreach (LLUUID tree in m_trees) | 128 | foreach (LLUUID tree in m_trees) |
107 | { | 129 | { |
108 | if (m_scene.Entities.ContainsKey(tree)) | 130 | if (m_scene.Entities.ContainsKey(tree)) |
109 | { | 131 | { |
110 | SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; | 132 | SceneObjectPart s_tree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart; |
111 | 133 | ||
112 | if (s_tree.Scale.X > 0.5) | 134 | if (s_tree.Scale.X > 0.5) |
113 | { | 135 | { |
@@ -116,7 +138,6 @@ namespace OpenSim.Region.Environment.Modules | |||
116 | SpawnChild(s_tree); | 138 | SpawnChild(s_tree); |
117 | } | 139 | } |
118 | } | 140 | } |
119 | |||
120 | } | 141 | } |
121 | else | 142 | else |
122 | { | 143 | { |
@@ -125,7 +146,7 @@ namespace OpenSim.Region.Environment.Modules | |||
125 | } | 146 | } |
126 | } | 147 | } |
127 | 148 | ||
128 | void killTrees() | 149 | private void killTrees() |
129 | { | 150 | { |
130 | foreach (LLUUID tree in m_trees) | 151 | foreach (LLUUID tree in m_trees) |
131 | { | 152 | { |
@@ -133,7 +154,7 @@ namespace OpenSim.Region.Environment.Modules | |||
133 | 154 | ||
134 | if (m_scene.Entities.ContainsKey(tree)) | 155 | if (m_scene.Entities.ContainsKey(tree)) |
135 | { | 156 | { |
136 | SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; | 157 | SceneObjectPart selectedTree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart; |
137 | double selectedTreeScale = Math.Sqrt(Math.Pow(selectedTree.Scale.X, 2) + | 158 | double selectedTreeScale = Math.Sqrt(Math.Pow(selectedTree.Scale.X, 2) + |
138 | Math.Pow(selectedTree.Scale.Y, 2) + | 159 | Math.Pow(selectedTree.Scale.Y, 2) + |
139 | Math.Pow(selectedTree.Scale.Z, 2)); | 160 | Math.Pow(selectedTree.Scale.Z, 2)); |
@@ -142,7 +163,7 @@ namespace OpenSim.Region.Environment.Modules | |||
142 | { | 163 | { |
143 | if (picktree != tree) | 164 | if (picktree != tree) |
144 | { | 165 | { |
145 | SceneObjectPart pickedTree = ((SceneObjectGroup)m_scene.Entities[picktree]).RootPart; | 166 | SceneObjectPart pickedTree = ((SceneObjectGroup) m_scene.Entities[picktree]).RootPart; |
146 | 167 | ||
147 | double pickedTreeScale = Math.Sqrt(Math.Pow(pickedTree.Scale.X, 2) + | 168 | double pickedTreeScale = Math.Sqrt(Math.Pow(pickedTree.Scale.X, 2) + |
148 | Math.Pow(pickedTree.Scale.Y, 2) + | 169 | Math.Pow(pickedTree.Scale.Y, 2) + |
@@ -162,10 +183,10 @@ namespace OpenSim.Region.Environment.Modules | |||
162 | m_trees.Remove(selectedTree.ParentGroup.UUID); | 183 | m_trees.Remove(selectedTree.ParentGroup.UUID); |
163 | 184 | ||
164 | m_scene.ForEachClient(delegate(IClientAPI controller) | 185 | m_scene.ForEachClient(delegate(IClientAPI controller) |
165 | { | 186 | { |
166 | controller.SendKillObject(m_scene.RegionInfo.RegionHandle, | 187 | controller.SendKillObject(m_scene.RegionInfo.RegionHandle, |
167 | selectedTree.LocalId); | 188 | selectedTree.LocalId); |
168 | }); | 189 | }); |
169 | 190 | ||
170 | break; | 191 | break; |
171 | } | 192 | } |
@@ -199,15 +220,15 @@ namespace OpenSim.Region.Environment.Modules | |||
199 | double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); | 220 | double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); |
200 | double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); | 221 | double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); |
201 | 222 | ||
202 | position.X += (float)randX; | 223 | position.X += (float) randX; |
203 | position.Y += (float)randY; | 224 | position.Y += (float) randY; |
204 | 225 | ||
205 | CreateTree(position); | 226 | CreateTree(position); |
206 | } | 227 | } |
207 | 228 | ||
208 | private void CreateTree(LLVector3 position) | 229 | private void CreateTree(LLVector3 position) |
209 | { | 230 | { |
210 | position.Z = (float)m_scene.Heightmap[(int)position.X, (int)position.Y]; | 231 | position.Z = (float) m_scene.Heightmap[(int) position.X, (int) position.Y]; |
211 | 232 | ||
212 | SceneObjectGroup tree = | 233 | SceneObjectGroup tree = |
213 | m_scene.AddTree(new LLVector3(0.1f, 0.1f, 0.1f), | 234 | m_scene.AddTree(new LLVector3(0.1f, 0.1f, 0.1f), |
@@ -220,29 +241,11 @@ namespace OpenSim.Region.Environment.Modules | |||
220 | tree.SendGroupFullUpdate(); | 241 | tree.SendGroupFullUpdate(); |
221 | } | 242 | } |
222 | 243 | ||
223 | void CalculateTrees_Elapsed(object sender, ElapsedEventArgs e) | 244 | private void CalculateTrees_Elapsed(object sender, ElapsedEventArgs e) |
224 | { | 245 | { |
225 | growTrees(); | 246 | growTrees(); |
226 | seedTrees(); | 247 | seedTrees(); |
227 | killTrees(); | 248 | killTrees(); |
228 | } | 249 | } |
229 | |||
230 | public void PostInitialise() | ||
231 | { | ||
232 | } | ||
233 | |||
234 | public void Close() | ||
235 | { | ||
236 | } | ||
237 | |||
238 | public string Name | ||
239 | { | ||
240 | get { return "TreePopulatorModule"; } | ||
241 | } | ||
242 | |||
243 | public bool IsSharedModule | ||
244 | { | ||
245 | get { return false; } | ||
246 | } | ||
247 | } | 250 | } |
248 | } | 251 | } \ No newline at end of file |