aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/LandManagement/Land.cs
diff options
context:
space:
mode:
authorSean Dague2007-07-30 20:11:40 +0000
committerSean Dague2007-07-30 20:11:40 +0000
commit74bb5282a09ec095a7ff810c62f79cc64e187686 (patch)
treee0a9b703bfcbbab59b04351dd71508fa913e741a /OpenSim/Region/Environment/LandManagement/Land.cs
parentadded OnDisconnectUser event to required classes (diff)
downloadopensim-SC_OLD-74bb5282a09ec095a7ff810c62f79cc64e187686.zip
opensim-SC_OLD-74bb5282a09ec095a7ff810c62f79cc64e187686.tar.gz
opensim-SC_OLD-74bb5282a09ec095a7ff810c62f79cc64e187686.tar.bz2
opensim-SC_OLD-74bb5282a09ec095a7ff810c62f79cc64e187686.tar.xz
mass update of files to have native line endings
Diffstat (limited to 'OpenSim/Region/Environment/LandManagement/Land.cs')
-rw-r--r--OpenSim/Region/Environment/LandManagement/Land.cs1204
1 files changed, 602 insertions, 602 deletions
diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs
index 625b176..97f8276 100644
--- a/OpenSim/Region/Environment/LandManagement/Land.cs
+++ b/OpenSim/Region/Environment/LandManagement/Land.cs
@@ -1,602 +1,602 @@
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.Interfaces; 5using OpenSim.Framework.Interfaces;
6using OpenSim.Framework.Types; 6using OpenSim.Framework.Types;
7using OpenSim.Region.Environment.Scenes; 7using OpenSim.Region.Environment.Scenes;
8 8
9namespace OpenSim.Region.Environment.LandManagement 9namespace OpenSim.Region.Environment.LandManagement
10{ 10{
11 #region Parcel Class 11 #region Parcel Class
12 /// <summary> 12 /// <summary>
13 /// Keeps track of a specific piece of land's information 13 /// Keeps track of a specific piece of land's information
14 /// </summary> 14 /// </summary>
15 public class Land 15 public class Land
16 { 16 {
17 #region Member Variables 17 #region Member Variables
18 public LandData landData = new LandData(); 18 public LandData landData = new LandData();
19 public List<SceneObject> primsOverMe = new List<SceneObject>(); 19 public List<SceneObject> primsOverMe = new List<SceneObject>();
20 20
21 public Scene m_scene; 21 public Scene m_scene;
22 22
23 private bool[,] landBitmap = new bool[64, 64]; 23 private bool[,] landBitmap = new bool[64, 64];
24 24
25 #endregion 25 #endregion
26 26
27 27
28 #region Constructors 28 #region Constructors
29 public Land(LLUUID owner_id, bool is_group_owned, Scene scene) 29 public Land(LLUUID owner_id, bool is_group_owned, Scene scene)
30 { 30 {
31 m_scene = scene; 31 m_scene = scene;
32 landData.ownerID = owner_id; 32 landData.ownerID = owner_id;
33 landData.isGroupOwned = is_group_owned; 33 landData.isGroupOwned = is_group_owned;
34 34
35 } 35 }
36 #endregion 36 #endregion
37 37
38 38
39 #region Member Functions 39 #region Member Functions
40 40
41 #region General Functions 41 #region General Functions
42 /// <summary> 42 /// <summary>
43 /// Checks to see if this land object contains a point 43 /// Checks to see if this land object contains a point
44 /// </summary> 44 /// </summary>
45 /// <param name="x"></param> 45 /// <param name="x"></param>
46 /// <param name="y"></param> 46 /// <param name="y"></param>
47 /// <returns>Returns true if the piece of land contains the specified point</returns> 47 /// <returns>Returns true if the piece of land contains the specified point</returns>
48 public bool containsPoint(int x, int y) 48 public bool containsPoint(int x, int y)
49 { 49 {
50 if (x >= 0 && y >= 0 && x <= 256 && x <= 256) 50 if (x >= 0 && y >= 0 && x <= 256 && x <= 256)
51 { 51 {
52 return (landBitmap[x / 4, y / 4] == true); 52 return (landBitmap[x / 4, y / 4] == true);
53 } 53 }
54 else 54 else
55 { 55 {
56 return false; 56 return false;
57 } 57 }
58 } 58 }
59 59
60 public Land Copy() 60 public Land Copy()
61 { 61 {
62 Land newLand = new Land(this.landData.ownerID, this.landData.isGroupOwned, m_scene); 62 Land newLand = new Land(this.landData.ownerID, this.landData.isGroupOwned, m_scene);
63 63
64 //Place all new variables here! 64 //Place all new variables here!
65 newLand.landBitmap = (bool[,])(this.landBitmap.Clone()); 65 newLand.landBitmap = (bool[,])(this.landBitmap.Clone());
66 newLand.landData = landData.Copy(); 66 newLand.landData = landData.Copy();
67 67
68 return newLand; 68 return newLand;
69 } 69 }
70 70
71 #endregion 71 #endregion
72 72
73 73
74 #region Packet Request Handling 74 #region Packet Request Handling
75 /// <summary> 75 /// <summary>
76 /// Sends land properties as requested 76 /// Sends land properties as requested
77 /// </summary> 77 /// </summary>
78 /// <param name="sequence_id">ID sent by client for them to keep track of</param> 78 /// <param name="sequence_id">ID sent by client for them to keep track of</param>
79 /// <param name="snap_selection">Bool sent by client for them to use</param> 79 /// <param name="snap_selection">Bool sent by client for them to use</param>
80 /// <param name="remote_client">Object representing the client</param> 80 /// <param name="remote_client">Object representing the client</param>
81 public void sendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client) 81 public void sendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client)
82 { 82 {
83 83
84 ParcelPropertiesPacket updatePacket = new ParcelPropertiesPacket(); 84 ParcelPropertiesPacket updatePacket = new ParcelPropertiesPacket();
85 updatePacket.ParcelData.AABBMax = landData.AABBMax; 85 updatePacket.ParcelData.AABBMax = landData.AABBMax;
86 updatePacket.ParcelData.AABBMin = landData.AABBMin; 86 updatePacket.ParcelData.AABBMin = landData.AABBMin;
87 updatePacket.ParcelData.Area = landData.area; 87 updatePacket.ParcelData.Area = landData.area;
88 updatePacket.ParcelData.AuctionID = landData.auctionID; 88 updatePacket.ParcelData.AuctionID = landData.auctionID;
89 updatePacket.ParcelData.AuthBuyerID = landData.authBuyerID; //unemplemented 89 updatePacket.ParcelData.AuthBuyerID = landData.authBuyerID; //unemplemented
90 90
91 updatePacket.ParcelData.Bitmap = landData.landBitmapByteArray; 91 updatePacket.ParcelData.Bitmap = landData.landBitmapByteArray;
92 92
93 updatePacket.ParcelData.Desc = Helpers.StringToField(landData.landDesc); 93 updatePacket.ParcelData.Desc = Helpers.StringToField(landData.landDesc);
94 updatePacket.ParcelData.Category = (byte)landData.category; 94 updatePacket.ParcelData.Category = (byte)landData.category;
95 updatePacket.ParcelData.ClaimDate = landData.claimDate; 95 updatePacket.ParcelData.ClaimDate = landData.claimDate;
96 updatePacket.ParcelData.ClaimPrice = landData.claimPrice; 96 updatePacket.ParcelData.ClaimPrice = landData.claimPrice;
97 updatePacket.ParcelData.GroupID = landData.groupID; 97 updatePacket.ParcelData.GroupID = landData.groupID;
98 updatePacket.ParcelData.GroupPrims = landData.groupPrims; 98 updatePacket.ParcelData.GroupPrims = landData.groupPrims;
99 updatePacket.ParcelData.IsGroupOwned = landData.isGroupOwned; 99 updatePacket.ParcelData.IsGroupOwned = landData.isGroupOwned;
100 updatePacket.ParcelData.LandingType = (byte)landData.landingType; 100 updatePacket.ParcelData.LandingType = (byte)landData.landingType;
101 updatePacket.ParcelData.LocalID = landData.localID; 101 updatePacket.ParcelData.LocalID = landData.localID;
102 if (landData.area > 0) 102 if (landData.area > 0)
103 { 103 {
104 updatePacket.ParcelData.MaxPrims = Convert.ToInt32(Math.Round((Convert.ToDecimal(landData.area) / Convert.ToDecimal(65536)) * 15000 * Convert.ToDecimal(m_scene.RegionInfo.estateSettings.objectBonusFactor))); 104 updatePacket.ParcelData.MaxPrims = Convert.ToInt32(Math.Round((Convert.ToDecimal(landData.area) / Convert.ToDecimal(65536)) * 15000 * Convert.ToDecimal(m_scene.RegionInfo.estateSettings.objectBonusFactor)));
105 } 105 }
106 else 106 else
107 { 107 {
108 updatePacket.ParcelData.MaxPrims = 0; 108 updatePacket.ParcelData.MaxPrims = 0;
109 } 109 }
110 updatePacket.ParcelData.MediaAutoScale = landData.mediaAutoScale; 110 updatePacket.ParcelData.MediaAutoScale = landData.mediaAutoScale;
111 updatePacket.ParcelData.MediaID = landData.mediaID; 111 updatePacket.ParcelData.MediaID = landData.mediaID;
112 updatePacket.ParcelData.MediaURL = Helpers.StringToField(landData.mediaURL); 112 updatePacket.ParcelData.MediaURL = Helpers.StringToField(landData.mediaURL);
113 updatePacket.ParcelData.MusicURL = Helpers.StringToField(landData.musicURL); 113 updatePacket.ParcelData.MusicURL = Helpers.StringToField(landData.musicURL);
114 updatePacket.ParcelData.Name = Helpers.StringToField(landData.landName); 114 updatePacket.ParcelData.Name = Helpers.StringToField(landData.landName);
115 updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented 115 updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented
116 updatePacket.ParcelData.OtherCount = 0; //unemplemented 116 updatePacket.ParcelData.OtherCount = 0; //unemplemented
117 updatePacket.ParcelData.OtherPrims = landData.otherPrims; 117 updatePacket.ParcelData.OtherPrims = landData.otherPrims;
118 updatePacket.ParcelData.OwnerID = landData.ownerID; 118 updatePacket.ParcelData.OwnerID = landData.ownerID;
119 updatePacket.ParcelData.OwnerPrims = landData.ownerPrims; 119 updatePacket.ParcelData.OwnerPrims = landData.ownerPrims;
120 updatePacket.ParcelData.ParcelFlags = landData.landFlags; 120 updatePacket.ParcelData.ParcelFlags = landData.landFlags;
121 updatePacket.ParcelData.ParcelPrimBonus = m_scene.RegionInfo.estateSettings.objectBonusFactor; 121 updatePacket.ParcelData.ParcelPrimBonus = m_scene.RegionInfo.estateSettings.objectBonusFactor;
122 updatePacket.ParcelData.PassHours = landData.passHours; 122 updatePacket.ParcelData.PassHours = landData.passHours;
123 updatePacket.ParcelData.PassPrice = landData.passPrice; 123 updatePacket.ParcelData.PassPrice = landData.passPrice;
124 updatePacket.ParcelData.PublicCount = 0; //unemplemented 124 updatePacket.ParcelData.PublicCount = 0; //unemplemented
125 125
126 uint regionFlags = (uint)m_scene.RegionInfo.estateSettings.regionFlags; 126 uint regionFlags = (uint)m_scene.RegionInfo.estateSettings.regionFlags;
127 updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint)Simulator.RegionFlags.DenyAnonymous) > 0); 127 updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint)Simulator.RegionFlags.DenyAnonymous) > 0);
128 updatePacket.ParcelData.RegionDenyIdentified = ((regionFlags & (uint)Simulator.RegionFlags.DenyIdentified) > 0); 128 updatePacket.ParcelData.RegionDenyIdentified = ((regionFlags & (uint)Simulator.RegionFlags.DenyIdentified) > 0);
129 updatePacket.ParcelData.RegionDenyTransacted = ((regionFlags & (uint)Simulator.RegionFlags.DenyTransacted) > 0); 129 updatePacket.ParcelData.RegionDenyTransacted = ((regionFlags & (uint)Simulator.RegionFlags.DenyTransacted) > 0);
130 updatePacket.ParcelData.RegionPushOverride = ((regionFlags & (uint)Simulator.RegionFlags.RestrictPushObject) > 0); 130 updatePacket.ParcelData.RegionPushOverride = ((regionFlags & (uint)Simulator.RegionFlags.RestrictPushObject) > 0);
131 131
132 updatePacket.ParcelData.RentPrice = 0; 132 updatePacket.ParcelData.RentPrice = 0;
133 updatePacket.ParcelData.RequestResult = request_result; 133 updatePacket.ParcelData.RequestResult = request_result;
134 updatePacket.ParcelData.SalePrice = landData.salePrice; 134 updatePacket.ParcelData.SalePrice = landData.salePrice;
135 updatePacket.ParcelData.SelectedPrims = landData.selectedPrims; 135 updatePacket.ParcelData.SelectedPrims = landData.selectedPrims;
136 updatePacket.ParcelData.SelfCount = 0;//unemplemented 136 updatePacket.ParcelData.SelfCount = 0;//unemplemented
137 updatePacket.ParcelData.SequenceID = sequence_id; 137 updatePacket.ParcelData.SequenceID = sequence_id;
138 if (landData.simwideArea > 0) 138 if (landData.simwideArea > 0)
139 { 139 {
140 updatePacket.ParcelData.SimWideMaxPrims = Convert.ToInt32(Math.Round((Convert.ToDecimal(landData.simwideArea) / Convert.ToDecimal(65536)) * 15000 * Convert.ToDecimal(m_scene.RegionInfo.estateSettings.objectBonusFactor))); 140 updatePacket.ParcelData.SimWideMaxPrims = Convert.ToInt32(Math.Round((Convert.ToDecimal(landData.simwideArea) / Convert.ToDecimal(65536)) * 15000 * Convert.ToDecimal(m_scene.RegionInfo.estateSettings.objectBonusFactor)));
141 } 141 }
142 else 142 else
143 { 143 {
144 updatePacket.ParcelData.SimWideMaxPrims = 0; 144 updatePacket.ParcelData.SimWideMaxPrims = 0;
145 } 145 }
146 updatePacket.ParcelData.SimWideTotalPrims = landData.simwidePrims; 146 updatePacket.ParcelData.SimWideTotalPrims = landData.simwidePrims;
147 updatePacket.ParcelData.SnapSelection = snap_selection; 147 updatePacket.ParcelData.SnapSelection = snap_selection;
148 updatePacket.ParcelData.SnapshotID = landData.snapshotID; 148 updatePacket.ParcelData.SnapshotID = landData.snapshotID;
149 updatePacket.ParcelData.Status = (byte)landData.landStatus; 149 updatePacket.ParcelData.Status = (byte)landData.landStatus;
150 updatePacket.ParcelData.TotalPrims = landData.ownerPrims + landData.groupPrims + landData.otherPrims + landData.selectedPrims; 150 updatePacket.ParcelData.TotalPrims = landData.ownerPrims + landData.groupPrims + landData.otherPrims + landData.selectedPrims;
151 updatePacket.ParcelData.UserLocation = landData.userLocation; 151 updatePacket.ParcelData.UserLocation = landData.userLocation;
152 updatePacket.ParcelData.UserLookAt = landData.userLookAt; 152 updatePacket.ParcelData.UserLookAt = landData.userLookAt;
153 remote_client.OutPacket((Packet)updatePacket); 153 remote_client.OutPacket((Packet)updatePacket);
154 } 154 }
155 155
156 public void updateLandProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) 156 public void updateLandProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client)
157 { 157 {
158 if (remote_client.AgentId == landData.ownerID) 158 if (remote_client.AgentId == landData.ownerID)
159 { 159 {
160 //Needs later group support 160 //Needs later group support
161 landData.authBuyerID = packet.ParcelData.AuthBuyerID; 161 landData.authBuyerID = packet.ParcelData.AuthBuyerID;
162 landData.category = (libsecondlife.Parcel.ParcelCategory)packet.ParcelData.Category; 162 landData.category = (libsecondlife.Parcel.ParcelCategory)packet.ParcelData.Category;
163 landData.landDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc); 163 landData.landDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc);
164 landData.groupID = packet.ParcelData.GroupID; 164 landData.groupID = packet.ParcelData.GroupID;
165 landData.landingType = packet.ParcelData.LandingType; 165 landData.landingType = packet.ParcelData.LandingType;
166 landData.mediaAutoScale = packet.ParcelData.MediaAutoScale; 166 landData.mediaAutoScale = packet.ParcelData.MediaAutoScale;
167 landData.mediaID = packet.ParcelData.MediaID; 167 landData.mediaID = packet.ParcelData.MediaID;
168 landData.mediaURL = Helpers.FieldToUTF8String(packet.ParcelData.MediaURL); 168 landData.mediaURL = Helpers.FieldToUTF8String(packet.ParcelData.MediaURL);
169 landData.musicURL = Helpers.FieldToUTF8String(packet.ParcelData.MusicURL); 169 landData.musicURL = Helpers.FieldToUTF8String(packet.ParcelData.MusicURL);
170 landData.landName = Helpers.FieldToUTF8String(packet.ParcelData.Name); 170 landData.landName = Helpers.FieldToUTF8String(packet.ParcelData.Name);
171 landData.landFlags = packet.ParcelData.ParcelFlags; 171 landData.landFlags = packet.ParcelData.ParcelFlags;
172 landData.passHours = packet.ParcelData.PassHours; 172 landData.passHours = packet.ParcelData.PassHours;
173 landData.passPrice = packet.ParcelData.PassPrice; 173 landData.passPrice = packet.ParcelData.PassPrice;
174 landData.salePrice = packet.ParcelData.SalePrice; 174 landData.salePrice = packet.ParcelData.SalePrice;
175 landData.snapshotID = packet.ParcelData.SnapshotID; 175 landData.snapshotID = packet.ParcelData.SnapshotID;
176 landData.userLocation = packet.ParcelData.UserLocation; 176 landData.userLocation = packet.ParcelData.UserLocation;
177 landData.userLookAt = packet.ParcelData.UserLookAt; 177 landData.userLookAt = packet.ParcelData.UserLookAt;
178 sendLandUpdateToAvatarsOverMe(); 178 sendLandUpdateToAvatarsOverMe();
179 179
180 180
181 } 181 }
182 } 182 }
183 183
184 public void sendLandUpdateToAvatarsOverMe() 184 public void sendLandUpdateToAvatarsOverMe()
185 { 185 {
186 List<ScenePresence> avatars = m_scene.RequestAvatarList(); 186 List<ScenePresence> avatars = m_scene.RequestAvatarList();
187 for (int i = 0; i < avatars.Count; i++) 187 for (int i = 0; i < avatars.Count; i++)
188 { 188 {
189 Land over = m_scene.LandManager.getLandObject((int)Math.Round(avatars[i].Pos.X), (int)Math.Round(avatars[i].Pos.Y)); 189 Land over = m_scene.LandManager.getLandObject((int)Math.Round(avatars[i].Pos.X), (int)Math.Round(avatars[i].Pos.Y));
190 if (over.landData.localID == this.landData.localID) 190 if (over.landData.localID == this.landData.localID)
191 { 191 {
192 sendLandProperties(0, false, 0, avatars[i].ControllingClient); 192 sendLandProperties(0, false, 0, avatars[i].ControllingClient);
193 } 193 }
194 } 194 }
195 } 195 }
196 #endregion 196 #endregion
197 197
198 198
199 #region Update Functions 199 #region Update Functions
200 /// <summary> 200 /// <summary>
201 /// Updates the AABBMin and AABBMax values after area/shape modification of the land object 201 /// Updates the AABBMin and AABBMax values after area/shape modification of the land object
202 /// </summary> 202 /// </summary>
203 private void updateAABBAndAreaValues() 203 private void updateAABBAndAreaValues()
204 { 204 {
205 int min_x = 64; 205 int min_x = 64;
206 int min_y = 64; 206 int min_y = 64;
207 int max_x = 0; 207 int max_x = 0;
208 int max_y = 0; 208 int max_y = 0;
209 int tempArea = 0; 209 int tempArea = 0;
210 int x, y; 210 int x, y;
211 for (x = 0; x < 64; x++) 211 for (x = 0; x < 64; x++)
212 { 212 {
213 for (y = 0; y < 64; y++) 213 for (y = 0; y < 64; y++)
214 { 214 {
215 if (landBitmap[x, y] == true) 215 if (landBitmap[x, y] == true)
216 { 216 {
217 if (min_x > x) min_x = x; 217 if (min_x > x) min_x = x;
218 if (min_y > y) min_y = y; 218 if (min_y > y) min_y = y;
219 if (max_x < x) max_x = x; 219 if (max_x < x) max_x = x;
220 if (max_y < y) max_y = y; 220 if (max_y < y) max_y = y;
221 tempArea += 16; //16sqm peice of land 221 tempArea += 16; //16sqm peice of land
222 } 222 }
223 } 223 }
224 } 224 }
225 landData.AABBMin = new LLVector3((float)(min_x * 4), (float)(min_y * 4), (float)m_scene.Terrain.GetHeight((min_x * 4), (min_y * 4))); 225 landData.AABBMin = new LLVector3((float)(min_x * 4), (float)(min_y * 4), (float)m_scene.Terrain.GetHeight((min_x * 4), (min_y * 4)));
226 landData.AABBMax = new LLVector3((float)(max_x * 4), (float)(max_y * 4), (float)m_scene.Terrain.GetHeight((max_x * 4), (max_y * 4))); 226 landData.AABBMax = new LLVector3((float)(max_x * 4), (float)(max_y * 4), (float)m_scene.Terrain.GetHeight((max_x * 4), (max_y * 4)));
227 landData.area = tempArea; 227 landData.area = tempArea;
228 } 228 }
229 229
230 public void updateLandBitmapByteArray() 230 public void updateLandBitmapByteArray()
231 { 231 {
232 landData.landBitmapByteArray = convertLandBitmapToBytes(); 232 landData.landBitmapByteArray = convertLandBitmapToBytes();
233 } 233 }
234 234
235 /// <summary> 235 /// <summary>
236 /// Update all settings in land such as area, bitmap byte array, etc 236 /// Update all settings in land such as area, bitmap byte array, etc
237 /// </summary> 237 /// </summary>
238 public void forceUpdateLandInfo() 238 public void forceUpdateLandInfo()
239 { 239 {
240 this.updateAABBAndAreaValues(); 240 this.updateAABBAndAreaValues();
241 this.updateLandBitmapByteArray(); 241 this.updateLandBitmapByteArray();
242 } 242 }
243 243
244 public void setLandBitmapFromByteArray() 244 public void setLandBitmapFromByteArray()
245 { 245 {
246 landBitmap = convertBytesToLandBitmap(); 246 landBitmap = convertBytesToLandBitmap();
247 } 247 }
248 #endregion 248 #endregion
249 249
250 250
251 #region Land Bitmap Functions 251 #region Land Bitmap Functions
252 /// <summary> 252 /// <summary>
253 /// Sets the land's bitmap manually 253 /// Sets the land's bitmap manually
254 /// </summary> 254 /// </summary>
255 /// <param name="bitmap">64x64 block representing where this land is on a map</param> 255 /// <param name="bitmap">64x64 block representing where this land is on a map</param>
256 public void setLandBitmap(bool[,] bitmap) 256 public void setLandBitmap(bool[,] bitmap)
257 { 257 {
258 if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2) 258 if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2)
259 { 259 {
260 //Throw an exception - The bitmap is not 64x64 260 //Throw an exception - The bitmap is not 64x64
261 throw new Exception("Error: Invalid Parcel Bitmap"); 261 throw new Exception("Error: Invalid Parcel Bitmap");
262 } 262 }
263 else 263 else
264 { 264 {
265 //Valid: Lets set it 265 //Valid: Lets set it
266 landBitmap = bitmap; 266 landBitmap = bitmap;
267 forceUpdateLandInfo(); 267 forceUpdateLandInfo();
268 268
269 } 269 }
270 } 270 }
271 /// <summary> 271 /// <summary>
272 /// Gets the land's bitmap manually 272 /// Gets the land's bitmap manually
273 /// </summary> 273 /// </summary>
274 /// <returns></returns> 274 /// <returns></returns>
275 public bool[,] getLandBitmap() 275 public bool[,] getLandBitmap()
276 { 276 {
277 return landBitmap; 277 return landBitmap;
278 } 278 }
279 /// <summary> 279 /// <summary>
280 /// Converts the land bitmap to a packet friendly byte array 280 /// Converts the land bitmap to a packet friendly byte array
281 /// </summary> 281 /// </summary>
282 /// <returns></returns> 282 /// <returns></returns>
283 private byte[] convertLandBitmapToBytes() 283 private byte[] convertLandBitmapToBytes()
284 { 284 {
285 byte[] tempConvertArr = new byte[512]; 285 byte[] tempConvertArr = new byte[512];
286 byte tempByte = 0; 286 byte tempByte = 0;
287 int x, y, i, byteNum = 0; 287 int x, y, i, byteNum = 0;
288 i = 0; 288 i = 0;
289 for (y = 0; y < 64; y++) 289 for (y = 0; y < 64; y++)
290 { 290 {
291 for (x = 0; x < 64; x++) 291 for (x = 0; x < 64; x++)
292 { 292 {
293 tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++ % 8)); 293 tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++ % 8));
294 if (i % 8 == 0) 294 if (i % 8 == 0)
295 { 295 {
296 tempConvertArr[byteNum] = tempByte; 296 tempConvertArr[byteNum] = tempByte;
297 tempByte = (byte)0; 297 tempByte = (byte)0;
298 i = 0; 298 i = 0;
299 byteNum++; 299 byteNum++;
300 } 300 }
301 } 301 }
302 } 302 }
303 return tempConvertArr; 303 return tempConvertArr;
304 } 304 }
305 305
306 private bool[,] convertBytesToLandBitmap() 306 private bool[,] convertBytesToLandBitmap()
307 { 307 {
308 bool[,] tempConvertMap = new bool[64, 64]; 308 bool[,] tempConvertMap = new bool[64, 64];
309 tempConvertMap.Initialize(); 309 tempConvertMap.Initialize();
310 byte tempByte = 0; 310 byte tempByte = 0;
311 int x = 0, y = 0, i = 0, bitNum = 0; 311 int x = 0, y = 0, i = 0, bitNum = 0;
312 for (i = 0; i < 512; i++) 312 for (i = 0; i < 512; i++)
313 { 313 {
314 tempByte = landData.landBitmapByteArray[i]; 314 tempByte = landData.landBitmapByteArray[i];
315 for (bitNum = 0; bitNum < 8; bitNum++) 315 for (bitNum = 0; bitNum < 8; bitNum++)
316 { 316 {
317 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte)1); 317 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte)1);
318 tempConvertMap[x, y] = bit; 318 tempConvertMap[x, y] = bit;
319 x++; 319 x++;
320 if (x > 63) 320 if (x > 63)
321 { 321 {
322 x = 0; 322 x = 0;
323 y++; 323 y++;
324 } 324 }
325 325
326 } 326 }
327 327
328 } 328 }
329 return tempConvertMap; 329 return tempConvertMap;
330 } 330 }
331 /// <summary> 331 /// <summary>
332 /// Full sim land object creation 332 /// Full sim land object creation
333 /// </summary> 333 /// </summary>
334 /// <returns></returns> 334 /// <returns></returns>
335 public static bool[,] basicFullRegionLandBitmap() 335 public static bool[,] basicFullRegionLandBitmap()
336 { 336 {
337 return getSquareLandBitmap(0, 0, 256, 256); 337 return getSquareLandBitmap(0, 0, 256, 256);
338 } 338 }
339 339
340 /// <summary> 340 /// <summary>
341 /// Used to modify the bitmap between the x and y points. Points use 64 scale 341 /// Used to modify the bitmap between the x and y points. Points use 64 scale
342 /// </summary> 342 /// </summary>
343 /// <param name="start_x"></param> 343 /// <param name="start_x"></param>
344 /// <param name="start_y"></param> 344 /// <param name="start_y"></param>
345 /// <param name="end_x"></param> 345 /// <param name="end_x"></param>
346 /// <param name="end_y"></param> 346 /// <param name="end_y"></param>
347 /// <returns></returns> 347 /// <returns></returns>
348 public static bool[,] getSquareLandBitmap(int start_x, int start_y, int end_x, int end_y) 348 public static bool[,] getSquareLandBitmap(int start_x, int start_y, int end_x, int end_y)
349 { 349 {
350 350
351 bool[,] tempBitmap = new bool[64, 64]; 351 bool[,] tempBitmap = new bool[64, 64];
352 tempBitmap.Initialize(); 352 tempBitmap.Initialize();
353 353
354 tempBitmap = modifyLandBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true); 354 tempBitmap = modifyLandBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true);
355 return tempBitmap; 355 return tempBitmap;
356 } 356 }
357 357
358 /// <summary> 358 /// <summary>
359 /// Change a land bitmap at within a square and set those points to a specific value 359 /// Change a land bitmap at within a square and set those points to a specific value
360 /// </summary> 360 /// </summary>
361 /// <param name="land_bitmap"></param> 361 /// <param name="land_bitmap"></param>
362 /// <param name="start_x"></param> 362 /// <param name="start_x"></param>
363 /// <param name="start_y"></param> 363 /// <param name="start_y"></param>
364 /// <param name="end_x"></param> 364 /// <param name="end_x"></param>
365 /// <param name="end_y"></param> 365 /// <param name="end_y"></param>
366 /// <param name="set_value"></param> 366 /// <param name="set_value"></param>
367 /// <returns></returns> 367 /// <returns></returns>
368 public static bool[,] modifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value) 368 public static bool[,] modifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value)
369 { 369 {
370 if (land_bitmap.GetLength(0) != 64 || land_bitmap.GetLength(1) != 64 || land_bitmap.Rank != 2) 370 if (land_bitmap.GetLength(0) != 64 || land_bitmap.GetLength(1) != 64 || land_bitmap.Rank != 2)
371 { 371 {
372 //Throw an exception - The bitmap is not 64x64 372 //Throw an exception - The bitmap is not 64x64
373 throw new Exception("Error: Invalid Parcel Bitmap in modifyLandBitmapSquare()"); 373 throw new Exception("Error: Invalid Parcel Bitmap in modifyLandBitmapSquare()");
374 } 374 }
375 375
376 int x, y; 376 int x, y;
377 for (y = 0; y < 64; y++) 377 for (y = 0; y < 64; y++)
378 { 378 {
379 for (x = 0; x < 64; x++) 379 for (x = 0; x < 64; x++)
380 { 380 {
381 if (x >= start_x / 4 && x < end_x / 4 381 if (x >= start_x / 4 && x < end_x / 4
382 && y >= start_y / 4 && y < end_y / 4) 382 && y >= start_y / 4 && y < end_y / 4)
383 { 383 {
384 land_bitmap[x, y] = set_value; 384 land_bitmap[x, y] = set_value;
385 } 385 }
386 } 386 }
387 } 387 }
388 return land_bitmap; 388 return land_bitmap;
389 } 389 }
390 /// <summary> 390 /// <summary>
391 /// Join the true values of 2 bitmaps together 391 /// Join the true values of 2 bitmaps together
392 /// </summary> 392 /// </summary>
393 /// <param name="bitmap_base"></param> 393 /// <param name="bitmap_base"></param>
394 /// <param name="bitmap_add"></param> 394 /// <param name="bitmap_add"></param>
395 /// <returns></returns> 395 /// <returns></returns>
396 public static bool[,] mergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add) 396 public static bool[,] mergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add)
397 { 397 {
398 if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2) 398 if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2)
399 { 399 {
400 //Throw an exception - The bitmap is not 64x64 400 //Throw an exception - The bitmap is not 64x64
401 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeLandBitmaps"); 401 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeLandBitmaps");
402 } 402 }
403 if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2) 403 if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2)
404 { 404 {
405 //Throw an exception - The bitmap is not 64x64 405 //Throw an exception - The bitmap is not 64x64
406 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeLandBitmaps"); 406 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeLandBitmaps");
407 407
408 } 408 }
409 409
410 int x, y; 410 int x, y;
411 for (y = 0; y < 64; y++) 411 for (y = 0; y < 64; y++)
412 { 412 {
413 for (x = 0; x < 64; x++) 413 for (x = 0; x < 64; x++)
414 { 414 {
415 if (bitmap_add[x, y]) 415 if (bitmap_add[x, y])
416 { 416 {
417 bitmap_base[x, y] = true; 417 bitmap_base[x, y] = true;
418 } 418 }
419 } 419 }
420 } 420 }
421 return bitmap_base; 421 return bitmap_base;
422 } 422 }
423 #endregion 423 #endregion
424 424
425 #region Object Select and Object Owner Listing 425 #region Object Select and Object Owner Listing
426 public void sendForceObjectSelect(int local_id, int request_type, IClientAPI remote_client) 426 public void sendForceObjectSelect(int local_id, int request_type, IClientAPI remote_client)
427 { 427 {
428 List<uint> resultLocalIDs = new List<uint>(); 428 List<uint> resultLocalIDs = new List<uint>();
429 foreach (SceneObject obj in primsOverMe) 429 foreach (SceneObject obj in primsOverMe)
430 { 430 {
431 if (obj.rootLocalID > 0) 431 if (obj.rootLocalID > 0)
432 { 432 {
433 if (request_type == LandManager.LAND_SELECT_OBJECTS_OWNER && obj.rootPrimitive.OwnerID == this.landData.ownerID) 433 if (request_type == LandManager.LAND_SELECT_OBJECTS_OWNER && obj.rootPrimitive.OwnerID == this.landData.ownerID)
434 { 434 {
435 resultLocalIDs.Add(obj.rootLocalID); 435 resultLocalIDs.Add(obj.rootLocalID);
436 } 436 }
437 else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && false) //TODO: change false to group support! 437 else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && false) //TODO: change false to group support!
438 { 438 {
439 439
440 } 440 }
441 else if (request_type == LandManager.LAND_SELECT_OBJECTS_OTHER && obj.rootPrimitive.OwnerID != remote_client.AgentId) 441 else if (request_type == LandManager.LAND_SELECT_OBJECTS_OTHER && obj.rootPrimitive.OwnerID != remote_client.AgentId)
442 { 442 {
443 resultLocalIDs.Add(obj.rootLocalID); 443 resultLocalIDs.Add(obj.rootLocalID);
444 } 444 }
445 } 445 }
446 } 446 }
447 447
448 448
449 bool firstCall = true; 449 bool firstCall = true;
450 int MAX_OBJECTS_PER_PACKET = 251; 450 int MAX_OBJECTS_PER_PACKET = 251;
451 ForceObjectSelectPacket pack = new ForceObjectSelectPacket(); 451 ForceObjectSelectPacket pack = new ForceObjectSelectPacket();
452 ForceObjectSelectPacket.DataBlock[] data; 452 ForceObjectSelectPacket.DataBlock[] data;
453 while (resultLocalIDs.Count > 0) 453 while (resultLocalIDs.Count > 0)
454 { 454 {
455 if (firstCall) 455 if (firstCall)
456 { 456 {
457 pack._Header.ResetList = true; 457 pack._Header.ResetList = true;
458 firstCall = false; 458 firstCall = false;
459 } 459 }
460 else 460 else
461 { 461 {
462 pack._Header.ResetList = false; 462 pack._Header.ResetList = false;
463 } 463 }
464 464
465 if (resultLocalIDs.Count > MAX_OBJECTS_PER_PACKET) 465 if (resultLocalIDs.Count > MAX_OBJECTS_PER_PACKET)
466 { 466 {
467 data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET]; 467 data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET];
468 } 468 }
469 else 469 else
470 { 470 {
471 data = new ForceObjectSelectPacket.DataBlock[resultLocalIDs.Count]; 471 data = new ForceObjectSelectPacket.DataBlock[resultLocalIDs.Count];
472 } 472 }
473 473
474 int i; 474 int i;
475 for (i = 0; i < MAX_OBJECTS_PER_PACKET && resultLocalIDs.Count > 0; i++) 475 for (i = 0; i < MAX_OBJECTS_PER_PACKET && resultLocalIDs.Count > 0; i++)
476 { 476 {
477 data[i] = new ForceObjectSelectPacket.DataBlock(); 477 data[i] = new ForceObjectSelectPacket.DataBlock();
478 data[i].LocalID = Convert.ToUInt32(resultLocalIDs[0]); 478 data[i].LocalID = Convert.ToUInt32(resultLocalIDs[0]);
479 resultLocalIDs.RemoveAt(0); 479 resultLocalIDs.RemoveAt(0);
480 } 480 }
481 pack.Data = data; 481 pack.Data = data;
482 remote_client.OutPacket((Packet)pack); 482 remote_client.OutPacket((Packet)pack);
483 } 483 }
484 484
485 } 485 }
486 public void sendLandObjectOwners(IClientAPI remote_client) 486 public void sendLandObjectOwners(IClientAPI remote_client)
487 { 487 {
488 Dictionary<LLUUID, int> ownersAndCount = new Dictionary<LLUUID, int>(); 488 Dictionary<LLUUID, int> ownersAndCount = new Dictionary<LLUUID, int>();
489 foreach (SceneObject obj in primsOverMe) 489 foreach (SceneObject obj in primsOverMe)
490 { 490 {
491 if (!ownersAndCount.ContainsKey(obj.rootPrimitive.OwnerID)) 491 if (!ownersAndCount.ContainsKey(obj.rootPrimitive.OwnerID))
492 { 492 {
493 ownersAndCount.Add(obj.rootPrimitive.OwnerID, 0); 493 ownersAndCount.Add(obj.rootPrimitive.OwnerID, 0);
494 } 494 }
495 ownersAndCount[obj.rootPrimitive.OwnerID] += obj.primCount; 495 ownersAndCount[obj.rootPrimitive.OwnerID] += obj.primCount;
496 } 496 }
497 if (ownersAndCount.Count > 0) 497 if (ownersAndCount.Count > 0)
498 { 498 {
499 499
500 ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[32]; 500 ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[32];
501 501
502 if (ownersAndCount.Count < 32) 502 if (ownersAndCount.Count < 32)
503 { 503 {
504 dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[ownersAndCount.Count]; 504 dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[ownersAndCount.Count];
505 } 505 }
506 506
507 507
508 int num = 0; 508 int num = 0;
509 foreach (LLUUID owner in ownersAndCount.Keys) 509 foreach (LLUUID owner in ownersAndCount.Keys)
510 { 510 {
511 dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock(); 511 dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock();
512 dataBlock[num].Count = ownersAndCount[owner]; 512 dataBlock[num].Count = ownersAndCount[owner];
513 dataBlock[num].IsGroupOwned = false; //TODO: fix me when group support is added 513 dataBlock[num].IsGroupOwned = false; //TODO: fix me when group support is added
514 dataBlock[num].OnlineStatus = true; //TODO: fix me later 514 dataBlock[num].OnlineStatus = true; //TODO: fix me later
515 dataBlock[num].OwnerID = owner; 515 dataBlock[num].OwnerID = owner;
516 516
517 num++; 517 num++;
518 } 518 }
519 519
520 ParcelObjectOwnersReplyPacket pack = new ParcelObjectOwnersReplyPacket(); 520 ParcelObjectOwnersReplyPacket pack = new ParcelObjectOwnersReplyPacket();
521 pack.Data = dataBlock; 521 pack.Data = dataBlock;
522 remote_client.OutPacket(pack); 522 remote_client.OutPacket(pack);
523 } 523 }
524 } 524 }
525 #endregion 525 #endregion
526 526
527 #region Object Returning 527 #region Object Returning
528 public void returnObject(SceneObject obj) 528 public void returnObject(SceneObject obj)
529 { 529 {
530 } 530 }
531 public void returnLandObjects(int type, LLUUID owner) 531 public void returnLandObjects(int type, LLUUID owner)
532 { 532 {
533 533
534 } 534 }
535 #endregion 535 #endregion
536 536
537 #region Object Adding/Removing from Parcel 537 #region Object Adding/Removing from Parcel
538 public void resetLandPrimCounts() 538 public void resetLandPrimCounts()
539 { 539 {
540 landData.groupPrims = 0; 540 landData.groupPrims = 0;
541 landData.ownerPrims = 0; 541 landData.ownerPrims = 0;
542 landData.otherPrims = 0; 542 landData.otherPrims = 0;
543 landData.selectedPrims = 0; 543 landData.selectedPrims = 0;
544 primsOverMe.Clear(); 544 primsOverMe.Clear();
545 } 545 }
546 546
547 public void addPrimToCount(SceneObject obj) 547 public void addPrimToCount(SceneObject obj)
548 { 548 {
549 LLUUID prim_owner = obj.rootPrimitive.OwnerID; 549 LLUUID prim_owner = obj.rootPrimitive.OwnerID;
550 int prim_count = obj.primCount; 550 int prim_count = obj.primCount;
551 551
552 if (obj.isSelected) 552 if (obj.isSelected)
553 { 553 {
554 landData.selectedPrims += prim_count; 554 landData.selectedPrims += prim_count;
555 } 555 }
556 else 556 else
557 { 557 {
558 if (prim_owner == landData.ownerID) 558 if (prim_owner == landData.ownerID)
559 { 559 {
560 landData.ownerPrims += prim_count; 560 landData.ownerPrims += prim_count;
561 } 561 }
562 else 562 else
563 { 563 {
564 landData.otherPrims += prim_count; 564 landData.otherPrims += prim_count;
565 } 565 }
566 } 566 }
567 567
568 primsOverMe.Add(obj); 568 primsOverMe.Add(obj);
569 569
570 } 570 }
571 571
572 public void removePrimFromCount(SceneObject obj) 572 public void removePrimFromCount(SceneObject obj)
573 { 573 {
574 if (primsOverMe.Contains(obj)) 574 if (primsOverMe.Contains(obj))
575 { 575 {
576 LLUUID prim_owner = obj.rootPrimitive.OwnerID; 576 LLUUID prim_owner = obj.rootPrimitive.OwnerID;
577 int prim_count = obj.primCount; 577 int prim_count = obj.primCount;
578 578
579 if (prim_owner == landData.ownerID) 579 if (prim_owner == landData.ownerID)
580 { 580 {
581 landData.ownerPrims -= prim_count; 581 landData.ownerPrims -= prim_count;
582 } 582 }
583 else if (prim_owner == landData.groupID) 583 else if (prim_owner == landData.groupID)
584 { 584 {
585 landData.groupPrims -= prim_count; 585 landData.groupPrims -= prim_count;
586 } 586 }
587 else 587 else
588 { 588 {
589 landData.otherPrims -= prim_count; 589 landData.otherPrims -= prim_count;
590 } 590 }
591 591
592 primsOverMe.Remove(obj); 592 primsOverMe.Remove(obj);
593 } 593 }
594 } 594 }
595 #endregion 595 #endregion
596 596
597 #endregion 597 #endregion
598 598
599 599
600 } 600 }
601 #endregion 601 #endregion
602} 602}