* Rex merge, environment/land
parent
db76041e4e
commit
f62f24bb70
|
@ -13,7 +13,7 @@
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
@ -31,6 +31,7 @@ using System.Collections.Generic;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using libsecondlife.Packets;
|
using libsecondlife.Packets;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Region.Environment.Scenes;
|
using OpenSim.Region.Environment.Scenes;
|
||||||
using OpenSim.Region.Environment.Interfaces;
|
using OpenSim.Region.Environment.Interfaces;
|
||||||
|
|
||||||
|
@ -46,6 +47,8 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
{
|
{
|
||||||
#region Member Variables
|
#region Member Variables
|
||||||
|
|
||||||
|
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
public LandData landData = new LandData();
|
public LandData landData = new LandData();
|
||||||
public List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
|
public List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
|
||||||
public Scene m_scene;
|
public Scene m_scene;
|
||||||
|
@ -77,7 +80,7 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
/// <returns>Returns true if the piece of land contains the specified point</returns>
|
/// <returns>Returns true if the piece of land contains the specified point</returns>
|
||||||
public bool containsPoint(int x, int y)
|
public bool containsPoint(int x, int y)
|
||||||
{
|
{
|
||||||
if (x >= 0 && y >= 0 && x <= 256 && x <= 256)
|
if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize)
|
||||||
{
|
{
|
||||||
return (landBitmap[x/4, y/4] == true);
|
return (landBitmap[x/4, y/4] == true);
|
||||||
}
|
}
|
||||||
|
@ -281,11 +284,20 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
public void sendLandUpdateToAvatarsOverMe()
|
public void sendLandUpdateToAvatarsOverMe()
|
||||||
{
|
{
|
||||||
List<ScenePresence> avatars = m_scene.GetAvatars();
|
List<ScenePresence> avatars = m_scene.GetAvatars();
|
||||||
|
Land over = null;
|
||||||
for (int i = 0; i < avatars.Count; i++)
|
for (int i = 0; i < avatars.Count; i++)
|
||||||
{
|
{
|
||||||
Land over =
|
try
|
||||||
m_scene.LandManager.getLandObject((int) Math.Round(avatars[i].AbsolutePosition.X),
|
{
|
||||||
(int) Math.Round(avatars[i].AbsolutePosition.Y));
|
over =
|
||||||
|
m_scene.LandManager.getLandObject((int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.X))),
|
||||||
|
(int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.Y))));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + Math.Round(avatars[i].AbsolutePosition.Y));
|
||||||
|
}
|
||||||
|
|
||||||
if (over != null)
|
if (over != null)
|
||||||
{
|
{
|
||||||
if (over.landData.localID == landData.localID)
|
if (over.landData.localID == landData.localID)
|
||||||
|
@ -544,7 +556,7 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool[,] basicFullRegionLandBitmap()
|
public static bool[,] basicFullRegionLandBitmap()
|
||||||
{
|
{
|
||||||
return getSquareLandBitmap(0, 0, 256, 256);
|
return getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Axiom.Math;
|
using Axiom.Math;
|
||||||
|
@ -38,7 +39,6 @@ using OpenSim.Region.Physics.Manager;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment.LandManagement
|
namespace OpenSim.Region.Environment.LandManagement
|
||||||
{
|
{
|
||||||
|
|
||||||
#region LandManager Class
|
#region LandManager Class
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -46,6 +46,8 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class LandManager
|
public class LandManager
|
||||||
{
|
{
|
||||||
|
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
#region Constants
|
#region Constants
|
||||||
|
|
||||||
//Land types set with flags in ParcelOverlay.
|
//Land types set with flags in ParcelOverlay.
|
||||||
|
@ -57,7 +59,6 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
public const byte LAND_TYPE_IS_FOR_SALE = (byte) 4; //Equals 00000100
|
public const byte LAND_TYPE_IS_FOR_SALE = (byte) 4; //Equals 00000100
|
||||||
public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte) 5; //Equals 00000101
|
public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte) 5; //Equals 00000101
|
||||||
|
|
||||||
|
|
||||||
//Flags that when set, a border on the given side will be placed
|
//Flags that when set, a border on the given side will be placed
|
||||||
//NOTE: North and East is assumable by the west and south sides (if land to east has a west border, then I have an east border; etc)
|
//NOTE: North and East is assumable by the west and south sides (if land to east has a west border, then I have an east border; etc)
|
||||||
//This took forever to figure out -- jeesh. /blame LL for even having to send these
|
//This took forever to figure out -- jeesh. /blame LL for even having to send these
|
||||||
|
@ -73,7 +74,6 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
public const int LAND_SELECT_OBJECTS_GROUP = 4;
|
public const int LAND_SELECT_OBJECTS_GROUP = 4;
|
||||||
public const int LAND_SELECT_OBJECTS_OTHER = 8;
|
public const int LAND_SELECT_OBJECTS_OTHER = 8;
|
||||||
|
|
||||||
|
|
||||||
//These are other constants. Yay!
|
//These are other constants. Yay!
|
||||||
public const int START_LAND_LOCAL_ID = 1;
|
public const int START_LAND_LOCAL_ID = 1;
|
||||||
|
|
||||||
|
@ -119,10 +119,22 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
|
|
||||||
public void IncomingLandObjectsFromStorage(List<LandData> data)
|
public void IncomingLandObjectsFromStorage(List<LandData> data)
|
||||||
{
|
{
|
||||||
foreach (LandData parcel in data)
|
for (int i = 0; i < data.Count; i++)
|
||||||
{
|
{
|
||||||
IncomingLandObjectFromStorage(parcel);
|
//try
|
||||||
|
//{
|
||||||
|
IncomingLandObjectFromStorage(data[i]);
|
||||||
|
//}
|
||||||
|
//catch (Exception ex)
|
||||||
|
//{
|
||||||
|
//m_log.Error("[LandManager]: IncomingLandObjectsFromStorage: Exception: " + ex.ToString());
|
||||||
|
//throw ex;
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
//foreach (LandData parcel in data)
|
||||||
|
//{
|
||||||
|
// IncomingLandObjectFromStorage(parcel);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IncomingLandObjectFromStorage(LandData data)
|
public void IncomingLandObjectFromStorage(LandData data)
|
||||||
|
@ -243,8 +255,18 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
/// <returns>Land object at the point supplied</returns>
|
/// <returns>Land object at the point supplied</returns>
|
||||||
public Land getLandObject(float x_float, float y_float)
|
public Land getLandObject(float x_float, float y_float)
|
||||||
{
|
{
|
||||||
int x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float)/Convert.ToDouble(4.0)));
|
int x;
|
||||||
int y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float)/Convert.ToDouble(4.0)));
|
int y;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / Convert.ToDouble(4.0)));
|
||||||
|
y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / Convert.ToDouble(4.0)));
|
||||||
|
}
|
||||||
|
catch (System.OverflowException)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (x >= 64 || y >= 64 || x < 0 || y < 0)
|
if (x >= 64 || y >= 64 || x < 0 || y < 0)
|
||||||
{
|
{
|
||||||
|
@ -259,7 +281,7 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
|
|
||||||
public Land getLandObject(int x, int y)
|
public Land getLandObject(int x, int y)
|
||||||
{
|
{
|
||||||
if (x >= 256 || y >= 256 || x < 0 || y < 0)
|
if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0)
|
||||||
{
|
{
|
||||||
// These exceptions here will cause a lot of complaints from the users specifically because
|
// These exceptions here will cause a lot of complaints from the users specifically because
|
||||||
// they happen every time at border crossings
|
// they happen every time at border crossings
|
||||||
|
@ -288,7 +310,15 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
{
|
{
|
||||||
//First, lets loop through the points and make sure they are all in the same peice of land
|
//First, lets loop through the points and make sure they are all in the same peice of land
|
||||||
//Get the land object at start
|
//Get the land object at start
|
||||||
Land startLandObject = getLandObject(start_x, start_y);
|
Land startLandObject = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
startLandObject = getLandObject(start_x, start_y);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
m_log.Error("[LAND]: " + "Unable to get land object for subdivision at x: " + start_x + " y:" + start_y);
|
||||||
|
}
|
||||||
if (startLandObject == null) return false; //No such land object at the beginning
|
if (startLandObject == null) return false; //No such land object at the beginning
|
||||||
|
|
||||||
//Loop through the points
|
//Loop through the points
|
||||||
|
@ -364,7 +394,15 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
{
|
{
|
||||||
for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4)
|
for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4)
|
||||||
{
|
{
|
||||||
Land p = getLandObject(stepXSelected, stepYSelected);
|
Land p = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
p = getLandObject(stepXSelected, stepYSelected);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
m_log.Error("[LAND]: " + "Unable to get land object for subdivision at x: " + stepXSelected + " y:" + stepYSelected);
|
||||||
|
}
|
||||||
if (p != null)
|
if (p != null)
|
||||||
{
|
{
|
||||||
if (!selectedLandObjects.Contains(p))
|
if (!selectedLandObjects.Contains(p))
|
||||||
|
@ -430,7 +468,18 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
for (x = 0; x < 64; x++)
|
for (x = 0; x < 64; x++)
|
||||||
{
|
{
|
||||||
byte tempByte = (byte) 0; //This represents the byte for the current 4x4
|
byte tempByte = (byte) 0; //This represents the byte for the current 4x4
|
||||||
Land currentParcelBlock = getLandObject(x*4, y*4);
|
Land currentParcelBlock = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
currentParcelBlock = getLandObject(x * 4, y * 4);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
m_log.Warn("[LAND]: " + "unable to get land at x: " + (x * 4) + " y: " + (y * 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (currentParcelBlock != null)
|
if (currentParcelBlock != null)
|
||||||
{
|
{
|
||||||
if (currentParcelBlock.landData.ownerID == remote_client.AgentId)
|
if (currentParcelBlock.landData.ownerID == remote_client.AgentId)
|
||||||
|
@ -504,8 +553,7 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
MainLog.Instance.Debug("LAND",
|
m_log.Debug("[LAND]: Skipped Land checks because avatar is out of bounds: " + e.Message);
|
||||||
"Skipped Land checks because avatar is out of bounds: " + e.Message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -524,7 +572,16 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
{
|
{
|
||||||
for (y = 0; y < inc_y; y++)
|
for (y = 0; y < inc_y; y++)
|
||||||
{
|
{
|
||||||
Land currentParcel = getLandObject(start_x + x, start_y + y);
|
|
||||||
|
Land currentParcel = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
currentParcel = getLandObject(start_x + x, start_y + y);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
m_log.Warn("[LAND]: " + "unable to get land at x: " + (start_x + x) + " y: " + (start_y + y));
|
||||||
|
}
|
||||||
if (currentParcel != null)
|
if (currentParcel != null)
|
||||||
{
|
{
|
||||||
if (!temp.Contains(currentParcel))
|
if (!temp.Contains(currentParcel))
|
||||||
|
@ -593,7 +650,7 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
|
|
||||||
Land fullSimParcel = new Land(LLUUID.Zero, false, m_scene);
|
Land fullSimParcel = new Land(LLUUID.Zero, false, m_scene);
|
||||||
|
|
||||||
fullSimParcel.setLandBitmap(Land.getSquareLandBitmap(0, 0, 256, 256));
|
fullSimParcel.setLandBitmap(Land.getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
|
||||||
fullSimParcel.landData.ownerID = m_regInfo.MasterAvatarAssignedUUID;
|
fullSimParcel.landData.ownerID = m_regInfo.MasterAvatarAssignedUUID;
|
||||||
|
|
||||||
addLandObject(fullSimParcel);
|
addLandObject(fullSimParcel);
|
||||||
|
@ -678,6 +735,7 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
{
|
{
|
||||||
if (presence.UUID == avatar.AgentId)
|
if (presence.UUID == avatar.AgentId)
|
||||||
{
|
{
|
||||||
|
|
||||||
List<Land> checkLandParcels = parcelsNearPoint(presence.AbsolutePosition);
|
List<Land> checkLandParcels = parcelsNearPoint(presence.AbsolutePosition);
|
||||||
foreach (Land checkBan in checkLandParcels)
|
foreach (Land checkBan in checkLandParcels)
|
||||||
{
|
{
|
||||||
|
@ -697,23 +755,46 @@ namespace OpenSim.Region.Environment.LandManagement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendLandUpdate(ScenePresence avatar)
|
public void sendLandUpdate(ScenePresence avatar, bool force)
|
||||||
{
|
{
|
||||||
Land over = getLandObject((int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
|
Land over = null;
|
||||||
(int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
|
try
|
||||||
|
{
|
||||||
|
over = getLandObject((int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
|
||||||
|
(int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatar.AbsolutePosition.X) + " y: " + Math.Round(avatar.AbsolutePosition.Y));
|
||||||
|
}
|
||||||
|
|
||||||
if (over != null)
|
if (over != null)
|
||||||
{
|
{
|
||||||
over.sendLandUpdateToClient(avatar.ControllingClient);
|
if (force)
|
||||||
|
{
|
||||||
|
if (!avatar.IsChildAgent)
|
||||||
|
{
|
||||||
|
over.sendLandUpdateToClient(avatar.ControllingClient);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (avatar.currentParcelUUID != over.landData.globalID)
|
if (avatar.currentParcelUUID != over.landData.globalID)
|
||||||
{
|
{
|
||||||
avatar.currentParcelUUID = over.landData.globalID;
|
if (!avatar.IsChildAgent)
|
||||||
m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID,
|
{
|
||||||
m_scene.RegionInfo.RegionID);
|
over.sendLandUpdateToClient(avatar.ControllingClient);
|
||||||
|
avatar.currentParcelUUID = over.landData.globalID;
|
||||||
|
m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID,
|
||||||
|
m_scene.RegionInfo.RegionID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void sendLandUpdate(ScenePresence avatar)
|
||||||
|
{
|
||||||
|
sendLandUpdate(avatar, false);
|
||||||
|
|
||||||
|
}
|
||||||
public void handleSignificantClientMovement(IClientAPI remote_client)
|
public void handleSignificantClientMovement(IClientAPI remote_client)
|
||||||
{
|
{
|
||||||
ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId);
|
ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId);
|
||||||
|
|
Loading…
Reference in New Issue