diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs index 4c6a0e0dc2..bd258a3b3a 100644 --- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs +++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs @@ -54,6 +54,7 @@ namespace OpenSim.Framework.Interfaces public delegate void UpdateShape(uint localID, ObjectShapePacket.ObjectDataBlock shapeBlock); public delegate void ObjectSelect(uint localID, IClientAPI remoteClient); + public delegate void ObjectDeselect(uint localID, IClientAPI remoteClient); public delegate void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient); public delegate void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient); public delegate void UpdateVector(uint localID, LLVector3 pos, IClientAPI remoteClient); @@ -71,7 +72,7 @@ namespace OpenSim.Framework.Interfaces public delegate void ParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client); public delegate void ParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client); public delegate void ParcelSelectObjects(int parcel_local_id, int request_type, IClientAPI remote_client); - + public delegate void ParcelObjectOwnerRequest(int local_id, IClientAPI remote_client); public delegate void EstateOwnerMessageRequest(EstateOwnerMessagePacket packet, IClientAPI remote_client); public delegate void UUIDNameRequest(LLUUID id, IClientAPI remote_client); @@ -106,6 +107,7 @@ namespace OpenSim.Framework.Interfaces event UpdateShape OnUpdatePrimShape; event ObjectSelect OnObjectSelect; + event ObjectDeselect OnObjectDeselect; event GenericCall7 OnObjectDescription; event GenericCall7 OnObjectName; event UpdatePrimFlags OnUpdatePrimFlags; @@ -128,7 +130,7 @@ namespace OpenSim.Framework.Interfaces event ParcelJoinRequest OnParcelJoinRequest; event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; event ParcelSelectObjects OnParcelSelectObjects; - + event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; event EstateOwnerMessageRequest OnEstateOwnerMessage; LLVector3 StartPos diff --git a/OpenSim/Framework/General/Types/ParcelData.cs b/OpenSim/Framework/General/Types/ParcelData.cs index 80b9b64573..17de655f19 100644 --- a/OpenSim/Framework/General/Types/ParcelData.cs +++ b/OpenSim/Framework/General/Types/ParcelData.cs @@ -49,6 +49,7 @@ namespace OpenSim.Framework.Types public int groupPrims = 0; public int otherPrims = 0; public int ownerPrims = 0; + public int selectedPrims = 0; public int simwidePrims = 0; public int simwideArea = 0; public int salePrice = 0; //Unemeplemented. Parcels price. @@ -90,6 +91,7 @@ namespace OpenSim.Framework.Types parcelData.groupPrims = this.groupPrims; parcelData.otherPrims = this.otherPrims; parcelData.ownerPrims = this.ownerPrims; + parcelData.selectedPrims = this.selectedPrims; parcelData.isGroupOwned = this.isGroupOwned; parcelData.localID = this.localID; parcelData.landingType = this.landingType; diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 6968c410ab..4815b8985c 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -240,7 +240,7 @@ namespace OpenSim LocalWorld.RegionInfo.MasterAvatarAssignedUUID = libsecondlife.LLUUID.Zero; LocalWorld.localStorage.LoadParcels((ILocalStorageParcelReceiver)LocalWorld.ParcelManager); } - + LocalWorld.performParcelPrimCountUpdate(); LocalWorld.StartTimer(); } } diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index cf0e294a2f..33e34c10f6 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -61,6 +61,7 @@ namespace OpenSim.Region.ClientStack public event AddNewPrim OnAddPrim; public event UpdateShape OnUpdatePrimShape; public event ObjectSelect OnObjectSelect; + public event ObjectDeselect OnObjectDeselect; public event GenericCall7 OnObjectDescription; public event GenericCall7 OnObjectName; public event UpdatePrimFlags OnUpdatePrimFlags; @@ -85,7 +86,7 @@ namespace OpenSim.Region.ClientStack public event ParcelJoinRequest OnParcelJoinRequest; public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; public event ParcelSelectObjects OnParcelSelectObjects; - + public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; public event EstateOwnerMessageRequest OnEstateOwnerMessage; /// diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index 37591d9040..a8512a7fe7 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs @@ -279,6 +279,16 @@ namespace OpenSim.Region.ClientStack } } break; + case PacketType.ObjectDeselect: + ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack; + for (int i = 0; i < incomingdeselect.ObjectData.Length; i++) + { + if (OnObjectDeselect != null) + { + OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this); + } + } + break; case PacketType.ObjectFlagUpdate: ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; if (OnUpdatePrimFlags != null) @@ -601,6 +611,14 @@ namespace OpenSim.Region.ClientStack OnParcelSelectObjects(selectPacket.ParcelData.LocalID, Convert.ToInt32(selectPacket.ParcelData.ReturnType), this); } break; + + case PacketType.ParcelObjectOwnersRequest: + ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack; + if (OnParcelObjectOwnerRequest != null) + { + OnParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this); + } + break; #endregion #region Estate Packets diff --git a/OpenSim/Region/Environment/ParcelManager.cs b/OpenSim/Region/Environment/ParcelManager.cs index 838a003d89..e4136506e9 100644 --- a/OpenSim/Region/Environment/ParcelManager.cs +++ b/OpenSim/Region/Environment/ParcelManager.cs @@ -33,6 +33,7 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Region.Environment.Scenes; using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence; +using System.IO; namespace OpenSim.Region.Environment { @@ -501,6 +502,11 @@ namespace OpenSim.Region.Environment { parcelList[local_id].sendForceObjectSelect(local_id, request_type, remote_client); } + + public void handleParcelObjectOwnersRequest(int local_id, IClientAPI remote_client) + { + parcelList[local_id].sendParcelObjectOwners(remote_client); + } #endregion /// @@ -591,7 +597,7 @@ namespace OpenSim.Region.Environment foreach (Parcel p in parcelOwnersAndParcels[owner]) { simArea += p.parcelData.area; - simPrims += p.parcelData.ownerPrims + p.parcelData.otherPrims + p.parcelData.groupPrims; + simPrims += p.parcelData.ownerPrims + p.parcelData.otherPrims + p.parcelData.groupPrims + p.parcelData.selectedPrims; } foreach (Parcel p in parcelOwnersAndParcels[owner]) @@ -713,7 +719,7 @@ namespace OpenSim.Region.Environment updatePacket.ParcelData.Name = Helpers.StringToField(parcelData.parcelName); updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented updatePacket.ParcelData.OtherCount = 0; //unemplemented - updatePacket.ParcelData.OtherPrims = parcelData.groupPrims; + updatePacket.ParcelData.OtherPrims = parcelData.otherPrims; updatePacket.ParcelData.OwnerID = parcelData.ownerID; updatePacket.ParcelData.OwnerPrims = parcelData.ownerPrims; updatePacket.ParcelData.ParcelFlags = parcelData.parcelFlags; @@ -728,7 +734,7 @@ namespace OpenSim.Region.Environment updatePacket.ParcelData.RentPrice = 0; updatePacket.ParcelData.RequestResult = request_result; updatePacket.ParcelData.SalePrice = parcelData.salePrice; - updatePacket.ParcelData.SelectedPrims = 0; //unemeplemented + updatePacket.ParcelData.SelectedPrims = parcelData.selectedPrims; updatePacket.ParcelData.SelfCount = 0;//unemplemented updatePacket.ParcelData.SequenceID = sequence_id; if (parcelData.simwideArea > 0) @@ -743,7 +749,7 @@ namespace OpenSim.Region.Environment updatePacket.ParcelData.SnapSelection = snap_selection; updatePacket.ParcelData.SnapshotID = parcelData.snapshotID; updatePacket.ParcelData.Status = (byte)parcelData.parcelStatus; - updatePacket.ParcelData.TotalPrims = parcelData.ownerPrims + parcelData.groupPrims + parcelData.otherPrims; + updatePacket.ParcelData.TotalPrims = parcelData.ownerPrims + parcelData.groupPrims + parcelData.otherPrims + parcelData.selectedPrims; updatePacket.ParcelData.UserLocation = parcelData.userLocation; updatePacket.ParcelData.UserLookAt = parcelData.userLookAt; remote_client.OutPacket((Packet)updatePacket); @@ -1042,7 +1048,7 @@ namespace OpenSim.Region.Environment bool firstCall = true; - int MAX_OBJECTS_PER_PACKET = 255; + int MAX_OBJECTS_PER_PACKET = 251; ForceObjectSelectPacket pack = new ForceObjectSelectPacket(); ForceObjectSelectPacket.DataBlock[] data; while (resultLocalIDs.Count > 0) @@ -1074,16 +1080,55 @@ namespace OpenSim.Region.Environment resultLocalIDs.RemoveAt(0); } pack.Data = data; - remote_client.OutPacket((Packet)pack); } } + public void sendParcelObjectOwners(IClientAPI remote_client) + { + Dictionary ownersAndCount = new Dictionary(); + foreach(SceneObject obj in primsOverMe) + { + if(!ownersAndCount.ContainsKey(obj.rootPrimitive.OwnerID)) + { + ownersAndCount.Add(obj.rootPrimitive.OwnerID,0); + } + ownersAndCount[obj.rootPrimitive.OwnerID] += obj.primCount; + } + if (ownersAndCount.Count > 0) + { + + ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[32]; + + if(ownersAndCount.Count < 32) + { + dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[ownersAndCount.Count]; + } + + + int num = 0; + foreach (LLUUID owner in ownersAndCount.Keys) + { + dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock(); + dataBlock[num].Count = ownersAndCount[owner]; + dataBlock[num].IsGroupOwned = false; //TODO: fix me when group support is added + dataBlock[num].OnlineStatus = true; //TODO: fix me later + dataBlock[num].OwnerID = owner; + + num++; + } + + ParcelObjectOwnersReplyPacket pack = new ParcelObjectOwnersReplyPacket(); + pack.Data = dataBlock; + remote_client.OutPacket(pack); + } + } public void resetParcelPrimCounts() { parcelData.groupPrims = 0; parcelData.ownerPrims = 0; - parcelData.groupPrims = 0; + parcelData.otherPrims = 0; + parcelData.selectedPrims = 0; primsOverMe.Clear(); } @@ -1092,14 +1137,22 @@ namespace OpenSim.Region.Environment LLUUID prim_owner = obj.rootPrimitive.OwnerID; int prim_count = obj.primCount; - if(prim_owner == parcelData.ownerID) + if (obj.isSelected) { - parcelData.ownerPrims += prim_count; + parcelData.selectedPrims += prim_count; } else { - parcelData.otherPrims += prim_count; + if (prim_owner == parcelData.ownerID) + { + parcelData.ownerPrims += prim_count; + } + else + { + parcelData.otherPrims += prim_count; + } } + primsOverMe.Add(obj); } diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 6431bc7954..347625a162 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -341,6 +341,29 @@ namespace OpenSim.Region.Environment.Scenes if (((SceneObject)ent).rootLocalID == primLocalID) { ((SceneObject)ent).GetProperites(remoteClient); + ((SceneObject)ent).isSelected = true; + this.ParcelManager.setPrimsTainted(); + break; + } + } + } + } + + /// + /// + /// + /// + /// + public void DeselectPrim(uint primLocalID, IClientAPI remoteClient) + { + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObject) + { + if (((SceneObject)ent).rootLocalID == primLocalID) + { + ((SceneObject)ent).isSelected = false; + this.ParcelManager.setPrimsTainted(); break; } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 5e2e49478d..ba57115a6c 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -537,6 +537,7 @@ namespace OpenSim.Region.Environment.Scenes client.OnUpdatePrimTexture += this.UpdatePrimTexture; client.OnTeleportLocationRequest += this.RequestTeleportLocation; client.OnObjectSelect += this.SelectPrim; + client.OnObjectDeselect += this.DeselectPrim; client.OnGrapUpdate += this.MoveObject; client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest; client.OnObjectDescription += this.PrimDescription; @@ -549,6 +550,8 @@ namespace OpenSim.Region.Environment.Scenes client.OnParcelJoinRequest += new ParcelJoinRequest(m_parcelManager.handleParcelJoinRequest); client.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(m_parcelManager.handleParcelPropertiesUpdateRequest); client.OnParcelSelectObjects += new ParcelSelectObjects(m_parcelManager.handleParcelSelectObjectsRequest); + client.OnParcelObjectOwnerRequest += new ParcelObjectOwnerRequest(m_parcelManager.handleParcelObjectOwnersRequest); + client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); } diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs index 8de7cdb322..e615599a56 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObject.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs @@ -49,6 +49,8 @@ namespace OpenSim.Region.Environment.Scenes private EventManager m_eventManager; + public bool isSelected = false; + public LLUUID rootUUID { get diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index 3e4bfeeb5b..d417851137 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs @@ -71,6 +71,7 @@ namespace SimpleApp world.LoadWorldMap(); world.PhysScene.SetTerrain(world.Terrain.getHeights1D()); + world.performParcelPrimCountUpdate(); udpServer.LocalWorld = world;