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