mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 03:45:35 +08:00
* Cruft removal step #1. Cleaning Modules directory.
This commit is contained in:
@@ -43,61 +43,45 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
|
||||
//Land types set with flags in ParcelOverlay.
|
||||
//Only one of these can be used.
|
||||
public const byte LAND_TYPE_PUBLIC = (byte)0; //Equals 00000000
|
||||
public const byte LAND_TYPE_OWNED_BY_OTHER = (byte)1; //Equals 00000001
|
||||
public const byte LAND_TYPE_OWNED_BY_GROUP = (byte)2; //Equals 00000010
|
||||
public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte)3; //Equals 00000011
|
||||
public const byte LAND_TYPE_IS_FOR_SALE = (byte)4; //Equals 00000100
|
||||
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
|
||||
//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
|
||||
public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte)64; //Equals 01000000
|
||||
public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte)128; //Equals 10000000
|
||||
public const float BAN_LINE_SAFETY_HIEGHT = 100;
|
||||
public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte) 128; //Equals 10000000
|
||||
public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte) 64; //Equals 01000000
|
||||
|
||||
//RequestResults (I think these are right, they seem to work):
|
||||
public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land
|
||||
public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land
|
||||
public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land
|
||||
|
||||
//ParcelSelectObjects
|
||||
public const int LAND_SELECT_OBJECTS_OWNER = 2;
|
||||
public const int LAND_SELECT_OBJECTS_GROUP = 4;
|
||||
public const int LAND_SELECT_OBJECTS_OTHER = 8;
|
||||
public const int LAND_SELECT_OBJECTS_OWNER = 2;
|
||||
public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte) 5; //Equals 00000101
|
||||
public const byte LAND_TYPE_IS_FOR_SALE = (byte) 4; //Equals 00000100
|
||||
public const byte LAND_TYPE_OWNED_BY_GROUP = (byte) 2; //Equals 00000010
|
||||
public const byte LAND_TYPE_OWNED_BY_OTHER = (byte) 1; //Equals 00000001
|
||||
public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte) 3; //Equals 00000011
|
||||
public const byte LAND_TYPE_PUBLIC = (byte) 0; //Equals 00000000
|
||||
|
||||
//These are other constants. Yay!
|
||||
public const int START_LAND_LOCAL_ID = 1;
|
||||
|
||||
public const float BAN_LINE_SAFETY_HIEGHT = 100;
|
||||
|
||||
#endregion
|
||||
|
||||
private Scene m_scene;
|
||||
|
||||
private int[,] landIDList = new int[64,64];
|
||||
private Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>();
|
||||
private int lastLandLocalID = START_LAND_LOCAL_ID - 1;
|
||||
private int[,] landIDList = new int[64, 64];
|
||||
|
||||
private bool landPrimCountTainted = false;
|
||||
private int lastLandLocalID = START_LAND_LOCAL_ID - 1;
|
||||
|
||||
private bool m_allowedForcefulBans = true;
|
||||
public bool allowedForcefulBans
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_allowedForcefulBans;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_allowedForcefulBans = value;
|
||||
}
|
||||
}
|
||||
private Scene m_scene;
|
||||
|
||||
public LandChannel(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
landIDList.Initialize();
|
||||
}
|
||||
|
||||
#region Land Object From Storage Functions
|
||||
|
||||
public void IncomingLandObjectsFromStorage(List<LandData> data)
|
||||
@@ -133,10 +117,64 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
resetSimLandObjects();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Parcel Add/Remove/Get/Create
|
||||
|
||||
public void updateLandObject(int local_id, LandData newData)
|
||||
{
|
||||
if (landList.ContainsKey(local_id))
|
||||
{
|
||||
landList[local_id].landData = newData.Copy();
|
||||
m_scene.EventManager.TriggerLandObjectUpdated((uint) local_id, landList[local_id]);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the land object at the specified point
|
||||
/// </summary>
|
||||
/// <param name="x">Value between 0 - 256 on the x axis of the point</param>
|
||||
/// <param name="y">Value between 0 - 256 on the y axis of the point</param>
|
||||
/// <returns>Land object at the point supplied</returns>
|
||||
public ILandObject getLandObject(float x_float, float y_float)
|
||||
{
|
||||
int x;
|
||||
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 (OverflowException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (x >= 64 || y >= 64 || x < 0 || y < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return landList[landIDList[x, y]];
|
||||
}
|
||||
}
|
||||
|
||||
public ILandObject getLandObject(int x, int y)
|
||||
{
|
||||
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
|
||||
// they happen every time at border crossings
|
||||
throw new Exception("Error: Parcel not found at point " + x + ", " + y);
|
||||
}
|
||||
else
|
||||
{
|
||||
return landList[landIDList[x / 4, y / 4]];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a basic Parcel object without an owner (a zeroed key)
|
||||
/// </summary>
|
||||
@@ -154,7 +192,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
{
|
||||
lastLandLocalID++;
|
||||
new_land.landData.localID = lastLandLocalID;
|
||||
landList.Add(lastLandLocalID, (LandObject)new_land.Copy());
|
||||
landList.Add(lastLandLocalID, (LandObject) new_land.Copy());
|
||||
|
||||
|
||||
bool[,] landBitmap = new_land.getLandBitmap();
|
||||
@@ -197,15 +235,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
landList.Remove(local_id);
|
||||
}
|
||||
|
||||
public void updateLandObject(int local_id, LandData newData)
|
||||
{
|
||||
if (landList.ContainsKey(local_id))
|
||||
{
|
||||
landList[local_id].landData = newData.Copy();
|
||||
m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landList[local_id]);
|
||||
}
|
||||
}
|
||||
|
||||
private void performFinalLandJoin(ILandObject master, ILandObject slave)
|
||||
{
|
||||
int x, y;
|
||||
@@ -225,37 +254,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
updateLandObject(master.landData.localID, master.landData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the land object at the specified point
|
||||
/// </summary>
|
||||
/// <param name="x">Value between 0 - 256 on the x axis of the point</param>
|
||||
/// <param name="y">Value between 0 - 256 on the y axis of the point</param>
|
||||
/// <returns>Land object at the point supplied</returns>
|
||||
public ILandObject getLandObject(float x_float, float y_float)
|
||||
{
|
||||
int x;
|
||||
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 (OverflowException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (x >= 64 || y >= 64 || x < 0 || y < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return landList[landIDList[x, y]];
|
||||
}
|
||||
}
|
||||
|
||||
public ILandObject getLandObject(int parcelLocalID)
|
||||
{
|
||||
lock (landList)
|
||||
@@ -268,24 +266,102 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
return null;
|
||||
}
|
||||
|
||||
public ILandObject getLandObject(int x, int y)
|
||||
{
|
||||
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
|
||||
// they happen every time at border crossings
|
||||
throw new Exception("Error: Parcel not found at point " + x + ", " + y);
|
||||
}
|
||||
else
|
||||
{
|
||||
return landList[landIDList[x / 4, y / 4]];
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Parcel Modification
|
||||
|
||||
public void resetAllLandPrimCounts()
|
||||
{
|
||||
foreach (LandObject p in landList.Values)
|
||||
{
|
||||
p.resetLandPrimCounts();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPrimsTainted()
|
||||
{
|
||||
landPrimCountTainted = true;
|
||||
}
|
||||
|
||||
public bool isLandPrimCountTainted()
|
||||
{
|
||||
return landPrimCountTainted;
|
||||
}
|
||||
|
||||
public void addPrimToLandPrimCounts(SceneObjectGroup obj)
|
||||
{
|
||||
LLVector3 position = obj.AbsolutePosition;
|
||||
ILandObject landUnderPrim = getLandObject(position.X, position.Y);
|
||||
if (landUnderPrim != null)
|
||||
{
|
||||
landUnderPrim.addPrimToCount(obj);
|
||||
}
|
||||
}
|
||||
|
||||
public void removePrimFromLandPrimCounts(SceneObjectGroup obj)
|
||||
{
|
||||
foreach (LandObject p in landList.Values)
|
||||
{
|
||||
p.removePrimFromCount(obj);
|
||||
}
|
||||
}
|
||||
|
||||
public void finalizeLandPrimCountUpdate()
|
||||
{
|
||||
//Get Simwide prim count for owner
|
||||
Dictionary<LLUUID, List<LandObject>> landOwnersAndParcels = new Dictionary<LLUUID, List<LandObject>>();
|
||||
foreach (LandObject p in landList.Values)
|
||||
{
|
||||
if (!landOwnersAndParcels.ContainsKey(p.landData.ownerID))
|
||||
{
|
||||
List<LandObject> tempList = new List<LandObject>();
|
||||
tempList.Add(p);
|
||||
landOwnersAndParcels.Add(p.landData.ownerID, tempList);
|
||||
}
|
||||
else
|
||||
{
|
||||
landOwnersAndParcels[p.landData.ownerID].Add(p);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (LLUUID owner in landOwnersAndParcels.Keys)
|
||||
{
|
||||
int simArea = 0;
|
||||
int simPrims = 0;
|
||||
foreach (LandObject p in landOwnersAndParcels[owner])
|
||||
{
|
||||
simArea += p.landData.area;
|
||||
simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims +
|
||||
p.landData.selectedPrims;
|
||||
}
|
||||
|
||||
foreach (LandObject p in landOwnersAndParcels[owner])
|
||||
{
|
||||
p.landData.simwideArea = simArea;
|
||||
p.landData.simwidePrims = simPrims;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLandPrimCounts()
|
||||
{
|
||||
foreach (EntityBase obj in m_scene.Entities.Values)
|
||||
{
|
||||
if (obj is SceneObjectGroup)
|
||||
{
|
||||
m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void performParcelPrimCountUpdate()
|
||||
{
|
||||
resetAllLandPrimCounts();
|
||||
m_scene.EventManager.TriggerParcelPrimCountUpdate();
|
||||
finalizeLandPrimCountUpdate();
|
||||
landPrimCountTainted = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subdivides a piece of land
|
||||
/// </summary>
|
||||
@@ -435,97 +511,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
return true;
|
||||
}
|
||||
|
||||
public void resetAllLandPrimCounts()
|
||||
{
|
||||
foreach (LandObject p in landList.Values)
|
||||
{
|
||||
p.resetLandPrimCounts();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPrimsTainted()
|
||||
{
|
||||
landPrimCountTainted = true;
|
||||
}
|
||||
|
||||
public bool isLandPrimCountTainted()
|
||||
{
|
||||
return landPrimCountTainted;
|
||||
}
|
||||
|
||||
public void addPrimToLandPrimCounts(SceneObjectGroup obj)
|
||||
{
|
||||
LLVector3 position = obj.AbsolutePosition;
|
||||
ILandObject landUnderPrim = getLandObject(position.X, position.Y);
|
||||
if (landUnderPrim != null)
|
||||
{
|
||||
landUnderPrim.addPrimToCount(obj);
|
||||
}
|
||||
}
|
||||
|
||||
public void removePrimFromLandPrimCounts(SceneObjectGroup obj)
|
||||
{
|
||||
foreach (LandObject p in landList.Values)
|
||||
{
|
||||
p.removePrimFromCount(obj);
|
||||
}
|
||||
}
|
||||
|
||||
public void finalizeLandPrimCountUpdate()
|
||||
{
|
||||
//Get Simwide prim count for owner
|
||||
Dictionary<LLUUID, List<LandObject>> landOwnersAndParcels = new Dictionary<LLUUID, List<LandObject>>();
|
||||
foreach (LandObject p in landList.Values)
|
||||
{
|
||||
if (!landOwnersAndParcels.ContainsKey(p.landData.ownerID))
|
||||
{
|
||||
List<LandObject> tempList = new List<LandObject>();
|
||||
tempList.Add(p);
|
||||
landOwnersAndParcels.Add(p.landData.ownerID, tempList);
|
||||
}
|
||||
else
|
||||
{
|
||||
landOwnersAndParcels[p.landData.ownerID].Add(p);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (LLUUID owner in landOwnersAndParcels.Keys)
|
||||
{
|
||||
int simArea = 0;
|
||||
int simPrims = 0;
|
||||
foreach (LandObject p in landOwnersAndParcels[owner])
|
||||
{
|
||||
simArea += p.landData.area;
|
||||
simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims +
|
||||
p.landData.selectedPrims;
|
||||
}
|
||||
|
||||
foreach (LandObject p in landOwnersAndParcels[owner])
|
||||
{
|
||||
p.landData.simwideArea = simArea;
|
||||
p.landData.simwidePrims = simPrims;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLandPrimCounts()
|
||||
{
|
||||
foreach (EntityBase obj in m_scene.Entities.Values)
|
||||
{
|
||||
if (obj is SceneObjectGroup)
|
||||
{
|
||||
m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup)obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void performParcelPrimCountUpdate()
|
||||
{
|
||||
resetAllLandPrimCounts();
|
||||
m_scene.EventManager.TriggerParcelPrimCountUpdate();
|
||||
finalizeLandPrimCountUpdate();
|
||||
landPrimCountTainted = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Parcel Updating
|
||||
@@ -547,7 +532,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
{
|
||||
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
|
||||
ILandObject currentParcelBlock = null;
|
||||
|
||||
try
|
||||
@@ -623,10 +608,10 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
if (byteArrayCount >= LAND_BLOCKS_PER_PACKET)
|
||||
{
|
||||
byteArrayCount = 0;
|
||||
packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
|
||||
packet = (ParcelOverlayPacket) PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
|
||||
packet.ParcelData.Data = byteArray;
|
||||
packet.ParcelData.SequenceID = sequenceID;
|
||||
remote_client.OutPacket((Packet)packet, ThrottleOutPacketType.Task);
|
||||
remote_client.OutPacket((Packet) packet, ThrottleOutPacketType.Task);
|
||||
sequenceID++;
|
||||
byteArray = new byte[LAND_BLOCKS_PER_PACKET];
|
||||
}
|
||||
@@ -652,7 +637,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
{
|
||||
for (y = 0; y < inc_y; y++)
|
||||
{
|
||||
|
||||
ILandObject currentParcel = null;
|
||||
try
|
||||
{
|
||||
@@ -693,7 +677,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
if (landList.ContainsKey(packet.ParcelData.LocalID))
|
||||
{
|
||||
landList[packet.ParcelData.LocalID].updateLandProperties(packet, remote_client);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -719,6 +702,14 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
|
||||
#endregion
|
||||
|
||||
#region ILandChannel Members
|
||||
|
||||
public bool allowedForcefulBans
|
||||
{
|
||||
get { return m_allowedForcefulBans; }
|
||||
set { m_allowedForcefulBans = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the sim to the default land object (full sim piece of land owned by the default user)
|
||||
/// </summary>
|
||||
@@ -731,7 +722,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
|
||||
ILandObject fullSimParcel = new LandObject(LLUUID.Zero, false, m_scene);
|
||||
|
||||
fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
|
||||
fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize));
|
||||
fullSimParcel.landData.ownerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
|
||||
|
||||
addLandObject(fullSimParcel);
|
||||
@@ -816,18 +807,17 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
{
|
||||
if (presence.UUID == avatar.AgentId)
|
||||
{
|
||||
|
||||
List<ILandObject> checkLandParcels = parcelsNearPoint(presence.AbsolutePosition);
|
||||
foreach (ILandObject checkBan in checkLandParcels)
|
||||
{
|
||||
if (checkBan.isBannedFromLand(avatar.AgentId))
|
||||
{
|
||||
checkBan.sendLandProperties(-30000, false, (int)ParcelManager.ParcelResult.Single, avatar);
|
||||
checkBan.sendLandProperties(-30000, false, (int) ParcelManager.ParcelResult.Single, avatar);
|
||||
return; //Only send one
|
||||
}
|
||||
else if (checkBan.isRestrictedFromLand(avatar.AgentId))
|
||||
{
|
||||
checkBan.sendLandProperties(-40000, false, (int)ParcelManager.ParcelResult.Single, avatar);
|
||||
checkBan.sendLandProperties(-40000, false, (int) ParcelManager.ParcelResult.Single, avatar);
|
||||
return; //Only send one
|
||||
}
|
||||
}
|
||||
@@ -841,8 +831,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
ILandObject over = null;
|
||||
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))));
|
||||
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)
|
||||
{
|
||||
@@ -873,11 +863,12 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendLandUpdate(ScenePresence avatar)
|
||||
{
|
||||
sendLandUpdate(avatar, false);
|
||||
|
||||
}
|
||||
|
||||
public void handleSignificantClientMovement(IClientAPI remote_client)
|
||||
{
|
||||
ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId);
|
||||
@@ -949,6 +940,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// If the economy has been validated by the economy module,
|
||||
// and land has been validated as well, this method transfers
|
||||
// the land ownership
|
||||
@@ -961,7 +954,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
{
|
||||
if (landList.ContainsKey(e.parcelLocalID))
|
||||
{
|
||||
landList[e.parcelLocalID].updateLandSold(e.agentId, e.groupId, e.groupOwned, (uint)e.transactionID, e.parcelPrice, e.parcelArea);
|
||||
landList[e.parcelLocalID].updateLandSold(e.agentId, e.groupId, e.groupOwned, (uint) e.transactionID, e.parcelPrice, e.parcelArea);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -989,17 +982,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
LLUUID AuthorizedID = lob.landData.authBuyerID;
|
||||
int saleprice = lob.landData.salePrice;
|
||||
LLUUID pOwnerID = lob.landData.ownerID;
|
||||
|
||||
bool landforsale = ((lob.landData.landFlags & (uint)(Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects)) != 0);
|
||||
|
||||
bool landforsale = ((lob.landData.landFlags &
|
||||
(uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects)) != 0);
|
||||
if ((AuthorizedID == LLUUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice && landforsale)
|
||||
{
|
||||
lock (e)
|
||||
{
|
||||
e.parcelOwnerID = pOwnerID;
|
||||
e.landValidated = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
using Nini.Config;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Modules.World.Land;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
@@ -43,7 +42,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
{
|
||||
m_scene = scene;
|
||||
landChannel = new LandChannel(scene);
|
||||
|
||||
|
||||
m_scene.EventManager.OnParcelPrimCountAdd += landChannel.addPrimToLandPrimCounts;
|
||||
m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts;
|
||||
m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel);
|
||||
@@ -53,18 +52,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
|
||||
lock (m_scene)
|
||||
{
|
||||
m_scene.LandChannel = (ILandChannel)landChannel;
|
||||
m_scene.LandChannel = (ILandChannel) landChannel;
|
||||
}
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string Name
|
||||
@@ -77,10 +74,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,6 @@ using libsecondlife.Packets;
|
||||
using log4net;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Modules.World.Land;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
@@ -46,23 +45,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
#region Member Variables
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private bool[,] m_landBitmap = new bool[64,64];
|
||||
|
||||
protected LandData m_landData = new LandData();
|
||||
protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
|
||||
protected Scene m_scene;
|
||||
|
||||
private bool[,] m_landBitmap = new bool[64,64];
|
||||
protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
|
||||
|
||||
public bool[,] landBitmap
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_landBitmap;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_landBitmap = value;
|
||||
}
|
||||
get { return m_landBitmap; }
|
||||
set { m_landBitmap = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -71,25 +63,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
|
||||
public LandData landData
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_landData;
|
||||
}
|
||||
get { return m_landData; }
|
||||
|
||||
set
|
||||
{
|
||||
m_landData = value;
|
||||
}
|
||||
set { m_landData = value; }
|
||||
}
|
||||
|
||||
public LLUUID regionUUID
|
||||
public LLUUID regionUUID
|
||||
{
|
||||
get { return m_scene.RegionInfo.RegionID; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Constructors
|
||||
|
||||
public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene)
|
||||
@@ -115,7 +98,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
{
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -149,7 +132,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
{
|
||||
ParcelPropertiesPacket updatePacket = (ParcelPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ParcelProperties);
|
||||
// TODO: don't create new blocks if recycling an old packet
|
||||
|
||||
|
||||
updatePacket.ParcelData.AABBMax = landData.AABBMax;
|
||||
updatePacket.ParcelData.AABBMin = landData.AABBMin;
|
||||
updatePacket.ParcelData.Area = landData.area;
|
||||
@@ -171,7 +154,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
{
|
||||
updatePacket.ParcelData.MaxPrims =
|
||||
Convert.ToInt32(
|
||||
Math.Round((Convert.ToDecimal(landData.area)/Convert.ToDecimal(65536))*m_scene.objectCapacity*
|
||||
Math.Round((Convert.ToDecimal(landData.area) / Convert.ToDecimal(65536)) * m_scene.objectCapacity *
|
||||
Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor)));
|
||||
}
|
||||
else
|
||||
@@ -193,7 +176,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
updatePacket.ParcelData.PassHours = landData.passHours;
|
||||
updatePacket.ParcelData.PassPrice = landData.passPrice;
|
||||
updatePacket.ParcelData.PublicCount = 0; //unemplemented
|
||||
|
||||
|
||||
uint regionFlags = (uint) m_scene.RegionInfo.EstateSettings.regionFlags;
|
||||
updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint) Simulator.RegionFlags.DenyAnonymous) >
|
||||
0);
|
||||
@@ -255,12 +238,13 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
newData.snapshotID = packet.ParcelData.SnapshotID;
|
||||
newData.userLocation = packet.ParcelData.UserLocation;
|
||||
newData.userLookAt = packet.ParcelData.UserLookAt;
|
||||
|
||||
|
||||
m_scene.LandChannel.updateLandObject(landData.localID, newData);
|
||||
|
||||
sendLandUpdateToAvatarsOverMe();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLandSold(LLUUID avatarID, LLUUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area)
|
||||
{
|
||||
LandData newData = landData.Copy();
|
||||
@@ -272,7 +256,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
newData.claimPrice = claimprice;
|
||||
newData.salePrice = 0;
|
||||
newData.authBuyerID = LLUUID.Zero;
|
||||
newData.landFlags &= ~(uint)(Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects);
|
||||
newData.landFlags &= ~(uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects);
|
||||
m_scene.LandChannel.updateLandObject(landData.localID, newData);
|
||||
|
||||
sendLandUpdateToAvatarsOverMe();
|
||||
@@ -339,12 +323,13 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
try
|
||||
{
|
||||
over =
|
||||
m_scene.LandChannel.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))));
|
||||
m_scene.LandChannel.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));
|
||||
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)
|
||||
@@ -463,6 +448,25 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
|
||||
#region Update Functions
|
||||
|
||||
public void updateLandBitmapByteArray()
|
||||
{
|
||||
landData.landBitmapByteArray = convertLandBitmapToBytes();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update all settings in land such as area, bitmap byte array, etc
|
||||
/// </summary>
|
||||
public void forceUpdateLandInfo()
|
||||
{
|
||||
updateAABBAndAreaValues();
|
||||
updateLandBitmapByteArray();
|
||||
}
|
||||
|
||||
public void setLandBitmapFromByteArray()
|
||||
{
|
||||
landBitmap = convertBytesToLandBitmap();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the AABBMin and AABBMax values after area/shape modification of the land object
|
||||
/// </summary>
|
||||
@@ -495,8 +499,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
if (ty > 255)
|
||||
ty = 255;
|
||||
landData.AABBMin =
|
||||
new LLVector3((float)(min_x * 4), (float)(min_y * 4),
|
||||
(float)m_scene.Heightmap[tx, ty]);
|
||||
new LLVector3((float) (min_x * 4), (float) (min_y * 4),
|
||||
(float) m_scene.Heightmap[tx, ty]);
|
||||
|
||||
tx = max_x * 4;
|
||||
if (tx > 255)
|
||||
@@ -505,30 +509,11 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
if (ty > 255)
|
||||
ty = 255;
|
||||
landData.AABBMax =
|
||||
new LLVector3((float)(max_x * 4), (float)(max_y * 4),
|
||||
(float)m_scene.Heightmap[tx, ty]);
|
||||
new LLVector3((float) (max_x * 4), (float) (max_y * 4),
|
||||
(float) m_scene.Heightmap[tx, ty]);
|
||||
landData.area = tempArea;
|
||||
}
|
||||
|
||||
public void updateLandBitmapByteArray()
|
||||
{
|
||||
landData.landBitmapByteArray = convertLandBitmapToBytes();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update all settings in land such as area, bitmap byte array, etc
|
||||
/// </summary>
|
||||
public void forceUpdateLandInfo()
|
||||
{
|
||||
updateAABBAndAreaValues();
|
||||
updateLandBitmapByteArray();
|
||||
}
|
||||
|
||||
public void setLandBitmapFromByteArray()
|
||||
{
|
||||
landBitmap = convertBytesToLandBitmap();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Land Bitmap Functions
|
||||
@@ -561,64 +546,13 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
return landBitmap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the land bitmap to a packet friendly byte array
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private byte[] convertLandBitmapToBytes()
|
||||
{
|
||||
byte[] tempConvertArr = new byte[512];
|
||||
byte tempByte = 0;
|
||||
int x, y, i, byteNum = 0;
|
||||
i = 0;
|
||||
for (y = 0; y < 64; y++)
|
||||
{
|
||||
for (x = 0; x < 64; x++)
|
||||
{
|
||||
tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++%8));
|
||||
if (i%8 == 0)
|
||||
{
|
||||
tempConvertArr[byteNum] = tempByte;
|
||||
tempByte = (byte) 0;
|
||||
i = 0;
|
||||
byteNum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return tempConvertArr;
|
||||
}
|
||||
|
||||
private bool[,] convertBytesToLandBitmap()
|
||||
{
|
||||
bool[,] tempConvertMap = new bool[64,64];
|
||||
tempConvertMap.Initialize();
|
||||
byte tempByte = 0;
|
||||
int x = 0, y = 0, i = 0, bitNum = 0;
|
||||
for (i = 0; i < 512; i++)
|
||||
{
|
||||
tempByte = landData.landBitmapByteArray[i];
|
||||
for (bitNum = 0; bitNum < 8; bitNum++)
|
||||
{
|
||||
bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1);
|
||||
tempConvertMap[x, y] = bit;
|
||||
x++;
|
||||
if (x > 63)
|
||||
{
|
||||
x = 0;
|
||||
y++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return tempConvertMap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Full sim land object creation
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool[,] basicFullRegionLandBitmap()
|
||||
{
|
||||
return getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize);
|
||||
return getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -662,8 +596,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
{
|
||||
for (x = 0; x < 64; x++)
|
||||
{
|
||||
if (x >= start_x/4 && x < end_x/4
|
||||
&& y >= start_y/4 && y < end_y/4)
|
||||
if (x >= start_x / 4 && x < end_x / 4
|
||||
&& y >= start_y / 4 && y < end_y / 4)
|
||||
{
|
||||
land_bitmap[x, y] = set_value;
|
||||
}
|
||||
@@ -705,6 +639,57 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
return bitmap_base;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the land bitmap to a packet friendly byte array
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private byte[] convertLandBitmapToBytes()
|
||||
{
|
||||
byte[] tempConvertArr = new byte[512];
|
||||
byte tempByte = 0;
|
||||
int x, y, i, byteNum = 0;
|
||||
i = 0;
|
||||
for (y = 0; y < 64; y++)
|
||||
{
|
||||
for (x = 0; x < 64; x++)
|
||||
{
|
||||
tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++ % 8));
|
||||
if (i % 8 == 0)
|
||||
{
|
||||
tempConvertArr[byteNum] = tempByte;
|
||||
tempByte = (byte) 0;
|
||||
i = 0;
|
||||
byteNum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return tempConvertArr;
|
||||
}
|
||||
|
||||
private bool[,] convertBytesToLandBitmap()
|
||||
{
|
||||
bool[,] tempConvertMap = new bool[64,64];
|
||||
tempConvertMap.Initialize();
|
||||
byte tempByte = 0;
|
||||
int x = 0, y = 0, i = 0, bitNum = 0;
|
||||
for (i = 0; i < 512; i++)
|
||||
{
|
||||
tempByte = landData.landBitmapByteArray[i];
|
||||
for (bitNum = 0; bitNum < 8; bitNum++)
|
||||
{
|
||||
bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1);
|
||||
tempConvertMap[x, y] = bit;
|
||||
x++;
|
||||
if (x > 63)
|
||||
{
|
||||
x = 0;
|
||||
y++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return tempConvertMap;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Object Select and Object Owner Listing
|
||||
@@ -781,7 +766,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
public void sendLandObjectOwners(IClientAPI remote_client)
|
||||
{
|
||||
Dictionary<LLUUID, int> primCount = new Dictionary<LLUUID, int>();
|
||||
ParcelObjectOwnersReplyPacket pack
|
||||
ParcelObjectOwnersReplyPacket pack
|
||||
= (ParcelObjectOwnersReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
|
||||
// TODO: don't create new blocks if recycling an old packet
|
||||
|
||||
@@ -807,21 +792,21 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
m_log.Error("[LAND]: Unable to match a prim with it's owner.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int notifyCount = primCount.Count;
|
||||
|
||||
|
||||
if (notifyCount > 0)
|
||||
{
|
||||
if (notifyCount > 32)
|
||||
{
|
||||
m_log.InfoFormat(
|
||||
"[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}"
|
||||
+ " - a developer might want to investigate whether this is a hard limit", 32);
|
||||
|
||||
+ " - a developer might want to investigate whether this is a hard limit", 32);
|
||||
|
||||
notifyCount = 32;
|
||||
}
|
||||
|
||||
ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock
|
||||
|
||||
ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock
|
||||
= new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount];
|
||||
|
||||
int num = 0;
|
||||
@@ -834,16 +819,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
dataBlock[num].OwnerID = owner;
|
||||
|
||||
num++;
|
||||
|
||||
|
||||
if (num >= notifyCount)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pack.Data = dataBlock;
|
||||
}
|
||||
|
||||
|
||||
remote_client.OutPacket(pack, ThrottleOutPacketType.Task);
|
||||
}
|
||||
|
||||
@@ -937,7 +922,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -110,6 +110,7 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
|
||||
private static void CreateCompressedXmlFile(MemoryStream xmlStream, string fileName)
|
||||
{
|
||||
#region GZip Compressed Version
|
||||
|
||||
FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create);
|
||||
MemoryStream gzipMSStream = new MemoryStream();
|
||||
GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress);
|
||||
@@ -117,6 +118,7 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
|
||||
gzipMSStream.WriteTo(objectsFileCompressed);
|
||||
objectsFileCompressed.Flush();
|
||||
objectsFileCompressed.Close();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,15 +39,17 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
//private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private const double m_real_day = 24.0;
|
||||
private const int m_default_frame = 100;
|
||||
private int m_frame_mod;
|
||||
private const double m_real_day = 24.0;
|
||||
private double m_day_length;
|
||||
private int m_dilation;
|
||||
private int m_frame;
|
||||
private long m_start;
|
||||
private int m_frame_mod;
|
||||
|
||||
private Scene m_scene;
|
||||
private long m_start;
|
||||
|
||||
#region IRegionModule Members
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource config)
|
||||
{
|
||||
@@ -66,7 +68,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
m_frame_mod = m_default_frame;
|
||||
}
|
||||
|
||||
m_dilation = (int) (m_real_day/m_day_length);
|
||||
m_dilation = (int) (m_real_day / m_day_length);
|
||||
m_scene = scene;
|
||||
scene.EventManager.OnFrame += SunUpdate;
|
||||
scene.EventManager.OnNewClient += SunToClient;
|
||||
@@ -90,6 +92,8 @@ namespace OpenSim.Region.Environment.Modules
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void SunToClient(IClientAPI client)
|
||||
{
|
||||
client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f));
|
||||
@@ -121,15 +125,15 @@ namespace OpenSim.Region.Environment.Modules
|
||||
// ticks don't get out of hand
|
||||
private double HourOfTheDay()
|
||||
{
|
||||
long m_addticks = (DateTime.Now.Ticks - m_start)*m_dilation;
|
||||
long m_addticks = (DateTime.Now.Ticks - m_start) * m_dilation;
|
||||
DateTime dt = new DateTime(m_start + m_addticks);
|
||||
return (double) dt.Hour + ((double) dt.Minute/60.0);
|
||||
return (double) dt.Hour + ((double) dt.Minute / 60.0);
|
||||
}
|
||||
|
||||
private LLVector3 SunPos(double hour)
|
||||
{
|
||||
// now we have our radian position
|
||||
double rad = (hour/m_real_day)*2*Math.PI - (Math.PI/2.0);
|
||||
double rad = (hour / m_real_day) * 2 * Math.PI - (Math.PI / 2.0);
|
||||
double z = Math.Sin(rad);
|
||||
double x = Math.Cos(rad);
|
||||
return new LLVector3((float) x, 0f, (float) z);
|
||||
@@ -192,4 +196,4 @@ namespace OpenSim.Region.Environment.Modules
|
||||
// // OutPacket(viewertime);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,6 @@
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
|
||||
{
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
|
||||
{
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
|
||||
{
|
||||
|
||||
@@ -35,7 +35,6 @@ using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Modules.Framework;
|
||||
using OpenSim.Region.Environment.Modules.World.Terrain;
|
||||
using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders;
|
||||
using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes;
|
||||
using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes;
|
||||
@@ -79,9 +78,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
|
||||
private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects =
|
||||
new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>();
|
||||
|
||||
private Dictionary<Location, ITerrainChannel> m_channels;
|
||||
|
||||
private ITerrainChannel m_channel;
|
||||
private Dictionary<Location, ITerrainChannel> m_channels;
|
||||
private Dictionary<string, ITerrainEffect> m_plugineffects;
|
||||
private ITerrainChannel m_revert;
|
||||
private Scene m_scene;
|
||||
@@ -252,7 +250,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
|
||||
{
|
||||
m_plugineffects.Add(pluginType.Name, terEffect);
|
||||
m_log.Info("E ... " + pluginType.Name);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Warn("E ... " + pluginType.Name + " (Already added)");
|
||||
}
|
||||
|
||||
@@ -44,13 +44,14 @@ namespace OpenSim.Region.Environment.Modules
|
||||
/// </summary>
|
||||
public class TreePopulatorModule : IRegionModule
|
||||
{
|
||||
private Scene m_scene;
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private List<LLUUID> m_trees;
|
||||
private Scene m_scene;
|
||||
|
||||
public double m_tree_density = 50.0; // Aim for this many per region
|
||||
public double m_tree_updates = 1000.0; // MS between updates
|
||||
private List<LLUUID> m_trees;
|
||||
|
||||
#region IRegionModule Members
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource config)
|
||||
{
|
||||
@@ -59,7 +60,8 @@ namespace OpenSim.Region.Environment.Modules
|
||||
m_tree_density = config.Configs["Trees"].GetDouble("tree_density", m_tree_density);
|
||||
}
|
||||
catch (Exception)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
m_trees = new List<LLUUID>();
|
||||
m_scene = scene;
|
||||
@@ -72,7 +74,27 @@ namespace OpenSim.Region.Environment.Modules
|
||||
m_log.Debug("[TREES]: Initialised tree module");
|
||||
}
|
||||
|
||||
void EventManager_OnPluginConsole(string[] args)
|
||||
public void PostInitialise()
|
||||
{
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "TreePopulatorModule"; }
|
||||
}
|
||||
|
||||
public bool IsSharedModule
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void EventManager_OnPluginConsole(string[] args)
|
||||
{
|
||||
if (args[0] == "tree")
|
||||
{
|
||||
@@ -81,13 +103,13 @@ namespace OpenSim.Region.Environment.Modules
|
||||
}
|
||||
}
|
||||
|
||||
void growTrees()
|
||||
private void growTrees()
|
||||
{
|
||||
foreach (LLUUID tree in m_trees)
|
||||
{
|
||||
if (m_scene.Entities.ContainsKey(tree))
|
||||
{
|
||||
SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
|
||||
SceneObjectPart s_tree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart;
|
||||
|
||||
// 100 seconds to grow 1m
|
||||
s_tree.Scale += new LLVector3(0.1f, 0.1f, 0.1f);
|
||||
@@ -101,13 +123,13 @@ namespace OpenSim.Region.Environment.Modules
|
||||
}
|
||||
}
|
||||
|
||||
void seedTrees()
|
||||
private void seedTrees()
|
||||
{
|
||||
foreach (LLUUID tree in m_trees)
|
||||
{
|
||||
if (m_scene.Entities.ContainsKey(tree))
|
||||
{
|
||||
SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
|
||||
SceneObjectPart s_tree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart;
|
||||
|
||||
if (s_tree.Scale.X > 0.5)
|
||||
{
|
||||
@@ -116,7 +138,6 @@ namespace OpenSim.Region.Environment.Modules
|
||||
SpawnChild(s_tree);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -125,7 +146,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
}
|
||||
}
|
||||
|
||||
void killTrees()
|
||||
private void killTrees()
|
||||
{
|
||||
foreach (LLUUID tree in m_trees)
|
||||
{
|
||||
@@ -133,7 +154,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
|
||||
if (m_scene.Entities.ContainsKey(tree))
|
||||
{
|
||||
SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
|
||||
SceneObjectPart selectedTree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart;
|
||||
double selectedTreeScale = Math.Sqrt(Math.Pow(selectedTree.Scale.X, 2) +
|
||||
Math.Pow(selectedTree.Scale.Y, 2) +
|
||||
Math.Pow(selectedTree.Scale.Z, 2));
|
||||
@@ -142,7 +163,7 @@ namespace OpenSim.Region.Environment.Modules
|
||||
{
|
||||
if (picktree != tree)
|
||||
{
|
||||
SceneObjectPart pickedTree = ((SceneObjectGroup)m_scene.Entities[picktree]).RootPart;
|
||||
SceneObjectPart pickedTree = ((SceneObjectGroup) m_scene.Entities[picktree]).RootPart;
|
||||
|
||||
double pickedTreeScale = Math.Sqrt(Math.Pow(pickedTree.Scale.X, 2) +
|
||||
Math.Pow(pickedTree.Scale.Y, 2) +
|
||||
@@ -162,10 +183,10 @@ namespace OpenSim.Region.Environment.Modules
|
||||
m_trees.Remove(selectedTree.ParentGroup.UUID);
|
||||
|
||||
m_scene.ForEachClient(delegate(IClientAPI controller)
|
||||
{
|
||||
controller.SendKillObject(m_scene.RegionInfo.RegionHandle,
|
||||
selectedTree.LocalId);
|
||||
});
|
||||
{
|
||||
controller.SendKillObject(m_scene.RegionInfo.RegionHandle,
|
||||
selectedTree.LocalId);
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -199,15 +220,15 @@ namespace OpenSim.Region.Environment.Modules
|
||||
double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);
|
||||
double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);
|
||||
|
||||
position.X += (float)randX;
|
||||
position.Y += (float)randY;
|
||||
position.X += (float) randX;
|
||||
position.Y += (float) randY;
|
||||
|
||||
CreateTree(position);
|
||||
}
|
||||
|
||||
private void CreateTree(LLVector3 position)
|
||||
{
|
||||
position.Z = (float)m_scene.Heightmap[(int)position.X, (int)position.Y];
|
||||
position.Z = (float) m_scene.Heightmap[(int) position.X, (int) position.Y];
|
||||
|
||||
SceneObjectGroup tree =
|
||||
m_scene.AddTree(new LLVector3(0.1f, 0.1f, 0.1f),
|
||||
@@ -220,29 +241,11 @@ namespace OpenSim.Region.Environment.Modules
|
||||
tree.SendGroupFullUpdate();
|
||||
}
|
||||
|
||||
void CalculateTrees_Elapsed(object sender, ElapsedEventArgs e)
|
||||
private void CalculateTrees_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
growTrees();
|
||||
seedTrees();
|
||||
killTrees();
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "TreePopulatorModule"; }
|
||||
}
|
||||
|
||||
public bool IsSharedModule
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user