*Moved EstateManager into a region module

0.6.0-stable
mingchen 2008-05-03 17:11:21 +00:00
parent e8acb49fef
commit 4a87d96c17
4 changed files with 761 additions and 714 deletions

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
@ -28,23 +28,22 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using libsecondlife;
using libsecondlife.Packets;
using log4net;
using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Framework;
using Nini.Config;
using log4net;
namespace OpenSim.Region.Environment
namespace OpenSim.Region.Environment.Modules.World.Estate
{
/// <summary>
/// Processes requests regarding estates. Refer to EstateSettings.cs in OpenSim.Framework. Types for all of the core settings
/// </summary>
public class EstateManager
public class EstateManagementModule : IRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private RegionInfo m_regInfo;
public enum EstateAccessCodex : uint
{
@ -55,11 +54,7 @@ namespace OpenSim.Region.Environment
}
public EstateManager(Scene scene, RegionInfo reginfo)
{
m_scene = scene;
m_regInfo = reginfo;
}
#region Helper Functions
private bool convertParamStringToBool(byte[] field)
{
@ -82,20 +77,20 @@ namespace OpenSim.Region.Environment
switch (corner)
{
case 0:
m_regInfo.EstateSettings.terrainStartHeight0 = lowValue;
m_regInfo.EstateSettings.terrainHeightRange0 = highValue;
m_scene.RegionInfo.EstateSettings.terrainStartHeight0 = lowValue;
m_scene.RegionInfo.EstateSettings.terrainHeightRange0 = highValue;
break;
case 1:
m_regInfo.EstateSettings.terrainStartHeight1 = lowValue;
m_regInfo.EstateSettings.terrainHeightRange1 = highValue;
m_scene.RegionInfo.EstateSettings.terrainStartHeight1 = lowValue;
m_scene.RegionInfo.EstateSettings.terrainHeightRange1 = highValue;
break;
case 2:
m_regInfo.EstateSettings.terrainStartHeight2 = lowValue;
m_regInfo.EstateSettings.terrainHeightRange2 = highValue;
m_scene.RegionInfo.EstateSettings.terrainStartHeight2 = lowValue;
m_scene.RegionInfo.EstateSettings.terrainHeightRange2 = highValue;
break;
case 3:
m_regInfo.EstateSettings.terrainStartHeight3 = lowValue;
m_regInfo.EstateSettings.terrainHeightRange3 = highValue;
m_scene.RegionInfo.EstateSettings.terrainStartHeight3 = lowValue;
m_scene.RegionInfo.EstateSettings.terrainHeightRange3 = highValue;
break;
}
}
@ -110,16 +105,16 @@ namespace OpenSim.Region.Environment
switch (band)
{
case 0:
m_regInfo.EstateSettings.terrainDetail0 = textureUUID;
m_scene.RegionInfo.EstateSettings.terrainDetail0 = textureUUID;
break;
case 1:
m_regInfo.EstateSettings.terrainDetail1 = textureUUID;
m_scene.RegionInfo.EstateSettings.terrainDetail1 = textureUUID;
break;
case 2:
m_regInfo.EstateSettings.terrainDetail2 = textureUUID;
m_scene.RegionInfo.EstateSettings.terrainDetail2 = textureUUID;
break;
case 3:
m_regInfo.EstateSettings.terrainDetail3 = textureUUID;
m_scene.RegionInfo.EstateSettings.terrainDetail3 = textureUUID;
break;
}
}
@ -136,16 +131,17 @@ namespace OpenSim.Region.Environment
bool UseFixedSun, float SunHour)
{
// Water Height
m_regInfo.EstateSettings.waterHeight = WaterHeight;
m_scene.RegionInfo.EstateSettings.waterHeight = WaterHeight;
// Terraforming limits
m_regInfo.EstateSettings.terrainRaiseLimit = TerrainRaiseLimit;
m_regInfo.EstateSettings.terrainLowerLimit = TerrainLowerLimit;
m_scene.RegionInfo.EstateSettings.terrainRaiseLimit = TerrainRaiseLimit;
m_scene.RegionInfo.EstateSettings.terrainLowerLimit = TerrainLowerLimit;
// Time of day / fixed sun
m_regInfo.EstateSettings.useFixedSun = UseFixedSun;
m_regInfo.EstateSettings.sunHour = SunHour;
m_scene.RegionInfo.EstateSettings.useFixedSun = UseFixedSun;
m_scene.RegionInfo.EstateSettings.sunHour = SunHour;
}
#endregion
#region Packet Handlers
@ -426,54 +422,54 @@ namespace OpenSim.Region.Environment
}
else
{
m_regInfo.EstateSettings.regionFlags = Simulator.RegionFlags.None;
m_scene.RegionInfo.EstateSettings.regionFlags = Simulator.RegionFlags.None;
if (convertParamStringToBool(packet.ParamList[0].Parameter))
{
m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
Simulator.RegionFlags.BlockTerraform;
}
if (convertParamStringToBool(packet.ParamList[1].Parameter))
{
m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
Simulator.RegionFlags.NoFly;
}
if (convertParamStringToBool(packet.ParamList[2].Parameter))
{
m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
Simulator.RegionFlags.AllowDamage;
}
if (convertParamStringToBool(packet.ParamList[3].Parameter) == false)
{
m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
Simulator.RegionFlags.BlockLandResell;
}
int tempMaxAgents =
Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter)));
m_regInfo.EstateSettings.maxAgents = (byte) tempMaxAgents;
m_scene.RegionInfo.EstateSettings.maxAgents = (byte)tempMaxAgents;
float tempObjectBonusFactor =
(float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
m_regInfo.EstateSettings.objectBonusFactor = tempObjectBonusFactor;
m_scene.RegionInfo.EstateSettings.objectBonusFactor = tempObjectBonusFactor;
int tempMatureLevel = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[6].Parameter));
m_regInfo.EstateSettings.simAccess = (Simulator.SimAccess) tempMatureLevel;
m_scene.RegionInfo.EstateSettings.simAccess = (Simulator.SimAccess)tempMatureLevel;
if (convertParamStringToBool(packet.ParamList[7].Parameter))
{
m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
Simulator.RegionFlags.RestrictPushObject;
}
if (convertParamStringToBool(packet.ParamList[8].Parameter))
{
m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
m_scene.RegionInfo.EstateSettings.regionFlags = m_scene.RegionInfo.EstateSettings.regionFlags |
Simulator.RegionFlags.AllowParcelChanges;
}
@ -560,16 +556,16 @@ namespace OpenSim.Region.Environment
switch (Convert.ToInt16(splitField[0]))
{
case 0:
m_regInfo.EstateSettings.terrainBase0 = tempUUID;
m_scene.RegionInfo.EstateSettings.terrainBase0 = tempUUID;
break;
case 1:
m_regInfo.EstateSettings.terrainBase1 = tempUUID;
m_scene.RegionInfo.EstateSettings.terrainBase1 = tempUUID;
break;
case 2:
m_regInfo.EstateSettings.terrainBase2 = tempUUID;
m_scene.RegionInfo.EstateSettings.terrainBase2 = tempUUID;
break;
case 3:
m_regInfo.EstateSettings.terrainBase3 = tempUUID;
m_scene.RegionInfo.EstateSettings.terrainBase3 = tempUUID;
break;
}
}
@ -594,7 +590,7 @@ namespace OpenSim.Region.Environment
foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
{
LLUUID newCovenantID = new LLUUID(Helpers.FieldToUTF8String(block.Parameter));
m_regInfo.CovenantID = newCovenantID;
m_scene.RegionInfo.CovenantID = newCovenantID;
m_scene.RegionInfo.SaveEstatecovenantUUID(newCovenantID);
}
}
@ -605,22 +601,22 @@ namespace OpenSim.Region.Environment
RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
rinfopack.AgentData.AgentID = client.AgentId;
rinfopack.AgentData.SessionID = client.SessionId;
rinfoblk.BillableFactor = m_regInfo.EstateSettings.billableFactor;
rinfoblk.EstateID = m_regInfo.EstateSettings.estateID;
rinfoblk.MaxAgents = m_regInfo.EstateSettings.maxAgents;
rinfoblk.ObjectBonusFactor = m_regInfo.EstateSettings.objectBonusFactor;
rinfoblk.ParentEstateID = m_regInfo.EstateSettings.parentEstateID;
rinfoblk.PricePerMeter = m_regInfo.EstateSettings.pricePerMeter;
rinfoblk.RedirectGridX = m_regInfo.EstateSettings.redirectGridX;
rinfoblk.RedirectGridY = m_regInfo.EstateSettings.redirectGridY;
rinfoblk.RegionFlags = (uint)( m_regInfo.EstateSettings.regionFlags);
rinfoblk.SimAccess = (byte) m_regInfo.EstateSettings.simAccess;
rinfoblk.SunHour = m_regInfo.EstateSettings.sunHour;
rinfoblk.TerrainLowerLimit = m_regInfo.EstateSettings.terrainLowerLimit;
rinfoblk.TerrainRaiseLimit = m_regInfo.EstateSettings.terrainRaiseLimit;
rinfoblk.UseEstateSun = !m_regInfo.EstateSettings.useFixedSun;
rinfoblk.WaterHeight = m_regInfo.EstateSettings.waterHeight;
rinfoblk.SimName = Helpers.StringToField(m_regInfo.RegionName);
rinfoblk.BillableFactor = m_scene.RegionInfo.EstateSettings.billableFactor;
rinfoblk.EstateID = m_scene.RegionInfo.EstateSettings.estateID;
rinfoblk.MaxAgents = m_scene.RegionInfo.EstateSettings.maxAgents;
rinfoblk.ObjectBonusFactor = m_scene.RegionInfo.EstateSettings.objectBonusFactor;
rinfoblk.ParentEstateID = m_scene.RegionInfo.EstateSettings.parentEstateID;
rinfoblk.PricePerMeter = m_scene.RegionInfo.EstateSettings.pricePerMeter;
rinfoblk.RedirectGridX = m_scene.RegionInfo.EstateSettings.redirectGridX;
rinfoblk.RedirectGridY = m_scene.RegionInfo.EstateSettings.redirectGridY;
rinfoblk.RegionFlags = (uint)(m_scene.RegionInfo.EstateSettings.regionFlags);
rinfoblk.SimAccess = (byte)m_scene.RegionInfo.EstateSettings.simAccess;
rinfoblk.SunHour = m_scene.RegionInfo.EstateSettings.sunHour;
rinfoblk.TerrainLowerLimit = m_scene.RegionInfo.EstateSettings.terrainLowerLimit;
rinfoblk.TerrainRaiseLimit = m_scene.RegionInfo.EstateSettings.terrainRaiseLimit;
rinfoblk.UseEstateSun = !m_scene.RegionInfo.EstateSettings.useFixedSun;
rinfoblk.WaterHeight = m_scene.RegionInfo.EstateSettings.waterHeight;
rinfoblk.SimName = Helpers.StringToField(m_scene.RegionInfo.RegionName);
rinfopack.RegionInfo = rinfoblk;
@ -631,11 +627,11 @@ namespace OpenSim.Region.Environment
{
EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
edata.CovenantID = m_regInfo.CovenantID;
edata.CovenantID = m_scene.RegionInfo.CovenantID;
edata.CovenantTimestamp = 0;
edata.EstateOwnerID = m_regInfo.MasterAvatarAssignedUUID;
edata.EstateOwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
edata.EstateName =
Helpers.StringToField(m_regInfo.MasterAvatarFirstName + " " + m_regInfo.MasterAvatarLastName);
Helpers.StringToField(m_scene.RegionInfo.MasterAvatarFirstName + " " + m_scene.RegionInfo.MasterAvatarLastName);
einfopack.Data = edata;
client.OutPacket(einfopack, ThrottleOutPacketType.Task);
}
@ -668,22 +664,22 @@ namespace OpenSim.Region.Environment
RegionInfoPacket regionInfoPacket = new RegionInfoPacket();
regionInfoPacket.AgentData.AgentID = circuitData.AgentID;
regionInfoPacket.AgentData.SessionID = circuitData.SessionID;
regionInfoPacket.RegionInfo.BillableFactor = m_regInfo.EstateSettings.billableFactor;
regionInfoPacket.RegionInfo.EstateID = m_regInfo.EstateSettings.estateID;
regionInfoPacket.RegionInfo.MaxAgents = m_regInfo.EstateSettings.maxAgents;
regionInfoPacket.RegionInfo.ObjectBonusFactor = m_regInfo.EstateSettings.objectBonusFactor;
regionInfoPacket.RegionInfo.ParentEstateID = m_regInfo.EstateSettings.parentEstateID;
regionInfoPacket.RegionInfo.PricePerMeter = m_regInfo.EstateSettings.pricePerMeter;
regionInfoPacket.RegionInfo.RedirectGridX = m_regInfo.EstateSettings.redirectGridX;
regionInfoPacket.RegionInfo.RedirectGridY = m_regInfo.EstateSettings.redirectGridY;
regionInfoPacket.RegionInfo.RegionFlags = (uint)(m_regInfo.EstateSettings.regionFlags);
regionInfoPacket.RegionInfo.SimAccess = (byte) m_regInfo.EstateSettings.simAccess;
regionInfoPacket.RegionInfo.SimName = Helpers.StringToField(m_regInfo.RegionName);
regionInfoPacket.RegionInfo.SunHour = m_regInfo.EstateSettings.sunHour;
regionInfoPacket.RegionInfo.TerrainLowerLimit = m_regInfo.EstateSettings.terrainLowerLimit;
regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_regInfo.EstateSettings.terrainRaiseLimit;
regionInfoPacket.RegionInfo.UseEstateSun = !m_regInfo.EstateSettings.useFixedSun;
regionInfoPacket.RegionInfo.WaterHeight = m_regInfo.EstateSettings.waterHeight;
regionInfoPacket.RegionInfo.BillableFactor = m_scene.RegionInfo.EstateSettings.billableFactor;
regionInfoPacket.RegionInfo.EstateID = m_scene.RegionInfo.EstateSettings.estateID;
regionInfoPacket.RegionInfo.MaxAgents = m_scene.RegionInfo.EstateSettings.maxAgents;
regionInfoPacket.RegionInfo.ObjectBonusFactor = m_scene.RegionInfo.EstateSettings.objectBonusFactor;
regionInfoPacket.RegionInfo.ParentEstateID = m_scene.RegionInfo.EstateSettings.parentEstateID;
regionInfoPacket.RegionInfo.PricePerMeter = m_scene.RegionInfo.EstateSettings.pricePerMeter;
regionInfoPacket.RegionInfo.RedirectGridX = m_scene.RegionInfo.EstateSettings.redirectGridX;
regionInfoPacket.RegionInfo.RedirectGridY = m_scene.RegionInfo.EstateSettings.redirectGridY;
regionInfoPacket.RegionInfo.RegionFlags = (uint)(m_scene.RegionInfo.EstateSettings.regionFlags);
regionInfoPacket.RegionInfo.SimAccess = (byte)m_scene.RegionInfo.EstateSettings.simAccess;
regionInfoPacket.RegionInfo.SimName = Helpers.StringToField(m_scene.RegionInfo.RegionName);
regionInfoPacket.RegionInfo.SunHour = m_scene.RegionInfo.EstateSettings.sunHour;
regionInfoPacket.RegionInfo.TerrainLowerLimit = m_scene.RegionInfo.EstateSettings.terrainLowerLimit;
regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_scene.RegionInfo.EstateSettings.terrainRaiseLimit;
regionInfoPacket.RegionInfo.UseEstateSun = !m_scene.RegionInfo.EstateSettings.useFixedSun;
regionInfoPacket.RegionInfo.WaterHeight = m_scene.RegionInfo.EstateSettings.waterHeight;
remote_client.OutPacket(regionInfoPacket, ThrottleOutPacketType.Task);
@ -691,9 +687,58 @@ namespace OpenSim.Region.Environment
public void sendRegionHandshake(IClientAPI remoteClient)
{
remoteClient.SendRegionHandshake(m_regInfo);
remoteClient.SendRegionHandshake(m_scene.RegionInfo);
}
#endregion
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource source)
{
m_scene = scene;
m_scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient);
m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
}
void EventManager_OnNewClient(IClientAPI client)
{
client.OnEstateOwnerMessage += handleEstateOwnerMessage;
client.OnRegionInfoRequest += HandleRegionInfoRequest;
client.OnEstateCovenantRequest += HandleEstateCovenantRequest;
sendRegionHandshake(client);
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "EstateManagementModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
#endregion
#region Other Functions
public void changeWaterHeight(float height)
{
setRegionSettings(height, m_scene.RegionInfo.EstateSettings.terrainRaiseLimit, m_scene.RegionInfo.EstateSettings.terrainLowerLimit, m_scene.RegionInfo.EstateSettings.useFixedSun, m_scene.RegionInfo.EstateSettings.sunHour);
sendRegionInfoPacketToAll();
}
#endregion
}
}

View File

@ -153,7 +153,6 @@ namespace OpenSim.Region.Environment.Scenes
get { return m_authenticateHandler; }
}
protected readonly EstateManager m_estateManager;
// an instance to the physics plugin's Scene object.
public PhysicsScene PhysicsScene
{
@ -167,11 +166,6 @@ namespace OpenSim.Region.Environment.Scenes
get { return m_innerScene.m_syncRoot; }
}
public EstateManager EstateManager
{
get { return m_estateManager; }
}
public float TimeDilation
{
get { return m_timedilation; }
@ -256,8 +250,6 @@ namespace OpenSim.Region.Environment.Scenes
EventManager.OnLandObjectRemoved +=
new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject);
m_estateManager = new EstateManager(this, m_regInfo);
m_permissionManager = permissionManager;
m_permissionManager.Initialise(this);
@ -1514,8 +1506,6 @@ namespace OpenSim.Region.Environment.Scenes
{
m_log.Info("[REGION]: Add New Scene Presence");
m_estateManager.sendRegionHandshake(client);
CreateAndAddScenePresence(client, child);
LandChannel.sendParcelOverlay(client);
@ -1572,9 +1562,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnParcelAccessListUpdateRequest +=
new ParcelAccessListUpdateRequest(LandChannel.handleParcelAccessUpdateRequest);
client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage);
client.OnRegionInfoRequest += m_estateManager.HandleRegionInfoRequest;
client.OnEstateCovenantRequest += m_estateManager.HandleEstateCovenantRequest;
client.OnRequestGodlikePowers += handleRequestGodlikePowers;
client.OnGodKickUser += HandleGodlikeKickUser;
client.OnObjectPermissions += HandleObjectPermissionsUpdate;

View File

@ -151,6 +151,10 @@ namespace OpenSim.Region.Environment.Scenes
public event NewInventoryItemUploadComplete OnNewInventoryItemUploadComplete;
public delegate void RequestChangeWaterHeight(float height);
public event RequestChangeWaterHeight OnRequestChangeWaterHeight;
public delegate void AvatarKillData(uint KillerLocalID, ScenePresence avatar);
public event AvatarKillData OnAvatarKilled;
@ -269,6 +273,8 @@ namespace OpenSim.Region.Environment.Scenes
private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps;
private DeregisterCapsEvent handlerDeregisterCaps = null; // OnDeregisterCaps;
private NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete = null;
private RequestChangeWaterHeight handlerRequestChangeWaterHeight = null; //OnRequestChangeWaterHeight
private LandBuy handlerLandBuy = null;
private LandBuy handlerValidateLandBuy = null;
private AvatarKillData handlerAvatarKill = null;
@ -579,6 +585,15 @@ namespace OpenSim.Region.Environment.Scenes
handlerScriptNotAtTargetEvent(localID);
}
}
public void TriggerRequestChangeWaterHeight(float height)
{
handlerRequestChangeWaterHeight = OnRequestChangeWaterHeight;
if (handlerRequestChangeWaterHeight != null)
{
handlerRequestChangeWaterHeight(height);
}
}
public void TriggerAvatarKill(uint KillerObjectLocalID, ScenePresence DeadAvatar)
{
handlerAvatarKill = OnAvatarKilled;

View File

@ -183,8 +183,7 @@ namespace OpenSim.Region.ScriptEngine.Common
//World.PermissionsMngr.GenericEstatePermission(
if (World.PermissionsMngr.GenericEstatePermission(m_host.OwnerID))
{
World.EstateManager.setRegionSettings((float)height, 0f, 0f, false, 0.5f);
World.EstateManager.sendRegionInfoPacketToAll();
World.EventManager.TriggerRequestChangeWaterHeight((float)height);
}
}