From a425e921680171c3eb3ae0c85c576030e2a8f834 Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Sat, 4 Aug 2007 00:45:55 +0000
Subject: * Little more cleaning of EstateManager - still needs packets to be
moved, but general functionality has been abstracted.
---
OpenSim/Region/Environment/EstateManager.cs | 146 ++++++++++++++++++++--------
1 file changed, 103 insertions(+), 43 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs
index b8bc949..67cfba6 100644
--- a/OpenSim/Region/Environment/EstateManager.cs
+++ b/OpenSim/Region/Environment/EstateManager.cs
@@ -64,6 +64,88 @@ namespace OpenSim.Region.Environment
return false;
}
+ ///
+ /// Sets terrain texture heights for each of the four corners of the region - textures are distributed as a linear range between the two heights.
+ ///
+ /// Which corner
+ /// Minimum height that texture range should cover
+ /// Maximum height that texture range should cover
+ public void setEstateTextureRange(UInt16 corner, float lowValue, float highValue)
+ {
+
+ switch (corner)
+ {
+ case 0:
+ m_regInfo.estateSettings.terrainStartHeight0 = lowValue;
+ m_regInfo.estateSettings.terrainHeightRange0 = highValue;
+ break;
+ case 1:
+ m_regInfo.estateSettings.terrainStartHeight1 = lowValue;
+ m_regInfo.estateSettings.terrainHeightRange1 = highValue;
+ break;
+ case 2:
+ m_regInfo.estateSettings.terrainStartHeight2 = lowValue;
+ m_regInfo.estateSettings.terrainHeightRange2 = highValue;
+ break;
+ case 3:
+ m_regInfo.estateSettings.terrainStartHeight3 = lowValue;
+ m_regInfo.estateSettings.terrainHeightRange3 = highValue;
+ break;
+ }
+ }
+
+ ///
+ /// Sets the 'detail' terrain texture on each of the bands.
+ ///
+ /// Which texture band
+ /// The UUID of the texture
+ public void setTerrainTexture(UInt16 band, LLUUID textureUUID)
+ {
+ switch (band)
+ {
+ case 0:
+ m_regInfo.estateSettings.terrainDetail0 = textureUUID;
+ break;
+ case 1:
+ m_regInfo.estateSettings.terrainDetail1 = textureUUID;
+ break;
+ case 2:
+ m_regInfo.estateSettings.terrainDetail2 = textureUUID;
+ break;
+ case 3:
+ m_regInfo.estateSettings.terrainDetail3 = textureUUID;
+ break;
+ }
+ }
+
+ ///
+ /// Sets common region settings
+ ///
+ /// Water height of the waterplane (may not nessecarily be one value)
+ /// Maximum amount terrain can be raised from previous baking
+ /// Minimum amount terrain can be lowered from previous baking
+ /// Use a fixed time of day on the sun?
+ /// The offset hour of the day
+ public void setRegionSettings(float WaterHeight, float TerrainRaiseLimit, float TerrainLowerLimit, bool UseFixedSun, float SunHour)
+ {
+ // Water Height
+ m_regInfo.estateSettings.waterHeight = WaterHeight;
+ m_scene.Terrain.watermap.Fill(WaterHeight);
+
+ // Terraforming limits
+ m_regInfo.estateSettings.terrainRaiseLimit = TerrainRaiseLimit;
+ m_regInfo.estateSettings.terrainLowerLimit = TerrainLowerLimit;
+ m_scene.Terrain.maxRaise = TerrainRaiseLimit;
+ m_scene.Terrain.minLower = TerrainLowerLimit;
+
+ // Time of day / fixed sun
+ m_regInfo.estateSettings.useFixedSun = UseFixedSun;
+ m_regInfo.estateSettings.sunHour = SunHour;
+ }
+
+ #region Packet Handlers
+
+
public void handleEstateOwnerMessage(EstateOwnerMessagePacket packet, IClientAPI remote_client)
{
if (remote_client.AgentId == m_regInfo.MasterAvatarAssignedUUID)
@@ -162,11 +244,13 @@ namespace OpenSim.Region.Environment
}
else
{
- m_regInfo.estateSettings.waterHeight = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[0].Parameter));
- m_regInfo.estateSettings.terrainRaiseLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter));
- m_regInfo.estateSettings.terrainLowerLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter));
- m_regInfo.estateSettings.useFixedSun = this.convertParamStringToBool(packet.ParamList[4].Parameter);
- m_regInfo.estateSettings.sunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
+ float WaterHeight = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[0].Parameter));
+ float TerrainRaiseLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter));
+ float TerrainLowerLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter));
+ bool UseFixedSun = this.convertParamStringToBool(packet.ParamList[4].Parameter);
+ float SunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
+
+ setRegionSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseFixedSun, SunHour);
sendRegionInfoPacketToAll();
}
@@ -176,34 +260,16 @@ namespace OpenSim.Region.Environment
{
foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
{
-
string s = Helpers.FieldToUTF8String(block.Parameter);
string[] splitField = s.Split(' ');
if (splitField.Length == 3)
{
- float tempHeightLow = (float)Convert.ToDecimal(splitField[1]);
- float tempHeightHigh = (float)Convert.ToDecimal(splitField[2]);
+ UInt16 corner = Convert.ToInt16(splitField[0]);
+ float lowValue = (float)Convert.ToDecimal(splitField[1]);
+ float highValue = (float)Convert.ToDecimal(splitField[2]);
- switch (Convert.ToInt16(splitField[0]))
- {
- case 0:
- m_regInfo.estateSettings.terrainStartHeight0 = tempHeightLow;
- m_regInfo.estateSettings.terrainHeightRange0 = tempHeightHigh;
- break;
- case 1:
- m_regInfo.estateSettings.terrainStartHeight1 = tempHeightLow;
- m_regInfo.estateSettings.terrainHeightRange1 = tempHeightHigh;
- break;
- case 2:
- m_regInfo.estateSettings.terrainStartHeight2 = tempHeightLow;
- m_regInfo.estateSettings.terrainHeightRange2 = tempHeightHigh;
- break;
- case 3:
- m_regInfo.estateSettings.terrainStartHeight3 = tempHeightLow;
- m_regInfo.estateSettings.terrainHeightRange3 = tempHeightHigh;
- break;
- }
+ setEstateTextureRange(corner, lowValue, highValue);
}
}
}
@@ -217,22 +283,10 @@ namespace OpenSim.Region.Environment
string[] splitField = s.Split(' ');
if (splitField.Length == 2)
{
- LLUUID tempUUID = new LLUUID(splitField[1]);
- switch (Convert.ToInt16(splitField[0]))
- {
- case 0:
- m_regInfo.estateSettings.terrainDetail0 = tempUUID;
- break;
- case 1:
- m_regInfo.estateSettings.terrainDetail1 = tempUUID;
- break;
- case 2:
- m_regInfo.estateSettings.terrainDetail2 = tempUUID;
- break;
- case 3:
- m_regInfo.estateSettings.terrainDetail3 = tempUUID;
- break;
- }
+ UInt16 corner = Convert.ToInt16(splitField[0]);
+ LLUUID textureUUID = new LLUUID(splitField[1]);
+
+ setTerrainTexture(corner, textureUUID);
}
}
}
@@ -265,6 +319,10 @@ namespace OpenSim.Region.Environment
}
}
+ #endregion
+
+ #region Outgoing Packets
+
public void sendRegionInfoPacketToAll()
{
List avatars = m_scene.RequestAvatarList();
@@ -319,5 +377,7 @@ namespace OpenSim.Region.Environment
remoteClient.SendRegionHandshake(m_regInfo);
}
+ #endregion
+
}
}
--
cgit v1.1