diff options
Taking Prims (SceneObjectGroups) in and out of inventory should now work and if left in inventory will still be there after restarts. (as with the rest of inventory it will only fully work in standalone mode with account authentication turned on).
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs | 107 |
1 files changed, 82 insertions, 25 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 10bdd54..b901d23 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs | |||
@@ -34,6 +34,7 @@ using OpenSim.Framework.Interfaces; | |||
34 | using OpenSim.Framework.Types; | 34 | using OpenSim.Framework.Types; |
35 | using OpenSim.Framework.Communications.Caches; | 35 | using OpenSim.Framework.Communications.Caches; |
36 | using OpenSim.Framework.Data; | 36 | using OpenSim.Framework.Data; |
37 | using OpenSim.Framework.Utilities; | ||
37 | 38 | ||
38 | namespace OpenSim.Region.Environment.Scenes | 39 | namespace OpenSim.Region.Environment.Scenes |
39 | { | 40 | { |
@@ -209,23 +210,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
209 | /// <summary> | 210 | /// <summary> |
210 | /// | 211 | /// |
211 | /// </summary> | 212 | /// </summary> |
212 | /// <param name="primAsset"></param> | ||
213 | /// <param name="pos"></param> | ||
214 | public void RezObject(AssetBase primAsset, LLVector3 pos) | ||
215 | { | ||
216 | |||
217 | } | ||
218 | |||
219 | /// <summary> | ||
220 | /// | ||
221 | /// </summary> | ||
222 | /// <param name="packet"></param> | 213 | /// <param name="packet"></param> |
223 | /// <param name="simClient"></param> | 214 | /// <param name="simClient"></param> |
224 | public void DeRezObject(Packet packet, IClientAPI simClient) | 215 | public void DeRezObject(Packet packet, IClientAPI remoteClient) |
225 | { | 216 | { |
226 | DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet; | 217 | DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet; |
227 | 218 | ||
228 | 219 | ||
229 | if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) | 220 | if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) |
230 | { | 221 | { |
231 | //currently following code not used (or don't know of any case of destination being zero | 222 | //currently following code not used (or don't know of any case of destination being zero |
@@ -246,17 +237,76 @@ namespace OpenSim.Region.Environment.Scenes | |||
246 | } | 237 | } |
247 | if (selectedEnt != null) | 238 | if (selectedEnt != null) |
248 | { | 239 | { |
249 | if (PermissionsMngr.CanDeRezObject(simClient.AgentId, selectedEnt.m_uuid)) | 240 | if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId,((SceneObjectGroup)selectedEnt).UUID)) |
250 | { | 241 | { |
251 | List<ScenePresence> avatars = this.RequestAvatarList(); | 242 | string sceneObjectXml = ((SceneObjectGroup)selectedEnt).ToXmlString(); |
252 | foreach (ScenePresence avatar in avatars) | 243 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); |
244 | if (userInfo != null) | ||
253 | { | 245 | { |
254 | avatar.ControllingClient.SendKillObject(this.m_regionHandle, selectedEnt.LocalId); | 246 | AssetBase asset = new AssetBase(); |
247 | asset.Name = ((SceneObjectGroup)selectedEnt).GetPartName(selectedEnt.LocalId); | ||
248 | asset.Description = ((SceneObjectGroup)selectedEnt).GetPartDescription(selectedEnt.LocalId); | ||
249 | asset.InvType = 6; | ||
250 | asset.Type = 6; | ||
251 | asset.FullID = LLUUID.Random(); | ||
252 | asset.Data = Helpers.StringToField(sceneObjectXml); | ||
253 | this.assetCache.AddAsset(asset); | ||
254 | |||
255 | |||
256 | InventoryItemBase item = new InventoryItemBase(); | ||
257 | item.avatarID = remoteClient.AgentId; | ||
258 | item.creatorsID = remoteClient.AgentId; | ||
259 | item.inventoryID = LLUUID.Random(); | ||
260 | item.assetID = asset.FullID; | ||
261 | item.inventoryDescription = asset.Description; | ||
262 | item.inventoryName = asset.Name; | ||
263 | item.assetType = asset.Type; | ||
264 | item.invType = asset.InvType; | ||
265 | item.parentFolderID = DeRezPacket.AgentBlock.DestinationID; | ||
266 | item.inventoryCurrentPermissions = 2147483647; | ||
267 | item.inventoryNextPermissions = 2147483647; | ||
268 | |||
269 | userInfo.AddItem(remoteClient.AgentId, item); | ||
270 | remoteClient.SendInventoryItemUpdate(item); | ||
255 | } | 271 | } |
256 | 272 | ||
273 | ((SceneObjectGroup)selectedEnt).DeleteGroup(); | ||
274 | |||
257 | lock (Entities) | 275 | lock (Entities) |
258 | { | 276 | { |
259 | Entities.Remove(selectedEnt.m_uuid); | 277 | Entities.Remove(((SceneObjectGroup) selectedEnt).UUID); |
278 | } | ||
279 | } | ||
280 | } | ||
281 | } | ||
282 | } | ||
283 | } | ||
284 | |||
285 | public void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos) | ||
286 | { | ||
287 | CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); | ||
288 | if (userInfo != null) | ||
289 | { | ||
290 | if(userInfo.RootFolder != null) | ||
291 | { | ||
292 | InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); | ||
293 | if (item != null) | ||
294 | { | ||
295 | AssetBase rezAsset = this.assetCache.GetAsset(item.assetID, false); | ||
296 | if (rezAsset != null) | ||
297 | { | ||
298 | this.AddRezObject(Util.FieldToString(rezAsset.Data), pos); | ||
299 | userInfo.DeleteItem(remoteClient.AgentId, item); | ||
300 | remoteClient.SendRemoveInventoryItem(itemID); | ||
301 | } | ||
302 | else | ||
303 | { | ||
304 | rezAsset = this.assetCache.GetAsset(item.assetID, false); | ||
305 | if (rezAsset != null) | ||
306 | { | ||
307 | this.AddRezObject(Util.FieldToString(rezAsset.Data), pos); | ||
308 | userInfo.DeleteItem(remoteClient.AgentId, item); | ||
309 | remoteClient.SendRemoveInventoryItem(itemID); | ||
260 | } | 310 | } |
261 | } | 311 | } |
262 | } | 312 | } |
@@ -264,6 +314,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
264 | } | 314 | } |
265 | } | 315 | } |
266 | 316 | ||
317 | private void AddRezObject(string xmlData, LLVector3 pos) | ||
318 | { | ||
319 | SceneObjectGroup group = new SceneObjectGroup(this, this.m_regionHandle, xmlData); | ||
320 | this.AddEntity(group); | ||
321 | group.Pos = pos; | ||
322 | } | ||
323 | |||
267 | /// <summary> | 324 | /// <summary> |
268 | /// | 325 | /// |
269 | /// </summary> | 326 | /// </summary> |
@@ -301,11 +358,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
301 | this.Entities.Add(copy.UUID, copy); | 358 | this.Entities.Add(copy.UUID, copy); |
302 | 359 | ||
303 | copy.ScheduleGroupForFullUpdate(); | 360 | copy.ScheduleGroupForFullUpdate(); |
304 | /* List<ScenePresence> avatars = this.RequestAvatarList(); | 361 | /* List<ScenePresence> avatars = this.RequestAvatarList(); |
305 | for (int i = 0; i < avatars.Count; i++) | 362 | for (int i = 0; i < avatars.Count; i++) |
306 | { | 363 | { |
307 | // copy.SendAllChildPrimsToClient(avatars[i].ControllingClient); | 364 | // copy.SendAllChildPrimsToClient(avatars[i].ControllingClient); |
308 | }*/ | 365 | }*/ |
309 | 366 | ||
310 | } | 367 | } |
311 | else | 368 | else |
@@ -620,7 +677,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
620 | if (hasPrim != false) | 677 | if (hasPrim != false) |
621 | { | 678 | { |
622 | ((SceneObjectGroup)ent).UpdateGroupRotation(pos, rot); | 679 | ((SceneObjectGroup)ent).UpdateGroupRotation(pos, rot); |
623 | // prim.UpdateGroupMouseRotation(pos, rot); | 680 | // prim.UpdateGroupMouseRotation(pos, rot); |
624 | break; | 681 | break; |
625 | } | 682 | } |
626 | } | 683 | } |
@@ -665,7 +722,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
665 | { | 722 | { |
666 | if (ent is SceneObjectGroup) | 723 | if (ent is SceneObjectGroup) |
667 | { | 724 | { |
668 | // prim = ((SceneObject)ent).HasChildPrim(localID); | 725 | // prim = ((SceneObject)ent).HasChildPrim(localID); |
669 | if (prim != null) | 726 | if (prim != null) |
670 | { | 727 | { |
671 | prim.UpdateSingleRotation(rot); | 728 | prim.UpdateSingleRotation(rot); |
@@ -692,7 +749,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
692 | if (hasPrim != false) | 749 | if (hasPrim != false) |
693 | { | 750 | { |
694 | ((SceneObjectGroup)ent).Resize(scale, localID); | 751 | ((SceneObjectGroup)ent).Resize(scale, localID); |
695 | // prim.ResizeGoup(scale); | 752 | // prim.ResizeGoup(scale); |
696 | break; | 753 | break; |
697 | } | 754 | } |
698 | } | 755 | } |