From 54ef77f0fda5fabc6f4677e145fafb74d225a77e Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 1 Jul 2007 18:33:44 +0000 Subject: [PATCH] Can change the name and description of a prim. --- .../General/Interfaces/IClientAPI.cs | 3 ++ OpenSim/Region/ClientStack/ClientView.API.cs | 2 + .../ClientStack/ClientView.ProcessPackets.cs | 29 ++++++++++-- OpenSim/Region/ClientStack/ClientView.cs | 1 + OpenSim/Region/Environment/Scenes/Entity.cs | 2 +- .../Region/Environment/Scenes/EntityBase.cs | 1 + .../Region/Environment/Scenes/Primitive.cs | 13 ++++++ .../Scenes/Scene.PacketHandlers.cs | 45 ++++++++++++++++++- OpenSim/Region/Environment/Scenes/Scene.cs | 6 ++- .../Region/Environment/Scenes/SceneObject.cs | 20 +++++++-- 10 files changed, 112 insertions(+), 10 deletions(-) diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs index 9c112ae5ee..2110b74c98 100644 --- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs +++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs @@ -51,6 +51,7 @@ namespace OpenSim.Framework.Interfaces public delegate void GenericCall4(Packet packet, IClientAPI remoteClient); public delegate void GenericCall5(IClientAPI remoteClient, bool status); public delegate void GenericCall6(LLUUID uid); + public delegate void GenericCall7(uint localID, string message); public delegate void UpdateShape(uint localID, ObjectShapePacket.ObjectDataBlock shapeBlock); public delegate void ObjectSelect(uint localID, IClientAPI remoteClient); @@ -96,6 +97,8 @@ namespace OpenSim.Framework.Interfaces event UpdateShape OnUpdatePrimShape; event ObjectSelect OnObjectSelect; + event GenericCall7 OnObjectDescription; + event GenericCall7 OnObjectName; event UpdatePrimFlags OnUpdatePrimFlags; event UpdatePrimTexture OnUpdatePrimTexture; event UpdateVector OnUpdatePrimPosition; diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index 5056f4151a..7a9c6cf1c1 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -58,6 +58,8 @@ namespace OpenSim.Region.ClientStack public event GenericCall4 OnAddPrim; public event UpdateShape OnUpdatePrimShape; public event ObjectSelect OnObjectSelect; + public event GenericCall7 OnObjectDescription; + public event GenericCall7 OnObjectName; public event UpdatePrimFlags OnUpdatePrimFlags; public event UpdatePrimTexture OnUpdatePrimTexture; public event UpdateVector OnUpdatePrimPosition; diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index 0d90968f92..75d3f65a30 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs @@ -130,7 +130,7 @@ namespace OpenSim.Region.ClientStack { if (OnModifyTerrain != null) { - OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlock.BrushSize, + OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlock.BrushSize, modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West); } } @@ -167,8 +167,8 @@ namespace OpenSim.Region.ClientStack case PacketType.AgentUpdate: if (OnAgentUpdate != null) { - AgentUpdatePacket agenUpdate = (AgentUpdatePacket) Pack; - OnAgentUpdate(this, agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotation ); + AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack; + OnAgentUpdate(this, agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotation); } break; case PacketType.AgentAnimation: @@ -274,6 +274,29 @@ namespace OpenSim.Region.ClientStack OnDeGrapObject(deGrap.ObjectData.LocalID, this); } break; + case PacketType.ObjectDescription: + ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack; + for (int i = 0; i < objDes.ObjectData.Length; i++) + { + if (OnObjectDescription != null) + { + OnObjectDescription(objDes.ObjectData[i].LocalID, enc.GetString(objDes.ObjectData[i].Description)); + } + } + break; + case PacketType.ObjectName: + ObjectNamePacket objName = (ObjectNamePacket)Pack; + for (int i = 0; i < objName.ObjectData.Length; i++) + { + if (OnObjectName != null) + { + OnObjectName(objName.ObjectData[i].LocalID, enc.GetString(objName.ObjectData[i].Name)); + } + } + break; + case PacketType.ObjectPermissions: + //Console.WriteLine("permissions set " + Pack.ToString()); + break; #endregion #region Inventory/Asset/Other related packets diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 402a3ca0ba..a36eeb0528 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -79,6 +79,7 @@ namespace OpenSim.Region.ClientStack private int cachedtextureserial = 0; private RegionInfo m_regionData; protected AuthenticateSessionsBase m_authenticateSessionsHandler; + private System.Text.Encoding enc = System.Text.Encoding.ASCII; public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions ) { diff --git a/OpenSim/Region/Environment/Scenes/Entity.cs b/OpenSim/Region/Environment/Scenes/Entity.cs index 9603f7ff81..6db57a4a8b 100644 --- a/OpenSim/Region/Environment/Scenes/Entity.cs +++ b/OpenSim/Region/Environment/Scenes/Entity.cs @@ -34,7 +34,7 @@ using libsecondlife; namespace OpenSim.Region.Environment.Scenes { - public abstract class Entity :EntityBase //will be phased out + public abstract class Entity :EntityBase //this class (Entity) will be phased out { protected PhysicsActor _physActor; diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs index edd72c51c1..63f3f5da54 100644 --- a/OpenSim/Region/Environment/Scenes/EntityBase.cs +++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs @@ -21,6 +21,7 @@ namespace OpenSim.Region.Environment.Scenes public virtual string Name { get { return m_name; } + set { m_name = value; } } protected LLVector3 m_pos; diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs index 497196dd23..97e79746c6 100644 --- a/OpenSim/Region/Environment/Scenes/Primitive.cs +++ b/OpenSim/Region/Environment/Scenes/Primitive.cs @@ -21,6 +21,7 @@ namespace OpenSim.Region.Environment.Scenes private Dictionary inventoryItems; + private string description = ""; public LLUUID OwnerID; public Int32 CreationDate; public uint OwnerMask = FULL_MASK_PERMISSIONS; @@ -55,6 +56,18 @@ namespace OpenSim.Region.Environment.Scenes } + public string Description + { + get + { + return this.description; + } + set + { + this.description = value; + } + } + public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent , SceneObject rootObject) { m_regionHandle = regionHandle; diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index f3d461a513..f55c118ae9 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -214,7 +214,6 @@ namespace OpenSim.Region.Environment.Scenes /// public void SelectPrim(uint primLocalID, IClientAPI remoteClient) { - Console.WriteLine("prim selected :" + primLocalID); foreach (EntityBase ent in Entities.Values) { if (ent is SceneObject) @@ -228,6 +227,50 @@ namespace OpenSim.Region.Environment.Scenes } } + /// + /// + /// + /// + /// + public void PrimDescription(uint primLocalID, string description) + { + Primitive prim = null; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObject) + { + prim = ((SceneObject)ent).HasChildPrim(primLocalID); + if (prim != null) + { + prim.Description = description; + break; + } + } + } + } + + /// + /// + /// + /// + /// + public void PrimName(uint primLocalID, string name) + { + Primitive prim = null; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObject) + { + prim = ((SceneObject)ent).HasChildPrim(primLocalID); + if (prim != null) + { + prim.Name = name; + break; + } + } + } + } + public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) { if (this.Entities.ContainsKey(objectID)) diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 2ff3976d41..08adc84a53 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -56,7 +56,7 @@ namespace OpenSim.Region.Environment.Scenes { protected System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer(); protected Dictionary Avatars; - protected Dictionary Prims; + protected Dictionary Prims; private PhysicsScene phyScene; private float timeStep = 0.1f; private Random Rand = new Random(); @@ -124,7 +124,7 @@ namespace OpenSim.Region.Environment.Scenes OpenSim.Framework.Console.MainLog.Instance.Verbose("World.cs - creating new entitities instance"); Entities = new Dictionary(); Avatars = new Dictionary(); - Prims = new Dictionary(); + Prims = new Dictionary(); OpenSim.Framework.Console.MainLog.Instance.Verbose("World.cs - creating LandMap"); Terrain = new TerrainEngine(); @@ -463,6 +463,8 @@ namespace OpenSim.Region.Environment.Scenes client.OnObjectSelect += this.SelectPrim; // client.OnGrapUpdate += this.MoveObject; client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest; + client.OnObjectDescription += this.PrimDescription; + client.OnObjectName += this.PrimName; /* remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest); remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest); diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs index a2286387b4..00df44718a 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObject.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs @@ -39,7 +39,7 @@ namespace OpenSim.Region.Environment.Scenes { public class SceneObject : EntityBase { - + private System.Text.Encoding enc = System.Text.Encoding.ASCII; private Dictionary ChildPrimitives = new Dictionary(); //list of all primitive id's that are part of this group protected Primitive rootPrimitive; private Scene m_world; @@ -114,6 +114,19 @@ namespace OpenSim.Region.Environment.Scenes return null; } + public Primitive HasChildPrim(uint localID) + { + Primitive returnPrim = null; + foreach (Primitive prim in this.children) + { + if (prim.LocalId == localID) + { + returnPrim = prim; + break; + } + } + return returnPrim; + } /// /// @@ -141,6 +154,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void GetProperites(IClientAPI client) { + //needs changing ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; @@ -158,8 +172,8 @@ namespace OpenSim.Region.Environment.Scenes proper.ObjectData[0].TouchName = new byte[0]; proper.ObjectData[0].TextureID = new byte[0]; proper.ObjectData[0].SitName = new byte[0]; - proper.ObjectData[0].Name = new byte[0]; - proper.ObjectData[0].Description = new byte[0]; + proper.ObjectData[0].Name = enc.GetBytes(this.rootPrimitive.Name +"\0"); + proper.ObjectData[0].Description = enc.GetBytes(this.rootPrimitive.Description +"\0"); proper.ObjectData[0].OwnerMask = this.rootPrimitive.OwnerMask; proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.NextOwnerMask; proper.ObjectData[0].GroupMask = this.rootPrimitive.GroupMask;