Merge branch 'careminster' into tests

This commit is contained in:
KittoFlora
2009-11-16 01:40:15 +01:00
177 changed files with 5520 additions and 4206 deletions

View File

@@ -2163,7 +2163,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Vector llGetOmega()
{
m_host.AddScriptLPS(1);
return new LSL_Vector(m_host.RotationalVelocity.X, m_host.RotationalVelocity.Y, m_host.RotationalVelocity.Z);
return new LSL_Vector(m_host.AngularVelocity.X, m_host.AngularVelocity.Y, m_host.AngularVelocity.Z);
}
public LSL_Float llGetTimeOfDay()
@@ -3163,7 +3163,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llTargetOmega(LSL_Vector axis, double spinrate, double gain)
{
m_host.AddScriptLPS(1);
m_host.RotationalVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate));
m_host.AngularVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate));
m_host.ScheduleTerseUpdate();
m_host.SendTerseUpdateToAllClients();
@@ -3821,7 +3820,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
case 1: // DATA_ONLINE (0|1)
// TODO: implement fetching of this information
if (userProfile.CurrentAgent.AgentOnline)
if (userProfile.CurrentAgent!=null && userProfile.CurrentAgent.AgentOnline)
reply = "1";
else
reply = "0";

View File

@@ -0,0 +1,134 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Remoting.Lifetime;
using OpenMetaverse;
using Nini.Config;
using OpenSim;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
namespace OpenSim.Region.ScriptEngine.Shared.Api
{
[Serializable]
public class MOD_Api : MarshalByRefObject, IMOD_Api, IScriptApi
{
internal IScriptEngine m_ScriptEngine;
internal SceneObjectPart m_host;
internal uint m_localID;
internal UUID m_itemID;
internal bool m_MODFunctionsEnabled = false;
internal IScriptModuleComms m_comms = null;
public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
{
m_ScriptEngine = ScriptEngine;
m_host = host;
m_localID = localID;
m_itemID = itemID;
if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false))
m_MODFunctionsEnabled = true;
m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>();
if (m_comms == null)
m_MODFunctionsEnabled = false;
}
public override Object InitializeLifetimeService()
{
ILease lease = (ILease)base.InitializeLifetimeService();
if (lease.CurrentState == LeaseState.Initial)
{
lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
// lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
// lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
}
return lease;
}
public Scene World
{
get { return m_ScriptEngine.World; }
}
internal void MODError(string msg)
{
throw new Exception("MOD Runtime Error: " + msg);
}
//
//Dumps an error message on the debug console.
//
internal void MODShoutError(string message)
{
if (message.Length > 1023)
message = message.Substring(0, 1023);
World.SimChat(Utils.StringToBytes(message),
ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true);
IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
}
public string modSendCommand(string module, string command, string k)
{
if (!m_MODFunctionsEnabled)
{
MODShoutError("Module command functions not enabled");
return UUID.Zero.ToString();;
}
UUID req = UUID.Random();
m_comms.RaiseEvent(m_itemID, req.ToString(), module, command, k);
return req.ToString();
}
}
}

View File

@@ -199,7 +199,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
//Dumps an error message on the debug console.
//
internal void OSSLShoutError(string message)
internal void OSSLShoutError(string message)
{
if (message.Length > 1023)
message = message.Substring(0, 1023);
@@ -384,7 +384,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
if (World.Entities.ContainsKey(target))
{
World.Entities[target].Rotation = rotation;
EntityBase entity;
if (World.Entities.TryGetValue(target, out entity))
{
if (entity is SceneObjectGroup)
((SceneObjectGroup)entity).Rotation = rotation;
else if (entity is ScenePresence)
((ScenePresence)entity).Rotation = rotation;
}
}
else
{
@@ -1169,7 +1176,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
land.SetMediaUrl(url);
}
public void osSetParcelSIPAddress(string SIPAddress)
{
// What actually is the difference to the LL function?
@@ -1177,7 +1184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL");
m_host.AddScriptLPS(1);
ILandObject land
= World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
@@ -1187,16 +1194,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
OSSLError("osSetParcelSIPAddress: Sorry, you need to own the land to use this function");
return;
}
// get the voice module
IVoiceModule voiceModule = World.RequestModuleInterface<IVoiceModule>();
if (voiceModule != null)
if (voiceModule != null)
voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID);
else
OSSLError("osSetParcelSIPAddress: No voice module enabled for this land");
}
public string osGetScriptEngineName()
@@ -1476,12 +1483,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
// Create new asset
AssetBase asset = new AssetBase();
asset.Name = notecardName;
AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard);
asset.Description = "Script Generated Notecard";
asset.Type = 7;
asset.FullID = UUID.Random();
string notecardData = "";
string notecardData = String.Empty;
for (int i = 0; i < contents.Length; i++) {
notecardData += contents.GetLSLStringItem(i) + "\n";
@@ -1521,10 +1525,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
/*Instead of using the LSL Dataserver event to pull notecard data,
/*Instead of using the LSL Dataserver event to pull notecard data,
this will simply read the requested line and return its data as a string.
Warning - due to the synchronous method this function uses to fetch assets, its use
Warning - due to the synchronous method this function uses to fetch assets, its use
may be dangerous and unreliable while running in grid mode.
*/
public string osGetNotecardLine(string name, int line)
@@ -1572,10 +1576,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
/*Instead of using the LSL Dataserver event to pull notecard data line by line,
/*Instead of using the LSL Dataserver event to pull notecard data line by line,
this will simply read the entire notecard and return its data as a string.
Warning - due to the synchronous method this function uses to fetch assets, its use
Warning - due to the synchronous method this function uses to fetch assets, its use
may be dangerous and unreliable while running in grid mode.
*/
@@ -1630,10 +1634,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
/*Instead of using the LSL Dataserver event to pull notecard data,
/*Instead of using the LSL Dataserver event to pull notecard data,
this will simply read the number of note card lines and return this data as an integer.
Warning - due to the synchronous method this function uses to fetch assets, its use
Warning - due to the synchronous method this function uses to fetch assets, its use
may be dangerous and unreliable while running in grid mode.
*/
@@ -1833,7 +1837,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return World.RegionInfo.RegionSettings.LoadedCreationID;
}
// Threat level is 'Low' because certain users could possibly be tricked into
// dropping an unverified script into one of their own objects, which could
// then gather the physical construction details of the object and transmit it
@@ -1857,7 +1861,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom)
{
CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
//QueueUserWorkItem
//QueueUserWorkItem
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
@@ -1906,5 +1910,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
module.DeleteNPC(new UUID(npc.m_string), World);
}
}
/// <summary>
/// Get current region's map texture UUID
/// </summary>
/// <returns></returns>
public LSL_Key osGetMapTexture()
{
CheckThreatLevel(ThreatLevel.None, "osGetMapTexture");
return m_ScriptEngine.World.RegionInfo.RegionSettings.TerrainImageID.ToString();
}
/// <summary>
/// Get a region's map texture UUID by region UUID or name.
/// </summary>
/// <param name="regionName"></param>
/// <returns></returns>
public LSL_Key osGetRegionMapTexture(string regionName)
{
CheckThreatLevel(ThreatLevel.High, "osGetRegionMapTexture");
Scene scene = m_ScriptEngine.World;
UUID key = UUID.Zero;
GridRegion region;
//If string is a key, use it. Otherwise, try to locate region by name.
if (UUID.TryParse(regionName, out key))
region = scene.GridService.GetRegionByUUID(UUID.Zero, key);
else
region = scene.GridService.GetRegionByName(UUID.Zero, regionName);
// If region was found, return the regions map texture key.
if (region != null)
key = region.TerrainImage;
ScriptSleep(1000);
return key.ToString();
}
}
}