aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes
diff options
context:
space:
mode:
authorMW2007-08-16 16:31:32 +0000
committerMW2007-08-16 16:31:32 +0000
commit531f64a53bbd084dd8d0b33ae6c49821c74d718a (patch)
tree6e515f4d52a974b72a229f1fbc39253a7ba2a8a0 /OpenSim/Region/Environment/Scenes
parentI will get it right, honestly! (diff)
downloadopensim-SC_OLD-531f64a53bbd084dd8d0b33ae6c49821c74d718a.zip
opensim-SC_OLD-531f64a53bbd084dd8d0b33ae6c49821c74d718a.tar.gz
opensim-SC_OLD-531f64a53bbd084dd8d0b33ae6c49821c74d718a.tar.bz2
opensim-SC_OLD-531f64a53bbd084dd8d0b33ae6c49821c74d718a.tar.xz
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')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs107
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs8
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs104
3 files changed, 172 insertions, 47 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;
34using OpenSim.Framework.Types; 34using OpenSim.Framework.Types;
35using OpenSim.Framework.Communications.Caches; 35using OpenSim.Framework.Communications.Caches;
36using OpenSim.Framework.Data; 36using OpenSim.Framework.Data;
37using OpenSim.Framework.Utilities;
37 38
38namespace OpenSim.Region.Environment.Scenes 39namespace 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 }
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 378acf9..96bb97a 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -538,7 +538,10 @@ namespace OpenSim.Region.Environment.Scenes
538 538
539 public void AddEntity(SceneObjectGroup sceneObject) 539 public void AddEntity(SceneObjectGroup sceneObject)
540 { 540 {
541 Entities.Add(sceneObject.UUID, sceneObject); 541 if(!Entities.ContainsKey(sceneObject.UUID))
542 {
543 Entities.Add(sceneObject.UUID, sceneObject);
544 }
542 } 545 }
543 546
544 public void RemoveEntity(SceneObjectGroup sceneObject) 547 public void RemoveEntity(SceneObjectGroup sceneObject)
@@ -604,6 +607,7 @@ namespace OpenSim.Region.Environment.Scenes
604 client.OnObjectDeselect += DeselectPrim; 607 client.OnObjectDeselect += DeselectPrim;
605 client.OnGrabUpdate += MoveObject; 608 client.OnGrabUpdate += MoveObject;
606 client.OnDeRezObject += DeRezObject; 609 client.OnDeRezObject += DeRezObject;
610 client.OnRezObject += RezObject;
607 client.OnNameFromUUIDRequest += commsManager.HandleUUIDNameRequest; 611 client.OnNameFromUUIDRequest += commsManager.HandleUUIDNameRequest;
608 client.OnObjectDescription += PrimDescription; 612 client.OnObjectDescription += PrimDescription;
609 client.OnObjectName += PrimName; 613 client.OnObjectName += PrimName;
@@ -1114,7 +1118,7 @@ namespace OpenSim.Region.Environment.Scenes
1114 this.assetCache.AddAsset(asset); 1118 this.assetCache.AddAsset(asset);
1115 1119
1116 item.assetID = asset.FullID; 1120 item.assetID = asset.FullID;
1117 userInfo.updateItem(remoteClient.AgentId, item); 1121 userInfo.UpdateItem(remoteClient.AgentId, item);
1118 1122
1119 // remoteClient.SendInventoryItemUpdate(item); 1123 // remoteClient.SendInventoryItemUpdate(item);
1120 1124
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 77d936d..73f199e 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Region.Environment.Scenes
39 { 39 {
40 get { return m_rootPart.RotationOffset; } 40 get { return m_rootPart.RotationOffset; }
41 } 41 }
42 42
43 43
44 /// <summary> 44 /// <summary>
45 /// 45 ///
@@ -108,6 +108,12 @@ namespace OpenSim.Region.Environment.Scenes
108 get { return m_rootPart.OwnerID; } 108 get { return m_rootPart.OwnerID; }
109 } 109 }
110 110
111 public string Text
112 {
113 get { return m_rootPart.Text; }
114 set { m_rootPart.Text = value; }
115 }
116
111 /// <summary> 117 /// <summary>
112 /// Added because the Parcel code seems to use it 118 /// Added because the Parcel code seems to use it
113 /// but not sure a object should have this 119 /// but not sure a object should have this
@@ -143,19 +149,40 @@ namespace OpenSim.Region.Environment.Scenes
143 149
144 StringReader sr = new StringReader(xmlData); 150 StringReader sr = new StringReader(xmlData);
145 XmlTextReader reader = new XmlTextReader(sr); 151 XmlTextReader reader = new XmlTextReader(sr);
152 reader.Read();
146 reader.ReadStartElement("SceneObjectGroup"); 153 reader.ReadStartElement("SceneObjectGroup");
147 reader.ReadStartElement("RootPart"); 154 reader.ReadStartElement("RootPart");
148 this.m_rootPart = SceneObjectPart.FromXml(reader); 155 this.m_rootPart = SceneObjectPart.FromXml(reader);
149 reader.ReadEndElement(); 156 reader.ReadEndElement();
150 //TODO: read and create rest of the parts 157
151 reader.ReadEndElement(); 158 while (reader.Read())
159 {
160 switch (reader.NodeType)
161 {
162 case XmlNodeType.Element:
163 if (reader.Name == "Part")
164 {
165 reader.Read();
166 SceneObjectPart Part = SceneObjectPart.FromXml(reader);
167 Part.LocalID = m_scene.PrimIDAllocate();
168 this.AddPart(Part);
169 Part.RegionHandle = m_regionHandle;
170 }
171 break;
172 case XmlNodeType.EndElement:
173 break;
174 }
175 }
152 reader.Close(); 176 reader.Close();
153 sr.Close(); 177 sr.Close();
154 178 this.m_rootPart.SetParent(this);
155 this.m_parts.Add(m_rootPart.UUID, m_rootPart); 179 this.m_parts.Add(m_rootPart.UUID, m_rootPart);
156 this.m_rootPart.LocalID = m_scene.PrimIDAllocate(); 180 this.m_rootPart.LocalID = m_scene.PrimIDAllocate();
181 this.m_rootPart.ParentID = 0;
157 this.m_rootPart.RegionHandle = m_regionHandle; 182 this.m_rootPart.RegionHandle = m_regionHandle;
183 this.UpdateParentIDs();
158 m_scene.EventManager.OnBackup += this.ProcessBackup; 184 m_scene.EventManager.OnBackup += this.ProcessBackup;
185 this.ScheduleGroupForFullUpdate();
159 } 186 }
160 187
161 /// <summary> 188 /// <summary>
@@ -192,6 +219,17 @@ namespace OpenSim.Region.Environment.Scenes
192 writer.WriteStartElement(String.Empty, "RootPart", String.Empty); 219 writer.WriteStartElement(String.Empty, "RootPart", String.Empty);
193 m_rootPart.ToXml(writer); 220 m_rootPart.ToXml(writer);
194 writer.WriteEndElement(); 221 writer.WriteEndElement();
222 writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
223 foreach (SceneObjectPart part in this.m_parts.Values)
224 {
225 if (part.UUID != this.m_rootPart.UUID)
226 {
227 writer.WriteStartElement(String.Empty, "Part", String.Empty);
228 part.ToXml(writer);
229 writer.WriteEndElement();
230 }
231 }
232 writer.WriteEndElement();
195 writer.WriteEndElement(); 233 writer.WriteEndElement();
196 writer.Close(); 234 writer.Close();
197 // System.Console.WriteLine("prim: " + sw.ToString()); 235 // System.Console.WriteLine("prim: " + sw.ToString());
@@ -215,11 +253,11 @@ namespace OpenSim.Region.Environment.Scenes
215 dupe.m_regionHandle = this.m_regionHandle; 253 dupe.m_regionHandle = this.m_regionHandle;
216 254
217 dupe.CopyRootPart(this.m_rootPart); 255 dupe.CopyRootPart(this.m_rootPart);
218 256
219 List<SceneObjectPart> partList = new List<SceneObjectPart>(this.m_parts.Values); 257 List<SceneObjectPart> partList = new List<SceneObjectPart>(this.m_parts.Values);
220 foreach (SceneObjectPart part in partList) 258 foreach (SceneObjectPart part in partList)
221 { 259 {
222 if (part.UUID != this.m_rootPart.UUID) 260 if (part.UUID != this.m_rootPart.UUID)
223 { 261 {
224 dupe.CopyPart(part); 262 dupe.CopyPart(part);
225 } 263 }
@@ -477,13 +515,6 @@ namespace OpenSim.Region.Environment.Scenes
477 } 515 }
478 } 516 }
479 517
480 public string Text
481 {
482 get { return m_rootPart.Text; }
483 set { m_rootPart.Text = value; }
484 }
485
486
487 public void SetPartText(string text, uint localID) 518 public void SetPartText(string text, uint localID)
488 { 519 {
489 SceneObjectPart part = this.GetChildPrim(localID); 520 SceneObjectPart part = this.GetChildPrim(localID);
@@ -502,6 +533,26 @@ namespace OpenSim.Region.Environment.Scenes
502 } 533 }
503 } 534 }
504 535
536 public string GetPartName(uint localID)
537 {
538 SceneObjectPart part = this.GetChildPrim(localID);
539 if (part != null)
540 {
541 return part.PartName;
542 }
543 return "";
544 }
545
546 public string GetPartDescription(uint localID)
547 {
548 SceneObjectPart part = this.GetChildPrim(localID);
549 if (part != null)
550 {
551 return part.Description;
552 }
553 return "";
554 }
555
505 /// <summary> 556 /// <summary>
506 /// 557 ///
507 /// </summary> 558 /// </summary>
@@ -598,7 +649,7 @@ namespace OpenSim.Region.Environment.Scenes
598 SceneObjectPart part = this.GetChildPrim(localID); 649 SceneObjectPart part = this.GetChildPrim(localID);
599 if (part != null) 650 if (part != null)
600 { 651 {
601 if (part.UUID== this.m_rootPart.UUID) 652 if (part.UUID == this.m_rootPart.UUID)
602 { 653 {
603 this.UpdateRootPosition(pos); 654 this.UpdateRootPosition(pos);
604 } 655 }
@@ -805,14 +856,14 @@ namespace OpenSim.Region.Environment.Scenes
805 856
806 public override void UpdateMovement() 857 public override void UpdateMovement()
807 { 858 {
808 foreach( SceneObjectPart part in m_parts.Values ) 859 foreach (SceneObjectPart part in m_parts.Values)
809 { 860 {
810 part.UpdateMovement(); 861 part.UpdateMovement();
811 } 862 }
812 863
813 base.UpdateMovement(); 864 base.UpdateMovement();
814 } 865 }
815 866
816 /// <summary> 867 /// <summary>
817 /// Added as a way for the storage provider to reset the scene, 868 /// Added as a way for the storage provider to reset the scene,
818 /// most likely a better way to do this sort of thing but for now... 869 /// most likely a better way to do this sort of thing but for now...
@@ -857,8 +908,8 @@ namespace OpenSim.Region.Environment.Scenes
857 } 908 }
858 return null; 909 return null;
859 } 910 }
860 911
861 public void UpdateText( string text ) 912 public void UpdateText(string text)
862 { 913 {
863 m_rootPart.Text = text; 914 m_rootPart.Text = text;
864 m_rootPart.ScheduleTerseUpdate(); 915 m_rootPart.ScheduleTerseUpdate();
@@ -866,7 +917,7 @@ namespace OpenSim.Region.Environment.Scenes
866 917
867 public void ObjectGrabHandler(uint localId, LLVector3 offsetPos, IClientAPI remoteClient) 918 public void ObjectGrabHandler(uint localId, LLVector3 offsetPos, IClientAPI remoteClient)
868 { 919 {
869 if( m_rootPart.LocalID == localId ) 920 if (m_rootPart.LocalID == localId)
870 { 921 {
871 OnGrabGroup(offsetPos, remoteClient); 922 OnGrabGroup(offsetPos, remoteClient);
872 } 923 }
@@ -886,5 +937,18 @@ namespace OpenSim.Region.Environment.Scenes
886 { 937 {
887 938
888 } 939 }
940
941 public void DeleteGroup()
942 {
943 m_scene.EventManager.OnBackup -= this.ProcessBackup;
944 foreach (SceneObjectPart part in this.m_parts.Values)
945 {
946 List<ScenePresence> avatars = this.RequestSceneAvatars();
947 for (int i = 0; i < avatars.Count; i++)
948 {
949 avatars[i].ControllingClient.SendKillObject(this.m_regionHandle, part.LocalID);
950 }
951 }
952 }
889 } 953 }
890} 954}