Add cmSetWindlightSceneTargeted. Add restrictions on windlight script use.

avinationmerge
CasperW 2009-12-17 18:40:34 +01:00
parent 6483470ec5
commit 6dbe25360e
8 changed files with 344 additions and 249 deletions

View File

@ -20,15 +20,15 @@ CREATE TABLE `regionwindlight` (
`little_wave_direction_x` float(3,2) NOT NULL DEFAULT '1.11',
`little_wave_direction_y` float(3,2) NOT NULL DEFAULT '-1.16',
`normal_map_texture` varchar(36) NOT NULL DEFAULT '822ded49-9a6c-f61c-cb89-6df54f42cdf4',
`horizon_r` float(3,2) unsigned NOT NULL DEFAULT '0.26',
`horizon_g` float(3,2) unsigned NOT NULL DEFAULT '0.24',
`horizon_b` float(3,2) unsigned NOT NULL DEFAULT '0.33',
`horizon_i` float(3,2) unsigned NOT NULL DEFAULT '0.33',
`horizon_r` float(3,2) unsigned NOT NULL DEFAULT '0.25',
`horizon_g` float(3,2) unsigned NOT NULL DEFAULT '0.25',
`horizon_b` float(3,2) unsigned NOT NULL DEFAULT '0.32',
`horizon_i` float(3,2) unsigned NOT NULL DEFAULT '0.32',
`haze_horizon` float(3,2) unsigned NOT NULL DEFAULT '0.19',
`blue_density_r` float(3,2) unsigned NOT NULL DEFAULT '0.10',
`blue_density_g` float(3,2) unsigned NOT NULL DEFAULT '0.93',
`blue_density_b` float(3,2) unsigned NOT NULL DEFAULT '0.02',
`blue_density_i` float(3,2) unsigned NOT NULL DEFAULT '0.93',
`blue_density_r` float(3,2) unsigned NOT NULL DEFAULT '0.12',
`blue_density_g` float(3,2) unsigned NOT NULL DEFAULT '0.22',
`blue_density_b` float(3,2) unsigned NOT NULL DEFAULT '0.38',
`blue_density_i` float(3,2) unsigned NOT NULL DEFAULT '0.38',
`haze_density` float(3,2) unsigned NOT NULL DEFAULT '0.70',
`density_multiplier` float(3,2) unsigned NOT NULL DEFAULT '0.18',
`distance_multiplier` float(4,1) unsigned NOT NULL DEFAULT '0.8',
@ -37,7 +37,7 @@ CREATE TABLE `regionwindlight` (
`sun_moon_color_g` float(3,2) unsigned NOT NULL DEFAULT '0.26',
`sun_moon_color_b` float(3,2) unsigned NOT NULL DEFAULT '0.30',
`sun_moon_color_i` float(3,2) unsigned NOT NULL DEFAULT '0.30',
`sun_moon_position` float(4,3) unsigned NOT NULL DEFAULT '0.335',
`sun_moon_position` float(4,3) unsigned NOT NULL DEFAULT '0.317',
`ambient_r` float(3,2) unsigned NOT NULL DEFAULT '0.35',
`ambient_g` float(3,2) unsigned NOT NULL DEFAULT '0.35',
`ambient_b` float(3,2) unsigned NOT NULL DEFAULT '0.35',
@ -63,7 +63,7 @@ CREATE TABLE `regionwindlight` (
`cloud_scroll_x_lock` tinyint(1) unsigned NOT NULL DEFAULT '0',
`cloud_scroll_y` float(3,2) unsigned NOT NULL DEFAULT '0.01',
`cloud_scroll_y_lock` tinyint(1) unsigned NOT NULL DEFAULT '0',
`draw_classic_clouds` tinyint(1) unsigned NOT NULL DEFAULT '0',
`draw_classic_clouds` tinyint(1) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`region_id`)
);

View File

@ -39,7 +39,7 @@ using OpenSim.Framework.Console;
namespace OpenSim.Framework
{
public class RegionMeta7WindlightData
public class RegionMeta7WindlightData : ICloneable
{
public UUID regionID = UUID.Zero;
public Vector3 waterColor = new Vector3(4.0f,38.0f,64.0f);
@ -54,19 +54,19 @@ namespace OpenSim.Framework
public Vector2 bigWaveDirection = new Vector2(1.05f,-0.42f);
public Vector2 littleWaveDirection = new Vector2(1.11f,-1.16f);
public UUID normalMapTexture = new UUID("822ded49-9a6c-f61c-cb89-6df54f42cdf4");
public Vector4 horizon = new Vector4(0.26f, 0.24f, 0.34f, 0.33f);
public Vector4 horizon = new Vector4(0.25f, 0.25f, 0.32f, 0.32f);
public float hazeHorizon = 0.19f;
public Vector4 blueDensity = new Vector4(0.10f, 0.93f, 0.02f, 0.93f);
public Vector4 blueDensity = new Vector4(0.12f, 0.22f, 0.38f, 0.38f);
public float hazeDensity = 0.70f;
public float densityMultiplier = 0.18f;
public float distanceMultiplier = 0.8f;
public UInt16 maxAltitude = 1605;
public Vector4 sunMoonColor = new Vector4(0.24f, 0.26f, 0.30f, 0.30f);
public float sunMoonPosition = 0.335f;
public float sunMoonPosition = 0.317f;
public Vector4 ambient = new Vector4(0.35f,0.35f,0.35f,0.35f);
public float eastAngle = 0.0f;
public float sunGlowFocus = 0.10f;
public float sunGlowSize = 0.10f;
public float sunGlowSize = 1.75f;
public float sceneGamma = 1.0f;
public float starBrightness = 0.0f;
public Vector4 cloudColor = new Vector4(0.41f, 0.41f, 0.41f, 0.41f);
@ -78,7 +78,7 @@ namespace OpenSim.Framework
public bool cloudScrollXLock = false;
public float cloudScrollY = 0.01f;
public bool cloudScrollYLock = false;
public bool drawClassicClouds = false;
public bool drawClassicClouds = true;
public delegate void SaveDelegate(RegionMeta7WindlightData wl);
public event SaveDelegate OnSave;
@ -87,6 +87,11 @@ namespace OpenSim.Framework
if (OnSave != null)
OnSave(this);
}
public object Clone()
{
return this.MemberwiseClone(); // call clone method
}
}
[Serializable]

View File

@ -71,20 +71,16 @@ namespace OpenSim.Region.CoreModules.World.Meta7Windlight
{
m_scene.EventManager.OnMakeRootAgent += EventManager_OnMakeRootAgent;
m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile;
m_scene.EventManager.OnSendNewWindlightProfileTargeted += EventManager_OnSendNewWindlightProfileTargeted;
}
InstallCommands();
m_log.Debug("[WINDLIGHT]: Initialised windlight module");
}
public void SendProfileToClient(ScenePresence presence)
private List<byte[]> compileWindlightSettings(RegionMeta7WindlightData wl)
{
if (m_enableWindlight)
{
if (presence.IsChildAgent == false)
{
IClientAPI client = presence.ControllingClient;
RegionMeta7WindlightData wl = m_scene.RegionInfo.WindlightSettings;
byte[] mBlock = new Byte[249];
int pos = 0;
@ -127,7 +123,33 @@ namespace OpenSim.Region.CoreModules.World.Meta7Windlight
mBlock[pos] = Convert.ToByte(wl.drawClassicClouds); pos++;
List<byte[]> param = new List<byte[]>();
param.Add(mBlock);
return param;
}
public void SendProfileToClient(ScenePresence presence)
{
IClientAPI client = presence.ControllingClient;
if (m_enableWindlight)
{
if (presence.IsChildAgent == false)
{
List<byte[]> param = compileWindlightSettings(m_scene.RegionInfo.WindlightSettings);
client.SendGenericMessage("Windlight", param);
}
}
else
{
//We probably don't want to spam chat with this.. probably
//m_log.Debug("[WINDLIGHT]: Module disabled");
}
}
public void SendProfileToClient(ScenePresence presence, RegionMeta7WindlightData wl)
{
IClientAPI client = presence.ControllingClient;
if (m_enableWindlight)
{
if (presence.IsChildAgent == false)
{
List<byte[]> param = compileWindlightSettings(wl);
client.SendGenericMessage("Windlight", param);
}
}
@ -142,7 +164,14 @@ namespace OpenSim.Region.CoreModules.World.Meta7Windlight
m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client");
SendProfileToClient(presence);
}
private void EventManager_OnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID pUUID)
{
ScenePresence Sc;
if (m_scene.TryGetAvatar(pUUID,out Sc))
{
SendProfileToClient(Sc,wl);
}
}
private void EventManager_OnSaveNewWindlightProfile()
{
m_scene.ForEachScenePresence(SendProfileToClient);

View File

@ -194,7 +194,9 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void OnMakeRootAgentDelegate(ScenePresence presence);
public delegate void OnSaveNewWindlightProfileDelegate();
public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionMeta7WindlightData wl, UUID user);
public event OnMakeRootAgentDelegate OnMakeRootAgent;
public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted;
public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile;
public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel);
@ -414,6 +416,7 @@ namespace OpenSim.Region.Framework.Scenes
private ClientClosed handlerClientClosed = null; //OnClientClosed;
private OnMakeChildAgentDelegate handlerMakeChildAgent = null; //OnMakeChildAgent;
private OnSaveNewWindlightProfileDelegate handlerSaveNewWindlightProfile = null; //OnSaveNewWindlightProfile;
private OnSendNewWindlightProfileTargetedDelegate handlerSendNewWindlightProfileTargeted = null; //OnSendNewWindlightProfileTargeted;
private OnMakeRootAgentDelegate handlerMakeRootAgent = null; //OnMakeRootAgent;
private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick;
private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps;
@ -775,6 +778,15 @@ namespace OpenSim.Region.Framework.Scenes
}
}
public void TriggerOnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID user)
{
handlerSendNewWindlightProfileTargeted = OnSendNewWindlightProfileTargeted;
if (handlerSendNewWindlightProfileTargeted != null)
{
handlerSendNewWindlightProfileTargeted(wl, user);
}
}
public void TriggerOnSaveNewWindlightProfile()
{
handlerSaveNewWindlightProfile = OnSaveNewWindlightProfile;

View File

@ -231,27 +231,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
/// <summary>
/// Set the current Windlight scene
/// </summary>
/// <param name="rules"></param>
/// <returns>success: true or false</returns>
public int cmSetWindlightScene(LSL_List rules)
private RegionMeta7WindlightData getWindlightProfileFromRules(LSL_List rules)
{
if (!m_CMFunctionsEnabled)
{
CMShoutError("Careminster functions are not enabled.");
return 0;
}
int success = 0;
m_host.AddScriptLPS(1);
if (Meta7WindlightModule.EnableWindlight)
{
RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
RegionMeta7WindlightData wl = (RegionMeta7WindlightData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone();
LSL_List values = new LSL_List();
int idx = 0;
success = 1;
while (idx < rules.Length)
{
uint rule = (uint)rules.GetLSLIntegerItem(idx);
@ -414,14 +399,72 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
idx++;
wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
break;
default:
success = 0;
break;
}
idx++;
}
return wl;
}
/// <summary>
/// Set the current Windlight scene
/// </summary>
/// <param name="rules"></param>
/// <returns>success: true or false</returns>
public int cmSetWindlightScene(LSL_List rules)
{
if (!m_CMFunctionsEnabled)
{
CMShoutError("Careminster functions are not enabled.");
return 0;
}
if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
{
CMShoutError("cmSetWindlightScene can only be used by estate managers or owners.");
return 0;
}
int success = 0;
m_host.AddScriptLPS(1);
if (Meta7WindlightModule.EnableWindlight)
{
RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
success = 1;
}
else
{
CMShoutError("Windlight module is disabled");
return 0;
}
return success;
}
/// <summary>
/// Set the current Windlight scene to a target avatar
/// </summary>
/// <param name="rules"></param>
/// <returns>success: true or false</returns>
public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
{
if (!m_CMFunctionsEnabled)
{
CMShoutError("Careminster functions are not enabled.");
return 0;
}
if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
{
CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners.");
return 0;
}
int success = 0;
m_host.AddScriptLPS(1);
if (Meta7WindlightModule.EnableWindlight)
{
RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string));
success = 1;
}
else
{
CMShoutError("Windlight module is disabled");
return 0;
}
return success;
}

View File

@ -16,5 +16,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
// Windlight Functions
LSL_List cmGetWindlightScene(LSL_List rules);
int cmSetWindlightScene(LSL_List rules);
int cmSetWindlightSceneTargeted(LSL_List rules, key target);
}
}

View File

@ -67,5 +67,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
return m_CM_Functions.cmSetWindlightScene(rules);
}
public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
{
return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target);
}
}
}