aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Interfaces/ILandChannel.cs104
-rw-r--r--OpenSim/Region/Environment/Interfaces/ILandObject.cs108
-rw-r--r--OpenSim/Region/Environment/Modules/LandManagement/LandChannel.cs1832
-rw-r--r--OpenSim/Region/Environment/Modules/LandManagement/LandManagementModule.cs124
-rw-r--r--OpenSim/Region/Environment/Modules/LandManagement/LandObject.cs1758
5 files changed, 1963 insertions, 1963 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/ILandChannel.cs b/OpenSim/Region/Environment/Interfaces/ILandChannel.cs
index 1e0493f..c100764 100644
--- a/OpenSim/Region/Environment/Interfaces/ILandChannel.cs
+++ b/OpenSim/Region/Environment/Interfaces/ILandChannel.cs
@@ -1,52 +1,52 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5using libsecondlife; 5using libsecondlife;
6using libsecondlife.Packets; 6using libsecondlife.Packets;
7using OpenSim.Region.Environment.Scenes; 7using OpenSim.Region.Environment.Scenes;
8using OpenSim.Framework; 8using OpenSim.Framework;
9 9
10namespace OpenSim.Region.Environment.Interfaces 10namespace OpenSim.Region.Environment.Interfaces
11{ 11{
12 public interface ILandChannel 12 public interface ILandChannel
13 { 13 {
14 bool allowedForcefulBans { get; set; } 14 bool allowedForcefulBans { get; set; }
15 void IncomingLandObjectsFromStorage(List<LandData> data); 15 void IncomingLandObjectsFromStorage(List<LandData> data);
16 void IncomingLandObjectFromStorage(LandData data); 16 void IncomingLandObjectFromStorage(LandData data);
17 17
18 void NoLandDataFromStorage(); 18 void NoLandDataFromStorage();
19 ILandObject getLandObject(int x, int y); 19 ILandObject getLandObject(int x, int y);
20 ILandObject getLandObject(float x, float y); 20 ILandObject getLandObject(float x, float y);
21 void setPrimsTainted(); 21 void setPrimsTainted();
22 bool isLandPrimCountTainted(); 22 bool isLandPrimCountTainted();
23 void sendLandUpdate(ScenePresence avatar, bool force); 23 void sendLandUpdate(ScenePresence avatar, bool force);
24 void sendLandUpdate(ScenePresence avatar); 24 void sendLandUpdate(ScenePresence avatar);
25 void resetAllLandPrimCounts(); 25 void resetAllLandPrimCounts();
26 void addPrimToLandPrimCounts(SceneObjectGroup obj); 26 void addPrimToLandPrimCounts(SceneObjectGroup obj);
27 void removePrimFromLandPrimCounts(SceneObjectGroup obj); 27 void removePrimFromLandPrimCounts(SceneObjectGroup obj);
28 void finalizeLandPrimCountUpdate(); 28 void finalizeLandPrimCountUpdate();
29 void updateLandPrimCounts(); 29 void updateLandPrimCounts();
30 void performParcelPrimCountUpdate(); 30 void performParcelPrimCountUpdate();
31 void updateLandObject(int local_id, LandData newData); 31 void updateLandObject(int local_id, LandData newData);
32 32
33 void sendParcelOverlay(IClientAPI remote_client); 33 void sendParcelOverlay(IClientAPI remote_client);
34 void handleParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client); 34 void handleParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client);
35 void handleParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client); 35 void handleParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client);
36 void handleParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client); 36 void handleParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client);
37 void handleParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client); 37 void handleParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client);
38 void handleParcelSelectObjectsRequest(int local_id, int request_type, IClientAPI remote_client); 38 void handleParcelSelectObjectsRequest(int local_id, int request_type, IClientAPI remote_client);
39 void handleParcelObjectOwnersRequest(int local_id, IClientAPI remote_client); 39 void handleParcelObjectOwnersRequest(int local_id, IClientAPI remote_client);
40 40
41 void resetSimLandObjects(); 41 void resetSimLandObjects();
42 List<ILandObject> parcelsNearPoint(LLVector3 position); 42 List<ILandObject> parcelsNearPoint(LLVector3 position);
43 void sendYouAreBannedNotice(ScenePresence avatar); 43 void sendYouAreBannedNotice(ScenePresence avatar);
44 void handleAvatarChangingParcel(ScenePresence avatar, int localLandID, LLUUID regionID); 44 void handleAvatarChangingParcel(ScenePresence avatar, int localLandID, LLUUID regionID);
45 void sendOutNearestBanLine(IClientAPI avatar); 45 void sendOutNearestBanLine(IClientAPI avatar);
46 void handleSignificantClientMovement(IClientAPI remote_client); 46 void handleSignificantClientMovement(IClientAPI remote_client);
47 void handleAnyClientMovement(ScenePresence avatar); 47 void handleAnyClientMovement(ScenePresence avatar);
48 void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, int landLocalID, IClientAPI remote_client); 48 void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, int landLocalID, IClientAPI remote_client);
49 void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID, uint flags, int landLocalID, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client); 49 void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID, uint flags, int landLocalID, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client);
50 50
51 } 51 }
52} 52}
diff --git a/OpenSim/Region/Environment/Interfaces/ILandObject.cs b/OpenSim/Region/Environment/Interfaces/ILandObject.cs
index f68fb82..61d8670 100644
--- a/OpenSim/Region/Environment/Interfaces/ILandObject.cs
+++ b/OpenSim/Region/Environment/Interfaces/ILandObject.cs
@@ -1,54 +1,54 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5using libsecondlife; 5using libsecondlife;
6using libsecondlife.Packets; 6using libsecondlife.Packets;
7using OpenSim.Region.Environment.Scenes; 7using OpenSim.Region.Environment.Scenes;
8 8
9using OpenSim.Framework; 9using OpenSim.Framework;
10 10
11namespace OpenSim.Region.Environment.Interfaces 11namespace OpenSim.Region.Environment.Interfaces
12{ 12{
13 public interface ILandObject 13 public interface ILandObject
14 { 14 {
15 15
16 LandData landData { get; set; } 16 LandData landData { get; set; }
17 bool[,] landBitmap { get; set; } 17 bool[,] landBitmap { get; set; }
18 LLUUID regionUUID { get; } 18 LLUUID regionUUID { get; }
19 bool containsPoint(int x, int y); 19 bool containsPoint(int x, int y);
20 ILandObject Copy(); 20 ILandObject Copy();
21 21
22 22
23 void sendLandUpdateToAvatarsOverMe(); 23 void sendLandUpdateToAvatarsOverMe();
24 24
25 void sendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client); 25 void sendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client);
26 void updateLandProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client); 26 void updateLandProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client);
27 bool isEitherBannedOrRestricted(LLUUID avatar); 27 bool isEitherBannedOrRestricted(LLUUID avatar);
28 bool isBannedFromLand(LLUUID avatar); 28 bool isBannedFromLand(LLUUID avatar);
29 bool isRestrictedFromLand(LLUUID avatar); 29 bool isRestrictedFromLand(LLUUID avatar);
30 void sendLandUpdateToClient(IClientAPI remote_client); 30 void sendLandUpdateToClient(IClientAPI remote_client);
31 ParcelAccessListReplyPacket.ListBlock[] createAccessListArrayByFlag(ParcelManager.AccessList flag); 31 ParcelAccessListReplyPacket.ListBlock[] createAccessListArrayByFlag(ParcelManager.AccessList flag);
32 void sendAccessList(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, IClientAPI remote_client); 32 void sendAccessList(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, IClientAPI remote_client);
33 void updateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client); 33 void updateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client);
34 void updateLandBitmapByteArray(); 34 void updateLandBitmapByteArray();
35 void setLandBitmapFromByteArray(); 35 void setLandBitmapFromByteArray();
36 bool[,] getLandBitmap(); 36 bool[,] getLandBitmap();
37 void forceUpdateLandInfo(); 37 void forceUpdateLandInfo();
38 void setLandBitmap(bool[,] bitmap); 38 void setLandBitmap(bool[,] bitmap);
39 39
40 bool[,] basicFullRegionLandBitmap(); 40 bool[,] basicFullRegionLandBitmap();
41 bool[,] getSquareLandBitmap(int start_x, int start_y, int end_x, int end_y); 41 bool[,] getSquareLandBitmap(int start_x, int start_y, int end_x, int end_y);
42 bool[,] modifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value); 42 bool[,] modifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value);
43 bool[,] mergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add); 43 bool[,] mergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add);
44 void sendForceObjectSelect(int local_id, int request_type, IClientAPI remote_client); 44 void sendForceObjectSelect(int local_id, int request_type, IClientAPI remote_client);
45 void sendLandObjectOwners(IClientAPI remote_client); 45 void sendLandObjectOwners(IClientAPI remote_client);
46 void returnObject(SceneObjectGroup obj); 46 void returnObject(SceneObjectGroup obj);
47 void returnLandObjects(int type, LLUUID owner); 47 void returnLandObjects(int type, LLUUID owner);
48 void resetLandPrimCounts(); 48 void resetLandPrimCounts();
49 void addPrimToCount(SceneObjectGroup obj); 49 void addPrimToCount(SceneObjectGroup obj);
50 void removePrimFromCount(SceneObjectGroup obj); 50 void removePrimFromCount(SceneObjectGroup obj);
51 51
52 52
53 } 53 }
54} 54}
diff --git a/OpenSim/Region/Environment/Modules/LandManagement/LandChannel.cs b/OpenSim/Region/Environment/Modules/LandManagement/LandChannel.cs
index ba0c550..d95e4b1 100644
--- a/OpenSim/Region/Environment/Modules/LandManagement/LandChannel.cs
+++ b/OpenSim/Region/Environment/Modules/LandManagement/LandChannel.cs
@@ -1,916 +1,916 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4 4
5using Axiom.Math; 5using Axiom.Math;
6using libsecondlife; 6using libsecondlife;
7using libsecondlife.Packets; 7using libsecondlife.Packets;
8using OpenSim.Framework; 8using OpenSim.Framework;
9using OpenSim.Framework.Console; 9using OpenSim.Framework.Console;
10using OpenSim.Region.Environment.Scenes; 10using OpenSim.Region.Environment.Scenes;
11using OpenSim.Region.Environment.Interfaces; 11using OpenSim.Region.Environment.Interfaces;
12using OpenSim.Region.Physics.Manager; 12using OpenSim.Region.Physics.Manager;
13 13
14namespace OpenSim.Region.Environment.Modules.LandManagement 14namespace OpenSim.Region.Environment.Modules.LandManagement
15{ 15{
16 public class LandChannel : ILandChannel 16 public class LandChannel : ILandChannel
17 { 17 {
18 #region Constants 18 #region Constants
19 19
20 //Land types set with flags in ParcelOverlay. 20 //Land types set with flags in ParcelOverlay.
21 //Only one of these can be used. 21 //Only one of these can be used.
22 public const byte LAND_TYPE_PUBLIC = (byte)0; //Equals 00000000 22 public const byte LAND_TYPE_PUBLIC = (byte)0; //Equals 00000000
23 public const byte LAND_TYPE_OWNED_BY_OTHER = (byte)1; //Equals 00000001 23 public const byte LAND_TYPE_OWNED_BY_OTHER = (byte)1; //Equals 00000001
24 public const byte LAND_TYPE_OWNED_BY_GROUP = (byte)2; //Equals 00000010 24 public const byte LAND_TYPE_OWNED_BY_GROUP = (byte)2; //Equals 00000010
25 public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte)3; //Equals 00000011 25 public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte)3; //Equals 00000011
26 public const byte LAND_TYPE_IS_FOR_SALE = (byte)4; //Equals 00000100 26 public const byte LAND_TYPE_IS_FOR_SALE = (byte)4; //Equals 00000100
27 public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte)5; //Equals 00000101 27 public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte)5; //Equals 00000101
28 28
29 //Flags that when set, a border on the given side will be placed 29 //Flags that when set, a border on the given side will be placed
30 //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) 30 //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)
31 //This took forever to figure out -- jeesh. /blame LL for even having to send these 31 //This took forever to figure out -- jeesh. /blame LL for even having to send these
32 public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte)64; //Equals 01000000 32 public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte)64; //Equals 01000000
33 public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte)128; //Equals 10000000 33 public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte)128; //Equals 10000000
34 34
35 //RequestResults (I think these are right, they seem to work): 35 //RequestResults (I think these are right, they seem to work):
36 public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land 36 public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land
37 public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land 37 public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land
38 38
39 //ParcelSelectObjects 39 //ParcelSelectObjects
40 public const int LAND_SELECT_OBJECTS_OWNER = 2; 40 public const int LAND_SELECT_OBJECTS_OWNER = 2;
41 public const int LAND_SELECT_OBJECTS_GROUP = 4; 41 public const int LAND_SELECT_OBJECTS_GROUP = 4;
42 public const int LAND_SELECT_OBJECTS_OTHER = 8; 42 public const int LAND_SELECT_OBJECTS_OTHER = 8;
43 43
44 //These are other constants. Yay! 44 //These are other constants. Yay!
45 public const int START_LAND_LOCAL_ID = 1; 45 public const int START_LAND_LOCAL_ID = 1;
46 46
47 public const float BAN_LINE_SAFETY_HIEGHT = 100; 47 public const float BAN_LINE_SAFETY_HIEGHT = 100;
48 48
49 #endregion 49 #endregion
50 50
51 private Scene m_scene; 51 private Scene m_scene;
52 52
53 private Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>(); 53 private Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>();
54 private int lastLandLocalID = START_LAND_LOCAL_ID - 1; 54 private int lastLandLocalID = START_LAND_LOCAL_ID - 1;
55 private int[,] landIDList = new int[64, 64]; 55 private int[,] landIDList = new int[64, 64];
56 56
57 private bool landPrimCountTainted = false; 57 private bool landPrimCountTainted = false;
58 58
59 private bool m_allowedForcefulBans = true; 59 private bool m_allowedForcefulBans = true;
60 public bool allowedForcefulBans 60 public bool allowedForcefulBans
61 { 61 {
62 get 62 get
63 { 63 {
64 return m_allowedForcefulBans; 64 return m_allowedForcefulBans;
65 } 65 }
66 set 66 set
67 { 67 {
68 m_allowedForcefulBans = value; 68 m_allowedForcefulBans = value;
69 } 69 }
70 } 70 }
71 71
72 public LandChannel(Scene scene) 72 public LandChannel(Scene scene)
73 { 73 {
74 m_scene = scene; 74 m_scene = scene;
75 landIDList.Initialize(); 75 landIDList.Initialize();
76 } 76 }
77 #region Land Object From Storage Functions 77 #region Land Object From Storage Functions
78 78
79 public void IncomingLandObjectsFromStorage(List<LandData> data) 79 public void IncomingLandObjectsFromStorage(List<LandData> data)
80 { 80 {
81 for (int i = 0; i < data.Count; i++) 81 for (int i = 0; i < data.Count; i++)
82 { 82 {
83 //try 83 //try
84 //{ 84 //{
85 IncomingLandObjectFromStorage(data[i]); 85 IncomingLandObjectFromStorage(data[i]);
86 //} 86 //}
87 //catch (Exception ex) 87 //catch (Exception ex)
88 //{ 88 //{
89 //m_log.Error("[LandManager]: IncomingLandObjectsFromStorage: Exception: " + ex.ToString()); 89 //m_log.Error("[LandManager]: IncomingLandObjectsFromStorage: Exception: " + ex.ToString());
90 //throw ex; 90 //throw ex;
91 //} 91 //}
92 } 92 }
93 //foreach (LandData parcel in data) 93 //foreach (LandData parcel in data)
94 //{ 94 //{
95 // IncomingLandObjectFromStorage(parcel); 95 // IncomingLandObjectFromStorage(parcel);
96 //} 96 //}
97 } 97 }
98 98
99 public void IncomingLandObjectFromStorage(LandData data) 99 public void IncomingLandObjectFromStorage(LandData data)
100 { 100 {
101 ILandObject new_land = new LandObject(data.ownerID, data.isGroupOwned, m_scene); 101 ILandObject new_land = new LandObject(data.ownerID, data.isGroupOwned, m_scene);
102 new_land.landData = data.Copy(); 102 new_land.landData = data.Copy();
103 new_land.setLandBitmapFromByteArray(); 103 new_land.setLandBitmapFromByteArray();
104 addLandObject(new_land); 104 addLandObject(new_land);
105 } 105 }
106 106
107 public void NoLandDataFromStorage() 107 public void NoLandDataFromStorage()
108 { 108 {
109 resetSimLandObjects(); 109 resetSimLandObjects();
110 } 110 }
111 111
112 #endregion 112 #endregion
113 113
114 #region Parcel Add/Remove/Get/Create 114 #region Parcel Add/Remove/Get/Create
115 115
116 /// <summary> 116 /// <summary>
117 /// Creates a basic Parcel object without an owner (a zeroed key) 117 /// Creates a basic Parcel object without an owner (a zeroed key)
118 /// </summary> 118 /// </summary>
119 /// <returns></returns> 119 /// <returns></returns>
120 public ILandObject createBaseLand() 120 public ILandObject createBaseLand()
121 { 121 {
122 return new LandObject(LLUUID.Zero, false, m_scene); 122 return new LandObject(LLUUID.Zero, false, m_scene);
123 } 123 }
124 124
125 /// <summary> 125 /// <summary>
126 /// Adds a land object to the stored list and adds them to the landIDList to what they own 126 /// Adds a land object to the stored list and adds them to the landIDList to what they own
127 /// </summary> 127 /// </summary>
128 /// <param name="new_land">The land object being added</param> 128 /// <param name="new_land">The land object being added</param>
129 public ILandObject addLandObject(ILandObject new_land) 129 public ILandObject addLandObject(ILandObject new_land)
130 { 130 {
131 lastLandLocalID++; 131 lastLandLocalID++;
132 new_land.landData.localID = lastLandLocalID; 132 new_land.landData.localID = lastLandLocalID;
133 landList.Add(lastLandLocalID, (LandObject)new_land.Copy()); 133 landList.Add(lastLandLocalID, (LandObject)new_land.Copy());
134 134
135 135
136 bool[,] landBitmap = new_land.getLandBitmap(); 136 bool[,] landBitmap = new_land.getLandBitmap();
137 int x, y; 137 int x, y;
138 for (x = 0; x < 64; x++) 138 for (x = 0; x < 64; x++)
139 { 139 {
140 for (y = 0; y < 64; y++) 140 for (y = 0; y < 64; y++)
141 { 141 {
142 if (landBitmap[x, y]) 142 if (landBitmap[x, y])
143 { 143 {
144 landIDList[x, y] = lastLandLocalID; 144 landIDList[x, y] = lastLandLocalID;
145 } 145 }
146 } 146 }
147 } 147 }
148 landList[lastLandLocalID].forceUpdateLandInfo(); 148 landList[lastLandLocalID].forceUpdateLandInfo();
149 m_scene.EventManager.TriggerLandObjectAdded(new_land); 149 m_scene.EventManager.TriggerLandObjectAdded(new_land);
150 return new_land; 150 return new_land;
151 } 151 }
152 152
153 /// <summary> 153 /// <summary>
154 /// Removes a land object from the list. Will not remove if local_id is still owning an area in landIDList 154 /// Removes a land object from the list. Will not remove if local_id is still owning an area in landIDList
155 /// </summary> 155 /// </summary>
156 /// <param name="local_id">Land.localID of the peice of land to remove.</param> 156 /// <param name="local_id">Land.localID of the peice of land to remove.</param>
157 public void removeLandObject(int local_id) 157 public void removeLandObject(int local_id)
158 { 158 {
159 int x, y; 159 int x, y;
160 for (x = 0; x < 64; x++) 160 for (x = 0; x < 64; x++)
161 { 161 {
162 for (y = 0; y < 64; y++) 162 for (y = 0; y < 64; y++)
163 { 163 {
164 if (landIDList[x, y] == local_id) 164 if (landIDList[x, y] == local_id)
165 { 165 {
166 return; 166 return;
167 //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y); 167 //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y);
168 } 168 }
169 } 169 }
170 } 170 }
171 171
172 m_scene.EventManager.TriggerLandObjectRemoved(landList[local_id].landData.globalID); 172 m_scene.EventManager.TriggerLandObjectRemoved(landList[local_id].landData.globalID);
173 landList.Remove(local_id); 173 landList.Remove(local_id);
174 } 174 }
175 175
176 public void updateLandObject(int local_id, LandData newData) 176 public void updateLandObject(int local_id, LandData newData)
177 { 177 {
178 if (landList.ContainsKey(local_id)) 178 if (landList.ContainsKey(local_id))
179 { 179 {
180 landList[local_id].landData = newData.Copy(); 180 landList[local_id].landData = newData.Copy();
181 m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landList[local_id]); 181 m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landList[local_id]);
182 } 182 }
183 } 183 }
184 184
185 private void performFinalLandJoin(ILandObject master, ILandObject slave) 185 private void performFinalLandJoin(ILandObject master, ILandObject slave)
186 { 186 {
187 int x, y; 187 int x, y;
188 bool[,] landBitmapSlave = slave.getLandBitmap(); 188 bool[,] landBitmapSlave = slave.getLandBitmap();
189 for (x = 0; x < 64; x++) 189 for (x = 0; x < 64; x++)
190 { 190 {
191 for (y = 0; y < 64; y++) 191 for (y = 0; y < 64; y++)
192 { 192 {
193 if (landBitmapSlave[x, y]) 193 if (landBitmapSlave[x, y])
194 { 194 {
195 landIDList[x, y] = master.landData.localID; 195 landIDList[x, y] = master.landData.localID;
196 } 196 }
197 } 197 }
198 } 198 }
199 199
200 removeLandObject(slave.landData.localID); 200 removeLandObject(slave.landData.localID);
201 updateLandObject(master.landData.localID, master.landData); 201 updateLandObject(master.landData.localID, master.landData);
202 } 202 }
203 203
204 /// <summary> 204 /// <summary>
205 /// Get the land object at the specified point 205 /// Get the land object at the specified point
206 /// </summary> 206 /// </summary>
207 /// <param name="x">Value between 0 - 256 on the x axis of the point</param> 207 /// <param name="x">Value between 0 - 256 on the x axis of the point</param>
208 /// <param name="y">Value between 0 - 256 on the y axis of the point</param> 208 /// <param name="y">Value between 0 - 256 on the y axis of the point</param>
209 /// <returns>Land object at the point supplied</returns> 209 /// <returns>Land object at the point supplied</returns>
210 public ILandObject getLandObject(float x_float, float y_float) 210 public ILandObject getLandObject(float x_float, float y_float)
211 { 211 {
212 int x; 212 int x;
213 int y; 213 int y;
214 214
215 try 215 try
216 { 216 {
217 x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / Convert.ToDouble(4.0))); 217 x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / Convert.ToDouble(4.0)));
218 y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / Convert.ToDouble(4.0))); 218 y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / Convert.ToDouble(4.0)));
219 } 219 }
220 catch (System.OverflowException) 220 catch (System.OverflowException)
221 { 221 {
222 return null; 222 return null;
223 } 223 }
224 224
225 if (x >= 64 || y >= 64 || x < 0 || y < 0) 225 if (x >= 64 || y >= 64 || x < 0 || y < 0)
226 { 226 {
227 return null; 227 return null;
228 } 228 }
229 else 229 else
230 { 230 {
231 return landList[landIDList[x, y]]; 231 return landList[landIDList[x, y]];
232 } 232 }
233 } 233 }
234 234
235 public ILandObject getLandObject(int x, int y) 235 public ILandObject getLandObject(int x, int y)
236 { 236 {
237 if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0) 237 if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0)
238 { 238 {
239 // These exceptions here will cause a lot of complaints from the users specifically because 239 // These exceptions here will cause a lot of complaints from the users specifically because
240 // they happen every time at border crossings 240 // they happen every time at border crossings
241 throw new Exception("Error: Parcel not found at point " + x + ", " + y); 241 throw new Exception("Error: Parcel not found at point " + x + ", " + y);
242 } 242 }
243 else 243 else
244 { 244 {
245 return landList[landIDList[x / 4, y / 4]]; 245 return landList[landIDList[x / 4, y / 4]];
246 } 246 }
247 } 247 }
248 248
249 #endregion 249 #endregion
250 250
251 #region Parcel Modification 251 #region Parcel Modification
252 252
253 /// <summary> 253 /// <summary>
254 /// Subdivides a piece of land 254 /// Subdivides a piece of land
255 /// </summary> 255 /// </summary>
256 /// <param name="start_x">West Point</param> 256 /// <param name="start_x">West Point</param>
257 /// <param name="start_y">South Point</param> 257 /// <param name="start_y">South Point</param>
258 /// <param name="end_x">East Point</param> 258 /// <param name="end_x">East Point</param>
259 /// <param name="end_y">North Point</param> 259 /// <param name="end_y">North Point</param>
260 /// <param name="attempting_user_id">LLUUID of user who is trying to subdivide</param> 260 /// <param name="attempting_user_id">LLUUID of user who is trying to subdivide</param>
261 /// <returns>Returns true if successful</returns> 261 /// <returns>Returns true if successful</returns>
262 private bool subdivide(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) 262 private bool subdivide(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id)
263 { 263 {
264 //First, lets loop through the points and make sure they are all in the same peice of land 264 //First, lets loop through the points and make sure they are all in the same peice of land
265 //Get the land object at start 265 //Get the land object at start
266 ILandObject startLandObject = null; 266 ILandObject startLandObject = null;
267 try 267 try
268 { 268 {
269 startLandObject = getLandObject(start_x, start_y); 269 startLandObject = getLandObject(start_x, start_y);
270 } 270 }
271 catch (Exception) 271 catch (Exception)
272 { 272 {
273 //m_log.Error("[LAND]: " + "Unable to get land object for subdivision at x: " + start_x + " y:" + start_y); 273 //m_log.Error("[LAND]: " + "Unable to get land object for subdivision at x: " + start_x + " y:" + start_y);
274 } 274 }
275 if (startLandObject == null) return false; //No such land object at the beginning 275 if (startLandObject == null) return false; //No such land object at the beginning
276 276
277 //Loop through the points 277 //Loop through the points
278 try 278 try
279 { 279 {
280 int totalX = end_x - start_x; 280 int totalX = end_x - start_x;
281 int totalY = end_y - start_y; 281 int totalY = end_y - start_y;
282 int x, y; 282 int x, y;
283 for (y = 0; y < totalY; y++) 283 for (y = 0; y < totalY; y++)
284 { 284 {
285 for (x = 0; x < totalX; x++) 285 for (x = 0; x < totalX; x++)
286 { 286 {
287 ILandObject tempLandObject = getLandObject(start_x + x, start_y + y); 287 ILandObject tempLandObject = getLandObject(start_x + x, start_y + y);
288 if (tempLandObject == null) return false; //No such land object at that point 288 if (tempLandObject == null) return false; //No such land object at that point
289 if (tempLandObject != startLandObject) return false; //Subdividing over 2 land objects; no-no 289 if (tempLandObject != startLandObject) return false; //Subdividing over 2 land objects; no-no
290 } 290 }
291 } 291 }
292 } 292 }
293 catch (Exception) 293 catch (Exception)
294 { 294 {
295 return false; //Exception. For now, lets skip subdivision 295 return false; //Exception. For now, lets skip subdivision
296 } 296 }
297 297
298 //If we are still here, then they are subdividing within one piece of land 298 //If we are still here, then they are subdividing within one piece of land
299 //Check owner 299 //Check owner
300 if (startLandObject.landData.ownerID != attempting_user_id) 300 if (startLandObject.landData.ownerID != attempting_user_id)
301 { 301 {
302 return false; //They cant do this! 302 return false; //They cant do this!
303 } 303 }
304 304
305 //Lets create a new land object with bitmap activated at that point (keeping the old land objects info) 305 //Lets create a new land object with bitmap activated at that point (keeping the old land objects info)
306 ILandObject newLand = startLandObject.Copy(); 306 ILandObject newLand = startLandObject.Copy();
307 newLand.landData.landName = "Subdivision of " + newLand.landData.landName; 307 newLand.landData.landName = "Subdivision of " + newLand.landData.landName;
308 newLand.landData.globalID = LLUUID.Random(); 308 newLand.landData.globalID = LLUUID.Random();
309 309
310 newLand.setLandBitmap(newLand.getSquareLandBitmap(start_x, start_y, end_x, end_y)); 310 newLand.setLandBitmap(newLand.getSquareLandBitmap(start_x, start_y, end_x, end_y));
311 311
312 //Now, lets set the subdivision area of the original to false 312 //Now, lets set the subdivision area of the original to false
313 int startLandObjectIndex = startLandObject.landData.localID; 313 int startLandObjectIndex = startLandObject.landData.localID;
314 landList[startLandObjectIndex].setLandBitmap( 314 landList[startLandObjectIndex].setLandBitmap(
315 newLand.modifyLandBitmapSquare(startLandObject.getLandBitmap(), start_x, start_y, end_x, end_y, false)); 315 newLand.modifyLandBitmapSquare(startLandObject.getLandBitmap(), start_x, start_y, end_x, end_y, false));
316 landList[startLandObjectIndex].forceUpdateLandInfo(); 316 landList[startLandObjectIndex].forceUpdateLandInfo();
317 317
318 setPrimsTainted(); 318 setPrimsTainted();
319 319
320 //Now add the new land object 320 //Now add the new land object
321 ILandObject result = addLandObject(newLand); 321 ILandObject result = addLandObject(newLand);
322 updateLandObject(startLandObject.landData.localID, startLandObject.landData); 322 updateLandObject(startLandObject.landData.localID, startLandObject.landData);
323 result.sendLandUpdateToAvatarsOverMe(); 323 result.sendLandUpdateToAvatarsOverMe();
324 324
325 325
326 return true; 326 return true;
327 } 327 }
328 328
329 /// <summary> 329 /// <summary>
330 /// Join 2 land objects together 330 /// Join 2 land objects together
331 /// </summary> 331 /// </summary>
332 /// <param name="start_x">x value in first piece of land</param> 332 /// <param name="start_x">x value in first piece of land</param>
333 /// <param name="start_y">y value in first piece of land</param> 333 /// <param name="start_y">y value in first piece of land</param>
334 /// <param name="end_x">x value in second peice of land</param> 334 /// <param name="end_x">x value in second peice of land</param>
335 /// <param name="end_y">y value in second peice of land</param> 335 /// <param name="end_y">y value in second peice of land</param>
336 /// <param name="attempting_user_id">LLUUID of the avatar trying to join the land objects</param> 336 /// <param name="attempting_user_id">LLUUID of the avatar trying to join the land objects</param>
337 /// <returns>Returns true if successful</returns> 337 /// <returns>Returns true if successful</returns>
338 private bool join(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) 338 private bool join(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id)
339 { 339 {
340 end_x -= 4; 340 end_x -= 4;
341 end_y -= 4; 341 end_y -= 4;
342 342
343 List<ILandObject> selectedLandObjects = new List<ILandObject>(); 343 List<ILandObject> selectedLandObjects = new List<ILandObject>();
344 int stepXSelected = 0; 344 int stepXSelected = 0;
345 int stepYSelected = 0; 345 int stepYSelected = 0;
346 for (stepYSelected = start_y; stepYSelected <= end_y; stepYSelected += 4) 346 for (stepYSelected = start_y; stepYSelected <= end_y; stepYSelected += 4)
347 { 347 {
348 for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4) 348 for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4)
349 { 349 {
350 ILandObject p = null; 350 ILandObject p = null;
351 try 351 try
352 { 352 {
353 p = getLandObject(stepXSelected, stepYSelected); 353 p = getLandObject(stepXSelected, stepYSelected);
354 } 354 }
355 catch (Exception) 355 catch (Exception)
356 { 356 {
357 //m_log.Error("[LAND]: " + "Unable to get land object for subdivision at x: " + stepXSelected + " y:" + stepYSelected); 357 //m_log.Error("[LAND]: " + "Unable to get land object for subdivision at x: " + stepXSelected + " y:" + stepYSelected);
358 } 358 }
359 if (p != null) 359 if (p != null)
360 { 360 {
361 if (!selectedLandObjects.Contains(p)) 361 if (!selectedLandObjects.Contains(p))
362 { 362 {
363 selectedLandObjects.Add(p); 363 selectedLandObjects.Add(p);
364 } 364 }
365 } 365 }
366 } 366 }
367 } 367 }
368 ILandObject masterLandObject = selectedLandObjects[0]; 368 ILandObject masterLandObject = selectedLandObjects[0];
369 selectedLandObjects.RemoveAt(0); 369 selectedLandObjects.RemoveAt(0);
370 370
371 371
372 if (selectedLandObjects.Count < 1) 372 if (selectedLandObjects.Count < 1)
373 { 373 {
374 return false; //Only one piece of land selected 374 return false; //Only one piece of land selected
375 } 375 }
376 if (masterLandObject.landData.ownerID != attempting_user_id) 376 if (masterLandObject.landData.ownerID != attempting_user_id)
377 { 377 {
378 return false; //Not the same owner 378 return false; //Not the same owner
379 } 379 }
380 foreach (ILandObject p in selectedLandObjects) 380 foreach (ILandObject p in selectedLandObjects)
381 { 381 {
382 if (p.landData.ownerID != masterLandObject.landData.ownerID) 382 if (p.landData.ownerID != masterLandObject.landData.ownerID)
383 { 383 {
384 return false; //Over multiple users. TODO: make this just ignore this piece of land? 384 return false; //Over multiple users. TODO: make this just ignore this piece of land?
385 } 385 }
386 } 386 }
387 foreach (ILandObject slaveLandObject in selectedLandObjects) 387 foreach (ILandObject slaveLandObject in selectedLandObjects)
388 { 388 {
389 landList[masterLandObject.landData.localID].setLandBitmap( 389 landList[masterLandObject.landData.localID].setLandBitmap(
390 slaveLandObject.mergeLandBitmaps(masterLandObject.getLandBitmap(), slaveLandObject.getLandBitmap())); 390 slaveLandObject.mergeLandBitmaps(masterLandObject.getLandBitmap(), slaveLandObject.getLandBitmap()));
391 performFinalLandJoin(masterLandObject, slaveLandObject); 391 performFinalLandJoin(masterLandObject, slaveLandObject);
392 } 392 }
393 393
394 394
395 setPrimsTainted(); 395 setPrimsTainted();
396 396
397 masterLandObject.sendLandUpdateToAvatarsOverMe(); 397 masterLandObject.sendLandUpdateToAvatarsOverMe();
398 398
399 return true; 399 return true;
400 } 400 }
401 401
402 public void resetAllLandPrimCounts() 402 public void resetAllLandPrimCounts()
403 { 403 {
404 foreach (LandObject p in landList.Values) 404 foreach (LandObject p in landList.Values)
405 { 405 {
406 p.resetLandPrimCounts(); 406 p.resetLandPrimCounts();
407 } 407 }
408 } 408 }
409 409
410 public void setPrimsTainted() 410 public void setPrimsTainted()
411 { 411 {
412 landPrimCountTainted = true; 412 landPrimCountTainted = true;
413 } 413 }
414 414
415 public bool isLandPrimCountTainted() 415 public bool isLandPrimCountTainted()
416 { 416 {
417 return landPrimCountTainted; 417 return landPrimCountTainted;
418 } 418 }
419 419
420 public void addPrimToLandPrimCounts(SceneObjectGroup obj) 420 public void addPrimToLandPrimCounts(SceneObjectGroup obj)
421 { 421 {
422 LLVector3 position = obj.AbsolutePosition; 422 LLVector3 position = obj.AbsolutePosition;
423 ILandObject landUnderPrim = getLandObject(position.X, position.Y); 423 ILandObject landUnderPrim = getLandObject(position.X, position.Y);
424 if (landUnderPrim != null) 424 if (landUnderPrim != null)
425 { 425 {
426 landUnderPrim.addPrimToCount(obj); 426 landUnderPrim.addPrimToCount(obj);
427 } 427 }
428 } 428 }
429 429
430 public void removePrimFromLandPrimCounts(SceneObjectGroup obj) 430 public void removePrimFromLandPrimCounts(SceneObjectGroup obj)
431 { 431 {
432 foreach (LandObject p in landList.Values) 432 foreach (LandObject p in landList.Values)
433 { 433 {
434 p.removePrimFromCount(obj); 434 p.removePrimFromCount(obj);
435 } 435 }
436 } 436 }
437 437
438 public void finalizeLandPrimCountUpdate() 438 public void finalizeLandPrimCountUpdate()
439 { 439 {
440 //Get Simwide prim count for owner 440 //Get Simwide prim count for owner
441 Dictionary<LLUUID, List<LandObject>> landOwnersAndParcels = new Dictionary<LLUUID, List<LandObject>>(); 441 Dictionary<LLUUID, List<LandObject>> landOwnersAndParcels = new Dictionary<LLUUID, List<LandObject>>();
442 foreach (LandObject p in landList.Values) 442 foreach (LandObject p in landList.Values)
443 { 443 {
444 if (!landOwnersAndParcels.ContainsKey(p.landData.ownerID)) 444 if (!landOwnersAndParcels.ContainsKey(p.landData.ownerID))
445 { 445 {
446 List<LandObject> tempList = new List<LandObject>(); 446 List<LandObject> tempList = new List<LandObject>();
447 tempList.Add(p); 447 tempList.Add(p);
448 landOwnersAndParcels.Add(p.landData.ownerID, tempList); 448 landOwnersAndParcels.Add(p.landData.ownerID, tempList);
449 } 449 }
450 else 450 else
451 { 451 {
452 landOwnersAndParcels[p.landData.ownerID].Add(p); 452 landOwnersAndParcels[p.landData.ownerID].Add(p);
453 } 453 }
454 } 454 }
455 455
456 foreach (LLUUID owner in landOwnersAndParcels.Keys) 456 foreach (LLUUID owner in landOwnersAndParcels.Keys)
457 { 457 {
458 int simArea = 0; 458 int simArea = 0;
459 int simPrims = 0; 459 int simPrims = 0;
460 foreach (LandObject p in landOwnersAndParcels[owner]) 460 foreach (LandObject p in landOwnersAndParcels[owner])
461 { 461 {
462 simArea += p.landData.area; 462 simArea += p.landData.area;
463 simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims + 463 simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims +
464 p.landData.selectedPrims; 464 p.landData.selectedPrims;
465 } 465 }
466 466
467 foreach (LandObject p in landOwnersAndParcels[owner]) 467 foreach (LandObject p in landOwnersAndParcels[owner])
468 { 468 {
469 p.landData.simwideArea = simArea; 469 p.landData.simwideArea = simArea;
470 p.landData.simwidePrims = simPrims; 470 p.landData.simwidePrims = simPrims;
471 } 471 }
472 } 472 }
473 } 473 }
474 474
475 public void updateLandPrimCounts() 475 public void updateLandPrimCounts()
476 { 476 {
477 foreach (EntityBase obj in m_scene.Entities.Values) 477 foreach (EntityBase obj in m_scene.Entities.Values)
478 { 478 {
479 if (obj is SceneObjectGroup) 479 if (obj is SceneObjectGroup)
480 { 480 {
481 m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup)obj); 481 m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup)obj);
482 } 482 }
483 } 483 }
484 } 484 }
485 485
486 public void performParcelPrimCountUpdate() 486 public void performParcelPrimCountUpdate()
487 { 487 {
488 resetAllLandPrimCounts(); 488 resetAllLandPrimCounts();
489 m_scene.EventManager.TriggerParcelPrimCountUpdate(); 489 m_scene.EventManager.TriggerParcelPrimCountUpdate();
490 finalizeLandPrimCountUpdate(); 490 finalizeLandPrimCountUpdate();
491 landPrimCountTainted = false; 491 landPrimCountTainted = false;
492 } 492 }
493 #endregion 493 #endregion
494 494
495 #region Parcel Updating 495 #region Parcel Updating
496 496
497 /// <summary> 497 /// <summary>
498 /// Where we send the ParcelOverlay packet to the client 498 /// Where we send the ParcelOverlay packet to the client
499 /// </summary> 499 /// </summary>
500 /// <param name="remote_client">The object representing the client</param> 500 /// <param name="remote_client">The object representing the client</param>
501 public void sendParcelOverlay(IClientAPI remote_client) 501 public void sendParcelOverlay(IClientAPI remote_client)
502 { 502 {
503 const int LAND_BLOCKS_PER_PACKET = 1024; 503 const int LAND_BLOCKS_PER_PACKET = 1024;
504 int x, y = 0; 504 int x, y = 0;
505 byte[] byteArray = new byte[LAND_BLOCKS_PER_PACKET]; 505 byte[] byteArray = new byte[LAND_BLOCKS_PER_PACKET];
506 int byteArrayCount = 0; 506 int byteArrayCount = 0;
507 int sequenceID = 0; 507 int sequenceID = 0;
508 ParcelOverlayPacket packet; 508 ParcelOverlayPacket packet;
509 509
510 for (y = 0; y < 64; y++) 510 for (y = 0; y < 64; y++)
511 { 511 {
512 for (x = 0; x < 64; x++) 512 for (x = 0; x < 64; x++)
513 { 513 {
514 byte tempByte = (byte)0; //This represents the byte for the current 4x4 514 byte tempByte = (byte)0; //This represents the byte for the current 4x4
515 ILandObject currentParcelBlock = null; 515 ILandObject currentParcelBlock = null;
516 516
517 try 517 try
518 { 518 {
519 currentParcelBlock = getLandObject(x * 4, y * 4); 519 currentParcelBlock = getLandObject(x * 4, y * 4);
520 } 520 }
521 catch (Exception) 521 catch (Exception)
522 { 522 {
523 //m_log.Warn("[LAND]: " + "unable to get land at x: " + (x * 4) + " y: " + (y * 4)); 523 //m_log.Warn("[LAND]: " + "unable to get land at x: " + (x * 4) + " y: " + (y * 4));
524 } 524 }
525 525
526 526
527 if (currentParcelBlock != null) 527 if (currentParcelBlock != null)
528 { 528 {
529 if (currentParcelBlock.landData.ownerID == remote_client.AgentId) 529 if (currentParcelBlock.landData.ownerID == remote_client.AgentId)
530 { 530 {
531 //Owner Flag 531 //Owner Flag
532 tempByte = Convert.ToByte(tempByte | LAND_TYPE_OWNED_BY_REQUESTER); 532 tempByte = Convert.ToByte(tempByte | LAND_TYPE_OWNED_BY_REQUESTER);
533 } 533 }
534 else if (currentParcelBlock.landData.salePrice > 0 && 534 else if (currentParcelBlock.landData.salePrice > 0 &&
535 (currentParcelBlock.landData.authBuyerID == LLUUID.Zero || 535 (currentParcelBlock.landData.authBuyerID == LLUUID.Zero ||
536 currentParcelBlock.landData.authBuyerID == remote_client.AgentId)) 536 currentParcelBlock.landData.authBuyerID == remote_client.AgentId))
537 { 537 {
538 //Sale Flag 538 //Sale Flag
539 tempByte = Convert.ToByte(tempByte | LAND_TYPE_IS_FOR_SALE); 539 tempByte = Convert.ToByte(tempByte | LAND_TYPE_IS_FOR_SALE);
540 } 540 }
541 else if (currentParcelBlock.landData.ownerID == LLUUID.Zero) 541 else if (currentParcelBlock.landData.ownerID == LLUUID.Zero)
542 { 542 {
543 //Public Flag 543 //Public Flag
544 tempByte = Convert.ToByte(tempByte | LAND_TYPE_PUBLIC); 544 tempByte = Convert.ToByte(tempByte | LAND_TYPE_PUBLIC);
545 } 545 }
546 else 546 else
547 { 547 {
548 //Other Flag 548 //Other Flag
549 tempByte = Convert.ToByte(tempByte | LAND_TYPE_OWNED_BY_OTHER); 549 tempByte = Convert.ToByte(tempByte | LAND_TYPE_OWNED_BY_OTHER);
550 } 550 }
551 551
552 552
553 //Now for border control 553 //Now for border control
554 try 554 try
555 { 555 {
556 ILandObject westParcel = null; 556 ILandObject westParcel = null;
557 ILandObject southParcel = null; 557 ILandObject southParcel = null;
558 if (x > 0) 558 if (x > 0)
559 { 559 {
560 westParcel = getLandObject((x - 1) * 4, y * 4); 560 westParcel = getLandObject((x - 1) * 4, y * 4);
561 } 561 }
562 if (y > 0) 562 if (y > 0)
563 { 563 {
564 southParcel = getLandObject(x * 4, (y - 1) * 4); 564 southParcel = getLandObject(x * 4, (y - 1) * 4);
565 } 565 }
566 566
567 if (x == 0) 567 if (x == 0)
568 { 568 {
569 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST); 569 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST);
570 } 570 }
571 else if (westParcel != null && westParcel != currentParcelBlock) 571 else if (westParcel != null && westParcel != currentParcelBlock)
572 { 572 {
573 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST); 573 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST);
574 } 574 }
575 575
576 if (y == 0) 576 if (y == 0)
577 { 577 {
578 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH); 578 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH);
579 } 579 }
580 else if (southParcel != null && southParcel != currentParcelBlock) 580 else if (southParcel != null && southParcel != currentParcelBlock)
581 { 581 {
582 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH); 582 tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH);
583 } 583 }
584 584
585 byteArray[byteArrayCount] = tempByte; 585 byteArray[byteArrayCount] = tempByte;
586 byteArrayCount++; 586 byteArrayCount++;
587 if (byteArrayCount >= LAND_BLOCKS_PER_PACKET) 587 if (byteArrayCount >= LAND_BLOCKS_PER_PACKET)
588 { 588 {
589 byteArrayCount = 0; 589 byteArrayCount = 0;
590 packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay); 590 packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
591 packet.ParcelData.Data = byteArray; 591 packet.ParcelData.Data = byteArray;
592 packet.ParcelData.SequenceID = sequenceID; 592 packet.ParcelData.SequenceID = sequenceID;
593 remote_client.OutPacket((Packet)packet, ThrottleOutPacketType.Task); 593 remote_client.OutPacket((Packet)packet, ThrottleOutPacketType.Task);
594 sequenceID++; 594 sequenceID++;
595 byteArray = new byte[LAND_BLOCKS_PER_PACKET]; 595 byteArray = new byte[LAND_BLOCKS_PER_PACKET];
596 } 596 }
597 } 597 }
598 catch (Exception e) 598 catch (Exception e)
599 { 599 {
600 //m_log.Debug("[LAND]: Skipped Land checks because avatar is out of bounds: " + e.Message); 600 //m_log.Debug("[LAND]: Skipped Land checks because avatar is out of bounds: " + e.Message);
601 } 601 }
602 } 602 }
603 } 603 }
604 } 604 }
605 } 605 }
606 606
607 public void handleParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, 607 public void handleParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id,
608 bool snap_selection, IClientAPI remote_client) 608 bool snap_selection, IClientAPI remote_client)
609 { 609 {
610 //Get the land objects within the bounds 610 //Get the land objects within the bounds
611 List<ILandObject> temp = new List<ILandObject>(); 611 List<ILandObject> temp = new List<ILandObject>();
612 int x, y, i; 612 int x, y, i;
613 int inc_x = end_x - start_x; 613 int inc_x = end_x - start_x;
614 int inc_y = end_y - start_y; 614 int inc_y = end_y - start_y;
615 for (x = 0; x < inc_x; x++) 615 for (x = 0; x < inc_x; x++)
616 { 616 {
617 for (y = 0; y < inc_y; y++) 617 for (y = 0; y < inc_y; y++)
618 { 618 {
619 619
620 ILandObject currentParcel = null; 620 ILandObject currentParcel = null;
621 try 621 try
622 { 622 {
623 currentParcel = getLandObject(start_x + x, start_y + y); 623 currentParcel = getLandObject(start_x + x, start_y + y);
624 } 624 }
625 catch (Exception) 625 catch (Exception)
626 { 626 {
627 //m_log.Warn("[LAND]: " + "unable to get land at x: " + (start_x + x) + " y: " + (start_y + y)); 627 //m_log.Warn("[LAND]: " + "unable to get land at x: " + (start_x + x) + " y: " + (start_y + y));
628 } 628 }
629 if (currentParcel != null) 629 if (currentParcel != null)
630 { 630 {
631 if (!temp.Contains(currentParcel)) 631 if (!temp.Contains(currentParcel))
632 { 632 {
633 currentParcel.forceUpdateLandInfo(); 633 currentParcel.forceUpdateLandInfo();
634 temp.Add(currentParcel); 634 temp.Add(currentParcel);
635 } 635 }
636 } 636 }
637 } 637 }
638 } 638 }
639 639
640 int requestResult = LAND_RESULT_SINGLE; 640 int requestResult = LAND_RESULT_SINGLE;
641 if (temp.Count > 1) 641 if (temp.Count > 1)
642 { 642 {
643 requestResult = LAND_RESULT_MULTIPLE; 643 requestResult = LAND_RESULT_MULTIPLE;
644 } 644 }
645 645
646 for (i = 0; i < temp.Count; i++) 646 for (i = 0; i < temp.Count; i++)
647 { 647 {
648 temp[i].sendLandProperties(sequence_id, snap_selection, requestResult, remote_client); 648 temp[i].sendLandProperties(sequence_id, snap_selection, requestResult, remote_client);
649 } 649 }
650 650
651 651
652 sendParcelOverlay(remote_client); 652 sendParcelOverlay(remote_client);
653 } 653 }
654 654
655 public void handleParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) 655 public void handleParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client)
656 { 656 {
657 if (landList.ContainsKey(packet.ParcelData.LocalID)) 657 if (landList.ContainsKey(packet.ParcelData.LocalID))
658 { 658 {
659 landList[packet.ParcelData.LocalID].updateLandProperties(packet, remote_client); 659 landList[packet.ParcelData.LocalID].updateLandProperties(packet, remote_client);
660 } 660 }
661 } 661 }
662 662
663 public void handleParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client) 663 public void handleParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client)
664 { 664 {
665 subdivide(west, south, east, north, remote_client.AgentId); 665 subdivide(west, south, east, north, remote_client.AgentId);
666 } 666 }
667 667
668 public void handleParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client) 668 public void handleParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client)
669 { 669 {
670 join(west, south, east, north, remote_client.AgentId); 670 join(west, south, east, north, remote_client.AgentId);
671 } 671 }
672 672
673 public void handleParcelSelectObjectsRequest(int local_id, int request_type, IClientAPI remote_client) 673 public void handleParcelSelectObjectsRequest(int local_id, int request_type, IClientAPI remote_client)
674 { 674 {
675 landList[local_id].sendForceObjectSelect(local_id, request_type, remote_client); 675 landList[local_id].sendForceObjectSelect(local_id, request_type, remote_client);
676 } 676 }
677 677
678 public void handleParcelObjectOwnersRequest(int local_id, IClientAPI remote_client) 678 public void handleParcelObjectOwnersRequest(int local_id, IClientAPI remote_client)
679 { 679 {
680 landList[local_id].sendLandObjectOwners(remote_client); 680 landList[local_id].sendLandObjectOwners(remote_client);
681 } 681 }
682 682
683 #endregion 683 #endregion
684 684
685 /// <summary> 685 /// <summary>
686 /// Resets the sim to the default land object (full sim piece of land owned by the default user) 686 /// Resets the sim to the default land object (full sim piece of land owned by the default user)
687 /// </summary> 687 /// </summary>
688 public void resetSimLandObjects() 688 public void resetSimLandObjects()
689 { 689 {
690 //Remove all the land objects in the sim and add a blank, full sim land object set to public 690 //Remove all the land objects in the sim and add a blank, full sim land object set to public
691 landList.Clear(); 691 landList.Clear();
692 lastLandLocalID = START_LAND_LOCAL_ID - 1; 692 lastLandLocalID = START_LAND_LOCAL_ID - 1;
693 landIDList.Initialize(); 693 landIDList.Initialize();
694 694
695 ILandObject fullSimParcel = new LandObject(LLUUID.Zero, false, m_scene); 695 ILandObject fullSimParcel = new LandObject(LLUUID.Zero, false, m_scene);
696 696
697 fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); 697 fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
698 fullSimParcel.landData.ownerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; 698 fullSimParcel.landData.ownerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
699 699
700 addLandObject(fullSimParcel); 700 addLandObject(fullSimParcel);
701 } 701 }
702 702
703 public List<ILandObject> parcelsNearPoint(LLVector3 position) 703 public List<ILandObject> parcelsNearPoint(LLVector3 position)
704 { 704 {
705 List<ILandObject> parcelsNear = new List<ILandObject>(); 705 List<ILandObject> parcelsNear = new List<ILandObject>();
706 int x, y; 706 int x, y;
707 for (x = -4; x <= 4; x += 4) 707 for (x = -4; x <= 4; x += 4)
708 { 708 {
709 for (y = -4; y <= 4; y += 4) 709 for (y = -4; y <= 4; y += 4)
710 { 710 {
711 ILandObject check = getLandObject(position.X + x, position.Y + y); 711 ILandObject check = getLandObject(position.X + x, position.Y + y);
712 if (check != null) 712 if (check != null)
713 { 713 {
714 if (!parcelsNear.Contains(check)) 714 if (!parcelsNear.Contains(check))
715 { 715 {
716 parcelsNear.Add(check); 716 parcelsNear.Add(check);
717 } 717 }
718 } 718 }
719 } 719 }
720 } 720 }
721 721
722 return parcelsNear; 722 return parcelsNear;
723 } 723 }
724 724
725 public void sendYouAreBannedNotice(ScenePresence avatar) 725 public void sendYouAreBannedNotice(ScenePresence avatar)
726 { 726 {
727 if (allowedForcefulBans) 727 if (allowedForcefulBans)
728 { 728 {
729 avatar.ControllingClient.SendAlertMessage( 729 avatar.ControllingClient.SendAlertMessage(
730 "You are not allowed on this parcel because you are banned. Please go away. <3 OpenSim Developers"); 730 "You are not allowed on this parcel because you are banned. Please go away. <3 OpenSim Developers");
731 731
732 avatar.PhysicsActor.Position = 732 avatar.PhysicsActor.Position =
733 new PhysicsVector(avatar.lastKnownAllowedPosition.x, avatar.lastKnownAllowedPosition.y, 733 new PhysicsVector(avatar.lastKnownAllowedPosition.x, avatar.lastKnownAllowedPosition.y,
734 avatar.lastKnownAllowedPosition.z); 734 avatar.lastKnownAllowedPosition.z);
735 avatar.PhysicsActor.Velocity = new PhysicsVector(0, 0, 0); 735 avatar.PhysicsActor.Velocity = new PhysicsVector(0, 0, 0);
736 } 736 }
737 else 737 else
738 { 738 {
739 avatar.ControllingClient.SendAlertMessage( 739 avatar.ControllingClient.SendAlertMessage(
740 "You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim! <3 OpenSim Developers"); 740 "You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim! <3 OpenSim Developers");
741 } 741 }
742 } 742 }
743 743
744 public void handleAvatarChangingParcel(ScenePresence avatar, int localLandID, LLUUID regionID) 744 public void handleAvatarChangingParcel(ScenePresence avatar, int localLandID, LLUUID regionID)
745 { 745 {
746 if (m_scene.RegionInfo.RegionID == regionID) 746 if (m_scene.RegionInfo.RegionID == regionID)
747 { 747 {
748 if (landList[localLandID] != null) 748 if (landList[localLandID] != null)
749 { 749 {
750 ILandObject parcelAvatarIsEntering = landList[localLandID]; 750 ILandObject parcelAvatarIsEntering = landList[localLandID];
751 if (avatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT) 751 if (avatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT)
752 { 752 {
753 if (parcelAvatarIsEntering.isBannedFromLand(avatar.UUID)) 753 if (parcelAvatarIsEntering.isBannedFromLand(avatar.UUID))
754 { 754 {
755 sendYouAreBannedNotice(avatar); 755 sendYouAreBannedNotice(avatar);
756 } 756 }
757 else if (parcelAvatarIsEntering.isRestrictedFromLand(avatar.UUID)) 757 else if (parcelAvatarIsEntering.isRestrictedFromLand(avatar.UUID))
758 { 758 {
759 avatar.ControllingClient.SendAlertMessage( 759 avatar.ControllingClient.SendAlertMessage(
760 "You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!). <3 OpenSim Developers"); 760 "You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!). <3 OpenSim Developers");
761 } 761 }
762 else 762 else
763 { 763 {
764 avatar.sentMessageAboutRestrictedParcelFlyingDown = true; 764 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
765 } 765 }
766 } 766 }
767 else 767 else
768 { 768 {
769 avatar.sentMessageAboutRestrictedParcelFlyingDown = true; 769 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
770 } 770 }
771 } 771 }
772 } 772 }
773 } 773 }
774 774
775 public void sendOutNearestBanLine(IClientAPI avatar) 775 public void sendOutNearestBanLine(IClientAPI avatar)
776 { 776 {
777 List<ScenePresence> avatars = m_scene.GetAvatars(); 777 List<ScenePresence> avatars = m_scene.GetAvatars();
778 foreach (ScenePresence presence in avatars) 778 foreach (ScenePresence presence in avatars)
779 { 779 {
780 if (presence.UUID == avatar.AgentId) 780 if (presence.UUID == avatar.AgentId)
781 { 781 {
782 782
783 List<ILandObject> checkLandParcels = parcelsNearPoint(presence.AbsolutePosition); 783 List<ILandObject> checkLandParcels = parcelsNearPoint(presence.AbsolutePosition);
784 foreach (ILandObject checkBan in checkLandParcels) 784 foreach (ILandObject checkBan in checkLandParcels)
785 { 785 {
786 if (checkBan.isBannedFromLand(avatar.AgentId)) 786 if (checkBan.isBannedFromLand(avatar.AgentId))
787 { 787 {
788 checkBan.sendLandProperties(-30000, false, (int)ParcelManager.ParcelResult.Single, avatar); 788 checkBan.sendLandProperties(-30000, false, (int)ParcelManager.ParcelResult.Single, avatar);
789 return; //Only send one 789 return; //Only send one
790 } 790 }
791 else if (checkBan.isRestrictedFromLand(avatar.AgentId)) 791 else if (checkBan.isRestrictedFromLand(avatar.AgentId))
792 { 792 {
793 checkBan.sendLandProperties(-40000, false, (int)ParcelManager.ParcelResult.Single, avatar); 793 checkBan.sendLandProperties(-40000, false, (int)ParcelManager.ParcelResult.Single, avatar);
794 return; //Only send one 794 return; //Only send one
795 } 795 }
796 } 796 }
797 return; 797 return;
798 } 798 }
799 } 799 }
800 } 800 }
801 801
802 public void sendLandUpdate(ScenePresence avatar, bool force) 802 public void sendLandUpdate(ScenePresence avatar, bool force)
803 { 803 {
804 ILandObject over = null; 804 ILandObject over = null;
805 try 805 try
806 { 806 {
807 over = getLandObject((int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), 807 over = getLandObject((int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
808 (int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); 808 (int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
809 } 809 }
810 catch (Exception) 810 catch (Exception)
811 { 811 {
812 //m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatar.AbsolutePosition.X) + " y: " + Math.Round(avatar.AbsolutePosition.Y)); 812 //m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatar.AbsolutePosition.X) + " y: " + Math.Round(avatar.AbsolutePosition.Y));
813 } 813 }
814 814
815 if (over != null) 815 if (over != null)
816 { 816 {
817 if (force) 817 if (force)
818 { 818 {
819 if (!avatar.IsChildAgent) 819 if (!avatar.IsChildAgent)
820 { 820 {
821 over.sendLandUpdateToClient(avatar.ControllingClient); 821 over.sendLandUpdateToClient(avatar.ControllingClient);
822 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID, 822 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID,
823 m_scene.RegionInfo.RegionID); 823 m_scene.RegionInfo.RegionID);
824 } 824 }
825 } 825 }
826 826
827 if (avatar.currentParcelUUID != over.landData.globalID) 827 if (avatar.currentParcelUUID != over.landData.globalID)
828 { 828 {
829 if (!avatar.IsChildAgent) 829 if (!avatar.IsChildAgent)
830 { 830 {
831 over.sendLandUpdateToClient(avatar.ControllingClient); 831 over.sendLandUpdateToClient(avatar.ControllingClient);
832 avatar.currentParcelUUID = over.landData.globalID; 832 avatar.currentParcelUUID = over.landData.globalID;
833 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID, 833 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID,
834 m_scene.RegionInfo.RegionID); 834 m_scene.RegionInfo.RegionID);
835 } 835 }
836 } 836 }
837 } 837 }
838 } 838 }
839 public void sendLandUpdate(ScenePresence avatar) 839 public void sendLandUpdate(ScenePresence avatar)
840 { 840 {
841 sendLandUpdate(avatar, false); 841 sendLandUpdate(avatar, false);
842 842
843 } 843 }
844 public void handleSignificantClientMovement(IClientAPI remote_client) 844 public void handleSignificantClientMovement(IClientAPI remote_client)
845 { 845 {
846 ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId); 846 ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId);
847 847
848 if (clientAvatar != null) 848 if (clientAvatar != null)
849 { 849 {
850 sendLandUpdate(clientAvatar); 850 sendLandUpdate(clientAvatar);
851 sendOutNearestBanLine(remote_client); 851 sendOutNearestBanLine(remote_client);
852 ILandObject parcel = getLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); 852 ILandObject parcel = getLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y);
853 if (parcel != null) 853 if (parcel != null)
854 { 854 {
855 if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && 855 if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT &&
856 clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) 856 clientAvatar.sentMessageAboutRestrictedParcelFlyingDown)
857 { 857 {
858 handleAvatarChangingParcel(clientAvatar, parcel.landData.localID, m_scene.RegionInfo.RegionID); 858 handleAvatarChangingParcel(clientAvatar, parcel.landData.localID, m_scene.RegionInfo.RegionID);
859 //They are going below the safety line! 859 //They are going below the safety line!
860 if (!parcel.isBannedFromLand(clientAvatar.UUID)) 860 if (!parcel.isBannedFromLand(clientAvatar.UUID))
861 { 861 {
862 clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false; 862 clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false;
863 } 863 }
864 } 864 }
865 else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && 865 else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT &&
866 parcel.isBannedFromLand(clientAvatar.UUID)) 866 parcel.isBannedFromLand(clientAvatar.UUID))
867 { 867 {
868 sendYouAreBannedNotice(clientAvatar); 868 sendYouAreBannedNotice(clientAvatar);
869 } 869 }
870 } 870 }
871 } 871 }
872 } 872 }
873 873
874 public void handleAnyClientMovement(ScenePresence avatar) 874 public void handleAnyClientMovement(ScenePresence avatar)
875 //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance. 875 //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance.
876 { 876 {
877 ILandObject over = getLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 877 ILandObject over = getLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
878 if (over != null) 878 if (over != null)
879 { 879 {
880 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)
881 { 881 {
882 avatar.lastKnownAllowedPosition = 882 avatar.lastKnownAllowedPosition =
883 new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); 883 new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z);
884 } 884 }
885 } 885 }
886 } 886 }
887 887
888 888
889 public void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, 889 public void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID,
890 int landLocalID, IClientAPI remote_client) 890 int landLocalID, IClientAPI remote_client)
891 { 891 {
892 if (landList.ContainsKey(landLocalID)) 892 if (landList.ContainsKey(landLocalID))
893 { 893 {
894 landList[landLocalID].sendAccessList(agentID, sessionID, flags, sequenceID, remote_client); 894 landList[landLocalID].sendAccessList(agentID, sessionID, flags, sequenceID, remote_client);
895 } 895 }
896 } 896 }
897 897
898 public void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID, uint flags, int landLocalID, 898 public void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID, uint flags, int landLocalID,
899 List<ParcelManager.ParcelAccessEntry> entries, 899 List<ParcelManager.ParcelAccessEntry> entries,
900 IClientAPI remote_client) 900 IClientAPI remote_client)
901 { 901 {
902 if (landList.ContainsKey(landLocalID)) 902 if (landList.ContainsKey(landLocalID))
903 { 903 {
904 if (agentID == landList[landLocalID].landData.ownerID) 904 if (agentID == landList[landLocalID].landData.ownerID)
905 { 905 {
906 landList[landLocalID].updateAccessList(flags, entries, remote_client); 906 landList[landLocalID].updateAccessList(flags, entries, remote_client);
907 } 907 }
908 } 908 }
909 else 909 else
910 { 910 {
911 Console.WriteLine("INVALID LOCAL LAND ID"); 911 Console.WriteLine("INVALID LOCAL LAND ID");
912 } 912 }
913 } 913 }
914 914
915 } 915 }
916} 916}
diff --git a/OpenSim/Region/Environment/Modules/LandManagement/LandManagementModule.cs b/OpenSim/Region/Environment/Modules/LandManagement/LandManagementModule.cs
index ac8c1a8..614929b 100644
--- a/OpenSim/Region/Environment/Modules/LandManagement/LandManagementModule.cs
+++ b/OpenSim/Region/Environment/Modules/LandManagement/LandManagementModule.cs
@@ -1,62 +1,62 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using libsecondlife; 3using libsecondlife;
4using libsecondlife.Packets; 4using libsecondlife.Packets;
5using OpenSim.Framework; 5using OpenSim.Framework;
6using OpenSim.Framework.Console; 6using OpenSim.Framework.Console;
7using OpenSim.Region.Environment.Scenes; 7using OpenSim.Region.Environment.Scenes;
8using OpenSim.Region.Environment.Interfaces; 8using OpenSim.Region.Environment.Interfaces;
9using Nini.Config; 9using Nini.Config;
10 10
11namespace OpenSim.Region.Environment.Modules.LandManagement 11namespace OpenSim.Region.Environment.Modules.LandManagement
12{ 12{
13 public class LandManagementModule : IRegionModule 13 public class LandManagementModule : IRegionModule
14 { 14 {
15 private LandChannel landChannel; 15 private LandChannel landChannel;
16 private Scene m_scene; 16 private Scene m_scene;
17 17
18 #region IRegionModule Members 18 #region IRegionModule Members
19 19
20 public void Initialise(Scene scene, IConfigSource source) 20 public void Initialise(Scene scene, IConfigSource source)
21 { 21 {
22 m_scene = scene; 22 m_scene = scene;
23 landChannel = new LandChannel(scene); 23 landChannel = new LandChannel(scene);
24 24
25 m_scene.EventManager.OnParcelPrimCountAdd += landChannel.addPrimToLandPrimCounts; 25 m_scene.EventManager.OnParcelPrimCountAdd += landChannel.addPrimToLandPrimCounts;
26 m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts; 26 m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts;
27 m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel); 27 m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel);
28 m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(landChannel.handleAnyClientMovement); 28 m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(landChannel.handleAnyClientMovement);
29 29
30 lock (m_scene) 30 lock (m_scene)
31 { 31 {
32 m_scene.LandChannel = (ILandChannel)landChannel; 32 m_scene.LandChannel = (ILandChannel)landChannel;
33 } 33 }
34 } 34 }
35 35
36 public void PostInitialise() 36 public void PostInitialise()
37 { 37 {
38 38
39 } 39 }
40 40
41 public void Close() 41 public void Close()
42 { 42 {
43 43
44 } 44 }
45 45
46 public string Name 46 public string Name
47 { 47 {
48 get { return "LandManagementModule"; } 48 get { return "LandManagementModule"; }
49 } 49 }
50 50
51 public bool IsSharedModule 51 public bool IsSharedModule
52 { 52 {
53 get { return false; } 53 get { return false; }
54 } 54 }
55 55
56 56
57 57
58 58
59 59
60 #endregion 60 #endregion
61 } 61 }
62} 62}
diff --git a/OpenSim/Region/Environment/Modules/LandManagement/LandObject.cs b/OpenSim/Region/Environment/Modules/LandManagement/LandObject.cs
index 4e2fbd3..1311fd3 100644
--- a/OpenSim/Region/Environment/Modules/LandManagement/LandObject.cs
+++ b/OpenSim/Region/Environment/Modules/LandManagement/LandObject.cs
@@ -1,879 +1,879 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using libsecondlife; 30using libsecondlife;
31using libsecondlife.Packets; 31using libsecondlife.Packets;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Console; 33using OpenSim.Framework.Console;
34using OpenSim.Region.Environment.Scenes; 34using OpenSim.Region.Environment.Scenes;
35using OpenSim.Region.Environment.Interfaces; 35using OpenSim.Region.Environment.Interfaces;
36 36
37namespace OpenSim.Region.Environment.Modules.LandManagement 37namespace OpenSim.Region.Environment.Modules.LandManagement
38{ 38{
39 39
40 #region LandObject Class 40 #region LandObject Class
41 41
42 /// <summary> 42 /// <summary>
43 /// Keeps track of a specific piece of land's information 43 /// Keeps track of a specific piece of land's information
44 /// </summary> 44 /// </summary>
45 public class LandObject : ILandObject 45 public class LandObject : ILandObject
46 { 46 {
47 #region Member Variables 47 #region Member Variables
48 48
49 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 protected LandData m_landData = new LandData(); 51 protected LandData m_landData = new LandData();
52 protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); 52 protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
53 protected Scene m_scene; 53 protected Scene m_scene;
54 54
55 private bool[,] m_landBitmap = new bool[64,64]; 55 private bool[,] m_landBitmap = new bool[64,64];
56 56
57 public bool[,] landBitmap 57 public bool[,] landBitmap
58 { 58 {
59 get 59 get
60 { 60 {
61 return m_landBitmap; 61 return m_landBitmap;
62 } 62 }
63 set 63 set
64 { 64 {
65 m_landBitmap = value; 65 m_landBitmap = value;
66 } 66 }
67 } 67 }
68 68
69 #endregion 69 #endregion
70 70
71 #region ILandObject Members 71 #region ILandObject Members
72 72
73 public LandData landData 73 public LandData landData
74 { 74 {
75 get 75 get
76 { 76 {
77 return m_landData; 77 return m_landData;
78 } 78 }
79 79
80 set 80 set
81 { 81 {
82 m_landData = value; 82 m_landData = value;
83 } 83 }
84 } 84 }
85 85
86 public LLUUID regionUUID 86 public LLUUID regionUUID
87 { 87 {
88 get { return m_scene.RegionInfo.RegionID; } 88 get { return m_scene.RegionInfo.RegionID; }
89 } 89 }
90 90
91 #endregion 91 #endregion
92 92
93 93
94 #region Constructors 94 #region Constructors
95 95
96 public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene) 96 public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene)
97 { 97 {
98 m_scene = scene; 98 m_scene = scene;
99 landData.ownerID = owner_id; 99 landData.ownerID = owner_id;
100 landData.isGroupOwned = is_group_owned; 100 landData.isGroupOwned = is_group_owned;
101 } 101 }
102 102
103 #endregion 103 #endregion
104 104
105 #region Member Functions 105 #region Member Functions
106 106
107 #region General Functions 107 #region General Functions
108 108
109 /// <summary> 109 /// <summary>
110 /// Checks to see if this land object contains a point 110 /// Checks to see if this land object contains a point
111 /// </summary> 111 /// </summary>
112 /// <param name="x"></param> 112 /// <param name="x"></param>
113 /// <param name="y"></param> 113 /// <param name="y"></param>
114 /// <returns>Returns true if the piece of land contains the specified point</returns> 114 /// <returns>Returns true if the piece of land contains the specified point</returns>
115 public bool containsPoint(int x, int y) 115 public bool containsPoint(int x, int y)
116 { 116 {
117 if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize) 117 if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize)
118 { 118 {
119 return (landBitmap[x/4, y/4] == true); 119 return (landBitmap[x/4, y/4] == true);
120 } 120 }
121 else 121 else
122 { 122 {
123 return false; 123 return false;
124 } 124 }
125 } 125 }
126 126
127 public ILandObject Copy() 127 public ILandObject Copy()
128 { 128 {
129 ILandObject newLand = new LandObject(landData.ownerID, landData.isGroupOwned, m_scene); 129 ILandObject newLand = new LandObject(landData.ownerID, landData.isGroupOwned, m_scene);
130 130
131 //Place all new variables here! 131 //Place all new variables here!
132 newLand.landBitmap = (bool[,]) (landBitmap.Clone()); 132 newLand.landBitmap = (bool[,]) (landBitmap.Clone());
133 newLand.landData = landData.Copy(); 133 newLand.landData = landData.Copy();
134 134
135 return newLand; 135 return newLand;
136 } 136 }
137 137
138 #endregion 138 #endregion
139 139
140 #region Packet Request Handling 140 #region Packet Request Handling
141 141
142 /// <summary> 142 /// <summary>
143 /// Sends land properties as requested 143 /// Sends land properties as requested
144 /// </summary> 144 /// </summary>
145 /// <param name="sequence_id">ID sent by client for them to keep track of</param> 145 /// <param name="sequence_id">ID sent by client for them to keep track of</param>
146 /// <param name="snap_selection">Bool sent by client for them to use</param> 146 /// <param name="snap_selection">Bool sent by client for them to use</param>
147 /// <param name="remote_client">Object representing the client</param> 147 /// <param name="remote_client">Object representing the client</param>
148 public void sendLandProperties(int sequence_id, bool snap_selection, int request_result, 148 public void sendLandProperties(int sequence_id, bool snap_selection, int request_result,
149 IClientAPI remote_client) 149 IClientAPI remote_client)
150 { 150 {
151 ParcelPropertiesPacket updatePacket = (ParcelPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ParcelProperties); 151 ParcelPropertiesPacket updatePacket = (ParcelPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ParcelProperties);
152 // TODO: don't create new blocks if recycling an old packet 152 // TODO: don't create new blocks if recycling an old packet
153 153
154 updatePacket.ParcelData.AABBMax = landData.AABBMax; 154 updatePacket.ParcelData.AABBMax = landData.AABBMax;
155 updatePacket.ParcelData.AABBMin = landData.AABBMin; 155 updatePacket.ParcelData.AABBMin = landData.AABBMin;
156 updatePacket.ParcelData.Area = landData.area; 156 updatePacket.ParcelData.Area = landData.area;
157 updatePacket.ParcelData.AuctionID = landData.auctionID; 157 updatePacket.ParcelData.AuctionID = landData.auctionID;
158 updatePacket.ParcelData.AuthBuyerID = landData.authBuyerID; //unemplemented 158 updatePacket.ParcelData.AuthBuyerID = landData.authBuyerID; //unemplemented
159 159
160 updatePacket.ParcelData.Bitmap = landData.landBitmapByteArray; 160 updatePacket.ParcelData.Bitmap = landData.landBitmapByteArray;
161 161
162 updatePacket.ParcelData.Desc = Helpers.StringToField(landData.landDesc); 162 updatePacket.ParcelData.Desc = Helpers.StringToField(landData.landDesc);
163 updatePacket.ParcelData.Category = (byte) landData.category; 163 updatePacket.ParcelData.Category = (byte) landData.category;
164 updatePacket.ParcelData.ClaimDate = landData.claimDate; 164 updatePacket.ParcelData.ClaimDate = landData.claimDate;
165 updatePacket.ParcelData.ClaimPrice = landData.claimPrice; 165 updatePacket.ParcelData.ClaimPrice = landData.claimPrice;
166 updatePacket.ParcelData.GroupID = landData.groupID; 166 updatePacket.ParcelData.GroupID = landData.groupID;
167 updatePacket.ParcelData.GroupPrims = landData.groupPrims; 167 updatePacket.ParcelData.GroupPrims = landData.groupPrims;
168 updatePacket.ParcelData.IsGroupOwned = landData.isGroupOwned; 168 updatePacket.ParcelData.IsGroupOwned = landData.isGroupOwned;
169 updatePacket.ParcelData.LandingType = (byte) landData.landingType; 169 updatePacket.ParcelData.LandingType = (byte) landData.landingType;
170 updatePacket.ParcelData.LocalID = landData.localID; 170 updatePacket.ParcelData.LocalID = landData.localID;
171 if (landData.area > 0) 171 if (landData.area > 0)
172 { 172 {
173 updatePacket.ParcelData.MaxPrims = 173 updatePacket.ParcelData.MaxPrims =
174 Convert.ToInt32( 174 Convert.ToInt32(
175 Math.Round((Convert.ToDecimal(landData.area)/Convert.ToDecimal(65536))*15000* 175 Math.Round((Convert.ToDecimal(landData.area)/Convert.ToDecimal(65536))*15000*
176 Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor))); 176 Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor)));
177 } 177 }
178 else 178 else
179 { 179 {
180 updatePacket.ParcelData.MaxPrims = 0; 180 updatePacket.ParcelData.MaxPrims = 0;
181 } 181 }
182 updatePacket.ParcelData.MediaAutoScale = landData.mediaAutoScale; 182 updatePacket.ParcelData.MediaAutoScale = landData.mediaAutoScale;
183 updatePacket.ParcelData.MediaID = landData.mediaID; 183 updatePacket.ParcelData.MediaID = landData.mediaID;
184 updatePacket.ParcelData.MediaURL = Helpers.StringToField(landData.mediaURL); 184 updatePacket.ParcelData.MediaURL = Helpers.StringToField(landData.mediaURL);
185 updatePacket.ParcelData.MusicURL = Helpers.StringToField(landData.musicURL); 185 updatePacket.ParcelData.MusicURL = Helpers.StringToField(landData.musicURL);
186 updatePacket.ParcelData.Name = Helpers.StringToField(landData.landName); 186 updatePacket.ParcelData.Name = Helpers.StringToField(landData.landName);
187 updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented 187 updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented
188 updatePacket.ParcelData.OtherCount = 0; //unemplemented 188 updatePacket.ParcelData.OtherCount = 0; //unemplemented
189 updatePacket.ParcelData.OtherPrims = landData.otherPrims; 189 updatePacket.ParcelData.OtherPrims = landData.otherPrims;
190 updatePacket.ParcelData.OwnerID = landData.ownerID; 190 updatePacket.ParcelData.OwnerID = landData.ownerID;
191 updatePacket.ParcelData.OwnerPrims = landData.ownerPrims; 191 updatePacket.ParcelData.OwnerPrims = landData.ownerPrims;
192 updatePacket.ParcelData.ParcelFlags = landData.landFlags; 192 updatePacket.ParcelData.ParcelFlags = landData.landFlags;
193 updatePacket.ParcelData.ParcelPrimBonus = m_scene.RegionInfo.EstateSettings.objectBonusFactor; 193 updatePacket.ParcelData.ParcelPrimBonus = m_scene.RegionInfo.EstateSettings.objectBonusFactor;
194 updatePacket.ParcelData.PassHours = landData.passHours; 194 updatePacket.ParcelData.PassHours = landData.passHours;
195 updatePacket.ParcelData.PassPrice = landData.passPrice; 195 updatePacket.ParcelData.PassPrice = landData.passPrice;
196 updatePacket.ParcelData.PublicCount = 0; //unemplemented 196 updatePacket.ParcelData.PublicCount = 0; //unemplemented
197 197
198 uint regionFlags = (uint) m_scene.RegionInfo.EstateSettings.regionFlags; 198 uint regionFlags = (uint) m_scene.RegionInfo.EstateSettings.regionFlags;
199 updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint) Simulator.RegionFlags.DenyAnonymous) > 199 updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint) Simulator.RegionFlags.DenyAnonymous) >
200 0); 200 0);
201 updatePacket.ParcelData.RegionDenyIdentified = ((regionFlags & (uint) Simulator.RegionFlags.DenyIdentified) > 201 updatePacket.ParcelData.RegionDenyIdentified = ((regionFlags & (uint) Simulator.RegionFlags.DenyIdentified) >
202 0); 202 0);
203 updatePacket.ParcelData.RegionDenyTransacted = ((regionFlags & (uint) Simulator.RegionFlags.DenyTransacted) > 203 updatePacket.ParcelData.RegionDenyTransacted = ((regionFlags & (uint) Simulator.RegionFlags.DenyTransacted) >
204 0); 204 0);
205 updatePacket.ParcelData.RegionPushOverride = ((regionFlags & (uint) Simulator.RegionFlags.RestrictPushObject) > 205 updatePacket.ParcelData.RegionPushOverride = ((regionFlags & (uint) Simulator.RegionFlags.RestrictPushObject) >
206 0); 206 0);
207 207
208 updatePacket.ParcelData.RentPrice = 0; 208 updatePacket.ParcelData.RentPrice = 0;
209 updatePacket.ParcelData.RequestResult = request_result; 209 updatePacket.ParcelData.RequestResult = request_result;
210 updatePacket.ParcelData.SalePrice = landData.salePrice; 210 updatePacket.ParcelData.SalePrice = landData.salePrice;
211 updatePacket.ParcelData.SelectedPrims = landData.selectedPrims; 211 updatePacket.ParcelData.SelectedPrims = landData.selectedPrims;
212 updatePacket.ParcelData.SelfCount = 0; //unemplemented 212 updatePacket.ParcelData.SelfCount = 0; //unemplemented
213 updatePacket.ParcelData.SequenceID = sequence_id; 213 updatePacket.ParcelData.SequenceID = sequence_id;
214 if (landData.simwideArea > 0) 214 if (landData.simwideArea > 0)
215 { 215 {
216 updatePacket.ParcelData.SimWideMaxPrims = 216 updatePacket.ParcelData.SimWideMaxPrims =
217 Convert.ToInt32( 217 Convert.ToInt32(
218 Math.Round((Convert.ToDecimal(landData.simwideArea)/Convert.ToDecimal(65536))*15000* 218 Math.Round((Convert.ToDecimal(landData.simwideArea)/Convert.ToDecimal(65536))*15000*
219 Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor))); 219 Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor)));
220 } 220 }
221 else 221 else
222 { 222 {
223 updatePacket.ParcelData.SimWideMaxPrims = 0; 223 updatePacket.ParcelData.SimWideMaxPrims = 0;
224 } 224 }
225 updatePacket.ParcelData.SimWideTotalPrims = landData.simwidePrims; 225 updatePacket.ParcelData.SimWideTotalPrims = landData.simwidePrims;
226 updatePacket.ParcelData.SnapSelection = snap_selection; 226 updatePacket.ParcelData.SnapSelection = snap_selection;
227 updatePacket.ParcelData.SnapshotID = landData.snapshotID; 227 updatePacket.ParcelData.SnapshotID = landData.snapshotID;
228 updatePacket.ParcelData.Status = (byte) landData.landStatus; 228 updatePacket.ParcelData.Status = (byte) landData.landStatus;
229 updatePacket.ParcelData.TotalPrims = landData.ownerPrims + landData.groupPrims + landData.otherPrims + 229 updatePacket.ParcelData.TotalPrims = landData.ownerPrims + landData.groupPrims + landData.otherPrims +
230 landData.selectedPrims; 230 landData.selectedPrims;
231 updatePacket.ParcelData.UserLocation = landData.userLocation; 231 updatePacket.ParcelData.UserLocation = landData.userLocation;
232 updatePacket.ParcelData.UserLookAt = landData.userLookAt; 232 updatePacket.ParcelData.UserLookAt = landData.userLookAt;
233 remote_client.OutPacket((Packet) updatePacket, ThrottleOutPacketType.Task); 233 remote_client.OutPacket((Packet) updatePacket, ThrottleOutPacketType.Task);
234 } 234 }
235 235
236 public void updateLandProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) 236 public void updateLandProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client)
237 { 237 {
238 if (remote_client.AgentId == landData.ownerID) 238 if (remote_client.AgentId == landData.ownerID)
239 { 239 {
240 //Needs later group support 240 //Needs later group support
241 LandData newData = landData.Copy(); 241 LandData newData = landData.Copy();
242 newData.authBuyerID = packet.ParcelData.AuthBuyerID; 242 newData.authBuyerID = packet.ParcelData.AuthBuyerID;
243 newData.category = (Parcel.ParcelCategory) packet.ParcelData.Category; 243 newData.category = (Parcel.ParcelCategory) packet.ParcelData.Category;
244 newData.landDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc); 244 newData.landDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc);
245 newData.groupID = packet.ParcelData.GroupID; 245 newData.groupID = packet.ParcelData.GroupID;
246 newData.landingType = packet.ParcelData.LandingType; 246 newData.landingType = packet.ParcelData.LandingType;
247 newData.mediaAutoScale = packet.ParcelData.MediaAutoScale; 247 newData.mediaAutoScale = packet.ParcelData.MediaAutoScale;
248 newData.mediaID = packet.ParcelData.MediaID; 248 newData.mediaID = packet.ParcelData.MediaID;
249 newData.mediaURL = Helpers.FieldToUTF8String(packet.ParcelData.MediaURL); 249 newData.mediaURL = Helpers.FieldToUTF8String(packet.ParcelData.MediaURL);
250 newData.musicURL = Helpers.FieldToUTF8String(packet.ParcelData.MusicURL); 250 newData.musicURL = Helpers.FieldToUTF8String(packet.ParcelData.MusicURL);
251 newData.landName = Helpers.FieldToUTF8String(packet.ParcelData.Name); 251 newData.landName = Helpers.FieldToUTF8String(packet.ParcelData.Name);
252 newData.landFlags = packet.ParcelData.ParcelFlags; 252 newData.landFlags = packet.ParcelData.ParcelFlags;
253 newData.passHours = packet.ParcelData.PassHours; 253 newData.passHours = packet.ParcelData.PassHours;
254 newData.passPrice = packet.ParcelData.PassPrice; 254 newData.passPrice = packet.ParcelData.PassPrice;
255 newData.salePrice = packet.ParcelData.SalePrice; 255 newData.salePrice = packet.ParcelData.SalePrice;
256 newData.snapshotID = packet.ParcelData.SnapshotID; 256 newData.snapshotID = packet.ParcelData.SnapshotID;
257 newData.userLocation = packet.ParcelData.UserLocation; 257 newData.userLocation = packet.ParcelData.UserLocation;
258 newData.userLookAt = packet.ParcelData.UserLookAt; 258 newData.userLookAt = packet.ParcelData.UserLookAt;
259 259
260 m_scene.LandChannel.updateLandObject(landData.localID, newData); 260 m_scene.LandChannel.updateLandObject(landData.localID, newData);
261 261
262 sendLandUpdateToAvatarsOverMe(); 262 sendLandUpdateToAvatarsOverMe();
263 } 263 }
264 } 264 }
265 265
266 public bool isEitherBannedOrRestricted(LLUUID avatar) 266 public bool isEitherBannedOrRestricted(LLUUID avatar)
267 { 267 {
268 if (isBannedFromLand(avatar)) 268 if (isBannedFromLand(avatar))
269 { 269 {
270 return true; 270 return true;
271 } 271 }
272 else if (isRestrictedFromLand(avatar)) 272 else if (isRestrictedFromLand(avatar))
273 { 273 {
274 return true; 274 return true;
275 } 275 }
276 return false; 276 return false;
277 } 277 }
278 278
279 public bool isBannedFromLand(LLUUID avatar) 279 public bool isBannedFromLand(LLUUID avatar)
280 { 280 {
281 if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseBanList) > 0) 281 if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseBanList) > 0)
282 { 282 {
283 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); 283 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
284 entry.AgentID = avatar; 284 entry.AgentID = avatar;
285 entry.Flags = ParcelManager.AccessList.Ban; 285 entry.Flags = ParcelManager.AccessList.Ban;
286 entry.Time = new DateTime(); 286 entry.Time = new DateTime();
287 if (landData.parcelAccessList.Contains(entry)) 287 if (landData.parcelAccessList.Contains(entry))
288 { 288 {
289 //They are banned, so lets send them a notice about this parcel 289 //They are banned, so lets send them a notice about this parcel
290 return true; 290 return true;
291 } 291 }
292 } 292 }
293 return false; 293 return false;
294 } 294 }
295 295
296 public bool isRestrictedFromLand(LLUUID avatar) 296 public bool isRestrictedFromLand(LLUUID avatar)
297 { 297 {
298 if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseAccessList) > 0) 298 if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseAccessList) > 0)
299 { 299 {
300 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); 300 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
301 entry.AgentID = avatar; 301 entry.AgentID = avatar;
302 entry.Flags = ParcelManager.AccessList.Access; 302 entry.Flags = ParcelManager.AccessList.Access;
303 entry.Time = new DateTime(); 303 entry.Time = new DateTime();
304 if (!landData.parcelAccessList.Contains(entry)) 304 if (!landData.parcelAccessList.Contains(entry))
305 { 305 {
306 //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel 306 //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel
307 return true; 307 return true;
308 } 308 }
309 } 309 }
310 return false; 310 return false;
311 } 311 }
312 312
313 public void sendLandUpdateToClient(IClientAPI remote_client) 313 public void sendLandUpdateToClient(IClientAPI remote_client)
314 { 314 {
315 sendLandProperties(0, false, 0, remote_client); 315 sendLandProperties(0, false, 0, remote_client);
316 } 316 }
317 317
318 public void sendLandUpdateToAvatarsOverMe() 318 public void sendLandUpdateToAvatarsOverMe()
319 { 319 {
320 List<ScenePresence> avatars = m_scene.GetAvatars(); 320 List<ScenePresence> avatars = m_scene.GetAvatars();
321 ILandObject over = null; 321 ILandObject over = null;
322 for (int i = 0; i < avatars.Count; i++) 322 for (int i = 0; i < avatars.Count; i++)
323 { 323 {
324 try 324 try
325 { 325 {
326 over = 326 over =
327 m_scene.LandChannel.getLandObject((int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.X))), 327 m_scene.LandChannel.getLandObject((int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.X))),
328 (int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.Y)))); 328 (int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.Y))));
329 } 329 }
330 catch (Exception) 330 catch (Exception)
331 { 331 {
332 m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + Math.Round(avatars[i].AbsolutePosition.Y)); 332 m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + Math.Round(avatars[i].AbsolutePosition.Y));
333 } 333 }
334 334
335 if (over != null) 335 if (over != null)
336 { 336 {
337 if (over.landData.localID == landData.localID) 337 if (over.landData.localID == landData.localID)
338 { 338 {
339 sendLandUpdateToClient(avatars[i].ControllingClient); 339 sendLandUpdateToClient(avatars[i].ControllingClient);
340 } 340 }
341 } 341 }
342 } 342 }
343 } 343 }
344 344
345 #endregion 345 #endregion
346 346
347 #region AccessList Functions 347 #region AccessList Functions
348 348
349 public ParcelAccessListReplyPacket.ListBlock[] createAccessListArrayByFlag(ParcelManager.AccessList flag) 349 public ParcelAccessListReplyPacket.ListBlock[] createAccessListArrayByFlag(ParcelManager.AccessList flag)
350 { 350 {
351 List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>(); 351 List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>();
352 foreach (ParcelManager.ParcelAccessEntry entry in landData.parcelAccessList) 352 foreach (ParcelManager.ParcelAccessEntry entry in landData.parcelAccessList)
353 { 353 {
354 if (entry.Flags == flag) 354 if (entry.Flags == flag)
355 { 355 {
356 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); 356 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock();
357 357
358 listBlock.Flags = (uint) 0; 358 listBlock.Flags = (uint) 0;
359 listBlock.ID = entry.AgentID; 359 listBlock.ID = entry.AgentID;
360 listBlock.Time = 0; 360 listBlock.Time = 0;
361 361
362 list.Add(listBlock); 362 list.Add(listBlock);
363 } 363 }
364 } 364 }
365 365
366 if (list.Count == 0) 366 if (list.Count == 0)
367 { 367 {
368 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); 368 ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock();
369 369
370 listBlock.Flags = (uint) 0; 370 listBlock.Flags = (uint) 0;
371 listBlock.ID = LLUUID.Zero; 371 listBlock.ID = LLUUID.Zero;
372 listBlock.Time = 0; 372 listBlock.Time = 0;
373 373
374 list.Add(listBlock); 374 list.Add(listBlock);
375 } 375 }
376 return list.ToArray(); 376 return list.ToArray();
377 } 377 }
378 378
379 public void sendAccessList(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, 379 public void sendAccessList(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID,
380 IClientAPI remote_client) 380 IClientAPI remote_client)
381 { 381 {
382 ParcelAccessListReplyPacket replyPacket; 382 ParcelAccessListReplyPacket replyPacket;
383 383
384 if (flags == (uint) ParcelManager.AccessList.Access || flags == (uint) ParcelManager.AccessList.Both) 384 if (flags == (uint) ParcelManager.AccessList.Access || flags == (uint) ParcelManager.AccessList.Both)
385 { 385 {
386 replyPacket = (ParcelAccessListReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply); 386 replyPacket = (ParcelAccessListReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply);
387 replyPacket.Data.AgentID = agentID; 387 replyPacket.Data.AgentID = agentID;
388 replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Access; 388 replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Access;
389 replyPacket.Data.LocalID = landData.localID; 389 replyPacket.Data.LocalID = landData.localID;
390 replyPacket.Data.SequenceID = 0; 390 replyPacket.Data.SequenceID = 0;
391 391
392 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Access); 392 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Access);
393 remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task); 393 remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task);
394 } 394 }
395 395
396 if (flags == (uint) ParcelManager.AccessList.Ban || flags == (uint) ParcelManager.AccessList.Both) 396 if (flags == (uint) ParcelManager.AccessList.Ban || flags == (uint) ParcelManager.AccessList.Both)
397 { 397 {
398 replyPacket = (ParcelAccessListReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply); 398 replyPacket = (ParcelAccessListReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply);
399 replyPacket.Data.AgentID = agentID; 399 replyPacket.Data.AgentID = agentID;
400 replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Ban; 400 replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Ban;
401 replyPacket.Data.LocalID = landData.localID; 401 replyPacket.Data.LocalID = landData.localID;
402 replyPacket.Data.SequenceID = 0; 402 replyPacket.Data.SequenceID = 0;
403 403
404 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Ban); 404 replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Ban);
405 remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task); 405 remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task);
406 } 406 }
407 } 407 }
408 408
409 public void updateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client) 409 public void updateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client)
410 { 410 {
411 LandData newData = landData.Copy(); 411 LandData newData = landData.Copy();
412 412
413 if (entries.Count == 1 && entries[0].AgentID == LLUUID.Zero) 413 if (entries.Count == 1 && entries[0].AgentID == LLUUID.Zero)
414 { 414 {
415 entries.Clear(); 415 entries.Clear();
416 } 416 }
417 417
418 List<ParcelManager.ParcelAccessEntry> toRemove = new List<ParcelManager.ParcelAccessEntry>(); 418 List<ParcelManager.ParcelAccessEntry> toRemove = new List<ParcelManager.ParcelAccessEntry>();
419 foreach (ParcelManager.ParcelAccessEntry entry in newData.parcelAccessList) 419 foreach (ParcelManager.ParcelAccessEntry entry in newData.parcelAccessList)
420 { 420 {
421 if (entry.Flags == (ParcelManager.AccessList) flags) 421 if (entry.Flags == (ParcelManager.AccessList) flags)
422 { 422 {
423 toRemove.Add(entry); 423 toRemove.Add(entry);
424 } 424 }
425 } 425 }
426 426
427 foreach (ParcelManager.ParcelAccessEntry entry in toRemove) 427 foreach (ParcelManager.ParcelAccessEntry entry in toRemove)
428 { 428 {
429 newData.parcelAccessList.Remove(entry); 429 newData.parcelAccessList.Remove(entry);
430 } 430 }
431 foreach (ParcelManager.ParcelAccessEntry entry in entries) 431 foreach (ParcelManager.ParcelAccessEntry entry in entries)
432 { 432 {
433 ParcelManager.ParcelAccessEntry temp = new ParcelManager.ParcelAccessEntry(); 433 ParcelManager.ParcelAccessEntry temp = new ParcelManager.ParcelAccessEntry();
434 temp.AgentID = entry.AgentID; 434 temp.AgentID = entry.AgentID;
435 temp.Time = new DateTime(); //Pointless? Yes. 435 temp.Time = new DateTime(); //Pointless? Yes.
436 temp.Flags = (ParcelManager.AccessList) flags; 436 temp.Flags = (ParcelManager.AccessList) flags;
437 437
438 if (!newData.parcelAccessList.Contains(temp)) 438 if (!newData.parcelAccessList.Contains(temp))
439 { 439 {
440 newData.parcelAccessList.Add(temp); 440 newData.parcelAccessList.Add(temp);
441 } 441 }
442 } 442 }
443 443
444 m_scene.LandChannel.updateLandObject(landData.localID, newData); 444 m_scene.LandChannel.updateLandObject(landData.localID, newData);
445 } 445 }
446 446
447 #endregion 447 #endregion
448 448
449 #region Update Functions 449 #region Update Functions
450 450
451 /// <summary> 451 /// <summary>
452 /// Updates the AABBMin and AABBMax values after area/shape modification of the land object 452 /// Updates the AABBMin and AABBMax values after area/shape modification of the land object
453 /// </summary> 453 /// </summary>
454 private void updateAABBAndAreaValues() 454 private void updateAABBAndAreaValues()
455 { 455 {
456 int min_x = 64; 456 int min_x = 64;
457 int min_y = 64; 457 int min_y = 64;
458 int max_x = 0; 458 int max_x = 0;
459 int max_y = 0; 459 int max_y = 0;
460 int tempArea = 0; 460 int tempArea = 0;
461 int x, y; 461 int x, y;
462 for (x = 0; x < 64; x++) 462 for (x = 0; x < 64; x++)
463 { 463 {
464 for (y = 0; y < 64; y++) 464 for (y = 0; y < 64; y++)
465 { 465 {
466 if (landBitmap[x, y] == true) 466 if (landBitmap[x, y] == true)
467 { 467 {
468 if (min_x > x) min_x = x; 468 if (min_x > x) min_x = x;
469 if (min_y > y) min_y = y; 469 if (min_y > y) min_y = y;
470 if (max_x < x) max_x = x; 470 if (max_x < x) max_x = x;
471 if (max_y < y) max_y = y; 471 if (max_y < y) max_y = y;
472 tempArea += 16; //16sqm peice of land 472 tempArea += 16; //16sqm peice of land
473 } 473 }
474 } 474 }
475 } 475 }
476 int tx = min_x * 4; 476 int tx = min_x * 4;
477 if (tx > 255) 477 if (tx > 255)
478 tx = 255; 478 tx = 255;
479 int ty = min_y * 4; 479 int ty = min_y * 4;
480 if (ty > 255) 480 if (ty > 255)
481 ty = 255; 481 ty = 255;
482 landData.AABBMin = 482 landData.AABBMin =
483 new LLVector3((float)(min_x * 4), (float)(min_y * 4), 483 new LLVector3((float)(min_x * 4), (float)(min_y * 4),
484 (float)m_scene.Heightmap[tx, ty]); 484 (float)m_scene.Heightmap[tx, ty]);
485 485
486 tx = max_x * 4; 486 tx = max_x * 4;
487 if (tx > 255) 487 if (tx > 255)
488 tx = 255; 488 tx = 255;
489 ty = max_y * 4; 489 ty = max_y * 4;
490 if (ty > 255) 490 if (ty > 255)
491 ty = 255; 491 ty = 255;
492 landData.AABBMax = 492 landData.AABBMax =
493 new LLVector3((float)(max_x * 4), (float)(max_y * 4), 493 new LLVector3((float)(max_x * 4), (float)(max_y * 4),
494 (float)m_scene.Heightmap[tx, ty]); 494 (float)m_scene.Heightmap[tx, ty]);
495 landData.area = tempArea; 495 landData.area = tempArea;
496 } 496 }
497 497
498 public void updateLandBitmapByteArray() 498 public void updateLandBitmapByteArray()
499 { 499 {
500 landData.landBitmapByteArray = convertLandBitmapToBytes(); 500 landData.landBitmapByteArray = convertLandBitmapToBytes();
501 } 501 }
502 502
503 /// <summary> 503 /// <summary>
504 /// Update all settings in land such as area, bitmap byte array, etc 504 /// Update all settings in land such as area, bitmap byte array, etc
505 /// </summary> 505 /// </summary>
506 public void forceUpdateLandInfo() 506 public void forceUpdateLandInfo()
507 { 507 {
508 updateAABBAndAreaValues(); 508 updateAABBAndAreaValues();
509 updateLandBitmapByteArray(); 509 updateLandBitmapByteArray();
510 } 510 }
511 511
512 public void setLandBitmapFromByteArray() 512 public void setLandBitmapFromByteArray()
513 { 513 {
514 landBitmap = convertBytesToLandBitmap(); 514 landBitmap = convertBytesToLandBitmap();
515 } 515 }
516 516
517 #endregion 517 #endregion
518 518
519 #region Land Bitmap Functions 519 #region Land Bitmap Functions
520 520
521 /// <summary> 521 /// <summary>
522 /// Sets the land's bitmap manually 522 /// Sets the land's bitmap manually
523 /// </summary> 523 /// </summary>
524 /// <param name="bitmap">64x64 block representing where this land is on a map</param> 524 /// <param name="bitmap">64x64 block representing where this land is on a map</param>
525 public void setLandBitmap(bool[,] bitmap) 525 public void setLandBitmap(bool[,] bitmap)
526 { 526 {
527 if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2) 527 if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2)
528 { 528 {
529 //Throw an exception - The bitmap is not 64x64 529 //Throw an exception - The bitmap is not 64x64
530 //throw new Exception("Error: Invalid Parcel Bitmap"); 530 //throw new Exception("Error: Invalid Parcel Bitmap");
531 } 531 }
532 else 532 else
533 { 533 {
534 //Valid: Lets set it 534 //Valid: Lets set it
535 landBitmap = bitmap; 535 landBitmap = bitmap;
536 forceUpdateLandInfo(); 536 forceUpdateLandInfo();
537 } 537 }
538 } 538 }
539 539
540 /// <summary> 540 /// <summary>
541 /// Gets the land's bitmap manually 541 /// Gets the land's bitmap manually
542 /// </summary> 542 /// </summary>
543 /// <returns></returns> 543 /// <returns></returns>
544 public bool[,] getLandBitmap() 544 public bool[,] getLandBitmap()
545 { 545 {
546 return landBitmap; 546 return landBitmap;
547 } 547 }
548 548
549 /// <summary> 549 /// <summary>
550 /// Converts the land bitmap to a packet friendly byte array 550 /// Converts the land bitmap to a packet friendly byte array
551 /// </summary> 551 /// </summary>
552 /// <returns></returns> 552 /// <returns></returns>
553 private byte[] convertLandBitmapToBytes() 553 private byte[] convertLandBitmapToBytes()
554 { 554 {
555 byte[] tempConvertArr = new byte[512]; 555 byte[] tempConvertArr = new byte[512];
556 byte tempByte = 0; 556 byte tempByte = 0;
557 int x, y, i, byteNum = 0; 557 int x, y, i, byteNum = 0;
558 i = 0; 558 i = 0;
559 for (y = 0; y < 64; y++) 559 for (y = 0; y < 64; y++)
560 { 560 {
561 for (x = 0; x < 64; x++) 561 for (x = 0; x < 64; x++)
562 { 562 {
563 tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++%8)); 563 tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++%8));
564 if (i%8 == 0) 564 if (i%8 == 0)
565 { 565 {
566 tempConvertArr[byteNum] = tempByte; 566 tempConvertArr[byteNum] = tempByte;
567 tempByte = (byte) 0; 567 tempByte = (byte) 0;
568 i = 0; 568 i = 0;
569 byteNum++; 569 byteNum++;
570 } 570 }
571 } 571 }
572 } 572 }
573 return tempConvertArr; 573 return tempConvertArr;
574 } 574 }
575 575
576 private bool[,] convertBytesToLandBitmap() 576 private bool[,] convertBytesToLandBitmap()
577 { 577 {
578 bool[,] tempConvertMap = new bool[64,64]; 578 bool[,] tempConvertMap = new bool[64,64];
579 tempConvertMap.Initialize(); 579 tempConvertMap.Initialize();
580 byte tempByte = 0; 580 byte tempByte = 0;
581 int x = 0, y = 0, i = 0, bitNum = 0; 581 int x = 0, y = 0, i = 0, bitNum = 0;
582 for (i = 0; i < 512; i++) 582 for (i = 0; i < 512; i++)
583 { 583 {
584 tempByte = landData.landBitmapByteArray[i]; 584 tempByte = landData.landBitmapByteArray[i];
585 for (bitNum = 0; bitNum < 8; bitNum++) 585 for (bitNum = 0; bitNum < 8; bitNum++)
586 { 586 {
587 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1); 587 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1);
588 tempConvertMap[x, y] = bit; 588 tempConvertMap[x, y] = bit;
589 x++; 589 x++;
590 if (x > 63) 590 if (x > 63)
591 { 591 {
592 x = 0; 592 x = 0;
593 y++; 593 y++;
594 } 594 }
595 } 595 }
596 } 596 }
597 return tempConvertMap; 597 return tempConvertMap;
598 } 598 }
599 599
600 /// <summary> 600 /// <summary>
601 /// Full sim land object creation 601 /// Full sim land object creation
602 /// </summary> 602 /// </summary>
603 /// <returns></returns> 603 /// <returns></returns>
604 public bool[,] basicFullRegionLandBitmap() 604 public bool[,] basicFullRegionLandBitmap()
605 { 605 {
606 return getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize); 606 return getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize);
607 } 607 }
608 608
609 /// <summary> 609 /// <summary>
610 /// Used to modify the bitmap between the x and y points. Points use 64 scale 610 /// Used to modify the bitmap between the x and y points. Points use 64 scale
611 /// </summary> 611 /// </summary>
612 /// <param name="start_x"></param> 612 /// <param name="start_x"></param>
613 /// <param name="start_y"></param> 613 /// <param name="start_y"></param>
614 /// <param name="end_x"></param> 614 /// <param name="end_x"></param>
615 /// <param name="end_y"></param> 615 /// <param name="end_y"></param>
616 /// <returns></returns> 616 /// <returns></returns>
617 public bool[,] getSquareLandBitmap(int start_x, int start_y, int end_x, int end_y) 617 public bool[,] getSquareLandBitmap(int start_x, int start_y, int end_x, int end_y)
618 { 618 {
619 bool[,] tempBitmap = new bool[64,64]; 619 bool[,] tempBitmap = new bool[64,64];
620 tempBitmap.Initialize(); 620 tempBitmap.Initialize();
621 621
622 tempBitmap = modifyLandBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true); 622 tempBitmap = modifyLandBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true);
623 return tempBitmap; 623 return tempBitmap;
624 } 624 }
625 625
626 /// <summary> 626 /// <summary>
627 /// Change a land bitmap at within a square and set those points to a specific value 627 /// Change a land bitmap at within a square and set those points to a specific value
628 /// </summary> 628 /// </summary>
629 /// <param name="land_bitmap"></param> 629 /// <param name="land_bitmap"></param>
630 /// <param name="start_x"></param> 630 /// <param name="start_x"></param>
631 /// <param name="start_y"></param> 631 /// <param name="start_y"></param>
632 /// <param name="end_x"></param> 632 /// <param name="end_x"></param>
633 /// <param name="end_y"></param> 633 /// <param name="end_y"></param>
634 /// <param name="set_value"></param> 634 /// <param name="set_value"></param>
635 /// <returns></returns> 635 /// <returns></returns>
636 public bool[,] modifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, 636 public bool[,] modifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y,
637 bool set_value) 637 bool set_value)
638 { 638 {
639 if (land_bitmap.GetLength(0) != 64 || land_bitmap.GetLength(1) != 64 || land_bitmap.Rank != 2) 639 if (land_bitmap.GetLength(0) != 64 || land_bitmap.GetLength(1) != 64 || land_bitmap.Rank != 2)
640 { 640 {
641 //Throw an exception - The bitmap is not 64x64 641 //Throw an exception - The bitmap is not 64x64
642 //throw new Exception("Error: Invalid Parcel Bitmap in modifyLandBitmapSquare()"); 642 //throw new Exception("Error: Invalid Parcel Bitmap in modifyLandBitmapSquare()");
643 } 643 }
644 644
645 int x, y; 645 int x, y;
646 for (y = 0; y < 64; y++) 646 for (y = 0; y < 64; y++)
647 { 647 {
648 for (x = 0; x < 64; x++) 648 for (x = 0; x < 64; x++)
649 { 649 {
650 if (x >= start_x/4 && x < end_x/4 650 if (x >= start_x/4 && x < end_x/4
651 && y >= start_y/4 && y < end_y/4) 651 && y >= start_y/4 && y < end_y/4)
652 { 652 {
653 land_bitmap[x, y] = set_value; 653 land_bitmap[x, y] = set_value;
654 } 654 }
655 } 655 }
656 } 656 }
657 return land_bitmap; 657 return land_bitmap;
658 } 658 }
659 659
660 /// <summary> 660 /// <summary>
661 /// Join the true values of 2 bitmaps together 661 /// Join the true values of 2 bitmaps together
662 /// </summary> 662 /// </summary>
663 /// <param name="bitmap_base"></param> 663 /// <param name="bitmap_base"></param>
664 /// <param name="bitmap_add"></param> 664 /// <param name="bitmap_add"></param>
665 /// <returns></returns> 665 /// <returns></returns>
666 public bool[,] mergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add) 666 public bool[,] mergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add)
667 { 667 {
668 if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2) 668 if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2)
669 { 669 {
670 //Throw an exception - The bitmap is not 64x64 670 //Throw an exception - The bitmap is not 64x64
671 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeLandBitmaps"); 671 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeLandBitmaps");
672 } 672 }
673 if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2) 673 if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2)
674 { 674 {
675 //Throw an exception - The bitmap is not 64x64 675 //Throw an exception - The bitmap is not 64x64
676 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeLandBitmaps"); 676 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeLandBitmaps");
677 } 677 }
678 678
679 int x, y; 679 int x, y;
680 for (y = 0; y < 64; y++) 680 for (y = 0; y < 64; y++)
681 { 681 {
682 for (x = 0; x < 64; x++) 682 for (x = 0; x < 64; x++)
683 { 683 {
684 if (bitmap_add[x, y]) 684 if (bitmap_add[x, y])
685 { 685 {
686 bitmap_base[x, y] = true; 686 bitmap_base[x, y] = true;
687 } 687 }
688 } 688 }
689 } 689 }
690 return bitmap_base; 690 return bitmap_base;
691 } 691 }
692 692
693 #endregion 693 #endregion
694 694
695 #region Object Select and Object Owner Listing 695 #region Object Select and Object Owner Listing
696 696
697 public void sendForceObjectSelect(int local_id, int request_type, IClientAPI remote_client) 697 public void sendForceObjectSelect(int local_id, int request_type, IClientAPI remote_client)
698 { 698 {
699 List<uint> resultLocalIDs = new List<uint>(); 699 List<uint> resultLocalIDs = new List<uint>();
700 foreach (SceneObjectGroup obj in primsOverMe) 700 foreach (SceneObjectGroup obj in primsOverMe)
701 { 701 {
702 if (obj.LocalId > 0) 702 if (obj.LocalId > 0)
703 { 703 {
704 if (request_type == LandChannel.LAND_SELECT_OBJECTS_OWNER && obj.OwnerID == landData.ownerID) 704 if (request_type == LandChannel.LAND_SELECT_OBJECTS_OWNER && obj.OwnerID == landData.ownerID)
705 { 705 {
706 resultLocalIDs.Add(obj.LocalId); 706 resultLocalIDs.Add(obj.LocalId);
707 } 707 }
708 // else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && ...) // TODO: group support 708 // else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && ...) // TODO: group support
709 // { 709 // {
710 // } 710 // }
711 else if (request_type == LandChannel.LAND_SELECT_OBJECTS_OTHER && 711 else if (request_type == LandChannel.LAND_SELECT_OBJECTS_OTHER &&
712 obj.OwnerID != remote_client.AgentId) 712 obj.OwnerID != remote_client.AgentId)
713 { 713 {
714 resultLocalIDs.Add(obj.LocalId); 714 resultLocalIDs.Add(obj.LocalId);
715 } 715 }
716 } 716 }
717 } 717 }
718 718
719 719
720 bool firstCall = true; 720 bool firstCall = true;
721 int MAX_OBJECTS_PER_PACKET = 251; 721 int MAX_OBJECTS_PER_PACKET = 251;
722 ForceObjectSelectPacket pack = (ForceObjectSelectPacket) PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect); 722 ForceObjectSelectPacket pack = (ForceObjectSelectPacket) PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect);
723 // TODO: don't create new blocks if recycling an old packet 723 // TODO: don't create new blocks if recycling an old packet
724 ForceObjectSelectPacket.DataBlock[] data; 724 ForceObjectSelectPacket.DataBlock[] data;
725 while (resultLocalIDs.Count > 0) 725 while (resultLocalIDs.Count > 0)
726 { 726 {
727 if (firstCall) 727 if (firstCall)
728 { 728 {
729 pack._Header.ResetList = true; 729 pack._Header.ResetList = true;
730 firstCall = false; 730 firstCall = false;
731 } 731 }
732 else 732 else
733 { 733 {
734 pack._Header.ResetList = false; 734 pack._Header.ResetList = false;
735 } 735 }
736 736
737 if (resultLocalIDs.Count > MAX_OBJECTS_PER_PACKET) 737 if (resultLocalIDs.Count > MAX_OBJECTS_PER_PACKET)
738 { 738 {
739 data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET]; 739 data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET];
740 } 740 }
741 else 741 else
742 { 742 {
743 data = new ForceObjectSelectPacket.DataBlock[resultLocalIDs.Count]; 743 data = new ForceObjectSelectPacket.DataBlock[resultLocalIDs.Count];
744 } 744 }
745 745
746 int i; 746 int i;
747 for (i = 0; i < MAX_OBJECTS_PER_PACKET && resultLocalIDs.Count > 0; i++) 747 for (i = 0; i < MAX_OBJECTS_PER_PACKET && resultLocalIDs.Count > 0; i++)
748 { 748 {
749 data[i] = new ForceObjectSelectPacket.DataBlock(); 749 data[i] = new ForceObjectSelectPacket.DataBlock();
750 data[i].LocalID = Convert.ToUInt32(resultLocalIDs[0]); 750 data[i].LocalID = Convert.ToUInt32(resultLocalIDs[0]);
751 resultLocalIDs.RemoveAt(0); 751 resultLocalIDs.RemoveAt(0);
752 } 752 }
753 pack.Data = data; 753 pack.Data = data;
754 remote_client.OutPacket((Packet) pack, ThrottleOutPacketType.Task); 754 remote_client.OutPacket((Packet) pack, ThrottleOutPacketType.Task);
755 } 755 }
756 } 756 }
757 757
758 public void sendLandObjectOwners(IClientAPI remote_client) 758 public void sendLandObjectOwners(IClientAPI remote_client)
759 { 759 {
760 Dictionary<LLUUID, int> ownersAndCount = new Dictionary<LLUUID, int>(); 760 Dictionary<LLUUID, int> ownersAndCount = new Dictionary<LLUUID, int>();
761 ParcelObjectOwnersReplyPacket pack = (ParcelObjectOwnersReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply); 761 ParcelObjectOwnersReplyPacket pack = (ParcelObjectOwnersReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
762 // TODO: don't create new blocks if recycling an old packet 762 // TODO: don't create new blocks if recycling an old packet
763 763
764 foreach (SceneObjectGroup obj in primsOverMe) 764 foreach (SceneObjectGroup obj in primsOverMe)
765 { 765 {
766 if (!ownersAndCount.ContainsKey(obj.OwnerID)) 766 if (!ownersAndCount.ContainsKey(obj.OwnerID))
767 { 767 {
768 ownersAndCount.Add(obj.OwnerID, 0); 768 ownersAndCount.Add(obj.OwnerID, 0);
769 } 769 }
770 ownersAndCount[obj.OwnerID] += obj.PrimCount; 770 ownersAndCount[obj.OwnerID] += obj.PrimCount;
771 } 771 }
772 if (ownersAndCount.Count > 0) 772 if (ownersAndCount.Count > 0)
773 { 773 {
774 ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[32]; 774 ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[32];
775 775
776 if (ownersAndCount.Count < 32) 776 if (ownersAndCount.Count < 32)
777 { 777 {
778 dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[ownersAndCount.Count]; 778 dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[ownersAndCount.Count];
779 } 779 }
780 780
781 781
782 int num = 0; 782 int num = 0;
783 foreach (LLUUID owner in ownersAndCount.Keys) 783 foreach (LLUUID owner in ownersAndCount.Keys)
784 { 784 {
785 dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock(); 785 dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock();
786 dataBlock[num].Count = ownersAndCount[owner]; 786 dataBlock[num].Count = ownersAndCount[owner];
787 dataBlock[num].IsGroupOwned = false; //TODO: fix me when group support is added 787 dataBlock[num].IsGroupOwned = false; //TODO: fix me when group support is added
788 dataBlock[num].OnlineStatus = true; //TODO: fix me later 788 dataBlock[num].OnlineStatus = true; //TODO: fix me later
789 dataBlock[num].OwnerID = owner; 789 dataBlock[num].OwnerID = owner;
790 790
791 num++; 791 num++;
792 } 792 }
793 pack.Data = dataBlock; 793 pack.Data = dataBlock;
794 } 794 }
795 remote_client.OutPacket(pack, ThrottleOutPacketType.Task); 795 remote_client.OutPacket(pack, ThrottleOutPacketType.Task);
796 } 796 }
797 797
798 #endregion 798 #endregion
799 799
800 #region Object Returning 800 #region Object Returning
801 801
802 public void returnObject(SceneObjectGroup obj) 802 public void returnObject(SceneObjectGroup obj)
803 { 803 {
804 } 804 }
805 805
806 public void returnLandObjects(int type, LLUUID owner) 806 public void returnLandObjects(int type, LLUUID owner)
807 { 807 {
808 } 808 }
809 809
810 #endregion 810 #endregion
811 811
812 #region Object Adding/Removing from Parcel 812 #region Object Adding/Removing from Parcel
813 813
814 public void resetLandPrimCounts() 814 public void resetLandPrimCounts()
815 { 815 {
816 landData.groupPrims = 0; 816 landData.groupPrims = 0;
817 landData.ownerPrims = 0; 817 landData.ownerPrims = 0;
818 landData.otherPrims = 0; 818 landData.otherPrims = 0;
819 landData.selectedPrims = 0; 819 landData.selectedPrims = 0;
820 primsOverMe.Clear(); 820 primsOverMe.Clear();
821 } 821 }
822 822
823 public void addPrimToCount(SceneObjectGroup obj) 823 public void addPrimToCount(SceneObjectGroup obj)
824 { 824 {
825 LLUUID prim_owner = obj.OwnerID; 825 LLUUID prim_owner = obj.OwnerID;
826 int prim_count = obj.PrimCount; 826 int prim_count = obj.PrimCount;
827 827
828 if (obj.IsSelected) 828 if (obj.IsSelected)
829 { 829 {
830 landData.selectedPrims += prim_count; 830 landData.selectedPrims += prim_count;
831 } 831 }
832 else 832 else
833 { 833 {
834 if (prim_owner == landData.ownerID) 834 if (prim_owner == landData.ownerID)
835 { 835 {
836 landData.ownerPrims += prim_count; 836 landData.ownerPrims += prim_count;
837 } 837 }
838 else 838 else
839 { 839 {
840 landData.otherPrims += prim_count; 840 landData.otherPrims += prim_count;
841 } 841 }
842 } 842 }
843 843
844 primsOverMe.Add(obj); 844 primsOverMe.Add(obj);
845 } 845 }
846 846
847 public void removePrimFromCount(SceneObjectGroup obj) 847 public void removePrimFromCount(SceneObjectGroup obj)
848 { 848 {
849 if (primsOverMe.Contains(obj)) 849 if (primsOverMe.Contains(obj))
850 { 850 {
851 LLUUID prim_owner = obj.OwnerID; 851 LLUUID prim_owner = obj.OwnerID;
852 int prim_count = obj.PrimCount; 852 int prim_count = obj.PrimCount;
853 853
854 if (prim_owner == landData.ownerID) 854 if (prim_owner == landData.ownerID)
855 { 855 {
856 landData.ownerPrims -= prim_count; 856 landData.ownerPrims -= prim_count;
857 } 857 }
858 else if (prim_owner == landData.groupID) 858 else if (prim_owner == landData.groupID)
859 { 859 {
860 landData.groupPrims -= prim_count; 860 landData.groupPrims -= prim_count;
861 } 861 }
862 else 862 else
863 { 863 {
864 landData.otherPrims -= prim_count; 864 landData.otherPrims -= prim_count;
865 } 865 }
866 866
867 primsOverMe.Remove(obj); 867 primsOverMe.Remove(obj);
868 } 868 }
869 } 869 }
870 870
871 #endregion 871 #endregion
872 872
873 #endregion 873 #endregion
874 874
875 875
876} 876}
877 877
878 #endregion 878 #endregion
879} 879}