From 862dc9fe975bdaa71116c8449ac27289f860441e Mon Sep 17 00:00:00 2001 From: mingchen Date: Fri, 13 Jul 2007 21:13:38 +0000 Subject: *Reworked parcel joining to work the same way as LL's method. **Parcels within selection now join and not the two parcels selected at each corner *Created OnSignificantClientMovement event that is triggered when an avatar moves more than 2 meters. --- OpenSim/Framework/General/Interfaces/IClientAPI.cs | 6 +++ OpenSim/Region/ClientStack/ClientView.API.cs | 9 ++++ OpenSim/Region/Environment/ParcelManager.cs | 54 +++++++++++++--------- OpenSim/Region/Environment/Scenes/Scene.cs | 2 + OpenSim/Region/Environment/Scenes/ScenePresence.cs | 3 +- 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs index 9ac7994..555f46e 100644 --- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs +++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs @@ -77,6 +77,8 @@ namespace OpenSim.Framework.Interfaces public delegate void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape); + public delegate void SignificantClientMovement(IClientAPI remote_client); + public interface IClientAPI { event ImprovedInstantMessage OnInstantMessage; @@ -126,6 +128,8 @@ namespace OpenSim.Framework.Interfaces event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; event EstateOwnerMessageRequest OnEstateOwnerMessage; + event SignificantClientMovement OnSignificantClientMovement; + LLVector3 StartPos { get; @@ -182,5 +186,7 @@ namespace OpenSim.Framework.Interfaces void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items); void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item); void SendNameReply(LLUUID profileId, string firstname, string lastname); + + void TriggerSignificantClientMovement(IClientAPI remote_client); } } diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index cc4fdbe..df5a853 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -87,6 +87,7 @@ namespace OpenSim.Region.ClientStack public event EstateOwnerMessageRequest OnEstateOwnerMessage; + public event SignificantClientMovement OnSignificantClientMovement; /// /// @@ -1177,5 +1178,13 @@ namespace OpenSim.Region.ClientStack OutPacket( packet ); } + + public void TriggerSignificantClientMovement(IClientAPI remote_client) + { + if (OnSignificantClientMovement != null) + { + OnSignificantClientMovement(remote_client); + } + } } } diff --git a/OpenSim/Region/Environment/ParcelManager.cs b/OpenSim/Region/Environment/ParcelManager.cs index ef6603d..125ba19 100644 --- a/OpenSim/Region/Environment/ParcelManager.cs +++ b/OpenSim/Region/Environment/ParcelManager.cs @@ -183,7 +183,6 @@ namespace OpenSim.Region.Environment } } removeParcel(slave.parcelData.localID); - master.sendParcelUpdateToAvatarsOverMe(); } /// /// Get the parcel at the specified point @@ -217,6 +216,7 @@ namespace OpenSim.Region.Environment /// Returns true if successful private bool subdivide(int start_x, int start_y, int end_x, int end_y, LLUUID attempting_user_id) { + //First, lets loop through the points and make sure they are all in the same parcel //Get the parcel at start Parcel startParcel = getParcel(start_x, start_y); @@ -286,39 +286,47 @@ namespace OpenSim.Region.Environment end_x -= 4; end_y -= 4; - //NOTE: The following only connects the parcels in each corner and not all the parcels that are within the selection box! - //This should be fixed later -- somewhat "incomplete code" --Ming - Parcel startParcel, endParcel; - - try + List selectedParcels = new List(); + int stepXSelected = 0; + int stepYSelected = 0; + for (stepYSelected = start_y; stepYSelected <= end_y; stepYSelected += 4) { - startParcel = getParcel(start_x, start_y); - endParcel = getParcel(end_x, end_y); + for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4) + { + Parcel p = getParcel(stepXSelected,stepYSelected); + if (!selectedParcels.Contains(p)) + { + selectedParcels.Add(p); + } + } } - catch (Exception) + Parcel masterParcel = selectedParcels[0]; + selectedParcels.RemoveAt(0); + + + if (selectedParcels.Count < 1) { - return false; //Error occured when trying to get the start and end parcels + return false; //Only one parcel selected } - if (startParcel == endParcel) + if (masterParcel.parcelData.ownerID != attempting_user_id) { - return false; //Subdivision of the same parcel is not allowed + return false; //Not the same owner } - - //Check the parcel owners: - if (startParcel.parcelData.ownerID != endParcel.parcelData.ownerID) + foreach (Parcel p in selectedParcels) { - return false; + if (p.parcelData.ownerID != masterParcel.parcelData.ownerID) + { + return false; //Over multiple users. TODO: make this just ignore this parcel? + } } - if (startParcel.parcelData.ownerID != attempting_user_id) + foreach (Parcel slaveParcel in selectedParcels) { - //TODO: Group editing stuff. Avatar owner support for now - return false; + parcelList[masterParcel.parcelData.localID].setParcelBitmap(Parcel.mergeParcelBitmaps(masterParcel.getParcelBitmap(), slaveParcel.getParcelBitmap())); + performFinalParcelJoin(masterParcel, slaveParcel); } - //Same owners! Lets join them - //Merge them to startParcel - parcelList[startParcel.parcelData.localID].setParcelBitmap(Parcel.mergeParcelBitmaps(startParcel.getParcelBitmap(), endParcel.getParcelBitmap())); - performFinalParcelJoin(startParcel, endParcel); + + masterParcel.sendParcelUpdateToAvatarsOverMe(); return true; diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index a1b060f..7098c38 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -484,6 +484,8 @@ namespace OpenSim.Region.Environment.Scenes client.OnParcelJoinRequest += new ParcelJoinRequest(parcelManager.handleParcelJoinRequest); client.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(parcelManager.handleParcelPropertiesUpdateRequest); client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(estateManager.handleEstateOwnerMessage); + + client.OnSignificantClientMovement += new SignificantClientMovement(parcelManager.handleSignificantClientMovement); } protected void CreateAndAddScenePresence(IClientAPI client) diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index a813aed..613ad52 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -479,8 +479,7 @@ namespace OpenSim.Region.Environment.Scenes if (libsecondlife.Helpers.VecDist(this.Pos, this.posLastSignificantMove) > 2.0) { this.posLastSignificantMove = this.Pos; - this.m_world.parcelManager.handleSignificantClientMovement(this.ControllingClient); - + this.ControllingClient.TriggerSignificantClientMovement(this.ControllingClient); } } #endregion -- cgit v1.1