From e2ed1a4e1f2776e5b929207f1ca6e271a4d6f6e1 Mon Sep 17 00:00:00 2001 From: mingchen Date: Sun, 16 Dec 2007 19:53:27 +0000 Subject: *Adding and Removing Avatars from the Access/Ban List for a parcel now works, but the actual ban lines, etc are not done. --- OpenSim/Framework/IClientAPI.cs | 6 ++ OpenSim/Region/ClientStack/ClientView.cs | 36 ++++++-- OpenSim/Region/Environment/LandManagement/Land.cs | 101 ++++++++++++++++++++- .../Environment/LandManagement/LandManager.cs | 24 +++++ OpenSim/Region/Environment/Scenes/Scene.cs | 2 + .../Region/Examples/SimpleApp/MyNpcCharacter.cs | 2 + 6 files changed, 164 insertions(+), 7 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 62a97e5..7d9fd9a 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -301,6 +301,10 @@ namespace OpenSim.Framework public delegate void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 grapPos, IClientAPI remoteClient); + public delegate void ParcelAccessListRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, int landLocalID,IClientAPI remote_client); + + public delegate void ParcelAccessListUpdateRequest(LLUUID agentID, LLUUID sessionID,uint flags, int landLocalID, List entries, IClientAPI remote_client); + public delegate void ParcelPropertiesRequest( int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client); @@ -453,6 +457,8 @@ namespace OpenSim.Framework event UUIDNameRequest OnNameFromUUIDRequest; + event ParcelAccessListRequest OnParcelAccessListRequest; + event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest; event ParcelPropertiesRequest OnParcelPropertiesRequest; event ParcelDivideRequest OnParcelDivideRequest; event ParcelJoinRequest OnParcelJoinRequest; diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 065e5e0..41e44a5 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -516,6 +516,8 @@ namespace OpenSim.Region.ClientStack public event UUIDNameRequest OnNameFromUUIDRequest; + public event ParcelAccessListRequest OnParcelAccessListRequest; + public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest; public event ParcelPropertiesRequest OnParcelPropertiesRequest; public event ParcelDivideRequest OnParcelDivideRequest; public event ParcelJoinRequest OnParcelJoinRequest; @@ -3117,8 +3119,33 @@ namespace OpenSim.Region.ClientStack break; #region Parcel related packets + case PacketType.ParcelAccessListRequest: + ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack; + if (OnParcelAccessListRequest != null) + { + OnParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID, requestPacket.Data.Flags, requestPacket.Data.SequenceID, requestPacket.Data.LocalID,this); + } + break; + case PacketType.ParcelAccessListUpdate: + ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack; + List entries = new List(); + foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List) + { + ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + entry.AgentID = block.ID; + entry.Flags = (ParcelManager.AccessList)block.Flags; + entry.Time = new DateTime(); + entries.Add(entry); + } + + if (OnParcelAccessListUpdateRequest != null) + { + OnParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID, updatePacket.AgentData.SessionID, updatePacket.Data.Flags, updatePacket.Data.LocalID, entries, this); + } + break; case PacketType.ParcelPropertiesRequest: + ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket) Pack; if (OnParcelPropertiesRequest != null) { @@ -3151,10 +3178,10 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.ParcelPropertiesUpdate: - ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket) Pack; + ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket) Pack; if (OnParcelPropertiesUpdateRequest != null) { - OnParcelPropertiesUpdateRequest(updatePacket, this); + OnParcelPropertiesUpdateRequest(parcelPropertiesPacket, this); } break; case PacketType.ParcelSelectObjects: @@ -3283,10 +3310,7 @@ namespace OpenSim.Region.ClientStack // TODO: handle this packet MainLog.Instance.Warn("CLIENT", "unhandled AgentDataUpdateRequest packet"); break; - case PacketType.ParcelAccessListRequest: - // TODO: handle this packet - MainLog.Instance.Warn("CLIENT", "unhandled ParcelAccessListRequest packet"); - break; + case PacketType.ParcelDwellRequest: // TODO: handle this packet MainLog.Instance.Warn("CLIENT", "unhandled ParcelDwellRequest packet"); diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs index a738bc0..791b3ea 100644 --- a/OpenSim/Region/Environment/LandManagement/Land.cs +++ b/OpenSim/Region/Environment/LandManagement/Land.cs @@ -47,7 +47,7 @@ namespace OpenSim.Region.Environment.LandManagement public LandData landData = new LandData(); public List primsOverMe = new List(); - + public List parcelAccessList = new List(); public Scene m_scene; private bool[,] landBitmap = new bool[64,64]; @@ -242,6 +242,105 @@ namespace OpenSim.Region.Environment.LandManagement #endregion + #region AccessList Functions + + public ParcelAccessListReplyPacket.ListBlock[] createAccessListArrayByFlag(ParcelManager.AccessList flag) + { + List list = new List(); + foreach (ParcelManager.ParcelAccessEntry entry in parcelAccessList) + { + if (entry.Flags == flag) + { + ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); + + listBlock.Flags = (uint)0; + listBlock.ID = entry.AgentID; + listBlock.Time = 0; + + list.Add(listBlock); + } + } + + if (list.Count == 0) + { + ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); + + listBlock.Flags = (uint)0; + listBlock.ID = LLUUID.Zero; + listBlock.Time = 0; + + list.Add(listBlock); + } + return list.ToArray(); + } + + public void sendAccessList(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, IClientAPI remote_client) + { + + ParcelAccessListReplyPacket replyPacket; + + if (flags == (uint)ParcelManager.AccessList.Access || flags == (uint)ParcelManager.AccessList.Both) + { + replyPacket = new ParcelAccessListReplyPacket(); + replyPacket.Data.AgentID = agentID; + replyPacket.Data.Flags = (uint)ParcelManager.AccessList.Access; + replyPacket.Data.LocalID = this.landData.localID; + replyPacket.Data.SequenceID = 0; + + replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Access); + remote_client.OutPacket((Packet)replyPacket, ThrottleOutPacketType.Task); + } + + if (flags == (uint)ParcelManager.AccessList.Ban || flags == (uint)ParcelManager.AccessList.Both) + { + replyPacket = new ParcelAccessListReplyPacket(); + replyPacket.Data.AgentID = agentID; + replyPacket.Data.Flags = (uint)ParcelManager.AccessList.Ban; + replyPacket.Data.LocalID = this.landData.localID; + replyPacket.Data.SequenceID = 0; + + replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Ban); + remote_client.OutPacket((Packet)replyPacket, ThrottleOutPacketType.Task); + } + + } + + public void updateAccessList(uint flags, List entries, IClientAPI remote_client) + { + if (entries.Count == 1 && entries[0].AgentID == LLUUID.Zero) + { + entries.Clear(); + } + + List toRemove = new List(); + foreach (ParcelManager.ParcelAccessEntry entry in parcelAccessList) + { + if (entry.Flags == (ParcelManager.AccessList)flags) + { + toRemove.Add(entry); + } + } + + foreach (ParcelManager.ParcelAccessEntry entry in toRemove) + { + parcelAccessList.Remove(entry); + } + foreach (ParcelManager.ParcelAccessEntry entry in entries) + { + ParcelManager.ParcelAccessEntry temp = new ParcelManager.ParcelAccessEntry(); + temp.AgentID = entry.AgentID; + temp.Time = new DateTime() ; //Pointless? Yes. + temp.Flags = (ParcelManager.AccessList)flags; + + if (!this.parcelAccessList.Contains(temp)) + { + this.parcelAccessList.Add(temp); + } + } + } + + #endregion + #region Update Functions /// diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs index c0fa296..0fa2c23 100644 --- a/OpenSim/Region/Environment/LandManagement/LandManager.cs +++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs @@ -554,6 +554,30 @@ namespace OpenSim.Region.Environment.LandManagement } } + + public void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, int landLocalID, IClientAPI remote_client) + { + if (landList.ContainsKey(landLocalID)) + { + landList[landLocalID].sendAccessList(agentID, sessionID, flags, sequenceID,remote_client); + } + } + + public void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID,uint flags, int landLocalID, List entries, IClientAPI remote_client) + { + if (landList.ContainsKey(landLocalID)) + { + if (agentID == landList[landLocalID].landData.ownerID) + { + landList[landLocalID].updateAccessList(flags, entries, remote_client); + } + } + else + { + Console.WriteLine("INVALID LOCAL LAND ID"); + } + } + public void resetAllLandPrimCounts() { foreach (Land p in landList.Values) diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index aad977a..828cb75 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1093,6 +1093,8 @@ namespace OpenSim.Region.Environment.Scenes client.OnParcelSelectObjects += new ParcelSelectObjects(m_LandManager.handleParcelSelectObjectsRequest); client.OnParcelObjectOwnerRequest += new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest); + client.OnParcelAccessListRequest += new ParcelAccessListRequest(m_LandManager.handleParcelAccessRequest); + client.OnParcelAccessListUpdateRequest += new ParcelAccessListUpdateRequest(m_LandManager.handleParcelAccessUpdateRequest); client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); client.OnRequestGodlikePowers += handleRequestGodlikePowers; diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index 9b2cdda..505d0bb 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -131,6 +131,8 @@ namespace SimpleApp public event ParcelJoinRequest OnParcelJoinRequest; public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; + public event ParcelAccessListRequest OnParcelAccessListRequest; + public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest; public event ParcelSelectObjects OnParcelSelectObjects; public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; public event ObjectDeselect OnObjectDeselect; -- cgit v1.1