diff options
author | lbsa71 | 2007-09-20 23:28:08 +0000 |
---|---|---|
committer | lbsa71 | 2007-09-20 23:28:08 +0000 |
commit | 101369e25ad4e72233e4855be4b82d1647233a6c (patch) | |
tree | 58b2a7dfcf83d474cba77f8d16f6c0de4d2f4ec2 /OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |
parent | Rev 1971 : The Lbsa71 vintage commit (diff) | |
download | opensim-SC-101369e25ad4e72233e4855be4b82d1647233a6c.zip opensim-SC-101369e25ad4e72233e4855be4b82d1647233a6c.tar.gz opensim-SC-101369e25ad4e72233e4855be4b82d1647233a6c.tar.bz2 opensim-SC-101369e25ad4e72233e4855be4b82d1647233a6c.tar.xz |
* Some more presence refactoring
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scene.Inventory.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | 825 |
1 files changed, 415 insertions, 410 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 048d2b4..a6e47f3 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -8,428 +8,433 @@ using OpenSim.Framework.Types; | |||
8 | using OpenSim.Framework.Utilities; | 8 | using OpenSim.Framework.Utilities; |
9 | using OpenSim.Region.Physics.Manager; | 9 | using OpenSim.Region.Physics.Manager; |
10 | 10 | ||
11 | namespace OpenSim.Region.Environment.Scenes | 11 | namespace OpenSim.Region.Environment.Scenes |
12 | { | 12 | { |
13 | public partial class Scene | 13 | public partial class Scene |
14 | { | 14 | { |
15 | //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete | 15 | //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete |
16 | // or at least some of they can be moved somewhere else | 16 | // or at least some of they can be moved somewhere else |
17 | 17 | ||
18 | public void AddInventoryItem(LLUUID userID, InventoryItemBase item) | 18 | public void AddInventoryItem(LLUUID avatarId, InventoryItemBase item) |
19 | { | 19 | { |
20 | if (Avatars.ContainsKey(userID)) | 20 | ScenePresence avatar; |
21 | { | 21 | |
22 | AddInventoryItem(Avatars[userID].ControllingClient, item); | 22 | if ( TryGetAvatar( avatarId, out avatar )) |
23 | } | 23 | { |
24 | } | 24 | AddInventoryItem(avatar.ControllingClient, item); |
25 | 25 | } | |
26 | public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item) | 26 | } |
27 | { | 27 | |
28 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); | 28 | public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item) |
29 | if (userInfo != null) | 29 | { |
30 | { | 30 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); |
31 | userInfo.AddItem(remoteClient.AgentId, item); | 31 | if (userInfo != null) |
32 | remoteClient.SendInventoryItemUpdate(item); | 32 | { |
33 | } | 33 | userInfo.AddItem(remoteClient.AgentId, item); |
34 | } | 34 | remoteClient.SendInventoryItemUpdate(item); |
35 | 35 | } | |
36 | public LLUUID CapsUpdateInventoryItemAsset(LLUUID userID, LLUUID itemID, byte[] data) | 36 | } |
37 | { | 37 | |
38 | if (Avatars.ContainsKey(userID)) | 38 | public LLUUID CapsUpdateInventoryItemAsset(LLUUID avatarId, LLUUID itemID, byte[] data) |
39 | { | 39 | { |
40 | return CapsUpdateInventoryItemAsset(Avatars[userID].ControllingClient, itemID, data); | 40 | ScenePresence avatar; |
41 | } | 41 | |
42 | return LLUUID.Zero; | 42 | if (TryGetAvatar(avatarId, out avatar)) |
43 | } | 43 | { |
44 | 44 | return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); | |
45 | public LLUUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data) | 45 | } |
46 | { | 46 | |
47 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); | 47 | return LLUUID.Zero; |
48 | if (userInfo != null) | 48 | } |
49 | { | 49 | |
50 | if (userInfo.RootFolder != null) | 50 | public LLUUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data) |
51 | { | 51 | { |
52 | InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); | 52 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); |
53 | if (item != null) | 53 | if (userInfo != null) |
54 | { | 54 | { |
55 | AssetBase asset; | 55 | if (userInfo.RootFolder != null) |
56 | asset = new AssetBase(); | 56 | { |
57 | asset.FullID = LLUUID.Random(); | 57 | InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); |
58 | asset.Type = (sbyte) item.assetType; | 58 | if (item != null) |
59 | asset.InvType = (sbyte) item.invType; | 59 | { |
60 | asset.Name = item.inventoryName; | 60 | AssetBase asset; |
61 | asset.Data = data; | 61 | asset = new AssetBase(); |
62 | commsManager.AssetCache.AddAsset(asset); | 62 | asset.FullID = LLUUID.Random(); |
63 | 63 | asset.Type = (sbyte) item.assetType; | |
64 | item.assetID = asset.FullID; | 64 | asset.InvType = (sbyte) item.invType; |
65 | userInfo.UpdateItem(remoteClient.AgentId, item); | 65 | asset.Name = item.inventoryName; |
66 | 66 | asset.Data = data; | |
67 | // remoteClient.SendInventoryItemUpdate(item); | 67 | commsManager.AssetCache.AddAsset(asset); |
68 | if (item.invType == 7) | 68 | |
69 | { | 69 | item.assetID = asset.FullID; |
70 | //do we want to know about updated note cards? | 70 | userInfo.UpdateItem(remoteClient.AgentId, item); |
71 | } | 71 | |
72 | else if (item.invType == 10) | 72 | // remoteClient.SendInventoryItemUpdate(item); |
73 | { | 73 | if (item.invType == 7) |
74 | // do we want to know about updated scripts | 74 | { |
75 | } | 75 | //do we want to know about updated note cards? |
76 | 76 | } | |
77 | return (asset.FullID); | 77 | else if (item.invType == 10) |
78 | } | 78 | { |
79 | } | 79 | // do we want to know about updated scripts |
80 | } | 80 | } |
81 | return LLUUID.Zero; | 81 | |
82 | } | 82 | return (asset.FullID); |
83 | 83 | } | |
84 | } | ||
85 | } | ||
86 | return LLUUID.Zero; | ||
87 | } | ||
88 | |||
84 | public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, | 89 | public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, |
85 | LLUUID itemID) | 90 | LLUUID itemID) |
86 | { | 91 | { |
87 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); | 92 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); |
88 | if (userInfo != null) | 93 | if (userInfo != null) |
89 | { | 94 | { |
90 | if (userInfo.RootFolder != null) | 95 | if (userInfo.RootFolder != null) |
91 | { | 96 | { |
92 | InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); | 97 | InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); |
93 | if (item != null) | 98 | if (item != null) |
94 | { | 99 | { |
95 | AgentAssetTransactions transactions = | 100 | AgentAssetTransactions transactions = |
96 | commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); | 101 | commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); |
97 | if (transactions != null) | 102 | if (transactions != null) |
98 | { | 103 | { |
99 | AssetBase asset = null; | 104 | AssetBase asset = null; |
100 | bool addToCache = false; | 105 | bool addToCache = false; |
101 | 106 | ||
102 | asset = commsManager.AssetCache.GetAsset(assetID); | 107 | asset = commsManager.AssetCache.GetAsset(assetID); |
103 | if (asset == null) | 108 | if (asset == null) |
104 | { | 109 | { |
105 | asset = transactions.GetTransactionAsset(transactionID); | 110 | asset = transactions.GetTransactionAsset(transactionID); |
106 | addToCache = true; | 111 | addToCache = true; |
107 | } | 112 | } |
108 | 113 | ||
109 | if (asset != null) | 114 | if (asset != null) |
110 | { | 115 | { |
111 | if (asset.FullID == assetID) | 116 | if (asset.FullID == assetID) |
112 | { | 117 | { |
113 | asset.Name = item.inventoryName; | 118 | asset.Name = item.inventoryName; |
114 | asset.Description = item.inventoryDescription; | 119 | asset.Description = item.inventoryDescription; |
115 | asset.InvType = (sbyte) item.invType; | 120 | asset.InvType = (sbyte) item.invType; |
116 | asset.Type = (sbyte) item.assetType; | 121 | asset.Type = (sbyte) item.assetType; |
117 | item.assetID = asset.FullID; | 122 | item.assetID = asset.FullID; |
118 | 123 | ||
119 | if (addToCache) | 124 | if (addToCache) |
120 | { | 125 | { |
121 | commsManager.AssetCache.AddAsset(asset); | 126 | commsManager.AssetCache.AddAsset(asset); |
122 | } | 127 | } |
123 | 128 | ||
124 | userInfo.UpdateItem(remoteClient.AgentId, item); | 129 | userInfo.UpdateItem(remoteClient.AgentId, item); |
125 | } | 130 | } |
126 | } | 131 | } |
127 | } | 132 | } |
128 | } | 133 | } |
129 | } | 134 | } |
130 | } | 135 | } |
131 | } | 136 | } |
132 | 137 | ||
133 | /// <summary> | 138 | /// <summary> |
134 | /// temporary method to test out creating new inventory items | 139 | /// temporary method to test out creating new inventory items |
135 | /// </summary> | 140 | /// </summary> |
136 | /// <param name="remoteClient"></param> | 141 | /// <param name="remoteClient"></param> |
137 | /// <param name="transActionID"></param> | 142 | /// <param name="transActionID"></param> |
138 | /// <param name="folderID"></param> | 143 | /// <param name="folderID"></param> |
139 | /// <param name="callbackID"></param> | 144 | /// <param name="callbackID"></param> |
140 | /// <param name="description"></param> | 145 | /// <param name="description"></param> |
141 | /// <param name="name"></param> | 146 | /// <param name="name"></param> |
142 | /// <param name="invType"></param> | 147 | /// <param name="invType"></param> |
143 | /// <param name="type"></param> | 148 | /// <param name="type"></param> |
144 | /// <param name="wearableType"></param> | 149 | /// <param name="wearableType"></param> |
145 | /// <param name="nextOwnerMask"></param> | 150 | /// <param name="nextOwnerMask"></param> |
146 | public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, | 151 | public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, |
147 | uint callbackID, string description, string name, sbyte invType, sbyte type, | 152 | uint callbackID, string description, string name, sbyte invType, sbyte type, |
148 | byte wearableType, uint nextOwnerMask) | 153 | byte wearableType, uint nextOwnerMask) |
149 | { | 154 | { |
150 | if (transActionID == LLUUID.Zero) | 155 | if (transActionID == LLUUID.Zero) |
151 | { | 156 | { |
152 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); | 157 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); |
153 | if (userInfo != null) | 158 | if (userInfo != null) |
154 | { | 159 | { |
155 | AssetBase asset = new AssetBase(); | 160 | AssetBase asset = new AssetBase(); |
156 | asset.Name = name; | 161 | asset.Name = name; |
157 | asset.Description = description; | 162 | asset.Description = description; |
158 | asset.InvType = invType; | 163 | asset.InvType = invType; |
159 | asset.Type = type; | 164 | asset.Type = type; |
160 | asset.FullID = LLUUID.Random(); | 165 | asset.FullID = LLUUID.Random(); |
161 | asset.Data = new byte[1]; | 166 | asset.Data = new byte[1]; |
162 | commsManager.AssetCache.AddAsset(asset); | 167 | commsManager.AssetCache.AddAsset(asset); |
163 | 168 | ||
164 | InventoryItemBase item = new InventoryItemBase(); | 169 | InventoryItemBase item = new InventoryItemBase(); |
165 | item.avatarID = remoteClient.AgentId; | 170 | item.avatarID = remoteClient.AgentId; |
166 | item.creatorsID = remoteClient.AgentId; | 171 | item.creatorsID = remoteClient.AgentId; |
167 | item.inventoryID = LLUUID.Random(); | 172 | item.inventoryID = LLUUID.Random(); |
168 | item.assetID = asset.FullID; | 173 | item.assetID = asset.FullID; |
169 | item.inventoryDescription = description; | 174 | item.inventoryDescription = description; |
170 | item.inventoryName = name; | 175 | item.inventoryName = name; |
171 | item.assetType = invType; | 176 | item.assetType = invType; |
172 | item.invType = invType; | 177 | item.invType = invType; |
173 | item.parentFolderID = folderID; | 178 | item.parentFolderID = folderID; |
174 | item.inventoryCurrentPermissions = 2147483647; | 179 | item.inventoryCurrentPermissions = 2147483647; |
175 | item.inventoryNextPermissions = nextOwnerMask; | 180 | item.inventoryNextPermissions = nextOwnerMask; |
176 | 181 | ||
177 | userInfo.AddItem(remoteClient.AgentId, item); | 182 | userInfo.AddItem(remoteClient.AgentId, item); |
178 | remoteClient.SendInventoryItemUpdate(item); | 183 | remoteClient.SendInventoryItemUpdate(item); |
179 | } | 184 | } |
180 | } | 185 | } |
181 | else | 186 | else |
182 | { | 187 | { |
183 | commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID, | 188 | commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID, |
184 | callbackID, description, name, invType, | 189 | callbackID, description, name, invType, |
185 | type, wearableType, nextOwnerMask); | 190 | type, wearableType, nextOwnerMask); |
186 | //System.Console.WriteLine("request to create inventory item from transaction " + transActionID); | 191 | //System.Console.WriteLine("request to create inventory item from transaction " + transActionID); |
187 | } | 192 | } |
188 | } | 193 | } |
189 | 194 | ||
190 | /// <summary> | 195 | /// <summary> |
191 | /// | 196 | /// |
192 | /// </summary> | 197 | /// </summary> |
193 | /// <param name="remoteClient"></param> | 198 | /// <param name="remoteClient"></param> |
194 | /// <param name="primLocalID"></param> | 199 | /// <param name="primLocalID"></param> |
195 | public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) | 200 | public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) |
196 | { | 201 | { |
197 | bool hasPrim = false; | 202 | bool hasPrim = false; |
198 | foreach (EntityBase ent in Entities.Values) | 203 | foreach (EntityBase ent in Entities.Values) |
199 | { | 204 | { |
200 | if (ent is SceneObjectGroup) | 205 | if (ent is SceneObjectGroup) |
201 | { | 206 | { |
202 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID); | 207 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID); |
203 | if (hasPrim != false) | 208 | if (hasPrim != false) |
204 | { | 209 | { |
205 | bool fileChange = ((SceneObjectGroup) ent).GetPartInventoryFileName(remoteClient, primLocalID); | 210 | bool fileChange = ((SceneObjectGroup) ent).GetPartInventoryFileName(remoteClient, primLocalID); |
206 | if (fileChange) | 211 | if (fileChange) |
207 | { | 212 | { |
208 | if (XferManager != null) | 213 | if (XferManager != null) |
209 | { | 214 | { |
210 | ((SceneObjectGroup) ent).RequestInventoryFile(primLocalID, XferManager); | 215 | ((SceneObjectGroup) ent).RequestInventoryFile(primLocalID, XferManager); |
211 | } | 216 | } |
212 | } | 217 | } |
213 | break; | 218 | break; |
214 | } | 219 | } |
215 | } | 220 | } |
216 | } | 221 | } |
217 | } | 222 | } |
218 | 223 | ||
219 | public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID) | 224 | public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID) |
220 | { | 225 | { |
221 | bool hasPrim = false; | 226 | bool hasPrim = false; |
222 | foreach (EntityBase ent in Entities.Values) | 227 | foreach (EntityBase ent in Entities.Values) |
223 | { | 228 | { |
224 | if (ent is SceneObjectGroup) | 229 | if (ent is SceneObjectGroup) |
225 | { | 230 | { |
226 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); | 231 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); |
227 | if (hasPrim != false) | 232 | if (hasPrim != false) |
228 | { | 233 | { |
229 | int type = ((SceneObjectGroup) ent).RemoveInventoryItem(remoteClient, localID, itemID); | 234 | int type = ((SceneObjectGroup) ent).RemoveInventoryItem(remoteClient, localID, itemID); |
230 | ((SceneObjectGroup) ent).GetProperites(remoteClient); | 235 | ((SceneObjectGroup) ent).GetProperites(remoteClient); |
231 | if (type == 10) | 236 | if (type == 10) |
232 | { | 237 | { |
233 | EventManager.TriggerRemoveScript(localID, itemID); | 238 | EventManager.TriggerRemoveScript(localID, itemID); |
234 | } | 239 | } |
235 | } | 240 | } |
236 | } | 241 | } |
237 | } | 242 | } |
238 | } | 243 | } |
239 | 244 | ||
240 | public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID) | 245 | public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID) |
241 | { | 246 | { |
242 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); | 247 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); |
243 | LLUUID copyID = LLUUID.Random(); | 248 | LLUUID copyID = LLUUID.Random(); |
244 | if (userInfo != null) | 249 | if (userInfo != null) |
245 | { | 250 | { |
246 | if (userInfo.RootFolder != null) | 251 | if (userInfo.RootFolder != null) |
247 | { | 252 | { |
248 | InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); | 253 | InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); |
249 | if (item != null) | 254 | if (item != null) |
250 | { | 255 | { |
251 | bool isTexture = false; | 256 | bool isTexture = false; |
252 | bool rezzed = false; | 257 | bool rezzed = false; |
253 | if (item.invType == 0) | 258 | if (item.invType == 0) |
254 | { | 259 | { |
255 | isTexture = true; | 260 | isTexture = true; |
256 | } | 261 | } |
257 | AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); | 262 | AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); |
258 | if (rezAsset != null) | 263 | if (rezAsset != null) |
259 | { | 264 | { |
260 | string script = Util.FieldToString(rezAsset.Data); | 265 | string script = Util.FieldToString(rezAsset.Data); |
261 | //Console.WriteLine("rez script "+script); | 266 | //Console.WriteLine("rez script "+script); |
262 | EventManager.TriggerRezScript(localID, copyID, script); | 267 | EventManager.TriggerRezScript(localID, copyID, script); |
263 | rezzed = true; | 268 | rezzed = true; |
264 | } | 269 | } |
265 | else | 270 | else |
266 | { | 271 | { |
267 | //lets try once more incase the asset cache is being slow getting the asset from server | 272 | //lets try once more incase the asset cache is being slow getting the asset from server |
268 | rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); | 273 | rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); |
269 | if (rezAsset != null) | 274 | if (rezAsset != null) |
270 | { | 275 | { |
271 | string script = Util.FieldToString(rezAsset.Data); | 276 | string script = Util.FieldToString(rezAsset.Data); |
272 | // Console.WriteLine("rez script " + script); | 277 | // Console.WriteLine("rez script " + script); |
273 | EventManager.TriggerRezScript(localID, copyID, script); | 278 | EventManager.TriggerRezScript(localID, copyID, script); |
274 | rezzed = true; | 279 | rezzed = true; |
275 | } | 280 | } |
276 | } | 281 | } |
277 | 282 | ||
278 | if (rezzed) | 283 | if (rezzed) |
279 | { | 284 | { |
280 | bool hasPrim = false; | 285 | bool hasPrim = false; |
281 | foreach (EntityBase ent in Entities.Values) | 286 | foreach (EntityBase ent in Entities.Values) |
282 | { | 287 | { |
283 | if (ent is SceneObjectGroup) | 288 | if (ent is SceneObjectGroup) |
284 | { | 289 | { |
285 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); | 290 | hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); |
286 | if (hasPrim != false) | 291 | if (hasPrim != false) |
287 | { | 292 | { |
288 | bool added = | 293 | bool added = |
289 | ((SceneObjectGroup) ent).AddInventoryItem(remoteClient, localID, item, | 294 | ((SceneObjectGroup) ent).AddInventoryItem(remoteClient, localID, item, |
290 | copyID); | 295 | copyID); |
291 | ((SceneObjectGroup) ent).GetProperites(remoteClient); | 296 | ((SceneObjectGroup) ent).GetProperites(remoteClient); |
292 | } | 297 | } |
293 | } | 298 | } |
294 | } | 299 | } |
295 | } | 300 | } |
296 | } | 301 | } |
297 | } | 302 | } |
298 | } | 303 | } |
299 | } | 304 | } |
300 | 305 | ||
301 | /// <summary> | 306 | /// <summary> |
302 | /// | 307 | /// |
303 | /// </summary> | 308 | /// </summary> |
304 | /// <param name="packet"></param> | 309 | /// <param name="packet"></param> |
305 | /// <param name="simClient"></param> | 310 | /// <param name="simClient"></param> |
306 | public void DeRezObject(Packet packet, IClientAPI remoteClient) | 311 | public void DeRezObject(Packet packet, IClientAPI remoteClient) |
307 | { | 312 | { |
308 | DeRezObjectPacket DeRezPacket = (DeRezObjectPacket) packet; | 313 | DeRezObjectPacket DeRezPacket = (DeRezObjectPacket) packet; |
309 | 314 | ||
310 | if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) | 315 | if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) |
311 | { | 316 | { |
312 | //currently following code not used (or don't know of any case of destination being zero | 317 | //currently following code not used (or don't know of any case of destination being zero |
313 | } | 318 | } |
314 | else | 319 | else |
315 | { | 320 | { |
316 | foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) | 321 | foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) |
317 | { | 322 | { |
318 | EntityBase selectedEnt = null; | 323 | EntityBase selectedEnt = null; |
319 | //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); | 324 | //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); |
320 | foreach (EntityBase ent in Entities.Values) | 325 | foreach (EntityBase ent in Entities.Values) |
321 | { | 326 | { |
322 | if (ent.LocalId == Data.ObjectLocalID) | 327 | if (ent.LocalId == Data.ObjectLocalID) |
323 | { | 328 | { |
324 | selectedEnt = ent; | 329 | selectedEnt = ent; |
325 | break; | 330 | break; |
326 | } | 331 | } |
327 | } | 332 | } |
328 | if (selectedEnt != null) | 333 | if (selectedEnt != null) |
329 | { | 334 | { |
330 | if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID)) | 335 | if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID)) |
331 | { | 336 | { |
332 | string sceneObjectXml = ((SceneObjectGroup) selectedEnt).ToXmlString(); | 337 | string sceneObjectXml = ((SceneObjectGroup) selectedEnt).ToXmlString(); |
333 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); | 338 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); |
334 | if (userInfo != null) | 339 | if (userInfo != null) |
335 | { | 340 | { |
336 | AssetBase asset = new AssetBase(); | 341 | AssetBase asset = new AssetBase(); |
337 | asset.Name = ((SceneObjectGroup) selectedEnt).GetPartName(selectedEnt.LocalId); | 342 | asset.Name = ((SceneObjectGroup) selectedEnt).GetPartName(selectedEnt.LocalId); |
338 | asset.Description = | 343 | asset.Description = |
339 | ((SceneObjectGroup) selectedEnt).GetPartDescription(selectedEnt.LocalId); | 344 | ((SceneObjectGroup) selectedEnt).GetPartDescription(selectedEnt.LocalId); |
340 | asset.InvType = 6; | 345 | asset.InvType = 6; |
341 | asset.Type = 6; | 346 | asset.Type = 6; |
342 | asset.FullID = LLUUID.Random(); | 347 | asset.FullID = LLUUID.Random(); |
343 | asset.Data = Helpers.StringToField(sceneObjectXml); | 348 | asset.Data = Helpers.StringToField(sceneObjectXml); |
344 | commsManager.AssetCache.AddAsset(asset); | 349 | commsManager.AssetCache.AddAsset(asset); |
345 | 350 | ||
346 | 351 | ||
347 | InventoryItemBase item = new InventoryItemBase(); | 352 | InventoryItemBase item = new InventoryItemBase(); |
348 | item.avatarID = remoteClient.AgentId; | 353 | item.avatarID = remoteClient.AgentId; |
349 | item.creatorsID = remoteClient.AgentId; | 354 | item.creatorsID = remoteClient.AgentId; |
350 | item.inventoryID = LLUUID.Random(); | 355 | item.inventoryID = LLUUID.Random(); |
351 | item.assetID = asset.FullID; | 356 | item.assetID = asset.FullID; |
352 | item.inventoryDescription = asset.Description; | 357 | item.inventoryDescription = asset.Description; |
353 | item.inventoryName = asset.Name; | 358 | item.inventoryName = asset.Name; |
354 | item.assetType = asset.Type; | 359 | item.assetType = asset.Type; |
355 | item.invType = asset.InvType; | 360 | item.invType = asset.InvType; |
356 | item.parentFolderID = DeRezPacket.AgentBlock.DestinationID; | 361 | item.parentFolderID = DeRezPacket.AgentBlock.DestinationID; |
357 | item.inventoryCurrentPermissions = 2147483647; | 362 | item.inventoryCurrentPermissions = 2147483647; |
358 | item.inventoryNextPermissions = 2147483647; | 363 | item.inventoryNextPermissions = 2147483647; |
359 | 364 | ||
360 | userInfo.AddItem(remoteClient.AgentId, item); | 365 | userInfo.AddItem(remoteClient.AgentId, item); |
361 | remoteClient.SendInventoryItemUpdate(item); | 366 | remoteClient.SendInventoryItemUpdate(item); |
362 | } | 367 | } |
363 | 368 | ||
364 | SceneObjectPart rootPart = | 369 | SceneObjectPart rootPart = |
365 | ((SceneObjectGroup) selectedEnt).GetChildPart(((SceneObjectGroup) selectedEnt).UUID); | 370 | ((SceneObjectGroup) selectedEnt).GetChildPart(((SceneObjectGroup) selectedEnt).UUID); |
366 | if (rootPart.PhysActor != null) | 371 | if (rootPart.PhysActor != null) |
367 | { | 372 | { |
368 | phyScene.RemovePrim(rootPart.PhysActor); | 373 | phyScene.RemovePrim(rootPart.PhysActor); |
369 | rootPart.PhysActor = null; | 374 | rootPart.PhysActor = null; |
370 | } | 375 | } |
371 | 376 | ||
372 | storageManager.DataStore.RemoveObject(((SceneObjectGroup) selectedEnt).UUID, | 377 | storageManager.DataStore.RemoveObject(((SceneObjectGroup) selectedEnt).UUID, |
373 | m_regInfo.SimUUID); | 378 | m_regInfo.SimUUID); |
374 | ((SceneObjectGroup) selectedEnt).DeleteGroup(); | 379 | ((SceneObjectGroup) selectedEnt).DeleteGroup(); |
375 | 380 | ||
376 | lock (Entities) | 381 | lock (Entities) |
377 | { | 382 | { |
378 | Entities.Remove(((SceneObjectGroup) selectedEnt).UUID); | 383 | Entities.Remove(((SceneObjectGroup) selectedEnt).UUID); |
379 | } | 384 | } |
380 | ((SceneObjectGroup) selectedEnt).DeleteParts(); | 385 | ((SceneObjectGroup) selectedEnt).DeleteParts(); |
381 | } | 386 | } |
382 | } | 387 | } |
383 | } | 388 | } |
384 | } | 389 | } |
385 | } | 390 | } |
386 | 391 | ||
387 | public void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos) | 392 | public void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos) |
388 | { | 393 | { |
389 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); | 394 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); |
390 | if (userInfo != null) | 395 | if (userInfo != null) |
391 | { | 396 | { |
392 | if (userInfo.RootFolder != null) | 397 | if (userInfo.RootFolder != null) |
393 | { | 398 | { |
394 | InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); | 399 | InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); |
395 | if (item != null) | 400 | if (item != null) |
396 | { | 401 | { |
397 | AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); | 402 | AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); |
398 | if (rezAsset != null) | 403 | if (rezAsset != null) |
399 | { | 404 | { |
400 | AddRezObject(Util.FieldToString(rezAsset.Data), pos); | 405 | AddRezObject(Util.FieldToString(rezAsset.Data), pos); |
401 | userInfo.DeleteItem(remoteClient.AgentId, item); | 406 | userInfo.DeleteItem(remoteClient.AgentId, item); |
402 | remoteClient.SendRemoveInventoryItem(itemID); | 407 | remoteClient.SendRemoveInventoryItem(itemID); |
403 | } | 408 | } |
404 | else | 409 | else |
405 | { | 410 | { |
406 | //lets try once more incase the asset cache is being slow getting the asset from server | 411 | //lets try once more incase the asset cache is being slow getting the asset from server |
407 | rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); | 412 | rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); |
408 | if (rezAsset != null) | 413 | if (rezAsset != null) |
409 | { | 414 | { |
410 | AddRezObject(Util.FieldToString(rezAsset.Data), pos); | 415 | AddRezObject(Util.FieldToString(rezAsset.Data), pos); |
411 | userInfo.DeleteItem(remoteClient.AgentId, item); | 416 | userInfo.DeleteItem(remoteClient.AgentId, item); |
412 | remoteClient.SendRemoveInventoryItem(itemID); | 417 | remoteClient.SendRemoveInventoryItem(itemID); |
413 | } | 418 | } |
414 | } | 419 | } |
415 | } | 420 | } |
416 | } | 421 | } |
417 | } | 422 | } |
418 | } | 423 | } |
419 | 424 | ||
420 | private void AddRezObject(string xmlData, LLVector3 pos) | 425 | private void AddRezObject(string xmlData, LLVector3 pos) |
421 | { | 426 | { |
422 | SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); | 427 | SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); |
423 | AddEntity(group); | 428 | AddEntity(group); |
424 | group.AbsolutePosition = pos; | 429 | group.AbsolutePosition = pos; |
425 | SceneObjectPart rootPart = group.GetChildPart(group.UUID); | 430 | SceneObjectPart rootPart = group.GetChildPart(group.UUID); |
426 | if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) | 431 | if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) |
427 | rootPart.PhysActor = phyScene.AddPrim( | 432 | rootPart.PhysActor = phyScene.AddPrim( |
428 | new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, | 433 | new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, |
429 | rootPart.AbsolutePosition.Z), | 434 | rootPart.AbsolutePosition.Z), |
430 | new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), | 435 | new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), |
431 | new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, | 436 | new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, |
432 | rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); | 437 | rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); |
433 | } | 438 | } |
434 | } | 439 | } |
435 | } \ No newline at end of file | 440 | } \ No newline at end of file |